@theholocron/holocron-plugin-sentry 5.0.0-alpha.277 → 5.0.0-alpha.279
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 +16 -0
- package/dist/index.mjs +10 -0
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AuthError, EnsureRelayInput, EnsureRelayResult, Errors, 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
|
+
/** Resolves the Sentry token from `--token`, `HOLOCRON_SENTRY_TOKEN`, `SENTRY_AUTH_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
|
|
3
4
|
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
4
5
|
/**
|
|
5
6
|
* The token for the Comlink relay: an integration, its client secret and an alert rule need more than the general token
|
|
@@ -13,18 +14,22 @@ export declare const resolveComlinkToken: import("@theholocron/cli").FeatureReso
|
|
|
13
14
|
export declare function resolveRelayToken(input?: ResolveTokenInput): string;
|
|
14
15
|
/** Every token this plugin takes, for `holocron doctor tokens`: the general one and the Comlink relay's own. */
|
|
15
16
|
export declare const tokens: PluginToken[];
|
|
17
|
+
/** Options for the Sentry `errors` capability. */
|
|
16
18
|
interface SentryErrorsOptions {
|
|
17
19
|
/** Sentry organization slug. Required for `whoami` and `ensureProject`. */
|
|
18
20
|
org?: string;
|
|
19
21
|
/** Default team slug for project creation. Defaults to org slug. */
|
|
20
22
|
team?: string;
|
|
21
23
|
}
|
|
24
|
+
/** The `errors` capability for Sentry: finds or creates a project and reports its DSN, and manages the Comlink relay. */
|
|
22
25
|
export declare class SentryErrors implements Errors {
|
|
23
26
|
private readonly client;
|
|
24
27
|
private readonly opts;
|
|
25
28
|
/** The client for the relay, made with the Comlink token (see `resolveRelayToken`). */
|
|
26
29
|
private readonly relayClient;
|
|
30
|
+
/** The capability key, always `errors`. */
|
|
27
31
|
readonly key: "errors";
|
|
32
|
+
/** The provider name, `sentry`. */
|
|
28
33
|
readonly providerName = "sentry";
|
|
29
34
|
constructor(client: () => SentryClient, opts: SentryErrorsOptions,
|
|
30
35
|
/** The client for the relay, made with the Comlink token (see `resolveRelayToken`). */
|
|
@@ -38,6 +43,7 @@ export declare class SentryErrors implements Errors {
|
|
|
38
43
|
whoami(): Promise<{
|
|
39
44
|
org: string;
|
|
40
45
|
} | null>;
|
|
46
|
+
/** Returns the public DSN of the project named `input.name` (matched by its slug), creating it when missing; needs `org`, and the new project uses `team` (default the org slug) and `platform` (default `node`). */
|
|
41
47
|
ensureProject(input: {
|
|
42
48
|
name: string;
|
|
43
49
|
platform?: string;
|
|
@@ -56,7 +62,9 @@ interface VerifyTokenOptions {
|
|
|
56
62
|
baseUrl?: string;
|
|
57
63
|
fetch?: typeof fetch;
|
|
58
64
|
}
|
|
65
|
+
/** Checks a Sentry token by listing its organizations; the success subject is `org:` and the first organization's slug, the failure carries the error message. */
|
|
59
66
|
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
67
|
+
/** Options for the Sentry plugin: token resolution, the organization and team, and test overrides. */
|
|
60
68
|
export interface SentryPluginOptions extends ResolveTokenInput, SentryErrorsOptions {
|
|
61
69
|
/**
|
|
62
70
|
* Sentry organization slug. Optional at load time — the `errors` capability
|
|
@@ -66,16 +74,23 @@ export interface SentryPluginOptions extends ResolveTokenInput, SentryErrorsOpti
|
|
|
66
74
|
org?: string;
|
|
67
75
|
/** Override base URL for tests. */
|
|
68
76
|
baseUrl?: string;
|
|
77
|
+
/** Override `fetch` for tests. */
|
|
69
78
|
fetch?: typeof fetch;
|
|
70
79
|
}
|
|
80
|
+
/** What the plugin's capabilities share: the options and two lazily built clients. */
|
|
71
81
|
export interface PluginContext {
|
|
82
|
+
/** The options the plugin was created with. */
|
|
72
83
|
options: SentryPluginOptions;
|
|
84
|
+
/** Builds the Sentry client on first call and reuses it; the token is resolved then, not at plugin load. */
|
|
73
85
|
client: () => SentryClient;
|
|
74
86
|
/** The client for the Comlink relay: its own token (`sentry.comlink`), the general one only as a last resort. */
|
|
75
87
|
relayClient: () => SentryClient;
|
|
76
88
|
}
|
|
89
|
+
/** Creates the shared context for the given options; no token is resolved until a client is first called. */
|
|
77
90
|
export declare function createContext(options: SentryPluginOptions): PluginContext;
|
|
91
|
+
/** Builds the `errors` capability from a plugin context, using the relay client for the Comlink relay. */
|
|
78
92
|
export declare function errors(ctx: PluginContext): Errors;
|
|
93
|
+
/** Creates the Sentry plugin: its probes, a `connection` probe and the `errors` capability. */
|
|
79
94
|
export declare function createPlugin(options: SentryPluginOptions): {
|
|
80
95
|
name: string;
|
|
81
96
|
probes: {
|
|
@@ -85,5 +100,6 @@ export declare function createPlugin(options: SentryPluginOptions): {
|
|
|
85
100
|
errors: () => Errors;
|
|
86
101
|
};
|
|
87
102
|
};
|
|
103
|
+
/** One-line hint shown by `holocron auth set sentry` when no token is given or the token is rejected. */
|
|
88
104
|
export declare const AUTH_HINT: string;
|
|
89
105
|
export { AuthError, type ResolveTokenInput, type SentryClient, type SentryClientOptions, type SentryErrorsOptions, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createSentryClient };
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { createSentryClient } from "@theholocron/sentry-client";
|
|
4
4
|
import { errorMessage } from "@theholocron/misc-utils";
|
|
5
5
|
// src/auth.ts
|
|
6
|
+
/** Resolves the Sentry token from `--token`, `HOLOCRON_SENTRY_TOKEN`, `SENTRY_AUTH_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
|
|
6
7
|
const resolveToken = createResolveToken({
|
|
7
8
|
envName: "HOLOCRON_SENTRY_TOKEN",
|
|
8
9
|
vendorEnvName: "SENTRY_AUTH_TOKEN",
|
|
@@ -264,11 +265,14 @@ async function inspectSentryRelay(client, org, input) {
|
|
|
264
265
|
};
|
|
265
266
|
}
|
|
266
267
|
// src/capabilities/errors.ts
|
|
268
|
+
/** The `errors` capability for Sentry: finds or creates a project and reports its DSN, and manages the Comlink relay. */
|
|
267
269
|
var SentryErrors = class {
|
|
268
270
|
client;
|
|
269
271
|
opts;
|
|
270
272
|
relayClient;
|
|
273
|
+
/** The capability key, always `errors`. */
|
|
271
274
|
key = "errors";
|
|
275
|
+
/** The provider name, `sentry`. */
|
|
272
276
|
providerName = "sentry";
|
|
273
277
|
constructor(client, opts, relayClient = client) {
|
|
274
278
|
this.client = client;
|
|
@@ -291,6 +295,7 @@ var SentryErrors = class {
|
|
|
291
295
|
if (!this.opts.org) return null;
|
|
292
296
|
return { org: (await this.client().auth.getOrg(this.opts.org)).slug };
|
|
293
297
|
}
|
|
298
|
+
/** Returns the public DSN of the project named `input.name` (matched by its slug), creating it when missing; needs `org`, and the new project uses `team` (default the org slug) and `platform` (default `node`). */
|
|
294
299
|
async ensureProject(input) {
|
|
295
300
|
const org = this.requireOrg();
|
|
296
301
|
const slug = toSlug(input.name);
|
|
@@ -568,6 +573,7 @@ function sentryProbes(deps) {
|
|
|
568
573
|
};
|
|
569
574
|
}
|
|
570
575
|
// src/verify-token.ts
|
|
576
|
+
/** Checks a Sentry token by listing its organizations; the success subject is `org:` and the first organization's slug, the failure carries the error message. */
|
|
571
577
|
async function verifyToken(token, opts = {}) {
|
|
572
578
|
const client = createSentryClient({
|
|
573
579
|
token,
|
|
@@ -587,6 +593,7 @@ async function verifyToken(token, opts = {}) {
|
|
|
587
593
|
}
|
|
588
594
|
}
|
|
589
595
|
// src/index.ts
|
|
596
|
+
/** Creates the shared context for the given options; no token is resolved until a client is first called. */
|
|
590
597
|
function createContext(options) {
|
|
591
598
|
let client;
|
|
592
599
|
let relayClient;
|
|
@@ -604,12 +611,14 @@ function createContext(options) {
|
|
|
604
611
|
})
|
|
605
612
|
};
|
|
606
613
|
}
|
|
614
|
+
/** Builds the `errors` capability from a plugin context, using the relay client for the Comlink relay. */
|
|
607
615
|
function errors(ctx) {
|
|
608
616
|
return new SentryErrors(ctx.client, {
|
|
609
617
|
org: ctx.options.org,
|
|
610
618
|
team: ctx.options.team
|
|
611
619
|
}, ctx.relayClient);
|
|
612
620
|
}
|
|
621
|
+
/** Creates the Sentry plugin: its probes, a `connection` probe and the `errors` capability. */
|
|
613
622
|
function createPlugin(options) {
|
|
614
623
|
const ctx = createContext(options);
|
|
615
624
|
return {
|
|
@@ -634,5 +643,6 @@ function createPlugin(options) {
|
|
|
634
643
|
capabilities: { errors: () => errors(ctx) }
|
|
635
644
|
};
|
|
636
645
|
}
|
|
646
|
+
/** One-line hint shown by `holocron auth set sentry` when no token is given or the token is rejected. */
|
|
637
647
|
const AUTH_HINT = "generate an auth token at https://sentry.io/settings/account/api/auth-tokens/ with project:read, project:write, and org:read scopes, then run: holocron auth set sentry <TOKEN>";
|
|
638
648
|
export { AUTH_HINT, AuthError, SentryErrors, createContext, createPlugin, createSentryClient, errors, resolveComlinkToken, resolveRelayToken, resolveToken, tokens, verifyToken };
|
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.279",
|
|
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",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"tsx": "4.23.15",
|
|
42
42
|
"typescript": "^5.9.3",
|
|
43
43
|
"vitest": "^5.0.5",
|
|
44
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
44
|
+
"@theholocron/cli": "5.0.0-alpha.279",
|
|
45
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.4",
|
|
45
46
|
"@theholocron/http-client": "^1.58.0-alpha.3",
|
|
46
|
-
"@theholocron/misc-utils": "^1.16.1-alpha.
|
|
47
|
-
"@theholocron/
|
|
47
|
+
"@theholocron/misc-utils": "^1.16.1-alpha.3",
|
|
48
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.4",
|
|
48
49
|
"@theholocron/sentry-client": "^1.58.0-alpha.3",
|
|
49
|
-
"@theholocron/
|
|
50
|
-
"@theholocron/vitest-config": "^8.9.0-alpha.
|
|
51
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.3"
|
|
50
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.4",
|
|
51
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.4"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@theholocron/misc-utils": "^1.16.0",
|
|
55
55
|
"@theholocron/sentry-client": "^1.56.0",
|
|
56
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
56
|
+
"@theholocron/cli": "5.0.0-alpha.279"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@theholocron/sentry-client": {}
|