@zapier/zapier-sdk 0.8.3 → 0.10.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 +18 -0
- package/README.md +17 -40
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +14 -0
- package/dist/api/debug.d.ts +1 -0
- package/dist/api/debug.d.ts.map +1 -1
- package/dist/api/debug.js +42 -1
- package/dist/api/debug.test.d.ts +2 -0
- package/dist/api/debug.test.d.ts.map +1 -0
- package/dist/api/debug.test.js +59 -0
- package/dist/api/schemas.d.ts +451 -251
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +51 -29
- package/dist/index.cjs +1149 -751
- package/dist/index.d.mts +2359 -2161
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.mjs +1143 -743
- package/dist/plugins/apps/index.d.ts +4 -0
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +9 -1
- package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +4 -0
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +10 -0
- package/dist/plugins/getAction/schemas.d.ts +5 -3
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts +2 -7
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +17 -9
- package/dist/plugins/getApp/index.test.js +3 -3
- package/dist/plugins/getApp/schemas.d.ts +3 -1
- package/dist/plugins/getApp/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/schemas.js +2 -4
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +8 -0
- package/dist/plugins/getAuthentication/index.test.js +1 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +4 -0
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/schemas.js +4 -3
- package/dist/plugins/listActions/index.d.ts +2 -4
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +10 -1
- package/dist/plugins/listActions/index.test.js +4 -4
- package/dist/plugins/listActions/schemas.d.ts +5 -3
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listActions/schemas.js +2 -4
- package/dist/plugins/listApps/index.d.ts +4 -7
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +37 -17
- package/dist/plugins/listApps/index.test.js +23 -3
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +3 -9
- package/dist/plugins/listAuthentications/index.d.ts +2 -4
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +12 -0
- package/dist/plugins/listAuthentications/index.test.js +39 -13
- package/dist/plugins/listAuthentications/schemas.d.ts +8 -3
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/schemas.js +4 -0
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +14 -2
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +14 -2
- package/dist/plugins/listInputFields/index.test.js +5 -9
- package/dist/plugins/listInputFields/schemas.d.ts +5 -3
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/index.d.ts +25 -9
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +239 -67
- package/dist/plugins/manifest/index.test.js +426 -171
- package/dist/plugins/manifest/schemas.d.ts +5 -1
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +1 -0
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +8 -2
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +1 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +12 -0
- package/dist/plugins/runAction/schemas.d.ts +5 -3
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/resolvers/actionKey.d.ts +13 -7
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +8 -7
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/resolvers/appKey.d.ts +2 -6
- package/dist/resolvers/appKey.d.ts.map +1 -1
- package/dist/resolvers/authenticationId.d.ts +7 -7
- package/dist/resolvers/authenticationId.d.ts.map +1 -1
- package/dist/resolvers/authenticationId.js +16 -7
- package/dist/resolvers/index.d.ts +3 -35
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +4 -87
- package/dist/resolvers/inputFieldKey.d.ts +11 -0
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
- package/dist/resolvers/inputFieldKey.js +23 -0
- package/dist/resolvers/inputs.d.ts +11 -6
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/resolvers/inputs.js +17 -0
- package/dist/schemas/Action.d.ts +8 -8
- package/dist/schemas/Action.d.ts.map +1 -1
- package/dist/schemas/Action.js +8 -3
- package/dist/schemas/App.d.ts +183 -11
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +7 -9
- package/dist/schemas/Auth.d.ts +12 -12
- package/dist/schemas/Auth.js +1 -1
- package/dist/schemas/Field.d.ts +5 -98
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +24 -52
- package/dist/schemas/Run.d.ts +3 -0
- package/dist/schemas/Run.d.ts.map +1 -0
- package/dist/schemas/Run.js +31 -0
- package/dist/schemas/UserProfile.d.ts +11 -11
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +21 -7
- package/dist/sdk.d.ts +15 -14
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +1 -4
- package/dist/types/plugin.d.ts +6 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/properties.d.ts +3 -1
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +11 -3
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/domain-utils.d.ts +17 -16
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +53 -78
- package/dist/utils/domain-utils.test.js +157 -3
- package/dist/utils/file-utils.d.ts +4 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +74 -0
- package/dist/utils/file-utils.test.d.ts +2 -0
- package/dist/utils/file-utils.test.d.ts.map +1 -0
- package/dist/utils/file-utils.test.js +51 -0
- package/dist/utils/schema-utils.d.ts +44 -21
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/dist/utils/schema-utils.js +17 -11
- package/package.json +1 -1
- package/src/api/client.ts +12 -0
- package/src/api/debug.test.ts +76 -0
- package/src/api/debug.ts +46 -2
- package/src/api/schemas.ts +51 -29
- package/src/index.ts +5 -6
- package/src/plugins/apps/index.ts +9 -2
- package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
- package/src/plugins/findFirstAuthentication/index.ts +14 -2
- package/src/plugins/findUniqueAuthentication/index.ts +4 -0
- package/src/plugins/getAction/index.ts +14 -0
- package/src/plugins/getApp/index.test.ts +3 -3
- package/src/plugins/getApp/index.ts +20 -14
- package/src/plugins/getApp/schemas.ts +7 -12
- package/src/plugins/getAuthentication/index.test.ts +1 -1
- package/src/plugins/getAuthentication/index.ts +8 -0
- package/src/plugins/getProfile/index.ts +4 -0
- package/src/plugins/getProfile/schemas.ts +4 -6
- package/src/plugins/listActions/index.test.ts +8 -7
- package/src/plugins/listActions/index.ts +12 -3
- package/src/plugins/listActions/schemas.ts +20 -25
- package/src/plugins/listApps/index.test.ts +24 -3
- package/src/plugins/listApps/index.ts +50 -25
- package/src/plugins/listApps/schemas.ts +17 -26
- package/src/plugins/listAuthentications/index.test.ts +52 -15
- package/src/plugins/listAuthentications/index.ts +15 -2
- package/src/plugins/listAuthentications/schemas.ts +4 -0
- package/src/plugins/listInputFieldChoices/index.ts +21 -1
- package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
- package/src/plugins/listInputFields/index.test.ts +5 -9
- package/src/plugins/listInputFields/index.ts +20 -2
- package/src/plugins/manifest/index.test.ts +503 -197
- package/src/plugins/manifest/index.ts +338 -82
- package/src/plugins/manifest/schemas.ts +9 -2
- package/src/plugins/registry/index.ts +8 -2
- package/src/plugins/request/index.ts +1 -0
- package/src/plugins/runAction/index.ts +18 -0
- package/src/resolvers/actionKey.ts +15 -13
- package/src/resolvers/actionType.ts +10 -12
- package/src/resolvers/appKey.ts +2 -6
- package/src/resolvers/authenticationId.ts +25 -19
- package/src/resolvers/index.ts +7 -113
- package/src/resolvers/inputFieldKey.ts +38 -0
- package/src/resolvers/inputs.ts +28 -10
- package/src/schemas/Action.ts +8 -3
- package/src/schemas/App.ts +7 -9
- package/src/schemas/Auth.ts +1 -1
- package/src/schemas/Field.ts +24 -57
- package/src/schemas/Run.ts +40 -0
- package/src/schemas/UserProfile.ts +24 -7
- package/src/sdk.ts +18 -12
- package/src/types/plugin.ts +8 -0
- package/src/types/sdk.ts +31 -21
- package/src/utils/domain-utils.test.ts +196 -2
- package/src/utils/domain-utils.ts +77 -102
- package/src/utils/file-utils.test.ts +73 -0
- package/src/utils/file-utils.ts +94 -0
- package/src/utils/schema-utils.ts +96 -44
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/plugins/lockVersion/index.d.ts +0 -24
- package/dist/plugins/lockVersion/index.d.ts.map +0 -1
- package/dist/plugins/lockVersion/index.js +0 -72
- package/dist/plugins/lockVersion/index.test.d.ts +0 -2
- package/dist/plugins/lockVersion/index.test.d.ts.map +0 -1
- package/dist/plugins/lockVersion/index.test.js +0 -129
- package/dist/plugins/lockVersion/schemas.d.ts +0 -10
- package/dist/plugins/lockVersion/schemas.d.ts.map +0 -1
- package/dist/plugins/lockVersion/schemas.js +0 -6
- package/src/plugins/lockVersion/index.test.ts +0 -176
- package/src/plugins/lockVersion/index.ts +0 -112
- package/src/plugins/lockVersion/schemas.ts +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3184903: No more global resolver registry, each plugin function has its own resolvers. Plugin function meta also stores output schema and some function type info to avoid some special case code for handling lists, documenting functions, etc. findFirstAuthentication throws an error to make all item functions consistent. Various other schema and output cleanup.
|
|
8
|
+
|
|
9
|
+
## 0.9.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 3cfed98: Reducing any usages
|
|
14
|
+
|
|
15
|
+
## 0.9.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 5ccaec6: AST-based type gen instead of string-based. Added `add` function for locking app versions and generating types. Removed `lockVersion` and `generateTypes functions. Manifest matching on slug or implementation name.
|
|
20
|
+
|
|
3
21
|
## 0.8.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
- [`listAuthentications`](#listauthentications)
|
|
26
26
|
- [HTTP Requests](#http-requests)
|
|
27
27
|
- [`request`](#request)
|
|
28
|
-
- [Utilities](#utilities)
|
|
29
|
-
- [`lockVersion`](#lockversion)
|
|
30
28
|
|
|
31
29
|
## Installation
|
|
32
30
|
|
|
@@ -68,7 +66,7 @@ Get current user's profile information
|
|
|
68
66
|
|
|
69
67
|
**Parameters:** None
|
|
70
68
|
|
|
71
|
-
**Returns:** `Promise<
|
|
69
|
+
**Returns:** `Promise<ProfileItem>`
|
|
72
70
|
|
|
73
71
|
**Example:**
|
|
74
72
|
|
|
@@ -172,7 +170,7 @@ Get the input fields required for a specific action
|
|
|
172
170
|
| `pageSize` | `number` | ❌ | — | — | Number of input fields per page |
|
|
173
171
|
| `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
174
172
|
|
|
175
|
-
**Returns:** `Promise<PaginatedResult<
|
|
173
|
+
**Returns:** `Promise<PaginatedResult<InputFieldItem>>`
|
|
176
174
|
|
|
177
175
|
**Example:**
|
|
178
176
|
|
|
@@ -200,7 +198,7 @@ Execute an action with the given inputs
|
|
|
200
198
|
| `pageSize` | `number` | ❌ | — | — | Number of results per page |
|
|
201
199
|
| `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
202
200
|
|
|
203
|
-
**Returns:** `Promise<
|
|
201
|
+
**Returns:** `Promise<PaginatedResult<ActionResultItem>>`
|
|
204
202
|
|
|
205
203
|
**Example:**
|
|
206
204
|
|
|
@@ -271,7 +269,7 @@ Find the first authentication matching the criteria
|
|
|
271
269
|
| `accountId` | `string` | ❌ | — | — | Filter by account ID |
|
|
272
270
|
| `owner` | `string` | ❌ | — | — | Filter by owner |
|
|
273
271
|
|
|
274
|
-
**Returns:** `Promise<
|
|
272
|
+
**Returns:** `Promise<AuthenticationItem>`
|
|
275
273
|
|
|
276
274
|
**Example:**
|
|
277
275
|
|
|
@@ -293,7 +291,7 @@ Find a unique authentication matching the criteria
|
|
|
293
291
|
| `accountId` | `string` | ❌ | — | — | Filter by account ID |
|
|
294
292
|
| `owner` | `string` | ❌ | — | — | Filter by owner |
|
|
295
293
|
|
|
296
|
-
**Returns:** `Promise<
|
|
294
|
+
**Returns:** `Promise<AuthenticationItem>`
|
|
297
295
|
|
|
298
296
|
**Example:**
|
|
299
297
|
|
|
@@ -311,7 +309,7 @@ Get a specific authentication by ID
|
|
|
311
309
|
| ------------------ | -------- | -------- | ------- | --------------- | ----------------------------- |
|
|
312
310
|
| `authenticationId` | `number` | ✅ | — | — | Authentication ID to retrieve |
|
|
313
311
|
|
|
314
|
-
**Returns:** `Promise<
|
|
312
|
+
**Returns:** `Promise<AuthenticationItem>`
|
|
315
313
|
|
|
316
314
|
**Example:**
|
|
317
315
|
|
|
@@ -327,17 +325,18 @@ List available authentications with optional filtering
|
|
|
327
325
|
|
|
328
326
|
**Parameters:**
|
|
329
327
|
|
|
330
|
-
| Name
|
|
331
|
-
|
|
|
332
|
-
| `appKey`
|
|
333
|
-
| `
|
|
334
|
-
| `
|
|
335
|
-
| `
|
|
336
|
-
| `
|
|
337
|
-
| `
|
|
338
|
-
| `
|
|
328
|
+
| Name | Type | Required | Default | Possible Values | Description |
|
|
329
|
+
| ------------------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------- |
|
|
330
|
+
| `appKey` | `string` | ❌ | — | — | App key of authentications to list (e.g., 'SlackCLIAPI') |
|
|
331
|
+
| `authenticationIds` | `array` | ❌ | — | — | List of authentication IDs to filter by |
|
|
332
|
+
| `search` | `string` | ❌ | — | — | Search term to filter authentications by title |
|
|
333
|
+
| `title` | `string` | ❌ | — | — | Filter authentications by exact title match |
|
|
334
|
+
| `accountId` | `string` | ❌ | — | — | Filter by account ID |
|
|
335
|
+
| `owner` | `string` | ❌ | — | — | Filter by owner |
|
|
336
|
+
| `pageSize` | `number` | ❌ | — | — | Number of authentications per page |
|
|
337
|
+
| `maxItems` | `number` | ❌ | — | — | Maximum total items to return across all pages |
|
|
339
338
|
|
|
340
|
-
**Returns:** `Promise<PaginatedResult<
|
|
339
|
+
**Returns:** `Promise<PaginatedResult<AuthenticationItem>>`
|
|
341
340
|
|
|
342
341
|
**Example:**
|
|
343
342
|
|
|
@@ -374,26 +373,4 @@ const result = await sdk.request({
|
|
|
374
373
|
});
|
|
375
374
|
```
|
|
376
375
|
|
|
377
|
-
### Utilities
|
|
378
|
-
|
|
379
|
-
#### `lockVersion`
|
|
380
|
-
|
|
381
|
-
Execute lockVersion
|
|
382
|
-
|
|
383
|
-
**Parameters:**
|
|
384
|
-
|
|
385
|
-
| Name | Type | Required | Default | Possible Values | Description |
|
|
386
|
-
| -------- | -------- | -------- | ------- | --------------- | -------------------------------------------------------- |
|
|
387
|
-
| `appKey` | `string` | ✅ | — | — | The app key to lock version for (e.g., 'slack', 'gmail') |
|
|
388
|
-
|
|
389
|
-
**Returns:** `Promise<any>`
|
|
390
|
-
|
|
391
|
-
**Example:**
|
|
392
|
-
|
|
393
|
-
```typescript
|
|
394
|
-
const result = await sdk.lockVersion({
|
|
395
|
-
appKey: "example-key",
|
|
396
|
-
});
|
|
397
|
-
```
|
|
398
|
-
|
|
399
376
|
<!-- End Generated API Reference -->
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAycjB,eAAO,MAAM,eAAe,GAAI,SAAS,gBAAgB,KAAG,SAqB3D,CAAC"}
|
package/dist/api/client.js
CHANGED
|
@@ -167,6 +167,20 @@ class ZapierApiClient {
|
|
|
167
167
|
if (this.isApiErrorArray(data.errors)) {
|
|
168
168
|
return data.errors[0].detail || data.errors[0].title;
|
|
169
169
|
}
|
|
170
|
+
else if (data.errors.length > 0) {
|
|
171
|
+
// Handle simple string errors array
|
|
172
|
+
const firstError = data.errors[0];
|
|
173
|
+
if (typeof firstError === "string") {
|
|
174
|
+
return firstError;
|
|
175
|
+
}
|
|
176
|
+
// For non-string errors, stringify them
|
|
177
|
+
try {
|
|
178
|
+
return JSON.stringify(firstError);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return String(firstError);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
170
184
|
}
|
|
171
185
|
}
|
|
172
186
|
return undefined;
|
package/dist/api/debug.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { DebugLogger } from "./types";
|
|
8
8
|
export declare function createDebugLogger(enabled: boolean): DebugLogger;
|
|
9
|
+
export declare function censorHeaders(headers?: HeadersInit): Record<string, string> | undefined;
|
|
9
10
|
export declare function createDebugFetch(options: {
|
|
10
11
|
originalFetch: typeof globalThis.fetch;
|
|
11
12
|
debugLog: DebugLogger;
|
package/dist/api/debug.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/api/debug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAQ/D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,aAAa,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACvC,QAAQ,EAAE,WAAW,CAAC;CACvB,IAEe,OAAO,WAAW,GAAG,GAAG,EAAE,UAAU,WAAW,uBA0C9D"}
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/api/debug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAQ/D;AAED,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAwCpC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,aAAa,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACvC,QAAQ,EAAE,WAAW,CAAC;CACvB,IAEe,OAAO,WAAW,GAAG,GAAG,EAAE,UAAU,WAAW,uBA0C9D"}
|
package/dist/api/debug.js
CHANGED
|
@@ -12,6 +12,47 @@ export function createDebugLogger(enabled) {
|
|
|
12
12
|
console.log(`[Zapier SDK] ${message}`, data || "");
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
export function censorHeaders(headers) {
|
|
16
|
+
if (!headers)
|
|
17
|
+
return headers;
|
|
18
|
+
const headersObj = new Headers(headers);
|
|
19
|
+
const authKeys = ["authorization", "x-api-key"];
|
|
20
|
+
for (const [key, value] of headersObj.entries()) {
|
|
21
|
+
if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
|
|
22
|
+
// Find space after prefix (like "Bearer ")
|
|
23
|
+
const spaceIndex = value.indexOf(" ");
|
|
24
|
+
if (spaceIndex > 0 && spaceIndex < value.length - 1) {
|
|
25
|
+
const prefix = value.substring(0, spaceIndex + 1); // Include the space
|
|
26
|
+
const token = value.substring(spaceIndex + 1);
|
|
27
|
+
if (token.length > 12) {
|
|
28
|
+
// Show first 4 and last 4 chars, truncate middle
|
|
29
|
+
const start = token.substring(0, 4);
|
|
30
|
+
const end = token.substring(token.length - 4);
|
|
31
|
+
headersObj.set(key, `${prefix}${start}...${end}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// Short token, use first character + three dots
|
|
35
|
+
const firstChar = token.charAt(0);
|
|
36
|
+
headersObj.set(key, `${prefix}${firstChar}...`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// No prefix found, truncate the whole value
|
|
41
|
+
if (value.length > 12) {
|
|
42
|
+
const start = value.substring(0, 4);
|
|
43
|
+
const end = value.substring(value.length - 4);
|
|
44
|
+
headersObj.set(key, `${start}...${end}`);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// Short token, use first character + three dots
|
|
48
|
+
const firstChar = value.charAt(0);
|
|
49
|
+
headersObj.set(key, `${firstChar}...`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return Object.fromEntries(headersObj);
|
|
55
|
+
}
|
|
15
56
|
export function createDebugFetch(options) {
|
|
16
57
|
const { originalFetch, debugLog } = options;
|
|
17
58
|
return async (input, options) => {
|
|
@@ -20,7 +61,7 @@ export function createDebugFetch(options) {
|
|
|
20
61
|
const url = typeof input === "string" ? input : input.toString();
|
|
21
62
|
const method = options?.method || "GET";
|
|
22
63
|
debugLog(`→ ${method} ${url}`, {
|
|
23
|
-
headers: options?.headers,
|
|
64
|
+
headers: censorHeaders(options?.headers),
|
|
24
65
|
body: options?.body && typeof options.body === "string"
|
|
25
66
|
? (() => {
|
|
26
67
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.test.d.ts","sourceRoot":"","sources":["../../src/api/debug.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { censorHeaders } from "./debug";
|
|
3
|
+
describe("censorHeaders", () => {
|
|
4
|
+
it("should return undefined for undefined headers", () => {
|
|
5
|
+
expect(censorHeaders(undefined)).toBeUndefined();
|
|
6
|
+
});
|
|
7
|
+
it("should return headers unchanged for non-auth headers", () => {
|
|
8
|
+
const headers = {
|
|
9
|
+
"Content-Type": "application/json",
|
|
10
|
+
"User-Agent": "test",
|
|
11
|
+
};
|
|
12
|
+
const result = censorHeaders(headers);
|
|
13
|
+
// Headers API normalizes header names to lowercase
|
|
14
|
+
expect(result["content-type"]).toBe("application/json");
|
|
15
|
+
expect(result["user-agent"]).toBe("test");
|
|
16
|
+
});
|
|
17
|
+
it("should censor authorization header with Bearer prefix - long token", () => {
|
|
18
|
+
const headers = { authorization: "Bearer abcdef1234567890xyz" };
|
|
19
|
+
const result = censorHeaders(headers);
|
|
20
|
+
expect(result.authorization).toBe("Bearer abcd...0xyz");
|
|
21
|
+
});
|
|
22
|
+
it("should censor authorization header with Bearer prefix - short token", () => {
|
|
23
|
+
const headers = { authorization: "Bearer short123" };
|
|
24
|
+
const result = censorHeaders(headers);
|
|
25
|
+
expect(result.authorization).toBe("Bearer s...");
|
|
26
|
+
});
|
|
27
|
+
it("should censor x-api-key header - long token", () => {
|
|
28
|
+
const headers = { "x-api-key": "sk-1234567890abcdefghij" };
|
|
29
|
+
const result = censorHeaders(headers);
|
|
30
|
+
expect(result["x-api-key"]).toBe("sk-1...ghij");
|
|
31
|
+
});
|
|
32
|
+
it("should censor x-api-key header - short token", () => {
|
|
33
|
+
const headers = { "x-api-key": "short" };
|
|
34
|
+
const result = censorHeaders(headers);
|
|
35
|
+
expect(result["x-api-key"]).toBe("s...");
|
|
36
|
+
});
|
|
37
|
+
it("should handle Headers object input", () => {
|
|
38
|
+
const headers = new Headers();
|
|
39
|
+
headers.set("authorization", "Bearer verylongtoken123456789");
|
|
40
|
+
const result = censorHeaders(headers);
|
|
41
|
+
expect(result.authorization).toBe("Bearer very...6789");
|
|
42
|
+
});
|
|
43
|
+
it("should handle mixed case authorization headers", () => {
|
|
44
|
+
const headers = { Authorization: "Bearer mixedcasetoken123" };
|
|
45
|
+
const result = censorHeaders(headers);
|
|
46
|
+
expect(result.authorization).toBe("Bearer mixe...n123");
|
|
47
|
+
});
|
|
48
|
+
it("should preserve non-auth headers while censoring auth headers", () => {
|
|
49
|
+
const headers = {
|
|
50
|
+
"Content-Type": "application/json",
|
|
51
|
+
authorization: "Bearer shouldbecensored123456789",
|
|
52
|
+
"User-Agent": "test-agent",
|
|
53
|
+
};
|
|
54
|
+
const result = censorHeaders(headers);
|
|
55
|
+
expect(result["content-type"]).toBe("application/json");
|
|
56
|
+
expect(result["user-agent"]).toBe("test-agent");
|
|
57
|
+
expect(result.authorization).toBe("Bearer shou...6789");
|
|
58
|
+
});
|
|
59
|
+
});
|