@zapier/zapier-sdk 0.0.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) 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/findFirstAuthentication/index.d.ts +12 -0
  19. package/dist/functions/findFirstAuthentication/index.js +21 -0
  20. package/dist/functions/findFirstAuthentication/info.d.ts +30 -0
  21. package/dist/functions/findFirstAuthentication/info.js +11 -0
  22. package/dist/functions/findFirstAuthentication/schemas.d.ts +42 -0
  23. package/dist/functions/findFirstAuthentication/schemas.js +25 -0
  24. package/dist/functions/findUniqueAuthentication/index.d.ts +13 -0
  25. package/dist/functions/findUniqueAuthentication/index.js +28 -0
  26. package/dist/functions/findUniqueAuthentication/info.d.ts +30 -0
  27. package/dist/functions/findUniqueAuthentication/info.js +11 -0
  28. package/dist/functions/findUniqueAuthentication/schemas.d.ts +42 -0
  29. package/dist/functions/findUniqueAuthentication/schemas.js +25 -0
  30. package/dist/functions/{generateTypes.d.ts → generateTypes/index.d.ts} +2 -7
  31. package/dist/functions/{generateTypes.js → generateTypes/index.js} +58 -24
  32. package/dist/functions/generateTypes/info.d.ts +21 -0
  33. package/dist/functions/generateTypes/info.js +11 -0
  34. package/dist/functions/generateTypes/schemas.d.ts +30 -0
  35. package/dist/functions/generateTypes/schemas.js +14 -0
  36. package/dist/functions/{getAction.d.ts → getAction/index.d.ts} +2 -6
  37. package/dist/functions/{getAction.js → getAction/index.js} +6 -5
  38. package/dist/functions/getAction/info.d.ts +18 -0
  39. package/dist/functions/getAction/info.js +11 -0
  40. package/dist/functions/getAction/schemas.d.ts +30 -0
  41. package/dist/functions/getAction/schemas.js +13 -0
  42. package/dist/functions/{getApp.d.ts → getApp/index.d.ts} +2 -4
  43. package/dist/functions/{getApp.js → getApp/index.js} +6 -10
  44. package/dist/functions/getApp/info.d.ts +12 -0
  45. package/dist/functions/getApp/info.js +11 -0
  46. package/dist/functions/getApp/schemas.d.ts +24 -0
  47. package/dist/functions/getApp/schemas.js +11 -0
  48. package/dist/functions/{listActions.d.ts → listActions/index.d.ts} +3 -6
  49. package/dist/functions/{listActions.js → listActions/index.js} +4 -3
  50. package/dist/functions/listActions/info.d.ts +15 -0
  51. package/dist/functions/listActions/info.js +11 -0
  52. package/dist/functions/listActions/schemas.d.ts +27 -0
  53. package/dist/functions/listActions/schemas.js +14 -0
  54. package/dist/functions/{listApps.d.ts → listApps/index.d.ts} +2 -6
  55. package/dist/functions/{listApps.js → listApps/index.js} +1 -1
  56. package/dist/functions/listApps/info.d.ts +18 -0
  57. package/dist/functions/listApps/info.js +11 -0
  58. package/dist/functions/listApps/schemas.d.ts +30 -0
  59. package/dist/functions/listApps/schemas.js +15 -0
  60. package/dist/functions/{listAuths.d.ts → listAuthentications/index.d.ts} +3 -9
  61. package/dist/functions/{listAuths.js → listAuthentications/index.js} +28 -12
  62. package/dist/functions/listAuthentications/info.d.ts +30 -0
  63. package/dist/functions/listAuthentications/info.js +11 -0
  64. package/dist/functions/listAuthentications/schemas.d.ts +42 -0
  65. package/dist/functions/listAuthentications/schemas.js +25 -0
  66. package/dist/functions/{listFields.d.ts → listFields/index.d.ts} +3 -9
  67. package/dist/functions/{listFields.js → listFields/index.js} +8 -10
  68. package/dist/functions/listFields/info.d.ts +24 -0
  69. package/dist/functions/listFields/info.js +11 -0
  70. package/dist/functions/listFields/schemas.d.ts +36 -0
  71. package/dist/functions/listFields/schemas.js +17 -0
  72. package/dist/functions/{runAction.d.ts → runAction/index.d.ts} +2 -8
  73. package/dist/functions/{runAction.js → runAction/index.js} +15 -14
  74. package/dist/functions/runAction/info.d.ts +24 -0
  75. package/dist/functions/runAction/info.js +11 -0
  76. package/dist/functions/runAction/schemas.d.ts +36 -0
  77. package/dist/functions/runAction/schemas.js +15 -0
  78. package/dist/index.d.ts +10 -4
  79. package/dist/index.js +17 -6
  80. package/dist/plugins/apps/index.d.ts +8 -0
  81. package/dist/plugins/apps/index.js +77 -0
  82. package/dist/plugins/apps/info.d.ts +6 -0
  83. package/dist/plugins/apps/info.js +13 -0
  84. package/dist/plugins/apps/types.d.ts +21 -0
  85. package/dist/plugins/apps/types.js +2 -0
  86. package/dist/resolvers/actionKey.d.ts +8 -0
  87. package/dist/resolvers/actionKey.js +20 -0
  88. package/dist/resolvers/actionType.d.ts +8 -0
  89. package/dist/resolvers/actionType.js +21 -0
  90. package/dist/resolvers/appKey.d.ts +6 -0
  91. package/dist/resolvers/appKey.js +8 -0
  92. package/dist/resolvers/authenticationId.d.ts +8 -0
  93. package/dist/resolvers/authenticationId.js +29 -0
  94. package/dist/resolvers/index.d.ts +39 -0
  95. package/dist/resolvers/index.js +105 -0
  96. package/dist/resolvers/inputs.d.ts +7 -0
  97. package/dist/resolvers/inputs.js +15 -0
  98. package/dist/schema-utils.d.ts +44 -0
  99. package/dist/schema-utils.js +76 -0
  100. package/dist/schemas/Action.d.ts +21 -0
  101. package/dist/schemas/Action.js +31 -0
  102. package/dist/schemas/App.d.ts +19 -0
  103. package/dist/schemas/App.js +32 -0
  104. package/dist/schemas/Auth.d.ts +27 -0
  105. package/dist/schemas/Auth.js +42 -0
  106. package/dist/schemas/Field.d.ts +15 -0
  107. package/dist/schemas/Field.js +25 -0
  108. package/dist/sdk.d.ts +3 -4
  109. package/dist/sdk.js +104 -11
  110. package/dist/types/domain.d.ts +22 -0
  111. package/dist/types/domain.js +21 -0
  112. package/dist/types/properties.d.ts +21 -0
  113. package/dist/types/properties.js +43 -0
  114. package/dist/types/sdk.d.ts +23 -0
  115. package/dist/types/sdk.js +2 -0
  116. package/package.json +4 -2
  117. package/src/api/auth.ts +28 -0
  118. package/src/api/client.ts +148 -0
  119. package/src/api/debug.ts +58 -0
  120. package/src/api/index.ts +83 -0
  121. package/src/api/polling.ts +56 -0
  122. package/src/api/types.ts +177 -0
  123. package/src/functions/{bundleCode.ts → bundleCode/index.ts} +1 -8
  124. package/src/functions/bundleCode/info.ts +9 -0
  125. package/src/functions/bundleCode/schemas.ts +30 -0
  126. package/src/functions/findFirstAuthentication/index.ts +24 -0
  127. package/src/functions/findFirstAuthentication/info.ts +9 -0
  128. package/src/functions/findFirstAuthentication/schemas.ts +60 -0
  129. package/src/functions/findUniqueAuthentication/index.ts +35 -0
  130. package/src/functions/findUniqueAuthentication/info.ts +9 -0
  131. package/src/functions/findUniqueAuthentication/schemas.ts +60 -0
  132. package/src/functions/{generateTypes.ts → generateTypes/index.ts} +70 -31
  133. package/src/functions/generateTypes/info.ts +9 -0
  134. package/src/functions/generateTypes/schemas.ts +38 -0
  135. package/src/functions/{getAction.ts → getAction/index.ts} +11 -12
  136. package/src/functions/getAction/info.ts +9 -0
  137. package/src/functions/getAction/schemas.ts +35 -0
  138. package/src/functions/{getApp.ts → getApp/index.ts} +9 -15
  139. package/src/functions/getApp/info.ts +9 -0
  140. package/src/functions/getApp/schemas.ts +31 -0
  141. package/src/functions/{listActions.ts → listActions/index.ts} +8 -10
  142. package/src/functions/listActions/info.ts +9 -0
  143. package/src/functions/listActions/schemas.ts +40 -0
  144. package/src/functions/{listApps.ts → listApps/index.ts} +3 -8
  145. package/src/functions/listApps/info.ts +9 -0
  146. package/src/functions/listApps/schemas.ts +43 -0
  147. package/src/functions/{listAuths.ts → listAuthentications/index.ts} +32 -23
  148. package/src/functions/listAuthentications/info.ts +9 -0
  149. package/src/functions/listAuthentications/schemas.ts +60 -0
  150. package/src/functions/{listFields.ts → listFields/index.ts} +11 -20
  151. package/src/functions/listFields/info.ts +9 -0
  152. package/src/functions/listFields/schemas.ts +46 -0
  153. package/src/functions/{runAction.ts → runAction/index.ts} +25 -23
  154. package/src/functions/runAction/info.ts +9 -0
  155. package/src/functions/runAction/schemas.ts +41 -0
  156. package/src/index.ts +19 -5
  157. package/src/plugins/apps/index.ts +144 -0
  158. package/src/plugins/apps/info.ts +12 -0
  159. package/src/plugins/apps/types.ts +34 -0
  160. package/src/resolvers/actionKey.ts +33 -0
  161. package/src/resolvers/actionType.ts +30 -0
  162. package/src/resolvers/appKey.ts +11 -0
  163. package/src/resolvers/authenticationId.ts +38 -0
  164. package/src/resolvers/index.ts +117 -0
  165. package/src/resolvers/inputs.ts +23 -0
  166. package/src/schema-utils.ts +154 -0
  167. package/src/schemas/Action.ts +40 -0
  168. package/src/schemas/App.ts +43 -0
  169. package/src/schemas/Auth.ts +54 -0
  170. package/src/schemas/Field.ts +34 -0
  171. package/src/sdk.ts +165 -19
  172. package/src/types/domain.ts +54 -0
  173. package/src/types/properties.ts +67 -0
  174. package/src/types/sdk.ts +46 -0
  175. package/dist/actions-sdk.d.ts +0 -47
  176. package/dist/actions-sdk.js +0 -208
  177. package/dist/api.d.ts +0 -62
  178. package/dist/api.js +0 -227
  179. package/dist/output-schemas.d.ts +0 -95
  180. package/dist/output-schemas.js +0 -138
  181. package/dist/schemas.d.ts +0 -338
  182. package/dist/schemas.js +0 -336
  183. package/dist/types.js +0 -41
  184. package/src/actions-sdk.ts +0 -356
  185. package/src/api.ts +0 -361
  186. package/src/output-schemas.ts +0 -196
  187. package/src/schemas.ts +0 -467
  188. package/src/types.ts +0 -257
  189. /package/dist/functions/{bundleCode.js → bundleCode/index.js} +0 -0
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+ import { withFormatter } from "../schema-utils";
3
+
4
+ // ============================================================================
5
+ // Auth Schemas
6
+ // ============================================================================
7
+
8
+ export const AuthItemSchema = withFormatter(
9
+ z.object({
10
+ id: z.number(),
11
+ title: z.string().optional(),
12
+ identifier: z.string().optional(),
13
+ account_id: z.string().optional(),
14
+ is_private: z.boolean().optional(),
15
+ shared_with_all: z.boolean().optional(),
16
+ marked_stale_at: z.string().optional(),
17
+ }),
18
+ {
19
+ format: (item) => {
20
+ const details = [];
21
+
22
+ if (item.identifier) {
23
+ details.push({
24
+ text: `Identifier: ${item.identifier}`,
25
+ style: "accent" as const,
26
+ });
27
+ }
28
+
29
+ details.push({
30
+ text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
31
+ style: "dim" as const,
32
+ });
33
+
34
+ if (item.marked_stale_at) {
35
+ details.push({
36
+ text: `⚠️ Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
37
+ style: "warning" as const,
38
+ });
39
+ }
40
+
41
+ return {
42
+ title: item.title || `Authentication ${item.id}`,
43
+ subtitle: `(ID: ${item.id})`,
44
+ details,
45
+ };
46
+ },
47
+ },
48
+ );
49
+
50
+ // ============================================================================
51
+ // Type Exports
52
+ // ============================================================================
53
+
54
+ export type AuthItem = z.infer<typeof AuthItemSchema>;
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { withFormatter } from "../schema-utils";
3
+
4
+ // ============================================================================
5
+ // Field Schemas
6
+ // ============================================================================
7
+
8
+ export const FieldItemSchema = withFormatter(
9
+ z.object({
10
+ key: z.string(),
11
+ name: z.string().optional(),
12
+ description: z.string().optional(),
13
+ }),
14
+ {
15
+ format: (item) => {
16
+ const details = [];
17
+ if (item.description) {
18
+ details.push({ text: item.description, style: "dim" as const });
19
+ }
20
+
21
+ return {
22
+ title: item.name || item.key,
23
+ subtitle: `(${item.key})`,
24
+ details,
25
+ };
26
+ },
27
+ },
28
+ );
29
+
30
+ // ============================================================================
31
+ // Type Exports
32
+ // ============================================================================
33
+
34
+ export type FieldItem = z.infer<typeof FieldItemSchema>;
package/src/sdk.ts CHANGED
@@ -1,26 +1,172 @@
1
- import { createActionsSdk, ActionsSdk } from "./actions-sdk";
2
- import { BaseSdkOptions } from "./types";
3
-
4
- export interface ZapierSdk extends ActionsSdk {
5
- // Future SDK namespaces will be added here
6
- // workflows: WorkflowsSdk
7
- // interfaces: InterfacesSdk
8
- // tables: TablesSdk
1
+ import { createZapierApi } from "./api";
2
+ import { BaseSdkOptions } from "./types/domain";
3
+ // Import function implementations
4
+ import { listApps } from "./functions/listApps";
5
+ import { getApp } from "./functions/getApp";
6
+ import { listActions } from "./functions/listActions";
7
+ import { getAction } from "./functions/getAction";
8
+ import { runAction } from "./functions/runAction";
9
+ import { listAuthentications } from "./functions/listAuthentications";
10
+ import { findFirstAuthentication } from "./functions/findFirstAuthentication";
11
+ import { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
12
+ import { listFields } from "./functions/listFields";
13
+ import { generateTypes } from "./functions/generateTypes";
14
+ import { bundleCode } from "./functions/bundleCode";
15
+
16
+ // Import function registry info objects (only for CLI registry)
17
+ import { listAppsInfo } from "./functions/listApps/info";
18
+ import { getAppInfo } from "./functions/getApp/info";
19
+ import { listActionsInfo } from "./functions/listActions/info";
20
+ import { getActionInfo } from "./functions/getAction/info";
21
+ import { runActionInfo } from "./functions/runAction/info";
22
+ import { listAuthenticationsInfo } from "./functions/listAuthentications/info";
23
+ import { findFirstAuthenticationInfo } from "./functions/findFirstAuthentication/info";
24
+ import { findUniqueAuthenticationInfo } from "./functions/findUniqueAuthentication/info";
25
+ import { listFieldsInfo } from "./functions/listFields/info";
26
+ import { generateTypesInfo } from "./functions/generateTypes/info";
27
+ import { bundleCodeInfo } from "./functions/bundleCode/info";
28
+
29
+ // Function registry as array - uses names from function info objects
30
+ const functionRegistry = [
31
+ listAppsInfo,
32
+ getAppInfo,
33
+ listActionsInfo,
34
+ getActionInfo,
35
+ runActionInfo,
36
+ listAuthenticationsInfo,
37
+ findFirstAuthenticationInfo,
38
+ findUniqueAuthenticationInfo,
39
+ listFieldsInfo,
40
+ generateTypesInfo,
41
+ bundleCodeInfo,
42
+ ];
43
+
44
+ // Import the properly typed SDK interface
45
+ import type { ZapierSdk } from "./types/sdk";
46
+
47
+ // Import plugin functions
48
+ import { createAppsPlugin } from "./plugins/apps/index";
49
+
50
+ // TODO: Add plugin registry back when needed for CLI compatibility
51
+
52
+ // Base SDK functions interface (functions + registry, no plugins)
53
+ interface BaseZapierSdkWithFunctions {
54
+ __registry: Array<{
55
+ name: string;
56
+ inputSchema: any;
57
+ implementation: Function;
58
+ }>;
59
+ listApps: ZapierSdk["listApps"];
60
+ getApp: ZapierSdk["getApp"];
61
+ listActions: ZapierSdk["listActions"];
62
+ getAction: ZapierSdk["getAction"];
63
+ runAction: ZapierSdk["runAction"];
64
+ listAuthentications: ZapierSdk["listAuthentications"];
65
+ findFirstAuthentication: ZapierSdk["findFirstAuthentication"];
66
+ findUniqueAuthentication: ZapierSdk["findUniqueAuthentication"];
67
+ listFields: ZapierSdk["listFields"];
68
+ generateTypes: ZapierSdk["generateTypes"];
69
+ bundleCode: ZapierSdk["bundleCode"];
9
70
  }
10
71
 
72
+ // Full SDK interface with plugins applied
73
+ export type { ZapierSdk } from "./types/sdk";
74
+
11
75
  export interface ZapierSdkOptions extends BaseSdkOptions {}
12
76
 
77
+ function createBaseZapierSdk(
78
+ options: ZapierSdkOptions = {},
79
+ ): BaseZapierSdkWithFunctions {
80
+ // Auto-load .env files (searches up directory tree)
81
+ try {
82
+ const { findUpSync } = require("find-up");
83
+ const envPath = findUpSync(".env");
84
+ if (envPath) {
85
+ require("dotenv").config({ path: envPath, quiet: true });
86
+ }
87
+ } catch {
88
+ // Silently fail if dotenv/find-up not available or .env not found
89
+ }
90
+
91
+ const {
92
+ fetch: customFetch = globalThis.fetch,
93
+ baseUrl = "https://zapier.com",
94
+ token,
95
+ debug = false,
96
+ } = options;
97
+
98
+ // If no token provided, try to get it from environment variable
99
+ const finalToken = token || process.env.ZAPIER_TOKEN;
100
+
101
+ // Create the API client
102
+ const api = createZapierApi({
103
+ baseUrl,
104
+ token: finalToken,
105
+ debug,
106
+ fetch: customFetch,
107
+ });
108
+
109
+ // Build SDK directly - TypeScript will enforce correct implementation
110
+ const sdk: BaseZapierSdkWithFunctions = {
111
+ // Registry for CLI
112
+ __registry: functionRegistry,
113
+
114
+ // Function implementations with API config injection
115
+ listApps: (options = {}) =>
116
+ listApps({ ...options, api, token: finalToken }),
117
+ getApp: (options) => getApp({ ...options, api, token: finalToken }),
118
+ listActions: (options = {}) =>
119
+ listActions({ ...options, api, token: finalToken }),
120
+ getAction: (options) => getAction({ ...options, api, token: finalToken }),
121
+ runAction: (options) => runAction({ ...options, api, token: finalToken }),
122
+ listAuthentications: (options = {}) =>
123
+ listAuthentications({ ...options, api, token: finalToken }),
124
+ findFirstAuthentication: (options = {}) =>
125
+ findFirstAuthentication({ ...options, api, token: finalToken }),
126
+ findUniqueAuthentication: (options = {}) =>
127
+ findUniqueAuthentication({ ...options, api, token: finalToken }),
128
+ listFields: (options) => listFields({ ...options, api, token: finalToken }),
129
+ generateTypes: (options) =>
130
+ generateTypes({ ...options, api, token: finalToken }),
131
+ bundleCode: (options) => bundleCode(options), // No API config needed
132
+ };
133
+
134
+ return sdk;
135
+ }
136
+
13
137
  export function createZapierSdk(options: ZapierSdkOptions = {}): ZapierSdk {
14
- // Create individual SDKs
15
- const actionsSdk = createActionsSdk(options);
16
-
17
- // For now, we just return the actions SDK
18
- // Later we'll combine multiple SDKs here
19
- return {
20
- ...actionsSdk,
21
- // Future SDKs will be spread here:
22
- // ...workflowsSdk,
23
- // ...interfacesSdk,
24
- // ...tablesSdk,
138
+ // Create base SDK
139
+ const baseSdk = createBaseZapierSdk(options);
140
+
141
+ // Extract options needed for plugins
142
+ const {
143
+ fetch: customFetch = globalThis.fetch,
144
+ baseUrl = "https://zapier.com",
145
+ token,
146
+ debug = false,
147
+ } = options;
148
+
149
+ const finalToken = token || process.env.ZAPIER_TOKEN;
150
+
151
+ // Create the API client for plugins
152
+ const api = createZapierApi({
153
+ baseUrl,
154
+ token: finalToken,
155
+ debug,
156
+ fetch: customFetch,
157
+ });
158
+
159
+ // Create plugins directly - TypeScript will enforce correct implementation
160
+ const appsPlugin = createAppsPlugin({
161
+ api,
162
+ token: finalToken,
163
+ });
164
+
165
+ // Compose final SDK - TypeScript will enforce we have all required properties
166
+ const fullSdk: ZapierSdk = {
167
+ ...baseSdk,
168
+ apps: appsPlugin,
25
169
  };
170
+
171
+ return fullSdk;
26
172
  }
@@ -0,0 +1,54 @@
1
+ // Re-export API types from the API module
2
+ export type {
3
+ Integration,
4
+ Action,
5
+ Trigger,
6
+ Field,
7
+ Choice,
8
+ ActionExecutionResult,
9
+ ActionField,
10
+ ActionFieldChoice,
11
+ NeedsRequest,
12
+ NeedsResponse,
13
+ Authentication,
14
+ AuthenticationsResponse,
15
+ } from "../api/types";
16
+
17
+ // SDK Configuration Types
18
+ export interface ActionExecutionOptions {
19
+ inputs?: Record<string, any>;
20
+ authenticationId?: number;
21
+ }
22
+
23
+ export interface AuthObject {
24
+ id: number;
25
+ }
26
+
27
+ export interface BaseSdkOptions {
28
+ token?: string;
29
+ fetch?: typeof fetch;
30
+ baseUrl?: string;
31
+ debug?: boolean;
32
+ }
33
+
34
+ // Error Classes
35
+ export class ZapierSdkError extends Error {
36
+ constructor(
37
+ message: string,
38
+ public code?: string,
39
+ ) {
40
+ super(message);
41
+ this.name = "ZapierSdkError";
42
+ }
43
+ }
44
+
45
+ export class AppNotFoundError extends ZapierSdkError {
46
+ appKey: string;
47
+
48
+ constructor(appKey: string) {
49
+ super(`App "${appKey}" not found`);
50
+ this.name = "AppNotFoundError";
51
+ this.code = "APP_NOT_FOUND";
52
+ this.appKey = appKey;
53
+ }
54
+ }
@@ -0,0 +1,67 @@
1
+ import { z } from "zod";
2
+ import { withPositional } from "../schema-utils";
3
+
4
+ // Shared property definitions for common parameters across functions
5
+ // These can be reused in function schemas without duplication
6
+
7
+ export const AppKeyPropertySchema = withPositional(
8
+ z.string().min(1).describe("App slug (e.g., 'slack', 'github')"),
9
+ );
10
+
11
+ export const ActionTypePropertySchema = z
12
+ .enum(["read", "write", "search", "create", "update", "delete"])
13
+ .describe("Action type that matches the action's defined type");
14
+
15
+ export const ActionKeyPropertySchema = z
16
+ .string()
17
+ .min(1)
18
+ .describe("Action key to execute");
19
+
20
+ export const AuthenticationIdPropertySchema = z
21
+ .number()
22
+ .int()
23
+ .describe("Authentication ID to use for this action");
24
+
25
+ export const InputsPropertySchema = z
26
+ .record(z.any())
27
+ .describe("Input parameters for the action");
28
+
29
+ export const LimitPropertySchema = z
30
+ .number()
31
+ .int()
32
+ .min(1)
33
+ .max(1000)
34
+ .default(50)
35
+ .describe("Maximum number of items to return");
36
+
37
+ export const OffsetPropertySchema = z
38
+ .number()
39
+ .int()
40
+ .min(0)
41
+ .default(0)
42
+ .describe("Number of items to skip for pagination");
43
+
44
+ export const OutputPropertySchema = z.string().describe("Output file path");
45
+
46
+ export const DebugPropertySchema = z
47
+ .boolean()
48
+ .default(false)
49
+ .describe("Enable debug logging");
50
+
51
+ export const ParamsPropertySchema = z
52
+ .record(z.any())
53
+ .describe("Additional parameters");
54
+
55
+ // Inferred TypeScript types for the properties
56
+ export type AppKeyProperty = z.infer<typeof AppKeyPropertySchema>;
57
+ export type ActionTypeProperty = z.infer<typeof ActionTypePropertySchema>;
58
+ export type ActionKeyProperty = z.infer<typeof ActionKeyPropertySchema>;
59
+ export type AuthenticationIdProperty = z.infer<
60
+ typeof AuthenticationIdPropertySchema
61
+ >;
62
+ export type InputsProperty = z.infer<typeof InputsPropertySchema>;
63
+ export type LimitProperty = z.infer<typeof LimitPropertySchema>;
64
+ export type OffsetProperty = z.infer<typeof OffsetPropertySchema>;
65
+ export type OutputProperty = z.infer<typeof OutputPropertySchema>;
66
+ export type DebugProperty = z.infer<typeof DebugPropertySchema>;
67
+ export type ParamsProperty = z.infer<typeof ParamsPropertySchema>;
@@ -0,0 +1,46 @@
1
+ // SDK interface composed from individual function interfaces
2
+ import type { ListActionsSdkFunction } from "../functions/listActions/schemas";
3
+ import type { GetActionSdkFunction } from "../functions/getAction/schemas";
4
+ import type { GetAppSdkFunction } from "../functions/getApp/schemas";
5
+ import type { RunActionSdkFunction } from "../functions/runAction/schemas";
6
+ import type { ListFieldsSdkFunction } from "../functions/listFields/schemas";
7
+ import type { ListAuthenticationsSdkFunction } from "../functions/listAuthentications/schemas";
8
+ import type { FindFirstAuthenticationSdkFunction } from "../functions/findFirstAuthentication/schemas";
9
+ import type { FindUniqueAuthenticationSdkFunction } from "../functions/findUniqueAuthentication/schemas";
10
+ import type { GenerateTypesSdkFunction } from "../functions/generateTypes/schemas";
11
+ import type { ListAppsSdkFunction } from "../functions/listApps/schemas";
12
+ import type { BundleCodeSdkFunction } from "../functions/bundleCode/schemas";
13
+
14
+ // Plugin interfaces
15
+ import type { AppsPluginSdkExtension } from "../plugins/apps/types";
16
+
17
+ // Compose SDK functions from individual function interfaces
18
+ export interface ZapierSdkFunctions
19
+ extends ListActionsSdkFunction,
20
+ GetActionSdkFunction,
21
+ GetAppSdkFunction,
22
+ RunActionSdkFunction,
23
+ ListFieldsSdkFunction,
24
+ ListAuthenticationsSdkFunction,
25
+ FindFirstAuthenticationSdkFunction,
26
+ FindUniqueAuthenticationSdkFunction,
27
+ GenerateTypesSdkFunction,
28
+ ListAppsSdkFunction,
29
+ BundleCodeSdkFunction {
30
+ // All functions now properly typed!
31
+ }
32
+
33
+ // Compose SDK plugins from individual plugin interfaces
34
+ export interface ZapierSdkPlugins extends AppsPluginSdkExtension {
35
+ // All plugins now properly typed!
36
+ }
37
+
38
+ // Main SDK interface with functions and plugins
39
+ export interface ZapierSdk extends ZapierSdkFunctions, ZapierSdkPlugins {
40
+ // Special property for CLI to access schemas
41
+ __registry: Array<{
42
+ name: string;
43
+ inputSchema: any;
44
+ implementation: Function;
45
+ }>;
46
+ }
@@ -1,47 +0,0 @@
1
- import { Integration, Action, ActionExecutionOptions, ActionExecutionResult, ActionField, Authentication, BaseSdkOptions } from "./types";
2
- import { AppsListOptions, AppsGetOptions, ActionsListOptions, ActionsGetOptions, ActionsRunOptions, AuthsListOptions, AuthsFindOptions, FieldsListOptions, GenerateOptions, BundleOptions } from "./schemas";
3
- export * from "./schemas";
4
- export * from "./output-schemas";
5
- export interface ActionsSdk {
6
- apps: AppsService;
7
- actions: ActionsService;
8
- auths: AuthsService;
9
- fields: FieldsService;
10
- generate: GenerateFunction;
11
- bundle: BundleFunction;
12
- }
13
- export interface AppsService {
14
- list(options?: AppsListOptions): Promise<Integration[]>;
15
- get(options: AppsGetOptions): Promise<Integration>;
16
- }
17
- interface ActionRunner {
18
- (params: ActionsRunOptions): Promise<ActionExecutionResult>;
19
- }
20
- interface ActionProxy {
21
- [app: string]: {
22
- [type: string]: {
23
- [action: string]: (options?: ActionExecutionOptions) => Promise<ActionExecutionResult>;
24
- };
25
- };
26
- }
27
- export interface GenerateFunction {
28
- (options: GenerateOptions): Promise<string>;
29
- }
30
- export interface BundleFunction {
31
- (options: BundleOptions): Promise<string>;
32
- }
33
- export interface ActionsService {
34
- list(options?: ActionsListOptions): Promise<Action[]>;
35
- get(options: ActionsGetOptions): Promise<Action>;
36
- run: ActionRunner & ActionProxy;
37
- }
38
- export interface AuthsService {
39
- list(options?: AuthsListOptions): Promise<Authentication[]>;
40
- find(options: AuthsFindOptions): number;
41
- }
42
- export interface FieldsService {
43
- list(options: FieldsListOptions): Promise<ActionField[]>;
44
- }
45
- export interface ActionsSdkOptions extends BaseSdkOptions {
46
- }
47
- export declare function createActionsSdk(options?: ActionsSdkOptions): ActionsSdk;