@openlup/platform 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +167 -109
  2. package/README.md +111 -8
  3. package/dist/account-support/accountReadFacade.d.ts +8 -0
  4. package/dist/account-support/accountReadFacade.js +10 -0
  5. package/dist/account-support/accountReadModels.d.ts +69 -0
  6. package/dist/account-support/accountReadModels.js +272 -0
  7. package/dist/account-support/bindings.d.ts +23 -0
  8. package/dist/account-support/bindings.js +16 -0
  9. package/dist/account-support/contracts/account.d.ts +281 -0
  10. package/dist/account-support/contracts/account.js +1 -0
  11. package/dist/account-support/contracts/capabilities.d.ts +44 -0
  12. package/dist/account-support/contracts/capabilities.js +1 -0
  13. package/dist/account-support/contracts/commands.d.ts +307 -0
  14. package/dist/account-support/contracts/commands.js +1 -0
  15. package/dist/account-support/contracts/customer360.d.ts +154 -0
  16. package/dist/account-support/contracts/customer360.js +1 -0
  17. package/dist/account-support/contracts/index.d.ts +10 -0
  18. package/dist/account-support/contracts/index.js +1 -0
  19. package/dist/account-support/contracts/invoice.d.ts +79 -0
  20. package/dist/account-support/contracts/invoice.js +1 -0
  21. package/dist/account-support/contracts/operator.d.ts +289 -0
  22. package/dist/account-support/contracts/operator.js +1 -0
  23. package/dist/account-support/contribution.d.ts +24 -0
  24. package/dist/account-support/contribution.js +22 -0
  25. package/dist/account-support/customer360.d.ts +106 -0
  26. package/dist/account-support/customer360.js +163 -0
  27. package/dist/account-support/customerAccountReadDiagnostics.d.ts +11 -0
  28. package/dist/account-support/customerAccountReadDiagnostics.js +71 -0
  29. package/dist/account-support/index.d.ts +26 -0
  30. package/dist/account-support/index.js +15 -0
  31. package/dist/account-support/invoiceAccess.d.ts +57 -0
  32. package/dist/account-support/invoiceAccess.js +40 -0
  33. package/dist/account-support/migrations.d.ts +14 -0
  34. package/dist/account-support/migrations.js +7 -0
  35. package/dist/account-support/operatorAuthority.d.ts +67 -0
  36. package/dist/account-support/operatorAuthority.js +379 -0
  37. package/dist/account-support/operatorRecovery.d.ts +66 -0
  38. package/dist/account-support/operatorRecovery.js +129 -0
  39. package/dist/account-support/orderHistory.d.ts +50 -0
  40. package/dist/account-support/orderHistory.js +188 -0
  41. package/dist/account-support/paymentMethodComposition.d.ts +5 -0
  42. package/dist/account-support/paymentMethodComposition.js +4 -0
  43. package/dist/account-support/postgresOperatorAuthority.d.ts +16 -0
  44. package/dist/account-support/postgresOperatorAuthority.js +93 -0
  45. package/dist/account-support/selfService.d.ts +6 -0
  46. package/dist/account-support/selfService.js +81 -0
  47. package/dist/account-support/subscriptionCommandCodec.d.ts +10 -0
  48. package/dist/account-support/subscriptionCommandCodec.js +38 -0
  49. package/dist/catalog/draftSchemas.d.ts +1 -1
  50. package/dist/catalog/foundationSchemas.d.ts +3 -3
  51. package/dist/catalog/resolvedSkuProjection.d.ts +2 -2
  52. package/dist/catalog/sellableSchemas.d.ts +2 -2
  53. package/dist/commerce/checkoutCommandSchemas.d.ts +2 -2
  54. package/dist/commerce/checkoutResumeSchemas.d.ts +6 -6
  55. package/dist/commerce/checkoutSchemas.d.ts +12 -12
  56. package/dist/commerce/commerceReturnsPort.d.ts +2 -2
  57. package/dist/commerce/configuratorIntentSchemas.d.ts +2 -2
  58. package/dist/commerce/contractPrimitives.d.ts +8 -8
  59. package/dist/commerce/customerDefaultsSnapshotSchemas.d.ts +4 -4
  60. package/dist/commerce/model/omsReadModelHelpers.d.ts +4 -4
  61. package/dist/commerce/offerAvailabilitySchemas.d.ts +1 -1
  62. package/dist/commerce/oms/omsContractBase.d.ts +15 -15
  63. package/dist/commerce/oms/omsContractReadAuxSchemas.d.ts +11 -11
  64. package/dist/commerce/oms/omsContractReadSchemas.d.ts +121 -121
  65. package/dist/commerce/oms/omsContractRequests.d.ts +13 -13
  66. package/dist/commerce/oms/omsControlPlane.d.ts +22 -22
  67. package/dist/commerce/oms/omsFulfillmentContractSchemas.d.ts +12 -12
  68. package/dist/commerce/oms/omsFulfillmentDebugSchemas.d.ts +12 -12
  69. package/dist/commerce/orderReviewContracts.d.ts +33 -33
  70. package/dist/commerce/outboxEventSchemas.d.ts +4 -4
  71. package/dist/commerce/schemas.d.ts +21 -21
  72. package/dist/commerce/server/orderReviewHandlers.d.ts +10 -10
  73. package/dist/communications/consentPurposeRegistry.d.ts +1 -1
  74. package/dist/communications/newsletterIntegrationContracts.d.ts +8 -8
  75. package/dist/composition/accountSupportContribution.d.ts +18 -0
  76. package/dist/composition/accountSupportContribution.js +21 -0
  77. package/dist/composition/index.d.ts +1 -0
  78. package/dist/composition/index.js +1 -0
  79. package/dist/fulfillment/handlerSchemas.d.ts +40 -40
  80. package/dist/identity/customerContracts.d.ts +2 -2
  81. package/dist/invoicing/snapshot.d.ts +1 -1
  82. package/dist/pricing/acquisitionQuoteBinding.d.ts +1 -1
  83. package/dist/pricing/catalogFactsSchemas.d.ts +1 -1
  84. package/dist/pricing/quotePromotionEvidence.d.ts +1 -1
  85. package/dist/pricing/quoteSchemas.d.ts +56 -56
  86. package/dist/promotions/adminPromotionCodesContracts.d.ts +30 -30
  87. package/dist/promotions/adminPromotionsContracts.d.ts +14 -14
  88. package/package.json +12 -2
  89. package/release-gates.json +30 -3
  90. package/sql/20261026120000_account_support_operator_authority.sql +693 -0
  91. package/src/account-support/accountReadFacade.ts +15 -0
  92. package/src/account-support/accountReadModels.ts +371 -0
  93. package/src/account-support/bindings.ts +28 -0
  94. package/src/account-support/contracts/account.ts +306 -0
  95. package/src/account-support/contracts/capabilities.ts +30 -0
  96. package/src/account-support/contracts/commands.ts +243 -0
  97. package/src/account-support/contracts/customer360.ts +150 -0
  98. package/src/account-support/contracts/index.ts +141 -0
  99. package/src/account-support/contracts/invoice.ts +44 -0
  100. package/src/account-support/contracts/operator.ts +123 -0
  101. package/src/account-support/contribution.ts +35 -0
  102. package/src/account-support/customer360.ts +268 -0
  103. package/src/account-support/customerAccountReadDiagnostics.ts +83 -0
  104. package/src/account-support/index.ts +72 -0
  105. package/src/account-support/invoiceAccess.ts +63 -0
  106. package/src/account-support/migrations.ts +7 -0
  107. package/src/account-support/operatorAuthority.ts +393 -0
  108. package/src/account-support/operatorRecovery.ts +136 -0
  109. package/src/account-support/orderHistory.ts +309 -0
  110. package/src/account-support/paymentMethodComposition.ts +8 -0
  111. package/src/account-support/postgresOperatorAuthority.ts +92 -0
  112. package/src/account-support/selfService.ts +83 -0
  113. package/src/account-support/subscriptionCommandCodec.ts +48 -0
  114. package/src/composition/accountSupportContribution.ts +28 -0
  115. package/src/composition/index.ts +1 -0
