@haakco/custd-sdk 2.4.0 → 3.71.2
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 +21 -0
- package/README.md +586 -40
- 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 +22 -0
- package/dist/admin-client-setup.js +11 -1
- 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 +20 -6
- package/dist/admin-offboarding.js +27 -6
- package/dist/admin-predictions.d.ts +127 -8
- package/dist/admin-predictions.js +22 -12
- package/dist/admin-privacy-erasures.d.ts +24 -12
- package/dist/admin-privacy-erasures.js +3 -2
- package/dist/admin-retention.d.ts +72 -24
- package/dist/admin-retention.js +38 -13
- 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 +58 -27
- package/dist/admin-subject-exports.js +32 -16
- 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 +22 -14
- package/dist/admin-tenant-storage.js +13 -14
- package/dist/admin-timeplans.d.ts +276 -2
- package/dist/admin-timeplans.js +54 -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 +82 -0
- package/dist/analytics-events.js +157 -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 +2 -2
- package/dist/browser-manifest.json +5 -5
- package/dist/browser-script-BWnwDjAC.js +711 -0
- package/dist/browser-sign-in.d.ts +153 -0
- package/dist/browser-sign-in.js +410 -0
- package/dist/browser-tracker.d.ts +95 -0
- package/dist/browser-tracker.js +362 -40
- package/dist/browser-web-vitals.d.ts +22 -0
- package/dist/browser-web-vitals.js +116 -0
- package/dist/browser.d.ts +9 -0
- package/dist/browser.js +9 -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 +1168 -154
- package/dist/index.js +682 -162
- 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/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/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/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 +2 -2
- package/dist/version.js +1 -1
- package/package.json +25 -14
- package/dist/browser-script-BvgjdZSO.js +0 -429
- package/dist/fixtures.d.ts +0 -10
- package/dist/fixtures.js +0 -57
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measurement reads and runs served by the analytics API: the tenant overview, prediction
|
|
3
|
+
* definitions with their runs, outcomes and evaluations, project forecasts and forecast stories,
|
|
4
|
+
* decision simulations, and uncertainty model runs. The credential names the tenant.
|
|
5
|
+
*/
|
|
6
|
+
import type { AppForecastRun, AppForecastRunRequest, AppForecastStory, AppForecastWarning } from "./app-items.js";
|
|
7
|
+
import type { AppModelRun, AppModelRunRequest, AppModelRunTrigger } from "./app-models.js";
|
|
8
|
+
import type { RequestOptions } from "./index.js";
|
|
9
|
+
type APIRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
10
|
+
export type MeasurementOverviewPoint = {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
/** One area of the tenant's measurement overview, shaped for one widget. */
|
|
15
|
+
export type MeasurementOverviewArea = {
|
|
16
|
+
key: string;
|
|
17
|
+
title: string;
|
|
18
|
+
headline: string;
|
|
19
|
+
value: string;
|
|
20
|
+
detail: string;
|
|
21
|
+
state: string;
|
|
22
|
+
widgetKind: string;
|
|
23
|
+
provenance?: string;
|
|
24
|
+
points: MeasurementOverviewPoint[];
|
|
25
|
+
};
|
|
26
|
+
export type MeasurementOverview = {
|
|
27
|
+
generatedAt: string;
|
|
28
|
+
tenant: {
|
|
29
|
+
companySlug: string;
|
|
30
|
+
label: string;
|
|
31
|
+
};
|
|
32
|
+
areas: MeasurementOverviewArea[];
|
|
33
|
+
};
|
|
34
|
+
/** One active prediction definition. */
|
|
35
|
+
export type PredictionDefinitionRead = {
|
|
36
|
+
uuid: string;
|
|
37
|
+
definitionKey: string;
|
|
38
|
+
displayName: string;
|
|
39
|
+
status: string;
|
|
40
|
+
isPaused: boolean;
|
|
41
|
+
updatedAt: string;
|
|
42
|
+
};
|
|
43
|
+
export type PredictionDefinitionReadList = {
|
|
44
|
+
items: PredictionDefinitionRead[];
|
|
45
|
+
};
|
|
46
|
+
/** One run of a prediction definition. */
|
|
47
|
+
export type PredictionRunRead = {
|
|
48
|
+
runUuid: string;
|
|
49
|
+
asOf: string;
|
|
50
|
+
horizonEnd: string;
|
|
51
|
+
output: number;
|
|
52
|
+
baseline: number;
|
|
53
|
+
overrideApplied: boolean;
|
|
54
|
+
inputHash: string;
|
|
55
|
+
contributionCount: number;
|
|
56
|
+
generatedAt: string;
|
|
57
|
+
};
|
|
58
|
+
export type PredictionRunReadList = {
|
|
59
|
+
items: PredictionRunRead[];
|
|
60
|
+
};
|
|
61
|
+
/** How one run resolved. */
|
|
62
|
+
export type PredictionOutcomeRead = {
|
|
63
|
+
runUuid: string;
|
|
64
|
+
resolution: string;
|
|
65
|
+
outcomeKind: string;
|
|
66
|
+
resolvedAt?: string;
|
|
67
|
+
observedValue: number;
|
|
68
|
+
isLateEvidence: boolean;
|
|
69
|
+
};
|
|
70
|
+
export type PredictionOutcomeReadList = {
|
|
71
|
+
items: PredictionOutcomeRead[];
|
|
72
|
+
};
|
|
73
|
+
/** The latest scored window of a definition's resolved runs. */
|
|
74
|
+
export type PredictionEvaluationRead = {
|
|
75
|
+
windowStartAt: string;
|
|
76
|
+
windowEndAt: string;
|
|
77
|
+
resolvedRunCount: number;
|
|
78
|
+
positiveCount: number;
|
|
79
|
+
negativeCount: number;
|
|
80
|
+
brierScore?: number;
|
|
81
|
+
logLoss?: number;
|
|
82
|
+
sparseBucketCount: number;
|
|
83
|
+
};
|
|
84
|
+
/** A decision simulation. A zero or absent seed and sample count use the server defaults. */
|
|
85
|
+
export type MeasurementSimulationRunRequest = {
|
|
86
|
+
seed?: number;
|
|
87
|
+
sampleCount?: number;
|
|
88
|
+
};
|
|
89
|
+
/** One variable's value of information, ranked. */
|
|
90
|
+
export type MeasurementSimulationVariable = {
|
|
91
|
+
variableUuid: string;
|
|
92
|
+
name: string;
|
|
93
|
+
rank: number;
|
|
94
|
+
evpi: number;
|
|
95
|
+
evppi?: number;
|
|
96
|
+
measurementCost: number;
|
|
97
|
+
worthMeasuring: boolean;
|
|
98
|
+
};
|
|
99
|
+
export type MeasurementSimulationRun = {
|
|
100
|
+
simulationRunUuid: string;
|
|
101
|
+
projectUuid: string;
|
|
102
|
+
decisionUuid: string;
|
|
103
|
+
status: string;
|
|
104
|
+
method: string;
|
|
105
|
+
generatedAt: string;
|
|
106
|
+
completedAt: string;
|
|
107
|
+
sampleCount: number;
|
|
108
|
+
seed: number;
|
|
109
|
+
variables: MeasurementSimulationVariable[];
|
|
110
|
+
warnings: AppForecastWarning[];
|
|
111
|
+
provenance: Record<string, string>;
|
|
112
|
+
};
|
|
113
|
+
/** One stored uncertainty model run, without its results. */
|
|
114
|
+
export type UncertaintyModelRunSummary = {
|
|
115
|
+
runUuid: string;
|
|
116
|
+
modelUuid: string;
|
|
117
|
+
versionNumber: number;
|
|
118
|
+
trigger: AppModelRunTrigger;
|
|
119
|
+
sourceForecastRunUuid?: string;
|
|
120
|
+
seed: number;
|
|
121
|
+
sampleCount: number;
|
|
122
|
+
createdAt: string;
|
|
123
|
+
};
|
|
124
|
+
export type UncertaintyModelRunList = {
|
|
125
|
+
runs: UncertaintyModelRunSummary[];
|
|
126
|
+
};
|
|
127
|
+
export declare class MeasurementClient {
|
|
128
|
+
private readonly request;
|
|
129
|
+
readonly predictions: MeasurementPredictionReads;
|
|
130
|
+
readonly projects: MeasurementProjectRuns;
|
|
131
|
+
readonly uncertaintyModels: MeasurementUncertaintyModelRuns;
|
|
132
|
+
constructor(request: APIRequester);
|
|
133
|
+
overview(): Promise<MeasurementOverview>;
|
|
134
|
+
}
|
|
135
|
+
/** The tenant's prediction definitions as the analytics API serves them; changes go through admin. */
|
|
136
|
+
export declare class MeasurementPredictionReads {
|
|
137
|
+
private readonly request;
|
|
138
|
+
constructor(request: APIRequester);
|
|
139
|
+
listDefinitions(): Promise<PredictionDefinitionReadList>;
|
|
140
|
+
getDefinition(definitionUuid: string): Promise<PredictionDefinitionRead>;
|
|
141
|
+
/** A definition's runs, newest first; `since` (RFC 3339) keeps only runs as of that time or later. */
|
|
142
|
+
listRuns(definitionUuid: string, since?: string): Promise<PredictionRunReadList>;
|
|
143
|
+
listOutcomes(definitionUuid: string): Promise<PredictionOutcomeReadList>;
|
|
144
|
+
getLatestEvaluation(definitionUuid: string): Promise<PredictionEvaluationRead>;
|
|
145
|
+
}
|
|
146
|
+
/** A measurement project's forecasts, forecast story and decision simulations. */
|
|
147
|
+
export declare class MeasurementProjectRuns {
|
|
148
|
+
private readonly request;
|
|
149
|
+
constructor(request: APIRequester);
|
|
150
|
+
runForecast(projectUuid: string, body?: AppForecastRunRequest): Promise<AppForecastRun>;
|
|
151
|
+
getForecastRun(projectUuid: string, runUuid: string): Promise<AppForecastRun>;
|
|
152
|
+
getForecastStory(projectUuid: string): Promise<AppForecastStory>;
|
|
153
|
+
runDecisionSimulation(projectUuid: string, decisionUuid: string, body?: MeasurementSimulationRunRequest): Promise<MeasurementSimulationRun>;
|
|
154
|
+
getDecisionSimulationRun(projectUuid: string, decisionUuid: string, runUuid: string): Promise<MeasurementSimulationRun>;
|
|
155
|
+
}
|
|
156
|
+
/** Runs of an uncertainty model; the model itself is managed through admin. */
|
|
157
|
+
export declare class MeasurementUncertaintyModelRuns {
|
|
158
|
+
private readonly request;
|
|
159
|
+
constructor(request: APIRequester);
|
|
160
|
+
createRun(modelUuid: string, body: AppModelRunRequest): Promise<AppModelRun>;
|
|
161
|
+
listRuns(modelUuid: string): Promise<UncertaintyModelRunList>;
|
|
162
|
+
getRun(modelUuid: string, runUuid: string): Promise<AppModelRun>;
|
|
163
|
+
}
|
|
164
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measurement reads and runs served by the analytics API: the tenant overview, prediction
|
|
3
|
+
* definitions with their runs, outcomes and evaluations, project forecasts and forecast stories,
|
|
4
|
+
* decision simulations, and uncertainty model runs. The credential names the tenant.
|
|
5
|
+
*/
|
|
6
|
+
export class MeasurementClient {
|
|
7
|
+
constructor(request) {
|
|
8
|
+
this.request = request;
|
|
9
|
+
this.predictions = new MeasurementPredictionReads(request);
|
|
10
|
+
this.projects = new MeasurementProjectRuns(request);
|
|
11
|
+
this.uncertaintyModels = new MeasurementUncertaintyModelRuns(request);
|
|
12
|
+
}
|
|
13
|
+
async overview() {
|
|
14
|
+
const wire = await this.request("GET", "/measurement/overview");
|
|
15
|
+
return { ...wire, areas: (wire.areas ?? []).map((area) => ({ ...area, points: area.points ?? [] })) };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** The tenant's prediction definitions as the analytics API serves them; changes go through admin. */
|
|
19
|
+
export class MeasurementPredictionReads {
|
|
20
|
+
constructor(request) {
|
|
21
|
+
this.request = request;
|
|
22
|
+
}
|
|
23
|
+
async listDefinitions() {
|
|
24
|
+
return items(await this.request("GET", definitionPath()));
|
|
25
|
+
}
|
|
26
|
+
getDefinition(definitionUuid) {
|
|
27
|
+
return this.request("GET", definitionPath(definitionUuid));
|
|
28
|
+
}
|
|
29
|
+
/** A definition's runs, newest first; `since` (RFC 3339) keeps only runs as of that time or later. */
|
|
30
|
+
async listRuns(definitionUuid, since) {
|
|
31
|
+
const query = since ? `?since=${encodeURIComponent(since)}` : "";
|
|
32
|
+
return items(await this.request("GET", `${definitionPath(definitionUuid, "/runs")}${query}`));
|
|
33
|
+
}
|
|
34
|
+
async listOutcomes(definitionUuid) {
|
|
35
|
+
return items(await this.request("GET", definitionPath(definitionUuid, "/outcomes")));
|
|
36
|
+
}
|
|
37
|
+
getLatestEvaluation(definitionUuid) {
|
|
38
|
+
return this.request("GET", definitionPath(definitionUuid, "/evaluations"));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** A measurement project's forecasts, forecast story and decision simulations. */
|
|
42
|
+
export class MeasurementProjectRuns {
|
|
43
|
+
constructor(request) {
|
|
44
|
+
this.request = request;
|
|
45
|
+
}
|
|
46
|
+
runForecast(projectUuid, body = {}) {
|
|
47
|
+
return this.request("POST", projectPath(projectUuid, "/forecast-runs"), body);
|
|
48
|
+
}
|
|
49
|
+
getForecastRun(projectUuid, runUuid) {
|
|
50
|
+
return this.request("GET", projectPath(projectUuid, `/forecast-runs/${encodeURIComponent(runUuid)}`));
|
|
51
|
+
}
|
|
52
|
+
async getForecastStory(projectUuid) {
|
|
53
|
+
const story = await this.request("GET", projectPath(projectUuid, "/forecast-story"));
|
|
54
|
+
return {
|
|
55
|
+
...story,
|
|
56
|
+
observations: story.observations ?? [],
|
|
57
|
+
snapshots: story.snapshots ?? [],
|
|
58
|
+
delivery: { ...story.delivery, estimates: story.delivery?.estimates ?? [] },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async runDecisionSimulation(projectUuid, decisionUuid, body = {}) {
|
|
62
|
+
const path = projectPath(projectUuid, `/decisions/${encodeURIComponent(decisionUuid)}/simulation-runs`);
|
|
63
|
+
return simulationRun(await this.request("POST", path, body));
|
|
64
|
+
}
|
|
65
|
+
async getDecisionSimulationRun(projectUuid, decisionUuid, runUuid) {
|
|
66
|
+
const resource = `/decisions/${encodeURIComponent(decisionUuid)}/simulation-runs/${encodeURIComponent(runUuid)}`;
|
|
67
|
+
return simulationRun(await this.request("GET", projectPath(projectUuid, resource)));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Runs of an uncertainty model; the model itself is managed through admin. */
|
|
71
|
+
export class MeasurementUncertaintyModelRuns {
|
|
72
|
+
constructor(request) {
|
|
73
|
+
this.request = request;
|
|
74
|
+
}
|
|
75
|
+
async createRun(modelUuid, body) {
|
|
76
|
+
return modelRun(await this.request("POST", runsPath(modelUuid), body));
|
|
77
|
+
}
|
|
78
|
+
async listRuns(modelUuid) {
|
|
79
|
+
const list = await this.request("GET", runsPath(modelUuid));
|
|
80
|
+
return { runs: list.runs ?? [] };
|
|
81
|
+
}
|
|
82
|
+
async getRun(modelUuid, runUuid) {
|
|
83
|
+
return modelRun(await this.request("GET", `${runsPath(modelUuid)}/${encodeURIComponent(runUuid)}`));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function items(wire) {
|
|
87
|
+
return { items: wire.items ?? [] };
|
|
88
|
+
}
|
|
89
|
+
function simulationRun(wire) {
|
|
90
|
+
return { ...wire, variables: wire.variables ?? [], warnings: wire.warnings ?? [] };
|
|
91
|
+
}
|
|
92
|
+
function modelRun(wire) {
|
|
93
|
+
return { ...wire, quantities: wire.quantities ?? [], boundInputs: wire.boundInputs ?? [] };
|
|
94
|
+
}
|
|
95
|
+
function definitionPath(definitionUuid, resource = "") {
|
|
96
|
+
const base = "/measurement/predictions/definitions";
|
|
97
|
+
return definitionUuid === undefined ? base : `${base}/${encodeURIComponent(definitionUuid)}${resource}`;
|
|
98
|
+
}
|
|
99
|
+
function projectPath(projectUuid, resource) {
|
|
100
|
+
return `/measurement/projects/${encodeURIComponent(projectUuid)}${resource}`;
|
|
101
|
+
}
|
|
102
|
+
function runsPath(modelUuid) {
|
|
103
|
+
return `/measurement/uncertainty-models/${encodeURIComponent(modelUuid)}/runs`;
|
|
104
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { RequestOptions } from "./index.js";
|
|
2
|
+
/** A parser family the ingestion dispatcher can execute. */
|
|
3
|
+
export type ParserType = "regex" | "json" | "xml" | "csv" | "syslog";
|
|
4
|
+
/** A stateless batch-framing mode applied before the application parser runs. */
|
|
5
|
+
export type ParserFramingType = "none" | "docker-json" | "k8s-cri" | "php-multiline";
|
|
6
|
+
/** Parser framing bounds. A caller may request a lower cap; these are hard limits. */
|
|
7
|
+
export declare const DEFAULT_PARSER_FRAMING_MAX_RECORD_BYTES: number;
|
|
8
|
+
export declare const DEFAULT_PARSER_FRAMING_MAX_LINES = 32;
|
|
9
|
+
export declare const MAX_PARSER_FRAMING_RECORD_BYTES: number;
|
|
10
|
+
export declare const MAX_PARSER_FRAMING_LINES = 256;
|
|
11
|
+
/** The visible per-record result of one framing pass. */
|
|
12
|
+
export type ParserFramingOutcome = "complete" | "malformed" | "incomplete" | "oversize";
|
|
13
|
+
/**
|
|
14
|
+
* Stateless framing configuration carried by a parser definition. Framing is
|
|
15
|
+
* revision-pinned with the parser and is the same configuration for preview and
|
|
16
|
+
* save. Multiline assembly is bounded by `maxRecordBytes`/`maxLines`; there is
|
|
17
|
+
* deliberately no idle timeout on stateless batch framing.
|
|
18
|
+
*/
|
|
19
|
+
export type ParserFraming = {
|
|
20
|
+
type: ParserFramingType;
|
|
21
|
+
maxRecordBytes?: number;
|
|
22
|
+
maxLines?: number;
|
|
23
|
+
};
|
|
24
|
+
/** How a generated field is computed from source fields. */
|
|
25
|
+
export type ParserGeneratedFieldConfig = {
|
|
26
|
+
fields: string[];
|
|
27
|
+
namespace: string;
|
|
28
|
+
};
|
|
29
|
+
/** A tenant-owned parser. */
|
|
30
|
+
export type ParserDefinition = {
|
|
31
|
+
uuid: string;
|
|
32
|
+
code: string;
|
|
33
|
+
name: string;
|
|
34
|
+
parserType: ParserType;
|
|
35
|
+
pattern: string | null;
|
|
36
|
+
timestampFormat: string;
|
|
37
|
+
fieldMapping: Record<string, string>;
|
|
38
|
+
generatedFields?: Record<string, ParserGeneratedFieldConfig> | null;
|
|
39
|
+
/** Stateless framing configuration, revision-pinned with the parser. */
|
|
40
|
+
framing?: ParserFraming;
|
|
41
|
+
/**
|
|
42
|
+
* Newer server fields. Both are optional so a response from a server that
|
|
43
|
+
* predates them still decodes; when present they carry the server's value.
|
|
44
|
+
*/
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
revision?: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The named parser-collection DTO. The route emits a bare JSON array; the
|
|
50
|
+
* client wraps it so callers never handle an untyped list.
|
|
51
|
+
*/
|
|
52
|
+
export type ParserListResponse = {
|
|
53
|
+
parsers: ParserDefinition[];
|
|
54
|
+
};
|
|
55
|
+
/** One built-in reusable parser definition from the published catalog. */
|
|
56
|
+
export type ParserPreset = {
|
|
57
|
+
code: string;
|
|
58
|
+
name: string;
|
|
59
|
+
family: string;
|
|
60
|
+
description: string;
|
|
61
|
+
parserType: ParserType;
|
|
62
|
+
pattern: string;
|
|
63
|
+
timestampFormat: string;
|
|
64
|
+
fieldMapping: Record<string, string>;
|
|
65
|
+
sample: string;
|
|
66
|
+
variants: string[];
|
|
67
|
+
};
|
|
68
|
+
/** The named preset-catalog DTO for GET /parsers/presets. */
|
|
69
|
+
export type ParserPresetListResponse = {
|
|
70
|
+
presets: ParserPreset[];
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The create/update body for a tenant-owned parser.
|
|
74
|
+
*
|
|
75
|
+
* `enabled` is optional: leaving it unset omits the field so the server keeps
|
|
76
|
+
* its default (an enabled parser), which also keeps the body valid against a
|
|
77
|
+
* server that does not yet accept the field.
|
|
78
|
+
*/
|
|
79
|
+
export type ParserSaveRequest = {
|
|
80
|
+
code: string;
|
|
81
|
+
name: string;
|
|
82
|
+
parserType: ParserType;
|
|
83
|
+
pattern: string | null;
|
|
84
|
+
timestampFormat: string;
|
|
85
|
+
fieldMapping: Record<string, string>;
|
|
86
|
+
/** Stateless framing configuration, the same for save and preview. */
|
|
87
|
+
framing?: ParserFraming;
|
|
88
|
+
enabled?: boolean;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The parser shape a preview executes. It mirrors the saved definition minus
|
|
92
|
+
* the server-assigned uuid and the newer-only enabled/revision fields, because
|
|
93
|
+
* the preview route decodes strictly.
|
|
94
|
+
*/
|
|
95
|
+
export type ParserPreviewDefinition = {
|
|
96
|
+
code: string;
|
|
97
|
+
name: string;
|
|
98
|
+
parserType: ParserType;
|
|
99
|
+
pattern: string | null;
|
|
100
|
+
timestampFormat: string;
|
|
101
|
+
fieldMapping: Record<string, string>;
|
|
102
|
+
/** The same framing configuration a save would carry. */
|
|
103
|
+
framing?: ParserFraming;
|
|
104
|
+
};
|
|
105
|
+
/** The dry-run body. The service bounds the sample to 256 KiB and maxLines to 100. */
|
|
106
|
+
export type ParserPreviewRequest = {
|
|
107
|
+
parser: ParserPreviewDefinition;
|
|
108
|
+
sample: string;
|
|
109
|
+
maxLines: number;
|
|
110
|
+
};
|
|
111
|
+
/** One sample line's result. `line` is 1-based in the original sample. */
|
|
112
|
+
export type ParserPreviewRow = {
|
|
113
|
+
line: number;
|
|
114
|
+
ok: boolean;
|
|
115
|
+
framing?: ParserFramingOutcome;
|
|
116
|
+
eventTypeSlug?: string;
|
|
117
|
+
timestamp?: string;
|
|
118
|
+
context?: Record<string, unknown>;
|
|
119
|
+
payload?: Record<string, unknown>;
|
|
120
|
+
error?: string;
|
|
121
|
+
};
|
|
122
|
+
/** The dry-run result. `parsed` and `failed` summarize `results`. */
|
|
123
|
+
export type ParserPreviewResponse = {
|
|
124
|
+
results: ParserPreviewRow[];
|
|
125
|
+
parsed: number;
|
|
126
|
+
failed: number;
|
|
127
|
+
};
|
|
128
|
+
/** The body of a successful parser deletion. */
|
|
129
|
+
export type ParserDeleteResponse = {
|
|
130
|
+
deleted: boolean;
|
|
131
|
+
};
|
|
132
|
+
type ParserRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
133
|
+
export declare class ParserClient {
|
|
134
|
+
private readonly request;
|
|
135
|
+
constructor(request: ParserRequester);
|
|
136
|
+
/** List the built-in reusable parser catalog. */
|
|
137
|
+
listPresets(options?: RequestOptions): Promise<ParserPresetListResponse>;
|
|
138
|
+
/** List this tenant's own parsers, wrapped in the named ParserListResponse. */
|
|
139
|
+
list(options?: RequestOptions): Promise<ParserListResponse>;
|
|
140
|
+
/** Create a tenant-owned parser. */
|
|
141
|
+
create(request: ParserSaveRequest, options?: RequestOptions): Promise<ParserDefinition>;
|
|
142
|
+
/** Replace a tenant-owned parser addressed by its explicit UUID. */
|
|
143
|
+
update(uuid: string, request: ParserSaveRequest, options?: RequestOptions): Promise<ParserDefinition>;
|
|
144
|
+
/** Delete a tenant-owned parser addressed by its explicit UUID. */
|
|
145
|
+
delete(uuid: string, options?: RequestOptions): Promise<ParserDeleteResponse>;
|
|
146
|
+
/** Run a parser definition against a bounded sample. Writes and retains nothing. */
|
|
147
|
+
preview(request: ParserPreviewRequest, options?: RequestOptions): Promise<ParserPreviewResponse>;
|
|
148
|
+
}
|
|
149
|
+
export {};
|
package/dist/parsers.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// ParserClient owns the tenant parser routes served by the schema registry:
|
|
2
|
+
// the built-in preset catalog, tenant-owned parser CRUD, and the bounded
|
|
3
|
+
// dry-run preview. Every method returns a named DTO, never a bare array.
|
|
4
|
+
//
|
|
5
|
+
// The routes are authenticated by the caller's tenant credential, so no tenant
|
|
6
|
+
// slug is ever supplied. Create/update/delete require the tenant
|
|
7
|
+
// schema-management authority; list/presets/preview require authentication.
|
|
8
|
+
const PARSER_FRAMING_TYPES = ["none", "docker-json", "k8s-cri", "php-multiline"];
|
|
9
|
+
/** Parser framing bounds. A caller may request a lower cap; these are hard limits. */
|
|
10
|
+
export const DEFAULT_PARSER_FRAMING_MAX_RECORD_BYTES = 64 << 10;
|
|
11
|
+
export const DEFAULT_PARSER_FRAMING_MAX_LINES = 32;
|
|
12
|
+
export const MAX_PARSER_FRAMING_RECORD_BYTES = 1 << 20;
|
|
13
|
+
export const MAX_PARSER_FRAMING_LINES = 256;
|
|
14
|
+
export class ParserClient {
|
|
15
|
+
constructor(request) {
|
|
16
|
+
this.request = request;
|
|
17
|
+
}
|
|
18
|
+
/** List the built-in reusable parser catalog. */
|
|
19
|
+
listPresets(options) {
|
|
20
|
+
return this.request("GET", "/parsers/presets", undefined, options);
|
|
21
|
+
}
|
|
22
|
+
/** List this tenant's own parsers, wrapped in the named ParserListResponse. */
|
|
23
|
+
async list(options) {
|
|
24
|
+
const value = await this.request("GET", "/parsers", undefined, options);
|
|
25
|
+
if (!Array.isArray(value)) {
|
|
26
|
+
throw new TypeError("custd: parser list response must be a JSON array");
|
|
27
|
+
}
|
|
28
|
+
return { parsers: value };
|
|
29
|
+
}
|
|
30
|
+
/** Create a tenant-owned parser. */
|
|
31
|
+
async create(request, options) {
|
|
32
|
+
const body = parserSaveBody(request);
|
|
33
|
+
return this.request("POST", "/parsers", body, options);
|
|
34
|
+
}
|
|
35
|
+
/** Replace a tenant-owned parser addressed by its explicit UUID. */
|
|
36
|
+
async update(uuid, request, options) {
|
|
37
|
+
const body = parserSaveBody(request);
|
|
38
|
+
return this.request("PUT", `/parsers/${encodeURIComponent(uuid)}`, body, options);
|
|
39
|
+
}
|
|
40
|
+
/** Delete a tenant-owned parser addressed by its explicit UUID. */
|
|
41
|
+
delete(uuid, options) {
|
|
42
|
+
return this.request("DELETE", `/parsers/${encodeURIComponent(uuid)}`, undefined, options);
|
|
43
|
+
}
|
|
44
|
+
/** Run a parser definition against a bounded sample. Writes and retains nothing. */
|
|
45
|
+
async preview(request, options) {
|
|
46
|
+
const body = parserPreviewBody(request);
|
|
47
|
+
return this.request("POST", "/parser-preview", body, options);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// parserSaveBody rebuilds the body from the documented fields. An unset
|
|
51
|
+
// `enabled` is omitted rather than sent as undefined/null, and extra caller
|
|
52
|
+
// properties are kept off the wire by construction.
|
|
53
|
+
function parserSaveBody(request) {
|
|
54
|
+
const body = {
|
|
55
|
+
code: request.code,
|
|
56
|
+
name: request.name,
|
|
57
|
+
parserType: request.parserType,
|
|
58
|
+
pattern: request.pattern,
|
|
59
|
+
timestampFormat: request.timestampFormat,
|
|
60
|
+
fieldMapping: request.fieldMapping,
|
|
61
|
+
};
|
|
62
|
+
if (request.framing !== undefined) {
|
|
63
|
+
body.framing = framingBody(request.framing);
|
|
64
|
+
}
|
|
65
|
+
if (request.enabled !== undefined) {
|
|
66
|
+
body.enabled = request.enabled;
|
|
67
|
+
}
|
|
68
|
+
return body;
|
|
69
|
+
}
|
|
70
|
+
// parserPreviewBody projects the previewed definition onto exactly the fields
|
|
71
|
+
// the strictly-decoded preview route accepts. `framing` is carried because
|
|
72
|
+
// preview and save share one configuration; the create/update-only `enabled`
|
|
73
|
+
// cannot reach it.
|
|
74
|
+
function parserPreviewBody(request) {
|
|
75
|
+
const definition = request.parser;
|
|
76
|
+
const parser = {
|
|
77
|
+
code: definition.code,
|
|
78
|
+
name: definition.name,
|
|
79
|
+
parserType: definition.parserType,
|
|
80
|
+
pattern: definition.pattern,
|
|
81
|
+
timestampFormat: definition.timestampFormat,
|
|
82
|
+
fieldMapping: definition.fieldMapping,
|
|
83
|
+
};
|
|
84
|
+
if (definition.framing !== undefined) {
|
|
85
|
+
parser.framing = framingBody(definition.framing);
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
parser,
|
|
89
|
+
sample: request.sample,
|
|
90
|
+
maxLines: request.maxLines,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// framingBody validates the framing type and rebuilds only the documented keys,
|
|
94
|
+
// so an unknown type never costs a round trip and an extra caller property never
|
|
95
|
+
// reaches the wire.
|
|
96
|
+
function framingBody(framing) {
|
|
97
|
+
if (!PARSER_FRAMING_TYPES.includes(framing.type)) {
|
|
98
|
+
throw new RangeError(`custd: parser framing type must be one of ${PARSER_FRAMING_TYPES.join(", ")}`);
|
|
99
|
+
}
|
|
100
|
+
if (framing.maxRecordBytes !== undefined &&
|
|
101
|
+
(framing.maxRecordBytes < 0 || framing.maxRecordBytes > MAX_PARSER_FRAMING_RECORD_BYTES)) {
|
|
102
|
+
throw new RangeError(`custd: parser framing maxRecordBytes must be 0..${MAX_PARSER_FRAMING_RECORD_BYTES}`);
|
|
103
|
+
}
|
|
104
|
+
if (framing.maxLines !== undefined && (framing.maxLines < 0 || framing.maxLines > MAX_PARSER_FRAMING_LINES)) {
|
|
105
|
+
throw new RangeError(`custd: parser framing maxLines must be 0..${MAX_PARSER_FRAMING_LINES}`);
|
|
106
|
+
}
|
|
107
|
+
const body = { type: framing.type };
|
|
108
|
+
if (framing.maxRecordBytes !== undefined) {
|
|
109
|
+
body.maxRecordBytes = framing.maxRecordBytes;
|
|
110
|
+
}
|
|
111
|
+
if (framing.maxLines !== undefined) {
|
|
112
|
+
body.maxLines = framing.maxLines;
|
|
113
|
+
}
|
|
114
|
+
return body;
|
|
115
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls that carry none of the client's own credentials: a hosted app's public discovery document, a
|
|
3
|
+
* shared site report opened by its link token, the auth-domain inventory an external checker probes
|
|
4
|
+
* with its monitoring key, and a published status page with its email subscriptions.
|
|
5
|
+
*/
|
|
6
|
+
import type { SiteReport } from "./admin-site-insights.js";
|
|
7
|
+
import type { SiteStatusPage } from "./admin-site-status-page.js";
|
|
8
|
+
import type { RequestOptions } from "./index.js";
|
|
9
|
+
/** Carries the external checker's monitoring key, its only credential. */
|
|
10
|
+
export declare const AUTH_DOMAIN_MONITORING_KEY_HEADER = "X-Custd-Auth-Domain-Monitoring-Key";
|
|
11
|
+
/**
|
|
12
|
+
* A hosted app's browser sign-in registration. Pages use the authorization-code flow with PKCE and
|
|
13
|
+
* send the access token to the app item routes as X-Custd-User-Token.
|
|
14
|
+
*/
|
|
15
|
+
export type AppDiscoverySignIn = {
|
|
16
|
+
issuer: string;
|
|
17
|
+
authorizationEndpoint: string;
|
|
18
|
+
tokenEndpoint: string;
|
|
19
|
+
endSessionEndpoint: string;
|
|
20
|
+
clientId: string;
|
|
21
|
+
audience: string;
|
|
22
|
+
redirectUri: string;
|
|
23
|
+
postLogoutRedirectUri: string;
|
|
24
|
+
};
|
|
25
|
+
/** A hosted app's public /.well-known/custd.json: where its API is, its public Site key and what it can do. */
|
|
26
|
+
export type AppDiscoveryDocument = {
|
|
27
|
+
apiBaseUrl: string;
|
|
28
|
+
host: string;
|
|
29
|
+
siteUuid: string;
|
|
30
|
+
browserKey: string;
|
|
31
|
+
environment: string;
|
|
32
|
+
capabilities: string[];
|
|
33
|
+
signIn?: AppDiscoverySignIn;
|
|
34
|
+
identityMode: string;
|
|
35
|
+
allowedOrigins: string[];
|
|
36
|
+
pageViewSchemaVersion?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The realm hostnames the external checker probes. A host that leaves `hosts` without appearing in
|
|
40
|
+
* `retiredHosts` was lost, not retired.
|
|
41
|
+
*/
|
|
42
|
+
export type AuthDomainMonitoringInventory = {
|
|
43
|
+
hosts: string[];
|
|
44
|
+
retiredHosts: string[];
|
|
45
|
+
};
|
|
46
|
+
/** Issues a GET with no client credential, adding only the headers given. */
|
|
47
|
+
export type PublicReader = <T>(path: string, headers: Record<string, string>, options?: RequestOptions) => Promise<T>;
|
|
48
|
+
/** Posts a JSON body with no client credential; the path and body are the only authority. */
|
|
49
|
+
export type PublicWriter = (path: string, body: unknown, options?: RequestOptions) => Promise<void>;
|
|
50
|
+
/** Asks a public status page to email its updates to one address. */
|
|
51
|
+
export type SiteStatusSubscriptionRequest = {
|
|
52
|
+
email: string;
|
|
53
|
+
};
|
|
54
|
+
/** The single-use token from a status page subscription email. */
|
|
55
|
+
export type SiteStatusSubscriptionToken = {
|
|
56
|
+
token: string;
|
|
57
|
+
};
|
|
58
|
+
export declare class PublicReadClient {
|
|
59
|
+
private readonly read;
|
|
60
|
+
private readonly write;
|
|
61
|
+
constructor(read: PublicReader, write?: PublicWriter);
|
|
62
|
+
/** Reads a hosted app's public discovery document by host. A host that serves no app answers 404. */
|
|
63
|
+
appDiscovery(host: string, options?: RequestOptions): Promise<AppDiscoveryDocument>;
|
|
64
|
+
/** Reads the site report a share link opens. The share token is the only authority. */
|
|
65
|
+
sharedSiteReport(token: string, options?: RequestOptions): Promise<SiteReport>;
|
|
66
|
+
/** Returns the realm hostnames the external checker may probe. */
|
|
67
|
+
authDomainMonitoringInventory(monitoringKey: string, options?: RequestOptions): Promise<AuthDomainMonitoringInventory>;
|
|
68
|
+
/** Reads a published status page by its public key. An unpublished key answers 404. */
|
|
69
|
+
statusPage(key: string, options?: RequestOptions): Promise<SiteStatusPage>;
|
|
70
|
+
/**
|
|
71
|
+
* Asks for a confirmation email. The server answers the same way for an unknown key, so success does
|
|
72
|
+
* not prove the page exists.
|
|
73
|
+
*/
|
|
74
|
+
subscribeToStatusPage(key: string, request: SiteStatusSubscriptionRequest, options?: RequestOptions): Promise<void>;
|
|
75
|
+
/** Confirms a subscription with the emailed token. */
|
|
76
|
+
confirmStatusPageSubscription(key: string, token: SiteStatusSubscriptionToken, options?: RequestOptions): Promise<void>;
|
|
77
|
+
/** Ends a subscription with the emailed token. */
|
|
78
|
+
unsubscribeFromStatusPage(key: string, token: SiteStatusSubscriptionToken, options?: RequestOptions): Promise<void>;
|
|
79
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls that carry none of the client's own credentials: a hosted app's public discovery document, a
|
|
3
|
+
* shared site report opened by its link token, the auth-domain inventory an external checker probes
|
|
4
|
+
* with its monitoring key, and a published status page with its email subscriptions.
|
|
5
|
+
*/
|
|
6
|
+
/** Carries the external checker's monitoring key, its only credential. */
|
|
7
|
+
export const AUTH_DOMAIN_MONITORING_KEY_HEADER = "X-Custd-Auth-Domain-Monitoring-Key";
|
|
8
|
+
export class PublicReadClient {
|
|
9
|
+
constructor(read, write = () => Promise.reject(new Error("custd: public writes need a writer"))) {
|
|
10
|
+
this.read = read;
|
|
11
|
+
this.write = write;
|
|
12
|
+
}
|
|
13
|
+
/** Reads a hosted app's public discovery document by host. A host that serves no app answers 404. */
|
|
14
|
+
async appDiscovery(host, options) {
|
|
15
|
+
const document = await this.read(`/app-hosts/${encodeURIComponent(host)}/discovery`, {}, options);
|
|
16
|
+
return { ...document, capabilities: document.capabilities ?? [], allowedOrigins: document.allowedOrigins ?? [] };
|
|
17
|
+
}
|
|
18
|
+
/** Reads the site report a share link opens. The share token is the only authority. */
|
|
19
|
+
sharedSiteReport(token, options) {
|
|
20
|
+
if (token.trim() === "")
|
|
21
|
+
return Promise.reject(new Error("custd: shared site report requires a share token"));
|
|
22
|
+
return this.read(`/shared-site-reports/${encodeURIComponent(token)}`, {}, options);
|
|
23
|
+
}
|
|
24
|
+
/** Returns the realm hostnames the external checker may probe. */
|
|
25
|
+
async authDomainMonitoringInventory(monitoringKey, options) {
|
|
26
|
+
if (monitoringKey.trim() === "") {
|
|
27
|
+
return Promise.reject(new Error("custd: auth domain monitoring requires a monitoring key"));
|
|
28
|
+
}
|
|
29
|
+
const inventory = await this.read("/auth-domain-monitoring/inventory", { [AUTH_DOMAIN_MONITORING_KEY_HEADER]: monitoringKey }, options);
|
|
30
|
+
return { hosts: inventory.hosts ?? [], retiredHosts: inventory.retiredHosts ?? [] };
|
|
31
|
+
}
|
|
32
|
+
/** Reads a published status page by its public key. An unpublished key answers 404. */
|
|
33
|
+
async statusPage(key, options) {
|
|
34
|
+
const page = await this.read(statusPagePath(key), {}, options);
|
|
35
|
+
return { ...page, components: page.components ?? [], updates: page.updates ?? [] };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Asks for a confirmation email. The server answers the same way for an unknown key, so success does
|
|
39
|
+
* not prove the page exists.
|
|
40
|
+
*/
|
|
41
|
+
async subscribeToStatusPage(key, request, options) {
|
|
42
|
+
return this.write(`${statusPagePath(key)}/subscribe`, request, options);
|
|
43
|
+
}
|
|
44
|
+
/** Confirms a subscription with the emailed token. */
|
|
45
|
+
async confirmStatusPageSubscription(key, token, options) {
|
|
46
|
+
return this.write(`${statusPagePath(key)}/confirm-subscription`, token, options);
|
|
47
|
+
}
|
|
48
|
+
/** Ends a subscription with the emailed token. */
|
|
49
|
+
async unsubscribeFromStatusPage(key, token, options) {
|
|
50
|
+
return this.write(`${statusPagePath(key)}/unsubscribe`, token, options);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function statusPagePath(key) {
|
|
54
|
+
if (key.trim() === "")
|
|
55
|
+
throw new Error("custd: public status page requires its key");
|
|
56
|
+
return `/public-status-pages/${encodeURIComponent(key)}`;
|
|
57
|
+
}
|