@zapier/zapier-sdk 0.3.1 → 0.4.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.
Files changed (162) hide show
  1. package/dist/index.cjs +1962 -0
  2. package/dist/index.d.mts +892 -0
  3. package/dist/index.d.ts +892 -20
  4. package/dist/index.mjs +1914 -0
  5. package/package.json +19 -7
  6. package/src/api/client.ts +106 -25
  7. package/src/api/polling.ts +4 -8
  8. package/src/api/types.ts +8 -1
  9. package/src/auth.ts +19 -287
  10. package/src/functions/findFirstAuthentication/schemas.ts +3 -13
  11. package/src/functions/findUniqueAuthentication/schemas.ts +3 -13
  12. package/src/functions/generateTypes/index.ts +15 -0
  13. package/src/functions/generateTypes/schemas.ts +3 -10
  14. package/src/functions/getAction/schemas.ts +3 -13
  15. package/src/functions/getApp/schemas.ts +2 -13
  16. package/src/functions/getAuthentication/index.ts +0 -1
  17. package/src/functions/getAuthentication/schemas.ts +3 -17
  18. package/src/functions/listActions/schemas.ts +3 -13
  19. package/src/functions/listApps/schemas.ts +2 -13
  20. package/src/functions/listAuthentications/index.ts +0 -1
  21. package/src/functions/listAuthentications/schemas.ts +3 -15
  22. package/src/functions/listFields/schemas.ts +3 -13
  23. package/src/functions/request/index.ts +150 -0
  24. package/src/functions/request/info.ts +11 -0
  25. package/src/functions/request/schemas.ts +53 -0
  26. package/src/functions/runAction/index.ts +0 -1
  27. package/src/functions/runAction/schemas.ts +6 -15
  28. package/src/index.ts +8 -2
  29. package/src/plugins/apps/index.ts +34 -9
  30. package/src/plugins/apps/types.ts +17 -1
  31. package/src/plugins/fetch/index.ts +50 -0
  32. package/src/plugins/fetch/types.ts +2 -0
  33. package/src/sdk.ts +19 -23
  34. package/src/types/domain.ts +16 -0
  35. package/src/types/sdk.ts +17 -2
  36. package/tsconfig.json +2 -2
  37. package/tsup.config.ts +21 -0
  38. package/dist/api/auth.d.ts +0 -8
  39. package/dist/api/auth.js +0 -29
  40. package/dist/api/client.d.ts +0 -8
  41. package/dist/api/client.js +0 -119
  42. package/dist/api/debug.d.ts +0 -12
  43. package/dist/api/debug.js +0 -50
  44. package/dist/api/index.d.ts +0 -28
  45. package/dist/api/index.js +0 -52
  46. package/dist/api/polling.d.ts +0 -17
  47. package/dist/api/polling.js +0 -34
  48. package/dist/api/types.d.ts +0 -147
  49. package/dist/api/types.js +0 -9
  50. package/dist/auth.d.ts +0 -59
  51. package/dist/auth.js +0 -261
  52. package/dist/functions/bundleCode/index.d.ts +0 -11
  53. package/dist/functions/bundleCode/index.js +0 -91
  54. package/dist/functions/bundleCode/info.d.ts +0 -27
  55. package/dist/functions/bundleCode/info.js +0 -11
  56. package/dist/functions/bundleCode/schemas.d.ts +0 -27
  57. package/dist/functions/bundleCode/schemas.js +0 -22
  58. package/dist/functions/findFirstAuthentication/index.d.ts +0 -12
  59. package/dist/functions/findFirstAuthentication/index.js +0 -21
  60. package/dist/functions/findFirstAuthentication/info.d.ts +0 -30
  61. package/dist/functions/findFirstAuthentication/info.js +0 -11
  62. package/dist/functions/findFirstAuthentication/schemas.d.ts +0 -42
  63. package/dist/functions/findFirstAuthentication/schemas.js +0 -25
  64. package/dist/functions/findUniqueAuthentication/index.d.ts +0 -13
  65. package/dist/functions/findUniqueAuthentication/index.js +0 -28
  66. package/dist/functions/findUniqueAuthentication/info.d.ts +0 -30
  67. package/dist/functions/findUniqueAuthentication/info.js +0 -11
  68. package/dist/functions/findUniqueAuthentication/schemas.d.ts +0 -42
  69. package/dist/functions/findUniqueAuthentication/schemas.js +0 -25
  70. package/dist/functions/generateTypes/index.d.ts +0 -11
  71. package/dist/functions/generateTypes/index.js +0 -305
  72. package/dist/functions/generateTypes/info.d.ts +0 -21
  73. package/dist/functions/generateTypes/info.js +0 -11
  74. package/dist/functions/generateTypes/schemas.d.ts +0 -30
  75. package/dist/functions/generateTypes/schemas.js +0 -14
  76. package/dist/functions/getAction/index.d.ts +0 -12
  77. package/dist/functions/getAction/index.js +0 -26
  78. package/dist/functions/getAction/info.d.ts +0 -18
  79. package/dist/functions/getAction/info.js +0 -11
  80. package/dist/functions/getAction/schemas.d.ts +0 -30
  81. package/dist/functions/getAction/schemas.js +0 -13
  82. package/dist/functions/getApp/index.d.ts +0 -12
  83. package/dist/functions/getApp/index.js +0 -37
  84. package/dist/functions/getApp/info.d.ts +0 -12
  85. package/dist/functions/getApp/info.js +0 -11
  86. package/dist/functions/getApp/schemas.d.ts +0 -24
  87. package/dist/functions/getApp/schemas.js +0 -11
  88. package/dist/functions/getAuthentication/index.d.ts +0 -13
  89. package/dist/functions/getAuthentication/index.js +0 -38
  90. package/dist/functions/getAuthentication/info.d.ts +0 -12
  91. package/dist/functions/getAuthentication/info.js +0 -11
  92. package/dist/functions/getAuthentication/schemas.d.ts +0 -26
  93. package/dist/functions/getAuthentication/schemas.js +0 -16
  94. package/dist/functions/listActions/index.d.ts +0 -12
  95. package/dist/functions/listActions/index.js +0 -128
  96. package/dist/functions/listActions/info.d.ts +0 -15
  97. package/dist/functions/listActions/info.js +0 -11
  98. package/dist/functions/listActions/schemas.d.ts +0 -27
  99. package/dist/functions/listActions/schemas.js +0 -14
  100. package/dist/functions/listApps/index.d.ts +0 -12
  101. package/dist/functions/listApps/index.js +0 -50
  102. package/dist/functions/listApps/info.d.ts +0 -18
  103. package/dist/functions/listApps/info.js +0 -11
  104. package/dist/functions/listApps/schemas.d.ts +0 -30
  105. package/dist/functions/listApps/schemas.js +0 -15
  106. package/dist/functions/listAuthentications/index.d.ts +0 -12
  107. package/dist/functions/listAuthentications/index.js +0 -131
  108. package/dist/functions/listAuthentications/info.d.ts +0 -30
  109. package/dist/functions/listAuthentications/info.js +0 -11
  110. package/dist/functions/listAuthentications/schemas.d.ts +0 -44
  111. package/dist/functions/listAuthentications/schemas.js +0 -25
  112. package/dist/functions/listFields/index.d.ts +0 -12
  113. package/dist/functions/listFields/index.js +0 -65
  114. package/dist/functions/listFields/info.d.ts +0 -24
  115. package/dist/functions/listFields/info.js +0 -11
  116. package/dist/functions/listFields/schemas.d.ts +0 -36
  117. package/dist/functions/listFields/schemas.js +0 -17
  118. package/dist/functions/runAction/index.d.ts +0 -12
  119. package/dist/functions/runAction/index.js +0 -86
  120. package/dist/functions/runAction/info.d.ts +0 -24
  121. package/dist/functions/runAction/info.js +0 -11
  122. package/dist/functions/runAction/schemas.d.ts +0 -38
  123. package/dist/functions/runAction/schemas.js +0 -15
  124. package/dist/index.js +0 -57
  125. package/dist/plugins/apps/index.d.ts +0 -8
  126. package/dist/plugins/apps/index.js +0 -77
  127. package/dist/plugins/apps/info.d.ts +0 -6
  128. package/dist/plugins/apps/info.js +0 -13
  129. package/dist/plugins/apps/types.d.ts +0 -21
  130. package/dist/plugins/apps/types.js +0 -2
  131. package/dist/resolvers/actionKey.d.ts +0 -8
  132. package/dist/resolvers/actionKey.js +0 -20
  133. package/dist/resolvers/actionType.d.ts +0 -8
  134. package/dist/resolvers/actionType.js +0 -21
  135. package/dist/resolvers/appKey.d.ts +0 -6
  136. package/dist/resolvers/appKey.js +0 -8
  137. package/dist/resolvers/authenticationId.d.ts +0 -8
  138. package/dist/resolvers/authenticationId.js +0 -29
  139. package/dist/resolvers/index.d.ts +0 -39
  140. package/dist/resolvers/index.js +0 -105
  141. package/dist/resolvers/inputs.d.ts +0 -7
  142. package/dist/resolvers/inputs.js +0 -15
  143. package/dist/schema-utils.d.ts +0 -44
  144. package/dist/schema-utils.js +0 -76
  145. package/dist/schemas/Action.d.ts +0 -21
  146. package/dist/schemas/Action.js +0 -31
  147. package/dist/schemas/App.d.ts +0 -19
  148. package/dist/schemas/App.js +0 -32
  149. package/dist/schemas/Auth.d.ts +0 -27
  150. package/dist/schemas/Auth.js +0 -42
  151. package/dist/schemas/Field.d.ts +0 -15
  152. package/dist/schemas/Field.js +0 -25
  153. package/dist/sdk.d.ts +0 -6
  154. package/dist/sdk.js +0 -90
  155. package/dist/types/domain.d.ts +0 -25
  156. package/dist/types/domain.js +0 -21
  157. package/dist/types/events.d.ts +0 -37
  158. package/dist/types/events.js +0 -8
  159. package/dist/types/properties.d.ts +0 -21
  160. package/dist/types/properties.js +0 -52
  161. package/dist/types/sdk.d.ts +0 -24
  162. package/dist/types/sdk.js +0 -2
