Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(schema): PDE-5719 split FieldSchema into InputFieldSchema, OutputFieldSchema, and AuthFieldSchema #957

Merged
merged 61 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
fd594f3
first attempt: split FieldSchema
Natay Jan 28, 2025
19b3125
PDE-5719 address PR comments
Natay Jan 28, 2025
6ebe53c
PDE-5719 address commented out lines
Natay Jan 28, 2025
879dd06
PDE-5719 address commented out lines
Natay Jan 28, 2025
a834d51
PDE-5719 clean up
Natay Jan 28, 2025
de4d6a2
PDE-5719 clean up
Natay Jan 29, 2025
215c3ea
rename to AuthFieldSchema
Natay Jan 29, 2025
ec60ed4
PR suggestions: remove cleanErrors addition
Natay Jan 29, 2025
3018bde
PR suggestions: add examples and anti-examples
Natay Jan 29, 2025
9354f50
fix description
Natay Jan 29, 2025
eee329e
remove FieldsSchema and DynamicFieldsSchema
Natay Jan 29, 2025
833bd10
add unit tests
Natay Jan 29, 2025
e89a3b8
update unit test
Natay Jan 29, 2025
eb2c904
Update packages/schema/lib/schemas/AuthFieldSchema.js
Natay Jan 29, 2025
0fa07cf
Update packages/schema/lib/schemas/AuthFieldSchema.js
Natay Jan 29, 2025
c121fc9
Update packages/schema/lib/schemas/AuthFieldSchema.js
Natay Jan 29, 2025
3ffcfa8
Update packages/schema/lib/schemas/AuthFieldsSchema.js
Natay Jan 29, 2025
e0651f1
Update packages/schema/lib/schemas/AuthFieldsSchema.js
Natay Jan 29, 2025
c371dc4
Update packages/schema/lib/schemas/AuthFieldsSchema.js
Natay Jan 29, 2025
3f50efe
Update packages/schema/lib/schemas/AuthFieldsSchema.js
Natay Jan 29, 2025
7260e55
Update packages/schema/lib/schemas/AuthFieldsSchema.js
Natay Jan 29, 2025
09e53fd
run yarn build
Natay Jan 29, 2025
6ed5ac8
PR suggestion: move isSafe check as a functional-contsraint
Natay Jan 29, 2025
387a7f5
update test
Natay Jan 29, 2025
78c1d79
Update packages/schema/test/index.js
Natay Jan 30, 2025
e5f22b3
Update packages/schema/test/index.js
Natay Jan 30, 2025
03cdb16
Update packages/schema/test/index.js
Natay Jan 30, 2025
e02fa4c
Update packages/schema/lib/utils/makeValidator.js
Natay Jan 30, 2025
a844f03
Update packages/schema/lib/functional-constraints/AuthFieldisSafe.js
Natay Jan 30, 2025
a6d3e90
Update packages/schema/lib/functional-constraints/AuthFieldisSafe.js
Natay Jan 30, 2025
6c75d36
Update packages/schema/lib/functional-constraints/AuthFieldisSafe.js
Natay Jan 30, 2025
91622cd
Update packages/schema/lib/functional-constraints/AuthFieldisSafe.js
Natay Jan 30, 2025
81ba9ce
Update packages/schema/lib/functional-constraints/AuthFieldisSafe.js
Natay Jan 30, 2025
298e148
Update packages/schema/lib/functional-constraints/AuthFieldisSafe.js
Natay Jan 30, 2025
dc34ca2
update FORBIDDEN_KEYS to match secret scrubber
Natay Jan 30, 2025
128f8e9
PR suggestions: tailor fields to not inherit from FieldSchema
Natay Jan 31, 2025
55284c0
run yarn build
Natay Jan 31, 2025
449486e
PR suggestions: remove uneeded fields and fix tests
Natay Jan 31, 2025
7016f01
PR suggestion:rename to isNotSecret
Natay Jan 31, 2025
22059ff
pull from dev branch
Natay Jan 31, 2025
8065bcf
PDE-5719 add helpText back to inputField
Natay Feb 3, 2025
6437724
update type enums for better fit
Natay Feb 3, 2025
ea1ef6c
apply PR suggestions
Natay Feb 3, 2025
e8e8db5
apply PR suggestions
Natay Feb 3, 2025
e8fa2df
remove copy from auth types
Natay Feb 3, 2025
2dbcbb1
add default back to input and output schema
Natay Feb 3, 2025
83e6d7d
update docs
Natay Feb 3, 2025
51bc727
apply PR suggestions
Natay Feb 3, 2025
04aa8e6
apply PR suggestions
Natay Feb 3, 2025
34ec873
PR suggestion: use common fields and update schemas
Natay Feb 3, 2025
a94f3ac
Update packages/schema/lib/functional-constraints/AuthFieldisSafe.js
Natay Feb 4, 2025
ec31b8f
Update packages/schema/lib/schemas/AuthFieldSchema.js
Natay Feb 4, 2025
edae9ea
Update packages/schema/lib/schemas/OutputFieldSchema.js
Natay Feb 4, 2025
f6ca550
Update packages/schema/test/index.js
Natay Feb 4, 2025
8a6387e
Update packages/schema/lib/schemas/FieldSchema.js
Natay Feb 4, 2025
de4e209
Update packages/schema/lib/schemas/AuthFieldSchema.js
Natay Feb 4, 2025
7bfc4a0
Update packages/schema/lib/schemas/AuthFieldSchema.js
Natay Feb 4, 2025
ca8c94f
Update packages/schema/lib/schemas/InputFieldSchema.js
Natay Feb 4, 2025
58ceac2
Split FieldSchema into AuthFieldSchema, InputFieldSchema, OutputField…
Natay Feb 4, 2025
dfc3dc5
add examples/anti-examples back for FieldSchema
Natay Feb 4, 2025
fb88e82
Update packages/schema/lib/schemas/AuthFieldSchema.js
Natay Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
265 changes: 202 additions & 63 deletions packages/core/types/zapier.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,68 @@ export interface App {
firehoseWebhooks?: { [k: string]: unknown };
}

