@zapier/zapier-sdk-cli 0.28.0 → 0.29.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.
- package/CHANGELOG.md +12 -0
- package/CLAUDE.md +15 -15
- package/README.md +142 -142
- package/dist/cli.cjs +61 -55
- package/dist/cli.mjs +61 -55
- package/dist/index.cjs +49 -49
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +49 -49
- package/dist/package.json +1 -1
- package/dist/src/generators/ast-generator.d.ts +1 -1
- package/dist/src/generators/ast-generator.js +7 -7
- package/dist/src/plugins/add/index.d.ts +2 -2
- package/dist/src/plugins/add/index.js +12 -12
- package/dist/src/plugins/add/schemas.d.ts +1 -1
- package/dist/src/plugins/add/schemas.js +2 -2
- package/dist/src/plugins/buildManifest/index.js +2 -2
- package/dist/src/plugins/generateAppTypes/index.d.ts +2 -2
- package/dist/src/plugins/generateAppTypes/index.js +26 -26
- package/dist/src/plugins/generateAppTypes/schemas.d.ts +7 -7
- package/dist/src/plugins/generateAppTypes/schemas.js +2 -2
- package/dist/src/utils/cli-generator.js +10 -2
- package/dist/src/utils/parameter-resolver.js +8 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -302,7 +302,7 @@ var LoginSchema = zod.z.object({
|
|
|
302
302
|
|
|
303
303
|
// package.json
|
|
304
304
|
var package_default = {
|
|
305
|
-
version: "0.
|
|
305
|
+
version: "0.29.0"};
|
|
306
306
|
|
|
307
307
|
// src/telemetry/builders.ts
|
|
308
308
|
function createCliBaseEvent(context = {}) {
|
|
@@ -595,8 +595,8 @@ var AddSchema = zod.z.object({
|
|
|
595
595
|
appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
596
596
|
"One or more app keys to add (e.g., 'slack', 'github', 'trello')"
|
|
597
597
|
),
|
|
598
|
-
|
|
599
|
-
"
|
|
598
|
+
connectionIds: zod.z.array(zod.z.string()).optional().describe(
|
|
599
|
+
"Connection IDs to use for type generation (e.g., ['123', '456'])"
|
|
600
600
|
),
|
|
601
601
|
configPath: zod.z.string().optional().describe(
|
|
602
602
|
`Path to Zapier config file (defaults to '${zapierSdk.DEFAULT_CONFIG_PATH}', e.g., './custom/.zapierrc')`
|
|
@@ -622,7 +622,7 @@ var addPlugin = ({ sdk }) => {
|
|
|
622
622
|
const add = zapierSdk.createFunction(async function add2(options) {
|
|
623
623
|
const {
|
|
624
624
|
appKeys,
|
|
625
|
-
|
|
625
|
+
connectionIds,
|
|
626
626
|
configPath,
|
|
627
627
|
typesOutput = await detectTypesOutputDirectory()
|
|
628
628
|
} = options;
|
|
@@ -661,22 +661,22 @@ var addPlugin = ({ sdk }) => {
|
|
|
661
661
|
};
|
|
662
662
|
const handleTypesProgress = (event) => {
|
|
663
663
|
switch (event.type) {
|
|
664
|
-
case "
|
|
665
|
-
console.log(`\u{1F510} Looking up ${event.count}
|
|
664
|
+
case "connections_lookup_start":
|
|
665
|
+
console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
|
|
666
666
|
break;
|
|
667
|
-
case "
|
|
668
|
-
console.log(`\u{1F510} Found ${event.count}
|
|
667
|
+
case "connections_lookup_complete":
|
|
668
|
+
console.log(`\u{1F510} Found ${event.count} connection(s)`);
|
|
669
669
|
break;
|
|
670
|
-
case "
|
|
671
|
-
const
|
|
670
|
+
case "connection_matched":
|
|
671
|
+
const appWithConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
672
672
|
console.log(
|
|
673
|
-
`\u{1F510} Using
|
|
673
|
+
`\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
|
|
674
674
|
);
|
|
675
675
|
break;
|
|
676
|
-
case "
|
|
677
|
-
const
|
|
676
|
+
case "connection_not_matched":
|
|
677
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
678
678
|
console.warn(
|
|
679
|
-
`\u26A0\uFE0F No matching
|
|
679
|
+
`\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
|
|
680
680
|
);
|
|
681
681
|
break;
|
|
682
682
|
case "file_written":
|
|
@@ -698,7 +698,7 @@ var addPlugin = ({ sdk }) => {
|
|
|
698
698
|
});
|
|
699
699
|
const typesResult = await sdk.generateAppTypes({
|
|
700
700
|
appKeys,
|
|
701
|
-
|
|
701
|
+
connectionIds,
|
|
702
702
|
skipWrite: false,
|
|
703
703
|
typesOutputDirectory: resolvedTypesOutput,
|
|
704
704
|
onProgress: handleTypesProgress
|
|
@@ -727,8 +727,8 @@ var GenerateAppTypesSchema = zod.z.object({
|
|
|
727
727
|
appKeys: zod.z.array(zod.z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
728
728
|
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
729
729
|
),
|
|
730
|
-
|
|
731
|
-
"
|
|
730
|
+
connectionIds: zod.z.array(zod.z.string()).optional().describe(
|
|
731
|
+
"Connection IDs to use for type generation (e.g., ['123', '456'])"
|
|
732
732
|
),
|
|
733
733
|
skipWrite: zod.z.boolean().optional().describe(
|
|
734
734
|
"If true, returns type definitions without writing to disk. If false or omitted, writes type files."
|
|
@@ -752,7 +752,7 @@ var AstTypeGenerator = class {
|
|
|
752
752
|
* Generate TypeScript types using AST for a specific app
|
|
753
753
|
*/
|
|
754
754
|
async generateTypes(options) {
|
|
755
|
-
const { app,
|
|
755
|
+
const { app, connectionId, sdk } = options;
|
|
756
756
|
const actionsResult = await sdk.listActions({
|
|
757
757
|
appKey: app.implementation_id
|
|
758
758
|
});
|
|
@@ -763,7 +763,7 @@ var AstTypeGenerator = class {
|
|
|
763
763
|
appKey: app.implementation_id,
|
|
764
764
|
actionKey: action.key,
|
|
765
765
|
actionType: action.action_type,
|
|
766
|
-
|
|
766
|
+
connectionId
|
|
767
767
|
})
|
|
768
768
|
);
|
|
769
769
|
const results = await zapierSdk.batch(inputFieldsTasks, {
|
|
@@ -829,10 +829,10 @@ Usage:
|
|
|
829
829
|
|
|
830
830
|
const zapier = createZapierSdk();
|
|
831
831
|
// Types are automatically available:
|
|
832
|
-
await zapier.apps.${preferredKey}.search.user_by_email({
|
|
833
|
-
|
|
834
|
-
// Factory usage (pinned
|
|
835
|
-
const ${myVariableName} = zapier.apps.${preferredKey}({
|
|
832
|
+
await zapier.apps.${preferredKey}.search.user_by_email({ connectionId: 123, inputs: { email } })
|
|
833
|
+
|
|
834
|
+
// Factory usage (pinned connection):
|
|
835
|
+
const ${myVariableName} = zapier.apps.${preferredKey}({ connectionId: 123 })
|
|
836
836
|
await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
|
|
837
837
|
const statements = [
|
|
838
838
|
// Import the SDK to activate module augmentation
|
|
@@ -1170,7 +1170,7 @@ Usage:
|
|
|
1170
1170
|
this.factory.createTypeLiteralNode([
|
|
1171
1171
|
this.factory.createPropertySignature(
|
|
1172
1172
|
void 0,
|
|
1173
|
-
"
|
|
1173
|
+
"connectionId",
|
|
1174
1174
|
void 0,
|
|
1175
1175
|
this.factory.createUnionTypeNode([
|
|
1176
1176
|
this.factory.createKeywordTypeNode(ts__namespace.SyntaxKind.StringKeyword),
|
|
@@ -1342,7 +1342,7 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1342
1342
|
const generateAppTypes = zapierSdk.createFunction(async function generateAppTypes2(options) {
|
|
1343
1343
|
const {
|
|
1344
1344
|
appKeys,
|
|
1345
|
-
|
|
1345
|
+
connectionIds,
|
|
1346
1346
|
skipWrite = false,
|
|
1347
1347
|
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
1348
1348
|
onProgress
|
|
@@ -1352,9 +1352,9 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1352
1352
|
typeDefinitions: {}
|
|
1353
1353
|
};
|
|
1354
1354
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1355
|
-
const
|
|
1355
|
+
const appsIterable = sdk.listApps({ appKeys }).items();
|
|
1356
1356
|
const apps = [];
|
|
1357
|
-
for await (const app of
|
|
1357
|
+
for await (const app of appsIterable) {
|
|
1358
1358
|
apps.push(app);
|
|
1359
1359
|
onProgress?.({ type: "app_found", app });
|
|
1360
1360
|
}
|
|
@@ -1362,19 +1362,19 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1362
1362
|
if (apps.length === 0) {
|
|
1363
1363
|
return result;
|
|
1364
1364
|
}
|
|
1365
|
-
const
|
|
1366
|
-
if (
|
|
1365
|
+
const connections = [];
|
|
1366
|
+
if (connectionIds && connectionIds.length > 0) {
|
|
1367
1367
|
onProgress?.({
|
|
1368
|
-
type: "
|
|
1369
|
-
count:
|
|
1368
|
+
type: "connections_lookup_start",
|
|
1369
|
+
count: connectionIds.length
|
|
1370
1370
|
});
|
|
1371
|
-
const
|
|
1372
|
-
for await (const
|
|
1373
|
-
|
|
1371
|
+
const connectionsIterable = sdk.listConnections({ connectionIds }).items();
|
|
1372
|
+
for await (const connection of connectionsIterable) {
|
|
1373
|
+
connections.push(connection);
|
|
1374
1374
|
}
|
|
1375
1375
|
onProgress?.({
|
|
1376
|
-
type: "
|
|
1377
|
-
count:
|
|
1376
|
+
type: "connections_lookup_complete",
|
|
1377
|
+
count: connections.length
|
|
1378
1378
|
});
|
|
1379
1379
|
}
|
|
1380
1380
|
if (!skipWrite && resolvedTypesOutput) {
|
|
@@ -1404,22 +1404,22 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
});
|
|
1406
1406
|
}
|
|
1407
|
-
let
|
|
1408
|
-
if (
|
|
1409
|
-
const
|
|
1410
|
-
return
|
|
1407
|
+
let connectionId;
|
|
1408
|
+
if (connections.length > 0) {
|
|
1409
|
+
const matchingConnection = connections.find((conn) => {
|
|
1410
|
+
return conn.app_key === app.key;
|
|
1411
1411
|
});
|
|
1412
|
-
if (
|
|
1413
|
-
|
|
1412
|
+
if (matchingConnection) {
|
|
1413
|
+
connectionId = matchingConnection.id;
|
|
1414
1414
|
onProgress?.({
|
|
1415
|
-
type: "
|
|
1415
|
+
type: "connection_matched",
|
|
1416
1416
|
appKey: app.key,
|
|
1417
|
-
|
|
1418
|
-
|
|
1417
|
+
connectionId: matchingConnection.id,
|
|
1418
|
+
connectionTitle: matchingConnection.title || ""
|
|
1419
1419
|
});
|
|
1420
1420
|
} else {
|
|
1421
1421
|
onProgress?.({
|
|
1422
|
-
type: "
|
|
1422
|
+
type: "connection_not_matched",
|
|
1423
1423
|
appKey: app.key
|
|
1424
1424
|
});
|
|
1425
1425
|
}
|
|
@@ -1428,7 +1428,7 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1428
1428
|
const generator = new AstTypeGenerator();
|
|
1429
1429
|
const typeDefinitionString = await generator.generateTypes({
|
|
1430
1430
|
app,
|
|
1431
|
-
|
|
1431
|
+
connectionId,
|
|
1432
1432
|
sdk
|
|
1433
1433
|
});
|
|
1434
1434
|
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
@@ -1501,9 +1501,9 @@ var buildManifestPlugin = ({ sdk, context }) => {
|
|
|
1501
1501
|
const buildManifest = zapierSdk.createFunction(async function buildManifest2(options) {
|
|
1502
1502
|
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
1503
1503
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1504
|
-
const
|
|
1504
|
+
const appsIterable = sdk.listApps({ appKeys }).items();
|
|
1505
1505
|
const apps = [];
|
|
1506
|
-
for await (const app of
|
|
1506
|
+
for await (const app of appsIterable) {
|
|
1507
1507
|
apps.push(app);
|
|
1508
1508
|
onProgress?.({ type: "app_found", app });
|
|
1509
1509
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -74,7 +74,7 @@ interface FeedbackPluginProvides {
|
|
|
74
74
|
|
|
75
75
|
declare const GenerateAppTypesSchema: z.ZodObject<{
|
|
76
76
|
appKeys: z.ZodArray<z.ZodString>;
|
|
77
|
-
|
|
77
|
+
connectionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
78
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
79
79
|
typesOutputDirectory: z.ZodOptional<z.ZodString>;
|
|
80
80
|
}, z.core.$strip>;
|
|
@@ -91,22 +91,22 @@ type AppTypesProgressEvent = {
|
|
|
91
91
|
type: "apps_lookup_complete";
|
|
92
92
|
count: number;
|
|
93
93
|
} | {
|
|
94
|
-
type: "
|
|
94
|
+
type: "connections_lookup_start";
|
|
95
95
|
count: number;
|
|
96
96
|
} | {
|
|
97
|
-
type: "
|
|
97
|
+
type: "connections_lookup_complete";
|
|
98
98
|
count: number;
|
|
99
99
|
} | {
|
|
100
100
|
type: "app_processing_start";
|
|
101
101
|
appKey: string;
|
|
102
102
|
slug?: string;
|
|
103
103
|
} | {
|
|
104
|
-
type: "
|
|
104
|
+
type: "connection_matched";
|
|
105
105
|
appKey: string;
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
connectionId: string;
|
|
107
|
+
connectionTitle: string;
|
|
108
108
|
} | {
|
|
109
|
-
type: "
|
|
109
|
+
type: "connection_not_matched";
|
|
110
110
|
appKey: string;
|
|
111
111
|
} | {
|
|
112
112
|
type: "type_generated";
|
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ interface FeedbackPluginProvides {
|
|
|
74
74
|
|
|
75
75
|
declare const GenerateAppTypesSchema: z.ZodObject<{
|
|
76
76
|
appKeys: z.ZodArray<z.ZodString>;
|
|
77
|
-
|
|
77
|
+
connectionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
78
|
skipWrite: z.ZodOptional<z.ZodBoolean>;
|
|
79
79
|
typesOutputDirectory: z.ZodOptional<z.ZodString>;
|
|
80
80
|
}, z.core.$strip>;
|
|
@@ -91,22 +91,22 @@ type AppTypesProgressEvent = {
|
|
|
91
91
|
type: "apps_lookup_complete";
|
|
92
92
|
count: number;
|
|
93
93
|
} | {
|
|
94
|
-
type: "
|
|
94
|
+
type: "connections_lookup_start";
|
|
95
95
|
count: number;
|
|
96
96
|
} | {
|
|
97
|
-
type: "
|
|
97
|
+
type: "connections_lookup_complete";
|
|
98
98
|
count: number;
|
|
99
99
|
} | {
|
|
100
100
|
type: "app_processing_start";
|
|
101
101
|
appKey: string;
|
|
102
102
|
slug?: string;
|
|
103
103
|
} | {
|
|
104
|
-
type: "
|
|
104
|
+
type: "connection_matched";
|
|
105
105
|
appKey: string;
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
connectionId: string;
|
|
107
|
+
connectionTitle: string;
|
|
108
108
|
} | {
|
|
109
|
-
type: "
|
|
109
|
+
type: "connection_not_matched";
|
|
110
110
|
appKey: string;
|
|
111
111
|
} | {
|
|
112
112
|
type: "type_generated";
|
package/dist/index.mjs
CHANGED
|
@@ -271,7 +271,7 @@ var LoginSchema = z.object({
|
|
|
271
271
|
|
|
272
272
|
// package.json
|
|
273
273
|
var package_default = {
|
|
274
|
-
version: "0.
|
|
274
|
+
version: "0.29.0"};
|
|
275
275
|
|
|
276
276
|
// src/telemetry/builders.ts
|
|
277
277
|
function createCliBaseEvent(context = {}) {
|
|
@@ -564,8 +564,8 @@ var AddSchema = z.object({
|
|
|
564
564
|
appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
565
565
|
"One or more app keys to add (e.g., 'slack', 'github', 'trello')"
|
|
566
566
|
),
|
|
567
|
-
|
|
568
|
-
"
|
|
567
|
+
connectionIds: z.array(z.string()).optional().describe(
|
|
568
|
+
"Connection IDs to use for type generation (e.g., ['123', '456'])"
|
|
569
569
|
),
|
|
570
570
|
configPath: z.string().optional().describe(
|
|
571
571
|
`Path to Zapier config file (defaults to '${DEFAULT_CONFIG_PATH}', e.g., './custom/.zapierrc')`
|
|
@@ -591,7 +591,7 @@ var addPlugin = ({ sdk }) => {
|
|
|
591
591
|
const add = createFunction(async function add2(options) {
|
|
592
592
|
const {
|
|
593
593
|
appKeys,
|
|
594
|
-
|
|
594
|
+
connectionIds,
|
|
595
595
|
configPath,
|
|
596
596
|
typesOutput = await detectTypesOutputDirectory()
|
|
597
597
|
} = options;
|
|
@@ -630,22 +630,22 @@ var addPlugin = ({ sdk }) => {
|
|
|
630
630
|
};
|
|
631
631
|
const handleTypesProgress = (event) => {
|
|
632
632
|
switch (event.type) {
|
|
633
|
-
case "
|
|
634
|
-
console.log(`\u{1F510} Looking up ${event.count}
|
|
633
|
+
case "connections_lookup_start":
|
|
634
|
+
console.log(`\u{1F510} Looking up ${event.count} connection(s)...`);
|
|
635
635
|
break;
|
|
636
|
-
case "
|
|
637
|
-
console.log(`\u{1F510} Found ${event.count}
|
|
636
|
+
case "connections_lookup_complete":
|
|
637
|
+
console.log(`\u{1F510} Found ${event.count} connection(s)`);
|
|
638
638
|
break;
|
|
639
|
-
case "
|
|
640
|
-
const
|
|
639
|
+
case "connection_matched":
|
|
640
|
+
const appWithConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
641
641
|
console.log(
|
|
642
|
-
`\u{1F510} Using
|
|
642
|
+
`\u{1F510} Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`
|
|
643
643
|
);
|
|
644
644
|
break;
|
|
645
|
-
case "
|
|
646
|
-
const
|
|
645
|
+
case "connection_not_matched":
|
|
646
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
647
647
|
console.warn(
|
|
648
|
-
`\u26A0\uFE0F No matching
|
|
648
|
+
`\u26A0\uFE0F No matching connection found for ${appWithoutConnection}`
|
|
649
649
|
);
|
|
650
650
|
break;
|
|
651
651
|
case "file_written":
|
|
@@ -667,7 +667,7 @@ var addPlugin = ({ sdk }) => {
|
|
|
667
667
|
});
|
|
668
668
|
const typesResult = await sdk.generateAppTypes({
|
|
669
669
|
appKeys,
|
|
670
|
-
|
|
670
|
+
connectionIds,
|
|
671
671
|
skipWrite: false,
|
|
672
672
|
typesOutputDirectory: resolvedTypesOutput,
|
|
673
673
|
onProgress: handleTypesProgress
|
|
@@ -696,8 +696,8 @@ var GenerateAppTypesSchema = z.object({
|
|
|
696
696
|
appKeys: z.array(z.string().min(1, "App key cannot be empty")).min(1, "At least one app key is required").describe(
|
|
697
697
|
"One or more app keys to generate types for (e.g., 'slack', 'github', 'trello')"
|
|
698
698
|
),
|
|
699
|
-
|
|
700
|
-
"
|
|
699
|
+
connectionIds: z.array(z.string()).optional().describe(
|
|
700
|
+
"Connection IDs to use for type generation (e.g., ['123', '456'])"
|
|
701
701
|
),
|
|
702
702
|
skipWrite: z.boolean().optional().describe(
|
|
703
703
|
"If true, returns type definitions without writing to disk. If false or omitted, writes type files."
|
|
@@ -721,7 +721,7 @@ var AstTypeGenerator = class {
|
|
|
721
721
|
* Generate TypeScript types using AST for a specific app
|
|
722
722
|
*/
|
|
723
723
|
async generateTypes(options) {
|
|
724
|
-
const { app,
|
|
724
|
+
const { app, connectionId, sdk } = options;
|
|
725
725
|
const actionsResult = await sdk.listActions({
|
|
726
726
|
appKey: app.implementation_id
|
|
727
727
|
});
|
|
@@ -732,7 +732,7 @@ var AstTypeGenerator = class {
|
|
|
732
732
|
appKey: app.implementation_id,
|
|
733
733
|
actionKey: action.key,
|
|
734
734
|
actionType: action.action_type,
|
|
735
|
-
|
|
735
|
+
connectionId
|
|
736
736
|
})
|
|
737
737
|
);
|
|
738
738
|
const results = await batch(inputFieldsTasks, {
|
|
@@ -798,10 +798,10 @@ Usage:
|
|
|
798
798
|
|
|
799
799
|
const zapier = createZapierSdk();
|
|
800
800
|
// Types are automatically available:
|
|
801
|
-
await zapier.apps.${preferredKey}.search.user_by_email({
|
|
802
|
-
|
|
803
|
-
// Factory usage (pinned
|
|
804
|
-
const ${myVariableName} = zapier.apps.${preferredKey}({
|
|
801
|
+
await zapier.apps.${preferredKey}.search.user_by_email({ connectionId: 123, inputs: { email } })
|
|
802
|
+
|
|
803
|
+
// Factory usage (pinned connection):
|
|
804
|
+
const ${myVariableName} = zapier.apps.${preferredKey}({ connectionId: 123 })
|
|
805
805
|
await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
|
|
806
806
|
const statements = [
|
|
807
807
|
// Import the SDK to activate module augmentation
|
|
@@ -1139,7 +1139,7 @@ Usage:
|
|
|
1139
1139
|
this.factory.createTypeLiteralNode([
|
|
1140
1140
|
this.factory.createPropertySignature(
|
|
1141
1141
|
void 0,
|
|
1142
|
-
"
|
|
1142
|
+
"connectionId",
|
|
1143
1143
|
void 0,
|
|
1144
1144
|
this.factory.createUnionTypeNode([
|
|
1145
1145
|
this.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
|
|
@@ -1311,7 +1311,7 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1311
1311
|
const generateAppTypes = createFunction(async function generateAppTypes2(options) {
|
|
1312
1312
|
const {
|
|
1313
1313
|
appKeys,
|
|
1314
|
-
|
|
1314
|
+
connectionIds,
|
|
1315
1315
|
skipWrite = false,
|
|
1316
1316
|
typesOutputDirectory = await detectTypesOutputDirectory(),
|
|
1317
1317
|
onProgress
|
|
@@ -1321,9 +1321,9 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1321
1321
|
typeDefinitions: {}
|
|
1322
1322
|
};
|
|
1323
1323
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1324
|
-
const
|
|
1324
|
+
const appsIterable = sdk.listApps({ appKeys }).items();
|
|
1325
1325
|
const apps = [];
|
|
1326
|
-
for await (const app of
|
|
1326
|
+
for await (const app of appsIterable) {
|
|
1327
1327
|
apps.push(app);
|
|
1328
1328
|
onProgress?.({ type: "app_found", app });
|
|
1329
1329
|
}
|
|
@@ -1331,19 +1331,19 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1331
1331
|
if (apps.length === 0) {
|
|
1332
1332
|
return result;
|
|
1333
1333
|
}
|
|
1334
|
-
const
|
|
1335
|
-
if (
|
|
1334
|
+
const connections = [];
|
|
1335
|
+
if (connectionIds && connectionIds.length > 0) {
|
|
1336
1336
|
onProgress?.({
|
|
1337
|
-
type: "
|
|
1338
|
-
count:
|
|
1337
|
+
type: "connections_lookup_start",
|
|
1338
|
+
count: connectionIds.length
|
|
1339
1339
|
});
|
|
1340
|
-
const
|
|
1341
|
-
for await (const
|
|
1342
|
-
|
|
1340
|
+
const connectionsIterable = sdk.listConnections({ connectionIds }).items();
|
|
1341
|
+
for await (const connection of connectionsIterable) {
|
|
1342
|
+
connections.push(connection);
|
|
1343
1343
|
}
|
|
1344
1344
|
onProgress?.({
|
|
1345
|
-
type: "
|
|
1346
|
-
count:
|
|
1345
|
+
type: "connections_lookup_complete",
|
|
1346
|
+
count: connections.length
|
|
1347
1347
|
});
|
|
1348
1348
|
}
|
|
1349
1349
|
if (!skipWrite && resolvedTypesOutput) {
|
|
@@ -1373,22 +1373,22 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1373
1373
|
}
|
|
1374
1374
|
});
|
|
1375
1375
|
}
|
|
1376
|
-
let
|
|
1377
|
-
if (
|
|
1378
|
-
const
|
|
1379
|
-
return
|
|
1376
|
+
let connectionId;
|
|
1377
|
+
if (connections.length > 0) {
|
|
1378
|
+
const matchingConnection = connections.find((conn) => {
|
|
1379
|
+
return conn.app_key === app.key;
|
|
1380
1380
|
});
|
|
1381
|
-
if (
|
|
1382
|
-
|
|
1381
|
+
if (matchingConnection) {
|
|
1382
|
+
connectionId = matchingConnection.id;
|
|
1383
1383
|
onProgress?.({
|
|
1384
|
-
type: "
|
|
1384
|
+
type: "connection_matched",
|
|
1385
1385
|
appKey: app.key,
|
|
1386
|
-
|
|
1387
|
-
|
|
1386
|
+
connectionId: matchingConnection.id,
|
|
1387
|
+
connectionTitle: matchingConnection.title || ""
|
|
1388
1388
|
});
|
|
1389
1389
|
} else {
|
|
1390
1390
|
onProgress?.({
|
|
1391
|
-
type: "
|
|
1391
|
+
type: "connection_not_matched",
|
|
1392
1392
|
appKey: app.key
|
|
1393
1393
|
});
|
|
1394
1394
|
}
|
|
@@ -1397,7 +1397,7 @@ var generateAppTypesPlugin = ({ sdk }) => {
|
|
|
1397
1397
|
const generator = new AstTypeGenerator();
|
|
1398
1398
|
const typeDefinitionString = await generator.generateTypes({
|
|
1399
1399
|
app,
|
|
1400
|
-
|
|
1400
|
+
connectionId,
|
|
1401
1401
|
sdk
|
|
1402
1402
|
});
|
|
1403
1403
|
result.typeDefinitions[manifestKey] = typeDefinitionString;
|
|
@@ -1470,9 +1470,9 @@ var buildManifestPlugin = ({ sdk, context }) => {
|
|
|
1470
1470
|
const buildManifest = createFunction(async function buildManifest2(options) {
|
|
1471
1471
|
const { appKeys, skipWrite = false, configPath, onProgress } = options;
|
|
1472
1472
|
onProgress?.({ type: "apps_lookup_start", count: appKeys.length });
|
|
1473
|
-
const
|
|
1473
|
+
const appsIterable = sdk.listApps({ appKeys }).items();
|
|
1474
1474
|
const apps = [];
|
|
1475
|
-
for await (const app of
|
|
1475
|
+
for await (const app of appsIterable) {
|
|
1476
1476
|
apps.push(app);
|
|
1477
1477
|
onProgress?.({ type: "app_found", app });
|
|
1478
1478
|
}
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GetSdkType, ListActionsPluginProvides, ListInputFieldsPluginProvides, ManifestPluginProvides, AppItem } from "@zapier/zapier-sdk";
|
|
2
2
|
interface GenerateTypesOptions {
|
|
3
3
|
app: AppItem;
|
|
4
|
-
|
|
4
|
+
connectionId?: string | number;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* AST-based TypeScript type generator using the TypeScript Compiler API
|
|
@@ -16,7 +16,7 @@ export class AstTypeGenerator {
|
|
|
16
16
|
* Generate TypeScript types using AST for a specific app
|
|
17
17
|
*/
|
|
18
18
|
async generateTypes(options) {
|
|
19
|
-
const { app,
|
|
19
|
+
const { app, connectionId, sdk } = options;
|
|
20
20
|
// Fetch all actions for the app using implementation_id for correct versioning
|
|
21
21
|
const actionsResult = await sdk.listActions({
|
|
22
22
|
appKey: app.implementation_id,
|
|
@@ -31,7 +31,7 @@ export class AstTypeGenerator {
|
|
|
31
31
|
appKey: app.implementation_id,
|
|
32
32
|
actionKey: action.key,
|
|
33
33
|
actionType: action.action_type,
|
|
34
|
-
|
|
34
|
+
connectionId: connectionId,
|
|
35
35
|
}));
|
|
36
36
|
const results = await batch(inputFieldsTasks, {
|
|
37
37
|
concurrency: 50, // Limit to 50 concurrent requests
|
|
@@ -92,10 +92,10 @@ Usage:
|
|
|
92
92
|
|
|
93
93
|
const zapier = createZapierSdk();
|
|
94
94
|
// Types are automatically available:
|
|
95
|
-
await zapier.apps.${preferredKey}.search.user_by_email({
|
|
96
|
-
|
|
97
|
-
// Factory usage (pinned
|
|
98
|
-
const ${myVariableName} = zapier.apps.${preferredKey}({
|
|
95
|
+
await zapier.apps.${preferredKey}.search.user_by_email({ connectionId: 123, inputs: { email } })
|
|
96
|
+
|
|
97
|
+
// Factory usage (pinned connection):
|
|
98
|
+
const ${myVariableName} = zapier.apps.${preferredKey}({ connectionId: 123 })
|
|
99
99
|
await ${myVariableName}.search.user_by_email({ inputs: { email } })`;
|
|
100
100
|
const statements = [
|
|
101
101
|
// Import the SDK to activate module augmentation
|
|
@@ -263,7 +263,7 @@ Usage:
|
|
|
263
263
|
createAppFactoryInterface(appName) {
|
|
264
264
|
const callSignature = this.factory.createCallSignature(undefined, [
|
|
265
265
|
this.factory.createParameterDeclaration(undefined, undefined, "options", undefined, this.factory.createTypeLiteralNode([
|
|
266
|
-
this.factory.createPropertySignature(undefined, "
|
|
266
|
+
this.factory.createPropertySignature(undefined, "connectionId", undefined, this.factory.createUnionTypeNode([
|
|
267
267
|
this.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
|
|
268
268
|
this.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),
|
|
269
269
|
])),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Plugin, GetSdkType, ListActionsPluginProvides, ListAppsPluginProvides, ListInputFieldsPluginProvides,
|
|
1
|
+
import type { Plugin, GetSdkType, ListActionsPluginProvides, ListAppsPluginProvides, ListInputFieldsPluginProvides, ListConnectionsPluginProvides } from "@zapier/zapier-sdk";
|
|
2
2
|
import { AddSchema, type AddOptions } from "./schemas";
|
|
3
3
|
import { type GenerateAppTypesPluginProvides } from "../generateAppTypes";
|
|
4
4
|
import { type BuildManifestPluginProvides } from "../buildManifest";
|
|
@@ -12,4 +12,4 @@ export interface AddPluginProvides {
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
export declare const addPlugin: Plugin<GetSdkType<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides &
|
|
15
|
+
export declare const addPlugin: Plugin<GetSdkType<ListAppsPluginProvides & ListActionsPluginProvides & ListInputFieldsPluginProvides & ListConnectionsPluginProvides & BuildManifestPluginProvides & GenerateAppTypesPluginProvides>, {}, AddPluginProvides>;
|
|
@@ -4,7 +4,7 @@ import { detectTypesOutputDirectory } from "../../utils/directory-detection";
|
|
|
4
4
|
import { resolve } from "path";
|
|
5
5
|
export const addPlugin = ({ sdk }) => {
|
|
6
6
|
const add = createFunction(async function add(options) {
|
|
7
|
-
const { appKeys,
|
|
7
|
+
const { appKeys, connectionIds, configPath, typesOutput = await detectTypesOutputDirectory(), } = options;
|
|
8
8
|
const resolvedTypesOutput = resolve(typesOutput);
|
|
9
9
|
console.log(`📦 Adding ${appKeys.length} app(s)...`);
|
|
10
10
|
// Track app names for better console output
|
|
@@ -46,19 +46,19 @@ export const addPlugin = ({ sdk }) => {
|
|
|
46
46
|
// Define progress handler for type generation
|
|
47
47
|
const handleTypesProgress = (event) => {
|
|
48
48
|
switch (event.type) {
|
|
49
|
-
case "
|
|
50
|
-
console.log(`🔐 Looking up ${event.count}
|
|
49
|
+
case "connections_lookup_start":
|
|
50
|
+
console.log(`🔐 Looking up ${event.count} connection(s)...`);
|
|
51
51
|
break;
|
|
52
|
-
case "
|
|
53
|
-
console.log(`🔐 Found ${event.count}
|
|
52
|
+
case "connections_lookup_complete":
|
|
53
|
+
console.log(`🔐 Found ${event.count} connection(s)`);
|
|
54
54
|
break;
|
|
55
|
-
case "
|
|
56
|
-
const
|
|
57
|
-
console.log(`🔐 Using
|
|
55
|
+
case "connection_matched":
|
|
56
|
+
const appWithConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
57
|
+
console.log(`🔐 Using connection ${event.connectionId} (${event.connectionTitle}) for ${appWithConnection}`);
|
|
58
58
|
break;
|
|
59
|
-
case "
|
|
60
|
-
const
|
|
61
|
-
console.warn(`⚠️ No matching
|
|
59
|
+
case "connection_not_matched":
|
|
60
|
+
const appWithoutConnection = appSlugAndKeyMap.get(event.appKey) || event.appKey;
|
|
61
|
+
console.warn(`⚠️ No matching connection found for ${appWithoutConnection}`);
|
|
62
62
|
break;
|
|
63
63
|
case "file_written":
|
|
64
64
|
console.log(`🔧 Generated types for ${event.manifestKey} at ${event.filePath}`);
|
|
@@ -77,7 +77,7 @@ export const addPlugin = ({ sdk }) => {
|
|
|
77
77
|
});
|
|
78
78
|
const typesResult = await sdk.generateAppTypes({
|
|
79
79
|
appKeys,
|
|
80
|
-
|
|
80
|
+
connectionIds,
|
|
81
81
|
skipWrite: false,
|
|
82
82
|
typesOutputDirectory: resolvedTypesOutput,
|
|
83
83
|
onProgress: handleTypesProgress,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const AddSchema: z.ZodObject<{
|
|
3
3
|
appKeys: z.ZodArray<z.ZodString>;
|
|
4
|
-
|
|
4
|
+
connectionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
5
|
configPath: z.ZodOptional<z.ZodString>;
|
|
6
6
|
typesOutput: z.ZodOptional<z.ZodString>;
|
|
7
7
|
}, z.core.$strip>;
|