@zapier/zapier-sdk 0.0.2 → 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 (167) 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 -76
  12. package/dist/api/types.js +9 -0
  13. package/dist/functions/bundleCode/index.d.ts +11 -0
  14. package/dist/functions/bundleCode/index.js +91 -0
  15. package/dist/functions/bundleCode/info.d.ts +27 -0
  16. package/dist/functions/bundleCode/info.js +11 -0
  17. package/dist/functions/bundleCode/schemas.d.ts +27 -0
  18. package/dist/functions/bundleCode/schemas.js +22 -0
  19. package/dist/functions/generateTypes/index.d.ts +11 -0
  20. package/dist/functions/generateTypes/index.js +305 -0
  21. package/dist/functions/generateTypes/info.d.ts +21 -0
  22. package/dist/functions/generateTypes/info.js +11 -0
  23. package/dist/functions/generateTypes/schemas.d.ts +30 -0
  24. package/dist/functions/generateTypes/schemas.js +14 -0
  25. package/dist/functions/getAction/index.d.ts +12 -0
  26. package/dist/functions/getAction/index.js +26 -0
  27. package/dist/functions/getAction/info.d.ts +18 -0
  28. package/dist/functions/getAction/info.js +11 -0
  29. package/dist/functions/getAction/schemas.d.ts +30 -0
  30. package/dist/functions/getAction/schemas.js +13 -0
  31. package/dist/functions/getApp/index.d.ts +12 -0
  32. package/dist/functions/getApp/index.js +37 -0
  33. package/dist/functions/getApp/info.d.ts +12 -0
  34. package/dist/functions/getApp/info.js +11 -0
  35. package/dist/functions/getApp/schemas.d.ts +24 -0
  36. package/dist/functions/getApp/schemas.js +11 -0
  37. package/dist/functions/listActions/index.d.ts +12 -0
  38. package/dist/functions/listActions/index.js +128 -0
  39. package/dist/functions/listActions/info.d.ts +15 -0
  40. package/dist/functions/listActions/info.js +11 -0
  41. package/dist/functions/listActions/schemas.d.ts +27 -0
  42. package/dist/functions/listActions/schemas.js +14 -0
  43. package/dist/functions/listApps/index.d.ts +12 -0
  44. package/dist/functions/listApps/index.js +50 -0
  45. package/dist/functions/listApps/info.d.ts +18 -0
  46. package/dist/functions/listApps/info.js +11 -0
  47. package/dist/functions/listApps/schemas.d.ts +30 -0
  48. package/dist/functions/listApps/schemas.js +15 -0
  49. package/dist/functions/listAuths/index.d.ts +12 -0
  50. package/dist/functions/listAuths/index.js +118 -0
  51. package/dist/functions/listAuths/info.d.ts +24 -0
  52. package/dist/functions/listAuths/info.js +11 -0
  53. package/dist/functions/listAuths/schemas.d.ts +36 -0
  54. package/dist/functions/listAuths/schemas.js +17 -0
  55. package/dist/functions/listFields/index.d.ts +12 -0
  56. package/dist/functions/listFields/index.js +65 -0
  57. package/dist/functions/listFields/info.d.ts +24 -0
  58. package/dist/functions/listFields/info.js +11 -0
  59. package/dist/functions/listFields/schemas.d.ts +36 -0
  60. package/dist/functions/listFields/schemas.js +17 -0
  61. package/dist/functions/runAction/index.d.ts +12 -0
  62. package/dist/functions/runAction/index.js +157 -0
  63. package/dist/functions/runAction/info.d.ts +24 -0
  64. package/dist/functions/runAction/info.js +11 -0
  65. package/dist/functions/runAction/schemas.d.ts +36 -0
  66. package/dist/functions/runAction/schemas.js +15 -0
  67. package/dist/index.d.ts +15 -3
  68. package/dist/index.js +27 -4
  69. package/dist/plugins/apps/index.d.ts +8 -0
  70. package/dist/plugins/apps/index.js +77 -0
  71. package/dist/plugins/apps/info.d.ts +6 -0
  72. package/dist/plugins/apps/info.js +13 -0
  73. package/dist/plugins/apps/types.d.ts +21 -0
  74. package/dist/plugins/apps/types.js +2 -0
  75. package/dist/resolvers/actionKey.d.ts +8 -0
  76. package/dist/resolvers/actionKey.js +20 -0
  77. package/dist/resolvers/actionType.d.ts +8 -0
  78. package/dist/resolvers/actionType.js +21 -0
  79. package/dist/resolvers/appKey.d.ts +6 -0
  80. package/dist/resolvers/appKey.js +8 -0
  81. package/dist/resolvers/authenticationId.d.ts +8 -0
  82. package/dist/resolvers/authenticationId.js +29 -0
  83. package/dist/resolvers/index.d.ts +39 -0
  84. package/dist/resolvers/index.js +105 -0
  85. package/dist/resolvers/inputs.d.ts +7 -0
  86. package/dist/resolvers/inputs.js +15 -0
  87. package/dist/schema-utils.d.ts +39 -0
  88. package/dist/schema-utils.js +52 -0
  89. package/dist/schemas/Action.d.ts +21 -0
  90. package/dist/schemas/Action.js +31 -0
  91. package/dist/schemas/App.d.ts +19 -0
  92. package/dist/schemas/App.js +32 -0
  93. package/dist/schemas/Auth.d.ts +30 -0
  94. package/dist/schemas/Auth.js +49 -0
  95. package/dist/schemas/Field.d.ts +15 -0
  96. package/dist/schemas/Field.js +25 -0
  97. package/dist/sdk.d.ts +3 -4
  98. package/dist/sdk.js +96 -11
  99. package/dist/types/domain.d.ts +22 -0
  100. package/dist/types/domain.js +21 -0
  101. package/dist/types/properties.d.ts +21 -0
  102. package/dist/types/properties.js +45 -0
  103. package/dist/types/sdk.d.ts +21 -0
  104. package/dist/types/sdk.js +2 -0
  105. package/package.json +4 -2
  106. package/src/api/auth.ts +28 -0
  107. package/src/api/client.ts +148 -0
  108. package/src/api/debug.ts +58 -0
  109. package/src/api/index.ts +83 -0
  110. package/src/api/polling.ts +56 -0
  111. package/src/{types.ts → api/types.ts} +51 -118
  112. package/src/functions/bundleCode/index.ts +78 -0
  113. package/src/functions/bundleCode/info.ts +9 -0
  114. package/src/functions/bundleCode/schemas.ts +30 -0
  115. package/src/functions/generateTypes/index.ts +348 -0
  116. package/src/functions/generateTypes/info.ts +9 -0
  117. package/src/functions/generateTypes/schemas.ts +38 -0
  118. package/src/functions/getAction/index.ts +33 -0
  119. package/src/functions/getAction/info.ts +9 -0
  120. package/src/functions/getAction/schemas.ts +35 -0
  121. package/src/functions/getApp/index.ts +41 -0
  122. package/src/functions/getApp/info.ts +9 -0
  123. package/src/functions/getApp/schemas.ts +31 -0
  124. package/src/functions/listActions/index.ts +149 -0
  125. package/src/functions/listActions/info.ts +9 -0
  126. package/src/functions/listActions/schemas.ts +40 -0
  127. package/src/functions/listApps/index.ts +60 -0
  128. package/src/functions/listApps/info.ts +9 -0
  129. package/src/functions/listApps/schemas.ts +43 -0
  130. package/src/functions/listAuths/index.ts +153 -0
  131. package/src/functions/listAuths/info.ts +9 -0
  132. package/src/functions/listAuths/schemas.ts +48 -0
  133. package/src/functions/listFields/index.ts +86 -0
  134. package/src/functions/listFields/info.ts +9 -0
  135. package/src/functions/listFields/schemas.ts +46 -0
  136. package/src/functions/runAction/index.ts +258 -0
  137. package/src/functions/runAction/info.ts +9 -0
  138. package/src/functions/runAction/schemas.ts +41 -0
  139. package/src/index.ts +24 -4
  140. package/src/plugins/apps/index.ts +144 -0
  141. package/src/plugins/apps/info.ts +12 -0
  142. package/src/plugins/apps/types.ts +34 -0
  143. package/src/resolvers/actionKey.ts +33 -0
  144. package/src/resolvers/actionType.ts +30 -0
  145. package/src/resolvers/appKey.ts +11 -0
  146. package/src/resolvers/authenticationId.ts +38 -0
  147. package/src/resolvers/index.ts +117 -0
  148. package/src/resolvers/inputs.ts +23 -0
  149. package/src/schema-utils.ts +119 -0
  150. package/src/schemas/Action.ts +40 -0
  151. package/src/schemas/App.ts +43 -0
  152. package/src/schemas/Auth.ts +62 -0
  153. package/src/schemas/Field.ts +34 -0
  154. package/src/sdk.ts +153 -19
  155. package/src/types/domain.ts +54 -0
  156. package/src/types/properties.ts +67 -0
  157. package/src/types/sdk.ts +42 -0
  158. package/dist/actions-sdk.d.ts +0 -51
  159. package/dist/actions-sdk.js +0 -1194
  160. package/dist/output-schemas.d.ts +0 -95
  161. package/dist/output-schemas.js +0 -138
  162. package/dist/schemas.d.ts +0 -338
  163. package/dist/schemas.js +0 -336
  164. package/dist/types.js +0 -41
  165. package/src/actions-sdk.ts +0 -1685
  166. package/src/output-schemas.ts +0 -196
  167. package/src/schemas.ts +0 -467
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Authentication Utilities
3
+ *
4
+ * This module provides utilities for handling authentication tokens,
5
+ * including JWT detection and authorization header generation.
6
+ */
7
+ export declare function isJwt(token: string): boolean;
8
+ export declare function getAuthorizationHeader(token: string): string;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * Authentication Utilities
4
+ *
5
+ * This module provides utilities for handling authentication tokens,
6
+ * including JWT detection and authorization header generation.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.isJwt = isJwt;
10
+ exports.getAuthorizationHeader = getAuthorizationHeader;
11
+ function isJwt(token) {
12
+ // JWT tokens have exactly 3 parts separated by dots
13
+ const parts = token.split(".");
14
+ if (parts.length !== 3) {
15
+ return false;
16
+ }
17
+ // Each part should be base64url encoded (no padding)
18
+ // Basic validation - each part should be non-empty and contain valid base64url characters
19
+ const base64UrlPattern = /^[A-Za-z0-9_-]+$/;
20
+ return parts.every((part) => part.length > 0 && base64UrlPattern.test(part));
21
+ }
22
+ function getAuthorizationHeader(token) {
23
+ // Check if token is a JWT (has 3 parts separated by dots)
24
+ if (isJwt(token)) {
25
+ return `JWT ${token}`;
26
+ }
27
+ // Default to Bearer for other token types
28
+ return `Bearer ${token}`;
29
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * API Client Implementation
3
+ *
4
+ * This module contains the core API client implementation, including
5
+ * HTTP method handlers, response processing, and client factory functions.
6
+ */
7
+ import type { ApiClient, ApiClientOptions } from "./types";
8
+ export declare function createZapierApi(options: ApiClientOptions): ApiClient;
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ /**
3
+ * API Client Implementation
4
+ *
5
+ * This module contains the core API client implementation, including
6
+ * HTTP method handlers, response processing, and client factory functions.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.createZapierApi = createZapierApi;
10
+ const auth_1 = require("./auth");
11
+ const debug_1 = require("./debug");
12
+ const polling_1 = require("./polling");
13
+ function createZapierApi(options) {
14
+ const { baseUrl, token, debug = false, fetch: originalFetch = globalThis.fetch, } = options;
15
+ const debugLog = (0, debug_1.createDebugLogger)(debug);
16
+ const fetch = (0, debug_1.createDebugFetch)({ originalFetch, debugLog });
17
+ // Helper to build full URLs
18
+ function buildUrl(path, searchParams) {
19
+ const url = new URL(path, baseUrl);
20
+ if (searchParams) {
21
+ Object.entries(searchParams).forEach(([key, value]) => {
22
+ url.searchParams.set(key, value);
23
+ });
24
+ }
25
+ return url.toString();
26
+ }
27
+ // Helper to build headers
28
+ function buildHeaders(options = {}) {
29
+ const headers = {
30
+ ...options.headers,
31
+ };
32
+ // Add auth header if token provided and not explicitly disabled
33
+ if (token && options.authRequired !== false) {
34
+ headers.Authorization = (0, auth_1.getAuthorizationHeader)(token);
35
+ }
36
+ return headers;
37
+ }
38
+ // Helper to handle responses
39
+ async function handleResponse(response, customErrorHandler) {
40
+ if (!response.ok) {
41
+ // Check for custom error handling first
42
+ if (customErrorHandler) {
43
+ const customError = customErrorHandler(response);
44
+ if (customError) {
45
+ throw customError;
46
+ }
47
+ }
48
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
49
+ }
50
+ // Try to parse JSON, fall back to text if that fails
51
+ try {
52
+ return await response.json();
53
+ }
54
+ catch {
55
+ return await response.text();
56
+ }
57
+ }
58
+ // Helper to perform HTTP requests with JSON handling
59
+ async function fetchJson(method, path, data, options = {}) {
60
+ const url = buildUrl(path, options.searchParams);
61
+ const headers = buildHeaders(options);
62
+ // Add Content-Type for JSON requests with body data
63
+ if (data && typeof data === "object") {
64
+ headers["Content-Type"] = "application/json";
65
+ }
66
+ const response = await fetch(url, {
67
+ method,
68
+ headers,
69
+ body: data ? JSON.stringify(data) : undefined,
70
+ });
71
+ return handleResponse(response, options.customErrorHandler);
72
+ }
73
+ return {
74
+ async get(path, options = {}) {
75
+ return fetchJson("GET", path, undefined, options);
76
+ },
77
+ async post(path, data, options = {}) {
78
+ return fetchJson("POST", path, data, options);
79
+ },
80
+ async put(path, data, options = {}) {
81
+ return fetchJson("PUT", path, data, options);
82
+ },
83
+ async delete(path, options = {}) {
84
+ return fetchJson("DELETE", path, undefined, options);
85
+ },
86
+ async poll(path, options = {}) {
87
+ const url = buildUrl(path, options.searchParams);
88
+ const headers = buildHeaders(options);
89
+ return (0, polling_1.pollUntilComplete)({
90
+ fetch,
91
+ url,
92
+ headers,
93
+ maxAttempts: options.maxAttempts,
94
+ initialDelay: options.initialDelay,
95
+ maxDelay: options.maxDelay,
96
+ successStatus: options.successStatus,
97
+ pendingStatus: options.pendingStatus,
98
+ resultExtractor: options.resultExtractor,
99
+ });
100
+ },
101
+ };
102
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Debug Logging Utilities
3
+ *
4
+ * This module provides debug logging capabilities for API requests and responses,
5
+ * including request timing and detailed logging of HTTP interactions.
6
+ */
7
+ import type { DebugLogger } from "./types";
8
+ export declare function createDebugLogger(enabled: boolean): DebugLogger;
9
+ export declare function createDebugFetch(options: {
10
+ originalFetch: typeof globalThis.fetch;
11
+ debugLog: DebugLogger;
12
+ }): (input: RequestInfo | URL, options?: RequestInit) => Promise<Response>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * Debug Logging Utilities
4
+ *
5
+ * This module provides debug logging capabilities for API requests and responses,
6
+ * including request timing and detailed logging of HTTP interactions.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.createDebugLogger = createDebugLogger;
10
+ exports.createDebugFetch = createDebugFetch;
11
+ function createDebugLogger(enabled) {
12
+ if (!enabled) {
13
+ return () => { }; // No-op function when debug is disabled
14
+ }
15
+ return (message, data) => {
16
+ console.log(`[Zapier SDK] ${message}`, data || "");
17
+ };
18
+ }
19
+ function createDebugFetch(options) {
20
+ const { originalFetch, debugLog } = options;
21
+ return async (input, options) => {
22
+ const startTime = Date.now();
23
+ // Convert input to URL string for logging
24
+ const url = typeof input === "string" ? input : input.toString();
25
+ const method = options?.method || "GET";
26
+ debugLog(`→ ${method} ${url}`, {
27
+ headers: options?.headers,
28
+ body: options?.body ? JSON.parse(options.body) : undefined,
29
+ });
30
+ try {
31
+ const response = await originalFetch(input, options);
32
+ const duration = Date.now() - startTime;
33
+ debugLog(`← ${response.status} ${response.statusText} (${duration}ms)`, {
34
+ url,
35
+ method,
36
+ status: response.status,
37
+ });
38
+ return response;
39
+ }
40
+ catch (error) {
41
+ const duration = Date.now() - startTime;
42
+ debugLog(`✖ Request failed (${duration}ms)`, {
43
+ url,
44
+ method,
45
+ error: error instanceof Error ? error.message : error,
46
+ });
47
+ throw error;
48
+ }
49
+ };
50
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Zapier API Client Module
3
+ *
4
+ * This module provides a centralized API layer for all HTTP interactions
5
+ * with Zapier's various APIs. It handles authentication, error handling,
6
+ * polling, and provides consistent patterns across all services.
7
+ */
8
+ export type { ApiClient, ApiClientOptions, RequestOptions, PollOptions, DebugLogger, Integration, Action, Trigger, Field, Choice, ActionExecutionResult, ActionField, ActionFieldChoice, NeedsRequest, NeedsResponse, Authentication, AuthenticationsResponse, } from "./types";
9
+ export { isJwt, getAuthorizationHeader } from "./auth";
10
+ export { createDebugLogger, createDebugFetch } from "./debug";
11
+ export { pollUntilComplete } from "./polling";
12
+ export { createZapierApi } from "./client";
13
+ export declare function generateRequestId(): string;
14
+ /**
15
+ * Utility function to get or create an API client for standalone functions
16
+ *
17
+ * @param config - Configuration that may include an existing API client
18
+ * @returns ApiClient instance
19
+ */
20
+ export declare function getOrCreateApiClient(config: {
21
+ baseUrl?: string;
22
+ token?: string;
23
+ api?: import("./types").ApiClient;
24
+ debug?: boolean;
25
+ fetch?: typeof globalThis.fetch;
26
+ }): import("./types").ApiClient;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * Zapier API Client Module
4
+ *
5
+ * This module provides a centralized API layer for all HTTP interactions
6
+ * with Zapier's various APIs. It handles authentication, error handling,
7
+ * polling, and provides consistent patterns across all services.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.createZapierApi = exports.pollUntilComplete = exports.createDebugFetch = exports.createDebugLogger = exports.getAuthorizationHeader = exports.isJwt = void 0;
11
+ exports.generateRequestId = generateRequestId;
12
+ exports.getOrCreateApiClient = getOrCreateApiClient;
13
+ // Re-export authentication utilities
14
+ var auth_1 = require("./auth");
15
+ Object.defineProperty(exports, "isJwt", { enumerable: true, get: function () { return auth_1.isJwt; } });
16
+ Object.defineProperty(exports, "getAuthorizationHeader", { enumerable: true, get: function () { return auth_1.getAuthorizationHeader; } });
17
+ // Re-export debug utilities
18
+ var debug_1 = require("./debug");
19
+ Object.defineProperty(exports, "createDebugLogger", { enumerable: true, get: function () { return debug_1.createDebugLogger; } });
20
+ Object.defineProperty(exports, "createDebugFetch", { enumerable: true, get: function () { return debug_1.createDebugFetch; } });
21
+ // Re-export polling utilities
22
+ var polling_1 = require("./polling");
23
+ Object.defineProperty(exports, "pollUntilComplete", { enumerable: true, get: function () { return polling_1.pollUntilComplete; } });
24
+ // Re-export the main client factory
25
+ var client_1 = require("./client");
26
+ Object.defineProperty(exports, "createZapierApi", { enumerable: true, get: function () { return client_1.createZapierApi; } });
27
+ // Utility Functions
28
+ function generateRequestId() {
29
+ return Math.random().toString(36).substring(2) + Date.now().toString(36);
30
+ }
31
+ /**
32
+ * Utility function to get or create an API client for standalone functions
33
+ *
34
+ * @param config - Configuration that may include an existing API client
35
+ * @returns ApiClient instance
36
+ */
37
+ function getOrCreateApiClient(config) {
38
+ const { baseUrl = "https://zapier.com", token = process.env.ZAPIER_TOKEN, api: providedApi, debug = false, fetch: customFetch, } = config;
39
+ // Use provided API client or create a new one
40
+ if (providedApi) {
41
+ return providedApi;
42
+ }
43
+ // Import createZapierApi locally to avoid circular imports
44
+ const { createZapierApi } = require("./client");
45
+ return createZapierApi({
46
+ baseUrl,
47
+ token,
48
+ debug,
49
+ fetch: customFetch,
50
+ });
51
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Polling Utilities
3
+ *
4
+ * This module provides utilities for polling HTTP endpoints until completion,
5
+ * with configurable retry logic and exponential backoff.
6
+ */
7
+ export declare function pollUntilComplete(options: {
8
+ fetch: typeof globalThis.fetch;
9
+ url: string;
10
+ headers?: Record<string, string>;
11
+ maxAttempts?: number;
12
+ initialDelay?: number;
13
+ maxDelay?: number;
14
+ successStatus?: number;
15
+ pendingStatus?: number;
16
+ resultExtractor?: (response: any) => any;
17
+ }): Promise<any>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Polling Utilities
4
+ *
5
+ * This module provides utilities for polling HTTP endpoints until completion,
6
+ * with configurable retry logic and exponential backoff.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.pollUntilComplete = pollUntilComplete;
10
+ async function pollUntilComplete(options) {
11
+ const { fetch, url, headers = {}, maxAttempts = 30, initialDelay = 50, maxDelay = 1000, successStatus = 200, pendingStatus = 202, resultExtractor = (response) => response, } = options;
12
+ let delay = initialDelay;
13
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
14
+ const response = await fetch(url, { headers });
15
+ if (response.status === successStatus) {
16
+ // Success - extract and return results
17
+ const result = await response.json();
18
+ return resultExtractor(result);
19
+ }
20
+ else if (response.status === pendingStatus) {
21
+ // Still processing - wait and retry
22
+ if (attempt < maxAttempts - 1) {
23
+ await new Promise((resolve) => setTimeout(resolve, delay));
24
+ delay = Math.min(delay * 2, maxDelay); // Exponential backoff
25
+ continue;
26
+ }
27
+ }
28
+ else {
29
+ // Error occurred
30
+ throw new Error(`Request failed: GET ${url} - ${response.status} ${response.statusText}`);
31
+ }
32
+ }
33
+ throw new Error(`Operation timed out after ${maxAttempts} attempts`);
34
+ }
@@ -1,3 +1,40 @@
1
+ /**
2
+ * API Client Type Definitions
3
+ *
4
+ * This module contains all type definitions related to the Zapier API client,
5
+ * including configuration options, client interfaces, request/response types,
6
+ * and API response models.
7
+ */
8
+ export interface ApiClientOptions {
9
+ baseUrl: string;
10
+ token?: string;
11
+ debug?: boolean;
12
+ fetch?: typeof globalThis.fetch;
13
+ }
14
+ export interface ApiClient {
15
+ get: (path: string, options?: RequestOptions) => Promise<any>;
16
+ post: (path: string, data?: any, options?: RequestOptions) => Promise<any>;
17
+ put: (path: string, data?: any, options?: RequestOptions) => Promise<any>;
18
+ delete: (path: string, options?: RequestOptions) => Promise<any>;
19
+ poll: (path: string, options?: PollOptions) => Promise<any>;
20
+ }
21
+ export interface RequestOptions {
22
+ headers?: Record<string, string>;
23
+ searchParams?: Record<string, string>;
24
+ authRequired?: boolean;
25
+ customErrorHandler?: (response: Response) => Error | undefined;
26
+ }
27
+ export interface PollOptions extends RequestOptions {
28
+ maxAttempts?: number;
29
+ initialDelay?: number;
30
+ maxDelay?: number;
31
+ successStatus?: number;
32
+ pendingStatus?: number;
33
+ resultExtractor?: (response: any) => any;
34
+ }
35
+ export interface DebugLogger {
36
+ (message: string, data?: any): void;
37
+ }
1
38
  export interface Integration {
2
39
  key: string;
3
40
  name: string;
@@ -37,17 +74,6 @@ export interface Choice {
37
74
  value: string | number;
38
75
  label: string;
39
76
  }
40
- export interface ListOptions {
41
- category?: string;
42
- appKey?: string;
43
- type?: string;
44
- limit?: number;
45
- offset?: number;
46
- }
47
- export interface ActionExecutionOptions {
48
- inputs?: Record<string, any>;
49
- authId?: number;
50
- }
51
77
  export interface ActionExecutionResult {
52
78
  success: boolean;
53
79
  data?: any;
@@ -89,34 +115,6 @@ export interface NeedsResponse {
89
115
  needs?: ActionField[];
90
116
  errors?: string[];
91
117
  }
92
- export interface Workflow {
93
- id: string;
94
- name: string;
95
- description: string;
96
- steps: WorkflowStep[];
97
- }
98
- export interface WorkflowStep {
99
- id: string;
100
- type: "trigger" | "action";
101
- appKey: string;
102
- actionKey?: string;
103
- triggerKey?: string;
104
- }
105
- export interface Interface {
106
- key: string;
107
- name: string;
108
- fields: Field[];
109
- }
110
- export interface Table {
111
- key: string;
112
- name: string;
113
- columns: TableColumn[];
114
- }
115
- export interface TableColumn {
116
- key: string;
117
- name: string;
118
- type: string;
119
- }
120
118
  export interface Authentication {
121
119
  id: number;
122
120
  date: string;
@@ -145,40 +143,3 @@ export interface AuthenticationsResponse {
145
143
  previous?: string | null;
146
144
  results: Authentication[];
147
145
  }
148
- export interface AuthenticationListOptions {
149
- account_id?: string;
150
- owner?: string;
151
- appKey?: string;
152
- limit?: number;
153
- offset?: number;
154
- }
155
- export declare class ZapierSdkError extends Error {
156
- code?: string | undefined;
157
- constructor(message: string, code?: string | undefined);
158
- }
159
- export declare class AppNotFoundError extends ZapierSdkError {
160
- constructor(appKey: string);
161
- }
162
- export declare class ActionNotFoundError extends ZapierSdkError {
163
- constructor(appKey: string, actionKey: string);
164
- }
165
- export declare class AuthenticationError extends ZapierSdkError {
166
- constructor(message: string);
167
- }
168
- export interface AuthObject {
169
- id: number;
170
- }
171
- export interface BaseSdkOptions {
172
- token?: string;
173
- authentications?: {
174
- [appKey: string]: AuthObject[];
175
- };
176
- fetch?: typeof fetch;
177
- baseUrl?: string;
178
- debug?: boolean;
179
- }
180
- export interface CombinedSdk {
181
- [namespace: string]: any;
182
- }
183
- export type SdkFactory<T = any> = (options: BaseSdkOptions) => T;
184
- export declare function combineSdks(sdks: Record<string, any>): CombinedSdk;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * API Client Type Definitions
4
+ *
5
+ * This module contains all type definitions related to the Zapier API client,
6
+ * including configuration options, client interfaces, request/response types,
7
+ * and API response models.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import type { BundleCodeOptions } from "./schemas";
2
+ /**
3
+ * Bundle TypeScript code into executable JavaScript
4
+ *
5
+ * This function can be used standalone without instantiating a full SDK,
6
+ * which enables better tree-shaking in applications that only need this functionality.
7
+ *
8
+ * @param options - Bundling configuration options
9
+ * @returns Promise<string> - Bundled JavaScript code
10
+ */
11
+ export declare function bundleCode(options: BundleCodeOptions): Promise<string>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.bundleCode = bundleCode;
37
+ /**
38
+ * Bundle TypeScript code into executable JavaScript
39
+ *
40
+ * This function can be used standalone without instantiating a full SDK,
41
+ * which enables better tree-shaking in applications that only need this functionality.
42
+ *
43
+ * @param options - Bundling configuration options
44
+ * @returns Promise<string> - Bundled JavaScript code
45
+ */
46
+ async function bundleCode(options) {
47
+ const { input, output, target = "es2020", cjs = false, minify = false, string: returnString = false, } = options;
48
+ // Dynamically import esbuild
49
+ const { buildSync } = await Promise.resolve().then(() => __importStar(require("esbuild")));
50
+ const fs = await Promise.resolve().then(() => __importStar(require("fs")));
51
+ const path = await Promise.resolve().then(() => __importStar(require("path")));
52
+ // Resolve input path
53
+ const resolvedInput = path.resolve(process.cwd(), input);
54
+ try {
55
+ // Bundle with esbuild
56
+ const result = buildSync({
57
+ entryPoints: [resolvedInput],
58
+ bundle: true,
59
+ platform: "node",
60
+ target: target,
61
+ format: cjs ? "cjs" : "esm",
62
+ minify: minify,
63
+ write: false,
64
+ external: [], // Bundle everything
65
+ banner: {
66
+ js: "#!/usr/bin/env node",
67
+ },
68
+ });
69
+ if (result.errors.length > 0) {
70
+ throw new Error(`Bundle failed: ${result.errors.map((e) => e.text).join(", ")}`);
71
+ }
72
+ const bundledCode = result.outputFiles?.[0]?.text;
73
+ if (!bundledCode) {
74
+ throw new Error("No output generated");
75
+ }
76
+ let finalOutput = bundledCode;
77
+ if (returnString) {
78
+ // Output as quoted string for node -e using JSON.stringify
79
+ finalOutput = JSON.stringify(bundledCode);
80
+ }
81
+ // Write to file if output path specified
82
+ if (output) {
83
+ fs.mkdirSync(path.dirname(output), { recursive: true });
84
+ fs.writeFileSync(output, finalOutput, "utf8");
85
+ }
86
+ return finalOutput;
87
+ }
88
+ catch (error) {
89
+ throw new Error(`Bundle failed: ${error instanceof Error ? error.message : "Unknown error"}`);
90
+ }
91
+ }
@@ -0,0 +1,27 @@
1
+ import { bundleCode } from "./index";
2
+ export declare const bundleCodeInfo: {
3
+ name: string;
4
+ inputSchema: import("zod").ZodObject<{
5
+ input: import("zod").ZodString;
6
+ output: import("zod").ZodOptional<import("zod").ZodString>;
7
+ string: import("zod").ZodDefault<import("zod").ZodBoolean>;
8
+ minify: import("zod").ZodDefault<import("zod").ZodBoolean>;
9
+ target: import("zod").ZodDefault<import("zod").ZodString>;
10
+ cjs: import("zod").ZodDefault<import("zod").ZodBoolean>;
11
+ }, "strip", import("zod").ZodTypeAny, {
12
+ string: boolean;
13
+ input: string;
14
+ minify: boolean;
15
+ target: string;
16
+ cjs: boolean;
17
+ output?: string | undefined;
18
+ }, {
19
+ input: string;
20
+ string?: boolean | undefined;
21
+ output?: string | undefined;
22
+ minify?: boolean | undefined;
23
+ target?: string | undefined;
24
+ cjs?: boolean | undefined;
25
+ }>;
26
+ implementation: typeof bundleCode;
27
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bundleCodeInfo = void 0;
4
+ const index_1 = require("./index");
5
+ const schemas_1 = require("./schemas");
6
+ // Function registry info - imports both function and schema
7
+ exports.bundleCodeInfo = {
8
+ name: index_1.bundleCode.name,
9
+ inputSchema: schemas_1.BundleCodeSchema,
10
+ implementation: index_1.bundleCode,
11
+ };
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ export declare const BundleCodeSchema: z.ZodObject<{
3
+ input: z.ZodString;
4
+ output: z.ZodOptional<z.ZodString>;
5
+ string: z.ZodDefault<z.ZodBoolean>;
6
+ minify: z.ZodDefault<z.ZodBoolean>;
7
+ target: z.ZodDefault<z.ZodString>;
8
+ cjs: z.ZodDefault<z.ZodBoolean>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ string: boolean;
11
+ input: string;
12
+ minify: boolean;
13
+ target: string;
14
+ cjs: boolean;
15
+ output?: string | undefined;
16
+ }, {
17
+ input: string;
18
+ string?: boolean | undefined;
19
+ output?: string | undefined;
20
+ minify?: boolean | undefined;
21
+ target?: string | undefined;
22
+ cjs?: boolean | undefined;
23
+ }>;
24
+ export type BundleCodeOptions = z.infer<typeof BundleCodeSchema>;
25
+ export interface BundleCodeSdkFunction {
26
+ bundleCode: (options: BundleCodeOptions) => Promise<string>;
27
+ }