@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.
Files changed (157) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/CLAUDE.md +6 -6
  3. package/README.md +217 -222
  4. package/dist/api/index.d.ts +1 -1
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/api/types.d.ts +3 -3
  7. package/dist/api/types.d.ts.map +1 -1
  8. package/dist/index.cjs +367 -216
  9. package/dist/index.d.mts +171 -91
  10. package/dist/index.d.ts +6 -5
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +4 -4
  13. package/dist/index.mjs +359 -211
  14. package/dist/plugins/apps/index.d.ts.map +1 -1
  15. package/dist/plugins/apps/index.js +20 -13
  16. package/dist/plugins/apps/schemas.d.ts +6 -2
  17. package/dist/plugins/apps/schemas.d.ts.map +1 -1
  18. package/dist/plugins/apps/schemas.js +7 -3
  19. package/dist/plugins/deprecated/authentications.d.ts +79 -0
  20. package/dist/plugins/deprecated/authentications.d.ts.map +1 -0
  21. package/dist/plugins/deprecated/authentications.js +90 -0
  22. package/dist/plugins/fetch/index.d.ts +4 -0
  23. package/dist/plugins/fetch/index.d.ts.map +1 -1
  24. package/dist/plugins/fetch/index.js +7 -4
  25. package/dist/plugins/fetch/schemas.d.ts +1 -0
  26. package/dist/plugins/fetch/schemas.d.ts.map +1 -1
  27. package/dist/plugins/fetch/schemas.js +3 -1
  28. package/dist/plugins/findFirstConnection/index.d.ts +21 -0
  29. package/dist/plugins/findFirstConnection/index.d.ts.map +1 -0
  30. package/dist/plugins/findFirstConnection/index.js +37 -0
  31. package/dist/plugins/findFirstConnection/index.test.d.ts.map +1 -0
  32. package/dist/plugins/{findFirstAuthentication → findFirstConnection}/index.test.js +43 -43
  33. package/dist/plugins/findFirstConnection/schemas.d.ts +22 -0
  34. package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -0
  35. package/dist/plugins/findFirstConnection/schemas.js +8 -0
  36. package/dist/plugins/findUniqueConnection/index.d.ts +21 -0
  37. package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -0
  38. package/dist/plugins/findUniqueConnection/index.js +40 -0
  39. package/dist/plugins/findUniqueConnection/index.test.d.ts.map +1 -0
  40. package/dist/plugins/{findUniqueAuthentication → findUniqueConnection}/index.test.js +41 -41
  41. package/dist/plugins/findUniqueConnection/schemas.d.ts +22 -0
  42. package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -0
  43. package/dist/plugins/findUniqueConnection/schemas.js +8 -0
  44. package/dist/plugins/getApp/index.js +2 -2
  45. package/dist/plugins/getConnection/index.d.ts +22 -0
  46. package/dist/plugins/getConnection/index.d.ts.map +1 -0
  47. package/dist/plugins/getConnection/index.js +35 -0
  48. package/dist/plugins/getConnection/index.test.d.ts.map +1 -0
  49. package/dist/plugins/{getAuthentication → getConnection}/index.test.js +46 -28
  50. package/dist/plugins/getConnection/schemas.d.ts +13 -0
  51. package/dist/plugins/getConnection/schemas.d.ts.map +1 -0
  52. package/dist/plugins/getConnection/schemas.js +8 -0
  53. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
  54. package/dist/plugins/getInputFieldsSchema/index.js +7 -4
  55. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +1 -0
  56. package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -1
  57. package/dist/plugins/getInputFieldsSchema/schemas.js +6 -2
  58. package/dist/plugins/listApps/schemas.js +2 -2
  59. package/dist/plugins/listClientCredentials/schemas.js +2 -2
  60. package/dist/plugins/listConnections/index.d.ts +24 -0
  61. package/dist/plugins/listConnections/index.d.ts.map +1 -0
  62. package/dist/plugins/{listAuthentications → listConnections}/index.js +28 -21
  63. package/dist/plugins/listConnections/index.test.d.ts.map +1 -0
  64. package/dist/plugins/{listAuthentications → listConnections}/index.test.js +219 -198
  65. package/dist/plugins/{listAuthentications → listConnections}/schemas.d.ts +11 -10
  66. package/dist/plugins/listConnections/schemas.d.ts.map +1 -0
  67. package/dist/plugins/listConnections/schemas.js +47 -0
  68. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  69. package/dist/plugins/listInputFieldChoices/index.js +8 -5
  70. package/dist/plugins/listInputFieldChoices/schemas.d.ts +1 -0
  71. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
  72. package/dist/plugins/listInputFieldChoices/schemas.js +3 -1
  73. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  74. package/dist/plugins/listInputFields/index.js +7 -4
  75. package/dist/plugins/listInputFields/schemas.d.ts +1 -0
  76. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
  77. package/dist/plugins/listInputFields/schemas.js +3 -1
  78. package/dist/plugins/manifest/schemas.d.ts +2 -0
  79. package/dist/plugins/manifest/schemas.d.ts.map +1 -1
  80. package/dist/plugins/manifest/schemas.js +3 -1
  81. package/dist/plugins/registry/index.d.ts.map +1 -1
  82. package/dist/plugins/registry/index.js +3 -2
  83. package/dist/plugins/request/index.d.ts.map +1 -1
  84. package/dist/plugins/request/index.js +5 -2
  85. package/dist/plugins/request/schemas.d.ts +2 -0
  86. package/dist/plugins/request/schemas.d.ts.map +1 -1
  87. package/dist/plugins/request/schemas.js +3 -1
  88. package/dist/plugins/runAction/index.d.ts.map +1 -1
  89. package/dist/plugins/runAction/index.js +12 -8
  90. package/dist/plugins/runAction/schemas.d.ts +1 -0
  91. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  92. package/dist/plugins/runAction/schemas.js +4 -2
  93. package/dist/resolvers/connectionId.d.ts +9 -0
  94. package/dist/resolvers/connectionId.d.ts.map +1 -0
  95. package/dist/resolvers/connectionId.js +42 -0
  96. package/dist/resolvers/index.d.ts +5 -1
  97. package/dist/resolvers/index.d.ts.map +1 -1
  98. package/dist/resolvers/index.js +6 -1
  99. package/dist/resolvers/inputFieldKey.d.ts +1 -1
  100. package/dist/resolvers/inputFieldKey.d.ts.map +1 -1
  101. package/dist/resolvers/inputFieldKey.js +2 -2
  102. package/dist/resolvers/inputs.d.ts +1 -1
  103. package/dist/resolvers/inputs.d.ts.map +1 -1
  104. package/dist/resolvers/inputs.js +4 -4
  105. package/dist/schemas/Connection.d.ts +29 -0
  106. package/dist/schemas/Connection.d.ts.map +1 -0
  107. package/dist/schemas/{Auth.js → Connection.js} +5 -7
  108. package/dist/sdk.d.ts +29 -7
  109. package/dist/sdk.d.ts.map +1 -1
  110. package/dist/sdk.js +12 -5
  111. package/dist/sdk.test.js +9 -8
  112. package/dist/services/implementations.d.ts +6 -6
  113. package/dist/services/implementations.d.ts.map +1 -1
  114. package/dist/services/implementations.js +10 -10
  115. package/dist/types/domain.d.ts +4 -4
  116. package/dist/types/domain.d.ts.map +1 -1
  117. package/dist/types/properties.d.ts +5 -1
  118. package/dist/types/properties.d.ts.map +1 -1
  119. package/dist/types/properties.js +4 -2
  120. package/dist/types/sdk.d.ts +12 -9
  121. package/dist/types/sdk.d.ts.map +1 -1
  122. package/package.json +2 -2
  123. package/dist/plugins/findFirstAuthentication/index.d.ts +0 -21
  124. package/dist/plugins/findFirstAuthentication/index.d.ts.map +0 -1
  125. package/dist/plugins/findFirstAuthentication/index.js +0 -36
  126. package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +0 -1
  127. package/dist/plugins/findFirstAuthentication/schemas.d.ts +0 -21
  128. package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +0 -1
  129. package/dist/plugins/findFirstAuthentication/schemas.js +0 -8
  130. package/dist/plugins/findUniqueAuthentication/index.d.ts +0 -21
  131. package/dist/plugins/findUniqueAuthentication/index.d.ts.map +0 -1
  132. package/dist/plugins/findUniqueAuthentication/index.js +0 -39
  133. package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +0 -1
  134. package/dist/plugins/findUniqueAuthentication/schemas.d.ts +0 -21
  135. package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +0 -1
  136. package/dist/plugins/findUniqueAuthentication/schemas.js +0 -8
  137. package/dist/plugins/getAuthentication/index.d.ts +0 -21
  138. package/dist/plugins/getAuthentication/index.d.ts.map +0 -1
  139. package/dist/plugins/getAuthentication/index.js +0 -29
  140. package/dist/plugins/getAuthentication/index.test.d.ts.map +0 -1
  141. package/dist/plugins/getAuthentication/schemas.d.ts +0 -7
  142. package/dist/plugins/getAuthentication/schemas.d.ts.map +0 -1
  143. package/dist/plugins/getAuthentication/schemas.js +0 -1
  144. package/dist/plugins/listAuthentications/index.d.ts +0 -24
  145. package/dist/plugins/listAuthentications/index.d.ts.map +0 -1
  146. package/dist/plugins/listAuthentications/index.test.d.ts.map +0 -1
  147. package/dist/plugins/listAuthentications/schemas.d.ts.map +0 -1
  148. package/dist/plugins/listAuthentications/schemas.js +0 -32
  149. package/dist/resolvers/authenticationId.d.ts +0 -9
  150. package/dist/resolvers/authenticationId.d.ts.map +0 -1
  151. package/dist/resolvers/authenticationId.js +0 -42
  152. package/dist/schemas/Auth.d.ts +0 -55
  153. package/dist/schemas/Auth.d.ts.map +0 -1
  154. /package/dist/plugins/{findFirstAuthentication → findFirstConnection}/index.test.d.ts +0 -0
  155. /package/dist/plugins/{findUniqueAuthentication → findUniqueConnection}/index.test.d.ts +0 -0
  156. /package/dist/plugins/{getAuthentication → getConnection}/index.test.d.ts +0 -0
  157. /package/dist/plugins/{listAuthentications → listConnections}/index.test.d.ts +0 -0
