@zapier/zapier-sdk 0.0.3 → 0.1.1
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/dist/api/auth.d.ts +8 -0
- package/dist/api/auth.js +29 -0
- package/dist/api/client.d.ts +8 -0
- package/dist/api/client.js +102 -0
- package/dist/api/debug.d.ts +12 -0
- package/dist/api/debug.js +50 -0
- package/dist/api/index.d.ts +26 -0
- package/dist/api/index.js +51 -0
- package/dist/api/polling.d.ts +17 -0
- package/dist/api/polling.js +34 -0
- package/dist/{types.d.ts → api/types.d.ts} +37 -88
- package/dist/api/types.js +9 -0
- package/dist/functions/{bundleCode.d.ts → bundleCode/index.d.ts} +1 -8
- package/dist/functions/bundleCode/info.d.ts +27 -0
- package/dist/functions/bundleCode/info.js +11 -0
- package/dist/functions/bundleCode/schemas.d.ts +27 -0
- package/dist/functions/bundleCode/schemas.js +22 -0
- package/dist/functions/findFirstAuthentication/index.d.ts +12 -0
- package/dist/functions/findFirstAuthentication/index.js +21 -0
- package/dist/functions/findFirstAuthentication/info.d.ts +30 -0
- package/dist/functions/findFirstAuthentication/info.js +11 -0
- package/dist/functions/findFirstAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findFirstAuthentication/schemas.js +25 -0
- package/dist/functions/findUniqueAuthentication/index.d.ts +13 -0
- package/dist/functions/findUniqueAuthentication/index.js +28 -0
- package/dist/functions/findUniqueAuthentication/info.d.ts +30 -0
- package/dist/functions/findUniqueAuthentication/info.js +11 -0
- package/dist/functions/findUniqueAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findUniqueAuthentication/schemas.js +25 -0
- package/dist/functions/{generateTypes.d.ts → generateTypes/index.d.ts} +2 -7
- package/dist/functions/{generateTypes.js → generateTypes/index.js} +58 -24
- package/dist/functions/generateTypes/info.d.ts +21 -0
- package/dist/functions/generateTypes/info.js +11 -0
- package/dist/functions/generateTypes/schemas.d.ts +30 -0
- package/dist/functions/generateTypes/schemas.js +14 -0
- package/dist/functions/{getAction.d.ts → getAction/index.d.ts} +2 -6
- package/dist/functions/{getAction.js → getAction/index.js} +6 -5
- package/dist/functions/getAction/info.d.ts +18 -0
- package/dist/functions/getAction/info.js +11 -0
- package/dist/functions/getAction/schemas.d.ts +30 -0
- package/dist/functions/getAction/schemas.js +13 -0
- package/dist/functions/{getApp.d.ts → getApp/index.d.ts} +2 -4
- package/dist/functions/{getApp.js → getApp/index.js} +6 -10
- package/dist/functions/getApp/info.d.ts +12 -0
- package/dist/functions/getApp/info.js +11 -0
- package/dist/functions/getApp/schemas.d.ts +24 -0
- package/dist/functions/getApp/schemas.js +11 -0
- package/dist/functions/{listActions.d.ts → listActions/index.d.ts} +3 -6
- package/dist/functions/{listActions.js → listActions/index.js} +4 -3
- package/dist/functions/listActions/info.d.ts +15 -0
- package/dist/functions/listActions/info.js +11 -0
- package/dist/functions/listActions/schemas.d.ts +27 -0
- package/dist/functions/listActions/schemas.js +14 -0
- package/dist/functions/{listApps.d.ts → listApps/index.d.ts} +2 -6
- package/dist/functions/{listApps.js → listApps/index.js} +1 -1
- package/dist/functions/listApps/info.d.ts +18 -0
- package/dist/functions/listApps/info.js +11 -0
- package/dist/functions/listApps/schemas.d.ts +30 -0
- package/dist/functions/listApps/schemas.js +15 -0
- package/dist/functions/{listAuths.d.ts → listAuthentications/index.d.ts} +3 -9
- package/dist/functions/{listAuths.js → listAuthentications/index.js} +28 -12
- package/dist/functions/listAuthentications/info.d.ts +30 -0
- package/dist/functions/listAuthentications/info.js +11 -0
- package/dist/functions/listAuthentications/schemas.d.ts +42 -0
- package/dist/functions/listAuthentications/schemas.js +25 -0
- package/dist/functions/{listFields.d.ts → listFields/index.d.ts} +3 -9
- package/dist/functions/{listFields.js → listFields/index.js} +8 -10
- package/dist/functions/listFields/info.d.ts +24 -0
- package/dist/functions/listFields/info.js +11 -0
- package/dist/functions/listFields/schemas.d.ts +36 -0
- package/dist/functions/listFields/schemas.js +17 -0
- package/dist/functions/{runAction.d.ts → runAction/index.d.ts} +2 -8
- package/dist/functions/{runAction.js → runAction/index.js} +15 -14
- package/dist/functions/runAction/info.d.ts +24 -0
- package/dist/functions/runAction/info.js +11 -0
- package/dist/functions/runAction/schemas.d.ts +36 -0
- package/dist/functions/runAction/schemas.js +15 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +17 -6
- package/dist/plugins/apps/index.d.ts +8 -0
- package/dist/plugins/apps/index.js +77 -0
- package/dist/plugins/apps/info.d.ts +6 -0
- package/dist/plugins/apps/info.js +13 -0
- package/dist/plugins/apps/types.d.ts +21 -0
- package/dist/plugins/apps/types.js +2 -0
- package/dist/resolvers/actionKey.d.ts +8 -0
- package/dist/resolvers/actionKey.js +20 -0
- package/dist/resolvers/actionType.d.ts +8 -0
- package/dist/resolvers/actionType.js +21 -0
- package/dist/resolvers/appKey.d.ts +6 -0
- package/dist/resolvers/appKey.js +8 -0
- package/dist/resolvers/authenticationId.d.ts +8 -0
- package/dist/resolvers/authenticationId.js +29 -0
- package/dist/resolvers/index.d.ts +39 -0
- package/dist/resolvers/index.js +105 -0
- package/dist/resolvers/inputs.d.ts +7 -0
- package/dist/resolvers/inputs.js +15 -0
- package/dist/schema-utils.d.ts +44 -0
- package/dist/schema-utils.js +76 -0
- package/dist/schemas/Action.d.ts +21 -0
- package/dist/schemas/Action.js +31 -0
- package/dist/schemas/App.d.ts +19 -0
- package/dist/schemas/App.js +32 -0
- package/dist/schemas/Auth.d.ts +27 -0
- package/dist/schemas/Auth.js +42 -0
- package/dist/schemas/Field.d.ts +15 -0
- package/dist/schemas/Field.js +25 -0
- package/dist/sdk.d.ts +3 -4
- package/dist/sdk.js +104 -11
- package/dist/types/domain.d.ts +22 -0
- package/dist/types/domain.js +21 -0
- package/dist/types/properties.d.ts +21 -0
- package/dist/types/properties.js +43 -0
- package/dist/types/sdk.d.ts +23 -0
- package/dist/types/sdk.js +2 -0
- package/package.json +4 -2
- package/src/api/auth.ts +28 -0
- package/src/api/client.ts +148 -0
- package/src/api/debug.ts +58 -0
- package/src/api/index.ts +83 -0
- package/src/api/polling.ts +56 -0
- package/src/api/types.ts +177 -0
- package/src/functions/{bundleCode.ts → bundleCode/index.ts} +1 -8
- package/src/functions/bundleCode/info.ts +9 -0
- package/src/functions/bundleCode/schemas.ts +30 -0
- package/src/functions/findFirstAuthentication/index.ts +24 -0
- package/src/functions/findFirstAuthentication/info.ts +9 -0
- package/src/functions/findFirstAuthentication/schemas.ts +60 -0
- package/src/functions/findUniqueAuthentication/index.ts +35 -0
- package/src/functions/findUniqueAuthentication/info.ts +9 -0
- package/src/functions/findUniqueAuthentication/schemas.ts +60 -0
- package/src/functions/{generateTypes.ts → generateTypes/index.ts} +70 -31
- package/src/functions/generateTypes/info.ts +9 -0
- package/src/functions/generateTypes/schemas.ts +38 -0
- package/src/functions/{getAction.ts → getAction/index.ts} +11 -12
- package/src/functions/getAction/info.ts +9 -0
- package/src/functions/getAction/schemas.ts +35 -0
- package/src/functions/{getApp.ts → getApp/index.ts} +9 -15
- package/src/functions/getApp/info.ts +9 -0
- package/src/functions/getApp/schemas.ts +31 -0
- package/src/functions/{listActions.ts → listActions/index.ts} +8 -10
- package/src/functions/listActions/info.ts +9 -0
- package/src/functions/listActions/schemas.ts +40 -0
- package/src/functions/{listApps.ts → listApps/index.ts} +3 -8
- package/src/functions/listApps/info.ts +9 -0
- package/src/functions/listApps/schemas.ts +43 -0
- package/src/functions/{listAuths.ts → listAuthentications/index.ts} +32 -23
- package/src/functions/listAuthentications/info.ts +9 -0
- package/src/functions/listAuthentications/schemas.ts +60 -0
- package/src/functions/{listFields.ts → listFields/index.ts} +11 -20
- package/src/functions/listFields/info.ts +9 -0
- package/src/functions/listFields/schemas.ts +46 -0
- package/src/functions/{runAction.ts → runAction/index.ts} +25 -23
- package/src/functions/runAction/info.ts +9 -0
- package/src/functions/runAction/schemas.ts +41 -0
- package/src/index.ts +19 -5
- package/src/plugins/apps/index.ts +144 -0
- package/src/plugins/apps/info.ts +12 -0
- package/src/plugins/apps/types.ts +34 -0
- package/src/resolvers/actionKey.ts +33 -0
- package/src/resolvers/actionType.ts +30 -0
- package/src/resolvers/appKey.ts +11 -0
- package/src/resolvers/authenticationId.ts +38 -0
- package/src/resolvers/index.ts +117 -0
- package/src/resolvers/inputs.ts +23 -0
- package/src/schema-utils.ts +154 -0
- package/src/schemas/Action.ts +40 -0
- package/src/schemas/App.ts +43 -0
- package/src/schemas/Auth.ts +54 -0
- package/src/schemas/Field.ts +34 -0
- package/src/sdk.ts +165 -19
- package/src/types/domain.ts +54 -0
- package/src/types/properties.ts +67 -0
- package/src/types/sdk.ts +46 -0
- package/dist/actions-sdk.d.ts +0 -47
- package/dist/actions-sdk.js +0 -208
- package/dist/api.d.ts +0 -62
- package/dist/api.js +0 -227
- package/dist/output-schemas.d.ts +0 -95
- package/dist/output-schemas.js +0 -138
- package/dist/schemas.d.ts +0 -338
- package/dist/schemas.js +0 -336
- package/dist/types.js +0 -41
- package/src/actions-sdk.ts +0 -356
- package/src/api.ts +0 -361
- package/src/output-schemas.ts +0 -196
- package/src/schemas.ts +0 -467
- package/src/types.ts +0 -257
- /package/dist/functions/{bundleCode.js → bundleCode/index.js} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listFieldsInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.listFieldsInfo = {
|
|
8
|
+
name: index_1.listFields.name,
|
|
9
|
+
inputSchema: schemas_1.ListFieldsSchema,
|
|
10
|
+
implementation: index_1.listFields,
|
|
11
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ActionField } from "../../types/domain";
|
|
3
|
+
export declare const ListFieldsSchema: z.ZodObject<{
|
|
4
|
+
appKey: z.ZodString;
|
|
5
|
+
actionType: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
|
|
6
|
+
actionKey: z.ZodString;
|
|
7
|
+
authenticationId: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
appKey: string;
|
|
11
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
12
|
+
actionKey: string;
|
|
13
|
+
params?: Record<string, any> | undefined;
|
|
14
|
+
authenticationId?: number | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
appKey: string;
|
|
17
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
18
|
+
actionKey: string;
|
|
19
|
+
params?: Record<string, any> | undefined;
|
|
20
|
+
authenticationId?: number | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type ListFieldsOptions = z.infer<typeof ListFieldsSchema> & {
|
|
23
|
+
/** Base URL for Zapier API */
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
/** Authentication token */
|
|
26
|
+
token?: string;
|
|
27
|
+
/** Optional pre-instantiated API client */
|
|
28
|
+
api?: any;
|
|
29
|
+
/** Enable debug logging */
|
|
30
|
+
debug?: boolean;
|
|
31
|
+
/** Custom fetch implementation */
|
|
32
|
+
fetch?: typeof globalThis.fetch;
|
|
33
|
+
};
|
|
34
|
+
export interface ListFieldsSdkFunction {
|
|
35
|
+
listFields: (options: ListFieldsOptions) => Promise<ActionField[]>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListFieldsSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const properties_1 = require("../../types/properties");
|
|
6
|
+
const schema_utils_1 = require("../../schema-utils");
|
|
7
|
+
const Field_1 = require("../../schemas/Field");
|
|
8
|
+
// Pure Zod schema - no resolver metadata!
|
|
9
|
+
exports.ListFieldsSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
appKey: properties_1.AppKeyPropertySchema,
|
|
12
|
+
actionType: properties_1.ActionTypePropertySchema,
|
|
13
|
+
actionKey: properties_1.ActionKeyPropertySchema,
|
|
14
|
+
authenticationId: properties_1.AuthenticationIdPropertySchema.optional(),
|
|
15
|
+
params: properties_1.ParamsPropertySchema.optional().describe("Additional parameters that may affect available fields"),
|
|
16
|
+
})
|
|
17
|
+
.describe("Get the input fields required for a specific action"), Field_1.FieldItemSchema);
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type { ActionExecutionResult
|
|
2
|
-
|
|
3
|
-
app: string;
|
|
4
|
-
type: string;
|
|
5
|
-
action: string;
|
|
6
|
-
inputs?: Record<string, any>;
|
|
7
|
-
authId?: number;
|
|
8
|
-
}
|
|
1
|
+
import type { ActionExecutionResult } from "../../types/domain";
|
|
2
|
+
import type { RunActionOptions } from "./schemas";
|
|
9
3
|
/**
|
|
10
4
|
* Execute an action
|
|
11
5
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runAction = runAction;
|
|
4
|
-
const api_1 = require("
|
|
5
|
-
const getAction_1 = require("
|
|
6
|
-
const getApp_1 = require("
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
|
+
const getAction_1 = require("../getAction");
|
|
6
|
+
const getApp_1 = require("../getApp");
|
|
7
7
|
/**
|
|
8
8
|
* Execute an action
|
|
9
9
|
*
|
|
@@ -14,7 +14,7 @@ const getApp_1 = require("./getApp");
|
|
|
14
14
|
* @returns Promise<ActionExecutionResult>
|
|
15
15
|
*/
|
|
16
16
|
async function runAction(options) {
|
|
17
|
-
const {
|
|
17
|
+
const { appKey, actionType, actionKey, inputs, authenticationId: providedAuthenticationId, token, } = options;
|
|
18
18
|
if (!token && !process.env.ZAPIER_TOKEN) {
|
|
19
19
|
throw new Error("Authentication token is required to run actions. Please provide token in options or set ZAPIER_TOKEN environment variable.");
|
|
20
20
|
}
|
|
@@ -22,24 +22,24 @@ async function runAction(options) {
|
|
|
22
22
|
// Validate that the action exists
|
|
23
23
|
const actionData = await (0, getAction_1.getAction)({
|
|
24
24
|
...options,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
appKey: appKey,
|
|
26
|
+
actionKey: actionKey,
|
|
27
|
+
actionType: actionType,
|
|
28
28
|
});
|
|
29
29
|
// Validate action type matches
|
|
30
|
-
if (actionData.type !==
|
|
31
|
-
throw new Error(`Action type mismatch: expected ${
|
|
30
|
+
if (actionData.type !== actionType) {
|
|
31
|
+
throw new Error(`Action type mismatch: expected ${actionType}, got ${actionData.type}`);
|
|
32
32
|
}
|
|
33
33
|
// Execute the action using the appropriate API based on action type
|
|
34
34
|
const startTime = Date.now();
|
|
35
35
|
const result = await executeActionWithStrategy({
|
|
36
36
|
api,
|
|
37
|
-
appSlug:
|
|
38
|
-
actionKey:
|
|
37
|
+
appSlug: appKey,
|
|
38
|
+
actionKey: actionKey,
|
|
39
39
|
actionType: actionData.type,
|
|
40
40
|
executionOptions: { inputs: inputs || {} },
|
|
41
41
|
auth: token
|
|
42
|
-
? { token: token, authentication_id:
|
|
42
|
+
? { token: token, authentication_id: providedAuthenticationId }
|
|
43
43
|
: undefined,
|
|
44
44
|
options,
|
|
45
45
|
});
|
|
@@ -86,7 +86,7 @@ async function executeActionViaActionsApi(apiOptions) {
|
|
|
86
86
|
const { api, appSlug, actionKey, actionType, executionOptions, auth, options, } = apiOptions;
|
|
87
87
|
// Use the standalone getApp function
|
|
88
88
|
const appData = await (0, getApp_1.getApp)({
|
|
89
|
-
|
|
89
|
+
appKey: appSlug,
|
|
90
90
|
api,
|
|
91
91
|
token: options.token,
|
|
92
92
|
baseUrl: options.baseUrl,
|
|
@@ -123,7 +123,7 @@ async function executeActionViaInvokeApi(apiOptions) {
|
|
|
123
123
|
const { api, appSlug, actionKey, actionType, executionOptions, auth, options, } = apiOptions;
|
|
124
124
|
// Use the standalone getApp function
|
|
125
125
|
const appData = await (0, getApp_1.getApp)({
|
|
126
|
-
|
|
126
|
+
appKey: appSlug,
|
|
127
127
|
api,
|
|
128
128
|
token: options.token,
|
|
129
129
|
baseUrl: options.baseUrl,
|
|
@@ -154,3 +154,4 @@ async function executeActionViaInvokeApi(apiOptions) {
|
|
|
154
154
|
resultExtractor: (result) => result.results || result,
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
|
+
// No registry info here - moved to info.ts for proper tree-shaking
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { runAction } from "./index";
|
|
2
|
+
export declare const runActionInfo: {
|
|
3
|
+
name: string;
|
|
4
|
+
inputSchema: import("zod").ZodObject<{
|
|
5
|
+
appKey: import("zod").ZodString;
|
|
6
|
+
actionType: import("zod").ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
|
|
7
|
+
actionKey: import("zod").ZodString;
|
|
8
|
+
inputs: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
9
|
+
authenticationId: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
10
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
11
|
+
appKey: string;
|
|
12
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
13
|
+
actionKey: string;
|
|
14
|
+
inputs?: Record<string, any> | undefined;
|
|
15
|
+
authenticationId?: number | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
appKey: string;
|
|
18
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
19
|
+
actionKey: string;
|
|
20
|
+
inputs?: Record<string, any> | undefined;
|
|
21
|
+
authenticationId?: number | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
implementation: typeof runAction;
|
|
24
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runActionInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.runActionInfo = {
|
|
8
|
+
name: index_1.runAction.name,
|
|
9
|
+
inputSchema: schemas_1.RunActionSchema,
|
|
10
|
+
implementation: index_1.runAction,
|
|
11
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ActionExecutionResult } from "../../types/domain";
|
|
3
|
+
export declare const RunActionSchema: z.ZodObject<{
|
|
4
|
+
appKey: z.ZodString;
|
|
5
|
+
actionType: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
|
|
6
|
+
actionKey: z.ZodString;
|
|
7
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
8
|
+
authenticationId: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
appKey: string;
|
|
11
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
12
|
+
actionKey: string;
|
|
13
|
+
inputs?: Record<string, any> | undefined;
|
|
14
|
+
authenticationId?: number | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
appKey: string;
|
|
17
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
18
|
+
actionKey: string;
|
|
19
|
+
inputs?: Record<string, any> | undefined;
|
|
20
|
+
authenticationId?: number | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type RunActionOptions = z.infer<typeof RunActionSchema> & {
|
|
23
|
+
/** Base URL for Zapier API */
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
/** Authentication token */
|
|
26
|
+
token?: string;
|
|
27
|
+
/** Optional pre-instantiated API client */
|
|
28
|
+
api?: any;
|
|
29
|
+
/** Enable debug logging */
|
|
30
|
+
debug?: boolean;
|
|
31
|
+
/** Custom fetch implementation */
|
|
32
|
+
fetch?: typeof globalThis.fetch;
|
|
33
|
+
};
|
|
34
|
+
export interface RunActionSdkFunction {
|
|
35
|
+
runAction: (options: RunActionOptions) => Promise<ActionExecutionResult>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RunActionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const properties_1 = require("../../types/properties");
|
|
6
|
+
// Pure Zod schema - no resolver metadata!
|
|
7
|
+
exports.RunActionSchema = zod_1.z
|
|
8
|
+
.object({
|
|
9
|
+
appKey: properties_1.AppKeyPropertySchema,
|
|
10
|
+
actionType: properties_1.ActionTypePropertySchema,
|
|
11
|
+
actionKey: properties_1.ActionKeyPropertySchema,
|
|
12
|
+
inputs: properties_1.InputsPropertySchema.optional().describe("Input parameters for the action"),
|
|
13
|
+
authenticationId: properties_1.AuthenticationIdPropertySchema.optional(),
|
|
14
|
+
})
|
|
15
|
+
.describe("Execute an action with the given inputs");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
export * from "./types";
|
|
2
|
-
export * from "./
|
|
3
|
-
export
|
|
1
|
+
export * from "./types/domain";
|
|
2
|
+
export * from "./types/properties";
|
|
3
|
+
export * from "./plugins/apps";
|
|
4
|
+
export { isPositional } from "./schema-utils";
|
|
5
|
+
export * from "./resolvers";
|
|
6
|
+
export { listAuthentications } from "./functions/listAuthentications";
|
|
7
|
+
export { findFirstAuthentication } from "./functions/findFirstAuthentication";
|
|
8
|
+
export { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
|
|
4
9
|
export { listApps } from "./functions/listApps";
|
|
5
10
|
export { getApp } from "./functions/getApp";
|
|
6
11
|
export { listActions } from "./functions/listActions";
|
|
@@ -9,4 +14,5 @@ export { runAction } from "./functions/runAction";
|
|
|
9
14
|
export { listFields } from "./functions/listFields";
|
|
10
15
|
export { generateTypes } from "./functions/generateTypes";
|
|
11
16
|
export { bundleCode } from "./functions/bundleCode";
|
|
12
|
-
export { createZapierSdk,
|
|
17
|
+
export { createZapierSdk, ZapierSdkOptions } from "./sdk";
|
|
18
|
+
export type { ZapierSdk } from "./types/sdk";
|
package/dist/index.js
CHANGED
|
@@ -14,13 +14,24 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createZapierSdk = exports.bundleCode = exports.generateTypes = exports.listFields = exports.runAction = exports.getAction = exports.listActions = exports.getApp = exports.listApps = exports.
|
|
18
|
-
// Export everything from types and
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
17
|
+
exports.createZapierSdk = exports.bundleCode = exports.generateTypes = exports.listFields = exports.runAction = exports.getAction = exports.listActions = exports.getApp = exports.listApps = exports.findUniqueAuthentication = exports.findFirstAuthentication = exports.listAuthentications = exports.isPositional = void 0;
|
|
18
|
+
// Export everything from types and plugins
|
|
19
|
+
__exportStar(require("./types/domain"), exports);
|
|
20
|
+
__exportStar(require("./types/properties"), exports);
|
|
21
|
+
__exportStar(require("./plugins/apps"), exports);
|
|
22
|
+
// Export schema utilities for CLI
|
|
23
|
+
var schema_utils_1 = require("./schema-utils");
|
|
24
|
+
Object.defineProperty(exports, "isPositional", { enumerable: true, get: function () { return schema_utils_1.isPositional; } });
|
|
25
|
+
// Export resolvers for CLI use
|
|
26
|
+
__exportStar(require("./resolvers"), exports);
|
|
27
|
+
// Note: SdkSchemas is now available via SDK.__registry
|
|
21
28
|
// Export individual functions for tree-shaking
|
|
22
|
-
var
|
|
23
|
-
Object.defineProperty(exports, "
|
|
29
|
+
var listAuthentications_1 = require("./functions/listAuthentications");
|
|
30
|
+
Object.defineProperty(exports, "listAuthentications", { enumerable: true, get: function () { return listAuthentications_1.listAuthentications; } });
|
|
31
|
+
var findFirstAuthentication_1 = require("./functions/findFirstAuthentication");
|
|
32
|
+
Object.defineProperty(exports, "findFirstAuthentication", { enumerable: true, get: function () { return findFirstAuthentication_1.findFirstAuthentication; } });
|
|
33
|
+
var findUniqueAuthentication_1 = require("./functions/findUniqueAuthentication");
|
|
34
|
+
Object.defineProperty(exports, "findUniqueAuthentication", { enumerable: true, get: function () { return findUniqueAuthentication_1.findUniqueAuthentication; } });
|
|
24
35
|
var listApps_1 = require("./functions/listApps");
|
|
25
36
|
Object.defineProperty(exports, "listApps", { enumerable: true, get: function () { return listApps_1.listApps; } });
|
|
26
37
|
var getApp_1 = require("./functions/getApp");
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ApiClient } from "../../api";
|
|
2
|
+
import type { ActionProxy } from "./types";
|
|
3
|
+
export interface AppsPluginOptions {
|
|
4
|
+
api: ApiClient;
|
|
5
|
+
token?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createAppsPlugin(options: AppsPluginOptions): ActionProxy;
|
|
8
|
+
export type { ActionProxy, AppsPluginSdkExtension } from "./types";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAppsPlugin = createAppsPlugin;
|
|
4
|
+
const runAction_1 = require("../../functions/runAction");
|
|
5
|
+
function createActionFunction(appKey, actionType, actionKey, options, pinnedAuthId) {
|
|
6
|
+
return async (actionOptions = {}) => {
|
|
7
|
+
const { api, token } = options;
|
|
8
|
+
const { inputs, authenticationId: providedAuthenticationId } = actionOptions;
|
|
9
|
+
// Use pinned auth ID first, then provided auth ID
|
|
10
|
+
const authenticationId = pinnedAuthId || providedAuthenticationId;
|
|
11
|
+
if (!authenticationId) {
|
|
12
|
+
throw new Error(`Authentication ID is required. Either use the factory pattern: sdk.apps.${appKey}({ authenticationId }) or provide authenticationId in the action call.`);
|
|
13
|
+
}
|
|
14
|
+
// Call runAction with the resolved parameters
|
|
15
|
+
return (0, runAction_1.runAction)({
|
|
16
|
+
appKey,
|
|
17
|
+
actionType: actionType,
|
|
18
|
+
actionKey,
|
|
19
|
+
inputs,
|
|
20
|
+
authenticationId,
|
|
21
|
+
api: api,
|
|
22
|
+
token,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function createActionTypeProxy(appKey, actionType, options, pinnedAuthId) {
|
|
27
|
+
return new Proxy({}, {
|
|
28
|
+
get(_, actionKey) {
|
|
29
|
+
if (typeof actionKey === "string") {
|
|
30
|
+
return createActionFunction(appKey, actionType, actionKey, options, pinnedAuthId);
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function createPinnedAppProxy(appKey, options, pinnedAuthId) {
|
|
37
|
+
return new Proxy({}, {
|
|
38
|
+
get(_, actionType) {
|
|
39
|
+
if (typeof actionType === "string") {
|
|
40
|
+
return createActionTypeProxy(appKey, actionType, options, pinnedAuthId);
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function createAppProxy(appKey, options) {
|
|
47
|
+
// Create the factory function that returns a pinned version
|
|
48
|
+
const appFactory = (factoryOptions) => {
|
|
49
|
+
return createPinnedAppProxy(appKey, options, factoryOptions.authenticationId);
|
|
50
|
+
};
|
|
51
|
+
// Add properties for direct usage (backward compatibility)
|
|
52
|
+
return new Proxy(appFactory, {
|
|
53
|
+
get(_, actionType) {
|
|
54
|
+
if (typeof actionType === "string") {
|
|
55
|
+
return createActionTypeProxy(appKey, actionType, options);
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function createAppsProxy(options) {
|
|
62
|
+
// Create a proxy object that intercepts property access
|
|
63
|
+
const appsProxy = new Proxy({}, {
|
|
64
|
+
get(_, prop) {
|
|
65
|
+
if (typeof prop === "string") {
|
|
66
|
+
// First level: App names (e.g., 'slack')
|
|
67
|
+
return createAppProxy(prop, options);
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
return appsProxy;
|
|
73
|
+
}
|
|
74
|
+
// Export the plugin creation function
|
|
75
|
+
function createAppsPlugin(options) {
|
|
76
|
+
return createAppsProxy(options);
|
|
77
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appsPluginInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
// Plugin info object for registry (keeping for compatibility)
|
|
6
|
+
exports.appsPluginInfo = {
|
|
7
|
+
plugin: (_sdk, options) => {
|
|
8
|
+
const appsProxy = (0, index_1.createAppsPlugin)(options);
|
|
9
|
+
return {
|
|
10
|
+
apps: appsProxy,
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ActionExecutionOptions, ActionExecutionResult } from "../../types/domain";
|
|
2
|
+
interface AppFactoryOptions {
|
|
3
|
+
authenticationId: number;
|
|
4
|
+
}
|
|
5
|
+
interface ActionTypeProxy {
|
|
6
|
+
[action: string]: (options?: ActionExecutionOptions) => Promise<ActionExecutionResult>;
|
|
7
|
+
}
|
|
8
|
+
interface AppProxy {
|
|
9
|
+
[type: string]: ActionTypeProxy;
|
|
10
|
+
}
|
|
11
|
+
interface AppFactory {
|
|
12
|
+
(options: AppFactoryOptions): AppProxy;
|
|
13
|
+
}
|
|
14
|
+
type AppProxyWithFactory = AppFactory & AppProxy;
|
|
15
|
+
export interface ActionProxy {
|
|
16
|
+
[app: string]: AppProxyWithFactory;
|
|
17
|
+
}
|
|
18
|
+
export interface AppsPluginSdkExtension {
|
|
19
|
+
apps: ActionProxy;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ZapierSdk } from "../types/sdk";
|
|
2
|
+
export interface ActionKeyResolver {
|
|
3
|
+
type: "dynamic";
|
|
4
|
+
depends: readonly string[];
|
|
5
|
+
fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
|
|
6
|
+
prompt: (items: any[], params: Record<string, any>) => any;
|
|
7
|
+
}
|
|
8
|
+
export declare const actionKeyResolver: ActionKeyResolver;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actionKeyResolver = void 0;
|
|
4
|
+
exports.actionKeyResolver = {
|
|
5
|
+
type: "dynamic",
|
|
6
|
+
depends: ["appKey", "actionType"],
|
|
7
|
+
fetch: async (sdk, resolvedParams) => {
|
|
8
|
+
const actions = await sdk.listActions({ appKey: resolvedParams.appKey });
|
|
9
|
+
return actions.filter((action) => action.type === resolvedParams.actionType);
|
|
10
|
+
},
|
|
11
|
+
prompt: (actions) => ({
|
|
12
|
+
type: "list",
|
|
13
|
+
name: "actionKey",
|
|
14
|
+
message: "Select action:",
|
|
15
|
+
choices: actions.map((action) => ({
|
|
16
|
+
name: `${action.name || action.key} - ${action.description || "No description"}`,
|
|
17
|
+
value: action.key,
|
|
18
|
+
})),
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ZapierSdk } from "../types/sdk";
|
|
2
|
+
export interface ActionTypeResolver {
|
|
3
|
+
type: "dynamic";
|
|
4
|
+
depends: readonly string[];
|
|
5
|
+
fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
|
|
6
|
+
prompt: (items: any[], params: Record<string, any>) => any;
|
|
7
|
+
}
|
|
8
|
+
export declare const actionTypeResolver: ActionTypeResolver;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actionTypeResolver = void 0;
|
|
4
|
+
exports.actionTypeResolver = {
|
|
5
|
+
type: "dynamic",
|
|
6
|
+
depends: ["appKey"],
|
|
7
|
+
fetch: async (sdk, resolvedParams) => {
|
|
8
|
+
const actions = await sdk.listActions({ appKey: resolvedParams.appKey });
|
|
9
|
+
const types = [...new Set(actions.map((action) => action.type))];
|
|
10
|
+
return types.map((type) => ({ key: type, name: type }));
|
|
11
|
+
},
|
|
12
|
+
prompt: (types) => ({
|
|
13
|
+
type: "list",
|
|
14
|
+
name: "actionType",
|
|
15
|
+
message: "Select action type:",
|
|
16
|
+
choices: types.map((type) => ({
|
|
17
|
+
name: type.name,
|
|
18
|
+
value: type.key,
|
|
19
|
+
})),
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ZapierSdk } from "../types/sdk";
|
|
2
|
+
export interface AuthenticationIdResolver {
|
|
3
|
+
type: "dynamic";
|
|
4
|
+
depends: readonly string[];
|
|
5
|
+
fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
|
|
6
|
+
prompt: (items: any[], params: Record<string, any>) => any;
|
|
7
|
+
}
|
|
8
|
+
export declare const authenticationIdResolver: AuthenticationIdResolver;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.authenticationIdResolver = void 0;
|
|
4
|
+
exports.authenticationIdResolver = {
|
|
5
|
+
type: "dynamic",
|
|
6
|
+
depends: ["appKey"],
|
|
7
|
+
fetch: async (sdk, resolvedParams) => {
|
|
8
|
+
// Get auths for the specific app (owned auths will be prioritized automatically)
|
|
9
|
+
return await sdk.listAuthentications({
|
|
10
|
+
appKey: resolvedParams.appKey,
|
|
11
|
+
limit: 1000,
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
prompt: (auths, params) => ({
|
|
15
|
+
type: "list",
|
|
16
|
+
name: "authenticationId",
|
|
17
|
+
message: `Select authentication for ${params.appKey}:`,
|
|
18
|
+
choices: [
|
|
19
|
+
...auths.map((auth) => ({
|
|
20
|
+
name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
|
|
21
|
+
value: auth.id,
|
|
22
|
+
})),
|
|
23
|
+
{
|
|
24
|
+
name: "↗ Skip authentication (may fail)",
|
|
25
|
+
value: null,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const resolverRegistry: {
|
|
2
|
+
readonly appKey: import("./appKey").AppKeyResolver;
|
|
3
|
+
readonly actionType: import("./actionType").ActionTypeResolver;
|
|
4
|
+
readonly actionKey: import("./actionKey").ActionKeyResolver;
|
|
5
|
+
readonly authenticationId: import("./authenticationId").AuthenticationIdResolver;
|
|
6
|
+
readonly inputs: import("./inputs").InputsResolver;
|
|
7
|
+
};
|
|
8
|
+
export type ResolverName = keyof typeof resolverRegistry;
|
|
9
|
+
export type ResolverType = (typeof resolverRegistry)[ResolverName];
|
|
10
|
+
/**
|
|
11
|
+
* Get a resolver by name
|
|
12
|
+
*/
|
|
13
|
+
export declare function getResolver(name: string): ResolverType | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get all resolvers for a list of missing parameters
|
|
16
|
+
*/
|
|
17
|
+
export declare function getResolversForMissingParams(missingParams: string[]): Record<string, ResolverType>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a parameter has a resolver
|
|
20
|
+
*/
|
|
21
|
+
export declare function hasResolver(paramName: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Get all parameter names that have resolvers
|
|
24
|
+
*/
|
|
25
|
+
export declare function getResolvableParams(): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Resolve dependency chain for a parameter
|
|
28
|
+
* Returns parameters in the order they need to be resolved
|
|
29
|
+
*/
|
|
30
|
+
export declare function getResolutionOrder(paramName: string, resolved?: Set<string>): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Get resolution order for multiple parameters
|
|
33
|
+
*/
|
|
34
|
+
export declare function getResolutionOrderForParams(paramNames: string[]): string[];
|
|
35
|
+
export { appKeyResolver } from "./appKey";
|
|
36
|
+
export { actionTypeResolver } from "./actionType";
|
|
37
|
+
export { actionKeyResolver } from "./actionKey";
|
|
38
|
+
export { authenticationIdResolver } from "./authenticationId";
|
|
39
|
+
export { inputsResolver } from "./inputs";
|