@zapier/zapier-sdk 0.5.1 → 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 +19 -0
- package/README.md +107 -83
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/schemas.d.ts +6 -6
- package/dist/api/types.d.ts +7 -7
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +343 -67
- package/dist/index.d.mts +416 -347
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.mjs +343 -67
- package/dist/plugins/api/index.js +1 -1
- package/dist/plugins/apps/types.d.ts +1 -1
- package/dist/plugins/apps/types.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +1 -0
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +1 -0
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +1 -0
- package/dist/plugins/getAction/index.test.js +1 -1
- package/dist/plugins/getApp/index.d.ts +6 -3
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +8 -18
- package/dist/plugins/getApp/index.test.js +2 -0
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +1 -0
- package/dist/plugins/getAuthentication/index.test.js +12 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +1 -0
- package/dist/plugins/listActions/index.d.ts +5 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +6 -6
- package/dist/plugins/listActions/index.test.js +26 -74
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +1 -0
- package/dist/plugins/listApps/schemas.d.ts +2 -2
- package/dist/plugins/listAuthentications/index.d.ts +4 -2
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +9 -12
- package/dist/plugins/listAuthentications/index.test.js +33 -40
- package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
- package/dist/plugins/listInputFields/index.d.ts +3 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +5 -5
- package/dist/plugins/listInputFields/index.test.js +10 -8
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/lockVersion/index.d.ts +24 -0
- package/dist/plugins/lockVersion/index.d.ts.map +1 -0
- package/dist/plugins/lockVersion/index.js +72 -0
- package/dist/plugins/lockVersion/index.test.d.ts +2 -0
- package/dist/plugins/lockVersion/index.test.d.ts.map +1 -0
- package/dist/plugins/lockVersion/index.test.js +129 -0
- package/dist/plugins/lockVersion/schemas.d.ts +10 -0
- package/dist/plugins/lockVersion/schemas.d.ts.map +1 -0
- package/dist/plugins/lockVersion/schemas.js +6 -0
- package/dist/plugins/manifest/index.d.ts +24 -0
- package/dist/plugins/manifest/index.d.ts.map +1 -0
- package/dist/plugins/manifest/index.js +119 -0
- package/dist/plugins/manifest/index.test.d.ts +2 -0
- package/dist/plugins/manifest/index.test.d.ts.map +1 -0
- package/dist/plugins/manifest/index.test.js +331 -0
- package/dist/plugins/manifest/schemas.d.ts +64 -0
- package/dist/plugins/manifest/schemas.d.ts.map +1 -0
- package/dist/plugins/manifest/schemas.js +25 -0
- package/dist/plugins/registry/index.d.ts +9 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +68 -3
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +1 -0
- package/dist/plugins/request/index.test.js +6 -1
- package/dist/plugins/request/schemas.d.ts +4 -4
- package/dist/plugins/runAction/index.d.ts +2 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +5 -5
- package/dist/plugins/runAction/index.test.js +9 -8
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/schemas/Auth.d.ts +4 -4
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/sdk.d.ts +3 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +18 -7
- package/dist/sdk.test.js +1 -1
- package/dist/types/errors.d.ts +6 -6
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +10 -2
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +13 -2
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/validation.test.js +2 -1
- package/package.json +2 -2
- package/src/api/client.ts +3 -3
- package/src/api/index.ts +2 -0
- package/src/api/types.ts +15 -7
- package/src/index.ts +0 -2
- package/src/plugins/api/index.ts +1 -1
- package/src/plugins/apps/types.ts +1 -1
- package/src/plugins/findFirstAuthentication/index.ts +1 -0
- package/src/plugins/findUniqueAuthentication/index.ts +1 -0
- package/src/plugins/getAction/index.test.ts +1 -1
- package/src/plugins/getAction/index.ts +1 -0
- package/src/plugins/getApp/index.test.ts +2 -0
- package/src/plugins/getApp/index.ts +12 -24
- package/src/plugins/getAuthentication/index.test.ts +13 -3
- package/src/plugins/getAuthentication/index.ts +1 -0
- package/src/plugins/getProfile/index.ts +1 -0
- package/src/plugins/listActions/index.test.ts +30 -89
- package/src/plugins/listActions/index.ts +34 -27
- package/src/plugins/listApps/index.ts +1 -0
- package/src/plugins/listAuthentications/index.test.ts +38 -47
- package/src/plugins/listAuthentications/index.ts +21 -18
- package/src/plugins/listInputFields/index.test.ts +12 -9
- package/src/plugins/listInputFields/index.ts +10 -6
- package/src/plugins/lockVersion/index.test.ts +176 -0
- package/src/plugins/lockVersion/index.ts +112 -0
- package/src/plugins/lockVersion/schemas.ts +9 -0
- package/src/plugins/manifest/index.test.ts +439 -0
- package/src/plugins/manifest/index.ts +171 -0
- package/src/plugins/manifest/schemas.ts +53 -0
- package/src/plugins/registry/index.ts +89 -8
- package/src/plugins/request/index.test.ts +8 -4
- package/src/plugins/request/index.ts +1 -0
- package/src/plugins/runAction/index.test.ts +9 -8
- package/src/plugins/runAction/index.ts +18 -9
- package/src/schemas/Field.ts +5 -2
- package/src/sdk.test.ts +1 -1
- package/src/sdk.ts +22 -7
- package/src/types/errors.ts +9 -6
- package/src/types/events.ts +1 -1
- package/src/types/plugin.ts +14 -2
- package/src/types/sdk.ts +15 -1
- package/src/utils/validation.test.ts +2 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -36,13 +36,14 @@ describe("runAction plugin", () => {
|
|
|
36
36
|
mockGetAction = vi.fn().mockResolvedValue({
|
|
37
37
|
data: mockAction,
|
|
38
38
|
});
|
|
39
|
-
mockGetApp = vi.fn().mockResolvedValue({
|
|
40
|
-
data: { current_implementation_id: "SlackCLIAPI" },
|
|
41
|
-
});
|
|
42
39
|
});
|
|
43
40
|
function createTestSdk() {
|
|
44
|
-
return createSdk({ getAction: mockGetAction, getApp: mockGetApp }, // Provide getAction and getApp in SDK
|
|
45
|
-
{
|
|
41
|
+
return createSdk({}, { getAction: mockGetAction, getApp: mockGetApp }, // Provide getAction and getApp in SDK
|
|
42
|
+
{
|
|
43
|
+
api: mockApiClient,
|
|
44
|
+
meta: {},
|
|
45
|
+
getVersionedImplementationId: () => "SlackCLIAPI@1.21.1",
|
|
46
|
+
}).addPlugin(runActionPlugin);
|
|
46
47
|
}
|
|
47
48
|
describe("schema validation", () => {
|
|
48
49
|
it("should throw validation error for missing appKey", () => {
|
|
@@ -126,7 +127,7 @@ describe("runAction plugin", () => {
|
|
|
126
127
|
});
|
|
127
128
|
expect(mockApiClient.post).toHaveBeenCalledWith("/api/actions/v1/runs", {
|
|
128
129
|
data: {
|
|
129
|
-
selected_api: "SlackCLIAPI",
|
|
130
|
+
selected_api: "SlackCLIAPI@1.21.1",
|
|
130
131
|
action_key: "send_message",
|
|
131
132
|
action_type: "write",
|
|
132
133
|
inputs: { message: "Hello", channel: "#general" },
|
|
@@ -149,7 +150,7 @@ describe("runAction plugin", () => {
|
|
|
149
150
|
});
|
|
150
151
|
expect(mockApiClient.post).toHaveBeenCalledWith("/api/actions/v1/runs", {
|
|
151
152
|
data: {
|
|
152
|
-
selected_api: "SlackCLIAPI",
|
|
153
|
+
selected_api: "SlackCLIAPI@1.21.1",
|
|
153
154
|
action_key: "send_message",
|
|
154
155
|
action_type: "write",
|
|
155
156
|
inputs: { message: "Hello" },
|
|
@@ -170,7 +171,7 @@ describe("runAction plugin", () => {
|
|
|
170
171
|
expect(mockApiClient.post).toHaveBeenCalledWith("/api/actions/v1/runs", expect.objectContaining({
|
|
171
172
|
data: expect.objectContaining({
|
|
172
173
|
inputs: { message: "Hello" },
|
|
173
|
-
selected_api: "SlackCLIAPI",
|
|
174
|
+
selected_api: "SlackCLIAPI@1.21.1",
|
|
174
175
|
action_key: "send_message",
|
|
175
176
|
action_type: "write",
|
|
176
177
|
}),
|
|
@@ -13,17 +13,17 @@ export declare const RunActionSchema: z.ZodObject<{
|
|
|
13
13
|
actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
|
|
14
14
|
actionKey: string;
|
|
15
15
|
authenticationId?: number | null | undefined;
|
|
16
|
-
maxItems?: number | undefined;
|
|
17
|
-
pageSize?: number | undefined;
|
|
18
16
|
inputs?: Record<string, any> | undefined;
|
|
17
|
+
pageSize?: number | undefined;
|
|
18
|
+
maxItems?: number | undefined;
|
|
19
19
|
}, {
|
|
20
20
|
appKey: string;
|
|
21
21
|
actionType: "filter" | "read" | "read_bulk" | "run" | "search" | "search_and_write" | "search_or_write" | "write";
|
|
22
22
|
actionKey: string;
|
|
23
23
|
authenticationId?: number | null | undefined;
|
|
24
|
-
maxItems?: number | undefined;
|
|
25
|
-
pageSize?: number | undefined;
|
|
26
24
|
inputs?: Record<string, any> | undefined;
|
|
25
|
+
pageSize?: number | undefined;
|
|
26
|
+
maxItems?: number | undefined;
|
|
27
27
|
}>;
|
|
28
28
|
export type RunActionOptions = z.infer<typeof RunActionSchema>;
|
|
29
29
|
export interface RunActionPage {
|
package/dist/schemas/Auth.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare const AuthenticationItemSchema: z.ZodObject<Omit<{
|
|
|
34
34
|
is_invite_only: boolean;
|
|
35
35
|
is_private: boolean;
|
|
36
36
|
shared_with_all: boolean;
|
|
37
|
+
url?: string | undefined;
|
|
37
38
|
title?: string | null | undefined;
|
|
38
39
|
version?: string | undefined;
|
|
39
40
|
label?: string | null | undefined;
|
|
@@ -44,7 +45,6 @@ export declare const AuthenticationItemSchema: z.ZodObject<Omit<{
|
|
|
44
45
|
is_shared?: string | undefined;
|
|
45
46
|
marked_stale_at?: string | null | undefined;
|
|
46
47
|
identifier?: string | null | undefined;
|
|
47
|
-
url?: string | undefined;
|
|
48
48
|
groups?: string | undefined;
|
|
49
49
|
members?: string | undefined;
|
|
50
50
|
user_id?: number | undefined;
|
|
@@ -59,6 +59,7 @@ export declare const AuthenticationItemSchema: z.ZodObject<Omit<{
|
|
|
59
59
|
is_invite_only: boolean;
|
|
60
60
|
is_private: boolean;
|
|
61
61
|
shared_with_all: boolean;
|
|
62
|
+
url?: string | undefined;
|
|
62
63
|
title?: string | null | undefined;
|
|
63
64
|
version?: string | undefined;
|
|
64
65
|
label?: string | null | undefined;
|
|
@@ -69,7 +70,6 @@ export declare const AuthenticationItemSchema: z.ZodObject<Omit<{
|
|
|
69
70
|
is_shared?: string | undefined;
|
|
70
71
|
marked_stale_at?: string | null | undefined;
|
|
71
72
|
identifier?: string | null | undefined;
|
|
72
|
-
url?: string | undefined;
|
|
73
73
|
groups?: string | undefined;
|
|
74
74
|
members?: string | undefined;
|
|
75
75
|
user_id?: number | undefined;
|
|
@@ -113,6 +113,7 @@ export declare const AuthItemSchema: z.ZodObject<Omit<{
|
|
|
113
113
|
is_invite_only: boolean;
|
|
114
114
|
is_private: boolean;
|
|
115
115
|
shared_with_all: boolean;
|
|
116
|
+
url?: string | undefined;
|
|
116
117
|
title?: string | null | undefined;
|
|
117
118
|
version?: string | undefined;
|
|
118
119
|
label?: string | null | undefined;
|
|
@@ -123,7 +124,6 @@ export declare const AuthItemSchema: z.ZodObject<Omit<{
|
|
|
123
124
|
is_shared?: string | undefined;
|
|
124
125
|
marked_stale_at?: string | null | undefined;
|
|
125
126
|
identifier?: string | null | undefined;
|
|
126
|
-
url?: string | undefined;
|
|
127
127
|
groups?: string | undefined;
|
|
128
128
|
members?: string | undefined;
|
|
129
129
|
user_id?: number | undefined;
|
|
@@ -138,6 +138,7 @@ export declare const AuthItemSchema: z.ZodObject<Omit<{
|
|
|
138
138
|
is_invite_only: boolean;
|
|
139
139
|
is_private: boolean;
|
|
140
140
|
shared_with_all: boolean;
|
|
141
|
+
url?: string | undefined;
|
|
141
142
|
title?: string | null | undefined;
|
|
142
143
|
version?: string | undefined;
|
|
143
144
|
label?: string | null | undefined;
|
|
@@ -148,7 +149,6 @@ export declare const AuthItemSchema: z.ZodObject<Omit<{
|
|
|
148
149
|
is_shared?: string | undefined;
|
|
149
150
|
marked_stale_at?: string | null | undefined;
|
|
150
151
|
identifier?: string | null | undefined;
|
|
151
|
-
url?: string | undefined;
|
|
152
152
|
groups?: string | undefined;
|
|
153
153
|
members?: string | undefined;
|
|
154
154
|
user_id?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/schemas/Field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/schemas/Field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkHhC,CAAC;AAMF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC"}
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseSdkOptions } from "./types/sdk";
|
|
2
2
|
import type { ZapierSdk } from "./types/sdk";
|
|
3
|
-
import type { Sdk } from "./types/plugin";
|
|
3
|
+
import type { Sdk, PluginMeta } from "./types/plugin";
|
|
4
4
|
export interface ZapierSdkOptions extends BaseSdkOptions {
|
|
5
5
|
}
|
|
6
6
|
export declare function createSdk<TCurrentSdk = {}, TCurrentContext = {
|
|
7
|
-
meta: Record<string,
|
|
8
|
-
}>(initialSdk?: TCurrentSdk, initialContext?: TCurrentContext): Sdk<TCurrentSdk, TCurrentContext>;
|
|
7
|
+
meta: Record<string, PluginMeta>;
|
|
8
|
+
}>(options?: ZapierSdkOptions, initialSdk?: TCurrentSdk, initialContext?: TCurrentContext): Sdk<TCurrentSdk, TCurrentContext>;
|
|
9
9
|
export declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
|
|
10
10
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,EAIH,UAAU,EACX,MAAM,gBAAgB,CAAC;AAyBxB,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,wBAAgB,SAAS,CACvB,WAAW,GAAG,EAAE,EAChB,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,EAEtD,OAAO,GAAE,gBAAqB,EAC9B,UAAU,GAAE,WAA+B,EAC3C,cAAc,GAAE,eAAiD,GAChE,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAqEnC;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAyCzE"}
|
package/dist/sdk.js
CHANGED
|
@@ -15,12 +15,14 @@ import { findFirstAuthenticationPlugin } from "./plugins/findFirstAuthentication
|
|
|
15
15
|
import { findUniqueAuthenticationPlugin } from "./plugins/findUniqueAuthentication";
|
|
16
16
|
import { listInputFieldsPlugin } from "./plugins/listInputFields";
|
|
17
17
|
import { requestPlugin } from "./plugins/request";
|
|
18
|
+
import { manifestPlugin } from "./plugins/manifest";
|
|
19
|
+
import { lockVersionPlugin } from "./plugins/lockVersion";
|
|
18
20
|
// Create SDK that supports flat plugins - returns an SDK, not a builder
|
|
19
|
-
export function createSdk(initialSdk = {}, initialContext = { meta: {} }) {
|
|
21
|
+
export function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} }) {
|
|
20
22
|
return {
|
|
21
23
|
...initialSdk,
|
|
22
24
|
getContext: () => initialContext,
|
|
23
|
-
addPlugin(plugin,
|
|
25
|
+
addPlugin(plugin, addPluginOptions = {}) {
|
|
24
26
|
// Create SDK with getContext method for plugins to use
|
|
25
27
|
const currentSdkWithContext = {
|
|
26
28
|
...initialSdk,
|
|
@@ -29,8 +31,12 @@ export function createSdk(initialSdk = {}, initialContext = { meta: {} }) {
|
|
|
29
31
|
// Apply the plugin with options merged in
|
|
30
32
|
const pluginResult = plugin({
|
|
31
33
|
sdk: currentSdkWithContext,
|
|
32
|
-
context:
|
|
33
|
-
|
|
34
|
+
context: {
|
|
35
|
+
...initialContext,
|
|
36
|
+
// Add the options that createSdk was called with to context
|
|
37
|
+
options,
|
|
38
|
+
},
|
|
39
|
+
...addPluginOptions,
|
|
34
40
|
});
|
|
35
41
|
// Extract context from plugin result if present
|
|
36
42
|
const { context: pluginContext, ...sdkProperties } = pluginResult;
|
|
@@ -40,6 +46,7 @@ export function createSdk(initialSdk = {}, initialContext = { meta: {} }) {
|
|
|
40
46
|
// Ensure meta is always present, starting with existing or empty object
|
|
41
47
|
let newContext = {
|
|
42
48
|
...initialContext,
|
|
49
|
+
...addPluginOptions,
|
|
43
50
|
meta: initialContext.meta || {},
|
|
44
51
|
};
|
|
45
52
|
if (pluginContext) {
|
|
@@ -61,22 +68,26 @@ export function createSdk(initialSdk = {}, initialContext = { meta: {} }) {
|
|
|
61
68
|
}
|
|
62
69
|
}
|
|
63
70
|
// Recursively create new SDK with updated properties
|
|
64
|
-
return createSdk(newSdk, newContext);
|
|
71
|
+
return createSdk(options, newSdk, newContext);
|
|
65
72
|
},
|
|
66
73
|
};
|
|
67
74
|
}
|
|
68
75
|
export function createZapierSdk(options = {}) {
|
|
69
|
-
return (createSdk()
|
|
76
|
+
return (createSdk(options)
|
|
70
77
|
// Provides the API client in context
|
|
71
|
-
.addPlugin(apiPlugin
|
|
78
|
+
.addPlugin(apiPlugin)
|
|
79
|
+
// Manifest plugin (provides version locking context)
|
|
72
80
|
// Apps/actions/fields
|
|
73
81
|
.addPlugin(listAppsPlugin)
|
|
82
|
+
.addPlugin(manifestPlugin)
|
|
74
83
|
.addPlugin(getAppPlugin)
|
|
75
84
|
.addPlugin(listActionsPlugin)
|
|
76
85
|
.addPlugin(getActionPlugin)
|
|
77
86
|
.addPlugin(listInputFieldsPlugin)
|
|
78
87
|
// Run action
|
|
79
88
|
.addPlugin(runActionPlugin)
|
|
89
|
+
// Version locking
|
|
90
|
+
.addPlugin(lockVersionPlugin)
|
|
80
91
|
// Authentications
|
|
81
92
|
.addPlugin(listAuthenticationsPlugin)
|
|
82
93
|
.addPlugin(getAuthenticationPlugin)
|
package/dist/sdk.test.js
CHANGED
|
@@ -113,7 +113,7 @@ describe("Flat Plugin System", () => {
|
|
|
113
113
|
});
|
|
114
114
|
const baseSdk = { existingMethod: () => "base" };
|
|
115
115
|
const baseContext = { customContext: "custom", meta: {} };
|
|
116
|
-
const sdk = createSdk(baseSdk, baseContext).addPlugin(pluginWithHelper);
|
|
116
|
+
const sdk = createSdk({}, baseSdk, baseContext).addPlugin(pluginWithHelper);
|
|
117
117
|
expect(sdk.helperMethod()).toBe("Helper: base + custom");
|
|
118
118
|
expect(sdk.existingMethod()).toBe("base"); // Original method still works
|
|
119
119
|
});
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export interface ApiError {
|
|
|
6
6
|
code: string;
|
|
7
7
|
title: string;
|
|
8
8
|
detail: string;
|
|
9
|
-
source?:
|
|
10
|
-
meta?:
|
|
9
|
+
source?: unknown;
|
|
10
|
+
meta?: unknown;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Base options for all error constructors
|
|
@@ -16,7 +16,7 @@ export interface ErrorOptions {
|
|
|
16
16
|
statusCode?: number;
|
|
17
17
|
errors?: ApiError[];
|
|
18
18
|
cause?: unknown;
|
|
19
|
-
response?:
|
|
19
|
+
response?: unknown;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Base class for all Zapier SDK errors
|
|
@@ -27,7 +27,7 @@ export declare abstract class ZapierError extends Error {
|
|
|
27
27
|
statusCode?: number;
|
|
28
28
|
errors?: ApiError[];
|
|
29
29
|
cause?: unknown;
|
|
30
|
-
response?:
|
|
30
|
+
response?: unknown;
|
|
31
31
|
constructor(message: string, options?: ErrorOptions);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -52,9 +52,9 @@ export declare class ZapierAppNotFoundError extends ZapierError {
|
|
|
52
52
|
*/
|
|
53
53
|
export declare class ZapierValidationError extends ZapierError {
|
|
54
54
|
readonly name = "ZapierValidationError";
|
|
55
|
-
details?:
|
|
55
|
+
details?: unknown;
|
|
56
56
|
constructor(message: string, options?: ErrorOptions & {
|
|
57
|
-
details?:
|
|
57
|
+
details?: unknown;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,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ChB,SAAS,CAAC,EAAE,MAAM,CAAC;gBAGxB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,YAAY,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO;IAQtE,IAAI,YAAY,2BAEf;CACF;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,QAAQ,CAAC,IAAI,yBAAyB;gBAE1B,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAGxD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CA8D7D"}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,YAAY,GAAG,aAAa,CAAC;IACxE,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,IAAI,EAAE,aAAa,GAAG,cAAc,GAAG,WAAW,CAAC;IACnD,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,IAAI,EAAE,eAAe,GAAG,aAAa,CAAC;IACtC,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC"}
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* This system makes context dependencies explicit to restore TypeScript's
|
|
7
7
|
* ability to catch missing context at compile time.
|
|
8
8
|
*/
|
|
9
|
+
import type { z } from "zod";
|
|
10
|
+
import { BaseSdkOptions } from "./sdk";
|
|
9
11
|
export interface PluginDependencies<TSdk = {}, TContext = {}> {
|
|
10
12
|
sdk: TSdk;
|
|
11
13
|
context: TContext;
|
|
@@ -13,6 +15,11 @@ export interface PluginDependencies<TSdk = {}, TContext = {}> {
|
|
|
13
15
|
export interface PluginProvides extends Record<string, any> {
|
|
14
16
|
context?: Record<string, any>;
|
|
15
17
|
}
|
|
18
|
+
export interface PluginMeta {
|
|
19
|
+
categories: string[];
|
|
20
|
+
inputSchema: z.ZodSchema;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
16
23
|
export type ExtractSdkProperties<T extends Record<string, any>> = Omit<T, "context">;
|
|
17
24
|
export type ExtractContextProperties<T extends PluginProvides> = T["context"];
|
|
18
25
|
export type GetSdkType<TPluginProvides extends PluginProvides> = ExtractSdkProperties<TPluginProvides> & {
|
|
@@ -35,7 +42,8 @@ export interface Plugin<TSdk = {}, TRequiresContext = {}, TProvides extends Plug
|
|
|
35
42
|
(params: {
|
|
36
43
|
sdk: TSdk;
|
|
37
44
|
context: TRequiresContext & {
|
|
38
|
-
meta: Record<string,
|
|
45
|
+
meta: Record<string, PluginMeta>;
|
|
46
|
+
options: BaseSdkOptions;
|
|
39
47
|
};
|
|
40
48
|
}): TProvides;
|
|
41
49
|
}
|
|
@@ -50,7 +58,7 @@ type ContextError<TRequired, TCurrent> = MissingContextKeys<TRequired, TCurrent>
|
|
|
50
58
|
* If not, TypeScript will emit a detailed error showing missing properties.
|
|
51
59
|
*/
|
|
52
60
|
export type Sdk<TCurrentSdk = {}, TCurrentContext = {
|
|
53
|
-
meta: Record<string,
|
|
61
|
+
meta: Record<string, PluginMeta>;
|
|
54
62
|
}> = TCurrentSdk & {
|
|
55
63
|
addPlugin<TRequiresContext, TProvides extends PluginProvides>(plugin: Plugin<TCurrentSdk & {
|
|
56
64
|
getContext(): TCurrentContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,kBAAkB,CAAC,IAAI,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE;IAC1D,GAAG,EAAE,IAAI,CAAC;IACV,OAAO,EAAE,QAAQ,CAAC;CACnB;AAGD,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAGD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CACpE,CAAC,EACD,SAAS,CACV,CAAC;AAGF,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,CAAC,S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|
|
11
11
|
debug?: boolean;
|
|
12
|
+
manifestPath?: string;
|
|
13
|
+
manifest?: {
|
|
14
|
+
apps: {
|
|
15
|
+
[appKey: string]: {
|
|
16
|
+
implementationName: string;
|
|
17
|
+
version?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
12
21
|
}
|
|
13
22
|
import type { ListInputFieldsSdkFunction } from "../plugins/listInputFields/schemas";
|
|
14
23
|
import type { GetAuthenticationSdkFunction } from "../plugins/getAuthentication/schemas";
|
|
15
24
|
import type { FindFirstAuthenticationSdkFunction } from "../plugins/findFirstAuthentication/schemas";
|
|
16
25
|
import type { FindUniqueAuthenticationSdkFunction } from "../plugins/findUniqueAuthentication/schemas";
|
|
17
26
|
import type { RelayRequestSdkFunction } from "../plugins/request/schemas";
|
|
27
|
+
import type { LockVersionPluginProvides } from "../plugins/lockVersion";
|
|
18
28
|
import type { z } from "zod";
|
|
19
29
|
import { RegistryPluginProvides } from "../plugins/registry";
|
|
20
30
|
import { GetProfilePluginProvides } from "../plugins/getProfile";
|
|
@@ -32,12 +42,13 @@ import { FindUniqueAuthenticationPluginProvides } from "../plugins/findUniqueAut
|
|
|
32
42
|
import { ListInputFieldsPluginProvides } from "../plugins/listInputFields";
|
|
33
43
|
import { RequestPluginProvides } from "../plugins/request";
|
|
34
44
|
import { GetSdkType } from "./plugin";
|
|
45
|
+
import { ManifestPluginProvides } from "../plugins/manifest";
|
|
35
46
|
export interface FunctionRegistryEntry {
|
|
36
47
|
name: string;
|
|
37
48
|
inputSchema: z.ZodSchema;
|
|
38
|
-
|
|
49
|
+
categories: string[];
|
|
39
50
|
}
|
|
40
51
|
export interface ZapierSdkFunctions extends ListInputFieldsSdkFunction, GetAuthenticationSdkFunction, FindFirstAuthenticationSdkFunction, FindUniqueAuthenticationSdkFunction, RelayRequestSdkFunction {
|
|
41
52
|
}
|
|
42
|
-
export type ZapierSdk = GetSdkType<RegistryPluginProvides & FetchPluginProvides & AppsPluginProvides & ListAppsPluginProvides & GetAppPluginProvides & ListActionsPluginProvides & GetActionPluginProvides & RunActionPluginProvides & ListAuthenticationsPluginProvides & GetAuthenticationPluginProvides & FindFirstAuthenticationPluginProvides & FindUniqueAuthenticationPluginProvides & ListInputFieldsPluginProvides & RequestPluginProvides & GetProfilePluginProvides>;
|
|
53
|
+
export type ZapierSdk = GetSdkType<RegistryPluginProvides & FetchPluginProvides & AppsPluginProvides & ListAppsPluginProvides & ManifestPluginProvides & GetAppPluginProvides & ListActionsPluginProvides & GetActionPluginProvides & RunActionPluginProvides & LockVersionPluginProvides & ListAuthenticationsPluginProvides & GetAuthenticationPluginProvides & FindFirstAuthenticationPluginProvides & FindUniqueAuthenticationPluginProvides & ListInputFieldsPluginProvides & RequestPluginProvides & GetProfilePluginProvides>;
|
|
43
54
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAA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AO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,qCAAqC,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,sCAAsC,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAM7D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAGD,MAAM,WAAW,kBACf,SAAQ,0BAA0B,EAChC,4BAA4B,EAC5B,kCAAkC,EAClC,mCAAmC,EACnC,uBAAuB;CAE1B;AAUD,MAAM,MAAM,SAAS,GAAG,UAAU,CAChC,sBAAsB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,sBAAsB,GACtB,oBAAoB,GACpB,yBAAyB,GACzB,uBAAuB,GACvB,uBAAuB,GACvB,yBAAyB,GACzB,iCAAiC,GACjC,+BAA+B,GAC/B,qCAAqC,GACrC,sCAAsC,GACtC,6BAA6B,GAC7B,qBAAqB,GACrB,wBAAwB,CAC3B,CAAC"}
|
|
@@ -36,7 +36,8 @@ describe("validation utilities", () => {
|
|
|
36
36
|
expect(error).toBeInstanceOf(ZapierValidationError);
|
|
37
37
|
expect(error.message).toContain("name:");
|
|
38
38
|
expect(error.message).toContain("age:");
|
|
39
|
-
expect(error.details
|
|
39
|
+
expect(error.details
|
|
40
|
+
?.zodErrors).toBeDefined();
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
43
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"tsup": "^8.5.0",
|
|
47
47
|
"typescript": "^5.8.3",
|
|
48
48
|
"vitest": "^3.2.3",
|
|
49
|
-
"@zapier/zapier-sdk-cli-login": "0.3.
|
|
49
|
+
"@zapier/zapier-sdk-cli-login": "0.3.2"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup",
|
package/src/api/client.ts
CHANGED
|
@@ -313,7 +313,7 @@ class ZapierApiClient implements ApiClient {
|
|
|
313
313
|
private async fetchJson<TOutput = unknown>(
|
|
314
314
|
method: string,
|
|
315
315
|
path: string,
|
|
316
|
-
data?:
|
|
316
|
+
data?: unknown,
|
|
317
317
|
options: RequestOptions = {},
|
|
318
318
|
): Promise<TOutput> {
|
|
319
319
|
const headers = { ...options.headers };
|
|
@@ -412,7 +412,7 @@ class ZapierApiClient implements ApiClient {
|
|
|
412
412
|
|
|
413
413
|
public post = async <TOutput = unknown>(
|
|
414
414
|
path: string,
|
|
415
|
-
data?:
|
|
415
|
+
data?: unknown,
|
|
416
416
|
options: RequestOptions = {},
|
|
417
417
|
): Promise<TOutput> => {
|
|
418
418
|
return this.fetchJson<TOutput>("POST", path, data, options);
|
|
@@ -420,7 +420,7 @@ class ZapierApiClient implements ApiClient {
|
|
|
420
420
|
|
|
421
421
|
public put = async <TOutput = unknown>(
|
|
422
422
|
path: string,
|
|
423
|
-
data?:
|
|
423
|
+
data?: unknown,
|
|
424
424
|
options: RequestOptions = {},
|
|
425
425
|
): Promise<TOutput> => {
|
|
426
426
|
return this.fetchJson<TOutput>("PUT", path, data, options);
|
package/src/api/index.ts
CHANGED
package/src/api/types.ts
CHANGED
|
@@ -49,11 +49,19 @@ export interface ApiClientOptions {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface ApiClient {
|
|
52
|
-
get: (path: string, options?: RequestOptions) => Promise<
|
|
53
|
-
post:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
get: <T = unknown>(path: string, options?: RequestOptions) => Promise<T>;
|
|
53
|
+
post: <T = unknown>(
|
|
54
|
+
path: string,
|
|
55
|
+
data?: unknown,
|
|
56
|
+
options?: RequestOptions,
|
|
57
|
+
) => Promise<T>;
|
|
58
|
+
put: <T = unknown>(
|
|
59
|
+
path: string,
|
|
60
|
+
data?: unknown,
|
|
61
|
+
options?: RequestOptions,
|
|
62
|
+
) => Promise<T>;
|
|
63
|
+
delete: <T = unknown>(path: string, options?: RequestOptions) => Promise<T>;
|
|
64
|
+
poll: <T = unknown>(path: string, options?: PollOptions) => Promise<T>;
|
|
57
65
|
fetch: (
|
|
58
66
|
path: string,
|
|
59
67
|
init?: RequestInit & {
|
|
@@ -70,7 +78,7 @@ export interface RequestOptions {
|
|
|
70
78
|
customErrorHandler?: (errorInfo: {
|
|
71
79
|
status: number;
|
|
72
80
|
statusText: string;
|
|
73
|
-
data:
|
|
81
|
+
data: unknown;
|
|
74
82
|
}) => Error | undefined;
|
|
75
83
|
}
|
|
76
84
|
|
|
@@ -80,7 +88,7 @@ export interface PollOptions extends RequestOptions {
|
|
|
80
88
|
maxDelay?: number;
|
|
81
89
|
successStatus?: number;
|
|
82
90
|
pendingStatus?: number;
|
|
83
|
-
resultExtractor?: (response:
|
|
91
|
+
resultExtractor?: (response: unknown) => unknown;
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
export interface DebugLogger {
|
package/src/index.ts
CHANGED
|
@@ -33,8 +33,6 @@ export * from "./auth";
|
|
|
33
33
|
// Export resolvers for CLI use
|
|
34
34
|
export * from "./resolvers";
|
|
35
35
|
|
|
36
|
-
// Note: SdkSchemas is now available via SDK.__registry
|
|
37
|
-
|
|
38
36
|
// All functions now available through the plugin system via createZapierSdk()
|
|
39
37
|
// Export plugin schemas for external use
|
|
40
38
|
export {
|
package/src/plugins/api/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface AppFactoryOptions {
|
|
|
10
10
|
|
|
11
11
|
// Base action type proxy for regular actions
|
|
12
12
|
interface BaseActionTypeProxy {
|
|
13
|
-
[action: string]: (options?: ActionExecutionOptions) =>
|
|
13
|
+
[action: string]: (options?: ActionExecutionOptions) => unknown;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// Special fetch function type
|
|
@@ -63,7 +63,7 @@ describe("getAction plugin", () => {
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
// Build SDK with proper plugin composition, providing API in initial context
|
|
66
|
-
return createSdk({}, { api: mockApiClient, meta: {} })
|
|
66
|
+
return createSdk({}, {}, { api: mockApiClient, meta: {} })
|
|
67
67
|
.addPlugin(mockListActionsPlugin)
|
|
68
68
|
.addPlugin(getActionPlugin);
|
|
69
69
|
}
|
|
@@ -7,11 +7,13 @@ import { getAppPlugin } from "./index";
|
|
|
7
7
|
import { createSdk } from "../../sdk";
|
|
8
8
|
import { apiPlugin } from "../api/index";
|
|
9
9
|
import { listAppsPlugin } from "../listApps";
|
|
10
|
+
import { manifestPlugin } from "../manifest";
|
|
10
11
|
|
|
11
12
|
function createTestSdk() {
|
|
12
13
|
return createSdk()
|
|
13
14
|
.addPlugin(apiPlugin, { fetch: global.fetch })
|
|
14
15
|
.addPlugin(listAppsPlugin)
|
|
16
|
+
.addPlugin(manifestPlugin)
|
|
15
17
|
.addPlugin(getAppPlugin);
|
|
16
18
|
}
|
|
17
19
|
|