@zapier/zapier-sdk-cli 0.4.3 → 0.5.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 +22 -0
- package/README.md +298 -0
- package/dist/cli.js +96 -46
- package/dist/src/commands/bundle-code/cli.js +1 -1
- package/dist/src/commands/generate-types/cli.js +13 -4
- package/dist/src/utils/api/client.d.ts +3 -3
- package/dist/src/utils/cli-generator-utils.d.ts +2 -2
- package/dist/src/utils/cli-generator.js +29 -20
- package/dist/src/utils/log.d.ts +4 -4
- package/dist/src/utils/parameter-resolver.d.ts +1 -1
- package/dist/src/utils/parameter-resolver.js +33 -22
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/commands/bundle-code/cli.ts +19 -4
- package/src/commands/generate-types/cli.ts +21 -6
- package/src/utils/api/client.ts +3 -3
- package/src/utils/cli-generator-utils.ts +7 -7
- package/src/utils/cli-generator.ts +80 -45
- package/src/utils/log.ts +4 -4
- package/src/utils/parameter-resolver.ts +79 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @zapier/zapier-sdk-cli
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 218a3ca: reducing 'any' usage with minimal changes to runtime
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [218a3ca]
|
|
12
|
+
- @zapier/zapier-sdk-cli-login@0.3.2
|
|
13
|
+
- @zapier/zapier-sdk-mcp@0.1.4
|
|
14
|
+
- @zapier/zapier-sdk@0.5.2
|
|
15
|
+
|
|
16
|
+
## 0.4.4
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- c662f79: Add proper README with dynamically-listed methods
|
|
21
|
+
- Updated dependencies [c662f79]
|
|
22
|
+
- @zapier/zapier-sdk-mcp@0.1.3
|
|
23
|
+
- @zapier/zapier-sdk@0.5.1
|
|
24
|
+
|
|
3
25
|
## 0.4.3
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# @zapier/zapier-sdk-cli
|
|
2
|
+
|
|
3
|
+
<!-- Generated CLI Reference -->
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Quick Start](#quick-start)
|
|
9
|
+
- [Available Commands](#available-commands)
|
|
10
|
+
- [Actions](#actions)
|
|
11
|
+
- [`listActions`](#listactions)
|
|
12
|
+
- [`getAction`](#getaction)
|
|
13
|
+
- [`listInputFields`](#listinputfields)
|
|
14
|
+
- [`runAction`](#runaction)
|
|
15
|
+
- [Apps](#apps)
|
|
16
|
+
- [`listApps`](#listapps)
|
|
17
|
+
- [`getApp`](#getapp)
|
|
18
|
+
- [Authentication](#authentication)
|
|
19
|
+
- [`listAuthentications`](#listauthentications)
|
|
20
|
+
- [`getAuthentication`](#getauthentication)
|
|
21
|
+
- [`findFirstAuthentication`](#findfirstauthentication)
|
|
22
|
+
- [`findUniqueAuthentication`](#finduniqueauthentication)
|
|
23
|
+
- [HTTP Requests](#http-requests)
|
|
24
|
+
- [`request`](#request)
|
|
25
|
+
- [User & Profile](#user--profile)
|
|
26
|
+
- [`getProfile`](#getprofile)
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install -D @zapier/zapier-sdk-cli
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# See all available commands
|
|
38
|
+
npx zapier-sdk --help
|
|
39
|
+
|
|
40
|
+
# Login to Zapier
|
|
41
|
+
npx zapier-sdk login
|
|
42
|
+
|
|
43
|
+
# List all available apps
|
|
44
|
+
npx zapier-sdk list-apps
|
|
45
|
+
|
|
46
|
+
# Generate TypeScript types for an app
|
|
47
|
+
npx zapier-sdk generate-types slack --output ./types/slack.ts
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Available Commands
|
|
51
|
+
|
|
52
|
+
The CLI automatically generates commands from the SDK registry. All SDK functions are available as CLI commands using kebab-case naming.
|
|
53
|
+
|
|
54
|
+
### Actions
|
|
55
|
+
|
|
56
|
+
#### `list-actions`
|
|
57
|
+
|
|
58
|
+
List all actions for a specific app
|
|
59
|
+
|
|
60
|
+
**Options:**
|
|
61
|
+
|
|
62
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
63
|
+
| --------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
64
|
+
| `<appKey>` | `string` | ✅ | — | — | App key of actions to list (e.g., 'SlackCLIAPI') |
|
|
65
|
+
| `--action-type` | `string` | ❌ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Filter actions by type |
|
|
66
|
+
| `--page-size` | `number` | ❌ | — | — | Number of actions per page |
|
|
67
|
+
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
68
|
+
|
|
69
|
+
**Usage:**
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npx zapier-sdk list-actions <appKey> [--action-type] [--page-size] [--max-items]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### `get-action`
|
|
76
|
+
|
|
77
|
+
Get detailed information about a specific action
|
|
78
|
+
|
|
79
|
+
**Options:**
|
|
80
|
+
|
|
81
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
82
|
+
| -------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
|
|
83
|
+
| `<appKey>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
|
|
84
|
+
| `<actionType>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
85
|
+
| `<actionKey>` | `string` | ✅ | — | — | Action key to execute |
|
|
86
|
+
|
|
87
|
+
**Usage:**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx zapier-sdk get-action <appKey> <actionType> <actionKey>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
#### `list-input-fields`
|
|
94
|
+
|
|
95
|
+
Get the input fields required for a specific action
|
|
96
|
+
|
|
97
|
+
**Options:**
|
|
98
|
+
|
|
99
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
100
|
+
| --------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
|
|
101
|
+
| `<appKey>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
|
|
102
|
+
| `<actionType>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
103
|
+
| `<actionKey>` | `string` | ✅ | — | — | Action key to execute |
|
|
104
|
+
| `--authentication-id` | `string` | ❌ | — | — | Authentication ID to use for this action |
|
|
105
|
+
| `--inputs` | `object` | ❌ | — | — | Current input values that may affect available fields |
|
|
106
|
+
| `--page-size` | `number` | ❌ | — | — | Number of input fields per page |
|
|
107
|
+
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
108
|
+
|
|
109
|
+
**Usage:**
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npx zapier-sdk list-input-fields <appKey> <actionType> <actionKey> [--authentication-id] [--inputs] [--page-size] [--max-items]
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### `run-action`
|
|
116
|
+
|
|
117
|
+
Execute an action with the given inputs
|
|
118
|
+
|
|
119
|
+
**Options:**
|
|
120
|
+
|
|
121
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
122
|
+
| --------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------- |
|
|
123
|
+
| `<appKey>` | `string` | ✅ | — | — | App key (e.g., 'SlackCLIAPI') |
|
|
124
|
+
| `<actionType>` | `string` | ✅ | — | `read`, `read_bulk`, `write`, `run`, `search`, `search_or_write`, `search_and_write`, `filter` | Action type that matches the action's defined type |
|
|
125
|
+
| `<actionKey>` | `string` | ✅ | — | — | Action key to execute |
|
|
126
|
+
| `--authentication-id` | `string` | ❌ | — | — | Authentication ID to use for this action |
|
|
127
|
+
| `--inputs` | `object` | ❌ | — | — | Input parameters for the action |
|
|
128
|
+
| `--page-size` | `number` | ❌ | — | — | Number of results per page |
|
|
129
|
+
| `--max-items` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
130
|
+
|
|
131
|
+
**Usage:**
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npx zapier-sdk run-action <appKey> <actionType> <actionKey> [--authentication-id] [--inputs] [--page-size] [--max-items]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Apps
|
|
138
|
+
|
|
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
|
+
#### `get-app`
|
|
159
|
+
|
|
160
|
+
Get detailed information about a specific app
|
|
161
|
+
|
|
162
|
+
**Options:**
|
|
163
|
+
|
|
164
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
165
|
+
| ---------- | -------- | -------- | ------- | --------------- | --------------------------------------------- |
|
|
166
|
+
| `<appKey>` | `string` | ✅ | — | — | App key of app to fetch (e.g., 'SlackCLIAPI') |
|
|
167
|
+
|
|
168
|
+
**Usage:**
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npx zapier-sdk get-app <appKey>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Authentication
|
|
175
|
+
|
|
176
|
+
#### `list-authentications`
|
|
177
|
+
|
|
178
|
+
List available authentications with optional filtering
|
|
179
|
+
|
|
180
|
+
**Options:**
|
|
181
|
+
|
|
182
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
183
|
+
| -------------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------- |
|
|
184
|
+
| `--app-key` | `string` | ❌ | — | — | App key of authentications to list (e.g., 'SlackCLIAPI') |
|
|
185
|
+
| `--search` | `string` | ❌ | — | — | Search term to filter authentications by title |
|
|
186
|
+
| `--title` | `string` | ❌ | — | — | Filter authentications by exact title match |
|
|
187
|
+
| `--account_id` | `string` | ❌ | — | — | Filter by account ID |
|
|
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 |
|
|
191
|
+
|
|
192
|
+
**Usage:**
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npx zapier-sdk list-authentications [--app-key] [--search] [--title] [--account_id] [--owner] [--page-size] [--max-items]
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### `get-authentication`
|
|
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
|
+
```
|
|
213
|
+
|
|
214
|
+
#### `find-first-authentication`
|
|
215
|
+
|
|
216
|
+
Find the first authentication matching the criteria
|
|
217
|
+
|
|
218
|
+
**Options:**
|
|
219
|
+
|
|
220
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
221
|
+
| -------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------------- |
|
|
222
|
+
| `--app-key` | `string` | ❌ | — | — | App key of authentication to find (e.g., 'SlackCLIAPI') |
|
|
223
|
+
| `--search` | `string` | ❌ | — | — | Search term to filter authentications by title |
|
|
224
|
+
| `--title` | `string` | ❌ | — | — | Filter authentications by exact title match |
|
|
225
|
+
| `--account_id` | `string` | ❌ | — | — | Filter by account ID |
|
|
226
|
+
| `--owner` | `string` | ❌ | — | — | Filter by owner |
|
|
227
|
+
|
|
228
|
+
**Usage:**
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npx zapier-sdk find-first-authentication [--app-key] [--search] [--title] [--account_id] [--owner]
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### `find-unique-authentication`
|
|
235
|
+
|
|
236
|
+
Find a unique authentication matching the criteria
|
|
237
|
+
|
|
238
|
+
**Options:**
|
|
239
|
+
|
|
240
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
241
|
+
| -------------- | -------- | -------- | ------- | --------------- | ------------------------------------------------------- |
|
|
242
|
+
| `--app-key` | `string` | ❌ | — | — | App key of authentication to find (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
|
+
|
|
248
|
+
**Usage:**
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
npx zapier-sdk find-unique-authentication [--app-key] [--search] [--title] [--account_id] [--owner]
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### HTTP Requests
|
|
255
|
+
|
|
256
|
+
#### `request`
|
|
257
|
+
|
|
258
|
+
Make authenticated HTTP requests through Zapier's Relay service
|
|
259
|
+
|
|
260
|
+
**Options:**
|
|
261
|
+
|
|
262
|
+
| Option | Type | Required | Default | Possible Values | Description |
|
|
263
|
+
| --------------------------- | -------- | -------- | ------- | ---------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
264
|
+
| `<url>` | `string` | ✅ | — | — | The URL to request (will be proxied through Relay) |
|
|
265
|
+
| `--method` | `string` | ❌ | — | `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS` | HTTP method |
|
|
266
|
+
| `--body` | `string` | ❌ | — | — | Request body as a string |
|
|
267
|
+
| `--authentication-id` | `number` | ❌ | — | — | Zapier authentication ID to use for the request |
|
|
268
|
+
| `--callback-url` | `string` | ❌ | — | — | URL to send async response to (makes request async) |
|
|
269
|
+
| `--authentication-template` | `string` | ❌ | — | — | Optional JSON string authentication template to bypass Notary lookup |
|
|
270
|
+
| `--headers` | `string` | ❌ | — | — | Request headers |
|
|
271
|
+
| `--relay-base-url` | `string` | ❌ | — | — | Base URL for Relay service |
|
|
272
|
+
|
|
273
|
+
**Usage:**
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
npx zapier-sdk request <url> [--method] [--body] [--authentication-id] [--callback-url] [--authentication-template] [--headers] [--relay-base-url]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### User & Profile
|
|
280
|
+
|
|
281
|
+
#### `get-profile`
|
|
282
|
+
|
|
283
|
+
Get current user's profile information
|
|
284
|
+
|
|
285
|
+
**Usage:**
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
npx zapier-sdk get-profile
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Additional CLI Commands
|
|
292
|
+
|
|
293
|
+
- `login` - Authenticate with Zapier
|
|
294
|
+
- `logout` - Clear authentication
|
|
295
|
+
- `generate-types <app-key>` - Generate TypeScript types for an app
|
|
296
|
+
- `mcp` - Start MCP server
|
|
297
|
+
|
|
298
|
+
<!-- End Generated CLI Reference -->
|
package/dist/cli.js
CHANGED
|
@@ -268,7 +268,7 @@ var SchemaParameterResolver = class {
|
|
|
268
268
|
break;
|
|
269
269
|
}
|
|
270
270
|
const newFields = fields.filter(
|
|
271
|
-
(field) => !processedFieldKeys.has(field.key)
|
|
271
|
+
(field) => !(field.key && processedFieldKeys.has(field.key))
|
|
272
272
|
);
|
|
273
273
|
if (newFields.length === 0) {
|
|
274
274
|
break;
|
|
@@ -343,40 +343,54 @@ Optional fields:`));
|
|
|
343
343
|
return inputs;
|
|
344
344
|
}
|
|
345
345
|
getNestedValue(obj, path3) {
|
|
346
|
-
return path3.reduce(
|
|
346
|
+
return path3.reduce(
|
|
347
|
+
(current, key) => current?.[key],
|
|
348
|
+
obj
|
|
349
|
+
);
|
|
347
350
|
}
|
|
348
351
|
setNestedValue(obj, path3, value) {
|
|
349
352
|
const lastKey = path3[path3.length - 1];
|
|
350
353
|
const parent = path3.slice(0, -1).reduce((current, key) => {
|
|
351
|
-
|
|
352
|
-
|
|
354
|
+
const currentObj = current;
|
|
355
|
+
if (!(key in currentObj)) {
|
|
356
|
+
currentObj[key] = {};
|
|
353
357
|
}
|
|
354
|
-
return
|
|
358
|
+
return currentObj[key];
|
|
355
359
|
}, obj);
|
|
356
360
|
parent[lastKey] = value;
|
|
357
361
|
}
|
|
358
362
|
async promptForField(field, inputs) {
|
|
363
|
+
const fieldObj = field;
|
|
359
364
|
const fieldPrompt = {
|
|
360
|
-
type:
|
|
361
|
-
name:
|
|
362
|
-
message: `${
|
|
363
|
-
...field.helpText && { prefix: chalk.gray(`\u2139 ${field.helpText}
|
|
364
|
-
`) },
|
|
365
|
-
...field.default && { default: field.default }
|
|
365
|
+
type: fieldObj.type === "boolean" ? "confirm" : "input",
|
|
366
|
+
name: fieldObj.key,
|
|
367
|
+
message: `${fieldObj.label || fieldObj.key}${fieldObj.required ? " (required)" : " (optional)"}:`
|
|
366
368
|
};
|
|
367
|
-
if (
|
|
369
|
+
if (fieldObj.helpText) {
|
|
370
|
+
fieldPrompt.prefix = chalk.gray(`\u2139 ${fieldObj.helpText}
|
|
371
|
+
`);
|
|
372
|
+
}
|
|
373
|
+
if (fieldObj.default !== void 0) {
|
|
374
|
+
fieldPrompt.default = fieldObj.default;
|
|
375
|
+
}
|
|
376
|
+
if (fieldObj.choices && fieldObj.choices.length > 0) {
|
|
368
377
|
fieldPrompt.type = "list";
|
|
369
|
-
fieldPrompt.choices =
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
378
|
+
fieldPrompt.choices = fieldObj.choices.map(
|
|
379
|
+
(choice) => {
|
|
380
|
+
const choiceObj = choice;
|
|
381
|
+
return {
|
|
382
|
+
name: choiceObj.label || choiceObj.value,
|
|
383
|
+
value: choiceObj.value
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
);
|
|
373
387
|
}
|
|
374
388
|
try {
|
|
375
389
|
const answer = await inquirer.prompt([fieldPrompt]);
|
|
376
|
-
if (answer[
|
|
377
|
-
inputs[
|
|
378
|
-
} else if (
|
|
379
|
-
throw new Error(`Required field ${
|
|
390
|
+
if (answer[fieldObj.key] !== void 0 && answer[fieldObj.key] !== "") {
|
|
391
|
+
inputs[fieldObj.key] = answer[fieldObj.key];
|
|
392
|
+
} else if (fieldObj.required) {
|
|
393
|
+
throw new Error(`Required field ${fieldObj.key} cannot be empty`);
|
|
380
394
|
}
|
|
381
395
|
} catch (error) {
|
|
382
396
|
if (this.isUserCancellation(error)) {
|
|
@@ -387,7 +401,8 @@ Optional fields:`));
|
|
|
387
401
|
}
|
|
388
402
|
}
|
|
389
403
|
isUserCancellation(error) {
|
|
390
|
-
|
|
404
|
+
const errorObj = error;
|
|
405
|
+
return errorObj?.name === "ExitPromptError" || errorObj?.message?.includes("User force closed") || errorObj?.isTTYError === true;
|
|
391
406
|
}
|
|
392
407
|
};
|
|
393
408
|
|
|
@@ -568,24 +583,27 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
|
|
|
568
583
|
rawParams,
|
|
569
584
|
sdk2
|
|
570
585
|
);
|
|
571
|
-
const hasOutputFile = resolvedParams.output;
|
|
572
|
-
if (hasOutputFile) {
|
|
573
|
-
await sdk2[sdkMethodName](resolvedParams);
|
|
574
|
-
console.log(
|
|
575
|
-
chalk3.green(`\u2705 ${cliCommandName} completed successfully!`)
|
|
576
|
-
);
|
|
577
|
-
console.log(chalk3.gray(`Output written to: ${resolvedParams.output}`));
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
586
|
if (isListCommand && hasPaginationParams && !shouldUseJson && !hasUserSpecifiedMaxItems) {
|
|
581
|
-
const
|
|
587
|
+
const sdkObj = sdk2;
|
|
588
|
+
const sdkIterator = await sdkObj[sdkMethodName](resolvedParams);
|
|
582
589
|
await handlePaginatedListWithAsyncIteration(
|
|
583
590
|
sdkMethodName,
|
|
584
591
|
sdkIterator,
|
|
585
592
|
schema
|
|
586
593
|
);
|
|
587
594
|
} else {
|
|
588
|
-
const
|
|
595
|
+
const hasOutputFile = resolvedParams.output;
|
|
596
|
+
if (hasOutputFile) {
|
|
597
|
+
const sdkObj2 = sdk2;
|
|
598
|
+
await sdkObj2[sdkMethodName](resolvedParams);
|
|
599
|
+
console.log(
|
|
600
|
+
chalk3.green(`\u2705 ${cliCommandName} completed successfully!`)
|
|
601
|
+
);
|
|
602
|
+
console.log(chalk3.gray(`Output written to: ${hasOutputFile}`));
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
const sdkObj = sdk2;
|
|
606
|
+
const result = await sdkObj[sdkMethodName](resolvedParams);
|
|
589
607
|
const items = result?.data ? result.data : result;
|
|
590
608
|
if (shouldUseJson) {
|
|
591
609
|
console.log(JSON.stringify(items, null, 2));
|
|
@@ -608,8 +626,13 @@ function createCommandConfig(cliCommandName, sdkMethodName, schema, sdk2) {
|
|
|
608
626
|
const validationErrors = JSON.parse(error.message);
|
|
609
627
|
console.error(chalk3.red("\u274C Validation Error:"));
|
|
610
628
|
validationErrors.forEach((err) => {
|
|
611
|
-
const
|
|
612
|
-
|
|
629
|
+
const errorObj = err;
|
|
630
|
+
const field = errorObj?.path?.join(".") || "unknown";
|
|
631
|
+
console.error(
|
|
632
|
+
chalk3.yellow(
|
|
633
|
+
` \u2022 ${field}: ${errorObj?.message || "Unknown error"}`
|
|
634
|
+
)
|
|
635
|
+
);
|
|
613
636
|
});
|
|
614
637
|
console.error(
|
|
615
638
|
"\n" + chalk3.dim(`Use --help to see available options`)
|
|
@@ -658,10 +681,18 @@ function addCommand(program2, commandName, config) {
|
|
|
658
681
|
command.option(flags.join(", "), param.description);
|
|
659
682
|
} else if (param.type === "array") {
|
|
660
683
|
const flagSignature = flags.join(", ") + ` <values...>`;
|
|
661
|
-
command.option(
|
|
684
|
+
command.option(
|
|
685
|
+
flagSignature,
|
|
686
|
+
param.description,
|
|
687
|
+
param.default
|
|
688
|
+
);
|
|
662
689
|
} else {
|
|
663
690
|
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
664
|
-
command.option(
|
|
691
|
+
command.option(
|
|
692
|
+
flagSignature,
|
|
693
|
+
param.description || "",
|
|
694
|
+
param.default
|
|
695
|
+
);
|
|
665
696
|
}
|
|
666
697
|
}
|
|
667
698
|
});
|
|
@@ -826,10 +857,11 @@ function formatNonPaginatedResults(result, requestedMaxItems, userSpecifiedMaxIt
|
|
|
826
857
|
}
|
|
827
858
|
function formatItemsGeneric2(items) {
|
|
828
859
|
items.forEach((item, index) => {
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
860
|
+
const itemObj = item;
|
|
861
|
+
const name = itemObj?.name || itemObj?.key || itemObj?.id || "Item";
|
|
862
|
+
console.log(`${chalk3.gray(`${index + 1}.`)} ${chalk3.cyan(String(name))}`);
|
|
863
|
+
if (itemObj?.description) {
|
|
864
|
+
console.log(` ${chalk3.dim(String(itemObj.description))}`);
|
|
833
865
|
}
|
|
834
866
|
console.log();
|
|
835
867
|
});
|
|
@@ -1556,7 +1588,11 @@ function createGenerateTypesCommand() {
|
|
|
1556
1588
|
command.option(flags.join(", "), param.description);
|
|
1557
1589
|
} else {
|
|
1558
1590
|
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
1559
|
-
command.option(
|
|
1591
|
+
command.option(
|
|
1592
|
+
flagSignature,
|
|
1593
|
+
param.description || "",
|
|
1594
|
+
param.default
|
|
1595
|
+
);
|
|
1560
1596
|
}
|
|
1561
1597
|
}
|
|
1562
1598
|
});
|
|
@@ -1577,16 +1613,24 @@ function createGenerateTypesCommand() {
|
|
|
1577
1613
|
rawParams,
|
|
1578
1614
|
sdk2
|
|
1579
1615
|
);
|
|
1616
|
+
const params = resolvedParams;
|
|
1580
1617
|
console.log(
|
|
1581
1618
|
chalk5.blue(
|
|
1582
|
-
`\u{1F527} Generating TypeScript types for ${
|
|
1619
|
+
`\u{1F527} Generating TypeScript types for ${params.appKey}...`
|
|
1583
1620
|
)
|
|
1584
1621
|
);
|
|
1585
|
-
const
|
|
1622
|
+
const generateTypesParams = {
|
|
1623
|
+
appKey: params.appKey,
|
|
1624
|
+
debug: params.debug ?? false,
|
|
1625
|
+
authenticationId: params.authenticationId,
|
|
1626
|
+
output: params.output,
|
|
1627
|
+
sdk: sdk2
|
|
1628
|
+
};
|
|
1629
|
+
const result = await generateTypes(generateTypesParams);
|
|
1586
1630
|
if (options.json) {
|
|
1587
1631
|
console.log(JSON.stringify({ result }, null, 2));
|
|
1588
1632
|
} else {
|
|
1589
|
-
const output =
|
|
1633
|
+
const output = params.output || `./types/${params.appKey}.d.ts`;
|
|
1590
1634
|
console.log(chalk5.green("\u2705 TypeScript types generated successfully!"));
|
|
1591
1635
|
console.log(chalk5.gray(`Output written to: ${output}`));
|
|
1592
1636
|
}
|
|
@@ -1717,7 +1761,11 @@ function createBundleCodeCommand() {
|
|
|
1717
1761
|
command.option(flags.join(", "), param.description);
|
|
1718
1762
|
} else {
|
|
1719
1763
|
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
1720
|
-
command.option(
|
|
1764
|
+
command.option(
|
|
1765
|
+
flagSignature,
|
|
1766
|
+
param.description || "",
|
|
1767
|
+
param.default
|
|
1768
|
+
);
|
|
1721
1769
|
}
|
|
1722
1770
|
}
|
|
1723
1771
|
});
|
|
@@ -1735,7 +1783,9 @@ function createBundleCodeCommand() {
|
|
|
1735
1783
|
throw new Error("Input file path is required");
|
|
1736
1784
|
}
|
|
1737
1785
|
console.log(chalk6.blue(`\u{1F4E6} Bundling ${rawParams.input}...`));
|
|
1738
|
-
const result = await bundleCode(
|
|
1786
|
+
const result = await bundleCode(
|
|
1787
|
+
rawParams
|
|
1788
|
+
);
|
|
1739
1789
|
if (options.json) {
|
|
1740
1790
|
console.log(JSON.stringify({ result }, null, 2));
|
|
1741
1791
|
} else if (rawParams.output && !rawParams.string) {
|
|
@@ -32,7 +32,7 @@ export function createBundleCodeCommand() {
|
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
35
|
-
command.option(flagSignature, param.description, param.default);
|
|
35
|
+
command.option(flagSignature, param.description || "", param.default);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
});
|
|
@@ -34,7 +34,7 @@ export function createGenerateTypesCommand() {
|
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
const flagSignature = flags.join(", ") + ` <${param.type}>`;
|
|
37
|
-
command.option(flagSignature, param.description, param.default);
|
|
37
|
+
command.option(flagSignature, param.description || "", param.default);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
});
|
|
@@ -52,14 +52,23 @@ export function createGenerateTypesCommand() {
|
|
|
52
52
|
// Resolve missing parameters interactively using schema metadata
|
|
53
53
|
const resolver = new SchemaParameterResolver();
|
|
54
54
|
const resolvedParams = await resolver.resolveParameters(GenerateTypesSchema, rawParams, sdk);
|
|
55
|
-
|
|
55
|
+
const params = resolvedParams;
|
|
56
|
+
console.log(chalk.blue(`🔧 Generating TypeScript types for ${params.appKey}...`));
|
|
56
57
|
// Call our implementation
|
|
57
|
-
const
|
|
58
|
+
const generateTypesParams = {
|
|
59
|
+
appKey: params.appKey,
|
|
60
|
+
debug: params.debug ?? false,
|
|
61
|
+
authenticationId: params.authenticationId,
|
|
62
|
+
output: params.output,
|
|
63
|
+
sdk,
|
|
64
|
+
};
|
|
65
|
+
const result = await generateTypes(generateTypesParams);
|
|
58
66
|
if (options.json) {
|
|
59
67
|
console.log(JSON.stringify({ result }, null, 2));
|
|
60
68
|
}
|
|
61
69
|
else {
|
|
62
|
-
const output =
|
|
70
|
+
const output = params.output ||
|
|
71
|
+
`./types/${params.appKey}.d.ts`;
|
|
63
72
|
console.log(chalk.green("✅ TypeScript types generated successfully!"));
|
|
64
73
|
console.log(chalk.gray(`Output written to: ${output}`));
|
|
65
74
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export interface ApiResponse<T =
|
|
1
|
+
export interface ApiResponse<T = unknown> {
|
|
2
2
|
data: T;
|
|
3
3
|
status: number;
|
|
4
4
|
}
|
|
5
5
|
export declare const createApiClient: () => {
|
|
6
|
-
post: <T =
|
|
6
|
+
post: <T = unknown>(url: string, data: Record<string, string>, options?: {
|
|
7
7
|
headers?: Record<string, string>;
|
|
8
8
|
}) => Promise<ApiResponse<T>>;
|
|
9
9
|
};
|
|
10
10
|
declare const api: {
|
|
11
|
-
post: <T =
|
|
11
|
+
post: <T = unknown>(url: string, data: Record<string, string>, options?: {
|
|
12
12
|
headers?: Record<string, string>;
|
|
13
13
|
}) => Promise<ApiResponse<T>>;
|
|
14
14
|
};
|
|
@@ -4,10 +4,10 @@ export interface CliParameter {
|
|
|
4
4
|
type: "string" | "number" | "boolean" | "array";
|
|
5
5
|
required: boolean;
|
|
6
6
|
description?: string;
|
|
7
|
-
default?:
|
|
7
|
+
default?: unknown;
|
|
8
8
|
choices?: string[];
|
|
9
9
|
hasResolver?: boolean;
|
|
10
10
|
isPositional?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export declare function analyzeZodSchema(schema: z.ZodSchema): CliParameter[];
|
|
13
|
-
export declare function convertCliArgsToSdkParams(parameters: CliParameter[], positionalArgs:
|
|
13
|
+
export declare function convertCliArgsToSdkParams(parameters: CliParameter[], positionalArgs: unknown[], options: Record<string, unknown>): Record<string, unknown>;
|