@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.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(),
|
|
@@ -956,7 +1046,8 @@ z.object({
|
|
|
956
1046
|
success: z.boolean(),
|
|
957
1047
|
needs: z.array(NeedSchema).optional(),
|
|
958
1048
|
errors: z.array(z.string()).optional(),
|
|
959
|
-
last_fetched_at: z.string().optional()
|
|
1049
|
+
last_fetched_at: z.string().optional(),
|
|
1050
|
+
schema: z.record(z.unknown()).optional()
|
|
960
1051
|
});
|
|
961
1052
|
var ImplementationSchema = z.object({
|
|
962
1053
|
selected_api: z.string(),
|
|
@@ -984,7 +1075,7 @@ z.object({
|
|
|
984
1075
|
previous: z.string().nullable().optional(),
|
|
985
1076
|
results: z.array(ImplementationSchema)
|
|
986
1077
|
});
|
|
987
|
-
var
|
|
1078
|
+
var ImplementationMetaSchema2 = z.object({
|
|
988
1079
|
id: z.string(),
|
|
989
1080
|
// e.g. "100HiresCLIAPI@1.2.1"
|
|
990
1081
|
name: z.string(),
|
|
@@ -1043,7 +1134,7 @@ z.object({
|
|
|
1043
1134
|
count: z.number(),
|
|
1044
1135
|
next: z.string().nullable().optional(),
|
|
1045
1136
|
previous: z.string().nullable().optional(),
|
|
1046
|
-
results: z.array(
|
|
1137
|
+
results: z.array(ImplementationMetaSchema2)
|
|
1047
1138
|
});
|
|
1048
1139
|
var NeedChoicesResponseMetaSchema = z.object({
|
|
1049
1140
|
page: z.string().nullable().optional()
|
|
@@ -1095,8 +1186,8 @@ function toSnakeCase(input) {
|
|
|
1095
1186
|
}
|
|
1096
1187
|
|
|
1097
1188
|
// src/schemas/App.ts
|
|
1098
|
-
var
|
|
1099
|
-
|
|
1189
|
+
var AppItemSchema2 = withFormatter(
|
|
1190
|
+
ImplementationMetaSchema2.omit({ name: true, id: true }).extend({
|
|
1100
1191
|
title: z.string(),
|
|
1101
1192
|
// Mapped from name
|
|
1102
1193
|
key: z.string(),
|
|
@@ -1125,6 +1216,62 @@ var AppItemSchema = withFormatter(
|
|
|
1125
1216
|
}
|
|
1126
1217
|
);
|
|
1127
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
|
+
|
|
1128
1275
|
// src/utils/domain-utils.ts
|
|
1129
1276
|
function splitVersionedKey(versionedKey) {
|
|
1130
1277
|
const parts = versionedKey.split("@");
|
|
@@ -1244,102 +1391,6 @@ function toAppLocator(appKey) {
|
|
|
1244
1391
|
function isResolvedAppLocator(appLocator) {
|
|
1245
1392
|
return !!appLocator.implementationName;
|
|
1246
1393
|
}
|
|
1247
|
-
function toImplementationId(appLocator) {
|
|
1248
|
-
return `${appLocator.implementationName}@${appLocator.version || "latest"}`;
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
// src/plugins/listApps/index.ts
|
|
1252
|
-
var listAppsPlugin = ({ context }) => {
|
|
1253
|
-
const listApps = createPaginatedFunction(async function listAppsPage(options) {
|
|
1254
|
-
const { api, resolveAppKeys: resolveAppKeys2 } = context;
|
|
1255
|
-
const appKeys = options.appKeys ?? [];
|
|
1256
|
-
const appLocators = await resolveAppKeys2({
|
|
1257
|
-
appKeys: [...appKeys]
|
|
1258
|
-
});
|
|
1259
|
-
const implementationNameToLocator = {};
|
|
1260
|
-
for (const locator of appLocators) {
|
|
1261
|
-
implementationNameToLocator[locator.implementationName] = [
|
|
1262
|
-
...implementationNameToLocator[locator.implementationName] ?? [],
|
|
1263
|
-
locator
|
|
1264
|
-
];
|
|
1265
|
-
}
|
|
1266
|
-
const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
|
|
1267
|
-
if (duplicatedLookupAppKeys.length > 0) {
|
|
1268
|
-
throw new Error(
|
|
1269
|
-
`Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
|
|
1270
|
-
);
|
|
1271
|
-
}
|
|
1272
|
-
if (options.search) {
|
|
1273
|
-
const searchParams2 = {};
|
|
1274
|
-
searchParams2.term = options.search;
|
|
1275
|
-
const searchEnvelope = await api.get(
|
|
1276
|
-
"/zapier/api/v4/implementations-meta/search/",
|
|
1277
|
-
{
|
|
1278
|
-
searchParams: searchParams2
|
|
1279
|
-
}
|
|
1280
|
-
);
|
|
1281
|
-
const implementations = searchEnvelope.results.map(
|
|
1282
|
-
normalizeImplementationMetaToAppItem
|
|
1283
|
-
);
|
|
1284
|
-
const implementationNameSet = new Set(
|
|
1285
|
-
appLocators.map((locator) => locator.implementationName)
|
|
1286
|
-
);
|
|
1287
|
-
for (const implementation of implementations) {
|
|
1288
|
-
const [implementationName] = splitVersionedKey(implementation.key);
|
|
1289
|
-
if (!implementationNameSet.has(implementationName)) {
|
|
1290
|
-
implementationNameSet.add(implementationName);
|
|
1291
|
-
appLocators.push({
|
|
1292
|
-
...toAppLocator(implementation.key),
|
|
1293
|
-
implementationName
|
|
1294
|
-
});
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
const searchParams = {};
|
|
1299
|
-
if (options.pageSize) {
|
|
1300
|
-
searchParams.limit = options.pageSize.toString();
|
|
1301
|
-
}
|
|
1302
|
-
if (appLocators.length === 0) {
|
|
1303
|
-
searchParams.latest_only = "true";
|
|
1304
|
-
}
|
|
1305
|
-
if (options.cursor) {
|
|
1306
|
-
searchParams.offset = options.cursor;
|
|
1307
|
-
}
|
|
1308
|
-
searchParams.selected_apis = appLocators.map((locator) => toImplementationId(locator)).join(",");
|
|
1309
|
-
if (appKeys.length > 0 && appLocators.length === 0) {
|
|
1310
|
-
return {
|
|
1311
|
-
data: [],
|
|
1312
|
-
nextCursor: void 0
|
|
1313
|
-
};
|
|
1314
|
-
}
|
|
1315
|
-
const implementationsEnvelope = await api.get(
|
|
1316
|
-
"/zapier/api/v4/implementations-meta/lookup/",
|
|
1317
|
-
{
|
|
1318
|
-
searchParams
|
|
1319
|
-
}
|
|
1320
|
-
);
|
|
1321
|
-
return {
|
|
1322
|
-
data: implementationsEnvelope.results.map(
|
|
1323
|
-
normalizeImplementationMetaToAppItem
|
|
1324
|
-
),
|
|
1325
|
-
nextCursor: extractCursor(implementationsEnvelope)
|
|
1326
|
-
};
|
|
1327
|
-
}, ListAppsSchema);
|
|
1328
|
-
return {
|
|
1329
|
-
listApps,
|
|
1330
|
-
context: {
|
|
1331
|
-
meta: {
|
|
1332
|
-
listApps: {
|
|
1333
|
-
categories: ["app"],
|
|
1334
|
-
type: "list",
|
|
1335
|
-
itemType: "App",
|
|
1336
|
-
inputSchema: ListAppsSchema,
|
|
1337
|
-
outputSchema: AppItemSchema
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
};
|
|
1343
1394
|
var ListActionsSchema = z.object({
|
|
1344
1395
|
appKey: AppKeyPropertySchema.describe(
|
|
1345
1396
|
"App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
|
|
@@ -2182,7 +2233,7 @@ var getAppPlugin = ({ sdk }) => {
|
|
|
2182
2233
|
type: "item",
|
|
2183
2234
|
itemType: "App",
|
|
2184
2235
|
inputSchema: GetAppSchema,
|
|
2185
|
-
outputSchema:
|
|
2236
|
+
outputSchema: AppItemSchema2,
|
|
2186
2237
|
resolvers: {
|
|
2187
2238
|
appKey: appKeyResolver
|
|
2188
2239
|
}
|
|
@@ -3364,6 +3415,135 @@ function getTrackingBaseUrl({
|
|
|
3364
3415
|
return ZAPIER_BASE_URL;
|
|
3365
3416
|
}
|
|
3366
3417
|
|
|
3418
|
+
// src/temporary-internal-core/utils/app-locators.ts
|
|
3419
|
+
function splitVersionedKey2(versionedKey) {
|
|
3420
|
+
const parts = versionedKey.split("@");
|
|
3421
|
+
if (parts.length >= 2) {
|
|
3422
|
+
const baseKey = parts[0];
|
|
3423
|
+
const version = parts.slice(1).join("@");
|
|
3424
|
+
return [baseKey, version];
|
|
3425
|
+
}
|
|
3426
|
+
return [versionedKey, void 0];
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3429
|
+
// src/temporary-internal-core/utils/transformations.ts
|
|
3430
|
+
function transformImplementationMetaToAppItem(implementationMeta) {
|
|
3431
|
+
const [selectedApi, appVersion] = splitVersionedKey2(implementationMeta.id);
|
|
3432
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
3433
|
+
return {
|
|
3434
|
+
...restOfImplementationMeta,
|
|
3435
|
+
title: name,
|
|
3436
|
+
key: selectedApi,
|
|
3437
|
+
implementation_id: id,
|
|
3438
|
+
version: appVersion
|
|
3439
|
+
};
|
|
3440
|
+
}
|
|
3441
|
+
function extractPaginationCursor(response) {
|
|
3442
|
+
if (!response.next) {
|
|
3443
|
+
return void 0;
|
|
3444
|
+
}
|
|
3445
|
+
try {
|
|
3446
|
+
const url = new URL(response.next);
|
|
3447
|
+
const offset = url.searchParams.get("offset");
|
|
3448
|
+
return offset || void 0;
|
|
3449
|
+
} catch {
|
|
3450
|
+
return void 0;
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
|
|
3454
|
+
// src/temporary-internal-core/handlers/listApps.ts
|
|
3455
|
+
var DEFAULT_PAGE_SIZE = 20;
|
|
3456
|
+
async function augmentWithSearchResults({
|
|
3457
|
+
searchTerm,
|
|
3458
|
+
implementationIds,
|
|
3459
|
+
httpClient
|
|
3460
|
+
}) {
|
|
3461
|
+
const searchResponse = await httpClient.get(
|
|
3462
|
+
"/zapier/api/v4/implementations-meta/search/",
|
|
3463
|
+
{
|
|
3464
|
+
searchParams: { term: searchTerm }
|
|
3465
|
+
}
|
|
3466
|
+
);
|
|
3467
|
+
const searchResults = searchResponse.results.map(
|
|
3468
|
+
transformImplementationMetaToAppItem
|
|
3469
|
+
);
|
|
3470
|
+
const implementationNameSet = new Set(
|
|
3471
|
+
implementationIds.map((id) => {
|
|
3472
|
+
const [name] = splitVersionedKey2(id);
|
|
3473
|
+
return name;
|
|
3474
|
+
})
|
|
3475
|
+
);
|
|
3476
|
+
const additionalIds = [];
|
|
3477
|
+
for (const result of searchResults) {
|
|
3478
|
+
const [implementationName] = splitVersionedKey2(result.key);
|
|
3479
|
+
if (!implementationNameSet.has(implementationName)) {
|
|
3480
|
+
implementationNameSet.add(implementationName);
|
|
3481
|
+
additionalIds.push(result.implementation_id);
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
return [...implementationIds, ...additionalIds];
|
|
3485
|
+
}
|
|
3486
|
+
var handleListApps = async ({ request, deps }) => {
|
|
3487
|
+
const validatedRequest = ListAppsHandlerRequestSchema.parse(request);
|
|
3488
|
+
const { httpClient } = deps;
|
|
3489
|
+
let { implementationIds } = validatedRequest;
|
|
3490
|
+
const pageSize = validatedRequest.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
3491
|
+
if (validatedRequest.search) {
|
|
3492
|
+
implementationIds = await augmentWithSearchResults({
|
|
3493
|
+
searchTerm: validatedRequest.search,
|
|
3494
|
+
implementationIds,
|
|
3495
|
+
httpClient
|
|
3496
|
+
});
|
|
3497
|
+
}
|
|
3498
|
+
if (implementationIds.length === 0) {
|
|
3499
|
+
if (validatedRequest.search) {
|
|
3500
|
+
return {
|
|
3501
|
+
data: [],
|
|
3502
|
+
nextCursor: void 0
|
|
3503
|
+
};
|
|
3504
|
+
}
|
|
3505
|
+
const searchParams2 = {
|
|
3506
|
+
latest_only: "true",
|
|
3507
|
+
selected_apis: "",
|
|
3508
|
+
limit: pageSize.toString()
|
|
3509
|
+
};
|
|
3510
|
+
if (validatedRequest.cursor) {
|
|
3511
|
+
searchParams2.offset = validatedRequest.cursor;
|
|
3512
|
+
}
|
|
3513
|
+
const implementationsResponse2 = await httpClient.get(
|
|
3514
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
3515
|
+
{
|
|
3516
|
+
searchParams: searchParams2
|
|
3517
|
+
}
|
|
3518
|
+
);
|
|
3519
|
+
return {
|
|
3520
|
+
data: implementationsResponse2.results.map(
|
|
3521
|
+
transformImplementationMetaToAppItem
|
|
3522
|
+
),
|
|
3523
|
+
nextCursor: extractPaginationCursor(implementationsResponse2)
|
|
3524
|
+
};
|
|
3525
|
+
}
|
|
3526
|
+
const searchParams = {
|
|
3527
|
+
selected_apis: implementationIds.join(","),
|
|
3528
|
+
limit: pageSize.toString()
|
|
3529
|
+
};
|
|
3530
|
+
if (validatedRequest.cursor) {
|
|
3531
|
+
searchParams.offset = validatedRequest.cursor;
|
|
3532
|
+
}
|
|
3533
|
+
const implementationsResponse = await httpClient.get(
|
|
3534
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
3535
|
+
{
|
|
3536
|
+
searchParams
|
|
3537
|
+
}
|
|
3538
|
+
);
|
|
3539
|
+
return {
|
|
3540
|
+
data: implementationsResponse.results.map(
|
|
3541
|
+
transformImplementationMetaToAppItem
|
|
3542
|
+
),
|
|
3543
|
+
nextCursor: extractPaginationCursor(implementationsResponse)
|
|
3544
|
+
};
|
|
3545
|
+
};
|
|
3546
|
+
|
|
3367
3547
|
// src/api/client.ts
|
|
3368
3548
|
var pathConfig = {
|
|
3369
3549
|
// e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
|
|
@@ -3375,6 +3555,9 @@ var pathConfig = {
|
|
|
3375
3555
|
"/zapier": {
|
|
3376
3556
|
authHeader: "Authorization",
|
|
3377
3557
|
pathPrefix: "/api/v0/sdk/zapier"
|
|
3558
|
+
},
|
|
3559
|
+
"/api/v0/apps": {
|
|
3560
|
+
handlerOverride: handleListApps
|
|
3378
3561
|
}
|
|
3379
3562
|
};
|
|
3380
3563
|
var ZapierApiClient = class {
|
|
@@ -3532,6 +3715,14 @@ var ZapierApiClient = class {
|
|
|
3532
3715
|
}
|
|
3533
3716
|
return void 0;
|
|
3534
3717
|
}
|
|
3718
|
+
// Helper to check if a path config has a handler override
|
|
3719
|
+
hasHandlerOverride(pathConfig2) {
|
|
3720
|
+
return pathConfig2 !== void 0 && "handlerOverride" in pathConfig2 && typeof pathConfig2.handlerOverride === "function";
|
|
3721
|
+
}
|
|
3722
|
+
// Helper to check if a path config is a standard path config
|
|
3723
|
+
isStandardPathConfig(pathConfig2) {
|
|
3724
|
+
return pathConfig2 !== void 0 && !this.hasHandlerOverride(pathConfig2);
|
|
3725
|
+
}
|
|
3535
3726
|
// Helper to parse API error response
|
|
3536
3727
|
parseErrorResponse(errorInfo) {
|
|
3537
3728
|
const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
|
|
@@ -3603,7 +3794,7 @@ var ZapierApiClient = class {
|
|
|
3603
3794
|
const headers = new Headers(options.headers ?? {});
|
|
3604
3795
|
const authToken = await this.getAuthToken();
|
|
3605
3796
|
if (authToken) {
|
|
3606
|
-
const authHeaderName = pathConfig2
|
|
3797
|
+
const authHeaderName = this.isStandardPathConfig(pathConfig2) && pathConfig2.authHeader ? pathConfig2.authHeader : "Authorization";
|
|
3607
3798
|
headers.set(authHeaderName, getAuthorizationHeader(authToken));
|
|
3608
3799
|
}
|
|
3609
3800
|
if (options.authRequired) {
|
|
@@ -3617,6 +3808,16 @@ var ZapierApiClient = class {
|
|
|
3617
3808
|
}
|
|
3618
3809
|
// Helper to perform HTTP requests with JSON handling
|
|
3619
3810
|
async fetchJson(method, path, data, options = {}) {
|
|
3811
|
+
const { pathConfig: pathConfig2 } = this.buildUrl(path, options.searchParams);
|
|
3812
|
+
if (this.hasHandlerOverride(pathConfig2)) {
|
|
3813
|
+
const handlerRequest = method === "GET" ? options.searchParams : data;
|
|
3814
|
+
return pathConfig2.handlerOverride({
|
|
3815
|
+
request: handlerRequest,
|
|
3816
|
+
deps: {
|
|
3817
|
+
httpClient: this
|
|
3818
|
+
}
|
|
3819
|
+
});
|
|
3820
|
+
}
|
|
3620
3821
|
const headers = { ...options.headers };
|
|
3621
3822
|
if (data && typeof data === "object") {
|
|
3622
3823
|
headers["Content-Type"] = "application/json";
|
|
@@ -3897,6 +4098,85 @@ var registryPlugin = ({ sdk, context }) => {
|
|
|
3897
4098
|
getRegistry
|
|
3898
4099
|
};
|
|
3899
4100
|
};
|
|
4101
|
+
var GetInputFieldsSchemaSchema = z.object({
|
|
4102
|
+
appKey: AppKeyPropertySchema.describe(
|
|
4103
|
+
"App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"
|
|
4104
|
+
),
|
|
4105
|
+
actionType: ActionTypePropertySchema.describe(
|
|
4106
|
+
"Action type that matches the action's defined type"
|
|
4107
|
+
),
|
|
4108
|
+
actionKey: ActionKeyPropertySchema.describe(
|
|
4109
|
+
"Action key to get the input schema for"
|
|
4110
|
+
),
|
|
4111
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional().describe(
|
|
4112
|
+
"Authentication ID to use when fetching the schema. Required if the action needs authentication to determine available fields."
|
|
4113
|
+
),
|
|
4114
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
4115
|
+
"Current input values that may affect the schema (e.g., when fields depend on other field values)"
|
|
4116
|
+
)
|
|
4117
|
+
}).describe(
|
|
4118
|
+
"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."
|
|
4119
|
+
);
|
|
4120
|
+
|
|
4121
|
+
// src/plugins/getInputFieldsSchema/index.ts
|
|
4122
|
+
var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
4123
|
+
const getInputFieldsSchema = createFunction(
|
|
4124
|
+
async function getInputFieldsSchema2(options) {
|
|
4125
|
+
const { api, getVersionedImplementationId } = context;
|
|
4126
|
+
const {
|
|
4127
|
+
appKey,
|
|
4128
|
+
actionKey,
|
|
4129
|
+
actionType,
|
|
4130
|
+
authenticationId = null,
|
|
4131
|
+
inputs
|
|
4132
|
+
} = options;
|
|
4133
|
+
const selectedApi = await getVersionedImplementationId(appKey);
|
|
4134
|
+
if (!selectedApi) {
|
|
4135
|
+
throw new ZapierConfigurationError(
|
|
4136
|
+
"No current_implementation_id found for app",
|
|
4137
|
+
{ configType: "current_implementation_id" }
|
|
4138
|
+
);
|
|
4139
|
+
}
|
|
4140
|
+
const { data: action } = await sdk.getAction({
|
|
4141
|
+
appKey,
|
|
4142
|
+
actionType,
|
|
4143
|
+
actionKey
|
|
4144
|
+
});
|
|
4145
|
+
const needsData = await fetchImplementationNeeds({
|
|
4146
|
+
api,
|
|
4147
|
+
selectedApi,
|
|
4148
|
+
action: action.key,
|
|
4149
|
+
actionType,
|
|
4150
|
+
authenticationId,
|
|
4151
|
+
inputs
|
|
4152
|
+
});
|
|
4153
|
+
return {
|
|
4154
|
+
data: needsData.schema || {}
|
|
4155
|
+
};
|
|
4156
|
+
},
|
|
4157
|
+
GetInputFieldsSchemaSchema
|
|
4158
|
+
);
|
|
4159
|
+
return {
|
|
4160
|
+
getInputFieldsSchema,
|
|
4161
|
+
context: {
|
|
4162
|
+
meta: {
|
|
4163
|
+
getInputFieldsSchema: {
|
|
4164
|
+
categories: ["action"],
|
|
4165
|
+
type: "item",
|
|
4166
|
+
itemType: "InputSchema",
|
|
4167
|
+
inputSchema: GetInputFieldsSchemaSchema,
|
|
4168
|
+
resolvers: {
|
|
4169
|
+
appKey: appKeyResolver,
|
|
4170
|
+
actionType: actionTypeResolver,
|
|
4171
|
+
actionKey: actionKeyResolver,
|
|
4172
|
+
authenticationId: authenticationIdResolver,
|
|
4173
|
+
inputs: inputsAllOptionalResolver
|
|
4174
|
+
}
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
};
|
|
4179
|
+
};
|
|
3900
4180
|
var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
|
|
3901
4181
|
format: (item) => {
|
|
3902
4182
|
const title = item.label || item.key || "Choice";
|
|
@@ -4200,7 +4480,7 @@ function getCpuTime() {
|
|
|
4200
4480
|
|
|
4201
4481
|
// package.json
|
|
4202
4482
|
var package_default = {
|
|
4203
|
-
version: "0.15.
|
|
4483
|
+
version: "0.15.2"};
|
|
4204
4484
|
|
|
4205
4485
|
// src/plugins/eventEmission/builders.ts
|
|
4206
4486
|
function createBaseEvent(context = {}) {
|
|
@@ -4516,7 +4796,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
|
|
|
4516
4796
|
};
|
|
4517
4797
|
}
|
|
4518
4798
|
function createZapierSdkWithoutRegistry(options = {}) {
|
|
4519
|
-
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);
|
|
4799
|
+
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);
|
|
4520
4800
|
}
|
|
4521
4801
|
function createZapierSdk(options = {}) {
|
|
4522
4802
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|