zapier-platform-core 18.0.0 → 18.0.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zapier-platform-core",
3
- "version": "18.0.0",
3
+ "version": "18.0.5",
4
4
  "description": "The core SDK for CLI apps in the Zapier Developer Platform.",
5
5
  "repository": "zapier/zapier-platform",
6
6
  "homepage": "https://platform.zapier.com/",
@@ -24,28 +24,6 @@
24
24
  "/src/",
25
25
  "/types/"
26
26
  ],
27
- "scripts": {
28
- "preversion": "git pull && yarn test",
29
- "version": "node bin/bump-dependencies.js && yarn && git add package.json yarn.lock",
30
- "postversion": "git push && git push --tags",
31
- "main-tests": "mocha -t 20s --recursive test --exit",
32
- "type-tests": "tsd --files types/**/*.test-d.ts",
33
- "solo-test": "test $(OPT_OUT_PATCH_TEST_ONLY=yes mocha --recursive test -g 'should be able to opt out of patch' -R json | jq '.stats.passes') -eq 1 && echo 'Ran 1 test and it passed!'",
34
- "test": "yarn main-tests && yarn solo-test && yarn type-tests",
35
- "test:debug": "mocha inspect -t 10s --recursive test",
36
- "debug": "mocha -t 10s --inspect-brk --recursive test",
37
- "test:w": "mocha -t 10s --recursive test --watch",
38
- "integration-test": "mocha -t 20s integration-test",
39
- "local-integration-test": "mocha -t 10s integration-test --local",
40
- "lambda-integration-test": "mocha -t 10s integration-test --lambda",
41
- "smoke-test": "mocha -t 2m smoke-test",
42
- "lint": "eslint src test",
43
- "lint:fix": "eslint --fix src test",
44
- "build-integration-test": "bin/build.sh local.bundle.zip",
45
- "upload-integration-test": "bin/upload-lambda.js local.bundle.zip",
46
- "deploy-integration-test": "yarn build-integration-test && yarn upload-integration-test",
47
- "validate": "yarn test && yarn smoke-test && yarn lint"
48
- },
49
27
  "engines": {
50
28
  "node": ">=16",
51
29
  "npm": ">=5.6.0"
@@ -63,7 +41,7 @@
63
41
  "node-fetch": "2.7.0",
64
42
  "oauth-sign": "0.9.0",
65
43
  "semver": "7.7.2",
66
- "zapier-platform-schema": "18.0.0"
44
+ "zapier-platform-schema": "18.0.5"
67
45
  },
68
46
  "devDependencies": {
69
47
  "@types/node-fetch": "^2.6.11",
@@ -77,5 +55,27 @@
77
55
  },
78
56
  "optionalDependencies": {
79
57
  "@types/node": "^20.3.1"
58
+ },
59
+ "scripts": {
60
+ "preversion": "git pull && pnpm test",
61
+ "version": "node bin/bump-dependencies.js && pnpm install && git add package.json pnpm-lock.yaml",
62
+ "postversion": "git push && git push --tags",
63
+ "main-tests": "mocha -t 20s --recursive test --exit",
64
+ "type-tests": "tsd --files types/**/*.test-d.ts",
65
+ "solo-test": "test $(OPT_OUT_PATCH_TEST_ONLY=yes mocha --recursive test -g 'should be able to opt out of patch' -R json | jq '.stats.passes') -eq 1 && echo 'Ran 1 test and it passed!'",
66
+ "test": "pnpm main-tests && pnpm solo-test && pnpm type-tests",
67
+ "test:debug": "mocha inspect -t 10s --recursive test",
68
+ "debug": "mocha -t 10s --inspect-brk --recursive test",
69
+ "test:w": "mocha -t 10s --recursive test --watch",
70
+ "integration-test": "mocha -t 20s integration-test",
71
+ "local-integration-test": "mocha -t 10s integration-test --local",
72
+ "lambda-integration-test": "mocha -t 10s integration-test --lambda",
73
+ "smoke-test": "mocha -t 2m smoke-test",
74
+ "lint": "eslint src test",
75
+ "lint:fix": "eslint --fix src test",
76
+ "build-integration-test": "bin/build.sh local.bundle.zip",
77
+ "upload-integration-test": "bin/upload-lambda.js local.bundle.zip",
78
+ "deploy-integration-test": "pnpm build-integration-test && pnpm upload-integration-test",
79
+ "validate": "pnpm test && pnpm smoke-test && pnpm lint"
80
80
  }
