@zapier/zapier-sdk 0.18.1 → 0.18.2
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 +6 -0
- package/README.md +5 -5
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +1 -7
- package/dist/api/router.test.js +1 -7
- package/dist/api/types.d.ts +2 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +0 -10
- package/dist/index.cjs +8 -199
- package/dist/index.d.mts +100 -191
- package/dist/index.mjs +8 -199
- package/dist/plugins/getAuthentication/index.d.ts +3 -3
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +3 -5
- package/dist/plugins/getAuthentication/index.test.js +4 -16
- package/dist/plugins/getAuthentication/schemas.d.ts +2 -4
- package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/schemas.js +1 -1
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/schemas/Auth.d.ts +11 -11
- package/dist/schemas/Auth.d.ts.map +1 -1
- package/dist/schemas/Auth.js +2 -12
- package/dist/sdk.d.ts +3 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/temporary-internal-core/index.d.ts +0 -2
- package/dist/temporary-internal-core/index.d.ts.map +1 -1
- package/dist/temporary-internal-core/index.js +0 -2
- package/dist/temporary-internal-core/utils/transformations.d.ts +1 -1
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/temporary-internal-core/handlers/getAuthentication.d.ts +0 -94
- package/dist/temporary-internal-core/handlers/getAuthentication.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/getAuthentication.js +0 -68
- package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts +0 -2
- package/dist/temporary-internal-core/handlers/getAuthentication.test.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/getAuthentication.test.js +0 -248
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts +0 -150
- package/dist/temporary-internal-core/schemas/authentications/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/authentications/index.js +0 -97
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { GetAuthenticationSchema, } from "./schemas";
|
|
2
1
|
import { createFunction } from "../../utils/function-utils";
|
|
3
2
|
import { authenticationIdGenericResolver } from "../../resolvers";
|
|
4
3
|
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
5
4
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
5
|
+
import { GetAuthenticationParamSchema, } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
|
|
6
6
|
export const getAuthenticationPlugin = ({ context }) => {
|
|
7
7
|
async function getAuthentication(options) {
|
|
8
8
|
const { api } = context;
|
|
9
|
-
// Call the SDK API endpoint, which will be routed to the handler via handlerOverride in pathConfig.
|
|
10
|
-
// When the handler is migrated to SDK API, this same API call will go over the network.
|
|
11
9
|
return await api.get(`/api/v0/authentications/${encodeURIComponent(options.authenticationId)}`);
|
|
12
10
|
}
|
|
13
|
-
const getAuthenticationDefinition = createFunction(getAuthentication,
|
|
11
|
+
const getAuthenticationDefinition = createFunction(getAuthentication, GetAuthenticationParamSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getAuthentication.name));
|
|
14
12
|
return {
|
|
15
13
|
getAuthentication: getAuthenticationDefinition,
|
|
16
14
|
context: {
|
|
@@ -19,7 +17,7 @@ export const getAuthenticationPlugin = ({ context }) => {
|
|
|
19
17
|
categories: ["authentication"],
|
|
20
18
|
type: "item",
|
|
21
19
|
itemType: "Authentication",
|
|
22
|
-
inputSchema:
|
|
20
|
+
inputSchema: GetAuthenticationParamSchema,
|
|
23
21
|
outputSchema: AuthenticationItemSchema,
|
|
24
22
|
resolvers: {
|
|
25
23
|
authenticationId: authenticationIdGenericResolver,
|
|
@@ -53,22 +53,10 @@ describe("getAuthentication plugin", () => {
|
|
|
53
53
|
authenticationId: true,
|
|
54
54
|
})).rejects.toThrow(ZapierValidationError);
|
|
55
55
|
});
|
|
56
|
-
it("should throw validation error for negative authenticationId", async () => {
|
|
57
|
-
const sdk = createTestSdk();
|
|
58
|
-
await expect(sdk.getAuthentication({
|
|
59
|
-
authenticationId: -1,
|
|
60
|
-
})).rejects.toThrow(ZapierValidationError);
|
|
61
|
-
});
|
|
62
|
-
it("should throw validation error for zero authenticationId", async () => {
|
|
63
|
-
const sdk = createTestSdk();
|
|
64
|
-
await expect(sdk.getAuthentication({
|
|
65
|
-
authenticationId: 0,
|
|
66
|
-
})).rejects.toThrow(ZapierValidationError);
|
|
67
|
-
});
|
|
68
56
|
it("should accept valid authenticationId", async () => {
|
|
69
57
|
const sdk = createTestSdk();
|
|
70
58
|
const result = await sdk.getAuthentication({
|
|
71
|
-
authenticationId: 123,
|
|
59
|
+
authenticationId: "123",
|
|
72
60
|
});
|
|
73
61
|
expect(result.data).toBeDefined();
|
|
74
62
|
expect(result.data.id).toBe("123");
|
|
@@ -77,7 +65,7 @@ describe("getAuthentication plugin", () => {
|
|
|
77
65
|
describe("SDK API endpoint routing", () => {
|
|
78
66
|
it("should call the correct SDK API endpoint with path params", async () => {
|
|
79
67
|
const sdk = createTestSdk();
|
|
80
|
-
await sdk.getAuthentication({ authenticationId: 123 });
|
|
68
|
+
await sdk.getAuthentication({ authenticationId: "123" });
|
|
81
69
|
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/authentications/123");
|
|
82
70
|
});
|
|
83
71
|
it("should URI encode string authenticationId in path", async () => {
|
|
@@ -87,7 +75,7 @@ describe("getAuthentication plugin", () => {
|
|
|
87
75
|
});
|
|
88
76
|
it("should return data from API response", async () => {
|
|
89
77
|
const sdk = createTestSdk();
|
|
90
|
-
const result = await sdk.getAuthentication({ authenticationId: 123 });
|
|
78
|
+
const result = await sdk.getAuthentication({ authenticationId: "123" });
|
|
91
79
|
expect(result.data).toEqual(mockAuthenticationItem);
|
|
92
80
|
});
|
|
93
81
|
});
|
|
@@ -95,7 +83,7 @@ describe("getAuthentication plugin", () => {
|
|
|
95
83
|
it("should propagate errors from API client", async () => {
|
|
96
84
|
mockApiClient.get = vi.fn().mockRejectedValue(new Error("API error"));
|
|
97
85
|
const sdk = createTestSdk();
|
|
98
|
-
await expect(sdk.getAuthentication({ authenticationId: 123 })).rejects.toThrow("API error");
|
|
86
|
+
await expect(sdk.getAuthentication({ authenticationId: "123" })).rejects.toThrow("API error");
|
|
99
87
|
});
|
|
100
88
|
});
|
|
101
89
|
describe("plugin metadata", () => {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { GetAuthenticationResponse } from "
|
|
1
|
+
import type { GetAuthenticationResponse, GetAuthenticationParam } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
|
|
2
2
|
import type { ZapierAuthenticationError, ZapierResourceNotFoundError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
|
|
3
|
-
import type { GetAuthenticationOptions } from "../../temporary-internal-core/schemas/authentications";
|
|
4
|
-
export { GetAuthenticationOptionsSchema as GetAuthenticationSchema, GetAuthenticationHandlerRequestSchema, GetAuthenticationResponseSchema, type GetAuthenticationOptions, type GetAuthenticationHandlerRequest, type GetAuthenticationResponse, } from "../../temporary-internal-core/schemas/authentications";
|
|
5
3
|
export type GetAuthenticationError = ZapierAuthenticationError | ZapierResourceNotFoundError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
6
4
|
export interface GetAuthenticationSdkFunction {
|
|
7
|
-
getAuthentication: (options:
|
|
5
|
+
getAuthentication: (options: GetAuthenticationParam) => Promise<GetAuthenticationResponse>;
|
|
8
6
|
}
|
|
9
7
|
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAuthentication/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,oDAAoD,CAAC;AAE5D,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,sBAAsB,GAC9B,yBAAyB,GACzB,2BAA2B,GAC3B,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,CACjB,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listAuthentications/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EACzB,KAAK,0BAA0B,EAEhC,MAAM,WAAW,CAAC;AAUnB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,0BAA0B,KAAK,OAAO,CAAC;QACrE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAC3B,UAAU,CAAC,E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CAAC;QAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QACnE,KAAK,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;KAC5C,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,mBAAmB,EAAE;gBACnB,WAAW,EAAE,OAAO,yBAAyB,CAAC;aAC/C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAC5C,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,iCAAiC,CAiHlC,CAAC"}
|
package/dist/schemas/Auth.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
export declare const AuthenticationItemSchema: z.ZodObject<{
|
|
3
|
-
url: z.ZodOptional<z.ZodString>;
|
|
4
|
-
members: z.ZodOptional<z.ZodString>;
|
|
5
|
-
label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
3
|
date: z.ZodString;
|
|
7
4
|
lastchanged: z.ZodOptional<z.ZodString>;
|
|
8
5
|
destination_selected_api: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -12,23 +9,23 @@ export declare const AuthenticationItemSchema: z.ZodObject<{
|
|
|
12
9
|
is_stale: z.ZodOptional<z.ZodString>;
|
|
13
10
|
is_shared: z.ZodOptional<z.ZodString>;
|
|
14
11
|
marked_stale_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
12
|
+
label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
13
|
identifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16
14
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
-
|
|
15
|
+
url: z.ZodOptional<z.ZodString>;
|
|
16
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
17
|
+
members: z.ZodOptional<z.ZodString>;
|
|
18
18
|
permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
19
19
|
id: z.ZodString;
|
|
20
20
|
account_id: z.ZodString;
|
|
21
21
|
implementation_id: z.ZodOptional<z.ZodString>;
|
|
22
|
+
profile_id: z.ZodOptional<z.ZodString>;
|
|
22
23
|
is_expired: z.ZodOptional<z.ZodString>;
|
|
23
24
|
expired_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
24
25
|
app_key: z.ZodOptional<z.ZodString>;
|
|
25
26
|
app_version: z.ZodOptional<z.ZodString>;
|
|
26
|
-
profile_id: z.ZodOptional<z.ZodString>;
|
|
27
27
|
}, z.core.$strip>;
|
|
28
28
|
export declare const AuthItemSchema: z.ZodObject<{
|
|
29
|
-
url: z.ZodOptional<z.ZodString>;
|
|
30
|
-
members: z.ZodOptional<z.ZodString>;
|
|
31
|
-
label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
29
|
date: z.ZodString;
|
|
33
30
|
lastchanged: z.ZodOptional<z.ZodString>;
|
|
34
31
|
destination_selected_api: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -38,18 +35,21 @@ export declare const AuthItemSchema: z.ZodObject<{
|
|
|
38
35
|
is_stale: z.ZodOptional<z.ZodString>;
|
|
39
36
|
is_shared: z.ZodOptional<z.ZodString>;
|
|
40
37
|
marked_stale_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
39
|
identifier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
40
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
|
-
|
|
41
|
+
url: z.ZodOptional<z.ZodString>;
|
|
42
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
43
|
+
members: z.ZodOptional<z.ZodString>;
|
|
44
44
|
permissions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
45
45
|
id: z.ZodString;
|
|
46
46
|
account_id: z.ZodString;
|
|
47
47
|
implementation_id: z.ZodOptional<z.ZodString>;
|
|
48
|
+
profile_id: z.ZodOptional<z.ZodString>;
|
|
48
49
|
is_expired: z.ZodOptional<z.ZodString>;
|
|
49
50
|
expired_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
51
|
app_key: z.ZodOptional<z.ZodString>;
|
|
51
52
|
app_version: z.ZodOptional<z.ZodString>;
|
|
52
|
-
profile_id: z.ZodOptional<z.ZodString>;
|
|
53
53
|
}, z.core.$strip>;
|
|
54
54
|
export type AuthItem = z.infer<typeof AuthItemSchema>;
|
|
55
55
|
//# sourceMappingURL=Auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../../src/schemas/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../../src/schemas/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQ7B,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;iBAgCpC,CAAC;AAGF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;iBAA2B,CAAC;AAMvD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
package/dist/schemas/Auth.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
1
|
import { withFormatter } from "../utils/schema-utils";
|
|
3
|
-
import {
|
|
2
|
+
import { AuthenticationItemSchema as AuthenticationItemSchemaBase } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
|
|
4
3
|
// ============================================================================
|
|
5
4
|
// Authentication Item Schema (extends API schema with computed fields and formatting)
|
|
6
5
|
// ============================================================================
|
|
7
|
-
export const AuthenticationItemSchema = withFormatter(
|
|
8
|
-
id: z.string(), // Converted from number
|
|
9
|
-
account_id: z.string(), // Converted from number
|
|
10
|
-
implementation_id: z.string().optional(), // Renamed from selected_api
|
|
11
|
-
is_expired: z.string().optional(), // Mapped from is_stale
|
|
12
|
-
expired_at: z.string().nullable().optional(), // Mapped from marked_stale_at
|
|
13
|
-
app_key: z.string().optional(), // App key from implementations endpoint
|
|
14
|
-
app_version: z.string().optional(), // Version extracted from implementation_id
|
|
15
|
-
profile_id: z.string().optional(), // Mapped from customuser_id, converted from number
|
|
16
|
-
}), {
|
|
6
|
+
export const AuthenticationItemSchema = withFormatter(AuthenticationItemSchemaBase, {
|
|
17
7
|
format: (item) => {
|
|
18
8
|
const details = [];
|
|
19
9
|
if (item.identifier) {
|
package/dist/sdk.d.ts
CHANGED
|
@@ -100,7 +100,9 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
|
|
|
100
100
|
} & {
|
|
101
101
|
meta: {
|
|
102
102
|
getAuthentication: {
|
|
103
|
-
inputSchema:
|
|
103
|
+
inputSchema: import("zod").ZodObject<{
|
|
104
|
+
authenticationId: import("zod").ZodString;
|
|
105
|
+
}, import("zod/v4/core").$strip>;
|
|
104
106
|
};
|
|
105
107
|
};
|
|
106
108
|
} & {
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD,OAAO,KAAK,EAAE,SAAS,EAA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MAAM,gBAAgB,CAAC;AA2BxB,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,wBAAgB,SAAS,CACvB,WAAW,GAAG,EAAE,EAChB,eAAe,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,GAAG;IAC7D,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAClC,EAED,OAAO,GAAE,gBAAqB,EAC9B,UAAU,GAAE,WAA+B,EAC3C,cAAc,GAAE,eAAiD;;cAKrD,gBAAgB,EAAE,SAAS,SAAS,cAAc,UAClD,MAAM,CACZ,WAAW,GAAG;QAAE,UAAU,IAAI,eAAe,CAAA;KAAE,EAC/C,gBAAgB,EAChB,SAAS,CACV,qBACiB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,GAAG,CACJ,WAAW,GAAG,oBAAoB,CAAC,SAAS,CAAC,EAC7C,eAAe,GAAG,WAAW,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC,CACnE;EA8DJ;AAED,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,gBAAqB;UApFnE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;;;;;;;;;;;+BAD2B,CAAC;kBAC/C,CAAC;;;;kBAKG,CAAC;iBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuH/C;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAMzE"}
|
|
@@ -14,7 +14,5 @@
|
|
|
14
14
|
export type { HandlerDeps, Handler, ValidatedHandler } from "./types";
|
|
15
15
|
export * from "./schemas/apps";
|
|
16
16
|
export * from "./schemas/implementations";
|
|
17
|
-
export * from "./schemas/authentications";
|
|
18
17
|
export { handleListApps, type ListAppsHandlerDeps } from "./handlers/listApps";
|
|
19
|
-
export { handleGetAuthentication, type GetAuthenticationHandlerDeps, } from "./handlers/getAuthentication";
|
|
20
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/temporary-internal-core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGtE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/temporary-internal-core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGtE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,2BAA2B,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -14,7 +14,5 @@
|
|
|
14
14
|
// Schemas
|
|
15
15
|
export * from "./schemas/apps";
|
|
16
16
|
export * from "./schemas/implementations";
|
|
17
|
-
export * from "./schemas/authentications";
|
|
18
17
|
// Handlers
|
|
19
18
|
export { handleListApps } from "./handlers/listApps";
|
|
20
|
-
export { handleGetAuthentication, } from "./handlers/getAuthentication";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ImplementationMeta } from "../schemas/implementations";
|
|
7
7
|
import type { AppItem } from "../schemas/apps";
|
|
8
|
-
import { type Authentication, type AuthenticationItem } from "
|
|
8
|
+
import { type Authentication, type AuthenticationItem } from "@zapier/zapier-sdk-core/v0/schemas/authentications";
|
|
9
9
|
/**
|
|
10
10
|
* Transforms ImplementationMeta from internal API to AppItem for SDK responses
|
|
11
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformations.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/utils/transformations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,
|
|
1
|
+
{"version":3,"file":"transformations.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/utils/transformations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,wBAAgB,oCAAoC,CAClD,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CAYT;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE;IAChD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,GAAG,MAAM,GAAG,SAAS,CAYrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,cAAc,EACpB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACvD,kBAAkB,CAyCpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@zapier/zapier-sdk-core": "^0.5.0",
|
|
39
40
|
"zod": "4.2.1"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Handler for getAuthentication operation
|
|
3
|
-
*
|
|
4
|
-
* This handler will become an SDK API endpoint handler.
|
|
5
|
-
* It encapsulates the business logic for retrieving a single authentication, including:
|
|
6
|
-
* - API call to internal authentication endpoint
|
|
7
|
-
* - Custom error handling (401, 403, 404)
|
|
8
|
-
* - Response transformation (field renaming, computed fields)
|
|
9
|
-
*
|
|
10
|
-
* The handler receives a validated authentication ID and returns normalized data.
|
|
11
|
-
*/
|
|
12
|
-
import type { Handler, HandlerDeps } from "../types";
|
|
13
|
-
import { type GetAuthenticationHandlerRequest, type GetAuthenticationResponse } from "../schemas/authentications";
|
|
14
|
-
/**
|
|
15
|
-
* Simple HTTP client interface for calling internal APIs
|
|
16
|
-
*
|
|
17
|
-
* Why pass this as a dependency instead of importing directly?
|
|
18
|
-
*
|
|
19
|
-
* 1. **Different implementations in different contexts:**
|
|
20
|
-
* - In the SDK: Uses the ApiClient wrapper (adds auth, error handling, etc.)
|
|
21
|
-
* - In the SDK API: Would use internal HTTP client or direct service calls
|
|
22
|
-
*
|
|
23
|
-
* 2. **Testability:**
|
|
24
|
-
* - Can mock httpClient in tests without complex setup
|
|
25
|
-
* - Can verify API calls and responses in isolation
|
|
26
|
-
*
|
|
27
|
-
* 3. **No hard coupling:**
|
|
28
|
-
* - Handler doesn't know/care how HTTP calls are made
|
|
29
|
-
* - Makes migration to SDK API easier (just swap implementation)
|
|
30
|
-
*/
|
|
31
|
-
export interface HttpClient {
|
|
32
|
-
get<T = unknown>(path: string, options?: {
|
|
33
|
-
searchParams?: Record<string, string>;
|
|
34
|
-
authRequired?: boolean;
|
|
35
|
-
customErrorHandler?: (errorInfo: {
|
|
36
|
-
status: number;
|
|
37
|
-
statusText: string;
|
|
38
|
-
data: unknown;
|
|
39
|
-
}) => Error | undefined;
|
|
40
|
-
}): Promise<T>;
|
|
41
|
-
post<T = unknown>(path: string, data?: unknown, options?: {
|
|
42
|
-
authRequired?: boolean;
|
|
43
|
-
customErrorHandler?: (errorInfo: {
|
|
44
|
-
status: number;
|
|
45
|
-
statusText: string;
|
|
46
|
-
data: unknown;
|
|
47
|
-
}) => Error | undefined;
|
|
48
|
-
}): Promise<T>;
|
|
49
|
-
delete<T = unknown>(path: string, options?: {
|
|
50
|
-
authRequired?: boolean;
|
|
51
|
-
customErrorHandler?: (errorInfo: {
|
|
52
|
-
status: number;
|
|
53
|
-
statusText: string;
|
|
54
|
-
data: unknown;
|
|
55
|
-
}) => Error | undefined;
|
|
56
|
-
}): Promise<T>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Dependencies required by the getAuthentication handler
|
|
60
|
-
*
|
|
61
|
-
* Passed as a parameter (dependency injection) rather than imported directly
|
|
62
|
-
* to allow different implementations in different environments:
|
|
63
|
-
* - SDK plugin injects: { httpClient: api } (SDK's ApiClient)
|
|
64
|
-
* - SDK API would inject: { httpClient: internalHttpClient } (direct internal calls)
|
|
65
|
-
* - Tests inject: { httpClient: mockHttpClient } (mocked responses)
|
|
66
|
-
*
|
|
67
|
-
* Extends HandlerDeps to ensure compatibility with the Handler interface.
|
|
68
|
-
*/
|
|
69
|
-
export interface GetAuthenticationHandlerDeps extends HandlerDeps {
|
|
70
|
-
httpClient: HttpClient;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Handles getAuthentication operation
|
|
74
|
-
*
|
|
75
|
-
* Conforms to the Handler<TRequest, TResponse, TDeps> interface contract.
|
|
76
|
-
*
|
|
77
|
-
* Flow:
|
|
78
|
-
* 1. Validates request (schema validation happens at plugin boundary)
|
|
79
|
-
* 2. Makes API call to /authentications/{id}/ with custom error handler
|
|
80
|
-
* 3. Transforms response to normalized AuthenticationItem
|
|
81
|
-
* 4. Returns wrapped in { data } envelope
|
|
82
|
-
*
|
|
83
|
-
* Error handling:
|
|
84
|
-
* - 401: Authentication error (invalid/expired token)
|
|
85
|
-
* - 403: Forbidden (insufficient scopes)
|
|
86
|
-
* - 404: Authentication not found
|
|
87
|
-
* - Other: Propagates original error
|
|
88
|
-
*
|
|
89
|
-
* @param request - The authentication ID to retrieve
|
|
90
|
-
* @param deps - Dependencies injected by the caller (httpClient)
|
|
91
|
-
* @returns Single authentication item wrapped in data envelope
|
|
92
|
-
*/
|
|
93
|
-
export declare const handleGetAuthentication: Handler<GetAuthenticationHandlerRequest, GetAuthenticationResponse, GetAuthenticationHandlerDeps>;
|
|
94
|
-
//# sourceMappingURL=getAuthentication.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthentication.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/handlers/getAuthentication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAEL,KAAK,+BAA+B,EACpC,KAAK,yBAAyB,EAE/B,MAAM,4BAA4B,CAAC;AAOpC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,CAAC,GAAG,OAAO,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE;YAC/B,MAAM,EAAE,MAAM,CAAC;YACf,UAAU,EAAE,MAAM,CAAC;YACnB,IAAI,EAAE,OAAO,CAAC;SACf,KAAK,KAAK,GAAG,SAAS,CAAC;KACzB,GACA,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,IAAI,CAAC,CAAC,GAAG,OAAO,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE;YAC/B,MAAM,EAAE,MAAM,CAAC;YACf,UAAU,EAAE,MAAM,CAAC;YACnB,IAAI,EAAE,OAAO,CAAC;SACf,KAAK,KAAK,GAAG,SAAS,CAAC;KACzB,GACA,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,MAAM,CAAC,CAAC,GAAG,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE;YAC/B,MAAM,EAAE,MAAM,CAAC;YACf,UAAU,EAAE,MAAM,CAAC;YACnB,IAAI,EAAE,OAAO,CAAC;SACf,KAAK,KAAK,GAAG,SAAS,CAAC;KACzB,GACA,OAAO,CAAC,CAAC,CAAC,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,4BAA6B,SAAQ,WAAW;IAC/D,UAAU,EAAE,UAAU,CAAC;CACxB;AAMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAC3C,+BAA+B,EAC/B,yBAAyB,EACzB,4BAA4B,CA8C7B,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Handler for getAuthentication operation
|
|
3
|
-
*
|
|
4
|
-
* This handler will become an SDK API endpoint handler.
|
|
5
|
-
* It encapsulates the business logic for retrieving a single authentication, including:
|
|
6
|
-
* - API call to internal authentication endpoint
|
|
7
|
-
* - Custom error handling (401, 403, 404)
|
|
8
|
-
* - Response transformation (field renaming, computed fields)
|
|
9
|
-
*
|
|
10
|
-
* The handler receives a validated authentication ID and returns normalized data.
|
|
11
|
-
*/
|
|
12
|
-
import { GetAuthenticationHandlerRequestSchema, } from "../schemas/authentications";
|
|
13
|
-
import { ZapierAuthenticationError, ZapierResourceNotFoundError, } from "../schemas/errors";
|
|
14
|
-
import { normalizeAuthenticationItem } from "../utils/transformations";
|
|
15
|
-
// ============================================================================
|
|
16
|
-
// Handler Implementation
|
|
17
|
-
// ============================================================================
|
|
18
|
-
/**
|
|
19
|
-
* Handles getAuthentication operation
|
|
20
|
-
*
|
|
21
|
-
* Conforms to the Handler<TRequest, TResponse, TDeps> interface contract.
|
|
22
|
-
*
|
|
23
|
-
* Flow:
|
|
24
|
-
* 1. Validates request (schema validation happens at plugin boundary)
|
|
25
|
-
* 2. Makes API call to /authentications/{id}/ with custom error handler
|
|
26
|
-
* 3. Transforms response to normalized AuthenticationItem
|
|
27
|
-
* 4. Returns wrapped in { data } envelope
|
|
28
|
-
*
|
|
29
|
-
* Error handling:
|
|
30
|
-
* - 401: Authentication error (invalid/expired token)
|
|
31
|
-
* - 403: Forbidden (insufficient scopes)
|
|
32
|
-
* - 404: Authentication not found
|
|
33
|
-
* - Other: Propagates original error
|
|
34
|
-
*
|
|
35
|
-
* @param request - The authentication ID to retrieve
|
|
36
|
-
* @param deps - Dependencies injected by the caller (httpClient)
|
|
37
|
-
* @returns Single authentication item wrapped in data envelope
|
|
38
|
-
*/
|
|
39
|
-
export const handleGetAuthentication = async ({ request, deps }) => {
|
|
40
|
-
// Validate and normalize request at handler boundary
|
|
41
|
-
const validatedRequest = GetAuthenticationHandlerRequestSchema.parse(request);
|
|
42
|
-
const { httpClient } = deps;
|
|
43
|
-
const { authenticationId } = validatedRequest;
|
|
44
|
-
// Make API call with custom error handling
|
|
45
|
-
const authentication = await httpClient.get(`/zapier/api/v4/authentications/${authenticationId}/`, {
|
|
46
|
-
authRequired: true,
|
|
47
|
-
customErrorHandler: ({ status }) => {
|
|
48
|
-
if (status === 401) {
|
|
49
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
50
|
-
}
|
|
51
|
-
if (status === 403) {
|
|
52
|
-
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to get authentication ${authenticationId}. (HTTP ${status})`, { statusCode: status });
|
|
53
|
-
}
|
|
54
|
-
if (status === 404) {
|
|
55
|
-
return new ZapierResourceNotFoundError(`Authentication ${authenticationId} not found. It may not exist or you may not have access to it. (HTTP ${status})`, {
|
|
56
|
-
resourceType: "Authentication",
|
|
57
|
-
resourceId: String(authenticationId),
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return undefined; // Let default error handling take over
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
// Transform to normalized AuthenticationItem
|
|
64
|
-
const normalizedAuthentication = normalizeAuthenticationItem(authentication);
|
|
65
|
-
return {
|
|
66
|
-
data: normalizedAuthentication,
|
|
67
|
-
};
|
|
68
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAuthentication.test.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/handlers/getAuthentication.test.ts"],"names":[],"mappings":""}
|