@zapier/zapier-sdk 0.13.5 → 0.13.7

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 (129) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/api/schemas.d.ts +38 -38
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.mts +170 -177
  5. package/dist/index.mjs +1 -1
  6. package/dist/plugins/fetch/schemas.d.ts +4 -4
  7. package/dist/plugins/getAction/schemas.d.ts +2 -2
  8. package/dist/plugins/listActions/schemas.d.ts +6 -6
  9. package/dist/plugins/listApps/schemas.d.ts +6 -6
  10. package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
  11. package/dist/plugins/listInputFieldChoices/schemas.d.ts +8 -8
  12. package/dist/plugins/listInputFields/schemas.d.ts +8 -8
  13. package/dist/plugins/request/schemas.d.ts +8 -8
  14. package/dist/plugins/runAction/schemas.d.ts +8 -8
  15. package/dist/schemas/Action.d.ts +2 -2
  16. package/dist/schemas/App.d.ts +8 -8
  17. package/dist/types/sdk.d.ts +2 -8
  18. package/dist/types/sdk.d.ts.map +1 -1
  19. package/package.json +8 -3
  20. package/src/api/auth.ts +0 -28
  21. package/src/api/client.ts +0 -491
  22. package/src/api/debug.test.ts +0 -76
  23. package/src/api/debug.ts +0 -154
  24. package/src/api/index.ts +0 -90
  25. package/src/api/polling.test.ts +0 -405
  26. package/src/api/polling.ts +0 -253
  27. package/src/api/schemas.ts +0 -465
  28. package/src/api/types.ts +0 -152
  29. package/src/auth.ts +0 -72
  30. package/src/constants.ts +0 -16
  31. package/src/index.ts +0 -111
  32. package/src/plugins/api/index.ts +0 -43
  33. package/src/plugins/apps/index.ts +0 -203
  34. package/src/plugins/apps/schemas.ts +0 -64
  35. package/src/plugins/eventEmission/builders.ts +0 -115
  36. package/src/plugins/eventEmission/index.test.ts +0 -169
  37. package/src/plugins/eventEmission/index.ts +0 -294
  38. package/src/plugins/eventEmission/transport.test.ts +0 -214
  39. package/src/plugins/eventEmission/transport.ts +0 -135
  40. package/src/plugins/eventEmission/types.ts +0 -58
  41. package/src/plugins/eventEmission/utils.ts +0 -121
  42. package/src/plugins/fetch/index.ts +0 -83
  43. package/src/plugins/fetch/schemas.ts +0 -37
  44. package/src/plugins/findFirstAuthentication/index.test.ts +0 -209
  45. package/src/plugins/findFirstAuthentication/index.ts +0 -68
  46. package/src/plugins/findFirstAuthentication/schemas.ts +0 -47
  47. package/src/plugins/findUniqueAuthentication/index.test.ts +0 -197
  48. package/src/plugins/findUniqueAuthentication/index.ts +0 -77
  49. package/src/plugins/findUniqueAuthentication/schemas.ts +0 -49
  50. package/src/plugins/getAction/index.test.ts +0 -239
  51. package/src/plugins/getAction/index.ts +0 -75
  52. package/src/plugins/getAction/schemas.ts +0 -41
  53. package/src/plugins/getApp/index.test.ts +0 -181
  54. package/src/plugins/getApp/index.ts +0 -60
  55. package/src/plugins/getApp/schemas.ts +0 -33
  56. package/src/plugins/getAuthentication/index.test.ts +0 -294
  57. package/src/plugins/getAuthentication/index.ts +0 -95
  58. package/src/plugins/getAuthentication/schemas.ts +0 -38
  59. package/src/plugins/getProfile/index.ts +0 -60
  60. package/src/plugins/getProfile/schemas.ts +0 -24
  61. package/src/plugins/listActions/index.test.ts +0 -526
  62. package/src/plugins/listActions/index.ts +0 -132
  63. package/src/plugins/listActions/schemas.ts +0 -55
  64. package/src/plugins/listApps/index.test.ts +0 -378
  65. package/src/plugins/listApps/index.ts +0 -159
  66. package/src/plugins/listApps/schemas.ts +0 -41
  67. package/src/plugins/listAuthentications/index.test.ts +0 -739
  68. package/src/plugins/listAuthentications/index.ts +0 -152
  69. package/src/plugins/listAuthentications/schemas.ts +0 -77
  70. package/src/plugins/listInputFieldChoices/index.test.ts +0 -653
  71. package/src/plugins/listInputFieldChoices/index.ts +0 -173
  72. package/src/plugins/listInputFieldChoices/schemas.ts +0 -125
  73. package/src/plugins/listInputFields/index.test.ts +0 -439
  74. package/src/plugins/listInputFields/index.ts +0 -294
  75. package/src/plugins/listInputFields/schemas.ts +0 -68
  76. package/src/plugins/manifest/index.test.ts +0 -776
  77. package/src/plugins/manifest/index.ts +0 -461
  78. package/src/plugins/manifest/schemas.ts +0 -60
  79. package/src/plugins/registry/index.ts +0 -160
  80. package/src/plugins/request/index.test.ts +0 -333
  81. package/src/plugins/request/index.ts +0 -105
  82. package/src/plugins/request/schemas.ts +0 -69
  83. package/src/plugins/runAction/index.test.ts +0 -388
  84. package/src/plugins/runAction/index.ts +0 -215
  85. package/src/plugins/runAction/schemas.ts +0 -60
  86. package/src/resolvers/actionKey.ts +0 -37
  87. package/src/resolvers/actionType.ts +0 -34
  88. package/src/resolvers/appKey.ts +0 -7
  89. package/src/resolvers/authenticationId.ts +0 -54
  90. package/src/resolvers/index.ts +0 -11
  91. package/src/resolvers/inputFieldKey.ts +0 -70
  92. package/src/resolvers/inputs.ts +0 -69
  93. package/src/schemas/Action.ts +0 -52
  94. package/src/schemas/App.ts +0 -45
  95. package/src/schemas/Auth.ts +0 -59
  96. package/src/schemas/Field.ts +0 -169
  97. package/src/schemas/Run.ts +0 -40
  98. package/src/schemas/UserProfile.ts +0 -60
  99. package/src/sdk.test.ts +0 -212
  100. package/src/sdk.ts +0 -178
  101. package/src/types/domain.test.ts +0 -50
  102. package/src/types/domain.ts +0 -66
  103. package/src/types/errors.ts +0 -278
  104. package/src/types/events.ts +0 -43
  105. package/src/types/functions.ts +0 -28
  106. package/src/types/optional-zapier-sdk-cli-login.d.ts +0 -37
  107. package/src/types/plugin.ts +0 -125
  108. package/src/types/properties.ts +0 -80
  109. package/src/types/sdk.ts +0 -117
  110. package/src/types/telemetry-events.ts +0 -85
  111. package/src/utils/array-utils.test.ts +0 -131
  112. package/src/utils/array-utils.ts +0 -41
  113. package/src/utils/domain-utils.test.ts +0 -433
  114. package/src/utils/domain-utils.ts +0 -267
  115. package/src/utils/file-utils.test.ts +0 -73
  116. package/src/utils/file-utils.ts +0 -94
  117. package/src/utils/function-utils.test.ts +0 -141
  118. package/src/utils/function-utils.ts +0 -245
  119. package/src/utils/pagination-utils.test.ts +0 -620
  120. package/src/utils/pagination-utils.ts +0 -242
  121. package/src/utils/schema-utils.ts +0 -207
  122. package/src/utils/string-utils.test.ts +0 -45
  123. package/src/utils/string-utils.ts +0 -54
  124. package/src/utils/validation.test.ts +0 -51
  125. package/src/utils/validation.ts +0 -44
  126. package/tsconfig.build.json +0 -18
  127. package/tsconfig.json +0 -20
  128. package/tsconfig.tsbuildinfo +0 -1
  129. package/tsup.config.ts +0 -23
