@zapier/zapier-sdk-cli 0.5.0 → 0.6.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.
- package/CHANGELOG.md +17 -0
- package/README.md +92 -72
- package/dist/cli.js +116 -21
- package/dist/src/cli.js +1 -1
- package/dist/src/commands/generate-types/cli.js +4 -2
- package/dist/src/commands/generate-types/index.js +26 -5
- package/dist/src/commands/generate-types/schemas.d.ts +3 -0
- package/dist/src/commands/generate-types/schemas.js +4 -0
- package/dist/src/utils/cli-generator.js +55 -3
- package/dist/src/utils/parameter-resolver.js +12 -8
- package/dist/src/utils/schema-formatter.d.ts +1 -1
- package/dist/src/utils/schema-formatter.js +6 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/cli.test.ts +1 -2
- package/src/cli.ts +1 -1
- package/src/commands/generate-types/cli.ts +4 -3
- package/src/commands/generate-types/index.ts +32 -6
- package/src/commands/generate-types/schemas.ts +4 -0
- package/src/utils/auth/login.ts +2 -1
- package/src/utils/cli-generator.ts +74 -3
- package/src/utils/parameter-resolver.ts +31 -17
- package/src/utils/schema-formatter.ts +20 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c402bcd: Remove \_\_registry in favor of getRegistry that also provides categories for functions.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- e08365e: Add support for lock file in generate-types command
|
|
12
|
+
- 8ef28ba: reducing any usage with minimal changes to runtime
|
|
13
|
+
- Updated dependencies [c472d6f]
|
|
14
|
+
- Updated dependencies [e08365e]
|
|
15
|
+
- Updated dependencies [8ef28ba]
|
|
16
|
+
- Updated dependencies [c402bcd]
|
|
17
|
+
- @zapier/zapier-sdk@0.6.0
|
|
18
|
+
- @zapier/zapier-sdk-mcp@0.2.0
|
|
19
|
+
|
|
3
20
|
## 0.5.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -8,22 +8,24 @@
|
|
|
8
8
|
- [Quick Start](#quick-start)
|
|
9
9
|
- [Available Commands](#available-commands)
|
|
10
10
|
- [Actions](#actions)
|
|
11
|
-
- [`listActions`](#listactions)
|
|
12
11
|
- [`getAction`](#getaction)
|
|
12
|
+
- [`listActions`](#listactions)
|
|
13
13
|
- [`listInputFields`](#listinputfields)
|
|
14
14
|
- [`runAction`](#runaction)
|
|
15
15
|
- [Apps](#apps)
|
|
16
|
-
- [`listApps`](#listapps)
|
|
17
16
|
- [`getApp`](#getapp)
|
|
18
|
-
- [
|
|
19
|
-
|
|
20
|
-
- [`getAuthentication`](#getauthentication)
|
|
17
|
+
- [`listApps`](#listapps)
|
|
18
|
+
- [Authentications](#authentications)
|
|
21
19
|
- [`findFirstAuthentication`](#findfirstauthentication)
|
|
22
20
|
- [`findUniqueAuthentication`](#finduniqueauthentication)
|
|
21
|
+
- [`getAuthentication`](#getauthentication)
|
|
22
|
+
- [`listAuthentications`](#listauthentications)
|
|
23
23
|
- [HTTP Requests](#http-requests)
|
|
24
24
|
- [`request`](#request)
|
|
25
|
-
- [
|
|
25
|
+
- [Users](#users)
|
|
26
26
|
- [`getProfile`](#getprofile)
|
|
27
|
+
- [Utilities](#utilities)
|
|
28
|
+
- [`lockVersion`](#lockversion)
|
|
27
29
|
|
|
28
30
|
## Installation
|
|
29
31
|
|
|
@@ -53,41 +55,41 @@ The CLI automatically generates commands from the SDK registry. All SDK function
|
|
|
53
55
|
|
|
54
56
|
### Actions
|
|
55
57
|
|
|
56
|
-
#### `
|
|
58
|
+
#### `get-action`
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
Get detailed information about a specific action
|
|
59
61
|
|
|
60
62
|
**Options:**
|
|
61
63
|
|
|
62
|
-
| Option
|
|
63
|
-
|
|
|
64
|
-
| `<appKey>`
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
64
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
65
|
+
| -------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
|
|
66
|
+
| `<appKey>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
|
|
67
|
+
| `<actionType>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
68
|
+
| `<actionKey>` | `string` | ✅ | — | — | Action key to execute |
|
|
68
69
|
|
|
69
70
|
**Usage:**
|
|
70
71
|
|
|
71
72
|
```bash
|
|
72
|
-
npx zapier-sdk
|
|
73
|
+
npx zapier-sdk get-action <appKey> <actionType> <actionKey>
|
|
73
74
|
```
|
|
74
75
|
|
|
75
|
-
#### `
|
|
76
|
+
#### `list-actions`
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
List all actions for a specific app
|
|
78
79
|
|
|
79
80
|
**Options:**
|
|
80
81
|
|
|
81
|
-
| Option
|
|
82
|
-
|
|
|
83
|
-
| `<appKey>`
|
|
84
|
-
|
|
|
85
|
-
|
|
|
82
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
83
|
+
| --------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
84
|
+
| `<appKey>` | `string` | ✅ | — | — | App key of actions to list (e.g., 'SlackCLIAPI') |
|
|
85
|
+
| `--action-type` | `string` | ❌ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Filter actions by type |
|
|
86
|
+
| `--page-size` | `number` | ❌ | — | — | Number of actions per page |
|
|
87
|
+
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
86
88
|
|
|
87
89
|
**Usage:**
|
|
88
90
|
|
|
89
91
|
```bash
|
|
90
|
-
npx zapier-sdk
|
|
92
|
+
npx zapier-sdk list-actions <appKey> [--action-type] [--page-size] [--max-items]
|
|
91
93
|
```
|
|
92
94
|
|
|
93
95
|
#### `list-input-fields`
|
|
@@ -136,25 +138,6 @@ npx zapier-sdk run-action <appKey> <actionType> <actionKey> [--authentication-id
|
|
|
136
138
|
|
|
137
139
|
### Apps
|
|
138
140
|
|
|
139
|
-
#### `list-apps`
|
|
140
|
-
|
|
141
|
-
List all available apps with optional filtering
|
|
142
|
-
|
|
143
|
-
**Options:**
|
|
144
|
-
|
|
145
|
-
| Option | Type | Required | Default | Possible Values | Description |
|
|
146
|
-
| ------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------------------------- |
|
|
147
|
-
| `--app-keys` | `array` | ❌ | — | — | Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github') |
|
|
148
|
-
| `--search` | `string` | ❌ | — | — | Search for apps by name |
|
|
149
|
-
| `--page-size` | `number` | ❌ | — | — | Number of apps per page |
|
|
150
|
-
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
151
|
-
|
|
152
|
-
**Usage:**
|
|
153
|
-
|
|
154
|
-
```bash
|
|
155
|
-
npx zapier-sdk list-apps [--app-keys] [--search] [--page-size] [--max-items]
|
|
156
|
-
```
|
|
157
|
-
|
|
158
141
|
#### `get-app`
|
|
159
142
|
|
|
160
143
|
Get detailed information about a specific app
|
|
@@ -171,45 +154,26 @@ Get detailed information about a specific app
|
|
|
171
154
|
npx zapier-sdk get-app <appKey>
|
|
172
155
|
```
|
|
173
156
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
#### `list-authentications`
|
|
157
|
+
#### `list-apps`
|
|
177
158
|
|
|
178
|
-
List available
|
|
159
|
+
List all available apps with optional filtering
|
|
179
160
|
|
|
180
161
|
**Options:**
|
|
181
162
|
|
|
182
|
-
| Option
|
|
183
|
-
|
|
|
184
|
-
| `--app-
|
|
185
|
-
| `--search`
|
|
186
|
-
| `--
|
|
187
|
-
| `--
|
|
188
|
-
| `--owner` | `string` | ❌ | — | — | Filter by owner |
|
|
189
|
-
| `--page-size` | `number` | ❌ | — | — | Number of authentications per page |
|
|
190
|
-
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
163
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
164
|
+
| ------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------------------------- |
|
|
165
|
+
| `--app-keys` | `array` | ❌ | — | — | Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github') |
|
|
166
|
+
| `--search` | `string` | ❌ | — | — | Search for apps by name |
|
|
167
|
+
| `--page-size` | `number` | ❌ | — | — | Number of apps per page |
|
|
168
|
+
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
191
169
|
|
|
192
170
|
**Usage:**
|
|
193
171
|
|
|
194
172
|
```bash
|
|
195
|
-
npx zapier-sdk list-
|
|
173
|
+
npx zapier-sdk list-apps [--app-keys] [--search] [--page-size] [--max-items]
|
|
196
174
|
```
|
|
197
175
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
Get a specific authentication by ID
|
|
201
|
-
|
|
202
|
-
**Options:**
|
|
203
|
-
|
|
204
|
-
| Option | Type | Required | Default | Possible Values | Description |
|
|
205
|
-
| -------------------- | -------- | -------- | ------- | --------------- | ----------------------------- |
|
|
206
|
-
| `<authenticationId>` | `number` | ✅ | — | — | Authentication ID to retrieve |
|
|
207
|
-
|
|
208
|
-
**Usage:**
|
|
209
|
-
|
|
210
|
-
```bash
|
|
211
|
-
npx zapier-sdk get-authentication <authenticationId>
|
|
212
|
-
```
|
|
176
|
+
### Authentications
|
|
213
177
|
|
|
214
178
|
#### `find-first-authentication`
|
|
215
179
|
|
|
@@ -251,6 +215,44 @@ Find a unique authentication matching the criteria
|
|
|
251
215
|
npx zapier-sdk find-unique-authentication [--app-key] [--search] [--title] [--account_id] [--owner]
|
|
252
216
|
```
|
|
253
217
|
|
|
218
|
+
#### `get-authentication`
|
|
219
|
+
|
|
220
|
+
Get a specific authentication by ID
|
|
221
|
+
|
|
222
|
+
**Options:**
|
|
223
|
+
|
|
224
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
225
|
+
| -------------------- | -------- | -------- | ------- | --------------- | ----------------------------- |
|
|
226
|
+
| `<authenticationId>` | `number` | ✅ | — | — | Authentication ID to retrieve |
|
|
227
|
+
|
|
228
|
+
**Usage:**
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npx zapier-sdk get-authentication <authenticationId>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### `list-authentications`
|
|
235
|
+
|
|
236
|
+
List available authentications with optional filtering
|
|
237
|
+
|
|
238
|
+
**Options:**
|
|
239
|
+
|
|
240
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
241
|
+
| -------------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------- |
|
|
242
|
+
| `--app-key` | `string` | ❌ | — | — | App key of authentications to list (e.g., 'SlackCLIAPI') |
|
|
243
|
+
| `--search` | `string` | ❌ | — | — | Search term to filter authentications by title |
|
|
244
|
+
| `--title` | `string` | ❌ | — | — | Filter authentications by exact title match |
|
|
245
|
+
| `--account_id` | `string` | ❌ | — | — | Filter by account ID |
|
|
246
|
+
| `--owner` | `string` | ❌ | — | — | Filter by owner |
|
|
247
|
+
| `--page-size` | `number` | ❌ | — | — | Number of authentications per page |
|
|
248
|
+
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
249
|
+
|
|
250
|
+
**Usage:**
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
npx zapier-sdk list-authentications [--app-key] [--search] [--title] [--account_id] [--owner] [--page-size] [--max-items]
|
|
254
|
+
```
|
|
255
|
+
|
|
254
256
|
### HTTP Requests
|
|
255
257
|
|
|
256
258
|
#### `request`
|
|
@@ -276,7 +278,7 @@ Make authenticated HTTP requests through Zapier's Relay service
|
|
|
276
278
|
npx zapier-sdk request <url> [--method] [--body] [--authentication-id] [--callback-url] [--authentication-template] [--headers] [--relay-base-url]
|
|
277
279
|
```
|
|
278
280
|
|
|
279
|
-
###
|
|
281
|
+
### Users
|
|
280
282
|
|
|
281
283
|
#### `get-profile`
|
|
282
284
|
|
|
@@ -288,6 +290,24 @@ Get current user's profile information
|
|
|
288
290
|
npx zapier-sdk get-profile
|
|
289
291
|
```
|
|
290
292
|
|
|
293
|
+
### Utilities
|
|
294
|
+
|
|
295
|
+
#### `lock-version`
|
|
296
|
+
|
|
297
|
+
Execute lockVersion
|
|
298
|
+
|
|
299
|
+
**Options:**
|
|
300
|
+
|
|
301
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
302
|
+
| ---------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------- |
|
|
303
|
+
| `<appKey>` | `string` | ✅ | — | — | The app key to lock version for (e.g., 'slack', 'gmail') |
|
|
304
|
+
|
|
305
|
+
**Usage:**
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
npx zapier-sdk lock-version <appKey>
|
|
309
|
+
```
|
|
310
|
+
|
|
291
311
|
### Additional CLI Commands
|
|
292
312
|
|
|
293
313
|
- `login` - Authenticate with Zapier
|
package/dist/cli.js
CHANGED
|
@@ -205,29 +205,38 @@ var SchemaParameterResolver = class {
|
|
|
205
205
|
}
|
|
206
206
|
console.log(chalk.blue(`
|
|
207
207
|
\u{1F50D} Resolving ${param.name}...`));
|
|
208
|
-
|
|
208
|
+
const typedResolver = resolver;
|
|
209
|
+
if (typedResolver.type === "static") {
|
|
209
210
|
const promptConfig = {
|
|
210
|
-
type:
|
|
211
|
+
type: typedResolver.inputType === "password" ? "password" : "input",
|
|
211
212
|
name: param.name,
|
|
212
213
|
message: `Enter ${param.name}:`,
|
|
213
|
-
...
|
|
214
|
+
...typedResolver.placeholder && {
|
|
215
|
+
default: typedResolver.placeholder
|
|
216
|
+
}
|
|
214
217
|
};
|
|
215
218
|
const answers = await inquirer.prompt([promptConfig]);
|
|
216
219
|
return answers[param.name];
|
|
217
|
-
} else if (
|
|
220
|
+
} else if (typedResolver.type === "dynamic") {
|
|
218
221
|
try {
|
|
219
222
|
if (param.isRequired && param.name !== "authenticationId") {
|
|
220
223
|
console.log(chalk.gray(`Fetching options for ${param.name}...`));
|
|
221
224
|
}
|
|
222
|
-
const items = await
|
|
225
|
+
const items = await typedResolver.fetch(
|
|
226
|
+
context.sdk,
|
|
227
|
+
context.resolvedParams
|
|
228
|
+
);
|
|
223
229
|
const safeItems = items || [];
|
|
224
|
-
const promptConfig =
|
|
230
|
+
const promptConfig = typedResolver.prompt(
|
|
231
|
+
safeItems,
|
|
232
|
+
context.resolvedParams
|
|
233
|
+
);
|
|
225
234
|
const answers = await inquirer.prompt([promptConfig]);
|
|
226
235
|
return answers[param.name];
|
|
227
236
|
} catch (error) {
|
|
228
237
|
throw error;
|
|
229
238
|
}
|
|
230
|
-
} else if (
|
|
239
|
+
} else if (typedResolver.type === "fields") {
|
|
231
240
|
return await this.resolveFieldsRecursively(
|
|
232
241
|
resolver,
|
|
233
242
|
context,
|
|
@@ -237,6 +246,7 @@ var SchemaParameterResolver = class {
|
|
|
237
246
|
throw new Error(`Unknown resolver type for ${param.name}`);
|
|
238
247
|
}
|
|
239
248
|
async resolveFieldsRecursively(resolver, context, param) {
|
|
249
|
+
const typedResolver = resolver;
|
|
240
250
|
const inputs = {};
|
|
241
251
|
let processedFieldKeys = /* @__PURE__ */ new Set();
|
|
242
252
|
let iteration = 0;
|
|
@@ -255,7 +265,7 @@ var SchemaParameterResolver = class {
|
|
|
255
265
|
`Fetching input fields for ${param.name}${iteration > 1 ? ` (iteration ${iteration})` : ""}...`
|
|
256
266
|
)
|
|
257
267
|
);
|
|
258
|
-
const fields = await
|
|
268
|
+
const fields = await typedResolver.fetch(
|
|
259
269
|
updatedContext.sdk,
|
|
260
270
|
updatedContext.resolvedParams
|
|
261
271
|
);
|
|
@@ -459,10 +469,11 @@ function applyStyle(value, style) {
|
|
|
459
469
|
}
|
|
460
470
|
function formatItemsGeneric(items) {
|
|
461
471
|
items.forEach((item, index) => {
|
|
462
|
-
const
|
|
472
|
+
const itemObj = item;
|
|
473
|
+
const name = itemObj.title || itemObj.name || itemObj.key || itemObj.id || "Item";
|
|
463
474
|
console.log(`${chalk2.gray(`${index + 1}.`)} ${chalk2.cyan(name)}`);
|
|
464
|
-
if (
|
|
465
|
-
console.log(` ${chalk2.dim(
|
|
475
|
+
if (itemObj.description) {
|
|
476
|
+
console.log(` ${chalk2.dim(itemObj.description)}`);
|
|
466
477
|
}
|
|
467
478
|
console.log();
|
|
468
479
|
});
|
|
@@ -540,11 +551,12 @@ function methodNameToCliCommand(methodName) {
|
|
|
540
551
|
return toKebabCase(methodName);
|
|
541
552
|
}
|
|
542
553
|
function generateCliCommands(program2, sdk2) {
|
|
543
|
-
if (
|
|
554
|
+
if (typeof sdk2.getRegistry !== "function") {
|
|
544
555
|
console.error("SDK registry not available");
|
|
545
556
|
return;
|
|
546
557
|
}
|
|
547
|
-
sdk2.
|
|
558
|
+
const registry = sdk2.getRegistry();
|
|
559
|
+
registry.functions.forEach((fnInfo) => {
|
|
548
560
|
if (!fnInfo.inputSchema) {
|
|
549
561
|
console.warn(`Schema not found for ${fnInfo.name}`);
|
|
550
562
|
return;
|
|
@@ -558,6 +570,66 @@ function generateCliCommands(program2, sdk2) {
|
|
|
558
570
|
);
|
|
559
571
|
addCommand(program2, cliCommandName, config);
|
|
560
572
|
});
|
|
573
|
+
program2.configureHelp({
|
|
574
|
+
formatHelp: (cmd, helper) => {
|
|
575
|
+
const helpWidth = helper.helpWidth || 80;
|
|
576
|
+
let output = helper.commandUsage(cmd) + "\n";
|
|
577
|
+
if (cmd.description()) {
|
|
578
|
+
output += helper.wrap(cmd.description(), helpWidth, 0) + "\n";
|
|
579
|
+
}
|
|
580
|
+
const options = helper.visibleOptions(cmd);
|
|
581
|
+
if (options.length > 0) {
|
|
582
|
+
output += "\nOptions:\n";
|
|
583
|
+
const longestOptionLength = Math.max(
|
|
584
|
+
...options.map((opt) => helper.optionTerm(opt).length)
|
|
585
|
+
);
|
|
586
|
+
options.forEach((option) => {
|
|
587
|
+
const term = helper.optionTerm(option);
|
|
588
|
+
const padding = " ".repeat(
|
|
589
|
+
Math.max(2, longestOptionLength - term.length + 4)
|
|
590
|
+
);
|
|
591
|
+
output += ` ${term}${padding}${helper.optionDescription(option)}
|
|
592
|
+
`;
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
const commands = helper.visibleCommands(cmd);
|
|
596
|
+
if (commands.length > 0) {
|
|
597
|
+
output += "\nCommands:\n";
|
|
598
|
+
const categorizedCommands = /* @__PURE__ */ new Set();
|
|
599
|
+
registry.categories.forEach((category) => {
|
|
600
|
+
const categoryCommands = commands.filter(
|
|
601
|
+
(command) => category.functions.some((functionName) => {
|
|
602
|
+
const cliCommandName = methodNameToCliCommand(functionName);
|
|
603
|
+
return command.name() === cliCommandName;
|
|
604
|
+
})
|
|
605
|
+
);
|
|
606
|
+
if (categoryCommands.length > 0) {
|
|
607
|
+
output += `
|
|
608
|
+
${category.titlePlural}:
|
|
609
|
+
`;
|
|
610
|
+
categoryCommands.forEach((command) => {
|
|
611
|
+
output += ` ${helper.subcommandTerm(command)}
|
|
612
|
+
`;
|
|
613
|
+
categorizedCommands.add(command.name());
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
const otherCommands = commands.filter(
|
|
618
|
+
(command) => !categorizedCommands.has(command.name())
|
|
619
|
+
);
|
|
620
|
+
if (otherCommands.length > 0) {
|
|
621
|
+
output += `
|
|
622
|
+
Other:
|
|
623
|
+
`;
|
|
624
|
+
otherCommands.forEach((command) => {
|
|
625
|
+
output += ` ${helper.subcommandTerm(command)}
|
|
626
|
+
`;
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return output;
|
|
631
|
+
}
|
|
632
|
+
});
|
|
561
633
|
}
|
|
562
634
|
function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
|
|
563
635
|
const parameters = analyzeZodSchema(schema);
|
|
@@ -1182,7 +1254,8 @@ var GenerateTypesSchema = z3.object({
|
|
|
1182
1254
|
),
|
|
1183
1255
|
debug: DebugPropertySchema.describe(
|
|
1184
1256
|
"Enable debug logging during generation"
|
|
1185
|
-
)
|
|
1257
|
+
),
|
|
1258
|
+
lockFilePath: z3.string().optional().describe("Path to the .zapierrc lock file (defaults to .zapierrc)")
|
|
1186
1259
|
}).describe("Generate TypeScript SDK code for a specific app");
|
|
1187
1260
|
|
|
1188
1261
|
// src/commands/generate-types/index.ts
|
|
@@ -1216,21 +1289,41 @@ async function generateTypes(options) {
|
|
|
1216
1289
|
if (authenticationId) {
|
|
1217
1290
|
for (const action of actions) {
|
|
1218
1291
|
try {
|
|
1292
|
+
const manifestEntry = sdk2.getContext().getManifestEntry(appKey);
|
|
1219
1293
|
const fieldsResult = await sdk2.listInputFields({
|
|
1220
|
-
appKey
|
|
1294
|
+
// If the appKey is in the manifest, use the appKey so that the types are consistent with the manifest's version, otherwise use the action.app_key
|
|
1295
|
+
appKey: manifestEntry ? appKey : action.app_key,
|
|
1221
1296
|
actionKey: action.key,
|
|
1222
1297
|
actionType: action.action_type,
|
|
1223
1298
|
authenticationId
|
|
1224
1299
|
});
|
|
1225
|
-
const fields = fieldsResult.data
|
|
1226
|
-
|
|
1300
|
+
const fields = fieldsResult.data.map((field) => {
|
|
1301
|
+
const fieldObj = field;
|
|
1302
|
+
return {
|
|
1303
|
+
...fieldObj,
|
|
1304
|
+
required: fieldObj.is_required || fieldObj.required || false
|
|
1305
|
+
};
|
|
1306
|
+
});
|
|
1307
|
+
actionsWithFields.push({
|
|
1308
|
+
...action,
|
|
1309
|
+
inputFields: fields,
|
|
1310
|
+
name: action.title || action.key
|
|
1311
|
+
});
|
|
1227
1312
|
} catch {
|
|
1228
|
-
actionsWithFields.push({
|
|
1313
|
+
actionsWithFields.push({
|
|
1314
|
+
...action,
|
|
1315
|
+
inputFields: [],
|
|
1316
|
+
name: action.title || action.key
|
|
1317
|
+
});
|
|
1229
1318
|
}
|
|
1230
1319
|
}
|
|
1231
1320
|
} else {
|
|
1232
1321
|
actions.forEach((action) => {
|
|
1233
|
-
actionsWithFields.push({
|
|
1322
|
+
actionsWithFields.push({
|
|
1323
|
+
...action,
|
|
1324
|
+
inputFields: [],
|
|
1325
|
+
name: action.title || action.key
|
|
1326
|
+
});
|
|
1234
1327
|
});
|
|
1235
1328
|
}
|
|
1236
1329
|
const typeDefinitions = generateTypeDefinitions(
|
|
@@ -1606,7 +1699,9 @@ function createGenerateTypesCommand() {
|
|
|
1606
1699
|
args.slice(0, -1),
|
|
1607
1700
|
options
|
|
1608
1701
|
);
|
|
1609
|
-
const sdk2 = createZapierSdk(
|
|
1702
|
+
const sdk2 = createZapierSdk({
|
|
1703
|
+
manifestPath: rawParams.lockFilePath
|
|
1704
|
+
});
|
|
1610
1705
|
const resolver = new SchemaParameterResolver();
|
|
1611
1706
|
const resolvedParams = await resolver.resolveParameters(
|
|
1612
1707
|
GenerateTypesSchema,
|
|
@@ -1820,7 +1915,7 @@ function createMcpCommand() {
|
|
|
1820
1915
|
|
|
1821
1916
|
// src/cli.ts
|
|
1822
1917
|
var program = new Command7();
|
|
1823
|
-
program.name("zapier-sdk").description("CLI for Zapier SDK
|
|
1918
|
+
program.name("zapier-sdk").description("CLI for Zapier SDK").version("1.0.0").option("--debug", "Enable debug logging");
|
|
1824
1919
|
var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
|
|
1825
1920
|
var sdk = createZapierSdk2({
|
|
1826
1921
|
debug: isDebugMode
|
package/dist/src/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createLoginCommand, createLogoutCommand, createConfigPathCommand, creat
|
|
|
6
6
|
const program = new Command();
|
|
7
7
|
program
|
|
8
8
|
.name("zapier-sdk")
|
|
9
|
-
.description("CLI for Zapier SDK
|
|
9
|
+
.description("CLI for Zapier SDK")
|
|
10
10
|
.version("1.0.0")
|
|
11
11
|
.option("--debug", "Enable debug logging");
|
|
12
12
|
// Check for debug flag early
|
|
@@ -47,8 +47,10 @@ export function createGenerateTypesCommand() {
|
|
|
47
47
|
const options = commandObj.opts();
|
|
48
48
|
// Convert CLI args to SDK method parameters
|
|
49
49
|
const rawParams = convertCliArgsToSdkParams(parameters, args.slice(0, -1), options);
|
|
50
|
-
// Create SDK instance
|
|
51
|
-
const sdk = createZapierSdk(
|
|
50
|
+
// Create SDK instance with manifest path if provided
|
|
51
|
+
const sdk = createZapierSdk({
|
|
52
|
+
manifestPath: rawParams.lockFilePath,
|
|
53
|
+
});
|
|
52
54
|
// Resolve missing parameters interactively using schema metadata
|
|
53
55
|
const resolver = new SchemaParameterResolver();
|
|
54
56
|
const resolvedParams = await resolver.resolveParameters(GenerateTypesSchema, rawParams, sdk);
|
|
@@ -32,25 +32,46 @@ export async function generateTypes(options) {
|
|
|
32
32
|
if (authenticationId) {
|
|
33
33
|
for (const action of actions) {
|
|
34
34
|
try {
|
|
35
|
+
// Check to see if the appKey is in the manifest
|
|
36
|
+
const manifestEntry = sdk.getContext().getManifestEntry(appKey);
|
|
35
37
|
const fieldsResult = await sdk.listInputFields({
|
|
36
|
-
appKey
|
|
38
|
+
// If the appKey is in the manifest, use the appKey so that the types are consistent with the manifest's version, otherwise use the action.app_key
|
|
39
|
+
appKey: manifestEntry ? appKey : action.app_key,
|
|
37
40
|
actionKey: action.key,
|
|
38
41
|
actionType: action.action_type,
|
|
39
42
|
authenticationId: authenticationId,
|
|
40
43
|
});
|
|
41
|
-
const fields = fieldsResult.data
|
|
42
|
-
|
|
44
|
+
const fields = fieldsResult.data.map((field) => {
|
|
45
|
+
const fieldObj = field;
|
|
46
|
+
return {
|
|
47
|
+
...fieldObj,
|
|
48
|
+
required: fieldObj.is_required || fieldObj.required || false,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
actionsWithFields.push({
|
|
52
|
+
...action,
|
|
53
|
+
inputFields: fields,
|
|
54
|
+
name: action.title || action.key,
|
|
55
|
+
});
|
|
43
56
|
}
|
|
44
57
|
catch {
|
|
45
58
|
// If we can't get fields for an action, include it without fields
|
|
46
|
-
actionsWithFields.push({
|
|
59
|
+
actionsWithFields.push({
|
|
60
|
+
...action,
|
|
61
|
+
inputFields: [],
|
|
62
|
+
name: action.title || action.key,
|
|
63
|
+
});
|
|
47
64
|
}
|
|
48
65
|
}
|
|
49
66
|
}
|
|
50
67
|
else {
|
|
51
68
|
// Convert actions to have empty input fields (will generate generic types)
|
|
52
69
|
actions.forEach((action) => {
|
|
53
|
-
actionsWithFields.push({
|
|
70
|
+
actionsWithFields.push({
|
|
71
|
+
...action,
|
|
72
|
+
inputFields: [],
|
|
73
|
+
name: action.title || action.key,
|
|
74
|
+
});
|
|
54
75
|
});
|
|
55
76
|
}
|
|
56
77
|
// Generate TypeScript types
|
|
@@ -4,15 +4,18 @@ export declare const GenerateTypesSchema: z.ZodObject<{
|
|
|
4
4
|
authenticationId: z.ZodOptional<z.ZodNumber>;
|
|
5
5
|
output: z.ZodOptional<z.ZodString>;
|
|
6
6
|
debug: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
lockFilePath: z.ZodOptional<z.ZodString>;
|
|
7
8
|
}, "strip", z.ZodTypeAny, {
|
|
8
9
|
appKey: string;
|
|
9
10
|
debug: boolean;
|
|
10
11
|
authenticationId?: number | undefined;
|
|
11
12
|
output?: string | undefined;
|
|
13
|
+
lockFilePath?: string | undefined;
|
|
12
14
|
}, {
|
|
13
15
|
appKey: string;
|
|
14
16
|
authenticationId?: number | undefined;
|
|
15
17
|
output?: string | undefined;
|
|
16
18
|
debug?: boolean | undefined;
|
|
19
|
+
lockFilePath?: string | undefined;
|
|
17
20
|
}>;
|
|
18
21
|
export type GenerateTypesOptions = z.infer<typeof GenerateTypesSchema>;
|
|
@@ -7,5 +7,9 @@ export const GenerateTypesSchema = z
|
|
|
7
7
|
authenticationId: AuthenticationIdPropertySchema.optional(),
|
|
8
8
|
output: OutputPropertySchema.optional().describe("Output file path (defaults to generated/<appKey>.ts)"),
|
|
9
9
|
debug: DebugPropertySchema.describe("Enable debug logging during generation"),
|
|
10
|
+
lockFilePath: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Path to the .zapierrc lock file (defaults to .zapierrc)"),
|
|
10
14
|
})
|
|
11
15
|
.describe("Generate TypeScript SDK code for a specific app");
|