@zapier/zapier-sdk-cli 0.13.11 → 0.13.13

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.
@@ -8,7 +8,7 @@ import type {
8
8
  ManifestPluginProvides,
9
9
  AppItem,
10
10
  } from "@zapier/zapier-sdk";
11
- import { toSnakeCase } from "@zapier/zapier-sdk";
11
+ import { toSnakeCase, batch } from "@zapier/zapier-sdk";
12
12
 
13
13
  interface ActionWithInputFields extends Omit<Action, "inputFields" | "type"> {
14
14
  inputFields: InputFieldItem[];
@@ -58,53 +58,61 @@ export class AstTypeGenerator {
58
58
  // Fetch input fields for each action
59
59
  const actionsWithFields: ActionWithInputFields[] = [];
60
60
 
61
- if (authenticationId) {
62
- for (const action of actions) {
63
- try {
64
- const fieldsResult = await sdk.listInputFields({
65
- appKey: app.implementation_id,
66
- actionKey: action.key,
67
- actionType: action.action_type,
68
- authenticationId: authenticationId,
69
- });
70
-
71
- const fields = fieldsResult.data as InputFieldItem[];
72
- actionsWithFields.push({
73
- ...action,
74
- inputFields: fields,
75
- name: action.title || action.key,
76
- });
77
- } catch {
78
- // If we can't get fields for an action, include it without fields
79
- actionsWithFields.push({
80
- ...action,
81
- inputFields: [],
82
- name: action.title || action.key,
83
- });
84
- }
61
+ // Fetch all input fields with concurrency limiting for better reliability
62
+ // Using batch() instead of Promise.allSettled() prevents overwhelming the API
63
+ // and triggering rate limits when apps have many actions
64
+ const inputFieldsTasks = actions.map(
65
+ (action) => () =>
66
+ sdk.listInputFields({
67
+ appKey: app.implementation_id,
68
+ actionKey: action.key,
69
+ actionType: action.action_type,
70
+ authenticationId: authenticationId,
71
+ }),
72
+ );
73
+
74
+ const results = await batch(inputFieldsTasks, {
75
+ concurrency: 50, // Limit to 50 concurrent requests
76
+ retry: true, // Automatically retry transient failures
77
+ timeoutMs: 180_000, // 3 minute overall timeout
78
+ taskTimeoutMs: 30_000, // 30 seconds per-task timeout (API calls shouldn't take longer)
79
+ });
80
+
81
+ const failedActions: string[] = [];
82
+
83
+ results.forEach((result, i) => {
84
+ const action = actions[i];
85
+
86
+ if (result.status === "fulfilled") {
87
+ actionsWithFields.push({
88
+ ...action,
89
+ inputFields: result.value.data as InputFieldItem[],
90
+ name: action.title || action.key,
91
+ });
92
+ } else {
93
+ failedActions.push(
94
+ `${action.key} (${action.action_type}): ${result.reason?.message || "Unknown error"}`,
95
+ );
96
+ actionsWithFields.push({
97
+ ...action,
98
+ inputFields: [],
99
+ name: action.title || action.key,
100
+ app_key: action.app_key || app.implementation_id,
101
+ action_type: (action.action_type as Action["type"]) || "write",
102
+ title: action.title || action.key,
103
+ type: "action" as const,
104
+ description: action.description || "",
105
+ });
85
106
  }
86
- } else {
87
- // Convert actions to have empty input fields (will generate generic types)
88
- actions.forEach(
89
- (action: {
90
- key: string;
91
- title?: string;
92
- app_key?: string;
93
- action_type?: string;
94
- description?: string;
95
- }) => {
96
- actionsWithFields.push({
97
- ...action,
98
- inputFields: [],
99
- name: action.title || action.key,
100
- app_key: action.app_key || app.implementation_id,
101
- action_type: (action.action_type as Action["type"]) || "write",
102
- title: action.title || action.key,
103
- type: "action" as const,
104
- description: action.description || "",
105
- });
106
- },
107
+ });
108
+
109
+ if (failedActions.length > 0) {
110
+ console.warn(
111
+ `Failed to fetch input fields for ${failedActions.length} action(s):`,
107
112
  );
113
+ failedActions.forEach((failedAction) => {
114
+ console.warn(` - ${failedAction}`);
115
+ });
108
116
  }
109
117
 
110
118
  // Generate TypeScript AST nodes