@zapier/zapier-sdk 0.16.3 → 0.18.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 (66) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +92 -92
  3. package/dist/api/schemas.d.ts +1 -1
  4. package/dist/api/schemas.js +1 -1
  5. package/dist/index.cjs +83 -46
  6. package/dist/index.d.mts +58 -100
  7. package/dist/index.mjs +83 -46
  8. package/dist/plugins/apps/index.js +2 -2
  9. package/dist/plugins/apps/schemas.d.ts +4 -3
  10. package/dist/plugins/apps/schemas.d.ts.map +1 -1
  11. package/dist/plugins/apps/schemas.js +3 -2
  12. package/dist/plugins/fetch/index.d.ts +2 -2
  13. package/dist/plugins/fetch/index.d.ts.map +1 -1
  14. package/dist/plugins/fetch/schemas.d.ts +1 -1
  15. package/dist/plugins/fetch/schemas.d.ts.map +1 -1
  16. package/dist/plugins/fetch/schemas.js +2 -4
  17. package/dist/plugins/findFirstAuthentication/index.test.js +4 -4
  18. package/dist/plugins/findUniqueAuthentication/index.test.js +4 -4
  19. package/dist/plugins/getAuthentication/index.js +1 -1
  20. package/dist/plugins/getAuthentication/index.test.js +9 -4
  21. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +1 -1
  22. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  23. package/dist/plugins/getProfile/index.js +7 -4
  24. package/dist/plugins/listAuthentications/index.test.js +9 -9
  25. package/dist/plugins/listInputFieldChoices/schemas.d.ts +1 -1
  26. package/dist/plugins/listInputFields/schemas.d.ts +1 -1
  27. package/dist/plugins/manifest/schemas.d.ts +2 -2
  28. package/dist/plugins/manifest/schemas.d.ts.map +1 -1
  29. package/dist/plugins/manifest/schemas.js +2 -5
  30. package/dist/plugins/request/index.d.ts.map +1 -1
  31. package/dist/plugins/request/index.js +2 -1
  32. package/dist/plugins/request/schemas.d.ts +2 -2
  33. package/dist/plugins/request/schemas.d.ts.map +1 -1
  34. package/dist/plugins/request/schemas.js +2 -5
  35. package/dist/plugins/runAction/schemas.d.ts +1 -1
  36. package/dist/resolvers/inputFieldKey.d.ts +1 -1
  37. package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
  38. package/dist/resolvers/inputs.d.ts +1 -1
  39. package/dist/resolvers/inputs.d.ts.map +1 -1
  40. package/dist/schemas/Auth.d.ts +6 -6
  41. package/dist/schemas/Auth.d.ts.map +1 -1
  42. package/dist/schemas/Auth.js +3 -1
  43. package/dist/schemas/UserProfile.d.ts +2 -44
  44. package/dist/schemas/UserProfile.d.ts.map +1 -1
  45. package/dist/schemas/UserProfile.js +10 -21
  46. package/dist/services/implementations.d.ts +2 -2
  47. package/dist/services/implementations.d.ts.map +1 -1
  48. package/dist/services/implementations.js +3 -2
  49. package/dist/temporary-internal-core/handlers/getAuthentication.test.js +7 -7
  50. package/dist/temporary-internal-core/schemas/authentications/index.d.ts +8 -8
  51. package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +1 -1
  52. package/dist/temporary-internal-core/schemas/authentications/index.js +6 -5
  53. package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
  54. package/dist/temporary-internal-core/utils/transformations.js +4 -2
  55. package/dist/types/properties.d.ts +1 -1
  56. package/dist/types/properties.d.ts.map +1 -1
  57. package/dist/types/properties.js +1 -2
  58. package/dist/utils/domain-utils.d.ts.map +1 -1
  59. package/dist/utils/domain-utils.js +4 -2
  60. package/dist/utils/id-utils.d.ts +13 -0
  61. package/dist/utils/id-utils.d.ts.map +1 -0
  62. package/dist/utils/id-utils.js +22 -0
  63. package/dist/utils/id-utils.test.d.ts +2 -0
  64. package/dist/utils/id-utils.test.d.ts.map +1 -0
  65. package/dist/utils/id-utils.test.js +22 -0
  66. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"domain-utils.d.ts","sourceRoot":"","sources":["../../src/utils/domain-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE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ACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAgCA;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG;IACrD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAUA;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOtD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAY1D;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAI9C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAkBvD;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,UAAU,GACrB,UAAU,IAAI,kBAAkB,CAElC;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,CAEzE"}
