@zapier/zapier-sdk 0.3.0 → 0.4.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.
Files changed (158) hide show
  1. package/dist/index.cjs +2001 -0
  2. package/dist/index.d.mts +840 -0
  3. package/dist/index.d.ts +840 -20
  4. package/dist/index.mjs +1955 -0
  5. package/package.json +19 -7
  6. package/src/api/client.ts +84 -16
  7. package/src/api/types.ts +9 -1
  8. package/src/auth.ts +19 -287
  9. package/src/functions/fetch/index.ts +180 -0
  10. package/src/functions/fetch/info.ts +8 -0
  11. package/src/functions/fetch/schemas.ts +46 -0
  12. package/src/functions/findFirstAuthentication/schemas.ts +3 -13
  13. package/src/functions/findUniqueAuthentication/schemas.ts +3 -13
  14. package/src/functions/generateTypes/index.ts +15 -0
  15. package/src/functions/generateTypes/schemas.ts +3 -10
  16. package/src/functions/getAction/schemas.ts +3 -13
  17. package/src/functions/getApp/schemas.ts +2 -13
  18. package/src/functions/getAuthentication/index.ts +0 -1
  19. package/src/functions/getAuthentication/schemas.ts +3 -17
  20. package/src/functions/listActions/schemas.ts +3 -13
  21. package/src/functions/listApps/schemas.ts +2 -13
  22. package/src/functions/listAuthentications/index.ts +0 -1
  23. package/src/functions/listAuthentications/schemas.ts +3 -15
  24. package/src/functions/listFields/schemas.ts +3 -13
  25. package/src/functions/runAction/index.ts +0 -1
  26. package/src/functions/runAction/schemas.ts +6 -15
  27. package/src/index.ts +4 -2
  28. package/src/plugins/apps/index.ts +35 -9
  29. package/src/sdk.ts +20 -22
  30. package/src/types/domain.ts +16 -0
  31. package/src/types/sdk.ts +13 -1
  32. package/tsconfig.json +2 -2
  33. package/tsup.config.ts +21 -0
  34. package/dist/api/auth.d.ts +0 -8
  35. package/dist/api/auth.js +0 -29
  36. package/dist/api/client.d.ts +0 -8
  37. package/dist/api/client.js +0 -119
  38. package/dist/api/debug.d.ts +0 -12
  39. package/dist/api/debug.js +0 -50
  40. package/dist/api/index.d.ts +0 -28
  41. package/dist/api/index.js +0 -52
  42. package/dist/api/polling.d.ts +0 -17
  43. package/dist/api/polling.js +0 -34
  44. package/dist/api/types.d.ts +0 -147
  45. package/dist/api/types.js +0 -9
  46. package/dist/auth.d.ts +0 -59
  47. package/dist/auth.js +0 -261
  48. package/dist/functions/bundleCode/index.d.ts +0 -11
  49. package/dist/functions/bundleCode/index.js +0 -91
  50. package/dist/functions/bundleCode/info.d.ts +0 -27
  51. package/dist/functions/bundleCode/info.js +0 -11
  52. package/dist/functions/bundleCode/schemas.d.ts +0 -27
  53. package/dist/functions/bundleCode/schemas.js +0 -22
  54. package/dist/functions/findFirstAuthentication/index.d.ts +0 -12
  55. package/dist/functions/findFirstAuthentication/index.js +0 -21
  56. package/dist/functions/findFirstAuthentication/info.d.ts +0 -30
  57. package/dist/functions/findFirstAuthentication/info.js +0 -11
  58. package/dist/functions/findFirstAuthentication/schemas.d.ts +0 -42
  59. package/dist/functions/findFirstAuthentication/schemas.js +0 -25
  60. package/dist/functions/findUniqueAuthentication/index.d.ts +0 -13
  61. package/dist/functions/findUniqueAuthentication/index.js +0 -28
  62. package/dist/functions/findUniqueAuthentication/info.d.ts +0 -30
  63. package/dist/functions/findUniqueAuthentication/info.js +0 -11
  64. package/dist/functions/findUniqueAuthentication/schemas.d.ts +0 -42
  65. package/dist/functions/findUniqueAuthentication/schemas.js +0 -25
  66. package/dist/functions/generateTypes/index.d.ts +0 -11
  67. package/dist/functions/generateTypes/index.js +0 -305
  68. package/dist/functions/generateTypes/info.d.ts +0 -21
  69. package/dist/functions/generateTypes/info.js +0 -11
  70. package/dist/functions/generateTypes/schemas.d.ts +0 -30
  71. package/dist/functions/generateTypes/schemas.js +0 -14
  72. package/dist/functions/getAction/index.d.ts +0 -12
  73. package/dist/functions/getAction/index.js +0 -26
  74. package/dist/functions/getAction/info.d.ts +0 -18
  75. package/dist/functions/getAction/info.js +0 -11
  76. package/dist/functions/getAction/schemas.d.ts +0 -30
  77. package/dist/functions/getAction/schemas.js +0 -13
  78. package/dist/functions/getApp/index.d.ts +0 -12
  79. package/dist/functions/getApp/index.js +0 -37
  80. package/dist/functions/getApp/info.d.ts +0 -12
  81. package/dist/functions/getApp/info.js +0 -11
  82. package/dist/functions/getApp/schemas.d.ts +0 -24
  83. package/dist/functions/getApp/schemas.js +0 -11
  84. package/dist/functions/getAuthentication/index.d.ts +0 -13
  85. package/dist/functions/getAuthentication/index.js +0 -38
  86. package/dist/functions/getAuthentication/info.d.ts +0 -12
  87. package/dist/functions/getAuthentication/info.js +0 -11
  88. package/dist/functions/getAuthentication/schemas.d.ts +0 -26
  89. package/dist/functions/getAuthentication/schemas.js +0 -16
  90. package/dist/functions/listActions/index.d.ts +0 -12
  91. package/dist/functions/listActions/index.js +0 -128
  92. package/dist/functions/listActions/info.d.ts +0 -15
  93. package/dist/functions/listActions/info.js +0 -11
  94. package/dist/functions/listActions/schemas.d.ts +0 -27
  95. package/dist/functions/listActions/schemas.js +0 -14
  96. package/dist/functions/listApps/index.d.ts +0 -12
  97. package/dist/functions/listApps/index.js +0 -50
  98. package/dist/functions/listApps/info.d.ts +0 -18
  99. package/dist/functions/listApps/info.js +0 -11
  100. package/dist/functions/listApps/schemas.d.ts +0 -30
  101. package/dist/functions/listApps/schemas.js +0 -15
  102. package/dist/functions/listAuthentications/index.d.ts +0 -12
  103. package/dist/functions/listAuthentications/index.js +0 -131
  104. package/dist/functions/listAuthentications/info.d.ts +0 -30
  105. package/dist/functions/listAuthentications/info.js +0 -11
  106. package/dist/functions/listAuthentications/schemas.d.ts +0 -44
  107. package/dist/functions/listAuthentications/schemas.js +0 -25
  108. package/dist/functions/listFields/index.d.ts +0 -12
  109. package/dist/functions/listFields/index.js +0 -65
  110. package/dist/functions/listFields/info.d.ts +0 -24
  111. package/dist/functions/listFields/info.js +0 -11
  112. package/dist/functions/listFields/schemas.d.ts +0 -36
  113. package/dist/functions/listFields/schemas.js +0 -17
  114. package/dist/functions/runAction/index.d.ts +0 -12
  115. package/dist/functions/runAction/index.js +0 -86
  116. package/dist/functions/runAction/info.d.ts +0 -24
  117. package/dist/functions/runAction/info.js +0 -11
  118. package/dist/functions/runAction/schemas.d.ts +0 -38
  119. package/dist/functions/runAction/schemas.js +0 -15
  120. package/dist/index.js +0 -57
  121. package/dist/plugins/apps/index.d.ts +0 -8
  122. package/dist/plugins/apps/index.js +0 -77
  123. package/dist/plugins/apps/info.d.ts +0 -6
  124. package/dist/plugins/apps/info.js +0 -13
  125. package/dist/plugins/apps/types.d.ts +0 -21
  126. package/dist/plugins/apps/types.js +0 -2
  127. package/dist/resolvers/actionKey.d.ts +0 -8
  128. package/dist/resolvers/actionKey.js +0 -20
  129. package/dist/resolvers/actionType.d.ts +0 -8
  130. package/dist/resolvers/actionType.js +0 -21
  131. package/dist/resolvers/appKey.d.ts +0 -6
  132. package/dist/resolvers/appKey.js +0 -8
  133. package/dist/resolvers/authenticationId.d.ts +0 -8
  134. package/dist/resolvers/authenticationId.js +0 -29
  135. package/dist/resolvers/index.d.ts +0 -39
  136. package/dist/resolvers/index.js +0 -105
  137. package/dist/resolvers/inputs.d.ts +0 -7
  138. package/dist/resolvers/inputs.js +0 -15
  139. package/dist/schema-utils.d.ts +0 -44
  140. package/dist/schema-utils.js +0 -76
  141. package/dist/schemas/Action.d.ts +0 -21
  142. package/dist/schemas/Action.js +0 -31
  143. package/dist/schemas/App.d.ts +0 -19
  144. package/dist/schemas/App.js +0 -32
  145. package/dist/schemas/Auth.d.ts +0 -27
  146. package/dist/schemas/Auth.js +0 -42
  147. package/dist/schemas/Field.d.ts +0 -15
  148. package/dist/schemas/Field.js +0 -25
  149. package/dist/sdk.d.ts +0 -6
  150. package/dist/sdk.js +0 -90
  151. package/dist/types/domain.d.ts +0 -25
  152. package/dist/types/domain.js +0 -21
  153. package/dist/types/events.d.ts +0 -37
  154. package/dist/types/events.js +0 -8
  155. package/dist/types/properties.d.ts +0 -21
  156. package/dist/types/properties.js +0 -52
  157. package/dist/types/sdk.d.ts +0 -24
  158. package/dist/types/sdk.js +0 -2
