@zapier/zapier-sdk 0.15.0 → 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 +12 -0
- package/README.md +28 -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/api/schemas.d.ts +3 -0
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +1 -0
- package/dist/index.cjs +386 -106
- package/dist/index.d.mts +290 -33
- package/dist/index.mjs +386 -106
- package/dist/plugins/getApp/index.test.js +17 -21
- package/dist/plugins/getInputFieldsSchema/index.d.ts +22 -0
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -0
- package/dist/plugins/getInputFieldsSchema/index.js +51 -0
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts +2 -0
- package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +1 -0
- package/dist/plugins/getInputFieldsSchema/index.test.js +288 -0
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +31 -0
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -0
- package/dist/plugins/getInputFieldsSchema/schemas.js +13 -0
- 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/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +2 -0
- package/dist/plugins/listInputFields/schemas.d.ts +4 -4
- package/dist/plugins/runAction/schemas.d.ts +4 -4
- package/dist/sdk.d.ts +8 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +2 -0
- 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 +18 -0
- package/dist/temporary-internal-core/index.d.ts.map +1 -0
- package/dist/temporary-internal-core/index.js +18 -0
- 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/dist/types/sdk.d.ts +2 -1
- package/dist/types/sdk.d.ts.map +1 -1
- 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(),
|
|
@@ -978,7 +1068,8 @@ zod.z.object({
|
|
|
978
1068
|
success: zod.z.boolean(),
|
|
979
1069
|
needs: zod.z.array(NeedSchema).optional(),
|
|
980
1070
|
errors: zod.z.array(zod.z.string()).optional(),
|
|
981
|
-
last_fetched_at: zod.z.string().optional()
|
|
1071
|
+
last_fetched_at: zod.z.string().optional(),
|
|
1072
|
+
schema: zod.z.record(zod.z.unknown()).optional()
|
|
982
1073
|
});
|
|
983
1074
|
var ImplementationSchema = zod.z.object({
|
|
984
1075
|
selected_api: zod.z.string(),
|
|
@@ -1006,7 +1097,7 @@ zod.z.object({
|
|
|
1006
1097
|
previous: zod.z.string().nullable().optional(),
|
|
1007
1098
|
results: zod.z.array(ImplementationSchema)
|
|
1008
1099
|
});
|
|
1009
|
-
var
|
|
1100
|
+
var ImplementationMetaSchema2 = zod.z.object({
|
|
1010
1101
|
id: zod.z.string(),
|
|
1011
1102
|
// e.g. "100HiresCLIAPI@1.2.1"
|
|
1012
1103
|
name: zod.z.string(),
|
|
@@ -1065,7 +1156,7 @@ zod.z.object({
|
|
|
1065
1156
|
count: zod.z.number(),
|
|
1066
1157
|
next: zod.z.string().nullable().optional(),
|
|
1067
1158
|
previous: zod.z.string().nullable().optional(),
|
|
1068
|
-
results: zod.z.array(
|
|
1159
|
+
results: zod.z.array(ImplementationMetaSchema2)
|
|
1069
1160
|
});
|
|
1070
1161
|
var NeedChoicesResponseMetaSchema = zod.z.object({
|
|
1071
1162
|
page: zod.z.string().nullable().optional()
|
|
@@ -1117,8 +1208,8 @@ function toSnakeCase(input) {
|
|
|
1117
1208
|
}
|
|
1118
1209
|
|
|
1119
1210
|
// src/schemas/App.ts
|
|
1120
|
-
var
|
|
1121
|
-
|
|
1211
|
+
var AppItemSchema2 = withFormatter(
|
|
1212
|
+
ImplementationMetaSchema2.omit({ name: true, id: true }).extend({
|
|
1122
1213
|
title: zod.z.string(),
|
|
1123
1214
|
// Mapped from name
|
|
1124
1215
|
key: zod.z.string(),
|
|
@@ -1147,6 +1238,62 @@ var AppItemSchema = withFormatter(
|
|
|
1147
1238
|
}
|
|
1148
1239
|
);
|
|
1149
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
|
+
|
|
1150
1297
|
// src/utils/domain-utils.ts
|
|
1151
1298
|
function splitVersionedKey(versionedKey) {
|
|
1152
1299
|
const parts = versionedKey.split("@");
|
|
@@ -1266,102 +1413,6 @@ function toAppLocator(appKey) {
|
|
|
1266
1413
|
function isResolvedAppLocator(appLocator) {
|
|
1267
1414
|
return !!appLocator.implementationName;
|
|
1268
1415
|
}
|
|
1269
|
-
function toImplementationId(appLocator) {
|
|
1270
|
-
return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
// src/plugins/listApps/index.ts
|
|
1274
|
-
var listAppsPlugin = ({ context }) => {
|
|
1275
|
-
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
1276
|
-
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1277
|
-
const appKeys = options.appKeys ?? [];
|
|
1278
|
-
const appLocators = await resolveAppKeys2({
|
|
1279
|
-
appKeys: [...appKeys]
|
|
1280
|
-
});
|
|
1281
|
-
const implementationNameToLocator = {};
|
|
1282
|
-
for (const locator of appLocators) {
|
|
1283
|
-
implementationNameToLocator[locator.implementationName] = [
|
|
1284
|
-
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
1285
|
-
locator
|
|
1286
|
-
];
|
|
1287
|
-
}
|
|
1288
|
-
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
1289
|
-
if (duplicatedLookupAppKeys.length > 0) {
|
|
1290
|
-
throw new Error(
|
|
1291
|
-
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
1292
|
-
);
|
|
1293
|
-
}
|
|
1294
|
-
if (options.search) {
|
|
1295
|
-
const searchParams2 = {};
|
|
1296
|
-
searchParams2.term = options.search;
|
|
1297
|
-
const searchEnvelope = await api.get(
|
|
1298
|
-
"/zapier/api/v4/implementations-meta/search/",
|
|
1299
|
-
{
|
|
1300
|
-
searchParams: searchParams2
|
|
1301
|
-
}
|
|
1302
|
-
);
|
|
1303
|
-
const implementations = searchEnvelope.results.map(
|
|
1304
|
-
normalizeImplementationMetaToAppItem
|
|
1305
|
-
);
|
|
1306
|
-
const implementationNameSet = new Set(
|
|
1307
|
-
appLocators.map((locator) => locator.implementationName)
|
|
1308
|
-
);
|
|
1309
|
-
for (const implementation of implementations) {
|
|
1310
|
-
const [implementationName] = splitVersionedKey(implementation.key);
|
|
1311
|
-
if (!implementationNameSet.has(implementationName)) {
|
|
1312
|
-
implementationNameSet.add(implementationName);
|
|
1313
|
-
appLocators.push({
|
|
1314
|
-
...toAppLocator(implementation.key),
|
|
1315
|
-
implementationName
|
|
1316
|
-
});
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
const searchParams = {};
|
|
1321
|
-
if (options.pageSize) {
|
|
1322
|
-
searchParams.limit = options.pageSize.toString();
|
|
1323
|
-
}
|
|
1324
|
-
if (appLocators.length === 0) {
|
|
1325
|
-
searchParams.latest_only = "true";
|
|
1326
|
-
}
|
|
1327
|
-
if (options.cursor) {
|
|
1328
|
-
searchParams.offset = options.cursor;
|
|
1329
|
-
}
|
|
1330
|
-
searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
|
|
1331
|
-
if (appKeys.length > 0 && appLocators.length === 0) {
|
|
1332
|
-
return {
|
|
1333
|
-
data: [],
|
|
1334
|
-
nextCursor: void 0
|
|
1335
|
-
};
|
|
1336
|
-
}
|
|
1337
|
-
const implementationsEnvelope = await api.get(
|
|
1338
|
-
"/zapier/api/v4/implementations-meta/lookup/",
|
|
1339
|
-
{
|
|
1340
|
-
searchParams
|
|
1341
|
-
}
|
|
1342
|
-
);
|
|
1343
|
-
return {
|
|
1344
|
-
data: implementationsEnvelope.results.map(
|
|
1345
|
-
normalizeImplementationMetaToAppItem
|
|
1346
|
-
),
|
|
1347
|
-
nextCursor: extractCursor(implementationsEnvelope)
|
|
1348
|
-
};
|
|
1349
|
-
}, ListAppsSchema);
|
|
1350
|
-
return {
|
|
1351
|
-
listApps,
|
|
1352
|
-
context: {
|
|
1353
|
-
meta: {
|
|
1354
|
-
listApps: {
|
|
1355
|
-
categories: ["app"],
|
|
1356
|
-
type: "list",
|
|
1357
|
-
itemType: "App",
|
|
1358
|
-
inputSchema: ListAppsSchema,
|
|
1359
|
-
outputSchema: AppItemSchema
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
};
|
|
1364
|
-
};
|
|
1365
1416
|
var ListActionsSchema = zod.z.object({
|
|
1366
1417
|
appKey: AppKeyPropertySchema.describe(
|
|
1367
1418
|
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
@@ -2204,7 +2255,7 @@ var getAppPlugin = ({ sdk }) => {
|
|
|
2204
2255
|
type: "item",
|
|
2205
2256
|
itemType: "App",
|
|
2206
2257
|
inputSchema: GetAppSchema,
|
|
2207
|
-
outputSchema:
|
|
2258
|
+
outputSchema: AppItemSchema2,
|
|
2208
2259
|
resolvers: {
|
|
2209
2260
|
appKey: appKeyResolver
|
|
2210
2261
|
}
|
|
@@ -3386,6 +3437,135 @@ function getTrackingBaseUrl({
|
|
|
3386
3437
|
return ZAPIER_BASE_URL;
|
|
3387
3438
|
}
|
|
3388
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
|
+
|
|
3389
3569
|
// src/api/client.ts
|
|
3390
3570
|
var pathConfig = {
|
|
3391
3571
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
@@ -3397,6 +3577,9 @@ var pathConfig = {
|
|
|
3397
3577
|
"/zapier": {
|
|
3398
3578
|
authHeader: "Authorization",
|
|
3399
3579
|
pathPrefix: "/api/v0/sdk/zapier"
|
|
3580
|
+
},
|
|
3581
|
+
"/api/v0/apps": {
|
|
3582
|
+
handlerOverride: handleListApps
|
|
3400
3583
|
}
|
|
3401
3584
|
};
|
|
3402
3585
|
var ZapierApiClient = class {
|
|
@@ -3554,6 +3737,14 @@ var ZapierApiClient = class {
|
|
|
3554
3737
|
}
|
|
3555
3738
|
return void 0;
|
|
3556
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
|
+
}
|
|
3557
3748
|
// Helper to parse API error response
|
|
3558
3749
|
parseErrorResponse(errorInfo) {
|
|
3559
3750
|
const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
|
|
@@ -3625,7 +3816,7 @@ var ZapierApiClient = class {
|
|
|
3625
3816
|
const headers = new Headers(options.headers ?? {});
|
|
3626
3817
|
const authToken = await this.getAuthToken();
|
|
3627
3818
|
if (authToken) {
|
|
3628
|
-
const authHeaderName = pathConfig2
|
|
3819
|
+
const authHeaderName = this.isStandardPathConfig(pathConfig2) && pathConfig2.authHeader ? pathConfig2.authHeader : "Authorization";
|
|
3629
3820
|
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
3630
3821
|
}
|
|
3631
3822
|
if (options.authRequired) {
|
|
@@ -3639,6 +3830,16 @@ var ZapierApiClient = class {
|
|
|
3639
3830
|
}
|
|
3640
3831
|
// Helper to perform HTTP requests with JSON handling
|
|
3641
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
|
+
}
|
|
3642
3843
|
const headers = { ...options.headers };
|
|
3643
3844
|
if (data && typeof data === "object") {
|
|
3644
3845
|
headers["Content-Type"] = "application/json";
|
|
@@ -3919,6 +4120,85 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
3919
4120
|
getRegistry
|
|
3920
4121
|
};
|
|
3921
4122
|
};
|
|
4123
|
+
var GetInputFieldsSchemaSchema = zod.z.object({
|
|
4124
|
+
appKey: AppKeyPropertySchema.describe(
|
|
4125
|
+
"App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"
|
|
4126
|
+
),
|
|
4127
|
+
actionType: ActionTypePropertySchema.describe(
|
|
4128
|
+
"Action type that matches the action's defined type"
|
|
4129
|
+
),
|
|
4130
|
+
actionKey: ActionKeyPropertySchema.describe(
|
|
4131
|
+
"Action key to get the input schema for"
|
|
4132
|
+
),
|
|
4133
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional().describe(
|
|
4134
|
+
"Authentication ID to use when fetching the schema. Required if the action needs authentication to determine available fields."
|
|
4135
|
+
),
|
|
4136
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
4137
|
+
"Current input values that may affect the schema (e.g., when fields depend on other field values)"
|
|
4138
|
+
)
|
|
4139
|
+
}).describe(
|
|
4140
|
+
"Get the JSON Schema representation of input fields for an action. Returns a JSON Schema object describing the structure, types, and validation rules for the action's input parameters."
|
|
4141
|
+
);
|
|
4142
|
+
|
|
4143
|
+
// src/plugins/getInputFieldsSchema/index.ts
|
|
4144
|
+
var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
4145
|
+
const getInputFieldsSchema = createFunction(
|
|
4146
|
+
async function getInputFieldsSchema2(options) {
|
|
4147
|
+
const { api, getVersionedImplementationId } = context;
|
|
4148
|
+
const {
|
|
4149
|
+
appKey,
|
|
4150
|
+
actionKey,
|
|
4151
|
+
actionType,
|
|
4152
|
+
authenticationId = null,
|
|
4153
|
+
inputs
|
|
4154
|
+
} = options;
|
|
4155
|
+
const selectedApi = await getVersionedImplementationId(appKey);
|
|
4156
|
+
if (!selectedApi) {
|
|
4157
|
+
throw new ZapierConfigurationError(
|
|
4158
|
+
"No current_implementation_id found for app",
|
|
4159
|
+
{ configType: "current_implementation_id" }
|
|
4160
|
+
);
|
|
4161
|
+
}
|
|
4162
|
+
const { data: action } = await sdk.getAction({
|
|
4163
|
+
appKey,
|
|
4164
|
+
actionType,
|
|
4165
|
+
actionKey
|
|
4166
|
+
});
|
|
4167
|
+
const needsData = await fetchImplementationNeeds({
|
|
4168
|
+
api,
|
|
4169
|
+
selectedApi,
|
|
4170
|
+
action: action.key,
|
|
4171
|
+
actionType,
|
|
4172
|
+
authenticationId,
|
|
4173
|
+
inputs
|
|
4174
|
+
});
|
|
4175
|
+
return {
|
|
4176
|
+
data: needsData.schema || {}
|
|
4177
|
+
};
|
|
4178
|
+
},
|
|
4179
|
+
GetInputFieldsSchemaSchema
|
|
4180
|
+
);
|
|
4181
|
+
return {
|
|
4182
|
+
getInputFieldsSchema,
|
|
4183
|
+
context: {
|
|
4184
|
+
meta: {
|
|
4185
|
+
getInputFieldsSchema: {
|
|
4186
|
+
categories: ["action"],
|
|
4187
|
+
type: "item",
|
|
4188
|
+
itemType: "InputSchema",
|
|
4189
|
+
inputSchema: GetInputFieldsSchemaSchema,
|
|
4190
|
+
resolvers: {
|
|
4191
|
+
appKey: appKeyResolver,
|
|
4192
|
+
actionType: actionTypeResolver,
|
|
4193
|
+
actionKey: actionKeyResolver,
|
|
4194
|
+
authenticationId: authenticationIdResolver,
|
|
4195
|
+
inputs: inputsAllOptionalResolver
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
};
|
|
4201
|
+
};
|
|
3922
4202
|
var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
|
|
3923
4203
|
format: (item) => {
|
|
3924
4204
|
const title = item.label || item.key || "Choice";
|
|
@@ -4222,7 +4502,7 @@ function getCpuTime() {
|
|
|
4222
4502
|
|
|
4223
4503
|
// package.json
|
|
4224
4504
|
var package_default = {
|
|
4225
|
-
version: "0.15.
|
|
4505
|
+
version: "0.15.2"};
|
|
4226
4506
|
|
|
4227
4507
|
// src/plugins/eventEmission/builders.ts
|
|
4228
4508
|
function createBaseEvent(context = {}) {
|
|
@@ -4538,7 +4818,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
|
|
|
4538
4818
|
};
|
|
4539
4819
|
}
|
|
4540
4820
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
4541
|
-
return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(requestPlugin).addPlugin(fetchPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
|
|
4821
|
+
return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(requestPlugin).addPlugin(fetchPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
|
|
4542
4822
|
}
|
|
4543
4823
|
function createZapierSdk(options = {}) {
|
|
4544
4824
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|