@superdurable/connector-atlassian-confluence 0.0.0-stage → 0.2.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.
@@ -0,0 +1,394 @@
1
+ // src/generated/models.ts
2
+ import { z } from "zod";
3
+ import { SecretString } from "@superdurable/connectors-sdk";
4
+ var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
5
+ function isGoTimeJSON(value) {
6
+ const match = goTimeJSONPattern.exec(value);
7
+ if (!match) return false;
8
+ const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
9
+ const year = Number(yearText);
10
+ const month = Number(monthText);
11
+ const day = Number(dayText);
12
+ const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
13
+ const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
14
+ return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
15
+ }
16
+ function canonicalGoTimeJSON(value) {
17
+ const match = goTimeJSONPattern.exec(value);
18
+ const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
19
+ const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
20
+ const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
21
+ const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
22
+ if (Math.abs(offsetMinutes) >= 1440) return value;
23
+ const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
24
+ return clock + (digits ? "." + digits : "") + offset;
25
+ }
26
+ var GoTimeJSONSchema = z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
27
+ var ConfigSchema = z.object({
28
+ "cloudId": z.string().optional(),
29
+ "endpoint": z.string().optional(),
30
+ "maxResponseBytes": z.number().int().optional(),
31
+ "pollIntervalMs": z.number().int().optional()
32
+ });
33
+ function decodeCredentials(value) {
34
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
35
+ const fields = value;
36
+ const allowed = /* @__PURE__ */ new Set(["access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
37
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
38
+ if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
39
+ if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
40
+ if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
41
+ if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
42
+ const credentials = {};
43
+ if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
44
+ credentials.oauthClientId = fields["oauth_client_id"] ?? "";
45
+ if (!fields["oauth_client_secret"]) throw new TypeError("credential oauth_client_secret is required");
46
+ credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"] ?? "");
47
+ if (!fields["access_token"]) throw new TypeError("credential access_token is required");
48
+ credentials.accessToken = new SecretString(fields["access_token"] ?? "");
49
+ if (!fields["refresh_token"]) throw new TypeError("credential refresh_token is required");
50
+ credentials.refreshToken = new SecretString(fields["refresh_token"] ?? "");
51
+ return credentials;
52
+ }
53
+ function decodeSharedCredentials(value) {
54
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
55
+ const fields = value;
56
+ const allowed = /* @__PURE__ */ new Set(["access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
57
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
58
+ if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
59
+ if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
60
+ if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
61
+ if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
62
+ const credentials = {};
63
+ if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
64
+ credentials.oauthClientId = fields["oauth_client_id"] ?? "";
65
+ credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"] ?? "");
66
+ if (!fields["access_token"]) throw new TypeError("credential access_token is required");
67
+ credentials.accessToken = new SecretString(fields["access_token"] ?? "");
68
+ credentials.refreshToken = new SecretString(fields["refresh_token"] ?? "");
69
+ return credentials;
70
+ }
71
+ var PageSearchFilterSchema = z.strictObject({
72
+ "spaceKeys": z.array(z.string()).optional(),
73
+ "titlePhrase": z.string().optional(),
74
+ "labels": z.array(z.string()).optional(),
75
+ "modifiedSince": GoTimeJSONSchema.nullable().optional(),
76
+ "additionalCql": z.string().optional(),
77
+ "order": z.string().optional()
78
+ });
79
+ var SearchPagesInputSchema = z.strictObject({
80
+ "filter": PageSearchFilterSchema,
81
+ "pageSize": z.number().int().optional(),
82
+ "cursor": z.string().optional()
83
+ });
84
+ var PageSummarySchema = z.strictObject({
85
+ "id": z.string(),
86
+ "title": z.string(),
87
+ "status": z.string().optional(),
88
+ "spaceId": z.string().optional(),
89
+ "spaceKey": z.string().optional(),
90
+ "versionNumber": z.number().int().optional(),
91
+ "lastModifiedAt": GoTimeJSONSchema,
92
+ "webUrl": z.string().optional()
93
+ });
94
+ var SearchPagesOutputSchema = z.strictObject({
95
+ "cql": z.string(),
96
+ "pages": z.array(PageSummarySchema).nullable(),
97
+ "nextCursor": z.string().optional()
98
+ });
99
+ var GetPageInputSchema = z.strictObject({
100
+ "pageId": z.string(),
101
+ "bodyRepresentation": z.string().optional(),
102
+ "bodyFormat": z.string().optional(),
103
+ "maxBodyCharacters": z.number().int().optional()
104
+ });
105
+ var PageVersionSchema = z.strictObject({
106
+ "number": z.number().int(),
107
+ "createdAt": GoTimeJSONSchema,
108
+ "authorAccountId": z.string().optional(),
109
+ "isMinorEdit": z.boolean().optional()
110
+ });
111
+ var PageSchema = z.strictObject({
112
+ "id": z.string(),
113
+ "title": z.string(),
114
+ "status": z.string(),
115
+ "spaceId": z.string(),
116
+ "parentPageId": z.string().optional(),
117
+ "authorAccountId": z.string().optional(),
118
+ "createdAt": GoTimeJSONSchema,
119
+ "version": PageVersionSchema,
120
+ "body": z.string(),
121
+ "bodyFormat": z.string(),
122
+ "isBodyTruncated": z.boolean().optional(),
123
+ "webUrl": z.string().optional()
124
+ });
125
+ var CreatePageInputSchema = z.strictObject({
126
+ "spaceId": z.string().optional(),
127
+ "spaceKey": z.string().optional(),
128
+ "parentPageId": z.string().optional(),
129
+ "title": z.string(),
130
+ "body": z.string(),
131
+ "bodyFormat": z.string().optional()
132
+ });
133
+ var CreatePageOutputSchema = z.strictObject({
134
+ "pageId": z.string().optional(),
135
+ "title": z.string(),
136
+ "spaceId": z.string().optional(),
137
+ "spaceKey": z.string().optional(),
138
+ "parentPageId": z.string().optional(),
139
+ "versionNumber": z.number().int().optional(),
140
+ "webUrl": z.string().optional(),
141
+ "isConfirmedByTitleLookup": z.boolean().optional()
142
+ });
143
+ var UpdatePageInputSchema = z.strictObject({
144
+ "pageId": z.string(),
145
+ "title": z.string(),
146
+ "body": z.string(),
147
+ "bodyFormat": z.string().optional(),
148
+ "nextVersionNumber": z.number().int(),
149
+ "versionMessage": z.string().optional()
150
+ });
151
+ var UpdatePageOutputSchema = z.strictObject({
152
+ "pageId": z.string(),
153
+ "title": z.string(),
154
+ "versionNumber": z.number().int().optional(),
155
+ "webUrl": z.string().optional(),
156
+ "isConfirmedByReadBack": z.boolean().optional()
157
+ });
158
+ var AddCommentInputSchema = z.strictObject({
159
+ "pageId": z.string(),
160
+ "body": z.string(),
161
+ "bodyFormat": z.string().optional()
162
+ });
163
+ var AddCommentOutputSchema = z.strictObject({
164
+ "pageId": z.string(),
165
+ "commentId": z.string().optional(),
166
+ "createdAt": GoTimeJSONSchema,
167
+ "isConfirmedByReadBack": z.boolean().optional()
168
+ });
169
+
170
+ // src/generated/definitions.ts
171
+ var ConnectorID = "confluence";
172
+ var ProviderID = "atlassian";
173
+ var SearchPagesBranch = {
174
+ Searched: "searched",
175
+ ProviderRejected: "providerRejected",
176
+ InvalidResponse: "invalidResponse",
177
+ Defect: "defect"
178
+ };
179
+ var SearchPagesBranchSearched = SearchPagesBranch.Searched;
180
+ var SearchPagesBranchProviderRejected = SearchPagesBranch.ProviderRejected;
181
+ var SearchPagesBranchInvalidResponse = SearchPagesBranch.InvalidResponse;
182
+ var SearchPagesBranchDefect = SearchPagesBranch.Defect;
183
+ var SearchPagesDefinition = {
184
+ operation: { connectorId: ConnectorID, operationId: "searchPages" },
185
+ branches: [
186
+ { id: "searched", description: "One page of matching pages was read; Confluence search is eventually consistent, so a page created or changed seconds ago can be missing." },
187
+ { id: "providerRejected", description: "Confluence conclusively rejected the search, such as unparsable CQL, an expired cursor, or missing permission.", optional: true },
188
+ { id: "invalidResponse", description: "Confluence returned an invalid or oversized search page.", optional: true },
189
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
190
+ ],
191
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
192
+ };
193
+ var SearchPagesMetadata = { kind: "query", idempotency: "none", authorization: "required" };
194
+ var GetPageBranch = {
195
+ Found: "found",
196
+ NotFound: "notFound",
197
+ ProviderRejected: "providerRejected",
198
+ InvalidResponse: "invalidResponse",
199
+ Defect: "defect"
200
+ };
201
+ var GetPageBranchFound = GetPageBranch.Found;
202
+ var GetPageBranchNotFound = GetPageBranch.NotFound;
203
+ var GetPageBranchProviderRejected = GetPageBranch.ProviderRejected;
204
+ var GetPageBranchInvalidResponse = GetPageBranch.InvalidResponse;
205
+ var GetPageBranchDefect = GetPageBranch.Defect;
206
+ var GetPageDefinition = {
207
+ operation: { connectorId: ConnectorID, operationId: "getPage" },
208
+ branches: [
209
+ { id: "found", description: "The page was read." },
210
+ { id: "notFound", description: "The page does not exist or the connection cannot view it.", optional: true },
211
+ { id: "providerRejected", description: "Confluence conclusively rejected the page read.", optional: true },
212
+ { id: "invalidResponse", description: "Confluence returned an invalid or oversized page.", optional: true },
213
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
214
+ ],
215
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
216
+ };
217
+ var GetPageMetadata = { kind: "query", idempotency: "none", authorization: "required" };
218
+ var CreatePageBranch = {
219
+ Created: "created",
220
+ TitleConflict: "titleConflict",
221
+ NotFound: "notFound",
222
+ ProviderRejected: "providerRejected",
223
+ Defect: "defect"
224
+ };
225
+ var CreatePageBranchCreated = CreatePageBranch.Created;
226
+ var CreatePageBranchTitleConflict = CreatePageBranch.TitleConflict;
227
+ var CreatePageBranchNotFound = CreatePageBranch.NotFound;
228
+ var CreatePageBranchProviderRejected = CreatePageBranch.ProviderRejected;
229
+ var CreatePageBranchDefect = CreatePageBranch.Defect;
230
+ var CreatePageDefinition = {
231
+ operation: { connectorId: ConnectorID, operationId: "createPage" },
232
+ branches: [
233
+ { id: "created", description: "The page exists with the requested title, created by this Step execution, including a create an earlier attempt sent." },
234
+ { id: "titleConflict", description: "Another page in the space already has this title, so nothing was created; the Value names that page and its current version.", optional: true },
235
+ { id: "notFound", description: "The space or parent page does not exist or the connection cannot view it; nothing was created.", optional: true },
236
+ { id: "providerRejected", description: "Confluence conclusively rejected the page, such as an invalid body or missing Add page permission; nothing was created.", optional: true },
237
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
238
+ ],
239
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync" },
240
+ repeatOnUnknown: "limited",
241
+ maxSends: 3
242
+ };
243
+ var CreatePageMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
244
+ var UpdatePageBranch = {
245
+ Updated: "updated",
246
+ VersionConflict: "versionConflict",
247
+ NotFound: "notFound",
248
+ ProviderRejected: "providerRejected",
249
+ Defect: "defect"
250
+ };
251
+ var UpdatePageBranchUpdated = UpdatePageBranch.Updated;
252
+ var UpdatePageBranchVersionConflict = UpdatePageBranch.VersionConflict;
253
+ var UpdatePageBranchNotFound = UpdatePageBranch.NotFound;
254
+ var UpdatePageBranchProviderRejected = UpdatePageBranch.ProviderRejected;
255
+ var UpdatePageBranchDefect = UpdatePageBranch.Defect;
256
+ var UpdatePageDefinition = {
257
+ operation: { connectorId: ConnectorID, operationId: "updatePage" },
258
+ branches: [
259
+ { id: "updated", description: "The page is at the requested version with this Step execution's change, including one an earlier attempt sent." },
260
+ { id: "versionConflict", description: "The page is no longer at the version before the requested one, because another edit was saved first; nothing was changed and the Value names the current version.", optional: true },
261
+ { id: "notFound", description: "The page does not exist or the connection cannot view it; nothing was changed.", optional: true },
262
+ { id: "providerRejected", description: "Confluence conclusively rejected the update, such as an invalid body, missing Edit permission, or a space that requires approval before publishing; nothing was changed.", optional: true },
263
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
264
+ ],
265
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" },
266
+ repeatOnUnknown: "limited",
267
+ maxSends: 3
268
+ };
269
+ var UpdatePageMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
270
+ var AddCommentBranch = {
271
+ Added: "added",
272
+ NotFound: "notFound",
273
+ ProviderRejected: "providerRejected",
274
+ Uncertain: "uncertain",
275
+ Defect: "defect"
276
+ };
277
+ var AddCommentBranchAdded = AddCommentBranch.Added;
278
+ var AddCommentBranchNotFound = AddCommentBranch.NotFound;
279
+ var AddCommentBranchProviderRejected = AddCommentBranch.ProviderRejected;
280
+ var AddCommentBranchUncertain = AddCommentBranch.Uncertain;
281
+ var AddCommentBranchDefect = AddCommentBranch.Defect;
282
+ var AddCommentDefinition = {
283
+ operation: { connectorId: ConnectorID, operationId: "addComment" },
284
+ branches: [
285
+ { id: "added", description: "The comment is on the page, including one an earlier attempt of this Step execution sent." },
286
+ { id: "notFound", description: "The page does not exist or the connection cannot view it; nothing was added.", optional: true },
287
+ { id: "providerRejected", description: "Confluence conclusively rejected the comment, such as an invalid body or missing Add comments permission; nothing was added.", optional: true },
288
+ { id: "uncertain", description: "An earlier attempt sent the comment and the page's comments do not confirm it; Confluence has no idempotency key, so it is never sent again automatically.", optional: true },
289
+ { id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
290
+ ],
291
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 5, totalDurationMs: 12e4 } },
292
+ repeatOnUnknown: "limited",
293
+ maxSends: 3
294
+ };
295
+ var AddCommentMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
296
+
297
+ // src/generated/connection.ts
298
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
299
+ import { newRefreshingCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
300
+ var Connection = class {
301
+ /** Stable provider and connection name. */
302
+ reference;
303
+ /** Bound provider operations. */
304
+ operations;
305
+ /** Validate a reference and bind operations. */
306
+ constructor(reference, operations) {
307
+ this.reference = ConnectionRefSchema.parse(reference);
308
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
309
+ if (!operations) throw new TypeError("connector operations are required");
310
+ this.operations = operations;
311
+ }
312
+ };
313
+ function newConnection(client, reference) {
314
+ if (!client) throw new TypeError("connector client is required");
315
+ return new Connection(reference, client);
316
+ }
317
+ function newConnectionWithOperations(operations, reference) {
318
+ return new Connection(reference, operations);
319
+ }
320
+ function newProjectConnection(project, connectionName, createClient) {
321
+ if (!project) throw new TypeError("loaded project is required");
322
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
323
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
324
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
325
+ return newConnection(createClient(project, connectionName), reference);
326
+ }
327
+ function newProjectCredentialProvider(project, connectionName, decode, encode, decodeShared) {
328
+ return newRefreshingCredentialProvider(project.connections, { connectorId: ConnectorID, connectionName }, decode, encode, decodeShared);
329
+ }
330
+
331
+ export {
332
+ ConfigSchema,
333
+ decodeCredentials,
334
+ decodeSharedCredentials,
335
+ PageSearchFilterSchema,
336
+ SearchPagesInputSchema,
337
+ PageSummarySchema,
338
+ SearchPagesOutputSchema,
339
+ GetPageInputSchema,
340
+ PageVersionSchema,
341
+ PageSchema,
342
+ CreatePageInputSchema,
343
+ CreatePageOutputSchema,
344
+ UpdatePageInputSchema,
345
+ UpdatePageOutputSchema,
346
+ AddCommentInputSchema,
347
+ AddCommentOutputSchema,
348
+ ConnectorID,
349
+ ProviderID,
350
+ SearchPagesBranch,
351
+ SearchPagesBranchSearched,
352
+ SearchPagesBranchProviderRejected,
353
+ SearchPagesBranchInvalidResponse,
354
+ SearchPagesBranchDefect,
355
+ SearchPagesDefinition,
356
+ SearchPagesMetadata,
357
+ GetPageBranch,
358
+ GetPageBranchFound,
359
+ GetPageBranchNotFound,
360
+ GetPageBranchProviderRejected,
361
+ GetPageBranchInvalidResponse,
362
+ GetPageBranchDefect,
363
+ GetPageDefinition,
364
+ GetPageMetadata,
365
+ CreatePageBranch,
366
+ CreatePageBranchCreated,
367
+ CreatePageBranchTitleConflict,
368
+ CreatePageBranchNotFound,
369
+ CreatePageBranchProviderRejected,
370
+ CreatePageBranchDefect,
371
+ CreatePageDefinition,
372
+ CreatePageMetadata,
373
+ UpdatePageBranch,
374
+ UpdatePageBranchUpdated,
375
+ UpdatePageBranchVersionConflict,
376
+ UpdatePageBranchNotFound,
377
+ UpdatePageBranchProviderRejected,
378
+ UpdatePageBranchDefect,
379
+ UpdatePageDefinition,
380
+ UpdatePageMetadata,
381
+ AddCommentBranch,
382
+ AddCommentBranchAdded,
383
+ AddCommentBranchNotFound,
384
+ AddCommentBranchProviderRejected,
385
+ AddCommentBranchUncertain,
386
+ AddCommentBranchDefect,
387
+ AddCommentDefinition,
388
+ AddCommentMetadata,
389
+ Connection,
390
+ newConnection,
391
+ newConnectionWithOperations,
392
+ newProjectConnection,
393
+ newProjectCredentialProvider
394
+ };