@superdurable/connector-sentry 0.1.0 → 0.1.1
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/README.md +2 -2
- package/dex-connector.json +73 -5
- package/dist/{chunk-I2K5L2H5.js → chunk-DLF3YZQL.js} +30 -1
- package/dist/{connection-Cvf7BnFm.d.ts → connection-e93NjxbJ.d.ts} +9 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +30 -26
- package/dist/mock.d.ts +1 -1
- package/dist/mock.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Sentry TypeScript connector
|
|
2
2
|
|
|
3
|
-
Install `@superdurable/connector-sentry` to use Sentry issue operations in Dex TypeScript Flows. The package implements `listIssues`, `getIssue`, and `updateIssueStatus`; the manifest's Go connector version remains independent of this package's `v0.1.
|
|
3
|
+
Install `@superdurable/connector-sentry` to use Sentry issue operations in Dex TypeScript Flows. The package implements `listIssues`, `getIssue`, and `updateIssueStatus`; the manifest's Go connector version remains independent of this package's `v0.1.1` release.
|
|
4
4
|
|
|
5
5
|
`SentryClient` accepts generated `Config` and a live `CredentialProvider<Credentials>`. It resolves the secret at invocation time and sends it only in the Authorization header. `newProjectConnection` reads a named connection and its `api_key` from the Dex project. Project `timeout` accepts a positive Go duration string such as `45s` or a nanosecond count and controls each provider request timeout. `newListIssuesStep`, `newGetIssueStep`, and `newUpdateIssueStatusStep` are the generated operation factories. `./mock` exports scripted operations.
|
|
6
6
|
|
|
7
|
-
The runnable [issue-review example](examples/issue-review/README.md) lists one organization issue page through a Dex Worker. The issue search query is provider syntax; the example sends no credentials in Flow input. The status mutation uses an absolute PUT and a stable Call ID key. Local invalid input or unavailable credentials select `defect`; 408, 429, 5xx, and transport failures retry. Definite provider rejection, missing detail resources, and malformed successful responses select their manifest branches.
|
|
7
|
+
The runnable [issue-review example](examples/issue-review/README.md) lists one organization issue page through a Dex Worker. The issue search query is provider syntax; the example sends no credentials in Flow input. The status mutation uses an absolute PUT and a stable Call ID key. Local invalid input or unavailable credentials select `defect`; 408, 429, 5xx, and transport failures retry. Definite provider rejection, missing detail resources, and malformed successful Query responses select their manifest branches. `updateIssueStatus` is declared `repeatOnUnknown: safe`: only HTTP 400, 401, 403, 404, 411, 413, 414, 415, or 422 rejects it, and every other unknown answer, including 409 and a malformed response, retries.
|
|
8
8
|
|
|
9
9
|
`npm run check` runs the package suite, typecheck, and lint. `npm run test:integration` requires a local `dexcli dev` address in `DEX_FLOW_SERVICE_ADDRESS` and exercises the example against a local HTTP fixture through a real Dex Worker. Go-recorded scenarios in `conformance/connectors/sentry/scenarios.json` are replayed by the TypeScript suite. Real Sentry authorization, API responses, and Dex Web Connections fields remain unverified.
|
package/dex-connector.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"connectorId": "sentry",
|
|
3
|
-
"releaseTag": "connectors/sentry/go/v0.2.
|
|
3
|
+
"releaseTag": "connectors/sentry/go/v0.2.1",
|
|
4
4
|
"package": {
|
|
5
5
|
"ecosystem": "npm",
|
|
6
6
|
"name": "@superdurable/connector-sentry",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.1"
|
|
8
8
|
},
|
|
9
9
|
"factories": [
|
|
10
10
|
{
|
|
11
11
|
"name": "newListIssuesStep",
|
|
12
12
|
"kind": "query",
|
|
13
13
|
"operationId": "listIssues",
|
|
14
|
+
"inputType": "ListIssuesInput",
|
|
15
|
+
"description": "ListIssues through the Sentry public JSON API.",
|
|
14
16
|
"fields": {
|
|
15
17
|
"stepType": "stepType",
|
|
16
18
|
"annotations": "annotations",
|
|
@@ -38,12 +40,33 @@
|
|
|
38
40
|
"field": "defect",
|
|
39
41
|
"optional": true
|
|
40
42
|
}
|
|
41
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"inputSchema": {
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"description": "ListIssuesInput selects one organization's current issues.",
|
|
47
|
+
"properties": {
|
|
48
|
+
"organization": {
|
|
49
|
+
"description": "Organization is the Sentry organization slug.",
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"query": {
|
|
53
|
+
"description": "Query is the provider search expression.",
|
|
54
|
+
"type": "string"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": [
|
|
58
|
+
"organization",
|
|
59
|
+
"query"
|
|
60
|
+
],
|
|
61
|
+
"type": "object"
|
|
62
|
+
}
|
|
42
63
|
},
|
|
43
64
|
{
|
|
44
65
|
"name": "newGetIssueStep",
|
|
45
66
|
"kind": "query",
|
|
46
67
|
"operationId": "getIssue",
|
|
68
|
+
"inputType": "GetIssueInput",
|
|
69
|
+
"description": "GetIssue through the Sentry public JSON API.",
|
|
47
70
|
"fields": {
|
|
48
71
|
"stepType": "stepType",
|
|
49
72
|
"annotations": "annotations",
|
|
@@ -76,12 +99,33 @@
|
|
|
76
99
|
"field": "defect",
|
|
77
100
|
"optional": true
|
|
78
101
|
}
|
|
79
|
-
]
|
|
102
|
+
],
|
|
103
|
+
"inputSchema": {
|
|
104
|
+
"additionalProperties": false,
|
|
105
|
+
"description": "GetIssueInput identifies one issue within an organization.",
|
|
106
|
+
"properties": {
|
|
107
|
+
"id": {
|
|
108
|
+
"description": "ID is the provider's stable resource identifier.",
|
|
109
|
+
"type": "string"
|
|
110
|
+
},
|
|
111
|
+
"organization": {
|
|
112
|
+
"description": "Organization is the Sentry organization slug.",
|
|
113
|
+
"type": "string"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"required": [
|
|
117
|
+
"id",
|
|
118
|
+
"organization"
|
|
119
|
+
],
|
|
120
|
+
"type": "object"
|
|
121
|
+
}
|
|
80
122
|
},
|
|
81
123
|
{
|
|
82
124
|
"name": "newUpdateIssueStatusStep",
|
|
83
125
|
"kind": "mutation",
|
|
84
126
|
"operationId": "updateIssueStatus",
|
|
127
|
+
"inputType": "UpdateIssueStatusInput",
|
|
128
|
+
"description": "UpdateIssueStatus through the Sentry public JSON API.",
|
|
85
129
|
"fields": {
|
|
86
130
|
"stepType": "stepType",
|
|
87
131
|
"annotations": "annotations",
|
|
@@ -114,7 +158,31 @@
|
|
|
114
158
|
"field": "defect",
|
|
115
159
|
"optional": true
|
|
116
160
|
}
|
|
117
|
-
]
|
|
161
|
+
],
|
|
162
|
+
"inputSchema": {
|
|
163
|
+
"additionalProperties": false,
|
|
164
|
+
"description": "UpdateIssueStatusInput sets one issue's absolute status.",
|
|
165
|
+
"properties": {
|
|
166
|
+
"id": {
|
|
167
|
+
"description": "ID is the provider's stable resource identifier.",
|
|
168
|
+
"type": "string"
|
|
169
|
+
},
|
|
170
|
+
"organization": {
|
|
171
|
+
"description": "Organization is the Sentry organization slug.",
|
|
172
|
+
"type": "string"
|
|
173
|
+
},
|
|
174
|
+
"status": {
|
|
175
|
+
"description": "Status is the provider's current status.",
|
|
176
|
+
"type": "string"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"required": [
|
|
180
|
+
"id",
|
|
181
|
+
"organization",
|
|
182
|
+
"status"
|
|
183
|
+
],
|
|
184
|
+
"type": "object"
|
|
185
|
+
}
|
|
118
186
|
}
|
|
119
187
|
]
|
|
120
188
|
}
|
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
// src/generated/models.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
3
4
|
var ConfigSchema = z.object({
|
|
4
5
|
"baseUrl": z.string().optional(),
|
|
5
6
|
"timeoutMs": z.number().int().optional(),
|
|
6
7
|
"maxResponseBytes": z.number().int().optional()
|
|
7
8
|
});
|
|
9
|
+
var CredentialMaterialError = class extends TypeError {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "CredentialMaterialError";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
16
|
+
"project credential decoding failed",
|
|
17
|
+
"shared project credential decoding failed",
|
|
18
|
+
"project credential decoding failed: this connector version does not support shared credentials"
|
|
19
|
+
]);
|
|
20
|
+
function isCredentialMaterialError(error) {
|
|
21
|
+
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
22
|
+
}
|
|
23
|
+
function decodeCredentials(value) {
|
|
24
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
25
|
+
const fields = value;
|
|
26
|
+
const allowed = /* @__PURE__ */ new Set(["api_key"]);
|
|
27
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
28
|
+
if (fields["api_key"] != null && !(typeof fields["api_key"] === "string")) throw new CredentialMaterialError("credential api_key has an invalid type");
|
|
29
|
+
const credentials = {};
|
|
30
|
+
if (!fields["api_key"]) throw new CredentialMaterialError("credential api_key is required");
|
|
31
|
+
credentials.apiKey = new SecretString(fields["api_key"] ?? "");
|
|
32
|
+
return credentials;
|
|
33
|
+
}
|
|
8
34
|
var ListIssuesInputSchema = z.strictObject({
|
|
9
35
|
"organization": z.string(),
|
|
10
36
|
"query": z.string()
|
|
@@ -94,7 +120,7 @@ var UpdateIssueStatusDefinition = {
|
|
|
94
120
|
{ id: "updated", description: "Sentry returned the requested result." },
|
|
95
121
|
{ id: "notFound", description: "The requested resource does not exist.", optional: true },
|
|
96
122
|
{ id: "providerRejected", description: "The provider definitively rejected the request.", optional: true },
|
|
97
|
-
{ id: "invalidResponse", description: "
|
|
123
|
+
{ id: "invalidResponse", description: "Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because repeating the absolute status update is safe.", optional: true },
|
|
98
124
|
{ id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
|
|
99
125
|
],
|
|
100
126
|
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
@@ -133,6 +159,9 @@ function newProjectConnection(project, connectionName, createClient) {
|
|
|
133
159
|
|
|
134
160
|
export {
|
|
135
161
|
ConfigSchema,
|
|
162
|
+
CredentialMaterialError,
|
|
163
|
+
isCredentialMaterialError,
|
|
164
|
+
decodeCredentials,
|
|
136
165
|
ListIssuesInputSchema,
|
|
137
166
|
IssueSchema,
|
|
138
167
|
IssuePageSchema,
|
|
@@ -21,6 +21,14 @@ interface Credentials {
|
|
|
21
21
|
/** Secret Sentry token. Start at https://sentry.io/settings/account/api/auth-tokens/, follow User Settings > Auth Tokens > Create New Token. Create an auth token with event:read for reads and event:write for status updates. Copy the opaque secret; blank prevents requests. It is sent only in the Authorization header. */
|
|
22
22
|
apiKey: SecretString;
|
|
23
23
|
}
|
|
24
|
+
/** Stored credential material that fails the connector credential checks, so no retry can succeed. */
|
|
25
|
+
declare class CredentialMaterialError extends TypeError {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
|
|
29
|
+
declare function isCredentialMaterialError(error: unknown): boolean;
|
|
30
|
+
/** Decode private credential fields for the connector. */
|
|
31
|
+
declare function decodeCredentials(value: unknown): Credentials;
|
|
24
32
|
/** Host-owned source of private connector credentials. */
|
|
25
33
|
type CredentialSource = CredentialProvider<Credentials>;
|
|
26
34
|
/** ListIssuesInput selects one organization's current issues. */
|
|
@@ -118,4 +126,4 @@ declare function newConnection(client: Operations, reference: ConnectionRef): Co
|
|
|
118
126
|
/** Bind scripted operations to a named connection. */
|
|
119
127
|
declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
|
|
120
128
|
|
|
121
|
-
export { Connection as C, type GetIssueInput as G, type Issue as I, type ListIssuesInput as L, type Operations as O, type UpdateIssueStatusInput as U, type IssuePage as a, type Config as b, type Credentials as c, ConfigSchema as d, type CredentialSource as
|
|
129
|
+
export { Connection as C, type GetIssueInput as G, type Issue as I, type ListIssuesInput as L, type Operations as O, type UpdateIssueStatusInput as U, type IssuePage as a, type Config as b, type Credentials as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, GetIssueInputSchema as g, IssuePageSchema as h, IssueSchema as i, ListIssuesInputSchema as j, UpdateIssueStatusInputSchema as k, decodeCredentials as l, isCredentialMaterialError as m, newConnection as n, newConnectionWithOperations as o };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GetIssueInput, I as Issue, C as Connection, L as ListIssuesInput, a as IssuePage, U as UpdateIssueStatusInput, b as Config, c as Credentials, O as Operations } from './connection-
|
|
2
|
-
export { d as ConfigSchema, e as
|
|
1
|
+
import { G as GetIssueInput, I as Issue, C as Connection, L as ListIssuesInput, a as IssuePage, U as UpdateIssueStatusInput, b as Config, c as Credentials, O as Operations } from './connection-e93NjxbJ.js';
|
|
2
|
+
export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as GetIssueInputSchema, h as IssuePageSchema, i as IssueSchema, j as ListIssuesInputSchema, k as UpdateIssueStatusInputSchema, l as decodeCredentials, m as isCredentialMaterialError, n as newConnection, o as newConnectionWithOperations } from './connection-e93NjxbJ.js';
|
|
3
3
|
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
4
|
import { QueryDefinition, MutationDefinition, QueryStepConfig, Query, QueryResult, MutationStepConfig, Mutation, MutationResult, QueryStep, MutationStep, Call, QueryAttempt, MutationAttempt, CredentialProvider, Failure } from '@superdurable/connectors-sdk';
|
|
5
5
|
import { StepTarget } from '@superdurable/dex';
|
|
@@ -74,7 +74,7 @@ declare const UpdateIssueStatusBranchUpdated: "updated";
|
|
|
74
74
|
declare const UpdateIssueStatusBranchNotFound: "notFound";
|
|
75
75
|
/** The provider definitively rejected the request. */
|
|
76
76
|
declare const UpdateIssueStatusBranchProviderRejected: "providerRejected";
|
|
77
|
-
/**
|
|
77
|
+
/** Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because repeating the absolute status update is safe. */
|
|
78
78
|
declare const UpdateIssueStatusBranchInvalidResponse: "invalidResponse";
|
|
79
79
|
/** Local input or connection credentials are invalid. */
|
|
80
80
|
declare const UpdateIssueStatusBranchDefect: "defect";
|
|
@@ -141,7 +141,7 @@ interface UpdateIssueStatusStepConfig<StepInput, OperationInput = UpdateIssueSta
|
|
|
141
141
|
notFound?: StepTarget<MutationResult<OperationOutput>>;
|
|
142
142
|
/** The provider definitively rejected the request. */
|
|
143
143
|
providerRejected?: StepTarget<MutationResult<OperationOutput>>;
|
|
144
|
-
/**
|
|
144
|
+
/** Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because repeating the absolute status update is safe. */
|
|
145
145
|
invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
|
|
146
146
|
/** Local input or connection credentials are invalid. */
|
|
147
147
|
defect?: StepTarget<MutationResult<OperationOutput>>;
|
|
@@ -207,6 +207,8 @@ declare class SentryClient {
|
|
|
207
207
|
/** Bind the absolute status mutation. */ updateIssueStatus(): UpdateIssueStatusOperation;
|
|
208
208
|
/** Send one request and classify Go-compatible provider failures. */
|
|
209
209
|
exchange(call: Call, operation: string, method: 'GET' | 'PUT', path: string, body?: Uint8Array, hasNotFoundBranch?: boolean): Promise<SentryExchange>;
|
|
210
|
+
/** Select providerRejected for a definite refusal; the safe PUT retries every other answer, including 409. */
|
|
211
|
+
private rejectedOrUnknown;
|
|
210
212
|
private failure;
|
|
211
213
|
}
|
|
212
214
|
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
ConfigSchema,
|
|
3
3
|
Connection,
|
|
4
4
|
ConnectorID,
|
|
5
|
+
CredentialMaterialError,
|
|
5
6
|
GetIssueBranch,
|
|
6
7
|
GetIssueBranchDefect,
|
|
7
8
|
GetIssueBranchFound,
|
|
@@ -31,10 +32,12 @@ import {
|
|
|
31
32
|
UpdateIssueStatusDefinition,
|
|
32
33
|
UpdateIssueStatusInputSchema,
|
|
33
34
|
UpdateIssueStatusMetadata,
|
|
35
|
+
decodeCredentials,
|
|
36
|
+
isCredentialMaterialError,
|
|
34
37
|
newConnection,
|
|
35
38
|
newConnectionWithOperations,
|
|
36
39
|
newProjectConnection
|
|
37
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-DLF3YZQL.js";
|
|
38
41
|
|
|
39
42
|
// src/generated/steps.ts
|
|
40
43
|
import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
|
|
@@ -77,7 +80,8 @@ import { z } from "zod";
|
|
|
77
80
|
|
|
78
81
|
// src/client.ts
|
|
79
82
|
import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
80
|
-
import { SecretString } from "@superdurable/connectors-sdk";
|
|
83
|
+
import { ReauthorizationRequiredError, SecretString } from "@superdurable/connectors-sdk";
|
|
84
|
+
import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
|
|
81
85
|
|
|
82
86
|
// src/operations.ts
|
|
83
87
|
import { newMutationBranch, newMutationRetry, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
|
|
@@ -154,7 +158,7 @@ var UpdateIssueStatusOperation = class {
|
|
|
154
158
|
try {
|
|
155
159
|
return newMutationBranch("updated", decodeIssue(JSON.parse(Buffer.from(exchange.body).toString("utf8"))), {});
|
|
156
160
|
} catch {
|
|
157
|
-
return
|
|
161
|
+
return newMutationRetry({ kind: "PROTOCOL", provider: "sentry", operation: "updateIssueStatus", message: "provider response is incomplete or malformed" });
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
164
|
};
|
|
@@ -239,15 +243,16 @@ var SentryClient = class {
|
|
|
239
243
|
}
|
|
240
244
|
/** Send one request and classify Go-compatible provider failures. */
|
|
241
245
|
async exchange(call, operation, method, path, body, hasNotFoundBranch = false) {
|
|
242
|
-
let
|
|
246
|
+
let resolved;
|
|
243
247
|
try {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
} catch {
|
|
249
|
-
return this.failure(operation, "defect", "AUTHENTICATION", "connection credentials or request are invalid");
|
|
248
|
+
resolved = await this.credentials.resolve(call, call.context.cancellationSignal);
|
|
249
|
+
} catch (error) {
|
|
250
|
+
if (isTerminalCredentialError(error)) return this.failure(operation, "defect", "AUTHENTICATION", "connection credentials or request are invalid");
|
|
251
|
+
return this.failure(operation, "retry", "AVAILABILITY", "connection credentials could not be read, so nothing was sent");
|
|
250
252
|
}
|
|
253
|
+
if (!(resolved?.apiKey instanceof SecretString)) return this.failure(operation, "defect", "AUTHENTICATION", "connection credentials or request are invalid");
|
|
254
|
+
const token = resolved.apiKey.reveal();
|
|
255
|
+
if (!token.trim() || !isHeaderSafeCredential(token)) return this.failure(operation, "defect", "AUTHENTICATION", "connection credentials or request are invalid");
|
|
251
256
|
let response;
|
|
252
257
|
try {
|
|
253
258
|
response = await this.send({
|
|
@@ -266,9 +271,9 @@ var SentryClient = class {
|
|
|
266
271
|
const retryAfter2 = parseRetryAfter(header({ status: status2 ?? 0, headers: error.headers ?? {}, body: new Uint8Array() }, "retry-after"), this.now());
|
|
267
272
|
if (status2 === 429) return this.failure(operation, "retry", "RATE_LIMIT", "provider rate limited the request", retryAfter2);
|
|
268
273
|
if (status2 === 408 || status2 !== void 0 && status2 >= 500) return this.failure(operation, "retry", "AVAILABILITY", "provider is temporarily unavailable", retryAfter2);
|
|
269
|
-
if (method === "PUT" && status2 === 409) return this.failure(operation, "retry", "AVAILABILITY", "provider is processing the same request");
|
|
270
274
|
if (status2 === 404 && hasNotFoundBranch) return this.failure(operation, "notFound", "NOT_FOUND", "provider resource was not found");
|
|
271
|
-
if (status2 !== void 0 && (method === "GET" ? status2 !== 200 : ![200, 201, 202].includes(status2))) return this.
|
|
275
|
+
if (status2 !== void 0 && (method === "GET" ? status2 !== 200 : ![200, 201, 202].includes(status2))) return this.rejectedOrUnknown(operation, method, status2);
|
|
276
|
+
if (method === "PUT") return this.failure(operation, "retry", "RESPONSE_TOO_LARGE", "provider response exceeded the configured limit");
|
|
272
277
|
return this.failure(operation, "invalidResponse", "RESPONSE_TOO_LARGE", "provider response exceeded the configured limit");
|
|
273
278
|
}
|
|
274
279
|
return this.failure(operation, "retry", "AVAILABILITY", "provider request failed");
|
|
@@ -277,31 +282,27 @@ var SentryClient = class {
|
|
|
277
282
|
const retryAfter = parseRetryAfter(header(response, "retry-after"), this.now());
|
|
278
283
|
if (status === 429) return this.failure(operation, "retry", "RATE_LIMIT", "provider rate limited the request", retryAfter);
|
|
279
284
|
if (status === 408 || status >= 500) return this.failure(operation, "retry", "AVAILABILITY", "provider is temporarily unavailable", retryAfter);
|
|
280
|
-
if (method === "PUT" && status === 409) {
|
|
281
|
-
const name = readConflictName(response.body);
|
|
282
|
-
if (name === "invalid_idempotent_request") return this.failure(operation, "providerRejected", "PROVIDER_REJECTION", "idempotency key was used for a different request");
|
|
283
|
-
return this.failure(operation, "retry", "AVAILABILITY", "provider is processing the same request");
|
|
284
|
-
}
|
|
285
285
|
if (status === 404 && hasNotFoundBranch) return this.failure(operation, "notFound", "NOT_FOUND", "provider resource was not found");
|
|
286
|
-
if (method === "GET" ? status !== 200 : ![200, 201, 202].includes(status)) return this.
|
|
286
|
+
if (method === "GET" ? status !== 200 : ![200, 201, 202].includes(status)) return this.rejectedOrUnknown(operation, method, status);
|
|
287
287
|
return { body: response.body };
|
|
288
288
|
}
|
|
289
|
+
/** Select providerRejected for a definite refusal; the safe PUT retries every other answer, including 409. */
|
|
290
|
+
rejectedOrUnknown(operation, method, status) {
|
|
291
|
+
if (method === "PUT" && !definiteRefusalStatuses.has(status)) return this.failure(operation, "retry", "AVAILABILITY", `provider answered HTTP ${status}, so the outcome is unknown`);
|
|
292
|
+
return this.failure(operation, "providerRejected", "PROVIDER_REJECTION", `provider rejected the request with HTTP ${status}`);
|
|
293
|
+
}
|
|
289
294
|
failure(operation, branch, kind, message, retryAfterMs = 0) {
|
|
290
295
|
return { branch, failure: { kind, provider: "sentry", operation, message }, retryAfterMs };
|
|
291
296
|
}
|
|
292
297
|
};
|
|
298
|
+
function isTerminalCredentialError(error) {
|
|
299
|
+
return error instanceof ReauthorizationRequiredError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError || error instanceof ObjectNotFoundError || isCredentialMaterialError(error);
|
|
300
|
+
}
|
|
301
|
+
var definiteRefusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
|
|
293
302
|
function header(response, name) {
|
|
294
303
|
const value = response.headers[name];
|
|
295
304
|
return Array.isArray(value) ? value[0] ?? "" : value ?? "";
|
|
296
305
|
}
|
|
297
|
-
function readConflictName(body) {
|
|
298
|
-
try {
|
|
299
|
-
const value = JSON.parse(Buffer.from(body).toString("utf8"));
|
|
300
|
-
if (value && typeof value === "object" && "name" in value && typeof value.name === "string") return value.name;
|
|
301
|
-
} catch {
|
|
302
|
-
}
|
|
303
|
-
return "";
|
|
304
|
-
}
|
|
305
306
|
|
|
306
307
|
// src/project.ts
|
|
307
308
|
var projectSettingsSchema = z.strictObject({
|
|
@@ -348,6 +349,7 @@ export {
|
|
|
348
349
|
ConfigSchema,
|
|
349
350
|
Connection,
|
|
350
351
|
ConnectorID,
|
|
352
|
+
CredentialMaterialError,
|
|
351
353
|
GetIssueBranch,
|
|
352
354
|
GetIssueBranchDefect,
|
|
353
355
|
GetIssueBranchFound,
|
|
@@ -381,6 +383,8 @@ export {
|
|
|
381
383
|
UpdateIssueStatusInputSchema,
|
|
382
384
|
UpdateIssueStatusMetadata,
|
|
383
385
|
UpdateIssueStatusOperation,
|
|
386
|
+
decodeCredentials,
|
|
387
|
+
isCredentialMaterialError,
|
|
384
388
|
newConnection,
|
|
385
389
|
newConnectionWithOperations,
|
|
386
390
|
newGetIssueStep,
|
package/dist/mock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MockQuery, MockMutation, Case } from '@superdurable/connectors-sdk/connectormock';
|
|
2
2
|
import { Failure } from '@superdurable/connectors-sdk';
|
|
3
|
-
import { O as Operations, C as Connection, L as ListIssuesInput, a as IssuePage, G as GetIssueInput, I as Issue, U as UpdateIssueStatusInput } from './connection-
|
|
3
|
+
import { O as Operations, C as Connection, L as ListIssuesInput, a as IssuePage, G as GetIssueInput, I as Issue, U as UpdateIssueStatusInput } from './connection-e93NjxbJ.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
|
6
6
|
/** Go zero value for ListIssuesInput in scripted cases. */
|
package/dist/mock.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
UpdateIssueStatusDefinition,
|
|
10
10
|
UpdateIssueStatusInputSchema,
|
|
11
11
|
newConnectionWithOperations
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-DLF3YZQL.js";
|
|
13
13
|
|
|
14
14
|
// src/generated/mock.ts
|
|
15
15
|
import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-sentry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Sentry issue operations for Dex Flows",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"./mock": {
|
|
27
27
|
"types": "./dist/mock.d.ts",
|
|
28
28
|
"import": "./dist/mock.js"
|
|
29
|
-
}
|
|
29
|
+
},
|
|
30
|
+
"./dex-connector.json": "./dex-connector.json"
|
|
30
31
|
},
|
|
31
32
|
"files": [
|
|
32
33
|
"dist",
|