@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
@@ -1,9 +1,7 @@
1
- import { getOrCreateApiClient } from "../api";
2
- import type { Integration, FunctionConfig } from "../types";
3
-
4
- export interface GetAppOptions extends FunctionConfig {
5
- key: string;
6
- }
1
+ import { getOrCreateApiClient } from "../../api";
2
+ import type { Integration } from "../../types/domain";
3
+ import { AppNotFoundError } from "../../types/domain";
4
+ import type { GetAppOptions } from "./schemas";
7
5
 
8
6
  /**
9
7
  * Get a specific app by key
@@ -17,18 +15,12 @@ export interface GetAppOptions extends FunctionConfig {
17
15
  export async function getApp(options: GetAppOptions): Promise<Integration> {
18
16
  const api = getOrCreateApiClient(options);
19
17
 
20
- const { key } = options;
18
+ const { appKey } = options;
21
19
 
22
- const app = await api.get(`/api/v4/apps/${key}/`, {
20
+ const app = await api.get(`/api/v4/apps/${appKey}/`, {
23
21
  customErrorHandler: (response) => {
24
22
  if (response.status === 404) {
25
- const AppNotFoundError = class extends Error {
26
- constructor(appKey: string) {
27
- super(`App not found: ${appKey}`);
28
- this.name = "AppNotFoundError";
29
- }
30
- };
31
- return new AppNotFoundError(key);
23
+ return new AppNotFoundError(appKey);
32
24
  }
33
25
  return undefined;
34
26
  },
@@ -45,3 +37,5 @@ export async function getApp(options: GetAppOptions): Promise<Integration> {
45
37
  current_implementation_id: app.current_implementation_id,
46
38
  };
47
39
  }
40
+
41
+ // No registry info here - moved to info.ts for proper tree-shaking
@@ -0,0 +1,9 @@
1
+ import { getApp } from "./index";
2
+ import { GetAppSchema } from "./schemas";
3
+
4
+ // Function registry info - imports both function and schema
5
+ export const getAppInfo = {
6
+ name: getApp.name,
7
+ inputSchema: GetAppSchema,
8
+ implementation: getApp,
9
+ };
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { AppKeyPropertySchema } from "../../types/properties";
3
+ import type { Integration } from "../../types/domain";
4
+
5
+ // Pure Zod schema - no resolver metadata!
6
+ export const GetAppSchema = z
7
+ .object({
8
+ appKey: AppKeyPropertySchema.describe(
9
+ "App key or slug to fetch (e.g., google-sheets, slack, github)",
10
+ ),
11
+ })
12
+ .describe("Get detailed information about a specific app");
13
+
14
+ // Type inferred from schema + function config
15
+ export type GetAppOptions = z.infer<typeof GetAppSchema> & {
16
+ /** Base URL for Zapier API */
17
+ baseUrl?: string;
18
+ /** Authentication token */
19
+ token?: string;
20
+ /** Optional pre-instantiated API client */
21
+ api?: any;
22
+ /** Enable debug logging */
23
+ debug?: boolean;
24
+ /** Custom fetch implementation */
25
+ fetch?: typeof globalThis.fetch;
26
+ };
27
+
28
+ // SDK function interface - ready to be mixed into main SDK interface
29
+ export interface GetAppSdkFunction {
30
+ getApp: (options: GetAppOptions) => Promise<Integration>;
31
+ }
@@ -1,11 +1,7 @@
1
- import { getOrCreateApiClient } from "../api";
2
- import type { Action, FunctionConfig } from "../types";
3
- import { getApp } from "./getApp";
4
-
5
- export interface ListActionsOptions extends FunctionConfig {
6
- appKey?: string;
7
- type?: string;
8
- }
1
+ import { getOrCreateApiClient } from "../../api";
2
+ import type { Action } from "../../types/domain";
3
+ import { getApp } from "../getApp";
4
+ import type { ListActionsOptions } from "./schemas";
9
5
 
10
6
  /**
11
7
  * List available actions with optional filtering
@@ -17,7 +13,7 @@ export interface ListActionsOptions extends FunctionConfig {
17
13
  * @returns Promise<Action[]> with pagination metadata
18
14
  */