@@ -1,44 +0,0 @@
1
- import { z } from "zod";
2
- import type { Authentication } from "../../types/domain";
3
- export declare const ListAuthenticationsSchema: z.ZodObject<{
4
- appKey: z.ZodOptional<z.ZodString>;
5
- search: z.ZodOptional<z.ZodString>;
6
- title: z.ZodOptional<z.ZodString>;
7
- account_id: z.ZodOptional<z.ZodString>;
8
- owner: z.ZodOptional<z.ZodString>;
9
- limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
10
- offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
11
- }, "strip", z.ZodTypeAny, {
12
- search?: string | undefined;
13
- appKey?: string | undefined;
14
- title?: string | undefined;
15
- account_id?: string | undefined;
16
- owner?: string | undefined;
17
- limit?: number | undefined;
18
- offset?: number | undefined;
19
- }, {
20
- search?: string | undefined;
21
- appKey?: string | undefined;
22
- title?: string | undefined;
23
- account_id?: string | undefined;
24
- owner?: string | undefined;
25
- limit?: number | undefined;
26
- offset?: number | undefined;
27
- }>;
28
- export type ListAuthenticationsOptions = z.infer<typeof ListAuthenticationsSchema> & {
29
- /** Base URL for Zapier API */
30
- baseUrl?: string;
31
- /** Authentication token */
32
- token?: string;
33
- /** Function to dynamically resolve authentication token */
34
- getToken?: () => Promise<string | undefined>;
35
- /** Optional pre-instantiated API client */
36
- api?: any;
37
- /** Enable debug logging */
38
- debug?: boolean;
39
- /** Custom fetch implementation */
40
- fetch?: typeof globalThis.fetch;
41
- };
42
- export interface ListAuthenticationsSdkFunction {
43
- listAuthentications: (options?: Partial<ListAuthenticationsOptions>) => Promise<Authentication[]>;
44
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ListAuthenticationsSchema = 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 Auth_1 = require("../../schemas/Auth");
8
- // Pure Zod schema - no resolver metadata!
9
- exports.ListAuthenticationsSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
10
- .object({
11
- appKey: properties_1.AppKeyPropertySchema.optional().describe("App slug to get authentications for (e.g., 'slack', 'github')"),
12
- search: zod_1.z
13
- .string()
14
- .optional()
15
- .describe("Search term to filter authentications by title"),
16
- title: zod_1.z
17
- .string()
18
- .optional()
19
- .describe("Filter authentications by exact title match"),
20
- account_id: zod_1.z.string().optional().describe("Filter by account ID"),
21
- owner: zod_1.z.string().optional().describe("Filter by owner"),
22
- limit: properties_1.LimitPropertySchema.optional().describe("Maximum number of items to return (1-200)"),
23
- offset: properties_1.OffsetPropertySchema.optional().describe("Number of items to skip for pagination"),
24
- })
25
- .describe("List available authentications with optional filtering"), Auth_1.AuthItemSchema);
@@ -1,12 +0,0 @@
1
- import type { ActionField } from "../../types/domain";
2
- import type { ListFieldsOptions } from "./schemas";
3
- /**
4
- * List available fields for an action
5
- *
6
- * This function can be used standalone without instantiating a full SDK,
7
- * which enables better tree-shaking in applications that only need this functionality.
8
- *
9
- * @param options - Action details, authentication ID, params, and API configuration options
10
- * @returns Promise<ActionField[]>
11
- */
12
- export declare function listFields(options: ListFieldsOptions): Promise<ActionField[]>;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listFields = listFields;
4
- const api_1 = require("../../api");
5
- const getApp_1 = require("../getApp");
6
- /**
7
- * List available fields for an action
8
- *
9
- * This function can be used standalone without instantiating a full SDK,
10
- * which enables better tree-shaking in applications that only need this functionality.
11
- *
12
- * @param options - Action details, authentication ID, params, and API configuration options
13
- * @returns Promise<ActionField[]>
14
- */
15
- async function listFields(options) {
16
- const api = (0, api_1.getOrCreateApiClient)(options);
17
- // Extract parameters
18
- const { appKey, actionKey, actionType, authenticationId, params } = options;
19
- // Use the standalone getApp function
20
- const appData = await (0, getApp_1.getApp)({
21
- appKey,
22
- api,
23
- token: options.token,
24
- baseUrl: options.baseUrl,
25
- debug: options.debug,
26
- fetch: options.fetch,
27
- });
28
- const selectedApi = appData.current_implementation_id;
29
- if (!selectedApi) {
30
- throw new Error("No current_implementation_id found for app");
31
- }
32
- // Build needs request
33
- const needsRequest = {
34
- selected_api: selectedApi,
35
- action: actionKey,
36
- type_of: actionType,
37
- authentication_id: authenticationId,
38
- params: params || {},
39
- };
40
- const needsData = await api.post("/api/v4/implementations/needs/", needsRequest);
41
- if (!needsData.success) {
42
- throw new Error(`Failed to get action fields: ${needsData.errors?.join(", ") || "Unknown error"}`);
43
- }
44
- // Transform API response to our ActionField interface
45
- return (needsData.needs || []).map((need) => ({
46
- key: need.key,
47
- label: need.label,
48
- required: need.required || false,
49
- type: need.type,
50
- helpText: need.help_text,
51
- helpTextHtml: need.help_text_html,
52
- choices: need.choices?.map((choice) => ({
53
- value: choice.value,
54
- label: choice.label,
55
- })),
56
- default: need.default,
57
- placeholder: need.placeholder,
58
- computed: need.computed,
59
- customField: need.custom_field,
60
- dependsOn: need.depends_on,
61
- format: need.format,
62
- inputFormat: need.input_format,
63
- }));
64
- }
65
- // No registry info here - moved to info.ts for proper tree-shaking
@@ -1,24 +0,0 @@
1
- import { listFields } from "./index";
2
- export declare const listFieldsInfo: {
3
- name: string;
4
- inputSchema: import("zod").ZodObject<{
5
- appKey: import("zod").ZodString;
6
- actionType: import("zod").ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
7
- actionKey: import("zod").ZodString;
8
- authenticationId: import("zod").ZodOptional<import("zod").ZodNumber>;
9
- params: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
10
- }, "strip", import("zod").ZodTypeAny, {
11
- appKey: string;
12
- actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
13
- actionKey: string;
14
- params?: Record<string, any> | undefined;
15
- authenticationId?: number | undefined;
16
- }, {
17
- appKey: string;
18
- actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
19
- actionKey: string;
20
- params?: Record<string, any> | undefined;
21
- authenticationId?: number | undefined;
22
- }>;
23
- implementation: typeof listFields;
24
- };
@@ -1,11 +0,0 @@
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
- };
@@ -1,36 +0,0 @@
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", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
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: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
12
- actionKey: string;
13
- params?: Record<string, any> | undefined;
14
- authenticationId?: number | undefined;
15
- }, {
16
- appKey: string;
17
- actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
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
- }
@@ -1,17 +0,0 @@
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,12 +0,0 @@
1
- import type { ActionExecutionResult } from "../../types/domain";
2
- import type { RunActionOptions } from "./schemas";
3
- /**
4
- * Execute an action
5
- *
6
- * This function can be used standalone without instantiating a full SDK,
7
- * which enables better tree-shaking in applications that only need this functionality.
8
- *
9
- * @param options - Action execution parameters and API configuration options
10
- * @returns Promise<ActionExecutionResult>
11
- */
12
- export declare function runAction(options: RunActionOptions): Promise<ActionExecutionResult>;
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runAction = runAction;
4
- const api_1 = require("../../api");
5
- const getAction_1 = require("../getAction");
6
- const getApp_1 = require("../getApp");
7
- /**
8
- * Execute an action
9
- *
10
- * This function can be used standalone without instantiating a full SDK,
11
- * which enables better tree-shaking in applications that only need this functionality.
12
- *
13
- * @param options - Action execution parameters and API configuration options
14
- * @returns Promise<ActionExecutionResult>
15
- */
16
- async function runAction(options) {
17
- const { appKey, actionType, actionKey, inputs, authenticationId: providedAuthenticationId, } = options;
18
- const api = (0, api_1.getOrCreateApiClient)(options);
19
- api.requireAuthTo("run actions");
20
- // Validate that the action exists
21
- const actionData = await (0, getAction_1.getAction)({
22
- ...options,
23
- appKey: appKey,
24
- actionKey: actionKey,
25
- actionType: actionType,
26
- });
27
- // Validate action type matches
28
- if (actionData.type !== actionType) {
29
- throw new Error(`Action type mismatch: expected ${actionType}, got ${actionData.type}`);
30
- }
31
- // Execute the action using the Actions API (supports all action types)
32
- const startTime = Date.now();
33
- const result = await executeAction({
34
- api,
35
- appSlug: appKey,
36
- actionKey: actionKey,
37
- actionType: actionData.type,
38
- executionOptions: { inputs: inputs || {} },
39
- authenticationId: providedAuthenticationId,
40
- options,
41
- });
42
- const executionTime = Date.now() - startTime;
43
- return {
44
- success: true,
45
- data: result,
46
- metadata: {
47
- executionTime,
48
- requestId: (0, api_1.generateRequestId)(),
49
- },
50
- };
51
- }
52
- async function executeAction(actionOptions) {
53
- const { api, appSlug, actionKey, actionType, executionOptions, authenticationId, options, } = actionOptions;
54
- // Use the standalone getApp function
55
- const appData = await (0, getApp_1.getApp)({
56
- appKey: appSlug,
57
- api,
58
- token: options.token,
59
- baseUrl: options.baseUrl,
60
- debug: options.debug,
61
- fetch: options.fetch,
62
- });
63
- const selectedApi = appData.current_implementation_id;
64
- if (!selectedApi) {
65
- throw new Error("No current_implementation_id found for app");
66
- }
67
- // Step 1: POST to /actions/v1/runs to start execution
68
- const runRequest = {
69
- data: {
70
- authentication_id: authenticationId || 1,
71
- selected_api: selectedApi,
72
- action_key: actionKey,
73
- action_type: actionType,
74
- inputs: executionOptions.inputs || {},
75
- },
76
- };
77
- const runData = await api.post("/api/actions/v1/runs", runRequest);
78
- const runId = runData.data.id;
79
- // Step 2: Poll GET /actions/v1/runs/{run_id} for results
80
- return await api.poll(`/api/actions/v1/runs/${runId}`, {
81
- successStatus: 200,
82
- pendingStatus: 202,
83
- resultExtractor: (result) => result.data,
84
- });
85
- }
86
- // No registry info here - moved to info.ts for proper tree-shaking
@@ -1,24 +0,0 @@
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", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
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: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
13
- actionKey: string;
14
- inputs?: Record<string, any> | undefined;
15
- authenticationId?: number | undefined;
16
- }, {
17
- appKey: string;
18
- actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
19
- actionKey: string;
20
- inputs?: Record<string, any> | undefined;
21
- authenticationId?: number | undefined;
22
- }>;
23
- implementation: typeof runAction;
24
- };
@@ -1,11 +0,0 @@
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
- };
@@ -1,38 +0,0 @@
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", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
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: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
12
- actionKey: string;
13
- inputs?: Record<string, any> | undefined;
14
- authenticationId?: number | undefined;
15
- }, {
16
- appKey: string;
17
- actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
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
- /** Function to dynamically resolve authentication token */
28
- getToken?: () => Promise<string | undefined>;
29
- /** Optional pre-instantiated API client */
30
- api?: any;
31
- /** Enable debug logging */
32
- debug?: boolean;
33
- /** Custom fetch implementation */
34
- fetch?: typeof globalThis.fetch;
35
- };
36
- export interface RunActionSdkFunction {
37
- runAction: (options: RunActionOptions) => Promise<ActionExecutionResult>;
38
- }
@@ -1,15 +0,0 @@
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.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
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.findUniqueAuthentication = exports.findFirstAuthentication = exports.getAuthentication = 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 auth utilities for CLI use
26
- __exportStar(require("./auth"), exports);
27
- // Export resolvers for CLI use
28
- __exportStar(require("./resolvers"), exports);
29
- // Note: SdkSchemas is now available via SDK.__registry
30
- // Export individual functions for tree-shaking
31
- var listAuthentications_1 = require("./functions/listAuthentications");
32
- Object.defineProperty(exports, "listAuthentications", { enumerable: true, get: function () { return listAuthentications_1.listAuthentications; } });
33
- var getAuthentication_1 = require("./functions/getAuthentication");
34
- Object.defineProperty(exports, "getAuthentication", { enumerable: true, get: function () { return getAuthentication_1.getAuthentication; } });
35
- var findFirstAuthentication_1 = require("./functions/findFirstAuthentication");
36
- Object.defineProperty(exports, "findFirstAuthentication", { enumerable: true, get: function () { return findFirstAuthentication_1.findFirstAuthentication; } });
37
- var findUniqueAuthentication_1 = require("./functions/findUniqueAuthentication");
38
- Object.defineProperty(exports, "findUniqueAuthentication", { enumerable: true, get: function () { return findUniqueAuthentication_1.findUniqueAuthentication; } });
39
- var listApps_1 = require("./functions/listApps");
40
- Object.defineProperty(exports, "listApps", { enumerable: true, get: function () { return listApps_1.listApps; } });
41
- var getApp_1 = require("./functions/getApp");
42
- Object.defineProperty(exports, "getApp", { enumerable: true, get: function () { return getApp_1.getApp; } });
43
- var listActions_1 = require("./functions/listActions");
44
- Object.defineProperty(exports, "listActions", { enumerable: true, get: function () { return listActions_1.listActions; } });
45
- var getAction_1 = require("./functions/getAction");
46
- Object.defineProperty(exports, "getAction", { enumerable: true, get: function () { return getAction_1.getAction; } });
47
- var runAction_1 = require("./functions/runAction");
48
- Object.defineProperty(exports, "runAction", { enumerable: true, get: function () { return runAction_1.runAction; } });
49
- var listFields_1 = require("./functions/listFields");
50
- Object.defineProperty(exports, "listFields", { enumerable: true, get: function () { return listFields_1.listFields; } });
51
- var generateTypes_1 = require("./functions/generateTypes");
52
- Object.defineProperty(exports, "generateTypes", { enumerable: true, get: function () { return generateTypes_1.generateTypes; } });
53
- var bundleCode_1 = require("./functions/bundleCode");
54
- Object.defineProperty(exports, "bundleCode", { enumerable: true, get: function () { return bundleCode_1.bundleCode; } });
55
- // Export the main combined SDK
56
- var sdk_1 = require("./sdk");
57
- Object.defineProperty(exports, "createZapierSdk", { enumerable: true, get: function () { return sdk_1.createZapierSdk; } });
@@ -1,8 +0,0 @@
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";
@@ -1,77 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- import type { AppsPluginOptions } from "./index";
2
- export declare const appsPluginInfo: {
3
- plugin: (_sdk: any, options: AppsPluginOptions) => {
4
- apps: import("./types").ActionProxy;
5
- };
6
- };
@@ -1,13 +0,0 @@
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
- };
@@ -1,21 +0,0 @@
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 {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
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;