@@ -1,253 +0,0 @@
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
-
8
- import {
9
- ZapierTimeoutError,
10
- ZapierApiError,
11
- ZapierValidationError,
12
- } from "../types/errors";
13
- import { setTimeout } from "timers/promises";
14
-
15
- // Constants
16
- const DEFAULT_TIMEOUT_MS = 180_000;
17
- const DEFAULT_SUCCESS_STATUS = 200;
18
- const DEFAULT_PENDING_STATUS = 202;
19
- const DEFAULT_INITIAL_DELAY_MS = 50;
20
- const DEFAULT_MAX_POLLING_INTERVAL_MS = 10_000;
21
- const MAX_CONSECUTIVE_ERRORS = 3;
22
- const MAX_TIMEOUT_BUFFER_MS = 10_000;
23
- const BASE_ERROR_BACKOFF_MS = 1_000;
24
- const JITTER_FACTOR = 0.5;
25
-
26
- // Polling stages: [threshold_ms, interval_ms]
27
- // Note: These are default stages, actual hard timeout is enforced separately below
28
- const DEFAULT_POLLING_STAGES = [
29
- [125, 125], // Up to 125ms: poll every 125ms
30
- [375, 250], // Up to 375ms: poll every 250ms
31
- [875, 500], // Up to 875ms: poll every 500ms
32
- [10_000, 1_000], // Up to 10s: poll every 1s
33
- [30_000, 2_500], // Up to 30s: poll every 2.5s
34
- [60_000, 5_000], // Up to 60s: poll every 5s
35
- ] as const satisfies Array<[number, number]>;
36
-
37
- /**
38
- * Options for the polling function
39
- */
40
- export interface PollOptions<TResult = unknown> {
41
- /** Function that performs the HTTP request */
42
- fetchPoll: () => Promise<Response>;
43
- /** Maximum time to wait for completion (in milliseconds) */
44
- timeoutMs?: number;
45
- /** HTTP status code indicating successful completion */
46
- successStatus?: number;
47
- /** HTTP status code indicating the operation is still pending */
48
- pendingStatus?: number;
49
- /** Function to extract the result from the response */
50
- resultExtractor?: (response: unknown) => TResult;
51
- /** Initial delay before the first poll attempt (in milliseconds) */
52
- initialDelay?: number;
53
- }
54
-
55
- const enum PollStatus {
56
- Success = "success",
57
- Continue = "continue",
58
- }
59
-
60
- /**
61
- * Result of a poll operation
62
- */
63
- export type PollResult<TResult = unknown> = {
64
- result?: TResult;
65
- status: PollStatus;
66
- errorCount: number;
67
- };
68
-
69
- // Helper to calculate wait time with jitter and error backoff
70
- const calculateWaitTime = (
71
- baseInterval: number,
72
- errorCount: number,
73
- ): number => {
74
- // Jitter to avoid thundering herd
75
- const jitter = Math.random() * JITTER_FACTOR * baseInterval;
76
- // More backoff added if errors are seen
77
- const errorBackoff = Math.min(
78
- BASE_ERROR_BACKOFF_MS * (errorCount / 2),
79
- baseInterval * 2, // Cap error backoff at 2x the base interval
80
- );
81
- return Math.floor(baseInterval + jitter + errorBackoff);
82
- };
83
-
84
- const processResponse = async <TResult = unknown>(
85
- response: Response,
86
- successStatus: number,
87
- pendingStatus: number,
88
- resultExtractor: (response: unknown) => TResult,
89
- errorCount: number,
90
- ): Promise<PollResult<TResult>> => {
91
- // Handle other error responses
92
- if (!response.ok) {
93
- return {
94
- status: PollStatus.Continue,
95
- // If for some reason the status is pending, we don't want to increment the error count
96
- errorCount:
97
- response.status === pendingStatus ? errorCount : errorCount + 1,
98
- };
99
- }
100
-
101
- // Check for successful completion
102
- if (response.status === successStatus) {
103
- try {
104
- const resultJson = await response.json();
105
- return {
106
- result: resultExtractor(resultJson),
107
- status: PollStatus.Success,
108
- errorCount: 0,
109
- };
110
- } catch (error) {
111
- throw new ZapierApiError(
112
- "Result extractor failed to parse successful response as JSON",
113
- {
114
- statusCode: response.status,
115
- cause: error,
116
- },
117
- );
118
- }
119
- }
120
-
121
- // If it's not pending, it's unexpected
122
- if (response.status !== pendingStatus) {
123
- throw new ZapierApiError(
124
- `Unexpected response status during polling: ${response.status}`,
125
- {
126
- statusCode: response.status,
127
- },
128
- );
129
- }
130
-
131
- // It's still pending, so we continue polling
132
- return {
133
- status: PollStatus.Continue,
134
- errorCount: 0,
135
- };
136
- };
137
-
138
- /**
139
- * Polls an endpoint until completion, timeout, or error
140
- * @param options Configuration options for polling
141
- * @returns The extracted result from the successful response
142
- * @throws {ZapierValidationError} When the input parameters are invalid
143
- * @throws {ZapierTimeoutError} When the operation times out
144
- * @throws {ZapierApiError} When the API returns consecutive errors
145
- */
146
- export async function pollUntilComplete<TResult = unknown>(
147
- options: PollOptions<TResult>,
148
- ): Promise<TResult> {
149
- const {
150
- fetchPoll,
151
- timeoutMs = DEFAULT_TIMEOUT_MS,
152
- initialDelay = DEFAULT_INITIAL_DELAY_MS,
153
- successStatus = DEFAULT_SUCCESS_STATUS,
154
- pendingStatus = DEFAULT_PENDING_STATUS,
155
- resultExtractor = (response) => response as TResult,
156
- } = options;
157
-
158
- // Validate input parameters
159
- if (timeoutMs <= 0) {
160
- throw new ZapierValidationError("Timeout must be greater than 0", {
161
- details: { timeoutMs },
162
- });
163
- }
164
-
165
- if (initialDelay < 0) {
166
- throw new ZapierValidationError("Initial delay must be non-negative", {
167
- details: { initialDelay },
168
- });
169
- }
170
-
171
- const startTime = Date.now();
172
- let attempts = 0;
173
- let errorCount = 0;
174
-
175
- // Build polling stages with the actual timeout appended
176
- const pollingStages = [
177
- ...DEFAULT_POLLING_STAGES,
178
- [timeoutMs + MAX_TIMEOUT_BUFFER_MS, DEFAULT_MAX_POLLING_INTERVAL_MS], // Up to timeout + 10s: poll every 10s
179
- ] as const satisfies Array<[number, number]>;
180
-
181
- // Apply initial delay if specified
182
- if (initialDelay > 0) {
183
- await setTimeout(initialDelay);
184
- }
185
-
186
- while (true) {
187
- attempts++;
188
- const elapsedTime = Date.now() - startTime;
189
-
190
- // Find the current polling stage
191
- const pollingInterval = pollingStages.find(
192
- ([maxTimeForStage, _interval]) => {
193
- return elapsedTime < maxTimeForStage;
194
- },
195
- );
196
-
197
- // If there isn't a current stage, throw timeout error
198
- if (!pollingInterval) {
199
- throw new ZapierTimeoutError(
200
- `Operation timed out after ${Math.floor(elapsedTime / 1000)}s (${attempts} attempts)`,
201
- {
202
- attempts,
203
- },
204
- );
205
- }
206
-
207
- // Wait before polling (except on first attempt)
208
- if (attempts > 1) {
209
- const waitTime = calculateWaitTime(pollingInterval[1], errorCount);
210
- await setTimeout(waitTime);
211
- }
212
-
213
- // Perform the poll request
214
- try {
215
- const response = await fetchPoll();
216
- const {
217
- result,
218
- errorCount: newErrorCount,
219
- status,
220
- } = await processResponse<TResult>(
221
- response,
222
- successStatus,
223
- pendingStatus,
224
- resultExtractor,
225
- errorCount,
226
- );
227
- errorCount = newErrorCount;
228
-
229
- if (status === PollStatus.Success) {
230
- return result as TResult;
231
- }
232
-
233
- if (errorCount >= MAX_CONSECUTIVE_ERRORS) {
234
- // Too many consecutive errors, fail
235
- throw new ZapierApiError(
236
- `Poll request failed: ${response.status} ${response.statusText}`,
237
- { statusCode: response.status },
238
- );
239
- }
240
- } catch (error) {
241
- errorCount++;
242
- if (errorCount >= MAX_CONSECUTIVE_ERRORS) {
243
- throw new ZapierApiError(
244
- `Failed to poll after ${errorCount} consecutive errors: ${error instanceof Error ? error.message : String(error)}`,
245
- {
246
- cause: error,
247
- },
248
- );
249
- }
250
- }
251
- // Continue polling if status is pending
252
- }
253
- }
@@ -1,465 +0,0 @@
1
- import { z } from "zod";
2
-
3
- /**
4
- * Base Zod schemas for API response models.
5
- * These schemas represent the raw data structures returned by Zapier API endpoints.
6
- * All TypeScript types in api/types.ts are inferred from these schemas.
7
- */
8
-
9
- // ============================================================================
10
- // Basic Building Block Schemas
11
- // ============================================================================
12
-
13
- export const NeedChoicesSchema = z.object({
14
- key: z.string().optional(),
15
- label: z.string().optional(),
16
- sample: z.string().optional(),
17
- value: z.string().optional(),
18
- });
19
-
20
- export const NeedSchema = z.object({
21
- key: z.string(),
22
- alters_custom_fields: z.boolean().nullable().optional(),
23
- capabilities: z.array(z.string()).optional(),
24
- choices: z.array(NeedChoicesSchema).optional(),
25
- computed: z.boolean().nullable().optional(),
26
- custom_field: z.boolean().optional(),
27
- default: z.string().optional(),
28
- depends_on: z.array(z.string()).optional(),
29
- format: z.literal("SELECT").optional(),
30
- from_search: z.boolean().optional(),
31
- from_write: z.boolean().optional(),
32
- help_text: z.string().optional(),
33
- help_text_html: z.string().optional(),
34
- input_format: z.array(z.string()).optional(),
35
- label: z.string().optional(),
36
- language: z.string().optional(),
37
- parent_key: z.string().optional(),
38
- placeholder: z.string().optional(),
39
- prefill: z.string().optional(),
40
- required: z.boolean().optional(),
41
- searchfill: z.string().optional(),
42
- send_in_json: z.boolean().optional(),
43
- regex: z.string().optional(),
44
- type: z
45
- .enum([
46
- "integer",
47
- "string",
48
- "text",
49
- "datetime",
50
- "boolean",
51
- "file",
52
- "decimal",
53
- "copy",
54
- "password",
55
- "dict",
56
- "code",
57
- "filter",
58
- "json",
59
- ])
60
- .optional(),
61
- list: z.boolean().optional(),
62
- });
63
-
64
- export const ActionLinksSchema = z.object({
65
- action_url: z.string().optional(),
66
- });
67
-
68
- export const ActionPermissionsSchema = z.object({
69
- can_use: z.boolean().optional(),
70
- });
71
-
72
- export const ActionSchema = z.object({
73
- id: z.string().optional(),
74
- type: z.enum([
75
- "filter",
76
- "read",
77
- "read_bulk",
78
- "run",
79
- "search",
80
- "search_and_write",
81
- "search_or_write",
82
- "write",
83
- ]),
84
- key: z.string(),
85
- name: z.string(),
86
- description: z.string(),
87
- is_important: z.boolean().optional(),
88
- is_hidden: z.boolean().optional(),
89
- selected_api: z.string().optional(),
90
- });
91
-
92
- export const ChoiceSchema = z.object({
93
- value: z.union([z.string(), z.number()]),
94
- label: z.string(),
95
- });
96
-
97
- export const FieldSchema = z.object({
98
- key: z.string(),
99
- label: z.string(),
100
- type: z.enum([
101
- "string",
102
- "number",
103
- "boolean",
104
- "datetime",
105
- "file",
106
- "object",
107
- "array",
108
- ]),
109
- required: z.boolean(),
110
- description: z.string().optional(),
111
- choices: z.array(ChoiceSchema).optional(),
112
- });
113
-
114
- export const ActionExecutionResultSchema = z.object({
115
- data: z.array(z.unknown()),
116
- });
117
-
118
- export const ActionFieldChoiceSchema = z.object({
119
- value: z.union([z.string(), z.number()]),
120
- label: z.string(),
121
- });
122
-
123
- export const ActionFieldSchema = z.object({
124
- key: z.string(),
125
- label: z.string().optional(),
126
- required: z.boolean(),
127
- type: z.string().optional(),
128
- helpText: z.string().optional(),
129
- helpTextHtml: z.string().optional(),
130
- choices: z.array(ActionFieldChoiceSchema).optional(),
131
- default: z.string().optional(),
132
- placeholder: z.string().optional(),
133
- computed: z.boolean().optional(),
134
- customField: z.boolean().optional(),
135
- dependsOn: z.array(z.string()).optional(),
136
- format: z.string().optional(),
137
- inputFormat: z.array(z.string()).optional(),
138
- });
139
-
140
- // ============================================================================
141
- // Main API Entity Schemas
142
- // ============================================================================
143
-
144
- export const AuthenticationSchema = z.object({
145
- id: z.number(),
146
- date: z.string(),
147
- lastchanged: z.string().optional(),
148
- account_id: z.number(),
149
- customuser_id: z.number().optional(),
150
- selected_api: z.string(),
151
- destination_selected_api: z.string().nullable().optional(),
152
- is_invite_only: z.boolean(),
153
- is_private: z.boolean(),
154
- shared_with_all: z.boolean(),
155
- is_stale: z.string().optional(),
156
- is_shared: z.string().optional(),
157
- marked_stale_at: z.string().nullable().optional(),
158
- label: z.string().nullable().optional(),
159
- identifier: z.string().nullable().optional(),
160
- title: z.string().nullable().optional(),
161
- url: z.string().optional(),
162
- groups: z.string().optional(),
163
- members: z.string().optional(),
164
- permissions: z.record(z.boolean()).optional(),
165
- });
166
-
167
- export const AuthenticationsResponseSchema = z.object({
168
- count: z.number(),
169
- next: z.string().nullable().optional(),
170
- previous: z.string().nullable().optional(),
171
- results: z.array(AuthenticationSchema),
172
- });
173
-
174
- export const UserProfileSchema = z.object({
175
- id: z.number(),
176
- code: z.string(),
177
- user_id: z.number(),
178
- auto_provisioned: z.boolean(),
179
- first_name: z.string(),
180
- last_name: z.string(),
181
- username: z.string(),
182
- personas: z.string(),
183
- user_generated_personas: z.string(),
184
- last_login: z.string(),
185
- email: z.string(),
186
- email_hash: z.string(),
187
- email_confirmed: z.boolean(),
188
- timezone: z.string(),
189
- photo_url: z.string(),
190
- has_seen_notifications: z.record(z.boolean().nullable()),
191
- signup: z.string(),
192
- since_signup: z.string(),
193
- has_activated: z.boolean(),
194
- enable_gz_creator: z.boolean(),
195
- should_see_nps_survey: z.boolean(),
196
- is_developer: z.boolean(),
197
- is_expert: z.boolean(),
198
- tos_agreement: z.boolean(),
199
- should_renew_tos: z.boolean(),
200
- is_gdpr_consented: z.boolean(),
201
- disable_ssl_check: z.boolean(),
202
- identity: z.number(),
203
- summary_schedule: z.string(),
204
- alert_triggers: z.string(),
205
- alert_actions: z.string(),
206
- is_staff: z.boolean(),
207
- is_zt_reviewer: z.boolean(),
208
- is_high_value: z.boolean(),
209
- is_temporary: z.boolean(),
210
- banner_message: z.string(),
211
- enable_totp_2fa: z.boolean(),
212
- viewed_help: z.record(z.boolean()),
213
- show_editor_migration_mesaging: z.boolean(),
214
- switches: z.record(z.unknown()),
215
- organizations: z.array(z.record(z.unknown()).nullable()),
216
- primary_organization: z.record(z.unknown()).nullable(),
217
- has_active_zaps: z.boolean(),
218
- has_google_sso: z.boolean(),
219
- auth_realm: z.string(),
220
- roles: z.array(
221
- z.object({
222
- account_id: z.number(),
223
- role: z.string(),
224
- }),
225
- ),
226
- });
227
-
228
- export const AppSchema = z.object({
229
- age_in_days: z.string().optional(),
230
- api_docs_url: z.string().nullable().optional(),
231
- app_profile_url: z.string(),
232
- banner: z.string().optional(),
233
- categories: z.array(z.string()).optional(), // Service category names
234
- canonical_id: z.string().optional(),
235
- current_implementation_id: z.string(),
236
- days_since_last_update: z.string().optional(),
237
- description: z.string(),
238
- external_url: z.string(),
239
- hashtag: z.string().optional(),
240
- id: z.number().optional(),
241
- image: z.string().optional(),
242
- images: z.string().optional(),
243
- integration_overview_html: z.string().nullable().optional(),
244
- internal_id: z.string(),
245
- invite_url: z.string().nullable().optional(),
246
- is_beta: z.string().optional(),
247
- is_built_in: z.string().optional(),
248
- is_featured: z.string().optional(),
249
- is_premium: z.boolean().optional(),
250
- is_public: z.string().optional(),
251
- is_upcoming: z.string().optional(),
252
- learn_more_url: z.string(),
253
- name: z.string(),
254
- popularity: z.number(),
255
- primary_color: z.string(),
256
- request_count: z.string().optional(),
257
- slug: z.string(),
258
- zap_usage_count: z.number().nullable().optional(),
259
- });
260
-
261
- export const ServiceSchema = z.object({
262
- id: z.number().optional(),
263
- canonical_id: z.string().optional(),
264
- current_implementation_id: z.string(),
265
- name: z.string(),
266
- slug: z.string(),
267
- app_url: z.string().optional(),
268
- learn_more_url: z.string().optional(),
269
- description: z.string(),
270
- primary_color: z.string(),
271
- popularity: z.number(),
272
- image: z.string().optional(),
273
- images: z.string().optional(),
274
- });
275
-
276
- export const ServicesResponseSchema = z.object({
277
- results: z.array(ServiceSchema),
278
- next: z.string().nullable().optional(),
279
- previous: z.string().nullable().optional(),
280
- });
281
-
282
- // ============================================================================
283
- // Request/Response Schemas
284
- // ============================================================================
285
-
286
- export const NeedsRequestSchema = z.object({
287
- selected_api: z.string(),
288
- action: z.string(),
289
- type_of: z.string(),
290
- authentication_id: z.number().optional(),
291
- params: z.record(z.unknown()).optional(),
292
- });
293
-
294
- export const NeedsResponseSchema = z.object({
295
- success: z.boolean(),
296
- needs: z.array(NeedSchema).optional(),
297
- errors: z.array(z.string()).optional(),
298
- last_fetched_at: z.string().optional(),
299
- });
300
-
301
- // ============================================================================
302
- // Implementation Schema
303
- // ============================================================================
304
-
305
- export const ImplementationSchema = z.object({
306
- selected_api: z.string(),
307
- app_id: z.number().optional(),
308
- auth_type: z.string().optional(),
309
- auth_fields: z.string().optional(),
310
- actions: z.array(ActionSchema).optional(),
311
- is_deprecated: z.boolean().optional(),
312
- is_private_only: z.boolean().optional(),
313
- is_invite_only: z.boolean().optional(),
314
- is_beta: z.boolean().optional().default(false),
315
- is_premium: z.boolean().optional().default(false),
316
- is_hidden: z.string().optional(),
317
- name: z.string().optional(),
318
- slug: z.string().optional(),
319
- images: z.record(z.string().nullable()).optional(),
320
- primary_color: z.string().optional(),
321
- secondary_color: z.string().optional(),
322
- current_implementation: z.string().optional(),
323
- other_implementations: z.string().optional(),
324
- });
325
-
326
- export const ImplementationsResponseSchema = z.object({
327
- count: z.number(),
328
- next: z.string().nullable().optional(),
329
- previous: z.string().nullable().optional(),
330
- results: z.array(ImplementationSchema),
331
- });
332
-
333
- // ============================================================================
334
- // Lightweight Implementation Meta Schema
335
- // ============================================================================
336
-
337
- export const ImplementationMetaSchema = z.object({
338
- id: z.string(), // e.g. "100HiresCLIAPI@1.2.1"
339
- name: z.string(),
340
- slug: z.string(),
341
- age_in_days: z.number().optional(),
342
- auth_type: z.string().optional(),
343
- banner: z.string().optional(),
344
- categories: z
345
- .array(
346
- z.object({
347
- id: z.number(),
348
- name: z.string(),
349
- slug: z.string(),
350
- }),
351
- )
352
- .optional(),
353
- images: z
354
- .object({
355
- url_16x16: z.string().optional(),
356
- url_32x32: z.string().optional(),
357
- url_64x64: z.string().optional(),
358
- url_128x128: z.string().optional(),
359
- })
360
- .optional(),
361
- popularity: z.number().optional(),
362
- has_filters: z.boolean().optional(),
363
- has_reads: z.boolean().optional(),
364
- has_searches: z.boolean().optional(),
365
- has_searches_or_writes: z.boolean().optional(),
366
- has_upfront_fields: z.boolean().optional(),
367
- has_writes: z.boolean().optional(),
368
- is_beta: z.boolean().optional(),
369
- is_built_in: z.boolean().optional(),
370
- is_deprecated: z.boolean().optional(),
371
- is_featured: z.boolean().optional(),
372
- is_hidden: z.boolean().optional(),
373
- is_invite: z.boolean().optional(),
374
- is_premium: z.boolean().optional(),
375
- is_public: z.boolean().optional(),
376
- is_upcoming: z.boolean().optional(),
377
- version: z.string().optional(),
378
- visibility: z.string().optional(),
379
- actions: z
380
- .object({
381
- read: z.number().optional(),
382
- read_bulk: z.number().optional(),
383
- write: z.number().optional(),
384
- search: z.number().optional(),
385
- search_or_write: z.number().optional(),
386
- search_and_write: z.number().optional(),
387
- filter: z.number().optional(),
388
- })
389
- .optional(),
390
- description: z.string().optional(),
391
- primary_color: z.string().optional(),
392
- secondary_color: z.string().optional(),
393
- classification: z.string().optional(),
394
- api_docs_url: z.string().optional(),
395
- image: z.string().optional(),
396
- });
397
-
398
- export const ImplementationsMetaResponseSchema = z.object({
399
- count: z.number(),
400
- next: z.string().nullable().optional(),
401
- previous: z.string().nullable().optional(),
402
- results: z.array(ImplementationMetaSchema),
403
- });
404
-
405
- // ============================================================================
406
- // Need Choices Schemas (for listInputFieldChoices functionality)
407
- // ============================================================================
408
-
409
- export const NeedChoicesResponseMetaSchema = z.object({
410
- page: z.string().nullable().optional(),
411
- });
412
-
413
- export const NeedChoicesResponseLinksSchema = z.object({
414
- next: z.string().nullable().optional(),
415
- prev: z.string().nullable().optional(),
416
- });
417
-
418
- export const NeedChoicesRequestSchema = z.object({
419
- selected_api: z
420
- .string()
421
- .optional()
422
- .describe(
423
- "Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them.",
424
- ),
425
- authentication_id: z
426
- .number()
427
- .optional()
428
- .describe(
429
- "If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared).",
430
- ),
431
- params: z
432
- .record(z.unknown())
433
- .optional()
434
- .describe(
435
- "Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action.",
436
- ),
437
- page: z.number().optional().default(0),
438
- prefill: z
439
- .string()
440
- .optional()
441
- .describe(
442
- "The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not.",
443
- ),
444
- action_id: z
445
- .string()
446
- .optional()
447
- .describe(
448
- "The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided.",
449
- ),
450
- input_field_id: z
451
- .string()
452
- .optional()
453
- .describe(
454
- "The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided.",
455
- ),
456
- });
457
-
458
- export const NeedChoicesResponseSchema = z.object({
459
- success: z.boolean(),
460
- choices: z.array(NeedChoicesSchema).optional(),
461
- next_page: z.number().optional(),
462
- errors: z.array(z.string()).optional(),
463
- meta: NeedChoicesResponseMetaSchema.optional(),
464
- links: NeedChoicesResponseLinksSchema.optional(),
465
- });