@@ -1,10 +1,10 @@
1
1
  import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError } from "../../types/errors";
3
- import { findFirstAuthenticationPlugin } from "./index";
3
+ import { findFirstConnectionPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
- import { ListAuthenticationsQuerySchema } from "../listAuthentications/schemas";
5
+ import { ListConnectionsQuerySchema } from "../listConnections/schemas";
6
6
  import { eventEmissionPlugin } from "../eventEmission";
7
- const mockAuthentications = [
7
+ const mockConnections = [
8
8
  {
9
9
  id: "123",
10
10
  title: "My Slack",
@@ -30,22 +30,22 @@ const mockAuthentications = [
30
30
  shared_with_all: false,
31
31
  },
32
32
  ];
33
- describe("findFirstAuthentication plugin", () => {
34
- let mockListAuthentications;
33
+ describe("findFirstConnection plugin", () => {
34
+ let mockListConnections;
35
35
  beforeEach(() => {
36
36
  vi.clearAllMocks();
37
- mockListAuthentications = vi.fn().mockResolvedValue({
38
- data: mockAuthentications,
37
+ mockListConnections = vi.fn().mockResolvedValue({
38
+ data: mockConnections,
39
39
  });
40
40
  });
41
41
  function createTestSdk() {
42
- // Create a proper plugin chain: first add a mock listAuthentications plugin, then add findFirstAuthentication
43
- const mockListAuthenticationsPlugin = () => ({
44
- listAuthentications: mockListAuthentications,
42
+ // Create a proper plugin chain: first add a mock listConnections plugin, then add findFirstConnection
43
+ const mockListConnectionsPlugin = () => ({
44
+ listConnections: mockListConnections,
45
45
  context: {
46
46
  meta: {
47
- listAuthentications: {
48
- inputSchema: ListAuthenticationsQuerySchema,
47
+ listConnections: {
48
+ inputSchema: ListConnectionsQuerySchema,
49
49
  },
50
50
  },
51
51
  },
@@ -58,35 +58,35 @@ describe("findFirstAuthentication plugin", () => {
58
58
  },
59
59
  }))
60
60
  .addPlugin(eventEmissionPlugin)
61
- .addPlugin(mockListAuthenticationsPlugin)
62
- .addPlugin(findFirstAuthenticationPlugin);
61
+ .addPlugin(mockListConnectionsPlugin)
62
+ .addPlugin(findFirstConnectionPlugin);
63
63
  }
64
64
  describe("schema validation", () => {
65
65
  it("should pass validation with empty options", async () => {
66
66
  const sdk = createTestSdk();
67
- const result = await sdk.findFirstAuthentication({});
67
+ const result = await sdk.findFirstConnection({});
68
68
  expect(result.data).toBeDefined();
69
69
  });
70
70
  it("should pass validation with undefined options", async () => {
71
71
  const sdk = createTestSdk();
72
- const result = await sdk.findFirstAuthentication();
72
+ const result = await sdk.findFirstConnection();
73
73
  expect(result.data).toBeDefined();
74
74
  });
75
75
  it("should throw validation error for invalid appKey type", async () => {
76
76
  const sdk = createTestSdk();
77
- await expect(sdk.findFirstAuthentication({
77
+ await expect(sdk.findFirstConnection({
78
78
  appKey: 123, // intentionally wrong type for testing
79
79
  })).rejects.toThrow(ZapierValidationError);
80
80
  });
81
81
  it("should throw validation error for invalid search type", async () => {
82
82
  const sdk = createTestSdk();
83
- await expect(sdk.findFirstAuthentication({
83
+ await expect(sdk.findFirstConnection({
84
84
  search: 123,
85
85
  })).rejects.toThrow(ZapierValidationError);
86
86
  });
87
87
  it("should throw validation error for invalid parameter types", async () => {
88
88
  const sdk = createTestSdk();
89
- await expect(sdk.findFirstAuthentication({
89
+ await expect(sdk.findFirstConnection({
90
90
  title: 123,
91
91
  accountId: 456,
92
92
  owner: true,
@@ -94,7 +94,7 @@ describe("findFirstAuthentication plugin", () => {
94
94
  });
95
95
  it("should pass validation with all valid fields", async () => {
96
96
  const sdk = createTestSdk();
97
- const result = await sdk.findFirstAuthentication({
97
+ const result = await sdk.findFirstConnection({
98
98
  appKey: "slack",
99
99
  search: "workspace",
100
100
  title: "My Slack Workspace",
@@ -105,40 +105,40 @@ describe("findFirstAuthentication plugin", () => {
105
105
  });
106
106
  });
107
107
  describe("business logic", () => {
108
- it("should return first authentication when found", async () => {
109
- const mockAuth = mockAuthentications[0];
110
- mockListAuthentications.mockResolvedValue({
111
- data: [mockAuth],
108
+ it("should return first connection when found", async () => {
109
+ const mockConnection = mockConnections[0];
110
+ mockListConnections.mockResolvedValue({
111
+ data: [mockConnection],
112
112
  });
113
113
  const sdk = createTestSdk();
114
- const result = await sdk.findFirstAuthentication({
114
+ const result = await sdk.findFirstConnection({
115
115
  appKey: "slack",
116
116
  });
117
- expect(result.data).toEqual(mockAuth);
117
+ expect(result.data).toEqual(mockConnection);
118
118
  });
119
- it("should throw error when no authentications found", async () => {
120
- mockListAuthentications.mockResolvedValue({
119
+ it("should throw error when no connections found", async () => {
120
+ mockListConnections.mockResolvedValue({
121
121
  data: [],
122
122
  });
123
123
  const sdk = createTestSdk();
124
- await expect(sdk.findFirstAuthentication({
124
+ await expect(sdk.findFirstConnection({
125
125
  appKey: "nonexistent",
126
- })).rejects.toThrow("No authentication found matching the specified criteria");
126
+ })).rejects.toThrow("No connection found matching the specified criteria");
127
127
  });
128
- it("should return first authentication when multiple found", async () => {
129
- const mockAuth = mockAuthentications[0];
130
- mockListAuthentications.mockResolvedValue({
131
- data: [mockAuth, mockAuthentications[1]],
128
+ it("should return first connection when multiple found", async () => {
129
+ const mockConnection = mockConnections[0];
130
+ mockListConnections.mockResolvedValue({
131
+ data: [mockConnection, mockConnections[1]],
132
132
  });
133
133
  const sdk = createTestSdk();
134
- const result = await sdk.findFirstAuthentication({
134
+ const result = await sdk.findFirstConnection({
135
135
  search: "Slack",
136
136
  });
137
- expect(result.data).toEqual(mockAuth);
137
+ expect(result.data).toEqual(mockConnection);
138
138
  });
139
139
  });
140
140
  describe("options forwarding", () => {
141
- it("should forward all options to listAuthentications", async () => {
141
+ it("should forward all options to listConnections", async () => {
142
142
  const sdk = createTestSdk();
143
143
  const options = {
144
144
  appKey: "slack",
@@ -147,8 +147,8 @@ describe("findFirstAuthentication plugin", () => {
147
147
  accountId: "acc_123",
148
148
  owner: "me",
149
149
  };
150
- await sdk.findFirstAuthentication(options);
151
- expect(mockListAuthentications).toHaveBeenCalledWith(expect.objectContaining({
150
+ await sdk.findFirstConnection(options);
151
+ expect(mockListConnections).toHaveBeenCalledWith(expect.objectContaining({
152
152
  ...options,
153
153
  maxItems: 1,
154
154
  }));
@@ -157,10 +157,10 @@ describe("findFirstAuthentication plugin", () => {
157
157
  describe("limit enforcement", () => {
158
158
  it("should automatically set maxItems to 1", async () => {
159
159
  const sdk = createTestSdk();
160
- await sdk.findFirstAuthentication({
160
+ await sdk.findFirstConnection({
161
161
  appKey: "slack",
162
162
  });
163
- expect(mockListAuthentications).toHaveBeenCalledWith(expect.objectContaining({
163
+ expect(mockListConnections).toHaveBeenCalledWith(expect.objectContaining({
164
164
  appKey: "slack",
165
165
  maxItems: 1,
166
166
  }));
@@ -170,8 +170,8 @@ describe("findFirstAuthentication plugin", () => {
170
170
  it("should provide context with meta information", () => {
171
171
  const sdk = createTestSdk();
172
172
  const context = sdk.getContext();
173
- expect(context.meta.findFirstAuthentication).toBeDefined();
174
- expect(context.meta.findFirstAuthentication.inputSchema).toBeDefined();
173
+ expect(context.meta.findFirstConnection).toBeDefined();
174
+ expect(context.meta.findFirstConnection.inputSchema).toBeDefined();
175
175
  });
176
176
  });
177
177
  });
@@ -0,0 +1,22 @@
1
+ import type { z } from "zod";
2
+ import type { ConnectionItem } from "../../types/domain";
3
+ import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
4
+ export declare const FindFirstConnectionSchema: z.ZodObject<{
5
+ search: z.ZodOptional<z.ZodString>;
6
+ title: z.ZodOptional<z.ZodString>;
7
+ appKey: z.ZodOptional<z.ZodString & {
8
+ _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
9
+ }>;
10
+ owner: z.ZodOptional<z.ZodString>;
11
+ authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
12
+ accountId: z.ZodOptional<z.ZodString>;
13
+ isExpired: z.ZodOptional<z.ZodBoolean>;
14
+ }, z.core.$strip>;
15
+ export type FindFirstConnectionOptions = z.infer<typeof FindFirstConnectionSchema>;
16
+ export type FindFirstConnectionError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
17
+ export interface FindFirstConnectionSdkFunction {
18
+ findFirstConnection: (options?: FindFirstConnectionOptions) => Promise<{
19
+ data: ConnectionItem | null;
20
+ }>;
21
+ }
22
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/findFirstConnection/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,yBAAyB;;;;;;;;;;iBAMwB,CAAC;AAG/D,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,yBAAyB,CACjC,CAAC;AAGF,MAAM,MAAM,wBAAwB,GAChC,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,8BAA8B;IAC7C,mBAAmB,EAAE,CACnB,OAAO,CAAC,EAAE,0BAA0B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;CAC/C"}
@@ -0,0 +1,8 @@
1
+ import { ListConnectionsQuerySchema } from "../listConnections/schemas";
2
+ export const FindFirstConnectionSchema = ListConnectionsQuerySchema.omit({
3
+ connectionIds: true,
4
+ pageSize: true,
5
+ maxItems: true,
6
+ cursor: true,
7
+ _telemetry: true,
8
+ }).describe("Find the first connection matching the criteria");
@@ -0,0 +1,21 @@
1
+ import type { Plugin, GetSdkType } from "../../types/plugin";
2
+ import type { ConnectionItem } from "../../types/domain";
3
+ import { FindUniqueConnectionSchema, type FindUniqueConnectionOptions } from "./schemas";
4
+ import type { ListConnectionsPluginProvides } from "../listConnections";
5
+ import type { EventEmissionContext } from "../eventEmission";
6
+ export interface FindUniqueConnectionPluginProvides {
7
+ findUniqueConnection: (options?: FindUniqueConnectionOptions) => Promise<{
8
+ data: ConnectionItem;
9
+ }>;
10
+ context: {
11
+ meta: {
12
+ findUniqueConnection: {
13
+ inputSchema: typeof FindUniqueConnectionSchema;
14
+ };
15
+ };
16
+ };
17
+ }
18
+ export declare const findUniqueConnectionPlugin: Plugin<GetSdkType<ListConnectionsPluginProvides>, // requires listConnections in SDK
19
+ EventEmissionContext, // requires eventEmission in context
20
+ FindUniqueConnectionPluginProvides>;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/findUniqueConnection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,0BAA0B,EAC1B,KAAK,2BAA2B,EACjC,MAAM,WAAW,CAAC;AAMnB,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG7D,MAAM,WAAW,kCAAkC;IACjD,oBAAoB,EAAE,CACpB,OAAO,CAAC,EAAE,2BAA2B,KAClC,OAAO,CAAC;QAAE,IAAI,EAAE,cAAc,CAAA;KAAE,CAAC,CAAC;IACvC,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,6BAA6B,CAAC,EAAE,kCAAkC;AAC7E,oBAAoB,EAAE,oCAAoC;AAC1D,kCAAkC,CAsDnC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { FindUniqueConnectionSchema, } from "./schemas";
2
+ import { ZapierResourceNotFoundError, ZapierValidationError, } from "../../types/errors";
3
+ import { createFunction } from "../../utils/function-utils";
4
+ import { ConnectionItemSchema } from "../../schemas/Connection";
5
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
6
+ export const findUniqueConnectionPlugin = ({ sdk, context }) => {
7
+ async function findUniqueConnection(options = {}) {
8
+ // Use listConnections with maxItems 2 to check for uniqueness
9
+ const connectionsResponse = await sdk.listConnections({
10
+ ...options,
11
+ maxItems: 2, // Get up to 2 to check for uniqueness
12
+ _telemetry: { isNested: true },
13
+ });
14
+ if (connectionsResponse.data.length === 0) {
15
+ throw new ZapierResourceNotFoundError("No connection found matching the specified criteria", { resourceType: "Connection" });
16
+ }
17
+ if (connectionsResponse.data.length > 1) {
18
+ throw new ZapierValidationError("Multiple connections found matching the specified criteria. Expected exactly one.");
19
+ }
20
+ return {
21
+ data: connectionsResponse.data[0],
22
+ };
23
+ }
24
+ const findUniqueConnectionDefinition = createFunction(findUniqueConnection, FindUniqueConnectionSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, findUniqueConnection.name));
25
+ return {
26
+ findUniqueConnection: findUniqueConnectionDefinition,
27
+ context: {
28
+ meta: {
29
+ findUniqueConnection: {
30
+ categories: ["connection"],
31
+ type: "item",
32
+ itemType: "Connection",
33
+ inputSchema: FindUniqueConnectionSchema,
34
+ outputSchema: ConnectionItemSchema,
35
+ deprecatedParameters: ["authenticationIds"],
36
+ },
37
+ },
38
+ },
39
+ };
40
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/findUniqueConnection/index.test.ts"],"names":[],"mappings":""}
@@ -1,10 +1,10 @@
1
1
  import { describe, it, expect, vi, beforeEach } from "vitest";
2
2
  import { ZapierValidationError, ZapierResourceNotFoundError, } from "../../types/errors";
3
- import { findUniqueAuthenticationPlugin } from "./index";
3
+ import { findUniqueConnectionPlugin } from "./index";
4
4
  import { createSdk } from "../../sdk";
5
- import { ListAuthenticationsQuerySchema } from "../listAuthentications/schemas";
5
+ import { ListConnectionsQuerySchema } from "../listConnections/schemas";
6
6
  import { eventEmissionPlugin } from "../eventEmission";
7
- const mockAuthentication = {
7
+ const mockConnection = {
8
8
  id: "123",
9
9
  title: "My Slack",
10
10
  date: "2021-01-01",
@@ -16,8 +16,8 @@ const mockAuthentication = {
16
16
  is_private: false,
17
17
  shared_with_all: false,
18
18
  };
19
- const mockAuthentications = [
20
- mockAuthentication,
19
+ const mockConnections = [
20
+ mockConnection,
21
21
  {
22
22
  id: "456",
23
23
  title: "Slack Workspace 2",
@@ -31,22 +31,22 @@ const mockAuthentications = [
31
31
  shared_with_all: false,
32
32
  },
33
33
  ];
34
- describe("findUniqueAuthentication plugin", () => {
35
- let mockListAuthentications;
34
+ describe("findUniqueConnection plugin", () => {
35
+ let mockListConnections;
36
36
  beforeEach(() => {
37
37
  vi.clearAllMocks();
38
- mockListAuthentications = vi.fn().mockResolvedValue({
39
- data: [mockAuthentication],
38
+ mockListConnections = vi.fn().mockResolvedValue({
39
+ data: [mockConnection],
40
40
  });
41
41
  });
42
42
  function createTestSdk() {
43
- // Create a proper plugin chain: first add a mock listAuthentications plugin, then add findUniqueAuthentication
44
- const mockListAuthenticationsPlugin = () => ({
45
- listAuthentications: mockListAuthentications,
43
+ // Create a proper plugin chain: first add a mock listConnections plugin, then add findUniqueConnection
44
+ const mockListConnectionsPlugin = () => ({
45
+ listConnections: mockListConnections,
46
46
  context: {
47
47
  meta: {
48
- listAuthentications: {
49
- inputSchema: ListAuthenticationsQuerySchema,
48
+ listConnections: {
49
+ inputSchema: ListConnectionsQuerySchema,
50
50
  },
51
51
  },
52
52
  },
@@ -59,24 +59,24 @@ describe("findUniqueAuthentication plugin", () => {
59
59
  },
60
60
  }))
61
61
  .addPlugin(eventEmissionPlugin)
62
- .addPlugin(mockListAuthenticationsPlugin)
63
- .addPlugin(findUniqueAuthenticationPlugin);
62
+ .addPlugin(mockListConnectionsPlugin)
63
+ .addPlugin(findUniqueConnectionPlugin);
64
64
  }
65
65
  describe("schema validation", () => {
66
66
  it("should pass validation with empty options", async () => {
67
67
  const sdk = createTestSdk();
68
- const result = await sdk.findUniqueAuthentication({});
68
+ const result = await sdk.findUniqueConnection({});
69
69
  expect(result.data).toBeDefined();
70
70
  });
71
71
  it("should throw validation error for invalid appKey type", async () => {
72
72
  const sdk = createTestSdk();
73
- await expect(sdk.findUniqueAuthentication({
73
+ await expect(sdk.findUniqueConnection({
74
74
  appKey: 123,
75
75
  })).rejects.toThrow(ZapierValidationError);
76
76
  });
77
77
  it("should throw validation error for invalid parameter types", async () => {
78
78
  const sdk = createTestSdk();
79
- await expect(sdk.findUniqueAuthentication({
79
+ await expect(sdk.findUniqueConnection({
80
80
  search: 123,
81
81
  title: 456,
82
82
  accountId: 789,
@@ -85,7 +85,7 @@ describe("findUniqueAuthentication plugin", () => {
85
85
  });
86
86
  it("should pass validation with all valid fields", async () => {
87
87
  const sdk = createTestSdk();
88
- const result = await sdk.findUniqueAuthentication({
88
+ const result = await sdk.findUniqueConnection({
89
89
  appKey: "slack",
90
90
  search: "Workspace",
91
91
  title: "My Slack",
@@ -96,43 +96,43 @@ describe("findUniqueAuthentication plugin", () => {
96
96
  });
97
97
  });
98
98
  describe("business logic", () => {
99
- it("should return the first authentication when exactly one is found", async () => {
100
- mockListAuthentications.mockResolvedValue({
101
- data: [mockAuthentication],
99
+ it("should return the first connection when exactly one is found", async () => {
100
+ mockListConnections.mockResolvedValue({
101
+ data: [mockConnection],
102
102
  });
103
103
  const sdk = createTestSdk();
104
- const result = await sdk.findUniqueAuthentication({
104
+ const result = await sdk.findUniqueConnection({
105
105
  appKey: "slack",
106
106
  });
107
- expect(result.data).toEqual(mockAuthentication);
107
+ expect(result.data).toEqual(mockConnection);
108
108
  });
109
- it("should throw ZapierResourceNotFoundError when no authentications found", async () => {
110
- mockListAuthentications.mockResolvedValue({
109
+ it("should throw ZapierResourceNotFoundError when no connections found", async () => {
110
+ mockListConnections.mockResolvedValue({
111
111
  data: [],
112
112
  });
113
113
  const sdk = createTestSdk();
114
- await expect(sdk.findUniqueAuthentication({
114
+ await expect(sdk.findUniqueConnection({
115
115
  appKey: "nonexistent",
116
116
  })).rejects.toThrow(ZapierResourceNotFoundError);
117
- await expect(sdk.findUniqueAuthentication({
117
+ await expect(sdk.findUniqueConnection({
118
118
  appKey: "nonexistent",
119
- })).rejects.toThrow("No authentication found matching the specified criteria");
119
+ })).rejects.toThrow("No connection found matching the specified criteria");
120
120
  });
121
- it("should throw ZapierValidationError when multiple authentications found", async () => {
122
- mockListAuthentications.mockResolvedValue({
123
- data: mockAuthentications, // Two authentications
121
+ it("should throw ZapierValidationError when multiple connections found", async () => {
122
+ mockListConnections.mockResolvedValue({
123
+ data: mockConnections, // Two connections
124
124
  });
125
125
  const sdk = createTestSdk();
126
- await expect(sdk.findUniqueAuthentication({
126
+ await expect(sdk.findUniqueConnection({
127
127
  search: "Workspace",
128
128
  })).rejects.toThrow(ZapierValidationError);
129
- await expect(sdk.findUniqueAuthentication({
129
+ await expect(sdk.findUniqueConnection({
130
130
  search: "Workspace",
131
- })).rejects.toThrow("Multiple authentications found matching the specified criteria. Expected exactly one.");
131
+ })).rejects.toThrow("Multiple connections found matching the specified criteria. Expected exactly one.");
132
132
  });
133
133
  });
134
134
  describe("options forwarding", () => {
135
- it("should forward all options to listAuthentications with maxItems=2", async () => {
135
+ it("should forward all options to listConnections with maxItems=2", async () => {
136
136
  const sdk = createTestSdk();
137
137
  const options = {
138
138
  appKey: "slack",
@@ -141,8 +141,8 @@ describe("findUniqueAuthentication plugin", () => {
141
141
  accountId: "acc_123",
142
142
  owner: "me",
143
143
  };
144
- await sdk.findUniqueAuthentication(options);
145
- expect(mockListAuthentications).toHaveBeenCalledWith(expect.objectContaining({
144
+ await sdk.findUniqueConnection(options);
145
+ expect(mockListConnections).toHaveBeenCalledWith(expect.objectContaining({
146
146
  ...options,
147
147
  maxItems: 2,
148
148
  }));
@@ -152,8 +152,8 @@ describe("findUniqueAuthentication plugin", () => {
152
152
  it("should provide context with meta information", () => {
153
153
  const sdk = createTestSdk();
154
154
  const context = sdk.getContext();
155
- expect(context.meta.findUniqueAuthentication).toBeDefined();
156
- expect(context.meta.findUniqueAuthentication.inputSchema).toBeDefined();
155
+ expect(context.meta.findUniqueConnection).toBeDefined();
156
+ expect(context.meta.findUniqueConnection.inputSchema).toBeDefined();
157
157
  });
158
158
  });
159
159
  });
@@ -0,0 +1,22 @@
1
+ import type { z } from "zod";
2
+ import type { ConnectionItem } from "../../types/domain";
3
+ import type { ZapierAuthenticationError, ZapierApiError, ZapierResourceNotFoundError, ZapierValidationError, ZapierUnknownError } from "../../types/errors";
4
+ export declare const FindUniqueConnectionSchema: z.ZodObject<{
5
+ search: z.ZodOptional<z.ZodString>;
6
+ title: z.ZodOptional<z.ZodString>;
7
+ appKey: z.ZodOptional<z.ZodString & {
8
+ _def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
9
+ }>;
10
+ owner: z.ZodOptional<z.ZodString>;
11
+ authenticationIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
12
+ accountId: z.ZodOptional<z.ZodString>;
13
+ isExpired: z.ZodOptional<z.ZodBoolean>;
14
+ }, z.core.$strip>;
15
+ export type FindUniqueConnectionOptions = z.infer<typeof FindUniqueConnectionSchema>;
16
+ export type FindUniqueConnectionError = ZapierAuthenticationError | ZapierApiError | ZapierResourceNotFoundError | ZapierValidationError | ZapierUnknownError;
17
+ export interface FindUniqueConnectionSdkFunction {
18
+ findUniqueConnection: (options?: FindUniqueConnectionOptions) => Promise<{
19
+ data: ConnectionItem;
20
+ }>;
21
+ }
22
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/findUniqueConnection/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,2BAA2B,EAC3B,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAG5B,eAAO,MAAM,0BAA0B;;;;;;;;;;iBAMsB,CAAC;AAG9D,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,0BAA0B,CAClC,CAAC;AAGF,MAAM,MAAM,yBAAyB,GACjC,yBAAyB,GACzB,cAAc,GACd,2BAA2B,GAC3B,qBAAqB,GACrB,kBAAkB,CAAC;AAGvB,MAAM,WAAW,+BAA+B;IAC9C,oBAAoB,EAAE,CACpB,OAAO,CAAC,EAAE,2BAA2B,KAClC,OAAO,CAAC;QAAE,IAAI,EAAE,cAAc,CAAA;KAAE,CAAC,CAAC;CACxC"}
@@ -0,0 +1,8 @@
1
+ import { ListConnectionsQuerySchema } from "../listConnections/schemas";
2
+ export const FindUniqueConnectionSchema = ListConnectionsQuerySchema.omit({
3
+ connectionIds: true,
4
+ pageSize: true,
5
+ maxItems: true,
6
+ cursor: true,
7
+ _telemetry: true,
8
+ }).describe("Find a unique connection matching the criteria");
@@ -7,13 +7,13 @@ import { createTelemetryCallback } from "../../utils/telemetry-utils";
7
7
  // GetApp plugin depends on listApps SDK function
8
8
  export const getAppPlugin = ({ sdk, context }) => {
9
9
  async function getApp(options) {
10
- const appsIterator = sdk
10
+ const appsIterable = sdk
11
11
  .listApps({
12
12
  appKeys: [options.appKey],
13
13
  _telemetry: { isNested: true },
14
14
  })
15
15
  .items();
16
- for await (const app of appsIterator) {
16
+ for await (const app of appsIterable) {
17
17
  return {
18
18
  data: app,
19
19
  };
@@ -0,0 +1,22 @@
1
+ import type { Plugin } from "../../types/plugin";
2
+ import type { ApiClient } from "../../api";
3
+ import type { EventEmissionContext } from "../eventEmission";
4
+ import type { GetConnectionResponse } from "@zapier/zapier-sdk-core/v0/schemas/connections";
5
+ import { GetConnectionParamSchema, type GetConnectionParam } from "./schemas";
6
+ export interface GetConnectionPluginProvides {
7
+ getConnection: (options: GetConnectionParam) => Promise<GetConnectionResponse>;
8
+ context: {
9
+ meta: {
10
+ getConnection: {
11
+ inputSchema: typeof GetConnectionParamSchema;
12
+ };
13
+ };
14
+ };
15
+ }
16
+ export declare const getConnectionPlugin: Plugin<{}, // no SDK dependencies
17
+ // no SDK dependencies
18
+ {
19
+ api: ApiClient;
20
+ } & EventEmissionContext, // requires api in context
21
+ GetConnectionPluginProvides>;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getConnection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE9E,MAAM,WAAW,2BAA2B;IAC1C,aAAa,EAAE,CACb,OAAO,EAAE,kBAAkB,KACxB,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,aAAa,EAAE;gBACb,WAAW,EAAE,OAAO,wBAAwB,CAAC;aAC9C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,EAAE,EAAE,sBAAsB;AAC1B,AADI,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,GAAG,oBAAoB,EAAE,0BAA0B;AACrE,2BAA2B,CA6C5B,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { createFunction } from "../../utils/function-utils";
2
+ import { connectionIdGenericResolver } from "../../resolvers";
3
+ import { ConnectionItemSchema } from "../../schemas/Connection";
4
+ import { createTelemetryCallback } from "../../utils/telemetry-utils";
5
+ import { GetConnectionParamSchema } from "./schemas";
6
+ export const getConnectionPlugin = ({ context }) => {
7
+ async function getConnection(options) {
8
+ const { api } = context;
9
+ // Support both connectionId (new) and authenticationId (deprecated)
10
+ const resolvedConnectionId = options.connectionId ?? options.authenticationId;
11
+ if (!resolvedConnectionId) {
12
+ throw new Error("connectionId is required");
13
+ }
14
+ return await api.get(`/api/v0/connections/${encodeURIComponent(String(resolvedConnectionId))}`);
15
+ }
16
+ const getConnectionDefinition = createFunction(getConnection, GetConnectionParamSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, getConnection.name));
17
+ return {
18
+ getConnection: getConnectionDefinition,
19
+ context: {
20
+ meta: {
21
+ getConnection: {
22
+ categories: ["connection"],
23
+ type: "item",
24
+ itemType: "Connection",
25
+ inputSchema: GetConnectionParamSchema,
26
+ outputSchema: ConnectionItemSchema,
27
+ resolvers: {
28
+ connectionId: connectionIdGenericResolver,
29
+ },
30
+ deprecatedParameters: ["authenticationId"],
31
+ },
32
+ },
33
+ },
34
+ };
35
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/getConnection/index.test.ts"],"names":[],"mappings":""}