@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.
Files changed (196) hide show
  1. package/README.md +958 -2
  2. package/dist/admin-accounting-evidence.d.ts +48 -0
  3. package/dist/admin-accounting-evidence.js +24 -0
  4. package/dist/admin-app-releases.d.ts +116 -0
  5. package/dist/admin-app-releases.js +8 -0
  6. package/dist/admin-apps.d.ts +120 -0
  7. package/dist/admin-apps.js +47 -0
  8. package/dist/admin-auth-project-domain.d.ts +125 -0
  9. package/dist/admin-auth-project-domain.js +37 -0
  10. package/dist/admin-auth-projects.d.ts +989 -0
  11. package/dist/admin-auth-projects.js +527 -0
  12. package/dist/admin-campaign-email.d.ts +120 -0
  13. package/dist/admin-campaign-email.js +64 -0
  14. package/dist/admin-client-setup.d.ts +122 -0
  15. package/dist/admin-client-setup.js +408 -0
  16. package/dist/admin-data-labels.d.ts +124 -0
  17. package/dist/admin-data-labels.js +51 -0
  18. package/dist/admin-data-scopes.d.ts +93 -0
  19. package/dist/admin-data-scopes.js +154 -0
  20. package/dist/admin-email-relay.d.ts +66 -0
  21. package/dist/admin-email-relay.js +25 -0
  22. package/dist/admin-environment-policy.d.ts +32 -0
  23. package/dist/admin-environment-policy.js +26 -0
  24. package/dist/admin-error-issues.d.ts +91 -0
  25. package/dist/admin-error-issues.js +52 -0
  26. package/dist/admin-event-types.d.ts +57 -0
  27. package/dist/admin-event-types.js +28 -0
  28. package/dist/admin-impersonation.d.ts +48 -0
  29. package/dist/admin-impersonation.js +27 -0
  30. package/dist/admin-ingest-claims.d.ts +35 -0
  31. package/dist/admin-ingest-claims.js +26 -0
  32. package/dist/admin-managed-audit.d.ts +13 -0
  33. package/dist/admin-managed-audit.js +13 -0
  34. package/dist/admin-measurement-projects.d.ts +166 -0
  35. package/dist/admin-measurement-projects.js +120 -0
  36. package/dist/admin-notification-destinations.d.ts +31 -0
  37. package/dist/admin-notification-destinations.js +19 -0
  38. package/dist/admin-notification-webhooks.d.ts +64 -0
  39. package/dist/admin-notification-webhooks.js +42 -0
  40. package/dist/admin-oauth-client-admissions.d.ts +65 -0
  41. package/dist/admin-oauth-client-admissions.js +46 -0
  42. package/dist/admin-offboarding.d.ts +123 -0
  43. package/dist/admin-offboarding.js +129 -0
  44. package/dist/admin-predictions.d.ts +266 -0
  45. package/dist/admin-predictions.js +93 -0
  46. package/dist/admin-privacy-erasures.d.ts +74 -0
  47. package/dist/admin-privacy-erasures.js +73 -0
  48. package/dist/admin-retention.d.ts +99 -0
  49. package/dist/admin-retention.js +60 -0
  50. package/dist/admin-rls.d.ts +94 -0
  51. package/dist/admin-rls.js +33 -0
  52. package/dist/admin-sdk-usage.d.ts +41 -0
  53. package/dist/admin-sdk-usage.js +23 -0
  54. package/dist/admin-site-ai.d.ts +72 -0
  55. package/dist/admin-site-ai.js +1 -0
  56. package/dist/admin-site-analytics.d.ts +52 -0
  57. package/dist/admin-site-analytics.js +14 -0
  58. package/dist/admin-site-audit-pages.d.ts +76 -0
  59. package/dist/admin-site-audit-pages.js +27 -0
  60. package/dist/admin-site-campaign-links.d.ts +40 -0
  61. package/dist/admin-site-campaign-links.js +9 -0
  62. package/dist/admin-site-domains.d.ts +733 -0
  63. package/dist/admin-site-domains.js +768 -0
  64. package/dist/admin-site-export.d.ts +76 -0
  65. package/dist/admin-site-export.js +15 -0
  66. package/dist/admin-site-insights-tasks.d.ts +44 -0
  67. package/dist/admin-site-insights-tasks.js +28 -0
  68. package/dist/admin-site-insights.d.ts +527 -0
  69. package/dist/admin-site-insights.js +61 -0
  70. package/dist/admin-site-links.d.ts +87 -0
  71. package/dist/admin-site-links.js +16 -0
  72. package/dist/admin-site-monitors.d.ts +110 -0
  73. package/dist/admin-site-monitors.js +25 -0
  74. package/dist/admin-site-next-actions.d.ts +93 -0
  75. package/dist/admin-site-next-actions.js +36 -0
  76. package/dist/admin-site-page-queries.d.ts +63 -0
  77. package/dist/admin-site-page-queries.js +20 -0
  78. package/dist/admin-site-rankings.d.ts +98 -0
  79. package/dist/admin-site-rankings.js +46 -0
  80. package/dist/admin-site-regional-trends.d.ts +30 -0
  81. package/dist/admin-site-regional-trends.js +1 -0
  82. package/dist/admin-site-saved-reports.d.ts +45 -0
  83. package/dist/admin-site-saved-reports.js +13 -0
  84. package/dist/admin-site-search-pool.d.ts +77 -0
  85. package/dist/admin-site-search-pool.js +41 -0
  86. package/dist/admin-site-search-value.d.ts +97 -0
  87. package/dist/admin-site-search-value.js +29 -0
  88. package/dist/admin-site-status-page.d.ts +57 -0
  89. package/dist/admin-site-status-page.js +10 -0
  90. package/dist/admin-site-traffic.d.ts +145 -0
  91. package/dist/admin-site-traffic.js +32 -0
  92. package/dist/admin-site-web-data.d.ts +258 -0
  93. package/dist/admin-site-web-data.js +60 -0
  94. package/dist/admin-subject-exports.d.ts +79 -0
  95. package/dist/admin-subject-exports.js +44 -0
  96. package/dist/admin-support-access.d.ts +32 -0
  97. package/dist/admin-support-access.js +21 -0
  98. package/dist/admin-system.d.ts +283 -0
  99. package/dist/admin-system.js +65 -0
  100. package/dist/admin-tenant-storage.d.ts +35 -0
  101. package/dist/admin-tenant-storage.js +24 -0
  102. package/dist/admin-timeplans.d.ts +512 -0
  103. package/dist/admin-timeplans.js +200 -0
  104. package/dist/admin-uncertainty-models.d.ts +42 -0
  105. package/dist/admin-uncertainty-models.js +53 -0
  106. package/dist/admin-usage.d.ts +124 -0
  107. package/dist/admin-usage.js +169 -0
  108. package/dist/admin-users.d.ts +124 -0
  109. package/dist/admin-users.js +82 -0
  110. package/dist/admin-workflow-timings.d.ts +367 -0
  111. package/dist/admin-workflow-timings.js +117 -0
  112. package/dist/analytics-events.d.ts +167 -0
  113. package/dist/analytics-events.js +197 -0
  114. package/dist/analytics-reads.d.ts +81 -0
  115. package/dist/analytics-reads.js +5 -0
  116. package/dist/app-account.d.ts +84 -0
  117. package/dist/app-account.js +177 -0
  118. package/dist/app-alerts.d.ts +120 -0
  119. package/dist/app-alerts.js +44 -0
  120. package/dist/app-items.d.ts +786 -0
  121. package/dist/app-items.js +524 -0
  122. package/dist/app-live.d.ts +84 -0
  123. package/dist/app-live.js +228 -0
  124. package/dist/app-meetings.d.ts +95 -0
  125. package/dist/app-meetings.js +26 -0
  126. package/dist/app-models.d.ts +271 -0
  127. package/dist/app-models.js +83 -0
  128. package/dist/app-push.d.ts +64 -0
  129. package/dist/app-push.js +178 -0
  130. package/dist/backend-lifecycle.d.ts +85 -0
  131. package/dist/backend-lifecycle.js +212 -0
  132. package/dist/browser-manifest.json +7 -0
  133. package/dist/browser-script-BWnwDjAC.js +711 -0
  134. package/dist/browser-script.d.ts +1 -0
  135. package/dist/browser-script.js +5 -0
  136. package/dist/browser-sign-in.d.ts +153 -0
  137. package/dist/browser-sign-in.js +410 -0
  138. package/dist/browser-tracker.d.ts +142 -0
  139. package/dist/browser-tracker.js +775 -0
  140. package/dist/browser-web-vitals.d.ts +22 -0
  141. package/dist/browser-web-vitals.js +116 -0
  142. package/dist/browser.d.ts +10 -0
  143. package/dist/browser.js +10 -0
  144. package/dist/download-stream.d.ts +16 -0
  145. package/dist/download-stream.js +55 -0
  146. package/dist/error-capture.d.ts +62 -0
  147. package/dist/error-capture.js +168 -0
  148. package/dist/hosted-app.d.ts +115 -0
  149. package/dist/hosted-app.js +275 -0
  150. package/dist/index.d.ts +2324 -0
  151. package/dist/index.js +2226 -0
  152. package/dist/ingest-operations.d.ts +483 -0
  153. package/dist/ingest-operations.js +154 -0
  154. package/dist/measurement.d.ts +164 -0
  155. package/dist/measurement.js +104 -0
  156. package/dist/mobile-adapter.d.ts +25 -0
  157. package/dist/mobile-adapter.js +57 -0
  158. package/dist/mobile-context.d.ts +32 -0
  159. package/dist/mobile-context.js +156 -0
  160. package/dist/mobile-queue.d.ts +22 -0
  161. package/dist/mobile-queue.js +73 -0
  162. package/dist/oauth.d.ts +1 -0
  163. package/dist/oauth.js +8 -0
  164. package/dist/parsers.d.ts +149 -0
  165. package/dist/parsers.js +115 -0
  166. package/dist/public-reads.d.ts +79 -0
  167. package/dist/public-reads.js +57 -0
  168. package/dist/reporting-catalogue.d.ts +264 -0
  169. package/dist/reporting-catalogue.js +5 -0
  170. package/dist/reporting-state.d.ts +46 -0
  171. package/dist/reporting-state.js +76 -0
  172. package/dist/response-lists.d.ts +16 -0
  173. package/dist/response-lists.generated.d.ts +7 -0
  174. package/dist/response-lists.generated.js +1927 -0
  175. package/dist/response-lists.js +70 -0
  176. package/dist/response-validation.d.ts +30 -0
  177. package/dist/response-validation.js +94 -0
  178. package/dist/runtime-readiness.d.ts +30 -0
  179. package/dist/runtime-readiness.js +150 -0
  180. package/dist/schema-registry.d.ts +45 -0
  181. package/dist/schema-registry.js +9 -0
  182. package/dist/secure-url.d.ts +4 -0
  183. package/dist/secure-url.js +23 -0
  184. package/dist/site-ai-owner.d.ts +34 -0
  185. package/dist/site-ai-owner.js +99 -0
  186. package/dist/site-monitor-reports.d.ts +15 -0
  187. package/dist/site-monitor-reports.js +87 -0
  188. package/dist/testing/fake-custd.d.ts +150 -0
  189. package/dist/testing/fake-custd.js +842 -0
  190. package/dist/testing/fake-results.d.ts +30 -0
  191. package/dist/testing/fake-results.js +293 -0
  192. package/dist/testing.d.ts +2 -0
  193. package/dist/testing.js +3 -0
  194. package/dist/version.d.ts +10 -0
  195. package/dist/version.js +10 -0
  196. package/package.json +57 -4
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Notification webhooks and their deliveries. A subscription posts signed notifications to an HTTPS
3
+ * endpoint or a Slack incoming webhook; its signing secret is shown only on create and rotate.
4
+ */
5
+ import type { RequestOptions } from "./index.js";
6
+ type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
7
+ export type NotificationWebhookKind = "webhook" | "slack";
8
+ export type NotificationWebhookSubscription = {
9
+ uuid: string;
10
+ name: string;
11
+ kind: NotificationWebhookKind;
12
+ endpoint: string;
13
+ enabled: boolean;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ };
17
+ /** A subscription plus its signing secret, returned only when the secret is created or rotated. */
18
+ export type NotificationWebhookSecret = NotificationWebhookSubscription & {
19
+ signingSecret: string;
20
+ };
21
+ export type NotificationWebhookListResponse = {
22
+ subscriptions: NotificationWebhookSubscription[];
23
+ };
24
+ export type NotificationWebhookCreateRequest = {
25
+ companySlug: string;
26
+ name: string;
27
+ endpoint: string;
28
+ enabled: boolean;
29
+ kind?: NotificationWebhookKind;
30
+ };
31
+ /** One notification delivery's current state. */
32
+ export type NotificationDeliveryStatus = {
33
+ messageUuid: string;
34
+ deliveryUuid: string;
35
+ templateId: string;
36
+ channel: string;
37
+ state: string;
38
+ attemptCount: number;
39
+ failureReason?: string;
40
+ lastErrorClass?: string;
41
+ nextAction?: string;
42
+ providerMessageId?: string;
43
+ createdAt: string;
44
+ updatedAt: string;
45
+ sentAt?: string;
46
+ terminalAt?: string;
47
+ };
48
+ /** Why an operator replays a delivery; it lands in the audit stream. At most 255 characters. */
49
+ export type NotificationDeliveryReplayRequest = {
50
+ reason: string;
51
+ };
52
+ export declare class NotificationWebhookAdminClient {
53
+ private readonly request;
54
+ constructor(request: AdminRequester);
55
+ list(companySlug?: string): Promise<NotificationWebhookListResponse>;
56
+ create(body: NotificationWebhookCreateRequest): Promise<NotificationWebhookSecret>;
57
+ setEnabled(uuid: string, enabled: boolean, companySlug?: string): Promise<NotificationWebhookSubscription>;
58
+ rotateSecret(uuid: string, companySlug?: string): Promise<NotificationWebhookSecret>;
59
+ delete(uuid: string, companySlug?: string): Promise<void>;
60
+ getDelivery(deliveryUuid: string, companySlug?: string): Promise<NotificationDeliveryStatus>;
61
+ /** Queues the delivery again. */
62
+ replay(deliveryUuid: string, body: NotificationDeliveryReplayRequest, companySlug?: string): Promise<void>;
63
+ }
64
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Notification webhooks and their deliveries. A subscription posts signed notifications to an HTTPS
3
+ * endpoint or a Slack incoming webhook; its signing secret is shown only on create and rotate.
4
+ */
5
+ const webhooksPath = "/notification-webhooks";
6
+ export class NotificationWebhookAdminClient {
7
+ constructor(request) {
8
+ this.request = request;
9
+ }
10
+ async list(companySlug) {
11
+ const response = await this.request("GET", withCompany(webhooksPath, companySlug));
12
+ return { subscriptions: response.subscriptions ?? [] };
13
+ }
14
+ create(body) {
15
+ return this.request("POST", webhooksPath, body);
16
+ }
17
+ setEnabled(uuid, enabled, companySlug) {
18
+ return this.request("PATCH", withCompany(webhookPath(uuid), companySlug), { enabled });
19
+ }
20
+ rotateSecret(uuid, companySlug) {
21
+ return this.request("POST", withCompany(`${webhookPath(uuid)}/rotate-secret`, companySlug));
22
+ }
23
+ delete(uuid, companySlug) {
24
+ return this.request("DELETE", withCompany(webhookPath(uuid), companySlug));
25
+ }
26
+ getDelivery(deliveryUuid, companySlug) {
27
+ return this.request("GET", withCompany(deliveryPath(deliveryUuid), companySlug));
28
+ }
29
+ /** Queues the delivery again. */
30
+ replay(deliveryUuid, body, companySlug) {
31
+ return this.request("POST", withCompany(`${deliveryPath(deliveryUuid)}/replay`, companySlug), body);
32
+ }
33
+ }
34
+ function webhookPath(uuid) {
35
+ return `${webhooksPath}/${encodeURIComponent(uuid)}`;
36
+ }
37
+ function deliveryPath(uuid) {
38
+ return `/notification-deliveries/${encodeURIComponent(uuid)}`;
39
+ }
40
+ function withCompany(path, companySlug) {
41
+ return companySlug ? `${path}?companySlug=${encodeURIComponent(companySlug)}` : path;
42
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * OAuth client admissions. A dynamically registered client asks for grants; a tenant administrator
3
+ * reviews the client's metadata, approves the grants it should hold, or revokes it. Every mutation
4
+ * names the revision it was decided against, so a stale decision is rejected.
5
+ */
6
+ import type { RequestOptions } from "./index.js";
7
+ /** The scopes one client may hold on one resource. */
8
+ export type OAuthClientAdmissionGrant = {
9
+ resourceUri: string;
10
+ scopes: string[];
11
+ };
12
+ export type OAuthClientAdmission = {
13
+ admissionUuid: string;
14
+ clientId: string;
15
+ companyUuid: string;
16
+ revision: number;
17
+ requestedGrants: OAuthClientAdmissionGrant[];
18
+ requestedSecurityRevision: string;
19
+ approvedGrants: OAuthClientAdmissionGrant[];
20
+ approvedSecurityRevision?: string;
21
+ approvedAt?: string;
22
+ revokedAt?: string;
23
+ };
24
+ export type OAuthClientAdmissionListResponse = {
25
+ admissions: OAuthClientAdmission[];
26
+ };
27
+ /** The registered client's public metadata a review needs. */
28
+ export type OAuthClientAdmissionMetadata = {
29
+ clientName: string;
30
+ redirectUris: string[];
31
+ securityRevision: string;
32
+ expiresAt: string;
33
+ };
34
+ export type OAuthClientAdmissionReviewRequest = {
35
+ companySlug: string;
36
+ };
37
+ export type OAuthClientAdmissionReviewResponse = {
38
+ admission: OAuthClientAdmission;
39
+ metadata: OAuthClientAdmissionMetadata;
40
+ };
41
+ export type OAuthClientAdmissionApproveRequest = {
42
+ companySlug: string;
43
+ clientId: string;
44
+ expectedRevision: number;
45
+ securityRevision: string;
46
+ grants: OAuthClientAdmissionGrant[];
47
+ };
48
+ export type OAuthClientAdmissionRevokeRequest = {
49
+ companySlug: string;
50
+ expectedRevision: number;
51
+ };
52
+ export type OAuthClientAdmissionMutationResponse = {
53
+ admission: OAuthClientAdmission;
54
+ };
55
+ type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
56
+ export declare class OAuthClientAdmissionAdminClient {
57
+ private readonly request;
58
+ constructor(request: AdminRequester);
59
+ list(companySlug: string, options?: RequestOptions): Promise<OAuthClientAdmissionListResponse>;
60
+ review(admissionUuid: string, body: OAuthClientAdmissionReviewRequest, options?: RequestOptions): Promise<OAuthClientAdmissionReviewResponse>;
61
+ approve(admissionUuid: string, body: OAuthClientAdmissionApproveRequest, options?: RequestOptions): Promise<OAuthClientAdmissionMutationResponse>;
62
+ revoke(admissionUuid: string, body: OAuthClientAdmissionRevokeRequest, options?: RequestOptions): Promise<OAuthClientAdmissionMutationResponse>;
63
+ private mutate;
64
+ }
65
+ export {};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * OAuth client admissions. A dynamically registered client asks for grants; a tenant administrator
3
+ * reviews the client's metadata, approves the grants it should hold, or revokes it. Every mutation
4
+ * names the revision it was decided against, so a stale decision is rejected.
5
+ */
6
+ const admissionsPath = "/oauth-client-admissions";
7
+ export class OAuthClientAdmissionAdminClient {
8
+ constructor(request) {
9
+ this.request = request;
10
+ }
11
+ async list(companySlug, options) {
12
+ const path = `${admissionsPath}?companySlug=${encodeURIComponent(companySlug)}`;
13
+ const list = await this.request("GET", path, undefined, options);
14
+ return { admissions: (list.admissions ?? []).map(normalizeAdmission) };
15
+ }
16
+ async review(admissionUuid, body, options) {
17
+ const review = await this.request("POST", `${admissionPath(admissionUuid)}/review`, body, options);
18
+ return {
19
+ admission: normalizeAdmission(review.admission),
20
+ metadata: { ...review.metadata, redirectUris: review.metadata.redirectUris ?? [] },
21
+ };
22
+ }
23
+ approve(admissionUuid, body, options) {
24
+ return this.mutate(`${admissionPath(admissionUuid)}/approve`, body, options);
25
+ }
26
+ revoke(admissionUuid, body, options) {
27
+ return this.mutate(`${admissionPath(admissionUuid)}/revoke`, body, options);
28
+ }
29
+ async mutate(path, body, options) {
30
+ const response = await this.request("POST", path, body, options);
31
+ return { admission: normalizeAdmission(response.admission) };
32
+ }
33
+ }
34
+ function admissionPath(admissionUuid) {
35
+ return `${admissionsPath}/${encodeURIComponent(admissionUuid)}`;
36
+ }
37
+ function normalizeGrants(grants) {
38
+ return (grants ?? []).map((grant) => ({ ...grant, scopes: grant.scopes ?? [] }));
39
+ }
40
+ function normalizeAdmission(admission) {
41
+ return {
42
+ ...admission,
43
+ requestedGrants: normalizeGrants(admission.requestedGrants),
44
+ approvedGrants: normalizeGrants(admission.approvedGrants),
45
+ };
46
+ }
@@ -0,0 +1,123 @@
1
+ import { type CustdDownloadStream } from "./download-stream.js";
2
+ import type { RequestOptions } from "./index.js";
3
+ export type OffboardingSchedule = {
4
+ tenantSlug: string;
5
+ effectiveAt: string;
6
+ gracePeriodDays: number;
7
+ reason: string;
8
+ status: string;
9
+ updatedAt?: string;
10
+ };
11
+ export type OffboardingScheduleRequest = {
12
+ tenantSlug: string;
13
+ effectiveAt: string;
14
+ gracePeriodDays: number;
15
+ reason: string;
16
+ status?: string;
17
+ };
18
+ export type OffboardingScheduleListResponse = {
19
+ schedules: OffboardingSchedule[];
20
+ };
21
+ export type OffboardingCancelRequest = {
22
+ reason: string;
23
+ };
24
+ export type OffboardingRequest = {
25
+ requestUuid: string;
26
+ state: string;
27
+ requestedAt: string;
28
+ };
29
+ export type OffboardingRequestCreate = {
30
+ confirmation: string;
31
+ };
32
+ export type OffboardingPreviewStore = {
33
+ store: string;
34
+ kind: string;
35
+ retentionClass: string;
36
+ estimatedCount: number;
37
+ sourceAuthority?: string;
38
+ };
39
+ export type OffboardingPreviewExclusion = {
40
+ store: string;
41
+ reason: string;
42
+ };
43
+ export type OffboardingPreviewResponse = {
44
+ requestUuid: string;
45
+ generatedAt: string;
46
+ expiresAt: string;
47
+ stores: OffboardingPreviewStore[];
48
+ exclusions?: OffboardingPreviewExclusion[];
49
+ previewInventoryDigest: string;
50
+ complete: boolean;
51
+ partial: boolean;
52
+ };
53
+ export type OffboardingWaiver = {
54
+ role: string;
55
+ timestamp: string;
56
+ };
57
+ export type OffboardingRequesterKind = "human" | "machine";
58
+ export type OffboardingExportResponse = {
59
+ requestUuid: string;
60
+ checksumSha256: string;
61
+ byteSize: number;
62
+ recordCount: number;
63
+ generatedAt: string;
64
+ expiresAt: string;
65
+ previewInventoryDigest: string;
66
+ };
67
+ export type OffboardingDownloadResponse = {
68
+ bytes: Uint8Array;
69
+ checksumSha256: string;
70
+ byteSize: number;
71
+ };
72
+ /**
73
+ * The offboarding bundle as it arrives. The body errors if it runs past or ends short of
74
+ * `byteSize`; `checksumSha256` is the server's digest, which the caller checks against the
75
+ * bytes it stored before acknowledging the export.
76
+ */
77
+ export type OffboardingDownloadStream = CustdDownloadStream & {
78
+ byteSize: number;
79
+ checksumSha256: string;
80
+ };
81
+ export type OffboardingAcknowledgeResponse = OffboardingRequest;
82
+ export type OffboardingExecuteResponse = OffboardingReceiptResponse;
83
+ export type OffboardingRetryResponse = OffboardingReceiptResponse;
84
+ export type OffboardingReceiptPerStore = {
85
+ store: string;
86
+ retentionClass: string;
87
+ deletedCount: number;
88
+ retainedExceptionsCount: number;
89
+ };
90
+ export type OffboardingReceiptResponse = {
91
+ companyId: number;
92
+ requestedByKind: OffboardingRequesterKind;
93
+ requestedAt: string;
94
+ completedAt: string;
95
+ finalState: string;
96
+ perStore: OffboardingReceiptPerStore[];
97
+ waiver?: OffboardingWaiver | null;
98
+ sha256: string;
99
+ };
100
+ type AdminRequester = <T>(method: string, path: string, body?: unknown, options?: RequestOptions) => Promise<T>;
101
+ type AdminDownloader = (path: string, options?: RequestOptions) => Promise<OffboardingDownloadStream>;
102
+ export declare class OffboardingClient {
103
+ private readonly request;
104
+ private readonly downloadBinary;
105
+ constructor(request: AdminRequester, downloadBinary: AdminDownloader);
106
+ schedule(body: OffboardingScheduleRequest, options?: RequestOptions): Promise<OffboardingSchedule>;
107
+ listSchedules(options?: RequestOptions): Promise<OffboardingScheduleListResponse>;
108
+ getSchedule(tenantSlug: string, options?: RequestOptions): Promise<OffboardingSchedule>;
109
+ cancelSchedule(tenantSlug: string, body: OffboardingCancelRequest, options?: RequestOptions): Promise<OffboardingSchedule>;
110
+ requestOffboarding(body: OffboardingRequestCreate, options?: RequestOptions): Promise<OffboardingRequest>;
111
+ getRequest(requestUuid: string, options?: RequestOptions): Promise<OffboardingRequest>;
112
+ cancelRequest(requestUuid: string, body: OffboardingCancelRequest, options?: RequestOptions): Promise<OffboardingRequest>;
113
+ confirmRequest(requestUuid: string, options?: RequestOptions): Promise<OffboardingRequest>;
114
+ preview(requestUuid: string, options?: RequestOptions): Promise<OffboardingPreviewResponse>;
115
+ export(requestUuid: string, options?: RequestOptions): Promise<OffboardingExportResponse>;
116
+ downloadStream(requestUuid: string, options?: RequestOptions): Promise<OffboardingDownloadStream>;
117
+ download(requestUuid: string, options?: RequestOptions): Promise<OffboardingDownloadResponse>;
118
+ acknowledge(requestUuid: string, options?: RequestOptions): Promise<OffboardingAcknowledgeResponse>;
119
+ execute(requestUuid: string, options?: RequestOptions): Promise<OffboardingExecuteResponse>;
120
+ retry(requestUuid: string, options?: RequestOptions): Promise<OffboardingRetryResponse>;
121
+ receipt(requestUuid: string, options?: RequestOptions): Promise<OffboardingReceiptResponse>;
122
+ }
123
+ export {};
@@ -0,0 +1,129 @@
1
+ // OffboardingClient owns the offboarding schedule and one-off request
2
+ // surfaces. Its types mirror the current admin-api JSON wire contract.
3
+ import { readDownloadStream } from "./download-stream.js";
4
+ /** The largest bundle download() holds in memory; downloadStream() has no limit. */
5
+ const maxBufferedDownloadBytes = 64 * 1024 * 1024;
6
+ function mapPreview(response) {
7
+ return {
8
+ ...response,
9
+ exclusions: response.exclusions ?? [],
10
+ stores: (response.stores ?? []).map((store) => ({
11
+ store: store.store,
12
+ kind: store.kind,
13
+ retentionClass: store.retention_class,
14
+ estimatedCount: store.estimated_count,
15
+ ...(store.source_authority ? { sourceAuthority: store.source_authority } : {}),
16
+ })),
17
+ };
18
+ }
19
+ function mapReceipt(response) {
20
+ return {
21
+ companyId: response.company_id,
22
+ requestedByKind: response.requested_by_kind,
23
+ requestedAt: response.requested_at,
24
+ completedAt: response.completed_at,
25
+ finalState: response.final_state,
26
+ perStore: (response.per_store ?? []).map((store) => ({
27
+ store: store.store,
28
+ retentionClass: store.retention_class,
29
+ deletedCount: store.deleted_count,
30
+ retainedExceptionsCount: store.retained_exceptions_count,
31
+ })),
32
+ waiver: response.waiver,
33
+ sha256: response.sha256,
34
+ };
35
+ }
36
+ export class OffboardingClient {
37
+ constructor(request, downloadBinary) {
38
+ this.request = request;
39
+ this.downloadBinary = downloadBinary;
40
+ }
41
+ // schedule writes a delayed offboarding schedule. tenantSlug is required and
42
+ // must match the authenticated tenant scope.
43
+ schedule(body, options) {
44
+ return this.request("POST", "/offboarding/schedules", body, options);
45
+ }
46
+ listSchedules(options) {
47
+ return this.request("GET", "/offboarding/schedules", undefined, options);
48
+ }
49
+ // getSchedule reads the delayed offboarding schedule for a single tenant.
50
+ // It targets the per-tenant route GET /offboarding/schedules/{tenantSlug},
51
+ // which is distinct from the global listSchedules collection read.
52
+ getSchedule(tenantSlug, options) {
53
+ return this.request("GET", `/offboarding/schedules/${encodeURIComponent(tenantSlug)}`, undefined, options);
54
+ }
55
+ cancelSchedule(tenantSlug, body, options) {
56
+ return this.request("POST", `/offboarding/schedules/${encodeURIComponent(tenantSlug)}/cancel`, body, options);
57
+ }
58
+ // request submits a one-off offboarding request for the effective tenant
59
+ // via POST /offboarding. The confirmation field must match the tenant
60
+ // slug the server reads from the auth context; mismatches fail with 400.
61
+ requestOffboarding(body, options) {
62
+ return this.request("POST", "/offboarding", body, options);
63
+ }
64
+ getRequest(requestUuid, options) {
65
+ return this.request("GET", `/offboarding/${encodeURIComponent(requestUuid)}`, undefined, options);
66
+ }
67
+ cancelRequest(requestUuid, body, options) {
68
+ return this.request("POST", `/offboarding/${encodeURIComponent(requestUuid)}/cancel`, body, options);
69
+ }
70
+ confirmRequest(requestUuid, options) {
71
+ return this.request("POST", `/offboarding/${encodeURIComponent(requestUuid)}/confirm`, undefined, options);
72
+ }
73
+ // preview asks the server to compute the per-store inventory estimate for
74
+ // the offboarding request. The result is server-issued and must be
75
+ // surfaced verbatim; the SDK must not re-derive estimatedCount.
76
+ async preview(requestUuid, options) {
77
+ const response = await this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/preview`, undefined, options);
78
+ return mapPreview(response);
79
+ }
80
+ // export triggers the destructive export packaging for a request. The
81
+ // response is the per-request artifact metadata; the download URL is
82
+ // fetched separately via download.
83
+ export(requestUuid, options) {
84
+ return this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/export`, undefined, options);
85
+ }
86
+ // downloadStream returns the bundle as it arrives, for a bundle too large to hold in memory.
87
+ // Pass options.signal to stop the transfer.
88
+ downloadStream(requestUuid, options) {
89
+ return this.downloadBinary(`/offboarding/requests/${encodeURIComponent(requestUuid)}/download`, options);
90
+ }
91
+ // download returns authenticated bytes with verified checksum and length, up to 64 MiB.
92
+ async download(requestUuid, options) {
93
+ const stream = await this.downloadStream(requestUuid, options);
94
+ if (stream.byteSize > maxBufferedDownloadBytes) {
95
+ await stream.body.cancel();
96
+ throw new Error("custd: offboarding download exceeds 64 MiB");
97
+ }
98
+ const bytes = await readDownloadStream(stream.body, maxBufferedDownloadBytes, "offboarding download");
99
+ if ((await sha256Hex(bytes)) !== stream.checksumSha256) {
100
+ throw new Error("custd: offboarding download checksum mismatch");
101
+ }
102
+ return { bytes, checksumSha256: stream.checksumSha256, byteSize: stream.byteSize };
103
+ }
104
+ // acknowledge records that the export was downloaded successfully and its
105
+ // inventory was confirmed. Never call it merely because preview succeeded.
106
+ acknowledge(requestUuid, options) {
107
+ return this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/acknowledge`, undefined, options);
108
+ }
109
+ // execute triggers the destructive phase. Approval is server-owned and the
110
+ // request intentionally has no caller-controlled body.
111
+ execute(requestUuid, options) {
112
+ return this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/execute`, undefined, options).then(mapReceipt);
113
+ }
114
+ // retry re-arms an offboarding request that previously failed. The server
115
+ // decides whether the request is retryable; the SDK does not pre-filter.
116
+ retry(requestUuid, options) {
117
+ return this.request("POST", `/offboarding/requests/${encodeURIComponent(requestUuid)}/retry`, undefined, options).then(mapReceipt);
118
+ }
119
+ // receipt returns the terminal offboarding receipt for a request. The
120
+ // sha256 is an unkeyed integrity checksum the client must retain alongside
121
+ // its offboarding record; it is not an authenticity signature.
122
+ receipt(requestUuid, options) {
123
+ return this.request("GET", `/offboarding/requests/${encodeURIComponent(requestUuid)}/receipt`, undefined, options).then(mapReceipt);
124
+ }
125
+ }
126
+ async function sha256Hex(bytes) {
127
+ const digest = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", Uint8Array.from(bytes).buffer));
128
+ return Array.from(digest, (value) => value.toString(16).padStart(2, "0")).join("");
129
+ }