@theholocron/sentry-client 1.7.0 → 1.7.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/dist/index.d.mts +58 -0
- package/dist/index.mjs +54 -0
- package/package.json +2 -2
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import "@theholocron/http-client";
|
|
2
|
+
//#region src/utils.d.ts
|
|
3
|
+
interface SentryClientOptions {
|
|
4
|
+
token: string;
|
|
5
|
+
/** Override base URL for testing. Defaults to https://sentry.io/api/0 */
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/auth/auth.d.ts
|
|
12
|
+
interface SentryOrganization {
|
|
13
|
+
id: string;
|
|
14
|
+
slug: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/projects/projects.d.ts
|
|
19
|
+
interface SentryProject {
|
|
20
|
+
id: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
name: string;
|
|
23
|
+
platform: string | null;
|
|
24
|
+
}
|
|
25
|
+
interface SentryKeyDsn {
|
|
26
|
+
public: string;
|
|
27
|
+
secret: string;
|
|
28
|
+
/** Content Security Policy endpoint. */
|
|
29
|
+
csp: string;
|
|
30
|
+
}
|
|
31
|
+
interface SentryKey {
|
|
32
|
+
id: string;
|
|
33
|
+
label: string;
|
|
34
|
+
public: string;
|
|
35
|
+
secret: string;
|
|
36
|
+
dsn: SentryKeyDsn;
|
|
37
|
+
}
|
|
38
|
+
interface CreateSentryProjectInput {
|
|
39
|
+
name: string;
|
|
40
|
+
platform?: string;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/index.d.ts
|
|
44
|
+
declare function createSentryClient(opts: SentryClientOptions): {
|
|
45
|
+
auth: {
|
|
46
|
+
organizations: () => Promise<SentryOrganization[]>;
|
|
47
|
+
getOrg: (org: string) => Promise<SentryOrganization>;
|
|
48
|
+
};
|
|
49
|
+
projects: {
|
|
50
|
+
list: (org: string) => Promise<SentryProject[]>;
|
|
51
|
+
get: (org: string, slug: string) => Promise<SentryProject>;
|
|
52
|
+
create: (org: string, team: string, input: CreateSentryProjectInput) => Promise<SentryProject>;
|
|
53
|
+
keys: (org: string, slug: string) => Promise<SentryKey[]>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
type SentryClient = ReturnType<typeof createSentryClient>;
|
|
57
|
+
//#endregion
|
|
58
|
+
export { type CreateSentryProjectInput, SentryClient, type SentryClientOptions, type SentryKey, type SentryKeyDsn, type SentryOrganization, type SentryProject, createSentryClient };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createRestClient } from "@theholocron/http-client";
|
|
2
|
+
//#region src/auth/auth.ts
|
|
3
|
+
function auth(rest) {
|
|
4
|
+
return {
|
|
5
|
+
/** List all organizations accessible with the current token. */
|
|
6
|
+
organizations: () => rest.request("/organizations/"),
|
|
7
|
+
/** Get a single organization by slug. */
|
|
8
|
+
getOrg: (org) => rest.request(`/organizations/${org}/`)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/projects/projects.ts
|
|
13
|
+
function projects(rest) {
|
|
14
|
+
return {
|
|
15
|
+
/** List all projects in an org. */
|
|
16
|
+
list: (org) => rest.request(`/organizations/${org}/projects/`),
|
|
17
|
+
/** Get a single project by slug. Throws ProviderApiError 404 if not found. */
|
|
18
|
+
get: (org, slug) => rest.request(`/projects/${org}/${slug}/`),
|
|
19
|
+
/**
|
|
20
|
+
* Create a project under a team. Returns the new project.
|
|
21
|
+
* Team slug defaults to org slug when omitted by the caller.
|
|
22
|
+
*/
|
|
23
|
+
create: (org, team, input) => rest.request(`/teams/${org}/${team}/projects/`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: {
|
|
26
|
+
name: input.name,
|
|
27
|
+
...input.platform ? { platform: input.platform } : {}
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
/** List client keys (DSNs) for a project. */
|
|
31
|
+
keys: (org, slug) => rest.request(`/projects/${org}/${slug}/keys/`)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/utils.ts
|
|
36
|
+
function createSentryRestClient(opts) {
|
|
37
|
+
return createRestClient({
|
|
38
|
+
baseUrl: opts.baseUrl ?? "https://sentry.io/api/0",
|
|
39
|
+
token: opts.token,
|
|
40
|
+
vendor: "Sentry",
|
|
41
|
+
fetch: opts.fetch
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/index.ts
|
|
46
|
+
function createSentryClient(opts) {
|
|
47
|
+
const rest = createSentryRestClient(opts);
|
|
48
|
+
return {
|
|
49
|
+
auth: auth(rest),
|
|
50
|
+
projects: projects(rest)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { createSentryClient };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/sentry-client",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "A TypeScript client for the Sentry management API",
|
|
5
5
|
"homepage": "https://github.com/theholocron/clients/tree/main/packages/sentry-client#readme",
|
|
6
6
|
"bugs": "https://github.com/theholocron/clients/issues",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@theholocron/http-client": "^1.7.
|
|
33
|
+
"@theholocron/http-client": "^1.7.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^26.2.0",
|