@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.
- package/CHANGELOG.md +12 -0
- package/README.md +92 -92
- package/dist/api/schemas.d.ts +1 -1
- package/dist/api/schemas.js +1 -1
- package/dist/index.cjs +83 -46
- package/dist/index.d.mts +58 -100
- package/dist/index.mjs +83 -46
- package/dist/plugins/apps/index.js +2 -2
- package/dist/plugins/apps/schemas.d.ts +4 -3
- package/dist/plugins/apps/schemas.d.ts.map +1 -1
- package/dist/plugins/apps/schemas.js +3 -2
- package/dist/plugins/fetch/index.d.ts +2 -2
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.d.ts +1 -1
- package/dist/plugins/fetch/schemas.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.js +2 -4
- package/dist/plugins/findFirstAuthentication/index.test.js +4 -4
- package/dist/plugins/findUniqueAuthentication/index.test.js +4 -4
- package/dist/plugins/getAuthentication/index.js +1 -1
- package/dist/plugins/getAuthentication/index.test.js +9 -4
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +1 -1
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +7 -4
- package/dist/plugins/listAuthentications/index.test.js +9 -9
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +1 -1
- package/dist/plugins/listInputFields/schemas.d.ts +1 -1
- package/dist/plugins/manifest/schemas.d.ts +2 -2
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +2 -5
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +2 -1
- package/dist/plugins/request/schemas.d.ts +2 -2
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/request/schemas.js +2 -5
- package/dist/plugins/runAction/schemas.d.ts +1 -1
- package/dist/resolvers/inputFieldKey.d.ts +1 -1
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
- package/dist/resolvers/inputs.d.ts +1 -1
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/schemas/Auth.d.ts +6 -6
- package/dist/schemas/Auth.d.ts.map +1 -1
- package/dist/schemas/Auth.js +3 -1
- package/dist/schemas/UserProfile.d.ts +2 -44
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +10 -21
- package/dist/services/implementations.d.ts +2 -2
- package/dist/services/implementations.d.ts.map +1 -1
- package/dist/services/implementations.js +3 -2
- package/dist/temporary-internal-core/handlers/getAuthentication.test.js +7 -7
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts +8 -8
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/schemas/authentications/index.js +6 -5
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
- package/dist/temporary-internal-core/utils/transformations.js +4 -2
- package/dist/types/properties.d.ts +1 -1
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/properties.js +1 -2
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +4 -2
- package/dist/utils/id-utils.d.ts +13 -0
- package/dist/utils/id-utils.d.ts.map +1 -0
- package/dist/utils/id-utils.js +22 -0
- package/dist/utils/id-utils.test.d.ts +2 -0
- package/dist/utils/id-utils.test.d.ts.map +1 -0
- package/dist/utils/id-utils.test.js +22 -0
- 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,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;;;;;;GASG;AACH,wB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AAE,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:
|
|
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
|
-
|
|
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 @@
|
|
|
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
|
+
});
|