@zapier/zapier-sdk 0.9.0 → 0.11.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 +7 -7
- 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 +968 -582
- package/dist/index.d.mts +2537 -2229
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.mjs +966 -576
- 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.map +1 -1
- package/dist/plugins/getApp/index.js +8 -0
- package/dist/plugins/getApp/index.test.js +2 -2
- 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/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.map +1 -1
- package/dist/plugins/listActions/index.js +9 -0
- 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.map +1 -1
- package/dist/plugins/listApps/index.js +4 -0
- package/dist/plugins/listApps/index.test.js +1 -1
- 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.map +1 -1
- package/dist/plugins/listAuthentications/index.js +8 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +5 -3
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- 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 +4 -4
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +71 -5
- package/dist/plugins/listInputFields/index.test.js +5 -9
- package/dist/plugins/listInputFields/schemas.d.ts +8 -6
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- 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 +47 -0
- package/dist/resolvers/inputs.d.ts +13 -4
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/resolvers/inputs.js +36 -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 +112 -97
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +63 -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 +11 -4
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/domain.d.ts +17 -1
- package/dist/types/domain.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +5 -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 +5 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/domain-utils.d.ts +1 -16
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +7 -51
- 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/dist/utils/string-utils.d.ts +12 -0
- package/dist/utils/string-utils.d.ts.map +1 -0
- package/dist/utils/string-utils.js +23 -0
- package/dist/utils/string-utils.test.d.ts +2 -0
- package/dist/utils/string-utils.test.d.ts.map +1 -0
- package/dist/utils/string-utils.test.js +36 -0
- 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 +4 -5
- 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 +2 -2
- package/src/plugins/getApp/index.ts +8 -0
- package/src/plugins/getApp/schemas.ts +7 -12
- 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.ts +9 -0
- package/src/plugins/listActions/schemas.ts +20 -25
- package/src/plugins/listApps/index.test.ts +1 -1
- package/src/plugins/listApps/index.ts +4 -0
- package/src/plugins/listApps/schemas.ts +17 -26
- package/src/plugins/listAuthentications/index.ts +8 -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 +89 -11
- package/src/plugins/listInputFields/schemas.ts +6 -3
- 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 +70 -0
- package/src/resolvers/inputs.ts +51 -7
- 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 +97 -60
- package/src/schemas/Run.ts +40 -0
- package/src/schemas/UserProfile.ts +24 -7
- package/src/sdk.ts +17 -7
- package/src/types/domain.ts +24 -1
- package/src/types/plugin.ts +5 -0
- package/src/types/sdk.ts +5 -0
- package/src/utils/domain-utils.ts +9 -67
- package/src/utils/schema-utils.ts +96 -44
- package/src/utils/string-utils.test.ts +45 -0
- package/src/utils/string-utils.ts +26 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { censorHeaders } from "./debug";
|
|
3
|
+
|
|
4
|
+
describe("censorHeaders", () => {
|
|
5
|
+
it("should return undefined for undefined headers", () => {
|
|
6
|
+
expect(censorHeaders(undefined)).toBeUndefined();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should return headers unchanged for non-auth headers", () => {
|
|
10
|
+
const headers = {
|
|
11
|
+
"Content-Type": "application/json",
|
|
12
|
+
"User-Agent": "test",
|
|
13
|
+
};
|
|
14
|
+
const result = censorHeaders(headers);
|
|
15
|
+
// Headers API normalizes header names to lowercase
|
|
16
|
+
expect(result!["content-type"]).toBe("application/json");
|
|
17
|
+
expect(result!["user-agent"]).toBe("test");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should censor authorization header with Bearer prefix - long token", () => {
|
|
21
|
+
const headers = { authorization: "Bearer abcdef1234567890xyz" };
|
|
22
|
+
const result = censorHeaders(headers);
|
|
23
|
+
|
|
24
|
+
expect(result!.authorization).toBe("Bearer abcd...0xyz");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should censor authorization header with Bearer prefix - short token", () => {
|
|
28
|
+
const headers = { authorization: "Bearer short123" };
|
|
29
|
+
const result = censorHeaders(headers);
|
|
30
|
+
|
|
31
|
+
expect(result!.authorization).toBe("Bearer s...");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should censor x-api-key header - long token", () => {
|
|
35
|
+
const headers = { "x-api-key": "sk-1234567890abcdefghij" };
|
|
36
|
+
const result = censorHeaders(headers);
|
|
37
|
+
|
|
38
|
+
expect(result!["x-api-key"]).toBe("sk-1...ghij");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should censor x-api-key header - short token", () => {
|
|
42
|
+
const headers = { "x-api-key": "short" };
|
|
43
|
+
const result = censorHeaders(headers);
|
|
44
|
+
|
|
45
|
+
expect(result!["x-api-key"]).toBe("s...");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should handle Headers object input", () => {
|
|
49
|
+
const headers = new Headers();
|
|
50
|
+
headers.set("authorization", "Bearer verylongtoken123456789");
|
|
51
|
+
|
|
52
|
+
const result = censorHeaders(headers);
|
|
53
|
+
expect(result!.authorization).toBe("Bearer very...6789");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should handle mixed case authorization headers", () => {
|
|
57
|
+
const headers = { Authorization: "Bearer mixedcasetoken123" };
|
|
58
|
+
const result = censorHeaders(headers);
|
|
59
|
+
|
|
60
|
+
expect(result!.authorization).toBe("Bearer mixe...n123");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should preserve non-auth headers while censoring auth headers", () => {
|
|
64
|
+
const headers = {
|
|
65
|
+
"Content-Type": "application/json",
|
|
66
|
+
authorization: "Bearer shouldbecensored123456789",
|
|
67
|
+
"User-Agent": "test-agent",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const result = censorHeaders(headers);
|
|
71
|
+
|
|
72
|
+
expect(result!["content-type"]).toBe("application/json");
|
|
73
|
+
expect(result!["user-agent"]).toBe("test-agent");
|
|
74
|
+
expect(result!.authorization).toBe("Bearer shou...6789");
|
|
75
|
+
});
|
|
76
|
+
});
|
package/src/api/debug.ts
CHANGED
|
@@ -12,11 +12,55 @@ export function createDebugLogger(enabled: boolean): DebugLogger {
|
|
|
12
12
|
return () => {}; // No-op function when debug is disabled
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
return (message: string, data?:
|
|
15
|
+
return (message: string, data?: unknown) => {
|
|
16
16
|
console.log(`[Zapier SDK] ${message}`, data || "");
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export function censorHeaders(
|
|
21
|
+
headers?: HeadersInit,
|
|
22
|
+
): Record<string, string> | undefined {
|
|
23
|
+
if (!headers) return headers;
|
|
24
|
+
|
|
25
|
+
const headersObj = new Headers(headers);
|
|
26
|
+
const authKeys = ["authorization", "x-api-key"];
|
|
27
|
+
|
|
28
|
+
for (const [key, value] of headersObj.entries()) {
|
|
29
|
+
if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
|
|
30
|
+
// Find space after prefix (like "Bearer ")
|
|
31
|
+
const spaceIndex = value.indexOf(" ");
|
|
32
|
+
if (spaceIndex > 0 && spaceIndex < value.length - 1) {
|
|
33
|
+
const prefix = value.substring(0, spaceIndex + 1); // Include the space
|
|
34
|
+
const token = value.substring(spaceIndex + 1);
|
|
35
|
+
|
|
36
|
+
if (token.length > 12) {
|
|
37
|
+
// Show first 4 and last 4 chars, truncate middle
|
|
38
|
+
const start = token.substring(0, 4);
|
|
39
|
+
const end = token.substring(token.length - 4);
|
|
40
|
+
headersObj.set(key, `${prefix}${start}...${end}`);
|
|
41
|
+
} else {
|
|
42
|
+
// Short token, use first character + three dots
|
|
43
|
+
const firstChar = token.charAt(0);
|
|
44
|
+
headersObj.set(key, `${prefix}${firstChar}...`);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
// No prefix found, truncate the whole value
|
|
48
|
+
if (value.length > 12) {
|
|
49
|
+
const start = value.substring(0, 4);
|
|
50
|
+
const end = value.substring(value.length - 4);
|
|
51
|
+
headersObj.set(key, `${start}...${end}`);
|
|
52
|
+
} else {
|
|
53
|
+
// Short token, use first character + three dots
|
|
54
|
+
const firstChar = value.charAt(0);
|
|
55
|
+
headersObj.set(key, `${firstChar}...`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return Object.fromEntries(headersObj);
|
|
62
|
+
}
|
|
63
|
+
|
|
20
64
|
export function createDebugFetch(options: {
|
|
21
65
|
originalFetch: typeof globalThis.fetch;
|
|
22
66
|
debugLog: DebugLogger;
|
|
@@ -30,7 +74,7 @@ export function createDebugFetch(options: {
|
|
|
30
74
|
const method = options?.method || "GET";
|
|
31
75
|
|
|
32
76
|
debugLog(`→ ${method} ${url}`, {
|
|
33
|
-
headers: options?.headers,
|
|
77
|
+
headers: censorHeaders(options?.headers),
|
|
34
78
|
body:
|
|
35
79
|
options?.body && typeof options.body === "string"
|
|
36
80
|
? (() => {
|
package/src/api/schemas.ts
CHANGED
|
@@ -118,7 +118,7 @@ export const FieldSchema = z.object({
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
export const ActionExecutionResultSchema = z.object({
|
|
121
|
-
data: z.array(z.
|
|
121
|
+
data: z.array(z.unknown()),
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
export const ActionFieldChoiceSchema = z.object({
|
|
@@ -217,9 +217,9 @@ export const UserProfileSchema = z.object({
|
|
|
217
217
|
enable_totp_2fa: z.boolean(),
|
|
218
218
|
viewed_help: z.record(z.boolean()),
|
|
219
219
|
show_editor_migration_mesaging: z.boolean(),
|
|
220
|
-
switches: z.record(z.
|
|
221
|
-
organizations: z.array(z.
|
|
222
|
-
primary_organization: z.
|
|
220
|
+
switches: z.record(z.unknown()),
|
|
221
|
+
organizations: z.array(z.record(z.unknown()).nullable()),
|
|
222
|
+
primary_organization: z.record(z.unknown()).nullable(),
|
|
223
223
|
has_active_zaps: z.boolean(),
|
|
224
224
|
has_google_sso: z.boolean(),
|
|
225
225
|
auth_realm: z.string(),
|
|
@@ -236,7 +236,7 @@ export const AppSchema = z.object({
|
|
|
236
236
|
api_docs_url: z.string().nullable().optional(),
|
|
237
237
|
app_profile_url: z.string(),
|
|
238
238
|
banner: z.string().optional(),
|
|
239
|
-
categories: z.array(z.
|
|
239
|
+
categories: z.array(z.string()).optional(), // Service category names
|
|
240
240
|
canonical_id: z.string().optional(),
|
|
241
241
|
current_implementation_id: z.string(),
|
|
242
242
|
days_since_last_update: z.string().optional(),
|
|
@@ -294,7 +294,7 @@ export const NeedsRequestSchema = z.object({
|
|
|
294
294
|
action: z.string(),
|
|
295
295
|
type_of: z.string(),
|
|
296
296
|
authentication_id: z.number().optional(),
|
|
297
|
-
params: z.record(z.
|
|
297
|
+
params: z.record(z.unknown()).optional(),
|
|
298
298
|
});
|
|
299
299
|
|
|
300
300
|
export const NeedsResponseSchema = z.object({
|
|
@@ -341,20 +341,11 @@ export const ImplementationsResponseSchema = z.object({
|
|
|
341
341
|
// ============================================================================
|
|
342
342
|
|
|
343
343
|
export const ImplementationMetaSchema = z.object({
|
|
344
|
-
id: z.string(), // e.g. "
|
|
344
|
+
id: z.string(), // e.g. "100HiresCLIAPI@1.2.1"
|
|
345
345
|
name: z.string(),
|
|
346
346
|
slug: z.string(),
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
url_16x16: z.string().optional(),
|
|
350
|
-
url_32x32: z.string().optional(),
|
|
351
|
-
url_64x64: z.string().optional(),
|
|
352
|
-
url_128x128: z.string().optional(),
|
|
353
|
-
})
|
|
354
|
-
.optional(),
|
|
355
|
-
// Include other fields for completeness but we'll only use what we need
|
|
356
|
-
ageInDays: z.union([z.string(), z.number()]).optional(),
|
|
357
|
-
authType: z.string().nullable().optional(),
|
|
347
|
+
age_in_days: z.number().optional(),
|
|
348
|
+
auth_type: z.string().optional(),
|
|
358
349
|
banner: z.string().optional(),
|
|
359
350
|
categories: z
|
|
360
351
|
.array(
|
|
@@ -365,18 +356,49 @@ export const ImplementationMetaSchema = z.object({
|
|
|
365
356
|
}),
|
|
366
357
|
)
|
|
367
358
|
.optional(),
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
isUpcoming: z.boolean().optional(),
|
|
359
|
+
images: z
|
|
360
|
+
.object({
|
|
361
|
+
url_16x16: z.string().optional(),
|
|
362
|
+
url_32x32: z.string().optional(),
|
|
363
|
+
url_64x64: z.string().optional(),
|
|
364
|
+
url_128x128: z.string().optional(),
|
|
365
|
+
})
|
|
366
|
+
.optional(),
|
|
377
367
|
popularity: z.number().optional(),
|
|
378
|
-
|
|
368
|
+
has_filters: z.boolean().optional(),
|
|
369
|
+
has_reads: z.boolean().optional(),
|
|
370
|
+
has_searches: z.boolean().optional(),
|
|
371
|
+
has_searches_or_writes: z.boolean().optional(),
|
|
372
|
+
has_upfront_fields: z.boolean().optional(),
|
|
373
|
+
has_writes: z.boolean().optional(),
|
|
374
|
+
is_beta: z.boolean().optional(),
|
|
375
|
+
is_built_in: z.boolean().optional(),
|
|
376
|
+
is_deprecated: z.boolean().optional(),
|
|
377
|
+
is_featured: z.boolean().optional(),
|
|
378
|
+
is_hidden: z.boolean().optional(),
|
|
379
|
+
is_invite: z.boolean().optional(),
|
|
380
|
+
is_premium: z.boolean().optional(),
|
|
381
|
+
is_public: z.boolean().optional(),
|
|
382
|
+
is_upcoming: z.boolean().optional(),
|
|
383
|
+
version: z.string().optional(),
|
|
384
|
+
visibility: z.string().optional(),
|
|
385
|
+
actions: z
|
|
386
|
+
.object({
|
|
387
|
+
read: z.number().optional(),
|
|
388
|
+
read_bulk: z.number().optional(),
|
|
389
|
+
write: z.number().optional(),
|
|
390
|
+
search: z.number().optional(),
|
|
391
|
+
search_or_write: z.number().optional(),
|
|
392
|
+
search_and_write: z.number().optional(),
|
|
393
|
+
filter: z.number().optional(),
|
|
394
|
+
})
|
|
395
|
+
.optional(),
|
|
396
|
+
description: z.string().optional(),
|
|
397
|
+
primary_color: z.string().optional(),
|
|
398
|
+
secondary_color: z.string().optional(),
|
|
379
399
|
classification: z.string().optional(),
|
|
400
|
+
api_docs_url: z.string().optional(),
|
|
401
|
+
image: z.string().optional(),
|
|
380
402
|
});
|
|
381
403
|
|
|
382
404
|
export const ImplementationsMetaResponseSchema = z.object({
|
|
@@ -413,7 +435,7 @@ export const NeedChoicesRequestSchema = z.object({
|
|
|
413
435
|
"If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared).",
|
|
414
436
|
),
|
|
415
437
|
params: z
|
|
416
|
-
.record(z.
|
|
438
|
+
.record(z.unknown())
|
|
417
439
|
.optional()
|
|
418
440
|
.describe(
|
|
419
441
|
"Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action.",
|
package/src/index.ts
CHANGED
|
@@ -38,16 +38,15 @@ export type {
|
|
|
38
38
|
} from "./api/types";
|
|
39
39
|
|
|
40
40
|
// Export schema utilities for CLI
|
|
41
|
-
export { isPositional } from "./utils/schema-utils";
|
|
42
|
-
export { hasResolver } from "./resolvers";
|
|
41
|
+
export { isPositional, PositionalMetadata } from "./utils/schema-utils";
|
|
43
42
|
export { createFunction } from "./utils/function-utils";
|
|
44
43
|
|
|
44
|
+
// Export resolver utilities for CLI
|
|
45
|
+
export * from "./resolvers";
|
|
46
|
+
|
|
45
47
|
// Export auth utilities for CLI use
|
|
46
48
|
export * from "./auth";
|
|
47
49
|
|
|
48
|
-
// Export resolvers for CLI use
|
|
49
|
-
export * from "./resolvers";
|
|
50
|
-
|
|
51
50
|
// All functions now available through the plugin system via createZapierSdk()
|
|
52
51
|
// Export plugin schemas for external use
|
|
53
52
|
export {
|
|
@@ -132,17 +132,20 @@ describe("findFirstAuthentication plugin", () => {
|
|
|
132
132
|
expect(result.data).toEqual(mockAuth);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
it("should
|
|
135
|
+
it("should throw error when no authentications found", async () => {
|
|
136
136
|
mockListAuthentications.mockResolvedValue({
|
|
137
137
|
data: [],
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
const sdk = createTestSdk();
|
|
141
|
-
const result = await sdk.findFirstAuthentication({
|
|
142
|
-
appKey: "nonexistent",
|
|
143
|
-
});
|
|
144
141
|
|
|
145
|
-
expect(
|
|
142
|
+
await expect(
|
|
143
|
+
sdk.findFirstAuthentication({
|
|
144
|
+
appKey: "nonexistent",
|
|
145
|
+
}),
|
|
146
|
+
).rejects.toThrow(
|
|
147
|
+
"No authentication found matching the specified criteria",
|
|
148
|
+
);
|
|
146
149
|
});
|
|
147
150
|
|
|
148
151
|
it("should return first authentication when multiple found", async () => {
|
|
@@ -6,11 +6,13 @@ import {
|
|
|
6
6
|
} from "./schemas";
|
|
7
7
|
import { createFunction } from "../../utils/function-utils";
|
|
8
8
|
import type { ListAuthenticationsPluginProvides } from "../listAuthentications";
|
|
9
|
+
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
10
|
+
import { ZapierResourceNotFoundError } from "../../types/errors";
|
|
9
11
|
|
|
10
12
|
export interface FindFirstAuthenticationPluginProvides {
|
|
11
13
|
findFirstAuthentication: (
|
|
12
14
|
options?: FindFirstAuthenticationOptions,
|
|
13
|
-
) => Promise<{ data: AuthenticationItem
|
|
15
|
+
) => Promise<{ data: AuthenticationItem }>;
|
|
14
16
|
context: {
|
|
15
17
|
meta: {
|
|
16
18
|
findFirstAuthentication: {
|
|
@@ -35,8 +37,15 @@ export const findFirstAuthenticationPlugin: Plugin<
|
|
|
35
37
|
maxItems: 1,
|
|
36
38
|
});
|
|
37
39
|
|
|
40
|
+
if (authsResponse.data.length === 0) {
|
|
41
|
+
throw new ZapierResourceNotFoundError(
|
|
42
|
+
"No authentication found matching the specified criteria",
|
|
43
|
+
{ resourceType: "Authentication" },
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
return {
|
|
39
|
-
data: authsResponse.data
|
|
48
|
+
data: authsResponse.data[0],
|
|
40
49
|
};
|
|
41
50
|
},
|
|
42
51
|
FindFirstAuthenticationSchema,
|
|
@@ -48,7 +57,10 @@ export const findFirstAuthenticationPlugin: Plugin<
|
|
|
48
57
|
meta: {
|
|
49
58
|
findFirstAuthentication: {
|
|
50
59
|
categories: ["authentication"],
|
|
60
|
+
type: "item",
|
|
61
|
+
itemType: "Authentication",
|
|
51
62
|
inputSchema: FindFirstAuthenticationSchema,
|
|
63
|
+
outputSchema: AuthenticationItemSchema,
|
|
52
64
|
},
|
|
53
65
|
},
|
|
54
66
|
},
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "../../types/errors";
|
|
11
11
|
import { createFunction } from "../../utils/function-utils";
|
|
12
12
|
import type { ListAuthenticationsPluginProvides } from "../listAuthentications";
|
|
13
|
+
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
13
14
|
|
|
14
15
|
export interface FindUniqueAuthenticationPluginProvides {
|
|
15
16
|
findUniqueAuthentication: (
|
|
@@ -65,7 +66,10 @@ export const findUniqueAuthenticationPlugin: Plugin<
|
|
|
65
66
|
meta: {
|
|
66
67
|
findUniqueAuthentication: {
|
|
67
68
|
categories: ["authentication"],
|
|
69
|
+
type: "item",
|
|
70
|
+
itemType: "Authentication",
|
|
68
71
|
inputSchema: FindUniqueAuthenticationSchema,
|
|
72
|
+
outputSchema: AuthenticationItemSchema,
|
|
69
73
|
},
|
|
70
74
|
},
|
|
71
75
|
},
|
|
@@ -5,6 +5,12 @@ import { GetActionSchema, type GetActionOptions } from "./schemas";
|
|
|
5
5
|
import { ZapierResourceNotFoundError } from "../../types/errors";
|
|
6
6
|
import { createFunction } from "../../utils/function-utils";
|
|
7
7
|
import type { ListActionsPluginProvides } from "../listActions";
|
|
8
|
+
import {
|
|
9
|
+
appKeyResolver,
|
|
10
|
+
actionTypeResolver,
|
|
11
|
+
actionKeyResolver,
|
|
12
|
+
} from "../../resolvers";
|
|
13
|
+
import { ActionItemSchema } from "../../schemas/Action";
|
|
8
14
|
|
|
9
15
|
export interface GetActionPluginProvides {
|
|
10
16
|
getAction: (options: GetActionOptions) => Promise<{ data: ActionItem }>;
|
|
@@ -50,7 +56,15 @@ export const getActionPlugin: Plugin<
|
|
|
50
56
|
meta: {
|
|
51
57
|
getAction: {
|
|
52
58
|
categories: ["action"],
|
|
59
|
+
type: "item",
|
|
60
|
+
itemType: "Action",
|
|
53
61
|
inputSchema: GetActionSchema,
|
|
62
|
+
outputSchema: ActionItemSchema,
|
|
63
|
+
resolvers: {
|
|
64
|
+
appKey: appKeyResolver,
|
|
65
|
+
actionType: actionTypeResolver,
|
|
66
|
+
actionKey: actionKeyResolver,
|
|
67
|
+
},
|
|
54
68
|
},
|
|
55
69
|
},
|
|
56
70
|
},
|
|
@@ -72,7 +72,7 @@ describe("getApp plugin", () => {
|
|
|
72
72
|
|
|
73
73
|
expect(result.data.title).toBe("Slack");
|
|
74
74
|
expect(result.data.key).toBe("SlackCLIAPI");
|
|
75
|
-
expect(result.data.
|
|
75
|
+
expect(result.data.implementation_id).toBe("SlackCLIAPI@1.0.0");
|
|
76
76
|
expect(result.data.version).toBe("1.0.0");
|
|
77
77
|
});
|
|
78
78
|
});
|
|
@@ -121,7 +121,7 @@ describe("getApp plugin", () => {
|
|
|
121
121
|
|
|
122
122
|
expect(result.data.title).toBeDefined();
|
|
123
123
|
expect(result.data.key).toBeDefined();
|
|
124
|
-
expect(result.data.
|
|
124
|
+
expect(result.data.implementation_id).toBeDefined();
|
|
125
125
|
expect(result.data.title).toBe("Test App");
|
|
126
126
|
expect(result.data.key).toBe("TestCLIAPI");
|
|
127
127
|
});
|
|
@@ -3,9 +3,11 @@ import { createFunction } from "../../utils/function-utils";
|
|
|
3
3
|
import { GetAppSchema } from "./schemas";
|
|
4
4
|
import type { GetAppOptions } from "./schemas";
|
|
5
5
|
import type { AppItem } from "../../types/domain";
|
|
6
|
+
import { AppItemSchema } from "../../schemas/App";
|
|
6
7
|
import { ZapierAppNotFoundError } from "../../types/errors";
|
|
7
8
|
import type { GetSdkType } from "../../types/plugin";
|
|
8
9
|
import type { ListAppsPluginProvides } from "../listApps";
|
|
10
|
+
import { appKeyResolver } from "../../resolvers";
|
|
9
11
|
|
|
10
12
|
// GetApp plugin provides interface - getApp goes directly to SDK root
|
|
11
13
|
export interface GetAppPluginProvides {
|
|
@@ -44,7 +46,13 @@ export const getAppPlugin: Plugin<
|
|
|
44
46
|
meta: {
|
|
45
47
|
getApp: {
|
|
46
48
|
categories: ["app"],
|
|
49
|
+
type: "item",
|
|
50
|
+
itemType: "App",
|
|
47
51
|
inputSchema: GetAppSchema,
|
|
52
|
+
outputSchema: AppItemSchema,
|
|
53
|
+
resolvers: {
|
|
54
|
+
appKey: appKeyResolver,
|
|
55
|
+
},
|
|
48
56
|
},
|
|
49
57
|
},
|
|
50
58
|
},
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AppKeyPropertySchema } from "../../types/properties";
|
|
3
|
-
import { withOutputSchema } from "../../utils/schema-utils";
|
|
4
|
-
import { AppItemSchema } from "../../schemas/App";
|
|
5
3
|
import type { AppItem } from "../../types/domain";
|
|
6
4
|
import type {
|
|
7
5
|
ZapierApiError,
|
|
@@ -18,16 +16,13 @@ export type GetAppError =
|
|
|
18
16
|
| ZapierValidationError;
|
|
19
17
|
|
|
20
18
|
// Pure Zod schema - no resolver metadata!
|
|
21
|
-
export const GetAppSchema =
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.describe("Get detailed information about a specific app"),
|
|
29
|
-
AppItemSchema,
|
|
30
|
-
);
|
|
19
|
+
export const GetAppSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
appKey: AppKeyPropertySchema.describe(
|
|
22
|
+
"App key of app to fetch (e.g., 'SlackCLIAPI')",
|
|
23
|
+
),
|
|
24
|
+
})
|
|
25
|
+
.describe("Get detailed information about a specific app");
|
|
31
26
|
|
|
32
27
|
// Type inferred from schema
|
|
33
28
|
export type GetAppOptions = z.infer<typeof GetAppSchema>;
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
} from "../../types/errors";
|
|
13
13
|
import { createFunction } from "../../utils/function-utils";
|
|
14
14
|
import { normalizeAuthenticationItem } from "../../utils/domain-utils";
|
|
15
|
+
import { authenticationIdGenericResolver } from "../../resolvers";
|
|
16
|
+
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
15
17
|
|
|
16
18
|
export interface GetAuthenticationPluginProvides {
|
|
17
19
|
getAuthentication: (
|
|
@@ -79,7 +81,13 @@ export const getAuthenticationPlugin: Plugin<
|
|
|
79
81
|
meta: {
|
|
80
82
|
getAuthentication: {
|
|
81
83
|
categories: ["authentication"],
|
|
84
|
+
type: "item",
|
|
85
|
+
itemType: "Authentication",
|
|
82
86
|
inputSchema: GetAuthenticationSchema,
|
|
87
|
+
outputSchema: AuthenticationItemSchema,
|
|
88
|
+
resolvers: {
|
|
89
|
+
authenticationId: authenticationIdGenericResolver,
|
|
90
|
+
},
|
|
83
91
|
},
|
|
84
92
|
},
|
|
85
93
|
},
|
|
@@ -4,6 +4,7 @@ import { createFunction } from "../../utils/function-utils";
|
|
|
4
4
|
import type { Plugin } from "../../types/plugin";
|
|
5
5
|
import type { UserProfileItem } from "../../types/domain";
|
|
6
6
|
import { GetProfileSchema } from "./schemas";
|
|
7
|
+
import { UserProfileItemSchema } from "../../schemas/UserProfile";
|
|
7
8
|
|
|
8
9
|
// GetProfile plugin provides interface - getProfile goes directly to SDK root
|
|
9
10
|
export interface GetProfilePluginProvides {
|
|
@@ -48,7 +49,10 @@ export const getProfilePlugin: Plugin<
|
|
|
48
49
|
meta: {
|
|
49
50
|
getProfile: {
|
|
50
51
|
categories: ["account"],
|
|
52
|
+
type: "item",
|
|
53
|
+
itemType: "Profile",
|
|
51
54
|
inputSchema: GetProfileSchema,
|
|
55
|
+
outputSchema: UserProfileItemSchema,
|
|
52
56
|
},
|
|
53
57
|
},
|
|
54
58
|
},
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { withOutputSchema } from "../../utils/schema-utils";
|
|
3
|
-
import { UserProfileItemSchema } from "../../schemas/UserProfile";
|
|
4
2
|
import type { FunctionOptions } from "../../types/functions";
|
|
5
3
|
import type { UserProfileItem } from "../../types/domain";
|
|
6
4
|
import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
@@ -9,10 +7,10 @@ import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
|
9
7
|
export type GetProfileError = ZapierApiError | ZapierValidationError;
|
|
10
8
|
|
|
11
9
|
// Pure Zod schema - no resolver metadata!
|
|
12
|
-
export const GetProfileSchema =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
10
|
+
export const GetProfileSchema = z
|
|
11
|
+
.object({})
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Get current user's profile information");
|
|
16
14
|
|
|
17
15
|
// Type inferred from schema + function config
|
|
18
16
|
export type GetProfileOptions = z.infer<typeof GetProfileSchema> &
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type ListActionsOptions,
|
|
8
8
|
type ListActionsPage,
|
|
9
9
|
} from "./schemas";
|
|
10
|
+
import { ActionItemSchema } from "../../schemas/Action";
|
|
10
11
|
import {
|
|
11
12
|
ZapierConfigurationError,
|
|
12
13
|
ZapierAuthenticationError,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
15
16
|
import type { ManifestPluginProvides } from "../manifest";
|
|
16
17
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
18
|
+
import { appKeyResolver, actionTypeResolver } from "../../resolvers";
|
|
17
19
|
|
|
18
20
|
export interface ListActionsPluginProvides {
|
|
19
21
|
listActions: (options?: ListActionsOptions) => Promise<{
|
|
@@ -114,7 +116,14 @@ export const listActionsPlugin: Plugin<
|
|
|
114
116
|
meta: {
|
|
115
117
|
listActions: {
|
|
116
118
|
categories: ["action"],
|
|
119
|
+
type: "list",
|
|
120
|
+
itemType: "Action",
|
|
117
121
|
inputSchema: ListActionsSchema,
|
|
122
|
+
outputSchema: ActionItemSchema,
|
|
123
|
+
resolvers: {
|
|
124
|
+
appKey: appKeyResolver,
|
|
125
|
+
actionType: actionTypeResolver,
|
|
126
|
+
},
|
|
118
127
|
},
|
|
119
128
|
},
|
|
120
129
|
},
|
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
AppKeyPropertySchema,
|
|
4
4
|
ActionTypePropertySchema,
|
|
5
5
|
} from "../../types/properties";
|
|
6
|
-
import { withOutputSchema } from "../../utils/schema-utils";
|
|
7
|
-
import { ActionItemSchema } from "../../schemas/Action";
|
|
8
6
|
import type { ActionItem } from "../../types/domain";
|
|
9
7
|
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
10
8
|
import type {
|
|
@@ -14,29 +12,26 @@ import type {
|
|
|
14
12
|
} from "../../types/errors";
|
|
15
13
|
|
|
16
14
|
// Pure Zod schema - no resolver metadata!
|
|
17
|
-
export const ListActionsSchema =
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.describe("List all actions for a specific app"),
|
|
38
|
-
ActionItemSchema,
|
|
39
|
-
);
|
|
15
|
+
export const ListActionsSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
appKey: AppKeyPropertySchema.describe(
|
|
18
|
+
"App key of actions to list (e.g., 'SlackCLIAPI')",
|
|
19
|
+
),
|
|
20
|
+
actionType: ActionTypePropertySchema.optional().describe(
|
|
21
|
+
"Filter actions by type",
|
|
22
|
+
),
|
|
23
|
+
pageSize: z
|
|
24
|
+
.number()
|
|
25
|
+
.min(1)
|
|
26
|
+
.optional()
|
|
27
|
+
.describe("Number of actions per page"),
|
|
28
|
+
maxItems: z
|
|
29
|
+
.number()
|
|
30
|
+
.min(1)
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Maximum total items to return across all pages"),
|
|
33
|
+
})
|
|
34
|
+
.describe("List all actions for a specific app");
|
|
40
35
|
|
|
41
36
|
// Type inferred from schema
|
|
42
37
|
export type ListActionsOptions = z.infer<typeof ListActionsSchema>;
|
|
@@ -228,7 +228,7 @@ describe("listApps plugin", () => {
|
|
|
228
228
|
|
|
229
229
|
expect(result.data[0]).toHaveProperty("title");
|
|
230
230
|
expect(result.data[0]).toHaveProperty("key");
|
|
231
|
-
expect(result.data[0]).toHaveProperty("
|
|
231
|
+
expect(result.data[0]).toHaveProperty("implementation_id");
|
|
232
232
|
// Version is optional
|
|
233
233
|
expect(result.data[0]).toHaveProperty("version");
|
|
234
234
|
});
|