@zapier/zapier-sdk 0.43.0 → 0.45.0

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 (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +75 -73
  3. package/dist/index.cjs +104 -113
  4. package/dist/index.d.mts +2486 -2467
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.mjs +104 -113
  8. package/dist/plugins/apps/index.d.ts +1 -1
  9. package/dist/plugins/apps/index.d.ts.map +1 -1
  10. package/dist/plugins/apps/index.js +4 -0
  11. package/dist/plugins/getInputFieldsSchema/schemas.js +1 -1
  12. package/dist/plugins/listInputFieldChoices/schemas.js +1 -1
  13. package/dist/plugins/listInputFields/schemas.js +1 -1
  14. package/dist/plugins/manifest/schemas.d.ts +2 -2
  15. package/dist/plugins/registry/index.d.ts +11 -16
  16. package/dist/plugins/registry/index.d.ts.map +1 -1
  17. package/dist/plugins/registry/index.js +9 -130
  18. package/dist/plugins/runAction/schemas.js +1 -1
  19. package/dist/registry.d.ts +9 -0
  20. package/dist/registry.d.ts.map +1 -0
  21. package/dist/registry.js +77 -0
  22. package/dist/sdk.d.ts +20 -2
  23. package/dist/sdk.d.ts.map +1 -1
  24. package/dist/sdk.js +25 -9
  25. package/dist/types/connections.d.ts +2 -2
  26. package/dist/types/connections.d.ts.map +1 -1
  27. package/dist/types/connections.js +5 -3
  28. package/dist/types/plugin.d.ts +7 -1
  29. package/dist/types/plugin.d.ts.map +1 -1
  30. package/dist/types/properties.js +1 -1
  31. package/dist/types/registry.d.ts +49 -0
  32. package/dist/types/registry.d.ts.map +1 -0
  33. package/dist/types/registry.js +1 -0
  34. package/dist/types/sdk.d.ts +1 -78
  35. package/dist/types/sdk.d.ts.map +1 -1
  36. package/dist/utils/schema-utils.d.ts +1 -1
  37. package/dist/utils/schema-utils.d.ts.map +1 -1
  38. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -101,7 +101,7 @@ var AuthenticationIdPropertySchema = ConnectionIdPropertySchema.meta({
101
101
  deprecated: true
102
102
  });
103
103
  var ConnectionPropertySchema = zod.z.union([zod.z.string(), zod.z.number().int().positive()]).describe(
104
- "Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly."
104
+ "Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly."
105
105
  );
106
106
  var InputsPropertySchema = zod.z.record(zod.z.string(), zod.z.unknown()).describe("Input parameters for the action");
107
107
  var LimitPropertySchema = zod.z.number().int().min(1).max(MAX_PAGE_LIMIT).default(50).describe("Maximum number of items to return");
@@ -545,6 +545,10 @@ function createAppsProxy(options) {
545
545
  }
546
546
  var appsPlugin = (sdk) => {
547
547
  return {
548
+ // Cast: ZapierSdkApps is augmented by user-generated .d.ts files to
549
+ // give specific types like `slack: SlackAppWithFactory`. At runtime
550
+ // the Proxy intercepts any property access, so the augmented entries
551
+ // always resolve correctly even though TS can't see that statically.
548
552
  apps: createAppsProxy({ sdk }),
549
553
  context: {
550
554
  meta: {
@@ -3013,7 +3017,7 @@ var listActionsPlugin = (sdk) => {
3013
3017
  var ListInputFieldsDescription = "Get the input fields required for a specific action";
3014
3018
  var ListInputFieldsBaseSchema = zod.z.object({
3015
3019
  connection: ConnectionPropertySchema.optional().describe(
3016
- "Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId."
3020
+ "Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
3017
3021
  ),
3018
3022
  connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
3019
3023
  "Connection ID to use when listing input fields. Required if the action needs a connection to determine available fields."
@@ -4113,7 +4117,7 @@ var findUniqueConnectionPlugin = (sdk) => {
4113
4117
  var RunActionDescription = "Execute an action with the given inputs";
4114
4118
  var RunActionBaseSchema = zod.z.object({
4115
4119
  connection: ConnectionPropertySchema.optional().describe(
4116
- "Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId."
4120
+ "Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
4117
4121
  ),
4118
4122
  connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
4119
4123
  "Connection ID to use when running the action. Required if the action needs a connection to authenticate and interact with the service."
@@ -4492,8 +4496,12 @@ async function readFile(filePath) {
4492
4496
  }
4493
4497
  throw new Error(`File not found: ${filePath}`);
4494
4498
  }
4499
+ var POSITIVE_INTEGER_OR_UUID = /^([1-9][0-9]*|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
4495
4500
  var ConnectionEntrySchema = zod.z.object({
4496
- connectionId: zod.z.number().int().positive().describe("Zapier connection ID for the third-party service.")
4501
+ connectionId: zod.z.union([
4502
+ zod.z.string().regex(POSITIVE_INTEGER_OR_UUID),
4503
+ zod.z.number().int().positive()
4504
+ ]).describe("Zapier connection ID for the third-party service.")
4497
4505
  });
4498
4506
  var ConnectionsMapSchema = zod.z.record(zod.z.string(), ConnectionEntrySchema);
4499
4507
 
@@ -7873,119 +7881,75 @@ var updateTableRecordsPlugin = (sdk) => {
7873
7881
  };
7874
7882
  };
7875
7883
 
7876
- // src/plugins/registry/index.ts
7877
- var registryPlugin = (sdk) => {
7878
- const metaKeys = Object.keys(sdk.context.meta || {});
7879
- const categoryDefinitions = {
7880
- account: {
7881
- title: "Account"
7882
- },
7883
- app: {
7884
- title: "App",
7885
- titlePlural: "Apps"
7886
- },
7887
- connection: {
7888
- title: "Connection"
7889
- },
7890
- action: {
7891
- title: "Action"
7892
- },
7893
- "client-credentials": {
7894
- title: "Client Credentials",
7895
- titlePlural: "Client Credentials"
7896
- },
7897
- table: {
7898
- title: "Table"
7899
- },
7900
- http: {
7901
- title: "HTTP Request"
7902
- },
7903
- utility: {
7904
- title: "Utility",
7905
- titlePlural: "Utilities"
7906
- },
7907
- other: {
7908
- title: "Other"
7909
- }
7910
- };
7911
- const functions = metaKeys.filter((key) => {
7884
+ // src/registry.ts
7885
+ var categoryDefinitions = {
7886
+ account: { title: "Account" },
7887
+ app: { title: "App", titlePlural: "Apps" },
7888
+ connection: { title: "Connection" },
7889
+ action: { title: "Action" },
7890
+ "client-credentials": {
7891
+ title: "Client Credentials",
7892
+ titlePlural: "Client Credentials"
7893
+ },
7894
+ table: { title: "Table" },
7895
+ http: { title: "HTTP Request" },
7896
+ utility: { title: "Utility", titlePlural: "Utilities" },
7897
+ other: { title: "Other" }
7898
+ };
7899
+ var knownCategories = Object.keys(categoryDefinitions);
7900
+ function buildRegistry({
7901
+ sdk,
7902
+ meta,
7903
+ packageFilter
7904
+ }) {
7905
+ const functions = Object.keys(meta).filter((key) => {
7912
7906
  const property = sdk[key];
7913
- if (typeof property === "function") {
7914
- return true;
7915
- }
7907
+ if (typeof property === "function") return true;
7916
7908
  const [rootKey] = key.split(".");
7917
7909
  const rootProperty = sdk[rootKey];
7918
- if (typeof rootProperty === "object" && rootProperty !== null) {
7919
- return true;
7920
- }
7921
- return false;
7910
+ return typeof rootProperty === "object" && rootProperty !== null;
7922
7911
  }).map((key) => {
7923
- const meta = sdk.context.meta[key];
7912
+ const m = meta[key];
7924
7913
  return {
7925
7914
  name: key,
7926
- description: meta.description,
7927
- type: meta.type,
7928
- itemType: meta.itemType,
7929
- returnType: meta.returnType,
7930
- inputSchema: meta.inputSchema,
7931
- inputParameters: meta.inputParameters,
7932
- outputSchema: meta.outputSchema,
7933
- categories: meta.categories || [],
7934
- resolvers: meta.resolvers,
7935
- formatter: meta.formatter,
7936
- packages: meta.packages,
7937
- // Auto-infer confirm: "delete" from type: "delete" (all deletes should confirm)
7938
- confirm: meta.confirm ?? (meta.type === "delete" ? "delete" : void 0),
7939
- deprecation: meta.deprecation,
7940
- aliases: meta.aliases,
7941
- supportsJsonOutput: meta.supportsJsonOutput ?? true
7915
+ description: m.description,
7916
+ type: m.type,
7917
+ itemType: m.itemType,
7918
+ returnType: m.returnType,
7919
+ inputSchema: m.inputSchema,
7920
+ inputParameters: m.inputParameters,
7921
+ outputSchema: m.outputSchema,
7922
+ categories: m.categories || [],
7923
+ resolvers: m.resolvers,
7924
+ formatter: m.formatter,
7925
+ packages: m.packages,
7926
+ confirm: m.confirm ?? (m.type === "delete" ? "delete" : void 0),
7927
+ deprecation: m.deprecation,
7928
+ aliases: m.aliases,
7929
+ supportsJsonOutput: m.supportsJsonOutput ?? true
7942
7930
  };
7943
7931
  }).sort((a, b) => a.name.localeCompare(b.name));
7944
- const knownCategories = Object.keys(categoryDefinitions);
7945
- const registryCache = /* @__PURE__ */ new Map();
7946
- function getRegistry(options) {
7947
- const packageFilter = options?.package;
7948
- const cacheKey = packageFilter || "__all__";
7949
- if (registryCache.has(cacheKey)) {
7950
- return registryCache.get(cacheKey);
7951
- }
7952
- const filteredFunctions = packageFilter ? functions.filter(
7953
- (f) => (
7954
- // Include if packages is undefined (belongs to all packages) or includes the specified package
7955
- !f.packages || f.packages.includes(packageFilter)
7956
- )
7957
- ) : functions;
7958
- const filteredCategories = knownCategories.sort((a, b) => {
7959
- if (a === "other") return 1;
7960
- if (b === "other") return -1;
7961
- const titleA = categoryDefinitions[a].title;
7962
- const titleB = categoryDefinitions[b].title;
7963
- return titleA.localeCompare(titleB);
7964
- }).map((categoryKey) => {
7965
- const categoryFunctions = filteredFunctions.filter(
7966
- (f) => f.categories.includes(categoryKey) || // If the category is "other" and the function is not in any other category, include it
7967
- categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
7968
- ).map((f) => f.name).sort();
7969
- const definition = categoryDefinitions[categoryKey];
7970
- const title = definition.title;
7971
- return {
7972
- key: categoryKey,
7973
- title,
7974
- titlePlural: definition.titlePlural ?? `${title}s`,
7975
- functions: categoryFunctions
7976
- };
7977
- }).filter((category) => category.functions.length > 0);
7978
- const result = {
7979
- functions: filteredFunctions,
7980
- categories: filteredCategories
7932
+ const filteredFunctions = packageFilter ? functions.filter((f) => !f.packages || f.packages.includes(packageFilter)) : functions;
7933
+ const filteredCategories = knownCategories.slice().sort((a, b) => {
7934
+ if (a === "other") return 1;
7935
+ if (b === "other") return -1;
7936
+ return categoryDefinitions[a].title.localeCompare(
7937
+ categoryDefinitions[b].title
7938
+ );
7939
+ }).map((categoryKey) => {
7940
+ const categoryFunctions = filteredFunctions.filter(
7941
+ (f) => f.categories.includes(categoryKey) || categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
7942
+ ).map((f) => f.name).sort();
7943
+ const definition = categoryDefinitions[categoryKey];
7944
+ return {
7945
+ key: categoryKey,
7946
+ title: definition.title,
7947
+ titlePlural: definition.titlePlural ?? `${definition.title}s`,
7948
+ functions: categoryFunctions
7981
7949
  };
7982
- registryCache.set(cacheKey, result);
7983
- return result;
7984
- }
7985
- return {
7986
- getRegistry
7987
- };
7988
- };
7950
+ }).filter((category) => category.functions.length > 0);
7951
+ return { functions: filteredFunctions, categories: filteredCategories };
7952
+ }
7989
7953
 
7990
7954
  // src/plugins/deprecated/authentications.ts
7991
7955
  var listAuthenticationsPlugin = (sdk) => ({
@@ -8051,7 +8015,7 @@ var findUniqueAuthenticationPlugin = (sdk) => ({
8051
8015
  var GetInputFieldsSchemaDescription = "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.";
8052
8016
  var GetInputFieldsSchemaBaseSchema = zod.z.object({
8053
8017
  connection: ConnectionPropertySchema.optional().describe(
8054
- "Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId."
8018
+ "Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
8055
8019
  ),
8056
8020
  connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
8057
8021
  "Connection ID to use when fetching the schema. Required if the action needs a connection to determine available fields."
@@ -8189,7 +8153,7 @@ var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
8189
8153
  var ListInputFieldChoicesDescription = "Get the available choices for a dynamic dropdown input field";
8190
8154
  var ListInputFieldChoicesBaseSchema = zod.z.object({
8191
8155
  connection: ConnectionPropertySchema.optional().describe(
8192
- "Connection alias (string) or numeric connectionId. Strings are resolved from the connections map; numbers are used directly. Mutually exclusive with connectionId."
8156
+ "Connection alias or connection ID (UUID or positive integer). Strings that match a key in the connections map are resolved against it; otherwise the value is used as a connection ID directly. Mutually exclusive with connectionId."
8193
8157
  ),
8194
8158
  connectionId: ConnectionIdPropertySchema.nullable().optional().describe(
8195
8159
  "Connection ID to use when listing available field choices. Required if the action needs a connection to populate dynamic dropdown options."
@@ -8986,13 +8950,28 @@ function createSdk() {
8986
8950
  }
8987
8951
  function buildSdk(properties, context) {
8988
8952
  const frozenContext = Object.freeze(context);
8989
- return {
8953
+ const registryCache = /* @__PURE__ */ new Map();
8954
+ const sdk = {
8990
8955
  ...properties,
8991
8956
  get context() {
8992
8957
  return frozenContext;
8993
8958
  },
8994
8959
  getContext: () => frozenContext,
8995
8960
  // runtime compat shim, not in types
8961
+ getRegistry(options) {
8962
+ const cacheKey = options?.package ?? "__all__";
8963
+ if (!registryCache.has(cacheKey)) {
8964
+ registryCache.set(
8965
+ cacheKey,
8966
+ buildRegistry({
8967
+ sdk,
8968
+ meta: frozenContext.meta,
8969
+ packageFilter: options?.package
8970
+ })
8971
+ );
8972
+ }
8973
+ return registryCache.get(cacheKey);
8974
+ },
8996
8975
  addPlugin(plugin) {
8997
8976
  const pluginResult = plugin({
8998
8977
  ...properties,
@@ -9023,12 +9002,16 @@ function buildSdk(properties, context) {
9023
9002
  );
9024
9003
  }
9025
9004
  };
9005
+ return sdk;
9026
9006
  }
9027
9007
  function createZapierSdkWithoutRegistry(options = {}) {
9028
- return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
9008
+ logDeprecation(
9009
+ "createZapierSdkWithoutRegistry is deprecated; use createZapierSdk instead. getRegistry is now available on every sdk."
9010
+ );
9011
+ return createZapierSdk(options);
9029
9012
  }
9030
9013
  function createZapierSdk(options = {}) {
9031
- return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
9014
+ return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
9032
9015
  }
9033
9016
  var BaseSdkOptionsSchema = zod.z.object({
9034
9017
  credentials: CredentialsSchema.optional().describe(
@@ -9072,6 +9055,14 @@ var BaseSdkOptionsSchema = zod.z.object({
9072
9055
  // Use credentials instead
9073
9056
  });
9074
9057
 
9058
+ // src/plugins/registry/index.ts
9059
+ var registryPlugin = () => {
9060
+ logDeprecation(
9061
+ "registryPlugin is deprecated and a no-op; getRegistry is now built into every sdk. Remove .addPlugin(registryPlugin)."
9062
+ );
9063
+ return {};
9064
+ };
9065
+
9075
9066
  exports.ActionKeyPropertySchema = ActionKeyPropertySchema;
9076
9067
  exports.ActionPropertySchema = ActionPropertySchema;
9077
9068
  exports.ActionTimeoutMsPropertySchema = ActionTimeoutMsPropertySchema;