@haakco/custd-sdk 0.0.0-stage → 3.71.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/README.md +958 -2
- package/dist/admin-accounting-evidence.d.ts +48 -0
- package/dist/admin-accounting-evidence.js +24 -0
- package/dist/admin-app-releases.d.ts +116 -0
- package/dist/admin-app-releases.js +8 -0
- package/dist/admin-apps.d.ts +120 -0
- package/dist/admin-apps.js +47 -0
- package/dist/admin-auth-project-domain.d.ts +125 -0
- package/dist/admin-auth-project-domain.js +37 -0
- package/dist/admin-auth-projects.d.ts +989 -0
- package/dist/admin-auth-projects.js +527 -0
- package/dist/admin-campaign-email.d.ts +120 -0
- package/dist/admin-campaign-email.js +64 -0
- package/dist/admin-client-setup.d.ts +122 -0
- package/dist/admin-client-setup.js +408 -0
- package/dist/admin-data-labels.d.ts +124 -0
- package/dist/admin-data-labels.js +51 -0
- package/dist/admin-data-scopes.d.ts +93 -0
- package/dist/admin-data-scopes.js +154 -0
- package/dist/admin-email-relay.d.ts +66 -0
- package/dist/admin-email-relay.js +25 -0
- package/dist/admin-environment-policy.d.ts +32 -0
- package/dist/admin-environment-policy.js +26 -0
- package/dist/admin-error-issues.d.ts +91 -0
- package/dist/admin-error-issues.js +52 -0
- package/dist/admin-event-types.d.ts +57 -0
- package/dist/admin-event-types.js +28 -0
- package/dist/admin-impersonation.d.ts +48 -0
- package/dist/admin-impersonation.js +27 -0
- package/dist/admin-ingest-claims.d.ts +35 -0
- package/dist/admin-ingest-claims.js +26 -0
- package/dist/admin-managed-audit.d.ts +13 -0
- package/dist/admin-managed-audit.js +13 -0
- package/dist/admin-measurement-projects.d.ts +166 -0
- package/dist/admin-measurement-projects.js +120 -0
- package/dist/admin-notification-destinations.d.ts +31 -0
- package/dist/admin-notification-destinations.js +19 -0
- package/dist/admin-notification-webhooks.d.ts +64 -0
- package/dist/admin-notification-webhooks.js +42 -0
- package/dist/admin-oauth-client-admissions.d.ts +65 -0
- package/dist/admin-oauth-client-admissions.js +46 -0
- package/dist/admin-offboarding.d.ts +123 -0
- package/dist/admin-offboarding.js +129 -0
- package/dist/admin-predictions.d.ts +266 -0
- package/dist/admin-predictions.js +93 -0
- package/dist/admin-privacy-erasures.d.ts +74 -0
- package/dist/admin-privacy-erasures.js +73 -0
- package/dist/admin-retention.d.ts +99 -0
- package/dist/admin-retention.js +60 -0
- package/dist/admin-rls.d.ts +94 -0
- package/dist/admin-rls.js +33 -0
- package/dist/admin-sdk-usage.d.ts +41 -0
- package/dist/admin-sdk-usage.js +23 -0
- package/dist/admin-site-ai.d.ts +72 -0
- package/dist/admin-site-ai.js +1 -0
- package/dist/admin-site-analytics.d.ts +52 -0
- package/dist/admin-site-analytics.js +14 -0
- package/dist/admin-site-audit-pages.d.ts +76 -0
- package/dist/admin-site-audit-pages.js +27 -0
- package/dist/admin-site-campaign-links.d.ts +40 -0
- package/dist/admin-site-campaign-links.js +9 -0
- package/dist/admin-site-domains.d.ts +733 -0
- package/dist/admin-site-domains.js +768 -0
- package/dist/admin-site-export.d.ts +76 -0
- package/dist/admin-site-export.js +15 -0
- package/dist/admin-site-insights-tasks.d.ts +44 -0
- package/dist/admin-site-insights-tasks.js +28 -0
- package/dist/admin-site-insights.d.ts +527 -0
- package/dist/admin-site-insights.js +61 -0
- package/dist/admin-site-links.d.ts +87 -0
- package/dist/admin-site-links.js +16 -0
- package/dist/admin-site-monitors.d.ts +110 -0
- package/dist/admin-site-monitors.js +25 -0
- package/dist/admin-site-next-actions.d.ts +93 -0
- package/dist/admin-site-next-actions.js +36 -0
- package/dist/admin-site-page-queries.d.ts +63 -0
- package/dist/admin-site-page-queries.js +20 -0
- package/dist/admin-site-rankings.d.ts +98 -0
- package/dist/admin-site-rankings.js +46 -0
- package/dist/admin-site-regional-trends.d.ts +30 -0
- package/dist/admin-site-regional-trends.js +1 -0
- package/dist/admin-site-saved-reports.d.ts +45 -0
- package/dist/admin-site-saved-reports.js +13 -0
- package/dist/admin-site-search-pool.d.ts +77 -0
- package/dist/admin-site-search-pool.js +41 -0
- package/dist/admin-site-search-value.d.ts +97 -0
- package/dist/admin-site-search-value.js +29 -0
- package/dist/admin-site-status-page.d.ts +57 -0
- package/dist/admin-site-status-page.js +10 -0
- package/dist/admin-site-traffic.d.ts +145 -0
- package/dist/admin-site-traffic.js +32 -0
- package/dist/admin-site-web-data.d.ts +258 -0
- package/dist/admin-site-web-data.js +60 -0
- package/dist/admin-subject-exports.d.ts +79 -0
- package/dist/admin-subject-exports.js +44 -0
- package/dist/admin-support-access.d.ts +32 -0
- package/dist/admin-support-access.js +21 -0
- package/dist/admin-system.d.ts +283 -0
- package/dist/admin-system.js +65 -0
- package/dist/admin-tenant-storage.d.ts +35 -0
- package/dist/admin-tenant-storage.js +24 -0
- package/dist/admin-timeplans.d.ts +512 -0
- package/dist/admin-timeplans.js +200 -0
- package/dist/admin-uncertainty-models.d.ts +42 -0
- package/dist/admin-uncertainty-models.js +53 -0
- package/dist/admin-usage.d.ts +124 -0
- package/dist/admin-usage.js +169 -0
- package/dist/admin-users.d.ts +124 -0
- package/dist/admin-users.js +82 -0
- package/dist/admin-workflow-timings.d.ts +367 -0
- package/dist/admin-workflow-timings.js +117 -0
- package/dist/analytics-events.d.ts +167 -0
- package/dist/analytics-events.js +197 -0
- package/dist/analytics-reads.d.ts +81 -0
- package/dist/analytics-reads.js +5 -0
- package/dist/app-account.d.ts +84 -0
- package/dist/app-account.js +177 -0
- package/dist/app-alerts.d.ts +120 -0
- package/dist/app-alerts.js +44 -0
- package/dist/app-items.d.ts +786 -0
- package/dist/app-items.js +524 -0
- package/dist/app-live.d.ts +84 -0
- package/dist/app-live.js +228 -0
- package/dist/app-meetings.d.ts +95 -0
- package/dist/app-meetings.js +26 -0
- package/dist/app-models.d.ts +271 -0
- package/dist/app-models.js +83 -0
- package/dist/app-push.d.ts +64 -0
- package/dist/app-push.js +178 -0
- package/dist/backend-lifecycle.d.ts +85 -0
- package/dist/backend-lifecycle.js +212 -0
- package/dist/browser-manifest.json +7 -0
- package/dist/browser-script-BWnwDjAC.js +711 -0
- package/dist/browser-script.d.ts +1 -0
- package/dist/browser-script.js +5 -0
- package/dist/browser-sign-in.d.ts +153 -0
- package/dist/browser-sign-in.js +410 -0
- package/dist/browser-tracker.d.ts +142 -0
- package/dist/browser-tracker.js +775 -0
- package/dist/browser-web-vitals.d.ts +22 -0
- package/dist/browser-web-vitals.js +116 -0
- package/dist/browser.d.ts +10 -0
- package/dist/browser.js +10 -0
- package/dist/download-stream.d.ts +16 -0
- package/dist/download-stream.js +55 -0
- package/dist/error-capture.d.ts +62 -0
- package/dist/error-capture.js +168 -0
- package/dist/hosted-app.d.ts +115 -0
- package/dist/hosted-app.js +275 -0
- package/dist/index.d.ts +2324 -0
- package/dist/index.js +2226 -0
- package/dist/ingest-operations.d.ts +483 -0
- package/dist/ingest-operations.js +154 -0
- package/dist/measurement.d.ts +164 -0
- package/dist/measurement.js +104 -0
- package/dist/mobile-adapter.d.ts +25 -0
- package/dist/mobile-adapter.js +57 -0
- package/dist/mobile-context.d.ts +32 -0
- package/dist/mobile-context.js +156 -0
- package/dist/mobile-queue.d.ts +22 -0
- package/dist/mobile-queue.js +73 -0
- package/dist/oauth.d.ts +1 -0
- package/dist/oauth.js +8 -0
- package/dist/parsers.d.ts +149 -0
- package/dist/parsers.js +115 -0
- package/dist/public-reads.d.ts +79 -0
- package/dist/public-reads.js +57 -0
- package/dist/reporting-catalogue.d.ts +264 -0
- package/dist/reporting-catalogue.js +5 -0
- package/dist/reporting-state.d.ts +46 -0
- package/dist/reporting-state.js +76 -0
- package/dist/response-lists.d.ts +16 -0
- package/dist/response-lists.generated.d.ts +7 -0
- package/dist/response-lists.generated.js +1927 -0
- package/dist/response-lists.js +70 -0
- package/dist/response-validation.d.ts +30 -0
- package/dist/response-validation.js +94 -0
- package/dist/runtime-readiness.d.ts +30 -0
- package/dist/runtime-readiness.js +150 -0
- package/dist/schema-registry.d.ts +45 -0
- package/dist/schema-registry.js +9 -0
- package/dist/secure-url.d.ts +4 -0
- package/dist/secure-url.js +23 -0
- package/dist/site-ai-owner.d.ts +34 -0
- package/dist/site-ai-owner.js +99 -0
- package/dist/site-monitor-reports.d.ts +15 -0
- package/dist/site-monitor-reports.js +87 -0
- package/dist/testing/fake-custd.d.ts +150 -0
- package/dist/testing/fake-custd.js +842 -0
- package/dist/testing/fake-results.d.ts +30 -0
- package/dist/testing/fake-results.js +293 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +3 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.js +10 -0
- package/package.json +57 -4
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { optionalString, requireBoolean, requireObjectList, requireRecord, requireString, } from "./response-validation.js";
|
|
2
|
+
function appHttpsUrl(value) {
|
|
3
|
+
const url = new URL(value);
|
|
4
|
+
if (url.protocol !== "https:" || url.username || url.password) {
|
|
5
|
+
throw new TypeError("custd: app account URLs must use HTTPS without credentials");
|
|
6
|
+
}
|
|
7
|
+
return url;
|
|
8
|
+
}
|
|
9
|
+
/** The issuer's bound on a return path. */
|
|
10
|
+
const maxReturnPathBytes = 512;
|
|
11
|
+
function validReturnPath(path) {
|
|
12
|
+
if (new TextEncoder().encode(path).length > maxReturnPathBytes || !path.startsWith("/") || path.startsWith("//")) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
// No backslash, fragment, whitespace or control character: the issuer refuses each of them.
|
|
16
|
+
return [...path].every((char) => char !== "\\" && char !== "#" && char.charCodeAt(0) > 0x20 && char.charCodeAt(0) !== 0x7f);
|
|
17
|
+
}
|
|
18
|
+
/** Issue a hosted settings entry ticket for the remembered application session. */
|
|
19
|
+
export async function createAppAccountEntry(options) {
|
|
20
|
+
const issuer = appHttpsUrl(options.issuer);
|
|
21
|
+
if (options.issuer !== issuer.origin && options.issuer !== `${issuer.origin}/`) {
|
|
22
|
+
throw new TypeError("custd: account entry requires an HTTPS issuer origin");
|
|
23
|
+
}
|
|
24
|
+
const applicationOrigin = appHttpsUrl(options.applicationOrigin).origin;
|
|
25
|
+
if (applicationOrigin !== options.applicationOrigin) {
|
|
26
|
+
throw new TypeError("custd: account entry requires a serialized application origin");
|
|
27
|
+
}
|
|
28
|
+
if (options.returnPath !== undefined && !validReturnPath(options.returnPath)) {
|
|
29
|
+
throw new TypeError("custd: account return path must be a path on the application origin");
|
|
30
|
+
}
|
|
31
|
+
const actionUrl = `${issuer.origin}/settings/entry`;
|
|
32
|
+
const response = await requestWithAppGrant(options.fetch ?? globalThis.fetch.bind(globalThis), options.accessToken, new URL(`${actionUrl}/ticket`), {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: { "Content-Type": "application/json" },
|
|
35
|
+
body: JSON.stringify(options.returnPath === undefined
|
|
36
|
+
? { applicationOrigin }
|
|
37
|
+
: { applicationOrigin, returnPath: options.returnPath }),
|
|
38
|
+
});
|
|
39
|
+
if (!response.ok)
|
|
40
|
+
throw new AppAccountEntryError(response.status);
|
|
41
|
+
const entry = requireRecord(await response.json().catch(() => {
|
|
42
|
+
throw new TypeError("custd: invalid app account entry response");
|
|
43
|
+
}), "app account entry");
|
|
44
|
+
const ticket = requireString(entry, "ticket", "app account entry");
|
|
45
|
+
if (entry.actionUrl !== actionUrl || !/^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/.test(ticket)) {
|
|
46
|
+
throw new TypeError("custd: invalid app account entry response");
|
|
47
|
+
}
|
|
48
|
+
return { actionUrl, ticket };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Open hosted account settings in the same tab from a browser app. It asks the issuer for a one-use
|
|
52
|
+
* ticket and posts it in a native form, so settings shows a verified link back to the app.
|
|
53
|
+
*/
|
|
54
|
+
export async function openAppAccountSettings(options) {
|
|
55
|
+
const page = options.document ?? globalThis.document;
|
|
56
|
+
const entry = await createAppAccountEntry({
|
|
57
|
+
...options,
|
|
58
|
+
applicationOrigin: options.applicationOrigin ?? globalThis.location.origin,
|
|
59
|
+
});
|
|
60
|
+
const form = page.createElement("form");
|
|
61
|
+
form.method = "post";
|
|
62
|
+
form.action = entry.actionUrl;
|
|
63
|
+
form.target = "_self";
|
|
64
|
+
form.hidden = true;
|
|
65
|
+
const ticket = page.createElement("input");
|
|
66
|
+
ticket.type = "hidden";
|
|
67
|
+
ticket.name = "ticket";
|
|
68
|
+
ticket.value = entry.ticket;
|
|
69
|
+
form.append(ticket);
|
|
70
|
+
page.body.append(form);
|
|
71
|
+
form.submit();
|
|
72
|
+
}
|
|
73
|
+
export class AppAccountEntryError extends Error {
|
|
74
|
+
constructor(status) {
|
|
75
|
+
super(`custd: app account entry request failed (HTTP ${status})`);
|
|
76
|
+
this.status = status;
|
|
77
|
+
this.name = "AppAccountEntryError";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export class CurrentAppProfileError extends Error {
|
|
81
|
+
constructor(status) {
|
|
82
|
+
super(`custd: current app profile request failed (HTTP ${status})`);
|
|
83
|
+
this.status = status;
|
|
84
|
+
this.name = "CurrentAppProfileError";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const profilePath = "/api/v1/app/profile";
|
|
88
|
+
const photoPath = `${profilePath}/photo`;
|
|
89
|
+
const maxPhotoBytes = 256 * 1024;
|
|
90
|
+
const profileContext = "current app profile";
|
|
91
|
+
export class CurrentAppProfileClient {
|
|
92
|
+
constructor(config) {
|
|
93
|
+
this.config = config;
|
|
94
|
+
this.origin = appHttpsUrl(config.apiBaseUrl).origin;
|
|
95
|
+
this.fetch = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
96
|
+
}
|
|
97
|
+
read() {
|
|
98
|
+
return this.profile(profilePath, { method: "GET" });
|
|
99
|
+
}
|
|
100
|
+
update(update) {
|
|
101
|
+
return this.writeFields("PATCH", update);
|
|
102
|
+
}
|
|
103
|
+
/** Fill only previously uninitialized fields and return the current profile. */
|
|
104
|
+
initialize(update) {
|
|
105
|
+
return this.writeFields("POST", update);
|
|
106
|
+
}
|
|
107
|
+
writeFields(method, update) {
|
|
108
|
+
return this.profile(profilePath, {
|
|
109
|
+
method,
|
|
110
|
+
headers: { "Content-Type": "application/json" },
|
|
111
|
+
body: JSON.stringify(update),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async readPhoto() {
|
|
115
|
+
const response = await this.request(photoPath, { method: "GET" });
|
|
116
|
+
const photo = await response.blob();
|
|
117
|
+
validatePhoto(photo);
|
|
118
|
+
return photo;
|
|
119
|
+
}
|
|
120
|
+
uploadPhoto(photo) {
|
|
121
|
+
return this.writePhoto("PUT", photo);
|
|
122
|
+
}
|
|
123
|
+
/** Fill a previously uninitialized photo and return the current profile. */
|
|
124
|
+
initializePhoto(photo) {
|
|
125
|
+
return this.writePhoto("POST", photo);
|
|
126
|
+
}
|
|
127
|
+
writePhoto(method, photo) {
|
|
128
|
+
validatePhoto(photo);
|
|
129
|
+
return this.profile(photoPath, { method, headers: { "Content-Type": photo.type }, body: photo });
|
|
130
|
+
}
|
|
131
|
+
removePhoto() {
|
|
132
|
+
return this.profile(photoPath, { method: "DELETE" });
|
|
133
|
+
}
|
|
134
|
+
async profile(path, init) {
|
|
135
|
+
const response = await this.request(path, init);
|
|
136
|
+
return decodeProfile(await response.json());
|
|
137
|
+
}
|
|
138
|
+
async request(path, init) {
|
|
139
|
+
const response = await requestWithAppGrant(this.fetch, await this.config.accessToken(), new URL(path, this.origin), init);
|
|
140
|
+
if (!response.ok)
|
|
141
|
+
throw new CurrentAppProfileError(response.status);
|
|
142
|
+
return response;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function requestWithAppGrant(fetcher, token, url, init) {
|
|
146
|
+
if (!token || /\s/.test(token))
|
|
147
|
+
throw new TypeError("custd: application access token is required");
|
|
148
|
+
const headers = new Headers(init.headers);
|
|
149
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
150
|
+
return fetcher(url, { ...init, headers, redirect: "error", credentials: "omit", cache: "no-store" });
|
|
151
|
+
}
|
|
152
|
+
function validatePhoto(photo) {
|
|
153
|
+
if (!["image/png", "image/webp"].includes(photo.type) || photo.size === 0 || photo.size > maxPhotoBytes) {
|
|
154
|
+
throw new TypeError("custd: app profile photo must be PNG or WebP and at most 256 KiB");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function decodeProfile(json) {
|
|
158
|
+
const record = requireRecord(json, profileContext);
|
|
159
|
+
const fields = requireObjectList(record, "fields", profileContext).map(decodeField);
|
|
160
|
+
if (record.managedPhoto === undefined)
|
|
161
|
+
return { fields };
|
|
162
|
+
return { fields, managedPhoto: requireBoolean(record, "managedPhoto", profileContext) };
|
|
163
|
+
}
|
|
164
|
+
function decodeField(record) {
|
|
165
|
+
const field = {
|
|
166
|
+
fieldKey: requireString(record, "fieldKey", profileContext),
|
|
167
|
+
present: requireBoolean(record, "present", profileContext),
|
|
168
|
+
initialized: record.initialized === undefined ? false : requireBoolean(record, "initialized", profileContext),
|
|
169
|
+
required: requireBoolean(record, "required", profileContext),
|
|
170
|
+
editableBy: requireString(record, "editableBy", profileContext),
|
|
171
|
+
editable: requireBoolean(record, "editable", profileContext),
|
|
172
|
+
};
|
|
173
|
+
optionalString(record, "value", profileContext);
|
|
174
|
+
if (typeof record.value === "string")
|
|
175
|
+
field.value = record.value;
|
|
176
|
+
return field;
|
|
177
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export declare const APP_ALERT_RULE_TYPES: {
|
|
2
|
+
/** The chance of finishing by the deadline fell below `threshold`. */
|
|
3
|
+
readonly deadlineProbabilityBelow: "deadline_probability_below";
|
|
4
|
+
/** The named model output's 95th percentile rose above the threshold. */
|
|
5
|
+
readonly modelRangeAbove: "model_range_above";
|
|
6
|
+
readonly targetReached: "target_reached";
|
|
7
|
+
/** No new estimate for `staleDays`. */
|
|
8
|
+
readonly estimateStale: "estimate_stale";
|
|
9
|
+
/** The forecast's upper completion bound moved on or before the deadline. */
|
|
10
|
+
readonly forecastMovedInsideTarget: "forecast_moved_inside_target";
|
|
11
|
+
};
|
|
12
|
+
export type AppAlertRuleType = (typeof APP_ALERT_RULE_TYPES)[keyof typeof APP_ALERT_RULE_TYPES];
|
|
13
|
+
export declare const APP_ALERT_CHANNELS: {
|
|
14
|
+
readonly webhook: "webhook";
|
|
15
|
+
readonly slack: "slack";
|
|
16
|
+
readonly email: "email";
|
|
17
|
+
};
|
|
18
|
+
export type AppAlertChannel = (typeof APP_ALERT_CHANNELS)[keyof typeof APP_ALERT_CHANNELS];
|
|
19
|
+
export declare const APP_ALERT_DELIVERY_OUTCOMES: {
|
|
20
|
+
readonly pending: "pending";
|
|
21
|
+
readonly sent: "sent";
|
|
22
|
+
readonly failed: "failed";
|
|
23
|
+
};
|
|
24
|
+
export type AppAlertDeliveryOutcome = (typeof APP_ALERT_DELIVERY_OUTCOMES)[keyof typeof APP_ALERT_DELIVERY_OUTCOMES];
|
|
25
|
+
/** Problem codes the alert routes answer with. */
|
|
26
|
+
export declare const APP_ALERT_ERROR_CODES: {
|
|
27
|
+
readonly notFound: "app_alert_not_found";
|
|
28
|
+
/** The item holds as many rules, webhooks or subscriptions as it may. */
|
|
29
|
+
readonly limit: "app_alert_limit";
|
|
30
|
+
/** The signed-in user has no verified email address to send alerts to: verify one first. */
|
|
31
|
+
readonly noVerifiedEmail: "app_alert_no_verified_email";
|
|
32
|
+
/** The user's email address could not be checked right now; retry. */
|
|
33
|
+
readonly emailCheckUnavailable: "app_alert_email_check_unavailable";
|
|
34
|
+
/** The rule's parameters do not match its type. */
|
|
35
|
+
readonly ruleInvalid: "app_alert_rule_invalid";
|
|
36
|
+
/** This deployment cannot deliver webhooks or email right now. */
|
|
37
|
+
readonly deliveryUnavailable: "app_alert_delivery_unavailable";
|
|
38
|
+
};
|
|
39
|
+
/** A rule's type and parameters. */
|
|
40
|
+
export type AppAlertRuleSpec = {
|
|
41
|
+
type: AppAlertRuleType;
|
|
42
|
+
/** A probability in (0, 1) or a finite model output threshold, depending on the rule. */
|
|
43
|
+
threshold?: number;
|
|
44
|
+
/** The quantity whose range is monitored by `model_range_above`. */
|
|
45
|
+
modelOutput?: string;
|
|
46
|
+
/** Days without a new estimate, 1 to 365; `estimate_stale` only. */
|
|
47
|
+
staleDays?: number;
|
|
48
|
+
};
|
|
49
|
+
/** One rule and the state it last saw. It fires again only after `conditionMet` clears. */
|
|
50
|
+
export type AppAlertRule = AppAlertRuleSpec & {
|
|
51
|
+
ruleUuid: string;
|
|
52
|
+
conditionMet: boolean;
|
|
53
|
+
/** How many times the condition has become true. */
|
|
54
|
+
crossings: number;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
};
|
|
57
|
+
export type AppAlertWebhookCreateRequest = {
|
|
58
|
+
/** HTTPS URL on port 443 that resolves only to public addresses. */
|
|
59
|
+
endpoint: string;
|
|
60
|
+
};
|
|
61
|
+
/** How a destination is delivered: signed Custd JSON, or a Slack message. */
|
|
62
|
+
export declare const APP_ALERT_DESTINATION_KINDS: {
|
|
63
|
+
readonly webhook: "webhook";
|
|
64
|
+
readonly slack: "slack";
|
|
65
|
+
};
|
|
66
|
+
export type AppAlertDestinationKind = (typeof APP_ALERT_DESTINATION_KINDS)[keyof typeof APP_ALERT_DESTINATION_KINDS];
|
|
67
|
+
export type AppAlertSlackCreateRequest = {
|
|
68
|
+
/** Slack incoming-webhook URL, `https://hooks.slack.com/services/...`. It is the secret: stored sealed, never shown again. */
|
|
69
|
+
webhookUrl: string;
|
|
70
|
+
};
|
|
71
|
+
/** One destination: a signed webhook or a Slack incoming webhook, whose `endpoint` is only a hint of its URL. */
|
|
72
|
+
export type AppAlertWebhook = {
|
|
73
|
+
webhookUuid: string;
|
|
74
|
+
kind: AppAlertDestinationKind;
|
|
75
|
+
endpoint: string;
|
|
76
|
+
createdAt: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* A new webhook and its signing secret, shown this once: keep it, Custd cannot. Every delivery is
|
|
80
|
+
* a POST with `X-Custd-Delivery-Id`, `X-Custd-Timestamp` and `X-Custd-Signature: v1=<hex
|
|
81
|
+
* HMAC-SHA256 of "<timestamp>.<body>" under the secret>`.
|
|
82
|
+
*/
|
|
83
|
+
export type AppAlertWebhookCreated = {
|
|
84
|
+
webhook: AppAlertWebhook;
|
|
85
|
+
signingSecret: string;
|
|
86
|
+
};
|
|
87
|
+
/** The signed-in user's email subscription; the address is their verified one. */
|
|
88
|
+
export type AppAlertSubscription = {
|
|
89
|
+
subscriptionUuid: string;
|
|
90
|
+
createdAt: string;
|
|
91
|
+
};
|
|
92
|
+
/** Everything an owner manages on the item's alerts. */
|
|
93
|
+
export type AppAlertSettings = {
|
|
94
|
+
rules: AppAlertRule[] | null;
|
|
95
|
+
webhooks: AppAlertWebhook[] | null;
|
|
96
|
+
/** The signed-in caller's own subscription; absent when there is none or no one is signed in. */
|
|
97
|
+
subscription?: AppAlertSubscription;
|
|
98
|
+
/** Whether this deployment can deliver webhooks and email at all. */
|
|
99
|
+
deliveryAvailable: boolean;
|
|
100
|
+
};
|
|
101
|
+
/** One delivery of one rule crossing to one destination. */
|
|
102
|
+
export type AppAlertDelivery = {
|
|
103
|
+
/** Matches the webhook's `X-Custd-Delivery-Id`. */
|
|
104
|
+
deliveryUuid: string;
|
|
105
|
+
ruleUuid: string;
|
|
106
|
+
ruleType: AppAlertRuleType;
|
|
107
|
+
crossing: number;
|
|
108
|
+
channel: AppAlertChannel;
|
|
109
|
+
webhookUuid?: string;
|
|
110
|
+
outcome: AppAlertDeliveryOutcome;
|
|
111
|
+
attempts: number;
|
|
112
|
+
lastErrorClass?: string;
|
|
113
|
+
lastStatusCode?: number;
|
|
114
|
+
createdAt: string;
|
|
115
|
+
updatedAt: string;
|
|
116
|
+
};
|
|
117
|
+
/** The item's newest deliveries, at most 100. */
|
|
118
|
+
export type AppAlertDeliveryList = {
|
|
119
|
+
deliveries: AppAlertDelivery[] | null;
|
|
120
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Alerts on an app item (Admin API /api/v1/app/item/alerts): rules that fire once each time their
|
|
2
|
+
// condition becomes true, signed webhooks and Slack incoming webhooks, the signed-in owner's email subscription, and the
|
|
3
|
+
// deliveries they made. Every alert route manages the item, so it needs the owner link or the
|
|
4
|
+
// owning user. The JSON names match the routes.
|
|
5
|
+
export const APP_ALERT_RULE_TYPES = {
|
|
6
|
+
/** The chance of finishing by the deadline fell below `threshold`. */
|
|
7
|
+
deadlineProbabilityBelow: "deadline_probability_below",
|
|
8
|
+
/** The named model output's 95th percentile rose above the threshold. */
|
|
9
|
+
modelRangeAbove: "model_range_above",
|
|
10
|
+
targetReached: "target_reached",
|
|
11
|
+
/** No new estimate for `staleDays`. */
|
|
12
|
+
estimateStale: "estimate_stale",
|
|
13
|
+
/** The forecast's upper completion bound moved on or before the deadline. */
|
|
14
|
+
forecastMovedInsideTarget: "forecast_moved_inside_target",
|
|
15
|
+
};
|
|
16
|
+
export const APP_ALERT_CHANNELS = {
|
|
17
|
+
webhook: "webhook",
|
|
18
|
+
slack: "slack",
|
|
19
|
+
email: "email",
|
|
20
|
+
};
|
|
21
|
+
export const APP_ALERT_DELIVERY_OUTCOMES = {
|
|
22
|
+
pending: "pending",
|
|
23
|
+
sent: "sent",
|
|
24
|
+
failed: "failed",
|
|
25
|
+
};
|
|
26
|
+
/** Problem codes the alert routes answer with. */
|
|
27
|
+
export const APP_ALERT_ERROR_CODES = {
|
|
28
|
+
notFound: "app_alert_not_found",
|
|
29
|
+
/** The item holds as many rules, webhooks or subscriptions as it may. */
|
|
30
|
+
limit: "app_alert_limit",
|
|
31
|
+
/** The signed-in user has no verified email address to send alerts to: verify one first. */
|
|
32
|
+
noVerifiedEmail: "app_alert_no_verified_email",
|
|
33
|
+
/** The user's email address could not be checked right now; retry. */
|
|
34
|
+
emailCheckUnavailable: "app_alert_email_check_unavailable",
|
|
35
|
+
/** The rule's parameters do not match its type. */
|
|
36
|
+
ruleInvalid: "app_alert_rule_invalid",
|
|
37
|
+
/** This deployment cannot deliver webhooks or email right now. */
|
|
38
|
+
deliveryUnavailable: "app_alert_delivery_unavailable",
|
|
39
|
+
};
|
|
40
|
+
/** How a destination is delivered: signed Custd JSON, or a Slack message. */
|
|
41
|
+
export const APP_ALERT_DESTINATION_KINDS = {
|
|
42
|
+
webhook: "webhook",
|
|
43
|
+
slack: "slack",
|
|
44
|
+
};
|