@superdurable/connector-linear 0.0.0-stage → 0.1.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,1261 @@
1
+ import {
2
+ AddCommentBranch,
3
+ AddCommentBranchAdded,
4
+ AddCommentBranchDefect,
5
+ AddCommentBranchNotFound,
6
+ AddCommentBranchProviderRejected,
7
+ AddCommentDefinition,
8
+ AddCommentInputSchema,
9
+ AddCommentMetadata,
10
+ AddCommentOutputSchema,
11
+ ConfigSchema,
12
+ Connection,
13
+ ConnectorID,
14
+ CreateIssueBranch,
15
+ CreateIssueBranchCreated,
16
+ CreateIssueBranchDefect,
17
+ CreateIssueBranchProviderRejected,
18
+ CreateIssueDefinition,
19
+ CreateIssueInputSchema,
20
+ CreateIssueMetadata,
21
+ CreateIssueOutputSchema,
22
+ CycleReferenceSchema,
23
+ FindUserByEmailBranch,
24
+ FindUserByEmailBranchDefect,
25
+ FindUserByEmailBranchFound,
26
+ FindUserByEmailBranchInvalidResponse,
27
+ FindUserByEmailBranchNotFound,
28
+ FindUserByEmailBranchProviderRejected,
29
+ FindUserByEmailDefinition,
30
+ FindUserByEmailInputSchema,
31
+ FindUserByEmailMetadata,
32
+ GetIssueBranch,
33
+ GetIssueBranchDefect,
34
+ GetIssueBranchFound,
35
+ GetIssueBranchInvalidResponse,
36
+ GetIssueBranchNotFound,
37
+ GetIssueBranchProviderRejected,
38
+ GetIssueDefinition,
39
+ GetIssueInputSchema,
40
+ GetIssueMetadata,
41
+ IssueLabelSchema,
42
+ IssueReferenceSchema,
43
+ IssueSchema,
44
+ IssueSearchFilterSchema,
45
+ IssueSummarySchema,
46
+ ListWorkflowStatesBranch,
47
+ ListWorkflowStatesBranchDefect,
48
+ ListWorkflowStatesBranchInvalidResponse,
49
+ ListWorkflowStatesBranchListed,
50
+ ListWorkflowStatesBranchNotFound,
51
+ ListWorkflowStatesBranchProviderRejected,
52
+ ListWorkflowStatesDefinition,
53
+ ListWorkflowStatesInputSchema,
54
+ ListWorkflowStatesMetadata,
55
+ ListWorkflowStatesOutputSchema,
56
+ ProjectReferenceSchema,
57
+ ProviderID,
58
+ SearchIssuesBranch,
59
+ SearchIssuesBranchDefect,
60
+ SearchIssuesBranchInvalidResponse,
61
+ SearchIssuesBranchProviderRejected,
62
+ SearchIssuesBranchSearched,
63
+ SearchIssuesDefinition,
64
+ SearchIssuesInputSchema,
65
+ SearchIssuesMetadata,
66
+ SearchIssuesOutputSchema,
67
+ TeamReferenceSchema,
68
+ UpdateIssueBranch,
69
+ UpdateIssueBranchDefect,
70
+ UpdateIssueBranchInvalidResponse,
71
+ UpdateIssueBranchNotFound,
72
+ UpdateIssueBranchProviderRejected,
73
+ UpdateIssueBranchUpdated,
74
+ UpdateIssueDefinition,
75
+ UpdateIssueInputSchema,
76
+ UpdateIssueMetadata,
77
+ UpdateIssueOutputSchema,
78
+ UserReferenceSchema,
79
+ UserSchema,
80
+ WorkflowStateReferenceSchema,
81
+ WorkflowStateSchema,
82
+ decodeCredentials,
83
+ decodeSharedCredentials,
84
+ newConnection,
85
+ newConnectionWithOperations,
86
+ newProjectConnection,
87
+ newProjectCredentialProvider
88
+ } from "./chunk-E64K42A5.js";
89
+
90
+ // src/generated/steps.ts
91
+ import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
92
+ function newSearchIssuesStep(configuration) {
93
+ const { connection, connectionName, searched, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
94
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
95
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.searchIssues(), connection: connection.reference, branches: [
96
+ goToBranch("searched", searched),
97
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
98
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
99
+ ...defect ? [goToBranch("defect", defect)] : []
100
+ ] });
101
+ }
102
+ function newGetIssueStep(configuration) {
103
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
104
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
105
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.getIssue(), connection: connection.reference, branches: [
106
+ goToBranch("found", found),
107
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
108
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
109
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
110
+ ...defect ? [goToBranch("defect", defect)] : []
111
+ ] });
112
+ }
113
+ function newCreateIssueStep(configuration) {
114
+ const { connection, connectionName, created, providerRejected, defect, ...stepConfiguration } = configuration;
115
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
116
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.createIssue(), connection: connection.reference, branches: [
117
+ goToBranch("created", created),
118
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
119
+ ...defect ? [goToBranch("defect", defect)] : []
120
+ ] });
121
+ }
122
+ function newUpdateIssueStep(configuration) {
123
+ const { connection, connectionName, updated, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
124
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
125
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.updateIssue(), connection: connection.reference, branches: [
126
+ goToBranch("updated", updated),
127
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
128
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
129
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
130
+ ...defect ? [goToBranch("defect", defect)] : []
131
+ ] });
132
+ }
133
+ function newAddCommentStep(configuration) {
134
+ const { connection, connectionName, added, notFound, providerRejected, defect, ...stepConfiguration } = configuration;
135
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
136
+ return newMutationStep({ ...stepConfiguration, operation: connection.operations.addComment(), connection: connection.reference, branches: [
137
+ goToBranch("added", added),
138
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
139
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
140
+ ...defect ? [goToBranch("defect", defect)] : []
141
+ ] });
142
+ }
143
+ function newFindUserByEmailStep(configuration) {
144
+ const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
145
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
146
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.findUserByEmail(), connection: connection.reference, branches: [
147
+ goToBranch("found", found),
148
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
149
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
150
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
151
+ ...defect ? [goToBranch("defect", defect)] : []
152
+ ] });
153
+ }
154
+ function newListWorkflowStatesStep(configuration) {
155
+ const { connection, connectionName, listed, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
156
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
157
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.listWorkflowStates(), connection: connection.reference, branches: [
158
+ goToBranch("listed", listed),
159
+ ...notFound ? [goToBranch("notFound", notFound)] : [],
160
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
161
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
162
+ ...defect ? [goToBranch("defect", defect)] : []
163
+ ] });
164
+ }
165
+
166
+ // src/client.ts
167
+ import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
168
+ import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
169
+ import { ReauthorizationRequiredError, resolveCredential, resolveCredentialAfterRejection } from "@superdurable/connectors-sdk";
170
+ import { RefreshFailedError } from "@superdurable/connectors-sdk/projectconfig";
171
+
172
+ // src/generated/refresh.ts
173
+ var Authorization = {
174
+ "defaultMethod": "personal-api-key",
175
+ "methods": [
176
+ {
177
+ "fields": [
178
+ {
179
+ "name": "api_key",
180
+ "required": true,
181
+ "type": "secretString"
182
+ },
183
+ {
184
+ "name": "webhook_signing_secret",
185
+ "required": false,
186
+ "type": "secretString"
187
+ }
188
+ ],
189
+ "id": "personal-api-key",
190
+ "type": "apiKey"
191
+ },
192
+ {
193
+ "fields": [
194
+ {
195
+ "name": "oauth_client_id",
196
+ "required": true,
197
+ "type": "string"
198
+ },
199
+ {
200
+ "name": "oauth_client_secret",
201
+ "required": true,
202
+ "type": "secretString"
203
+ },
204
+ {
205
+ "name": "access_token",
206
+ "required": true,
207
+ "type": "secretString"
208
+ },
209
+ {
210
+ "name": "refresh_token",
211
+ "required": true,
212
+ "type": "secretString"
213
+ },
214
+ {
215
+ "name": "webhook_signing_secret",
216
+ "required": false,
217
+ "type": "secretString"
218
+ }
219
+ ],
220
+ "id": "linear-oauth",
221
+ "oauth2": {
222
+ "clientIDCredential": "oauth_client_id",
223
+ "clientSecretCredential": "oauth_client_secret",
224
+ "credentialMappings": [
225
+ {
226
+ "credential": "access_token",
227
+ "source": "access_token"
228
+ },
229
+ {
230
+ "credential": "refresh_token",
231
+ "source": "refresh_token"
232
+ }
233
+ ],
234
+ "refresh": {
235
+ "missingExpiry": "reject",
236
+ "scopeSeparators": "whitespaceAndComma",
237
+ "storedMissingExpiry": "refresh",
238
+ "terminalErrorCodes": [
239
+ "invalid_grant",
240
+ "invalid_client",
241
+ "unauthorized_client"
242
+ ]
243
+ },
244
+ "scopes": [
245
+ "write"
246
+ ],
247
+ "tokenEndpoint": "https://api.linear.app/oauth/token"
248
+ },
249
+ "type": "oauth2"
250
+ }
251
+ ],
252
+ "refreshable": true
253
+ };
254
+ var CredentialFields = {
255
+ "access_token": "accessToken",
256
+ "api_key": "apiKey",
257
+ "oauth_client_id": "oauthClientId",
258
+ "oauth_client_secret": "oauthClientSecret",
259
+ "refresh_token": "refreshToken",
260
+ "webhook_signing_secret": "webhookSigningSecret"
261
+ };
262
+
263
+ // src/operations.ts
264
+ import { createHash } from "crypto";
265
+ import { newMutationBranch, newMutationRetry, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
266
+
267
+ // src/documents.ts
268
+ var searchIssuesDocument = "query LinearSearchIssues($filter: IssueFilter, $first: Int!, $after: String, $orderBy: PaginationOrderBy, $includeArchived: Boolean) {\n issues(filter: $filter, first: $first, after: $after, orderBy: $orderBy, includeArchived: $includeArchived) {\n nodes { id identifier title url priority dueDate labelIds createdAt updatedAt archivedAt\n team { id key name } state { id name type } assignee { id } }\n pageInfo { hasNextPage endCursor }\n }\n}";
269
+ var getIssueDocument = "query LinearGetIssue($filter: IssueFilter!) {\n issues(filter: $filter, first: 1, includeArchived: true) { nodes { id identifier number title url priority priorityLabel estimate dueDate labelIds branchName trashed\n description createdAt updatedAt archivedAt startedAt completedAt canceledAt\n team { id key name } state { id name type } assignee { id name displayName } creator { id name displayName }\n labels(first: 50) { nodes { id name color } } project { id name } cycle { id number name } parent { id identifier } } }\n}";
270
+ var readIssueSummaryDocument = "query LinearReadIssueSummary($filter: IssueFilter!) {\n issues(filter: $filter, first: 1, includeArchived: true) { nodes { id identifier title url priority dueDate labelIds createdAt updatedAt archivedAt\n team { id key name } state { id name type } assignee { id } } }\n}";
271
+ var createIssueDocument = "mutation LinearCreateIssue($input: IssueCreateInput!) {\n issueCreate(input: $input) { success issue { id identifier title url priority dueDate labelIds createdAt updatedAt archivedAt\n team { id key name } state { id name type } assignee { id } } }\n}";
272
+ var updateIssueDocument = "mutation LinearUpdateIssue($id: String!, $input: IssueUpdateInput!) {\n issueUpdate(id: $id, input: $input) { success issue { id identifier title url priority dueDate labelIds createdAt updatedAt archivedAt\n team { id key name } state { id name type } assignee { id } } }\n}";
273
+ var addCommentDocument = "mutation LinearAddComment($input: CommentCreateInput!) {\n commentCreate(input: $input) { success comment { id url createdAt } }\n}";
274
+ var readCommentDocument = "query LinearReadComment($filter: CommentFilter!) {\n comments(filter: $filter, first: 1) { nodes { id url createdAt } }\n}";
275
+ var findUserByEmailDocument = "query LinearFindUserByEmail($email: String!, $includeDisabled: Boolean) {\n users(filter: { email: { eqIgnoreCase: $email } }, first: 2, includeDisabled: $includeDisabled) {\n nodes { id name displayName email active admin guest url }\n }\n}";
276
+ var listWorkflowStatesDocument = "query LinearListWorkflowStates($teamId: ID!) {\n workflowStates(filter: { team: { id: { eq: $teamId } } }, first: 100) {\n nodes { id name type position color team { id } }\n }\n}";
277
+
278
+ // src/operations.ts
279
+ var zeroTime = "0001-01-01T00:00:00Z";
280
+ var zeroSummary = { id: "", identifier: "", title: "", url: "", team: { id: "", key: "", name: "" }, state: { id: "", name: "", type: "" }, priority: 0, createdAt: zeroTime, updatedAt: zeroTime };
281
+ var zeroIssue = { ...zeroSummary, number: 0 };
282
+ var zeroUser = { id: "", name: "", displayName: "", email: "", active: false };
283
+ var uuidPattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
284
+ var stateOrder = ["triage", "backlog", "unstarted", "started", "completed", "canceled", "duplicate"];
285
+ var SearchIssuesOperation = class {
286
+ /** Bind the Linear client. */
287
+ constructor(client) {
288
+ this.client = client;
289
+ }
290
+ client;
291
+ /** Return the manifest definition. */
292
+ definition() {
293
+ return SearchIssuesDefinition;
294
+ }
295
+ /** Validate and execute one page request. */
296
+ async invoke(call, input) {
297
+ const empty = { issues: [] };
298
+ let variables;
299
+ try {
300
+ variables = searchVariables(input);
301
+ } catch (error) {
302
+ return queryFailure("searchIssues", "defect", empty, "VALIDATION", String(error), {});
303
+ }
304
+ const opened = await this.client.open(call, "searchIssues");
305
+ if ("failed" in opened) return queryExchange(opened.failed, empty, credentialReceipt(call, false));
306
+ const exchange = await this.client.exchange(call, "searchIssues", opened.credentials, "LinearSearchIssues", searchIssuesDocument, variables);
307
+ const receipt = this.client.receipt(call, exchange);
308
+ if (exchange.disposition !== "succeeded") return queryExchange(exchange, empty, receipt);
309
+ try {
310
+ const issues = object(exchange.data?.issues);
311
+ const nodes = array(issues.nodes);
312
+ if (nodes.length > 100) throw new Error("invalid issue page");
313
+ const output = { issues: nodes.map((node) => decodeSummary(object(node))) };
314
+ const pageInfo = object(issues.pageInfo);
315
+ if (pageInfo.hasNextPage === true) {
316
+ if (typeof pageInfo.endCursor !== "string" || !cursorPattern.test(pageInfo.endCursor)) throw new Error("invalid cursor");
317
+ output.nextCursor = pageInfo.endCursor;
318
+ } else if (typeof pageInfo.hasNextPage !== "boolean") throw new Error("invalid pageInfo");
319
+ return newQueryBranch("searched", output, receipt);
320
+ } catch {
321
+ return queryFailure("searchIssues", "invalidResponse", empty, "PROTOCOL", "Linear returned a malformed issue page", receipt);
322
+ }
323
+ }
324
+ };
325
+ var GetIssueOperation = class {
326
+ /** Bind the Linear client. */
327
+ constructor(client) {
328
+ this.client = client;
329
+ }
330
+ client;
331
+ /** Return the manifest definition. */
332
+ definition() {
333
+ return GetIssueDefinition;
334
+ }
335
+ /** Validate and execute one issue request. */
336
+ async invoke(call, input) {
337
+ let locator;
338
+ try {
339
+ locator = parseLocator(input.issueId);
340
+ } catch (error) {
341
+ return queryFailure("getIssue", "defect", zeroIssue, "VALIDATION", String(error), {});
342
+ }
343
+ const opened = await this.client.open(call, "getIssue");
344
+ if ("failed" in opened) return queryExchange(opened.failed, zeroIssue, credentialReceipt(call, false));
345
+ const exchange = await this.client.exchange(call, "getIssue", opened.credentials, "LinearGetIssue", getIssueDocument, { filter: locator.filter });
346
+ const receipt = this.client.receipt(call, exchange, locator.id);
347
+ if (exchange.disposition !== "succeeded") return queryExchange(exchange, zeroIssue, receipt);
348
+ try {
349
+ const nodes = issueNodes(exchange);
350
+ if (nodes.length === 0) return queryFailure("getIssue", "notFound", zeroIssue, "NOT_FOUND", "Linear has no issue with this ID that the connection can see", receipt);
351
+ const issue = decodeIssue(object(nodes[0]));
352
+ if (!locator.matches(issue)) throw new Error("issue mismatch");
353
+ return newQueryBranch("found", issue, this.client.receipt(call, exchange, issue.id));
354
+ } catch {
355
+ return queryFailure("getIssue", "invalidResponse", zeroIssue, "PROTOCOL", "Linear returned a malformed issue or another issue than requested", receipt);
356
+ }
357
+ }
358
+ };
359
+ var FindUserByEmailOperation = class {
360
+ /** Bind the Linear client. */
361
+ constructor(client) {
362
+ this.client = client;
363
+ }
364
+ client;
365
+ /** Return the manifest definition. */
366
+ definition() {
367
+ return FindUserByEmailDefinition;
368
+ }
369
+ /** Validate and execute the user lookup. */
370
+ async invoke(call, input) {
371
+ let email;
372
+ try {
373
+ email = validateEmail(input.email);
374
+ } catch (error) {
375
+ return queryFailure("findUserByEmail", "defect", zeroUser, "VALIDATION", String(error), {});
376
+ }
377
+ const opened = await this.client.open(call, "findUserByEmail");
378
+ if ("failed" in opened) return queryExchange(opened.failed, zeroUser, credentialReceipt(call, false));
379
+ const exchange = await this.client.exchange(call, "findUserByEmail", opened.credentials, "LinearFindUserByEmail", findUserByEmailDocument, { email, includeDisabled: input.includesDisabled ?? false });
380
+ const receipt = this.client.receipt(call, exchange);
381
+ if (exchange.disposition !== "succeeded") return queryExchange(exchange, zeroUser, receipt);
382
+ try {
383
+ const nodes = array(object(exchange.data?.users).nodes);
384
+ if (nodes.length > 1) throw new Error("multiple users");
385
+ if (nodes.length === 0) return queryFailure("findUserByEmail", "notFound", zeroUser, "NOT_FOUND", "no Linear user that the connection can see has this email", receipt);
386
+ const user = object(nodes[0]);
387
+ if (!uuidPattern.test(string(user.id)) || string(user.email).trim().toLowerCase() !== email.toLowerCase()) throw new Error("user mismatch");
388
+ const output = { id: string(user.id), name: optionalString(user.name), displayName: optionalString(user.displayName), email: string(user.email), active: boolean(user.active), ...user.admin ? { admin: boolean(user.admin) } : {}, ...user.guest ? { guest: boolean(user.guest) } : {}, ...user.url ? { url: string(user.url) } : {} };
389
+ return newQueryBranch("found", output, this.client.receipt(call, exchange, output.id));
390
+ } catch {
391
+ return queryFailure("findUserByEmail", "invalidResponse", zeroUser, "PROTOCOL", "Linear returned a malformed user list", receipt);
392
+ }
393
+ }
394
+ };
395
+ var ListWorkflowStatesOperation = class {
396
+ /** Bind the Linear client. */
397
+ constructor(client) {
398
+ this.client = client;
399
+ }
400
+ client;
401
+ /** Return the manifest definition. */
402
+ definition() {
403
+ return ListWorkflowStatesDefinition;
404
+ }
405
+ /** Validate and execute one team state request. */
406
+ async invoke(call, input) {
407
+ const requested = { teamId: input.teamId, states: [] };
408
+ let teamId;
409
+ try {
410
+ teamId = validateUUID(input.teamId, "teamId", true);
411
+ requested.teamId = teamId;
412
+ } catch (error) {
413
+ return queryFailure("listWorkflowStates", "defect", requested, "VALIDATION", String(error), {});
414
+ }
415
+ const opened = await this.client.open(call, "listWorkflowStates");
416
+ if ("failed" in opened) return queryExchange(opened.failed, requested, credentialReceipt(call, false));
417
+ const exchange = await this.client.exchange(call, "listWorkflowStates", opened.credentials, "LinearListWorkflowStates", listWorkflowStatesDocument, { teamId });
418
+ const receipt = this.client.receipt(call, exchange, teamId);
419
+ if (exchange.disposition !== "succeeded") return queryExchange(exchange, requested, receipt);
420
+ try {
421
+ const nodes = array(object(exchange.data?.workflowStates).nodes);
422
+ if (nodes.length > 100) throw new Error("too many states");
423
+ const states = nodes.map((value) => {
424
+ const node = object(value);
425
+ if (!uuidPattern.test(string(node.id)) || !string(node.name) || !string(node.type) || string(object(node.team).id).toLowerCase() !== teamId) throw new Error("invalid state");
426
+ return { id: string(node.id), name: string(node.name), type: string(node.type), position: number(node.position), ...node.color ? { color: string(node.color) } : {} };
427
+ });
428
+ if (!states.length) return queryFailure("listWorkflowStates", "notFound", requested, "NOT_FOUND", "Linear has no team with this ID that the connection can see", receipt);
429
+ states.sort((left, right) => (stateOrder.indexOf(left.type) < 0 ? 8 : stateOrder.indexOf(left.type)) - (stateOrder.indexOf(right.type) < 0 ? 8 : stateOrder.indexOf(right.type)) || left.position - right.position);
430
+ return newQueryBranch("listed", { teamId, states }, receipt);
431
+ } catch {
432
+ return queryFailure("listWorkflowStates", "invalidResponse", requested, "PROTOCOL", "Linear returned a malformed workflow state list", receipt);
433
+ }
434
+ }
435
+ };
436
+ var CreateIssueOperation = class {
437
+ /** Bind the Linear client. */
438
+ constructor(client) {
439
+ this.client = client;
440
+ }
441
+ client;
442
+ /** Return the manifest definition. */
443
+ definition() {
444
+ return CreateIssueDefinition;
445
+ }
446
+ /** Reuse the Dex Call ID for every attempt. */
447
+ idempotencyKey(callId) {
448
+ return callId;
449
+ }
450
+ /** Send and read back one idempotent create. */
451
+ async invoke(call, input) {
452
+ const requested = { teamId: input.teamId, title: input.title };
453
+ let issueId, variables;
454
+ try {
455
+ ({ issueId, variables } = createVariables(call.idempotencyKey ?? "", input, requested));
456
+ } catch (error) {
457
+ return mutationFailure("createIssue", "defect", requested, "VALIDATION", String(error), {});
458
+ }
459
+ const opened = await this.client.open(call, "createIssue");
460
+ if ("failed" in opened) return writeExchange(opened.failed, requested, credentialReceipt(call, true));
461
+ let exchange = await this.client.exchange(call, "createIssue", opened.credentials, "LinearCreateIssue", createIssueDocument, variables);
462
+ const receipt = this.client.receipt(call, exchange, issueId);
463
+ const decoded = mutationIssue(exchange, "issueCreate");
464
+ if (decoded) return newMutationBranch("created", { ...requested, issueId: decoded.id, issue: decoded }, this.client.receipt(call, exchange, decoded.id));
465
+ exchange = classifyUnusableWrite(exchange, "issueCreate", "createIssue");
466
+ if (readBackWorthy(exchange)) {
467
+ const read = await readIssue(this.client, call, opened.credentials, "createIssue", parseLocator(issueId));
468
+ if (read.summary) return newMutationBranch("created", { ...requested, issueId: read.summary.id, issue: read.summary, replayed: true }, this.client.receipt(call, read.exchange, issueId));
469
+ if (read.exchange.disposition !== "succeeded") return newMutationRetry(read.exchange.failure, read.exchange.retryAfterMs);
470
+ if (exchange.disposition === "invalid") return newMutationRetry(exchange.failure, 0);
471
+ }
472
+ return writeExchange(exchange, requested, receipt);
473
+ }
474
+ };
475
+ var UpdateIssueOperation = class {
476
+ /** Bind the Linear client. */
477
+ constructor(client) {
478
+ this.client = client;
479
+ }
480
+ client;
481
+ /** Return the manifest definition. */
482
+ definition() {
483
+ return UpdateIssueDefinition;
484
+ }
485
+ /** Reuse the Dex Call ID for every attempt. */
486
+ idempotencyKey(callId) {
487
+ return callId;
488
+ }
489
+ /** Send one repeat safe update. */
490
+ async invoke(call, input) {
491
+ const requested = { issueId: input.issueId };
492
+ let locator, variables;
493
+ try {
494
+ ({ locator, variables } = updateVariables(input));
495
+ requested.issueId = locator.id;
496
+ } catch (error) {
497
+ return mutationFailure("updateIssue", "defect", requested, "VALIDATION", String(error), {});
498
+ }
499
+ const opened = await this.client.open(call, "updateIssue");
500
+ if ("failed" in opened) return updateExchange(opened.failed, requested, credentialReceipt(call, true));
501
+ let exchange = await this.client.exchange(call, "updateIssue", opened.credentials, "LinearUpdateIssue", updateIssueDocument, variables);
502
+ const receipt = this.client.receipt(call, exchange, locator.id);
503
+ const decoded = mutationIssue(exchange, "issueUpdate");
504
+ if (decoded) return newMutationBranch("updated", { ...requested, issue: decoded }, this.client.receipt(call, exchange, decoded.id));
505
+ exchange = classifyUnusableWrite(exchange, "issueUpdate", "updateIssue");
506
+ if (exchange.disposition === "rejected" && readBackWorthy(exchange)) {
507
+ const read = await readIssue(this.client, call, opened.credentials, "updateIssue", locator);
508
+ if (read.exchange.disposition === "succeeded" && !read.summary) return mutationFailure("updateIssue", "notFound", requested, "NOT_FOUND", "Linear has no issue with this ID that the connection can see", receipt);
509
+ if (read.exchange.disposition === "retry") return newMutationRetry(read.exchange.failure, read.exchange.retryAfterMs);
510
+ }
511
+ return updateExchange(exchange, requested, receipt);
512
+ }
513
+ };
514
+ var AddCommentOperation = class {
515
+ /** Bind the Linear client. */
516
+ constructor(client) {
517
+ this.client = client;
518
+ }
519
+ client;
520
+ /** Return the manifest definition. */
521
+ definition() {
522
+ return AddCommentDefinition;
523
+ }
524
+ /** Reuse the Dex Call ID for every attempt. */
525
+ idempotencyKey(callId) {
526
+ return callId;
527
+ }
528
+ /** Send and read back one idempotent comment. */
529
+ async invoke(call, input) {
530
+ const requested = { issueId: input.issueId };
531
+ let locator, commentId;
532
+ try {
533
+ locator = parseLocator(input.issueId);
534
+ requested.issueId = locator.id;
535
+ validateMarkdown(input.body, true);
536
+ commentId = entityId(call.idempotencyKey ?? "", "comment");
537
+ } catch (error) {
538
+ return mutationFailure("addComment", "defect", requested, "VALIDATION", String(error), {});
539
+ }
540
+ const opened = await this.client.open(call, "addComment");
541
+ if ("failed" in opened) return writeExchange(opened.failed, requested, credentialReceipt(call, true));
542
+ let exchange = await this.client.exchange(call, "addComment", opened.credentials, "LinearAddComment", addCommentDocument, { input: { id: commentId, issueId: locator.id, body: input.body } });
543
+ const receipt = this.client.receipt(call, exchange, commentId);
544
+ const comment = mutationComment(exchange, commentId);
545
+ if (comment) return newMutationBranch("added", { ...requested, commentId, url: comment.url, createdAt: comment.createdAt }, receipt);
546
+ exchange = classifyUnusableWrite(exchange, "commentCreate", "addComment");
547
+ if (!readBackWorthy(exchange)) return writeExchange(exchange, requested, receipt);
548
+ const read = await this.client.exchange(call, "addComment", opened.credentials, "LinearReadComment", readCommentDocument, { filter: { id: { eq: commentId } } });
549
+ if (read.disposition !== "succeeded") return newMutationRetry(read.failure, read.retryAfterMs);
550
+ try {
551
+ const nodes = array(object(read.data?.comments).nodes);
552
+ if (nodes.length > 1) throw new Error("multiple comments");
553
+ if (nodes.length === 1) {
554
+ const recovered = decodeComment(object(nodes[0]), commentId);
555
+ return newMutationBranch("added", { ...requested, commentId, url: recovered.url, createdAt: recovered.createdAt, replayed: true }, this.client.receipt(call, read, commentId));
556
+ }
557
+ } catch {
558
+ return newMutationRetry(failure("addComment", "PROTOCOL", "Linear returned an unusable comment read-back"));
559
+ }
560
+ if (exchange.disposition !== "rejected") return writeExchange(exchange, requested, receipt);
561
+ const issueRead = await readIssue(this.client, call, opened.credentials, "addComment", locator);
562
+ if (issueRead.exchange.disposition === "retry") return newMutationRetry(issueRead.exchange.failure, issueRead.exchange.retryAfterMs);
563
+ if (issueRead.exchange.disposition === "succeeded" && !issueRead.summary) return mutationFailure("addComment", "notFound", requested, "NOT_FOUND", "Linear has no issue with this ID that the connection can see", receipt);
564
+ return writeExchange(exchange, requested, receipt);
565
+ }
566
+ };
567
+ function failure(operation, kind, message) {
568
+ return { kind, provider: "linear", operation, message };
569
+ }
570
+ function credentialReceipt(call, isMutation) {
571
+ return { callId: call.id, provider: "linear", ...isMutation && call.idempotencyKey ? { idempotencyKey: call.idempotencyKey } : {} };
572
+ }
573
+ function queryFailure(operation, branch, output, kind, message, receipt) {
574
+ return newQueryBranch(branch, output, receipt, failure(operation, kind, message));
575
+ }
576
+ function mutationFailure(operation, branch, output, kind, message, receipt) {
577
+ return newMutationBranch(branch, output, receipt, failure(operation, kind, message));
578
+ }
579
+ function queryExchange(exchange, output, receipt) {
580
+ if (exchange.disposition === "retry") return newQueryRetry(exchange.failure, exchange.retryAfterMs);
581
+ return newQueryBranch(exchange.disposition === "invalid" ? "invalidResponse" : exchange.disposition === "defect" ? "defect" : "providerRejected", output, receipt, exchange.failure);
582
+ }
583
+ function writeExchange(exchange, output, receipt) {
584
+ if (exchange.disposition === "retry" || exchange.disposition === "invalid") return newMutationRetry(exchange.failure, exchange.retryAfterMs);
585
+ return newMutationBranch(exchange.disposition === "defect" ? "defect" : "providerRejected", output, receipt, exchange.failure);
586
+ }
587
+ function updateExchange(exchange, output, receipt) {
588
+ if (exchange.disposition === "retry") return newMutationRetry(exchange.failure, exchange.retryAfterMs);
589
+ return newMutationBranch(exchange.disposition === "invalid" ? "invalidResponse" : exchange.disposition === "defect" ? "defect" : "providerRejected", output, receipt, exchange.failure);
590
+ }
591
+ function readBackWorthy(exchange) {
592
+ return exchange.disposition === "invalid" || exchange.disposition === "retry" && ["AVAILABILITY", "TRANSPORT"].includes(exchange.failure?.kind ?? "") || exchange.disposition === "rejected" && ["VALIDATION", "PROVIDER_REJECTION", "QUOTA_EXHAUSTED"].includes(exchange.failure?.kind ?? "");
593
+ }
594
+ function classifyUnusableWrite(exchange, field, operation) {
595
+ if (exchange.disposition !== "succeeded") return exchange;
596
+ const payload = exchange.data?.[field];
597
+ if (payload && typeof payload === "object" && payload.success === false) return { ...exchange, disposition: "rejected", failure: failure(operation, "PROVIDER_REJECTION", "Linear reported that the write did not succeed") };
598
+ return { ...exchange, disposition: "invalid", failure: failure(operation, "PROTOCOL", "Linear accepted the write but returned an unusable record") };
599
+ }
600
+ function mutationIssue(exchange, field) {
601
+ try {
602
+ const payload = object(exchange.data?.[field]);
603
+ return payload.success === true ? decodeSummary(object(payload.issue)) : void 0;
604
+ } catch {
605
+ return void 0;
606
+ }
607
+ }
608
+ function mutationComment(exchange, commentId) {
609
+ try {
610
+ const payload = object(exchange.data?.commentCreate);
611
+ return payload.success === true ? decodeComment(object(payload.comment), commentId) : void 0;
612
+ } catch {
613
+ return void 0;
614
+ }
615
+ }
616
+ function decodeComment(value, commentId) {
617
+ if (string(value.id).toLowerCase() !== commentId.toLowerCase()) throw new Error("comment mismatch");
618
+ return { url: optionalString(value.url), createdAt: parseTime(string(value.createdAt)) };
619
+ }
620
+ async function readIssue(client, call, credentials, operation, locator) {
621
+ const exchange = await client.exchange(call, operation, credentials, "LinearReadIssueSummary", readIssueSummaryDocument, { filter: locator.filter });
622
+ if (exchange.disposition !== "succeeded") return { exchange };
623
+ try {
624
+ const nodes = issueNodes(exchange);
625
+ if (!nodes.length) return { exchange };
626
+ const summary = decodeSummary(object(nodes[0]));
627
+ if (!locator.matches(summary)) throw new Error("issue mismatch");
628
+ return { exchange, summary };
629
+ } catch {
630
+ return { exchange: { ...exchange, disposition: "invalid", failure: failure(operation, "PROTOCOL", "Linear returned a malformed issue or another issue than requested") } };
631
+ }
632
+ }
633
+ function issueNodes(exchange) {
634
+ const nodes = array(object(exchange.data?.issues).nodes);
635
+ if (nodes.length > 1) throw new Error("multiple issues");
636
+ return nodes;
637
+ }
638
+ function decodeSummary(value) {
639
+ const team = object(value.team), state = object(value.state);
640
+ if (!uuidPattern.test(string(value.id)) || !string(value.identifier).trim() || !uuidPattern.test(string(team.id)) || !uuidPattern.test(string(state.id))) throw new Error("invalid issue");
641
+ const priority = number(value.priority);
642
+ if (priority < 0 || priority > 4) throw new Error("invalid priority");
643
+ const summary = {
644
+ id: string(value.id),
645
+ identifier: string(value.identifier),
646
+ title: optionalString(value.title),
647
+ url: optionalString(value.url),
648
+ team: { id: string(team.id), key: optionalString(team.key), name: optionalString(team.name) },
649
+ state: { id: string(state.id), name: optionalString(state.name), type: optionalString(state.type) },
650
+ priority: Math.trunc(priority),
651
+ createdAt: parseTime(string(value.createdAt)),
652
+ updatedAt: parseTime(string(value.updatedAt))
653
+ };
654
+ if (value.assignee != null) summary.assigneeId = optionalString(object(value.assignee).id);
655
+ if (value.labelIds != null) {
656
+ const labelIds = array(value.labelIds).map(string);
657
+ if (labelIds.length) summary.labelIds = labelIds;
658
+ }
659
+ if (value.dueDate != null) summary.dueDate = string(value.dueDate);
660
+ if (value.archivedAt != null) summary.archivedAt = parseTime(string(value.archivedAt));
661
+ return summary;
662
+ }
663
+ function decodeIssue(value) {
664
+ const summary = decodeSummary(value);
665
+ const wireNumber = number(value.number);
666
+ if (wireNumber < 0 || wireNumber > 2147483647) throw new Error("invalid issue number");
667
+ const issue = { ...summary, number: Math.trunc(wireNumber) };
668
+ if (value.priorityLabel) issue.priorityLabel = string(value.priorityLabel);
669
+ if (value.estimate != null) issue.estimate = number(value.estimate);
670
+ if (value.description != null) {
671
+ const text = string(value.description);
672
+ const characters = Array.from(text);
673
+ issue.description = characters.slice(0, 32768).join("");
674
+ if (characters.length > 32768) issue.descriptionTruncated = true;
675
+ }
676
+ if (value.branchName) issue.branchName = string(value.branchName);
677
+ if (value.trashed === true) issue.trashed = true;
678
+ for (const name of ["assignee", "creator"]) if (value[name] != null) {
679
+ const reference = object(value[name]);
680
+ issue[name] = { id: string(reference.id), ...reference.name ? { name: string(reference.name) } : {}, ...reference.displayName ? { displayName: string(reference.displayName) } : {} };
681
+ }
682
+ if (value.labels != null) {
683
+ const labels = array(object(value.labels).nodes).map((node) => {
684
+ const label = object(node);
685
+ return { id: string(label.id), name: string(label.name), ...label.color ? { color: string(label.color) } : {} };
686
+ });
687
+ if (labels.length) issue.labels = labels;
688
+ }
689
+ if (value.project != null) {
690
+ const project = object(value.project);
691
+ issue.project = { id: string(project.id), name: string(project.name) };
692
+ }
693
+ if (value.cycle != null) {
694
+ const cycle = object(value.cycle);
695
+ issue.cycle = { id: string(cycle.id), number: Math.trunc(number(cycle.number)), ...cycle.name ? { name: string(cycle.name) } : {} };
696
+ }
697
+ if (value.parent != null) {
698
+ const parent = object(value.parent);
699
+ issue.parent = { id: string(parent.id), identifier: string(parent.identifier) };
700
+ }
701
+ for (const name of ["startedAt", "completedAt", "canceledAt"]) if (value[name] != null) issue[name] = parseTime(string(value[name]));
702
+ return issue;
703
+ }
704
+ function parseLocator(value) {
705
+ const trimmed = value.trim();
706
+ if (uuidPattern.test(trimmed)) {
707
+ const id2 = trimmed.toLowerCase();
708
+ return { id: id2, filter: { id: { eq: id2 } }, matches: (summary) => summary.id.toLowerCase() === id2 };
709
+ }
710
+ const match = /^([A-Za-z][A-Za-z0-9]{0,9})-([1-9][0-9]{0,8})$/.exec(trimmed);
711
+ if (!match) throw new Error("issueId must be an issue UUID or an identifier such as ENG-123");
712
+ const teamKey = match[1].toUpperCase(), number2 = Number(match[2]);
713
+ const id = `${teamKey}-${number2}`;
714
+ return { id, filter: { team: { key: { eq: teamKey } }, number: { eq: number2 } }, matches: (summary) => summary.identifier.toLowerCase() === id.toLowerCase() };
715
+ }
716
+ function validateUUID(value, field, required = false) {
717
+ const trimmed = (value ?? "").trim();
718
+ if (!trimmed && !required) return "";
719
+ if (!uuidPattern.test(trimmed)) throw new Error(`${field} must be a Linear UUID`);
720
+ return trimmed.toLowerCase();
721
+ }
722
+ function validateUUIDs(values, field) {
723
+ if ((values?.length ?? 0) > 50) throw new Error(`${field} accepts at most 50 IDs`);
724
+ const ids = (values ?? []).map((value) => validateUUID(value, field, true));
725
+ if (new Set(ids).size !== ids.length) throw new Error(`${field} lists an ID twice`);
726
+ return ids;
727
+ }
728
+ function validateText(value, field) {
729
+ const trimmed = value.trim();
730
+ if (!trimmed || Array.from(trimmed).length > 255 || Array.from(trimmed).some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127)) throw new Error(`${field} must be one line of up to 255 characters`);
731
+ return trimmed;
732
+ }
733
+ function validateMarkdown(value, required) {
734
+ const text = value ?? "";
735
+ if (required && !text.trim() || Array.from(text).length > 65536 || Array.from(text).some((character) => character.charCodeAt(0) < 32 && !["\n", "\r", " "].includes(character) || character.charCodeAt(0) === 127)) throw new Error("body or description is invalid Markdown");
736
+ return text;
737
+ }
738
+ function validateEmail(value) {
739
+ const email = value.trim(), index = email.indexOf("@");
740
+ if (!email || Buffer.byteLength(email) > 320 || index < 1 || !email.slice(index + 1).includes(".") || email.slice(index + 1).includes("@") || Array.from(email).some((character) => character.charCodeAt(0) <= 32 || character.charCodeAt(0) === 127)) throw new Error("email must be one address such as alice@example.com");
741
+ return email;
742
+ }
743
+ function validateDate(value) {
744
+ const date = (value ?? "").trim();
745
+ if (!date) return "";
746
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(date);
747
+ if (!match || Number(match[2]) < 1 || Number(match[2]) > 12 || Number(match[3]) < 1 || Number(match[3]) > daysInMonth(Number(match[1]), Number(match[2]))) throw new Error("dueDate must be a calendar date");
748
+ return date;
749
+ }
750
+ function parseTime(value) {
751
+ const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|[+-]\d{2}:\d{2})$/.exec(value);
752
+ if (!match || Number(match[4]) > 23 || Number(match[5]) > 59 || Number(match[6]) > 59 || Number(match[2]) < 1 || Number(match[2]) > 12 || Number(match[3]) < 1 || Number(match[3]) > daysInMonth(Number(match[1]), Number(match[2]))) throw new Error("invalid Linear time");
753
+ const offset = match[8] === "Z" ? 0 : (match[8].startsWith("+") ? 1 : -1) * (Number(match[8].slice(1, 3)) * 60 + Number(match[8].slice(4, 6)));
754
+ if (match[8] !== "Z" && Number(match[8].slice(4, 6)) > 59) throw new Error("invalid Linear time");
755
+ const parsed = /* @__PURE__ */ new Date(0);
756
+ parsed.setUTCFullYear(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
757
+ parsed.setUTCHours(Number(match[4]), Number(match[5]) - offset, Number(match[6]), 0);
758
+ if (!Number.isFinite(parsed.getTime())) throw new Error("invalid Linear time");
759
+ const fractional = (match[7] ?? "").slice(0, 9).padEnd(9, "0").replace(/0+$/, "");
760
+ return parsed.toISOString().replace(".000Z", fractional ? `.${fractional}Z` : "Z");
761
+ }
762
+ function daysInMonth(year, month) {
763
+ if (month === 2) return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28;
764
+ return [4, 6, 9, 11].includes(month) ? 30 : 31;
765
+ }
766
+ function validatePriority(value) {
767
+ if (value !== void 0 && (!Number.isInteger(value) || value < 0 || value > 4)) throw new Error("priority must be 0 through 4");
768
+ }
769
+ function entityId(key, entity) {
770
+ if (!key.trim()) throw new Error("Linear write has no idempotency key");
771
+ const digest = createHash("sha256").update(`dex-linear-client-id/v1\0${entity}\0${key}`).digest();
772
+ digest[6] = digest[6] & 15 | 64;
773
+ digest[8] = digest[8] & 63 | 128;
774
+ const hex = digest.subarray(0, 16).toString("hex");
775
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
776
+ }
777
+ function object(value) {
778
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("expected object");
779
+ return value;
780
+ }
781
+ function array(value) {
782
+ if (value == null) return [];
783
+ if (!Array.isArray(value)) throw new Error("expected array");
784
+ return value;
785
+ }
786
+ function string(value) {
787
+ if (value == null) return "";
788
+ if (typeof value !== "string") throw new Error("expected string");
789
+ return value;
790
+ }
791
+ function optionalString(value) {
792
+ return value == null ? "" : string(value);
793
+ }
794
+ function number(value) {
795
+ if (value == null) return 0;
796
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new Error("expected number");
797
+ return value;
798
+ }
799
+ function boolean(value) {
800
+ if (value == null) return false;
801
+ if (typeof value !== "boolean") throw new Error("expected boolean");
802
+ return value;
803
+ }
804
+ var cursorPattern = /^[A-Za-z0-9_\-.~=+/:]{1,512}$/;
805
+ function searchVariables(input) {
806
+ const pageSize = input.pageSize || 50;
807
+ if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100) throw new Error("pageSize must be between 1 and 100");
808
+ const order = input.order || "createdAt";
809
+ if (order !== "createdAt" && order !== "updatedAt") throw new Error("order must be createdAt or updatedAt");
810
+ const filter = searchFilter(input.filter);
811
+ const variables = { first: pageSize, orderBy: order, includeArchived: input.includesArchived ?? false };
812
+ if (Object.keys(filter).length) variables.filter = filter;
813
+ const cursor = input.cursor?.trim() ?? "";
814
+ if (cursor) {
815
+ if (!cursorPattern.test(cursor)) throw new Error("cursor is invalid");
816
+ variables.after = cursor;
817
+ }
818
+ return variables;
819
+ }
820
+ function searchFilter(filter) {
821
+ const clauses = {};
822
+ const teamId = validateUUID(filter.teamId, "filter.teamId"), teamKey = filter.teamKey?.trim() ?? "";
823
+ if (teamId && teamKey) throw new Error("set at most one of filter.teamId and filter.teamKey");
824
+ if (teamId) clauses.team = { id: { eq: teamId } };
825
+ else if (teamKey) {
826
+ if (!/^[A-Za-z][A-Za-z0-9]{0,9}$/.test(teamKey)) throw new Error("invalid team key");
827
+ clauses.team = { key: { eq: teamKey.toUpperCase() } };
828
+ }
829
+ const state = {};
830
+ if ((filter.stateTypes?.length ?? 0) > 20) throw new Error("too many state types");
831
+ if (filter.stateTypes?.length) {
832
+ if (filter.stateTypes.some((value) => !stateOrder.includes(value))) throw new Error("unknown state type");
833
+ state.type = { in: filter.stateTypes };
834
+ }
835
+ const stateIds = validateUUIDs(filter.stateIds, "filter.stateIds");
836
+ if (stateIds.length) state.id = { in: stateIds };
837
+ if (Object.keys(state).length) clauses.state = state;
838
+ const assigneeId = validateUUID(filter.assigneeId, "filter.assigneeId");
839
+ if (filter.unassigned && (assigneeId || filter.assigneeEmail)) throw new Error("unassigned excludes assignee");
840
+ if (filter.unassigned) clauses.assignee = { null: true };
841
+ else {
842
+ const assignee = {};
843
+ if (assigneeId) assignee.id = { eq: assigneeId };
844
+ if (filter.assigneeEmail) assignee.email = { eqIgnoreCase: validateEmail(filter.assigneeEmail) };
845
+ if (Object.keys(assignee).length) clauses.assignee = assignee;
846
+ }
847
+ const labels = {};
848
+ const labelIds = validateUUIDs(filter.labelIds, "filter.labelIds");
849
+ if (labelIds.length) labels.id = { in: labelIds };
850
+ if ((filter.labelNames?.length ?? 0) > 20) throw new Error("too many label names");
851
+ if (filter.labelNames?.length) labels.name = { in: filter.labelNames.map((name) => validateText(name, "filter.labelNames")) };
852
+ if (Object.keys(labels).length) clauses.labels = { some: labels };
853
+ const projectId = validateUUID(filter.projectId, "filter.projectId");
854
+ if (projectId) clauses.project = { id: { eq: projectId } };
855
+ const title = {};
856
+ if (filter.title) title.eq = validateText(filter.title, "filter.title");
857
+ if (filter.titleContains) title.containsIgnoreCase = validateText(filter.titleContains, "filter.titleContains");
858
+ if (Object.keys(title).length) clauses.title = title;
859
+ if (filter.updatedAfter) clauses.updatedAt = { gt: formatFilterTime(filter.updatedAfter) };
860
+ if (filter.createdAfter) clauses.createdAt = { gt: formatFilterTime(filter.createdAfter) };
861
+ return clauses;
862
+ }
863
+ function formatFilterTime(value) {
864
+ return new Date(parseTime(value)).toISOString();
865
+ }
866
+ function createVariables(key, input, requested) {
867
+ const teamId = validateUUID(input.teamId, "teamId", true), title = validateText(input.title, "title");
868
+ requested.teamId = teamId;
869
+ requested.title = title;
870
+ const description = validateMarkdown(input.description, false);
871
+ validatePriority(input.priority);
872
+ const dueDate = validateDate(input.dueDate);
873
+ const labelIds = validateUUIDs(input.labelIds, "labelIds");
874
+ const issueId = entityId(key, "issue");
875
+ const fields = { id: issueId, teamId, title };
876
+ for (const name of ["stateId", "assigneeId", "projectId"]) {
877
+ const value = validateUUID(input[name], name);
878
+ if (value) fields[name] = value;
879
+ }
880
+ if (input.parentId) fields.parentId = parseLocator(input.parentId).id;
881
+ if (description) fields.description = description;
882
+ if (labelIds.length) fields.labelIds = labelIds;
883
+ if (input.priority !== void 0) fields.priority = input.priority;
884
+ if (dueDate) fields.dueDate = dueDate;
885
+ return { issueId, variables: { input: fields } };
886
+ }
887
+ function updateVariables(input) {
888
+ const locator = parseLocator(input.issueId);
889
+ const fields = {};
890
+ const stateId = validateUUID(input.stateId, "stateId"), assigneeId = validateUUID(input.assigneeId, "assigneeId");
891
+ if (stateId) fields.stateId = stateId;
892
+ if (assigneeId && input.unassigns) throw new Error("set at most one of assigneeId and unassigns");
893
+ if (assigneeId) fields.assigneeId = assigneeId;
894
+ else if (input.unassigns) fields.assigneeId = null;
895
+ const added = validateUUIDs(input.addedLabelIds, "addedLabelIds"), removed = validateUUIDs(input.removedLabelIds, "removedLabelIds");
896
+ if (added.some((id) => removed.includes(id))) throw new Error("a label cannot be both added and removed");
897
+ if (added.length) fields.addedLabelIds = added;
898
+ if (removed.length) fields.removedLabelIds = removed;
899
+ validatePriority(input.priority);
900
+ if (input.priority !== void 0) fields.priority = input.priority;
901
+ const dueDate = validateDate(input.dueDate);
902
+ if (dueDate && input.clearsDueDate) throw new Error("set at most one of dueDate and clearsDueDate");
903
+ if (dueDate) fields.dueDate = dueDate;
904
+ else if (input.clearsDueDate) fields.dueDate = null;
905
+ if (input.title) fields.title = validateText(input.title, "title");
906
+ if (!Object.keys(fields).length) throw new Error("updateIssue needs at least one change");
907
+ return { locator, variables: { id: locator.id, input: fields } };
908
+ }
909
+
910
+ // src/client.ts
911
+ var defaultEndpoint = "https://api.linear.app/graphql";
912
+ var requestIdPattern = /^[A-Za-z0-9._:-]{1,128}$/;
913
+ var knownTypes = /* @__PURE__ */ new Set(["feature not accessible", "invalid input", "ratelimited", "network error", "authentication error", "forbidden", "bootstrap error", "unknown", "internal error", "other", "user error", "graphql error", "lock timeout", "usage limit exceeded"]);
914
+ var LinearClient = class {
915
+ /** Validate configuration and bind a renewable credential source. */
916
+ constructor(config, credentials, options = {}) {
917
+ this.credentials = credentials;
918
+ if (!credentials) throw new TypeError("Linear credential provider is required");
919
+ this.endpoint = validateBaseURL(options.endpoint ?? defaultEndpoint);
920
+ this.maxResponseBytes = config.maxResponseBytes ?? 4194304;
921
+ if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes < 1) throw new TypeError("Linear maxResponseBytes must be positive");
922
+ if (config.webhookMaxBodyBytes !== void 0 && (!Number.isSafeInteger(config.webhookMaxBodyBytes) || config.webhookMaxBodyBytes < 1)) throw new TypeError("Linear webhookMaxBodyBytes must be positive");
923
+ if (config.webhookSignatureToleranceMs !== void 0 && (!Number.isSafeInteger(config.webhookSignatureToleranceMs) || config.webhookSignatureToleranceMs < 1e3)) throw new TypeError("Linear webhookSignatureTolerance must be at least one second");
924
+ this.send = options.send ?? sendProviderRequest;
925
+ this.now = options.now ?? (() => /* @__PURE__ */ new Date());
926
+ }
927
+ credentials;
928
+ endpoint;
929
+ maxResponseBytes;
930
+ send;
931
+ now;
932
+ refreshDriver = new ManifestCredentialRefreshDriver({ providerName: "Linear", auth: Authorization, credentialFields: CredentialFields });
933
+ /** Bind the search query. */
934
+ searchIssues() {
935
+ return new SearchIssuesOperation(this);
936
+ }
937
+ /** Bind the issue query. */
938
+ getIssue() {
939
+ return new GetIssueOperation(this);
940
+ }
941
+ /** Bind the create mutation. */
942
+ createIssue() {
943
+ return new CreateIssueOperation(this);
944
+ }
945
+ /** Bind the update mutation. */
946
+ updateIssue() {
947
+ return new UpdateIssueOperation(this);
948
+ }
949
+ /** Bind the comment mutation. */
950
+ addComment() {
951
+ return new AddCommentOperation(this);
952
+ }
953
+ /** Bind the user query. */
954
+ findUserByEmail() {
955
+ return new FindUserByEmailOperation(this);
956
+ }
957
+ /** Bind the workflow state query. */
958
+ listWorkflowStates() {
959
+ return new ListWorkflowStatesOperation(this);
960
+ }
961
+ /** Return a secret-free correlation receipt. */
962
+ receipt(call, exchange, objectId = "") {
963
+ return {
964
+ callId: call.id,
965
+ provider: "linear",
966
+ observedAt: this.now().toISOString(),
967
+ ...call.idempotencyKey ? { idempotencyKey: call.idempotencyKey } : {},
968
+ ...objectId ? { providerObjectId: objectId } : {},
969
+ ...exchange.requestId ? { providerRequestId: exchange.requestId } : {}
970
+ };
971
+ }
972
+ /** Resolve credentials once for an operation and classify host failures. */
973
+ async open(call, operation) {
974
+ try {
975
+ const credentials = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
976
+ const token = credentials.authMethodId === "linear-oauth" ? credentials.accessToken?.reveal() : credentials.apiKey?.reveal();
977
+ if (!["linear-oauth", "personal-api-key"].includes(credentials.authMethodId ?? "") || !token || !isHeaderSafeCredential(token)) throw new TypeError("unusable Linear credential");
978
+ return { credentials };
979
+ } catch (error) {
980
+ if (error instanceof ReauthorizationRequiredError) return { failed: this.failed(operation, "rejected", "AUTHENTICATION", "Linear authorization must be renewed in Dex Web Connections") };
981
+ if (error instanceof RefreshFailedError) return { failed: this.failed(operation, "retry", "AVAILABILITY", "Linear OAuth token refresh is temporarily unavailable") };
982
+ return { failed: this.failed(operation, "defect", "AUTHENTICATION", "Linear connection credentials are unavailable or unusable") };
983
+ }
984
+ }
985
+ /** Send one named GraphQL request, then refresh and resend a rejected OAuth token once. */
986
+ async exchange(call, operation, credentials, operationName, query, variables) {
987
+ let result = await this.sendOnce(call, operation, credentials, operationName, query, variables);
988
+ if (result.status !== 401 || credentials.authMethodId !== "linear-oauth" || !("resolveAfterRejection" in this.credentials)) return result;
989
+ try {
990
+ const replacement = await resolveCredentialAfterRejection(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
991
+ result = await this.sendOnce(call, operation, replacement, operationName, query, variables);
992
+ } catch {
993
+ }
994
+ return result;
995
+ }
996
+ async sendOnce(call, operation, credentials, operationName, query, variables) {
997
+ const token = credentials.authMethodId === "linear-oauth" ? credentials.accessToken?.reveal() : credentials.apiKey?.reveal();
998
+ if (!token || !isHeaderSafeCredential(token)) return this.failed(operation, "defect", "AUTHENTICATION", "Linear connection credentials are unavailable or unusable");
999
+ const authorization = credentials.authMethodId === "linear-oauth" ? `Bearer ${token}` : token;
1000
+ const request = {
1001
+ url: this.endpoint,
1002
+ method: "POST",
1003
+ headers: { Accept: "application/json", "Content-Type": "application/json", Authorization: authorization },
1004
+ body: Buffer.from(JSON.stringify({ operationName, query, variables })),
1005
+ maxResponseBytes: this.maxResponseBytes,
1006
+ maxErrorResponseBytes: this.maxResponseBytes,
1007
+ timeoutMs: 12e3,
1008
+ addressPolicy: this.endpoint === defaultEndpoint ? "publicHTTPS" : "unrestricted",
1009
+ signal: call.context.cancellationSignal
1010
+ };
1011
+ let response;
1012
+ try {
1013
+ response = await this.send(request);
1014
+ } catch (error) {
1015
+ if (error instanceof BodyTooLargeError) {
1016
+ const status = error.status ?? 0;
1017
+ if (status >= 200 && status < 300) return this.failed(operation, "invalid", "RESPONSE_TOO_LARGE", "Linear response exceeds the configured maxResponseBytes limit", status, header(error.headers ?? {}, "x-request-id"));
1018
+ return classify(operation, status, {}, parseRetryAfter(header(error.headers ?? {}, "retry-after"), this.now()), header(error.headers ?? {}, "x-request-id"));
1019
+ }
1020
+ return this.failed(operation, "retry", "TRANSPORT", "Linear request failed before a response arrived");
1021
+ }
1022
+ const requestId = header(response.headers, "x-request-id");
1023
+ const safeRequestId = requestIdPattern.test(requestId.trim()) ? requestId.trim() : "";
1024
+ const body = Buffer.from(response.body).toString("utf8");
1025
+ if (body.includes(token)) return this.failed(operation, "invalid", "PROTOCOL", "Linear response reflected the connection credential", response.status, safeRequestId);
1026
+ let envelope;
1027
+ try {
1028
+ envelope = JSON.parse(body);
1029
+ } catch {
1030
+ if (response.status >= 200 && response.status < 300) return this.failed(operation, "invalid", "PROTOCOL", "Linear returned a response that is not a GraphQL JSON object", response.status, safeRequestId);
1031
+ return classify(operation, response.status, {}, parseRetryAfter(header(response.headers, "retry-after"), this.now()), safeRequestId);
1032
+ }
1033
+ if (!envelope || typeof envelope !== "object" || Array.isArray(envelope)) {
1034
+ if (response.status >= 200 && response.status < 300) return this.failed(operation, "invalid", "PROTOCOL", "Linear returned a response that is not a GraphQL JSON object", response.status, safeRequestId);
1035
+ return classify(operation, response.status, {}, 0, safeRequestId);
1036
+ }
1037
+ const fields = envelope;
1038
+ if (fields.errors != null && !Array.isArray(fields.errors)) {
1039
+ if (response.status >= 200 && response.status < 300) return this.failed(operation, "invalid", "PROTOCOL", "Linear returned a response that is not a GraphQL JSON object", response.status, safeRequestId);
1040
+ return classify(operation, response.status, {}, parseRetryAfter(header(response.headers, "retry-after"), this.now()), safeRequestId);
1041
+ }
1042
+ const errors = Array.isArray(fields.errors) ? fields.errors : [];
1043
+ const data = fields.data && typeof fields.data === "object" && !Array.isArray(fields.data) ? fields.data : void 0;
1044
+ if (errors.length || response.status < 200 || response.status >= 300) {
1045
+ const first = errors[0] && typeof errors[0] === "object" ? errors[0] : {};
1046
+ const extensions = first.extensions && typeof first.extensions === "object" ? first.extensions : {};
1047
+ const code = typeof extensions.code === "string" && /^[A-Za-z0-9_.:-]{1,64}$/.test(extensions.code) && !extensions.code.includes(token) ? extensions.code : "";
1048
+ const errorType = typeof extensions.type === "string" && knownTypes.has(extensions.type) ? extensions.type : "";
1049
+ return { ...classify(operation, response.status, { code, errorType }, parseRetryAfter(header(response.headers, "retry-after"), this.now()), safeRequestId), ...data ? { data } : {} };
1050
+ }
1051
+ if (!data) return this.failed(operation, "invalid", "PROTOCOL", "Linear returned neither data nor errors", response.status, safeRequestId);
1052
+ return { disposition: "succeeded", data, status: response.status, requestId: safeRequestId, retryAfterMs: 0 };
1053
+ }
1054
+ failed(operation, disposition, kind, message, status = 0, requestId = "") {
1055
+ return { disposition, status, requestId, retryAfterMs: 0, failure: { kind, provider: "linear", operation, message } };
1056
+ }
1057
+ };
1058
+ function header(headers, name) {
1059
+ const value = headers[name] ?? headers[name.toLowerCase()] ?? headers[name.replace(/(^|-)([a-z])/g, (_, prefix, letter) => prefix + letter.toUpperCase())];
1060
+ return Array.isArray(value) ? value[0] ?? "" : value ?? "";
1061
+ }
1062
+ function classify(operation, status, summary, retryAfterMs, requestId) {
1063
+ const code = summary.code ?? "", errorType = summary.errorType ?? "";
1064
+ let disposition = "rejected";
1065
+ let kind = "PROVIDER_REJECTION";
1066
+ let verb = "rejected the request";
1067
+ if (code === "RATELIMITED" || errorType === "ratelimited") {
1068
+ disposition = "retry";
1069
+ kind = "RATE_LIMIT";
1070
+ verb = "rate limited the request";
1071
+ } else if (["AUTHENTICATION_ERROR", "UNAUTHENTICATED"].includes(code) || errorType === "authentication error") {
1072
+ kind = "AUTHENTICATION";
1073
+ verb = "rejected the credential";
1074
+ } else if (code === "FORBIDDEN" || ["forbidden", "feature not accessible"].includes(errorType)) {
1075
+ kind = "AUTHORIZATION";
1076
+ verb = "denied permission";
1077
+ } else if (errorType === "usage limit exceeded") {
1078
+ kind = "QUOTA_EXHAUSTED";
1079
+ verb = "reported a workspace usage limit";
1080
+ } else if (["GRAPHQL_PARSE_FAILED", "GRAPHQL_VALIDATION_FAILED", "BAD_REQUEST", "OPERATION_RESOLUTION_FAILURE"].includes(code) || errorType === "graphql error") {
1081
+ disposition = "defect";
1082
+ kind = "PROTOCOL";
1083
+ verb = "rejected the connector's GraphQL request";
1084
+ } else if (["INTERNAL_SERVER_ERROR", "INTERNAL_ERROR", "LOCK_TIMEOUT"].includes(code) || ["internal error", "lock timeout", "network error", "bootstrap error"].includes(errorType)) {
1085
+ disposition = "retry";
1086
+ kind = "AVAILABILITY";
1087
+ verb = "could not complete the request";
1088
+ } else if (["INPUT_ERROR", "BAD_USER_INPUT", "INVALID_INPUT"].includes(code) || ["invalid input", "user error"].includes(errorType)) {
1089
+ kind = "VALIDATION";
1090
+ verb = "rejected the input";
1091
+ } else if (status === 429) {
1092
+ disposition = "retry";
1093
+ kind = "RATE_LIMIT";
1094
+ verb = "rate limited the request";
1095
+ } else if (status === 408 || status >= 500) {
1096
+ disposition = "retry";
1097
+ kind = "AVAILABILITY";
1098
+ verb = "could not complete the request";
1099
+ } else if (status === 401) {
1100
+ kind = "AUTHENTICATION";
1101
+ verb = "rejected the credential";
1102
+ } else if (status === 403) {
1103
+ kind = "AUTHORIZATION";
1104
+ verb = "denied permission";
1105
+ } else if (status === 400 && !code && !errorType) {
1106
+ disposition = "defect";
1107
+ kind = "PROTOCOL";
1108
+ verb = "rejected the connector's GraphQL request";
1109
+ } else if (status >= 300 && status < 400) {
1110
+ kind = "PROTOCOL";
1111
+ verb = "redirected the request";
1112
+ }
1113
+ const suffix = [code, errorType].filter(Boolean).join("; ");
1114
+ const failure2 = { kind, provider: "linear", operation, message: `Linear ${verb} (HTTP ${status})${suffix ? ` [${suffix}]` : ""}` };
1115
+ return { disposition, status, requestId, retryAfterMs, failure: failure2 };
1116
+ }
1117
+
1118
+ // src/project.ts
1119
+ function encodeCredentials(credentials) {
1120
+ return credentials.authMethodId === "linear-oauth" ? {
1121
+ auth_method: "linear-oauth",
1122
+ oauth_client_id: credentials.oauthClientId ?? "",
1123
+ oauth_client_secret: credentials.oauthClientSecret?.reveal() ?? "",
1124
+ access_token: credentials.accessToken?.reveal() ?? "",
1125
+ refresh_token: credentials.refreshToken?.reveal() ?? "",
1126
+ webhook_signing_secret: credentials.webhookSigningSecret?.reveal() ?? ""
1127
+ } : { auth_method: "personal-api-key", api_key: credentials.apiKey?.reveal() ?? "", webhook_signing_secret: credentials.webhookSigningSecret?.reveal() ?? "" };
1128
+ }
1129
+ function newProjectConnection2(project, connectionName, options = {}) {
1130
+ return newProjectConnection(project, connectionName, (loadedProject, name) => {
1131
+ const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "linear" && entry.connectionName === name);
1132
+ if (!selected) throw new TypeError("Linear project connection is not configured");
1133
+ const raw = selected.configuration;
1134
+ const config = ConfigSchema.parse({
1135
+ ...raw,
1136
+ ...raw.webhookSignatureTolerance !== void 0 ? { webhookSignatureToleranceMs: parseDurationMilliseconds(raw.webhookSignatureTolerance) } : {}
1137
+ });
1138
+ const settings = {
1139
+ ...config.maxResponseBytes !== void 0 ? { maxResponseBytes: config.maxResponseBytes } : {},
1140
+ ...config.webhookMaxBodyBytes !== void 0 ? { webhookMaxBodyBytes: config.webhookMaxBodyBytes } : {},
1141
+ ...config.webhookSignatureToleranceMs !== void 0 ? { webhookSignatureToleranceMs: config.webhookSignatureToleranceMs } : {}
1142
+ };
1143
+ return new LinearClient(settings, newProjectCredentialProvider(loadedProject, name, decodeCredentials, encodeCredentials, decodeSharedCredentials), options);
1144
+ });
1145
+ }
1146
+ function parseDurationMilliseconds(value) {
1147
+ if (typeof value === "number") return Math.ceil(value / 1e6);
1148
+ if (typeof value !== "string") throw new TypeError("Linear duration must be a Go duration");
1149
+ let remaining = value, milliseconds = 0;
1150
+ const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
1151
+ while (remaining) {
1152
+ const component = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
1153
+ if (!component) throw new TypeError("Linear duration must be a Go duration");
1154
+ milliseconds += Number(component[1]) * units[component[2]];
1155
+ remaining = remaining.slice(component[0].length);
1156
+ }
1157
+ if (!Number.isSafeInteger(milliseconds) || milliseconds < 1) throw new TypeError("Linear duration must resolve to positive whole milliseconds");
1158
+ return milliseconds;
1159
+ }
1160
+ export {
1161
+ AddCommentBranch,
1162
+ AddCommentBranchAdded,
1163
+ AddCommentBranchDefect,
1164
+ AddCommentBranchNotFound,
1165
+ AddCommentBranchProviderRejected,
1166
+ AddCommentDefinition,
1167
+ AddCommentInputSchema,
1168
+ AddCommentMetadata,
1169
+ AddCommentOperation,
1170
+ AddCommentOutputSchema,
1171
+ ConfigSchema,
1172
+ Connection,
1173
+ ConnectorID,
1174
+ CreateIssueBranch,
1175
+ CreateIssueBranchCreated,
1176
+ CreateIssueBranchDefect,
1177
+ CreateIssueBranchProviderRejected,
1178
+ CreateIssueDefinition,
1179
+ CreateIssueInputSchema,
1180
+ CreateIssueMetadata,
1181
+ CreateIssueOperation,
1182
+ CreateIssueOutputSchema,
1183
+ CycleReferenceSchema,
1184
+ FindUserByEmailBranch,
1185
+ FindUserByEmailBranchDefect,
1186
+ FindUserByEmailBranchFound,
1187
+ FindUserByEmailBranchInvalidResponse,
1188
+ FindUserByEmailBranchNotFound,
1189
+ FindUserByEmailBranchProviderRejected,
1190
+ FindUserByEmailDefinition,
1191
+ FindUserByEmailInputSchema,
1192
+ FindUserByEmailMetadata,
1193
+ FindUserByEmailOperation,
1194
+ GetIssueBranch,
1195
+ GetIssueBranchDefect,
1196
+ GetIssueBranchFound,
1197
+ GetIssueBranchInvalidResponse,
1198
+ GetIssueBranchNotFound,
1199
+ GetIssueBranchProviderRejected,
1200
+ GetIssueDefinition,
1201
+ GetIssueInputSchema,
1202
+ GetIssueMetadata,
1203
+ GetIssueOperation,
1204
+ IssueLabelSchema,
1205
+ IssueReferenceSchema,
1206
+ IssueSchema,
1207
+ IssueSearchFilterSchema,
1208
+ IssueSummarySchema,
1209
+ LinearClient,
1210
+ ListWorkflowStatesBranch,
1211
+ ListWorkflowStatesBranchDefect,
1212
+ ListWorkflowStatesBranchInvalidResponse,
1213
+ ListWorkflowStatesBranchListed,
1214
+ ListWorkflowStatesBranchNotFound,
1215
+ ListWorkflowStatesBranchProviderRejected,
1216
+ ListWorkflowStatesDefinition,
1217
+ ListWorkflowStatesInputSchema,
1218
+ ListWorkflowStatesMetadata,
1219
+ ListWorkflowStatesOperation,
1220
+ ListWorkflowStatesOutputSchema,
1221
+ ProjectReferenceSchema,
1222
+ ProviderID,
1223
+ SearchIssuesBranch,
1224
+ SearchIssuesBranchDefect,
1225
+ SearchIssuesBranchInvalidResponse,
1226
+ SearchIssuesBranchProviderRejected,
1227
+ SearchIssuesBranchSearched,
1228
+ SearchIssuesDefinition,
1229
+ SearchIssuesInputSchema,
1230
+ SearchIssuesMetadata,
1231
+ SearchIssuesOperation,
1232
+ SearchIssuesOutputSchema,
1233
+ TeamReferenceSchema,
1234
+ UpdateIssueBranch,
1235
+ UpdateIssueBranchDefect,
1236
+ UpdateIssueBranchInvalidResponse,
1237
+ UpdateIssueBranchNotFound,
1238
+ UpdateIssueBranchProviderRejected,
1239
+ UpdateIssueBranchUpdated,
1240
+ UpdateIssueDefinition,
1241
+ UpdateIssueInputSchema,
1242
+ UpdateIssueMetadata,
1243
+ UpdateIssueOperation,
1244
+ UpdateIssueOutputSchema,
1245
+ UserReferenceSchema,
1246
+ UserSchema,
1247
+ WorkflowStateReferenceSchema,
1248
+ WorkflowStateSchema,
1249
+ decodeCredentials,
1250
+ decodeSharedCredentials,
1251
+ newAddCommentStep,
1252
+ newConnection,
1253
+ newConnectionWithOperations,
1254
+ newCreateIssueStep,
1255
+ newFindUserByEmailStep,
1256
+ newGetIssueStep,
1257
+ newListWorkflowStatesStep,
1258
+ newProjectConnection2 as newProjectConnection,
1259
+ newSearchIssuesStep,
1260
+ newUpdateIssueStep
1261
+ };