@zapier/zapier-sdk 0.26.0 → 0.27.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 +6 -0
- package/CLAUDE.md +6 -6
- package/README.md +217 -222
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/types.d.ts +3 -3
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +367 -216
- package/dist/index.d.mts +171 -91
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +359 -211
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +20 -13
- package/dist/plugins/apps/schemas.d.ts +6 -2
- package/dist/plugins/apps/schemas.d.ts.map +1 -1
- package/dist/plugins/apps/schemas.js +7 -3
- package/dist/plugins/deprecated/authentications.d.ts +79 -0
- package/dist/plugins/deprecated/authentications.d.ts.map +1 -0
- package/dist/plugins/deprecated/authentications.js +90 -0
- package/dist/plugins/fetch/index.d.ts +4 -0
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +7 -4
- package/dist/plugins/fetch/schemas.d.ts +1 -0
- package/dist/plugins/fetch/schemas.d.ts.map +1 -1
- package/dist/plugins/fetch/schemas.js +3 -1
- package/dist/plugins/findFirstConnection/index.d.ts +21 -0
- package/dist/plugins/findFirstConnection/index.d.ts.map +1 -0
- package/dist/plugins/findFirstConnection/index.js +37 -0
- package/dist/plugins/findFirstConnection/index.test.d.ts.map +1 -0
- package/dist/plugins/{findFirstAuthentication → findFirstConnection}/index.test.js +43 -43
- package/dist/plugins/findFirstConnection/schemas.d.ts +22 -0
- package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -0
- package/dist/plugins/findFirstConnection/schemas.js +8 -0
- package/dist/plugins/findUniqueConnection/index.d.ts +21 -0
- package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -0
- package/dist/plugins/findUniqueConnection/index.js +40 -0
- package/dist/plugins/findUniqueConnection/index.test.d.ts.map +1 -0
- package/dist/plugins/{findUniqueAuthentication → findUniqueConnection}/index.test.js +41 -41
- package/dist/plugins/findUniqueConnection/schemas.d.ts +22 -0
- package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -0
- package/dist/plugins/findUniqueConnection/schemas.js +8 -0
- package/dist/plugins/getApp/index.js +2 -2
- package/dist/plugins/getConnection/index.d.ts +22 -0
- package/dist/plugins/getConnection/index.d.ts.map +1 -0
- package/dist/plugins/getConnection/index.js +35 -0
- package/dist/plugins/getConnection/index.test.d.ts.map +1 -0
- package/dist/plugins/{getAuthentication → getConnection}/index.test.js +46 -28
- package/dist/plugins/getConnection/schemas.d.ts +13 -0
- package/dist/plugins/getConnection/schemas.d.ts.map +1 -0
- package/dist/plugins/getConnection/schemas.js +8 -0
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.js +7 -4
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +1 -0
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/schemas.js +6 -2
- package/dist/plugins/listApps/schemas.js +2 -2
- package/dist/plugins/listClientCredentials/schemas.js +2 -2
- package/dist/plugins/listConnections/index.d.ts +24 -0
- package/dist/plugins/listConnections/index.d.ts.map +1 -0
- package/dist/plugins/{listAuthentications → listConnections}/index.js +28 -21
- package/dist/plugins/listConnections/index.test.d.ts.map +1 -0
- package/dist/plugins/{listAuthentications → listConnections}/index.test.js +219 -198
- package/dist/plugins/{listAuthentications → listConnections}/schemas.d.ts +11 -10
- package/dist/plugins/listConnections/schemas.d.ts.map +1 -0
- package/dist/plugins/listConnections/schemas.js +47 -0
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +8 -5
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +1 -0
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +3 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +7 -4
- package/dist/plugins/listInputFields/schemas.d.ts +1 -0
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFields/schemas.js +3 -1
- package/dist/plugins/manifest/schemas.d.ts +2 -0
- package/dist/plugins/manifest/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/schemas.js +3 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +3 -2
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +5 -2
- package/dist/plugins/request/schemas.d.ts +2 -0
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/request/schemas.js +3 -1
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +12 -8
- package/dist/plugins/runAction/schemas.d.ts +1 -0
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/schemas.js +4 -2
- package/dist/resolvers/connectionId.d.ts +9 -0
- package/dist/resolvers/connectionId.d.ts.map +1 -0
- package/dist/resolvers/connectionId.js +42 -0
- package/dist/resolvers/index.d.ts +5 -1
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +6 -1
- package/dist/resolvers/inputFieldKey.d.ts +1 -1
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
- package/dist/resolvers/inputFieldKey.js +2 -2
- package/dist/resolvers/inputs.d.ts +1 -1
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/resolvers/inputs.js +4 -4
- package/dist/schemas/Connection.d.ts +29 -0
- package/dist/schemas/Connection.d.ts.map +1 -0
- package/dist/schemas/{Auth.js → Connection.js} +5 -7
- package/dist/sdk.d.ts +29 -7
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +12 -5
- package/dist/sdk.test.js +9 -8
- package/dist/services/implementations.d.ts +6 -6
- package/dist/services/implementations.d.ts.map +1 -1
- package/dist/services/implementations.js +10 -10
- package/dist/types/domain.d.ts +4 -4
- package/dist/types/domain.d.ts.map +1 -1
- package/dist/types/properties.d.ts +5 -1
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/properties.js +4 -2
- package/dist/types/sdk.d.ts +12 -9
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/plugins/findFirstAuthentication/index.d.ts +0 -21
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/index.js +0 -36
- package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +0 -21
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/findFirstAuthentication/schemas.js +0 -8
- package/dist/plugins/findUniqueAuthentication/index.d.ts +0 -21
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/index.js +0 -39
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +0 -21
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/findUniqueAuthentication/schemas.js +0 -8
- package/dist/plugins/getAuthentication/index.d.ts +0 -21
- package/dist/plugins/getAuthentication/index.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/index.js +0 -29
- package/dist/plugins/getAuthentication/index.test.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/schemas.d.ts +0 -7
- package/dist/plugins/getAuthentication/schemas.d.ts.map +0 -1
- package/dist/plugins/getAuthentication/schemas.js +0 -1
- package/dist/plugins/listAuthentications/index.d.ts +0 -24
- package/dist/plugins/listAuthentications/index.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/index.test.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/schemas.d.ts.map +0 -1
- package/dist/plugins/listAuthentications/schemas.js +0 -32
- package/dist/resolvers/authenticationId.d.ts +0 -9
- package/dist/resolvers/authenticationId.d.ts.map +0 -1
- package/dist/resolvers/authenticationId.js +0 -42
- package/dist/schemas/Auth.d.ts +0 -55
- package/dist/schemas/Auth.d.ts.map +0 -1
- /package/dist/plugins/{findFirstAuthentication → findFirstConnection}/index.test.d.ts +0 -0
- /package/dist/plugins/{findUniqueAuthentication → findUniqueConnection}/index.test.d.ts +0 -0
- /package/dist/plugins/{getAuthentication → getConnection}/index.test.d.ts +0 -0
- /package/dist/plugins/{listAuthentications → listConnections}/index.test.d.ts +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
2
|
import { ZapierValidationError } from "../../types/errors";
|
|
3
|
-
import {
|
|
3
|
+
import { getConnectionPlugin } from "./index";
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
5
|
import { eventEmissionPlugin } from "../eventEmission";
|
|
6
|
-
const
|
|
6
|
+
const mockConnectionItem = {
|
|
7
7
|
id: "123",
|
|
8
8
|
date: "2021-01-01",
|
|
9
9
|
account_id: "456",
|
|
@@ -18,12 +18,12 @@ const mockAuthenticationItem = {
|
|
|
18
18
|
app_key: "SlackCLIAPI",
|
|
19
19
|
app_version: "1.21.1",
|
|
20
20
|
};
|
|
21
|
-
describe("
|
|
21
|
+
describe("getConnection plugin", () => {
|
|
22
22
|
let mockApiClient;
|
|
23
23
|
beforeEach(() => {
|
|
24
24
|
vi.clearAllMocks();
|
|
25
25
|
mockApiClient = {
|
|
26
|
-
get: vi.fn().mockResolvedValue({ data:
|
|
26
|
+
get: vi.fn().mockResolvedValue({ data: mockConnectionItem }),
|
|
27
27
|
};
|
|
28
28
|
});
|
|
29
29
|
const apiPlugin = () => ({
|
|
@@ -40,23 +40,23 @@ describe("getAuthentication plugin", () => {
|
|
|
40
40
|
}))
|
|
41
41
|
.addPlugin(apiPlugin)
|
|
42
42
|
.addPlugin(eventEmissionPlugin)
|
|
43
|
-
.addPlugin(
|
|
43
|
+
.addPlugin(getConnectionPlugin);
|
|
44
44
|
}
|
|
45
45
|
describe("input validation", () => {
|
|
46
|
-
it("should throw validation error for missing
|
|
46
|
+
it("should throw validation error for missing connectionId", async () => {
|
|
47
47
|
const sdk = createTestSdk();
|
|
48
|
-
await expect(sdk.
|
|
48
|
+
await expect(sdk.getConnection({})).rejects.toThrow("connectionId is required");
|
|
49
49
|
});
|
|
50
|
-
it("should throw validation error for invalid
|
|
50
|
+
it("should throw validation error for invalid connectionId type", async () => {
|
|
51
51
|
const sdk = createTestSdk();
|
|
52
|
-
await expect(sdk.
|
|
53
|
-
|
|
52
|
+
await expect(sdk.getConnection({
|
|
53
|
+
connectionId: true,
|
|
54
54
|
})).rejects.toThrow(ZapierValidationError);
|
|
55
55
|
});
|
|
56
|
-
it("should accept valid
|
|
56
|
+
it("should accept valid connectionId", async () => {
|
|
57
57
|
const sdk = createTestSdk();
|
|
58
|
-
const result = await sdk.
|
|
59
|
-
|
|
58
|
+
const result = await sdk.getConnection({
|
|
59
|
+
connectionId: "123",
|
|
60
60
|
});
|
|
61
61
|
expect(result.data).toBeDefined();
|
|
62
62
|
expect(result.data.id).toBe("123");
|
|
@@ -65,42 +65,60 @@ describe("getAuthentication plugin", () => {
|
|
|
65
65
|
describe("SDK API endpoint routing", () => {
|
|
66
66
|
it("should call the correct SDK API endpoint with path params", async () => {
|
|
67
67
|
const sdk = createTestSdk();
|
|
68
|
-
await sdk.
|
|
69
|
-
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/
|
|
68
|
+
await sdk.getConnection({ connectionId: "123" });
|
|
69
|
+
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/connections/123");
|
|
70
70
|
});
|
|
71
|
-
it("should URI encode string
|
|
71
|
+
it("should URI encode string connectionId in path", async () => {
|
|
72
72
|
const sdk = createTestSdk();
|
|
73
|
-
await sdk.
|
|
74
|
-
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/
|
|
73
|
+
await sdk.getConnection({ connectionId: "test/with spaces" });
|
|
74
|
+
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/connections/test%2Fwith%20spaces");
|
|
75
75
|
});
|
|
76
76
|
it("should return data from API response", async () => {
|
|
77
77
|
const sdk = createTestSdk();
|
|
78
|
-
const result = await sdk.
|
|
79
|
-
expect(result.data).toEqual(
|
|
78
|
+
const result = await sdk.getConnection({ connectionId: "123" });
|
|
79
|
+
expect(result.data).toEqual(mockConnectionItem);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe("deprecated authenticationId support", () => {
|
|
83
|
+
it("should accept deprecated authenticationId parameter", async () => {
|
|
84
|
+
const sdk = createTestSdk();
|
|
85
|
+
const result = await sdk.getConnection({
|
|
86
|
+
authenticationId: "123",
|
|
87
|
+
});
|
|
88
|
+
expect(result.data).toBeDefined();
|
|
89
|
+
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/connections/123");
|
|
90
|
+
});
|
|
91
|
+
it("should prefer connectionId over authenticationId when both provided", async () => {
|
|
92
|
+
const sdk = createTestSdk();
|
|
93
|
+
await sdk.getConnection({
|
|
94
|
+
connectionId: "new-id",
|
|
95
|
+
authenticationId: "old-id",
|
|
96
|
+
});
|
|
97
|
+
expect(mockApiClient.get).toHaveBeenCalledWith("/api/v0/connections/new-id");
|
|
80
98
|
});
|
|
81
99
|
});
|
|
82
100
|
describe("error propagation", () => {
|
|
83
101
|
it("should propagate errors from API client", async () => {
|
|
84
102
|
mockApiClient.get = vi.fn().mockRejectedValue(new Error("API error"));
|
|
85
103
|
const sdk = createTestSdk();
|
|
86
|
-
await expect(sdk.
|
|
104
|
+
await expect(sdk.getConnection({ connectionId: "123" })).rejects.toThrow("API error");
|
|
87
105
|
});
|
|
88
106
|
});
|
|
89
107
|
describe("plugin metadata", () => {
|
|
90
108
|
it("should provide metadata in SDK context", () => {
|
|
91
109
|
const sdk = createTestSdk();
|
|
92
110
|
const context = sdk.getContext();
|
|
93
|
-
expect(context.meta.
|
|
94
|
-
expect(context.meta.
|
|
95
|
-
expect(context.meta.
|
|
96
|
-
expect(context.meta.
|
|
97
|
-
expect(context.meta.
|
|
111
|
+
expect(context.meta.getConnection).toBeDefined();
|
|
112
|
+
expect(context.meta.getConnection.inputSchema).toBeDefined();
|
|
113
|
+
expect(context.meta.getConnection.outputSchema).toBeDefined();
|
|
114
|
+
expect(context.meta.getConnection.type).toBe("item");
|
|
115
|
+
expect(context.meta.getConnection.itemType).toBe("Connection");
|
|
98
116
|
});
|
|
99
117
|
it("should include resolvers in metadata", () => {
|
|
100
118
|
const sdk = createTestSdk();
|
|
101
119
|
const context = sdk.getContext();
|
|
102
|
-
expect(context.meta.
|
|
103
|
-
expect(context.meta.
|
|
120
|
+
expect(context.meta.getConnection.resolvers).toBeDefined();
|
|
121
|
+
expect(context.meta.getConnection.resolvers.connectionId).toBeDefined();
|
|
104
122
|
});
|
|
105
123
|
});
|
|
106
124
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GetConnectionResponse } from "@zapier/zapier-sdk-core/v0/schemas/connections";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { ZapierAuthenticationError, ZapierResourceNotFoundError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
|
|
4
|
+
export declare const GetConnectionParamSchema: z.ZodObject<{
|
|
5
|
+
connectionId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
6
|
+
authenticationId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type GetConnectionParam = z.infer<typeof GetConnectionParamSchema>;
|
|
9
|
+
export type GetConnectionError = ZapierAuthenticationError | ZapierResourceNotFoundError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
10
|
+
export interface GetConnectionSdkFunction {
|
|
11
|
+
getConnection: (options: GetConnectionParam) => Promise<GetConnectionResponse>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getConnection/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,wBAAwB;;;iBAInC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAG1E,MAAM,MAAM,kBAAkB,GAC1B,yBAAyB,GACzB,2BAA2B,GAC3B,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,CACb,OAAO,EAAE,kBAAkB,KACxB,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ConnectionIdPropertySchema } from "../../types/properties";
|
|
3
|
+
// Schema that supports both connectionId (new) and authenticationId (deprecated)
|
|
4
|
+
export const GetConnectionParamSchema = z.object({
|
|
5
|
+
connectionId: ConnectionIdPropertySchema.optional(),
|
|
6
|
+
/** @deprecated Use connectionId instead */
|
|
7
|
+
authenticationId: ConnectionIdPropertySchema.optional(),
|
|
8
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,KAAK,2BAA2B,IAAI,2BAA2B,EAChE,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAUxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,kCAAkC;IACjD,oBAAoB,EAAE,CACpB,OAAO,EAAE,2BAA2B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAChD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,oBAAoB,EAAE;gBACpB,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAC7C,UAAU,CAAC,uBAAuB,CAAC,EACnC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,kCAAkC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,KAAK,2BAA2B,IAAI,2BAA2B,EAChE,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAUxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,WAAW,kCAAkC;IACjD,oBAAoB,EAAE,CACpB,OAAO,EAAE,2BAA2B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAChD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,oBAAoB,EAAE;gBACpB,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAC7C,UAAU,CAAC,uBAAuB,CAAC,EACnC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,kCAAkC,CA8EnC,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { GetInputFieldsSchemaSchema, } from "./schemas";
|
|
2
2
|
import { ZapierConfigurationError } from "../../types/errors";
|
|
3
3
|
import { createFunction } from "../../utils/function-utils";
|
|
4
|
-
import { appKeyResolver, actionTypeResolver, actionKeyResolver,
|
|
4
|
+
import { appKeyResolver, actionTypeResolver, actionKeyResolver, connectionIdResolver, inputsAllOptionalResolver, } from "../../resolvers";
|
|
5
5
|
import { fetchImplementationNeeds } from "../../services/implementations";
|
|
6
6
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
7
|
export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
8
8
|
async function getInputFieldsSchema(options) {
|
|
9
9
|
const { api, getVersionedImplementationId } = context;
|
|
10
|
-
const { appKey, actionKey, actionType, authenticationId
|
|
10
|
+
const { appKey, actionKey, actionType, connectionId, authenticationId, inputs, } = options;
|
|
11
|
+
// Support both connectionId (new) and authenticationId (deprecated)
|
|
12
|
+
const resolvedConnectionId = connectionId ?? authenticationId ?? null;
|
|
11
13
|
const selectedApi = await getVersionedImplementationId(appKey);
|
|
12
14
|
if (!selectedApi) {
|
|
13
15
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
@@ -22,7 +24,7 @@ export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
|
22
24
|
selectedApi,
|
|
23
25
|
action: action.key,
|
|
24
26
|
actionType,
|
|
25
|
-
|
|
27
|
+
connectionId: resolvedConnectionId,
|
|
26
28
|
inputs,
|
|
27
29
|
});
|
|
28
30
|
return {
|
|
@@ -43,9 +45,10 @@ export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
|
|
|
43
45
|
appKey: appKeyResolver,
|
|
44
46
|
actionType: actionTypeResolver,
|
|
45
47
|
actionKey: actionKeyResolver,
|
|
46
|
-
|
|
48
|
+
connectionId: connectionIdResolver,
|
|
47
49
|
inputs: inputsAllOptionalResolver,
|
|
48
50
|
},
|
|
51
|
+
deprecatedParameters: ["authenticationId"],
|
|
49
52
|
},
|
|
50
53
|
},
|
|
51
54
|
},
|
|
@@ -15,6 +15,7 @@ export declare const GetInputFieldsSchemaSchema: z.ZodObject<{
|
|
|
15
15
|
write: "write";
|
|
16
16
|
}>;
|
|
17
17
|
actionKey: z.ZodString;
|
|
18
|
+
connectionId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
18
19
|
authenticationId: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
19
20
|
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
21
|
}, z.core.$strip>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,OAAO,KAAK,EACV,wBAAwB,EACxB,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;iBA4BpC,CAAC;AAEJ,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,0BAA0B,CAClC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACjC,wBAAwB,GACxB,cAAc,GACd,yBAAyB,GACzB,sBAAsB,GACtB,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,+BAA+B;IAC9C,oBAAoB,EAAE,CACpB,OAAO,EAAE,2BAA2B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACjD"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { AppKeyPropertySchema, ActionTypePropertySchema, ActionKeyPropertySchema, AuthenticationIdPropertySchema, InputsPropertySchema, } from "../../types/properties";
|
|
2
|
+
import { AppKeyPropertySchema, ActionTypePropertySchema, ActionKeyPropertySchema, ConnectionIdPropertySchema, AuthenticationIdPropertySchema, InputsPropertySchema, } from "../../types/properties";
|
|
3
3
|
export const GetInputFieldsSchemaSchema = z
|
|
4
4
|
.object({
|
|
5
5
|
appKey: AppKeyPropertySchema.describe("App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"),
|
|
6
6
|
actionType: ActionTypePropertySchema.describe("Action type that matches the action's defined type"),
|
|
7
7
|
actionKey: ActionKeyPropertySchema.describe("Action key to get the input schema for"),
|
|
8
|
+
connectionId: ConnectionIdPropertySchema.nullable()
|
|
9
|
+
.optional()
|
|
10
|
+
.describe("Connection ID to use when fetching the schema. Required if the action needs a connection to determine available fields."),
|
|
11
|
+
/** @deprecated Use connectionId instead */
|
|
8
12
|
authenticationId: AuthenticationIdPropertySchema.nullable()
|
|
9
13
|
.optional()
|
|
10
|
-
.describe("Authentication ID to use when fetching the schema. Required if the action needs
|
|
14
|
+
.describe("Authentication ID to use when fetching the schema. Required if the action needs a connection to determine available fields."),
|
|
11
15
|
inputs: InputsPropertySchema.optional().describe("Current input values that may affect the schema (e.g., when fields depend on other field values)"),
|
|
12
16
|
})
|
|
13
17
|
.describe("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.");
|
|
@@ -36,13 +36,13 @@ export const ListAppsSchema = ListAppsQueryBase.omit({
|
|
|
36
36
|
.describe("Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"),
|
|
37
37
|
// Override pageSize to make optional (base has default value)
|
|
38
38
|
pageSize: z.number().min(1).optional().describe("Number of apps per page"),
|
|
39
|
-
// SDK specific property for pagination/
|
|
39
|
+
// SDK specific property for pagination/iterable helpers
|
|
40
40
|
maxItems: z
|
|
41
41
|
.number()
|
|
42
42
|
.min(1)
|
|
43
43
|
.optional()
|
|
44
44
|
.describe("Maximum total items to return across all pages"),
|
|
45
|
-
// SDK specific property for pagination/
|
|
45
|
+
// SDK specific property for pagination/iterable helpers
|
|
46
46
|
cursor: z.string().optional().describe("Cursor to start from"),
|
|
47
47
|
})
|
|
48
48
|
.merge(TelemetryMarkerSchema)
|
|
@@ -11,13 +11,13 @@ export const ListClientCredentialsQuerySchema = ListClientCredentialsQueryBase.o
|
|
|
11
11
|
.min(1)
|
|
12
12
|
.optional()
|
|
13
13
|
.describe("Number of credentials per page"),
|
|
14
|
-
// SDK specific property for pagination/
|
|
14
|
+
// SDK specific property for pagination/iterable helpers
|
|
15
15
|
maxItems: z
|
|
16
16
|
.number()
|
|
17
17
|
.min(1)
|
|
18
18
|
.optional()
|
|
19
19
|
.describe("Maximum total items to return across all pages"),
|
|
20
|
-
// SDK specific property for pagination/
|
|
20
|
+
// SDK specific property for pagination/iterable helpers
|
|
21
21
|
cursor: z.string().optional().describe("Cursor to start from"),
|
|
22
22
|
})
|
|
23
23
|
.merge(TelemetryMarkerSchema)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../api";
|
|
3
|
+
import type { ConnectionItem } from "@zapier/zapier-sdk-core/v0/schemas/connections";
|
|
4
|
+
import { ListConnectionsQuerySchema, type ListConnectionsOptions, type ListConnectionsPage } from "./schemas";
|
|
5
|
+
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
6
|
+
import type { ManifestPluginProvides } from "../manifest";
|
|
7
|
+
import type { EventEmissionContext } from "../eventEmission";
|
|
8
|
+
export interface ListConnectionsPluginProvides {
|
|
9
|
+
listConnections: (options?: ListConnectionsOptions) => Promise<ListConnectionsPage> & AsyncIterable<ListConnectionsPage> & {
|
|
10
|
+
items(): AsyncIterable<ConnectionItem>;
|
|
11
|
+
};
|
|
12
|
+
context: {
|
|
13
|
+
meta: {
|
|
14
|
+
listConnections: {
|
|
15
|
+
inputSchema: typeof ListConnectionsQuerySchema;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare const listConnectionsPlugin: Plugin<GetSdkType<ManifestPluginProvides>, {
|
|
21
|
+
api: ApiClient;
|
|
22
|
+
getVersionedImplementationId: GetVersionedImplementationId;
|
|
23
|
+
} & EventEmissionContext, ListConnectionsPluginProvides>;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listConnections/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AACrF,OAAO,EACL,0BAA0B,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,WAAW,CAAC;AAInB,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;AAK7D,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CACf,OAAO,CAAC,EAAE,sBAAsB,KAC7B,OAAO,CAAC,mBAAmB,CAAC,GAC/B,aAAa,CAAC,mBAAmB,CAAC,GAAG;QACnC,KAAK,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;KACxC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,UAAU,CAAC,sBAAsB,CAAC,EAClC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,GAAG,oBAAoB,EACxB,6BAA6B,CA2G9B,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListConnectionsQuerySchema, } from "./schemas";
|
|
2
2
|
import { splitVersionedKey } from "../../utils/domain-utils";
|
|
3
3
|
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
4
4
|
import { appKeyResolver } from "../../resolvers";
|
|
5
|
-
import {
|
|
5
|
+
import { ConnectionItemSchema } from "../../schemas/Connection";
|
|
6
6
|
import { createTelemetryCallback } from "../../utils/telemetry-utils";
|
|
7
7
|
import { stripPageSuffix } from "../../utils/string-utils";
|
|
8
8
|
import { ZapierAuthenticationError } from "../../types/errors";
|
|
9
|
-
export const
|
|
10
|
-
async function
|
|
9
|
+
export const listConnectionsPlugin = ({ context }) => {
|
|
10
|
+
async function listConnectionsPage(options) {
|
|
11
11
|
const { api, getVersionedImplementationId } = context;
|
|
12
12
|
const searchParams = {
|
|
13
|
-
|
|
13
|
+
page_size: options.pageSize.toString(),
|
|
14
14
|
};
|
|
15
15
|
// Resolve appKey to implementationId if provided
|
|
16
16
|
if (options.appKey) {
|
|
@@ -18,12 +18,18 @@ export const listAuthenticationsPlugin = ({ context }) => {
|
|
|
18
18
|
if (implementationId) {
|
|
19
19
|
// Extract versionless app key to pass to handler
|
|
20
20
|
const [versionlessSelectedApi] = splitVersionedKey(implementationId);
|
|
21
|
-
searchParams.
|
|
21
|
+
searchParams.app_key = versionlessSelectedApi;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// If we can't resolve via manifest, pass the raw appKey and let the API handle it
|
|
25
|
+
searchParams.app_key = options.appKey;
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
// Pass other filter options as searchParams
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
// Support both connectionIds (new) and authenticationIds (deprecated)
|
|
30
|
+
const resolvedConnectionIds = options.connectionIds ?? options.authenticationIds;
|
|
31
|
+
if (resolvedConnectionIds && resolvedConnectionIds.length > 0) {
|
|
32
|
+
searchParams.connection_ids = resolvedConnectionIds.join(",");
|
|
27
33
|
}
|
|
28
34
|
if (options.search) {
|
|
29
35
|
searchParams.search = options.search;
|
|
@@ -32,25 +38,25 @@ export const listAuthenticationsPlugin = ({ context }) => {
|
|
|
32
38
|
searchParams.title = options.title;
|
|
33
39
|
}
|
|
34
40
|
if (options.accountId) {
|
|
35
|
-
searchParams.
|
|
41
|
+
searchParams.account_id = options.accountId;
|
|
36
42
|
}
|
|
37
43
|
if (options.owner) {
|
|
38
44
|
searchParams.owner = options.owner;
|
|
39
45
|
}
|
|
40
46
|
if (options.isExpired !== undefined) {
|
|
41
|
-
searchParams.
|
|
47
|
+
searchParams.is_expired = options.isExpired.toString();
|
|
42
48
|
}
|
|
43
49
|
if (options.cursor) {
|
|
44
50
|
searchParams.offset = options.cursor;
|
|
45
51
|
}
|
|
46
|
-
const response = await api.get("/api/v0/
|
|
52
|
+
const response = await api.get("/api/v0/connections", {
|
|
47
53
|
searchParams,
|
|
48
54
|
customErrorHandler: ({ status }) => {
|
|
49
55
|
if (status === 401) {
|
|
50
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access
|
|
56
|
+
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access connections or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
51
57
|
}
|
|
52
58
|
if (status === 403) {
|
|
53
|
-
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to list
|
|
59
|
+
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to list connections. (HTTP ${status})`, { statusCode: status });
|
|
54
60
|
}
|
|
55
61
|
return undefined;
|
|
56
62
|
},
|
|
@@ -58,21 +64,22 @@ export const listAuthenticationsPlugin = ({ context }) => {
|
|
|
58
64
|
});
|
|
59
65
|
return response;
|
|
60
66
|
}
|
|
61
|
-
const methodName = stripPageSuffix(
|
|
62
|
-
const
|
|
67
|
+
const methodName = stripPageSuffix(listConnectionsPage.name);
|
|
68
|
+
const listConnectionsDefinition = createPaginatedFunction(listConnectionsPage, ListConnectionsQuerySchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
63
69
|
return {
|
|
64
|
-
|
|
70
|
+
listConnections: listConnectionsDefinition,
|
|
65
71
|
context: {
|
|
66
72
|
meta: {
|
|
67
|
-
|
|
68
|
-
categories: ["
|
|
73
|
+
listConnections: {
|
|
74
|
+
categories: ["connection"],
|
|
69
75
|
type: "list",
|
|
70
|
-
itemType: "
|
|
71
|
-
inputSchema:
|
|
72
|
-
outputSchema:
|
|
76
|
+
itemType: "Connection",
|
|
77
|
+
inputSchema: ListConnectionsQuerySchema,
|
|
78
|
+
outputSchema: ConnectionItemSchema,
|
|
73
79
|
resolvers: {
|
|
74
80
|
appKey: appKeyResolver,
|
|
75
81
|
},
|
|
82
|
+
deprecatedParameters: ["authenticationIds"],
|
|
76
83
|
},
|
|
77
84
|
},
|
|
78
85
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/listConnections/index.test.ts"],"names":[],"mappings":""}
|