/**
* A path to a file that might have content like `module.exports =
* (z, bundle) => [{id: 123}];`.
*
* [Docs: FunctionRequireSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#FunctionRequireSchema)
*/
export interface FunctionRequire {
require: string;
}

/**
* Source code like `{source: "return 1 + 2"}` which the system will
* wrap in a function for you.
*
* [Docs: FunctionSourceSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#FunctionSourceSchema)
*/
export interface FunctionSource {
/**
* JavaScript code for the function body. This must end with a
* `return` statement.
*/
source: string;

/**
* Function signature. Defaults to `['z', 'bundle']` if not
* specified.
*/
args?: string[];
}

/**
* An object whose values can only be primitives
*
* [Docs: FlatObjectSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#FlatObjectSchema)
*/
export interface FlatObject {
/**
* Any key may exist in this flat object as long as its values are
* simple.
*
* This interface was referenced by `FlatObjectSchema`'s JSON-Schema
* definition
* via the `patternProperty` "[^\s]+".
*/
[k: string]: null | string | number | boolean;
}

/**
* Internal pointer to a function from the original source or the
* source code itself. Encodes arity and if `arguments` is used in
* the body. Note - just write normal functions and the system will
* encode the pointers for you. Or, provide {source: "return 1 + 2"}
* and the system will wrap in a function for you.
*
* [Docs: FunctionSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#FunctionSchema)
*/
export type Function =
| PerformFunction
| string
| FunctionRequire
| FunctionSource;

/**
* An object describing a labeled choice in a static dropdown.
* Useful if the value a user picks isn't exactly what the zap uses.
Expand Down Expand Up @@ -347,68 +409,6 @@ export interface Field {
meta?: FieldMeta;
}

/**
* A path to a file that might have content like `module.exports =
* (z, bundle) => [{id: 123}];`.
*
* [Docs: FunctionRequireSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#FunctionRequireSchema)
*/
export interface FunctionRequire {
require: string;
}

/**
* Source code like `{source: "return 1 + 2"}` which the system will
* wrap in a function for you.
*
* [Docs: FunctionSourceSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#FunctionSourceSchema)
*/
export interface FunctionSource {
/**
* JavaScript code for the function body. This must end with a
* `return` statement.
*/
source: string;

/**
* Function signature. Defaults to `['z', 'bundle']` if not
* specified.
*/
args?: string[];
}

/**
* An object whose values can only be primitives
*
* [Docs: FlatObjectSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#FlatObjectSchema)
*/
export interface FlatObject {
/**
* Any key may exist in this flat object as long as its values are
* simple.
*
* This interface was referenced by `FlatObjectSchema`'s JSON-Schema
* definition
* via the `patternProperty` "[^\s]+".
*/
[k: string]: null | string | number | boolean;
}

/**
* Internal pointer to a function from the original source or the
* source code itself. Encodes arity and if `arguments` is used in
* the body. Note - just write normal functions and the system will
* encode the pointers for you. Or, provide {source: "return 1 + 2"}
* and the system will wrap in a function for you.
*
* [Docs: FunctionSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#FunctionSchema)
*/
export type Function =
| PerformFunction
| string
| FunctionRequire
| FunctionSource;

