@rustrak/client 0.16.3 → 0.17.0
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.cjs +205 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -4
- package/dist/index.d.ts +210 -4
- package/dist/index.js +205 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -134,13 +134,24 @@ var alertRuleChannelInputSchema = zod.z.object({
|
|
|
134
134
|
integration_id: zod.z.number().int(),
|
|
135
135
|
routing_override: zod.z.record(zod.z.string(), zod.z.unknown()).default({})
|
|
136
136
|
});
|
|
137
|
+
var alertRuleConditionsSchema = zod.z.object({
|
|
138
|
+
/** The quietest level that still fires. The server takes `null` as absent. */
|
|
139
|
+
min_level: zod.z.enum(["debug", "info", "warning", "error", "fatal"]).nullish(),
|
|
140
|
+
/** When non-empty, the only environments that fire. */
|
|
141
|
+
environments: zod.z.array(zod.z.string()).optional(),
|
|
142
|
+
/** A new issue fires when it reaches this many events, not on its first. */
|
|
143
|
+
min_events: zod.z.number().int().min(1).nullish()
|
|
144
|
+
});
|
|
137
145
|
var alertRuleSchema = zod.z.object({
|
|
138
146
|
id: zod.z.number().int(),
|
|
139
147
|
project_id: zod.z.number().int(),
|
|
140
148
|
name: zod.z.string(),
|
|
141
149
|
alert_type: alertTypeSchema,
|
|
142
150
|
is_enabled: zod.z.boolean(),
|
|
143
|
-
|
|
151
|
+
// A rule stored before the filters existed may hold any object. The server
|
|
152
|
+
// evaluates one it cannot read as no filters; one bad row must not fail the
|
|
153
|
+
// whole list either.
|
|
154
|
+
conditions: alertRuleConditionsSchema.catch({}),
|
|
144
155
|
cooldown_minutes: zod.z.number().int(),
|
|
145
156
|
last_triggered_at: dateTimeSchema.nullable(),
|
|
146
157
|
created_at: dateTimeSchema,
|
|
@@ -153,13 +164,13 @@ var createAlertRuleSchema = zod.z.object({
|
|
|
153
164
|
alert_type: alertTypeSchema,
|
|
154
165
|
channels: zod.z.array(alertRuleChannelInputSchema).default([]),
|
|
155
166
|
is_enabled: zod.z.boolean().optional(),
|
|
156
|
-
conditions:
|
|
167
|
+
conditions: alertRuleConditionsSchema.optional(),
|
|
157
168
|
cooldown_minutes: zod.z.number().int().min(0).optional()
|
|
158
169
|
});
|
|
159
170
|
var updateAlertRuleSchema = zod.z.object({
|
|
160
171
|
name: zod.z.string().min(1).optional(),
|
|
161
172
|
is_enabled: zod.z.boolean().optional(),
|
|
162
|
-
conditions:
|
|
173
|
+
conditions: alertRuleConditionsSchema.optional(),
|
|
163
174
|
cooldown_minutes: zod.z.number().int().min(0).optional(),
|
|
164
175
|
channels: zod.z.array(alertRuleChannelInputSchema).optional()
|
|
165
176
|
});
|
|
@@ -231,6 +242,89 @@ var eventDetailSchema = zod.z.object({
|
|
|
231
242
|
data: zod.z.record(zod.z.string(), zod.z.any())
|
|
232
243
|
// Full Sentry event JSON
|
|
233
244
|
});
|
|
245
|
+
var gitHubAppSchema = zod.z.object({
|
|
246
|
+
app_id: zod.z.number().int(),
|
|
247
|
+
slug: zod.z.string(),
|
|
248
|
+
html_url: zod.z.string(),
|
|
249
|
+
owner_login: zod.z.string(),
|
|
250
|
+
install_url: zod.z.string(),
|
|
251
|
+
last_webhook_at: dateTimeSchema.nullable(),
|
|
252
|
+
created_at: dateTimeSchema
|
|
253
|
+
});
|
|
254
|
+
var gitHubInstallationSchema = zod.z.object({
|
|
255
|
+
id: zod.z.number().int(),
|
|
256
|
+
account_login: zod.z.string(),
|
|
257
|
+
account_type: zod.z.string(),
|
|
258
|
+
suspended: zod.z.boolean(),
|
|
259
|
+
created_at: dateTimeSchema
|
|
260
|
+
});
|
|
261
|
+
var gitHubStatusSchema = zod.z.object({
|
|
262
|
+
app: gitHubAppSchema.nullable(),
|
|
263
|
+
installations: zod.z.array(gitHubInstallationSchema),
|
|
264
|
+
webhook_url: zod.z.string()
|
|
265
|
+
});
|
|
266
|
+
var gitHubManifestSchema = zod.z.object({
|
|
267
|
+
action_url: zod.z.string(),
|
|
268
|
+
manifest: zod.z.string()
|
|
269
|
+
});
|
|
270
|
+
var gitHubRepositorySchema = zod.z.object({
|
|
271
|
+
installation_id: zod.z.number().int(),
|
|
272
|
+
full_name: zod.z.string(),
|
|
273
|
+
default_branch: zod.z.string(),
|
|
274
|
+
private: zod.z.boolean(),
|
|
275
|
+
html_url: zod.z.string()
|
|
276
|
+
});
|
|
277
|
+
var codeMappingSchema = zod.z.object({
|
|
278
|
+
stack_root: zod.z.string(),
|
|
279
|
+
source_root: zod.z.string()
|
|
280
|
+
});
|
|
281
|
+
var projectRepositorySchema = zod.z.object({
|
|
282
|
+
project_id: zod.z.number().int(),
|
|
283
|
+
installation_id: zod.z.number().int(),
|
|
284
|
+
repo_full_name: zod.z.string(),
|
|
285
|
+
default_branch: zod.z.string(),
|
|
286
|
+
html_url: zod.z.string(),
|
|
287
|
+
code_mappings: zod.z.array(codeMappingSchema),
|
|
288
|
+
/** Open a GitHub issue for new issues that pass `auto_create_conditions`. */
|
|
289
|
+
auto_create_issues: zod.z.boolean(),
|
|
290
|
+
auto_create_conditions: alertRuleConditionsSchema,
|
|
291
|
+
codeowners_rules: zod.z.number().int().nullable(),
|
|
292
|
+
codeowners_synced_at: dateTimeSchema.nullable()
|
|
293
|
+
});
|
|
294
|
+
var updateProjectRepositorySchema = zod.z.object({
|
|
295
|
+
installation_id: zod.z.number().int(),
|
|
296
|
+
repo_full_name: zod.z.string().min(1),
|
|
297
|
+
code_mappings: zod.z.array(codeMappingSchema).optional(),
|
|
298
|
+
auto_create_issues: zod.z.boolean().optional(),
|
|
299
|
+
auto_create_conditions: alertRuleConditionsSchema.optional()
|
|
300
|
+
});
|
|
301
|
+
var issueLinkSchema = zod.z.object({
|
|
302
|
+
id: zod.z.number().int(),
|
|
303
|
+
issue_id: zod.z.string(),
|
|
304
|
+
repo_full_name: zod.z.string(),
|
|
305
|
+
number: zod.z.number().int(),
|
|
306
|
+
title: zod.z.string(),
|
|
307
|
+
url: zod.z.string(),
|
|
308
|
+
state: zod.z.string(),
|
|
309
|
+
created_at: dateTimeSchema
|
|
310
|
+
});
|
|
311
|
+
var repoCommitSchema = zod.z.object({
|
|
312
|
+
repo_full_name: zod.z.string(),
|
|
313
|
+
sha: zod.z.string(),
|
|
314
|
+
message: zod.z.string(),
|
|
315
|
+
author_name: zod.z.string(),
|
|
316
|
+
author_login: zod.z.string().nullable(),
|
|
317
|
+
url: zod.z.string(),
|
|
318
|
+
committed_at: dateTimeSchema
|
|
319
|
+
});
|
|
320
|
+
var issueGitHubSchema = zod.z.object({
|
|
321
|
+
links: zod.z.array(issueLinkSchema),
|
|
322
|
+
suspect_commits: zod.z.array(repoCommitSchema),
|
|
323
|
+
owners: zod.z.array(zod.z.string())
|
|
324
|
+
});
|
|
325
|
+
var gitHubLoginSchema = zod.z.object({
|
|
326
|
+
login: zod.z.string().nullable()
|
|
327
|
+
});
|
|
234
328
|
var globalRoleSchema = zod.z.enum(["admin", "member"]);
|
|
235
329
|
var teamMemberSchema = zod.z.object({
|
|
236
330
|
id: zod.z.number().int(),
|
|
@@ -1663,6 +1757,109 @@ var EventsResource = class extends BaseResource {
|
|
|
1663
1757
|
);
|
|
1664
1758
|
}
|
|
1665
1759
|
};
|
|
1760
|
+
|
|
1761
|
+
// src/resources/github.ts
|
|
1762
|
+
var GitHubResource = class extends BaseResource {
|
|
1763
|
+
/** The app, its installations and the webhook address (admin only). */
|
|
1764
|
+
async status() {
|
|
1765
|
+
return this.request(() => this.http.get("api/github"), gitHubStatusSchema);
|
|
1766
|
+
}
|
|
1767
|
+
/** The form to post to GitHub to create the app, under an org if given. */
|
|
1768
|
+
async manifest(organization) {
|
|
1769
|
+
return this.request(
|
|
1770
|
+
() => this.http.post("api/github/manifest", { json: { organization } }),
|
|
1771
|
+
gitHubManifestSchema
|
|
1772
|
+
);
|
|
1773
|
+
}
|
|
1774
|
+
async disconnect() {
|
|
1775
|
+
return this.requestVoid(() => this.http.delete("api/github"));
|
|
1776
|
+
}
|
|
1777
|
+
/** Repositories the installations reach, for a project's settings. */
|
|
1778
|
+
async repositories(projectId) {
|
|
1779
|
+
return this.request(
|
|
1780
|
+
() => this.http.get("api/github/repositories", {
|
|
1781
|
+
searchParams: { project_id: projectId }
|
|
1782
|
+
}),
|
|
1783
|
+
gitHubRepositorySchema.array()
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
async projectRepository(projectId) {
|
|
1787
|
+
return this.request(
|
|
1788
|
+
() => this.http.get(`api/projects/${projectId}/github`),
|
|
1789
|
+
projectRepositorySchema.nullable()
|
|
1790
|
+
);
|
|
1791
|
+
}
|
|
1792
|
+
async setProjectRepository(projectId, input) {
|
|
1793
|
+
const validated = this.validateInput(input, updateProjectRepositorySchema);
|
|
1794
|
+
if (!validated.success) {
|
|
1795
|
+
return validated;
|
|
1796
|
+
}
|
|
1797
|
+
return this.request(
|
|
1798
|
+
() => this.http.put(`api/projects/${projectId}/github`, {
|
|
1799
|
+
json: validated.data
|
|
1800
|
+
}),
|
|
1801
|
+
projectRepositorySchema
|
|
1802
|
+
);
|
|
1803
|
+
}
|
|
1804
|
+
async removeProjectRepository(projectId) {
|
|
1805
|
+
return this.requestVoid(
|
|
1806
|
+
() => this.http.delete(`api/projects/${projectId}/github`)
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
/** Copies the repository's CODEOWNERS into Rustrak. */
|
|
1810
|
+
async syncCodeowners(projectId) {
|
|
1811
|
+
return this.request(
|
|
1812
|
+
() => this.http.post(`api/projects/${projectId}/github/codeowners`),
|
|
1813
|
+
projectRepositorySchema
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
/** Links, suspect commits and owners for one issue. */
|
|
1817
|
+
async issue(projectId, issueId) {
|
|
1818
|
+
return this.request(
|
|
1819
|
+
() => this.http.get(`api/projects/${projectId}/issues/${issueId}/github`),
|
|
1820
|
+
issueGitHubSchema
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1823
|
+
async createIssue(projectId, issueId, input = {}) {
|
|
1824
|
+
return this.request(
|
|
1825
|
+
() => this.http.post(
|
|
1826
|
+
`api/projects/${projectId}/issues/${issueId}/github/issues`,
|
|
1827
|
+
{ json: input }
|
|
1828
|
+
),
|
|
1829
|
+
issueLinkSchema
|
|
1830
|
+
);
|
|
1831
|
+
}
|
|
1832
|
+
/** `reference` is a GitHub URL, `owner/repo#12` or `#12`. */
|
|
1833
|
+
async linkIssue(projectId, issueId, reference) {
|
|
1834
|
+
return this.request(
|
|
1835
|
+
() => this.http.post(
|
|
1836
|
+
`api/projects/${projectId}/issues/${issueId}/github/links`,
|
|
1837
|
+
{ json: { reference } }
|
|
1838
|
+
),
|
|
1839
|
+
issueLinkSchema
|
|
1840
|
+
);
|
|
1841
|
+
}
|
|
1842
|
+
async unlinkIssue(projectId, issueId, linkId) {
|
|
1843
|
+
return this.requestVoid(
|
|
1844
|
+
() => this.http.delete(
|
|
1845
|
+
`api/projects/${projectId}/issues/${issueId}/github/links/${linkId}`
|
|
1846
|
+
)
|
|
1847
|
+
);
|
|
1848
|
+
}
|
|
1849
|
+
/** The signed-in person's GitHub username, used to sync assignees. */
|
|
1850
|
+
async myLogin() {
|
|
1851
|
+
return this.request(
|
|
1852
|
+
() => this.http.get("api/github/me"),
|
|
1853
|
+
gitHubLoginSchema
|
|
1854
|
+
);
|
|
1855
|
+
}
|
|
1856
|
+
async setMyLogin(login) {
|
|
1857
|
+
return this.request(
|
|
1858
|
+
() => this.http.put("api/github/me", { json: { login } }),
|
|
1859
|
+
gitHubLoginSchema
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1666
1863
|
var serverVersionSchema = zod.z.object({
|
|
1667
1864
|
version: zod.z.string()
|
|
1668
1865
|
});
|
|
@@ -2701,6 +2898,10 @@ var RustrakClient = class {
|
|
|
2701
2898
|
* Health API resource (version info)
|
|
2702
2899
|
*/
|
|
2703
2900
|
health;
|
|
2901
|
+
/**
|
|
2902
|
+
* GitHub integration resource
|
|
2903
|
+
*/
|
|
2904
|
+
github;
|
|
2704
2905
|
/**
|
|
2705
2906
|
* Create a new Rustrak API client
|
|
2706
2907
|
*
|
|
@@ -2713,6 +2914,7 @@ var RustrakClient = class {
|
|
|
2713
2914
|
this.issues = new IssuesResource(this.http);
|
|
2714
2915
|
this.events = new EventsResource(this.http);
|
|
2715
2916
|
this.tokens = new TokensResource(this.http);
|
|
2917
|
+
this.github = new GitHubResource(this.http);
|
|
2716
2918
|
this.alertIntegrations = new AlertIntegrationsResource(this.http);
|
|
2717
2919
|
this.alertRules = new AlertRulesResource(this.http);
|
|
2718
2920
|
this.sourceMaps = new SourceMapsResource(this.http);
|