@opencxh/domain 1.303.0 → 1.304.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.
@@ -1,22 +1,20 @@
1
- /**
2
- * `provisioning-source`: an app that can order at a supplier through its API (Eylo: a customer
3
- * account, numbers). Fulfilment submits a request per act and follows it; the provider says
4
- * what it needs and what it made.
5
- */
1
+ import { Commitment, LineRhythm } from '../entities/agreement/types';
6
2
  export declare const PROVISIONING_SOURCE_GROUP = "provisioning-source";
7
3
  export declare const PROVISIONING_ROUTES: {
8
4
  readonly describe: "/provisioning/describe";
9
5
  readonly submit: "/provisioning/submit";
10
6
  readonly status: "/provisioning/status";
11
7
  readonly subscriptions: "/provisioning/subscriptions";
12
- /** Optional, for offers that declare `qualify`: deliverable here, before the promise (047 step 8). */
13
- readonly qualify: "/provisioning/qualify";
14
8
  /** Optional, for account offers that declare `accounts`: every customer account it knows (047 step 9). */
15
9
  readonly accounts: "/provisioning/accounts";
16
10
  /** Optional, for providers that declare `catalog`: the assortment as price-list rows (045 D N-1). */
17
11
  readonly catalog: "/provisioning/catalog";
18
- /** Optional, for offers that declare `quote`: what one order costs, per part (045 D N-2). */
19
- readonly quote: "/provisioning/quote";
12
+ /**
13
+ * A dry run of `submit` (plan 053): the next questions, what is still unmet and the cost — of a
14
+ * purchase, a change or an end. Every provider answers it; without a handler of its own, its
15
+ * declared `params` do.
16
+ */
17
+ readonly prepare: "/provisioning/prepare";
20
18
  };
21
19
  /**
22
20
  * One vocabulary for the act, on the wire and on a `ProvisioningRequest` (plan 047 v2): `convert`
@@ -89,65 +87,16 @@ export interface ProvisionableOffer {
89
87
  recovery?: Partial<Record<ProvisioningAction, ProvisioningRecovery>>;
90
88
  /** The provider lists what runs under an account (`subscriptions`): polled into `reported`. */
91
89
  listing?: boolean;
92
- /** Answers `POST /provisioning/qualify` with its `qualify` params (047 step 8). */
93
- qualify?: boolean;
94
- /** Priced per order: answers `POST /provisioning/quote` (045 D N-2). */
95
- quote?: boolean;
96
90
  /**
97
91
  * An account offer whose accounts the provider lists (`POST /provisioning/accounts`): where
98
92
  * fulfilment looks for what already runs when an existing business moves over (047 step 9).
99
93
  */
100
94
  accounts?: boolean;
101
- /**
102
- * Internal only: a federated resource (`"nextpertise:SiteCheck"`) for a check a form cannot do.
103
- * Runs with a colleague's rights, so an offer checkable only this way is never self-service.
104
- */
105
- resource?: string;
106
- }
107
- /**
108
- * `qualify`: the offer, the supplier's product (`SupplierOffer.vendorSku`: one Nextpertise offer
109
- * covers every carrier product) and its `qualify` answers (an address as a crm address id).
110
- */
111
- export interface QualifyCommand {
112
- offer: string;
113
- vendorSku?: string;
114
- params: Record<string, string>;
115
- }
116
- /**
117
- * A provider's answer, per supplier option, with its cost: internal, never shown to a customer.
118
- * An option's `key` is one of the provider's own offer keys, so fulfilment can name it as ours.
119
- */
120
- export interface ProviderQualification {
121
- available: boolean;
122
- reason?: string;
123
- options?: {
124
- key: string;
125
- label: string;
126
- costCents?: number;
127
- termMonths?: number;
128
- }[];
129
- expiresAt: number;
95
+ /** The questions it starts with (plan 053); `prepare` answers the rest. */
96
+ requirements?: RequirementSpec[];
130
97
  }
131
98
  /**
132
- * `quote`: what an act costs. A purchase (no `action`): the offer, the supplier's product
133
- * (`SupplierOffer.vendorSku`), its commitment (`SupplierOffer.termMonths`) and the request's
134
- * answers. A cancel: the running subscription, the account it runs under and the day it ends.
135
- */
136
- export interface QuoteCommand {
137
- offer: string;
138
- action?: ProvisioningAction;
139
- vendorSku?: string;
140
- termMonths?: number;
141
- params: Record<string, string>;
142
- externalRef?: string;
143
- parent?: {
144
- externalRef?: string;
145
- fulfillment?: Record<string, string>;
146
- };
147
- effectiveAt?: number;
148
- }
149
- /**
150
- * What one order costs at the supplier, per part: each part is a line on the purchase order, once
99
+ * What one act costs at the supplier, per part: each part is a line on the purchase order, once
151
100
  * or per month. Cost, internal — never shown to a customer.
152
101
  */
