@zapier/zapier-sdk 0.18.2 → 0.18.4

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 (85) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +13 -13
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +0 -18
  5. package/dist/api/schemas.d.ts +0 -158
  6. package/dist/api/schemas.d.ts.map +1 -1
  7. package/dist/api/schemas.js +0 -95
  8. package/dist/api/types.d.ts +2 -1
  9. package/dist/api/types.d.ts.map +1 -1
  10. package/dist/index.cjs +400 -808
  11. package/dist/index.d.mts +67 -122
  12. package/dist/index.mjs +401 -809
  13. package/dist/plugins/findFirstAuthentication/index.test.js +2 -2
  14. package/dist/plugins/findUniqueAuthentication/index.test.js +2 -2
  15. package/dist/plugins/listApps/index.d.ts +2 -8
  16. package/dist/plugins/listApps/index.d.ts.map +1 -1
  17. package/dist/plugins/listApps/index.js +4 -6
  18. package/dist/plugins/listApps/index.test.js +62 -82
  19. package/dist/plugins/listApps/schemas.d.ts +35 -14
  20. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  21. package/dist/plugins/listApps/schemas.js +44 -14
  22. package/dist/plugins/listAuthentications/index.d.ts +4 -10
  23. package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
  24. package/dist/plugins/listAuthentications/index.js +19 -31
  25. package/dist/plugins/listAuthentications/index.test.js +363 -127
  26. package/dist/plugins/listAuthentications/schemas.d.ts +7 -7
  27. package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
  28. package/dist/plugins/listAuthentications/schemas.js +10 -16
  29. package/dist/schemas/App.d.ts +28 -28
  30. package/dist/schemas/App.d.ts.map +1 -1
  31. package/dist/schemas/App.js +3 -8
  32. package/dist/sdk.d.ts +2 -2
  33. package/dist/sdk.test.js +12 -9
  34. package/dist/utils/domain-utils.d.ts +2 -15
  35. package/dist/utils/domain-utils.d.ts.map +1 -1
  36. package/dist/utils/domain-utils.js +0 -38
  37. package/dist/utils/function-utils.d.ts +1 -0
  38. package/dist/utils/function-utils.d.ts.map +1 -1
  39. package/dist/utils/function-utils.js +15 -3
  40. package/package.json +2 -2
  41. package/dist/api/client.integration.test.d.ts +0 -5
  42. package/dist/api/client.integration.test.d.ts.map +0 -1
  43. package/dist/api/client.integration.test.js +0 -318
  44. package/dist/api/client.methods.test.d.ts +0 -2
  45. package/dist/api/client.methods.test.d.ts.map +0 -1
  46. package/dist/api/client.methods.test.js +0 -158
  47. package/dist/api/router.d.ts +0 -16
  48. package/dist/api/router.d.ts.map +0 -1
  49. package/dist/api/router.js +0 -31
  50. package/dist/api/router.test.d.ts +0 -2
  51. package/dist/api/router.test.d.ts.map +0 -1
  52. package/dist/api/router.test.js +0 -103
  53. package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
  54. package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
  55. package/dist/temporary-internal-core/handlers/listApps.js +0 -134
  56. package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
  57. package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
  58. package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
  59. package/dist/temporary-internal-core/index.d.ts +0 -18
  60. package/dist/temporary-internal-core/index.d.ts.map +0 -1
  61. package/dist/temporary-internal-core/index.js +0 -18
  62. package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
  63. package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
  64. package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
  65. package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
  66. package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
  67. package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
  68. package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
  69. package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
  70. package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
  71. package/dist/temporary-internal-core/types/handler.d.ts +0 -51
  72. package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
  73. package/dist/temporary-internal-core/types/handler.js +0 -8
  74. package/dist/temporary-internal-core/types/index.d.ts +0 -5
  75. package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
  76. package/dist/temporary-internal-core/types/index.js +0 -4
  77. package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
  78. package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
  79. package/dist/temporary-internal-core/utils/app-locators.js +0 -39
  80. package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
  81. package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
  82. package/dist/temporary-internal-core/utils/string-utils.js +0 -52
  83. package/dist/temporary-internal-core/utils/transformations.d.ts +0 -32
  84. package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
  85. package/dist/temporary-internal-core/utils/transformations.js +0 -74
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { AuthenticationItemSchema as AuthenticationItemSchema$1, GetAuthenticationParamSchema } from '@zapier/zapier-sdk-core/v0/schemas/authentications';
2
+ import { ListAppsQuerySchema, AppItemSchema as AppItemSchema$1 } from '@zapier/zapier-sdk-core/v0/schemas/apps';
3
+ import { ListAuthenticationsQuerySchema as ListAuthenticationsQuerySchema$1, AuthenticationItemSchema as AuthenticationItemSchema$1, GetAuthenticationParamSchema } from '@zapier/zapier-sdk-core/v0/schemas/authentications';
3
4
  import { setTimeout as setTimeout$1 } from 'timers/promises';
4
5
  import * as os from 'os';
5
6
 
