@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.
- package/CHANGELOG.md +167 -109
- package/README.md +111 -8
- package/dist/account-support/accountReadFacade.d.ts +8 -0
- package/dist/account-support/accountReadFacade.js +10 -0
- package/dist/account-support/accountReadModels.d.ts +69 -0
- package/dist/account-support/accountReadModels.js +272 -0
- package/dist/account-support/bindings.d.ts +23 -0
- package/dist/account-support/bindings.js +16 -0
- package/dist/account-support/contracts/account.d.ts +281 -0
- package/dist/account-support/contracts/account.js +1 -0
- package/dist/account-support/contracts/capabilities.d.ts +44 -0
- package/dist/account-support/contracts/capabilities.js +1 -0
- package/dist/account-support/contracts/commands.d.ts +307 -0
- package/dist/account-support/contracts/commands.js +1 -0
- package/dist/account-support/contracts/customer360.d.ts +154 -0
- package/dist/account-support/contracts/customer360.js +1 -0
- package/dist/account-support/contracts/index.d.ts +10 -0
- package/dist/account-support/contracts/index.js +1 -0
- package/dist/account-support/contracts/invoice.d.ts +79 -0
- package/dist/account-support/contracts/invoice.js +1 -0
- package/dist/account-support/contracts/operator.d.ts +289 -0
- package/dist/account-support/contracts/operator.js +1 -0
- package/dist/account-support/contribution.d.ts +24 -0
- package/dist/account-support/contribution.js +22 -0
- package/dist/account-support/customer360.d.ts +106 -0
- package/dist/account-support/customer360.js +163 -0
- package/dist/account-support/customerAccountReadDiagnostics.d.ts +11 -0
- package/dist/account-support/customerAccountReadDiagnostics.js +71 -0
- package/dist/account-support/index.d.ts +26 -0
- package/dist/account-support/index.js +15 -0
- package/dist/account-support/invoiceAccess.d.ts +57 -0
- package/dist/account-support/invoiceAccess.js +40 -0
- package/dist/account-support/migrations.d.ts +14 -0
- package/dist/account-support/migrations.js +7 -0
- package/dist/account-support/operatorAuthority.d.ts +67 -0
- package/dist/account-support/operatorAuthority.js +379 -0
- package/dist/account-support/operatorRecovery.d.ts +66 -0
- package/dist/account-support/operatorRecovery.js +129 -0
- package/dist/account-support/orderHistory.d.ts +50 -0
- package/dist/account-support/orderHistory.js +188 -0
- package/dist/account-support/paymentMethodComposition.d.ts +5 -0
- package/dist/account-support/paymentMethodComposition.js +4 -0
- package/dist/account-support/postgresOperatorAuthority.d.ts +16 -0
- package/dist/account-support/postgresOperatorAuthority.js +93 -0
- package/dist/account-support/selfService.d.ts +6 -0
- package/dist/account-support/selfService.js +81 -0
- package/dist/account-support/subscriptionCommandCodec.d.ts +10 -0
- package/dist/account-support/subscriptionCommandCodec.js +38 -0
- package/dist/catalog/draftSchemas.d.ts +1 -1
- package/dist/catalog/foundationSchemas.d.ts +3 -3
- package/dist/catalog/resolvedSkuProjection.d.ts +2 -2
- package/dist/catalog/sellableSchemas.d.ts +2 -2
- package/dist/commerce/checkoutCommandSchemas.d.ts +2 -2
- package/dist/commerce/checkoutResumeSchemas.d.ts +6 -6
- package/dist/commerce/checkoutSchemas.d.ts +12 -12
- package/dist/commerce/commerceReturnsPort.d.ts +2 -2
- package/dist/commerce/configuratorIntentSchemas.d.ts +2 -2
- package/dist/commerce/contractPrimitives.d.ts +8 -8
- package/dist/commerce/customerDefaultsSnapshotSchemas.d.ts +4 -4
- package/dist/commerce/model/omsReadModelHelpers.d.ts +4 -4
- package/dist/commerce/offerAvailabilitySchemas.d.ts +1 -1
- package/dist/commerce/oms/omsContractBase.d.ts +15 -15
- package/dist/commerce/oms/omsContractReadAuxSchemas.d.ts +11 -11
- package/dist/commerce/oms/omsContractReadSchemas.d.ts +121 -121
- package/dist/commerce/oms/omsContractRequests.d.ts +13 -13
- package/dist/commerce/oms/omsControlPlane.d.ts +22 -22
- package/dist/commerce/oms/omsFulfillmentContractSchemas.d.ts +12 -12
- package/dist/commerce/oms/omsFulfillmentDebugSchemas.d.ts +12 -12
- package/dist/commerce/orderReviewContracts.d.ts +33 -33
- package/dist/commerce/outboxEventSchemas.d.ts +4 -4
- package/dist/commerce/schemas.d.ts +21 -21
- package/dist/commerce/server/orderReviewHandlers.d.ts +10 -10
- package/dist/communications/consentPurposeRegistry.d.ts +1 -1
- package/dist/communications/newsletterIntegrationContracts.d.ts +8 -8
- package/dist/composition/accountSupportContribution.d.ts +18 -0
- package/dist/composition/accountSupportContribution.js +21 -0
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/index.js +1 -0
- package/dist/fulfillment/handlerSchemas.d.ts +40 -40
- package/dist/identity/customerContracts.d.ts +2 -2
- package/dist/invoicing/snapshot.d.ts +1 -1
- package/dist/pricing/acquisitionQuoteBinding.d.ts +1 -1
- package/dist/pricing/catalogFactsSchemas.d.ts +1 -1
- package/dist/pricing/quotePromotionEvidence.d.ts +1 -1
- package/dist/pricing/quoteSchemas.d.ts +56 -56
- package/dist/promotions/adminPromotionCodesContracts.d.ts +30 -30
- package/dist/promotions/adminPromotionsContracts.d.ts +14 -14
- package/package.json +12 -2
- package/release-gates.json +30 -3
- package/sql/20261026120000_account_support_operator_authority.sql +693 -0
- package/src/account-support/accountReadFacade.ts +15 -0
- package/src/account-support/accountReadModels.ts +371 -0
- package/src/account-support/bindings.ts +28 -0
- package/src/account-support/contracts/account.ts +306 -0
- package/src/account-support/contracts/capabilities.ts +30 -0
- package/src/account-support/contracts/commands.ts +243 -0
- package/src/account-support/contracts/customer360.ts +150 -0
- package/src/account-support/contracts/index.ts +141 -0
- package/src/account-support/contracts/invoice.ts +44 -0
- package/src/account-support/contracts/operator.ts +123 -0
- package/src/account-support/contribution.ts +35 -0
- package/src/account-support/customer360.ts +268 -0
- package/src/account-support/customerAccountReadDiagnostics.ts +83 -0
- package/src/account-support/index.ts +72 -0
- package/src/account-support/invoiceAccess.ts +63 -0
- package/src/account-support/migrations.ts +7 -0
- package/src/account-support/operatorAuthority.ts +393 -0
- package/src/account-support/operatorRecovery.ts +136 -0
- package/src/account-support/orderHistory.ts +309 -0
- package/src/account-support/paymentMethodComposition.ts +8 -0
- package/src/account-support/postgresOperatorAuthority.ts +92 -0
- package/src/account-support/selfService.ts +83 -0
- package/src/account-support/subscriptionCommandCodec.ts +48 -0
- package/src/composition/accountSupportContribution.ts +28 -0
- package/src/composition/index.ts +1 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import type { CustomerContext } from "./account.js";
|
|
2
|
+
import type { AccountSupportCapabilities, AccountSupportLaneUnavailable } from "./capabilities.js";
|
|
3
|
+
/** Local transcriptions of owner contracts; portFit checks equality against the owners. */
|
|
4
|
+
export interface SubscriptionCommandContext {
|
|
5
|
+
actor: {
|
|
6
|
+
kind: "customer" | "operator";
|
|
7
|
+
actorId: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
};
|
|
10
|
+
subscriptionId: string;
|
|
11
|
+
idempotencyKey: string;
|
|
12
|
+
now: string;
|
|
13
|
+
}
|
|
14
|
+
export type SubscriptionCommand = SubscriptionCommandContext & ({
|
|
15
|
+
action: "pause";
|
|
16
|
+
pausePreset: string;
|
|
17
|
+
reason: string | null;
|
|
18
|
+
survey: string | null;
|
|
19
|
+
saveOffer: string | null;
|
|
20
|
+
} | {
|
|
21
|
+
action: "resume" | "skip" | "cancel";
|
|
22
|
+
reason: string | null;
|
|
23
|
+
confirmedChargeTiming: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
action: "slide";
|
|
26
|
+
newNextCycleAt: string;
|
|
27
|
+
confirmedChargeTiming: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
action: "edit_future_terms";
|
|
30
|
+
shippingAddressId: string;
|
|
31
|
+
planDays: number;
|
|
32
|
+
cadenceDays: number;
|
|
33
|
+
expectedTemplateVersion: number;
|
|
34
|
+
/** Empty string means no quote (semantic no-op). */
|
|
35
|
+
acceptedQuoteHash: string;
|
|
36
|
+
confirmedChargeTiming: boolean;
|
|
37
|
+
coreLines: readonly SubscriptionBundleLine[];
|
|
38
|
+
addonLines: readonly SubscriptionBundleLine[];
|
|
39
|
+
compositionConstraint: string;
|
|
40
|
+
});
|
|
41
|
+
export interface SubscriptionBundleLine {
|
|
42
|
+
sku: string;
|
|
43
|
+
quantity: number;
|
|
44
|
+
}
|
|
45
|
+
export interface SubscriptionCommandReceipt {
|
|
46
|
+
actorId: string;
|
|
47
|
+
idempotencyKey: string;
|
|
48
|
+
commandFingerprint: string;
|
|
49
|
+
outcome: "applied" | "replayed" | "noop";
|
|
50
|
+
subscriptionId: string;
|
|
51
|
+
originalState: string;
|
|
52
|
+
nextCycleAt: string | null;
|
|
53
|
+
revision: string;
|
|
54
|
+
eventId: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface SubscriptionCommandRefusal {
|
|
57
|
+
outcome: "refused";
|
|
58
|
+
/** Stable machine code; never provider, PostgreSQL diagnostic or customer text.
|
|
59
|
+
* Unrecognized native or host diagnostics map to subscription_command_invalid_input. */
|
|
60
|
+
reason: "multi_cycle_prepaid_unsupported" | "subscription_command_addon_not_found" | "subscription_command_bundle_total_mismatch" | "subscription_command_charge_timing_not_confirmed" | "subscription_command_idempotency_conflict" | "subscription_command_invalid_composition_constraint" | "subscription_command_invalid_input" | "subscription_command_not_active" | "subscription_command_operation_busy" | "subscription_command_pause_forbidden" | "subscription_command_payment_blocked" | "subscription_command_preview_unsupported" | "subscription_command_renewal_terms_missing" | "subscription_command_unsupported_action" | "subscription_edit_catalog_unavailable" | "subscription_edit_invalid_lines" | "subscription_edit_invalid_request" | "subscription_edit_quote_expired" | "subscription_edit_quote_required" | "subscription_edit_stale_template" | "subscription_edit_window_closed" | "subscription_lifecycle_invalid_transition" | "subscription_lifecycle_invalid_skip" | "subscription_lifecycle_invalid_slide" | "subscription_lifecycle_payment_blocked";
|
|
61
|
+
}
|
|
62
|
+
export type SubscriptionUnsupportedCode = "multi_cycle_prepaid_unsupported" | "native_generic_bundle_commands_unsupported" | "native_command_bound_receipts_unsupported" | "native_prepared_attempt_store_unsupported";
|
|
63
|
+
export interface SubscriptionUnsupported {
|
|
64
|
+
supported: false;
|
|
65
|
+
refusalCode: SubscriptionUnsupportedCode;
|
|
66
|
+
}
|
|
67
|
+
/** Readiness must be selected explicitly; a port declaration does not install a store. */
|
|
68
|
+
export interface SubscriptionCapabilities {
|
|
69
|
+
graph: "managed" | "native";
|
|
70
|
+
multiCyclePrepaid: {
|
|
71
|
+
supported: false;
|
|
72
|
+
refusalCode: "multi_cycle_prepaid_unsupported";
|
|
73
|
+
};
|
|
74
|
+
genericBundleCommands: {
|
|
75
|
+
supported: true;
|
|
76
|
+
} | {
|
|
77
|
+
supported: false;
|
|
78
|
+
refusalCode: "native_generic_bundle_commands_unsupported";
|
|
79
|
+
};
|
|
80
|
+
commandBoundReceipts: {
|
|
81
|
+
supported: true;
|
|
82
|
+
} | {
|
|
83
|
+
supported: false;
|
|
84
|
+
refusalCode: "native_command_bound_receipts_unsupported";
|
|
85
|
+
};
|
|
86
|
+
preparedAttemptStore: {
|
|
87
|
+
supported: true;
|
|
88
|
+
} | {
|
|
89
|
+
supported: false;
|
|
90
|
+
refusalCode: "native_prepared_attempt_store_unsupported";
|
|
91
|
+
};
|
|
92
|
+
retryRecovery: "unavailable" | "selected";
|
|
93
|
+
stockRecovery: "unavailable" | "selected";
|
|
94
|
+
deliveryAdmission: "required";
|
|
95
|
+
executorCount: 1;
|
|
96
|
+
defaultEnabled: false;
|
|
97
|
+
}
|
|
98
|
+
/** Exact raw native owner command; its result still requires a host codec. */
|
|
99
|
+
export interface NativeSubscriptionCommand {
|
|
100
|
+
actorId: string;
|
|
101
|
+
clientId: string;
|
|
102
|
+
idempotencyKey: string;
|
|
103
|
+
subscriptionId: string;
|
|
104
|
+
action: string;
|
|
105
|
+
payload: Record<string, unknown>;
|
|
106
|
+
now: string;
|
|
107
|
+
}
|
|
108
|
+
/** Driver DTOs are explicit type arguments, never a claim that all graphs implement them. */
|
|
109
|
+
export interface SelfServiceCommandFacade<ManagedRequest, ManagedPreviewRequest, ManagedPreview, ManagedReceipt, ProfileRequest, ProfileResult, MethodRequest, MethodResult, CommerceRequest, CommerceResult, RecoveryRequest, RecoveryResult, ControlSnapshot = unknown> {
|
|
110
|
+
capabilities: AccountSupportCapabilities;
|
|
111
|
+
managedSubscription: {
|
|
112
|
+
previewAction(userId: string, request: ManagedPreviewRequest): Promise<ManagedPreview | null | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
113
|
+
applyAction(userId: string, request: ManagedRequest): Promise<ManagedReceipt | null | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
114
|
+
};
|
|
115
|
+
nativeLegacySubscription: {
|
|
116
|
+
previewAction(userId: string, request: ManagedPreviewRequest): Promise<ManagedPreview | null | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
117
|
+
applyAction(userId: string, request: ManagedRequest): Promise<ManagedReceipt | null | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
118
|
+
};
|
|
119
|
+
subscriptionControl: {
|
|
120
|
+
getSnapshot(userId: string): Promise<ControlSnapshot | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
121
|
+
};
|
|
122
|
+
nativeRawSubscription: {
|
|
123
|
+
preview(command: NativeSubscriptionCommand): Promise<Record<string, unknown> | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
124
|
+
apply(command: NativeSubscriptionCommand): Promise<Record<string, unknown> | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
125
|
+
};
|
|
126
|
+
nativeSubscription: {
|
|
127
|
+
apply(command: SubscriptionCommand): Promise<SubscriptionCommandReceipt | SubscriptionCommandRefusal | SubscriptionUnsupported | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
128
|
+
preview(command: Extract<SubscriptionCommand, {
|
|
129
|
+
action: "edit_future_terms";
|
|
130
|
+
}>): Promise<Record<string, unknown> | SubscriptionCommandRefusal | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
131
|
+
};
|
|
132
|
+
profile: {
|
|
133
|
+
updateProfile(userId: string, request: ProfileRequest): Promise<ProfileResult | null | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
134
|
+
};
|
|
135
|
+
paymentMethod: {
|
|
136
|
+
execute(userId: string, request: MethodRequest): Promise<MethodResult | AccountSupportLaneUnavailable<"unsupported">>;
|
|
137
|
+
};
|
|
138
|
+
commerce: {
|
|
139
|
+
execute(userId: string, request: CommerceRequest): Promise<CommerceResult | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
140
|
+
};
|
|
141
|
+
recovery: {
|
|
142
|
+
startPaymentRecovery(userId: string, request: RecoveryRequest): Promise<RecoveryResult | null | AccountSupportLaneUnavailable<"host_binding_required">>;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export interface AccountSupportMoney {
|
|
146
|
+
amountMinor: number;
|
|
147
|
+
currency: string;
|
|
148
|
+
}
|
|
149
|
+
export type SubscriptionPaymentMethodStatus = "usable" | "expiring" | "missing" | "revoked" | "requires_action" | "invalid" | "provider_disabled";
|
|
150
|
+
export type SubscriptionRenewalBlockStatus = "blocked_preflight" | "payment_pending" | "dunning" | "paid_fulfillment_pending" | "fulfillment_blocked" | "catalog_blocked" | "customer_action_required";
|
|
151
|
+
export type EligibilityRefusal = "not_active" | "edit_window_closed" | "cycle_locked" | "payment_blocked" | "missing_payment_method" | "invalid_address" | null;
|
|
152
|
+
export interface LegacySubscriptionPreviewResponse {
|
|
153
|
+
preview: {
|
|
154
|
+
subscriptionId: string;
|
|
155
|
+
action: string;
|
|
156
|
+
canApply: boolean;
|
|
157
|
+
blockedReason: EligibilityRefusal;
|
|
158
|
+
nextCycleAt: string | null;
|
|
159
|
+
editCutoffAt: string | null;
|
|
160
|
+
templateVersion: number | null;
|
|
161
|
+
lockedCycle?: {
|
|
162
|
+
locked: boolean;
|
|
163
|
+
status: SubscriptionRenewalBlockStatus | null;
|
|
164
|
+
};
|
|
165
|
+
futureTemplate?: {
|
|
166
|
+
templateVersion: number | null;
|
|
167
|
+
effectiveCycleAt: string | null;
|
|
168
|
+
priceAgreementPolicy: "lock_until_edit";
|
|
169
|
+
};
|
|
170
|
+
paymentMethodStatus?: SubscriptionPaymentMethodStatus;
|
|
171
|
+
deliverability?: {
|
|
172
|
+
status: "address_book_validated" | "blocked" | "unknown";
|
|
173
|
+
blockedReason: EligibilityRefusal;
|
|
174
|
+
};
|
|
175
|
+
catalogAvailability?: {
|
|
176
|
+
status: "available" | "blocked" | "unknown";
|
|
177
|
+
blockedReason: EligibilityRefusal;
|
|
178
|
+
};
|
|
179
|
+
quoteHash?: string;
|
|
180
|
+
quoteExpiresAt?: string;
|
|
181
|
+
currentTotal?: AccountSupportMoney;
|
|
182
|
+
newTotal?: AccountSupportMoney;
|
|
183
|
+
delta?: AccountSupportMoney;
|
|
184
|
+
chargeTiming?: {
|
|
185
|
+
requiresConfirmation: boolean;
|
|
186
|
+
confirmed: boolean;
|
|
187
|
+
earliestChargeAt: string | null;
|
|
188
|
+
};
|
|
189
|
+
dateAvailability?: {
|
|
190
|
+
earliestAllowedAt: string;
|
|
191
|
+
latestAllowedAt: string;
|
|
192
|
+
availableDates: string[];
|
|
193
|
+
blockedReason: EligibilityRefusal;
|
|
194
|
+
};
|
|
195
|
+
packageEdit?: {
|
|
196
|
+
currentRecurringPrice: AccountSupportMoney;
|
|
197
|
+
newRecurringPrice: AccountSupportMoney;
|
|
198
|
+
delta: AccountSupportMoney;
|
|
199
|
+
quoteHash: string;
|
|
200
|
+
effectiveCycleAt: string | null;
|
|
201
|
+
priceAgreementPolicy: "lock_until_edit";
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** Already resolved host request. The codec never supplies policy or catalogue fields. */
|
|
206
|
+
export interface LegacySubscriptionRequest<Action extends string = string, Payload extends Record<string, unknown> = Record<string, unknown>> {
|
|
207
|
+
subscriptionId: string;
|
|
208
|
+
idempotencyKey: string;
|
|
209
|
+
action: Action;
|
|
210
|
+
payload: Payload;
|
|
211
|
+
}
|
|
212
|
+
export interface RawSubscriptionCommands {
|
|
213
|
+
preview(command: NativeSubscriptionCommand): Promise<Record<string, unknown>>;
|
|
214
|
+
apply(command: NativeSubscriptionCommand): Promise<Record<string, unknown>>;
|
|
215
|
+
}
|
|
216
|
+
/** Only checked native quote records reach a host projection. */
|
|
217
|
+
export interface NativeSubscriptionPreview extends Record<string, unknown> {
|
|
218
|
+
status: "previewed";
|
|
219
|
+
canApply: true;
|
|
220
|
+
templateVersion: number;
|
|
221
|
+
quoteHash: string;
|
|
222
|
+
quoteExpiresAt: string;
|
|
223
|
+
currentTotalMinor: number;
|
|
224
|
+
newTotalMinor: number;
|
|
225
|
+
lines: {
|
|
226
|
+
variantId: string;
|
|
227
|
+
quantity: number;
|
|
228
|
+
isAddon: boolean;
|
|
229
|
+
sortOrder: number;
|
|
230
|
+
unitPriceMinor: number;
|
|
231
|
+
currency: string;
|
|
232
|
+
}[];
|
|
233
|
+
priceAgreementPolicy: {
|
|
234
|
+
kind: "lock_until_edit";
|
|
235
|
+
proration: "none";
|
|
236
|
+
cycleEffect: "future_unlocked_cycles_only";
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
export type NativePreviewProjection<Preview> = {
|
|
240
|
+
kind: "projected";
|
|
241
|
+
preview: Preview;
|
|
242
|
+
} | {
|
|
243
|
+
kind: "owner";
|
|
244
|
+
result: Record<string, unknown>;
|
|
245
|
+
};
|
|
246
|
+
export interface SubscriptionDriver<Request, Preview, Receipt> {
|
|
247
|
+
preview(context: CustomerContext, request: Request): Promise<Preview>;
|
|
248
|
+
apply(context: CustomerContext, request: Request): Promise<Receipt>;
|
|
249
|
+
}
|
|
250
|
+
/** Browser-safe transcription of M07 collection; instantiate with its branded handoff. */
|
|
251
|
+
export interface MethodSetupInput {
|
|
252
|
+
customer: string;
|
|
253
|
+
metadata: Record<string, string>;
|
|
254
|
+
idempotencyKey: string;
|
|
255
|
+
}
|
|
256
|
+
export type MethodSetupResult<Handoff> = {
|
|
257
|
+
kind: "ready";
|
|
258
|
+
setupRef: string;
|
|
259
|
+
handoff: Handoff;
|
|
260
|
+
replayed: boolean;
|
|
261
|
+
} | {
|
|
262
|
+
kind: "unsupported";
|
|
263
|
+
};
|
|
264
|
+
export interface MethodSetupPort<Handoff> {
|
|
265
|
+
setupMethod(input: MethodSetupInput): Promise<MethodSetupResult<Handoff>>;
|
|
266
|
+
}
|
|
267
|
+
/** Host parts retain repricing, quote validation, authorization and error construction. */
|
|
268
|
+
export interface NativeLegacySubscriptionParts<Request, PreviewRequest, Preview, Receipt, ControlSnapshot = unknown> {
|
|
269
|
+
explicitPause: {
|
|
270
|
+
applyAction(userId: string, request: Request): Promise<Receipt | null>;
|
|
271
|
+
};
|
|
272
|
+
control: LegacySubscriptionPort<Request, PreviewRequest, Preview, Receipt> & {
|
|
273
|
+
hasSubscription(userId: string, subscriptionId: string): Promise<boolean>;
|
|
274
|
+
getSnapshot(userId: string): Promise<ControlSnapshot>;
|
|
275
|
+
};
|
|
276
|
+
ownershipRefusal(): unknown;
|
|
277
|
+
}
|
|
278
|
+
export interface LegacySubscriptionPort<Request, PreviewRequest, Preview, Receipt> {
|
|
279
|
+
previewAction(userId: string, request: PreviewRequest): Promise<Preview | null>;
|
|
280
|
+
applyAction(userId: string, request: Request): Promise<Receipt | null>;
|
|
281
|
+
}
|
|
282
|
+
/** The host supplies capabilities and explicitly selects each owner lane. */
|
|
283
|
+
export type SelfServiceCommandFacadeInput<Request, PreviewRequest, Preview, Receipt, ProfileRequest, ProfileResult, MethodRequest, MethodResult, CommerceRequest, CommerceResult, RecoveryRequest, RecoveryResult, ControlSnapshot = unknown> = {
|
|
284
|
+
context: CustomerContext;
|
|
285
|
+
capabilities: AccountSupportCapabilities;
|
|
286
|
+
managedSubscription?: LegacySubscriptionPort<Request, PreviewRequest, Preview, Receipt>;
|
|
287
|
+
nativeLegacySubscription?: NativeLegacySubscriptionParts<Request, PreviewRequest, Preview, Receipt, ControlSnapshot>;
|
|
288
|
+
nativeRawSubscription?: RawSubscriptionCommands;
|
|
289
|
+
nativeSubscription?: {
|
|
290
|
+
apply(command: SubscriptionCommand): Promise<SubscriptionCommandReceipt | SubscriptionCommandRefusal | SubscriptionUnsupported>;
|
|
291
|
+
preview(command: Extract<SubscriptionCommand, {
|
|
292
|
+
action: "edit_future_terms";
|
|
293
|
+
}>): Promise<Record<string, unknown> | SubscriptionCommandRefusal>;
|
|
294
|
+
};
|
|
295
|
+
profile?: {
|
|
296
|
+
updateProfile(userId: string, request: ProfileRequest): Promise<ProfileResult | null>;
|
|
297
|
+
};
|
|
298
|
+
paymentMethod?: {
|
|
299
|
+
execute(userId: string, request: MethodRequest): Promise<MethodResult>;
|
|
300
|
+
};
|
|
301
|
+
commerce?: {
|
|
302
|
+
execute(userId: string, request: CommerceRequest): Promise<CommerceResult>;
|
|
303
|
+
};
|
|
304
|
+
recovery?: {
|
|
305
|
+
startPaymentRecovery(userId: string, request: RecoveryRequest): Promise<RecoveryResult | null>;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/** Verified human administrator context, supplied by the host. */
|
|
2
|
+
export interface OperatorContext {
|
|
3
|
+
operatorId: string;
|
|
4
|
+
role: "admin";
|
|
5
|
+
isMachineActor: false;
|
|
6
|
+
graph: "managed" | "native";
|
|
7
|
+
}
|
|
8
|
+
/** Verbatim parsed customer-360 lookup vocabulary; defaults belong to the host codec. */
|
|
9
|
+
export interface Customer360Lookup {
|
|
10
|
+
query?: string;
|
|
11
|
+
subjectId?: string;
|
|
12
|
+
orderId?: string;
|
|
13
|
+
subscriptionId?: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
pageSize: number;
|
|
16
|
+
mode?: "search" | "snapshot";
|
|
17
|
+
}
|
|
18
|
+
/** The supplied search/snapshot DTOs preserve owner coverage and omitted enrichments. */
|
|
19
|
+
export interface Customer360ReadPort<Search, Snapshot> {
|
|
20
|
+
searchCustomerJourney(request: Customer360Lookup): Promise<Search>;
|
|
21
|
+
getCustomerJourney(request: Customer360Lookup): Promise<Snapshot | null>;
|
|
22
|
+
}
|
|
23
|
+
export type Customer360LifecycleStage = "lead" | "waitlist" | "tester" | "customer" | "inactive";
|
|
24
|
+
export interface Customer360Subject {
|
|
25
|
+
subjectId: string;
|
|
26
|
+
displayName: string | null;
|
|
27
|
+
email: string | null;
|
|
28
|
+
phone?: string | null;
|
|
29
|
+
lifecycleStage: Customer360LifecycleStage;
|
|
30
|
+
lifecycle: {
|
|
31
|
+
stage: Customer360LifecycleStage;
|
|
32
|
+
enteredAt: string | null;
|
|
33
|
+
exitedAt: string | null;
|
|
34
|
+
}[];
|
|
35
|
+
firstSeenAt: string | null;
|
|
36
|
+
lastActivityAt: string | null;
|
|
37
|
+
authUserLinked?: boolean;
|
|
38
|
+
hasSignedIn?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface Customer360Order {
|
|
41
|
+
orderId: string;
|
|
42
|
+
orderNumber: string | null;
|
|
43
|
+
status: string;
|
|
44
|
+
subscriptionId: string | null;
|
|
45
|
+
totalMinor: number | null;
|
|
46
|
+
currency: string | null;
|
|
47
|
+
createdAt: string | null;
|
|
48
|
+
}
|
|
49
|
+
export interface Customer360Subscription {
|
|
50
|
+
subscriptionId: string;
|
|
51
|
+
status: string;
|
|
52
|
+
nextCycleAt: string | null;
|
|
53
|
+
latestOrderId: string | null;
|
|
54
|
+
templateVersion?: number;
|
|
55
|
+
shippingAddressId?: string | null;
|
|
56
|
+
paymentMethodKind?: string | null;
|
|
57
|
+
paymentMethodStatus?: string | null;
|
|
58
|
+
}
|
|
59
|
+
export interface Customer360PaymentTruth {
|
|
60
|
+
orderId: string;
|
|
61
|
+
status: string;
|
|
62
|
+
recoverable: boolean;
|
|
63
|
+
amountMinor: number | null;
|
|
64
|
+
currency: string | null;
|
|
65
|
+
lastAttemptAt: string | null;
|
|
66
|
+
}
|
|
67
|
+
export interface Customer360DunningCase {
|
|
68
|
+
caseId: string;
|
|
69
|
+
subscriptionId: string;
|
|
70
|
+
orderId: string | null;
|
|
71
|
+
status: string;
|
|
72
|
+
retryAttempt: number;
|
|
73
|
+
nextRetryAt: string | null;
|
|
74
|
+
notificationStatus: string | null;
|
|
75
|
+
recoveryAvailable: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface Customer360Recovery {
|
|
78
|
+
caseId: string;
|
|
79
|
+
status: "available" | "unavailable";
|
|
80
|
+
actionAvailable: boolean;
|
|
81
|
+
lastIssuedAt: string | null;
|
|
82
|
+
lastDeliveryStatus: string | null;
|
|
83
|
+
}
|
|
84
|
+
export interface Customer360ContactHealth {
|
|
85
|
+
lastTerminalStatus: "delivered" | "bounced" | "complained" | "failed" | null;
|
|
86
|
+
lastTerminalAt: string | null;
|
|
87
|
+
reachable: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface Customer360Address {
|
|
90
|
+
addressId: string;
|
|
91
|
+
label: string | null;
|
|
92
|
+
recipientName: string | null;
|
|
93
|
+
line1: string;
|
|
94
|
+
line2: string | null;
|
|
95
|
+
postalCode: string;
|
|
96
|
+
city: string;
|
|
97
|
+
country: string;
|
|
98
|
+
contactPhone: string | null;
|
|
99
|
+
isDefault: boolean;
|
|
100
|
+
kind: "shipping" | "both";
|
|
101
|
+
}
|
|
102
|
+
export interface Customer360AuditEvent {
|
|
103
|
+
eventId: string;
|
|
104
|
+
occurredAt: string;
|
|
105
|
+
action: string;
|
|
106
|
+
outcome: string;
|
|
107
|
+
entity: {
|
|
108
|
+
kind: "subject" | "order" | "subscription" | "dunning_case" | "recovery";
|
|
109
|
+
id: string;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export interface Customer360LookupResult {
|
|
113
|
+
query: string;
|
|
114
|
+
matchedBy: "subject_id" | "email" | "order_id" | "order_number" | "subscription_id" | "text";
|
|
115
|
+
confidence: "exact" | "high" | "medium";
|
|
116
|
+
warnings: string[];
|
|
117
|
+
}
|
|
118
|
+
export interface Customer360SearchResponse {
|
|
119
|
+
contractVersion: "support.customer_360.v2";
|
|
120
|
+
query: string;
|
|
121
|
+
candidates: {
|
|
122
|
+
subjectId: string;
|
|
123
|
+
displayName: string | null;
|
|
124
|
+
email: string | null;
|
|
125
|
+
lifecycleStage: Customer360LifecycleStage;
|
|
126
|
+
matchedBy: Customer360LookupResult["matchedBy"];
|
|
127
|
+
confidence: Customer360LookupResult["confidence"];
|
|
128
|
+
lastActivityAt: string | null;
|
|
129
|
+
snapshotLookup: {
|
|
130
|
+
subjectId: string;
|
|
131
|
+
};
|
|
132
|
+
}[];
|
|
133
|
+
warnings: string[];
|
|
134
|
+
}
|
|
135
|
+
export interface Customer360Snapshot<Extension = unknown> {
|
|
136
|
+
contractVersion: "support.customer_360.v2";
|
|
137
|
+
lookup: Customer360LookupResult;
|
|
138
|
+
subject: Customer360Subject;
|
|
139
|
+
orders: Customer360Order[];
|
|
140
|
+
subscriptions: Customer360Subscription[];
|
|
141
|
+
payment: Customer360PaymentTruth[];
|
|
142
|
+
dunningCases: Customer360DunningCase[];
|
|
143
|
+
recovery: Customer360Recovery[];
|
|
144
|
+
auditTrail: Customer360AuditEvent[];
|
|
145
|
+
contactHealth?: Customer360ContactHealth;
|
|
146
|
+
addresses?: Customer360Address[];
|
|
147
|
+
extension?: Extension;
|
|
148
|
+
}
|
|
149
|
+
export interface Customer360SummaryReadPort<Request, Result> {
|
|
150
|
+
getPortableSummary(request: Request): Promise<Result>;
|
|
151
|
+
}
|
|
152
|
+
export interface DiagnosticHistoryReadPort<Request, Result> {
|
|
153
|
+
history(request: Request): Promise<Result>;
|
|
154
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { CustomerContext, AccountReadRefusal, AccountReadPort, AccountProfile, AccountAddress, AccountBillingProfile, AccountPaymentPreference, AccountPickupPoint, AccountDeliverySelection, AccountDeliveryPreference, AccountEvent, AccountSubscriptionLine, AccountSubscription, AccountTrackingReference, AccountTrackingEvent, AccountInvoiceSummary, AccountInvoiceDocument, AccountOrderSummary, AccountOrderLine, AccountFulfillmentSummary, AccountOrderDetail, AccountOrderList, AccountOrderDetailResponse, AccountActionRequired, AccountActionMessage, AccountSnapshot } from "./account.js";
|
|
2
|
+
export type { OperatorContext, Customer360Lookup, Customer360ReadPort, Customer360LifecycleStage, Customer360Subject, Customer360Order, Customer360Subscription, Customer360PaymentTruth, Customer360DunningCase, Customer360Recovery, Customer360ContactHealth, Customer360Address, Customer360AuditEvent, Customer360LookupResult, Customer360SearchResponse, Customer360Snapshot, Customer360SummaryReadPort, DiagnosticHistoryReadPort } from "./customer360.js";
|
|
3
|
+
export type { SubscriptionCommandContext, SubscriptionCommand, SubscriptionBundleLine, SubscriptionCommandReceipt, SubscriptionCommandRefusal, SubscriptionUnsupportedCode, SubscriptionUnsupported, SubscriptionCapabilities, NativeSubscriptionCommand, SelfServiceCommandFacade, AccountSupportMoney, SubscriptionPaymentMethodStatus, SubscriptionRenewalBlockStatus, EligibilityRefusal, LegacySubscriptionPreviewResponse } from "./commands.js";
|
|
4
|
+
export type { OperatorSubscriptionAction, OperatorNewShippingAddress, OperatorShippingAddressPayload, OperatorSubscriptionPayload, OperatorSubscriptionRefusal, RecoveryRefusal, EmailCorrectionRefusal, PhoneCorrectionRefusal, LeadRefusal, OperatorContactCommand, OperatorLeadCommand, OperatorRecoveryCommand, OperatorRecoveryCommandEnvelope, OperatorSubscriptionResult } from "./operator.js";
|
|
5
|
+
export type { InvoiceDocumentIdentity, InvoiceUnsupported, InvoiceClearanceState, InvoiceAccessPort, CustomerDocumentDeliveryStatus, CustomerInvoiceDocumentRole, CustomerInvoiceDownloadArtifact, CustomerInvoiceDownloadRequest, AccountInvoiceHistoryResult, AccountInvoiceHistoryDocument } from "./invoice.js";
|
|
6
|
+
export type { AccountSupportCapability, AccountSupportCapabilities } from "./capabilities.js";
|
|
7
|
+
export type { LegacySubscriptionRequest, RawSubscriptionCommands, NativeSubscriptionPreview, NativePreviewProjection, SubscriptionDriver, MethodSetupInput, MethodSetupResult, MethodSetupPort, NativeLegacySubscriptionParts, LegacySubscriptionPort, SelfServiceCommandFacadeInput } from "./commands.js";
|
|
8
|
+
export type { AccountSupportLaneUnavailable } from "./capabilities.js";
|
|
9
|
+
export type { OperatorOwnerReceipt, NativeOperatorSubscriptionResult, OperatorAuthorityUnavailable, OperatorEmailCorrectionResult, OperatorPhoneCorrectionResult, CustomerRecoveryAuthorityResult, LeadAbsorptionCarried, OperatorLeadAbsorptionResult, OperatorEmailCorrectionClaim, OperatorIdentityMovePort, OperatorEmailCorrectionAdmission, OperatorEmailCorrectionPhase, OperatorEmailCorrectionSettlement, OperatorEmailCorrectionExecution, OperatorAccountLinkRefusal, OperatorAccountLinkResult, OperatorAccountLinkRequest, OperatorAccountLinkIdentityPort, OperatorSubscriptionInput, OperatorEmailInput, OperatorPhoneInput, OperatorLinkInput, OperatorRecoveryInput, OperatorAbsorptionInput, ManagedOperatorAuthorityPort, NativeOperatorAuthorityPort, LinkThenSubscriptionResult } from "./operator.js";
|
|
10
|
+
export type { OperatorAuthorityCapabilities } from "./capabilities.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** Exact browser-safe transcriptions of M09 account-history inputs and outcomes. */
|
|
2
|
+
export interface InvoiceDocumentIdentity {
|
|
3
|
+
readonly providerRef: string;
|
|
4
|
+
readonly documentRef: string;
|
|
5
|
+
readonly providerDocumentRef: string | null;
|
|
6
|
+
readonly orderRef: string;
|
|
7
|
+
readonly invoiceRef: string;
|
|
8
|
+
readonly parentProviderDocumentRef: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface InvoiceUnsupported {
|
|
11
|
+
readonly kind: "unsupported";
|
|
12
|
+
readonly code: "host_binding_required" | "unsupported";
|
|
13
|
+
readonly retryable: false;
|
|
14
|
+
readonly effectMayHaveSucceeded: false;
|
|
15
|
+
}
|
|
16
|
+
export type InvoiceClearanceState = "accepted" | "not_submitted" | "pending" | "rejected" | "not_required" | "unsupported";
|
|
17
|
+
export type InvoiceAccessPort = {
|
|
18
|
+
read(input: {
|
|
19
|
+
readonly accountRef: string;
|
|
20
|
+
readonly orderId: string;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
readonly kind: "found";
|
|
23
|
+
readonly accountRef: string;
|
|
24
|
+
readonly orderId: string;
|
|
25
|
+
readonly documents: readonly {
|
|
26
|
+
readonly documentRef: string;
|
|
27
|
+
readonly invoiceRef: string;
|
|
28
|
+
readonly parentDocumentRef: string | null;
|
|
29
|
+
readonly role: "original" | "correction" | "replacement";
|
|
30
|
+
readonly status: string;
|
|
31
|
+
readonly issuedAt: string | null;
|
|
32
|
+
readonly clearance: {
|
|
33
|
+
readonly state: InvoiceClearanceState;
|
|
34
|
+
readonly reference: string | null;
|
|
35
|
+
} | null;
|
|
36
|
+
readonly documentKind: string | null;
|
|
37
|
+
readonly artifact: "invoice" | "correction";
|
|
38
|
+
readonly providerDocumentNumber: string | null;
|
|
39
|
+
readonly totalGrossMinor: number | null;
|
|
40
|
+
readonly currency: string;
|
|
41
|
+
readonly emailState: "not_requested" | "pending" | "provider_accepted" | "failed";
|
|
42
|
+
readonly isCurrent: boolean;
|
|
43
|
+
readonly createdAt: string;
|
|
44
|
+
readonly downloadAvailable: boolean;
|
|
45
|
+
}[];
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: "denied";
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: "unknown";
|
|
50
|
+
readonly code: "unknown";
|
|
51
|
+
} | InvoiceUnsupported>;
|
|
52
|
+
resolveDownload(input: {
|
|
53
|
+
readonly accountRef: string;
|
|
54
|
+
readonly orderId: string;
|
|
55
|
+
readonly documentRef: string;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
readonly kind: "authorized";
|
|
58
|
+
readonly identity: InvoiceDocumentIdentity;
|
|
59
|
+
readonly artifactRef: string;
|
|
60
|
+
readonly fileName: string;
|
|
61
|
+
readonly parentDocumentRef: string | null;
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "denied";
|
|
64
|
+
} | {
|
|
65
|
+
readonly kind: "unknown";
|
|
66
|
+
readonly code: "unknown";
|
|
67
|
+
} | InvoiceUnsupported>;
|
|
68
|
+
};
|
|
69
|
+
export type CustomerDocumentDeliveryStatus = "not_ready" | "pdf_ready" | "ksef_pending" | "email_pending" | "email_provider_accepted" | "email_sent" | "requires_correction" | "delivery_failed";
|
|
70
|
+
export type CustomerInvoiceDocumentRole = "original" | "correction" | "replacement";
|
|
71
|
+
export type CustomerInvoiceDownloadArtifact = "invoice" | "correction";
|
|
72
|
+
export interface CustomerInvoiceDownloadRequest {
|
|
73
|
+
invoiceId: string;
|
|
74
|
+
artifact: CustomerInvoiceDownloadArtifact;
|
|
75
|
+
}
|
|
76
|
+
export type AccountInvoiceHistoryResult = Awaited<ReturnType<InvoiceAccessPort["read"]>>;
|
|
77
|
+
export type AccountInvoiceHistoryDocument = Extract<AccountInvoiceHistoryResult, {
|
|
78
|
+
kind: "found";
|
|
79
|
+
}>["documents"][number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|