19
15
  export async function listActions(
20
- options: ListActionsOptions = {},
16
+ options: Partial<ListActionsOptions> = {},
21
17
  ): Promise<Action[]> {
22
18
  const api = getOrCreateApiClient(options);
23
19
 
@@ -26,7 +22,7 @@ export async function listActions(
26
22
  try {
27
23
  // Use the standalone getApp function
28
24
  const appData = await getApp({
29
- key: options.appKey,
25
+ appKey: options.appKey,
30
26
  api,
31
27
  token: options.token,
32
28
  baseUrl: options.baseUrl,
@@ -149,3 +145,5 @@ export async function listActions(
149
145
 
150
146
  return actions;
151
147
  }
148
+
149
+ // No registry info here - moved to info.ts for proper tree-shaking
@@ -0,0 +1,9 @@
1
+ import { listActions } from "./index";
2
+ import { ListActionsSchema } from "./schemas";
3
+
4
+ // Function registry info - imports both function and schema
5
+ export const listActionsInfo = {
6
+ name: listActions.name,
7
+ inputSchema: ListActionsSchema,
8
+ implementation: listActions,
9
+ };
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ import {
3
+ AppKeyPropertySchema,
4
+ ActionTypePropertySchema,
5
+ } from "../../types/properties";
6
+ import { withOutputSchema } from "../../schema-utils";
7
+ import { ActionItemSchema } from "../../schemas/Action";
8
+ import type { Action } from "../../types/domain";
9
+
10
+ // Pure Zod schema - no resolver metadata!
11
+ export const ListActionsSchema = withOutputSchema(
12
+ z
13
+ .object({
14
+ appKey: AppKeyPropertySchema.optional(),
15
+ type: ActionTypePropertySchema.optional().describe(
16
+ "Filter actions by type",
17
+ ),
18
+ })
19
+ .describe("List all actions for a specific app"),
20
+ ActionItemSchema,
21
+ );
22
+
23
+ // Type inferred from schema + function config
24
+ export type ListActionsOptions = z.infer<typeof ListActionsSchema> & {
25
+ /** Base URL for Zapier API */
26
+ baseUrl?: string;
27
+ /** Authentication token */
28
+ token?: string;
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
+
37
+ // SDK function interface - ready to be mixed into main SDK interface
38
+ export interface ListActionsSdkFunction {
39
+ listActions: (options?: Partial<ListActionsOptions>) => Promise<Action[]>;
40
+ }
@@ -1,11 +1,6 @@
1
- import { getOrCreateApiClient } from "../api";
2
- import type { Integration, FunctionConfig } from "../types";
3
-
4
- export interface ListAppsOptions extends FunctionConfig {
5
- category?: string;
6
- limit?: number;
7
- offset?: number;
8
- }
1
+ import { getOrCreateApiClient } from "../../api";
2
+ import type { Integration } from "../../types/domain";
3
+ import type { ListAppsOptions } from "./schemas";
9
4
 
10
5
  /**
11
6
  * List available apps with optional filtering
@@ -0,0 +1,9 @@
1
+ import { listApps } from "./index";
2
+ import { ListAppsSchema } from "./schemas";
3
+
4
+ // Function registry info - imports both function and schema
5
+ export const listAppsInfo = {
6
+ name: listApps.name,
7
+ inputSchema: ListAppsSchema,
8
+ implementation: listApps,
9
+ };
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ import {
3
+ LimitPropertySchema,
4
+ OffsetPropertySchema,
5
+ } from "../../types/properties";
6
+ import { withOutputSchema } from "../../schema-utils";
7
+ import { AppItemSchema } from "../../schemas/App";
8
+ import type { Integration } from "../../types/domain";
9
+
10
+ // Pure Zod schema - no resolver metadata!
11
+ export const ListAppsSchema = withOutputSchema(
12
+ z
13
+ .object({
14
+ category: z.string().optional().describe("Filter apps by category"),
15
+ limit: LimitPropertySchema.optional().describe(
16
+ "Maximum number of items to return (1-200)",
17
+ ),
18
+ offset: OffsetPropertySchema.optional().describe(
19
+ "Number of items to skip for pagination",
20
+ ),
21
+ })
22
+ .describe("List all available apps with optional filtering"),
23
+ AppItemSchema,
24
+ );
25
+
26
+ // Type inferred from schema + function config
27
+ export type ListAppsOptions = z.infer<typeof ListAppsSchema> & {
28
+ /** Base URL for Zapier API */
29
+ baseUrl?: string;
30
+ /** Authentication token */
31
+ token?: string;
32
+ /** Optional pre-instantiated API client */
33
+ api?: any;
34
+ /** Enable debug logging */
35
+ debug?: boolean;
36
+ /** Custom fetch implementation */
37
+ fetch?: typeof globalThis.fetch;
38
+ };
39
+
40
+ // SDK function interface - ready to be mixed into main SDK interface
41
+ export interface ListAppsSdkFunction {
42
+ listApps: (options?: Partial<ListAppsOptions>) => Promise<Integration[]>;
43
+ }
@@ -1,18 +1,10 @@
1
- import { getOrCreateApiClient } from "../api";
1
+ import { getOrCreateApiClient } from "../../api";
2
2
  import type {
3
3
  Authentication,
4
4
  AuthenticationsResponse,
5
- FunctionConfig,
6
- } from "../types";
7
- import { getApp } from "./getApp";
8
-
9
- export interface ListAuthsOptions extends FunctionConfig {
10
- appKey?: string;
11
- account_id?: string;
12
- owner?: string;
13
- limit?: number;
14
- offset?: number;
15
- }
5
+ } from "../../types/domain";
6
+ import { getApp } from "../getApp";
7
+ import type { ListAuthsOptions } from "./schemas";
16
8
 
17
9
  /**
18
10
  * List available authentications with optional filtering
@@ -24,7 +16,7 @@ export interface ListAuthsOptions extends FunctionConfig {
24
16
  * @returns Promise<Authentication[]> with pagination metadata
25
17
  */
26
18
  export async function listAuths(
27
- options: ListAuthsOptions = {},
19
+ options: Partial<ListAuthsOptions> = {},
28
20
  ): Promise<Authentication[]> {
29
21
  const { token } = options;
30
22
 
@@ -48,7 +40,7 @@ export async function listAuths(
48
40
  try {
49
41
  // Use the standalone getApp function
50
42
  const app = await getApp({
51
- key: options.appKey,
43
+ appKey: options.appKey,
52
44
  api,
53
45
  token: options.token,
54
46
  baseUrl: options.baseUrl,
@@ -146,9 +138,9 @@ export async function listAuths(
146
138
  });
147
139
 
148
140
  // Filter out auths the user already owns to avoid duplicates
149
- const ownedAuthIds = new Set(ownedAuths.map((auth) => auth.id));
141
+ const ownedAuthenticationIds = new Set(ownedAuths.map((auth) => auth.id));
150
142
  const additionalAuths = allAuths.filter(
151
- (auth) => !ownedAuthIds.has(auth.id),
143
+ (auth) => !ownedAuthenticationIds.has(auth.id),
152
144
  );
153
145
 
154
146
  // Combine and slice to the requested limit
@@ -0,0 +1,9 @@
1
+ import { listAuths } from "./index";
2
+ import { ListAuthsSchema } from "./schemas";
3
+
4
+ // Function registry info - imports both function and schema
5
+ export const listAuthsInfo = {
6
+ name: listAuths.name,
7
+ inputSchema: ListAuthsSchema,
8
+ implementation: listAuths,
9
+ };
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import {
3
+ AppKeyPropertySchema,
4
+ LimitPropertySchema,
5
+ OffsetPropertySchema,
6
+ } from "../../types/properties";
7
+ import { withOutputSchema } from "../../schema-utils";
8
+ import { AuthItemSchema } from "../../schemas/Auth";
9
+ import type { Authentication } from "../../types/domain";
10
+
11
+ // Pure Zod schema - no resolver metadata!
12
+ export const ListAuthsSchema = withOutputSchema(
13
+ z
14
+ .object({
15
+ appKey: AppKeyPropertySchema.optional().describe(
16
+ "App slug to get authentications for (e.g., 'slack', 'github')",
17
+ ),
18
+ account_id: z.string().optional().describe("Filter by account ID"),
19
+ owner: z.string().optional().describe("Filter by owner"),
20
+ limit: LimitPropertySchema.optional().describe(
21
+ "Maximum number of items to return (1-200)",
22
+ ),
23
+ offset: OffsetPropertySchema.optional().describe(
24
+ "Number of items to skip for pagination",
25
+ ),
26
+ })
27
+ .describe("List available authentications with optional filtering"),
28
+ AuthItemSchema,
29
+ );
30
+
31
+ // Type inferred from schema + function config
32
+ export type ListAuthsOptions = z.infer<typeof ListAuthsSchema> & {
33
+ /** Base URL for Zapier API */
34
+ baseUrl?: string;
35
+ /** Authentication token */
36
+ token?: string;
37
+ /** Optional pre-instantiated API client */
38
+ api?: any;
39
+ /** Enable debug logging */
40
+ debug?: boolean;
41
+ /** Custom fetch implementation */
42
+ fetch?: typeof globalThis.fetch;
43
+ };
44
+
45
+ // SDK function interface - ready to be mixed into main SDK interface
46
+ export interface ListAuthsSdkFunction {
47
+ listAuths: (options?: Partial<ListAuthsOptions>) => Promise<Authentication[]>;
48
+ }
@@ -1,19 +1,11 @@
1
- import { getOrCreateApiClient } from "../api";
1
+ import { getOrCreateApiClient } from "../../api";
2
2
  import type {
3
3
  ActionField,
4
4
  NeedsRequest,
5
5
  NeedsResponse,
6
- FunctionConfig,
7
- } from "../types";
8
- import { getApp } from "./getApp";
9
-
10
- export interface ListFieldsOptions extends FunctionConfig {
11
- app: string;
12
- action: string;
13
- type: string;
14
- authId?: number;
15
- params?: Record<string, any>;
16
- }
6
+ } from "../../types/domain";
7
+ import { getApp } from "../getApp";
8
+ import type { ListFieldsOptions } from "./schemas";
17
9
 
18
10
  /**
19
11
  * List available fields for an action
@@ -21,7 +13,7 @@ export interface ListFieldsOptions extends FunctionConfig {
21
13
  * This function can be used standalone without instantiating a full SDK,
22
14
  * which enables better tree-shaking in applications that only need this functionality.
23
15
  *
24
- * @param options - Action details, auth ID, params, and API configuration options
16
+ * @param options - Action details, authentication ID, params, and API configuration options
25
17
  * @returns Promise<ActionField[]>
26
18
  */
27
19
  export async function listFields(
@@ -29,15 +21,12 @@ export async function listFields(
29
21
  ): Promise<ActionField[]> {
30
22
  const api = getOrCreateApiClient(options);
31
23
 
32
- // Map consistent parameter names to internal API names
33
- const { app, action, type, authId, params } = options;
34
- const appKey = app;
35
- const actionKey = action;
36
- const actionType = type;
24
+ // Extract parameters
25
+ const { appKey, actionKey, actionType, authenticationId, params } = options;
37
26
 
38
27
  // Use the standalone getApp function
39
28
  const appData = await getApp({
40
- key: appKey,
29
+ appKey,
41
30
  api,
42
31
  token: options.token,
43
32
  baseUrl: options.baseUrl,
@@ -55,7 +44,7 @@ export async function listFields(
55
44
  selected_api: selectedApi,
56
45
  action: actionKey,
57
46
  type_of: actionType,
58
- authentication_id: authId,
47
+ authentication_id: authenticationId,
59
48
  params: params || {},
60
49
  };
61
50
 
@@ -93,3 +82,5 @@ export async function listFields(
93
82
  inputFormat: need.input_format,
94
83
  }));
95
84
  }
85
+
86
+ // No registry info here - moved to info.ts for proper tree-shaking
@@ -0,0 +1,9 @@
1
+ import { listFields } from "./index";
2
+ import { ListFieldsSchema } from "./schemas";
3
+
4
+ // Function registry info - imports both function and schema
5
+ export const listFieldsInfo = {
6
+ name: listFields.name,
7
+ inputSchema: ListFieldsSchema,
8
+ implementation: listFields,
9
+ };
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ import {
3
+ AppKeyPropertySchema,
4
+ ActionTypePropertySchema,
5
+ ActionKeyPropertySchema,
6
+ AuthenticationIdPropertySchema,
7
+ ParamsPropertySchema,
8
+ } from "../../types/properties";
9
+ import { withOutputSchema } from "../../schema-utils";
10
+ import { FieldItemSchema } from "../../schemas/Field";
11
+ import type { ActionField } from "../../types/domain";
12
+
13
+ // Pure Zod schema - no resolver metadata!
14
+ export const ListFieldsSchema = withOutputSchema(
15
+ z
16
+ .object({
17
+ appKey: AppKeyPropertySchema,
18
+ actionType: ActionTypePropertySchema,
19
+ actionKey: ActionKeyPropertySchema,
20
+ authenticationId: AuthenticationIdPropertySchema.optional(),
21
+ params: ParamsPropertySchema.optional().describe(
22
+ "Additional parameters that may affect available fields",
23
+ ),
24
+ })
25
+ .describe("Get the input fields required for a specific action"),
26
+ FieldItemSchema,
27
+ );
28
+
29
+ // Type inferred from schema + function config
30
+ export type ListFieldsOptions = z.infer<typeof ListFieldsSchema> & {
31
+ /** Base URL for Zapier API */
32
+ baseUrl?: string;
33
+ /** Authentication token */
34
+ token?: string;
35
+ /** Optional pre-instantiated API client */
36
+ api?: any;
37
+ /** Enable debug logging */
38
+ debug?: boolean;
39
+ /** Custom fetch implementation */
40
+ fetch?: typeof globalThis.fetch;
41
+ };
42
+
43
+ // SDK function interface - ready to be mixed into main SDK interface
44
+ export interface ListFieldsSdkFunction {
45
+ listFields: (options: ListFieldsOptions) => Promise<ActionField[]>;
46
+ }
@@ -1,15 +1,8 @@
1
- import { getOrCreateApiClient, generateRequestId } from "../api";
2
- import type { ActionExecutionResult, FunctionConfig } from "../types";
3
- import { getAction } from "./getAction";
4
- import { getApp } from "./getApp";
5
-
6
- export interface RunActionOptions extends FunctionConfig {
7
- app: string;
8
- type: string;
9
- action: string;
10
- inputs?: Record<string, any>;
11
- authId?: number;
12
- }
1
+ import { getOrCreateApiClient, generateRequestId } from "../../api";
2
+ import type { ActionExecutionResult } from "../../types/domain";
3
+ import { getAction } from "../getAction";
4
+ import { getApp } from "../getApp";
5
+ import type { RunActionOptions } from "./schemas";
13
6
 
14
7
  /**
15
8
  * Execute an action
@@ -23,7 +16,14 @@ export interface RunActionOptions extends FunctionConfig {
23
16
  export async function runAction(
24
17
  options: RunActionOptions,
25
18
  ): Promise<ActionExecutionResult> {
26
- const { app, type, action, inputs, authId: providedAuthId, token } = options;
19
+ const {
20
+ appKey,
21
+ actionType,
22
+ actionKey,
23
+ inputs,
24
+ authenticationId: providedAuthenticationId,
25
+ token,
26
+ } = options;
27
27
 
28
28
  if (!token && !process.env.ZAPIER_TOKEN) {
29
29
  throw new Error(
@@ -36,15 +36,15 @@ export async function runAction(
36
36
  // Validate that the action exists
37
37
  const actionData = await getAction({
38
38
  ...options,
39
- app: app,
40
- action: action,
41
- type: type,
39
+ appKey: appKey,
40
+ actionKey: actionKey,
41
+ actionType: actionType,
42
42
  });
43
43
 
44
44
  // Validate action type matches
45
- if (actionData.type !== type) {
45
+ if (actionData.type !== actionType) {
46
46
  throw new Error(
47
- `Action type mismatch: expected ${type}, got ${actionData.type}`,
47
+ `Action type mismatch: expected ${actionType}, got ${actionData.type}`,
48
48
  );
49
49
  }
50
50
 
@@ -52,12 +52,12 @@ export async function runAction(
52
52
  const startTime = Date.now();
53
53
  const result = await executeActionWithStrategy({
54
54
  api,
55
- appSlug: app,
56
- actionKey: action,
55
+ appSlug: appKey,
56
+ actionKey: actionKey,
57
57
  actionType: actionData.type,
58
58
  executionOptions: { inputs: inputs || {} },
59
59
  auth: token
60
- ? { token: token, authentication_id: providedAuthId }
60
+ ? { token: token, authentication_id: providedAuthenticationId }
61
61
  : undefined,
62
62
  options,
63
63
  });
@@ -150,7 +150,7 @@ async function executeActionViaActionsApi(
150
150
 
151
151
  // Use the standalone getApp function
152
152
  const appData = await getApp({
153
- key: appSlug,
153
+ appKey: appSlug,
154
154
  api,
155
155
  token: options.token,
156
156
  baseUrl: options.baseUrl,
@@ -216,7 +216,7 @@ async function executeActionViaInvokeApi(
216
216
 
217
217
  // Use the standalone getApp function
218
218
  const appData = await getApp({
219
- key: appSlug,
219
+ appKey: appSlug,
220
220
  api,
221
221
  token: options.token,
222
222
  baseUrl: options.baseUrl,
@@ -254,3 +254,5 @@ async function executeActionViaInvokeApi(
254
254
  resultExtractor: (result: any) => result.results || result,
255
255
  });
256
256
  }
257
+
258
+ // No registry info here - moved to info.ts for proper tree-shaking
@@ -0,0 +1,9 @@
1
+ import { runAction } from "./index";
2
+ import { RunActionSchema } from "./schemas";
3
+
4
+ // Function registry info - imports both function and schema
5
+ export const runActionInfo = {
6
+ name: runAction.name,
7
+ inputSchema: RunActionSchema,
8
+ implementation: runAction,
9
+ };
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ import {
3
+ AppKeyPropertySchema,
4
+ ActionTypePropertySchema,
5
+ ActionKeyPropertySchema,
6
+ AuthenticationIdPropertySchema,
7
+ InputsPropertySchema,
8
+ } from "../../types/properties";
9
+ import type { ActionExecutionResult } from "../../types/domain";
10
+
11
+ // Pure Zod schema - no resolver metadata!
12
+ export const RunActionSchema = z
13
+ .object({
14
+ appKey: AppKeyPropertySchema,
15
+ actionType: ActionTypePropertySchema,
16
+ actionKey: ActionKeyPropertySchema,
17
+ inputs: InputsPropertySchema.optional().describe(
18
+ "Input parameters for the action",
19
+ ),
20
+ authenticationId: AuthenticationIdPropertySchema.optional(),
21
+ })
22
+ .describe("Execute an action with the given inputs");
23
+
24
+ // Type inferred from schema + function config
25
+ export type RunActionOptions = z.infer<typeof RunActionSchema> & {
26
+ /** Base URL for Zapier API */
27
+ baseUrl?: string;
28
+ /** Authentication token */
29
+ token?: string;
30
+ /** Optional pre-instantiated API client */
31
+ api?: any;
32
+ /** Enable debug logging */
33
+ debug?: boolean;
34
+ /** Custom fetch implementation */
35
+ fetch?: typeof globalThis.fetch;
36
+ };
37
+
38
+ // SDK function interface - ready to be mixed into main SDK interface
39
+ export interface RunActionSdkFunction {
40
+ runAction: (options: RunActionOptions) => Promise<ActionExecutionResult>;
41
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,12 @@
1
- // Export everything from types and actions-sdk
2
- export * from "./types";
3
- export * from "./actions-sdk";
1
+ // Export everything from types and plugins
2
+ export * from "./types/domain";
3
+ export * from "./types/properties";
4
+ export * from "./plugins/apps";
5
+
6
+ // Export resolvers for CLI use
7
+ export * from "./resolvers";
8
+
9
+ // Note: SdkSchemas is now available via SDK.__registry
4
10
 
5
11
  // Export individual functions for tree-shaking
6
12
  export { listAuths } from "./functions/listAuths";
@@ -14,4 +20,7 @@ export { generateTypes } from "./functions/generateTypes";
14
20
  export { bundleCode } from "./functions/bundleCode";
15
21
 
16
22
  // Export the main combined SDK
17
- export { createZapierSdk, ZapierSdk, ZapierSdkOptions } from "./sdk";
23
+ export { createZapierSdk, ZapierSdkOptions } from "./sdk";
24
+
25
+ // Export SDK type from types (not sdk.ts to avoid circular imports)
26
+ export type { ZapierSdk } from "./types/sdk";