@zapier/zapier-sdk 0.15.1 → 0.15.3
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/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.integration.test.d.ts +5 -0
- package/dist/api/client.integration.test.d.ts.map +1 -0
- package/dist/api/client.integration.test.js +318 -0
- package/dist/api/client.js +31 -1
- package/dist/index.cjs +401 -108
- package/dist/index.d.mts +360 -56
- package/dist/index.mjs +401 -108
- package/dist/plugins/fetch/schemas.d.ts +2 -2
- package/dist/plugins/getAction/schemas.d.ts +2 -2
- package/dist/plugins/getApp/index.test.js +17 -21
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +2 -2
- package/dist/plugins/listActions/index.test.js +25 -0
- package/dist/plugins/listActions/schemas.d.ts +6 -6
- package/dist/plugins/listApps/index.d.ts +1 -3
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +18 -44
- package/dist/plugins/listApps/index.test.js +89 -288
- package/dist/plugins/listApps/schemas.d.ts +19 -26
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +19 -18
- package/dist/plugins/listAuthentications/index.test.js +20 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +8 -8
- package/dist/plugins/listInputFields/schemas.d.ts +8 -8
- package/dist/plugins/manifest/index.d.ts +42 -3
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +68 -1
- package/dist/plugins/manifest/index.test.js +513 -1
- package/dist/plugins/manifest/schemas.d.ts +75 -2
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +27 -3
- package/dist/plugins/request/schemas.d.ts +4 -4
- package/dist/plugins/runAction/schemas.d.ts +8 -8
- package/dist/sdk.d.ts +24 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/temporary-internal-core/handlers/listApps.d.ts +67 -0
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/listApps.js +121 -0
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts +2 -0
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +1 -0
- package/dist/temporary-internal-core/handlers/listApps.test.js +328 -0
- package/dist/temporary-internal-core/index.d.ts +4 -0
- package/dist/temporary-internal-core/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/index.js +5 -1
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +582 -0
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/apps/index.js +95 -0
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts +511 -0
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/schemas/implementations/index.js +79 -0
- package/dist/temporary-internal-core/types/handler.d.ts +51 -0
- package/dist/temporary-internal-core/types/handler.d.ts.map +1 -0
- package/dist/temporary-internal-core/types/handler.js +8 -0
- package/dist/temporary-internal-core/types/index.d.ts +5 -0
- package/dist/temporary-internal-core/types/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/types/index.js +4 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts +54 -0
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/app-locators.js +83 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts +18 -0
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -0
- package/dist/temporary-internal-core/utils/transformations.js +36 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -688,7 +688,69 @@ function createPaginatedFunction(coreFn, schema) {
|
|
|
688
688
|
};
|
|
689
689
|
return namedFunctions[functionName];
|
|
690
690
|
}
|
|
691
|
-
var
|
|
691
|
+
var ImplementationMetaSchema = z.object({
|
|
692
|
+
id: z.string(),
|
|
693
|
+
name: z.string(),
|
|
694
|
+
slug: z.string(),
|
|
695
|
+
age_in_days: z.number().optional(),
|
|
696
|
+
auth_type: z.string().optional(),
|
|
697
|
+
banner: z.string().optional(),
|
|
698
|
+
categories: z.array(
|
|
699
|
+
z.object({
|
|
700
|
+
id: z.number(),
|
|
701
|
+
name: z.string(),
|
|
702
|
+
slug: z.string()
|
|
703
|
+
})
|
|
704
|
+
).optional(),
|
|
705
|
+
images: z.object({
|
|
706
|
+
url_16x16: z.string().optional(),
|
|
707
|
+
url_32x32: z.string().optional(),
|
|
708
|
+
url_64x64: z.string().optional(),
|
|
709
|
+
url_128x128: z.string().optional()
|
|
710
|
+
}).optional(),
|
|
711
|
+
popularity: z.number().optional(),
|
|
712
|
+
has_filters: z.boolean().optional(),
|
|
713
|
+
has_reads: z.boolean().optional(),
|
|
714
|
+
has_searches: z.boolean().optional(),
|
|
715
|
+
has_searches_or_writes: z.boolean().optional(),
|
|
716
|
+
has_upfront_fields: z.boolean().optional(),
|
|
717
|
+
has_writes: z.boolean().optional(),
|
|
718
|
+
is_beta: z.boolean().optional(),
|
|
719
|
+
is_built_in: z.boolean().optional(),
|
|
720
|
+
is_deprecated: z.boolean().optional(),
|
|
721
|
+
is_featured: z.boolean().optional(),
|
|
722
|
+
is_hidden: z.boolean().optional(),
|
|
723
|
+
is_invite: z.boolean().optional(),
|
|
724
|
+
is_premium: z.boolean().optional(),
|
|
725
|
+
is_public: z.boolean().optional(),
|
|
726
|
+
is_upcoming: z.boolean().optional(),
|
|
727
|
+
version: z.string().optional(),
|
|
728
|
+
visibility: z.string().optional(),
|
|
729
|
+
actions: z.object({
|
|
730
|
+
read: z.number().optional(),
|
|
731
|
+
read_bulk: z.number().optional(),
|
|
732
|
+
write: z.number().optional(),
|
|
733
|
+
search: z.number().optional(),
|
|
734
|
+
search_or_write: z.number().optional(),
|
|
735
|
+
search_and_write: z.number().optional(),
|
|
736
|
+
filter: z.number().optional()
|
|
737
|
+
}).optional(),
|
|
738
|
+
description: z.string().optional(),
|
|
739
|
+
primary_color: z.string().optional(),
|
|
740
|
+
secondary_color: z.string().optional(),
|
|
741
|
+
classification: z.string().optional(),
|
|
742
|
+
api_docs_url: z.string().optional(),
|
|
743
|
+
image: z.string().optional()
|
|
744
|
+
});
|
|
745
|
+
z.object({
|
|
746
|
+
count: z.number(),
|
|
747
|
+
next: z.string().nullable().optional(),
|
|
748
|
+
previous: z.string().nullable().optional(),
|
|
749
|
+
results: z.array(ImplementationMetaSchema)
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
// src/temporary-internal-core/schemas/apps/index.ts
|
|
753
|
+
var ListAppsOptionsSchema = z.object({
|
|
692
754
|
appKeys: z.array(z.string()).optional().describe(
|
|
693
755
|
"Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
694
756
|
),
|
|
@@ -697,6 +759,34 @@ var ListAppsSchema = z.object({
|
|
|
697
759
|
maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
698
760
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
699
761
|
}).describe("List all available apps with optional filtering");
|
|
762
|
+
var AppItemSchema = ImplementationMetaSchema.omit({
|
|
763
|
+
name: true,
|
|
764
|
+
id: true
|
|
765
|
+
}).extend({
|
|
766
|
+
title: z.string(),
|
|
767
|
+
key: z.string(),
|
|
768
|
+
implementation_id: z.string(),
|
|
769
|
+
version: z.string().optional()
|
|
770
|
+
});
|
|
771
|
+
z.object({
|
|
772
|
+
data: z.array(AppItemSchema),
|
|
773
|
+
nextCursor: z.string().optional()
|
|
774
|
+
});
|
|
775
|
+
var ListAppsHandlerRequestSchema = z.object({
|
|
776
|
+
implementationIds: z.union([z.string(), z.array(z.string())]).optional().describe(
|
|
777
|
+
"Pre-resolved implementation IDs - array or comma-separated string"
|
|
778
|
+
),
|
|
779
|
+
search: z.string().optional().describe("Optional search term to augment results"),
|
|
780
|
+
pageSize: z.union([z.string(), z.number()]).optional().describe("Number of apps per page"),
|
|
781
|
+
cursor: z.string().optional().describe("Pagination cursor")
|
|
782
|
+
}).transform((data) => ({
|
|
783
|
+
// Normalize implementationIds to array
|
|
784
|
+
implementationIds: typeof data.implementationIds === "string" ? data.implementationIds === "" ? [] : data.implementationIds.split(",") : data.implementationIds ?? [],
|
|
785
|
+
search: data.search,
|
|
786
|
+
// Normalize pageSize to number
|
|
787
|
+
pageSize: typeof data.pageSize === "string" ? parseInt(data.pageSize, 10) : data.pageSize,
|
|
788
|
+
cursor: data.cursor
|
|
789
|
+
}));
|
|
700
790
|
var NeedChoicesSchema = z.object({
|
|
701
791
|
key: z.string().optional(),
|
|
702
792
|
label: z.string().optional(),
|
|
@@ -985,7 +1075,7 @@ z.object({
|
|
|
985
1075
|
previous: z.string().nullable().optional(),
|
|
986
1076
|
results: z.array(ImplementationSchema)
|
|
987
1077
|
});
|
|
988
|
-
var
|
|
1078
|
+
var ImplementationMetaSchema2 = z.object({
|
|
989
1079
|
id: z.string(),
|
|
990
1080
|
// e.g. "100HiresCLIAPI@1.2.1"
|
|
991
1081
|
name: z.string(),
|
|
@@ -1044,7 +1134,7 @@ z.object({
|
|
|
1044
1134
|
count: z.number(),
|
|
1045
1135
|
next: z.string().nullable().optional(),
|
|
1046
1136
|
previous: z.string().nullable().optional(),
|
|
1047
|
-
results: z.array(
|
|
1137
|
+
results: z.array(ImplementationMetaSchema2)
|
|
1048
1138
|
});
|
|
1049
1139
|
var NeedChoicesResponseMetaSchema = z.object({
|
|
1050
1140
|
page: z.string().nullable().optional()
|
|
@@ -1096,8 +1186,8 @@ function toSnakeCase(input) {
|
|
|
1096
1186
|
}
|
|
1097
1187
|
|
|
1098
1188
|
// src/schemas/App.ts
|
|
1099
|
-
var
|
|
1100
|
-
|
|
1189
|
+
var AppItemSchema2 = withFormatter(
|
|
1190
|
+
ImplementationMetaSchema2.omit({ name: true, id: true }).extend({
|
|
1101
1191
|
title: z.string(),
|
|
1102
1192
|
// Mapped from name
|
|
1103
1193
|
key: z.string(),
|
|
@@ -1126,6 +1216,62 @@ var AppItemSchema = withFormatter(
|
|
|
1126
1216
|
}
|
|
1127
1217
|
);
|
|
1128
1218
|
|
|
1219
|
+
// src/plugins/listApps/index.ts
|
|
1220
|
+
var listAppsPlugin = ({ context }) => {
|
|
1221
|
+
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
1222
|
+
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1223
|
+
const appKeys = options.appKeys ?? [];
|
|
1224
|
+
const appLocators = await resolveAppKeys2({
|
|
1225
|
+
appKeys: [...appKeys]
|
|
1226
|
+
});
|
|
1227
|
+
const implementationNameToLocator = {};
|
|
1228
|
+
for (const locator of appLocators) {
|
|
1229
|
+
implementationNameToLocator[locator.implementationName] = [
|
|
1230
|
+
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
1231
|
+
locator
|
|
1232
|
+
];
|
|
1233
|
+
}
|
|
1234
|
+
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
1235
|
+
if (duplicatedLookupAppKeys.length > 0) {
|
|
1236
|
+
throw new Error(
|
|
1237
|
+
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
1238
|
+
);
|
|
1239
|
+
}
|
|
1240
|
+
if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
|
|
1241
|
+
return {
|
|
1242
|
+
data: [],
|
|
1243
|
+
nextCursor: void 0
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1246
|
+
const implementationIds = appLocators.map((locator) => {
|
|
1247
|
+
const version = locator.version || "latest";
|
|
1248
|
+
return `${locator.implementationName}@${version}`;
|
|
1249
|
+
});
|
|
1250
|
+
return await api.get("/api/v0/apps", {
|
|
1251
|
+
searchParams: {
|
|
1252
|
+
implementationIds: implementationIds.join(","),
|
|
1253
|
+
...options.search && { search: options.search },
|
|
1254
|
+
pageSize: options.pageSize.toString(),
|
|
1255
|
+
...options.cursor && { cursor: options.cursor }
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
}, ListAppsOptionsSchema);
|
|
1259
|
+
return {
|
|
1260
|
+
listApps,
|
|
1261
|
+
context: {
|
|
1262
|
+
meta: {
|
|
1263
|
+
listApps: {
|
|
1264
|
+
categories: ["app"],
|
|
1265
|
+
type: "list",
|
|
1266
|
+
itemType: "App",
|
|
1267
|
+
inputSchema: ListAppsOptionsSchema,
|
|
1268
|
+
outputSchema: AppItemSchema2
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1129
1275
|
// src/utils/domain-utils.ts
|
|
1130
1276
|
function splitVersionedKey(versionedKey) {
|
|
1131
1277
|
const parts = versionedKey.split("@");
|
|
@@ -1245,102 +1391,6 @@ function toAppLocator(appKey) {
|
|
|
1245
1391
|
function isResolvedAppLocator(appLocator) {
|
|
1246
1392
|
return !!appLocator.implementationName;
|
|
1247
1393
|
}
|
|
1248
|
-
function toImplementationId(appLocator) {
|
|
1249
|
-
return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
// src/plugins/listApps/index.ts
|
|
1253
|
-
var listAppsPlugin = ({ context }) => {
|
|
1254
|
-
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
1255
|
-
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1256
|
-
const appKeys = options.appKeys ?? [];
|
|
1257
|
-
const appLocators = await resolveAppKeys2({
|
|
1258
|
-
appKeys: [...appKeys]
|
|
1259
|
-
});
|
|
1260
|
-
const implementationNameToLocator = {};
|
|
1261
|
-
for (const locator of appLocators) {
|
|
1262
|
-
implementationNameToLocator[locator.implementationName] = [
|
|
1263
|
-
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
1264
|
-
locator
|
|
1265
|
-
];
|
|
1266
|
-
}
|
|
1267
|
-
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
1268
|
-
if (duplicatedLookupAppKeys.length > 0) {
|
|
1269
|
-
throw new Error(
|
|
1270
|
-
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
1271
|
-
);
|
|
1272
|
-
}
|
|
1273
|
-
if (options.search) {
|
|
1274
|
-
const searchParams2 = {};
|
|
1275
|
-
searchParams2.term = options.search;
|
|
1276
|
-
const searchEnvelope = await api.get(
|
|
1277
|
-
"/zapier/api/v4/implementations-meta/search/",
|
|
1278
|
-
{
|
|
1279
|
-
searchParams: searchParams2
|
|
1280
|
-
}
|
|
1281
|
-
);
|
|
1282
|
-
const implementations = searchEnvelope.results.map(
|
|
1283
|
-
normalizeImplementationMetaToAppItem
|
|
1284
|
-
);
|
|
1285
|
-
const implementationNameSet = new Set(
|
|
1286
|
-
appLocators.map((locator) => locator.implementationName)
|
|
1287
|
-
);
|
|
1288
|
-
for (const implementation of implementations) {
|
|
1289
|
-
const [implementationName] = splitVersionedKey(implementation.key);
|
|
1290
|
-
if (!implementationNameSet.has(implementationName)) {
|
|
1291
|
-
implementationNameSet.add(implementationName);
|
|
1292
|
-
appLocators.push({
|
|
1293
|
-
...toAppLocator(implementation.key),
|
|
1294
|
-
implementationName
|
|
1295
|
-
});
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
const searchParams = {};
|
|
1300
|
-
if (options.pageSize) {
|
|
1301
|
-
searchParams.limit = options.pageSize.toString();
|
|
1302
|
-
}
|
|
1303
|
-
if (appLocators.length === 0) {
|
|
1304
|
-
searchParams.latest_only = "true";
|
|
1305
|
-
}
|
|
1306
|
-
if (options.cursor) {
|
|
1307
|
-
searchParams.offset = options.cursor;
|
|
1308
|
-
}
|
|
1309
|
-
searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
|
|
1310
|
-
if (appKeys.length > 0 && appLocators.length === 0) {
|
|
1311
|
-
return {
|
|
1312
|
-
data: [],
|
|
1313
|
-
nextCursor: void 0
|
|
1314
|
-
};
|
|
1315
|
-
}
|
|
1316
|
-
const implementationsEnvelope = await api.get(
|
|
1317
|
-
"/zapier/api/v4/implementations-meta/lookup/",
|
|
1318
|
-
{
|
|
1319
|
-
searchParams
|
|
1320
|
-
}
|
|
1321
|
-
);
|
|
1322
|
-
return {
|
|
1323
|
-
data: implementationsEnvelope.results.map(
|
|
1324
|
-
normalizeImplementationMetaToAppItem
|
|
1325
|
-
),
|
|
1326
|
-
nextCursor: extractCursor(implementationsEnvelope)
|
|
1327
|
-
};
|
|
1328
|
-
}, ListAppsSchema);
|
|
1329
|
-
return {
|
|
1330
|
-
listApps,
|
|
1331
|
-
context: {
|
|
1332
|
-
meta: {
|
|
1333
|
-
listApps: {
|
|
1334
|
-
categories: ["app"],
|
|
1335
|
-
type: "list",
|
|
1336
|
-
itemType: "App",
|
|
1337
|
-
inputSchema: ListAppsSchema,
|
|
1338
|
-
outputSchema: AppItemSchema
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
};
|
|
1343
|
-
};
|
|
1344
1394
|
var ListActionsSchema = z.object({
|
|
1345
1395
|
appKey: AppKeyPropertySchema.describe(
|
|
1346
1396
|
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
@@ -2183,7 +2233,7 @@ var getAppPlugin = ({ sdk }) => {
|
|
|
2183
2233
|
type: "item",
|
|
2184
2234
|
itemType: "App",
|
|
2185
2235
|
inputSchema: GetAppSchema,
|
|
2186
|
-
outputSchema:
|
|
2236
|
+
outputSchema: AppItemSchema2,
|
|
2187
2237
|
resolvers: {
|
|
2188
2238
|
appKey: appKeyResolver
|
|
2189
2239
|
}
|
|
@@ -2649,6 +2699,17 @@ async function readFile(filePath) {
|
|
|
2649
2699
|
throw new Error(`File not found: ${filePath}`);
|
|
2650
2700
|
}
|
|
2651
2701
|
var DEFAULT_CONFIG_PATH = ".zapierrc";
|
|
2702
|
+
var ActionEntrySchema = z.object({
|
|
2703
|
+
appKey: z.string().describe("App key (slug or implementation name)"),
|
|
2704
|
+
actionKey: z.string().describe("Action key identifier"),
|
|
2705
|
+
actionType: z.string().describe("Action type (e.g., 'read', 'write', 'search')"),
|
|
2706
|
+
authenticationId: z.number().nullable().optional().describe("Authentication ID used"),
|
|
2707
|
+
inputs: z.record(z.unknown()).optional().describe("Resolved input values"),
|
|
2708
|
+
schema: z.record(z.unknown()).describe(
|
|
2709
|
+
"Complete JSON Schema from getInputFieldsSchema (includes $schema, type, properties, required, etc.)"
|
|
2710
|
+
),
|
|
2711
|
+
createdAt: z.string().describe("ISO 8601 timestamp when created")
|
|
2712
|
+
});
|
|
2652
2713
|
var ManifestSchema = z.object({
|
|
2653
2714
|
apps: z.record(
|
|
2654
2715
|
z.string(),
|
|
@@ -2658,8 +2719,9 @@ var ManifestSchema = z.object({
|
|
|
2658
2719
|
),
|
|
2659
2720
|
version: z.string().describe("Version string (e.g., '1.21.1')")
|
|
2660
2721
|
})
|
|
2661
|
-
)
|
|
2662
|
-
|
|
2722
|
+
),
|
|
2723
|
+
actions: z.record(z.string(), ActionEntrySchema).optional().describe("Saved action configurations with their schemas")
|
|
2724
|
+
}).describe("Manifest for app version locking and action configurations");
|
|
2663
2725
|
z.object({
|
|
2664
2726
|
manifestPath: z.string().optional().describe("Path to manifest file"),
|
|
2665
2727
|
manifest: z.record(
|
|
@@ -2930,7 +2992,81 @@ var manifestPlugin = (params) => {
|
|
|
2930
2992
|
await writeManifestToFile(updatedManifest, configPath);
|
|
2931
2993
|
resolvedManifest = void 0;
|
|
2932
2994
|
}
|
|
2933
|
-
return
|
|
2995
|
+
return {
|
|
2996
|
+
key: manifestKey,
|
|
2997
|
+
entry,
|
|
2998
|
+
manifest: updatedManifest
|
|
2999
|
+
};
|
|
3000
|
+
};
|
|
3001
|
+
const addActionEntry = async (options2) => {
|
|
3002
|
+
const {
|
|
3003
|
+
name,
|
|
3004
|
+
entry,
|
|
3005
|
+
configPath = DEFAULT_CONFIG_PATH,
|
|
3006
|
+
skipWrite = false,
|
|
3007
|
+
manifest: inputManifest
|
|
3008
|
+
} = options2;
|
|
3009
|
+
const manifest2 = inputManifest || await readManifestFromFile(configPath) || { apps: {} };
|
|
3010
|
+
const actions = manifest2.actions || {};
|
|
3011
|
+
if (actions[name] && !skipWrite) {
|
|
3012
|
+
throw new Error(
|
|
3013
|
+
`Action "${name}" already exists. Please choose a different name or remove the existing action first.`
|
|
3014
|
+
);
|
|
3015
|
+
}
|
|
3016
|
+
const updatedManifest = {
|
|
3017
|
+
...manifest2,
|
|
3018
|
+
actions: {
|
|
3019
|
+
...actions,
|
|
3020
|
+
[name]: entry
|
|
3021
|
+
}
|
|
3022
|
+
};
|
|
3023
|
+
if (!skipWrite) {
|
|
3024
|
+
await writeManifestToFile(updatedManifest, configPath);
|
|
3025
|
+
resolvedManifest = void 0;
|
|
3026
|
+
}
|
|
3027
|
+
return {
|
|
3028
|
+
name,
|
|
3029
|
+
entry,
|
|
3030
|
+
manifest: updatedManifest
|
|
3031
|
+
};
|
|
3032
|
+
};
|
|
3033
|
+
const findActionEntry = ({
|
|
3034
|
+
name,
|
|
3035
|
+
manifest: manifest2
|
|
3036
|
+
}) => {
|
|
3037
|
+
return manifest2.actions?.[name] || null;
|
|
3038
|
+
};
|
|
3039
|
+
const listActionEntries = async ({
|
|
3040
|
+
configPath = DEFAULT_CONFIG_PATH
|
|
3041
|
+
} = {}) => {
|
|
3042
|
+
const manifest2 = await readManifestFromFile(configPath) || { };
|
|
3043
|
+
return Object.entries(manifest2.actions || {});
|
|
3044
|
+
};
|
|
3045
|
+
const deleteActionEntry = async ({
|
|
3046
|
+
name,
|
|
3047
|
+
configPath = DEFAULT_CONFIG_PATH,
|
|
3048
|
+
skipWrite = false
|
|
3049
|
+
}) => {
|
|
3050
|
+
const manifest2 = await readManifestFromFile(configPath) || { apps: {} };
|
|
3051
|
+
if (!manifest2.actions?.[name]) {
|
|
3052
|
+
throw new Error(`Action "${name}" does not exist.`);
|
|
3053
|
+
}
|
|
3054
|
+
const { [name]: removed, ...remainingActions } = manifest2.actions;
|
|
3055
|
+
const updatedManifest = {
|
|
3056
|
+
...manifest2,
|
|
3057
|
+
actions: remainingActions
|
|
3058
|
+
};
|
|
3059
|
+
if (!skipWrite) {
|
|
3060
|
+
await writeManifestToFile(updatedManifest, configPath);
|
|
3061
|
+
resolvedManifest = void 0;
|
|
3062
|
+
}
|
|
3063
|
+
return updatedManifest;
|
|
3064
|
+
};
|
|
3065
|
+
const hasActionEntry = ({
|
|
3066
|
+
name,
|
|
3067
|
+
manifest: manifest2
|
|
3068
|
+
}) => {
|
|
3069
|
+
return !!manifest2.actions?.[name];
|
|
2934
3070
|
};
|
|
2935
3071
|
return {
|
|
2936
3072
|
context: {
|
|
@@ -2940,7 +3076,14 @@ var manifestPlugin = (params) => {
|
|
|
2940
3076
|
api,
|
|
2941
3077
|
manifest: await getResolvedManifest() ?? { apps: {} }
|
|
2942
3078
|
}),
|
|
2943
|
-
updateManifestEntry
|
|
3079
|
+
updateManifestEntry,
|
|
3080
|
+
addActionEntry,
|
|
3081
|
+
findActionEntry,
|
|
3082
|
+
listActionEntries,
|
|
3083
|
+
deleteActionEntry,
|
|
3084
|
+
hasActionEntry,
|
|
3085
|
+
findManifestEntry,
|
|
3086
|
+
readManifestFromFile
|
|
2944
3087
|
}
|
|
2945
3088
|
};
|
|
2946
3089
|
};
|
|
@@ -3365,6 +3508,135 @@ function getTrackingBaseUrl({
|
|
|
3365
3508
|
return ZAPIER_BASE_URL;
|
|
3366
3509
|
}
|
|
3367
3510
|
|
|
3511
|
+
// src/temporary-internal-core/utils/app-locators.ts
|
|
3512
|
+
function splitVersionedKey2(versionedKey) {
|
|
3513
|
+
const parts = versionedKey.split("@");
|
|
3514
|
+
if (parts.length >= 2) {
|
|
3515
|
+
const baseKey = parts[0];
|
|
3516
|
+
const version = parts.slice(1).join("@");
|
|
3517
|
+
return [baseKey, version];
|
|
3518
|
+
}
|
|
3519
|
+
return [versionedKey, void 0];
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
// src/temporary-internal-core/utils/transformations.ts
|
|
3523
|
+
function transformImplementationMetaToAppItem(implementationMeta) {
|
|
3524
|
+
const [selectedApi, appVersion] = splitVersionedKey2(implementationMeta.id);
|
|
3525
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
3526
|
+
return {
|
|
3527
|
+
...restOfImplementationMeta,
|
|
3528
|
+
title: name,
|
|
3529
|
+
key: selectedApi,
|
|
3530
|
+
implementation_id: id,
|
|
3531
|
+
version: appVersion
|
|
3532
|
+
};
|
|
3533
|
+
}
|
|
3534
|
+
function extractPaginationCursor(response) {
|
|
3535
|
+
if (!response.next) {
|
|
3536
|
+
return void 0;
|
|
3537
|
+
}
|
|
3538
|
+
try {
|
|
3539
|
+
const url = new URL(response.next);
|
|
3540
|
+
const offset = url.searchParams.get("offset");
|
|
3541
|
+
return offset || void 0;
|
|
3542
|
+
} catch {
|
|
3543
|
+
return void 0;
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
|
|
3547
|
+
// src/temporary-internal-core/handlers/listApps.ts
|
|
3548
|
+
var DEFAULT_PAGE_SIZE = 20;
|
|
3549
|
+
async function augmentWithSearchResults({
|
|
3550
|
+
searchTerm,
|
|
3551
|
+
implementationIds,
|
|
3552
|
+
httpClient
|
|
3553
|
+
}) {
|
|
3554
|
+
const searchResponse = await httpClient.get(
|
|
3555
|
+
"/zapier/api/v4/implementations-meta/search/",
|
|
3556
|
+
{
|
|
3557
|
+
searchParams: { term: searchTerm }
|
|
3558
|
+
}
|
|
3559
|
+
);
|
|
3560
|
+
const searchResults = searchResponse.results.map(
|
|
3561
|
+
transformImplementationMetaToAppItem
|
|
3562
|
+
);
|
|
3563
|
+
const implementationNameSet = new Set(
|
|
3564
|
+
implementationIds.map((id) => {
|
|
3565
|
+
const [name] = splitVersionedKey2(id);
|
|
3566
|
+
return name;
|
|
3567
|
+
})
|
|
3568
|
+
);
|
|
3569
|
+
const additionalIds = [];
|
|
3570
|
+
for (const result of searchResults) {
|
|
3571
|
+
const [implementationName] = splitVersionedKey2(result.key);
|
|
3572
|
+
if (!implementationNameSet.has(implementationName)) {
|
|
3573
|
+
implementationNameSet.add(implementationName);
|
|
3574
|
+
additionalIds.push(result.implementation_id);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
return [...implementationIds, ...additionalIds];
|
|
3578
|
+
}
|
|
3579
|
+
var handleListApps = async ({ request, deps }) => {
|
|
3580
|
+
const validatedRequest = ListAppsHandlerRequestSchema.parse(request);
|
|
3581
|
+
const { httpClient } = deps;
|
|
3582
|
+
let { implementationIds } = validatedRequest;
|
|
3583
|
+
const pageSize = validatedRequest.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
3584
|
+
if (validatedRequest.search) {
|
|
3585
|
+
implementationIds = await augmentWithSearchResults({
|
|
3586
|
+
searchTerm: validatedRequest.search,
|
|
3587
|
+
implementationIds,
|
|
3588
|
+
httpClient
|
|
3589
|
+
});
|
|
3590
|
+
}
|
|
3591
|
+
if (implementationIds.length === 0) {
|
|
3592
|
+
if (validatedRequest.search) {
|
|
3593
|
+
return {
|
|
3594
|
+
data: [],
|
|
3595
|
+
nextCursor: void 0
|
|
3596
|
+
};
|
|
3597
|
+
}
|
|
3598
|
+
const searchParams2 = {
|
|
3599
|
+
latest_only: "true",
|
|
3600
|
+
selected_apis: "",
|
|
3601
|
+
limit: pageSize.toString()
|
|
3602
|
+
};
|
|
3603
|
+
if (validatedRequest.cursor) {
|
|
3604
|
+
searchParams2.offset = validatedRequest.cursor;
|
|
3605
|
+
}
|
|
3606
|
+
const implementationsResponse2 = await httpClient.get(
|
|
3607
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
3608
|
+
{
|
|
3609
|
+
searchParams: searchParams2
|
|
3610
|
+
}
|
|
3611
|
+
);
|
|
3612
|
+
return {
|
|
3613
|
+
data: implementationsResponse2.results.map(
|
|
3614
|
+
transformImplementationMetaToAppItem
|
|
3615
|
+
),
|
|
3616
|
+
nextCursor: extractPaginationCursor(implementationsResponse2)
|
|
3617
|
+
};
|
|
3618
|
+
}
|
|
3619
|
+
const searchParams = {
|
|
3620
|
+
selected_apis: implementationIds.join(","),
|
|
3621
|
+
limit: pageSize.toString()
|
|
3622
|
+
};
|
|
3623
|
+
if (validatedRequest.cursor) {
|
|
3624
|
+
searchParams.offset = validatedRequest.cursor;
|
|
3625
|
+
}
|
|
3626
|
+
const implementationsResponse = await httpClient.get(
|
|
3627
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
3628
|
+
{
|
|
3629
|
+
searchParams
|
|
3630
|
+
}
|
|
3631
|
+
);
|
|
3632
|
+
return {
|
|
3633
|
+
data: implementationsResponse.results.map(
|
|
3634
|
+
transformImplementationMetaToAppItem
|
|
3635
|
+
),
|
|
3636
|
+
nextCursor: extractPaginationCursor(implementationsResponse)
|
|
3637
|
+
};
|
|
3638
|
+
};
|
|
3639
|
+
|
|
3368
3640
|
// src/api/client.ts
|
|
3369
3641
|
var pathConfig = {
|
|
3370
3642
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
@@ -3376,6 +3648,9 @@ var pathConfig = {
|
|
|
3376
3648
|
"/zapier": {
|
|
3377
3649
|
authHeader: "Authorization",
|
|
3378
3650
|
pathPrefix: "/api/v0/sdk/zapier"
|
|
3651
|
+
},
|
|
3652
|
+
"/api/v0/apps": {
|
|
3653
|
+
handlerOverride: handleListApps
|
|
3379
3654
|
}
|
|
3380
3655
|
};
|
|
3381
3656
|
var ZapierApiClient = class {
|
|
@@ -3533,6 +3808,14 @@ var ZapierApiClient = class {
|
|
|
3533
3808
|
}
|
|
3534
3809
|
return void 0;
|
|
3535
3810
|
}
|
|
3811
|
+
// Helper to check if a path config has a handler override
|
|
3812
|
+
hasHandlerOverride(pathConfig2) {
|
|
3813
|
+
return pathConfig2 !== void 0 && "handlerOverride" in pathConfig2 && typeof pathConfig2.handlerOverride === "function";
|
|
3814
|
+
}
|
|
3815
|
+
// Helper to check if a path config is a standard path config
|
|
3816
|
+
isStandardPathConfig(pathConfig2) {
|
|
3817
|
+
return pathConfig2 !== void 0 && !this.hasHandlerOverride(pathConfig2);
|
|
3818
|
+
}
|
|
3536
3819
|
// Helper to parse API error response
|
|
3537
3820
|
parseErrorResponse(errorInfo) {
|
|
3538
3821
|
const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
|
|
@@ -3604,7 +3887,7 @@ var ZapierApiClient = class {
|
|
|
3604
3887
|
const headers = new Headers(options.headers ?? {});
|
|
3605
3888
|
const authToken = await this.getAuthToken();
|
|
3606
3889
|
if (authToken) {
|
|
3607
|
-
const authHeaderName = pathConfig2
|
|
3890
|
+
const authHeaderName = this.isStandardPathConfig(pathConfig2) && pathConfig2.authHeader ? pathConfig2.authHeader : "Authorization";
|
|
3608
3891
|
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
3609
3892
|
}
|
|
3610
3893
|
if (options.authRequired) {
|
|
@@ -3618,6 +3901,16 @@ var ZapierApiClient = class {
|
|
|
3618
3901
|
}
|
|
3619
3902
|
// Helper to perform HTTP requests with JSON handling
|
|
3620
3903
|
async fetchJson(method, path, data, options = {}) {
|
|
3904
|
+
const { pathConfig: pathConfig2 } = this.buildUrl(path, options.searchParams);
|
|
3905
|
+
if (this.hasHandlerOverride(pathConfig2)) {
|
|
3906
|
+
const handlerRequest = method === "GET" ? options.searchParams : data;
|
|
3907
|
+
return pathConfig2.handlerOverride({
|
|
3908
|
+
request: handlerRequest,
|
|
3909
|
+
deps: {
|
|
3910
|
+
httpClient: this
|
|
3911
|
+
}
|
|
3912
|
+
});
|
|
3913
|
+
}
|
|
3621
3914
|
const headers = { ...options.headers };
|
|
3622
3915
|
if (data && typeof data === "object") {
|
|
3623
3916
|
headers["Content-Type"] = "application/json";
|
|
@@ -4280,7 +4573,7 @@ function getCpuTime() {
|
|
|
4280
4573
|
|
|
4281
4574
|
// package.json
|
|
4282
4575
|
var package_default = {
|
|
4283
|
-
version: "0.15.
|
|
4576
|
+
version: "0.15.3"};
|
|
4284
4577
|
|
|
4285
4578
|
// src/plugins/eventEmission/builders.ts
|
|
4286
4579
|
function createBaseEvent(context = {}) {
|
|
@@ -9,16 +9,16 @@ export declare const FetchInitSchema: z.ZodOptional<z.ZodObject<{
|
|
|
9
9
|
authenticationTemplate: z.ZodOptional<z.ZodString>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
11
|
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | undefined;
|
|
12
|
+
authenticationId?: number | undefined;
|
|
12
13
|
headers?: Record<string, string> | undefined;
|
|
13
14
|
body?: string | FormData | URLSearchParams | undefined;
|
|
14
|
-
authenticationId?: number | undefined;
|
|
15
15
|
callbackUrl?: string | undefined;
|
|
16
16
|
authenticationTemplate?: string | undefined;
|
|
17
17
|
}, {
|
|
18
18
|
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | undefined;
|
|
19
|
+
authenticationId?: number | undefined;
|
|
19
20
|
headers?: Record<string, string> | undefined;
|
|
20
21
|
body?: string | FormData | URLSearchParams | undefined;
|
|
21
|
-
authenticationId?: number | undefined;
|
|
22
22
|
callbackUrl?: string | undefined;
|
|
23
23
|
authenticationTemplate?: string | undefined;
|
|
24
24
|
}>>;
|
|
@@ -9,12 +9,12 @@ export declare const GetActionSchema: z.ZodObject<{
|
|
|
9
9
|
actionKey: z.ZodString;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
11
|
appKey: string;
|
|
12
|
-
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
13
12
|
actionKey: string;
|
|
13
|
+
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
14
14
|
}, {
|
|
15
15
|
appKey: string;
|
|
16
|
-
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
17
16
|
actionKey: string;
|
|
17
|
+
actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
|
|
18
18
|
}>;
|
|
19
19
|
export type GetActionOptions = z.infer<typeof GetActionSchema>;
|
|
20
20
|
export type GetActionError = ZapierAuthenticationError | ZapierApiError | ZapierAppNotFoundError | ZapierValidationError | ZapierResourceNotFoundError | ZapierUnknownError;
|