@zapier/zapier-sdk-cli 0.13.9 → 0.13.10
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 +6 -0
- package/dist/cli.cjs +65 -86
- package/dist/cli.mjs +67 -88
- package/dist/index.cjs +64 -85
- package/dist/index.d.mts +0 -8
- package/dist/index.d.ts +0 -8
- package/dist/index.mjs +66 -87
- package/dist/package.json +1 -1
- package/dist/src/plugins/add/index.js +0 -8
- package/dist/src/plugins/buildManifest/index.js +12 -12
- package/dist/src/plugins/buildManifest/schemas.d.ts +0 -4
- package/dist/src/plugins/generateAppTypes/index.js +47 -59
- package/dist/src/plugins/generateAppTypes/schemas.d.ts +0 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/plugins/add/index.ts +0 -9
- package/src/plugins/buildManifest/index.test.ts +96 -53
- package/src/plugins/buildManifest/index.ts +17 -14
- package/src/plugins/buildManifest/schemas.ts +0 -4
- package/src/plugins/generateAppTypes/index.test.ts +679 -0
- package/src/plugins/generateAppTypes/index.ts +53 -61
- package/src/plugins/generateAppTypes/schemas.ts +0 -4
package/dist/index.cjs
CHANGED
|
@@ -107,28 +107,28 @@ var client_default = api;
|
|
|
107
107
|
|
|
108
108
|
// src/utils/getCallablePromise.ts
|
|
109
109
|
var getCallablePromise = () => {
|
|
110
|
-
let
|
|
110
|
+
let resolve4 = () => {
|
|
111
111
|
};
|
|
112
112
|
let reject = () => {
|
|
113
113
|
};
|
|
114
114
|
const promise = new Promise((_resolve, _reject) => {
|
|
115
|
-
|
|
115
|
+
resolve4 = _resolve;
|
|
116
116
|
reject = _reject;
|
|
117
117
|
});
|
|
118
118
|
return {
|
|
119
119
|
promise,
|
|
120
|
-
resolve:
|
|
120
|
+
resolve: resolve4,
|
|
121
121
|
reject
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
var getCallablePromise_default = getCallablePromise;
|
|
125
125
|
var findAvailablePort = () => {
|
|
126
|
-
return new Promise((
|
|
126
|
+
return new Promise((resolve4, reject) => {
|
|
127
127
|
let portIndex = 0;
|
|
128
128
|
const tryPort = (port) => {
|
|
129
129
|
const server = express__default.default().listen(port, () => {
|
|
130
130
|
server.close();
|
|
131
|
-
|
|
131
|
+
resolve4(port);
|
|
132
132
|
});
|
|
133
133
|
server.on("error", (err) => {
|
|
134
134
|
if (err.code === "EADDRINUSE") {
|
|
@@ -218,15 +218,15 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
218
218
|
} finally {
|
|
219
219
|
process.off("SIGINT", cleanup);
|
|
220
220
|
process.off("SIGTERM", cleanup);
|
|
221
|
-
await new Promise((
|
|
221
|
+
await new Promise((resolve4) => {
|
|
222
222
|
const timeout = setTimeout(() => {
|
|
223
223
|
log_default.info("Server close timed out, forcing connection shutdown...");
|
|
224
224
|
connections.forEach((conn) => conn.destroy());
|
|
225
|
-
|
|
225
|
+
resolve4();
|
|
226
226
|
}, 1e3);
|
|
227
227
|
server.close(() => {
|
|
228
228
|
clearTimeout(timeout);
|
|
229
|
-
|
|
229
|
+
resolve4();
|
|
230
230
|
});
|
|
231
231
|
});
|
|
232
232
|
}
|
|
@@ -258,7 +258,7 @@ var LoginSchema = zod.z.object({
|
|
|
258
258
|
|
|
259
259
|
// package.json
|
|
260
260
|
var package_default = {
|
|
261
|
-
version: "0.13.
|
|
261
|
+
version: "0.13.10"};
|
|
262
262
|
|
|
263
263
|
// src/telemetry/builders.ts
|
|
264
264
|
function createCliBaseEvent(context = {}) {
|
|
@@ -649,14 +649,6 @@ var addPlugin = ({ sdk }) => {
|
|
|
649
649
|
if (successfulApps.length > 0) {
|
|
650
650
|
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
651
651
|
}
|
|
652
|
-
const allErrors = [...manifestResult.errors, ...typesResult.errors];
|
|
653
|
-
if (allErrors.length > 0) {
|
|
654
|
-
console.warn(`
|
|
655
|
-
\u26A0\uFE0F ${allErrors.length} error(s) occurred:`);
|
|
656
|
-
allErrors.forEach(({ appKey, error }) => {
|
|
657
|
-
console.warn(` - ${appKey}: ${error}`);
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
652
|
}, AddSchema);
|
|
661
653
|
return {
|
|
662
654
|
add,
|
|
@@ -1276,17 +1268,12 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1276
1268
|
appKeys,
|
|
1277
1269
|
authenticationIds,
|
|
1278
1270
|
skipWrite = false,
|
|
1279
|
-
typesOutputDirectory,
|
|
1271
|
+
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
1280
1272
|
onProgress
|
|
1281
1273
|
} = options;
|
|
1282
|
-
|
|
1283
|
-
throw new Error(
|
|
1284
|
-
"typesOutputDirectory is required when skipWrite is false"
|
|
1285
|
-
);
|
|
1286
|
-
}
|
|
1274
|
+
const resolvedTypesOutput = path.resolve(typesOutputDirectory);
|
|
1287
1275
|
const result = {
|
|
1288
|
-
typeDefinitions: {}
|
|
1289
|
-
errors: []
|
|
1276
|
+
typeDefinitions: {}
|
|
1290
1277
|
};
|
|
1291
1278
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1292
1279
|
const appsIterator = sdk.listApps({ appKeys }).items();
|
|
@@ -1314,8 +1301,8 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1314
1301
|
count: authentications.length
|
|
1315
1302
|
});
|
|
1316
1303
|
}
|
|
1317
|
-
if (!skipWrite &&
|
|
1318
|
-
await promises.mkdir(
|
|
1304
|
+
if (!skipWrite && resolvedTypesOutput) {
|
|
1305
|
+
await promises.mkdir(resolvedTypesOutput, { recursive: true });
|
|
1319
1306
|
}
|
|
1320
1307
|
if (!skipWrite) {
|
|
1321
1308
|
result.writtenFiles = {};
|
|
@@ -1328,17 +1315,18 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1328
1315
|
});
|
|
1329
1316
|
try {
|
|
1330
1317
|
if (!app.version) {
|
|
1331
|
-
const
|
|
1332
|
-
result.errors.push({
|
|
1333
|
-
appKey: app.key,
|
|
1334
|
-
error
|
|
1335
|
-
});
|
|
1318
|
+
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
1336
1319
|
onProgress?.({
|
|
1337
1320
|
type: "app_processing_error",
|
|
1338
1321
|
appKey: app.key,
|
|
1339
|
-
error
|
|
1322
|
+
error: errorMessage
|
|
1323
|
+
});
|
|
1324
|
+
throw new zapierSdk.ZapierValidationError(errorMessage, {
|
|
1325
|
+
details: {
|
|
1326
|
+
appKey: app.key,
|
|
1327
|
+
implementationId: app.implementation_id
|
|
1328
|
+
}
|
|
1340
1329
|
});
|
|
1341
|
-
continue;
|
|
1342
1330
|
}
|
|
1343
1331
|
let authenticationId;
|
|
1344
1332
|
if (authentications.length > 0) {
|
|
@@ -1361,56 +1349,47 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1361
1349
|
}
|
|
1362
1350
|
}
|
|
1363
1351
|
const manifestKey = getManifestKey(app);
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1352
|
+
const generator = new AstTypeGenerator();
|
|
1353
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
1354
|
+
app,
|
|
1355
|
+
authenticationId,
|
|
1356
|
+
sdk
|
|
1357
|
+
});
|
|
1358
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
1359
|
+
onProgress?.({
|
|
1360
|
+
type: "type_generated",
|
|
1361
|
+
manifestKey,
|
|
1362
|
+
sizeBytes: typeDefinitionString.length
|
|
1363
|
+
});
|
|
1364
|
+
if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
|
|
1365
|
+
const filePath = path.join(resolvedTypesOutput, `${manifestKey}.d.ts`);
|
|
1366
|
+
await promises.writeFile(filePath, typeDefinitionString, "utf8");
|
|
1367
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
1372
1368
|
onProgress?.({
|
|
1373
|
-
type: "
|
|
1369
|
+
type: "file_written",
|
|
1374
1370
|
manifestKey,
|
|
1375
|
-
|
|
1376
|
-
});
|
|
1377
|
-
if (!skipWrite && typesOutputDirectory && result.writtenFiles) {
|
|
1378
|
-
const filePath = path.join(typesOutputDirectory, `${manifestKey}.d.ts`);
|
|
1379
|
-
await promises.writeFile(filePath, typeDefinitionString, "utf8");
|
|
1380
|
-
result.writtenFiles[manifestKey] = filePath;
|
|
1381
|
-
onProgress?.({
|
|
1382
|
-
type: "file_written",
|
|
1383
|
-
manifestKey,
|
|
1384
|
-
filePath
|
|
1385
|
-
});
|
|
1386
|
-
}
|
|
1387
|
-
onProgress?.({
|
|
1388
|
-
type: "app_processing_complete",
|
|
1389
|
-
appKey: app.key
|
|
1390
|
-
});
|
|
1391
|
-
} catch (error) {
|
|
1392
|
-
const errorMessage = `Failed to generate types: ${error}`;
|
|
1393
|
-
result.errors.push({
|
|
1394
|
-
appKey: app.key,
|
|
1395
|
-
error: errorMessage
|
|
1396
|
-
});
|
|
1397
|
-
onProgress?.({
|
|
1398
|
-
type: "app_processing_error",
|
|
1399
|
-
appKey: app.key,
|
|
1400
|
-
error: errorMessage
|
|
1371
|
+
filePath
|
|
1401
1372
|
});
|
|
1402
1373
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
appKey: app.key,
|
|
1407
|
-
error: errorMessage
|
|
1374
|
+
onProgress?.({
|
|
1375
|
+
type: "app_processing_complete",
|
|
1376
|
+
appKey: app.key
|
|
1408
1377
|
});
|
|
1378
|
+
} catch (error) {
|
|
1379
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1409
1380
|
onProgress?.({
|
|
1410
1381
|
type: "app_processing_error",
|
|
1411
1382
|
appKey: app.key,
|
|
1412
1383
|
error: errorMessage
|
|
1413
1384
|
});
|
|
1385
|
+
if (error instanceof zapierSdk.ZapierValidationError) {
|
|
1386
|
+
throw error;
|
|
1387
|
+
} else {
|
|
1388
|
+
throw new zapierSdk.ZapierUnknownError(errorMessage, {
|
|
1389
|
+
cause: error
|
|
1390
|
+
// Works for both Error and non-Error
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1414
1393
|
}
|
|
1415
1394
|
}
|
|
1416
1395
|
return result;
|
|
@@ -1445,9 +1424,6 @@ var BuildManifestSchema = zod.z.object({
|
|
|
1445
1424
|
var buildManifestPlugin = ({ sdk, context }) => {
|
|
1446
1425
|
const buildManifest = zapierSdk.createFunction(async function buildManifest2(options) {
|
|
1447
1426
|
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
1448
|
-
const result = {
|
|
1449
|
-
errors: []
|
|
1450
|
-
};
|
|
1451
1427
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1452
1428
|
const appsIterator = sdk.listApps({ appKeys }).items();
|
|
1453
1429
|
const apps = [];
|
|
@@ -1457,7 +1433,7 @@ var buildManifestPlugin = ({ sdk, context }) => {
|
|
|
1457
1433
|
}
|
|
1458
1434
|
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
1459
1435
|
if (apps.length === 0) {
|
|
1460
|
-
return
|
|
1436
|
+
return {};
|
|
1461
1437
|
}
|
|
1462
1438
|
let updatedManifest;
|
|
1463
1439
|
for (const app of apps) {
|
|
@@ -1490,20 +1466,23 @@ var buildManifestPlugin = ({ sdk, context }) => {
|
|
|
1490
1466
|
});
|
|
1491
1467
|
onProgress?.({ type: "app_processing_complete", appKey: app.key });
|
|
1492
1468
|
} catch (error) {
|
|
1493
|
-
const errorMessage = `Failed to process app: ${error}`;
|
|
1494
|
-
result.errors.push({
|
|
1495
|
-
appKey: app.key,
|
|
1496
|
-
error: errorMessage
|
|
1497
|
-
});
|
|
1469
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1498
1470
|
onProgress?.({
|
|
1499
1471
|
type: "app_processing_error",
|
|
1500
1472
|
appKey: app.key,
|
|
1501
1473
|
error: errorMessage
|
|
1502
1474
|
});
|
|
1475
|
+
if (error instanceof zapierSdk.ZapierValidationError) {
|
|
1476
|
+
throw error;
|
|
1477
|
+
} else {
|
|
1478
|
+
throw new zapierSdk.ZapierUnknownError(errorMessage, {
|
|
1479
|
+
cause: error
|
|
1480
|
+
// Works for both Error and non-Error
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1503
1483
|
}
|
|
1504
1484
|
}
|
|
1505
|
-
|
|
1506
|
-
return result;
|
|
1485
|
+
return { manifest: updatedManifest };
|
|
1507
1486
|
}, BuildManifestSchema);
|
|
1508
1487
|
return {
|
|
1509
1488
|
buildManifest,
|
package/dist/index.d.mts
CHANGED
|
@@ -50,10 +50,6 @@ type ManifestBuildProgressEvent = {
|
|
|
50
50
|
};
|
|
51
51
|
interface BuildManifestResult {
|
|
52
52
|
manifest?: Manifest;
|
|
53
|
-
errors: Array<{
|
|
54
|
-
appKey: string;
|
|
55
|
-
error: string;
|
|
56
|
-
}>;
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
interface BuildManifestPluginProvides {
|
|
@@ -132,10 +128,6 @@ type AppTypesProgressEvent = {
|
|
|
132
128
|
interface GenerateAppTypesResult {
|
|
133
129
|
typeDefinitions: Record<string, string>;
|
|
134
130
|
writtenFiles?: Record<string, string>;
|
|
135
|
-
errors: Array<{
|
|
136
|
-
appKey: string;
|
|
137
|
-
error: string;
|
|
138
|
-
}>;
|
|
139
131
|
}
|
|
140
132
|
|
|
141
133
|
interface GenerateAppTypesPluginProvides {
|
package/dist/index.d.ts
CHANGED
|
@@ -50,10 +50,6 @@ type ManifestBuildProgressEvent = {
|
|
|
50
50
|
};
|
|
51
51
|
interface BuildManifestResult {
|
|
52
52
|
manifest?: Manifest;
|
|
53
|
-
errors: Array<{
|
|
54
|
-
appKey: string;
|
|
55
|
-
error: string;
|
|
56
|
-
}>;
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
interface BuildManifestPluginProvides {
|
|
@@ -132,10 +128,6 @@ type AppTypesProgressEvent = {
|
|
|
132
128
|
interface GenerateAppTypesResult {
|
|
133
129
|
typeDefinitions: Record<string, string>;
|
|
134
130
|
writtenFiles?: Record<string, string>;
|
|
135
|
-
errors: Array<{
|
|
136
|
-
appKey: string;
|
|
137
|
-
error: string;
|
|
138
|
-
}>;
|
|
139
131
|
}
|
|
140
132
|
|
|
141
133
|
interface GenerateAppTypesPluginProvides {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, getOsInfo, getPlatformVersions, getCiPlatform, isCi, createZapierSdkWithoutRegistry, registryPlugin, getReleaseId, getCurrentTimestamp, generateEventId, toSnakeCase } from '@zapier/zapier-sdk';
|
|
1
|
+
import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, getOsInfo, getPlatformVersions, getCiPlatform, isCi, createZapierSdkWithoutRegistry, registryPlugin, getReleaseId, getCurrentTimestamp, generateEventId, ZapierValidationError, ZapierUnknownError, toSnakeCase } from '@zapier/zapier-sdk';
|
|
2
2
|
import open from 'open';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
import express from 'express';
|
|
@@ -11,7 +11,7 @@ import { startMcpServerAsProcess } from '@zapier/zapier-sdk-mcp';
|
|
|
11
11
|
import { buildSync } from 'esbuild';
|
|
12
12
|
import * as fs from 'fs';
|
|
13
13
|
import * as path from 'path';
|
|
14
|
-
import {
|
|
14
|
+
import { resolve, join } from 'path';
|
|
15
15
|
import { mkdir, writeFile, access } from 'fs/promises';
|
|
16
16
|
import * as ts from 'typescript';
|
|
17
17
|
|
|
@@ -76,28 +76,28 @@ var client_default = api;
|
|
|
76
76
|
|
|
77
77
|
// src/utils/getCallablePromise.ts
|
|
78
78
|
var getCallablePromise = () => {
|
|
79
|
-
let
|
|
79
|
+
let resolve4 = () => {
|
|
80
80
|
};
|
|
81
81
|
let reject = () => {
|
|
82
82
|
};
|
|
83
83
|
const promise = new Promise((_resolve, _reject) => {
|
|
84
|
-
|
|
84
|
+
resolve4 = _resolve;
|
|
85
85
|
reject = _reject;
|
|
86
86
|
});
|
|
87
87
|
return {
|
|
88
88
|
promise,
|
|
89
|
-
resolve:
|
|
89
|
+
resolve: resolve4,
|
|
90
90
|
reject
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
var getCallablePromise_default = getCallablePromise;
|
|
94
94
|
var findAvailablePort = () => {
|
|
95
|
-
return new Promise((
|
|
95
|
+
return new Promise((resolve4, reject) => {
|
|
96
96
|
let portIndex = 0;
|
|
97
97
|
const tryPort = (port) => {
|
|
98
98
|
const server = express().listen(port, () => {
|
|
99
99
|
server.close();
|
|
100
|
-
|
|
100
|
+
resolve4(port);
|
|
101
101
|
});
|
|
102
102
|
server.on("error", (err) => {
|
|
103
103
|
if (err.code === "EADDRINUSE") {
|
|
@@ -187,15 +187,15 @@ var login = async (timeoutMs = LOGIN_TIMEOUT_MS) => {
|
|
|
187
187
|
} finally {
|
|
188
188
|
process.off("SIGINT", cleanup);
|
|
189
189
|
process.off("SIGTERM", cleanup);
|
|
190
|
-
await new Promise((
|
|
190
|
+
await new Promise((resolve4) => {
|
|
191
191
|
const timeout = setTimeout(() => {
|
|
192
192
|
log_default.info("Server close timed out, forcing connection shutdown...");
|
|
193
193
|
connections.forEach((conn) => conn.destroy());
|
|
194
|
-
|
|
194
|
+
resolve4();
|
|
195
195
|
}, 1e3);
|
|
196
196
|
server.close(() => {
|
|
197
197
|
clearTimeout(timeout);
|
|
198
|
-
|
|
198
|
+
resolve4();
|
|
199
199
|
});
|
|
200
200
|
});
|
|
201
201
|
}
|
|
@@ -227,7 +227,7 @@ var LoginSchema = z.object({
|
|
|
227
227
|
|
|
228
228
|
// package.json
|
|
229
229
|
var package_default = {
|
|
230
|
-
version: "0.13.
|
|
230
|
+
version: "0.13.10"};
|
|
231
231
|
|
|
232
232
|
// src/telemetry/builders.ts
|
|
233
233
|
function createCliBaseEvent(context = {}) {
|
|
@@ -618,14 +618,6 @@ var addPlugin = ({ sdk }) => {
|
|
|
618
618
|
if (successfulApps.length > 0) {
|
|
619
619
|
console.log(`\u2705 Added ${successfulApps.length} app(s) to manifest`);
|
|
620
620
|
}
|
|
621
|
-
const allErrors = [...manifestResult.errors, ...typesResult.errors];
|
|
622
|
-
if (allErrors.length > 0) {
|
|
623
|
-
console.warn(`
|
|
624
|
-
\u26A0\uFE0F ${allErrors.length} error(s) occurred:`);
|
|
625
|
-
allErrors.forEach(({ appKey, error }) => {
|
|
626
|
-
console.warn(` - ${appKey}: ${error}`);
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
621
|
}, AddSchema);
|
|
630
622
|
return {
|
|
631
623
|
add,
|
|
@@ -1245,17 +1237,12 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1245
1237
|
appKeys,
|
|
1246
1238
|
authenticationIds,
|
|
1247
1239
|
skipWrite = false,
|
|
1248
|
-
typesOutputDirectory,
|
|
1240
|
+
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
1249
1241
|
onProgress
|
|
1250
1242
|
} = options;
|
|
1251
|
-
|
|
1252
|
-
throw new Error(
|
|
1253
|
-
"typesOutputDirectory is required when skipWrite is false"
|
|
1254
|
-
);
|
|
1255
|
-
}
|
|
1243
|
+
const resolvedTypesOutput = resolve(typesOutputDirectory);
|
|
1256
1244
|
const result = {
|
|
1257
|
-
typeDefinitions: {}
|
|
1258
|
-
errors: []
|
|
1245
|
+
typeDefinitions: {}
|
|
1259
1246
|
};
|
|
1260
1247
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1261
1248
|
const appsIterator = sdk.listApps({ appKeys }).items();
|
|
@@ -1283,8 +1270,8 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1283
1270
|
count: authentications.length
|
|
1284
1271
|
});
|
|
1285
1272
|
}
|
|
1286
|
-
if (!skipWrite &&
|
|
1287
|
-
await mkdir(
|
|
1273
|
+
if (!skipWrite && resolvedTypesOutput) {
|
|
1274
|
+
await mkdir(resolvedTypesOutput, { recursive: true });
|
|
1288
1275
|
}
|
|
1289
1276
|
if (!skipWrite) {
|
|
1290
1277
|
result.writtenFiles = {};
|
|
@@ -1297,17 +1284,18 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1297
1284
|
});
|
|
1298
1285
|
try {
|
|
1299
1286
|
if (!app.version) {
|
|
1300
|
-
const
|
|
1301
|
-
result.errors.push({
|
|
1302
|
-
appKey: app.key,
|
|
1303
|
-
error
|
|
1304
|
-
});
|
|
1287
|
+
const errorMessage = `Invalid implementation ID format: ${app.implementation_id}. Expected format: <implementationName>@<version>`;
|
|
1305
1288
|
onProgress?.({
|
|
1306
1289
|
type: "app_processing_error",
|
|
1307
1290
|
appKey: app.key,
|
|
1308
|
-
error
|
|
1291
|
+
error: errorMessage
|
|
1292
|
+
});
|
|
1293
|
+
throw new ZapierValidationError(errorMessage, {
|
|
1294
|
+
details: {
|
|
1295
|
+
appKey: app.key,
|
|
1296
|
+
implementationId: app.implementation_id
|
|
1297
|
+
}
|
|
1309
1298
|
});
|
|
1310
|
-
continue;
|
|
1311
1299
|
}
|
|
1312
1300
|
let authenticationId;
|
|
1313
1301
|
if (authentications.length > 0) {
|
|
@@ -1330,56 +1318,47 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1330
1318
|
}
|
|
1331
1319
|
}
|
|
1332
1320
|
const manifestKey = getManifestKey(app);
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1321
|
+
const generator = new AstTypeGenerator();
|
|
1322
|
+
const typeDefinitionString = await generator.generateTypes({
|
|
1323
|
+
app,
|
|
1324
|
+
authenticationId,
|
|
1325
|
+
sdk
|
|
1326
|
+
});
|
|
1327
|
+
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
1328
|
+
onProgress?.({
|
|
1329
|
+
type: "type_generated",
|
|
1330
|
+
manifestKey,
|
|
1331
|
+
sizeBytes: typeDefinitionString.length
|
|
1332
|
+
});
|
|
1333
|
+
if (!skipWrite && resolvedTypesOutput && result.writtenFiles) {
|
|
1334
|
+
const filePath = join(resolvedTypesOutput, `${manifestKey}.d.ts`);
|
|
1335
|
+
await writeFile(filePath, typeDefinitionString, "utf8");
|
|
1336
|
+
result.writtenFiles[manifestKey] = filePath;
|
|
1341
1337
|
onProgress?.({
|
|
1342
|
-
type: "
|
|
1338
|
+
type: "file_written",
|
|
1343
1339
|
manifestKey,
|
|
1344
|
-
|
|
1345
|
-
});
|
|
1346
|
-
if (!skipWrite && typesOutputDirectory && result.writtenFiles) {
|
|
1347
|
-
const filePath = join(typesOutputDirectory, `${manifestKey}.d.ts`);
|
|
1348
|
-
await writeFile(filePath, typeDefinitionString, "utf8");
|
|
1349
|
-
result.writtenFiles[manifestKey] = filePath;
|
|
1350
|
-
onProgress?.({
|
|
1351
|
-
type: "file_written",
|
|
1352
|
-
manifestKey,
|
|
1353
|
-
filePath
|
|
1354
|
-
});
|
|
1355
|
-
}
|
|
1356
|
-
onProgress?.({
|
|
1357
|
-
type: "app_processing_complete",
|
|
1358
|
-
appKey: app.key
|
|
1359
|
-
});
|
|
1360
|
-
} catch (error) {
|
|
1361
|
-
const errorMessage = `Failed to generate types: ${error}`;
|
|
1362
|
-
result.errors.push({
|
|
1363
|
-
appKey: app.key,
|
|
1364
|
-
error: errorMessage
|
|
1365
|
-
});
|
|
1366
|
-
onProgress?.({
|
|
1367
|
-
type: "app_processing_error",
|
|
1368
|
-
appKey: app.key,
|
|
1369
|
-
error: errorMessage
|
|
1340
|
+
filePath
|
|
1370
1341
|
});
|
|
1371
1342
|
}
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
appKey: app.key,
|
|
1376
|
-
error: errorMessage
|
|
1343
|
+
onProgress?.({
|
|
1344
|
+
type: "app_processing_complete",
|
|
1345
|
+
appKey: app.key
|
|
1377
1346
|
});
|
|
1347
|
+
} catch (error) {
|
|
1348
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1378
1349
|
onProgress?.({
|
|
1379
1350
|
type: "app_processing_error",
|
|
1380
1351
|
appKey: app.key,
|
|
1381
1352
|
error: errorMessage
|
|
1382
1353
|
});
|
|
1354
|
+
if (error instanceof ZapierValidationError) {
|
|
1355
|
+
throw error;
|
|
1356
|
+
} else {
|
|
1357
|
+
throw new ZapierUnknownError(errorMessage, {
|
|
1358
|
+
cause: error
|
|
1359
|
+
// Works for both Error and non-Error
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1383
1362
|
}
|
|
1384
1363
|
}
|
|
1385
1364
|
return result;
|
|
@@ -1414,9 +1393,6 @@ var BuildManifestSchema = z.object({
|
|
|
1414
1393
|
var buildManifestPlugin = ({ sdk, context }) => {
|
|
1415
1394
|
const buildManifest = createFunction(async function buildManifest2(options) {
|
|
1416
1395
|
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
1417
|
-
const result = {
|
|
1418
|
-
errors: []
|
|
1419
|
-
};
|
|
1420
1396
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1421
1397
|
const appsIterator = sdk.listApps({ appKeys }).items();
|
|
1422
1398
|
const apps = [];
|
|
@@ -1426,7 +1402,7 @@ var buildManifestPlugin = ({ sdk, context }) => {
|
|
|
1426
1402
|
}
|
|
1427
1403
|
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
1428
1404
|
if (apps.length === 0) {
|
|
1429
|
-
return
|
|
1405
|
+
return {};
|
|
1430
1406
|
}
|
|
1431
1407
|
let updatedManifest;
|
|
1432
1408
|
for (const app of apps) {
|
|
@@ -1459,20 +1435,23 @@ var buildManifestPlugin = ({ sdk, context }) => {
|
|
|
1459
1435
|
});
|
|
1460
1436
|
onProgress?.({ type: "app_processing_complete", appKey: app.key });
|
|
1461
1437
|
} catch (error) {
|
|
1462
|
-
const errorMessage = `Failed to process app: ${error}`;
|
|
1463
|
-
result.errors.push({
|
|
1464
|
-
appKey: app.key,
|
|
1465
|
-
error: errorMessage
|
|
1466
|
-
});
|
|
1438
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
1467
1439
|
onProgress?.({
|
|
1468
1440
|
type: "app_processing_error",
|
|
1469
1441
|
appKey: app.key,
|
|
1470
1442
|
error: errorMessage
|
|
1471
1443
|
});
|
|
1444
|
+
if (error instanceof ZapierValidationError) {
|
|
1445
|
+
throw error;
|
|
1446
|
+
} else {
|
|
1447
|
+
throw new ZapierUnknownError(errorMessage, {
|
|
1448
|
+
cause: error
|
|
1449
|
+
// Works for both Error and non-Error
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1472
1452
|
}
|
|
1473
1453
|
}
|
|
1474
|
-
|
|
1475
|
-
return result;
|
|
1454
|
+
return { manifest: updatedManifest };
|
|
1476
1455
|
}, BuildManifestSchema);
|
|
1477
1456
|
return {
|
|
1478
1457
|
buildManifest,
|
package/dist/package.json
CHANGED
|
@@ -88,14 +88,6 @@ export const addPlugin = ({ sdk }) => {
|
|
|
88
88
|
if (successfulApps.length > 0) {
|
|
89
89
|
console.log(`✅ Added ${successfulApps.length} app(s) to manifest`);
|
|
90
90
|
}
|
|
91
|
-
// Report any errors
|
|
92
|
-
const allErrors = [...manifestResult.errors, ...typesResult.errors];
|
|
93
|
-
if (allErrors.length > 0) {
|
|
94
|
-
console.warn(`\n⚠️ ${allErrors.length} error(s) occurred:`);
|
|
95
|
-
allErrors.forEach(({ appKey, error }) => {
|
|
96
|
-
console.warn(` - ${appKey}: ${error}`);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
91
|
}, AddSchema);
|
|
100
92
|
return {
|
|
101
93
|
add,
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { createFunction } from "@zapier/zapier-sdk";
|
|
1
|
+
import { createFunction, ZapierValidationError, ZapierUnknownError, } from "@zapier/zapier-sdk";
|
|
2
2
|
import { BuildManifestSchema, } from "./schemas";
|
|
3
3
|
import { createManifestEntry } from "../../utils/manifest-helpers";
|
|
4
4
|
export const buildManifestPlugin = ({ sdk, context }) => {
|
|
5
5
|
const buildManifest = createFunction(async function buildManifest(options) {
|
|
6
6
|
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
7
|
-
const result = {
|
|
8
|
-
errors: [],
|
|
9
|
-
};
|
|
10
7
|
// Get apps using listApps (which respects existing manifest for version locking)
|
|
11
8
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
12
9
|
const appsIterator = sdk.listApps({ appKeys }).items();
|
|
@@ -17,7 +14,7 @@ export const buildManifestPlugin = ({ sdk, context }) => {
|
|
|
17
14
|
}
|
|
18
15
|
onProgress?.({ type: "apps_lookup_complete", count: apps.length });
|
|
19
16
|
if (apps.length === 0) {
|
|
20
|
-
return
|
|
17
|
+
return {};
|
|
21
18
|
}
|
|
22
19
|
let updatedManifest;
|
|
23
20
|
// Process each app
|
|
@@ -52,20 +49,23 @@ export const buildManifestPlugin = ({ sdk, context }) => {
|
|
|
52
49
|
onProgress?.({ type: "app_processing_complete", appKey: app.key });
|
|
53
50
|
}
|
|
54
51
|
catch (error) {
|
|
55
|
-
const errorMessage = `Failed to process app: ${error}`;
|
|
56
|
-
result.errors.push({
|
|
57
|
-
appKey: app.key,
|
|
58
|
-
error: errorMessage,
|
|
59
|
-
});
|
|
52
|
+
const errorMessage = `Failed to process app ${app.key}: ${error instanceof Error ? error.message : String(error)}`;
|
|
60
53
|
onProgress?.({
|
|
61
54
|
type: "app_processing_error",
|
|
62
55
|
appKey: app.key,
|
|
63
56
|
error: errorMessage,
|
|
64
57
|
});
|
|
58
|
+
if (error instanceof ZapierValidationError) {
|
|
59
|
+
throw error; // Preserve the specific error type
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new ZapierUnknownError(errorMessage, {
|
|
63
|
+
cause: error, // Works for both Error and non-Error
|
|
64
|
+
});
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
-
return result;
|
|
68
|
+
return { manifest: updatedManifest };
|
|
69
69
|
}, BuildManifestSchema);
|
|
70
70
|
return {
|
|
71
71
|
buildManifest,
|