81
- }
81
+ }
package/types/inputs.d.ts CHANGED
@@ -241,7 +241,19 @@ export type PlainFieldContribution<$Field extends PlainInputField> =
241
241
  */
242
242
  type ParentFieldContribution<
243
243
  $Field extends PlainInputField & { children: PlainInputField[] },
244
- > = PlainFieldArrayContribution<$Field['children']>;
244
+ > = Simplify<
245
+ PlainFieldArrayContribution<$Field['children']> &
246
+ // When line items are mapped into any child input, then the parent will also
247
+ // be included as an array of objects containing the children's inputs'
248
+ // contributions. This may or may not apply on a per-zap basis, so this parent
249
+ // array is an optional member of inputData.
250
+ Partial<
251
+ Record<
252
+ $Field['key'],
253
+ Array<PlainFieldArrayContribution<$Field['children']>>
254
+ >
255
+ >
256
+ >;
245
257
 
246
258
  /**
247
259
  * Extract the contribution of a dictionary field to the input data. A
@@ -14,7 +14,17 @@ type singleRequiredChildren = PlainFieldContribution<{
14
14
  key: 'parent_input';
15
15
  children: [{ key: 'string_required'; type: 'string'; required: true }];
16
16
  }>;
17
- expectType<singleRequiredChildren>(singleRequiredChild);
17
+ expectAssignable<singleRequiredChildren>(singleRequiredChild);
18
+ expectAssignable<singleRequiredChildren>({
19
+ string_required: 'some_string',
20
+ parent_input: [{ string_required: 'value1' }, { string_required: 'value2' }],
21
+ });
22
+ expectType<singleRequiredChildren>(
23
+ singleRequiredChild as {
24
+ string_required: string;
25
+ parent_input?: { string_required: string }[];
26
+ },
27
+ );
18
28
 
19
29
  // Complete `children: [{...}]` case.
20
30
  const multipleRequiredChild = {
@@ -26,6 +36,26 @@ const multipleRequiredChild = {
26
36
  password_required: 'some_password',
27
37
  code_required: 'some_code',
28
38
  };
39
+ const multipleRequiredChildWithLineItems = {
40
+ string_required: 'some_string',
41
+ number_required: 1,
42
+ boolean_required: true,
43
+ datetime_required: '2021-01-01T00:00:00Z',
44
+ file_required: 'some_file',
45
+ password_required: 'some_password',
46
+ code_required: 'some_code',
47
+ parent_input: [
48
+ {
49
+ string_required: 'item1',
50
+ number_required: 2,
51
+ boolean_required: false,
52
+ datetime_required: '2022-01-01T00:00:00Z',
53
+ file_required: 'file1',
54
+ password_required: 'pass1',
55
+ code_required: 'code1',
56
+ },
57
+ ],
58
+ };
29
59
  type multipleRequiredChildren = PlainFieldContribution<{
30
60
  key: 'parent_input';
31
61
  children: [
@@ -38,10 +68,31 @@ type multipleRequiredChildren = PlainFieldContribution<{
38
68
  { key: 'code_required'; type: 'code'; required: true },
39
69
  ];
40
70
  }>;
41
- expectType<multipleRequiredChildren>(multipleRequiredChild);
71
+ expectAssignable<multipleRequiredChildren>(multipleRequiredChild);
72
+ expectAssignable<multipleRequiredChildren>(multipleRequiredChildWithLineItems);
73
+ expectType<multipleRequiredChildren>(
74
+ {} as {
75
+ string_required: string;
76
+ number_required: number;
77
+ boolean_required: boolean;
78
+ datetime_required: string;
79
+ file_required: string;
80
+ password_required: string;
81
+ code_required: string;
82
+ parent_input?: {
83
+ string_required: string;
84
+ number_required: number;
85
+ boolean_required: boolean;
86
+ datetime_required: string;
87
+ file_required: string;
88
+ password_required: string;
89
+ code_required: string;
90
+ }[];
91
+ },
92
+ );
42
93
 
43
94
  // Complete `children: [{...}]` case where all children are optional.
44
- const multipleOptionalChild = {
95
+ const multipleOptionalChildNoLineItems = {
45
96
  string_optional: 'some_string',
46
97
  number_optional: 1,
47
98
  boolean_optional: true,
@@ -50,6 +101,16 @@ const multipleOptionalChild = {
50
101
  password_optional: 'some_password',
51
102
  code_optional: 'some_code',
52
103
  };
104
+ const multipleOptionalChildWithLineItems = {
105
+ string_optional: 'some_string',
106
+ number_optional: 1,
107
+ boolean_optional: true,
108
+ datetime_optional: '2021-01-01T00:00:00Z',
109
+ file_optional: 'some_file',
110
+ password_optional: 'some_password',
111
+ code_optional: 'some_code',
112
+ parent_input: [{ string_optional: 'item1' }],
113
+ };
53
114
  type multipleOptionalChildren = PlainFieldContribution<{
54
115
  key: 'parent_input';
55
116
  children: [
@@ -62,12 +123,50 @@ type multipleOptionalChildren = PlainFieldContribution<{
62
123
  { key: 'code_optional'; type: 'code'; required: false },
63
124
  ];
64
125
  }>;
65
- expectAssignable<multipleOptionalChildren>(multipleOptionalChild);
66
126
  expectAssignable<multipleOptionalChildren>({});
127
+ expectAssignable<multipleOptionalChildren>(multipleOptionalChildNoLineItems);
128
+ expectAssignable<multipleOptionalChildren>({ parent_input: [{}] });
129
+ expectAssignable<multipleOptionalChildren>(multipleOptionalChildWithLineItems);
130
+ expectType<multipleOptionalChildren>(
131
+ {} as {
132
+ string_optional?: string;
133
+ number_optional?: number;
134
+ boolean_optional?: boolean;
135
+ datetime_optional?: string;
136
+ file_optional?: string;
137
+ password_optional?: string;
138
+ code_optional?: string;
139
+ parent_input?: {
140
+ string_optional?: string;
141
+ number_optional?: number;
142
+ boolean_optional?: boolean;
143
+ datetime_optional?: string;
144
+ file_optional?: string;
145
+ password_optional?: string;
146
+ code_optional?: string;
147
+ }[];
148
+ },
149
+ );
67
150
 
68
151
  // Complete `children: [{...}]` case with complete mixture of required
69
152
  // and optional fields.
70
- const mixedOptionalChildren = {
153
+ const mixedOptionalChildrenNoLineItems = {
154
+ string_required: 'some_string',
155
+ string_optional: 'some_string',
156
+ number_required: 1,
157
+ number_optional: 1,
158
+ boolean_required: true,
159
+ boolean_optional: true,
160
+ datetime_required: '2021-01-01T00:00:00Z',
161
+ datetime_optional: '2021-01-01T00:00:00Z',
162
+ file_required: 'some_file',
163
+ file_optional: 'some_file',
164
+ password_required: 'some_password',
165
+ password_optional: 'some_password',
166
+ code_required: 'some_code',
167
+ code_optional: 'some_code',
168
+ };
169
+ const mixedOptionalChildrenWithLineItems = {
71
170
  string_required: 'some_string',
72
171
  string_optional: 'some_string',
73
172
  number_required: 1,
@@ -80,20 +179,75 @@ const mixedOptionalChildren = {
80
179
  file_optional: 'some_file',
81
180
  password_required: 'some_password',
82
181
  password_optional: 'some_password',
182
+ code_required: 'some_code',
83
183
  code_optional: 'some_code',
184
+ parent_input: [
185
+ {
186
+ string_required: 'item1',
187
+ number_required: 2,
188
+ boolean_required: false,
189
+ datetime_required: '2022-01-01T00:00:00Z',
190
+ file_required: 'file1',
191
+ password_required: 'pass1',
192
+ code_required: 'code1',
193
+ },
194
+ ],
84
195
  };
85
- type mixedOptionalChildren = PlainFieldContribution<{
196
+ type MixedOptionalChildren = PlainFieldContribution<{
86
197
  key: 'parent_input';
87
198
  children: [
88
199
  { key: 'string_required'; type: 'string'; required: true },
89
200
  { key: 'string_optional'; type: 'string'; required: false },
201
+ { key: 'number_required'; type: 'number'; required: true },
202
+ { key: 'number_optional'; type: 'number'; required: false },
203
+ { key: 'boolean_required'; type: 'boolean'; required: true },
204
+ { key: 'boolean_optional'; type: 'boolean'; required: false },
205
+ { key: 'datetime_required'; type: 'datetime'; required: true },
206
+ { key: 'datetime_optional'; type: 'datetime'; required: false },
207
+ { key: 'file_required'; type: 'file'; required: true },
208
+ { key: 'file_optional'; type: 'file'; required: false },
209
+ { key: 'password_required'; type: 'password'; required: true },
210
+ { key: 'password_optional'; type: 'password'; required: false },
211
+ { key: 'code_required'; type: 'code'; required: true },
212
+ { key: 'code_optional'; type: 'code'; required: false },
90
213
  ];
91
214
  }>;
92
- expectAssignable<mixedOptionalChildren>(multipleRequiredChild);
93
- expectAssignable<mixedOptionalChildren>({
94
- ...multipleRequiredChild,
95
- ...multipleOptionalChild,
96
- });
215
+ expectAssignable<MixedOptionalChildren>(mixedOptionalChildrenNoLineItems);
216
+ expectAssignable<MixedOptionalChildren>(mixedOptionalChildrenWithLineItems);
217
+ expectType<MixedOptionalChildren>(
218
+ {} as {
219
+ string_required: string;
220
+ string_optional?: string;
221
+ number_required: number;
222
+ number_optional?: number;
223
+ boolean_required: boolean;
224
+ boolean_optional?: boolean;
225
+ datetime_required: string;
226
+ datetime_optional?: string;
227
+ file_required: string;
228
+ file_optional?: string;
229
+ password_required: string;
230
+ password_optional?: string;
231
+ code_required: string;
232
+ code_optional?: string;
233
+ parent_input?: {
234
+ string_required: string;
235
+ string_optional?: string;
236
+ number_required: number;
237
+ number_optional?: number;
238
+ boolean_required: boolean;
239
+ boolean_optional?: boolean;
240
+ datetime_required: string;
241
+ datetime_optional?: string;
242
+ file_required: string;
243
+ file_optional?: string;
244
+ password_required: string;
245
+ password_optional?: string;
246
+ code_required: string;
247
+ code_optional?: string;
248
+ }[];
249
+ },
250
+ );
97
251
 
98
252
  //
99
253
  // Dictionary fields (where `dict:true` is set)
@@ -294,7 +294,7 @@ const choicesInputs = defineInputFields([
294
294
  choices: ['c7', 'c8'],
295
295
  },
296
296
  {
297
- key: 'ignored_parent',
297
+ key: 'parent_key',
298
298
  children: [
299
299
  {
300
300
  key: 'child_choice',
@@ -327,4 +327,8 @@ expectType<{
327
327
  choices_list: StringHints<'c7' | 'c8'>[];
328
328
  child_choice: StringHints<'c9' | 'c10'>;
329
329
  child_choice_list: StringHints<'c11' | 'c12'>[];
330
+ parent_key?: Array<{
331
+ child_choice: StringHints<'c9' | 'c10'>;
332
+ child_choice_list: StringHints<'c11' | 'c12'>[];
333
+ }>;
330
334
  }>(choicesResult);
@@ -4,7 +4,7 @@
4
4
  * files, and/or the schema-to-ts tool and run its CLI to regenerate
5
5
  * these typings.
6
6
  *
7
- * zapier-platform-schema version: 17.9.1
7
+ * zapier-platform-schema version: 18.0.5
8
8
  * schema-to-ts compiler version: 0.1.0
9
9
  */
10
10
  import type {
package/CHANGELOG.md DELETED
@@ -1 +0,0 @@
1
- See [CHANGELOG.md](https://github.com/zapier/zapier-platform/blob/main/CHANGELOG.md).