@theholocron/holocron-plugin-sentry 5.0.0-alpha.481 → 5.0.0-alpha.483
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.d.mts +2 -1
- package/dist/index.mjs +76 -0
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthError, EnsureRelayInput, EnsureRelayResult, Errors, InspectRelayInput, PluginToken, RelayState, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, EnsureRelayInput, EnsureRelayResult, Errors, ErrorsInspection, InspectErrorsInput, InspectRelayInput, PluginToken, RelayState, ResolveTokenInput, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
2
2
|
import { SentryClient, SentryClientOptions, createSentryClient } from "@theholocron/sentry-client";
|
|
3
3
|
/** Resolves the Sentry token from `--token`, `HOLOCRON_SENTRY_TOKEN`, `SENTRY_AUTH_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
|
|
4
4
|
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
@@ -39,6 +39,7 @@ export declare class SentryErrors implements Errors {
|
|
|
39
39
|
relayClient?: () => SentryClient);
|
|
40
40
|
ensureRelay(input: EnsureRelayInput): Promise<EnsureRelayResult>;
|
|
41
41
|
inspectRelay(input: InspectRelayInput): Promise<RelayState>;
|
|
42
|
+
inspect(input: InspectErrorsInput): Promise<ErrorsInspection>;
|
|
42
43
|
describe(): Promise<{
|
|
43
44
|
provider: string;
|
|
44
45
|
envKeys: string[];
|
package/dist/index.mjs
CHANGED
|
@@ -97,6 +97,79 @@ const tokens = [
|
|
|
97
97
|
},
|
|
98
98
|
releaseToken
|
|
99
99
|
];
|
|
100
|
+
// src/capabilities/inspect-errors.ts
|
|
101
|
+
const notFound = (err) => err instanceof ProviderApiError && err.status === 404;
|
|
102
|
+
/**
|
|
103
|
+
* Read the organization and the named projects: that each exists, has a client key, and is watched by an enabled
|
|
104
|
+
* alert rule. Reads only. Counts the keys and rules and returns neither, so no DSN or key leaves this function.
|
|
105
|
+
* The alert rules are read with `alertsClient` (the relay token, which has the alert scope); one that cannot be read
|
|
106
|
+
* does not fail the rest, it is reported in `alertsUnreadable`.
|
|
107
|
+
*/
|
|
108
|
+
async function inspectSentryErrors(client, alertsClient, orgSlug, input) {
|
|
109
|
+
let org;
|
|
110
|
+
try {
|
|
111
|
+
const found = await client.auth.getOrg(orgSlug);
|
|
112
|
+
org = {
|
|
113
|
+
slug: found.slug,
|
|
114
|
+
exists: true,
|
|
115
|
+
name: found.name
|
|
116
|
+
};
|
|
117
|
+
} catch (err) {
|
|
118
|
+
if (!notFound(err)) throw err;
|
|
119
|
+
return {
|
|
120
|
+
org: {
|
|
121
|
+
slug: orgSlug,
|
|
122
|
+
exists: false
|
|
123
|
+
},
|
|
124
|
+
projects: input.projects.map((slug) => ({
|
|
125
|
+
slug,
|
|
126
|
+
exists: false
|
|
127
|
+
}))
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const found = /* @__PURE__ */ new Map();
|
|
131
|
+
for (const slug of input.projects) try {
|
|
132
|
+
const project = await client.projects.get(orgSlug, slug);
|
|
133
|
+
const keys = await client.projects.keys(orgSlug, project.slug);
|
|
134
|
+
found.set(slug, {
|
|
135
|
+
id: project.id,
|
|
136
|
+
hasDsn: keys.length > 0
|
|
137
|
+
});
|
|
138
|
+
} catch (err) {
|
|
139
|
+
if (!notFound(err)) throw err;
|
|
140
|
+
}
|
|
141
|
+
let rules;
|
|
142
|
+
let alertsUnreadable;
|
|
143
|
+
if (found.size > 0) try {
|
|
144
|
+
const alerts = alertsClient();
|
|
145
|
+
const [detectors, workflows] = await Promise.all([alerts.workflows.detectors(orgSlug), alerts.workflows.list(orgSlug)]);
|
|
146
|
+
rules = /* @__PURE__ */ new Map();
|
|
147
|
+
for (const { id: projectId } of found.values()) {
|
|
148
|
+
const detector = detectors.find((d) => d.projectId === projectId && d.type === "issue_stream");
|
|
149
|
+
rules.set(projectId, detector ? workflows.filter((w) => w.enabled && w.detectorIds.includes(detector.id)).length : 0);
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
alertsUnreadable = err instanceof Error ? err.message : "the alert rules could not be read";
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
org,
|
|
156
|
+
projects: input.projects.map((slug) => {
|
|
157
|
+
const project = found.get(slug);
|
|
158
|
+
if (!project) return {
|
|
159
|
+
slug,
|
|
160
|
+
exists: false
|
|
161
|
+
};
|
|
162
|
+
const alertRules = rules?.get(project.id);
|
|
163
|
+
return {
|
|
164
|
+
slug,
|
|
165
|
+
exists: true,
|
|
166
|
+
hasDsn: project.hasDsn,
|
|
167
|
+
...alertRules === void 0 ? {} : { alertRules }
|
|
168
|
+
};
|
|
169
|
+
}),
|
|
170
|
+
...alertsUnreadable === void 0 ? {} : { alertsUnreadable }
|
|
171
|
+
};
|
|
172
|
+
}
|
|
100
173
|
// src/capabilities/relay.ts
|
|
101
174
|
/** What the integration needs to read: the alert's event. It is also why reading its secret needs the same scope. */
|
|
102
175
|
const INTEGRATION_SCOPES = ["event:read"];
|
|
@@ -349,6 +422,9 @@ var SentryErrors = class {
|
|
|
349
422
|
async inspectRelay(input) {
|
|
350
423
|
return inspectSentryRelay(this.relayClient(), this.requireOrg(), input);
|
|
351
424
|
}
|
|
425
|
+
async inspect(input) {
|
|
426
|
+
return inspectSentryErrors(this.client(), this.relayClient, this.requireOrg(), input);
|
|
427
|
+
}
|
|
352
428
|
async describe() {
|
|
353
429
|
return {
|
|
354
430
|
provider: "sentry",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-sentry",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.483",
|
|
4
4
|
"description": "Holocron plugin for Sentry. Implements the errors capability against Sentry's management API — project provisioning and DSN retrieval.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"errors",
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
"tsx": "4.23.15",
|
|
45
45
|
"typescript": "^5.9.3",
|
|
46
46
|
"vitest": "^5.1.0",
|
|
47
|
+
"@theholocron/cli": "5.0.0-alpha.483",
|
|
47
48
|
"@theholocron/eslint-config": "^8.9.0-alpha.21",
|
|
49
|
+
"@theholocron/http-client": "^1.58.0-alpha.41",
|
|
48
50
|
"@theholocron/misc-utils": "^1.17.0-alpha.5",
|
|
49
|
-
"@theholocron/cli": "5.0.0-alpha.481",
|
|
50
|
-
"@theholocron/tsdown-config": "^8.9.0-alpha.21",
|
|
51
|
-
"@theholocron/vitest-config": "^8.9.0-alpha.21",
|
|
52
51
|
"@theholocron/sentry-client": "^1.58.0-alpha.41",
|
|
53
|
-
"@theholocron/
|
|
54
|
-
"@theholocron/
|
|
52
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.21",
|
|
53
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.21",
|
|
54
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.21"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@theholocron/misc-utils": "^1.16.0",
|
|
58
58
|
"@theholocron/sentry-client": "^1.56.0",
|
|
59
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
59
|
+
"@theholocron/cli": "5.0.0-alpha.483"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|
|
62
62
|
"@theholocron/sentry-client": {}
|