@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.
- package/CHANGELOG.md +18 -0
- package/dist/cli.cjs +50 -38
- package/dist/cli.mjs +51 -39
- package/dist/index.cjs +49 -37
- package/dist/index.mjs +50 -38
- package/dist/package.json +1 -1
- package/dist/src/generators/ast-generator.js +33 -29
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/generators/ast-generator.test.ts +908 -0
- package/src/generators/ast-generator.ts +54 -46
|
@@ -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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|