@haakco/custd-sdk 2.4.0 → 3.71.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +586 -40
- package/dist/admin-accounting-evidence.d.ts +48 -0
- package/dist/admin-accounting-evidence.js +24 -0
- package/dist/admin-app-releases.d.ts +116 -0
- package/dist/admin-app-releases.js +8 -0
- package/dist/admin-apps.d.ts +120 -0
- package/dist/admin-apps.js +47 -0
- package/dist/admin-auth-project-domain.d.ts +125 -0
- package/dist/admin-auth-project-domain.js +37 -0
- package/dist/admin-auth-projects.d.ts +989 -0
- package/dist/admin-auth-projects.js +527 -0
- package/dist/admin-campaign-email.d.ts +120 -0
- package/dist/admin-campaign-email.js +64 -0
- package/dist/admin-client-setup.d.ts +22 -0
- package/dist/admin-client-setup.js +11 -1
- package/dist/admin-data-scopes.d.ts +93 -0
- package/dist/admin-data-scopes.js +154 -0
- package/dist/admin-email-relay.d.ts +66 -0
- package/dist/admin-email-relay.js +25 -0
- package/dist/admin-environment-policy.d.ts +32 -0
- package/dist/admin-environment-policy.js +26 -0
- package/dist/admin-error-issues.d.ts +91 -0
- package/dist/admin-error-issues.js +52 -0
- package/dist/admin-event-types.d.ts +57 -0
- package/dist/admin-event-types.js +28 -0
- package/dist/admin-impersonation.d.ts +48 -0
- package/dist/admin-impersonation.js +27 -0
- package/dist/admin-ingest-claims.d.ts +35 -0
- package/dist/admin-ingest-claims.js +26 -0
- package/dist/admin-managed-audit.d.ts +13 -0
- package/dist/admin-managed-audit.js +13 -0
- package/dist/admin-measurement-projects.d.ts +166 -0
- package/dist/admin-measurement-projects.js +120 -0
- package/dist/admin-notification-destinations.d.ts +31 -0
- package/dist/admin-notification-destinations.js +19 -0
- package/dist/admin-notification-webhooks.d.ts +64 -0
- package/dist/admin-notification-webhooks.js +42 -0
- package/dist/admin-oauth-client-admissions.d.ts +65 -0
- package/dist/admin-oauth-client-admissions.js +46 -0
- package/dist/admin-offboarding.d.ts +20 -6
- package/dist/admin-offboarding.js +27 -6
- package/dist/admin-predictions.d.ts +127 -8
- package/dist/admin-predictions.js +22 -12
- package/dist/admin-privacy-erasures.d.ts +24 -12
- package/dist/admin-privacy-erasures.js +3 -2
- package/dist/admin-retention.d.ts +72 -24
- package/dist/admin-retention.js +38 -13
- package/dist/admin-rls.d.ts +94 -0
- package/dist/admin-rls.js +33 -0
- package/dist/admin-sdk-usage.d.ts +41 -0
- package/dist/admin-sdk-usage.js +23 -0
- package/dist/admin-site-ai.d.ts +72 -0
- package/dist/admin-site-ai.js +1 -0
- package/dist/admin-site-analytics.d.ts +52 -0
- package/dist/admin-site-analytics.js +14 -0
- package/dist/admin-site-audit-pages.d.ts +76 -0
- package/dist/admin-site-audit-pages.js +27 -0
- package/dist/admin-site-campaign-links.d.ts +40 -0
- package/dist/admin-site-campaign-links.js +9 -0
- package/dist/admin-site-domains.d.ts +733 -0
- package/dist/admin-site-domains.js +768 -0
- package/dist/admin-site-export.d.ts +76 -0
- package/dist/admin-site-export.js +15 -0
- package/dist/admin-site-insights-tasks.d.ts +44 -0
- package/dist/admin-site-insights-tasks.js +28 -0
- package/dist/admin-site-insights.d.ts +527 -0
- package/dist/admin-site-insights.js +61 -0
- package/dist/admin-site-links.d.ts +87 -0
- package/dist/admin-site-links.js +16 -0
- package/dist/admin-site-monitors.d.ts +110 -0
- package/dist/admin-site-monitors.js +25 -0
- package/dist/admin-site-next-actions.d.ts +93 -0
- package/dist/admin-site-next-actions.js +36 -0
- package/dist/admin-site-page-queries.d.ts +63 -0
- package/dist/admin-site-page-queries.js +20 -0
- package/dist/admin-site-rankings.d.ts +98 -0
- package/dist/admin-site-rankings.js +46 -0
- package/dist/admin-site-regional-trends.d.ts +30 -0
- package/dist/admin-site-regional-trends.js +1 -0
- package/dist/admin-site-saved-reports.d.ts +45 -0
- package/dist/admin-site-saved-reports.js +13 -0
- package/dist/admin-site-search-pool.d.ts +77 -0
- package/dist/admin-site-search-pool.js +41 -0
- package/dist/admin-site-search-value.d.ts +97 -0
- package/dist/admin-site-search-value.js +29 -0
- package/dist/admin-site-status-page.d.ts +57 -0
- package/dist/admin-site-status-page.js +10 -0
- package/dist/admin-site-traffic.d.ts +145 -0
- package/dist/admin-site-traffic.js +32 -0
- package/dist/admin-site-web-data.d.ts +258 -0
- package/dist/admin-site-web-data.js +60 -0
- package/dist/admin-subject-exports.d.ts +58 -27
- package/dist/admin-subject-exports.js +32 -16
- package/dist/admin-support-access.d.ts +32 -0
- package/dist/admin-support-access.js +21 -0
- package/dist/admin-system.d.ts +283 -0
- package/dist/admin-system.js +65 -0
- package/dist/admin-tenant-storage.d.ts +22 -14
- package/dist/admin-tenant-storage.js +13 -14
- package/dist/admin-timeplans.d.ts +276 -2
- package/dist/admin-timeplans.js +54 -0
- package/dist/admin-uncertainty-models.d.ts +42 -0
- package/dist/admin-uncertainty-models.js +53 -0
- package/dist/admin-usage.d.ts +124 -0
- package/dist/admin-usage.js +169 -0
- package/dist/admin-users.d.ts +124 -0
- package/dist/admin-users.js +82 -0
- package/dist/admin-workflow-timings.d.ts +367 -0
- package/dist/admin-workflow-timings.js +117 -0
- package/dist/analytics-events.d.ts +82 -0
- package/dist/analytics-events.js +157 -0
- package/dist/analytics-reads.d.ts +81 -0
- package/dist/analytics-reads.js +5 -0
- package/dist/app-account.d.ts +84 -0
- package/dist/app-account.js +177 -0
- package/dist/app-alerts.d.ts +120 -0
- package/dist/app-alerts.js +44 -0
- package/dist/app-items.d.ts +786 -0
- package/dist/app-items.js +524 -0
- package/dist/app-live.d.ts +84 -0
- package/dist/app-live.js +228 -0
- package/dist/app-meetings.d.ts +95 -0
- package/dist/app-meetings.js +26 -0
- package/dist/app-models.d.ts +271 -0
- package/dist/app-models.js +83 -0
- package/dist/app-push.d.ts +64 -0
- package/dist/app-push.js +178 -0
- package/dist/backend-lifecycle.d.ts +2 -2
- package/dist/browser-manifest.json +5 -5
- package/dist/browser-script-BWnwDjAC.js +711 -0
- package/dist/browser-sign-in.d.ts +153 -0
- package/dist/browser-sign-in.js +410 -0
- package/dist/browser-tracker.d.ts +95 -0
- package/dist/browser-tracker.js +362 -40
- package/dist/browser-web-vitals.d.ts +22 -0
- package/dist/browser-web-vitals.js +116 -0
- package/dist/browser.d.ts +9 -0
- package/dist/browser.js +9 -0
- package/dist/download-stream.d.ts +16 -0
- package/dist/download-stream.js +55 -0
- package/dist/error-capture.d.ts +62 -0
- package/dist/error-capture.js +168 -0
- package/dist/hosted-app.d.ts +115 -0
- package/dist/hosted-app.js +275 -0
- package/dist/index.d.ts +1168 -154
- package/dist/index.js +682 -162
- package/dist/ingest-operations.d.ts +483 -0
- package/dist/ingest-operations.js +154 -0
- package/dist/measurement.d.ts +164 -0
- package/dist/measurement.js +104 -0
- package/dist/parsers.d.ts +149 -0
- package/dist/parsers.js +115 -0
- package/dist/public-reads.d.ts +79 -0
- package/dist/public-reads.js +57 -0
- package/dist/reporting-catalogue.d.ts +264 -0
- package/dist/reporting-catalogue.js +5 -0
- package/dist/response-lists.d.ts +16 -0
- package/dist/response-lists.generated.d.ts +7 -0
- package/dist/response-lists.generated.js +1927 -0
- package/dist/response-lists.js +70 -0
- package/dist/response-validation.d.ts +30 -0
- package/dist/response-validation.js +94 -0
- package/dist/schema-registry.d.ts +45 -0
- package/dist/schema-registry.js +9 -0
- package/dist/secure-url.d.ts +4 -0
- package/dist/secure-url.js +23 -0
- package/dist/site-ai-owner.d.ts +34 -0
- package/dist/site-ai-owner.js +99 -0
- package/dist/site-monitor-reports.d.ts +15 -0
- package/dist/site-monitor-reports.js +87 -0
- package/dist/testing/fake-custd.d.ts +150 -0
- package/dist/testing/fake-custd.js +842 -0
- package/dist/testing/fake-results.d.ts +30 -0
- package/dist/testing/fake-results.js +293 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +3 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/package.json +25 -14
- package/dist/browser-script-BvgjdZSO.js +0 -429
- package/dist/fixtures.d.ts +0 -10
- package/dist/fixtures.js +0 -57
package/dist/index.js
CHANGED
|
@@ -1,32 +1,105 @@
|
|
|
1
|
+
import { AuthProjectAdminClient } from "./admin-auth-projects.js";
|
|
1
2
|
import { ClientSetupClient } from "./admin-client-setup.js";
|
|
2
3
|
import { DataLabelAdminClient } from "./admin-data-labels.js";
|
|
3
|
-
import {
|
|
4
|
+
import { DataScopeAdminClient, validDataScopeCode } from "./admin-data-scopes.js";
|
|
5
|
+
import { OffboardingClient, } from "./admin-offboarding.js";
|
|
4
6
|
import { PredictionAdminClient } from "./admin-predictions.js";
|
|
5
7
|
import { PrivacyErasureClient } from "./admin-privacy-erasures.js";
|
|
6
8
|
import { RetentionClient } from "./admin-retention.js";
|
|
9
|
+
import { SiteDomainAdminClient } from "./admin-site-domains.js";
|
|
10
|
+
import { SiteInsightsAdminClient } from "./admin-site-insights-tasks.js";
|
|
7
11
|
import { SubjectExportClient } from "./admin-subject-exports.js";
|
|
8
12
|
import { TenantStorageClient } from "./admin-tenant-storage.js";
|
|
13
|
+
import { responseDownloadStream } from "./download-stream.js";
|
|
14
|
+
import { isLocalHostname } from "./secure-url.js";
|
|
15
|
+
export { AUTH_PROJECT_DOMAIN_CONVERGENCES, AUTH_PROJECT_DOMAIN_IMAGE_COMPONENTS, AUTH_PROJECT_DOMAIN_IMAGE_SOURCES, AUTH_PROJECT_DOMAIN_LIFECYCLES, AUTH_PROJECT_DOMAIN_STATUSES, } from "./admin-auth-project-domain.js";
|
|
16
|
+
export { ADMIN_USER_GLOBAL_STATES, ADMIN_USER_MEMBERSHIP_STATES, ADMIN_USER_ROLES, AdminUserAdminClient, } from "./admin-users.js";
|
|
17
|
+
export { WORKFLOW_TIMING_FACT_KINDS, WORKFLOW_TIMING_STATES, WorkflowTimingAdminClient, } from "./admin-workflow-timings.js";
|
|
18
|
+
import { AccountingEvidenceAdminClient } from "./admin-accounting-evidence.js";
|
|
19
|
+
import { CampaignEmailAdminClient } from "./admin-campaign-email.js";
|
|
20
|
+
import { EmailRelayAdminClient } from "./admin-email-relay.js";
|
|
21
|
+
import { EnvironmentPolicyAdminClient } from "./admin-environment-policy.js";
|
|
22
|
+
import { ErrorIssueAdminClient } from "./admin-error-issues.js";
|
|
23
|
+
import { EventTypeAdminClient } from "./admin-event-types.js";
|
|
24
|
+
import { ImpersonationAdminClient } from "./admin-impersonation.js";
|
|
25
|
+
import { IngestClaimAdminClient } from "./admin-ingest-claims.js";
|
|
26
|
+
import { ManagedAuditAdminClient } from "./admin-managed-audit.js";
|
|
27
|
+
import { AdminMeasurementNamespace } from "./admin-measurement-projects.js";
|
|
28
|
+
import { NotificationDestinationAdminClient } from "./admin-notification-destinations.js";
|
|
29
|
+
import { NotificationWebhookAdminClient } from "./admin-notification-webhooks.js";
|
|
30
|
+
import { OAuthClientAdmissionAdminClient } from "./admin-oauth-client-admissions.js";
|
|
31
|
+
import { RlsAdminClient } from "./admin-rls.js";
|
|
32
|
+
import { SdkUsageAdminClient } from "./admin-sdk-usage.js";
|
|
33
|
+
import { SupportAccessAdminClient } from "./admin-support-access.js";
|
|
34
|
+
import { SystemAdminClient } from "./admin-system.js";
|
|
9
35
|
import { TimePlanAdminClient } from "./admin-timeplans.js";
|
|
36
|
+
import { UncertaintyModelAdminClient } from "./admin-uncertainty-models.js";
|
|
37
|
+
import { UsageAdminClient } from "./admin-usage.js";
|
|
38
|
+
import { AdminUserAdminClient } from "./admin-users.js";
|
|
39
|
+
import { WorkflowTimingAdminClient } from "./admin-workflow-timings.js";
|
|
10
40
|
import { AnalyticsEventClient } from "./analytics-events.js";
|
|
11
41
|
import { BackendLifecycleClient } from "./backend-lifecycle.js";
|
|
42
|
+
import { IngestOperationsClient } from "./ingest-operations.js";
|
|
43
|
+
import { MeasurementClient } from "./measurement.js";
|
|
12
44
|
import { basicAuthorization } from "./oauth.js";
|
|
45
|
+
import { ParserClient } from "./parsers.js";
|
|
46
|
+
import { PublicReadClient } from "./public-reads.js";
|
|
47
|
+
import { emptyApiNullLists } from "./response-lists.js";
|
|
48
|
+
import { eventSchemaPath, schemaRegistryPath, } from "./schema-registry.js";
|
|
49
|
+
import { redeemSiteAIOwnerHandoff } from "./site-ai-owner.js";
|
|
13
50
|
import { SDK_IDENTITY } from "./version.js";
|
|
51
|
+
export { APP_ERROR_CODES, APP_REASON_CODES, APP_SIGN_IN_MODES, APP_STATUSES, } from "./admin-apps.js";
|
|
52
|
+
export { AuthProjectAdminClient, AuthProjectRealmNotConvergedError, AuthProjectRealmProvisionError, } from "./admin-auth-projects.js";
|
|
14
53
|
export { ClientSetupClient, validateClientSetupManifest, } from "./admin-client-setup.js";
|
|
15
54
|
export { DataLabelAdminClient, } from "./admin-data-labels.js";
|
|
55
|
+
export { DataScopeAdminClient, validDataScopeCode, validDataScopeName, } from "./admin-data-scopes.js";
|
|
16
56
|
export { OffboardingClient, } from "./admin-offboarding.js";
|
|
17
57
|
export { PredictionAdminClient, } from "./admin-predictions.js";
|
|
18
58
|
export { PrivacyErasureClient, PrivacyErasureError, } from "./admin-privacy-erasures.js";
|
|
19
59
|
export { RetentionClient, } from "./admin-retention.js";
|
|
60
|
+
export { SITE_ANALYTICS_CONNECTION_NOT_FOUND_CODE, SITE_ANALYTICS_PROPERTY_INVALID_CODE, SITE_ANALYTICS_PROVIDER_GA4, SiteAnalyticsUnavailableReport, } from "./admin-site-analytics.js";
|
|
61
|
+
export { SITE_AUDIT_PAGES_DEFAULT_LIMIT, SITE_AUDIT_PAGES_MAX_LIMIT, SITE_LIGHTHOUSE_MAX_EXTRA_PAGES, SITE_LIGHTHOUSE_PAGE_NOT_EXTRA_CODE, SiteAuditPageIndexability, SiteAuditRun, } from "./admin-site-audit-pages.js";
|
|
62
|
+
export { SITE_CAMPAIGN_LINK_LIMIT_CODE, SITE_CAMPAIGN_LINK_TAKEN_CODE, SITE_CAMPAIGN_LINKS_MAX, } from "./admin-site-campaign-links.js";
|
|
63
|
+
export { SITE_BROWSER_COLLECTOR_MODES, SITE_DOMAIN_NOT_VERIFIED_CODE, SITE_FINDING_DISMISSAL_SCOPES, SITE_SEARCH_CONNECTION_NOT_FOUND_CODE, SITE_SEARCH_NOT_CONFIGURED_CODE, SITE_SEARCH_RETRY_NOT_FAILING_CODE, SiteDomainAdminClient, SiteRule, } from "./admin-site-domains.js";
|
|
64
|
+
export { SITE_INSIGHTS_EXPORT_SCHEMA, SITE_INSIGHTS_EXPORT_SEARCH_METRICS_MAX_LIMIT, SiteSearchMetricDimension, } from "./admin-site-export.js";
|
|
65
|
+
export { IndexNowSubmissionStatus, SITE_CHOICE_REQUIRED_CODE, SITE_INDEXNOW_DOMAIN_UNVERIFIED_CODE, SITE_INDEXNOW_KEY_UNVERIFIED_CODE, SITE_INDEXNOW_LIMIT_CODE, SITE_INDEXNOW_NOT_ENABLED_CODE, SITE_INDEXNOW_URLS_INVALID_CODE, SITE_PAGE_NOT_ON_DOMAIN_CODE, SITE_PAGE_NOT_READ_CODE, SITE_PAGE_RECHECK_LIMIT_CODE, SITE_PAGE_RECHECK_READ_LIMIT, SITE_SEARCH_INSPECTION_LIMIT_CODE, SITE_SEARCH_INSPECTION_NOT_CONNECTED_CODE, SITE_SEARCH_INSPECTION_URL_INVALID_CODE, SiteGeneratedFormat, SitePageCheckScope, SitePageRecheckState, SiteRemedyKind, } from "./admin-site-insights.js";
|
|
66
|
+
export { SiteInsightsAdminClient, SiteInsightsTaskName, } from "./admin-site-insights-tasks.js";
|
|
67
|
+
export { SiteLinkSource, SiteLinkSourceStatus, } from "./admin-site-links.js";
|
|
68
|
+
export { PRIVATE_UPTIME_FAILURES, PRIVATE_UPTIME_STATUSES, SITE_HEARTBEAT_OUTCOMES, SITE_HEARTBEAT_STATUSES, } from "./admin-site-monitors.js";
|
|
69
|
+
export { SITE_NEXT_ACTIONS_MAX, SiteNextActionKind, SiteNextActionPlace, SiteNotChecked, } from "./admin-site-next-actions.js";
|
|
70
|
+
export { SitePageLinkSourceWhere, SitePageQueriesState, SiteTitleTemplate, } from "./admin-site-page-queries.js";
|
|
71
|
+
export { SITE_RANKINGS_DAYS_INVALID_CODE, SITE_RANKINGS_DEFAULT_DAYS, SITE_RANKINGS_MAX_DAYS, SITE_TRACKED_KEYWORD_ALL, SITE_TRACKED_KEYWORD_DEFAULT_NOTIFY_POSITION, SITE_TRACKED_KEYWORD_DUPLICATE_CODE, SITE_TRACKED_KEYWORD_INVALID_CODE, SITE_TRACKED_KEYWORD_LIMIT_CODE, SITE_TRACKED_KEYWORD_NOT_FOUND_CODE, SITE_TRACKED_KEYWORDS_MAX, SiteRankDevice, SiteRankingsSource, SiteRankState, SiteTrackedKeywordStatus, } from "./admin-site-rankings.js";
|
|
72
|
+
export { SAVED_SITE_REPORT_LIMIT_CODE, SAVED_SITE_REPORT_NAME_TAKEN_CODE, SITE_SAVED_REPORTS_MAX, SiteReportTemplate, } from "./admin-site-saved-reports.js";
|
|
73
|
+
export { SEARCH_POOL_MIN_CONTRIBUTORS, SEARCH_POOL_MIN_IMPRESSIONS, SEARCH_POOL_QUERIES_DEFAULT_LIMIT, SEARCH_POOL_QUERIES_MAX_LIMIT, SEARCH_POOL_SEARCH_MAX_LENGTH, SEARCH_POOL_TERMS_VERSION, SEARCH_POOL_WINDOW_DAYS, SearchPoolAccess, SearchPoolDemandBand, SITE_SEARCH_POOL_NOT_JOINED_CODE, SITE_SEARCH_POOL_QUERY_INVALID_CODE, SITE_SEARCH_POOL_SETTING_INVALID_CODE, SITE_SEARCH_POOL_SITE_BOUND_CODE, } from "./admin-site-search-pool.js";
|
|
74
|
+
export { SITE_FINDING_IMPACT_DEFAULT_DAYS, SITE_FINDING_IMPACT_MAX_DAYS, SITE_FINDING_IMPACT_MIN_DAYS, SITE_SEARCH_VALUE_DEFAULT_DAYS, SITE_SEARCH_VALUE_MAX_DAYS, SITE_SEARCH_VALUE_MAX_GOALS, SITE_SEARCH_VALUE_MAX_PAGES, SiteFindingImpactStatus, SiteSearchGoalStatus, } from "./admin-site-search-value.js";
|
|
75
|
+
export { siteStatusPagePublicUrl, } from "./admin-site-status-page.js";
|
|
76
|
+
export { ACCESS_LOG_HOUR_INVALID_CODE, AccessLogHourStatus, SiteCrawlerIdentity, SiteReferrerClass, SiteTrafficDayCoverage, TRAFFIC_OTHER_KEY, } from "./admin-site-traffic.js";
|
|
77
|
+
export { SITE_KEYWORD_DEMAND_SOURCE_BING, SITE_KEYWORD_LIST_LIMIT_CODE, SITE_KEYWORD_LIST_NOT_FOUND_CODE, SiteContentGapCoverage, SiteKeywordDemandState, SiteTopicTrendSource, SiteTopicTrendStatus, SiteTrancoBand, SiteWebDomainRole, SiteWebInventoryStatus, SiteWebPageSource, } from "./admin-site-web-data.js";
|
|
20
78
|
export { SubjectExportClient, } from "./admin-subject-exports.js";
|
|
21
79
|
export { TenantStorageClient, } from "./admin-tenant-storage.js";
|
|
22
80
|
export { TimePlanAdminClient, validateTimePlanDefinition, } from "./admin-timeplans.js";
|
|
23
|
-
export {
|
|
81
|
+
export { USAGE_DEFAULT_LIMIT, USAGE_MAX_LIMIT, UsageAdminClient, } from "./admin-usage.js";
|
|
82
|
+
export { ANALYTICS_MAX_LABEL_FILTERS, ANALYTICS_MAX_RANGE_DAYS, ANALYTICS_RANGE_GROUP_BY, AnalyticsEventClient, } from "./analytics-events.js";
|
|
24
83
|
export { BackendLifecycleClient, createVerifiedOffboardingExportReceiver, } from "./backend-lifecycle.js";
|
|
84
|
+
export { BrowserSignIn, createSignInCodeChallenge, DEFAULT_SIGN_IN_SCOPES, SIGN_IN_ERROR_CODES, SIGN_IN_STATUSES, SignInError, signInConfigFromDiscovery, } from "./browser-sign-in.js";
|
|
85
|
+
export { DEFAULT_PARSER_FRAMING_MAX_LINES, DEFAULT_PARSER_FRAMING_MAX_RECORD_BYTES, MAX_PARSER_FRAMING_LINES, MAX_PARSER_FRAMING_RECORD_BYTES, ParserClient, } from "./parsers.js";
|
|
25
86
|
export { classifyReportingData, getReportingViewState, reportingQueryKey, } from "./reporting-state.js";
|
|
26
87
|
export { checkRuntimeReadiness, } from "./runtime-readiness.js";
|
|
27
88
|
export { createMobileAsyncQueueStorage, createMobileFlushTriggers, } from "./mobile-adapter.js";
|
|
28
89
|
export { createMobileEvent, } from "./mobile-context.js";
|
|
29
90
|
export { AsyncEventQueue } from "./mobile-queue.js";
|
|
91
|
+
/**
|
|
92
|
+
* Mint a fresh key from the current time and a random UUIDv4. Mint it ONCE per
|
|
93
|
+
* request object so a resend reuses the key; a genuinely repeated occurrence
|
|
94
|
+
* needs a new request object and therefore a new key.
|
|
95
|
+
*/
|
|
96
|
+
export function createRawRequestIdempotencyKey() {
|
|
97
|
+
return `${Date.now()}:${randomUUID()}`;
|
|
98
|
+
}
|
|
99
|
+
/** Mint one prepared request with a fresh, retained idempotency key. */
|
|
100
|
+
export function createRawIngestRequest(input) {
|
|
101
|
+
return { ...input, idempotencyKey: createRawRequestIdempotencyKey() };
|
|
102
|
+
}
|
|
30
103
|
export class AdminWorkflowError extends Error {
|
|
31
104
|
constructor(status, reason, code, safeNextAction) {
|
|
32
105
|
let message = `custd: ${reason || "admin workflow request failed"} (status ${status})`;
|
|
@@ -60,9 +133,37 @@ export class CustdRequestError extends Error {
|
|
|
60
133
|
(this.status !== null && this.status >= 500));
|
|
61
134
|
}
|
|
62
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* CustdRawAcceptanceUnknownError reports that a raw upload's acceptance could
|
|
138
|
+
* not be determined: the connection failed before a response arrived, the 202
|
|
139
|
+
* acceptance body was missing or malformed, or the response carried a status
|
|
140
|
+
* that does not prove rejection. The request may or may not have landed, so
|
|
141
|
+
* this error carries no retry guidance (`retryability` "none", `nextAction`
|
|
142
|
+
* "escalate"): there is no verified occurrence identity, and replaying the POST
|
|
143
|
+
* could double-land accepted records. The cause never carries the request
|
|
144
|
+
* payload or a token.
|
|
145
|
+
*/
|
|
146
|
+
export class CustdRawAcceptanceUnknownError extends Error {
|
|
147
|
+
constructor(options) {
|
|
148
|
+
super("custd: raw upload acceptance is unknown; the request may or may not have landed and must not be replayed");
|
|
149
|
+
this.name = "CustdRawAcceptanceUnknownError";
|
|
150
|
+
this.retryability = "none";
|
|
151
|
+
this.nextAction = { action: "escalate" };
|
|
152
|
+
this.cause = options?.cause;
|
|
153
|
+
this.operationKey = options?.operationKey;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** A 404 on schema audit: the named tenant does not exist. */
|
|
157
|
+
export const SCHEMA_AUDIT_TENANT_NOT_FOUND_CODE = "schema_audit_tenant_not_found";
|
|
158
|
+
/** A 400 on schema audit: the request names no tenantSlug. */
|
|
159
|
+
export const SCHEMA_AUDIT_TENANT_SLUG_REQUIRED_CODE = "schema_audit_tenant_slug_required";
|
|
63
160
|
function publicAdminSite(site) {
|
|
64
161
|
const { writeKey: _writeKey, ...safeSite } = site;
|
|
65
|
-
return
|
|
162
|
+
return {
|
|
163
|
+
...safeSite,
|
|
164
|
+
allowedOrigins: site.allowedOrigins ?? [],
|
|
165
|
+
allowedEnvironments: site.allowedEnvironments ?? [],
|
|
166
|
+
};
|
|
66
167
|
}
|
|
67
168
|
export class MemoryQueueStorage {
|
|
68
169
|
constructor() {
|
|
@@ -139,6 +240,7 @@ export class CustdClient {
|
|
|
139
240
|
// The SDK's own identity is authoritative: a caller may add default
|
|
140
241
|
// headers, but cannot accidentally drop the release Custd records.
|
|
141
242
|
this.defaultHeaders = { ...(config.defaultHeaders ?? {}), "X-Custd-Sdk": SDK_IDENTITY };
|
|
243
|
+
this.actingCompanySlug = config.actingCompanySlug?.trim() ?? "";
|
|
142
244
|
this.retry = normalizeRetryOptions(config.retry);
|
|
143
245
|
this.batch = config.batch;
|
|
144
246
|
this.queueEnabled = config.queue?.enabled ?? config.batch != null;
|
|
@@ -152,6 +254,10 @@ export class CustdClient {
|
|
|
152
254
|
this.reporting = new ReportingNamespace((method, path, body, options) => this.apiRequest(method, path, body, options), (path, options) => this.apiDownload(path, options));
|
|
153
255
|
this.schemas = new SchemaNamespace((method, path, body) => this.apiRequest(method, path, body));
|
|
154
256
|
this.analytics = new AnalyticsEventClient((method, path, body, options) => this.apiRequest(method, path, body, options));
|
|
257
|
+
this.parsers = new ParserClient((method, path, body, options) => this.apiRequest(method, path, body, options));
|
|
258
|
+
this.measurement = new MeasurementClient((method, path, body, options) => this.apiRequest(method, path, body, options));
|
|
259
|
+
this.ingestOperations = new IngestOperationsClient((method, path, body, options, headers) => this.apiRequest(method, path, body, options, headers), this.actingCompanySlug);
|
|
260
|
+
this.publicReads = new PublicReadClient((path, headers, options) => this.publicRead(path, headers, options), (path, body, options) => this.publicWrite(path, body, options));
|
|
155
261
|
if (this.queueEnabled) {
|
|
156
262
|
this.queue = this.queueStorage.load();
|
|
157
263
|
}
|
|
@@ -251,7 +357,6 @@ export class CustdClient {
|
|
|
251
357
|
validateEvent(prepared);
|
|
252
358
|
return this.sendWithRetry(prepared);
|
|
253
359
|
}
|
|
254
|
-
// biome-ignore lint/suspicious/noConfusingVoidType: public return type — track() resolves to nothing when queued, or a Response when sent immediately.
|
|
255
360
|
async track(event) {
|
|
256
361
|
const prepared = prepareEvent(event);
|
|
257
362
|
validateEvent(prepared);
|
|
@@ -314,6 +419,71 @@ export class CustdClient {
|
|
|
314
419
|
}
|
|
315
420
|
this.removeFlushTriggers = [];
|
|
316
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Upload raw, line-delimited content for the bound parser.
|
|
424
|
+
*
|
|
425
|
+
* X-Parser-UUID binds the parser exactly as direct collectors do. When
|
|
426
|
+
* `target` is supplied its paired subClient/resource codes are appended as
|
|
427
|
+
* query parameters: a declarative default the backend applies to records with
|
|
428
|
+
* no canonical selection and refuses to let override an explicit selection.
|
|
429
|
+
*
|
|
430
|
+
* The route answers 202 Accepted, so the status alone is not success. Read
|
|
431
|
+
* `processed` and `failed` on the returned result.
|
|
432
|
+
*
|
|
433
|
+
* A transport failure or an unusable acceptance body cannot prove whether the
|
|
434
|
+
* upload landed, so it throws {@link CustdRawAcceptanceUnknownError} — which
|
|
435
|
+
* carries no retry guidance — rather than a retryable transport error.
|
|
436
|
+
* Replaying the POST could double-land accepted records; the SDK never retries
|
|
437
|
+
* this operation automatically.
|
|
438
|
+
*/
|
|
439
|
+
async ingestRawLines(request, options) {
|
|
440
|
+
const parserUuid = assertRawParserUuid(request.parserUuid);
|
|
441
|
+
const params = new URLSearchParams();
|
|
442
|
+
if (request.target !== undefined) {
|
|
443
|
+
assertRawSourceTarget(request.target);
|
|
444
|
+
params.set("subClient", request.target.subClient);
|
|
445
|
+
params.set("resource", request.target.resource);
|
|
446
|
+
}
|
|
447
|
+
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
448
|
+
const token = await this.getToken(options);
|
|
449
|
+
const headers = {
|
|
450
|
+
...this.defaultHeaders,
|
|
451
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
452
|
+
Authorization: `Bearer ${token}`,
|
|
453
|
+
"X-Parser-UUID": parserUuid,
|
|
454
|
+
};
|
|
455
|
+
const operationKey = request.idempotencyKey;
|
|
456
|
+
if (operationKey !== undefined && operationKey !== "") {
|
|
457
|
+
headers["Idempotency-Key"] = operationKey;
|
|
458
|
+
}
|
|
459
|
+
let response;
|
|
460
|
+
try {
|
|
461
|
+
response = await this.fetchImpl(`${this.baseUrl}/api/v1/raw${query}`, {
|
|
462
|
+
method: "POST",
|
|
463
|
+
headers,
|
|
464
|
+
body: request.content,
|
|
465
|
+
signal: options?.signal,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
catch (error) {
|
|
469
|
+
// A disconnect cannot prove whether the upload landed; offer no retry.
|
|
470
|
+
throw new CustdRawAcceptanceUnknownError({ cause: error, operationKey });
|
|
471
|
+
}
|
|
472
|
+
if (!response.ok) {
|
|
473
|
+
if (this.retry.retryOnStatuses.includes(response.status)) {
|
|
474
|
+
throw new CustdRawAcceptanceUnknownError({ operationKey });
|
|
475
|
+
}
|
|
476
|
+
throw await problemError(response, `custd: raw ingest failed with status ${response.status}`);
|
|
477
|
+
}
|
|
478
|
+
let value;
|
|
479
|
+
try {
|
|
480
|
+
value = await response.json();
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
throw new CustdRawAcceptanceUnknownError({ cause: error, operationKey });
|
|
484
|
+
}
|
|
485
|
+
return validateRawIngestResult(value, operationKey);
|
|
486
|
+
}
|
|
317
487
|
async sendWithRetry(event) {
|
|
318
488
|
return withRetry(this.retry, async () => {
|
|
319
489
|
const token = await this.getToken();
|
|
@@ -408,66 +578,67 @@ export class CustdClient {
|
|
|
408
578
|
return `custd: batch rejected ${failed.length} of ${results?.length ?? failed.length} event(s): ${parts.join("; ")}`;
|
|
409
579
|
}
|
|
410
580
|
async adminRequest(method, path, body, options) {
|
|
411
|
-
return this.apiRequest(method, `/admin${path}`, body, options);
|
|
581
|
+
return this.apiRequest(method, `/admin${this.actingCompanyPath(path)}`, body, options);
|
|
412
582
|
}
|
|
413
|
-
|
|
583
|
+
// actingCompanyPath names the configured acting company in the `companySlug` query
|
|
584
|
+
// the admin routes read, keeping a selector the call already set.
|
|
585
|
+
actingCompanyPath(path) {
|
|
586
|
+
if (this.actingCompanySlug === "") {
|
|
587
|
+
return path;
|
|
588
|
+
}
|
|
589
|
+
const [route, query = ""] = path.split("?", 2);
|
|
590
|
+
const params = new URLSearchParams(query);
|
|
591
|
+
if (params.get("companySlug")) {
|
|
592
|
+
return path;
|
|
593
|
+
}
|
|
594
|
+
params.set("companySlug", this.actingCompanySlug);
|
|
595
|
+
return `${route}?${params.toString()}`;
|
|
596
|
+
}
|
|
597
|
+
async adminDownload(path, operation, options) {
|
|
414
598
|
const token = await this.getToken(options);
|
|
415
|
-
const response = await this.fetchImpl(`${this.baseUrl}/api/v1/admin${path}`, {
|
|
599
|
+
const response = await this.fetchImpl(`${this.baseUrl}/api/v1/admin${this.actingCompanyPath(path)}`, {
|
|
416
600
|
method: "GET",
|
|
417
601
|
headers: { Authorization: `Bearer ${token}`, ...this.defaultHeaders },
|
|
418
602
|
signal: options?.signal,
|
|
419
603
|
});
|
|
420
604
|
if (!response.ok) {
|
|
421
|
-
throw new Error(`custd:
|
|
605
|
+
throw new Error(`custd: ${operation} failed with status ${response.status}`);
|
|
422
606
|
}
|
|
607
|
+
return response;
|
|
608
|
+
}
|
|
609
|
+
async offboardingDownload(path, options) {
|
|
610
|
+
const response = await this.adminDownload(path, "offboarding download", options);
|
|
423
611
|
const lengthHeader = response.headers.get("content-length")?.trim() ?? "";
|
|
424
612
|
const byteSize = Number(lengthHeader);
|
|
613
|
+
const checksumSha256 = (response.headers.get("x-checksum-sha256") ?? "").trim().toLowerCase();
|
|
425
614
|
if (!/^\d+$/.test(lengthHeader) || !Number.isSafeInteger(byteSize)) {
|
|
615
|
+
await response.body?.cancel();
|
|
426
616
|
throw new Error("custd: offboarding download content length is invalid");
|
|
427
617
|
}
|
|
428
|
-
if (byteSize > maxOffboardingDownloadBytes) {
|
|
429
|
-
throw new Error("custd: offboarding download exceeds 64 MiB");
|
|
430
|
-
}
|
|
431
|
-
const bytes = await readBoundedResponse(response, maxOffboardingDownloadBytes, "offboarding download");
|
|
432
|
-
if (bytes.byteLength !== byteSize) {
|
|
433
|
-
throw new Error("custd: offboarding download content length mismatch");
|
|
434
|
-
}
|
|
435
|
-
const checksumSha256 = (response.headers.get("x-checksum-sha256") ?? "").trim().toLowerCase();
|
|
436
618
|
if (!/^[a-f0-9]{64}$/.test(checksumSha256)) {
|
|
619
|
+
await response.body?.cancel();
|
|
437
620
|
throw new Error("custd: offboarding download checksum header is invalid");
|
|
438
621
|
}
|
|
439
|
-
|
|
440
|
-
if (actual !== checksumSha256) {
|
|
441
|
-
throw new Error("custd: offboarding download checksum mismatch");
|
|
442
|
-
}
|
|
443
|
-
return { bytes, checksumSha256, byteSize };
|
|
622
|
+
return { ...responseDownloadStream(response, "offboarding download", byteSize), byteSize, checksumSha256 };
|
|
444
623
|
}
|
|
445
624
|
async auditExportDownload(path, options) {
|
|
446
|
-
|
|
447
|
-
const response = await this.fetchImpl(`${this.baseUrl}/api/v1/admin${path}`, {
|
|
448
|
-
method: "GET",
|
|
449
|
-
headers: { Authorization: `Bearer ${token}`, ...this.defaultHeaders },
|
|
450
|
-
signal: options?.signal,
|
|
451
|
-
});
|
|
452
|
-
if (!response.ok) {
|
|
453
|
-
throw new Error(`custd: audit export failed with status ${response.status}`);
|
|
454
|
-
}
|
|
455
|
-
const bytes = await readBoundedResponse(response, maxAuditExportBytes, "audit export download");
|
|
456
|
-
return { bytes, contentType: response.headers.get("content-type") ?? "" };
|
|
625
|
+
return responseDownloadStream(await this.adminDownload(path, "audit export", options), "audit export");
|
|
457
626
|
}
|
|
458
|
-
async apiRequest(method, path, body, options) {
|
|
627
|
+
async apiRequest(method, path, body, options, headers) {
|
|
459
628
|
const token = await this.getToken(options);
|
|
460
629
|
let response;
|
|
461
630
|
try {
|
|
462
631
|
response = await this.fetchImpl(`${this.baseUrl}/api/v1${path}`, {
|
|
463
632
|
method,
|
|
464
633
|
headers: {
|
|
465
|
-
|
|
634
|
+
...requestContentType(body),
|
|
466
635
|
Authorization: `Bearer ${token}`,
|
|
467
636
|
...this.defaultHeaders,
|
|
637
|
+
...headers,
|
|
468
638
|
...(options?.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {}),
|
|
639
|
+
...(options?.owningUserUuid ? { "X-Custd-Owning-User-UUID": options.owningUserUuid } : {}),
|
|
469
640
|
},
|
|
470
|
-
body:
|
|
641
|
+
body: requestBody(body),
|
|
471
642
|
signal: options?.signal,
|
|
472
643
|
});
|
|
473
644
|
}
|
|
@@ -509,7 +680,49 @@ export class CustdClient {
|
|
|
509
680
|
if (response.status === 204) {
|
|
510
681
|
return undefined;
|
|
511
682
|
}
|
|
512
|
-
return (await response.json());
|
|
683
|
+
return emptyApiNullLists(method, `/api/v1${path}`, (await response.json()));
|
|
684
|
+
}
|
|
685
|
+
// publicRead issues a GET that carries none of the client's own credentials.
|
|
686
|
+
async publicRead(path, headers, options) {
|
|
687
|
+
let response;
|
|
688
|
+
try {
|
|
689
|
+
response = await this.fetchImpl(`${this.baseUrl}/api/v1${path}`, {
|
|
690
|
+
method: "GET",
|
|
691
|
+
headers: { ...headers, "X-Custd-Sdk": SDK_IDENTITY },
|
|
692
|
+
signal: options?.signal,
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
catch (error) {
|
|
696
|
+
throw transportRequestError(error);
|
|
697
|
+
}
|
|
698
|
+
if (!response.ok)
|
|
699
|
+
throw await responseRequestError(response, "request_failed");
|
|
700
|
+
return emptyApiNullLists("GET", `/api/v1${path}`, (await response.json()));
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Opens a data-space owner's AI settings session from a handoff, on the broker's hub server.
|
|
704
|
+
* hubOrigin is the broker's registered hub origin; the session never sends this client's credential.
|
|
705
|
+
*/
|
|
706
|
+
redeemSiteAIOwnerHandoff(handoff, hubOrigin, options) {
|
|
707
|
+
const failure = (response) => responseRequestError(response, "request_failed");
|
|
708
|
+
return redeemSiteAIOwnerHandoff({ fetch: this.fetchImpl, failure }, handoff, hubOrigin, options);
|
|
709
|
+
}
|
|
710
|
+
// publicWrite posts JSON that carries none of the client's own credentials and expects no body back.
|
|
711
|
+
async publicWrite(path, body, options) {
|
|
712
|
+
let response;
|
|
713
|
+
try {
|
|
714
|
+
response = await this.fetchImpl(`${this.baseUrl}/api/v1${path}`, {
|
|
715
|
+
method: "POST",
|
|
716
|
+
headers: { "Content-Type": "application/json", "X-Custd-Sdk": SDK_IDENTITY },
|
|
717
|
+
body: JSON.stringify(body),
|
|
718
|
+
signal: options?.signal,
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
catch (error) {
|
|
722
|
+
throw transportRequestError(error);
|
|
723
|
+
}
|
|
724
|
+
if (!response.ok)
|
|
725
|
+
throw await responseRequestError(response, "request_failed");
|
|
513
726
|
}
|
|
514
727
|
async apiDownload(path, options) {
|
|
515
728
|
const token = await this.getToken(options);
|
|
@@ -529,38 +742,22 @@ export class CustdClient {
|
|
|
529
742
|
return bytes;
|
|
530
743
|
}
|
|
531
744
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
let total = 0;
|
|
539
|
-
while (true) {
|
|
540
|
-
const { done, value } = await reader.read();
|
|
541
|
-
if (done)
|
|
542
|
-
break;
|
|
543
|
-
total += value.byteLength;
|
|
544
|
-
if (total > maxBytes) {
|
|
545
|
-
await reader.cancel();
|
|
546
|
-
throw new Error(`custd: ${operation} exceeds 64 MiB`);
|
|
547
|
-
}
|
|
548
|
-
chunks.push(value);
|
|
549
|
-
}
|
|
550
|
-
const result = new Uint8Array(total);
|
|
551
|
-
let offset = 0;
|
|
552
|
-
for (const chunk of chunks) {
|
|
553
|
-
result.set(chunk, offset);
|
|
554
|
-
offset += chunk.byteLength;
|
|
555
|
-
}
|
|
556
|
-
return result;
|
|
745
|
+
// A byte body is a file upload sent as raw bytes, a form is a multipart upload whose boundary fetch
|
|
746
|
+
// sets, and every other body is JSON.
|
|
747
|
+
function requestContentType(body) {
|
|
748
|
+
if (body instanceof FormData)
|
|
749
|
+
return {};
|
|
750
|
+
return { "Content-Type": body instanceof Uint8Array ? "application/octet-stream" : "application/json" };
|
|
557
751
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
752
|
+
function requestBody(body) {
|
|
753
|
+
if (body === undefined)
|
|
754
|
+
return undefined;
|
|
755
|
+
if (body instanceof FormData)
|
|
756
|
+
return body;
|
|
757
|
+
if (body instanceof Uint8Array)
|
|
758
|
+
return Uint8Array.from(body);
|
|
759
|
+
return JSON.stringify(body);
|
|
561
760
|
}
|
|
562
|
-
const maxOffboardingDownloadBytes = 64 * 1024 * 1024;
|
|
563
|
-
const maxAuditExportBytes = 64 * 1024 * 1024;
|
|
564
761
|
class ReportingNamespace {
|
|
565
762
|
constructor(request, download) {
|
|
566
763
|
this.request = request;
|
|
@@ -571,10 +768,11 @@ class ReportingNamespace {
|
|
|
571
768
|
throw new Error("custd: report export requires a dashboard key and 1 to 8 formats");
|
|
572
769
|
return this.request("POST", "/reporting/exports", input, options);
|
|
573
770
|
}
|
|
574
|
-
listExports(limit = 50, options) {
|
|
771
|
+
async listExports(limit = 50, options) {
|
|
575
772
|
if (!Number.isInteger(limit) || limit < 1 || limit > 100)
|
|
576
773
|
throw new Error("custd: report export limit must be between 1 and 100");
|
|
577
|
-
|
|
774
|
+
const list = await this.request("GET", `/reporting/exports?limit=${limit}`, undefined, options);
|
|
775
|
+
return { exports: list.exports ?? [] };
|
|
578
776
|
}
|
|
579
777
|
getExport(exportId, options) {
|
|
580
778
|
assertUuid(exportId, "exportId");
|
|
@@ -589,6 +787,42 @@ class ReportingNamespace {
|
|
|
589
787
|
assertUuid(artifactId, "artifactId");
|
|
590
788
|
return this.download(`/reporting/exports/${encodeURIComponent(exportId)}/artifacts/${encodeURIComponent(artifactId)}`, options);
|
|
591
789
|
}
|
|
790
|
+
/** Exports a completed time-plan run's frozen report source in one to eight formats. */
|
|
791
|
+
async createCompletedRunExport(input, options) {
|
|
792
|
+
if (input.formats.length < 1 || input.formats.length > 8)
|
|
793
|
+
throw new Error("custd: completed run export requires 1 to 8 formats");
|
|
794
|
+
const job = await this.request("POST", "/reporting/exports/completed-run", input, options);
|
|
795
|
+
return { ...job, formats: job.formats ?? [] };
|
|
796
|
+
}
|
|
797
|
+
/** Lists the dashboards the tenant can open. */
|
|
798
|
+
async dashboards(options) {
|
|
799
|
+
const response = await this.request("GET", "/reporting/dashboards", undefined, options);
|
|
800
|
+
return {
|
|
801
|
+
dashboards: (response.dashboards ?? []).map((entry) => ({
|
|
802
|
+
...entry,
|
|
803
|
+
interactions: entry.interactions ?? [],
|
|
804
|
+
exportFormats: entry.exportFormats ?? [],
|
|
805
|
+
})),
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
/** Starts, or returns, the data generation that backs one dashboard view. */
|
|
809
|
+
async generateDashboardData(input, options) {
|
|
810
|
+
const generation = await this.request("POST", "/reporting/dashboard-data-generations", input, options);
|
|
811
|
+
return {
|
|
812
|
+
...generation,
|
|
813
|
+
datasetRowCounts: generation.datasetRowCounts ?? [],
|
|
814
|
+
datasetSchemas: (generation.datasetSchemas ?? []).map((schema) => ({ ...schema, columns: schema.columns ?? [] })),
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
/** Renders one query against a pack definition that is not published. */
|
|
818
|
+
async previewDraft(input, options) {
|
|
819
|
+
const data = await this.request("POST", "/reporting/draft-preview", input, options);
|
|
820
|
+
emptyNullBuckets(data);
|
|
821
|
+
if (!isRenderedWidgetData(data)) {
|
|
822
|
+
throw new Error("custd: invalid reporting draft preview response");
|
|
823
|
+
}
|
|
824
|
+
return data;
|
|
825
|
+
}
|
|
592
826
|
dashboard(key, options) {
|
|
593
827
|
return this.request("GET", `/reporting/dashboards/${encodeURIComponent(key)}`, undefined, options);
|
|
594
828
|
}
|
|
@@ -609,6 +843,7 @@ class ReportingNamespace {
|
|
|
609
843
|
}
|
|
610
844
|
async query(request, options) {
|
|
611
845
|
const data = await this.request("POST", "/reporting/query", request, options);
|
|
846
|
+
emptyNullBuckets(data);
|
|
612
847
|
if (!isRenderedWidgetData(data)) {
|
|
613
848
|
throw new Error("custd: invalid reporting query response");
|
|
614
849
|
}
|
|
@@ -622,6 +857,8 @@ class ReportingNamespace {
|
|
|
622
857
|
throw new Error("custd: invalid subject insight request");
|
|
623
858
|
}
|
|
624
859
|
const response = await this.request("POST", "/reporting/insights/subject", request, options);
|
|
860
|
+
if (isRecord(response))
|
|
861
|
+
emptyNullBuckets(response.data);
|
|
625
862
|
if (!isSubjectInsightResponse(response)) {
|
|
626
863
|
throw new Error("custd: invalid subject insight response");
|
|
627
864
|
}
|
|
@@ -690,6 +927,11 @@ function isValidRfc3339(value) {
|
|
|
690
927
|
offsetMinute <= 59 &&
|
|
691
928
|
(offsetHour !== 24 || offsetMinute === 0));
|
|
692
929
|
}
|
|
930
|
+
/** A JSON null bucket list decodes as empty. */
|
|
931
|
+
function emptyNullBuckets(value) {
|
|
932
|
+
if (isRecord(value) && value.buckets === null)
|
|
933
|
+
value.buckets = [];
|
|
934
|
+
}
|
|
693
935
|
function isSubjectInsightResponse(value) {
|
|
694
936
|
if (!isRecord(value) || !isRenderedWidgetData(value.data))
|
|
695
937
|
return false;
|
|
@@ -809,6 +1051,40 @@ class SchemaNamespace {
|
|
|
809
1051
|
infer(input) {
|
|
810
1052
|
return this.request("POST", "/schemas/infer", input);
|
|
811
1053
|
}
|
|
1054
|
+
/** Lists the tenant's event types. */
|
|
1055
|
+
async list() {
|
|
1056
|
+
const eventTypes = await this.request("GET", schemaRegistryPath);
|
|
1057
|
+
return { eventTypes: eventTypes ?? [] };
|
|
1058
|
+
}
|
|
1059
|
+
/** Lists an event type's schema versions. */
|
|
1060
|
+
async listVersions(eventType) {
|
|
1061
|
+
const versions = await this.request("GET", `${eventSchemaPath(eventType)}/versions`);
|
|
1062
|
+
return { versions: versions ?? [] };
|
|
1063
|
+
}
|
|
1064
|
+
/** Returns one version's JSON Schema document. */
|
|
1065
|
+
async get(eventType, version) {
|
|
1066
|
+
return { schema: await this.request("GET", eventSchemaPath(eventType, version)) };
|
|
1067
|
+
}
|
|
1068
|
+
/** Stores a schema version, creating the event type when it is new, and returns the event type. */
|
|
1069
|
+
register(input) {
|
|
1070
|
+
return this.request("POST", schemaRegistryPath, input);
|
|
1071
|
+
}
|
|
1072
|
+
/** Makes one version the event type's active schema. */
|
|
1073
|
+
activate(eventType, version) {
|
|
1074
|
+
return this.request("POST", `${eventSchemaPath(eventType, version)}/active`);
|
|
1075
|
+
}
|
|
1076
|
+
/** Lets events validate against one version again. */
|
|
1077
|
+
enable(eventType, version) {
|
|
1078
|
+
return this.request("PUT", `${eventSchemaPath(eventType, version)}/enabled`);
|
|
1079
|
+
}
|
|
1080
|
+
/** Deprecates one version so new events no longer validate against it. */
|
|
1081
|
+
disable(eventType, version) {
|
|
1082
|
+
return this.request("DELETE", `${eventSchemaPath(eventType, version)}/enabled`);
|
|
1083
|
+
}
|
|
1084
|
+
/** Retires the tenant's event type. Its schemas and stored events stay readable. */
|
|
1085
|
+
disableEventType(eventType) {
|
|
1086
|
+
return this.request("DELETE", eventSchemaPath(eventType));
|
|
1087
|
+
}
|
|
812
1088
|
async sendTestEvent(event) {
|
|
813
1089
|
const prepared = prepareEvent(event);
|
|
814
1090
|
validateEvent(prepared);
|
|
@@ -822,11 +1098,14 @@ class SchemaNamespace {
|
|
|
822
1098
|
class AdminNamespace {
|
|
823
1099
|
constructor(request, nonAdminRequest, offboardingDownload, auditExportDownload) {
|
|
824
1100
|
this.dataLabels = new DataLabelAdminClient(request);
|
|
1101
|
+
this.dataScopes = new DataScopeAdminClient(request);
|
|
825
1102
|
this.tenants = new AdminTenantNamespace(request);
|
|
826
1103
|
this.lifecycle = new BackendLifecycleClient(request, offboardingDownload);
|
|
827
1104
|
this.clientSetup = new ClientSetupClient(request);
|
|
828
1105
|
this.oauthClients = new AdminOAuthClientNamespace(request);
|
|
829
1106
|
this.sites = new AdminSiteNamespace(request);
|
|
1107
|
+
this.siteDomains = new SiteDomainAdminClient(nonAdminRequest);
|
|
1108
|
+
this.siteInsights = new SiteInsightsAdminClient(request);
|
|
830
1109
|
this.schemas = new AdminSchemaNamespace(request);
|
|
831
1110
|
this.measurement = new AdminMeasurementNamespace(request);
|
|
832
1111
|
this.predictions = new PredictionAdminClient(request);
|
|
@@ -840,6 +1119,27 @@ class AdminNamespace {
|
|
|
840
1119
|
this.subjectExports = new SubjectExportClient(request);
|
|
841
1120
|
this.privacyErasures = new PrivacyErasureClient(request);
|
|
842
1121
|
this.timePlans = new TimePlanAdminClient(request);
|
|
1122
|
+
this.usage = new UsageAdminClient(request);
|
|
1123
|
+
this.authProjects = new AuthProjectAdminClient(request);
|
|
1124
|
+
this.workflowTimings = new WorkflowTimingAdminClient(request);
|
|
1125
|
+
this.users = new AdminUserAdminClient(request);
|
|
1126
|
+
this.uncertaintyModels = new UncertaintyModelAdminClient(request);
|
|
1127
|
+
this.impersonation = new ImpersonationAdminClient(request);
|
|
1128
|
+
this.supportAccess = new SupportAccessAdminClient(request);
|
|
1129
|
+
this.system = new SystemAdminClient(request);
|
|
1130
|
+
this.environmentPolicy = new EnvironmentPolicyAdminClient(request);
|
|
1131
|
+
this.rls = new RlsAdminClient(request);
|
|
1132
|
+
this.oauthClientAdmissions = new OAuthClientAdmissionAdminClient(request);
|
|
1133
|
+
this.sdkUsage = new SdkUsageAdminClient(request);
|
|
1134
|
+
this.ingestClaims = new IngestClaimAdminClient(request);
|
|
1135
|
+
this.accountingEvidence = new AccountingEvidenceAdminClient(request);
|
|
1136
|
+
this.webhooks = new NotificationWebhookAdminClient(request);
|
|
1137
|
+
this.notificationDestinations = new NotificationDestinationAdminClient(nonAdminRequest);
|
|
1138
|
+
this.emailRelay = new EmailRelayAdminClient(request);
|
|
1139
|
+
this.campaignEmail = new CampaignEmailAdminClient(request);
|
|
1140
|
+
this.eventTypes = new EventTypeAdminClient(request);
|
|
1141
|
+
this.errorIssues = new ErrorIssueAdminClient(nonAdminRequest);
|
|
1142
|
+
this.managedAudit = new ManagedAuditAdminClient(nonAdminRequest);
|
|
843
1143
|
}
|
|
844
1144
|
}
|
|
845
1145
|
class ProvisioningNamespace {
|
|
@@ -849,47 +1149,100 @@ class ProvisioningNamespace {
|
|
|
849
1149
|
this.reservations = new ProvisioningReservationsNamespace(request);
|
|
850
1150
|
}
|
|
851
1151
|
}
|
|
1152
|
+
/** Producer reservations under one data space. A system administrator names the parent tenant. */
|
|
852
1153
|
class ProvisioningReservationsNamespace {
|
|
853
1154
|
constructor(request) {
|
|
854
1155
|
this.request = request;
|
|
855
1156
|
}
|
|
856
|
-
reserve(dataSpaceSlug, body) {
|
|
857
|
-
return this.request("POST",
|
|
1157
|
+
reserve(dataSpaceSlug, body, parentCompanySlug) {
|
|
1158
|
+
return this.request("POST", reservationsPath(dataSpaceSlug, "", parentCompanySlug), body);
|
|
858
1159
|
}
|
|
859
|
-
list(dataSpaceSlug) {
|
|
860
|
-
return this.request("GET",
|
|
1160
|
+
list(dataSpaceSlug, parentCompanySlug) {
|
|
1161
|
+
return this.request("GET", reservationsPath(dataSpaceSlug, "", parentCompanySlug));
|
|
861
1162
|
}
|
|
862
|
-
claim(dataSpaceSlug, producerSlug, body) {
|
|
863
|
-
return this.request("POST",
|
|
1163
|
+
claim(dataSpaceSlug, producerSlug, body, parentCompanySlug) {
|
|
1164
|
+
return this.request("POST", reservationsPath(dataSpaceSlug, `/${encodeURIComponent(producerSlug)}/claim`, parentCompanySlug), body);
|
|
864
1165
|
}
|
|
865
|
-
release(dataSpaceSlug, producerSlug) {
|
|
866
|
-
return this.request("DELETE",
|
|
1166
|
+
release(dataSpaceSlug, producerSlug, parentCompanySlug) {
|
|
1167
|
+
return this.request("DELETE", reservationsPath(dataSpaceSlug, `/${encodeURIComponent(producerSlug)}`, parentCompanySlug));
|
|
867
1168
|
}
|
|
868
1169
|
}
|
|
1170
|
+
function reservationsPath(dataSpaceSlug, suffix, parentCompanySlug) {
|
|
1171
|
+
return `/data-spaces/${encodeURIComponent(dataSpaceSlug)}/producer-reservations${suffix}${parentQuery(parentCompanySlug)}`;
|
|
1172
|
+
}
|
|
869
1173
|
class ProvisioningDataSpaceNamespace {
|
|
870
1174
|
constructor(request) {
|
|
871
1175
|
this.request = request;
|
|
872
1176
|
}
|
|
873
|
-
|
|
874
|
-
|
|
1177
|
+
/** Creates a data space under the caller's company; a system administrator names the parent tenant. */
|
|
1178
|
+
create(dataSpace, parentCompanySlug) {
|
|
1179
|
+
return this.request("POST", `/data-spaces${parentQuery(parentCompanySlug)}`, dataSpace);
|
|
875
1180
|
}
|
|
876
|
-
|
|
877
|
-
|
|
1181
|
+
/** Lists the caller's data spaces; a system administrator names the parent tenant. */
|
|
1182
|
+
list(parentCompanySlug) {
|
|
1183
|
+
return this.request("GET", `/data-spaces${parentQuery(parentCompanySlug)}`);
|
|
1184
|
+
}
|
|
1185
|
+
/** Reads retained storage per data space. A system administrator names the parent tenant. */
|
|
1186
|
+
async usage(parentCompanySlug) {
|
|
1187
|
+
const summary = await this.request("GET", `/data-spaces/usage${parentQuery(parentCompanySlug)}`);
|
|
1188
|
+
return { ...summary, dataSpaces: summary.dataSpaces ?? [] };
|
|
1189
|
+
}
|
|
1190
|
+
revoke(slug, parentCompanySlug) {
|
|
1191
|
+
return this.request("DELETE", `/data-spaces/${encodeURIComponent(slug)}${parentQuery(parentCompanySlug)}`);
|
|
1192
|
+
}
|
|
1193
|
+
/** Asks Custd to erase everything a data space holds. The answer is the accepted request, not the finished erasure. */
|
|
1194
|
+
erase(slug, parentCompanySlug) {
|
|
1195
|
+
return this.request("POST", `/data-spaces/${encodeURIComponent(slug)}/erasure${parentQuery(parentCompanySlug)}`);
|
|
1196
|
+
}
|
|
1197
|
+
getErasure(slug, parentCompanySlug) {
|
|
1198
|
+
return this.request("GET", `/data-spaces/${encodeURIComponent(slug)}/erasure${parentQuery(parentCompanySlug)}`);
|
|
1199
|
+
}
|
|
1200
|
+
/** Reads whether a data space's signing producers are ready and what ingest refused. */
|
|
1201
|
+
async getSigningStatus(slug, parentCompanySlug) {
|
|
1202
|
+
const path = `/data-spaces/${encodeURIComponent(slug)}/signing-status${parentQuery(parentCompanySlug)}`;
|
|
1203
|
+
const status = await this.request("GET", path);
|
|
1204
|
+
return {
|
|
1205
|
+
...status,
|
|
1206
|
+
producers: (status.producers ?? []).map((producer) => ({
|
|
1207
|
+
...producer,
|
|
1208
|
+
keyFingerprints: producer.keyFingerprints ?? [],
|
|
1209
|
+
})),
|
|
1210
|
+
};
|
|
878
1211
|
}
|
|
879
|
-
|
|
880
|
-
|
|
1212
|
+
/**
|
|
1213
|
+
* Moves a parent's Site, with every record keyed to it, into the data space. Its credentials keep their
|
|
1214
|
+
* client id and secret. Repeating it answers `already_adopted`.
|
|
1215
|
+
*/
|
|
1216
|
+
async adoptSite(slug, siteUuid, parentCompanySlug) {
|
|
1217
|
+
const path = `/data-spaces/${encodeURIComponent(slug)}/sites/${encodeURIComponent(siteUuid)}/adopt${parentQuery(parentCompanySlug)}`;
|
|
1218
|
+
const adoption = await this.request("POST", path);
|
|
1219
|
+
return { ...adoption, credentialClientIds: adoption.credentialClientIds ?? [] };
|
|
881
1220
|
}
|
|
882
1221
|
}
|
|
1222
|
+
function parentQuery(parentCompanySlug) {
|
|
1223
|
+
return parentCompanySlug ? `?${new URLSearchParams({ parentCompanySlug })}` : "";
|
|
1224
|
+
}
|
|
1225
|
+
function provisionedProducer(credentials) {
|
|
1226
|
+
return {
|
|
1227
|
+
...credentials,
|
|
1228
|
+
scopes: credentials.scopes ?? [],
|
|
1229
|
+
allowedEnvironments: credentials.allowedEnvironments ?? [],
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
883
1232
|
class ProvisioningProducerNamespace {
|
|
884
1233
|
constructor(request) {
|
|
885
1234
|
this.request = request;
|
|
886
1235
|
}
|
|
887
|
-
provision(request) {
|
|
888
|
-
return this.request("POST", "/producer-provisioning", request);
|
|
1236
|
+
async provision(request) {
|
|
1237
|
+
return provisionedProducer(await this.request("POST", "/producer-provisioning", request));
|
|
889
1238
|
}
|
|
890
|
-
list(companySlug) {
|
|
1239
|
+
async list(companySlug) {
|
|
891
1240
|
const query = companySlug ? `?companySlug=${encodeURIComponent(companySlug)}` : "";
|
|
892
|
-
|
|
1241
|
+
const response = await this.request("GET", `/producer-provisioning${query}`);
|
|
1242
|
+
return { producers: (response.producers ?? []).map(publicProducer) };
|
|
1243
|
+
}
|
|
1244
|
+
async get(clientId) {
|
|
1245
|
+
return publicProducer(await this.request("GET", `/producer-provisioning/${encodeURIComponent(clientId)}`));
|
|
893
1246
|
}
|
|
894
1247
|
rotateSecret(clientId) {
|
|
895
1248
|
return this.request("POST", `/producer-provisioning/${encodeURIComponent(clientId)}/rotate-secret`);
|
|
@@ -900,15 +1253,53 @@ class ProvisioningProducerNamespace {
|
|
|
900
1253
|
* credential: one producer is expected to carry every environment unless an
|
|
901
1254
|
* operator deliberately restricts it.
|
|
902
1255
|
*/
|
|
903
|
-
updateEnvironment(clientId, environment) {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
1256
|
+
async updateEnvironment(clientId, environment) {
|
|
1257
|
+
const path = `/producer-provisioning/${encodeURIComponent(clientId)}/environment`;
|
|
1258
|
+
return publicProducer(await this.request("PATCH", path, { environment }));
|
|
1259
|
+
}
|
|
1260
|
+
/** Replaces the public keys a producer minted with the hosting-email-delivery template signs with. */
|
|
1261
|
+
async setSigningKeys(clientId, update) {
|
|
1262
|
+
const path = `/producer-provisioning/${encodeURIComponent(clientId)}/signing-keys`;
|
|
1263
|
+
return signingKeys(await this.request("PUT", path, update));
|
|
1264
|
+
}
|
|
1265
|
+
/** Reads the public keys, and their fingerprints, a signing producer's events are verified with. */
|
|
1266
|
+
async getSigningKeys(clientId) {
|
|
1267
|
+
const path = `/producer-provisioning/${encodeURIComponent(clientId)}/signing-keys`;
|
|
1268
|
+
return signingKeys(await this.request("GET", path));
|
|
907
1269
|
}
|
|
908
1270
|
revoke(clientId) {
|
|
909
1271
|
return this.request("DELETE", `/producer-provisioning/${encodeURIComponent(clientId)}`);
|
|
910
1272
|
}
|
|
911
1273
|
}
|
|
1274
|
+
function signingKeys(keys) {
|
|
1275
|
+
return { ...keys, publicKeys: keys.publicKeys ?? [], keyFingerprints: keys.keyFingerprints ?? [] };
|
|
1276
|
+
}
|
|
1277
|
+
function publicProducer(producer) {
|
|
1278
|
+
return { ...producer, scopes: producer.scopes ?? [], allowedEnvironments: producer.allowedEnvironments ?? [] };
|
|
1279
|
+
}
|
|
1280
|
+
function historicalCleanupReceipt(wire) {
|
|
1281
|
+
return {
|
|
1282
|
+
companyId: wire.company_id,
|
|
1283
|
+
requestedByKind: wire.requested_by_kind,
|
|
1284
|
+
requestedAt: wire.requested_at,
|
|
1285
|
+
completedAt: wire.completed_at,
|
|
1286
|
+
finalState: wire.final_state,
|
|
1287
|
+
perStore: (wire.per_store ?? []).map((store) => ({
|
|
1288
|
+
store: store.store,
|
|
1289
|
+
retentionClass: store.retention_class,
|
|
1290
|
+
deletedCount: store.deleted_count,
|
|
1291
|
+
retainedExceptionsCount: store.retained_exceptions_count,
|
|
1292
|
+
})),
|
|
1293
|
+
...(wire.waiver ? { waiver: wire.waiver } : {}),
|
|
1294
|
+
sha256: wire.sha256,
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
function tenantCompanyPath(slug, action, companyId) {
|
|
1298
|
+
if (!Number.isInteger(companyId) || companyId <= 0) {
|
|
1299
|
+
throw new Error("custd: company id must be a positive integer");
|
|
1300
|
+
}
|
|
1301
|
+
return `/tenants/${encodeURIComponent(slug)}/${action}?companyId=${companyId}`;
|
|
1302
|
+
}
|
|
912
1303
|
class AdminTenantNamespace {
|
|
913
1304
|
constructor(request) {
|
|
914
1305
|
this.request = request;
|
|
@@ -925,6 +1316,34 @@ class AdminTenantNamespace {
|
|
|
925
1316
|
delete(slug) {
|
|
926
1317
|
return this.request("DELETE", `/tenants/${encodeURIComponent(slug)}`);
|
|
927
1318
|
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Permanently removes an already deleted tenant once its cleanup is finished.
|
|
1321
|
+
* The server refuses an unready tenant with a conflict.
|
|
1322
|
+
*/
|
|
1323
|
+
finalize(slug, companyId) {
|
|
1324
|
+
return this.request("POST", tenantCompanyPath(slug, "finalize", companyId));
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* Runs the credential-revoking, queue, database and object-storage cleanup for a
|
|
1328
|
+
* deleted tenant. The idempotencyKey is required: repeat it to retry the same cleanup.
|
|
1329
|
+
*/
|
|
1330
|
+
async historicalCleanup(slug, companyId, options = {}) {
|
|
1331
|
+
const path = tenantCompanyPath(slug, "historical-cleanup", companyId);
|
|
1332
|
+
if (!options.idempotencyKey?.trim()) {
|
|
1333
|
+
throw new Error("custd: historical cleanup idempotency key is required");
|
|
1334
|
+
}
|
|
1335
|
+
const wire = await this.request("POST", path, undefined, options);
|
|
1336
|
+
return historicalCleanupReceipt(wire);
|
|
1337
|
+
}
|
|
1338
|
+
getDataSpaceEntitlement(slug) {
|
|
1339
|
+
return this.request("GET", `/tenants/${encodeURIComponent(slug)}/data-space-entitlement`);
|
|
1340
|
+
}
|
|
1341
|
+
updateDataSpaceEntitlement(slug, body) {
|
|
1342
|
+
return this.request("PUT", `/tenants/${encodeURIComponent(slug)}/data-space-entitlement`, body);
|
|
1343
|
+
}
|
|
1344
|
+
updateStorageLimit(slug, body) {
|
|
1345
|
+
return this.request("PUT", `/tenants/${encodeURIComponent(slug)}/storage-limit`, body);
|
|
1346
|
+
}
|
|
928
1347
|
}
|
|
929
1348
|
// Custd requires a canonical UUIDv7 Idempotency-Key on every OAuth client
|
|
930
1349
|
// mutation, so one is generated when the caller does not supply it. A caller that
|
|
@@ -934,8 +1353,18 @@ class AdminOAuthClientNamespace {
|
|
|
934
1353
|
constructor(request) {
|
|
935
1354
|
this.request = request;
|
|
936
1355
|
}
|
|
937
|
-
create(client, options = {}) {
|
|
938
|
-
|
|
1356
|
+
async create(client, options = {}) {
|
|
1357
|
+
const created = await this.request("POST", "/oauth-clients", client, mutationOptions(options));
|
|
1358
|
+
const { loginSetup } = created;
|
|
1359
|
+
return {
|
|
1360
|
+
...created,
|
|
1361
|
+
scopes: created.scopes ?? [],
|
|
1362
|
+
...(loginSetup
|
|
1363
|
+
? {
|
|
1364
|
+
loginSetup: { ...loginSetup, scopes: loginSetup.scopes ?? [], redirectUris: loginSetup.redirectUris ?? [] },
|
|
1365
|
+
}
|
|
1366
|
+
: {}),
|
|
1367
|
+
};
|
|
939
1368
|
}
|
|
940
1369
|
list() {
|
|
941
1370
|
return this.request("GET", "/oauth-clients");
|
|
@@ -949,6 +1378,13 @@ class AdminOAuthClientNamespace {
|
|
|
949
1378
|
rotateSecret(clientId, options = {}) {
|
|
950
1379
|
return this.request("POST", `/oauth-clients/${encodeURIComponent(clientId)}/rotate-secret`, undefined, mutationOptions(options));
|
|
951
1380
|
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Issues a new secret for a client whose current secret nobody holds. The new secret is shown only
|
|
1383
|
+
* in this response.
|
|
1384
|
+
*/
|
|
1385
|
+
replaceUnknownSecret(clientId, options = {}) {
|
|
1386
|
+
return this.request("POST", `/oauth-clients/${encodeURIComponent(clientId)}/replace-unknown-secret`, undefined, mutationOptions(options));
|
|
1387
|
+
}
|
|
952
1388
|
updateScopes(clientId, body, options = {}) {
|
|
953
1389
|
return this.request("PATCH", `/oauth-clients/${encodeURIComponent(clientId)}/scopes`, body, mutationOptions(options));
|
|
954
1390
|
}
|
|
@@ -965,12 +1401,16 @@ class AdminSiteNamespace {
|
|
|
965
1401
|
}
|
|
966
1402
|
async list() {
|
|
967
1403
|
const response = await this.request("GET", "/sites");
|
|
968
|
-
return { sites: response.sites.map(publicAdminSite) };
|
|
1404
|
+
return { sites: (response.sites ?? []).map(publicAdminSite) };
|
|
969
1405
|
}
|
|
970
1406
|
async get(siteUuid) {
|
|
971
1407
|
const site = await this.request("GET", `/sites/${encodeURIComponent(siteUuid)}`);
|
|
972
1408
|
return publicAdminSite(site);
|
|
973
1409
|
}
|
|
1410
|
+
async update(siteUuid, body) {
|
|
1411
|
+
const site = await this.request("PATCH", `/sites/${encodeURIComponent(siteUuid)}`, body);
|
|
1412
|
+
return publicAdminSite(site);
|
|
1413
|
+
}
|
|
974
1414
|
delete(siteUuid) {
|
|
975
1415
|
return this.request("DELETE", `/sites/${encodeURIComponent(siteUuid)}`);
|
|
976
1416
|
}
|
|
@@ -982,46 +1422,72 @@ class AdminSchemaNamespace {
|
|
|
982
1422
|
constructor(request) {
|
|
983
1423
|
this.request = request;
|
|
984
1424
|
}
|
|
985
|
-
list() {
|
|
986
|
-
return this.request("GET", "/schemas");
|
|
987
|
-
}
|
|
988
|
-
get(eventTypeSlug) {
|
|
989
|
-
return this.request("GET", `/schemas/${encodeURIComponent(eventTypeSlug)}`);
|
|
990
|
-
}
|
|
991
|
-
register(schema) {
|
|
992
|
-
return this.request("POST", "/schemas", schema);
|
|
993
|
-
}
|
|
994
|
-
createVersion(eventTypeSlug, schema) {
|
|
995
|
-
return this.request("POST", `/schemas/${encodeURIComponent(eventTypeSlug)}/versions`, schema);
|
|
996
|
-
}
|
|
997
1425
|
validate(body) {
|
|
998
1426
|
return this.request("POST", "/schema/validate", body);
|
|
999
1427
|
}
|
|
1000
1428
|
enableVersion(tenantSlug, eventTypeSlug, body) {
|
|
1001
1429
|
return this.request("POST", `/schema/${encodeURIComponent(tenantSlug)}/${encodeURIComponent(eventTypeSlug)}/enable`, body);
|
|
1002
1430
|
}
|
|
1431
|
+
register(tenantSlug, eventTypeSlug, body) {
|
|
1432
|
+
return this.request("POST", `/schema/${encodeURIComponent(tenantSlug)}/${encodeURIComponent(eventTypeSlug)}/register`, body);
|
|
1433
|
+
}
|
|
1003
1434
|
dryRun(tenantSlug, eventTypeSlug, body) {
|
|
1004
1435
|
return this.request("POST", `/schema/${encodeURIComponent(tenantSlug)}/${encodeURIComponent(eventTypeSlug)}/dry-run`, body);
|
|
1005
1436
|
}
|
|
1006
|
-
audit() {
|
|
1007
|
-
|
|
1437
|
+
async audit(tenantSlug) {
|
|
1438
|
+
const query = tenantSlug ? `?${new URLSearchParams({ tenantSlug })}` : "";
|
|
1439
|
+
const audit = await this.request("GET", `/schema/audit${query}`);
|
|
1440
|
+
return { ...audit, schemas: (audit.schemas ?? []).map(schemaAuditResult) };
|
|
1008
1441
|
}
|
|
1009
1442
|
}
|
|
1443
|
+
function schemaAuditResult(result) {
|
|
1444
|
+
const compile = (pass) => ({ ...pass, issues: pass.issues ?? [] });
|
|
1445
|
+
return {
|
|
1446
|
+
...result,
|
|
1447
|
+
issueCodes: result.issueCodes ?? [],
|
|
1448
|
+
legacyCompile: compile(result.legacyCompile),
|
|
1449
|
+
sharedCompile: compile(result.sharedCompile),
|
|
1450
|
+
exampleValidation: { ...result.exampleValidation, issueCodes: result.exampleValidation.issueCodes ?? [] },
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
function privacyRules(rules) {
|
|
1454
|
+
return { ...rules, rules: rules.rules ?? [] };
|
|
1455
|
+
}
|
|
1010
1456
|
class AdminPrivacyNamespace {
|
|
1011
1457
|
constructor(request) {
|
|
1012
1458
|
this.request = request;
|
|
1013
1459
|
}
|
|
1014
|
-
getRules() {
|
|
1015
|
-
|
|
1460
|
+
async getRules(companySlug) {
|
|
1461
|
+
const query = companySlug ? `?${new URLSearchParams({ companySlug })}` : "";
|
|
1462
|
+
return privacyRules(await this.request("GET", `/privacy/rules${query}`));
|
|
1016
1463
|
}
|
|
1017
|
-
setRules(body) {
|
|
1018
|
-
return this.request("PUT", "/privacy/rules", body);
|
|
1464
|
+
async setRules(body) {
|
|
1465
|
+
return privacyRules(await this.request("PUT", "/privacy/rules", body));
|
|
1019
1466
|
}
|
|
1020
1467
|
mapIdentifier(companySlug, body) {
|
|
1021
1468
|
return this.request("POST", `/privacy/identifiers/${encodeURIComponent(companySlug)}/map`, body);
|
|
1022
1469
|
}
|
|
1023
|
-
listIdentifierMappings(companySlug) {
|
|
1024
|
-
|
|
1470
|
+
async listIdentifierMappings(companySlug) {
|
|
1471
|
+
const list = await this.request("GET", `/privacy/identifiers/${encodeURIComponent(companySlug)}`);
|
|
1472
|
+
return { ...list, mappings: list.mappings ?? [] };
|
|
1473
|
+
}
|
|
1474
|
+
async listConsent(subjectId, companySlug) {
|
|
1475
|
+
const params = new URLSearchParams({ subjectId });
|
|
1476
|
+
if (companySlug)
|
|
1477
|
+
params.set("companySlug", companySlug);
|
|
1478
|
+
const response = await this.request("GET", `/privacy/consent?${params}`);
|
|
1479
|
+
return { ...response, records: response.records ?? [] };
|
|
1480
|
+
}
|
|
1481
|
+
recordConsent(body) {
|
|
1482
|
+
return this.request("POST", "/privacy/consent", body);
|
|
1483
|
+
}
|
|
1484
|
+
revokeConsent(subjectId, revoke) {
|
|
1485
|
+
const params = new URLSearchParams({ purpose: revoke.purpose });
|
|
1486
|
+
if (revoke.source)
|
|
1487
|
+
params.set("source", revoke.source);
|
|
1488
|
+
if (revoke.companySlug)
|
|
1489
|
+
params.set("companySlug", revoke.companySlug);
|
|
1490
|
+
return this.request("DELETE", `/privacy/consent/${encodeURIComponent(subjectId)}?${params}`);
|
|
1025
1491
|
}
|
|
1026
1492
|
}
|
|
1027
1493
|
class AdminStorageAlertsNamespace {
|
|
@@ -1037,6 +1503,10 @@ class AdminStorageAlertsNamespace {
|
|
|
1037
1503
|
deleteRule(tenantSlug, ruleId) {
|
|
1038
1504
|
return this.request("DELETE", `/storage/alerts/${encodeURIComponent(tenantSlug)}/${encodeURIComponent(ruleId)}`);
|
|
1039
1505
|
}
|
|
1506
|
+
async listEvents(tenantSlug) {
|
|
1507
|
+
const response = await this.request("GET", `/storage/alerts/${encodeURIComponent(tenantSlug)}/events`);
|
|
1508
|
+
return { events: response.events ?? [] };
|
|
1509
|
+
}
|
|
1040
1510
|
}
|
|
1041
1511
|
const auditDisclosureStates = new Set(["available", "redacted", "not_recorded"]);
|
|
1042
1512
|
function mapAdminAuditChange(value) {
|
|
@@ -1104,6 +1574,7 @@ function mapAdminAuditEvent(event) {
|
|
|
1104
1574
|
...(changes.length > 0 ? { changes } : {}),
|
|
1105
1575
|
...(details !== undefined && typeof details === "object" && !Array.isArray(details) ? { details } : {}),
|
|
1106
1576
|
...(network !== undefined ? { network } : {}),
|
|
1577
|
+
...(event.domainHistory !== undefined ? { domainHistory: event.domainHistory } : {}),
|
|
1107
1578
|
createdAt: event.createdAt,
|
|
1108
1579
|
};
|
|
1109
1580
|
}
|
|
@@ -1113,7 +1584,6 @@ function mapAdminReportingPackAuditEvent(event) {
|
|
|
1113
1584
|
...(event.actorReference !== undefined ? { actorReference: event.actorReference } : {}),
|
|
1114
1585
|
actorDisplayName: event.actorDisplayName,
|
|
1115
1586
|
resourceType: event.resourceType,
|
|
1116
|
-
resourceId: event.resourceId,
|
|
1117
1587
|
packKey: event.packKey,
|
|
1118
1588
|
createdAt: event.createdAt,
|
|
1119
1589
|
};
|
|
@@ -1153,6 +1623,8 @@ class AdminAuditNamespace {
|
|
|
1153
1623
|
params.set("outcome", options.outcome);
|
|
1154
1624
|
if (options.correlationId)
|
|
1155
1625
|
params.set("correlationId", options.correlationId);
|
|
1626
|
+
if (options.environmentId)
|
|
1627
|
+
params.set("environmentId", options.environmentId);
|
|
1156
1628
|
if (includePagination && typeof options.limit === "number")
|
|
1157
1629
|
params.set("limit", String(options.limit));
|
|
1158
1630
|
if (includePagination && options.cursor)
|
|
@@ -1175,8 +1647,8 @@ class AdminAuditNamespace {
|
|
|
1175
1647
|
const response = await this.request("GET", `/audit/events${this.auditQuery(options)}`);
|
|
1176
1648
|
const retention = mapAdminAuditRetention(response.retention);
|
|
1177
1649
|
return {
|
|
1178
|
-
events: response.events.map(mapAdminAuditEvent),
|
|
1179
|
-
nextCursor: response.nextCursor ?? {
|
|
1650
|
+
events: (response.events ?? []).map(mapAdminAuditEvent),
|
|
1651
|
+
nextCursor: response.nextCursor ?? {},
|
|
1180
1652
|
...(typeof response.coverageBeginsAt === "string" ? { coverageBeginsAt: response.coverageBeginsAt } : {}),
|
|
1181
1653
|
...(retention === undefined ? {} : { retention }),
|
|
1182
1654
|
};
|
|
@@ -1195,7 +1667,7 @@ class AdminAuditNamespace {
|
|
|
1195
1667
|
}
|
|
1196
1668
|
async listReportingPackEvents(packKey) {
|
|
1197
1669
|
const response = await this.request("GET", `/reporting-packs/audit-events?packKey=${encodeURIComponent(packKey)}`);
|
|
1198
|
-
return { events: response.events.map(mapAdminReportingPackAuditEvent) };
|
|
1670
|
+
return { events: (response.events ?? []).map(mapAdminReportingPackAuditEvent) };
|
|
1199
1671
|
}
|
|
1200
1672
|
}
|
|
1201
1673
|
class AdminReportingPacksNamespace {
|
|
@@ -1205,6 +1677,19 @@ class AdminReportingPacksNamespace {
|
|
|
1205
1677
|
listDrafts() {
|
|
1206
1678
|
return this.request("GET", "/reporting-packs/drafts");
|
|
1207
1679
|
}
|
|
1680
|
+
/** List the reviewed setup templates (each with its canonical definition). */
|
|
1681
|
+
listSetupTemplates() {
|
|
1682
|
+
return this.request("GET", "/reporting-packs/setup-templates");
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Apply typed bindings to one reviewed setup template and return the
|
|
1686
|
+
* server-built definition. Pure build: the server creates no data, grants no
|
|
1687
|
+
* scope, and writes no generation; post the result through createDraft/preview
|
|
1688
|
+
* only when the caller intends to.
|
|
1689
|
+
*/
|
|
1690
|
+
bindSetupTemplate(kind, body) {
|
|
1691
|
+
return this.request("POST", `/reporting-packs/setup-templates/${encodeURIComponent(kind)}/bind`, body);
|
|
1692
|
+
}
|
|
1208
1693
|
getDraft(draftId) {
|
|
1209
1694
|
return this.request("GET", `/reporting-packs/drafts/${encodeURIComponent(draftId)}`);
|
|
1210
1695
|
}
|
|
@@ -1235,52 +1720,14 @@ class AdminReportingPacksNamespace {
|
|
|
1235
1720
|
rollbackGeneration(generationId) {
|
|
1236
1721
|
return this.request("POST", `/reporting-packs/generations/${encodeURIComponent(generationId)}/rollback`);
|
|
1237
1722
|
}
|
|
1723
|
+
async listGenerationValidity() {
|
|
1724
|
+
const response = await this.request("GET", "/reporting-packs/generation-validity");
|
|
1725
|
+
return { generations: response.generations ?? [] };
|
|
1726
|
+
}
|
|
1238
1727
|
getRollupProvenance(generationId) {
|
|
1239
1728
|
return this.request("GET", `/reporting-packs/generations/${encodeURIComponent(generationId)}/rollup-provenance`);
|
|
1240
1729
|
}
|
|
1241
1730
|
}
|
|
1242
|
-
class AdminMeasurementNamespace {
|
|
1243
|
-
constructor(request) {
|
|
1244
|
-
this.projects = new AdminMeasurementProjectNamespace(request);
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
class AdminMeasurementProjectNamespace {
|
|
1248
|
-
constructor(request) {
|
|
1249
|
-
this.request = request;
|
|
1250
|
-
}
|
|
1251
|
-
create(project) {
|
|
1252
|
-
return this.request("POST", "/measurement/projects", project);
|
|
1253
|
-
}
|
|
1254
|
-
list() {
|
|
1255
|
-
return this.request("GET", "/measurement/projects");
|
|
1256
|
-
}
|
|
1257
|
-
get(projectUuid) {
|
|
1258
|
-
return this.request("GET", `/measurement/projects/${encodeURIComponent(projectUuid)}`);
|
|
1259
|
-
}
|
|
1260
|
-
submitObservation(projectUuid, observation) {
|
|
1261
|
-
return this.submitObservations(projectUuid, { rows: [observation] });
|
|
1262
|
-
}
|
|
1263
|
-
async submitObservations(projectUuid, request) {
|
|
1264
|
-
const response = await this.request("POST", `/measurement/projects/${encodeURIComponent(projectUuid)}/observations:bulk`, request);
|
|
1265
|
-
validateMeasurementResults(response.results, request.rows.length);
|
|
1266
|
-
return response;
|
|
1267
|
-
}
|
|
1268
|
-
async importCSVString(projectUuid, csv, expectedRows) {
|
|
1269
|
-
const response = await this.request("POST", `/measurement/projects/${encodeURIComponent(projectUuid)}/observations:csv`, { csv });
|
|
1270
|
-
validateMeasurementResults(response.results, expectedRows);
|
|
1271
|
-
return response;
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
function validateMeasurementResults(results, submittedRows) {
|
|
1275
|
-
if (results.length !== submittedRows) {
|
|
1276
|
-
throw new Error(`custd: measurement result count ${results.length} does not match submitted row count ${submittedRows}`);
|
|
1277
|
-
}
|
|
1278
|
-
results.forEach((result, index) => {
|
|
1279
|
-
if (result.success && !result.observationUuid) {
|
|
1280
|
-
throw new Error(`custd: measurement result ${index} missing observationUuid`);
|
|
1281
|
-
}
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1284
1731
|
// redactedProvisionedProducer returns the display-safe view of a provisioned
|
|
1285
1732
|
// producer bundle, omitting the client secret so it is safe for dashboards.
|
|
1286
1733
|
export function redactedProvisionedProducer(credentials) {
|
|
@@ -1451,6 +1898,51 @@ export function prepareEvent(event, options = {}) {
|
|
|
1451
1898
|
anonymousId: event.anonymousId || randomUUID(),
|
|
1452
1899
|
};
|
|
1453
1900
|
}
|
|
1901
|
+
const RAW_PARSER_UUID_PATTERN = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
1902
|
+
// assertRawParserUuid rejects a missing or malformed parser UUID before a
|
|
1903
|
+
// request is sent. It is a cheap shape check; the backend still verifies the
|
|
1904
|
+
// parser exists and is enabled.
|
|
1905
|
+
function assertRawParserUuid(value) {
|
|
1906
|
+
if (typeof value !== "string" || !RAW_PARSER_UUID_PATTERN.test(value)) {
|
|
1907
|
+
throw new RangeError("custd: raw ingest requires a parser UUID");
|
|
1908
|
+
}
|
|
1909
|
+
return value;
|
|
1910
|
+
}
|
|
1911
|
+
// assertRawSourceTarget rejects a partial or malformed target before a request
|
|
1912
|
+
// is sent. Both codes must be present and well-formed; the backend remains the
|
|
1913
|
+
// authority on whether they are registered.
|
|
1914
|
+
function assertRawSourceTarget(target) {
|
|
1915
|
+
if (typeof target.subClient !== "string" ||
|
|
1916
|
+
typeof target.resource !== "string" ||
|
|
1917
|
+
!validDataScopeCode(target.subClient) ||
|
|
1918
|
+
!validDataScopeCode(target.resource)) {
|
|
1919
|
+
throw new RangeError("custd: raw source target requires subClient and resource as a pair of valid codes");
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
// validateRawIngestResult requires an actual object carrying a boolean success
|
|
1923
|
+
// and non-negative integer processed and failed. A missing field, a null, a
|
|
1924
|
+
// wrong type, or a negative count is rejected rather than defaulted or coerced.
|
|
1925
|
+
// Legitimate partial counts are returned unchanged.
|
|
1926
|
+
function validateRawIngestResult(value, operationKey) {
|
|
1927
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
1928
|
+
throw new CustdRawAcceptanceUnknownError({ operationKey });
|
|
1929
|
+
}
|
|
1930
|
+
const record = value;
|
|
1931
|
+
if (typeof record.success !== "boolean") {
|
|
1932
|
+
throw new CustdRawAcceptanceUnknownError({ operationKey });
|
|
1933
|
+
}
|
|
1934
|
+
return {
|
|
1935
|
+
success: record.success,
|
|
1936
|
+
processed: requireNonNegativeInteger(record.processed, operationKey),
|
|
1937
|
+
failed: requireNonNegativeInteger(record.failed, operationKey),
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
function requireNonNegativeInteger(value, operationKey) {
|
|
1941
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
|
|
1942
|
+
throw new CustdRawAcceptanceUnknownError({ operationKey });
|
|
1943
|
+
}
|
|
1944
|
+
return value;
|
|
1945
|
+
}
|
|
1454
1946
|
export class RetryableError extends Error {
|
|
1455
1947
|
}
|
|
1456
1948
|
function transportRequestError(error) {
|
|
@@ -1629,9 +2121,6 @@ function assertSecureOrLocalHTTP(rawUrl, field) {
|
|
|
1629
2121
|
}
|
|
1630
2122
|
throw new Error(`custd: ${field} must use https unless it targets localhost`);
|
|
1631
2123
|
}
|
|
1632
|
-
function isLocalHostname(hostname) {
|
|
1633
|
-
return (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "host.docker.internal");
|
|
1634
|
-
}
|
|
1635
2124
|
export function normalizeRetryOptions(options) {
|
|
1636
2125
|
return {
|
|
1637
2126
|
maxAttempts: options?.maxAttempts ?? 3,
|
|
@@ -1698,9 +2187,40 @@ function uuidv7() {
|
|
|
1698
2187
|
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1699
2188
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
1700
2189
|
}
|
|
2190
|
+
/** Opaque per-event identity, including runtimes without Web Crypto. Not an authentication token. */
|
|
2191
|
+
export function createEventId() {
|
|
2192
|
+
return randomUUID();
|
|
2193
|
+
}
|
|
1701
2194
|
function randomUUID() {
|
|
1702
2195
|
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
1703
2196
|
return crypto.randomUUID();
|
|
1704
2197
|
}
|
|
1705
2198
|
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (Number(c) ^ ((Math.random() * 16) >> (Number(c) / 4))).toString(16));
|
|
1706
2199
|
}
|
|
2200
|
+
export * from "./admin-accounting-evidence.js";
|
|
2201
|
+
export * from "./admin-campaign-email.js";
|
|
2202
|
+
export * from "./admin-email-relay.js";
|
|
2203
|
+
export * from "./admin-environment-policy.js";
|
|
2204
|
+
export * from "./admin-error-issues.js";
|
|
2205
|
+
export * from "./admin-event-types.js";
|
|
2206
|
+
export * from "./admin-impersonation.js";
|
|
2207
|
+
export * from "./admin-ingest-claims.js";
|
|
2208
|
+
export * from "./admin-managed-audit.js";
|
|
2209
|
+
export * from "./admin-measurement-projects.js";
|
|
2210
|
+
export * from "./admin-notification-destinations.js";
|
|
2211
|
+
export * from "./admin-notification-webhooks.js";
|
|
2212
|
+
export * from "./admin-oauth-client-admissions.js";
|
|
2213
|
+
export * from "./admin-rls.js";
|
|
2214
|
+
export * from "./admin-sdk-usage.js";
|
|
2215
|
+
export * from "./admin-support-access.js";
|
|
2216
|
+
export * from "./admin-system.js";
|
|
2217
|
+
export * from "./admin-uncertainty-models.js";
|
|
2218
|
+
export * from "./analytics-reads.js";
|
|
2219
|
+
export * from "./app-account.js";
|
|
2220
|
+
export { createErrorCaptureEvent, ErrorCaptureClient, installBrowserErrorCapture, installNativeErrorCapture, } from "./error-capture.js";
|
|
2221
|
+
export * from "./ingest-operations.js";
|
|
2222
|
+
export * from "./measurement.js";
|
|
2223
|
+
export * from "./public-reads.js";
|
|
2224
|
+
export * from "./reporting-catalogue.js";
|
|
2225
|
+
export { SiteAIOwnerSession } from "./site-ai-owner.js";
|
|
2226
|
+
export * from "./site-monitor-reports.js";
|