@puppi/adapter-sentry 0.0.0-stage → 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/LICENSE +202 -0
- package/README.md +29 -2
- package/dist/define.d.ts +17 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +12 -0
- package/dist/define.js.map +1 -0
- package/dist/index.d.ts +345 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +171 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi.d.ts +1018 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +6 -0
- package/dist/openapi.js.map +1 -0
- package/dist/operations.d.ts +13 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +49 -0
- package/dist/operations.js.map +1 -0
- package/package.json +48 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { read, TerminalError, OpenApiClient, openApiClientOptions, } from "@puppi/sdk";
|
|
36
|
+
import connector from "./define.js";
|
|
37
|
+
import { operations } from "./operations.js";
|
|
38
|
+
export default connector;
|
|
39
|
+
const auth = connector.auth;
|
|
40
|
+
const SENTRY_PAGE = {
|
|
41
|
+
rows: "$",
|
|
42
|
+
next: { header: "link", rel: "next" },
|
|
43
|
+
};
|
|
44
|
+
let Client = (() => {
|
|
45
|
+
let _classSuper = OpenApiClient;
|
|
46
|
+
let _instanceExtraInitializers = [];
|
|
47
|
+
let _projects_decorators;
|
|
48
|
+
let _issues_decorators;
|
|
49
|
+
let _events_decorators;
|
|
50
|
+
return class Client extends _classSuper {
|
|
51
|
+
static {
|
|
52
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
53
|
+
_projects_decorators = [read];
|
|
54
|
+
_issues_decorators = [read];
|
|
55
|
+
_events_decorators = [read];
|
|
56
|
+
__esDecorate(this, null, _projects_decorators, { kind: "method", name: "projects", static: false, private: false, access: { has: obj => "projects" in obj, get: obj => obj.projects }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
57
|
+
__esDecorate(this, null, _issues_decorators, { kind: "method", name: "issues", static: false, private: false, access: { has: obj => "issues" in obj, get: obj => obj.issues }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
58
|
+
__esDecorate(this, null, _events_decorators, { kind: "method", name: "events", static: false, private: false, access: { has: obj => "events" in obj, get: obj => obj.events }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
59
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
60
|
+
}
|
|
61
|
+
constructor(config, secrets = {}, options = {}) {
|
|
62
|
+
super(config, options, ...openApiClientOptions(connector, config, secrets, operations, { extract }));
|
|
63
|
+
__runInitializers(this, _instanceExtraInitializers);
|
|
64
|
+
}
|
|
65
|
+
/** `GET /api/0/organizations/` proves `token`. A 403 names scope `org:read`. */
|
|
66
|
+
async check() {
|
|
67
|
+
const result = await this.prove("/api/0/organizations/", auth.secret);
|
|
68
|
+
if (result.ok || result.reason !== "authorization")
|
|
69
|
+
return result;
|
|
70
|
+
return { ok: false, reason: "authorization", message: `${result.message} (scope org:read)` };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Every page of projects in `organization`. `perPage` and `query` are sent
|
|
74
|
+
* only when the caller passed them. `cursor` is the next page URL, or null
|
|
75
|
+
* when `Link` `rel="next"` has `results` other than `true`.
|
|
76
|
+
*/
|
|
77
|
+
projects(args) {
|
|
78
|
+
return this.pages("listOrganizationProjects", SENTRY_PAGE, {
|
|
79
|
+
cursor: args.cursor,
|
|
80
|
+
path: { organization_id_or_slug: args.organization },
|
|
81
|
+
query: { per_page: args.perPage, query: args.query },
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Every page of issues in `organization`. Omitting `query` leaves Sentry's
|
|
86
|
+
* default `is:unresolved`; pass `""` for every issue. `project` and
|
|
87
|
+
* `environment` each send one value. `cursor` is the next page URL, or null
|
|
88
|
+
* when `Link` `rel="next"` has `results` other than `true`.
|
|
89
|
+
*/
|
|
90
|
+
issues(args) {
|
|
91
|
+
return this.pages("listOrganizationIssues", SENTRY_PAGE, {
|
|
92
|
+
cursor: args.cursor,
|
|
93
|
+
path: { organization_id_or_slug: args.organization },
|
|
94
|
+
query: {
|
|
95
|
+
query: args.query,
|
|
96
|
+
limit: args.limit,
|
|
97
|
+
sort: args.sort,
|
|
98
|
+
project: args.project,
|
|
99
|
+
environment: args.environment,
|
|
100
|
+
statsPeriod: args.statsPeriod,
|
|
101
|
+
start: args.start,
|
|
102
|
+
end: args.end,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Every page of error events for one project. `full: true` includes the
|
|
108
|
+
* stacktrace and Sentry caps that page at 10. `statsPeriod` overrides
|
|
109
|
+
* `start` and `end` when both are sent. `cursor` is the next page URL, or
|
|
110
|
+
* null when `Link` `rel="next"` has `results` other than `true`.
|
|
111
|
+
*/
|
|
112
|
+
events(args) {
|
|
113
|
+
return this.pages("listProjectEvents", SENTRY_PAGE, {
|
|
114
|
+
cursor: args.cursor,
|
|
115
|
+
path: {
|
|
116
|
+
organization_id_or_slug: args.organization,
|
|
117
|
+
project_id_or_slug: args.project,
|
|
118
|
+
},
|
|
119
|
+
query: {
|
|
120
|
+
statsPeriod: args.statsPeriod,
|
|
121
|
+
start: args.start,
|
|
122
|
+
end: args.end,
|
|
123
|
+
full: args.full,
|
|
124
|
+
sample: args.sample,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
})();
|
|
130
|
+
export { Client };
|
|
131
|
+
/**
|
|
132
|
+
* Sentry sends `rel="next"` on the last page too. The walk continues only
|
|
133
|
+
* when that link's `results` parameter is `true`.
|
|
134
|
+
*/
|
|
135
|
+
function extract(operationId, body, headers) {
|
|
136
|
+
if (operationId !== "listOrganizationProjects" &&
|
|
137
|
+
operationId !== "listOrganizationIssues" &&
|
|
138
|
+
operationId !== "listProjectEvents") {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
if (!Array.isArray(body)) {
|
|
142
|
+
// A 200 that is not an array cannot succeed on retry.
|
|
143
|
+
throw new TerminalError(`expected a JSON array, received ${JSON.stringify(body).slice(0, 200)}`);
|
|
144
|
+
}
|
|
145
|
+
return { data: body, next: nextUrl(headers) };
|
|
146
|
+
}
|
|
147
|
+
function nextUrl(headers) {
|
|
148
|
+
const header = headers.get("link");
|
|
149
|
+
if (!header)
|
|
150
|
+
return null;
|
|
151
|
+
for (const part of header.split(",")) {
|
|
152
|
+
const url = /<([^>]+)>/.exec(part)?.[1];
|
|
153
|
+
if (!url)
|
|
154
|
+
continue;
|
|
155
|
+
const params = linkParams(part);
|
|
156
|
+
if (params.get("rel") === "next" && params.get("results") === "true")
|
|
157
|
+
return url;
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
function linkParams(part) {
|
|
162
|
+
const params = new Map();
|
|
163
|
+
const body = part.replace(/<[^>]*>/, "");
|
|
164
|
+
for (const piece of body.split(";")) {
|
|
165
|
+
const match = /^\s*([A-Za-z0-9_-]+)\s*=\s*"?([^";]*)"?\s*$/.exec(piece);
|
|
166
|
+
if (match?.[1])
|
|
167
|
+
params.set(match[1], match[2] ?? "");
|
|
168
|
+
}
|
|
169
|
+
return params;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,E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