@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,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant administrator users and their roles. A user has a global identity state and a
|
|
3
|
+
* per-company membership state, reported separately: disabling an identity and ending a
|
|
4
|
+
* membership are different decisions.
|
|
5
|
+
*/
|
|
6
|
+
import type { RequestOptions } from "./index.js";
|
|
7
|
+
/** The roles a tenant membership can carry. */
|
|
8
|
+
export declare const ADMIN_USER_ROLES: {
|
|
9
|
+
readonly tenantAdmin: "tenant_admin";
|
|
10
|
+
readonly tenantIngestManager: "tenant_ingest_manager";
|
|
11
|
+
readonly tenantAnalyst: "tenant_analyst";
|
|
12
|
+
};
|
|
13
|
+
export type AdminUserRole = (typeof ADMIN_USER_ROLES)[keyof typeof ADMIN_USER_ROLES];
|
|
14
|
+
export declare const ADMIN_USER_GLOBAL_STATES: {
|
|
15
|
+
readonly enabled: "enabled";
|
|
16
|
+
readonly suspended: "suspended";
|
|
17
|
+
};
|
|
18
|
+
export type AdminUserGlobalState = (typeof ADMIN_USER_GLOBAL_STATES)[keyof typeof ADMIN_USER_GLOBAL_STATES];
|
|
19
|
+
export declare const ADMIN_USER_MEMBERSHIP_STATES: {
|
|
20
|
+
readonly active: "active";
|
|
21
|
+
readonly ended: "ended";
|
|
22
|
+
};
|
|
23
|
+
export type AdminUserMembershipState = (typeof ADMIN_USER_MEMBERSHIP_STATES)[keyof typeof ADMIN_USER_MEMBERSHIP_STATES];
|
|
24
|
+
/** One administrator user in one company. The removal fields are null until the user is removed. */
|
|
25
|
+
export type AdminUser = {
|
|
26
|
+
userUuid: string;
|
|
27
|
+
email: string;
|
|
28
|
+
companySlug: string;
|
|
29
|
+
roles: AdminUserRole[];
|
|
30
|
+
globalUserState: AdminUserGlobalState;
|
|
31
|
+
membershipState: AdminUserMembershipState;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
lastLoginAt: string | null;
|
|
34
|
+
welcomeNotificationStatus: string;
|
|
35
|
+
deletedAt: string | null;
|
|
36
|
+
deletedByUserUuid: string | null;
|
|
37
|
+
deleteReason: string | null;
|
|
38
|
+
};
|
|
39
|
+
export type AdminUserListResponse = {
|
|
40
|
+
users: AdminUser[];
|
|
41
|
+
};
|
|
42
|
+
/** A role a membership can carry, with its display name. */
|
|
43
|
+
export type AdminUserRoleDescription = {
|
|
44
|
+
slug: AdminUserRole;
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
export type AdminUserRoleListResponse = {
|
|
49
|
+
roles: AdminUserRoleDescription[];
|
|
50
|
+
};
|
|
51
|
+
/** Filters for a user list. A tenant administrator always sees only its own company. */
|
|
52
|
+
export type AdminUserListQuery = {
|
|
53
|
+
companySlug?: string;
|
|
54
|
+
role?: AdminUserRole;
|
|
55
|
+
globalState?: AdminUserGlobalState;
|
|
56
|
+
membershipState?: AdminUserMembershipState;
|
|
57
|
+
welcomeStatus?: string;
|
|
58
|
+
includeEnded?: boolean;
|
|
59
|
+
/** Lists removed users too. System administrators only. */
|
|
60
|
+
includeDeleted?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/** Narrows a single-user read or action to one company, optionally including ended memberships. */
|
|
63
|
+
export type AdminUserScope = {
|
|
64
|
+
companySlug?: string;
|
|
65
|
+
includeEnded?: boolean;
|
|
66
|
+
};
|
|
67
|
+
export type AdminUserCreateRequest = {
|
|
68
|
+
companySlug: string;
|
|
69
|
+
email: string;
|
|
70
|
+
roles: AdminUserRole[];
|
|
71
|
+
};
|
|
72
|
+
export type AdminUserUpdateRequest = {
|
|
73
|
+
roles: AdminUserRole[];
|
|
74
|
+
};
|
|
75
|
+
export type AdminUserMembershipCreateRequest = {
|
|
76
|
+
companySlug: string;
|
|
77
|
+
roles: AdminUserRole[];
|
|
78
|
+
};
|
|
79
|
+
/** A disable. `globalUser` disables the identity rather than one membership (system administrators only). */
|
|
80
|
+
export type AdminUserDisableRequest = {
|
|
81
|
+
reason?: string;
|
|
82
|
+
companySlug?: string;
|
|
83
|
+
globalUser?: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** An enable. A membership reopens only with the roles it carries. */
|
|
86
|
+
export type AdminUserEnableRequest = {
|
|
87
|
+
roles: AdminUserRole[];
|
|
88
|
+
companySlug?: string;
|
|
89
|
+
globalUser?: boolean;
|
|
90
|
+
};
|
|
91
|
+
/** The reason for a soft delete or restore; it lands in the tenant's audit stream. */
|
|
92
|
+
export type AdminUserRemovalRequest = {
|
|
93
|
+
reason: string;
|
|
94
|
+
};
|
|
95
|
+
/** The notification a reset queued, not a password: the server never returns the credential. */
|
|
96
|
+
export type AdminUserPasswordReset = {
|
|
97
|
+
messageUuid: string;
|
|
98
|
+
deliveryUuids: string[];
|
|
99
|
+
};
|
|
100
|
+
type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
101
|
+
export declare class AdminUserAdminClient {
|
|
102
|
+
private readonly request;
|
|
103
|
+
constructor(request: AdminRequester);
|
|
104
|
+
list(query?: AdminUserListQuery, options?: RequestOptions): Promise<AdminUserListResponse>;
|
|
105
|
+
/** The roles a membership can be given. */
|
|
106
|
+
listRoles(options?: RequestOptions): Promise<AdminUserRoleListResponse>;
|
|
107
|
+
get(userUuid: string, scope?: AdminUserScope, options?: RequestOptions): Promise<AdminUser>;
|
|
108
|
+
/** Creates a user with a membership in one company and queues the welcome notification. */
|
|
109
|
+
create(body: AdminUserCreateRequest, options?: RequestOptions): Promise<AdminUser>;
|
|
110
|
+
/** Replaces the user's roles in one company. */
|
|
111
|
+
update(userUuid: string, body: AdminUserUpdateRequest, companySlug?: string, options?: RequestOptions): Promise<AdminUser>;
|
|
112
|
+
disable(userUuid: string, request?: AdminUserDisableRequest, options?: RequestOptions): Promise<void>;
|
|
113
|
+
enable(userUuid: string, request: AdminUserEnableRequest, options?: RequestOptions): Promise<void>;
|
|
114
|
+
/** Adds an existing user to another company with the given roles. */
|
|
115
|
+
addMembership(userUuid: string, body: AdminUserMembershipCreateRequest, options?: RequestOptions): Promise<AdminUser>;
|
|
116
|
+
resetPassword(userUuid: string, scope?: AdminUserScope, options?: RequestOptions): Promise<AdminUserPasswordReset>;
|
|
117
|
+
/** Removes the user's access in one company while keeping the record. */
|
|
118
|
+
softDelete(userUuid: string, companySlug: string, body: AdminUserRemovalRequest, options?: RequestOptions): Promise<AdminUser>;
|
|
119
|
+
/** Reverses a soft delete in one company. */
|
|
120
|
+
restore(userUuid: string, companySlug: string, body: AdminUserRemovalRequest, options?: RequestOptions): Promise<AdminUser>;
|
|
121
|
+
/** Re-sends the welcome notification. */
|
|
122
|
+
retryWelcome(userUuid: string, scope?: AdminUserScope, options?: RequestOptions): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant administrator users and their roles. A user has a global identity state and a
|
|
3
|
+
* per-company membership state, reported separately: disabling an identity and ending a
|
|
4
|
+
* membership are different decisions.
|
|
5
|
+
*/
|
|
6
|
+
/** The roles a tenant membership can carry. */
|
|
7
|
+
export const ADMIN_USER_ROLES = {
|
|
8
|
+
tenantAdmin: "tenant_admin",
|
|
9
|
+
tenantIngestManager: "tenant_ingest_manager",
|
|
10
|
+
tenantAnalyst: "tenant_analyst",
|
|
11
|
+
};
|
|
12
|
+
export const ADMIN_USER_GLOBAL_STATES = { enabled: "enabled", suspended: "suspended" };
|
|
13
|
+
export const ADMIN_USER_MEMBERSHIP_STATES = { active: "active", ended: "ended" };
|
|
14
|
+
const usersPath = "/users";
|
|
15
|
+
export class AdminUserAdminClient {
|
|
16
|
+
constructor(request) {
|
|
17
|
+
this.request = request;
|
|
18
|
+
}
|
|
19
|
+
async list(query = {}, options) {
|
|
20
|
+
const response = await this.request("GET", withQuery(usersPath, query), undefined, options);
|
|
21
|
+
return { users: response.users ?? [] };
|
|
22
|
+
}
|
|
23
|
+
/** The roles a membership can be given. */
|
|
24
|
+
async listRoles(options) {
|
|
25
|
+
const response = await this.request("GET", "/user-roles", undefined, options);
|
|
26
|
+
return { roles: response.roles ?? [] };
|
|
27
|
+
}
|
|
28
|
+
get(userUuid, scope = {}, options) {
|
|
29
|
+
return this.request("GET", withQuery(userPath(userUuid), scope), undefined, options);
|
|
30
|
+
}
|
|
31
|
+
/** Creates a user with a membership in one company and queues the welcome notification. */
|
|
32
|
+
create(body, options) {
|
|
33
|
+
return this.request("POST", usersPath, body, options);
|
|
34
|
+
}
|
|
35
|
+
/** Replaces the user's roles in one company. */
|
|
36
|
+
update(userUuid, body, companySlug, options) {
|
|
37
|
+
return this.request("PUT", withQuery(userPath(userUuid), { companySlug }), body, options);
|
|
38
|
+
}
|
|
39
|
+
disable(userUuid, request = {}, options) {
|
|
40
|
+
const { reason, ...query } = request;
|
|
41
|
+
const body = reason === undefined ? undefined : { reason };
|
|
42
|
+
return this.request("POST", withQuery(`${userPath(userUuid)}/disable`, query), body, options);
|
|
43
|
+
}
|
|
44
|
+
enable(userUuid, request, options) {
|
|
45
|
+
const { roles, ...query } = request;
|
|
46
|
+
return this.request("POST", withQuery(`${userPath(userUuid)}/enable`, query), { roles }, options);
|
|
47
|
+
}
|
|
48
|
+
/** Adds an existing user to another company with the given roles. */
|
|
49
|
+
addMembership(userUuid, body, options) {
|
|
50
|
+
return this.request("POST", `${userPath(userUuid)}/memberships`, body, options);
|
|
51
|
+
}
|
|
52
|
+
async resetPassword(userUuid, scope = {}, options) {
|
|
53
|
+
const path = withQuery(`${userPath(userUuid)}/reset-password`, scope);
|
|
54
|
+
const reset = await this.request("POST", path, undefined, options);
|
|
55
|
+
return { messageUuid: reset.messageUuid, deliveryUuids: reset.deliveryUuids ?? [] };
|
|
56
|
+
}
|
|
57
|
+
/** Removes the user's access in one company while keeping the record. */
|
|
58
|
+
softDelete(userUuid, companySlug, body, options) {
|
|
59
|
+
return this.request("POST", withQuery(`${userPath(userUuid)}/soft-delete`, { companySlug }), body, options);
|
|
60
|
+
}
|
|
61
|
+
/** Reverses a soft delete in one company. */
|
|
62
|
+
restore(userUuid, companySlug, body, options) {
|
|
63
|
+
return this.request("POST", withQuery(`${userPath(userUuid)}/restore`, { companySlug }), body, options);
|
|
64
|
+
}
|
|
65
|
+
/** Re-sends the welcome notification. */
|
|
66
|
+
retryWelcome(userUuid, scope = {}, options) {
|
|
67
|
+
return this.request("POST", withQuery(`${userPath(userUuid)}/retry-welcome`, scope), undefined, options);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function userPath(userUuid) {
|
|
71
|
+
return `${usersPath}/${encodeURIComponent(userUuid)}`;
|
|
72
|
+
}
|
|
73
|
+
function withQuery(path, query) {
|
|
74
|
+
const params = new URLSearchParams();
|
|
75
|
+
for (const [key, value] of Object.entries(query)) {
|
|
76
|
+
if (value === undefined || value === "" || value === false)
|
|
77
|
+
continue;
|
|
78
|
+
params.set(key, String(value));
|
|
79
|
+
}
|
|
80
|
+
const encoded = params.toString();
|
|
81
|
+
return encoded ? `${path}?${encoded}` : path;
|
|
82
|
+
}
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow timings: facts another system observed about its own work. Custd is not the
|
|
3
|
+
* controller: the caller keeps its own lifecycle and reports what it observed after its own
|
|
4
|
+
* commit. Every append is idempotent through the caller's deterministic key, and a 200 answer
|
|
5
|
+
* is not a durable append: read each result's `accepted`.
|
|
6
|
+
*/
|
|
7
|
+
import type { RequestOptions } from "./index.js";
|
|
8
|
+
/** Expectation states. Only `ready` may be presented as a forecast; a cold start must look different. */
|
|
9
|
+
export declare const WORKFLOW_TIMING_STATES: {
|
|
10
|
+
readonly ready: "ready";
|
|
11
|
+
readonly coldStart: "cold_start";
|
|
12
|
+
readonly sparse: "sparse";
|
|
13
|
+
readonly stale: "stale";
|
|
14
|
+
readonly partial: "partial";
|
|
15
|
+
readonly unavailable: "unavailable";
|
|
16
|
+
readonly error: "error";
|
|
17
|
+
};
|
|
18
|
+
export type WorkflowTimingState = (typeof WORKFLOW_TIMING_STATES)[keyof typeof WORKFLOW_TIMING_STATES];
|
|
19
|
+
/** The observed fact kinds. */
|
|
20
|
+
export declare const WORKFLOW_TIMING_FACT_KINDS: {
|
|
21
|
+
readonly runStarted: "run_started";
|
|
22
|
+
readonly runFinished: "run_finished";
|
|
23
|
+
readonly stepStarted: "step_started";
|
|
24
|
+
readonly stepFinished: "step_finished";
|
|
25
|
+
};
|
|
26
|
+
export type WorkflowTimingFactKind = (typeof WORKFLOW_TIMING_FACT_KINDS)[keyof typeof WORKFLOW_TIMING_FACT_KINDS];
|
|
27
|
+
/** One declared step of a workflow shape. */
|
|
28
|
+
export type WorkflowTimingStepDeclaration = {
|
|
29
|
+
stepKey: string;
|
|
30
|
+
name: string;
|
|
31
|
+
nominalMs: number;
|
|
32
|
+
};
|
|
33
|
+
/** The declarative workflow shape. Repeating it is a no-op; a changed shape adds a forward-only revision. */
|
|
34
|
+
export type WorkflowTimingDeclaration = {
|
|
35
|
+
workflowKey: string;
|
|
36
|
+
name: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
allowOverlap?: boolean;
|
|
39
|
+
dimensions?: string[];
|
|
40
|
+
steps: WorkflowTimingStepDeclaration[];
|
|
41
|
+
retired?: boolean;
|
|
42
|
+
predictionVersionUuid?: string;
|
|
43
|
+
};
|
|
44
|
+
export type WorkflowTimingRunFact = {
|
|
45
|
+
state: string;
|
|
46
|
+
};
|
|
47
|
+
export type WorkflowTimingStepFact = {
|
|
48
|
+
stepKey: string;
|
|
49
|
+
attempt: number;
|
|
50
|
+
state: string;
|
|
51
|
+
errorClass?: string;
|
|
52
|
+
};
|
|
53
|
+
/** The observed fact body. */
|
|
54
|
+
export type WorkflowTimingFact = {
|
|
55
|
+
kind: WorkflowTimingFactKind;
|
|
56
|
+
occurredAt: string;
|
|
57
|
+
dimensions?: Record<string, string>;
|
|
58
|
+
run?: WorkflowTimingRunFact;
|
|
59
|
+
step?: WorkflowTimingStepFact;
|
|
60
|
+
};
|
|
61
|
+
/** Which collector supplied a fact. Both the actor kind and reference are required. */
|
|
62
|
+
export type WorkflowTimingProvenance = {
|
|
63
|
+
actorKind: string;
|
|
64
|
+
actorRef: string;
|
|
65
|
+
collector?: string;
|
|
66
|
+
};
|
|
67
|
+
/** One observed fact with its idempotency identity. */
|
|
68
|
+
export type WorkflowTimingObservation = {
|
|
69
|
+
workflowKey: string;
|
|
70
|
+
externalRunId: string;
|
|
71
|
+
idempotencyKey: string;
|
|
72
|
+
supersedesFactUuid?: string;
|
|
73
|
+
provenance?: WorkflowTimingProvenance;
|
|
74
|
+
fact: WorkflowTimingFact;
|
|
75
|
+
};
|
|
76
|
+
/** The per-item outcome of an append. */
|
|
77
|
+
export type WorkflowTimingObservationResult = {
|
|
78
|
+
index: number;
|
|
79
|
+
accepted: boolean;
|
|
80
|
+
duplicate: boolean;
|
|
81
|
+
workflowKey: string;
|
|
82
|
+
externalRunId: string;
|
|
83
|
+
idempotencyKey: string;
|
|
84
|
+
runUuid?: string;
|
|
85
|
+
factUuid?: string;
|
|
86
|
+
errorCode?: string;
|
|
87
|
+
errorMessage?: string;
|
|
88
|
+
};
|
|
89
|
+
/** The outcome of one append. A rejected item is not a durable append. */
|
|
90
|
+
export type WorkflowTimingBatchResult = {
|
|
91
|
+
results: WorkflowTimingObservationResult[];
|
|
92
|
+
accepted: number;
|
|
93
|
+
rejected: number;
|
|
94
|
+
duplicates: number;
|
|
95
|
+
};
|
|
96
|
+
export type WorkflowTimingDimensionDefinition = {
|
|
97
|
+
dimensionKey: string;
|
|
98
|
+
maxValueBytes: number;
|
|
99
|
+
};
|
|
100
|
+
export type WorkflowTimingStepDefinition = {
|
|
101
|
+
stepKey: string;
|
|
102
|
+
name: string;
|
|
103
|
+
sequence: number;
|
|
104
|
+
nominalMs: number;
|
|
105
|
+
};
|
|
106
|
+
/** An immutable compiled workflow shape. */
|
|
107
|
+
export type WorkflowTimingRevision = {
|
|
108
|
+
uuid: string;
|
|
109
|
+
number: number;
|
|
110
|
+
hash: string;
|
|
111
|
+
allowOverlap: boolean;
|
|
112
|
+
predictionVersionUuid?: string;
|
|
113
|
+
dimensions: WorkflowTimingDimensionDefinition[];
|
|
114
|
+
steps: WorkflowTimingStepDefinition[];
|
|
115
|
+
};
|
|
116
|
+
/** One tenant-scoped workflow shape. */
|
|
117
|
+
export type WorkflowTimingDefinition = {
|
|
118
|
+
uuid: string;
|
|
119
|
+
workflowKey: string;
|
|
120
|
+
name: string;
|
|
121
|
+
description: string;
|
|
122
|
+
status: string;
|
|
123
|
+
currentRevision: WorkflowTimingRevision;
|
|
124
|
+
revisionCount: number;
|
|
125
|
+
};
|
|
126
|
+
export type WorkflowTimingDefinitionList = {
|
|
127
|
+
items: WorkflowTimingDefinition[];
|
|
128
|
+
};
|
|
129
|
+
/** What one reconcile changed. */
|
|
130
|
+
export type WorkflowTimingReconcileResult = {
|
|
131
|
+
definition: WorkflowTimingDefinition;
|
|
132
|
+
created: boolean;
|
|
133
|
+
revisionChanged: boolean;
|
|
134
|
+
};
|
|
135
|
+
/** One evidence-backed duration expectation. The point and range are absent when not produced. */
|
|
136
|
+
export type WorkflowTimingExpectation = {
|
|
137
|
+
seriesKey: string;
|
|
138
|
+
stepKey?: string;
|
|
139
|
+
attempt?: number;
|
|
140
|
+
state: WorkflowTimingState;
|
|
141
|
+
baselineMs: number;
|
|
142
|
+
expectedMs?: number;
|
|
143
|
+
conservativeLowMs?: number;
|
|
144
|
+
conservativeHighMs?: number;
|
|
145
|
+
sampleCount: number;
|
|
146
|
+
method: string;
|
|
147
|
+
methodVersion: string;
|
|
148
|
+
predictionVersionUuid?: string;
|
|
149
|
+
inputHash: string;
|
|
150
|
+
generatedAt: string;
|
|
151
|
+
evidenceWindowStart: string;
|
|
152
|
+
warnings: string[];
|
|
153
|
+
};
|
|
154
|
+
/** One observed run's completion expectation. */
|
|
155
|
+
export type WorkflowTimingPrediction = {
|
|
156
|
+
runUuid: string;
|
|
157
|
+
workflowKey: string;
|
|
158
|
+
externalRunId: string;
|
|
159
|
+
state: WorkflowTimingState;
|
|
160
|
+
allowOverlap: boolean;
|
|
161
|
+
generatedAt: string;
|
|
162
|
+
run: WorkflowTimingExpectation;
|
|
163
|
+
steps: WorkflowTimingExpectation[];
|
|
164
|
+
};
|
|
165
|
+
/** The projection state of one run. Pending facts mean its durations are not yet trustworthy. */
|
|
166
|
+
export type WorkflowTimingProjectionStatus = {
|
|
167
|
+
state: string;
|
|
168
|
+
projectedLedgerId: number;
|
|
169
|
+
latestLedgerId: number;
|
|
170
|
+
pendingFacts: number;
|
|
171
|
+
foldError?: string;
|
|
172
|
+
healthy: boolean;
|
|
173
|
+
nextAction: string;
|
|
174
|
+
};
|
|
175
|
+
export type WorkflowTimingAttempt = {
|
|
176
|
+
stepKey: string;
|
|
177
|
+
attempt: number;
|
|
178
|
+
state: string;
|
|
179
|
+
startedAt?: string;
|
|
180
|
+
finishedAt?: string;
|
|
181
|
+
errorClass?: string;
|
|
182
|
+
occurredAt: string;
|
|
183
|
+
receiptAt: string;
|
|
184
|
+
};
|
|
185
|
+
/** One observed run with its projection status and attempts. */
|
|
186
|
+
export type WorkflowTimingRun = {
|
|
187
|
+
runUuid: string;
|
|
188
|
+
workflowKey: string;
|
|
189
|
+
workflowUuid: string;
|
|
190
|
+
revisionUuid: string;
|
|
191
|
+
revisionNumber: number;
|
|
192
|
+
revisionHash: string;
|
|
193
|
+
externalRunId: string;
|
|
194
|
+
state: string;
|
|
195
|
+
startedAt?: string;
|
|
196
|
+
finishedAt?: string;
|
|
197
|
+
sourceOccurredAt?: string;
|
|
198
|
+
receiptAt: string;
|
|
199
|
+
dimensions: Record<string, string>;
|
|
200
|
+
attempts: WorkflowTimingAttempt[];
|
|
201
|
+
projectionStatus: WorkflowTimingProjectionStatus;
|
|
202
|
+
};
|
|
203
|
+
export type WorkflowTimingRunSummary = {
|
|
204
|
+
runUuid: string;
|
|
205
|
+
externalRunId: string;
|
|
206
|
+
workflowKey: string;
|
|
207
|
+
state: string;
|
|
208
|
+
startedAt?: string;
|
|
209
|
+
finishedAt?: string;
|
|
210
|
+
pendingFacts: number;
|
|
211
|
+
openAttempts: number;
|
|
212
|
+
receiptAt: string;
|
|
213
|
+
};
|
|
214
|
+
export type WorkflowTimingRunList = {
|
|
215
|
+
items: WorkflowTimingRunSummary[];
|
|
216
|
+
};
|
|
217
|
+
/** The closed outcome tally of a workflow. */
|
|
218
|
+
export type WorkflowTimingOutcomeCounts = {
|
|
219
|
+
completedRuns: number;
|
|
220
|
+
failedRuns: number;
|
|
221
|
+
cancelledRuns: number;
|
|
222
|
+
runningRuns: number;
|
|
223
|
+
completedSteps: number;
|
|
224
|
+
failedAttempts: number;
|
|
225
|
+
skippedAttempts: number;
|
|
226
|
+
cancelledSteps: number;
|
|
227
|
+
openAttempts: number;
|
|
228
|
+
retries: number;
|
|
229
|
+
};
|
|
230
|
+
export type WorkflowTimingDurationHistoryEntry = {
|
|
231
|
+
runUuid: string;
|
|
232
|
+
stepKey: string;
|
|
233
|
+
valueMs: number;
|
|
234
|
+
baselineMs: number;
|
|
235
|
+
revisionUuid: string;
|
|
236
|
+
revisionNumber: number;
|
|
237
|
+
outcome: string;
|
|
238
|
+
corrected: boolean;
|
|
239
|
+
observedAt: string;
|
|
240
|
+
};
|
|
241
|
+
export type WorkflowTimingContribution = {
|
|
242
|
+
stepKey: string;
|
|
243
|
+
attempts: number;
|
|
244
|
+
totalMs: number;
|
|
245
|
+
baselineMs: number;
|
|
246
|
+
contributionPermille: number;
|
|
247
|
+
};
|
|
248
|
+
/** The latest completed run's split. Active time is the union of step intervals, never their sum. */
|
|
249
|
+
export type WorkflowTimingRunTiming = {
|
|
250
|
+
runUuid: string;
|
|
251
|
+
wallClockMs: number;
|
|
252
|
+
activeMs: number;
|
|
253
|
+
waitMs: number;
|
|
254
|
+
nominalMs: number;
|
|
255
|
+
};
|
|
256
|
+
export type WorkflowTimingDurationHistory = {
|
|
257
|
+
workflowKey: string;
|
|
258
|
+
workflowUuid: string;
|
|
259
|
+
entries: WorkflowTimingDurationHistoryEntry[];
|
|
260
|
+
outcomes: WorkflowTimingOutcomeCounts;
|
|
261
|
+
contributions: WorkflowTimingContribution[];
|
|
262
|
+
latestCompletedRun?: WorkflowTimingRunTiming;
|
|
263
|
+
};
|
|
264
|
+
/** The measurement owner's evaluation artifact, as it stores it. */
|
|
265
|
+
export type WorkflowTimingEvaluationArtifact = {
|
|
266
|
+
schema_version: string;
|
|
267
|
+
source: string;
|
|
268
|
+
prediction_version_uuid: string;
|
|
269
|
+
content_sha256: string;
|
|
270
|
+
evaluation: Record<string, unknown>;
|
|
271
|
+
};
|
|
272
|
+
/** The rolling-origin evaluation. Unavailable, with a next action, until a prediction version is selected. */
|
|
273
|
+
export type WorkflowTimingEvaluation = {
|
|
274
|
+
workflowKey: string;
|
|
275
|
+
workflowUuid: string;
|
|
276
|
+
seriesKey: string;
|
|
277
|
+
state: string;
|
|
278
|
+
nextAction: string;
|
|
279
|
+
baselineMs: number;
|
|
280
|
+
outcomes: WorkflowTimingOutcomeCounts;
|
|
281
|
+
predictionVersionUuid?: string;
|
|
282
|
+
artifact?: WorkflowTimingEvaluationArtifact;
|
|
283
|
+
};
|
|
284
|
+
export type WorkflowTimingRunProjection = {
|
|
285
|
+
runUuid: string;
|
|
286
|
+
state: string;
|
|
287
|
+
corrected: boolean;
|
|
288
|
+
startedAt?: string;
|
|
289
|
+
finishedAt?: string;
|
|
290
|
+
occurredAt?: string;
|
|
291
|
+
receiptAt: string;
|
|
292
|
+
dimensions: Record<string, string>;
|
|
293
|
+
attempts: WorkflowTimingAttempt[];
|
|
294
|
+
appliedLedgerId: number;
|
|
295
|
+
openAttempts: number;
|
|
296
|
+
};
|
|
297
|
+
export type WorkflowTimingRunDuration = {
|
|
298
|
+
valueMs: number;
|
|
299
|
+
baselineMs: number;
|
|
300
|
+
startedAt: string;
|
|
301
|
+
finishedAt: string;
|
|
302
|
+
};
|
|
303
|
+
export type WorkflowTimingStepDuration = {
|
|
304
|
+
stepKey: string;
|
|
305
|
+
attempt: number;
|
|
306
|
+
valueMs: number;
|
|
307
|
+
baselineMs: number;
|
|
308
|
+
startedAt: string;
|
|
309
|
+
finishedAt: string;
|
|
310
|
+
receiptAt: string;
|
|
311
|
+
};
|
|
312
|
+
export type WorkflowTimingExcludedStep = {
|
|
313
|
+
stepKey: string;
|
|
314
|
+
attempt: number;
|
|
315
|
+
outcome: string;
|
|
316
|
+
};
|
|
317
|
+
export type WorkflowTimingDurationProjection = {
|
|
318
|
+
runEligible: boolean;
|
|
319
|
+
run: WorkflowTimingRunDuration;
|
|
320
|
+
steps: WorkflowTimingStepDuration[];
|
|
321
|
+
excluded: WorkflowTimingExcludedStep[];
|
|
322
|
+
activeMs: number;
|
|
323
|
+
waitMs: number;
|
|
324
|
+
openAttempts: number;
|
|
325
|
+
};
|
|
326
|
+
/** What one deterministic projection rebuild produced. */
|
|
327
|
+
export type WorkflowTimingRebuildResult = {
|
|
328
|
+
runUuid: string;
|
|
329
|
+
workflowKey: string;
|
|
330
|
+
externalRunId: string;
|
|
331
|
+
facts: number;
|
|
332
|
+
status: WorkflowTimingProjectionStatus;
|
|
333
|
+
observationsWritten: number;
|
|
334
|
+
projection: WorkflowTimingRunProjection;
|
|
335
|
+
durations: WorkflowTimingDurationProjection;
|
|
336
|
+
};
|
|
337
|
+
/** Optional narrowing for a run list. */
|
|
338
|
+
export type WorkflowTimingRunListQuery = {
|
|
339
|
+
workflowKey?: string;
|
|
340
|
+
limit?: number;
|
|
341
|
+
};
|
|
342
|
+
type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
343
|
+
export declare class WorkflowTimingAdminClient {
|
|
344
|
+
private readonly request;
|
|
345
|
+
constructor(request: AdminRequester);
|
|
346
|
+
/** Declaratively applies one workflow shape, keyed by its workflowKey. */
|
|
347
|
+
reconcileDefinition(companySlug: string, declaration: WorkflowTimingDeclaration, options?: RequestOptions): Promise<WorkflowTimingReconcileResult>;
|
|
348
|
+
listDefinitions(companySlug: string, limit?: number, options?: RequestOptions): Promise<WorkflowTimingDefinitionList>;
|
|
349
|
+
getDefinition(companySlug: string, workflowKey: string, options?: RequestOptions): Promise<WorkflowTimingDefinition>;
|
|
350
|
+
/** Records one observed fact. Read the result's `accepted`, not the transport status. */
|
|
351
|
+
appendObservation(companySlug: string, observation: WorkflowTimingObservation, options?: RequestOptions): Promise<WorkflowTimingBatchResult>;
|
|
352
|
+
/** Records a bounded batch (10,000 facts, 1 MiB). Replay a failed request with the same idempotency keys. */
|
|
353
|
+
appendObservations(companySlug: string, observations: WorkflowTimingObservation[], options?: RequestOptions): Promise<WorkflowTimingBatchResult>;
|
|
354
|
+
/** Appends a fact that supersedes an accepted one; the observation must name `supersedesFactUuid`. */
|
|
355
|
+
correctObservation(companySlug: string, observation: WorkflowTimingObservation, options?: RequestOptions): Promise<WorkflowTimingBatchResult>;
|
|
356
|
+
/** Lists observed runs, newest first. The server filters by workflow before it limits. */
|
|
357
|
+
listRuns(companySlug: string, query?: WorkflowTimingRunListQuery, options?: RequestOptions): Promise<WorkflowTimingRunList>;
|
|
358
|
+
getRun(companySlug: string, runUuid: string, options?: RequestOptions): Promise<WorkflowTimingRun>;
|
|
359
|
+
/** Reads the evidence-backed completion expectation for one run. */
|
|
360
|
+
getPrediction(companySlug: string, runUuid: string, options?: RequestOptions): Promise<WorkflowTimingPrediction>;
|
|
361
|
+
getDurationHistory(companySlug: string, workflowKey: string, limit?: number, options?: RequestOptions): Promise<WorkflowTimingDurationHistory>;
|
|
362
|
+
getEvaluation(companySlug: string, workflowKey: string, seriesKey?: string, options?: RequestOptions): Promise<WorkflowTimingEvaluation>;
|
|
363
|
+
/** Rebuilds one run's projection from its ledger: the repair path when its status reports pending facts. */
|
|
364
|
+
rebuildRun(companySlug: string, runUuid: string, options?: RequestOptions): Promise<WorkflowTimingRebuildResult>;
|
|
365
|
+
private append;
|
|
366
|
+
}
|
|
367
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow timings: facts another system observed about its own work. Custd is not the
|
|
3
|
+
* controller: the caller keeps its own lifecycle and reports what it observed after its own
|
|
4
|
+
* commit. Every append is idempotent through the caller's deterministic key, and a 200 answer
|
|
5
|
+
* is not a durable append: read each result's `accepted`.
|
|
6
|
+
*/
|
|
7
|
+
/** Expectation states. Only `ready` may be presented as a forecast; a cold start must look different. */
|
|
8
|
+
export const WORKFLOW_TIMING_STATES = {
|
|
9
|
+
ready: "ready",
|
|
10
|
+
coldStart: "cold_start",
|
|
11
|
+
sparse: "sparse",
|
|
12
|
+
stale: "stale",
|
|
13
|
+
partial: "partial",
|
|
14
|
+
unavailable: "unavailable",
|
|
15
|
+
error: "error",
|
|
16
|
+
};
|
|
17
|
+
/** The observed fact kinds. */
|
|
18
|
+
export const WORKFLOW_TIMING_FACT_KINDS = {
|
|
19
|
+
runStarted: "run_started",
|
|
20
|
+
runFinished: "run_finished",
|
|
21
|
+
stepStarted: "step_started",
|
|
22
|
+
stepFinished: "step_finished",
|
|
23
|
+
};
|
|
24
|
+
export class WorkflowTimingAdminClient {
|
|
25
|
+
constructor(request) {
|
|
26
|
+
this.request = request;
|
|
27
|
+
}
|
|
28
|
+
/** Declaratively applies one workflow shape, keyed by its workflowKey. */
|
|
29
|
+
reconcileDefinition(companySlug, declaration, options) {
|
|
30
|
+
const path = timingPath(`/definitions/${encodeURIComponent(declaration.workflowKey)}`, companySlug);
|
|
31
|
+
return this.request("PUT", path, declaration, options).then((result) => ({
|
|
32
|
+
...result,
|
|
33
|
+
definition: definition(result.definition),
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
async listDefinitions(companySlug, limit, options) {
|
|
37
|
+
const path = timingPath("/definitions", companySlug, { limit });
|
|
38
|
+
const list = await this.request("GET", path, undefined, options);
|
|
39
|
+
return { items: (list.items ?? []).map(definition) };
|
|
40
|
+
}
|
|
41
|
+
async getDefinition(companySlug, workflowKey, options) {
|
|
42
|
+
const path = timingPath(`/definitions/${encodeURIComponent(workflowKey)}`, companySlug);
|
|
43
|
+
return definition(await this.request("GET", path, undefined, options));
|
|
44
|
+
}
|
|
45
|
+
/** Records one observed fact. Read the result's `accepted`, not the transport status. */
|
|
46
|
+
appendObservation(companySlug, observation, options) {
|
|
47
|
+
return this.append("/observations", companySlug, { observation }, options);
|
|
48
|
+
}
|
|
49
|
+
/** Records a bounded batch (10,000 facts, 1 MiB). Replay a failed request with the same idempotency keys. */
|
|
50
|
+
appendObservations(companySlug, observations, options) {
|
|
51
|
+
return this.append("/observations:batch", companySlug, { observations }, options);
|
|
52
|
+
}
|
|
53
|
+
/** Appends a fact that supersedes an accepted one; the observation must name `supersedesFactUuid`. */
|
|
54
|
+
correctObservation(companySlug, observation, options) {
|
|
55
|
+
return this.append("/corrections", companySlug, { observation }, options);
|
|
56
|
+
}
|
|
57
|
+
/** Lists observed runs, newest first. The server filters by workflow before it limits. */
|
|
58
|
+
async listRuns(companySlug, query = {}, options) {
|
|
59
|
+
const path = timingPath("/runs", companySlug, { workflowKey: query.workflowKey, limit: query.limit });
|
|
60
|
+
const list = await this.request("GET", path, undefined, options);
|
|
61
|
+
return { items: list.items ?? [] };
|
|
62
|
+
}
|
|
63
|
+
async getRun(companySlug, runUuid, options) {
|
|
64
|
+
const path = timingPath(`/runs/${encodeURIComponent(runUuid)}`, companySlug);
|
|
65
|
+
const run = await this.request("GET", path, undefined, options);
|
|
66
|
+
return { ...run, attempts: run.attempts ?? [] };
|
|
67
|
+
}
|
|
68
|
+
/** Reads the evidence-backed completion expectation for one run. */
|
|
69
|
+
async getPrediction(companySlug, runUuid, options) {
|
|
70
|
+
const path = timingPath(`/runs/${encodeURIComponent(runUuid)}/prediction`, companySlug);
|
|
71
|
+
const prediction = await this.request("GET", path, undefined, options);
|
|
72
|
+
return { ...prediction, run: expectation(prediction.run), steps: (prediction.steps ?? []).map(expectation) };
|
|
73
|
+
}
|
|
74
|
+
async getDurationHistory(companySlug, workflowKey, limit, options) {
|
|
75
|
+
const path = timingPath(`/definitions/${encodeURIComponent(workflowKey)}/duration-history`, companySlug, { limit });
|
|
76
|
+
const history = await this.request("GET", path, undefined, options);
|
|
77
|
+
return { ...history, entries: history.entries ?? [], contributions: history.contributions ?? [] };
|
|
78
|
+
}
|
|
79
|
+
getEvaluation(companySlug, workflowKey, seriesKey, options) {
|
|
80
|
+
const path = timingPath(`/definitions/${encodeURIComponent(workflowKey)}/evaluation`, companySlug, { seriesKey });
|
|
81
|
+
return this.request("GET", path, undefined, options);
|
|
82
|
+
}
|
|
83
|
+
/** Rebuilds one run's projection from its ledger: the repair path when its status reports pending facts. */
|
|
84
|
+
async rebuildRun(companySlug, runUuid, options) {
|
|
85
|
+
const path = timingPath(`/runs/${encodeURIComponent(runUuid)}/rebuild`, companySlug);
|
|
86
|
+
return rebuildResult(await this.request("POST", path, undefined, options));
|
|
87
|
+
}
|
|
88
|
+
async append(route, companySlug, body, options) {
|
|
89
|
+
const result = await this.request("POST", timingPath(route, companySlug), body, options);
|
|
90
|
+
return { ...result, results: result.results ?? [] };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function timingPath(route, companySlug, query = {}) {
|
|
94
|
+
const params = new URLSearchParams({ companySlug });
|
|
95
|
+
for (const [key, value] of Object.entries(query)) {
|
|
96
|
+
if (value !== undefined && value !== "")
|
|
97
|
+
params.set(key, String(value));
|
|
98
|
+
}
|
|
99
|
+
return `/workflow-timings${route}?${params.toString()}`;
|
|
100
|
+
}
|
|
101
|
+
function definition(value) {
|
|
102
|
+
const revision = value.currentRevision;
|
|
103
|
+
return {
|
|
104
|
+
...value,
|
|
105
|
+
currentRevision: { ...revision, dimensions: revision.dimensions ?? [], steps: revision.steps ?? [] },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function expectation(value) {
|
|
109
|
+
return { ...value, warnings: value.warnings ?? [] };
|
|
110
|
+
}
|
|
111
|
+
function rebuildResult(value) {
|
|
112
|
+
return {
|
|
113
|
+
...value,
|
|
114
|
+
projection: { ...value.projection, attempts: value.projection.attempts ?? [] },
|
|
115
|
+
durations: { ...value.durations, steps: value.durations.steps ?? [], excluded: value.durations.excluded ?? [] },
|
|
116
|
+
};
|
|
117
|
+
}
|