@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.
Files changed (65) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api/client.integration.test.d.ts +5 -0
  4. package/dist/api/client.integration.test.d.ts.map +1 -0
  5. package/dist/api/client.integration.test.js +318 -0
  6. package/dist/api/client.js +31 -1
  7. package/dist/index.cjs +401 -108
  8. package/dist/index.d.mts +360 -56
  9. package/dist/index.mjs +401 -108
  10. package/dist/plugins/fetch/schemas.d.ts +2 -2
  11. package/dist/plugins/getAction/schemas.d.ts +2 -2
  12. package/dist/plugins/getApp/index.test.js +17 -21
  13. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +2 -2
  14. package/dist/plugins/listActions/index.test.js +25 -0
  15. package/dist/plugins/listActions/schemas.d.ts +6 -6
  16. package/dist/plugins/listApps/index.d.ts +1 -3
  17. package/dist/plugins/listApps/index.d.ts.map +1 -1
  18. package/dist/plugins/listApps/index.js +18 -44
  19. package/dist/plugins/listApps/index.test.js +89 -288
  20. package/dist/plugins/listApps/schemas.d.ts +19 -26
  21. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  22. package/dist/plugins/listApps/schemas.js +19 -18
  23. package/dist/plugins/listAuthentications/index.test.js +20 -0
  24. package/dist/plugins/listAuthentications/schemas.d.ts +4 -4
  25. package/dist/plugins/listInputFieldChoices/schemas.d.ts +8 -8
  26. package/dist/plugins/listInputFields/schemas.d.ts +8 -8
  27. package/dist/plugins/manifest/index.d.ts +42 -3
  28. package/dist/plugins/manifest/index.d.ts.map +1 -1
  29. package/dist/plugins/manifest/index.js +68 -1
  30. package/dist/plugins/manifest/index.test.js +513 -1
  31. package/dist/plugins/manifest/schemas.d.ts +75 -2
  32. package/dist/plugins/manifest/schemas.d.ts.map +1 -1
  33. package/dist/plugins/manifest/schemas.js +27 -3
  34. package/dist/plugins/request/schemas.d.ts +4 -4
  35. package/dist/plugins/runAction/schemas.d.ts +8 -8
  36. package/dist/sdk.d.ts +24 -2
  37. package/dist/sdk.d.ts.map +1 -1
  38. package/dist/temporary-internal-core/handlers/listApps.d.ts +67 -0
  39. package/dist/temporary-internal-core/handlers/listApps.d.ts.map +1 -0
  40. package/dist/temporary-internal-core/handlers/listApps.js +121 -0
  41. package/dist/temporary-internal-core/handlers/listApps.test.d.ts +2 -0
  42. package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +1 -0
  43. package/dist/temporary-internal-core/handlers/listApps.test.js +328 -0
  44. package/dist/temporary-internal-core/index.d.ts +4 -0
  45. package/dist/temporary-internal-core/index.d.ts.map +1 -1
  46. package/dist/temporary-internal-core/index.js +5 -1
  47. package/dist/temporary-internal-core/schemas/apps/index.d.ts +582 -0
  48. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +1 -0
  49. package/dist/temporary-internal-core/schemas/apps/index.js +95 -0
  50. package/dist/temporary-internal-core/schemas/implementations/index.d.ts +511 -0
  51. package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +1 -0
  52. package/dist/temporary-internal-core/schemas/implementations/index.js +79 -0
  53. package/dist/temporary-internal-core/types/handler.d.ts +51 -0
  54. package/dist/temporary-internal-core/types/handler.d.ts.map +1 -0
  55. package/dist/temporary-internal-core/types/handler.js +8 -0
  56. package/dist/temporary-internal-core/types/index.d.ts +5 -0
  57. package/dist/temporary-internal-core/types/index.d.ts.map +1 -0
  58. package/dist/temporary-internal-core/types/index.js +4 -0
  59. package/dist/temporary-internal-core/utils/app-locators.d.ts +54 -0
  60. package/dist/temporary-internal-core/utils/app-locators.d.ts.map +1 -0
  61. package/dist/temporary-internal-core/utils/app-locators.js +83 -0
  62. package/dist/temporary-internal-core/utils/transformations.d.ts +18 -0
  63. package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -0
  64. package/dist/temporary-internal-core/utils/transformations.js +36 -0
  65. 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 ListAppsSchema = zod.z.object({
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 ImplementationMetaSchema = zod.z.object({
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(ImplementationMetaSchema)
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 AppItemSchema = withFormatter(
1122
- ImplementationMetaSchema.omit({ name: true, id: true }).extend({
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: AppItemSchema,
2258
+ outputSchema: AppItemSchema2,
2209
2259
  resolvers: {
2210
2260
  appKey: appKeyResolver
2211
2261
  }
@@ -2671,6 +2721,17 @@ async function readFile(filePath) {
2671
2721
  throw new Error(`File not found: ${filePath}`);
2672
2722
  }
2673
2723
  var DEFAULT_CONFIG_PATH = ".zapierrc";
2724
+ var ActionEntrySchema = zod.z.object({
2725
+ appKey: zod.z.string().describe("App key (slug or implementation name)"),
2726
+ actionKey: zod.z.string().describe("Action key identifier"),
2727
+ actionType: zod.z.string().describe("Action type (e.g., 'read', 'write', 'search')"),
2728
+ authenticationId: zod.z.number().nullable().optional().describe("Authentication ID used"),
2729
+ inputs: zod.z.record(zod.z.unknown()).optional().describe("Resolved input values"),
2730
+ schema: zod.z.record(zod.z.unknown()).describe(
2731
+ "Complete JSON Schema from getInputFieldsSchema (includes $schema, type, properties, required, etc.)"
2732
+ ),
2733
+ createdAt: zod.z.string().describe("ISO 8601 timestamp when created")
2734
+ });
2674
2735
  var ManifestSchema = zod.z.object({
2675
2736
  apps: zod.z.record(
2676
2737
  zod.z.string(),
@@ -2680,8 +2741,9 @@ var ManifestSchema = zod.z.object({
2680
2741
  ),
2681
2742
  version: zod.z.string().describe("Version string (e.g., '1.21.1')")
2682
2743
  })
2683
- )
2684
- }).describe("Manifest mapping app keys to version information");
2744
+ ),
2745
+ actions: zod.z.record(zod.z.string(), ActionEntrySchema).optional().describe("Saved action configurations with their schemas")
2746
+ }).describe("Manifest for app version locking and action configurations");
2685
2747
  zod.z.object({
2686
2748
  manifestPath: zod.z.string().optional().describe("Path to manifest file"),
2687
2749
  manifest: zod.z.record(
@@ -2952,7 +3014,81 @@ var manifestPlugin = (params) => {
2952
3014
  await writeManifestToFile(updatedManifest, configPath);
2953
3015
  resolvedManifest = void 0;
2954
3016
  }
2955
- return [manifestKey, entry, updatedManifest];
3017
+ return {
3018
+ key: manifestKey,
3019
+ entry,
3020
+ manifest: updatedManifest
3021
+ };
3022
+ };
3023
+ const addActionEntry = async (options2) => {
3024
+ const {
3025
+ name,
3026
+ entry,
3027
+ configPath = DEFAULT_CONFIG_PATH,
3028
+ skipWrite = false,
3029
+ manifest: inputManifest
3030
+ } = options2;
3031
+ const manifest2 = inputManifest || await readManifestFromFile(configPath) || { apps: {} };
3032
+ const actions = manifest2.actions || {};
3033
+ if (actions[name] && !skipWrite) {
3034
+ throw new Error(
3035
+ `Action "${name}" already exists. Please choose a different name or remove the existing action first.`
3036
+ );
3037
+ }
3038
+ const updatedManifest = {
3039
+ ...manifest2,
3040
+ actions: {
3041
+ ...actions,
3042
+ [name]: entry
3043
+ }
3044
+ };
3045
+ if (!skipWrite) {
3046
+ await writeManifestToFile(updatedManifest, configPath);
3047
+ resolvedManifest = void 0;
3048
+ }
3049
+ return {
3050
+ name,
3051
+ entry,
3052
+ manifest: updatedManifest
3053
+ };
3054
+ };
3055
+ const findActionEntry = ({
3056
+ name,
3057
+ manifest: manifest2
3058
+ }) => {
3059
+ return manifest2.actions?.[name] || null;
3060
+ };
3061
+ const listActionEntries = async ({
3062
+ configPath = DEFAULT_CONFIG_PATH
3063
+ } = {}) => {
3064
+ const manifest2 = await readManifestFromFile(configPath) || { };
3065
+ return Object.entries(manifest2.actions || {});
3066
+ };
3067
+ const deleteActionEntry = async ({
3068
+ name,
3069
+ configPath = DEFAULT_CONFIG_PATH,
3070
+ skipWrite = false
3071
+ }) => {
3072
+ const manifest2 = await readManifestFromFile(configPath) || { apps: {} };
3073
+ if (!manifest2.actions?.[name]) {
3074
+ throw new Error(`Action "${name}" does not exist.`);
3075
+ }
3076
+ const { [name]: removed, ...remainingActions } = manifest2.actions;
3077
+ const updatedManifest = {
3078
+ ...manifest2,
3079
+ actions: remainingActions
3080
+ };
3081
+ if (!skipWrite) {
3082
+ await writeManifestToFile(updatedManifest, configPath);
3083
+ resolvedManifest = void 0;
3084
+ }
3085
+ return updatedManifest;
3086
+ };
3087
+ const hasActionEntry = ({
3088
+ name,
3089
+ manifest: manifest2
3090
+ }) => {
3091
+ return !!manifest2.actions?.[name];
2956
3092
  };
2957
3093
  return {
2958
3094
  context: {
@@ -2962,7 +3098,14 @@ var manifestPlugin = (params) => {
2962
3098
  api,
2963
3099
  manifest: await getResolvedManifest() ?? { apps: {} }
2964
3100
  }),
2965
- updateManifestEntry
3101
+ updateManifestEntry,
3102
+ addActionEntry,
3103
+ findActionEntry,
3104
+ listActionEntries,
3105
+ deleteActionEntry,
3106
+ hasActionEntry,
3107
+ findManifestEntry,
3108
+ readManifestFromFile
2966
3109
  }
2967
3110
  };
2968
3111
  };
@@ -3387,6 +3530,135 @@ function getTrackingBaseUrl({
3387
3530
  return ZAPIER_BASE_URL;
3388
3531
  }
3389
3532
 
3533
+ // src/temporary-internal-core/utils/app-locators.ts
3534
+ function splitVersionedKey2(versionedKey) {
3535
+ const parts = versionedKey.split("@");
3536
+ if (parts.length >= 2) {
3537
+ const baseKey = parts[0];
3538
+ const version = parts.slice(1).join("@");
3539
+ return [baseKey, version];
3540
+ }
3541
+ return [versionedKey, void 0];
3542
+ }
3543
+
3544
+ // src/temporary-internal-core/utils/transformations.ts
3545
+ function transformImplementationMetaToAppItem(implementationMeta) {
3546
+ const [selectedApi, appVersion] = splitVersionedKey2(implementationMeta.id);
3547
+ const { id, name, ...restOfImplementationMeta } = implementationMeta;
3548
+ return {
3549
+ ...restOfImplementationMeta,
3550
+ title: name,
3551
+ key: selectedApi,
3552
+ implementation_id: id,
3553
+ version: appVersion
3554
+ };
3555
+ }
3556
+ function extractPaginationCursor(response) {
3557
+ if (!response.next) {
3558
+ return void 0;
3559
+ }
3560
+ try {
3561
+ const url = new URL(response.next);
3562
+ const offset = url.searchParams.get("offset");
3563
+ return offset || void 0;
3564
+ } catch {
3565
+ return void 0;
3566
+ }
3567
+ }
3568
+
3569
+ // src/temporary-internal-core/handlers/listApps.ts
3570
+ var DEFAULT_PAGE_SIZE = 20;
3571
+ async function augmentWithSearchResults({
3572
+ searchTerm,
3573
+ implementationIds,
3574
+ httpClient
3575
+ }) {
3576
+ const searchResponse = await httpClient.get(
3577
+ "/zapier/api/v4/implementations-meta/search/",
3578
+ {
3579
+ searchParams: { term: searchTerm }
3580
+ }
3581
+ );
3582
+ const searchResults = searchResponse.results.map(
3583
+ transformImplementationMetaToAppItem
3584
+ );
3585
+ const implementationNameSet = new Set(
3586
+ implementationIds.map((id) => {
3587
+ const [name] = splitVersionedKey2(id);
3588
+ return name;
3589
+ })
3590
+ );
3591
+ const additionalIds = [];
3592
+ for (const result of searchResults) {
3593
+ const [implementationName] = splitVersionedKey2(result.key);
3594
+ if (!implementationNameSet.has(implementationName)) {
3595
+ implementationNameSet.add(implementationName);
3596
+ additionalIds.push(result.implementation_id);
3597
+ }
3598
+ }
3599
+ return [...implementationIds, ...additionalIds];
3600
+ }
3601
+ var handleListApps = async ({ request, deps }) => {
3602
+ const validatedRequest = ListAppsHandlerRequestSchema.parse(request);
3603
+ const { httpClient } = deps;
3604
+ let { implementationIds } = validatedRequest;
3605
+ const pageSize = validatedRequest.pageSize ?? DEFAULT_PAGE_SIZE;
3606
+ if (validatedRequest.search) {
3607
+ implementationIds = await augmentWithSearchResults({
3608
+ searchTerm: validatedRequest.search,
3609
+ implementationIds,
3610
+ httpClient
3611
+ });
3612
+ }
3613
+ if (implementationIds.length === 0) {
3614
+ if (validatedRequest.search) {
3615
+ return {
3616
+ data: [],
3617
+ nextCursor: void 0
3618
+ };
3619
+ }
3620
+ const searchParams2 = {
3621
+ latest_only: "true",
3622
+ selected_apis: "",
3623
+ limit: pageSize.toString()
3624
+ };
3625
+ if (validatedRequest.cursor) {
3626
+ searchParams2.offset = validatedRequest.cursor;
3627
+ }
3628
+ const implementationsResponse2 = await httpClient.get(
3629
+ "/zapier/api/v4/implementations-meta/lookup/",
3630
+ {
3631
+ searchParams: searchParams2
3632
+ }
3633
+ );
3634
+ return {
3635
+ data: implementationsResponse2.results.map(
3636
+ transformImplementationMetaToAppItem
3637
+ ),
3638
+ nextCursor: extractPaginationCursor(implementationsResponse2)
3639
+ };
3640
+ }
3641
+ const searchParams = {
3642
+ selected_apis: implementationIds.join(","),
3643
+ limit: pageSize.toString()
3644
+ };
3645
+ if (validatedRequest.cursor) {
3646
+ searchParams.offset = validatedRequest.cursor;
3647
+ }
3648
+ const implementationsResponse = await httpClient.get(
3649
+ "/zapier/api/v4/implementations-meta/lookup/",
3650
+ {
3651
+ searchParams
3652
+ }
3653
+ );
3654
+ return {
3655
+ data: implementationsResponse.results.map(
3656
+ transformImplementationMetaToAppItem
3657
+ ),
3658
+ nextCursor: extractPaginationCursor(implementationsResponse)
3659
+ };
3660
+ };
3661
+
3390
3662
  // src/api/client.ts
3391
3663
  var pathConfig = {
3392
3664
  // e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
@@ -3398,6 +3670,9 @@ var pathConfig = {
3398
3670
  "/zapier": {
3399
3671
  authHeader: "Authorization",
3400
3672
  pathPrefix: "/api/v0/sdk/zapier"
3673
+ },
3674
+ "/api/v0/apps": {
3675
+ handlerOverride: handleListApps
3401
3676
  }
3402
3677
  };
3403
3678
  var ZapierApiClient = class {
@@ -3555,6 +3830,14 @@ var ZapierApiClient = class {
3555
3830
  }
3556
3831
  return void 0;
3557
3832
  }
3833
+ // Helper to check if a path config has a handler override
3834
+ hasHandlerOverride(pathConfig2) {
3835
+ return pathConfig2 !== void 0 && "handlerOverride" in pathConfig2 && typeof pathConfig2.handlerOverride === "function";
3836
+ }
3837
+ // Helper to check if a path config is a standard path config
3838
+ isStandardPathConfig(pathConfig2) {
3839
+ return pathConfig2 !== void 0 && !this.hasHandlerOverride(pathConfig2);
3840
+ }
3558
3841
  // Helper to parse API error response
3559
3842
  parseErrorResponse(errorInfo) {
3560
3843
  const fallbackMessage = `HTTP ${errorInfo.status}: ${errorInfo.statusText}`;
@@ -3626,7 +3909,7 @@ var ZapierApiClient = class {
3626
3909
  const headers = new Headers(options.headers ?? {});
3627
3910
  const authToken = await this.getAuthToken();
3628
3911
  if (authToken) {
3629
- const authHeaderName = pathConfig2?.authHeader || "Authorization";
3912
+ const authHeaderName = this.isStandardPathConfig(pathConfig2) && pathConfig2.authHeader ? pathConfig2.authHeader : "Authorization";
3630
3913
  headers.set(authHeaderName, getAuthorizationHeader(authToken));
3631
3914
  }
3632
3915
  if (options.authRequired) {
@@ -3640,6 +3923,16 @@ var ZapierApiClient = class {
3640
3923
  }
3641
3924
  // Helper to perform HTTP requests with JSON handling
3642
3925
  async fetchJson(method, path, data, options = {}) {
3926
+ const { pathConfig: pathConfig2 } = this.buildUrl(path, options.searchParams);
3927
+ if (this.hasHandlerOverride(pathConfig2)) {
3928
+ const handlerRequest = method === "GET" ? options.searchParams : data;
3929
+ return pathConfig2.handlerOverride({
3930
+ request: handlerRequest,
3931
+ deps: {
3932
+ httpClient: this
3933
+ }
3934
+ });
3935
+ }
3643
3936
  const headers = { ...options.headers };
3644
3937
  if (data && typeof data === "object") {
3645
3938
  headers["Content-Type"] = "application/json";
@@ -4302,7 +4595,7 @@ function getCpuTime() {
4302
4595
 
4303
4596
  // package.json
4304
4597
  var package_default = {
4305
- version: "0.15.1"};
4598
+ version: "0.15.3"};
4306
4599
 
4307
4600
  // src/plugins/eventEmission/builders.ts
4308
4601
  function createBaseEvent(context = {}) {