@zapier/zapier-sdk 0.0.3 → 0.1.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 (171) hide show
  1. package/dist/api/auth.d.ts +8 -0
  2. package/dist/api/auth.js +29 -0
  3. package/dist/api/client.d.ts +8 -0
  4. package/dist/api/client.js +102 -0
  5. package/dist/api/debug.d.ts +12 -0
  6. package/dist/api/debug.js +50 -0
  7. package/dist/api/index.d.ts +26 -0
  8. package/dist/api/index.js +51 -0
  9. package/dist/api/polling.d.ts +17 -0
  10. package/dist/api/polling.js +34 -0
  11. package/dist/{types.d.ts → api/types.d.ts} +37 -88
  12. package/dist/api/types.js +9 -0
  13. package/dist/functions/{bundleCode.d.ts → bundleCode/index.d.ts} +1 -8
  14. package/dist/functions/bundleCode/info.d.ts +27 -0
  15. package/dist/functions/bundleCode/info.js +11 -0
  16. package/dist/functions/bundleCode/schemas.d.ts +27 -0
  17. package/dist/functions/bundleCode/schemas.js +22 -0
  18. package/dist/functions/{generateTypes.d.ts → generateTypes/index.d.ts} +2 -7
  19. package/dist/functions/{generateTypes.js → generateTypes/index.js} +58 -24
  20. package/dist/functions/generateTypes/info.d.ts +21 -0
  21. package/dist/functions/generateTypes/info.js +11 -0
  22. package/dist/functions/generateTypes/schemas.d.ts +30 -0
  23. package/dist/functions/generateTypes/schemas.js +14 -0
  24. package/dist/functions/{getAction.d.ts → getAction/index.d.ts} +2 -6
  25. package/dist/functions/{getAction.js → getAction/index.js} +6 -5
  26. package/dist/functions/getAction/info.d.ts +18 -0
  27. package/dist/functions/getAction/info.js +11 -0
  28. package/dist/functions/getAction/schemas.d.ts +30 -0
  29. package/dist/functions/getAction/schemas.js +13 -0
  30. package/dist/functions/{getApp.d.ts → getApp/index.d.ts} +2 -4
  31. package/dist/functions/{getApp.js → getApp/index.js} +6 -10
  32. package/dist/functions/getApp/info.d.ts +12 -0
  33. package/dist/functions/getApp/info.js +11 -0
  34. package/dist/functions/getApp/schemas.d.ts +24 -0
  35. package/dist/functions/getApp/schemas.js +11 -0
  36. package/dist/functions/{listActions.d.ts → listActions/index.d.ts} +3 -6
  37. package/dist/functions/{listActions.js → listActions/index.js} +4 -3
  38. package/dist/functions/listActions/info.d.ts +15 -0
  39. package/dist/functions/listActions/info.js +11 -0
  40. package/dist/functions/listActions/schemas.d.ts +27 -0
  41. package/dist/functions/listActions/schemas.js +14 -0
  42. package/dist/functions/{listApps.d.ts → listApps/index.d.ts} +2 -6
  43. package/dist/functions/{listApps.js → listApps/index.js} +1 -1
  44. package/dist/functions/listApps/info.d.ts +18 -0
  45. package/dist/functions/listApps/info.js +11 -0
  46. package/dist/functions/listApps/schemas.d.ts +30 -0
  47. package/dist/functions/listApps/schemas.js +15 -0
  48. package/dist/functions/{listAuths.d.ts → listAuths/index.d.ts} +3 -9
  49. package/dist/functions/{listAuths.js → listAuths/index.js} +5 -5
  50. package/dist/functions/listAuths/info.d.ts +24 -0
  51. package/dist/functions/listAuths/info.js +11 -0
  52. package/dist/functions/listAuths/schemas.d.ts +36 -0
  53. package/dist/functions/listAuths/schemas.js +17 -0
  54. package/dist/functions/{listFields.d.ts → listFields/index.d.ts} +3 -9
  55. package/dist/functions/{listFields.js → listFields/index.js} +8 -10
  56. package/dist/functions/listFields/info.d.ts +24 -0
  57. package/dist/functions/listFields/info.js +11 -0
  58. package/dist/functions/listFields/schemas.d.ts +36 -0
  59. package/dist/functions/listFields/schemas.js +17 -0
  60. package/dist/functions/{runAction.d.ts → runAction/index.d.ts} +2 -8
  61. package/dist/functions/{runAction.js → runAction/index.js} +15 -14
  62. package/dist/functions/runAction/info.d.ts +24 -0
  63. package/dist/functions/runAction/info.js +11 -0
  64. package/dist/functions/runAction/schemas.d.ts +36 -0
  65. package/dist/functions/runAction/schemas.js +15 -0
  66. package/dist/index.d.ts +6 -3
  67. package/dist/index.js +7 -3
  68. package/dist/plugins/apps/index.d.ts +8 -0
  69. package/dist/plugins/apps/index.js +77 -0
  70. package/dist/plugins/apps/info.d.ts +6 -0
  71. package/dist/plugins/apps/info.js +13 -0
  72. package/dist/plugins/apps/types.d.ts +21 -0
  73. package/dist/plugins/apps/types.js +2 -0
  74. package/dist/resolvers/actionKey.d.ts +8 -0
  75. package/dist/resolvers/actionKey.js +20 -0
  76. package/dist/resolvers/actionType.d.ts +8 -0
  77. package/dist/resolvers/actionType.js +21 -0
  78. package/dist/resolvers/appKey.d.ts +6 -0
  79. package/dist/resolvers/appKey.js +8 -0
  80. package/dist/resolvers/authenticationId.d.ts +8 -0
  81. package/dist/resolvers/authenticationId.js +29 -0
  82. package/dist/resolvers/index.d.ts +39 -0
  83. package/dist/resolvers/index.js +105 -0
  84. package/dist/resolvers/inputs.d.ts +7 -0
  85. package/dist/resolvers/inputs.js +15 -0
  86. package/dist/schema-utils.d.ts +39 -0
  87. package/dist/schema-utils.js +52 -0
  88. package/dist/schemas/Action.d.ts +21 -0
  89. package/dist/schemas/Action.js +31 -0
  90. package/dist/schemas/App.d.ts +19 -0
  91. package/dist/schemas/App.js +32 -0
  92. package/dist/schemas/Auth.d.ts +30 -0
  93. package/dist/schemas/Auth.js +49 -0
  94. package/dist/schemas/Field.d.ts +15 -0
  95. package/dist/schemas/Field.js +25 -0
  96. package/dist/sdk.d.ts +3 -4
  97. package/dist/sdk.js +96 -11
  98. package/dist/types/domain.d.ts +22 -0
  99. package/dist/types/domain.js +21 -0
  100. package/dist/types/properties.d.ts +21 -0
  101. package/dist/types/properties.js +45 -0
  102. package/dist/types/sdk.d.ts +21 -0
  103. package/dist/types/sdk.js +2 -0
  104. package/package.json +4 -2
  105. package/src/api/auth.ts +28 -0
  106. package/src/api/client.ts +148 -0
  107. package/src/api/debug.ts +58 -0
  108. package/src/api/index.ts +83 -0
  109. package/src/api/polling.ts +56 -0
  110. package/src/api/types.ts +177 -0
  111. package/src/functions/{bundleCode.ts → bundleCode/index.ts} +1 -8
  112. package/src/functions/bundleCode/info.ts +9 -0
  113. package/src/functions/bundleCode/schemas.ts +30 -0
  114. package/src/functions/{generateTypes.ts → generateTypes/index.ts} +70 -31
  115. package/src/functions/generateTypes/info.ts +9 -0
  116. package/src/functions/generateTypes/schemas.ts +38 -0
  117. package/src/functions/{getAction.ts → getAction/index.ts} +11 -12
  118. package/src/functions/getAction/info.ts +9 -0
  119. package/src/functions/getAction/schemas.ts +35 -0
  120. package/src/functions/{getApp.ts → getApp/index.ts} +9 -15
  121. package/src/functions/getApp/info.ts +9 -0
  122. package/src/functions/getApp/schemas.ts +31 -0
  123. package/src/functions/{listActions.ts → listActions/index.ts} +8 -10
  124. package/src/functions/listActions/info.ts +9 -0
  125. package/src/functions/listActions/schemas.ts +40 -0
  126. package/src/functions/{listApps.ts → listApps/index.ts} +3 -8
  127. package/src/functions/listApps/info.ts +9 -0
  128. package/src/functions/listApps/schemas.ts +43 -0
  129. package/src/functions/{listAuths.ts → listAuths/index.ts} +8 -16
  130. package/src/functions/listAuths/info.ts +9 -0
  131. package/src/functions/listAuths/schemas.ts +48 -0
  132. package/src/functions/{listFields.ts → listFields/index.ts} +11 -20
  133. package/src/functions/listFields/info.ts +9 -0
  134. package/src/functions/listFields/schemas.ts +46 -0
  135. package/src/functions/{runAction.ts → runAction/index.ts} +25 -23
  136. package/src/functions/runAction/info.ts +9 -0
  137. package/src/functions/runAction/schemas.ts +41 -0
  138. package/src/index.ts +13 -4
  139. package/src/plugins/apps/index.ts +144 -0
  140. package/src/plugins/apps/info.ts +12 -0
  141. package/src/plugins/apps/types.ts +34 -0
  142. package/src/resolvers/actionKey.ts +33 -0
  143. package/src/resolvers/actionType.ts +30 -0
  144. package/src/resolvers/appKey.ts +11 -0
  145. package/src/resolvers/authenticationId.ts +38 -0
  146. package/src/resolvers/index.ts +117 -0
  147. package/src/resolvers/inputs.ts +23 -0
  148. package/src/schema-utils.ts +119 -0
  149. package/src/schemas/Action.ts +40 -0
  150. package/src/schemas/App.ts +43 -0
  151. package/src/schemas/Auth.ts +62 -0
  152. package/src/schemas/Field.ts +34 -0
  153. package/src/sdk.ts +153 -19
  154. package/src/types/domain.ts +54 -0
  155. package/src/types/properties.ts +67 -0
  156. package/src/types/sdk.ts +42 -0
  157. package/dist/actions-sdk.d.ts +0 -47
  158. package/dist/actions-sdk.js +0 -208
  159. package/dist/api.d.ts +0 -62
  160. package/dist/api.js +0 -227
  161. package/dist/output-schemas.d.ts +0 -95
  162. package/dist/output-schemas.js +0 -138
  163. package/dist/schemas.d.ts +0 -338
  164. package/dist/schemas.js +0 -336
  165. package/dist/types.js +0 -41
  166. package/src/actions-sdk.ts +0 -356
  167. package/src/api.ts +0 -361
  168. package/src/output-schemas.ts +0 -196
  169. package/src/schemas.ts +0 -467
  170. package/src/types.ts +0 -257
  171. /package/dist/functions/{bundleCode.js → bundleCode/index.js} +0 -0