@@ -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;
@@ -1,20 +0,0 @@
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
- };
@@ -1,8 +0,0 @@
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;
@@ -1,21 +0,0 @@
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
- };
@@ -1,6 +0,0 @@
1
- export interface AppKeyResolver {
2
- type: "static";
3
- inputType?: "text" | "password" | "email";
4
- placeholder?: string;
5
- }
6
- export declare const appKeyResolver: AppKeyResolver;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appKeyResolver = void 0;
4
- exports.appKeyResolver = {
5
- type: "static",
6
- inputType: "text",
7
- placeholder: "Enter app slug (e.g., 'slack', 'github')",
8
- };
@@ -1,8 +0,0 @@
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;
@@ -1,29 +0,0 @@
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
- };
@@ -1,39 +0,0 @@
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";
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inputsResolver = exports.authenticationIdResolver = exports.actionKeyResolver = exports.actionTypeResolver = exports.appKeyResolver = exports.resolverRegistry = void 0;
4
- exports.getResolver = getResolver;
5
- exports.getResolversForMissingParams = getResolversForMissingParams;
6
- exports.hasResolver = hasResolver;
7
- exports.getResolvableParams = getResolvableParams;
8
- exports.getResolutionOrder = getResolutionOrder;
9
- exports.getResolutionOrderForParams = getResolutionOrderForParams;
10
- const appKey_1 = require("./appKey");
11
- const actionType_1 = require("./actionType");
12
- const actionKey_1 = require("./actionKey");
13
- const authenticationId_1 = require("./authenticationId");
14
- const inputs_1 = require("./inputs");
15
- // Centralized resolver registry
16
- exports.resolverRegistry = {
17
- appKey: appKey_1.appKeyResolver,
18
- actionType: actionType_1.actionTypeResolver,
19
- actionKey: actionKey_1.actionKeyResolver,
20
- authenticationId: authenticationId_1.authenticationIdResolver,
21
- inputs: inputs_1.inputsResolver,
22
- };
23
- // Utility functions for working with resolvers
24
- /**
25
- * Get a resolver by name
26
- */
27
- function getResolver(name) {
28
- return exports.resolverRegistry[name];
29
- }
30
- /**
31
- * Get all resolvers for a list of missing parameters
32
- */
33
- function getResolversForMissingParams(missingParams) {
34
- const resolvers = {};
35
- for (const param of missingParams) {
36
- const resolver = exports.resolverRegistry[param];
37
- if (resolver) {
38
- resolvers[param] = resolver;
39
- }
40
- }
41
- return resolvers;
42
- }
43
- /**
44
- * Check if a parameter has a resolver
45
- */
46
- function hasResolver(paramName) {
47
- return paramName in exports.resolverRegistry;
48
- }
49
- /**
50
- * Get all parameter names that have resolvers
51
- */
52
- function getResolvableParams() {
53
- return Object.keys(exports.resolverRegistry);
54
- }
55
- /**
56
- * Resolve dependency chain for a parameter
57
- * Returns parameters in the order they need to be resolved
58
- */
59
- function getResolutionOrder(paramName, resolved = new Set()) {
60
- const resolver = getResolver(paramName);
61
- if (!resolver || resolver.type === "static") {
62
- return [paramName];
63
- }
64
- const order = [];
65
- if ("depends" in resolver && resolver.depends) {
66
- for (const dependency of resolver.depends) {
67
- if (!resolved.has(dependency)) {
68
- order.push(...getResolutionOrder(dependency, resolved));
69
- resolved.add(dependency);
70
- }
71
- }
72
- }
73
- if (!resolved.has(paramName)) {
74
- order.push(paramName);
75
- resolved.add(paramName);
76
- }
77
- return order;
78
- }
79
- /**
80
- * Get resolution order for multiple parameters
81
- */
82
- function getResolutionOrderForParams(paramNames) {
83
- const resolved = new Set();
84
- const order = [];
85
- for (const paramName of paramNames) {
86
- const paramOrder = getResolutionOrder(paramName, resolved);
87
- for (const param of paramOrder) {
88
- if (!order.includes(param)) {
89
- order.push(param);
90
- }
91
- }
92
- }
93
- return order;
94
- }
95
- // Re-export individual resolvers for direct access if needed
96
- var appKey_2 = require("./appKey");
97
- Object.defineProperty(exports, "appKeyResolver", { enumerable: true, get: function () { return appKey_2.appKeyResolver; } });
98
- var actionType_2 = require("./actionType");
99
- Object.defineProperty(exports, "actionTypeResolver", { enumerable: true, get: function () { return actionType_2.actionTypeResolver; } });
100
- var actionKey_2 = require("./actionKey");
101
- Object.defineProperty(exports, "actionKeyResolver", { enumerable: true, get: function () { return actionKey_2.actionKeyResolver; } });
102
- var authenticationId_2 = require("./authenticationId");
103
- Object.defineProperty(exports, "authenticationIdResolver", { enumerable: true, get: function () { return authenticationId_2.authenticationIdResolver; } });
104
- var inputs_2 = require("./inputs");
105
- Object.defineProperty(exports, "inputsResolver", { enumerable: true, get: function () { return inputs_2.inputsResolver; } });
@@ -1,7 +0,0 @@
1
- import type { ZapierSdk } from "../types/sdk";
2
- export interface InputsResolver {
3
- type: "fields";
4
- depends: readonly string[];
5
- fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
6
- }
7
- export declare const inputsResolver: InputsResolver;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inputsResolver = void 0;
4
- exports.inputsResolver = {
5
- type: "fields",
6
- depends: ["appKey", "actionKey", "actionType", "authenticationId"],
7
- fetch: async (sdk, resolvedParams) => {
8
- return await sdk.listFields({
9
- appKey: resolvedParams.appKey,
10
- actionKey: resolvedParams.actionKey,
11
- actionType: resolvedParams.actionType,
12
- authenticationId: resolvedParams.authenticationId,
13
- });
14
- },
15
- };
@@ -1,44 +0,0 @@
1
- import { z } from "zod";
2
- export interface FormattedItem {
3
- title: string;
4
- subtitle?: string;
5
- details: Array<{
6
- text: string;
7
- style: "normal" | "dim" | "accent" | "warning" | "success";
8
- }>;
9
- }
10
- export interface FormatMetadata {
11
- format: (item: any) => FormattedItem;
12
- }
13
- export declare function withFormatter<T extends z.ZodType>(schema: T, formatMeta: FormatMetadata): T;
14
- export declare function getFormatMetadata(schema: z.ZodType): FormatMetadata | undefined;
15
- export declare function withOutputSchema<T extends z.ZodType>(inputSchema: T, outputSchema: z.ZodType): T;
16
- export declare function getOutputSchema(inputSchema: z.ZodType): z.ZodType | undefined;
17
- export interface StaticResolver {
18
- type: "static";
19
- inputType?: "text" | "password" | "email";
20
- placeholder?: string;
21
- }
22
- export interface DynamicResolver {
23
- type: "dynamic";
24
- fetch: (sdk: any, resolvedParams: any) => Promise<any[]>;
25
- prompt: (items: any[], params: any) => any;
26
- depends?: string[];
27
- }
28
- export interface FieldsResolver {
29
- type: "fields";
30
- fetch: (sdk: any, resolvedParams: any) => Promise<any[]>;
31
- depends?: string[];
32
- }
33
- export type ResolverMetadata = StaticResolver | DynamicResolver | FieldsResolver;
34
- export interface ResolverConfig {
35
- resolver: ResolverMetadata;
36
- }
37
- export declare function withResolver<T extends z.ZodType>(schema: T, config: ResolverConfig): T;
38
- export declare function getSchemaDescription(schema: z.ZodSchema): string | undefined;
39
- export declare function getFieldDescriptions(schema: z.ZodObject<any>): Record<string, string>;
40
- export interface PositionalMetadata {
41
- positional: true;
42
- }
43
- export declare function withPositional<T extends z.ZodType>(schema: T): T;
44
- export declare function isPositional(schema: z.ZodType): boolean;