@@ -694,10 +695,16 @@ function createPageFunction(coreFn) {
694
695
  try {
695
696
  const result = await coreFn(options);
696
697
  if (result && typeof result === "object" && "data" in result) {
697
- const data = result.data;
698
+ const paginatedResult = result;
699
+ let nextCursor;
700
+ if (paginatedResult.nextCursor) {
701
+ nextCursor = paginatedResult.nextCursor;
702
+ } else if (paginatedResult.links?.next) {
703
+ nextCursor = extractCursor({ next: paginatedResult.links.next });
704
+ }
698
705
  return {
699
- data: Array.isArray(data) ? data : [data],
700
- nextCursor: result.nextCursor
706
+ data: Array.isArray(paginatedResult.data) ? paginatedResult.data : [paginatedResult.data],
707
+ nextCursor
701
708
  };
702
709
  }
703
710
  if (Array.isArray(result)) {
@@ -789,105 +796,230 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
789
796
  };
790
797
  return namedFunctions[functionName];
791
798
  }
792
- var ImplementationMetaSchema = z.object({
793
- id: z.string(),
794
- name: z.string(),
795
- slug: z.string(),
796
- age_in_days: z.number().optional(),
797
- auth_type: z.string().optional(),
798
- banner: z.string().optional(),
799
- categories: z.array(
800
- z.object({
801
- id: z.number(),
802
- name: z.string(),
803
- slug: z.string()
804
- })
805
- ).optional(),
806
- images: z.object({
807
- url_16x16: z.string().optional(),
808
- url_32x32: z.string().optional(),
809
- url_64x64: z.string().optional(),
810
- url_128x128: z.string().optional()
811
- }).optional(),
812
- popularity: z.number().optional(),
813
- has_filters: z.boolean().optional(),
814
- has_reads: z.boolean().optional(),
815
- has_searches: z.boolean().optional(),
816
- has_searches_or_writes: z.boolean().optional(),
817
- has_upfront_fields: z.boolean().optional(),
818
- has_writes: z.boolean().optional(),
819
- is_beta: z.boolean().optional(),
820
- is_built_in: z.boolean().optional(),
821
- is_deprecated: z.boolean().optional(),
822
- is_featured: z.boolean().optional(),
823
- is_hidden: z.boolean().optional(),
824
- is_invite: z.boolean().optional(),
825
- is_premium: z.boolean().optional(),
826
- is_public: z.boolean().optional(),
827
- is_upcoming: z.boolean().optional(),
828
- version: z.string().optional(),
829
- visibility: z.string().optional(),
830
- actions: z.object({
831
- read: z.number().optional(),
832
- read_bulk: z.number().optional(),
833
- write: z.number().optional(),
834
- search: z.number().optional(),
835
- search_or_write: z.number().optional(),
836
- search_and_write: z.number().optional(),
837
- filter: z.number().optional()
838
- }).optional(),
839
- description: z.string().optional(),
840
- primary_color: z.string().optional(),
841
- secondary_color: z.string().optional(),
842
- classification: z.string().optional(),
843
- api_docs_url: z.string().optional(),
844
- image: z.string().optional()
845
- });
846
- z.object({
847
- count: z.number(),
848
- next: z.string().nullable().optional(),
849
- previous: z.string().nullable().optional(),
850
- results: z.array(ImplementationMetaSchema)
851
- });
852
-
853
- // src/temporary-internal-core/schemas/apps/index.ts
854
- var ListAppsOptionsSchema = z.object({
799
+ var ListAppsSchema = ListAppsQuerySchema.omit({
800
+ offset: true
801
+ }).extend({
802
+ // Override appKeys to be an array instead of comma-separated string
855
803
  appKeys: z.array(z.string()).optional().describe(
856
804
  "Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"
857
805
  ),
858
- search: z.string().optional().describe("Search for apps by name"),
806
+ // Override pageSize to make optional (base has default value)
859
807
  pageSize: z.number().min(1).optional().describe("Number of apps per page"),
808
+ // SDK specific property for pagination/iterator helpers
860
809
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
810
+ // SDK specific property for pagination/iterator helpers
861
811
  cursor: z.string().optional().describe("Cursor to start from")
862
812
  }).merge(TelemetryMarkerSchema).describe("List all available apps with optional filtering");
863
- var AppItemSchema = ImplementationMetaSchema.omit({
864
- name: true,
865
- id: true
866
- }).extend({
867
- title: z.string(),
868
- key: z.string(),
869
- implementation_id: z.string(),
870
- version: z.string().optional()
871
- });
872
- z.object({
873
- data: z.array(AppItemSchema),
874
- nextCursor: z.string().optional()
813
+
814
+ // src/utils/string-utils.ts
815
+ function toTitleCase(input) {
816
+ return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
817
+ }
818
+ function toSnakeCase(input) {
819
+ let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
820
+ if (/^[0-9]/.test(result)) {
821
+ result = "_" + result;
822
+ }
823
+ return result;
824
+ }
825
+ function stripPageSuffix(functionName) {
826
+ return functionName.replace(/Page$/, "");
827
+ }
828
+
829
+ // src/schemas/App.ts
830
+ var AppItemSchema = withFormatter(AppItemSchema$1, {
831
+ format: (item) => {
832
+ const additionalKeys = [];
833
+ if (item.slug && item.slug !== item.key) {
834
+ additionalKeys.push(item.slug);
835
+ const snakeCaseSlug = toSnakeCase(item.slug);
836
+ if (snakeCaseSlug !== item.slug && snakeCaseSlug !== item.key) {
837
+ additionalKeys.push(snakeCaseSlug);
838
+ }
839
+ }
840
+ return {
841
+ title: item.title,
842
+ key: item.key,
843
+ keys: [item.key, ...additionalKeys],
844
+ description: item.description,
845
+ details: []
846
+ };
847
+ }
875
848
  });
876
- var ListAppsHandlerRequestSchema = z.object({
877
- implementationIds: z.union([z.string(), z.array(z.string())]).optional().describe(
878
- "Pre-resolved implementation IDs - array or comma-separated string"
849
+
850
+ // src/utils/telemetry-utils.ts
851
+ function createTelemetryCallback(emitMethodCalled, methodName) {
852
+ return {
853
+ onMethodCalled: (data) => {
854
+ emitMethodCalled({
855
+ method_name: methodName,
856
+ execution_duration_ms: data.durationMs,
857
+ success_flag: data.success,
858
+ error_message: data.error?.message ?? null,
859
+ error_type: data.error?.constructor.name ?? null,
860
+ argument_count: data.argumentCount,
861
+ is_paginated: data.isPaginated
862
+ });
863
+ }
864
+ };
865
+ }
866
+
867
+ // src/plugins/listApps/index.ts
868
+ var listAppsPlugin = ({ context }) => {
869
+ async function listAppsPage(options) {
870
+ const { api, resolveAppKeys: resolveAppKeys2 } = context;
871
+ const appKeys = options.appKeys ?? [];
872
+ const appLocators = await resolveAppKeys2({
873
+ appKeys: [...appKeys]
874
+ });
875
+ const implementationNameToLocator = {};
876
+ for (const locator of appLocators) {
877
+ implementationNameToLocator[locator.implementationName] = [
878
+ ...implementationNameToLocator[locator.implementationName] ?? [],
879
+ locator
880
+ ];
881
+ }
882
+ const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
883
+ if (duplicatedLookupAppKeys.length > 0) {
884
+ throw new Error(
885
+ `Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
886
+ );
887
+ }
888
+ if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
889
+ return {
890
+ data: [],
891
+ links: { next: null },
892
+ meta: { count: 0, limit: 0, offset: 0 }
893
+ };
894
+ }
895
+ const implementationIds = appLocators.map((locator) => {
896
+ const version = locator.version || "latest";
897
+ return `${locator.implementationName}@${version}`;
898
+ });
899
+ return await api.get("/api/v0/apps", {
900
+ searchParams: {
901
+ appKeys: implementationIds.join(","),
902
+ ...options.search && { search: options.search },
903
+ pageSize: options.pageSize.toString(),
904
+ ...options.cursor && { offset: options.cursor }
905
+ }
906
+ });
907
+ }
908
+ const methodName = stripPageSuffix(listAppsPage.name);
909
+ const listAppsDefinition = createPaginatedFunction(
910
+ listAppsPage,
911
+ ListAppsSchema,
912
+ createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
913
+ methodName
914
+ );
915
+ return {
916
+ listApps: listAppsDefinition,
917
+ context: {
918
+ meta: {
919
+ listApps: {
920
+ categories: ["app"],
921
+ type: "list",
922
+ itemType: "App",
923
+ inputSchema: ListAppsSchema,
924
+ outputSchema: AppItemSchema
925
+ }
926
+ }
927
+ }
928
+ };
929
+ };
930
+
931
+ // src/utils/domain-utils.ts
932
+ function splitVersionedKey(versionedKey) {
933
+ const parts = versionedKey.split("@");
934
+ if (parts.length >= 2) {
935
+ const baseKey = parts[0];
936
+ const version = parts.slice(1).join("@");
937
+ return [baseKey, version];
938
+ }
939
+ return [versionedKey, void 0];
940
+ }
941
+ function normalizeImplementationMetaToAppItem(implementationMeta) {
942
+ const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
943
+ const { id, name, ...restOfImplementationMeta } = implementationMeta;
944
+ return {
945
+ ...restOfImplementationMeta,
946
+ title: name,
947
+ key: selectedApi,
948
+ implementation_id: id,
949
+ version: appVersion
950
+ };
951
+ }
952
+ function normalizeActionItem(action) {
953
+ const { name, type, selected_api: selectedApi } = action;
954
+ const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
955
+ return {
956
+ // Only include the fields we want - explicitly list them
957
+ id: action.id,
958
+ key: action.key,
959
+ description: action.description,
960
+ is_important: action.is_important,
961
+ is_hidden: action.is_hidden,
962
+ // Transformed fields
963
+ app_key: appKey,
964
+ app_version: appVersion,
965
+ action_type: type,
966
+ title: name,
967
+ // Map name to title
968
+ type: "action"
969
+ };
970
+ }
971
+ function isSlug(slug) {
972
+ return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
973
+ }
974
+ function isSnakeCasedSlug(slug) {
975
+ if (slug.match(/^_[0-9]/)) {
976
+ slug = slug.slice(1);
977
+ }
978
+ return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
979
+ }
980
+ function dashifySnakeCasedSlug(slug) {
981
+ if (!isSnakeCasedSlug(slug)) {
982
+ return slug;
983
+ }
984
+ if (slug.startsWith("_")) {
985
+ slug = slug.slice(1);
986
+ }
987
+ return slug.replace(/_/g, "-");
988
+ }
989
+ function isUuid(appKey) {
990
+ return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
991
+ appKey
992
+ );
993
+ }
994
+ function toAppLocator(appKey) {
995
+ const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
996
+ if (isUuid(appKeyWithoutVersion)) {
997
+ throw new Error(
998
+ `UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
999
+ );
1000
+ }
1001
+ const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
1002
+ return {
1003
+ lookupAppKey: appKeyWithoutVersion,
1004
+ slug,
1005
+ implementationName: slug ? void 0 : appKeyWithoutVersion,
1006
+ version
1007
+ };
1008
+ }
1009
+ function isResolvedAppLocator(appLocator) {
1010
+ return !!appLocator.implementationName;
1011
+ }
1012
+ var ListActionsSchema = z.object({
1013
+ appKey: AppKeyPropertySchema.describe(
1014
+ "App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
1015
+ ),
1016
+ actionType: ActionTypePropertySchema.optional().describe(
1017
+ "Filter actions by type"
879
1018
  ),
880
- search: z.string().optional().describe("Optional search term to augment results"),
881
- pageSize: z.union([z.string(), z.number()]).optional().describe("Number of apps per page"),
882
- cursor: z.string().optional().describe("Pagination cursor")
883
- }).transform((data) => ({
884
- // Normalize implementationIds to array
885
- implementationIds: typeof data.implementationIds === "string" ? data.implementationIds === "" ? [] : data.implementationIds.split(",") : data.implementationIds ?? [],
886
- search: data.search,
887
- // Normalize pageSize to number
888
- pageSize: typeof data.pageSize === "string" ? parseInt(data.pageSize, 10) : data.pageSize,
889
- cursor: data.cursor
890
- }));
1019
+ pageSize: z.number().min(1).optional().describe("Number of actions per page"),
1020
+ maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
1021
+ cursor: z.string().optional().describe("Cursor to start from")
1022
+ }).merge(TelemetryMarkerSchema).describe("List all actions for a specific app");
891
1023
  var NeedChoicesSchema = z.object({
892
1024
  key: z.string().optional(),
893
1025
  label: z.string().optional(),
@@ -1003,34 +1135,6 @@ z.object({
1003
1135
  format: z.string().optional(),
1004
1136
  inputFormat: z.array(z.string()).optional()
1005
1137
  });
1006
- var AuthenticationSchema = z.object({
1007
- id: z.number(),
1008
- date: z.string(),
1009
- lastchanged: z.string().optional(),
1010
- account_id: z.number(),
1011
- customuser_id: z.number().optional(),
1012
- selected_api: z.string(),
1013
- destination_selected_api: z.string().nullable().optional(),
1014
- is_invite_only: z.boolean(),
1015
- is_private: z.boolean(),
1016
- shared_with_all: z.boolean(),
1017
- is_stale: z.string().optional(),
1018
- is_shared: z.string().optional(),
1019
- marked_stale_at: z.string().nullable().optional(),
1020
- label: z.string().nullable().optional(),
1021
- identifier: z.string().nullable().optional(),
1022
- title: z.string().nullable().optional(),
1023
- url: z.string().optional(),
1024
- groups: z.string().optional(),
1025
- members: z.string().optional(),
1026
- permissions: z.record(z.string(), z.boolean()).optional()
1027
- });
1028
- z.object({
1029
- count: z.number(),
1030
- next: z.string().nullable().optional(),
1031
- previous: z.string().nullable().optional(),
1032
- results: z.array(AuthenticationSchema)
1033
- });
1034
1138
  z.object({
1035
1139
  id: z.number(),
1036
1140
  code: z.string(),
@@ -1063,479 +1167,157 @@ z.object({
1063
1167
  summary_schedule: z.string(),
1064
1168
  alert_triggers: z.string(),
1065
1169
  alert_actions: z.string(),
1066
- is_staff: z.boolean(),
1067
- is_zt_reviewer: z.boolean(),
1068
- is_high_value: z.boolean(),
1069
- is_temporary: z.boolean(),
1070
- banner_message: z.string(),
1071
- enable_totp_2fa: z.boolean(),
1072
- viewed_help: z.record(z.string(), z.boolean()),
1073
- show_editor_migration_mesaging: z.boolean(),
1074
- switches: z.record(z.string(), z.unknown()),
1075
- organizations: z.array(z.record(z.string(), z.unknown()).nullable()),
1076
- primary_organization: z.record(z.string(), z.unknown()).nullable(),
1077
- has_active_zaps: z.boolean(),
1078
- has_google_sso: z.boolean(),
1079
- auth_realm: z.string(),
1080
- roles: z.array(
1081
- z.object({
1082
- account_id: z.number(),
1083
- role: z.string()
1084
- })
1085
- )
1086
- });
1087
- z.object({
1088
- age_in_days: z.string().optional(),
1089
- api_docs_url: z.string().nullable().optional(),
1090
- app_profile_url: z.string(),
1091
- banner: z.string().optional(),
1092
- categories: z.array(z.string()).optional(),
1093
- // Service category names
1094
- canonical_id: z.string().optional(),
1095
- current_implementation_id: z.string(),
1096
- days_since_last_update: z.string().optional(),
1097
- description: z.string(),
1098
- external_url: z.string(),
1099
- hashtag: z.string().optional(),
1100
- id: z.number().optional(),
1101
- image: z.string().optional(),
1102
- images: z.string().optional(),
1103
- integration_overview_html: z.string().nullable().optional(),
1104
- internal_id: z.string(),
1105
- invite_url: z.string().nullable().optional(),
1106
- is_beta: z.string().optional(),
1107
- is_built_in: z.string().optional(),
1108
- is_featured: z.string().optional(),
1109
- is_premium: z.boolean().optional(),
1110
- is_public: z.string().optional(),
1111
- is_upcoming: z.string().optional(),
1112
- learn_more_url: z.string(),
1113
- name: z.string(),
1114
- popularity: z.number(),
1115
- primary_color: z.string(),
1116
- request_count: z.string().optional(),
1117
- slug: z.string(),
1118
- zap_usage_count: z.number().nullable().optional()
1119
- });
1120
- var ServiceSchema = z.object({
1121
- id: z.number().optional(),
1122
- canonical_id: z.string().optional(),
1123
- current_implementation_id: z.string(),
1124
- name: z.string(),
1125
- slug: z.string(),
1126
- app_url: z.string().optional(),
1127
- learn_more_url: z.string().optional(),
1128
- description: z.string(),
1129
- primary_color: z.string(),
1130
- popularity: z.number(),
1131
- image: z.string().optional(),
1132
- images: z.string().optional()
1133
- });
1134
- z.object({
1135
- results: z.array(ServiceSchema),
1136
- next: z.string().nullable().optional(),
1137
- previous: z.string().nullable().optional()
1138
- });
1139
- z.object({
1140
- selected_api: z.string(),
1141
- action: z.string(),
1142
- type_of: z.string(),
1143
- authentication_id: z.number().optional(),
1144
- params: z.record(z.string(), z.unknown()).optional()
1145
- });
1146
- z.object({
1147
- success: z.boolean(),
1148
- needs: z.array(NeedSchema).optional(),
1149
- errors: z.array(z.string()).optional(),
1150
- last_fetched_at: z.string().optional(),
1151
- schema: z.record(z.string(), z.unknown()).optional()
1152
- });
1153
- var ImplementationSchema = z.object({
1154
- selected_api: z.string(),
1155
- app_id: z.number().optional(),
1156
- auth_type: z.string().optional(),
1157
- auth_fields: z.string().optional(),
1158
- actions: z.array(ActionSchema).optional(),
1159
- is_deprecated: z.boolean().optional(),
1160
- is_private_only: z.boolean().optional(),
1161
- is_invite_only: z.boolean().optional(),
1162
- is_beta: z.boolean().optional().default(false),
1163
- is_premium: z.boolean().optional().default(false),
1164
- is_hidden: z.string().optional(),
1165
- name: z.string().optional(),
1166
- slug: z.string().optional(),
1167
- images: z.record(z.string(), z.string().nullable()).optional(),
1168
- primary_color: z.string().optional(),
1169
- secondary_color: z.string().optional(),
1170
- current_implementation: z.string().optional(),
1171
- other_implementations: z.string().optional()
1172
- });
1173
- z.object({
1174
- count: z.number(),
1175
- next: z.string().nullable().optional(),
1176
- previous: z.string().nullable().optional(),
1177
- results: z.array(ImplementationSchema)
1178
- });
1179
- var ImplementationMetaSchema2 = z.object({
1180
- id: z.string(),
1181
- // e.g. "100HiresCLIAPI@1.2.1"
1182
- name: z.string(),
1183
- slug: z.string(),
1184
- age_in_days: z.number().optional(),
1185
- auth_type: z.string().optional(),
1186
- banner: z.string().optional(),
1187
- categories: z.array(
1188
- z.object({
1189
- id: z.number(),
1190
- name: z.string(),
1191
- slug: z.string()
1192
- })
1193
- ).optional(),
1194
- images: z.object({
1195
- url_16x16: z.string().optional(),
1196
- url_32x32: z.string().optional(),
1197
- url_64x64: z.string().optional(),
1198
- url_128x128: z.string().optional()
1199
- }).optional(),
1200
- popularity: z.number().optional(),
1201
- has_filters: z.boolean().optional(),
1202
- has_reads: z.boolean().optional(),
1203
- has_searches: z.boolean().optional(),
1204
- has_searches_or_writes: z.boolean().optional(),
1205
- has_upfront_fields: z.boolean().optional(),
1206
- has_writes: z.boolean().optional(),
1207
- is_beta: z.boolean().optional(),
1208
- is_built_in: z.boolean().optional(),
1209
- is_deprecated: z.boolean().optional(),
1210
- is_featured: z.boolean().optional(),
1211
- is_hidden: z.boolean().optional(),
1212
- is_invite: z.boolean().optional(),
1213
- is_premium: z.boolean().optional(),
1214
- is_public: z.boolean().optional(),
1215
- is_upcoming: z.boolean().optional(),
1216
- version: z.string().optional(),
1217
- visibility: z.string().optional(),
1218
- actions: z.object({
1219
- read: z.number().optional(),
1220
- read_bulk: z.number().optional(),
1221
- write: z.number().optional(),
1222
- search: z.number().optional(),
1223
- search_or_write: z.number().optional(),
1224
- search_and_write: z.number().optional(),
1225
- filter: z.number().optional()
1226
- }).optional(),
1227
- description: z.string().optional(),
1228
- primary_color: z.string().optional(),
1229
- secondary_color: z.string().optional(),
1230
- classification: z.string().optional(),
1231
- api_docs_url: z.string().optional(),
1232
- image: z.string().optional()
1233
- });
1234
- z.object({
1235
- count: z.number(),
1236
- next: z.string().nullable().optional(),
1237
- previous: z.string().nullable().optional(),
1238
- results: z.array(ImplementationMetaSchema2)
1239
- });
1240
- var NeedChoicesResponseMetaSchema = z.object({
1241
- page: z.string().nullable().optional()
1242
- });
1243
- var NeedChoicesResponseLinksSchema = z.object({
1244
- next: z.string().nullable().optional(),
1245
- prev: z.string().nullable().optional()
1246
- });
1247
- z.object({
1248
- selected_api: z.string().optional().describe(
1249
- "Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
1250
- ),
1251
- authentication_id: z.coerce.number().optional().describe(
1252
- "If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
1253
- ),
1254
- params: z.record(z.string(), z.unknown()).optional().describe(
1255
- "Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
1256
- ),
1257
- page: z.number().optional().default(0),
1258
- prefill: z.string().optional().describe(
1259
- "The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not."
1260
- ),
1261
- action_id: z.string().optional().describe(
1262
- "The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided."
1263
- ),
1264
- input_field_id: z.string().optional().describe(
1265
- "The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided."
1266
- )
1267
- });
1268
- z.object({
1269
- success: z.boolean(),
1270
- choices: z.array(NeedChoicesSchema).optional(),
1271
- next_page: z.number().optional(),
1272
- errors: z.array(z.string()).optional(),
1273
- meta: NeedChoicesResponseMetaSchema.optional(),
1274
- links: NeedChoicesResponseLinksSchema.optional()
1275
- });
1276
-
1277
- // src/utils/string-utils.ts
1278
- function toTitleCase(input) {
1279
- return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
1280
- }
1281
- function toSnakeCase(input) {
1282
- let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
1283
- if (/^[0-9]/.test(result)) {
1284
- result = "_" + result;
1285
- }
1286
- return result;
1287
- }
1288
- function stripPageSuffix(functionName) {
1289
- return functionName.replace(/Page$/, "");
1290
- }
1291
-
1292
- // src/schemas/App.ts
1293
- var AppItemSchema2 = withFormatter(
1294
- ImplementationMetaSchema2.omit({ name: true, id: true }).extend({
1295
- title: z.string(),
1296
- // Mapped from name
1297
- key: z.string(),
1298
- // Extracted from id (base part without version)
1299
- implementation_id: z.string()
1300
- // Mapped from id (full versioned ID)
1301
- }),
1302
- {
1303
- format: (item) => {
1304
- const additionalKeys = [];
1305
- if (item.slug && item.slug !== item.key) {
1306
- additionalKeys.push(item.slug);
1307
- const snakeCaseSlug = toSnakeCase(item.slug);
1308
- if (snakeCaseSlug !== item.slug && snakeCaseSlug !== item.key) {
1309
- additionalKeys.push(snakeCaseSlug);
1310
- }
1311
- }
1312
- return {
1313
- title: item.title,
1314
- key: item.key,
1315
- keys: [item.key, ...additionalKeys],
1316
- description: item.description,
1317
- details: []
1318
- };
1319
- }
1320
- }
1321
- );
1322
-
1323
- // src/utils/telemetry-utils.ts
1324
- function createTelemetryCallback(emitMethodCalled, methodName) {
1325
- return {
1326
- onMethodCalled: (data) => {
1327
- emitMethodCalled({
1328
- method_name: methodName,
1329
- execution_duration_ms: data.durationMs,
1330
- success_flag: data.success,
1331
- error_message: data.error?.message ?? null,
1332
- error_type: data.error?.constructor.name ?? null,
1333
- argument_count: data.argumentCount,
1334
- is_paginated: data.isPaginated
1335
- });
1336
- }
1337
- };
1338
- }
1339
-
1340
- // src/plugins/listApps/index.ts
1341
- var listAppsPlugin = ({ context }) => {
1342
- async function listAppsPage(options) {
1343
- const { api, resolveAppKeys: resolveAppKeys2 } = context;
1344
- const appKeys = options.appKeys ?? [];
1345
- const appLocators = await resolveAppKeys2({
1346
- appKeys: [...appKeys]
1347
- });
1348
- const implementationNameToLocator = {};
1349
- for (const locator of appLocators) {
1350
- implementationNameToLocator[locator.implementationName] = [
1351
- ...implementationNameToLocator[locator.implementationName] ?? [],
1352
- locator
1353
- ];
1354
- }
1355
- const duplicatedLookupAppKeys = Object.keys(implementationNameToLocator).filter((key) => implementationNameToLocator[key].length > 1).map((key) => implementationNameToLocator[key]).flat().map((locator) => locator.lookupAppKey);
1356
- if (duplicatedLookupAppKeys.length > 0) {
1357
- throw new Error(
1358
- `Duplicate lookup app keys found: ${duplicatedLookupAppKeys.join(", ")}`
1359
- );
1360
- }
1361
- if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
1362
- return {
1363
- data: [],
1364
- nextCursor: void 0
1365
- };
1366
- }
1367
- const implementationIds = appLocators.map((locator) => {
1368
- const version = locator.version || "latest";
1369
- return `${locator.implementationName}@${version}`;
1370
- });
1371
- return await api.get("/api/v0/apps", {
1372
- searchParams: {
1373
- implementationIds: implementationIds.join(","),
1374
- ...options.search && { search: options.search },
1375
- pageSize: options.pageSize.toString(),
1376
- ...options.cursor && { cursor: options.cursor }
1377
- }
1378
- });
1379
- }
1380
- const methodName = stripPageSuffix(listAppsPage.name);
1381
- const listAppsDefinition = createPaginatedFunction(
1382
- listAppsPage,
1383
- ListAppsOptionsSchema,
1384
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
1385
- methodName
1386
- );
1387
- return {
1388
- listApps: listAppsDefinition,
1389
- context: {
1390
- meta: {
1391
- listApps: {
1392
- categories: ["app"],
1393
- type: "list",
1394
- itemType: "App",
1395
- inputSchema: ListAppsOptionsSchema,
1396
- outputSchema: AppItemSchema2
1397
- }
1398
- }
1399
- }
1400
- };
1401
- };
1402
-
1403
- // src/utils/domain-utils.ts
1404
- function splitVersionedKey(versionedKey) {
1405
- const parts = versionedKey.split("@");
1406
- if (parts.length >= 2) {
1407
- const baseKey = parts[0];
1408
- const version = parts.slice(1).join("@");
1409
- return [baseKey, version];
1410
- }
1411
- return [versionedKey, void 0];
1412
- }
1413
- function normalizeImplementationMetaToAppItem(implementationMeta) {
1414
- const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
1415
- const { id, name, ...restOfImplementationMeta } = implementationMeta;
1416
- return {
1417
- ...restOfImplementationMeta,
1418
- title: name,
1419
- key: selectedApi,
1420
- implementation_id: id,
1421
- version: appVersion
1422
- };
1423
- }
1424
- function normalizeAuthenticationItem(auth, options = {}) {
1425
- let appKey = options.app_key;
1426
- let appVersion = options.app_version;
1427
- if (auth.selected_api) {
1428
- const [extractedAppKey, extractedVersion] = splitVersionedKey(
1429
- auth.selected_api
1430
- );
1431
- if (!appKey) {
1432
- appKey = extractedAppKey;
1433
- }
1434
- if (!appVersion) {
1435
- appVersion = extractedVersion;
1436
- }
1437
- }
1438
- const {
1439
- selected_api: selectedApi,
1440
- customuser_id: profileId,
1441
- id,
1442
- account_id: accountId,
1443
- ...restOfAuth
1444
- } = auth;
1445
- return {
1446
- ...restOfAuth,
1447
- // Pass through all other API response fields except selected_api
1448
- id: String(id),
1449
- // Convert to string
1450
- account_id: String(accountId),
1451
- // Convert to string
1452
- implementation_id: selectedApi,
1453
- // Rename selected_api to implementation_id
1454
- title: auth.title || auth.label || void 0,
1455
- // Coerce title from label if missing
1456
- is_expired: auth.is_stale,
1457
- // Map is_stale to is_expired
1458
- expired_at: auth.marked_stale_at,
1459
- // Map marked_stale_at to expired_at
1460
- app_key: appKey,
1461
- // App key from implementations endpoint or parsed from selected_api
1462
- app_version: appVersion,
1463
- // Version from selected_api or provided
1464
- profile_id: profileId != null ? String(profileId) : void 0
1465
- // Map customuser_id to profile_id, convert to string
1466
- };
1467
- }
1468
- function normalizeActionItem(action) {
1469
- const { name, type, selected_api: selectedApi } = action;
1470
- const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
1471
- return {
1472
- // Only include the fields we want - explicitly list them
1473
- id: action.id,
1474
- key: action.key,
1475
- description: action.description,
1476
- is_important: action.is_important,
1477
- is_hidden: action.is_hidden,
1478
- // Transformed fields
1479
- app_key: appKey,
1480
- app_version: appVersion,
1481
- action_type: type,
1482
- title: name,
1483
- // Map name to title
1484
- type: "action"
1485
- };
1486
- }
1487
- function isSlug(slug) {
1488
- return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
1489
- }
1490
- function isSnakeCasedSlug(slug) {
1491
- if (slug.match(/^_[0-9]/)) {
1492
- slug = slug.slice(1);
1493
- }
1494
- return !!slug.match(/^[a-z0-9]+(?:_[a-z0-9]+)*$/);
1495
- }
1496
- function dashifySnakeCasedSlug(slug) {
1497
- if (!isSnakeCasedSlug(slug)) {
1498
- return slug;
1499
- }
1500
- if (slug.startsWith("_")) {
1501
- slug = slug.slice(1);
1502
- }
1503
- return slug.replace(/_/g, "-");
1504
- }
1505
- function isUuid(appKey) {
1506
- return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
1507
- appKey
1508
- );
1509
- }
1510
- function toAppLocator(appKey) {
1511
- const [appKeyWithoutVersion, version] = splitVersionedKey(appKey);
1512
- if (isUuid(appKeyWithoutVersion)) {
1513
- throw new Error(
1514
- `UUID app keys are not supported. Use app slug or implementation ID instead of: ${appKey}`
1515
- );
1516
- }
1517
- const slug = isSlug(appKeyWithoutVersion) ? appKeyWithoutVersion : isSnakeCasedSlug(appKeyWithoutVersion) ? dashifySnakeCasedSlug(appKeyWithoutVersion) : void 0;
1518
- return {
1519
- lookupAppKey: appKeyWithoutVersion,
1520
- slug,
1521
- implementationName: slug ? void 0 : appKeyWithoutVersion,
1522
- version
1523
- };
1524
- }
1525
- function isResolvedAppLocator(appLocator) {
1526
- return !!appLocator.implementationName;
1527
- }
1528
- var ListActionsSchema = z.object({
1529
- appKey: AppKeyPropertySchema.describe(
1530
- "App key of actions to list (e.g., 'SlackCLIAPI' or slug like 'github')"
1170
+ is_staff: z.boolean(),
1171
+ is_zt_reviewer: z.boolean(),
1172
+ is_high_value: z.boolean(),
1173
+ is_temporary: z.boolean(),
1174
+ banner_message: z.string(),
1175
+ enable_totp_2fa: z.boolean(),
1176
+ viewed_help: z.record(z.string(), z.boolean()),
1177
+ show_editor_migration_mesaging: z.boolean(),
1178
+ switches: z.record(z.string(), z.unknown()),
1179
+ organizations: z.array(z.record(z.string(), z.unknown()).nullable()),
1180
+ primary_organization: z.record(z.string(), z.unknown()).nullable(),
1181
+ has_active_zaps: z.boolean(),
1182
+ has_google_sso: z.boolean(),
1183
+ auth_realm: z.string(),
1184
+ roles: z.array(
1185
+ z.object({
1186
+ account_id: z.number(),
1187
+ role: z.string()
1188
+ })
1189
+ )
1190
+ });
1191
+ z.object({
1192
+ age_in_days: z.string().optional(),
1193
+ api_docs_url: z.string().nullable().optional(),
1194
+ app_profile_url: z.string(),
1195
+ banner: z.string().optional(),
1196
+ categories: z.array(z.string()).optional(),
1197
+ // Service category names
1198
+ canonical_id: z.string().optional(),
1199
+ current_implementation_id: z.string(),
1200
+ days_since_last_update: z.string().optional(),
1201
+ description: z.string(),
1202
+ external_url: z.string(),
1203
+ hashtag: z.string().optional(),
1204
+ id: z.number().optional(),
1205
+ image: z.string().optional(),
1206
+ images: z.string().optional(),
1207
+ integration_overview_html: z.string().nullable().optional(),
1208
+ internal_id: z.string(),
1209
+ invite_url: z.string().nullable().optional(),
1210
+ is_beta: z.string().optional(),
1211
+ is_built_in: z.string().optional(),
1212
+ is_featured: z.string().optional(),
1213
+ is_premium: z.boolean().optional(),
1214
+ is_public: z.string().optional(),
1215
+ is_upcoming: z.string().optional(),
1216
+ learn_more_url: z.string(),
1217
+ name: z.string(),
1218
+ popularity: z.number(),
1219
+ primary_color: z.string(),
1220
+ request_count: z.string().optional(),
1221
+ slug: z.string(),
1222
+ zap_usage_count: z.number().nullable().optional()
1223
+ });
1224
+ var ServiceSchema = z.object({
1225
+ id: z.number().optional(),
1226
+ canonical_id: z.string().optional(),
1227
+ current_implementation_id: z.string(),
1228
+ name: z.string(),
1229
+ slug: z.string(),
1230
+ app_url: z.string().optional(),
1231
+ learn_more_url: z.string().optional(),
1232
+ description: z.string(),
1233
+ primary_color: z.string(),
1234
+ popularity: z.number(),
1235
+ image: z.string().optional(),
1236
+ images: z.string().optional()
1237
+ });
1238
+ z.object({
1239
+ results: z.array(ServiceSchema),
1240
+ next: z.string().nullable().optional(),
1241
+ previous: z.string().nullable().optional()
1242
+ });
1243
+ z.object({
1244
+ selected_api: z.string(),
1245
+ action: z.string(),
1246
+ type_of: z.string(),
1247
+ authentication_id: z.number().optional(),
1248
+ params: z.record(z.string(), z.unknown()).optional()
1249
+ });
1250
+ z.object({
1251
+ success: z.boolean(),
1252
+ needs: z.array(NeedSchema).optional(),
1253
+ errors: z.array(z.string()).optional(),
1254
+ last_fetched_at: z.string().optional(),
1255
+ schema: z.record(z.string(), z.unknown()).optional()
1256
+ });
1257
+ var ImplementationSchema = z.object({
1258
+ selected_api: z.string(),
1259
+ app_id: z.number().optional(),
1260
+ auth_type: z.string().optional(),
1261
+ auth_fields: z.string().optional(),
1262
+ actions: z.array(ActionSchema).optional(),
1263
+ is_deprecated: z.boolean().optional(),
1264
+ is_private_only: z.boolean().optional(),
1265
+ is_invite_only: z.boolean().optional(),
1266
+ is_beta: z.boolean().optional().default(false),
1267
+ is_premium: z.boolean().optional().default(false),
1268
+ is_hidden: z.string().optional(),
1269
+ name: z.string().optional(),
1270
+ slug: z.string().optional(),
1271
+ images: z.record(z.string(), z.string().nullable()).optional(),
1272
+ primary_color: z.string().optional(),
1273
+ secondary_color: z.string().optional(),
1274
+ current_implementation: z.string().optional(),
1275
+ other_implementations: z.string().optional()
1276
+ });
1277
+ z.object({
1278
+ count: z.number(),
1279
+ next: z.string().nullable().optional(),
1280
+ previous: z.string().nullable().optional(),
1281
+ results: z.array(ImplementationSchema)
1282
+ });
1283
+ var NeedChoicesResponseMetaSchema = z.object({
1284
+ page: z.string().nullable().optional()
1285
+ });
1286
+ var NeedChoicesResponseLinksSchema = z.object({
1287
+ next: z.string().nullable().optional(),
1288
+ prev: z.string().nullable().optional()
1289
+ });
1290
+ z.object({
1291
+ selected_api: z.string().optional().describe(
1292
+ "Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them."
1531
1293
  ),
1532
- actionType: ActionTypePropertySchema.optional().describe(
1533
- "Filter actions by type"
1294
+ authentication_id: z.coerce.number().optional().describe(
1295
+ "If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared)."
1534
1296
  ),
1535
- pageSize: z.number().min(1).optional().describe("Number of actions per page"),
1536
- maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
1537
- cursor: z.string().optional().describe("Cursor to start from")
1538
- }).merge(TelemetryMarkerSchema).describe("List all actions for a specific app");
1297
+ params: z.record(z.string(), z.unknown()).optional().describe(
1298
+ "Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action."
1299
+ ),
1300
+ page: z.number().optional().default(0),
1301
+ prefill: z.string().optional().describe(
1302
+ "The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not."
1303
+ ),
1304
+ action_id: z.string().optional().describe(
1305
+ "The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided."
1306
+ ),
1307
+ input_field_id: z.string().optional().describe(
1308
+ "The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided."
1309
+ )
1310
+ });
1311
+ z.object({
1312
+ success: z.boolean(),
1313
+ choices: z.array(NeedChoicesSchema).optional(),
1314
+ next_page: z.number().optional(),
1315
+ errors: z.array(z.string()).optional(),
1316
+ meta: NeedChoicesResponseMetaSchema.optional(),
1317
+ links: NeedChoicesResponseLinksSchema.optional()
1318
+ });
1319
+
1320
+ // src/schemas/Action.ts
1539
1321
  var ActionItemSchema = withFormatter(
1540
1322
  ActionSchema.omit({ type: true, name: true, selected_api: true }).extend({
1541
1323
  app_key: z.string(),
@@ -2226,19 +2008,22 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
2226
2008
  }
2227
2009
  };
2228
2010
  };
2229
- var ListAuthenticationsSchema = z.object({
2011
+ var ListAuthenticationsQuerySchema = ListAuthenticationsQuerySchema$1.omit(
2012
+ {
2013
+ offset: true
2014
+ }
2015
+ ).extend({
2016
+ // Override appKey with our custom schema (array type, different description)
2230
2017
  appKey: AppKeyPropertySchema.optional().describe(
2231
2018
  "App key of authentications to list (e.g., 'SlackCLIAPI' or slug like 'github')"
2232
2019
  ),
2020
+ // Override authenticationIds to be an array instead of comma-separated string
2233
2021
  authenticationIds: z.array(z.string()).optional().describe("List of authentication IDs to filter by"),
2234
- search: z.string().optional().describe("Search term to filter authentications by title"),
2235
- title: z.string().optional().describe("Filter authentications by exact title match"),
2236
- accountId: z.string().optional().describe("Filter by account ID"),
2237
- owner: z.union([z.string(), z.literal("me")]).optional().describe(
2238
- "Filter by owner, 'me' for your own authentications or a specific user ID"
2239
- ),
2022
+ // Override pageSize to make optional (needs to be fixed in `zapier-sdk-core`)
2240
2023
  pageSize: z.number().min(1).optional().describe("Number of authentications per page"),
2024
+ // SDK specific property for pagination/iterator helpers
2241
2025
  maxItems: z.number().min(1).optional().describe("Maximum total items to return across all pages"),
2026
+ // SDK specific property for pagination/iterator helpers
2242
2027
  cursor: z.string().optional().describe("Cursor to start from")
2243
2028
  }).merge(TelemetryMarkerSchema).describe("List available authentications with optional filtering");
2244
2029
  var AuthenticationItemSchema = withFormatter(
@@ -2275,36 +2060,38 @@ var AuthenticationItemSchema = withFormatter(
2275
2060
  var listAuthenticationsPlugin = ({ context }) => {
2276
2061
  async function listAuthenticationsPage(options) {
2277
2062
  const { api, getVersionedImplementationId } = context;
2278
- const searchParams = {};
2063
+ const searchParams = {
2064
+ pageSize: options.pageSize.toString()
2065
+ };
2279
2066
  if (options.appKey) {
2280
2067
  const implementationId = await getVersionedImplementationId(
2281
2068
  options.appKey
2282
2069
  );
2283
2070
  if (implementationId) {
2284
2071
  const [versionlessSelectedApi] = splitVersionedKey(implementationId);
2285
- searchParams.versionless_selected_api = versionlessSelectedApi;
2072
+ searchParams.appKey = versionlessSelectedApi;
2286
2073
  }
2287
2074
  }
2288
2075
  if (options.authenticationIds && options.authenticationIds.length > 0) {
2289
- searchParams.ids = options.authenticationIds.join(",");
2076
+ searchParams.authenticationIds = options.authenticationIds.join(",");
2290
2077
  }
2291
2078
  if (options.search) {
2292
2079
  searchParams.search = options.search;
2293
- } else if (options.title) {
2294
- searchParams.search = options.title;
2080
+ }
2081
+ if (options.title) {
2082
+ searchParams.title = options.title;
2295
2083
  }
2296
2084
  if (options.accountId) {
2297
- searchParams.account_id = options.accountId;
2085
+ searchParams.accountId = options.accountId;
2298
2086
  }
2299
2087
  if (options.owner) {
2300
2088
  searchParams.owner = options.owner;
2301
2089
  }
2302
- searchParams.limit = options.pageSize.toString();
2303
2090
  if (options.cursor) {
2304
2091
  searchParams.offset = options.cursor;
2305
2092
  }
2306
- const data = await api.get(
2307
- "/zapier/api/v4/authentications/",
2093
+ const response = await api.get(
2094
+ "/api/v0/authentications",
2308
2095
  {
2309
2096
  searchParams,
2310
2097
  customErrorHandler: ({ status }) => {
@@ -2325,23 +2112,12 @@ var listAuthenticationsPlugin = ({ context }) => {
2325
2112
  authRequired: true
2326
2113
  }
2327
2114
  );
2328
- let auths = (data.results || []).map(
2329
- (auth) => normalizeAuthenticationItem(auth)
2330
- );
2331
- if (options.title) {
2332
- auths = auths.filter(
2333
- (auth) => auth.title === options.title
2334
- );
2335
- }
2336
- return {
2337
- data: auths,
2338
- nextCursor: extractCursor(data)
2339
- };
2115
+ return response;
2340
2116
  }
2341
2117
  const methodName = stripPageSuffix(listAuthenticationsPage.name);
2342
2118
  const listAuthenticationsDefinition = createPaginatedFunction(
2343
2119
  listAuthenticationsPage,
2344
- ListAuthenticationsSchema,
2120
+ ListAuthenticationsQuerySchema,
2345
2121
  createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
2346
2122
  methodName
2347
2123
  );
@@ -2353,7 +2129,7 @@ var listAuthenticationsPlugin = ({ context }) => {
2353
2129
  categories: ["authentication"],
2354
2130
  type: "list",
2355
2131
  itemType: "Authentication",
2356
- inputSchema: ListAuthenticationsSchema,
2132
+ inputSchema: ListAuthenticationsQuerySchema,
2357
2133
  outputSchema: AuthenticationItemSchema,
2358
2134
  resolvers: {
2359
2135
  appKey: appKeyResolver
@@ -2402,7 +2178,7 @@ var getAppPlugin = ({ sdk, context }) => {
2402
2178
  type: "item",
2403
2179
  itemType: "App",
2404
2180
  inputSchema: GetAppSchema,
2405
- outputSchema: AppItemSchema2,
2181
+ outputSchema: AppItemSchema,
2406
2182
  resolvers: {
2407
2183
  appKey: appKeyResolver
2408
2184
  }
@@ -3745,176 +3521,6 @@ function getTrackingBaseUrl({
3745
3521
  return ZAPIER_BASE_URL;
3746
3522
  }
3747
3523
 
3748
- // src/temporary-internal-core/utils/string-utils.ts
3749
- function splitVersionedKey2(versionedKey) {
3750
- const parts = versionedKey.split("@");
3751
- if (parts.length >= 2) {
3752
- const baseKey = parts[0];
3753
- const version = parts.slice(1).join("@");
3754
- return [baseKey, version];
3755
- }
3756
- return [versionedKey, void 0];
3757
- }
3758
-
3759
- // src/temporary-internal-core/utils/transformations.ts
3760
- function transformImplementationMetaToAppItem(implementationMeta) {
3761
- const [selectedApi, appVersion] = splitVersionedKey2(implementationMeta.id);
3762
- const { id, name, ...restOfImplementationMeta } = implementationMeta;
3763
- return {
3764
- ...restOfImplementationMeta,
3765
- title: name,
3766
- key: selectedApi,
3767
- implementation_id: id,
3768
- version: appVersion
3769
- };
3770
- }
3771
- function extractPaginationCursor(response) {
3772
- if (!response.next) {
3773
- return void 0;
3774
- }
3775
- try {
3776
- const url = new URL(response.next);
3777
- const offset = url.searchParams.get("offset");
3778
- return offset || void 0;
3779
- } catch {
3780
- return void 0;
3781
- }
3782
- }
3783
-
3784
- // src/temporary-internal-core/handlers/listApps.ts
3785
- var DEFAULT_PAGE_SIZE = 20;
3786
- async function augmentWithSearchResults({
3787
- searchTerm,
3788
- implementationIds,
3789
- httpClient
3790
- }) {
3791
- const searchResponse = await httpClient.get(
3792
- "/zapier/api/v4/implementations-meta/search/",
3793
- {
3794
- searchParams: { term: searchTerm }
3795
- }
3796
- );
3797
- const byImplementationName = /* @__PURE__ */ new Map();
3798
- for (const result of searchResponse.results) {
3799
- const [implementationName] = splitVersionedKey2(result.id);
3800
- const isPublic = result.visibility === "public";
3801
- const existing = byImplementationName.get(implementationName);
3802
- if (!existing || isPublic && !existing.isPublic) {
3803
- byImplementationName.set(implementationName, { result, isPublic });
3804
- }
3805
- }
3806
- const searchResults = Array.from(byImplementationName.values()).map(
3807
- (entry) => transformImplementationMetaToAppItem(entry.result)
3808
- );
3809
- const implementationNameSet = new Set(
3810
- implementationIds.map((id) => {
3811
- const [name] = splitVersionedKey2(id);
3812
- return name;
3813
- })
3814
- );
3815
- const additionalIds = [];
3816
- for (const result of searchResults) {
3817
- const [implementationName] = splitVersionedKey2(result.key);
3818
- if (!implementationNameSet.has(implementationName)) {
3819
- implementationNameSet.add(implementationName);
3820
- additionalIds.push(result.implementation_id);
3821
- }
3822
- }
3823
- return [...implementationIds, ...additionalIds];
3824
- }
3825
- var handleListApps = async ({ request, deps }) => {
3826
- const validatedRequest = ListAppsHandlerRequestSchema.parse(request);
3827
- const { httpClient } = deps;
3828
- let { implementationIds } = validatedRequest;
3829
- const pageSize = validatedRequest.pageSize ?? DEFAULT_PAGE_SIZE;
3830
- if (validatedRequest.search) {
3831
- implementationIds = await augmentWithSearchResults({
3832
- searchTerm: validatedRequest.search,
3833
- implementationIds,
3834
- httpClient
3835
- });
3836
- }
3837
- if (implementationIds.length === 0) {
3838
- if (validatedRequest.search) {
3839
- return {
3840
- data: [],
3841
- nextCursor: void 0
3842
- };
3843
- }
3844
- const searchParams2 = {
3845
- latest_only: "true",
3846
- selected_apis: "",
3847
- limit: pageSize.toString()
3848
- };
3849
- if (validatedRequest.cursor) {
3850
- searchParams2.offset = validatedRequest.cursor;
3851
- }
3852
- const implementationsResponse2 = await httpClient.get(
3853
- "/zapier/api/v4/implementations-meta/lookup/",
3854
- {
3855
- searchParams: searchParams2
3856
- }
3857
- );
3858
- return {
3859
- data: implementationsResponse2.results.map(
3860
- transformImplementationMetaToAppItem
3861
- ),
3862
- nextCursor: extractPaginationCursor(implementationsResponse2)
3863
- };
3864
- }
3865
- const searchParams = {
3866
- selected_apis: implementationIds.join(","),
3867
- limit: pageSize.toString()
3868
- };
3869
- if (validatedRequest.cursor) {
3870
- searchParams.offset = validatedRequest.cursor;
3871
- }
3872
- const implementationsResponse = await httpClient.get(
3873
- "/zapier/api/v4/implementations-meta/lookup/",
3874
- {
3875
- searchParams
3876
- }
3877
- );
3878
- return {
3879
- data: implementationsResponse.results.map(
3880
- transformImplementationMetaToAppItem
3881
- ),
3882
- nextCursor: extractPaginationCursor(implementationsResponse)
3883
- };
3884
- };
3885
-
3886
- // src/api/router.ts
3887
- var routes = [
3888
- {
3889
- method: "GET",
3890
- pattern: /^\/api\/v0\/apps$/,
3891
- handler: handleListApps,
3892
- paramMap: []
3893
- }
3894
- ];
3895
- function findMatchingRoute(routeList, method, path) {
3896
- for (const route of routeList) {
3897
- if (route.method !== method) {
3898
- continue;
3899
- }
3900
- const match = path.match(route.pattern);
3901
- if (match) {
3902
- const params = {};
3903
- route.paramMap.forEach((name, index) => {
3904
- params[name] = match[index + 1];
3905
- });
3906
- return {
3907
- handler: route.handler,
3908
- params
3909
- };
3910
- }
3911
- }
3912
- return null;
3913
- }
3914
- function matchRoute(method, path) {
3915
- return findMatchingRoute(routes, method, path);
3916
- }
3917
-
3918
3524
  // src/api/client.ts
3919
3525
  var pathConfig = {
3920
3526
  // e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
@@ -4163,20 +3769,6 @@ var ZapierApiClient = class {
4163
3769
  }
4164
3770
  // Helper to perform HTTP requests with JSON handling
4165
3771
  async fetchJson(method, path, data, options = {}) {
4166
- const routeMatch = matchRoute(method, path);
4167
- if (routeMatch) {
4168
- const handlerRequest = {
4169
- ...typeof data === "object" ? data : {},
4170
- ...options.searchParams,
4171
- ...routeMatch.params
4172
- };
4173
- return routeMatch.handler({
4174
- request: handlerRequest,
4175
- deps: {
4176
- httpClient: this
4177
- }
4178
- });
4179
- }
4180
3772
  const headers = { ...options.headers };
4181
3773
  if (data && typeof data === "object") {
4182
3774
  headers["Content-Type"] = "application/json";
@@ -4859,7 +4451,7 @@ function getCpuTime() {
4859
4451
 
4860
4452
  // package.json
4861
4453
  var package_default = {
4862
- version: "0.18.2"};
4454
+ version: "0.18.4"};
4863
4455
 
4864
4456
  // src/plugins/eventEmission/builders.ts
4865
4457
  function createBaseEvent(context = {}) {