@zapier/zapier-sdk 0.15.1 → 0.15.2
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/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 +304 -104
- package/dist/index.d.mts +243 -31
- package/dist/index.mjs +304 -104
- package/dist/plugins/getApp/index.test.js +17 -21
- package/dist/plugins/listActions/schemas.d.ts +4 -4
- 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/schemas.d.ts +4 -4
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +4 -4
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/sdk.d.ts +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.cjs
CHANGED
|
@@ -710,7 +710,69 @@ function createPaginatedFunction(coreFn, schema) {
|
|
|
710
710
|
};
|
|
711
711
|
return namedFunctions[functionName];
|
|
712
712
|
}
|
|
713
|
-
var
|
|
713
|
+
var ImplementationMetaSchema = zod.z.object({
|
|
714
|
+
id: zod.z.string(),
|
|
715
|
+
name: zod.z.string(),
|
|
716
|
+
slug: zod.z.string(),
|
|
717
|
+
age_in_days: zod.z.number().optional(),
|
|
718
|
+
auth_type: zod.z.string().optional(),
|
|
719
|
+
banner: zod.z.string().optional(),
|
|
720
|
+
categories: zod.z.array(
|
|
721
|
+
zod.z.object({
|
|
722
|
+
id: zod.z.number(),
|
|
723
|
+
name: zod.z.string(),
|
|
724
|
+
slug: zod.z.string()
|
|
725
|
+
})
|
|
726
|
+
).optional(),
|
|
727
|
+
images: zod.z.object({
|
|
728
|
+
url_16x16: zod.z.string().optional(),
|
|
729
|
+
url_32x32: zod.z.string().optional(),
|
|
730
|
+
url_64x64: zod.z.string().optional(),
|
|
731
|
+
url_128x128: zod.z.string().optional()
|
|
732
|
+
}).optional(),
|
|
733
|
+
popularity: zod.z.number().optional(),
|
|
734
|
+
has_filters: zod.z.boolean().optional(),
|
|
735
|
+
has_reads: zod.z.boolean().optional(),
|
|
736
|
+
has_searches: zod.z.boolean().optional(),
|
|
737
|
+
has_searches_or_writes: zod.z.boolean().optional(),
|
|
738
|
+
has_upfront_fields: zod.z.boolean().optional(),
|
|
739
|
+
has_writes: zod.z.boolean().optional(),
|
|
740
|
+
is_beta: zod.z.boolean().optional(),
|
|
741
|
+
is_built_in: zod.z.boolean().optional(),
|
|
742
|
+
is_deprecated: zod.z.boolean().optional(),
|
|
743
|
+
is_featured: zod.z.boolean().optional(),
|
|
744
|
+
is_hidden: zod.z.boolean().optional(),
|
|
745
|
+
is_invite: zod.z.boolean().optional(),
|
|
746
|
+
is_premium: zod.z.boolean().optional(),
|
|
747
|
+
is_public: zod.z.boolean().optional(),
|
|
748
|
+
is_upcoming: zod.z.boolean().optional(),
|
|
749
|
+
version: zod.z.string().optional(),
|
|
750
|
+
visibility: zod.z.string().optional(),
|
|
751
|
+
actions: zod.z.object({
|
|
752
|
+
read: zod.z.number().optional(),
|
|
753
|
+
read_bulk: zod.z.number().optional(),
|
|
754
|
+
write: zod.z.number().optional(),
|
|
755
|
+
search: zod.z.number().optional(),
|
|
756
|
+
search_or_write: zod.z.number().optional(),
|
|
757
|
+
search_and_write: zod.z.number().optional(),
|
|
758
|
+
filter: zod.z.number().optional()
|
|
759
|
+
}).optional(),
|
|
760
|
+
description: zod.z.string().optional(),
|
|
761
|
+
primary_color: zod.z.string().optional(),
|
|
762
|
+
secondary_color: zod.z.string().optional(),
|
|
763
|
+
classification: zod.z.string().optional(),
|
|
764
|
+
api_docs_url: zod.z.string().optional(),
|
|
765
|
+
image: zod.z.string().optional()
|
|
766
|
+
});
|
|
767
|
+
zod.z.object({
|
|
768
|
+
count: zod.z.number(),
|
|
769
|
+
next: zod.z.string().nullable().optional(),
|
|
770
|
+
previous: zod.z.string().nullable().optional(),
|
|
771
|
+
results: zod.z.array(ImplementationMetaSchema)
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
// src/temporary-internal-core/schemas/apps/index.ts
|
|
775
|
+
var ListAppsOptionsSchema = zod.z.object({
|
|
714
776
|
appKeys: zod.z.array(zod.z.string()).optional().describe(
|
|
715
777
|
"Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
716
778
|
),
|
|
@@ -719,6 +781,34 @@ var ListAppsSchema = zod.z.object({
|
|
|
719
781
|
maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
|
|
720
782
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
721
783
|
}).describe("List all available apps with optional filtering");
|
|
784
|
+
var AppItemSchema = ImplementationMetaSchema.omit({
|
|
785
|
+
name: true,
|
|
786
|
+
id: true
|
|
787
|
+
}).extend({
|
|
788
|
+
title: zod.z.string(),
|
|
789
|
+
key: zod.z.string(),
|
|
790
|
+
implementation_id: zod.z.string(),
|
|
791
|
+
version: zod.z.string().optional()
|
|
792
|
+
});
|
|
793
|
+
zod.z.object({
|
|
794
|
+
data: zod.z.array(AppItemSchema),
|
|
795
|
+
nextCursor: zod.z.string().optional()
|
|
796
|
+
});
|
|
797
|
+
var ListAppsHandlerRequestSchema = zod.z.object({
|
|
798
|
+
implementationIds: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).optional().describe(
|
|
799
|
+
"Pre-resolved implementation IDs - array or comma-separated string"
|
|
800
|
+
),
|
|
801
|
+
search: zod.z.string().optional().describe("Optional search term to augment results"),
|
|
802
|
+
pageSize: zod.z.union([zod.z.string(), zod.z.number()]).optional().describe("Number of apps per page"),
|
|
803
|
+
cursor: zod.z.string().optional().describe("Pagination cursor")
|
|
804
|
+
}).transform((data) => ({
|
|
805
|
+
// Normalize implementationIds to array
|
|
806
|
+
implementationIds: typeof data.implementationIds === "string" ? data.implementationIds === "" ? [] : data.implementationIds.split(",") : data.implementationIds ?? [],
|
|
807
|
+
search: data.search,
|
|
808
|
+
// Normalize pageSize to number
|
|
809
|
+
pageSize: typeof data.pageSize === "string" ? parseInt(data.pageSize, 10) : data.pageSize,
|
|
810
|
+
cursor: data.cursor
|
|
811
|
+
}));
|
|
722
812
|
var NeedChoicesSchema = zod.z.object({
|
|
723
813
|
key: zod.z.string().optional(),
|
|
724
814
|
label: zod.z.string().optional(),
|
|
@@ -1007,7 +1097,7 @@ zod.z.object({
|
|
|
1007
1097
|
previous: zod.z.string().nullable().optional(),
|
|
1008
1098
|
results: zod.z.array(ImplementationSchema)
|
|
1009
1099
|
});
|
|
1010
|
-
var
|
|
1100
|
+
var ImplementationMetaSchema2 = zod.z.object({
|
|
1011
1101
|
id: zod.z.string(),
|
|
1012
1102
|
// e.g. "100HiresCLIAPI@1.2.1"
|
|
1013
1103
|
name: zod.z.string(),
|
|
@@ -1066,7 +1156,7 @@ zod.z.object({
|
|
|
1066
1156
|
count: zod.z.number(),
|
|
1067
1157
|
next: zod.z.string().nullable().optional(),
|
|
1068
1158
|
previous: zod.z.string().nullable().optional(),
|
|
1069
|
-
results: zod.z.array(
|
|
1159
|
+
results: zod.z.array(ImplementationMetaSchema2)
|
|
1070
1160
|
});
|
|
1071
1161
|
var NeedChoicesResponseMetaSchema = zod.z.object({
|
|
1072
1162
|
page: zod.z.string().nullable().optional()
|
|
@@ -1118,8 +1208,8 @@ function toSnakeCase(input) {
|
|
|
1118
1208
|
}
|
|
1119
1209
|
|
|
1120
1210
|
// src/schemas/App.ts
|
|
1121
|
-
var
|
|
1122
|
-
|
|
1211
|
+
var AppItemSchema2 = withFormatter(
|
|
1212
|
+
ImplementationMetaSchema2.omit({ name: true, id: true }).extend({
|
|
1123
1213
|
title: zod.z.string(),
|
|
1124
1214
|
// Mapped from name
|
|
1125
1215
|
key: zod.z.string(),
|
|
@@ -1148,6 +1238,62 @@ var AppItemSchema = withFormatter(
|
|
|
1148
1238
|
}
|
|
1149
1239
|
);
|
|
1150
1240
|
|
|
1241
|
+
// src/plugins/listApps/index.ts
|
|
1242
|
+
var listAppsPlugin = ({ context }) => {
|
|
1243
|
+
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
1244
|
+
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1245
|
+
const appKeys = options.appKeys ?? [];
|
|
1246
|
+
const appLocators = await resolveAppKeys2({
|
|
1247
|
+
appKeys: [...appKeys]
|
|
1248
|
+
});
|
|
1249
|
+
const implementationNameToLocator = {};
|
|
1250
|
+
for (const locator of appLocators) {
|
|
1251
|
+
implementationNameToLocator[locator.implementationName] = [
|
|
1252
|
+
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
1253
|
+
locator
|
|
1254
|
+
];
|
|
1255
|
+
}
|
|
1256
|
+
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
1257
|
+
if (duplicatedLookupAppKeys.length > 0) {
|
|
1258
|
+
throw new Error(
|
|
1259
|
+
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1262
|
+
if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
|
|
1263
|
+
return {
|
|
1264
|
+
data: [],
|
|
1265
|
+
nextCursor: void 0
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
const implementationIds = appLocators.map((locator) => {
|
|
1269
|
+
const version = locator.version || "latest";
|
|
1270
|
+
return `${locator.implementationName}@${version}`;
|
|
1271
|
+
});
|
|
1272
|
+
return await api.get("/api/v0/apps", {
|
|
1273
|
+
searchParams: {
|
|
1274
|
+
implementationIds: implementationIds.join(","),
|
|
1275
|
+
...options.search && { search: options.search },
|
|
1276
|
+
pageSize: options.pageSize.toString(),
|
|
1277
|
+
...options.cursor && { cursor: options.cursor }
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
}, ListAppsOptionsSchema);
|
|
1281
|
+
return {
|
|
1282
|
+
listApps,
|
|
1283
|
+
context: {
|
|
1284
|
+
meta: {
|
|
1285
|
+
listApps: {
|
|
1286
|
+
categories: ["app"],
|
|
1287
|
+
type: "list",
|
|
1288
|
+
itemType: "App",
|
|
1289
|
+
inputSchema: ListAppsOptionsSchema,
|
|
1290
|
+
outputSchema: AppItemSchema2
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1151
1297
|
// src/utils/domain-utils.ts
|
|
1152
1298
|
function splitVersionedKey(versionedKey) {
|
|
1153
1299
|
const parts = versionedKey.split("@");
|
|
@@ -1267,102 +1413,6 @@ function toAppLocator(appKey) {
|
|
|
1267
1413
|
function isResolvedAppLocator(appLocator) {
|
|
1268
1414
|
return !!appLocator.implementationName;
|
|
1269
1415
|
}
|
|
1270
|
-
function toImplementationId(appLocator) {
|
|
1271
|
-
return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
// src/plugins/listApps/index.ts
|
|
1275
|
-
var listAppsPlugin = ({ context }) => {
|
|
1276
|
-
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
1277
|
-
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1278
|
-
const appKeys = options.appKeys ?? [];
|
|
1279
|
-
const appLocators = await resolveAppKeys2({
|
|
1280
|
-
appKeys: [...appKeys]
|
|
1281
|
-
});
|
|
1282
|
-
const implementationNameToLocator = {};
|
|
1283
|
-
for (const locator of appLocators) {
|
|
1284
|
-
implementationNameToLocator[locator.implementationName] = [
|
|
1285
|
-
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
1286
|
-
locator
|
|
1287
|
-
];
|
|
1288
|
-
}
|
|
1289
|
-
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
1290
|
-
if (duplicatedLookupAppKeys.length > 0) {
|
|
1291
|
-
throw new Error(
|
|
1292
|
-
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
1293
|
-
);
|
|
1294
|
-
}
|
|
1295
|
-
if (options.search) {
|
|
1296
|
-
const searchParams2 = {};
|
|
1297
|
-
searchParams2.term = options.search;
|
|
1298
|
-
const searchEnvelope = await api.get(
|
|
1299
|
-
"/zapier/api/v4/implementations-meta/search/",
|
|
1300
|
-
{
|
|
1301
|
-
searchParams: searchParams2
|
|
1302
|
-
}
|
|
1303
|
-
);
|
|
1304
|
-
const implementations = searchEnvelope.results.map(
|
|
1305
|
-
normalizeImplementationMetaToAppItem
|
|
1306
|
-
);
|
|
1307
|
-
const implementationNameSet = new Set(
|
|
1308
|
-
appLocators.map((locator) => locator.implementationName)
|
|
1309
|
-
);
|
|
1310
|
-
for (const implementation of implementations) {
|
|
1311
|
-
const [implementationName] = splitVersionedKey(implementation.key);
|
|
1312
|
-
if (!implementationNameSet.has(implementationName)) {
|
|
1313
|
-
implementationNameSet.add(implementationName);
|
|
1314
|
-
appLocators.push({
|
|
1315
|
-
...toAppLocator(implementation.key),
|
|
1316
|
-
implementationName
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
const searchParams = {};
|
|
1322
|
-
if (options.pageSize) {
|
|
1323
|
-
searchParams.limit = options.pageSize.toString();
|
|
1324
|
-
}
|
|
1325
|
-
if (appLocators.length === 0) {
|
|
1326
|
-
searchParams.latest_only = "true";
|
|
1327
|
-
}
|
|
1328
|
-
if (options.cursor) {
|
|
1329
|
-
searchParams.offset = options.cursor;
|
|
1330
|
-
}
|
|
1331
|
-
searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
|
|
1332
|
-
if (appKeys.length > 0 && appLocators.length === 0) {
|
|
1333
|
-
return {
|
|
1334
|
-
data: [],
|
|
1335
|
-
nextCursor: void 0
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1338
|
-
const implementationsEnvelope = await api.get(
|
|
1339
|
-
"/zapier/api/v4/implementations-meta/lookup/",
|
|
1340
|
-
{
|
|
1341
|
-
searchParams
|
|
1342
|
-
}
|
|
1343
|
-
);
|
|
1344
|
-
return {
|
|
1345
|
-
data: implementationsEnvelope.results.map(
|
|
1346
|
-
normalizeImplementationMetaToAppItem
|
|
1347
|
-
),
|
|
1348
|
-
nextCursor: extractCursor(implementationsEnvelope)
|
|
1349
|
-
};
|
|
1350
|
-
}, ListAppsSchema);
|
|
1351
|
-
return {
|
|
1352
|
-
listApps,
|
|
1353
|
-
context: {
|
|
1354
|
-
meta: {
|
|
1355
|
-
listApps: {
|
|
1356
|
-
categories: ["app"],
|
|
1357
|
-
type: "list",
|
|
1358
|
-
itemType: "App",
|
|
1359
|
-
inputSchema: ListAppsSchema,
|
|
1360
|
-
outputSchema: AppItemSchema
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
};
|
|
1365
|
-
};
|
|
1366
1416
|
var ListActionsSchema = zod.z.object({
|
|
1367
1417
|
appKey: AppKeyPropertySchema.describe(
|
|
1368
1418
|
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
@@ -2205,7 +2255,7 @@ var getAppPlugin = ({ sdk }) => {
|
|
|
2205
2255
|
type: "item",
|
|
2206
2256
|
itemType: "App",
|
|
2207
2257
|
inputSchema: GetAppSchema,
|
|
2208
|
-
outputSchema:
|
|
2258
|
+
outputSchema: AppItemSchema2,
|
|
2209
2259
|
resolvers: {
|
|
2210
2260
|
appKey: appKeyResolver
|
|
2211
2261
|
}
|
|
@@ -3387,6 +3437,135 @@ function getTrackingBaseUrl({
|
|
|
3387
3437
|
return ZAPIER_BASE_URL;
|
|
3388
3438
|
}
|
|
3389
3439
|
|
|
3440
|
+
// src/temporary-internal-core/utils/app-locators.ts
|
|
3441
|
+
function splitVersionedKey2(versionedKey) {
|
|
3442
|
+
const parts = versionedKey.split("@");
|
|
3443
|
+
if (parts.length >= 2) {
|
|
3444
|
+
const baseKey = parts[0];
|
|
3445
|
+
const version = parts.slice(1).join("@");
|
|
3446
|
+
return [baseKey, version];
|
|
3447
|
+
}
|
|
3448
|
+
return [versionedKey, void 0];
|
|
3449
|
+
}
|
|
3450
|
+
|
|
3451
|
+
// src/temporary-internal-core/utils/transformations.ts
|
|
3452
|
+
function transformImplementationMetaToAppItem(implementationMeta) {
|
|
3453
|
+
const [selectedApi, appVersion] = splitVersionedKey2(implementationMeta.id);
|
|
3454
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
3455
|
+
return {
|
|
3456
|
+
...restOfImplementationMeta,
|
|
3457
|
+
title: name,
|
|
3458
|
+
key: selectedApi,
|
|
3459
|
+
implementation_id: id,
|
|
3460
|
+
version: appVersion
|
|
3461
|
+
};
|
|
3462
|
+
}
|
|
3463
|
+
function extractPaginationCursor(response) {
|
|
3464
|
+
if (!response.next) {
|
|
3465
|
+
return void 0;
|
|
3466
|
+
}
|
|
3467
|
+
try {
|
|
3468
|
+
const url = new URL(response.next);
|
|
3469
|
+
const offset = url.searchParams.get("offset");
|
|
3470
|
+
return offset || void 0;
|
|
3471
|
+
} catch {
|
|
3472
|
+
return void 0;
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
|
|
3476
|
+
// src/temporary-internal-core/handlers/listApps.ts
|
|
3477
|
+
var DEFAULT_PAGE_SIZE = 20;
|
|
3478
|
+
async function augmentWithSearchResults({
|
|
3479
|
+
searchTerm,
|
|
3480
|
+
implementationIds,
|
|
3481
|
+
httpClient
|
|
3482
|
+
}) {
|
|
3483
|
+
const searchResponse = await httpClient.get(
|
|
3484
|
+
"/zapier/api/v4/implementations-meta/search/",
|
|
3485
|
+
{
|
|
3486
|
+
searchParams: { term: searchTerm }
|
|
3487
|
+
}
|
|
3488
|
+
);
|
|
3489
|
+
const searchResults = searchResponse.results.map(
|
|
3490
|
+
transformImplementationMetaToAppItem
|
|
3491
|
+
);
|
|
3492
|
+
const implementationNameSet = new Set(
|
|
3493
|
+
implementationIds.map((id) => {
|
|
3494
|
+
const [name] = splitVersionedKey2(id);
|
|
3495
|
+
return name;
|
|
3496
|
+
})
|
|
3497
|
+
);
|
|
3498
|
+
const additionalIds = [];
|
|
3499
|
+
for (const result of searchResults) {
|
|
3500
|
+
const [implementationName] = splitVersionedKey2(result.key);
|
|
3501
|
+
if (!implementationNameSet.has(implementationName)) {
|
|
3502
|
+
implementationNameSet.add(implementationName);
|
|
3503
|
+
additionalIds.push(result.implementation_id);
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
return [...implementationIds, ...additionalIds];
|
|
3507
|
+
}
|
|
3508
|
+
var handleListApps = async ({ request, deps }) => {
|
|
3509
|
+
const validatedRequest = ListAppsHandlerRequestSchema.parse(request);
|
|
3510
|
+
const { httpClient } = deps;
|
|
3511
|
+
let { implementationIds } = validatedRequest;
|
|
3512
|
+
const pageSize = validatedRequest.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
3513
|
+
if (validatedRequest.search) {
|
|
3514
|
+
implementationIds = await augmentWithSearchResults({
|
|
3515
|
+
searchTerm: validatedRequest.search,
|
|
3516
|
+
implementationIds,
|
|
3517
|
+
httpClient
|
|
3518
|
+
});
|
|
3519
|
+
}
|
|
3520
|
+
if (implementationIds.length === 0) {
|
|
3521
|
+
if (validatedRequest.search) {
|
|
3522
|
+
return {
|
|
3523
|
+
data: [],
|
|
3524
|
+
nextCursor: void 0
|
|
3525
|
+
};
|
|
3526
|
+
}
|
|
3527
|
+
const searchParams2 = {
|
|
3528
|
+
latest_only: "true",
|
|
3529
|
+
selected_apis: "",
|
|
3530
|
+
limit: pageSize.toString()
|
|
3531
|
+
};
|
|
3532
|
+
if (validatedRequest.cursor) {
|
|
3533
|
+
searchParams2.offset = validatedRequest.cursor;
|
|
3534
|
+
}
|
|
3535
|
+
const implementationsResponse2 = await httpClient.get(
|
|
3536
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
3537
|
+
{
|
|
3538
|
+
searchParams: searchParams2
|
|
3539
|
+
}
|
|
3540
|
+
);
|
|
3541
|
+
return {
|
|
3542
|
+
data: implementationsResponse2.results.map(
|
|
3543
|
+
transformImplementationMetaToAppItem
|
|
3544
|
+
),
|
|
3545
|
+
nextCursor: extractPaginationCursor(implementationsResponse2)
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
3548
|
+
const searchParams = {
|
|
3549
|
+
selected_apis: implementationIds.join(","),
|
|
3550
|
+
limit: pageSize.toString()
|
|
3551
|
+
};
|
|
3552
|
+
if (validatedRequest.cursor) {
|
|
3553
|
+
searchParams.offset = validatedRequest.cursor;
|
|
3554
|
+
}
|
|
3555
|
+
const implementationsResponse = await httpClient.get(
|
|
3556
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
3557
|
+
{
|
|
3558
|
+
searchParams
|
|
3559
|
+
}
|
|
3560
|
+
);
|
|
3561
|
+
return {
|
|
3562
|
+
data: implementationsResponse.results.map(
|
|
3563
|
+
transformImplementationMetaToAppItem
|
|
3564
|
+
),
|
|
3565
|
+
nextCursor: extractPaginationCursor(implementationsResponse)
|
|
3566
|
+
};
|
|
3567
|
+
};
|
|
3568
|
+
|
|
3390
3569
|
// src/api/client.ts
|
|
3391
3570
|
var pathConfig = {
|
|
3392
3571
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
@@ -3398,6 +3577,9 @@ var pathConfig = {
|
|
|
3398
3577
|
"/zapier": {
|
|
3399
3578
|
authHeader: "Authorization",
|
|
3400
3579
|
pathPrefix: "/api/v0/sdk/zapier"
|
|
3580
|
+
},
|
|
3581
|
+
"/api/v0/apps": {
|
|
3582
|
+
handlerOverride: handleListApps
|
|
3401
3583
|
}
|
|
3402
3584
|
};
|
|
3403
3585
|
var ZapierApiClient = class {
|
|
@@ -3555,6 +3737,14 @@ var ZapierApiClient = class {
|
|
|
3555
3737
|
}
|
|
3556
3738
|
return void 0;
|
|
3557
3739
|
}
|
|
3740
|
+
// Helper to check if a path config has a handler override
|
|
3741
|
+
hasHandlerOverride(pathConfig2) {
|
|
3742
|
+
return pathConfig2 !== void 0 && "handlerOverride" in pathConfig2 && typeof pathConfig2.handlerOverride === "function";
|
|
3743
|
+
}
|
|
3744
|
+
// Helper to check if a path config is a standard path config
|
|
3745
|
+
isStandardPathConfig(pathConfig2) {
|
|
3746
|
+
return pathConfig2 !== void 0 && !this.hasHandlerOverride(pathConfig2);
|
|
3747
|
+
}
|
|
3558
3748
|
// Helper to parse API error response
|
|
3559
3749
|
parseErrorResponse(errorInfo) {
|
|
3560
3750
|
const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
|
|
@@ -3626,7 +3816,7 @@ var ZapierApiClient = class {
|
|
|
3626
3816
|
const headers = new Headers(options.headers ?? {});
|
|
3627
3817
|
const authToken = await this.getAuthToken();
|
|
3628
3818
|
if (authToken) {
|
|
3629
|
-
const authHeaderName = pathConfig2
|
|
3819
|
+
const authHeaderName = this.isStandardPathConfig(pathConfig2) && pathConfig2.authHeader ? pathConfig2.authHeader : "Authorization";
|
|
3630
3820
|
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
3631
3821
|
}
|
|
3632
3822
|
if (options.authRequired) {
|
|
@@ -3640,6 +3830,16 @@ var ZapierApiClient = class {
|
|
|
3640
3830
|
}
|
|
3641
3831
|
// Helper to perform HTTP requests with JSON handling
|
|
3642
3832
|
async fetchJson(method, path, data, options = {}) {
|
|
3833
|
+
const { pathConfig: pathConfig2 } = this.buildUrl(path, options.searchParams);
|
|
3834
|
+
if (this.hasHandlerOverride(pathConfig2)) {
|
|
3835
|
+
const handlerRequest = method === "GET" ? options.searchParams : data;
|
|
3836
|
+
return pathConfig2.handlerOverride({
|
|
3837
|
+
request: handlerRequest,
|
|
3838
|
+
deps: {
|
|
3839
|
+
httpClient: this
|
|
3840
|
+
}
|
|
3841
|
+
});
|
|
3842
|
+
}
|
|
3643
3843
|
const headers = { ...options.headers };
|
|
3644
3844
|
if (data && typeof data === "object") {
|
|
3645
3845
|
headers["Content-Type"] = "application/json";
|
|
@@ -4302,7 +4502,7 @@ function getCpuTime() {
|
|
|
4302
4502
|
|
|
4303
4503
|
// package.json
|
|
4304
4504
|
var package_default = {
|
|
4305
|
-
version: "0.15.
|
|
4505
|
+
version: "0.15.2"};
|
|
4306
4506
|
|
|
4307
4507
|
// src/plugins/eventEmission/builders.ts
|
|
4308
4508
|
function createBaseEvent(context = {}) {
|