-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PDE-5395] feat(schema): Add
meta
field support for FieldSchema (#883)
* initial implementation idea * more complete example * typo * updated typing * Update packages/core/types/zapier.generated.d.ts Co-authored-by: Fokke Zandbergen <[email protected]> * Update packages/schema/exported-schema.json Co-authored-by: Fokke Zandbergen <[email protected]> * Update packages/schema/lib/schemas/FieldMetaSchema.js Co-authored-by: Fokke Zandbergen <[email protected]> * review suggestions * typing doc changes * update FieldMetaSchema * update typing --------- Co-authored-by: Fokke Zandbergen <[email protected]>
- Loading branch information
Showing
7 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ This is automatically generated by the `npm run docs` command in `zapier-platfor | |
* [/DynamicFieldsSchema](#dynamicfieldsschema) | ||
* [/FieldChoiceWithLabelSchema](#fieldchoicewithlabelschema) | ||
* [/FieldChoicesSchema](#fieldchoicesschema) | ||
* [/FieldMetaSchema](#fieldmetaschema) | ||
* [/FieldOrFunctionSchema](#fieldorfunctionschema) | ||
* [/FieldSchema](#fieldschema) | ||
* [/FieldsSchema](#fieldsschema) | ||
|
@@ -931,6 +932,33 @@ Yes | Yes | Array of [FieldChoiceWithLabel](#fieldchoicewithlabelschema) | |
|
||
----- | ||
|
||
## /FieldMetaSchema | ||
|
||
Allows for additional metadata to be stored on the field. | ||
|
||
#### Details | ||
|
||
* **Type** - `object` | ||
* [**Source Code**](https://github.com/zapier/zapier-platform/blob/[email protected]/packages/schema/lib/schemas/FieldMetaSchema.js) | ||
|
||
#### Properties | ||
|
||
Key | Required | Type | Description | ||
--- | -------- | ---- | ----------- | ||
`[^\s]+` | no | anyOf(`string`, `integer`, `boolean`) | Only string, integer or boolean values are allowed. | ||
|
||
#### Examples | ||
|
||
* `{ shouldCapitalize: true }` | ||
* `{ shouldCapitalize: true, internalType: 'datetime' }` | ||
|
||
#### Anti-Examples | ||
|
||
* `{ databank: { primaryContact: 'abc' } }` - _No complex values allowed_ | ||
* `{ needsProcessing: null }` - _No null values allowed_ | ||
|
||
----- | ||
|
||
## /FieldOrFunctionSchema | ||
|
||
Represents an array of fields or functions. | ||
|
@@ -997,6 +1025,7 @@ Key | Required | Type | Description | |
`altersDynamicFields` | no | `boolean` | Does the value of this field affect the definitions of other fields in the set? | ||
`steadyState` | no | `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. | ||
`inputFormat` | no | `string` | 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"). | ||
`meta` | no | [/FieldMetaSchema](#fieldmetaschema) | Allows for additional metadata to be stored on the field. Supports simple key-values only (no sub-objects or arrays). | ||
|
||
#### Examples | ||
|
||
|
@@ -1006,6 +1035,13 @@ Key | Required | Type | Description | |
* `{ key: 'abc', choices: [ { label: 'Red', sample: '#f00', value: '#f00' } ] }` | ||
* `{ key: 'abc', children: [ { key: 'abc' } ] }` | ||
* `{ key: 'abc', type: 'integer', helpText: 'neat' }` | ||
* ``` | ||
{ | ||
key: 'abc', | ||
type: 'integer', | ||
meta: { internalType: 'numeric', should_call_api: true, display_order: 1 } | ||
} | ||
``` | ||
|
||
#### Anti-Examples | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const makeSchema = require('../utils/makeSchema'); | ||
|
||
module.exports = makeSchema({ | ||
id: '/FieldMetaSchema', | ||
type: 'object', | ||
description: 'Allows for additional metadata to be stored on the field.', | ||
patternProperties: { | ||
'[^\\s]+': { | ||
description: 'Only string, integer or boolean values are allowed.', | ||
anyOf: [{ type: 'string' }, { type: 'integer' }, { type: 'boolean' }], | ||
}, | ||
}, | ||
examples: [ | ||
{ shouldCapitalize: true }, | ||
{ shouldCapitalize: true, internalType: 'datetime' }, | ||
], | ||
antiExamples: [ | ||
{ | ||
example: { databank: { primaryContact: 'abc' } }, | ||
reason: 'No complex values allowed', | ||
}, | ||
{ | ||
example: { needsProcessing: null }, | ||
reason: 'No null values allowed', | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters