@haakco/custd-sdk 0.0.0-stage → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +412 -2
- package/dist/admin-client-setup.d.ts +100 -0
- package/dist/admin-client-setup.js +398 -0
- package/dist/admin-data-labels.d.ts +124 -0
- package/dist/admin-data-labels.js +51 -0
- package/dist/admin-offboarding.d.ts +109 -0
- package/dist/admin-offboarding.js +108 -0
- package/dist/admin-predictions.d.ts +147 -0
- package/dist/admin-predictions.js +83 -0
- package/dist/admin-privacy-erasures.d.ts +62 -0
- package/dist/admin-privacy-erasures.js +72 -0
- package/dist/admin-retention.d.ts +51 -0
- package/dist/admin-retention.js +35 -0
- package/dist/admin-subject-exports.d.ts +48 -0
- package/dist/admin-subject-exports.js +28 -0
- package/dist/admin-tenant-storage.d.ts +27 -0
- package/dist/admin-tenant-storage.js +25 -0
- package/dist/admin-timeplans.d.ts +238 -0
- package/dist/admin-timeplans.js +146 -0
- package/dist/analytics-events.d.ts +85 -0
- package/dist/analytics-events.js +40 -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-BvgjdZSO.js +429 -0
- package/dist/browser-script.d.ts +1 -0
- package/dist/browser-script.js +5 -0
- package/dist/browser-tracker.d.ts +47 -0
- package/dist/browser-tracker.js +453 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.js +1 -0
- package/dist/fixtures.d.ts +10 -0
- package/dist/fixtures.js +57 -0
- package/dist/index.d.ts +1310 -0
- package/dist/index.js +1706 -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/reporting-state.d.ts +46 -0
- package/dist/reporting-state.js +76 -0
- package/dist/runtime-readiness.d.ts +30 -0
- package/dist/runtime-readiness.js +150 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.js +10 -0
- package/package.json +46 -4
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// OffboardingClient owns the offboarding schedule and one-off request
|
|
2
|
+
// surfaces. Its types mirror the current admin-api JSON wire contract.
|
|
3
|
+
function mapPreview(response) {
|
|
4
|
+
return {
|
|
5
|
+
...response,
|
|
6
|
+
stores: response.stores.map((store) => ({
|
|
7
|
+
store: store.store,
|
|
8
|
+
kind: store.kind,
|
|
9
|
+
retentionClass: store.retention_class,
|
|
10
|
+
estimatedCount: store.estimated_count,
|
|
11
|
+
...(store.source_authority ? { sourceAuthority: store.source_authority } : {}),
|
|
12
|
+
})),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function mapReceipt(response) {
|
|
16
|
+
return {
|
|
17
|
+
companyId: response.company_id,
|
|
18
|
+
requestedByActor: response.requested_by_actor,
|
|
19
|
+
requestedByUserId: response.requested_by_user_id,
|
|
20
|
+
requestedAt: response.requested_at,
|
|
21
|
+
completedAt: response.completed_at,
|
|
22
|
+
finalState: response.final_state,
|
|
23
|
+
perStore: response.per_store.map((store) => ({
|
|
24
|
+
store: store.store,
|
|
25
|
+
retentionClass: store.retention_class,
|
|
26
|
+
deletedCount: store.deleted_count,
|
|
27
|
+
retainedExceptionsCount: store.retained_exceptions_count,
|
|
28
|
+
})),
|
|
29
|
+
waiver: response.waiver,
|
|
30
|
+
sha256: response.sha256,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export class OffboardingClient {
|
|
34
|
+
constructor(request, downloadBinary) {
|
|
35
|
+
this.request = request;
|
|
36
|
+
this.downloadBinary = downloadBinary;
|
|
37
|
+
}
|
|
38
|
+
// schedule writes a delayed offboarding schedule. tenantSlug is required and
|
|
39
|
+
// must match the authenticated tenant scope.
|
|
40
|
+
schedule(body, options) {
|
|
41
|
+
return this.request("POST", "/offboarding/schedules", body, options);
|
|
42
|
+
}
|
|
43
|
+
listSchedules(options) {
|
|
44
|
+
return this.request("GET", "/offboarding/schedules", undefined, options);
|
|
45
|
+
}
|
|
46
|
+
// getSchedule reads the delayed offboarding schedule for a single tenant.
|
|
47
|
+
// It targets the per-tenant route GET /offboarding/schedules/{tenantSlug},
|
|
48
|
+
// which is distinct from the global listSchedules collection read.
|
|
49
|
+
getSchedule(tenantSlug, options) {
|
|
50
|
+
return this.request("GET", `/offboarding/schedules/${encodeURIComponent(tenantSlug)}`, undefined, options);
|
|
51
|
+
}
|
|
52
|
+
cancelSchedule(tenantSlug, body, options) {
|
|
53
|
+
return this.request("POST", `/offboarding/schedules/${encodeURIComponent(tenantSlug)}/cancel`, body, options);
|
|
54
|
+
}
|
|
55
|
+
// request submits a one-off offboarding request for the effective tenant
|
|
56
|
+
// via POST /offboarding. The confirmation field must match the tenant
|
|
57
|
+
// slug the server reads from the auth context; mismatches fail with 400.
|
|
58
|
+
requestOffboarding(body, options) {
|
|
59
|
+
return this.request("POST", "/offboarding", body, options);
|
|
60
|
+
}
|
|
61
|
+
getRequest(requestUuid, options) {
|
|
62
|
+
return this.request("GET", `/offboarding/${encodeURIComponent(requestUuid)}`, undefined, options);
|
|
63
|
+
}
|
|
64
|
+
cancelRequest(requestUuid, body, options) {
|
|
65
|
+
return this.request("POST", `/offboarding/${encodeURIComponent(requestUuid)}/cancel`, body, options);
|
|
66
|
+
}
|
|
67
|
+
confirmRequest(requestUuid, options) {
|
|
68
|
+
return this.request("POST", `/offboarding/${encodeURIComponent(requestUuid)}/confirm`, undefined, options);
|
|
69
|
+
}
|
|
70
|
+
// preview asks the server to compute the per-store inventory estimate for
|
|
71
|
+
// the offboarding request. The result is server-issued and must be
|
|
72
|
+
// surfaced verbatim; the SDK must not re-derive estimatedCount.
|
|
73
|
+
async preview(requestUuid, options) {
|
|
74
|
+
const response = await this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/preview`, undefined, options);
|
|
75
|
+
return mapPreview(response);
|
|
76
|
+
}
|
|
77
|
+
// export triggers the destructive export packaging for a request. The
|
|
78
|
+
// response is the per-request artifact metadata; the download URL is
|
|
79
|
+
// fetched separately via download.
|
|
80
|
+
export(requestUuid, options) {
|
|
81
|
+
return this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/export`, undefined, options);
|
|
82
|
+
}
|
|
83
|
+
// download returns authenticated bytes with verified checksum and length.
|
|
84
|
+
download(requestUuid, options) {
|
|
85
|
+
return this.downloadBinary(`/offboarding/requests/${encodeURIComponent(requestUuid)}/download`, options);
|
|
86
|
+
}
|
|
87
|
+
// acknowledge records that the export was downloaded successfully and its
|
|
88
|
+
// inventory was confirmed. Never call it merely because preview succeeded.
|
|
89
|
+
acknowledge(requestUuid, options) {
|
|
90
|
+
return this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/acknowledge`, undefined, options);
|
|
91
|
+
}
|
|
92
|
+
// execute triggers the destructive phase. Approval is server-owned and the
|
|
93
|
+
// request intentionally has no caller-controlled body.
|
|
94
|
+
execute(requestUuid, options) {
|
|
95
|
+
return this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/execute`, undefined, options).then(mapReceipt);
|
|
96
|
+
}
|
|
97
|
+
// retry re-arms an offboarding request that previously failed. The server
|
|
98
|
+
// decides whether the request is retryable; the SDK does not pre-filter.
|
|
99
|
+
retry(requestUuid, options) {
|
|
100
|
+
return this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/retry`, undefined, options).then(mapReceipt);
|
|
101
|
+
}
|
|
102
|
+
// receipt returns the terminal offboarding receipt for a request. The
|
|
103
|
+
// sha256 is an unkeyed integrity checksum the client must retain alongside
|
|
104
|
+
// its offboarding record; it is not an authenticity signature.
|
|
105
|
+
receipt(requestUuid, options) {
|
|
106
|
+
return this.request("GET", `/offboarding/requests/${encodeURIComponent(requestUuid)}/receipt`, undefined, options).then(mapReceipt);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { RequestOptions } from "./index.js";
|
|
2
|
+
export type PredictionDefinition = {
|
|
3
|
+
uuid: string;
|
|
4
|
+
definition_key: string;
|
|
5
|
+
display_name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
status: string;
|
|
8
|
+
schedule_kind: string;
|
|
9
|
+
default_horizon_seconds?: number;
|
|
10
|
+
is_paused: boolean;
|
|
11
|
+
created_at: string;
|
|
12
|
+
updated_at: string;
|
|
13
|
+
};
|
|
14
|
+
export type PredictionDefinitionCreateRequest = {
|
|
15
|
+
definition_key: string;
|
|
16
|
+
display_name: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
};
|
|
19
|
+
export type PredictionDefinitionUpdateRequest = {
|
|
20
|
+
definition_key?: string;
|
|
21
|
+
display_name?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
revision: number;
|
|
24
|
+
};
|
|
25
|
+
export type PredictionDefinitionListResponse = {
|
|
26
|
+
items: PredictionDefinition[];
|
|
27
|
+
next_page_token?: string;
|
|
28
|
+
};
|
|
29
|
+
export type PredictionVersion = {
|
|
30
|
+
uuid: string;
|
|
31
|
+
version_uuid: string;
|
|
32
|
+
version_number: number;
|
|
33
|
+
version_status: string;
|
|
34
|
+
definition_hash: string;
|
|
35
|
+
definition: Record<string, unknown>;
|
|
36
|
+
feature_count: number;
|
|
37
|
+
source_count: number;
|
|
38
|
+
created_by: string;
|
|
39
|
+
created_at: string;
|
|
40
|
+
};
|
|
41
|
+
export type PredictionVersionPublishRequest = {
|
|
42
|
+
definition: Record<string, unknown>;
|
|
43
|
+
created_by: string;
|
|
44
|
+
};
|
|
45
|
+
export type PredictionActivateRequest = {
|
|
46
|
+
version_uuid: string;
|
|
47
|
+
};
|
|
48
|
+
export type PredictionRollbackRequest = {
|
|
49
|
+
version_uuid: string;
|
|
50
|
+
reason?: string;
|
|
51
|
+
};
|
|
52
|
+
export type PredictionPauseRequest = {
|
|
53
|
+
reason?: string;
|
|
54
|
+
};
|
|
55
|
+
export type PredictionRunNowRequest = {
|
|
56
|
+
worker_id?: string;
|
|
57
|
+
};
|
|
58
|
+
export type PredictionSignalSource = {
|
|
59
|
+
uuid: string;
|
|
60
|
+
source_key: string;
|
|
61
|
+
source_mode: string;
|
|
62
|
+
display_name: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
poll_interval_seconds?: number;
|
|
65
|
+
source_status: string;
|
|
66
|
+
is_paused: boolean;
|
|
67
|
+
created_at: string;
|
|
68
|
+
updated_at: string;
|
|
69
|
+
last_succeeded_at?: string;
|
|
70
|
+
consecutive_failed_count: number;
|
|
71
|
+
};
|
|
72
|
+
export type PredictionSignalSourceCreateRequest = {
|
|
73
|
+
source_key: string;
|
|
74
|
+
source_mode: string;
|
|
75
|
+
display_name: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
configuration: Record<string, unknown>;
|
|
78
|
+
poll_interval_seconds?: number;
|
|
79
|
+
};
|
|
80
|
+
export type PredictionRunSummary = {
|
|
81
|
+
run_uuid: string;
|
|
82
|
+
as_of_at: string;
|
|
83
|
+
horizon_end_at: string;
|
|
84
|
+
output: number;
|
|
85
|
+
baseline: number;
|
|
86
|
+
override_applied: boolean;
|
|
87
|
+
input_hash: string;
|
|
88
|
+
engine_version: string;
|
|
89
|
+
warning_count: number;
|
|
90
|
+
generated_at: string;
|
|
91
|
+
duration_milliseconds?: number;
|
|
92
|
+
};
|
|
93
|
+
export type PredictionOutcomeSummary = {
|
|
94
|
+
run_uuid: string;
|
|
95
|
+
resolution: string;
|
|
96
|
+
outcome_kind: string;
|
|
97
|
+
resolved_at?: string;
|
|
98
|
+
observed_value: number;
|
|
99
|
+
is_late_evidence: boolean;
|
|
100
|
+
};
|
|
101
|
+
export type PredictionEvaluationSummary = {
|
|
102
|
+
window_start_at: string;
|
|
103
|
+
window_end_at: string;
|
|
104
|
+
resolved_run_count: number;
|
|
105
|
+
positive_count: number;
|
|
106
|
+
negative_count: number;
|
|
107
|
+
brier_score?: number;
|
|
108
|
+
log_loss?: number;
|
|
109
|
+
sparse_bucket_count: number;
|
|
110
|
+
};
|
|
111
|
+
export type PredictionThresholdEvent = {
|
|
112
|
+
version_uuid: string;
|
|
113
|
+
hysteresis_state: string;
|
|
114
|
+
direction: string;
|
|
115
|
+
observed_value: number;
|
|
116
|
+
threshold: number;
|
|
117
|
+
trigger_run_uuid: string;
|
|
118
|
+
dedup_key: string;
|
|
119
|
+
emitted_at: string;
|
|
120
|
+
};
|
|
121
|
+
type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
122
|
+
export declare class PredictionAdminClient {
|
|
123
|
+
private readonly request;
|
|
124
|
+
constructor(request: AdminRequester);
|
|
125
|
+
listDefinitions(companySlug: string, pageSize?: number, pageToken?: string, options?: RequestOptions): Promise<PredictionDefinitionListResponse>;
|
|
126
|
+
getDefinition(companySlug: string, definitionUuid: string, options?: RequestOptions): Promise<PredictionDefinition>;
|
|
127
|
+
createDefinition(companySlug: string, body: PredictionDefinitionCreateRequest, options?: RequestOptions): Promise<PredictionDefinition>;
|
|
128
|
+
updateDefinition(companySlug: string, definitionUuid: string, body: PredictionDefinitionUpdateRequest, options?: RequestOptions): Promise<PredictionDefinition>;
|
|
129
|
+
getVersion(companySlug: string, definitionUuid: string, versionUuid: string, options?: RequestOptions): Promise<PredictionVersion>;
|
|
130
|
+
publishVersion(companySlug: string, definitionUuid: string, body: PredictionVersionPublishRequest, options?: RequestOptions): Promise<PredictionVersion>;
|
|
131
|
+
activateVersion(companySlug: string, definitionUuid: string, body: PredictionActivateRequest, options?: RequestOptions): Promise<PredictionVersion>;
|
|
132
|
+
rollbackVersion(companySlug: string, definitionUuid: string, body: PredictionRollbackRequest, options?: RequestOptions): Promise<PredictionVersion>;
|
|
133
|
+
pauseDefinition(companySlug: string, definitionUuid: string, body?: PredictionPauseRequest, options?: RequestOptions): Promise<void>;
|
|
134
|
+
resumeDefinition(companySlug: string, definitionUuid: string, options?: RequestOptions): Promise<void>;
|
|
135
|
+
archiveDefinition(companySlug: string, definitionUuid: string, options?: RequestOptions): Promise<void>;
|
|
136
|
+
runNow(companySlug: string, definitionUuid: string, body?: PredictionRunNowRequest, options?: RequestOptions): Promise<void>;
|
|
137
|
+
listRuns(companySlug: string, definitionUuid: string, pageSize?: number, options?: RequestOptions): Promise<PredictionRunSummary[]>;
|
|
138
|
+
listOutcomes(companySlug: string, definitionUuid: string, pageSize?: number, options?: RequestOptions): Promise<PredictionOutcomeSummary[]>;
|
|
139
|
+
getEvaluation(companySlug: string, definitionUuid: string, options?: RequestOptions): Promise<PredictionEvaluationSummary>;
|
|
140
|
+
listThresholdEvents(companySlug: string, definitionUuid: string, pageSize?: number, options?: RequestOptions): Promise<PredictionThresholdEvent[]>;
|
|
141
|
+
listSignalSources(companySlug: string, pageSize?: number, pageToken?: string, options?: RequestOptions): Promise<PredictionSignalSource[]>;
|
|
142
|
+
getSignalSource(companySlug: string, sourceUuid: string, options?: RequestOptions): Promise<PredictionSignalSource>;
|
|
143
|
+
createSignalSource(companySlug: string, body: PredictionSignalSourceCreateRequest, options?: RequestOptions): Promise<PredictionSignalSource>;
|
|
144
|
+
activateSignalSource(companySlug: string, sourceUuid: string, options?: RequestOptions): Promise<void>;
|
|
145
|
+
archiveSignalSource(companySlug: string, sourceUuid: string, options?: RequestOptions): Promise<void>;
|
|
146
|
+
}
|
|
147
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export class PredictionAdminClient {
|
|
2
|
+
constructor(request) {
|
|
3
|
+
this.request = request;
|
|
4
|
+
}
|
|
5
|
+
listDefinitions(companySlug, pageSize, pageToken, options) {
|
|
6
|
+
return this.request("GET", collectionPath("/definitions", companySlug, pageSize, pageToken), undefined, options);
|
|
7
|
+
}
|
|
8
|
+
getDefinition(companySlug, definitionUuid, options) {
|
|
9
|
+
return this.request("GET", resourcePath(`/definitions/${definitionUuid}`, companySlug), undefined, options);
|
|
10
|
+
}
|
|
11
|
+
createDefinition(companySlug, body, options) {
|
|
12
|
+
return this.request("POST", collectionPath("/definitions", companySlug), body, options);
|
|
13
|
+
}
|
|
14
|
+
updateDefinition(companySlug, definitionUuid, body, options) {
|
|
15
|
+
return this.request("PATCH", resourcePath(`/definitions/${definitionUuid}`, companySlug), body, options);
|
|
16
|
+
}
|
|
17
|
+
getVersion(companySlug, definitionUuid, versionUuid, options) {
|
|
18
|
+
return this.request("GET", resourcePath(`/definitions/${definitionUuid}/versions/${versionUuid}`, companySlug), undefined, options);
|
|
19
|
+
}
|
|
20
|
+
publishVersion(companySlug, definitionUuid, body, options) {
|
|
21
|
+
return this.request("POST", resourcePath(`/definitions/${definitionUuid}/publish`, companySlug), body, options);
|
|
22
|
+
}
|
|
23
|
+
activateVersion(companySlug, definitionUuid, body, options) {
|
|
24
|
+
return this.request("POST", resourcePath(`/definitions/${definitionUuid}/activate`, companySlug), body, options);
|
|
25
|
+
}
|
|
26
|
+
rollbackVersion(companySlug, definitionUuid, body, options) {
|
|
27
|
+
return this.request("POST", resourcePath(`/definitions/${definitionUuid}/rollback`, companySlug), body, options);
|
|
28
|
+
}
|
|
29
|
+
pauseDefinition(companySlug, definitionUuid, body = {}, options) {
|
|
30
|
+
return this.request("POST", resourcePath(`/definitions/${definitionUuid}/pause`, companySlug), body, options);
|
|
31
|
+
}
|
|
32
|
+
resumeDefinition(companySlug, definitionUuid, options) {
|
|
33
|
+
return this.request("POST", resourcePath(`/definitions/${definitionUuid}/resume`, companySlug), undefined, options);
|
|
34
|
+
}
|
|
35
|
+
archiveDefinition(companySlug, definitionUuid, options) {
|
|
36
|
+
return this.request("POST", resourcePath(`/definitions/${definitionUuid}/archive`, companySlug), undefined, options);
|
|
37
|
+
}
|
|
38
|
+
runNow(companySlug, definitionUuid, body = {}, options) {
|
|
39
|
+
return this.request("POST", resourcePath(`/definitions/${definitionUuid}/run-now`, companySlug), body, options);
|
|
40
|
+
}
|
|
41
|
+
listRuns(companySlug, definitionUuid, pageSize, options) {
|
|
42
|
+
return this.request("GET", collectionPath(`/definitions/${definitionUuid}/runs`, companySlug, pageSize), undefined, options);
|
|
43
|
+
}
|
|
44
|
+
listOutcomes(companySlug, definitionUuid, pageSize, options) {
|
|
45
|
+
return this.request("GET", collectionPath(`/definitions/${definitionUuid}/outcomes`, companySlug, pageSize), undefined, options);
|
|
46
|
+
}
|
|
47
|
+
getEvaluation(companySlug, definitionUuid, options) {
|
|
48
|
+
return this.request("GET", resourcePath(`/definitions/${definitionUuid}/evaluations`, companySlug), undefined, options);
|
|
49
|
+
}
|
|
50
|
+
listThresholdEvents(companySlug, definitionUuid, pageSize, options) {
|
|
51
|
+
return this.request("GET", collectionPath(`/definitions/${definitionUuid}/threshold-events`, companySlug, pageSize), undefined, options);
|
|
52
|
+
}
|
|
53
|
+
listSignalSources(companySlug, pageSize, pageToken, options) {
|
|
54
|
+
return this.request("GET", collectionPath("/sources", companySlug, pageSize, pageToken), undefined, options);
|
|
55
|
+
}
|
|
56
|
+
getSignalSource(companySlug, sourceUuid, options) {
|
|
57
|
+
return this.request("GET", resourcePath(`/sources/${sourceUuid}`, companySlug), undefined, options);
|
|
58
|
+
}
|
|
59
|
+
createSignalSource(companySlug, body, options) {
|
|
60
|
+
return this.request("POST", collectionPath("/sources", companySlug), body, options);
|
|
61
|
+
}
|
|
62
|
+
activateSignalSource(companySlug, sourceUuid, options) {
|
|
63
|
+
return this.request("POST", resourcePath(`/sources/${sourceUuid}/activate`, companySlug), undefined, options);
|
|
64
|
+
}
|
|
65
|
+
archiveSignalSource(companySlug, sourceUuid, options) {
|
|
66
|
+
return this.request("POST", resourcePath(`/sources/${sourceUuid}/archive`, companySlug), undefined, options);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function collectionPath(path, companySlug, pageSize, pageToken) {
|
|
70
|
+
const query = new URLSearchParams({ companySlug });
|
|
71
|
+
if (pageSize !== undefined)
|
|
72
|
+
query.set("pageSize", String(pageSize));
|
|
73
|
+
if (pageToken !== undefined)
|
|
74
|
+
query.set("pageToken", pageToken);
|
|
75
|
+
return `/measurement/predictions${path}?${query.toString()}`;
|
|
76
|
+
}
|
|
77
|
+
function resourcePath(path, companySlug) {
|
|
78
|
+
const encodedPath = path
|
|
79
|
+
.split("/")
|
|
80
|
+
.map((segment, index) => (index === 0 ? segment : encodeURIComponent(segment)))
|
|
81
|
+
.join("/");
|
|
82
|
+
return collectionPath(encodedPath, companySlug);
|
|
83
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { RequestOptions } from "./index.js";
|
|
2
|
+
export type PrivacyErasureSelector = {
|
|
3
|
+
type: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export type PrivacyErasureStoreProgress = {
|
|
7
|
+
store: string;
|
|
8
|
+
state: string;
|
|
9
|
+
deletedCount?: number;
|
|
10
|
+
reason?: string;
|
|
11
|
+
};
|
|
12
|
+
export type PrivacyErasure = {
|
|
13
|
+
requestUuid: string;
|
|
14
|
+
status: string;
|
|
15
|
+
state?: string;
|
|
16
|
+
selectorType?: string;
|
|
17
|
+
selectorDisplay?: string;
|
|
18
|
+
perStoreProgress?: PrivacyErasureStoreProgress[];
|
|
19
|
+
createdAt?: string;
|
|
20
|
+
completedAt?: string;
|
|
21
|
+
};
|
|
22
|
+
export type PrivacyErasureCreateRequest = {
|
|
23
|
+
companySlug: string;
|
|
24
|
+
selector: PrivacyErasureSelector;
|
|
25
|
+
reason: string;
|
|
26
|
+
redactionId: string;
|
|
27
|
+
forceNow?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type PrivacyErasureListResponse = {
|
|
30
|
+
requests: PrivacyErasure[];
|
|
31
|
+
};
|
|
32
|
+
export type PrivacyErasureState = {
|
|
33
|
+
request?: PrivacyErasure;
|
|
34
|
+
safe_next_action?: string;
|
|
35
|
+
safe_next_action_code?: string;
|
|
36
|
+
};
|
|
37
|
+
export type PrivacyErasureWaitOptions = RequestOptions & {
|
|
38
|
+
maxPolls?: number;
|
|
39
|
+
pollIntervalMs?: number;
|
|
40
|
+
onProgress?: (request: PrivacyErasure) => void | Promise<void>;
|
|
41
|
+
};
|
|
42
|
+
export type PrivacyErasureRetryClassification = "retryable" | "non_retryable";
|
|
43
|
+
export declare class PrivacyErasureError extends Error {
|
|
44
|
+
readonly code: string;
|
|
45
|
+
readonly retryClassification: PrivacyErasureRetryClassification;
|
|
46
|
+
readonly retryable: boolean;
|
|
47
|
+
constructor(code: string, retryClassification: PrivacyErasureRetryClassification, message: string);
|
|
48
|
+
}
|
|
49
|
+
type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
50
|
+
export declare class PrivacyErasureClient {
|
|
51
|
+
private readonly request;
|
|
52
|
+
constructor(request: AdminRequester);
|
|
53
|
+
create(body: PrivacyErasureCreateRequest, options?: RequestOptions): Promise<PrivacyErasure>;
|
|
54
|
+
list(companySlug: string, options?: RequestOptions): Promise<PrivacyErasureListResponse>;
|
|
55
|
+
get(companySlug: string, requestUuid: string, options?: RequestOptions): Promise<PrivacyErasure>;
|
|
56
|
+
force(companySlug: string, requestUuid: string, options?: RequestOptions): Promise<PrivacyErasureState>;
|
|
57
|
+
createAndWait(body: PrivacyErasureCreateRequest, options?: PrivacyErasureWaitOptions): Promise<PrivacyErasure>;
|
|
58
|
+
waitForCompletion(companySlug: string, requestUuid: string, options?: PrivacyErasureWaitOptions & {
|
|
59
|
+
initialRequest?: PrivacyErasure;
|
|
60
|
+
}): Promise<PrivacyErasure>;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// PrivacyErasureClient owns per-tenant subject erasure requests. Erasures
|
|
2
|
+
// are forward-only. This client owns bounded polling and the single supported
|
|
3
|
+
// force-recovery attempt so product integrations do not recreate that workflow.
|
|
4
|
+
export class PrivacyErasureError extends Error {
|
|
5
|
+
constructor(code, retryClassification, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.retryClassification = retryClassification;
|
|
9
|
+
this.name = "PrivacyErasureError";
|
|
10
|
+
this.retryable = retryClassification === "retryable";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class PrivacyErasureClient {
|
|
14
|
+
constructor(request) {
|
|
15
|
+
this.request = request;
|
|
16
|
+
}
|
|
17
|
+
create(body, options) {
|
|
18
|
+
return classifiedRequest(() => this.request("POST", "/privacy/erasures", body, options), "create_request_failed");
|
|
19
|
+
}
|
|
20
|
+
list(companySlug, options) {
|
|
21
|
+
return classifiedRequest(() => this.request("GET", `/privacy/erasures?companySlug=${encodeURIComponent(companySlug)}`, undefined, options), "list_request_failed");
|
|
22
|
+
}
|
|
23
|
+
get(companySlug, requestUuid, options) {
|
|
24
|
+
return classifiedRequest(() => this.request("GET", `/privacy/erasures/${encodeURIComponent(requestUuid)}?companySlug=${encodeURIComponent(companySlug)}`, undefined, options), "get_request_failed");
|
|
25
|
+
}
|
|
26
|
+
force(companySlug, requestUuid, options) {
|
|
27
|
+
return classifiedRequest(() => this.request("POST", `/privacy/erasures/${encodeURIComponent(requestUuid)}/force?companySlug=${encodeURIComponent(companySlug)}`, undefined, options), "force_request_failed");
|
|
28
|
+
}
|
|
29
|
+
async createAndWait(body, options = {}) {
|
|
30
|
+
const created = await this.create(body, options);
|
|
31
|
+
await options.onProgress?.(created);
|
|
32
|
+
return this.waitForCompletion(body.companySlug, created.requestUuid, { ...options, initialRequest: created });
|
|
33
|
+
}
|
|
34
|
+
async waitForCompletion(companySlug, requestUuid, options = {}) {
|
|
35
|
+
const maxPolls = options.maxPolls ?? 60;
|
|
36
|
+
const pollIntervalMs = options.pollIntervalMs ?? 1000;
|
|
37
|
+
let current = options.initialRequest;
|
|
38
|
+
let forced = false;
|
|
39
|
+
for (let poll = 0; poll < maxPolls; poll += 1) {
|
|
40
|
+
if (!current || poll > 0 || options.initialRequest) {
|
|
41
|
+
if (pollIntervalMs > 0)
|
|
42
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
43
|
+
current = await this.get(companySlug, requestUuid, options);
|
|
44
|
+
await options.onProgress?.(current);
|
|
45
|
+
}
|
|
46
|
+
if (current.status === "s3_reflected")
|
|
47
|
+
return current;
|
|
48
|
+
if (current.status === "failed" && !forced) {
|
|
49
|
+
const recovery = await this.force(companySlug, requestUuid, options);
|
|
50
|
+
forced = true;
|
|
51
|
+
if (recovery.safe_next_action) {
|
|
52
|
+
const retryable = recovery.safe_next_action === "retry";
|
|
53
|
+
throw new PrivacyErasureError(retryable ? "force_recovery_retry" : "force_recovery_blocked", retryable ? "retryable" : "non_retryable", `Custd privacy erasure recovery blocked (${recovery.safe_next_action_code || "unknown"})`);
|
|
54
|
+
}
|
|
55
|
+
current = recovery.request;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
throw new PrivacyErasureError("poll_timeout", "retryable", "Custd privacy erasure did not complete within the polling limit");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function classifiedRequest(request, code) {
|
|
62
|
+
try {
|
|
63
|
+
return await request();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof PrivacyErasureError)
|
|
67
|
+
throw error;
|
|
68
|
+
const status = error?.problem?.status;
|
|
69
|
+
const retryable = typeof status !== "number" || status === 429 || status >= 500;
|
|
70
|
+
throw new PrivacyErasureError(code, retryable ? "retryable" : "non_retryable", `Custd privacy erasure request failed${typeof status === "number" ? ` (HTTP ${status})` : ""}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { RequestOptions } from "./index.js";
|
|
2
|
+
export type RetentionPolicy = {
|
|
3
|
+
tenantSlug: string;
|
|
4
|
+
maxAgeDays: number;
|
|
5
|
+
hardDeleteAfterDays: number;
|
|
6
|
+
applyToEventTypes: string[];
|
|
7
|
+
applyToDataSpaces: string[];
|
|
8
|
+
};
|
|
9
|
+
export type RetentionPolicyUpsertRequest = {
|
|
10
|
+
maxAgeDays: number;
|
|
11
|
+
hardDeleteAfterDays: number;
|
|
12
|
+
applyToEventTypes?: string[];
|
|
13
|
+
applyToDataSpaces?: string[];
|
|
14
|
+
};
|
|
15
|
+
export type RetentionPolicyListResponse = {
|
|
16
|
+
policies: RetentionPolicy[];
|
|
17
|
+
};
|
|
18
|
+
export type RetentionRunDeletion = {
|
|
19
|
+
store: string;
|
|
20
|
+
count: number;
|
|
21
|
+
};
|
|
22
|
+
export type RetentionRunPreview = {
|
|
23
|
+
previewId: string;
|
|
24
|
+
tenantSlug: string;
|
|
25
|
+
estimatedDeletions: RetentionRunDeletion[];
|
|
26
|
+
previewedAt?: string;
|
|
27
|
+
};
|
|
28
|
+
export type RetentionRun = {
|
|
29
|
+
runId: string;
|
|
30
|
+
tenantSlug: string;
|
|
31
|
+
state: string;
|
|
32
|
+
startedAt?: string;
|
|
33
|
+
completedAt?: string;
|
|
34
|
+
deletedCount?: number;
|
|
35
|
+
};
|
|
36
|
+
export type RetentionRunsListResponse = {
|
|
37
|
+
runs: RetentionRun[];
|
|
38
|
+
};
|
|
39
|
+
type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
40
|
+
export declare class RetentionClient {
|
|
41
|
+
private readonly request;
|
|
42
|
+
constructor(request: AdminRequester);
|
|
43
|
+
list(options?: RequestOptions): Promise<RetentionPolicyListResponse>;
|
|
44
|
+
get(tenantSlug: string, options?: RequestOptions): Promise<RetentionPolicy>;
|
|
45
|
+
upsert(tenantSlug: string, body: RetentionPolicyUpsertRequest, options?: RequestOptions): Promise<RetentionPolicy>;
|
|
46
|
+
delete(tenantSlug: string, options?: RequestOptions): Promise<void>;
|
|
47
|
+
preview(tenantSlug: string, options?: RequestOptions): Promise<RetentionRunPreview>;
|
|
48
|
+
apply(tenantSlug: string, options?: RequestOptions): Promise<RetentionRun>;
|
|
49
|
+
listRuns(tenantSlug: string, options?: RequestOptions): Promise<RetentionRunsListResponse>;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// RetentionClient owns per-tenant retention policies. Effective-tenant
|
|
2
|
+
// authority is enforced server-side; wrong-tenant requests return 404.
|
|
3
|
+
export class RetentionClient {
|
|
4
|
+
constructor(request) {
|
|
5
|
+
this.request = request;
|
|
6
|
+
}
|
|
7
|
+
list(options) {
|
|
8
|
+
return this.request("GET", "/retention/policies", undefined, options);
|
|
9
|
+
}
|
|
10
|
+
get(tenantSlug, options) {
|
|
11
|
+
return this.request("GET", `/retention/policies/${encodeURIComponent(tenantSlug)}`, undefined, options);
|
|
12
|
+
}
|
|
13
|
+
upsert(tenantSlug, body, options) {
|
|
14
|
+
return this.request("PUT", `/retention/policies/${encodeURIComponent(tenantSlug)}`, body, options);
|
|
15
|
+
}
|
|
16
|
+
delete(tenantSlug, options) {
|
|
17
|
+
return this.request("DELETE", `/retention/policies/${encodeURIComponent(tenantSlug)}`, undefined, options);
|
|
18
|
+
}
|
|
19
|
+
// Preview asks the server to compute a deletion estimate without applying
|
|
20
|
+
// it. The estimate is server-issued; the SDK must surface it verbatim and
|
|
21
|
+
// never round or re-derive the per-store counts.
|
|
22
|
+
preview(tenantSlug, options) {
|
|
23
|
+
return this.request("POST", `/retention/policies/${encodeURIComponent(tenantSlug)}/preview`, undefined, options);
|
|
24
|
+
}
|
|
25
|
+
// Apply submits the destructive retention run. The server is the authority
|
|
26
|
+
// for whether deletion actually happens; the SDK must not pre-announce state.
|
|
27
|
+
apply(tenantSlug, options) {
|
|
28
|
+
return this.request("POST", `/retention/policies/${encodeURIComponent(tenantSlug)}/apply`, undefined, options);
|
|
29
|
+
}
|
|
30
|
+
// ListRuns returns the retention runs for a single tenant. Empty runs list
|
|
31
|
+
// is the canonical "no runs yet" response, not an error.
|
|
32
|
+
listRuns(tenantSlug, options) {
|
|
33
|
+
return this.request("GET", `/retention/policies/${encodeURIComponent(tenantSlug)}/runs`, undefined, options);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { RequestOptions } from "./index.js";
|
|
2
|
+
export type SubjectExportSubject = {
|
|
3
|
+
type: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export type SubjectExport = {
|
|
7
|
+
requestId: string;
|
|
8
|
+
tenantSlug: string;
|
|
9
|
+
subject: SubjectExportSubject;
|
|
10
|
+
scope: string;
|
|
11
|
+
state: string;
|
|
12
|
+
createdAt?: string;
|
|
13
|
+
expiresAt?: string;
|
|
14
|
+
checksum?: string;
|
|
15
|
+
artifactSize?: number;
|
|
16
|
+
};
|
|
17
|
+
export type SubjectExportListResponse = {
|
|
18
|
+
exports: SubjectExport[];
|
|
19
|
+
};
|
|
20
|
+
export type SubjectExportCreateRequest = {
|
|
21
|
+
tenantSlug: string;
|
|
22
|
+
subject: SubjectExportSubject;
|
|
23
|
+
scope: string;
|
|
24
|
+
idempotencyKey: string;
|
|
25
|
+
};
|
|
26
|
+
export type SubjectExportDownloadResponse = {
|
|
27
|
+
requestId: string;
|
|
28
|
+
downloadUrl: string;
|
|
29
|
+
expiresAt?: string;
|
|
30
|
+
};
|
|
31
|
+
export type SubjectExportState = {
|
|
32
|
+
requestId: string;
|
|
33
|
+
state: string;
|
|
34
|
+
cancelledAt?: string;
|
|
35
|
+
forcedAt?: string;
|
|
36
|
+
};
|
|
37
|
+
type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
38
|
+
export declare class SubjectExportClient {
|
|
39
|
+
private readonly request;
|
|
40
|
+
constructor(request: AdminRequester);
|
|
41
|
+
create(body: SubjectExportCreateRequest, options?: RequestOptions): Promise<SubjectExport>;
|
|
42
|
+
list(options?: RequestOptions): Promise<SubjectExportListResponse>;
|
|
43
|
+
get(requestId: string, options?: RequestOptions): Promise<SubjectExport>;
|
|
44
|
+
cancel(requestId: string, options?: RequestOptions): Promise<SubjectExportState>;
|
|
45
|
+
download(requestId: string, options?: RequestOptions): Promise<SubjectExportDownloadResponse>;
|
|
46
|
+
force(requestId: string, options?: RequestOptions): Promise<SubjectExportState>;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SubjectExportClient owns per-tenant subject export requests. The download
|
|
2
|
+
// surface returns a short-lived signed URL the SDK must surface only to the
|
|
3
|
+
// caller; it must not be logged or echoed into error messages.
|
|
4
|
+
export class SubjectExportClient {
|
|
5
|
+
constructor(request) {
|
|
6
|
+
this.request = request;
|
|
7
|
+
}
|
|
8
|
+
create(body, options) {
|
|
9
|
+
return this.request("POST", "/subject-exports", body, options);
|
|
10
|
+
}
|
|
11
|
+
list(options) {
|
|
12
|
+
return this.request("GET", "/subject-exports", undefined, options);
|
|
13
|
+
}
|
|
14
|
+
get(requestId, options) {
|
|
15
|
+
return this.request("GET", `/subject-exports/${encodeURIComponent(requestId)}`, undefined, options);
|
|
16
|
+
}
|
|
17
|
+
cancel(requestId, options) {
|
|
18
|
+
return this.request("POST", `/subject-exports/${encodeURIComponent(requestId)}/cancel`, undefined, options);
|
|
19
|
+
}
|
|
20
|
+
// Download returns a short-lived signed URL. The downloadUrl field is
|
|
21
|
+
// sensitive; callers must not log the URL or echo it into error messages.
|
|
22
|
+
download(requestId, options) {
|
|
23
|
+
return this.request("GET", `/subject-exports/${encodeURIComponent(requestId)}/download`, undefined, options);
|
|
24
|
+
}
|
|
25
|
+
force(requestId, options) {
|
|
26
|
+
return this.request("POST", `/subject-exports/${encodeURIComponent(requestId)}/force`, undefined, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RequestOptions } from "./index.js";
|
|
2
|
+
export type TenantStorageLocation = {
|
|
3
|
+
id: string;
|
|
4
|
+
tenantSlug: string;
|
|
5
|
+
clientLocation: string;
|
|
6
|
+
serverAssignedPrefix: string;
|
|
7
|
+
status: string;
|
|
8
|
+
createdAt?: string;
|
|
9
|
+
expiresAt?: string;
|
|
10
|
+
};
|
|
11
|
+
export type TenantStorageListResponse = {
|
|
12
|
+
locations: TenantStorageLocation[];
|
|
13
|
+
};
|
|
14
|
+
export type TenantStorageCreateRequest = {
|
|
15
|
+
tenantSlug?: string;
|
|
16
|
+
clientLocation: string;
|
|
17
|
+
};
|
|
18
|
+
type NonAdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
|
|
19
|
+
export declare class TenantStorageClient {
|
|
20
|
+
private readonly request;
|
|
21
|
+
constructor(request: NonAdminRequester);
|
|
22
|
+
list(options?: RequestOptions): Promise<TenantStorageListResponse>;
|
|
23
|
+
create(body: TenantStorageCreateRequest, options?: RequestOptions): Promise<TenantStorageLocation>;
|
|
24
|
+
get(id: string, options?: RequestOptions): Promise<TenantStorageLocation>;
|
|
25
|
+
revoke(id: string, options?: RequestOptions): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|