zapier-platform-schema 18.2.2 → 18.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "18.2.2",
2
+ "version": "18.3.0",
3
3
  "schemas": {
4
4
  "AppSchema": {
5
5
  "id": "/AppSchema",
@@ -650,6 +650,26 @@
650
650
  "type": "string",
651
651
  "pattern": "^[a-zA-Z0-9_]+\\.[a-zA-Z0-9_\\s\\[\\]]+(\\.[a-zA-Z0-9_\\s\\[\\]]+(,[a-zA-Z0-9_\\s\\[\\]]+)*)?$"
652
652
  },
653
+ "FieldDynamicChoicesSchema": {
654
+ "id": "/FieldDynamicChoicesSchema",
655
+ "description": "Describes dynamic dropdowns powered by a perform function or request.",
656
+ "type": "object",
657
+ "required": ["perform"],
658
+ "properties": {
659
+ "perform": {
660
+ "description": "A function or request that returns choices for this dynamic dropdown.",
661
+ "oneOf": [
662
+ {
663
+ "$ref": "/FunctionSchema"
664
+ },
665
+ {
666
+ "$ref": "/RequestSchema"
667
+ }
668
+ ]
669
+ }
670
+ },
671
+ "additionalProperties": false
672
+ },
653
673
  "FieldMetaSchema": {
654
674
  "id": "/FieldMetaSchema",
655
675
  "type": "object",
@@ -749,9 +769,29 @@
749
769
  "description": "A reference to a trigger that will power a dynamic dropdown.",
750
770
  "$ref": "/RefResourceSchema"
751
771
  },
772
+ "dependsOn": {
773
+ "description": "Specifies which other input fields this field depends on. These must be filled before this one becomes enabled, and when their values change, this field's value should be cleared.",
774
+ "type": "array",
775
+ "items": {
776
+ "type": "string"
777
+ }
778
+ },
779
+ "resource": {
780
+ "description": "Explicitly links this input field to a resource. Use the resource key (e.g., \"spreadsheet\") or dot notation for resource fields (e.g., \"spreadsheet.url\"). If not set for dynamic dropdowns, the resource is derived implicitly from the `dynamic` property.",
781
+ "type": "string",
782
+ "minLength": 1,
783
+ "pattern": "^[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)?$"
784
+ },
752
785
  "choices": {
753
- "description": "An object of machine keys and human values to populate a static dropdown.",
754
- "$ref": "/FieldChoicesSchema"
786
+ "description": "Describes how to populate this dropdown. Can be a static list or a dynamic object with pagination and search support.",
787
+ "oneOf": [
788
+ {
789
+ "$ref": "/FieldChoicesSchema"
790
+ },
791
+ {
792
+ "$ref": "/FieldDynamicChoicesSchema"
793
+ }
794
+ ]
755
795
  },
756
796
  "placeholder": {
757
797
  "description": "An example value that is not saved.",
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ const makeSchema = require('../utils/makeSchema');
4
+
5
+ const FunctionSchema = require('./FunctionSchema');
6
+ const RequestSchema = require('./RequestSchema');
7
+
8
+ module.exports = makeSchema(
9
+ {
10
+ id: '/FieldDynamicChoicesSchema',
11
+ description:
12
+ 'Describes dynamic dropdowns powered by a perform function or request.',
13
+ type: 'object',
14
+ required: ['perform'],
15
+ properties: {
16
+ perform: {
17
+ description:
18
+ 'A function or request that returns choices for this dynamic dropdown.',
19
+ oneOf: [{ $ref: FunctionSchema.id }, { $ref: RequestSchema.id }],
20
+ },
21
+ },
22
+ additionalProperties: false,
23
+ examples: [
24
+ { perform: '$func$0$f$' },
25
+ { perform: { source: 'return []' } },
26
+ {
27
+ perform: {
28
+ method: 'GET',
29
+ url: 'https://api.example.com/choices',
30
+ },
31
+ },
32
+ ],
33
+ antiExamples: [
34
+ {
35
+ example: {},
36
+ reason: 'Missing required key: perform',
37
+ },
38
+ {
39
+ example: { someKey: 'value' },
40
+ reason: 'Missing required key: perform',
41
+ },
42
+ {
43
+ example: { perform: 'invalid' },
44
+ reason:
45
+ 'Invalid value for key: perform (must be a function or request)',
46
+ },
47
+ {
48
+ example: { perform: '$func$0$f$', unknownKey: 'value' },
49
+ reason: 'Invalid extra property: unknownKey',
50
+ },
51
+ ],
52
+ },
53
+ [FunctionSchema, RequestSchema],
54
+ );
@@ -3,6 +3,7 @@
3
3
  const makeSchema = require('../utils/makeSchema');
4
4
  const RefResourceSchema = require('./RefResourceSchema');
5
5
  const FieldChoicesSchema = require('./FieldChoicesSchema');
6
+ const FieldDynamicChoicesSchema = require('./FieldDynamicChoicesSchema');
6
7
  const PlainFieldSchema = require('./PlainFieldSchema');
7
8
  const FieldMetaSchema = require('./FieldMetaSchema');
8
9
  const KeySchema = require('./KeySchema');
@@ -39,10 +40,26 @@ module.exports = makeSchema(
39
40
  'A reference to a trigger that will power a dynamic dropdown.',
40
41
  $ref: RefResourceSchema.id,
41
42
  },
43
+ dependsOn: {
44
+ description:
45
+ "Specifies which other input fields this field depends on. These must be filled before this one becomes enabled, and when their values change, this field's value should be cleared.",
46
+ type: 'array',
47
+ items: { type: 'string' },
48
+ },
49
+ resource: {
50
+ description:
51
+ 'Explicitly links this input field to a resource. Use the resource key (e.g., "spreadsheet") or dot notation for resource fields (e.g., "spreadsheet.url"). If not set for dynamic dropdowns, the resource is derived implicitly from the `dynamic` property.',
52
+ type: 'string',
53
+ minLength: 1,
54
+ pattern: '^[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)?$',
55
+ },
42
56
  choices: {
43
57
  description:
44
- 'An object of machine keys and human values to populate a static dropdown.',
45
- $ref: FieldChoicesSchema.id,
58
+ 'Describes how to populate this dropdown. Can be a static list or a dynamic object with pagination and search support.',
59
+ oneOf: [
60
+ { $ref: FieldChoicesSchema.id },
61
+ { $ref: FieldDynamicChoicesSchema.id },
62
+ ],
46
63
  },
47
64
  placeholder: {
48
65
  description: 'An example value that is not saved.',
@@ -85,6 +102,10 @@ module.exports = makeSchema(
85
102
  key: 'abc',
86
103
  choices: [{ label: 'Red', sample: '#f00', value: '#f00' }],
87
104
  },
105
+ {
106
+ key: 'abc',
107
+ choices: { perform: '$func$0$f$' },
108
+ },
88
109
  { key: 'abc', children: [{ key: 'abc' }] },
89
110
  { key: 'abc', type: 'integer' },
90
111
  {
@@ -104,6 +125,19 @@ module.exports = makeSchema(
104
125
  key: 'email',
105
126
  group: 'contact',
106
127
  },
128
+ {
129
+ key: 'spreadsheet',
130
+ dependsOn: ['folder'],
131
+ },
132
+ {
133
+ key: 'worksheet',
134
+ dependsOn: ['folder', 'spreadsheet'],
135
+ },
136
+ {
137
+ key: 'spreadsheet_id',
138
+ resource: 'spreadsheet',
139
+ choices: { perform: '$func$0$f$' },
140
+ },
107
141
  ],
108
142
  antiExamples: [
109
143
  {
@@ -149,6 +183,7 @@ module.exports = makeSchema(
149
183
  [
150
184
  RefResourceSchema,
151
185
  FieldChoicesSchema,
186
+ FieldDynamicChoicesSchema,
152
187
  FieldMetaSchema,
153
188
  PlainFieldSchema,
154
189
  KeySchema,
@@ -32,7 +32,8 @@ const makePath = (path, newSegment) =>
32
32
  const processBaseError = (err, path) => {
33
33
  const completePath = makePath(path, err.property)
34
34
  .replace(/\.instance\.?/g, '.')
35
- .replace(/\.instance$/, '');
35
+ .replace(/\.instance$/, '')
36
+ .replace(/\.$/, ''); // Remove any trailing dots
36
37
 
37
38
  const subSchemas = err.message.match(/\[subschema \d+\]/g);
38
39
  if (subSchemas) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zapier-platform-schema",
3
- "version": "18.2.2",
3
+ "version": "18.3.0",
4
4
  "description": "Schema definition for CLI apps in the Zapier Developer Platform.",
5
5
  "repository": "zapier/zapier-platform",
6
6
  "homepage": "https://platform.zapier.com/",