@@ -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,6 @@
1
+ import type { AppsPluginOptions } from "./index";
2
+ export declare const appsPluginInfo: {
3
+ plugin: (_sdk: any, options: AppsPluginOptions) => {
4
+ apps: import("./types").ActionProxy;
5
+ };
6
+ };
@@ -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,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,6 @@
1
+ export interface AppKeyResolver {
2
+ type: "static";
3
+ inputType?: "text" | "password" | "email";
4
+ placeholder?: string;
5
+ }
6
+ export declare const appKeyResolver: AppKeyResolver;
@@ -0,0 +1,8 @@
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
+ };
@@ -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.listAuths({
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";
@@ -0,0 +1,105 @@
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; } });
@@ -0,0 +1,7 @@
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;
@@ -0,0 +1,15 @@
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
+ };
@@ -0,0 +1,39 @@
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>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withFormatter = withFormatter;
4
+ exports.getFormatMetadata = getFormatMetadata;
5
+ exports.withOutputSchema = withOutputSchema;
6
+ exports.getOutputSchema = getOutputSchema;
7
+ exports.withResolver = withResolver;
8
+ exports.getSchemaDescription = getSchemaDescription;
9
+ exports.getFieldDescriptions = getFieldDescriptions;
10
+ const zod_1 = require("zod");
11
+ // Helper function to add format metadata to schemas
12
+ function withFormatter(schema, formatMeta) {
13
+ // Store format metadata on the schema definition
14
+ schema._def.formatMeta = formatMeta;
15
+ return schema;
16
+ }
17
+ // Helper function to get format metadata from a schema
18
+ function getFormatMetadata(schema) {
19
+ return schema._def.formatMeta;
20
+ }
21
+ // Helper function to link input schemas to output schemas
22
+ function withOutputSchema(inputSchema, outputSchema) {
23
+ // Store output schema reference on the input schema
24
+ inputSchema._def.outputSchema = outputSchema;
25
+ return inputSchema;
26
+ }
27
+ // Helper function to get output schema from an input schema
28
+ function getOutputSchema(inputSchema) {
29
+ return inputSchema._def.outputSchema;
30
+ }
31
+ // Helper function to add resolver metadata to schemas
32
+ function withResolver(schema, config) {
33
+ // Store resolver metadata on the schema definition
34
+ schema._def.resolverMeta = config;
35
+ return schema;
36
+ }
37
+ // ============================================================================
38
+ // Schema Description Utilities
39
+ // ============================================================================
40
+ function getSchemaDescription(schema) {
41
+ return schema.description;
42
+ }
43
+ function getFieldDescriptions(schema) {
44
+ const descriptions = {};
45
+ const shape = schema.shape;
46
+ for (const [key, fieldSchema] of Object.entries(shape)) {
47
+ if (fieldSchema instanceof zod_1.z.ZodType && fieldSchema.description) {
48
+ descriptions[key] = fieldSchema.description;
49
+ }
50
+ }
51
+ return descriptions;
52
+ }
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ export declare const ActionItemSchema: z.ZodObject<{
3
+ key: z.ZodString;
4
+ name: z.ZodOptional<z.ZodString>;
5
+ type: z.ZodString;
6
+ appKey: z.ZodOptional<z.ZodString>;
7
+ description: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ type: string;
10
+ key: string;
11
+ appKey?: string | undefined;
12
+ name?: string | undefined;
13
+ description?: string | undefined;
14
+ }, {
15
+ type: string;
16
+ key: string;
17
+ appKey?: string | undefined;
18
+ name?: string | undefined;
19
+ description?: string | undefined;
20
+ }>;
21
+ export type ActionItem = z.infer<typeof ActionItemSchema>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const schema_utils_1 = require("../schema-utils");
6
+ // ============================================================================
7
+ // Action Schemas
8
+ // ============================================================================
9
+ exports.ActionItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
10
+ key: zod_1.z.string(),
11
+ name: zod_1.z.string().optional(),
12
+ type: zod_1.z.string(),
13
+ appKey: zod_1.z.string().optional(),
14
+ description: zod_1.z.string().optional(),
15
+ }), {
16
+ format: (item) => {
17
+ const details = [];
18
+ details.push({ text: `Type: ${item.type}`, style: "accent" });
19
+ if (item.appKey) {
20
+ details.push({ text: `App: ${item.appKey}`, style: "normal" });
21
+ }
22
+ if (item.description) {
23
+ details.push({ text: item.description, style: "dim" });
24
+ }
25
+ return {
26
+ title: item.name || item.key,
27
+ subtitle: `(${item.key})`,
28
+ details,
29
+ };
30
+ },
31
+ });
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ export { FormattedItem, FormatMetadata } from "../schema-utils";
3
+ export declare const AppItemSchema: z.ZodObject<{
4
+ key: z.ZodString;
5
+ name: z.ZodOptional<z.ZodString>;
6
+ description: z.ZodOptional<z.ZodString>;
7
+ category: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ key: string;
10
+ name?: string | undefined;
11
+ description?: string | undefined;
12
+ category?: string | undefined;
13
+ }, {
14
+ key: string;
15
+ name?: string | undefined;
16
+ description?: string | undefined;
17
+ category?: string | undefined;
18
+ }>;
19
+ export type AppItem = z.infer<typeof AppItemSchema>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const schema_utils_1 = require("../schema-utils");
6
+ // ============================================================================
7
+ // App Schemas
8
+ // ============================================================================
9
+ exports.AppItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
10
+ key: zod_1.z.string(),
11
+ name: zod_1.z.string().optional(),
12
+ description: zod_1.z.string().optional(),
13
+ category: zod_1.z.string().optional(),
14
+ }), {
15
+ format: (item) => {
16
+ const details = [];
17
+ if (item.description) {
18
+ details.push({ text: item.description, style: "dim" });
19
+ }
20
+ if (item.category) {
21
+ details.push({
22
+ text: `Category: ${item.category}`,
23
+ style: "accent",
24
+ });
25
+ }
26
+ return {
27
+ title: item.name || item.key,
28
+ subtitle: `(${item.key})`,
29
+ details,
30
+ };
31
+ },
32
+ });
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ export declare const AuthItemSchema: z.ZodObject<{
3
+ id: z.ZodNumber;
4
+ title: z.ZodOptional<z.ZodString>;
5
+ label: z.ZodOptional<z.ZodString>;
6
+ identifier: z.ZodOptional<z.ZodString>;
7
+ account_id: z.ZodOptional<z.ZodString>;
8
+ is_private: z.ZodOptional<z.ZodBoolean>;
9
+ shared_with_all: z.ZodOptional<z.ZodBoolean>;
10
+ marked_stale_at: z.ZodOptional<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ id: number;
13
+ title?: string | undefined;
14
+ label?: string | undefined;
15
+ identifier?: string | undefined;
16
+ account_id?: string | undefined;
17
+ is_private?: boolean | undefined;
18
+ shared_with_all?: boolean | undefined;
19
+ marked_stale_at?: string | undefined;
20
+ }, {
21
+ id: number;
22
+ title?: string | undefined;
23
+ label?: string | undefined;
24
+ identifier?: string | undefined;
25
+ account_id?: string | undefined;
26
+ is_private?: boolean | undefined;
27
+ shared_with_all?: boolean | undefined;
28
+ marked_stale_at?: string | undefined;
29
+ }>;
30
+ export type AuthItem = z.infer<typeof AuthItemSchema>;