153
102
  export interface ProviderQuote {
@@ -263,6 +212,13 @@ export interface ProvisioningCommand {
263
212
  effectiveAt?: number;
264
213
  }
265
214
  export type ProvisioningState = "pending" | "approved" | "failed" | "inquiring";
215
+ /** What the supplier ships itself for a service (the SIM, the router), followed by its tracking. */
216
+ export interface ProviderShipment {
217
+ carrier?: string;
218
+ trackingNumber?: string;
219
+ serials?: string[];
220
+ at?: number;
221
+ }
266
222
  export interface ProvisioningResult {
267
223
  state: ProvisioningState;
268
224
  externalRef?: string;
@@ -282,4 +238,126 @@ export interface ProvisioningResult {
282
238
  quantity?: number;
283
239
  /** What it now provides to others, normalised (047 v2 §7). */
284
240
  resources?: ProvidedResource[];
241
+ /** Shipped by the supplier, for this request (plan 053 G3). */
242
+ deliveries?: ProviderShipment[];
285
243
  }
244
+ /** What is bought, at whom: the provider's offer and, where one offer covers many, their product. */
245
+ export interface OfferRef {
246
+ app: string;
247
+ offer: string;
248
+ sku?: string;
249
+ }
250
+ /** `app:offer`, plus `:sku` when there is one: the one way to key an offer. */
251
+ export declare function offerKey(ref: OfferRef): string;
252
+ /** The same offer; a ref without a sku matches every product of that offer. */
253
+ export declare function sameOffer(a: OfferRef, b: OfferRef): boolean;
254
+ /** Every answer by requirement key; a quantity or a yes/no is a string too. */
255
+ export type ProvisioningAnswers = Record<string, string>;
256
+ /** By when it must be met: before the quote is accepted, or before the order goes out. */
257
+ export type RequirementGate = "quote" | "order";
258
+ export type AnswerType = "text" | "email" | "address" | "select" | "boolean" | "quantity";
259
+ /** One choice, live from the supplier. A `sku` makes it a product; its cost is internal. */
260
+ export interface RequirementOption {
261
+ key: string;
262
+ label: string;
263
+ sku?: string;
264
+ costCents?: number;
265
+ recurring?: "month";
266
+ /**
267
+ * What this choice binds us to at the supplier (NCE monthly vs yearly, plan 053 G1): the same
268
+ * `Commitment` as an agreement, as far as the supplier says it (Nextpertise names only the term).
269
+ * How often they invoice is no commitment: `billedEvery`.
270
+ */
271
+ commitment?: Partial<Commitment>;
272
+ billedEvery?: LineRhythm;
273
+ }
274
+ interface RequirementBase {
275
+ key: string;
276
+ label: string;
277
+ before: RequirementGate;
278
+ }
279
+ /**
280
+ * Something we fill in. `line` says it is sold: `main` picks the supplier's product of the line
281
+ * (the network, the bundle), `addon` becomes a sub-line of its own (an EVC, premium SLA).
282
+ * `perUnit`: every unit of an exclusive item has its own (the number to port, per SIM).
283
+ */
284
+ export interface AnswerSpec extends RequirementBase {
285
+ kind: "answer";
286
+ type: AnswerType;
287
+ required?: boolean;
288
+ options?: RequirementOption[];
289
+ line?: "main" | "addon";
290
+ /** A `boolean` or `quantity` add-on's own product and cost, per unit. */
291
+ sku?: string;
292
+ costCents?: number;
293
+ recurring?: "month";
294
+ min?: number;
295
+ max?: number;
296
+ perUnit?: boolean;
297
+ /**
298
+ * An offer may fix it (`SupplierOffer.provider.answers`): the article as a filter — "Glasvezel
299
+ * 1 Gbit" fixes technology and speed. Never asked in the flow; declared in `describe`.
300
+ */
301
+ preset?: boolean;
302
+ }
303
+ /** Something the provider judges; `who` resolves it when it is not met. */
304
+ export interface ConditionSpec extends RequirementBase {
305
+ kind: "condition";
306
+ who: "colleague" | "customer" | "provider";
307
+ }
308
+ /** Declared in `describe`: the questions an offer starts with, so a search knows who to ask. */
309
+ export type RequirementSpec = AnswerSpec | ConditionSpec;
310
+ /** What to do to meet a condition: send the link, set the record. */
311
+ export interface RequirementInstructions {
312
+ text: string;
313
+ link?: string;
314
+ record?: {
315
+ type: string;
316
+ name: string;
317
+ value: string;
318
+ };
319
+ }
320
+ export interface RequirementState {
321
+ met: boolean;
322
+ reason?: string;
323
+ /** An answer the provider proposes (from crm, or its only option). */
324
+ value?: string;
325
+ instructions?: RequirementInstructions;
326
+ }
327
+ export type Requirement = RequirementSpec & RequirementState;
328
+ /**
329
+ * `prepare`: the same act as `submit`, not sent. `answers` are everything filled in so far, the
330
+ * offer's own fixed ones included (`SupplierOffer.provider.answers`: the article as a filter).
331
+ */
332
+ export interface PrepareCommand {
333
+ ref: OfferRef;
334
+ action?: ProvisioningAction;
335
+ quantity: number;
336
+ answers: ProvisioningAnswers;
337
+ commitment?: Partial<Commitment>;
338
+ billedEvery?: LineRhythm;
339
+ externalRef?: string;
340
+ parent?: {
341
+ externalRef?: string;
342
+ fulfillment?: Record<string, string>;
343
+ };
344
+ customer?: {
345
+ companyId: string;
346
+ name?: string;
347
+ };
348
+ effectiveAt?: number;
349
+ }
350
+ /** The provider's answer: the next state of the questions, and what it costs. Internal. */
351
+ export interface Preparation {
352
+ requirements: Requirement[];
353
+ cost?: ProviderQuote;
354
+ /** Until when it holds: a deliverability check does not last. */
355
+ expiresAt?: number;
356
+ }
357
+ /**
358
+ * The questions of an offer that computes nothing: its declared `params`, met when answered
359
+ * (`qualify` before the quote, `ordering` before the order; what the supplier hands back is no
360
+ * question). What `prepare` answers for a provider that does not implement it.
361
+ */
362
+ export declare function preparationFromParams(params: ProvisioningParam[], answers: ProvisioningAnswers): Preparation;
363
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencxh/domain",
3
- "version": "1.303.0",
3
+ "version": "1.304.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",