/**
* A representation of a HTTP request - you can use the `{{syntax}}`
* to inject authentication, field or global variables.
Expand Down Expand Up @@ -1087,6 +1087,138 @@ export interface BasicActionOperation {
throttle?: ThrottleObject;
}

/**
* Field schema specialized for output fields.
*
* [Docs: OutputFieldSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#OutputFieldSchema)
*/
export interface OutputField {
/** A unique machine readable key for this value (IE: "fname"). */
key: string;

/** A human readable label for this value (IE: "First Name"). */
label?: string;

/**
* A human readable description of this value (IE: "The first part
* of a full name."). You can use Markdown.
*/
helpText?: string;

/**
* The type of this value. Use `string` for basic text input, `text`
* for a large, `<textarea>` style box, and `code` for a
* `<textarea>` with a fixed-width font. Field type of `file` will
* accept either a file object or a string. If a URL is provided in
* the string, Zapier will automatically make a GET for that file.
* Otherwise, a .txt file will be generated.
*/
type?:
| 'string'
| 'text'
| 'integer'
| 'number'
| 'boolean'
| 'datetime'
| 'file'
| 'password'
| 'copy'
| 'code';

/** If this value is required or not. */
required?: boolean;

/** An example value that is not saved. */
placeholder?: string;

/**
* A default value that is saved the first time a Zap is created.
*/
default?: string;

/**
* Use this field as part of the primary key for deduplication. You
* can set multiple fields as "primary", provided they are unique
* together. If no fields are set, Zapier will default to using the
* `id` field. `primary` only makes sense for `outputFields`; it
* will be ignored if set in `inputFields`. It only works in static
* `outputFields`; will not work in custom/dynamic `outputFields`.
* For more information, see [How deduplication works in
* Zapier](https://platform.zapier.com/build/deduplication).
*/
primary?: boolean;

/**
* A reference to a trigger that will power a dynamic dropdown.
*/
dynamic?: RefResource;

/**
* A reference to a search that will guide the user to add a search
* step to populate this field when creating a Zap.
*/
search?: RefResource;

/**
* An object of machine keys and human values to populate a static
* dropdown.
*/
choices?: FieldChoices;

/**
* Acts differently when used in inputFields vs. when used in
* outputFields. In inputFields: Can a user provide multiples of
* this field? In outputFields: Does this field return an array of
* items of type `type`?
*/
list?: boolean;

/**
* An array of child fields that define the structure of a
* sub-object for this field. Usually used for line items.
*
* @minItems 1
*/
children?: Field[];

/** Is this field a key/value input? */
dict?: boolean;

/**
* Is this field automatically populated (and hidden from the user)?
* Note: Only OAuth and Session Auth support fields with this key.
*/
computed?: boolean;

/**
* Does the value of this field affect the definitions of other
* fields in the set?
*/
altersDynamicFields?: boolean;

/**
* Prevents triggering on new output until all values for fields
* with this property remain unchanged for 2 polls. It can be used
* to, e.g., not trigger on a new contact until the contact has
* completed typing their name. NOTE that this only applies to the
* `outputFields` of polling triggers.
*/
steadyState?: boolean;

/**
* Useful when you expect the input to be part of a longer string.
* Put "{{input}}" in place of the user's input (IE:
* "https://{{input}}.yourdomain.com").
*/
inputFormat?: string;

/**
* Allows for additional metadata to be stored on the field.
* Supports simple key-values only (no sub-objects or arrays).
*/
meta?: FieldMeta;
}

/**
* How will we get a single object given a unique identifier/id?
*
Expand Down Expand Up @@ -1160,6 +1292,13 @@ export interface ResourceMethodCreate {
operation: BasicActionOperation;
}

/**
* An array or collection of output fields.
*
* [Docs: DynamicOutputFieldsSchema](https://github.com/zapier/zapier-platform/blob/main/packages/schema/docs/build/schema.md#DynamicOutputFieldsSchema)
*/
export type DynamicOutputFields = (OutputField | Function)[];

/**
* Represents a resource, which will in turn power triggers,
* searches, or creates.
Expand Down Expand Up @@ -1206,7 +1345,7 @@ export interface Resource {
create?: ResourceMethodCreate;

/** What fields of data will this return? */
outputFields?: DynamicFields;
outputFields?: DynamicOutputFields;

/** What does a sample of data look like? */
sample?: { [k: string]: unknown };
Expand Down
Loading
Loading