@superdurable/connector-atlassian-bitbucket 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.
package/dist/index.js ADDED
@@ -0,0 +1,2113 @@
1
+ import {
2
+ BranchPageSchema,
3
+ BranchRefInputSchema,
4
+ BranchSchema,
5
+ BranchTargetSchema,
6
+ ConfigSchema,
7
+ Connection,
8
+ ConnectorID,
9
+ CreateBranchBranch,
10
+ CreateBranchBranchCreated,
11
+ CreateBranchBranchDefect,
12
+ CreateBranchBranchInvalidResponse,
13
+ CreateBranchBranchNotFound,
14
+ CreateBranchBranchProviderRejected,
15
+ CreateBranchDefinition,
16
+ CreateBranchInputSchema,
17
+ CreateBranchMetadata,
18
+ CreatePullRequestBranch,
19
+ CreatePullRequestBranchCreated,
20
+ CreatePullRequestBranchDefect,
21
+ CreatePullRequestBranchProviderRejected,
22
+ CreatePullRequestBranchUncertain,
23
+ CreatePullRequestCommentBranch,
24
+ CreatePullRequestCommentBranchCreated,
25
+ CreatePullRequestCommentBranchDefect,
26
+ CreatePullRequestCommentBranchProviderRejected,
27
+ CreatePullRequestCommentBranchUncertain,
28
+ CreatePullRequestCommentDefinition,
29
+ CreatePullRequestCommentInputSchema,
30
+ CreatePullRequestCommentMetadata,
31
+ CreatePullRequestDefinition,
32
+ CreatePullRequestInputSchema,
33
+ CreatePullRequestMetadata,
34
+ CreateRepositoryBranch,
35
+ CreateRepositoryBranchCreated,
36
+ CreateRepositoryBranchDefect,
37
+ CreateRepositoryBranchInvalidResponse,
38
+ CreateRepositoryBranchNotFound,
39
+ CreateRepositoryBranchProviderRejected,
40
+ CreateRepositoryDefinition,
41
+ CreateRepositoryInputSchema,
42
+ CreateRepositoryMetadata,
43
+ CredentialMaterialError,
44
+ DeclinePullRequestBranch,
45
+ DeclinePullRequestBranchDeclined,
46
+ DeclinePullRequestBranchDefect,
47
+ DeclinePullRequestBranchInvalidResponse,
48
+ DeclinePullRequestBranchNotFound,
49
+ DeclinePullRequestBranchProviderRejected,
50
+ DeclinePullRequestDefinition,
51
+ DeclinePullRequestMetadata,
52
+ DeleteBranchBranch,
53
+ DeleteBranchBranchDefect,
54
+ DeleteBranchBranchDeleted,
55
+ DeleteBranchBranchNotFound,
56
+ DeleteBranchBranchProviderRejected,
57
+ DeleteBranchDefinition,
58
+ DeleteBranchMetadata,
59
+ DeletePullRequestCommentBranch,
60
+ DeletePullRequestCommentBranchDefect,
61
+ DeletePullRequestCommentBranchDeleted,
62
+ DeletePullRequestCommentBranchNotFound,
63
+ DeletePullRequestCommentBranchProviderRejected,
64
+ DeletePullRequestCommentDefinition,
65
+ DeletePullRequestCommentMetadata,
66
+ DeleteRepositoryBranch,
67
+ DeleteRepositoryBranchDefect,
68
+ DeleteRepositoryBranchDeleted,
69
+ DeleteRepositoryBranchInvalidResponse,
70
+ DeleteRepositoryBranchNotFound,
71
+ DeleteRepositoryBranchProviderRejected,
72
+ DeleteRepositoryDefinition,
73
+ DeleteRepositoryInputSchema,
74
+ DeleteRepositoryMetadata,
75
+ DeletedBranchSchema,
76
+ DeletedPullRequestCommentSchema,
77
+ DeletedRepositorySchema,
78
+ GetBranchBranch,
79
+ GetBranchBranchDefect,
80
+ GetBranchBranchFound,
81
+ GetBranchBranchInvalidResponse,
82
+ GetBranchBranchNotFound,
83
+ GetBranchBranchProviderRejected,
84
+ GetBranchDefinition,
85
+ GetBranchMetadata,
86
+ GetPullRequestBranch,
87
+ GetPullRequestBranchDefect,
88
+ GetPullRequestBranchFound,
89
+ GetPullRequestBranchInvalidResponse,
90
+ GetPullRequestBranchNotFound,
91
+ GetPullRequestBranchProviderRejected,
92
+ GetPullRequestCommentBranch,
93
+ GetPullRequestCommentBranchDefect,
94
+ GetPullRequestCommentBranchFound,
95
+ GetPullRequestCommentBranchInvalidResponse,
96
+ GetPullRequestCommentBranchNotFound,
97
+ GetPullRequestCommentBranchProviderRejected,
98
+ GetPullRequestCommentDefinition,
99
+ GetPullRequestCommentMetadata,
100
+ GetPullRequestDefinition,
101
+ GetPullRequestInputSchema,
102
+ GetPullRequestMetadata,
103
+ GetRepositoryBranch,
104
+ GetRepositoryBranchDefect,
105
+ GetRepositoryBranchFound,
106
+ GetRepositoryBranchInvalidResponse,
107
+ GetRepositoryBranchNotFound,
108
+ GetRepositoryBranchProviderRejected,
109
+ GetRepositoryDefinition,
110
+ GetRepositoryInputSchema,
111
+ GetRepositoryMetadata,
112
+ ListBranchesBranch,
113
+ ListBranchesBranchDefect,
114
+ ListBranchesBranchInvalidResponse,
115
+ ListBranchesBranchListed,
116
+ ListBranchesBranchNotFound,
117
+ ListBranchesBranchProviderRejected,
118
+ ListBranchesDefinition,
119
+ ListBranchesInputSchema,
120
+ ListBranchesMetadata,
121
+ ListPullRequestCommentsBranch,
122
+ ListPullRequestCommentsBranchDefect,
123
+ ListPullRequestCommentsBranchInvalidResponse,
124
+ ListPullRequestCommentsBranchListed,
125
+ ListPullRequestCommentsBranchNotFound,
126
+ ListPullRequestCommentsBranchProviderRejected,
127
+ ListPullRequestCommentsDefinition,
128
+ ListPullRequestCommentsMetadata,
129
+ ListPullRequestsBranch,
130
+ ListPullRequestsBranchDefect,
131
+ ListPullRequestsBranchInvalidResponse,
132
+ ListPullRequestsBranchListed,
133
+ ListPullRequestsBranchNotFound,
134
+ ListPullRequestsBranchProviderRejected,
135
+ ListPullRequestsDefinition,
136
+ ListPullRequestsInputSchema,
137
+ ListPullRequestsMetadata,
138
+ ListRepositoriesBranch,
139
+ ListRepositoriesBranchDefect,
140
+ ListRepositoriesBranchInvalidResponse,
141
+ ListRepositoriesBranchListed,
142
+ ListRepositoriesBranchNotFound,
143
+ ListRepositoriesBranchProviderRejected,
144
+ ListRepositoriesDefinition,
145
+ ListRepositoriesInputSchema,
146
+ ListRepositoriesMetadata,
147
+ MergePullRequestBranch,
148
+ MergePullRequestBranchDefect,
149
+ MergePullRequestBranchInvalidResponse,
150
+ MergePullRequestBranchMerged,
151
+ MergePullRequestBranchNotFound,
152
+ MergePullRequestBranchProviderRejected,
153
+ MergePullRequestDefinition,
154
+ MergePullRequestMetadata,
155
+ ProviderID,
156
+ PullRequestActionInputSchema,
157
+ PullRequestCommentContentSchema,
158
+ PullRequestCommentIDInputSchema,
159
+ PullRequestCommentPageSchema,
160
+ PullRequestCommentResolutionSchema,
161
+ PullRequestCommentSchema,
162
+ PullRequestPageSchema,
163
+ PullRequestSchema,
164
+ RepositoryPageSchema,
165
+ RepositorySchema,
166
+ ResolvePullRequestCommentBranch,
167
+ ResolvePullRequestCommentBranchDefect,
168
+ ResolvePullRequestCommentBranchInvalidResponse,
169
+ ResolvePullRequestCommentBranchNotFound,
170
+ ResolvePullRequestCommentBranchProviderRejected,
171
+ ResolvePullRequestCommentBranchResolved,
172
+ ResolvePullRequestCommentDefinition,
173
+ ResolvePullRequestCommentMetadata,
174
+ UnresolvePullRequestCommentBranch,
175
+ UnresolvePullRequestCommentBranchDefect,
176
+ UnresolvePullRequestCommentBranchInvalidResponse,
177
+ UnresolvePullRequestCommentBranchNotFound,
178
+ UnresolvePullRequestCommentBranchProviderRejected,
179
+ UnresolvePullRequestCommentBranchUnresolved,
180
+ UnresolvePullRequestCommentDefinition,
181
+ UnresolvePullRequestCommentMetadata,
182
+ UpdatePullRequestCommentBranch,
183
+ UpdatePullRequestCommentBranchDefect,
184
+ UpdatePullRequestCommentBranchInvalidResponse,
185
+ UpdatePullRequestCommentBranchNotFound,
186
+ UpdatePullRequestCommentBranchProviderRejected,
187
+ UpdatePullRequestCommentBranchUpdated,
188
+ UpdatePullRequestCommentDefinition,
189
+ UpdatePullRequestCommentInputSchema,
190
+ UpdatePullRequestCommentMetadata,
191
+ UpdatePullRequestTitleBranch,
192
+ UpdatePullRequestTitleBranchDefect,
193
+ UpdatePullRequestTitleBranchInvalidResponse,
194
+ UpdatePullRequestTitleBranchNotFound,
195
+ UpdatePullRequestTitleBranchProviderRejected,
196
+ UpdatePullRequestTitleBranchUpdated,
197
+ UpdatePullRequestTitleDefinition,
198
+ UpdatePullRequestTitleInputSchema,
199
+ UpdatePullRequestTitleMetadata,
200
+ UpdateRepositoryBranch,
201
+ UpdateRepositoryBranchDefect,
202
+ UpdateRepositoryBranchInvalidResponse,
203
+ UpdateRepositoryBranchNotFound,
204
+ UpdateRepositoryBranchProviderRejected,
205
+ UpdateRepositoryBranchUpdated,
206
+ UpdateRepositoryDefinition,
207
+ UpdateRepositoryInputSchema,
208
+ UpdateRepositoryMetadata,
209
+ decodeCredentials,
210
+ decodeSignedInteger,
211
+ exactIntegerJSONCodec,
212
+ isCredentialMaterialError,
213
+ newConnection,
214
+ newConnectionWithOperations,
215
+ newProjectConnection,
216
+ parseExactIntegerJSON,
217
+ parseJSONNumberTokens
218
+ } from "./chunk-4VFVRU2P.js";
219
+
220
+ // src/generated/steps.ts
221
+ import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
222
+ function newListBranchesStep(configuration) {
223
+ const { connection, connectionName, listed, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
224
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
225
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listBranches(), connection: connection.reference, branches: [
226
+ goToBranch("listed", listed),
227
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
228
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
229
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
230
+ ...defect ? [goToBranch("defect", defect)] : []
231
+ ] });
232
+ }
233
+ function newGetBranchStep(configuration) {
234
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
235
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
236
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getBranch(), connection: connection.reference, branches: [
237
+ goToBranch("found", found),
238
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
239
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
240
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
241
+ ...defect ? [goToBranch("defect", defect)] : []
242
+ ] });
243
+ }
244
+ function newCreateBranchStep(configuration) {
245
+ const { connection, connectionName, created, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
246
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
247
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createBranch(), connection: connection.reference, branches: [
248
+ goToBranch("created", created),
249
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
250
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
251
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
252
+ ...defect ? [goToBranch("defect", defect)] : []
253
+ ] });
254
+ }
255
+ function newDeleteBranchStep(configuration) {
256
+ const { connection, connectionName, deleted, notFound, providerRejected, defect, maxSends, ...stepConfiguration } = configuration;
257
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
258
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.deleteBranch(), connection: connection.reference, branches: [
259
+ goToBranch("deleted", deleted),
260
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
261
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
262
+ ...defect ? [goToBranch("defect", defect)] : []
263
+ ] });
264
+ }
265
+ function newListPullRequestCommentsStep(configuration) {
266
+ const { connection, connectionName, listed, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
267
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
268
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listPullRequestComments(), connection: connection.reference, branches: [
269
+ goToBranch("listed", listed),
270
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
271
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
272
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
273
+ ...defect ? [goToBranch("defect", defect)] : []
274
+ ] });
275
+ }
276
+ function newGetPullRequestCommentStep(configuration) {
277
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
278
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
279
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getPullRequestComment(), connection: connection.reference, branches: [
280
+ goToBranch("found", found),
281
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
282
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
283
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
284
+ ...defect ? [goToBranch("defect", defect)] : []
285
+ ] });
286
+ }
287
+ function newCreatePullRequestCommentStep(configuration) {
288
+ const { connection, connectionName, created, providerRejected, defect, uncertain, ...stepConfiguration } = configuration;
289
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
290
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createPullRequestComment(), connection: connection.reference, branches: [
291
+ goToBranch("created", created),
292
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
293
+ ...defect ? [goToBranch("defect", defect)] : [],
294
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : []
295
+ ] });
296
+ }
297
+ function newUpdatePullRequestCommentStep(configuration) {
298
+ const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
299
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
300
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updatePullRequestComment(), connection: connection.reference, branches: [
301
+ goToBranch("updated", updated),
302
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
303
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
304
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
305
+ ...defect ? [goToBranch("defect", defect)] : []
306
+ ] });
307
+ }
308
+ function newDeletePullRequestCommentStep(configuration) {
309
+ const { connection, connectionName, deleted, notFound, providerRejected, defect, maxSends, ...stepConfiguration } = configuration;
310
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
311
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.deletePullRequestComment(), connection: connection.reference, branches: [
312
+ goToBranch("deleted", deleted),
313
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
314
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
315
+ ...defect ? [goToBranch("defect", defect)] : []
316
+ ] });
317
+ }
318
+ function newResolvePullRequestCommentStep(configuration) {
319
+ const { connection, connectionName, resolved, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
320
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
321
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.resolvePullRequestComment(), connection: connection.reference, branches: [
322
+ goToBranch("resolved", resolved),
323
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
324
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
325
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
326
+ ...defect ? [goToBranch("defect", defect)] : []
327
+ ] });
328
+ }
329
+ function newUnresolvePullRequestCommentStep(configuration) {
330
+ const { connection, connectionName, unresolved, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
331
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
332
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.unresolvePullRequestComment(), connection: connection.reference, branches: [
333
+ goToBranch("unresolved", unresolved),
334
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
335
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
336
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
337
+ ...defect ? [goToBranch("defect", defect)] : []
338
+ ] });
339
+ }
340
+ function newCreatePullRequestStep(configuration) {
341
+ const { connection, connectionName, created, providerRejected, defect, uncertain, ...stepConfiguration } = configuration;
342
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
343
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createPullRequest(), connection: connection.reference, branches: [
344
+ goToBranch("created", created),
345
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
346
+ ...defect ? [goToBranch("defect", defect)] : [],
347
+ ...uncertain ? [goToBranch("uncertain", uncertain)] : []
348
+ ] });
349
+ }
350
+ function newMergePullRequestStep(configuration) {
351
+ const { connection, connectionName, merged, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
352
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
353
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.mergePullRequest(), connection: connection.reference, branches: [
354
+ goToBranch("merged", merged),
355
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
356
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
357
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
358
+ ...defect ? [goToBranch("defect", defect)] : []
359
+ ] });
360
+ }
361
+ function newDeclinePullRequestStep(configuration) {
362
+ const { connection, connectionName, declined, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
363
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
364
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.declinePullRequest(), connection: connection.reference, branches: [
365
+ goToBranch("declined", declined),
366
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
367
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
368
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
369
+ ...defect ? [goToBranch("defect", defect)] : []
370
+ ] });
371
+ }
372
+ function newCreateRepositoryStep(configuration) {
373
+ const { connection, connectionName, created, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
374
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
375
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createRepository(), connection: connection.reference, branches: [
376
+ goToBranch("created", created),
377
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
378
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
379
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
380
+ ...defect ? [goToBranch("defect", defect)] : []
381
+ ] });
382
+ }
383
+ function newUpdateRepositoryStep(configuration) {
384
+ const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
385
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
386
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateRepository(), connection: connection.reference, branches: [
387
+ goToBranch("updated", updated),
388
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
389
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
390
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
391
+ ...defect ? [goToBranch("defect", defect)] : []
392
+ ] });
393
+ }
394
+ function newDeleteRepositoryStep(configuration) {
395
+ const { connection, connectionName, deleted, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
396
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
397
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.deleteRepository(), connection: connection.reference, branches: [
398
+ goToBranch("deleted", deleted),
399
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
400
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
401
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
402
+ ...defect ? [goToBranch("defect", defect)] : []
403
+ ] });
404
+ }
405
+ function newGetRepositoryStep(configuration) {
406
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
407
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
408
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getRepository(), connection: connection.reference, branches: [
409
+ goToBranch("found", found),
410
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
411
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
412
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
413
+ ...defect ? [goToBranch("defect", defect)] : []
414
+ ] });
415
+ }
416
+ function newGetPullRequestStep(configuration) {
417
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
418
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
419
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getPullRequest(), connection: connection.reference, branches: [
420
+ goToBranch("found", found),
421
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
422
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
423
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
424
+ ...defect ? [goToBranch("defect", defect)] : []
425
+ ] });
426
+ }
427
+ function newUpdatePullRequestTitleStep(configuration) {
428
+ const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, maxSends, ...stepConfiguration } = configuration;
429
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
430
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updatePullRequestTitle(), connection: connection.reference, branches: [
431
+ goToBranch("updated", updated),
432
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
433
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
434
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
435
+ ...defect ? [goToBranch("defect", defect)] : []
436
+ ] });
437
+ }
438
+ function newListRepositoriesStep(configuration) {
439
+ const { connection, connectionName, listed, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
440
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
441
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listRepositories(), connection: connection.reference, branches: [
442
+ goToBranch("listed", listed),
443
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
444
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
445
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
446
+ ...defect ? [goToBranch("defect", defect)] : []
447
+ ] });
448
+ }
449
+ function newListPullRequestsStep(configuration) {
450
+ const { connection, connectionName, listed, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
451
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
452
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listPullRequests(), connection: connection.reference, branches: [
453
+ goToBranch("listed", listed),
454
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
455
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
456
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
457
+ ...defect ? [goToBranch("defect", defect)] : []
458
+ ] });
459
+ }
460
+
461
+ // src/client.ts
462
+ import { BodyTooLargeError, ProviderTransportError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
463
+ import { SecretString, defaultTriggerLogger } from "@superdurable/connectors-sdk";
464
+
465
+ // src/operations.ts
466
+ import { newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
467
+ var zeroRepositories = { values: [], next: "", page: 0, pagelen: 0 };
468
+ var zeroPullRequests = { values: [], next: "", page: 0, pagelen: 0 };
469
+ var ListRepositoriesOperation = class {
470
+ /** Bind one Bitbucket client. */
471
+ constructor(client) {
472
+ this.client = client;
473
+ }
474
+ client;
475
+ /** Return the manifest definition. */
476
+ definition() {
477
+ return ListRepositoriesDefinition;
478
+ }
479
+ /** Validate the workspace and read one page. */
480
+ async invoke(call, input) {
481
+ if (!validSegment(input.workspace)) return failed("listRepositories", "defect", "VALIDATION", "workspace must be a path segment", zeroRepositories);
482
+ const result = await this.client.read(call, "listRepositories", `/repositories/${escapePathSegment(input.workspace)}`);
483
+ if (!("response" in result)) return readFailure(result, zeroRepositories);
484
+ try {
485
+ return newQueryBranch("listed", decodeRepositoryPage(result.response.body));
486
+ } catch {
487
+ return failed("listRepositories", "invalidResponse", "PROTOCOL", "provider returned invalid JSON", zeroRepositories);
488
+ }
489
+ }
490
+ };
491
+ var ListPullRequestsOperation = class {
492
+ /** Bind one Bitbucket client. */
493
+ constructor(client) {
494
+ this.client = client;
495
+ }
496
+ client;
497
+ /** Return the manifest definition. */
498
+ definition() {
499
+ return ListPullRequestsDefinition;
500
+ }
501
+ /** Validate both path segments and read one page. */
502
+ async invoke(call, input) {
503
+ if (!validSegment(input.workspace)) return failed("listPullRequests", "defect", "VALIDATION", "workspace must be a path segment", zeroPullRequests);
504
+ if (!validSegment(input.repository)) return failed("listPullRequests", "defect", "VALIDATION", "repository must be a path segment", zeroPullRequests);
505
+ const path = `/repositories/${escapePathSegment(input.workspace)}/${escapePathSegment(input.repository)}/pullrequests`;
506
+ const result = await this.client.read(call, "listPullRequests", path);
507
+ if (!("response" in result)) return readFailure(result, zeroPullRequests);
508
+ try {
509
+ return newQueryBranch("listed", decodePullRequestPage(result.response.body));
510
+ } catch {
511
+ return failed("listPullRequests", "invalidResponse", "PROTOCOL", "provider returned invalid JSON", zeroPullRequests);
512
+ }
513
+ }
514
+ };
515
+ function validSegment(value) {
516
+ return typeof value === "string" && value !== "" && value !== "." && value !== ".." && !/[/?#]/.test(value) && ![...value].some((character) => character.charCodeAt(0) < 32);
517
+ }
518
+ function escapePathSegment(value) {
519
+ return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%24|%26|%2B|%3D|%3A|%40/gi, (encoded) => String.fromCharCode(Number.parseInt(encoded.slice(1), 16)));
520
+ }
521
+ function readFailure(result, zero) {
522
+ if ("retry" in result) return newQueryRetry(result.failure, result.retryAfterMs);
523
+ return newQueryBranch(result.branch, zero, {}, result.failure);
524
+ }
525
+ function failed(operation, branch, kind, message, zero) {
526
+ return newQueryBranch(branch, zero, {}, { kind, provider: "bitbucket", operation, message });
527
+ }
528
+ function decodePage(body) {
529
+ const value = parseJSONNumberTokens(Buffer.from(body).toString("utf8"));
530
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("invalid page");
531
+ const page2 = value;
532
+ if (!Array.isArray(page2.values)) throw new TypeError("missing values");
533
+ return page2;
534
+ }
535
+ function goString(value) {
536
+ if (value === void 0 || value === null) return "";
537
+ if (typeof value !== "string") throw new TypeError("invalid string");
538
+ return value;
539
+ }
540
+ function goInteger(value) {
541
+ return decodeSignedInteger(value ?? 0);
542
+ }
543
+ function goBoolean(value) {
544
+ if (value === void 0 || value === null) return false;
545
+ if (typeof value !== "boolean") throw new TypeError("invalid boolean");
546
+ return value;
547
+ }
548
+ function goObject(value) {
549
+ if (value === null) return {};
550
+ if (typeof value !== "object" || Array.isArray(value)) throw new TypeError("invalid item");
551
+ return value;
552
+ }
553
+ function decodeRepositoryPage(body) {
554
+ const page2 = decodePage(body);
555
+ return { values: page2.values.map((item) => {
556
+ const repository2 = goObject(item);
557
+ return { uuid: goString(repository2.uuid), name: goString(repository2.name), full_name: goString(repository2.full_name), is_private: goBoolean(repository2.is_private) };
558
+ }), next: goString(page2.next), page: goInteger(page2.page), pagelen: goInteger(page2.pagelen) };
559
+ }
560
+ function decodePullRequestPage(body) {
561
+ const page2 = decodePage(body);
562
+ return { values: page2.values.map((item) => {
563
+ const pullRequest2 = goObject(item);
564
+ return { id: goInteger(pullRequest2.id), title: goString(pullRequest2.title), state: goString(pullRequest2.state) };
565
+ }), next: goString(page2.next), page: goInteger(page2.page), pagelen: goInteger(page2.pagelen) };
566
+ }
567
+
568
+ // src/management.ts
569
+ import {
570
+ definitionMaxSends,
571
+ newMutationBranch,
572
+ newMutationRetry,
573
+ newMutationUncertain,
574
+ newQueryBranch as newQueryBranch2,
575
+ newQueryRetry as newQueryRetry2
576
+ } from "@superdurable/connectors-sdk";
577
+ import { Fence } from "@superdurable/connectors-sdk/singledispatch";
578
+
579
+ // src/transport.ts
580
+ var prepareWrite = /* @__PURE__ */ Symbol("prepareWrite");
581
+
582
+ // src/management.ts
583
+ var auth = "Bitbucket credentials are unavailable";
584
+ var refusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
585
+ var Operation = class {
586
+ constructor(client) {
587
+ this.client = client;
588
+ if (!client) throw new TypeError("Bitbucket client is required");
589
+ }
590
+ client;
591
+ failure(kind, message) {
592
+ return { kind, message, provider: "bitbucket", operation: this.operation };
593
+ }
594
+ };
595
+ var QueryOperation = class extends Operation {
596
+ /** Return the generated Query contract. */
597
+ definition() {
598
+ return this.contract;
599
+ }
600
+ defect() {
601
+ return newQueryBranch2("defect", this.empty(), {}, this.failure("VALIDATION", "Bitbucket resource identity is invalid"));
602
+ }
603
+ async read(call, path, branch, decode) {
604
+ const outcome = await this.client.read(call, this.operation, path);
605
+ if ("retry" in outcome) return newQueryRetry2(outcome.failure, outcome.retryAfterMs);
606
+ if ("failure" in outcome) return newQueryBranch2(outcome.branch, this.empty(), {}, outcome.failure);
607
+ try {
608
+ return newQueryBranch2(branch, decode(providerJSON(outcome.response.body)));
609
+ } catch {
610
+ return newQueryBranch2(
611
+ "invalidResponse",
612
+ this.empty(),
613
+ {},
614
+ this.failure("PROTOCOL", "Bitbucket returned invalid resource data")
615
+ );
616
+ }
617
+ }
618
+ };
619
+ var MutationOperation = class extends Operation {
620
+ /** Return the generated Mutation contract. */
621
+ definition() {
622
+ return this.contract;
623
+ }
624
+ /** Use the stable call identity across attempts. */
625
+ idempotencyKey(callId, input) {
626
+ void input;
627
+ return callId;
628
+ }
629
+ branch(branch, kind, message) {
630
+ return newMutationBranch(branch, this.empty(), {}, this.failure(kind, message));
631
+ }
632
+ defect() {
633
+ return this.branch("defect", "VALIDATION", "Bitbucket write input is invalid");
634
+ }
635
+ retry(kind, message, delay = 0) {
636
+ return newMutationRetry(this.failure(kind, message), delay);
637
+ }
638
+ async exchange(call, method, path, payload) {
639
+ const sender = await this.client[prepareWrite](call, method, path, payload);
640
+ return typeof sender === "function" ? sender(call.context.cancellationSignal) : sender;
641
+ }
642
+ transient(call, exchange, availabilityDelay = false, confirming = false, comment2 = false) {
643
+ const { status, error, retryAfterMs } = exchange;
644
+ if (error === "credential") {
645
+ if (attempt(call) > 1) return this.retry("TRANSPORT", "An earlier Bitbucket write remains unconfirmed");
646
+ return this.branch(confirming ? "invalidResponse" : "defect", "AUTHENTICATION", auth);
647
+ }
648
+ if (error === "transport") return this.retry("TRANSPORT", "Bitbucket write request failed");
649
+ if (status === 429) {
650
+ if (confirming && comment2) return this.retry("AVAILABILITY", "Bitbucket confirmation is unavailable");
651
+ return this.retry("RATE_LIMIT", "Bitbucket rate limited the request", retryAfterMs);
652
+ }
653
+ if (status >= 500 || status === 408 && !(confirming && comment2))
654
+ return this.retry("AVAILABILITY", "Bitbucket is temporarily unavailable", availabilityDelay ? retryAfterMs : 0);
655
+ }
656
+ refusal(call, exchange, authStatus) {
657
+ if (attempt(call) > 1 || !definiteRefusal(exchange))
658
+ return this.retry("TRANSPORT", "Bitbucket write outcome is unknown");
659
+ if (exchange.status === 404) return this.branch("notFound", "NOT_FOUND", "Bitbucket resource was not found");
660
+ let kind = "PROVIDER_REJECTION";
661
+ if (authStatus && (exchange.status === 401 || exchange.status === 403))
662
+ kind = exchange.status === 401 && authStatus === "title" ? "AUTHENTICATION" : "AUTHORIZATION";
663
+ return this.branch("providerRejected", kind, `Bitbucket rejected HTTP ${exchange.status}`);
664
+ }
665
+ async write(call, request) {
666
+ const exchange = await this.exchange(call, request.method, request.path, request.payload);
667
+ const transient = this.transient(call, exchange, request.availabilityDelay);
668
+ if (transient) return transient;
669
+ const confirmation = request.confirmation;
670
+ if (confirmation?.statuses.includes(exchange.status)) return this.confirm(call, request, confirmation);
671
+ const authStatus = request.authStatus ?? "";
672
+ if (!(request.statuses ?? [200]).includes(exchange.status)) return this.refusal(call, exchange, authStatus);
673
+ if (authStatus === "repository" || authStatus === "title") {
674
+ if (exchange.error === "tooLarge") return this.retry("RESPONSE_TOO_LARGE", "Bitbucket response exceeded the limit");
675
+ if (exchange.error === "read") return this.retry("TRANSPORT", "Bitbucket response was interrupted");
676
+ }
677
+ try {
678
+ const value = decodeExchange(exchange, request.decode);
679
+ if (!request.matches(value)) throw new TypeError("Bitbucket returned different state");
680
+ return newMutationBranch(request.branch, value);
681
+ } catch {
682
+ return this.retry("PROTOCOL", "Bitbucket returned an unconfirmed resource");
683
+ }
684
+ }
685
+ async confirm(call, request, confirmation) {
686
+ const exchange = await this.exchange(call, "GET", confirmation.path);
687
+ const transient = this.transient(call, exchange, false, true, confirmation.comment);
688
+ if (transient) return transient;
689
+ if (exchange.status !== 200) return this.retry("TRANSPORT", "Bitbucket did not confirm the resource state");
690
+ let value;
691
+ try {
692
+ value = decodeExchange(exchange, request.decode);
693
+ if (confirmation.identity && !confirmation.identity(value)) throw new TypeError("Bitbucket returned a different resource");
694
+ } catch {
695
+ return this.retry("PROTOCOL", "Bitbucket returned an invalid confirmation");
696
+ }
697
+ if (!request.matches(value)) return this.retry("TRANSPORT", "Bitbucket resource state remains unconfirmed");
698
+ return newMutationBranch(request.branch, value);
699
+ }
700
+ async delete(call, path, value, isRepository = false) {
701
+ const exchange = await this.exchange(call, "DELETE", path);
702
+ const transient = this.transient(call, exchange, isRepository);
703
+ if (transient) return transient;
704
+ if (exchange.status === 204) {
705
+ if (exchange.body.length || exchange.error) return this.retry("PROTOCOL", "Bitbucket deletion acknowledgment is invalid");
706
+ return newMutationBranch("deleted", value);
707
+ }
708
+ if (exchange.status === 200 && isRepository)
709
+ return this.retry("PROTOCOL", "Bitbucket returned an unexpected deletion response");
710
+ return this.refusal(call, exchange, isRepository ? "repository" : "");
711
+ }
712
+ async createLimited(call, path, payload, decode, matches) {
713
+ const maxSends = call.maxSendsOverride ?? definitionMaxSends(this.contract);
714
+ let fence;
715
+ try {
716
+ fence = new Fence(call, this.contract.stepDefaults.executeMethodTimeoutMs, { maxSends });
717
+ } catch {
718
+ return this.branch("defect", "LOCAL_DEFECT", "Bitbucket dispatch checkpoint is unavailable");
719
+ }
720
+ const decision = fence.decide();
721
+ if (decision.kind === "failClosed") return this.retry("TRANSPORT", "Bitbucket dispatch checkpoint is unreadable");
722
+ if (decision.kind === "readBackRequired")
723
+ return newMutationUncertain(this.empty(), this.failure("TRANSPORT", "Bitbucket creation could not be confirmed within the send cap"), {});
724
+ const prior = decision.priorSendUpperBound ?? 0;
725
+ const send = await this.client[prepareWrite](call, "POST", path, payload);
726
+ if (typeof send !== "function") {
727
+ if (prior) return this.retry("AUTHENTICATION", "An earlier Bitbucket creation may have succeeded");
728
+ if (this.operation === "createPullRequest" && attempt(call) > 1)
729
+ return this.retry("TRANSPORT", "An earlier Bitbucket creation remains unconfirmed");
730
+ return this.branch("defect", "AUTHENTICATION", auth);
731
+ }
732
+ let exchange;
733
+ try {
734
+ exchange = await fence.dispatch(send);
735
+ } catch {
736
+ return this.retry("AVAILABILITY", "Bitbucket request was not dispatched");
737
+ }
738
+ const { status, error, retryAfterMs } = exchange;
739
+ if (error === "transport") return this.retry("TRANSPORT", "Bitbucket creation request failed");
740
+ if (status === 429 || status === 503) {
741
+ if (!await recordResend(fence)) return this.retry("AVAILABILITY", "Bitbucket resend checkpoint is unavailable");
742
+ return this.retry(
743
+ status === 429 ? "RATE_LIMIT" : "AVAILABILITY",
744
+ "Bitbucket temporarily rejected creation",
745
+ retryAfterMs
746
+ );
747
+ }
748
+ if (status === 408 || status >= 500) return this.retry("AVAILABILITY", "Bitbucket creation outcome is unknown");
749
+ if (status !== 201) {
750
+ if (!definiteRefusal(exchange)) return this.retry("TRANSPORT", "Bitbucket creation outcome is unknown");
751
+ if (prior) return this.retry("PROVIDER_REJECTION", "An earlier Bitbucket creation may have succeeded");
752
+ if (!await recordResend(fence)) return this.retry("TRANSPORT", "Bitbucket refusal checkpoint is unavailable");
753
+ return this.branch("providerRejected", "PROVIDER_REJECTION", `Bitbucket rejected HTTP ${status}`);
754
+ }
755
+ try {
756
+ const value = decodeExchange(exchange, decode);
757
+ if (!matches(value)) throw new TypeError("Bitbucket returned different state");
758
+ return newMutationBranch("created", value);
759
+ } catch {
760
+ return this.retry("PROTOCOL", "Bitbucket returned an unconfirmed created resource");
761
+ }
762
+ }
763
+ };
764
+ async function recordResend(fence) {
765
+ try {
766
+ await fence.recordCanResend();
767
+ return true;
768
+ } catch {
769
+ return false;
770
+ }
771
+ }
772
+ function attempt(call) {
773
+ return call.context.attempt ?? 1;
774
+ }
775
+ function providerJSON(body) {
776
+ return parseJSONNumberTokens(Buffer.from(body).toString("utf8"));
777
+ }
778
+ function decodeExchange(exchange, decode) {
779
+ if (exchange.error) throw new TypeError("Bitbucket response could not be read");
780
+ return decode(providerJSON(exchange.body));
781
+ }
782
+ function definiteRefusal(exchange) {
783
+ if (exchange.error || !refusalStatuses.has(exchange.status)) return false;
784
+ try {
785
+ const response = goObject(providerJSON(exchange.body));
786
+ return response.type === "error" && !!goString(goObject(response.error).message) && response.data == null && response.result == null;
787
+ } catch {
788
+ return false;
789
+ }
790
+ }
791
+ function entity(value) {
792
+ const row = goObject(value);
793
+ if (row.success === false || row.type === "error" || ["error", "errors"].some((field) => {
794
+ const item = row[field];
795
+ if (item == null) return false;
796
+ return typeof item !== "object" || Object.keys(item).length !== 0;
797
+ })) throw new TypeError("Bitbucket response contains contradictory error data");
798
+ return row;
799
+ }
800
+ function repository(value) {
801
+ const row = entity(value);
802
+ const uuid = goString(row.uuid);
803
+ const name = goString(row.name);
804
+ const fullName = goString(row.full_name);
805
+ if (!uuid || !name || !fullName) throw new TypeError("Bitbucket repository identity is incomplete");
806
+ return { uuid, name, full_name: fullName, is_private: goBoolean(row.is_private) };
807
+ }
808
+ function pullRequest(value) {
809
+ const row = entity(value);
810
+ const id = goInteger(row.id);
811
+ const title = goString(row.title);
812
+ const state = goString(row.state);
813
+ if (!validId(id) || !title || !state) throw new TypeError("Bitbucket pull request identity is incomplete");
814
+ return { id, title, state };
815
+ }
816
+ function branchFields(row) {
817
+ const name = goString(row.name);
818
+ const hash = goString(goObject(row.target).hash);
819
+ if (!branchName(name) || !hash) throw new TypeError("Bitbucket branch identity is incomplete");
820
+ return { name, target: { hash } };
821
+ }
822
+ function branchValue(value) {
823
+ return branchFields(entity(value));
824
+ }
825
+ function commentFields(row) {
826
+ const id = goInteger(row.id);
827
+ if (!validId(id)) throw new TypeError("Bitbucket comment identity is incomplete");
828
+ const raw = goString(goObject(row.content ?? null).raw);
829
+ return {
830
+ id,
831
+ content: { raw },
832
+ deleted: goBoolean(row.deleted),
833
+ ...row.resolution == null ? {} : { resolution: { created_on: goString(goObject(row.resolution).created_on) } }
834
+ };
835
+ }
836
+ function comment(value) {
837
+ return commentFields(entity(value));
838
+ }
839
+ function page(value, decode) {
840
+ const row = goObject(value);
841
+ if (!Array.isArray(row.values)) throw new TypeError("Bitbucket page is missing values");
842
+ return {
843
+ values: row.values.map((item) => decode(goObject(item))),
844
+ next: goString(row.next),
845
+ page: goInteger(row.page),
846
+ pagelen: goInteger(row.pagelen)
847
+ };
848
+ }
849
+ function validId(value) {
850
+ try {
851
+ return BigInt(idText(decodeSignedInteger(value))) > 0n;
852
+ } catch {
853
+ return false;
854
+ }
855
+ }
856
+ function idText(value) {
857
+ return typeof value === "number" ? String(value) : value.rawJSON;
858
+ }
859
+ function sameId(first, second) {
860
+ return idText(first) === idText(second);
861
+ }
862
+ function validRepository(workspace, repositoryName) {
863
+ return validSegment(workspace) && validSegment(repositoryName);
864
+ }
865
+ function repositoryPath(workspace, repositoryName) {
866
+ return `/repositories/${escapePathSegment(workspace)}/${escapePathSegment(repositoryName)}`;
867
+ }
868
+ function branches(workspace, repositoryName) {
869
+ return repositoryPath(workspace, repositoryName) + "/refs/branches";
870
+ }
871
+ function pullRequests(workspace, repositoryName) {
872
+ return repositoryPath(workspace, repositoryName) + "/pullrequests";
873
+ }
874
+ function pull(workspace, repositoryName, id) {
875
+ return `${pullRequests(workspace, repositoryName)}/${idText(id)}`;
876
+ }
877
+ function comments(workspace, repositoryName, id) {
878
+ return pull(workspace, repositoryName, id) + "/comments";
879
+ }
880
+ function branchName(name) {
881
+ return !!name && name !== "@" && !name.startsWith("/") && !name.endsWith("/") && !name.startsWith("refs/heads/") && !["//", "..", "@{"].some((part) => name.includes(part)) && ![..." \r\n~^:?*[\\"].some((character) => name.includes(character));
882
+ }
883
+ function writtenText(value, length) {
884
+ return !!value.trim() && (length === void 0 || Buffer.byteLength(value) <= length);
885
+ }
886
+ var ListBranchesOperation = class extends QueryOperation {
887
+ operation = "listBranches";
888
+ contract = ListBranchesDefinition;
889
+ empty() {
890
+ return { values: [], next: "", page: 0, pagelen: 0 };
891
+ }
892
+ /** List branches in a Bitbucket repository. */
893
+ async invoke(call, input) {
894
+ if (!validRepository(input.workspace, input.repository)) return this.defect();
895
+ const path = branches(input.workspace, input.repository);
896
+ return this.read(call, path, "listed", (value) => page(value, branchFields));
897
+ }
898
+ };
899
+ var GetBranchOperation = class extends QueryOperation {
900
+ operation = "getBranch";
901
+ contract = GetBranchDefinition;
902
+ empty() {
903
+ return { name: "", target: { hash: "" } };
904
+ }
905
+ /** Read a branch in a Bitbucket repository. */
906
+ async invoke(call, input) {
907
+ if (!validRepository(input.workspace, input.repository) || !branchName(input.name)) return this.defect();
908
+ const path = branches(input.workspace, input.repository) + "/" + escapePathSegment(input.name);
909
+ return this.read(call, path, "found", branchValue);
910
+ }
911
+ };
912
+ var CreateBranchOperation = class extends MutationOperation {
913
+ operation = "createBranch";
914
+ contract = CreateBranchDefinition;
915
+ empty() {
916
+ return { name: "", target: { hash: "" } };
917
+ }
918
+ /** Create a branch in a Bitbucket repository. */
919
+ async invoke(call, input) {
920
+ if (!validRepository(input.workspace, input.repository) || !branchName(input.name) || !/^[0-9a-fA-F]{40}(?![\s\S])/u.test(input.targetHash)) return this.defect();
921
+ const path = branches(input.workspace, input.repository);
922
+ return this.write(call, {
923
+ method: "POST",
924
+ path,
925
+ payload: { name: input.name, target: { hash: input.targetHash } },
926
+ branch: "created",
927
+ decode: branchValue,
928
+ statuses: [201],
929
+ matches: (value) => value.name === input.name && value.target.hash.toLowerCase() === input.targetHash.toLowerCase()
930
+ });
931
+ }
932
+ };
933
+ var DeleteBranchOperation = class extends MutationOperation {
934
+ operation = "deleteBranch";
935
+ contract = DeleteBranchDefinition;
936
+ empty() {
937
+ return { workspace: "", repository: "", name: "" };
938
+ }
939
+ /** Delete a branch in a Bitbucket repository. */
940
+ async invoke(call, input) {
941
+ if (!validRepository(input.workspace, input.repository) || !branchName(input.name)) return this.defect();
942
+ const path = branches(input.workspace, input.repository) + "/" + escapePathSegment(input.name);
943
+ return this.delete(call, path, { workspace: input.workspace, repository: input.repository, name: input.name });
944
+ }
945
+ };
946
+ var ListPullRequestCommentsOperation = class extends QueryOperation {
947
+ operation = "listPullRequestComments";
948
+ contract = ListPullRequestCommentsDefinition;
949
+ empty() {
950
+ return { values: [], next: "", page: 0, pagelen: 0 };
951
+ }
952
+ /** List comments on a pull request. */
953
+ async invoke(call, input) {
954
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId)) return this.defect();
955
+ const path = comments(input.workspace, input.repository, input.pullRequestId);
956
+ return this.read(call, path, "listed", (value) => page(value, commentFields));
957
+ }
958
+ };
959
+ var GetPullRequestCommentOperation = class extends QueryOperation {
960
+ operation = "getPullRequestComment";
961
+ contract = GetPullRequestCommentDefinition;
962
+ empty() {
963
+ return { id: 0, content: { raw: "" }, deleted: false };
964
+ }
965
+ /** Read one pull request comment. */
966
+ async invoke(call, input) {
967
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId) || !validId(input.commentId)) return this.defect();
968
+ const path = comments(input.workspace, input.repository, input.pullRequestId) + "/" + idText(input.commentId);
969
+ return this.read(call, path, "found", comment);
970
+ }
971
+ };
972
+ var CreatePullRequestCommentOperation = class extends MutationOperation {
973
+ operation = "createPullRequestComment";
974
+ contract = CreatePullRequestCommentDefinition;
975
+ empty() {
976
+ return { id: 0, content: { raw: "" }, deleted: false };
977
+ }
978
+ /** Create a pull request comment. */
979
+ async invoke(call, input) {
980
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId) || !writtenText(input.raw)) return this.defect();
981
+ const path = comments(input.workspace, input.repository, input.pullRequestId);
982
+ return this.createLimited(
983
+ call,
984
+ path,
985
+ { content: { raw: input.raw } },
986
+ comment,
987
+ (value) => value.content.raw === input.raw
988
+ );
989
+ }
990
+ };
991
+ var UpdatePullRequestCommentOperation = class extends MutationOperation {
992
+ operation = "updatePullRequestComment";
993
+ contract = UpdatePullRequestCommentDefinition;
994
+ empty() {
995
+ return { id: 0, content: { raw: "" }, deleted: false };
996
+ }
997
+ /** Replace pull request comment text. */
998
+ async invoke(call, input) {
999
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId) || !validId(input.commentId) || !writtenText(input.raw)) return this.defect();
1000
+ const path = comments(input.workspace, input.repository, input.pullRequestId) + "/" + idText(input.commentId);
1001
+ return this.write(call, {
1002
+ method: "PUT",
1003
+ path,
1004
+ payload: { content: { raw: input.raw } },
1005
+ branch: "updated",
1006
+ decode: comment,
1007
+ matches: (value) => sameId(value.id, input.commentId) && value.content.raw === input.raw
1008
+ });
1009
+ }
1010
+ };
1011
+ var DeletePullRequestCommentOperation = class extends MutationOperation {
1012
+ operation = "deletePullRequestComment";
1013
+ contract = DeletePullRequestCommentDefinition;
1014
+ empty() {
1015
+ return { workspace: "", repository: "", pullRequestId: 0, commentId: 0 };
1016
+ }
1017
+ /** Delete a pull request comment. */
1018
+ async invoke(call, input) {
1019
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId) || !validId(input.commentId)) return this.defect();
1020
+ const path = comments(input.workspace, input.repository, input.pullRequestId) + "/" + idText(input.commentId);
1021
+ return this.delete(call, path, { workspace: input.workspace, repository: input.repository, pullRequestId: input.pullRequestId, commentId: input.commentId });
1022
+ }
1023
+ };
1024
+ var ResolvePullRequestCommentOperation = class extends MutationOperation {
1025
+ operation = "resolvePullRequestComment";
1026
+ contract = ResolvePullRequestCommentDefinition;
1027
+ empty() {
1028
+ return { id: 0, content: { raw: "" }, deleted: false };
1029
+ }
1030
+ /** Resolve a pull request comment. */
1031
+ async invoke(call, input) {
1032
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId) || !validId(input.commentId)) return this.defect();
1033
+ const path = comments(input.workspace, input.repository, input.pullRequestId) + "/" + idText(input.commentId);
1034
+ return this.write(call, {
1035
+ method: "POST",
1036
+ path: path + "/resolve",
1037
+ branch: "resolved",
1038
+ decode: comment,
1039
+ matches: (value) => sameId(value.id, input.commentId) && value.resolution !== void 0,
1040
+ confirmation: { path, statuses: [204, 409], comment: true }
1041
+ });
1042
+ }
1043
+ };
1044
+ var UnresolvePullRequestCommentOperation = class extends MutationOperation {
1045
+ operation = "unresolvePullRequestComment";
1046
+ contract = UnresolvePullRequestCommentDefinition;
1047
+ empty() {
1048
+ return { id: 0, content: { raw: "" }, deleted: false };
1049
+ }
1050
+ /** Reopen a resolved pull request comment. */
1051
+ async invoke(call, input) {
1052
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId) || !validId(input.commentId)) return this.defect();
1053
+ const path = comments(input.workspace, input.repository, input.pullRequestId) + "/" + idText(input.commentId);
1054
+ return this.write(call, {
1055
+ method: "DELETE",
1056
+ path: path + "/resolve",
1057
+ branch: "unresolved",
1058
+ decode: comment,
1059
+ matches: (value) => sameId(value.id, input.commentId) && value.resolution === void 0,
1060
+ confirmation: { path, statuses: [204, 409], comment: true }
1061
+ });
1062
+ }
1063
+ };
1064
+ var CreatePullRequestOperation = class extends MutationOperation {
1065
+ operation = "createPullRequest";
1066
+ contract = CreatePullRequestDefinition;
1067
+ empty() {
1068
+ return { id: 0, title: "", state: "" };
1069
+ }
1070
+ /** Create a pull request between two branches of one repository. */
1071
+ async invoke(call, input) {
1072
+ if (!validRepository(input.workspace, input.repository) || !writtenText(input.title, 512) || !writtenText(input.sourceBranch) || !writtenText(input.destinationBranch) || input.sourceBranch === input.destinationBranch) return this.defect();
1073
+ const path = pullRequests(input.workspace, input.repository);
1074
+ const payload = {
1075
+ title: input.title,
1076
+ source: { branch: { name: input.sourceBranch } },
1077
+ destination: { branch: { name: input.destinationBranch } }
1078
+ };
1079
+ return this.createLimited(call, path, payload, pullRequest, (value) => value.title === input.title && value.state === "OPEN");
1080
+ }
1081
+ };
1082
+ var MergePullRequestOperation = class extends MutationOperation {
1083
+ operation = "mergePullRequest";
1084
+ contract = MergePullRequestDefinition;
1085
+ empty() {
1086
+ return { id: 0, title: "", state: "" };
1087
+ }
1088
+ /** Merge an open pull request into its destination branch. */
1089
+ async invoke(call, input) {
1090
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId)) return this.defect();
1091
+ const path = pull(input.workspace, input.repository, input.pullRequestId);
1092
+ return this.write(call, {
1093
+ method: "POST",
1094
+ path: path + "/merge",
1095
+ branch: "merged",
1096
+ decode: pullRequest,
1097
+ authStatus: "action",
1098
+ matches: (value) => sameId(value.id, input.pullRequestId) && value.state === "MERGED",
1099
+ confirmation: { path, statuses: [409], identity: (value) => sameId(value.id, input.pullRequestId) }
1100
+ });
1101
+ }
1102
+ };
1103
+ var DeclinePullRequestOperation = class extends MutationOperation {
1104
+ operation = "declinePullRequest";
1105
+ contract = DeclinePullRequestDefinition;
1106
+ empty() {
1107
+ return { id: 0, title: "", state: "" };
1108
+ }
1109
+ /** Decline an open pull request. */
1110
+ async invoke(call, input) {
1111
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId)) return this.defect();
1112
+ const path = pull(input.workspace, input.repository, input.pullRequestId);
1113
+ return this.write(call, {
1114
+ method: "POST",
1115
+ path: path + "/decline",
1116
+ branch: "declined",
1117
+ decode: pullRequest,
1118
+ authStatus: "action",
1119
+ matches: (value) => sameId(value.id, input.pullRequestId) && value.state === "DECLINED",
1120
+ confirmation: { path, statuses: [409], identity: (value) => sameId(value.id, input.pullRequestId) }
1121
+ });
1122
+ }
1123
+ };
1124
+ var CreateRepositoryOperation = class extends MutationOperation {
1125
+ operation = "createRepository";
1126
+ contract = CreateRepositoryDefinition;
1127
+ empty() {
1128
+ return { uuid: "", name: "", full_name: "", is_private: false };
1129
+ }
1130
+ /** Create a private Bitbucket repository under a workspace. */
1131
+ async invoke(call, input) {
1132
+ if (!validRepository(input.workspace, input.repository) || !writtenText(input.name, 255) || typeof input.is_private !== "boolean") return this.defect();
1133
+ const path = repositoryPath(input.workspace, input.repository);
1134
+ const fullName = `${input.workspace}/${input.repository}`;
1135
+ return this.write(call, {
1136
+ method: "POST",
1137
+ path,
1138
+ payload: { scm: "git", name: input.name, is_private: input.is_private },
1139
+ branch: "created",
1140
+ decode: repository,
1141
+ statuses: [200, 201],
1142
+ availabilityDelay: true,
1143
+ authStatus: "repository",
1144
+ matches: (value) => value.full_name === fullName && value.name === input.name && value.is_private === input.is_private
1145
+ });
1146
+ }
1147
+ };
1148
+ var UpdateRepositoryOperation = class extends MutationOperation {
1149
+ operation = "updateRepository";
1150
+ contract = UpdateRepositoryDefinition;
1151
+ empty() {
1152
+ return { uuid: "", name: "", full_name: "", is_private: false };
1153
+ }
1154
+ /** Replace a repository's name and visibility. */
1155
+ async invoke(call, input) {
1156
+ if (!validRepository(input.workspace, input.repository) || !writtenText(input.name, 255) || typeof input.is_private !== "boolean") return this.defect();
1157
+ const path = repositoryPath(input.workspace, input.repository);
1158
+ const fullName = `${input.workspace}/${input.repository}`;
1159
+ return this.write(call, {
1160
+ method: "PUT",
1161
+ path,
1162
+ payload: { name: input.name, is_private: input.is_private },
1163
+ branch: "updated",
1164
+ decode: repository,
1165
+ statuses: [200, 201],
1166
+ availabilityDelay: true,
1167
+ authStatus: "repository",
1168
+ matches: (value) => value.full_name === fullName && value.name === input.name && value.is_private === input.is_private
1169
+ });
1170
+ }
1171
+ };
1172
+ var DeleteRepositoryOperation = class extends MutationOperation {
1173
+ operation = "deleteRepository";
1174
+ contract = DeleteRepositoryDefinition;
1175
+ empty() {
1176
+ return { workspace: "", repository: "" };
1177
+ }
1178
+ /** Delete a repository by workspace and slug. */
1179
+ async invoke(call, input) {
1180
+ if (!validRepository(input.workspace, input.repository)) return this.defect();
1181
+ const path = repositoryPath(input.workspace, input.repository);
1182
+ return this.delete(call, path, { workspace: input.workspace, repository: input.repository }, true);
1183
+ }
1184
+ };
1185
+ var GetRepositoryOperation = class extends QueryOperation {
1186
+ operation = "getRepository";
1187
+ contract = GetRepositoryDefinition;
1188
+ empty() {
1189
+ return { uuid: "", name: "", full_name: "", is_private: false };
1190
+ }
1191
+ /** Read one repository by workspace and repository slug. */
1192
+ async invoke(call, input) {
1193
+ if (!validRepository(input.workspace, input.repository)) return this.defect();
1194
+ const path = repositoryPath(input.workspace, input.repository);
1195
+ return this.read(call, path, "found", repository);
1196
+ }
1197
+ };
1198
+ var GetPullRequestOperation = class extends QueryOperation {
1199
+ operation = "getPullRequest";
1200
+ contract = GetPullRequestDefinition;
1201
+ empty() {
1202
+ return { id: 0, title: "", state: "" };
1203
+ }
1204
+ /** Read one pull request by workspace, repository, and numeric ID. */
1205
+ async invoke(call, input) {
1206
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId)) return this.defect();
1207
+ const path = pull(input.workspace, input.repository, input.pullRequestId);
1208
+ return this.read(call, path, "found", pullRequest);
1209
+ }
1210
+ };
1211
+ var UpdatePullRequestTitleOperation = class extends MutationOperation {
1212
+ operation = "updatePullRequestTitle";
1213
+ contract = UpdatePullRequestTitleDefinition;
1214
+ empty() {
1215
+ return { id: 0, title: "", state: "" };
1216
+ }
1217
+ /** Replace one pull request title with an absolute value. */
1218
+ async invoke(call, input) {
1219
+ if (!validRepository(input.workspace, input.repository) || !validId(input.pullRequestId) || !writtenText(input.title, 512)) return this.defect();
1220
+ const path = pull(input.workspace, input.repository, input.pullRequestId);
1221
+ return this.write(call, {
1222
+ method: "PUT",
1223
+ path,
1224
+ payload: { title: input.title },
1225
+ branch: "updated",
1226
+ decode: pullRequest,
1227
+ availabilityDelay: true,
1228
+ authStatus: "title",
1229
+ matches: (value) => sameId(value.id, input.pullRequestId) && value.title === input.title
1230
+ });
1231
+ }
1232
+ };
1233
+
1234
+ // src/client.ts
1235
+ var defaultBaseURL = "https://api.bitbucket.org/2.0";
1236
+ var defaultMaxResponseBytes = 2097152;
1237
+ var defaultTimeoutMs = 15e3;
1238
+ var BitbucketClient = class {
1239
+ baseURL;
1240
+ /** Maximum webhook and API response size in bytes. */
1241
+ maxResponseBytes;
1242
+ timeoutMs;
1243
+ /** Call-time API credentials shared by operations and webhooks. */
1244
+ credentials;
1245
+ /** Process-local webhook signing secret. */
1246
+ webhookSecret;
1247
+ /** Trigger logger shared by bindings. */
1248
+ triggerLogger;
1249
+ send;
1250
+ /** Clock for webhook receipt and retry delays. */
1251
+ now;
1252
+ /** Validate settings without contacting Bitbucket. */
1253
+ constructor(config, credentials, options = {}) {
1254
+ if (!config || !credentials) throw new TypeError("Bitbucket configuration and credential provider are required");
1255
+ this.baseURL = validateBaseURL(config.baseUrl || defaultBaseURL);
1256
+ this.maxResponseBytes = config.maxResponseBytes || defaultMaxResponseBytes;
1257
+ this.timeoutMs = config.timeoutMs || defaultTimeoutMs;
1258
+ if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0 || !Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0) {
1259
+ throw new TypeError("timeout and maxResponseBytes must be positive");
1260
+ }
1261
+ this.credentials = credentials;
1262
+ this.webhookSecret = options.webhookSecret;
1263
+ this.triggerLogger = options.logger ?? defaultTriggerLogger;
1264
+ this.send = options.send ?? sendProviderRequest;
1265
+ this.now = options.now ?? (() => /* @__PURE__ */ new Date());
1266
+ }
1267
+ /** Bind the repository listing Query. */
1268
+ listRepositories() {
1269
+ return new ListRepositoriesOperation(this);
1270
+ }
1271
+ /** Bind the pull request listing Query. */
1272
+ listPullRequests() {
1273
+ return new ListPullRequestsOperation(this);
1274
+ }
1275
+ /** Bind the listBranches operation. */
1276
+ listBranches() {
1277
+ return new ListBranchesOperation(this);
1278
+ }
1279
+ /** Bind the getBranch operation. */
1280
+ getBranch() {
1281
+ return new GetBranchOperation(this);
1282
+ }
1283
+ /** Bind the createBranch operation. */
1284
+ createBranch() {
1285
+ return new CreateBranchOperation(this);
1286
+ }
1287
+ /** Bind the deleteBranch operation. */
1288
+ deleteBranch() {
1289
+ return new DeleteBranchOperation(this);
1290
+ }
1291
+ /** Bind the listPullRequestComments operation. */
1292
+ listPullRequestComments() {
1293
+ return new ListPullRequestCommentsOperation(this);
1294
+ }
1295
+ /** Bind the getPullRequestComment operation. */
1296
+ getPullRequestComment() {
1297
+ return new GetPullRequestCommentOperation(this);
1298
+ }
1299
+ /** Bind the createPullRequestComment operation. */
1300
+ createPullRequestComment() {
1301
+ return new CreatePullRequestCommentOperation(this);
1302
+ }
1303
+ /** Bind the updatePullRequestComment operation. */
1304
+ updatePullRequestComment() {
1305
+ return new UpdatePullRequestCommentOperation(this);
1306
+ }
1307
+ /** Bind the deletePullRequestComment operation. */
1308
+ deletePullRequestComment() {
1309
+ return new DeletePullRequestCommentOperation(this);
1310
+ }
1311
+ /** Bind the resolvePullRequestComment operation. */
1312
+ resolvePullRequestComment() {
1313
+ return new ResolvePullRequestCommentOperation(this);
1314
+ }
1315
+ /** Bind the unresolvePullRequestComment operation. */
1316
+ unresolvePullRequestComment() {
1317
+ return new UnresolvePullRequestCommentOperation(this);
1318
+ }
1319
+ /** Bind the createPullRequest operation. */
1320
+ createPullRequest() {
1321
+ return new CreatePullRequestOperation(this);
1322
+ }
1323
+ /** Bind the mergePullRequest operation. */
1324
+ mergePullRequest() {
1325
+ return new MergePullRequestOperation(this);
1326
+ }
1327
+ /** Bind the declinePullRequest operation. */
1328
+ declinePullRequest() {
1329
+ return new DeclinePullRequestOperation(this);
1330
+ }
1331
+ /** Bind the createRepository operation. */
1332
+ createRepository() {
1333
+ return new CreateRepositoryOperation(this);
1334
+ }
1335
+ /** Bind the updateRepository operation. */
1336
+ updateRepository() {
1337
+ return new UpdateRepositoryOperation(this);
1338
+ }
1339
+ /** Bind the deleteRepository operation. */
1340
+ deleteRepository() {
1341
+ return new DeleteRepositoryOperation(this);
1342
+ }
1343
+ /** Bind the getRepository operation. */
1344
+ getRepository() {
1345
+ return new GetRepositoryOperation(this);
1346
+ }
1347
+ /** Bind the getPullRequest operation. */
1348
+ getPullRequest() {
1349
+ return new GetPullRequestOperation(this);
1350
+ }
1351
+ /** Bind the updatePullRequestTitle operation. */
1352
+ updatePullRequestTitle() {
1353
+ return new UpdatePullRequestTitleOperation(this);
1354
+ }
1355
+ /** Resolve credentials, send one bounded GET, and classify the exchange. */
1356
+ async read(call, operation, path) {
1357
+ const token = await this.resolveToken(call);
1358
+ if (!token) return this.branch(operation, "defect", "AUTHENTICATION", "Bitbucket credentials are unavailable");
1359
+ let response;
1360
+ try {
1361
+ response = await this.send({
1362
+ url: this.baseURL + path,
1363
+ method: "GET",
1364
+ headers: { Accept: "application/json", Authorization: `Bearer ${token}` },
1365
+ maxResponseBytes: this.maxResponseBytes,
1366
+ timeoutMs: this.timeoutMs,
1367
+ ignoreErrorBodyReadFailure: true,
1368
+ addressPolicy: this.baseURL === defaultBaseURL ? "publicHTTPS" : "privateNetworkHTTP",
1369
+ signal: call.context.cancellationSignal
1370
+ });
1371
+ } catch (error) {
1372
+ if (error instanceof BodyTooLargeError) {
1373
+ if (error.status !== void 0 && error.status !== 200) response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
1374
+ else return this.branch(operation, "invalidResponse", "RESPONSE_TOO_LARGE", "provider response exceeded the configured limit");
1375
+ } else return this.retry(operation, "AVAILABILITY", "provider read failed");
1376
+ }
1377
+ const status = response.status;
1378
+ if (status === 429) return this.retry(operation, "RATE_LIMIT", "provider rate limited the read", this.retryAfter(response));
1379
+ if (status === 408 || status >= 500) return this.retry(operation, "AVAILABILITY", "provider read is temporarily unavailable", this.retryAfter(response));
1380
+ if (status === 404) return this.branch(operation, "notFound", "PROVIDER_REJECTION", "resource was not found");
1381
+ if (status === 401) return this.branch(operation, "providerRejected", "AUTHENTICATION", "provider rejected credentials");
1382
+ if (status === 403) return this.branch(operation, "providerRejected", "AUTHORIZATION", "provider denied access");
1383
+ if (status !== 200) return this.branch(operation, "providerRejected", "PROVIDER_REJECTION", `provider rejected read with HTTP ${status}`);
1384
+ return { response };
1385
+ }
1386
+ /** Resolve OAuth credentials before a Mutation claims a send. */
1387
+ async [prepareWrite](call, method, path, payload) {
1388
+ const token = await this.resolveToken(call);
1389
+ if (!token) return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error: "credential" };
1390
+ return (signal) => this.sendWrite(method, path, token, signal, payload);
1391
+ }
1392
+ async resolveToken(call) {
1393
+ try {
1394
+ const resolved = await this.credentials.resolve(call, call.context.cancellationSignal);
1395
+ if (!(resolved.accessToken instanceof SecretString)) return void 0;
1396
+ const token = resolved.accessToken.reveal();
1397
+ return isHeaderSafeCredential(token) ? token : void 0;
1398
+ } catch {
1399
+ return void 0;
1400
+ }
1401
+ }
1402
+ async sendWrite(method, path, token, signal, payload) {
1403
+ const headers = {
1404
+ Accept: "application/json",
1405
+ Authorization: `Bearer ${token}`,
1406
+ ...payload === void 0 ? {} : { "Content-Type": "application/json" }
1407
+ };
1408
+ let response;
1409
+ try {
1410
+ response = await this.send({
1411
+ url: this.baseURL + path,
1412
+ method,
1413
+ headers,
1414
+ ...payload === void 0 ? {} : { body: Buffer.from(JSON.stringify(payload)) },
1415
+ maxResponseBytes: this.maxResponseBytes,
1416
+ timeoutMs: this.timeoutMs,
1417
+ addressPolicy: this.baseURL === defaultBaseURL ? "publicHTTPS" : "privateNetworkHTTP",
1418
+ signal
1419
+ });
1420
+ } catch (error) {
1421
+ if ((error instanceof BodyTooLargeError || error instanceof ProviderTransportError) && error.status !== void 0) {
1422
+ const unavailable = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
1423
+ return {
1424
+ ...unavailable,
1425
+ retryAfterMs: this.retryAfter(unavailable),
1426
+ error: error instanceof BodyTooLargeError ? "tooLarge" : "read"
1427
+ };
1428
+ }
1429
+ return { status: 0, body: new Uint8Array(), retryAfterMs: 0, error: "transport" };
1430
+ }
1431
+ const retryAfterMs = this.retryAfter(response);
1432
+ if (response.body.length > this.maxResponseBytes)
1433
+ return { status: response.status, body: new Uint8Array(), retryAfterMs, error: "tooLarge" };
1434
+ return { status: response.status, body: response.body, retryAfterMs };
1435
+ }
1436
+ retryAfter(response) {
1437
+ const value = Object.entries(response.headers).find(([name]) => name.toLowerCase() === "retry-after")?.[1];
1438
+ return parseRetryAfter(Array.isArray(value) ? value[0] ?? "" : value ?? "", this.now());
1439
+ }
1440
+ branch(operation, branch, kind, message) {
1441
+ return { branch, failure: { kind, provider: "bitbucket", operation, message } };
1442
+ }
1443
+ retry(operation, kind, message, retryAfterMs = 0) {
1444
+ return { retry: true, failure: { kind, provider: "bitbucket", operation, message }, retryAfterMs };
1445
+ }
1446
+ };
1447
+
1448
+ // src/project.ts
1449
+ import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
1450
+ import { z } from "zod";
1451
+ var projectSettingsSchema = z.strictObject({
1452
+ baseUrl: z.string().optional(),
1453
+ timeout: z.union([z.string(), z.number().int()]).optional(),
1454
+ maxResponseBytes: z.number().int().optional()
1455
+ });
1456
+ function newProjectConnection2(project, connectionName, options = {}) {
1457
+ return newProjectConnection(project, connectionName, (loadedProject, name) => {
1458
+ const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "bitbucket" && entry.connectionName === name);
1459
+ if (!selected) throw new TypeError("Bitbucket project connection is not configured");
1460
+ const settings = projectSettingsSchema.parse(selected.configuration);
1461
+ const timeoutMs = typeof settings.timeout === "number" ? Math.ceil(settings.timeout / 1e6) : settings.timeout !== void 0 ? parseDurationMilliseconds(settings.timeout) : void 0;
1462
+ const config = {
1463
+ ...settings.baseUrl !== void 0 ? { baseUrl: settings.baseUrl } : {},
1464
+ ...timeoutMs !== void 0 ? { timeoutMs } : {},
1465
+ ...settings.maxResponseBytes !== void 0 ? { maxResponseBytes: settings.maxResponseBytes } : {}
1466
+ };
1467
+ const credentials = {
1468
+ async resolve(call, signal) {
1469
+ void call;
1470
+ const fields = await loadedProject.resolveCredential("bitbucket", name, signal);
1471
+ const decoded = z.object({ access_token: z.string().min(1) }).parse(fields);
1472
+ return { accessToken: new SecretString2(decoded.access_token) };
1473
+ }
1474
+ };
1475
+ return new BitbucketClient(config, credentials, options);
1476
+ });
1477
+ }
1478
+ function parseDurationMilliseconds(value) {
1479
+ let remaining = value;
1480
+ let milliseconds = 0;
1481
+ const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
1482
+ while (remaining) {
1483
+ const component = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
1484
+ if (!component) throw new TypeError("Bitbucket timeout must be a positive Go duration");
1485
+ milliseconds += Number(component[1]) * (units[component[2] ?? ""] ?? NaN);
1486
+ remaining = remaining.slice(component[0].length);
1487
+ }
1488
+ if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Bitbucket timeout must resolve to positive whole milliseconds");
1489
+ return milliseconds;
1490
+ }
1491
+
1492
+ // src/trigger.ts
1493
+ import { createHmac, timingSafeEqual } from "crypto";
1494
+ import {
1495
+ mustTriggerBindingDefinition,
1496
+ newTrigger
1497
+ } from "@superdurable/connectors-sdk";
1498
+ import {
1499
+ decodeTriggerConfiguration,
1500
+ newDurableTriggerTarget
1501
+ } from "@superdurable/connectors-sdk/projectconfig";
1502
+ import {
1503
+ WebhookEndpoint,
1504
+ WebhookEndpointRunner,
1505
+ WebhookVerificationUnavailableError
1506
+ } from "@superdurable/connectors-sdk/webhooktrigger";
1507
+ import { z as z2 } from "zod";
1508
+ import { parseTree } from "jsonc-parser";
1509
+ var RepositoryEventKeys = [
1510
+ "repo:push",
1511
+ "repo:fork",
1512
+ "repo:updated",
1513
+ "repo:commit_comment_created",
1514
+ "repo:commit_status_created",
1515
+ "repo:commit_status_updated",
1516
+ "pullrequest:created",
1517
+ "pullrequest:push",
1518
+ "pullrequest:updated",
1519
+ "pullrequest:fulfilled",
1520
+ "pullrequest:rejected",
1521
+ "pullrequest:changes_request_created",
1522
+ "pullrequest:changes_request_removed",
1523
+ "pullrequest:approved",
1524
+ "pullrequest:unapproved",
1525
+ "pullrequest:comment_created",
1526
+ "pullrequest:comment_updated",
1527
+ "pullrequest:comment_deleted",
1528
+ "pullrequest:comment_resolved",
1529
+ "pullrequest:comment_reopened",
1530
+ "issue:created",
1531
+ "issue:updated",
1532
+ "issue:comment_created",
1533
+ "pipeline:span_created",
1534
+ "project:updated",
1535
+ "repo:created",
1536
+ "repo:deleted",
1537
+ "repo:imported",
1538
+ "repo:transfer"
1539
+ ];
1540
+ var RepositoryEventReceivedTriggerConfigurationSchema = z2.strictObject({ eventKeys: z2.array(z2.string()).nullable().optional() }).superRefine((configuration, context) => {
1541
+ const events = configuration.eventKeys ?? [];
1542
+ if (events.some((event) => !RepositoryEventKeys.includes(event)) || new Set(events).size !== events.length)
1543
+ context.addIssue({
1544
+ code: "custom",
1545
+ message: "Bitbucket webhook events must be distinct supported repository events"
1546
+ });
1547
+ });
1548
+ var tokenJSON = JSON;
1549
+ var int64Schema = z2.union([
1550
+ z2.number().int().safe(),
1551
+ z2.custom(
1552
+ (value) => tokenJSON.isRawJSON(value) && /^-?[0-9]{1,19}$/.test(value.rawJSON) && BigInt(value.rawJSON) >= -(1n << 63n) && BigInt(value.rawJSON) < 1n << 63n
1553
+ )
1554
+ ]);
1555
+ var RepositoryPushChangeSchema = z2.object({
1556
+ oldRefType: z2.string().optional(),
1557
+ oldBranch: z2.string().optional(),
1558
+ oldTag: z2.string().optional(),
1559
+ oldTargetHash: z2.string().optional(),
1560
+ newRefType: z2.string().optional(),
1561
+ newBranch: z2.string().optional(),
1562
+ newTag: z2.string().optional(),
1563
+ newTargetHash: z2.string().optional()
1564
+ });
1565
+ var RepositoryEventSchema = z2.object({
1566
+ eventKey: z2.string(),
1567
+ repositoryUuid: z2.string(),
1568
+ repositoryFullName: z2.string(),
1569
+ workspaceSlug: z2.string().optional(),
1570
+ projectKey: z2.string().optional(),
1571
+ issueId: int64Schema.optional(),
1572
+ pullRequestId: int64Schema.optional(),
1573
+ commentId: int64Schema.optional(),
1574
+ pushChanges: z2.array(RepositoryPushChangeSchema).optional()
1575
+ });
1576
+ var repositoryEventCodec = {
1577
+ typeName: "BitbucketRepositoryEvent",
1578
+ wireKind: "json",
1579
+ encode(event) {
1580
+ return { kind: "json", data: JSON.stringify(RepositoryEventSchema.parse(event)) };
1581
+ },
1582
+ decode(value) {
1583
+ if (value.kind !== "json") throw new TypeError("Bitbucket repository event requires JSON");
1584
+ return decodeStoredEvent(value.data);
1585
+ }
1586
+ };
1587
+ function decodeStoredEvent(text) {
1588
+ return RepositoryEventSchema.parse(
1589
+ JSON.parse(
1590
+ text,
1591
+ (name, value, context) => ["issueId", "pullRequestId", "commentId"].includes(name) && typeof value === "number" && context?.source ? integer(context.source) : value
1592
+ )
1593
+ );
1594
+ }
1595
+ var RepositoryEventReceivedTriggerDefinition = {
1596
+ trigger: { connectorId: ConnectorID, triggerName: "repositoryEventReceived" },
1597
+ description: "Receive HMAC-verified repository or workspace webhooks as identifier-only events."
1598
+ };
1599
+ function defineRepositoryEventReceivedTriggerBinding(config) {
1600
+ return mustTriggerBindingDefinition({ definition: RepositoryEventReceivedTriggerDefinition, ...config });
1601
+ }
1602
+ function newRepositoryEventReceivedTrigger(config) {
1603
+ if (config.connectionName !== config.connection.reference.name)
1604
+ throw new TypeError("Bitbucket repositoryEventReceived connection name does not match its connection");
1605
+ const client = bitbucketClientOf(config.connection);
1606
+ const configuration = RepositoryEventReceivedTriggerConfigurationSchema.parse(config.configuration);
1607
+ const source = webhookEndpoint(client, config.connection.reference).newSource(
1608
+ (event) => !configuration.eventKeys?.length || configuration.eventKeys.includes(event.payload.eventKey)
1609
+ );
1610
+ const definition = RepositoryEventReceivedTriggerDefinition;
1611
+ return newTrigger({
1612
+ definition,
1613
+ binding: {
1614
+ connection: config.connection.reference,
1615
+ trigger: definition.trigger,
1616
+ name: config.bindingName
1617
+ },
1618
+ source,
1619
+ target: config.target,
1620
+ logger: client.triggerLogger
1621
+ });
1622
+ }
1623
+ function repositoryEventReceivedWebhookHandler(connection) {
1624
+ return webhookEndpoint(bitbucketClientOf(connection), connection.reference);
1625
+ }
1626
+ var RepositoryEventReceivedEndpointRunner = class {
1627
+ /** @internal Construct through newProjectRepositoryEventReceivedEndpointRunner. */
1628
+ constructor(endpoint, runners) {
1629
+ this.endpoint = endpoint;
1630
+ this.#runner = new WebhookEndpointRunner(endpoint, runners);
1631
+ }
1632
+ endpoint;
1633
+ #runner;
1634
+ /** Verify, record, and acknowledge one delivery, or answer 503 until pending events have replayed. */
1635
+ serveHTTP(request, response) {
1636
+ return this.#runner.serveHTTP(request, response);
1637
+ }
1638
+ /** Replay durable inboxes, then deliver new events until stopped. */
1639
+ run(context) {
1640
+ return this.#runner.run(context);
1641
+ }
1642
+ /** Number of bindings ready to receive. */
1643
+ runningSourceCount() {
1644
+ return this.endpoint.runningSourceCount();
1645
+ }
1646
+ };
1647
+ function newProjectRepositoryEventReceivedEndpointRunner(project, connectionName, routes, options = {}) {
1648
+ if (routes.length === 0) throw new TypeError("Bitbucket repositoryEventReceived routes are required");
1649
+ const connection = newProjectConnection2(project, connectionName, options);
1650
+ const client = bitbucketClientOf(connection);
1651
+ const triggerName = RepositoryEventReceivedTriggerDefinition.trigger.triggerName;
1652
+ const bindingNames = /* @__PURE__ */ new Set();
1653
+ const runners = routes.map((route) => {
1654
+ const bindingName = route.bindingName?.replace(/^\p{White_Space}+|\p{White_Space}+$/gu, "") ?? "";
1655
+ if (!bindingName || !route.target)
1656
+ throw new TypeError("Bitbucket repositoryEventReceived binding name and target are required");
1657
+ if (bindingNames.has(bindingName))
1658
+ throw new TypeError(`Bitbucket repositoryEventReceived binding name "${bindingName}" is duplicated`);
1659
+ bindingNames.add(bindingName);
1660
+ const key = { connectorId: ConnectorID, connectionName, triggerName, bindingName };
1661
+ const configuration = decodeTriggerConfiguration(
1662
+ project.configuration,
1663
+ key,
1664
+ RepositoryEventReceivedTriggerConfigurationSchema
1665
+ );
1666
+ const inbox = project.triggerInbox(key);
1667
+ const durable = newDurableTriggerTarget(inbox, key, route.target, {
1668
+ logger: client.triggerLogger,
1669
+ decodePayload: decodeStoredEvent
1670
+ });
1671
+ const target = {
1672
+ async prepareTrigger(context, event) {
1673
+ if (![event.payload.issueId, event.payload.pullRequestId, event.payload.commentId].some(
1674
+ (value) => tokenJSON.isRawJSON(value)
1675
+ )) {
1676
+ await durable.prepareTrigger(context, event);
1677
+ return;
1678
+ }
1679
+ context.signal.throwIfAborted();
1680
+ await inbox.add({
1681
+ id: event.id,
1682
+ event: Buffer.from(
1683
+ JSON.stringify({ eventId: event.id, occurredAt: event.occurredAt, payload: event.payload })
1684
+ )
1685
+ });
1686
+ },
1687
+ handleTrigger: (context, event) => durable.handleTrigger(context, event),
1688
+ replayTriggerDeliveries: (context) => durable.replayTriggerDeliveries(context)
1689
+ };
1690
+ return newRepositoryEventReceivedTrigger({
1691
+ connection,
1692
+ connectionName,
1693
+ bindingName,
1694
+ configuration,
1695
+ target
1696
+ });
1697
+ });
1698
+ return new RepositoryEventReceivedEndpointRunner(webhookEndpoint(client, connection.reference), runners);
1699
+ }
1700
+ var endpoints = /* @__PURE__ */ new WeakMap();
1701
+ function webhookEndpoint(client, connection) {
1702
+ let byConnection = endpoints.get(client);
1703
+ if (!byConnection) {
1704
+ byConnection = /* @__PURE__ */ new Map();
1705
+ endpoints.set(client, byConnection);
1706
+ }
1707
+ const key = `${connection.provider}\0${connection.name}`;
1708
+ let endpoint = byConnection.get(key);
1709
+ if (!endpoint) {
1710
+ endpoint = new WebhookEndpoint({
1711
+ connectorId: ConnectorID,
1712
+ triggerName: "repositoryEventReceived",
1713
+ connection,
1714
+ credentials: client.credentials,
1715
+ maxBodyBytes: client.maxResponseBytes,
1716
+ verifyRequest: (request) => verifyRequest(request, client),
1717
+ decodeEvent,
1718
+ now: client.now,
1719
+ logger: client.triggerLogger
1720
+ });
1721
+ byConnection.set(key, endpoint);
1722
+ }
1723
+ return endpoint;
1724
+ }
1725
+ function bitbucketClientOf(connection) {
1726
+ if (!(connection?.operations instanceof BitbucketClient))
1727
+ throw new TypeError("Bitbucket Triggers require a BitbucketClient connection");
1728
+ return connection.operations;
1729
+ }
1730
+ function header(request, name) {
1731
+ const value = request.headers[name];
1732
+ return ((Array.isArray(value) ? value[0] : value) ?? "").replace(
1733
+ /^\p{White_Space}+|\p{White_Space}+$/gu,
1734
+ ""
1735
+ );
1736
+ }
1737
+ async function verifyRequest(request, client) {
1738
+ const secret = client.webhookSecret?.reveal();
1739
+ if (!secret) throw new WebhookVerificationUnavailableError();
1740
+ const match = /^sha256=([a-fA-F0-9]{64})$/.exec(header(request, "x-hub-signature"));
1741
+ if (!match || !timingSafeEqual(
1742
+ Buffer.from(match[1], "hex"),
1743
+ createHmac("sha256", secret).update(request.body).digest()
1744
+ ))
1745
+ throw new TypeError("Bitbucket webhook signature is invalid");
1746
+ }
1747
+ function integer(source) {
1748
+ if (!/^-?[0-9]{1,19}$/.test(source)) throw new TypeError("Invalid Bitbucket integer");
1749
+ const value = BigInt(source);
1750
+ if (value < -(1n << 63n) || value >= 1n << 63n) throw new TypeError("Bitbucket ID outside int64");
1751
+ return Number.isSafeInteger(Number(value)) ? Number(value) : tokenJSON.rawJSON(value.toString());
1752
+ }
1753
+ var ref = { type: "string", name: "string", target: { hash: "string" } };
1754
+ var messageFields = {
1755
+ repository: { uuid: "string", full_name: "string" },
1756
+ workspace: { slug: "string" },
1757
+ project: { key: "string" },
1758
+ issue: { id: "int" },
1759
+ pullrequest: { id: "int" },
1760
+ comment: { id: "int" },
1761
+ push: { changes: [{ old: ref, new: ref }] }
1762
+ };
1763
+ function projectFields(node, fields, source, result) {
1764
+ if (node.type === "null") return result;
1765
+ if (node.type !== "object") throw new TypeError("Invalid Bitbucket webhook object");
1766
+ for (const property of node.children ?? []) {
1767
+ const [keyNode, value] = property.children;
1768
+ const key = keyNode.value.toLowerCase().replace(/ſ/g, "s");
1769
+ if (!Object.hasOwn(fields, key)) continue;
1770
+ const kind = fields[key];
1771
+ if (value.type === "null") {
1772
+ if (key === "old" || key === "new" || key === "changes") delete result[key];
1773
+ } else if (kind === "string" && value.type === "string") result[key] = value.value;
1774
+ else if (kind === "int" && value.type === "number")
1775
+ result[key] = integer(source.slice(value.offset, value.offset + value.length));
1776
+ else if (Array.isArray(kind) && value.type === "array")
1777
+ result[key] = (value.children ?? []).map((item) => projectFields(item, kind[0], source, {}));
1778
+ else if (typeof kind === "object" && !Array.isArray(kind))
1779
+ result[key] = projectFields(
1780
+ value,
1781
+ kind,
1782
+ source,
1783
+ result[key] ?? {}
1784
+ );
1785
+ else throw new TypeError("Invalid Bitbucket webhook field");
1786
+ }
1787
+ return result;
1788
+ }
1789
+ function pushChange(change) {
1790
+ const output = {};
1791
+ let named = false;
1792
+ for (const side of ["old", "new"]) {
1793
+ const ref2 = change[side];
1794
+ if (ref2?.type) output[`${side}RefType`] = ref2.type;
1795
+ if (ref2?.target?.hash) output[`${side}TargetHash`] = ref2.target.hash;
1796
+ if (ref2?.name && (ref2.type === "branch" || ref2.type === "tag")) {
1797
+ output[`${side}${ref2.type === "branch" ? "Branch" : "Tag"}`] = ref2.name;
1798
+ named = true;
1799
+ }
1800
+ }
1801
+ return named ? output : void 0;
1802
+ }
1803
+ function positiveId(value) {
1804
+ if (value === void 0 || (typeof value === "number" ? value <= 0 : value.rawJSON.startsWith("-")))
1805
+ throw new TypeError("Missing Bitbucket event ID");
1806
+ return value;
1807
+ }
1808
+ function decodeEvent(request) {
1809
+ const eventKey = header(request, "x-event-key");
1810
+ if (!RepositoryEventKeys.includes(eventKey)) return void 0;
1811
+ const uuid = header(request, "x-request-uuid");
1812
+ if (Buffer.byteLength(uuid) < 8 || Buffer.byteLength(uuid) > 128 || /[ \t\r\n/]/.test(uuid))
1813
+ throw new TypeError("Invalid Bitbucket request UUID");
1814
+ const source = Buffer.from(request.body).toString("utf8");
1815
+ const errors = [];
1816
+ const root = parseTree(source, errors, { disallowComments: true, allowTrailingComma: false });
1817
+ if (errors.length || !root) throw new TypeError("Invalid Bitbucket webhook JSON");
1818
+ const msg = projectFields(root, messageFields, source, {});
1819
+ const payload = {
1820
+ eventKey,
1821
+ repositoryUuid: msg.repository?.uuid ?? "",
1822
+ repositoryFullName: msg.repository?.full_name ?? ""
1823
+ };
1824
+ if (eventKey !== "project:updated" && (!payload.repositoryUuid || !payload.repositoryFullName))
1825
+ throw new TypeError("Missing repository identity");
1826
+ if (msg.project?.key) payload.projectKey = msg.project.key;
1827
+ if (msg.workspace?.slug) payload.workspaceSlug = msg.workspace.slug;
1828
+ if (msg.issue?.id) payload.issueId = msg.issue.id;
1829
+ if (eventKey === "repo:push") {
1830
+ if (!msg.push?.changes?.length) throw new TypeError("Missing push changes");
1831
+ const changes = msg.push.changes.map(pushChange).filter((x) => x !== void 0);
1832
+ if (!changes.length) return void 0;
1833
+ payload.pushChanges = changes;
1834
+ } else if (eventKey.startsWith("pullrequest:")) {
1835
+ payload.pullRequestId = positiveId(msg.pullrequest?.id);
1836
+ if (eventKey.startsWith("pullrequest:comment_")) payload.commentId = positiveId(msg.comment?.id);
1837
+ }
1838
+ return { id: uuid + ":" + eventKey, occurredAt: request.receivedAt, payload };
1839
+ }
1840
+ export {
1841
+ BitbucketClient,
1842
+ BranchPageSchema,
1843
+ BranchRefInputSchema,
1844
+ BranchSchema,
1845
+ BranchTargetSchema,
1846
+ ConfigSchema,
1847
+ Connection,
1848
+ ConnectorID,
1849
+ CreateBranchBranch,
1850
+ CreateBranchBranchCreated,
1851
+ CreateBranchBranchDefect,
1852
+ CreateBranchBranchInvalidResponse,
1853
+ CreateBranchBranchNotFound,
1854
+ CreateBranchBranchProviderRejected,
1855
+ CreateBranchDefinition,
1856
+ CreateBranchInputSchema,
1857
+ CreateBranchMetadata,
1858
+ CreateBranchOperation,
1859
+ CreatePullRequestBranch,
1860
+ CreatePullRequestBranchCreated,
1861
+ CreatePullRequestBranchDefect,
1862
+ CreatePullRequestBranchProviderRejected,
1863
+ CreatePullRequestBranchUncertain,
1864
+ CreatePullRequestCommentBranch,
1865
+ CreatePullRequestCommentBranchCreated,
1866
+ CreatePullRequestCommentBranchDefect,
1867
+ CreatePullRequestCommentBranchProviderRejected,
1868
+ CreatePullRequestCommentBranchUncertain,
1869
+ CreatePullRequestCommentDefinition,
1870
+ CreatePullRequestCommentInputSchema,
1871
+ CreatePullRequestCommentMetadata,
1872
+ CreatePullRequestCommentOperation,
1873
+ CreatePullRequestDefinition,
1874
+ CreatePullRequestInputSchema,
1875
+ CreatePullRequestMetadata,
1876
+ CreatePullRequestOperation,
1877
+ CreateRepositoryBranch,
1878
+ CreateRepositoryBranchCreated,
1879
+ CreateRepositoryBranchDefect,
1880
+ CreateRepositoryBranchInvalidResponse,
1881
+ CreateRepositoryBranchNotFound,
1882
+ CreateRepositoryBranchProviderRejected,
1883
+ CreateRepositoryDefinition,
1884
+ CreateRepositoryInputSchema,
1885
+ CreateRepositoryMetadata,
1886
+ CreateRepositoryOperation,
1887
+ CredentialMaterialError,
1888
+ DeclinePullRequestBranch,
1889
+ DeclinePullRequestBranchDeclined,
1890
+ DeclinePullRequestBranchDefect,
1891
+ DeclinePullRequestBranchInvalidResponse,
1892
+ DeclinePullRequestBranchNotFound,
1893
+ DeclinePullRequestBranchProviderRejected,
1894
+ DeclinePullRequestDefinition,
1895
+ DeclinePullRequestMetadata,
1896
+ DeclinePullRequestOperation,
1897
+ DeleteBranchBranch,
1898
+ DeleteBranchBranchDefect,
1899
+ DeleteBranchBranchDeleted,
1900
+ DeleteBranchBranchNotFound,
1901
+ DeleteBranchBranchProviderRejected,
1902
+ DeleteBranchDefinition,
1903
+ DeleteBranchMetadata,
1904
+ DeleteBranchOperation,
1905
+ DeletePullRequestCommentBranch,
1906
+ DeletePullRequestCommentBranchDefect,
1907
+ DeletePullRequestCommentBranchDeleted,
1908
+ DeletePullRequestCommentBranchNotFound,
1909
+ DeletePullRequestCommentBranchProviderRejected,
1910
+ DeletePullRequestCommentDefinition,
1911
+ DeletePullRequestCommentMetadata,
1912
+ DeletePullRequestCommentOperation,
1913
+ DeleteRepositoryBranch,
1914
+ DeleteRepositoryBranchDefect,
1915
+ DeleteRepositoryBranchDeleted,
1916
+ DeleteRepositoryBranchInvalidResponse,
1917
+ DeleteRepositoryBranchNotFound,
1918
+ DeleteRepositoryBranchProviderRejected,
1919
+ DeleteRepositoryDefinition,
1920
+ DeleteRepositoryInputSchema,
1921
+ DeleteRepositoryMetadata,
1922
+ DeleteRepositoryOperation,
1923
+ DeletedBranchSchema,
1924
+ DeletedPullRequestCommentSchema,
1925
+ DeletedRepositorySchema,
1926
+ GetBranchBranch,
1927
+ GetBranchBranchDefect,
1928
+ GetBranchBranchFound,
1929
+ GetBranchBranchInvalidResponse,
1930
+ GetBranchBranchNotFound,
1931
+ GetBranchBranchProviderRejected,
1932
+ GetBranchDefinition,
1933
+ GetBranchMetadata,
1934
+ GetBranchOperation,
1935
+ GetPullRequestBranch,
1936
+ GetPullRequestBranchDefect,
1937
+ GetPullRequestBranchFound,
1938
+ GetPullRequestBranchInvalidResponse,
1939
+ GetPullRequestBranchNotFound,
1940
+ GetPullRequestBranchProviderRejected,
1941
+ GetPullRequestCommentBranch,
1942
+ GetPullRequestCommentBranchDefect,
1943
+ GetPullRequestCommentBranchFound,
1944
+ GetPullRequestCommentBranchInvalidResponse,
1945
+ GetPullRequestCommentBranchNotFound,
1946
+ GetPullRequestCommentBranchProviderRejected,
1947
+ GetPullRequestCommentDefinition,
1948
+ GetPullRequestCommentMetadata,
1949
+ GetPullRequestCommentOperation,
1950
+ GetPullRequestDefinition,
1951
+ GetPullRequestInputSchema,
1952
+ GetPullRequestMetadata,
1953
+ GetPullRequestOperation,
1954
+ GetRepositoryBranch,
1955
+ GetRepositoryBranchDefect,
1956
+ GetRepositoryBranchFound,
1957
+ GetRepositoryBranchInvalidResponse,
1958
+ GetRepositoryBranchNotFound,
1959
+ GetRepositoryBranchProviderRejected,
1960
+ GetRepositoryDefinition,
1961
+ GetRepositoryInputSchema,
1962
+ GetRepositoryMetadata,
1963
+ GetRepositoryOperation,
1964
+ ListBranchesBranch,
1965
+ ListBranchesBranchDefect,
1966
+ ListBranchesBranchInvalidResponse,
1967
+ ListBranchesBranchListed,
1968
+ ListBranchesBranchNotFound,
1969
+ ListBranchesBranchProviderRejected,
1970
+ ListBranchesDefinition,
1971
+ ListBranchesInputSchema,
1972
+ ListBranchesMetadata,
1973
+ ListBranchesOperation,
1974
+ ListPullRequestCommentsBranch,
1975
+ ListPullRequestCommentsBranchDefect,
1976
+ ListPullRequestCommentsBranchInvalidResponse,
1977
+ ListPullRequestCommentsBranchListed,
1978
+ ListPullRequestCommentsBranchNotFound,
1979
+ ListPullRequestCommentsBranchProviderRejected,
1980
+ ListPullRequestCommentsDefinition,
1981
+ ListPullRequestCommentsMetadata,
1982
+ ListPullRequestCommentsOperation,
1983
+ ListPullRequestsBranch,
1984
+ ListPullRequestsBranchDefect,
1985
+ ListPullRequestsBranchInvalidResponse,
1986
+ ListPullRequestsBranchListed,
1987
+ ListPullRequestsBranchNotFound,
1988
+ ListPullRequestsBranchProviderRejected,
1989
+ ListPullRequestsDefinition,
1990
+ ListPullRequestsInputSchema,
1991
+ ListPullRequestsMetadata,
1992
+ ListPullRequestsOperation,
1993
+ ListRepositoriesBranch,
1994
+ ListRepositoriesBranchDefect,
1995
+ ListRepositoriesBranchInvalidResponse,
1996
+ ListRepositoriesBranchListed,
1997
+ ListRepositoriesBranchNotFound,
1998
+ ListRepositoriesBranchProviderRejected,
1999
+ ListRepositoriesDefinition,
2000
+ ListRepositoriesInputSchema,
2001
+ ListRepositoriesMetadata,
2002
+ ListRepositoriesOperation,
2003
+ MergePullRequestBranch,
2004
+ MergePullRequestBranchDefect,
2005
+ MergePullRequestBranchInvalidResponse,
2006
+ MergePullRequestBranchMerged,
2007
+ MergePullRequestBranchNotFound,
2008
+ MergePullRequestBranchProviderRejected,
2009
+ MergePullRequestDefinition,
2010
+ MergePullRequestMetadata,
2011
+ MergePullRequestOperation,
2012
+ ProviderID,
2013
+ PullRequestActionInputSchema,
2014
+ PullRequestCommentContentSchema,
2015
+ PullRequestCommentIDInputSchema,
2016
+ PullRequestCommentPageSchema,
2017
+ PullRequestCommentResolutionSchema,
2018
+ PullRequestCommentSchema,
2019
+ PullRequestPageSchema,
2020
+ PullRequestSchema,
2021
+ RepositoryEventKeys,
2022
+ RepositoryEventReceivedEndpointRunner,
2023
+ RepositoryEventReceivedTriggerConfigurationSchema,
2024
+ RepositoryEventReceivedTriggerDefinition,
2025
+ RepositoryEventSchema,
2026
+ RepositoryPageSchema,
2027
+ RepositoryPushChangeSchema,
2028
+ RepositorySchema,
2029
+ ResolvePullRequestCommentBranch,
2030
+ ResolvePullRequestCommentBranchDefect,
2031
+ ResolvePullRequestCommentBranchInvalidResponse,
2032
+ ResolvePullRequestCommentBranchNotFound,
2033
+ ResolvePullRequestCommentBranchProviderRejected,
2034
+ ResolvePullRequestCommentBranchResolved,
2035
+ ResolvePullRequestCommentDefinition,
2036
+ ResolvePullRequestCommentMetadata,
2037
+ ResolvePullRequestCommentOperation,
2038
+ UnresolvePullRequestCommentBranch,
2039
+ UnresolvePullRequestCommentBranchDefect,
2040
+ UnresolvePullRequestCommentBranchInvalidResponse,
2041
+ UnresolvePullRequestCommentBranchNotFound,
2042
+ UnresolvePullRequestCommentBranchProviderRejected,
2043
+ UnresolvePullRequestCommentBranchUnresolved,
2044
+ UnresolvePullRequestCommentDefinition,
2045
+ UnresolvePullRequestCommentMetadata,
2046
+ UnresolvePullRequestCommentOperation,
2047
+ UpdatePullRequestCommentBranch,
2048
+ UpdatePullRequestCommentBranchDefect,
2049
+ UpdatePullRequestCommentBranchInvalidResponse,
2050
+ UpdatePullRequestCommentBranchNotFound,
2051
+ UpdatePullRequestCommentBranchProviderRejected,
2052
+ UpdatePullRequestCommentBranchUpdated,
2053
+ UpdatePullRequestCommentDefinition,
2054
+ UpdatePullRequestCommentInputSchema,
2055
+ UpdatePullRequestCommentMetadata,
2056
+ UpdatePullRequestCommentOperation,
2057
+ UpdatePullRequestTitleBranch,
2058
+ UpdatePullRequestTitleBranchDefect,
2059
+ UpdatePullRequestTitleBranchInvalidResponse,
2060
+ UpdatePullRequestTitleBranchNotFound,
2061
+ UpdatePullRequestTitleBranchProviderRejected,
2062
+ UpdatePullRequestTitleBranchUpdated,
2063
+ UpdatePullRequestTitleDefinition,
2064
+ UpdatePullRequestTitleInputSchema,
2065
+ UpdatePullRequestTitleMetadata,
2066
+ UpdatePullRequestTitleOperation,
2067
+ UpdateRepositoryBranch,
2068
+ UpdateRepositoryBranchDefect,
2069
+ UpdateRepositoryBranchInvalidResponse,
2070
+ UpdateRepositoryBranchNotFound,
2071
+ UpdateRepositoryBranchProviderRejected,
2072
+ UpdateRepositoryBranchUpdated,
2073
+ UpdateRepositoryDefinition,
2074
+ UpdateRepositoryInputSchema,
2075
+ UpdateRepositoryMetadata,
2076
+ UpdateRepositoryOperation,
2077
+ decodeCredentials,
2078
+ decodeSignedInteger,
2079
+ defineRepositoryEventReceivedTriggerBinding,
2080
+ exactIntegerJSONCodec,
2081
+ isCredentialMaterialError,
2082
+ newConnection,
2083
+ newConnectionWithOperations,
2084
+ newCreateBranchStep,
2085
+ newCreatePullRequestCommentStep,
2086
+ newCreatePullRequestStep,
2087
+ newCreateRepositoryStep,
2088
+ newDeclinePullRequestStep,
2089
+ newDeleteBranchStep,
2090
+ newDeletePullRequestCommentStep,
2091
+ newDeleteRepositoryStep,
2092
+ newGetBranchStep,
2093
+ newGetPullRequestCommentStep,
2094
+ newGetPullRequestStep,
2095
+ newGetRepositoryStep,
2096
+ newListBranchesStep,
2097
+ newListPullRequestCommentsStep,
2098
+ newListPullRequestsStep,
2099
+ newListRepositoriesStep,
2100
+ newMergePullRequestStep,
2101
+ newProjectConnection2 as newProjectConnection,
2102
+ newProjectRepositoryEventReceivedEndpointRunner,
2103
+ newRepositoryEventReceivedTrigger,
2104
+ newResolvePullRequestCommentStep,
2105
+ newUnresolvePullRequestCommentStep,
2106
+ newUpdatePullRequestCommentStep,
2107
+ newUpdatePullRequestTitleStep,
2108
+ newUpdateRepositoryStep,
2109
+ parseExactIntegerJSON,
2110
+ parseJSONNumberTokens,
2111
+ repositoryEventCodec,
2112
+ repositoryEventReceivedWebhookHandler
2113
+ };