@@ -0,0 +1,71 @@
1
+ export class CustomerAccountReadModelError extends Error {
2
+ stage;
3
+ cause;
4
+ constructor(stage, cause) {
5
+ super(`Customer account read model failed at ${stage}`);
6
+ this.name = "CustomerAccountReadModelError";
7
+ this.stage = stage;
8
+ this.cause = cause;
9
+ }
10
+ }
11
+ export async function withCustomerAccountReadStage(stage, operation) {
12
+ try {
13
+ return await operation();
14
+ }
15
+ catch (error) {
16
+ if (error instanceof CustomerAccountReadModelError)
17
+ throw error;
18
+ throw new CustomerAccountReadModelError(stage, error);
19
+ }
20
+ }
21
+ export function customerAccountReadFailureDetails(error) {
22
+ if (!(error instanceof CustomerAccountReadModelError)) {
23
+ return { reason: "read_model_failed", stage: "unknown" };
24
+ }
25
+ return {
26
+ reason: "read_model_failed",
27
+ stage: error.stage,
28
+ providerCode: diagnosticText(readRecord(error.cause).code),
29
+ };
30
+ }
31
+ export function logCustomerAccountReadFailure(error) {
32
+ if (error instanceof CustomerAccountReadModelError) {
33
+ console.error("[customer-account] read model failed:", JSON.stringify({
34
+ stage: error.stage,
35
+ cause: safeCause(error.cause),
36
+ }));
37
+ return;
38
+ }
39
+ console.error("[customer-account] read failed:", JSON.stringify({ cause: safeCause(error) }));
40
+ }
41
+ function safeCause(error) {
42
+ if (error instanceof Error) {
43
+ const record = readRecord(error);
44
+ return compact({
45
+ name: error.name,
46
+ message: error.message,
47
+ code: diagnosticText(record.code),
48
+ hint: diagnosticText(record.hint),
49
+ details: diagnosticText(record.details),
50
+ });
51
+ }
52
+ return compact({
53
+ type: typeof error,
54
+ code: diagnosticText(readRecord(error).code),
55
+ message: diagnosticText(readRecord(error).message),
56
+ });
57
+ }
58
+ function readRecord(value) {
59
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
60
+ }
61
+ function diagnosticText(value) {
62
+ if (typeof value !== "string")
63
+ return undefined;
64
+ const trimmed = value.trim();
65
+ if (!trimmed)
66
+ return undefined;
67
+ return trimmed.slice(0, 300);
68
+ }
69
+ function compact(value) {
70
+ return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
71
+ }
@@ -0,0 +1,26 @@
1
+ export { createAccountReadFacade } from "./accountReadFacade.js";
2
+ export { CustomerAccountReadModelError, withCustomerAccountReadStage, customerAccountReadFailureDetails, logCustomerAccountReadFailure } from "./customerAccountReadDiagnostics.js";
3
+ export type { CustomerAccountReadStage } from "./customerAccountReadDiagnostics.js";
4
+ export type * from "./contracts/index.js";
5
+ export { CUSTOMER_ACCOUNT_V2_CONTRACT_VERSION, readAccountSnapshot, isCustomerVisibleSubscription, recurringPrice, computeEditState, editCutoff, buildActionRequired } from "./accountReadModels.js";
6
+ export type { AccountReadSources, AccountReadProjectionPolicy, CustomerSubscriptionEligibilityInput, CustomerSubscriptionEligibility, SubscriptionActionState } from "./accountReadModels.js";
7
+ export { CUSTOMER_ORDERS_CONTRACT_VERSION, readCustomerOrderSummaries, readCustomerOrderDetail, customerOrderMoney, toOrderMoneyHeader, toOrderMoneyItem, mapCustomerOrderLines, lineListTotalMinor } from "./orderHistory.js";
8
+ export type { CustomerOrderHistoryRow, CustomerOrderHistoryReadStore, CustomerOrderLinePresentationPort, CustomerOrderHistoryProjectionPort } from "./orderHistory.js";
9
+ export { SUPPORT_CUSTOMER_360_CONTRACT_VERSION, projectCustomer360Snapshot, deriveContactHealth, boundedCustomerJourneyAudit, createCustomer360ReadFacade } from "./customer360.js";
10
+ export type { Customer360ProjectionInput, Customer360ProjectionPolicy, ContactHealthDelivery, CustomerJourneyAuditEvent } from "./customer360.js";
11
+ export { createInvoiceAccess, downloadOwnedInvoicePdf, deriveCustomerDocumentDeliveryStatus } from "./invoiceAccess.js";
12
+ export type { InvoiceOwnerAccessPort, InvoiceArtifactDownloadPort, InvoiceAccessOptions, CustomerInvoiceDocumentStatusInput } from "./invoiceAccess.js";
13
+ export { createSelfServiceCommandFacade } from "./selfService.js";
14
+ export { encodeNativeSubscriptionCommand, decodeNativeSubscriptionPreview, createNativeSubscriptionDriver } from "./subscriptionCommandCodec.js";
15
+ export { createPaymentMethodComposition } from "./paymentMethodComposition.js";
16
+ export { createOperatorRecovery, moveIdentityForEmailCorrection, OperatorIdentityMoveRefusedError, executeOperatorAccountLink, linkThenApply } from "./operatorRecovery.js";
17
+ export type { OperatorRecoverySelection } from "./operatorRecovery.js";
18
+ export { createManagedOperatorAuthority, operatorAuthorityCapabilities, CustomerSupportCommandInvalidError, CustomerSupportCommandIdempotencyConflictError, OperatorSubscriptionAuthorityUnavailableError, CustomerSupportCommandRequiresHumanError, CustomerSupportOperatorInactiveError, CustomerSupportOperatorNotProvisionedError } from "./operatorAuthority.js";
19
+ export type { OperatorRpcExecutor, OperatorAuthorityOptions } from "./operatorAuthority.js";
20
+ export { createPostgresOperatorAuthority } from "./postgresOperatorAuthority.js";
21
+ export type { OperatorQueryExecutor, OperatorTransactionExecutor } from "./postgresOperatorAuthority.js";
22
+ export { ACCOUNT_SUPPORT_MIGRATIONS } from "./migrations.js";
23
+ export { createAccountSupportBindings } from "./bindings.js";
24
+ export type { AccountSupportCallable, AccountSupportOperations, AccountSupportHostBindingRequired } from "./bindings.js";
25
+ export { createAccountSupportServices } from "./contribution.js";
26
+ export type { AccountSupportBindingRefusal, AccountSupportReadiness, GuardedAccountSupportOperation, GuardedAccountSupportOperations } from "./contribution.js";
@@ -0,0 +1,15 @@
1
+ export { createAccountReadFacade } from "./accountReadFacade.js";
2
+ export { CustomerAccountReadModelError, withCustomerAccountReadStage, customerAccountReadFailureDetails, logCustomerAccountReadFailure } from "./customerAccountReadDiagnostics.js";
3
+ export { CUSTOMER_ACCOUNT_V2_CONTRACT_VERSION, readAccountSnapshot, isCustomerVisibleSubscription, recurringPrice, computeEditState, editCutoff, buildActionRequired } from "./accountReadModels.js";
4
+ export { CUSTOMER_ORDERS_CONTRACT_VERSION, readCustomerOrderSummaries, readCustomerOrderDetail, customerOrderMoney, toOrderMoneyHeader, toOrderMoneyItem, mapCustomerOrderLines, lineListTotalMinor } from "./orderHistory.js";
5
+ export { SUPPORT_CUSTOMER_360_CONTRACT_VERSION, projectCustomer360Snapshot, deriveContactHealth, boundedCustomerJourneyAudit, createCustomer360ReadFacade } from "./customer360.js";
6
+ export { createInvoiceAccess, downloadOwnedInvoicePdf, deriveCustomerDocumentDeliveryStatus } from "./invoiceAccess.js";
7
+ export { createSelfServiceCommandFacade } from "./selfService.js";
8
+ export { encodeNativeSubscriptionCommand, decodeNativeSubscriptionPreview, createNativeSubscriptionDriver } from "./subscriptionCommandCodec.js";
9
+ export { createPaymentMethodComposition } from "./paymentMethodComposition.js";
10
+ export { createOperatorRecovery, moveIdentityForEmailCorrection, OperatorIdentityMoveRefusedError, executeOperatorAccountLink, linkThenApply } from "./operatorRecovery.js";
11
+ export { createManagedOperatorAuthority, operatorAuthorityCapabilities, CustomerSupportCommandInvalidError, CustomerSupportCommandIdempotencyConflictError, OperatorSubscriptionAuthorityUnavailableError, CustomerSupportCommandRequiresHumanError, CustomerSupportOperatorInactiveError, CustomerSupportOperatorNotProvisionedError } from "./operatorAuthority.js";
12
+ export { createPostgresOperatorAuthority } from "./postgresOperatorAuthority.js";
13
+ export { ACCOUNT_SUPPORT_MIGRATIONS } from "./migrations.js";
14
+ export { createAccountSupportBindings } from "./bindings.js";
15
+ export { createAccountSupportServices } from "./contribution.js";
@@ -0,0 +1,57 @@
1
+ import type { InvoiceHostPorts } from "../invoicing/contracts/index.js";
2
+ import type { CustomerDocumentDeliveryStatus } from "./contracts/invoice.js";
3
+ export type InvoiceOwnerAccessPort = InvoiceHostPorts["accountHistory"];
4
+ export type InvoiceArtifactDownloadPort = Pick<InvoiceHostPorts["artifacts"], "download">;
5
+ export interface InvoiceAccessOptions {
6
+ accountHistory?: InvoiceOwnerAccessPort;
7
+ artifacts?: InvoiceArtifactDownloadPort;
8
+ }
9
+ export declare function createInvoiceAccess(options?: InvoiceAccessOptions): {
10
+ history: (input: Parameters<InvoiceHostPorts["accountHistory"]["read"]>[0]) => ReturnType<InvoiceHostPorts["accountHistory"]["read"]>;
11
+ download: (input: Parameters<InvoiceHostPorts["accountHistory"]["resolveDownload"]>[0]) => Promise<{
12
+ readonly kind: "unsupported";
13
+ readonly code: "host_binding_required";
14
+ readonly retryable: false;
15
+ readonly effectMayHaveSucceeded: false;
16
+ } | {
17
+ readonly kind: "unknown";
18
+ readonly code: "unknown";
19
+ } | {
20
+ kind: "denied";
21
+ content?: undefined;
22
+ contentType?: undefined;
23
+ fileName?: undefined;
24
+ parentDocumentRef?: undefined;
25
+ } | {
26
+ kind: "downloaded";
27
+ content: Uint8Array<ArrayBufferLike>;
28
+ contentType: string;
29
+ fileName: string;
30
+ parentDocumentRef: string | null;
31
+ }>;
32
+ };
33
+ export declare function downloadOwnedInvoicePdf<Ticket, Pdf extends {
34
+ content: Uint8Array;
35
+ contentType: string;
36
+ }>(input: {
37
+ resolve(): Promise<Ticket | null>;
38
+ download(ticket: Ticket): Promise<Pdf>;
39
+ }): Promise<{
40
+ kind: "denied";
41
+ ticket?: undefined;
42
+ pdf?: undefined;
43
+ } | {
44
+ kind: "downloaded";
45
+ ticket: NonNullable<Awaited<Ticket>>;
46
+ pdf: Pdf;
47
+ }>;
48
+ export interface CustomerInvoiceDocumentStatusInput {
49
+ blockedReason: string | null;
50
+ status: string | null;
51
+ documentKind: string | null;
52
+ ksefStatus: string | null;
53
+ emailStatus: string | null;
54
+ outboxStatus: string | null;
55
+ downloadAvailable: boolean;
56
+ }
57
+ export declare function deriveCustomerDocumentDeliveryStatus(input: CustomerInvoiceDocumentStatusInput): CustomerDocumentDeliveryStatus;
@@ -0,0 +1,40 @@
1
+ import { createInvoiceReadModel } from "../invoicing/index.js";
2
+ export function createInvoiceAccess(options = {}) {
3
+ const accountHistory = options.accountHistory;
4
+ const owner = createInvoiceReadModel({
5
+ ...options,
6
+ accountHistory: accountHistory && {
7
+ read: input => accountHistory.read(input),
8
+ async resolveDownload(input) {
9
+ const history = await accountHistory.read({ accountRef: input.accountRef, orderId: input.orderId });
10
+ if (history.kind !== "found")
11
+ return history;
12
+ if (history.accountRef !== input.accountRef || history.orderId !== input.orderId
13
+ || !history.documents.some(document => document.documentRef === input.documentRef))
14
+ return { kind: "denied" };
15
+ return accountHistory.resolveDownload(input);
16
+ }
17
+ }
18
+ });
19
+ return { history: owner.history, download: owner.download };
20
+ }
21
+ export function downloadOwnedInvoicePdf(input) {
22
+ return createInvoiceReadModel().ownedPdf(input);
23
+ }
24
+ export function deriveCustomerDocumentDeliveryStatus(input) {
25
+ const status = normalized(input.status), clearance = normalized(input.ksefStatus), email = normalized(input.emailStatus), outbox = normalized(input.outboxStatus);
26
+ if (input.blockedReason || ["rejected", "voided", "cancelled"].includes(status) || clearance === "rejected")
27
+ return "requires_correction";
28
+ if (email === "failed" || ["failed", "uncertain", "cancelled"].includes(outbox))
29
+ return "delivery_failed";
30
+ if (input.documentKind === "b2b_vat" && !["accepted", "not_required"].includes(clearance))
31
+ return "ksef_pending";
32
+ if (["sent", "provider_accepted"].includes(email) || outbox === "succeeded")
33
+ return "email_provider_accepted";
34
+ if (email === "pending" || ["pending", "processing"].includes(outbox))
35
+ return "email_pending";
36
+ return input.downloadAvailable ? "pdf_ready" : "not_ready";
37
+ }
38
+ function normalized(value) {
39
+ return value?.trim().toLowerCase() ?? "";
40
+ }
@@ -0,0 +1,14 @@
1
+ /** Sparse projections only. Install the complete native/managed prefix, never this list alone. */
2
+ export declare const ACCOUNT_SUPPORT_MIGRATIONS: {
3
+ readonly native: {
4
+ readonly units: readonly [{
5
+ readonly position: 87;
6
+ readonly catalogPath: "db/platform/migrations/20261026120000_account_support_operator_authority.sql";
7
+ readonly sha256: "ac1e31679179e712d7558e7b1d82e8113f264abf9aaa44c2562ab988acdc7508";
8
+ readonly url: URL;
9
+ }];
10
+ };
11
+ readonly managed: {
12
+ readonly units: readonly ["supabase/migrations/20261026120100_account_support_current_authority.sql"];
13
+ };
14
+ };
@@ -0,0 +1,7 @@
1
+ /** Sparse projections only. Install the complete native/managed prefix, never this list alone. */
2
+ export const ACCOUNT_SUPPORT_MIGRATIONS = {
3
+ native: { units: [{ position: 87, catalogPath: "db/platform/migrations/20261026120000_account_support_operator_authority.sql",
4
+ sha256: "ac1e31679179e712d7558e7b1d82e8113f264abf9aaa44c2562ab988acdc7508",
5
+ url: new URL("../../sql/20261026120000_account_support_operator_authority.sql", import.meta.url) }] },
6
+ managed: { units: ["supabase/migrations/20261026120100_account_support_current_authority.sql"] },
7
+ };
@@ -0,0 +1,67 @@
1
+ import type { OperatorSubscriptionRefusal as OperatorSubscriptionRefusalCode, OperatorSubscriptionResult as OperatorSubscriptionCommandResult, OperatorEmailCorrectionResult, OperatorPhoneCorrectionResult, OperatorEmailCorrectionAdmission, OperatorEmailCorrectionExecution, OperatorEmailCorrectionSettlement, NativeOperatorSubscriptionResult, ManagedOperatorAuthorityPort, OperatorAuthorityCapabilities, OperatorAccountLinkResult, OperatorLeadAbsorptionResult, CustomerRecoveryAuthorityResult } from "./contracts/index.js";
2
+ export declare class CustomerSupportCommandInvalidError extends Error {
3
+ constructor();
4
+ }
5
+ export declare class CustomerSupportCommandIdempotencyConflictError extends Error {
6
+ constructor();
7
+ }
8
+ export declare class OperatorSubscriptionAuthorityUnavailableError extends Error {
9
+ constructor();
10
+ }
11
+ export declare class CustomerSupportCommandRequiresHumanError extends Error {
12
+ constructor();
13
+ }
14
+ export declare class CustomerSupportOperatorInactiveError extends Error {
15
+ constructor();
16
+ }
17
+ export declare class CustomerSupportOperatorNotProvisionedError extends Error {
18
+ constructor();
19
+ }
20
+ export declare const SUBSCRIPTION_REFUSALS: Set<OperatorSubscriptionRefusalCode>;
21
+ export declare function emailCorrection(value: unknown): OperatorEmailCorrectionResult;
22
+ /** Admission authorizes a command; only a service claim authorizes its execution. */
23
+ export declare function emailCorrectionAdmission(value: unknown): OperatorEmailCorrectionAdmission;
24
+ export declare function emailCorrectionExecution(value: unknown): OperatorEmailCorrectionExecution;
25
+ export declare function emailCorrectionSettlement(value: unknown): OperatorEmailCorrectionSettlement;
26
+ export declare function phoneCorrection(value: unknown): OperatorPhoneCorrectionResult;
27
+ export declare function subscriptionCommand(value: unknown): OperatorSubscriptionCommandResult;
28
+ /**
29
+ * Translate the routine's raised SQLSTATEs into failures the route can price as
30
+ * HTTP without reading a driver error. Anything unrecognized stays an opaque
31
+ * upstream failure rather than being guessed into a client fault.
32
+ */
33
+ export declare function operatorCommandFailure(error: unknown, fallback: string): Error;
34
+ /** Translate the routine's JSON into the one result shape both lanes report. */
35
+ export declare function leadAbsorption(value: unknown): OperatorLeadAbsorptionResult;
36
+ /** Translate the routine's JSON into the one result shape the route reports. */
37
+ export declare function accountLink(value: unknown): OperatorAccountLinkResult;
38
+ export declare function recoveryResult(value: unknown): CustomerRecoveryAuthorityResult;
39
+ /** Native-only additions never enter the managed subscription decoder. */
40
+ export declare function nativeSubscriptionCommand(value: unknown): NativeOperatorSubscriptionResult;
41
+ export declare function operatorAuthorityCapabilities(graph: "managed" | "native"): OperatorAuthorityCapabilities;
42
+ export interface OperatorRpcExecutor {
43
+ rpc(name: string, args: Record<string, unknown>): PromiseLike<{
44
+ data: unknown;
45
+ error: unknown;
46
+ }>;
47
+ }
48
+ /** Injected recovery material is private to the adapter; paths belong to the host. */
49
+ export interface OperatorRecoveryMaterial {
50
+ tokenHash: string;
51
+ payloadFingerprint: string;
52
+ expiresAt: string;
53
+ recoveryPath: string;
54
+ }
55
+ export interface OperatorAuthorityOptions {
56
+ operatorId: string;
57
+ now: () => number;
58
+ recoveryPath: (rawToken: string) => string;
59
+ /** Defaults to 32 random bytes from Web Crypto, encoded as base64url. */
60
+ createOpaqueToken?: () => string;
61
+ }
62
+ export declare function operatorRecoveryMaterial(input: {
63
+ subjectId: string;
64
+ caseId: string;
65
+ }, options: OperatorAuthorityOptions): Promise<OperatorRecoveryMaterial>;
66
+ /** Current managed calls over an injected executor; no provider, credentials or defaults. */
67
+ export declare function createManagedOperatorAuthority(executor: OperatorRpcExecutor, options: OperatorAuthorityOptions): ManagedOperatorAuthorityPort;