@@ -61,16 +61,18 @@ export function normalizeAuthenticationItem(auth, options = {}) {
61
61
  appVersion = extractedVersion;
62
62
  }
63
63
  }
64
- const { selected_api: selectedApi, customuser_id: userId, ...restOfAuth } = auth;
64
+ const { selected_api: selectedApi, customuser_id: profileId, id, account_id: accountId, ...restOfAuth } = auth;
65
65
  return {
66
66
  ...restOfAuth, // Pass through all other API response fields except selected_api
67
+ id: String(id), // Convert to string
68
+ account_id: String(accountId), // Convert to string
67
69
  implementation_id: selectedApi, // Rename selected_api to implementation_id
68
70
  title: auth.title || auth.label || undefined, // Coerce title from label if missing
69
71
  is_expired: auth.is_stale, // Map is_stale to is_expired
70
72
  expired_at: auth.marked_stale_at, // Map marked_stale_at to expired_at
71
73
  app_key: appKey, // App key from implementations endpoint or parsed from selected_api
72
74
  app_version: appVersion, // Version from selected_api or provided
73
- user_id: userId, // Map customuser_id to user_id
75
+ profile_id: profileId != null ? String(profileId) : undefined, // Map customuser_id to profile_id, convert to string
74
76
  };
75
77
  }
76
78
  export function normalizeActionItem(action) {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Utility functions for working with IDs
3
+ */
4
+ /**
5
+ * Coerces a string or number ID to a number for API calls that require numeric IDs.
6
+ *
7
+ * @param fieldName - The name of the field (for error messages)
8
+ * @param value - The ID value to coerce
9
+ * @returns The numeric ID
10
+ * @throws {ZapierValidationError} If the value cannot be converted to a valid number
11
+ */
12
+ export declare function coerceToNumericId(fieldName: string, value: string | number): number;
13
+ //# sourceMappingURL=id-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-utils.d.ts","sourceRoot":"","sources":["../../src/utils/id-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,MAAM,GACrB,MAAM,CAcR"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Utility functions for working with IDs
3
+ */
4
+ import { ZapierValidationError } from "../types/errors";
5
+ /**
6
+ * Coerces a string or number ID to a number for API calls that require numeric IDs.
7
+ *
8
+ * @param fieldName - The name of the field (for error messages)
9
+ * @param value - The ID value to coerce
10
+ * @returns The numeric ID
11
+ * @throws {ZapierValidationError} If the value cannot be converted to a valid number
12
+ */
13
+ export function coerceToNumericId(fieldName, value) {
14
+ if (value === "") {
15
+ throw new ZapierValidationError(`The ${fieldName} cannot be empty`);
16
+ }
17
+ const numericValue = typeof value === "number" ? value : Number(value);
18
+ if (!Number.isFinite(numericValue)) {
19
+ throw new ZapierValidationError(`The ${fieldName} "${value}" could not be converted to a number`);
20
+ }
21
+ return numericValue;
22
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=id-utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-utils.test.d.ts","sourceRoot":"","sources":["../../src/utils/id-utils.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { coerceToNumericId } from "./id-utils";
3
+ import { ZapierValidationError } from "../types/errors";
4
+ describe("coerceToNumericId", () => {
5
+ it("should return number unchanged", () => {
6
+ expect(coerceToNumericId("test_id", 123)).toBe(123);
7
+ });
8
+ it("should convert string number to number", () => {
9
+ expect(coerceToNumericId("test_id", "456")).toBe(456);
10
+ });
11
+ it("should throw for non-numeric string", () => {
12
+ expect(() => coerceToNumericId("auth_id", "abc")).toThrow(ZapierValidationError);
13
+ expect(() => coerceToNumericId("auth_id", "abc")).toThrow('The auth_id "abc" could not be converted to a number');
14
+ });
15
+ it("should throw for empty string", () => {
16
+ expect(() => coerceToNumericId("test_id", "")).toThrow(ZapierValidationError);
17
+ expect(() => coerceToNumericId("test_id", "")).toThrow("The test_id cannot be empty");
18
+ });
19
+ it("should throw for Infinity", () => {
20
+ expect(() => coerceToNumericId("test_id", Infinity)).toThrow(ZapierValidationError);
21
+ });
22
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk",
3
- "version": "0.16.3",
3
+ "version": "0.18.0",
4
4
  "description": "Complete Zapier SDK - combines all Zapier SDK packages",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",