@questwork/q-store-model 0.2.1 → 0.2.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/dist/v2/commercialVocabulary.d.ts +31 -0
- package/dist/v2/evaluation/acquisition.d.ts +2 -1
- package/dist/v2/evaluation/ruleEvaluators.d.ts +3 -2
- package/dist/v2/evaluation/shared.d.ts +1 -1
- package/dist/v2/index.d.ts +4 -1
- package/dist/v2/internal/validation.d.ts +5 -0
- package/dist/v2/models/Acquisition.d.ts +5 -0
- package/dist/v2/models/CommercialLifecycle.d.ts +5 -0
- package/dist/v2/models/InventoryBalance.d.ts +5 -0
- package/dist/v2/models/InventoryLedgerEntry.d.ts +10 -0
- package/dist/v2/models/Invoice.d.ts +5 -0
- package/dist/v2/models/InvoiceRevision.d.ts +5 -0
- package/dist/v2/models/Order.d.ts +5 -0
- package/dist/v2/models/OrderLine.d.ts +4 -0
- package/dist/v2/models/PaymentAttempt.d.ts +7 -0
- package/dist/v2/models/PaymentMethodConfigurationSnapshot.d.ts +4 -0
- package/dist/v2/models/Receipt.d.ts +5 -0
- package/dist/v2/models/Reservation.d.ts +4 -0
- package/dist/v2/models/Settlement.d.ts +5 -0
- package/dist/v2/models/index.d.ts +13 -0
- package/dist/v2/paymentTime.d.ts +8 -0
- package/dist/v2/q-store-model-v2.cjs +1 -1
- package/dist/v2/q-store-model-v2.esm.js +1448 -894
- package/dist/v2/ruleVocabulary.d.ts +1 -0
- package/dist/v2/walletItemUpdates.d.ts +11 -0
- package/package.json +1 -1
|
@@ -1,16 +1,44 @@
|
|
|
1
|
-
import { TenantAwareEntity as
|
|
2
|
-
|
|
1
|
+
import { TenantAwareEntity as Rt } from "@questwork/q-utilities";
|
|
2
|
+
const ht = Object.freeze({
|
|
3
|
+
CREATED: "CREATED",
|
|
4
|
+
PAYMENT_REQUIRED: "PAYMENT_REQUIRED",
|
|
5
|
+
PAYMENT_IN_PROGRESS: "PAYMENT_IN_PROGRESS",
|
|
6
|
+
PAID: "PAID",
|
|
7
|
+
COMPLETED: "COMPLETED",
|
|
8
|
+
CANCELLED: "CANCELLED",
|
|
9
|
+
EXPIRED: "EXPIRED"
|
|
10
|
+
}), It = Object.freeze({
|
|
11
|
+
HELD_FOR_CHECKOUT: "HELD_FOR_CHECKOUT",
|
|
12
|
+
HELD_FOR_PROVIDER: "HELD_FOR_PROVIDER",
|
|
13
|
+
HELD_FOR_REVIEW: "HELD_FOR_REVIEW",
|
|
14
|
+
CONSUMED: "CONSUMED",
|
|
15
|
+
RELEASED: "RELEASED",
|
|
16
|
+
EXPIRED: "EXPIRED"
|
|
17
|
+
}), Tt = Object.freeze({
|
|
18
|
+
CREATED: "CREATED",
|
|
19
|
+
PAYMENT_IN_PROGRESS: "PAYMENT_IN_PROGRESS",
|
|
20
|
+
SUCCEEDED: "SUCCEEDED",
|
|
21
|
+
FAILED: "FAILED",
|
|
22
|
+
CANCELLED: "CANCELLED",
|
|
23
|
+
EXPIRED: "EXPIRED"
|
|
24
|
+
}), Ce = Object.freeze({
|
|
25
|
+
PURCHASE: "PURCHASE",
|
|
26
|
+
ADMIN_ASSIGNMENT: "ADMIN_ASSIGNMENT",
|
|
27
|
+
ROLE_BENEFIT: "ROLE_BENEFIT",
|
|
28
|
+
PROMOTION_REDEMPTION: "PROMOTION_REDEMPTION"
|
|
29
|
+
});
|
|
30
|
+
class J extends Error {
|
|
3
31
|
constructor({ contractName: o, issues: e }) {
|
|
4
32
|
super(`${o} is invalid: ${e.join("; ")}`), this.name = "StoreContractValidationError", this.code = "STORE_CONTRACT_INVALID", this.contractName = o, this.issues = [...e];
|
|
5
33
|
}
|
|
6
34
|
}
|
|
7
|
-
const
|
|
35
|
+
const gt = ["boolean", "number", "string"];
|
|
8
36
|
function D(n, o = "value") {
|
|
9
37
|
if (n === null)
|
|
10
38
|
return null;
|
|
11
39
|
if (Array.isArray(n))
|
|
12
40
|
return n.map((e, t) => D(e, `${o}[${t}]`));
|
|
13
|
-
if (
|
|
41
|
+
if (gt.includes(typeof n)) {
|
|
14
42
|
if (typeof n == "number" && !Number.isFinite(n))
|
|
15
43
|
throw new TypeError(`${o} must be a finite number`);
|
|
16
44
|
return n;
|
|
@@ -23,42 +51,185 @@ function D(n, o = "value") {
|
|
|
23
51
|
}));
|
|
24
52
|
throw new TypeError(`${o} must contain JSON-safe values only`);
|
|
25
53
|
}
|
|
26
|
-
function
|
|
27
|
-
return n && typeof n == "object" && !Object.isFrozen(n) && (Object.values(n).forEach(
|
|
54
|
+
function L(n) {
|
|
55
|
+
return n && typeof n == "object" && !Object.isFrozen(n) && (Object.values(n).forEach(L), Object.freeze(n)), n;
|
|
28
56
|
}
|
|
29
|
-
function
|
|
30
|
-
const t = Object.keys(o).filter((
|
|
57
|
+
function nt({ contractName: n, object: o, fields: e }) {
|
|
58
|
+
const t = Object.keys(o).filter((r) => !e.includes(r));
|
|
31
59
|
if (t.length > 0)
|
|
32
|
-
throw new
|
|
60
|
+
throw new J({
|
|
33
61
|
contractName: n,
|
|
34
|
-
issues: t.map((
|
|
62
|
+
issues: t.map((r) => `unknown field "${r}"`)
|
|
35
63
|
});
|
|
36
64
|
}
|
|
37
|
-
function
|
|
65
|
+
function s(n, o, e) {
|
|
38
66
|
return typeof n != "string" || n.trim().length === 0 ? (e.push(`${o} must be a non-empty string`), "") : n;
|
|
39
67
|
}
|
|
40
|
-
function
|
|
68
|
+
function N(n, o, e) {
|
|
41
69
|
if (!(typeof n > "u" || n === null))
|
|
42
|
-
return
|
|
70
|
+
return s(n, o, e);
|
|
43
71
|
}
|
|
44
|
-
function
|
|
72
|
+
function f(n, o, e, t = 1) {
|
|
45
73
|
return !Number.isInteger(n) || n < 1 ? (e.push(`${o} must be a positive integer`), t) : n;
|
|
46
74
|
}
|
|
47
|
-
function
|
|
75
|
+
function x(n, o, e, t = 0) {
|
|
48
76
|
return typeof n != "number" || !Number.isFinite(n) || n < 0 ? (e.push(`${o} must be a non-negative finite number`), t) : n;
|
|
49
77
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
78
|
+
function oe(n, o, e, t = 0) {
|
|
79
|
+
return !Number.isInteger(n) || n < 0 ? (e.push(`${o} must be a non-negative integer`), t) : n;
|
|
80
|
+
}
|
|
81
|
+
function $(n, o, e) {
|
|
82
|
+
const t = s(n, o, e);
|
|
83
|
+
return t && !Number.isFinite(Date.parse(t)) && e.push(`${o} must be an ISO-compatible timestamp`), t;
|
|
84
|
+
}
|
|
85
|
+
function ae(n, o, e) {
|
|
86
|
+
if (!(typeof n > "u" || n === null))
|
|
87
|
+
return $(n, o, e);
|
|
88
|
+
}
|
|
89
|
+
function B(n, o, e) {
|
|
90
|
+
return !n || typeof n != "object" || Array.isArray(n) ? (e.push(`${o} must be an object`), {}) : D(n, o);
|
|
91
|
+
}
|
|
92
|
+
function Z(n, o, e) {
|
|
93
|
+
return Array.isArray(n) ? D(n, o) : (e.push(`${o} must be an array`), []);
|
|
94
|
+
}
|
|
95
|
+
function U(n, o, e) {
|
|
96
|
+
return Array.isArray(n) ? n.map((t, r) => s(t, `${o}[${r}]`, e)) : (e.push(`${o} must be an array`), []);
|
|
97
|
+
}
|
|
98
|
+
const bt = [
|
|
99
|
+
"_id",
|
|
100
|
+
"_tenant",
|
|
101
|
+
"_type",
|
|
102
|
+
"id",
|
|
103
|
+
"meta",
|
|
104
|
+
"metadata",
|
|
105
|
+
"remarks",
|
|
106
|
+
"tenantCode"
|
|
107
|
+
], ot = [
|
|
108
|
+
"active",
|
|
109
|
+
"created",
|
|
110
|
+
"creator",
|
|
111
|
+
"deleted",
|
|
112
|
+
"modified",
|
|
113
|
+
"owner",
|
|
114
|
+
"revision"
|
|
115
|
+
];
|
|
116
|
+
class O extends Rt {
|
|
117
|
+
constructor({ contractName: o, object: e, fields: t, normalize: r }) {
|
|
118
|
+
var l;
|
|
119
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
120
|
+
throw new J({ contractName: o, issues: ["input must be an object"] });
|
|
121
|
+
nt({ contractName: o, object: e, fields: [...bt, ...t] });
|
|
122
|
+
const i = [], d = s(e.tenantCode, "tenantCode", i);
|
|
123
|
+
Dt(e.meta, i), Ve(e.metadata, "metadata", i), Ve(e.remarks, "remarks", i);
|
|
124
|
+
const c = D(Object.fromEntries(t.flatMap((m) => Object.hasOwn(e, m) ? [[m, e[m]]] : []))), a = r(c, i, { meta: D(e.meta || {}) });
|
|
125
|
+
if (i.length > 0)
|
|
126
|
+
throw new J({ contractName: o, issues: i });
|
|
127
|
+
super({ ...e, tenantCode: d });
|
|
128
|
+
const u = (l = e.meta) == null ? void 0 : l.revision;
|
|
129
|
+
Number.isInteger(u) && u >= 0 && (this.meta.revision = u), this._type = e._type || o, Object.assign(this, a), Object.defineProperty(this, "_storeContractFields", {
|
|
130
|
+
configurable: !1,
|
|
131
|
+
enumerable: !1,
|
|
132
|
+
value: Object.freeze([...t]),
|
|
133
|
+
writable: !1
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
getId() {
|
|
137
|
+
return this.id === null || typeof this.id > "u" ? "" : this.id.toString();
|
|
138
|
+
}
|
|
139
|
+
toJSON() {
|
|
140
|
+
return this.toObject();
|
|
141
|
+
}
|
|
142
|
+
toObject() {
|
|
143
|
+
const o = {
|
|
144
|
+
_type: this._type,
|
|
145
|
+
meta: Le(this.meta, ot),
|
|
146
|
+
metadata: qe(this.metadata),
|
|
147
|
+
remarks: qe(this.remarks),
|
|
148
|
+
tenantCode: this.tenantCode,
|
|
149
|
+
...Le(this, this._storeContractFields)
|
|
150
|
+
}, e = this.getId();
|
|
151
|
+
return e && (o.id = e), D(o);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function Dt(n, o) {
|
|
155
|
+
if (!(typeof n > "u")) {
|
|
156
|
+
if (!n || typeof n != "object" || Array.isArray(n)) {
|
|
157
|
+
o.push("meta must be an object");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
Object.keys(n).forEach((e) => {
|
|
161
|
+
ot.includes(e) || o.push(`meta contains unknown field "${e}"`);
|
|
162
|
+
}), ["active", "deleted"].forEach((e) => {
|
|
163
|
+
typeof n[e] < "u" && typeof n[e] != "boolean" && o.push(`meta.${e} must be a boolean`);
|
|
164
|
+
}), ["created", "modified"].forEach((e) => {
|
|
165
|
+
typeof n[e] < "u" && (!Number.isFinite(n[e]) || n[e] < 0) && o.push(`meta.${e} must be a non-negative finite number`);
|
|
166
|
+
}), ["creator", "owner"].forEach((e) => {
|
|
167
|
+
typeof n[e] < "u" && typeof n[e] != "string" && o.push(`meta.${e} must be a string`);
|
|
168
|
+
}), typeof n.revision < "u" && (!Number.isInteger(n.revision) || n.revision < 0) && o.push("meta.revision must be a non-negative integer");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function qe(n) {
|
|
172
|
+
return Array.isArray(n) ? n.map((o) => ({ key: o.key, value: D(o.value) })) : [];
|
|
173
|
+
}
|
|
174
|
+
function Le(n, o) {
|
|
175
|
+
return Object.fromEntries(o.flatMap((e) => typeof n[e] > "u" ? [] : [[e, D(n[e])]]));
|
|
176
|
+
}
|
|
177
|
+
function Ve(n, o, e) {
|
|
178
|
+
if (!(typeof n > "u")) {
|
|
179
|
+
if (!Array.isArray(n)) {
|
|
180
|
+
e.push(`${o} must be an array`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
n.forEach((t, r) => {
|
|
184
|
+
if (!t || typeof t != "object" || Array.isArray(t)) {
|
|
185
|
+
e.push(`${o}[${r}] must be an object`);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
Object.keys(t).forEach((i) => {
|
|
189
|
+
["key", "value"].includes(i) || e.push(`${o}[${r}] contains unknown field "${i}"`);
|
|
190
|
+
}), s(t.key, `${o}[${r}].key`, e), Object.hasOwn(t, "value") ? D(t.value, `${o}[${r}].value`) : e.push(`${o}[${r}].value is required`);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
52
193
|
}
|
|
53
|
-
class
|
|
54
|
-
constructor(
|
|
194
|
+
class pn extends O {
|
|
195
|
+
constructor(o = {}) {
|
|
196
|
+
super({
|
|
197
|
+
contractName: "Acquisition",
|
|
198
|
+
object: o,
|
|
199
|
+
fields: ["acquisitionCode", "commandCode", "source", "eventRegistrationCode", "initiatedBy", "orderCode", "settlementCode", "merchandiseSnapshot", "productSnapshots", "walletItemCodes", "acquired"],
|
|
200
|
+
normalize(e, t) {
|
|
201
|
+
const r = s(e.source, "source", t);
|
|
202
|
+
Object.values(Ce).includes(r) || t.push(`source "${r}" is not supported`);
|
|
203
|
+
const i = N(e.orderCode, "orderCode", t), d = N(e.settlementCode, "settlementCode", t);
|
|
204
|
+
return r === Ce.PURCHASE && !i && t.push("orderCode is required for PURCHASE acquisition"), r !== Ce.PURCHASE && (i || d) && t.push("non-purchase acquisition must not reference an Order or Settlement"), {
|
|
205
|
+
acquisitionCode: s(e.acquisitionCode, "acquisitionCode", t),
|
|
206
|
+
commandCode: s(e.commandCode, "commandCode", t),
|
|
207
|
+
source: r,
|
|
208
|
+
eventRegistrationCode: s(e.eventRegistrationCode, "eventRegistrationCode", t),
|
|
209
|
+
initiatedBy: s(e.initiatedBy, "initiatedBy", t),
|
|
210
|
+
...i ? { orderCode: i } : {},
|
|
211
|
+
...d ? { settlementCode: d } : {},
|
|
212
|
+
merchandiseSnapshot: e.merchandiseSnapshot || {},
|
|
213
|
+
productSnapshots: Z(e.productSnapshots, "productSnapshots", t),
|
|
214
|
+
walletItemCodes: Z(e.walletItemCodes, "walletItemCodes", t),
|
|
215
|
+
acquired: $(e.acquired, "acquired", t)
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
getCode() {
|
|
221
|
+
return this.acquisitionCode;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
class h {
|
|
225
|
+
constructor({ contractName: o, object: e, fields: t, normalize: r }) {
|
|
55
226
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
56
|
-
throw new
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
throw new
|
|
61
|
-
Object.assign(this,
|
|
227
|
+
throw new J({ contractName: o, issues: ["input must be an object"] });
|
|
228
|
+
nt({ contractName: o, object: e, fields: t });
|
|
229
|
+
const i = [], d = r(D(e), i);
|
|
230
|
+
if (i.length > 0)
|
|
231
|
+
throw new J({ contractName: o, issues: i });
|
|
232
|
+
Object.assign(this, L(d)), Object.freeze(this);
|
|
62
233
|
}
|
|
63
234
|
toObject() {
|
|
64
235
|
return D(Object.fromEntries(Object.entries(this)));
|
|
@@ -67,26 +238,26 @@ class T {
|
|
|
67
238
|
return this.toObject();
|
|
68
239
|
}
|
|
69
240
|
}
|
|
70
|
-
class
|
|
241
|
+
class ve extends h {
|
|
71
242
|
constructor(o = {}) {
|
|
72
243
|
super({
|
|
73
244
|
contractName: "PriceEvaluationContext",
|
|
74
245
|
object: o,
|
|
75
246
|
fields: ["acquisitionSource", "countryCode", "countryRank", "currency", "instant"],
|
|
76
247
|
normalize(e, t) {
|
|
77
|
-
const
|
|
78
|
-
return
|
|
79
|
-
acquisitionSource:
|
|
80
|
-
countryCode:
|
|
81
|
-
countryRank:
|
|
82
|
-
currency:
|
|
83
|
-
instant:
|
|
248
|
+
const r = s(e.instant, "instant", t);
|
|
249
|
+
return r && !Number.isFinite(Date.parse(r)) && t.push("instant must be an ISO-compatible timestamp"), {
|
|
250
|
+
acquisitionSource: s(e.acquisitionSource, "acquisitionSource", t),
|
|
251
|
+
countryCode: s(e.countryCode, "countryCode", t),
|
|
252
|
+
countryRank: f(e.countryRank, "countryRank", t),
|
|
253
|
+
currency: s(e.currency, "currency", t),
|
|
254
|
+
instant: r
|
|
84
255
|
};
|
|
85
256
|
}
|
|
86
257
|
});
|
|
87
258
|
}
|
|
88
259
|
}
|
|
89
|
-
class
|
|
260
|
+
class Ue extends h {
|
|
90
261
|
constructor(o = {}) {
|
|
91
262
|
super({
|
|
92
263
|
contractName: "PriceScheduleRef",
|
|
@@ -94,55 +265,56 @@ class ge extends T {
|
|
|
94
265
|
fields: ["priceScheduleCode", "priceScheduleVersion"],
|
|
95
266
|
normalize(e, t) {
|
|
96
267
|
return {
|
|
97
|
-
priceScheduleCode:
|
|
98
|
-
priceScheduleVersion:
|
|
268
|
+
priceScheduleCode: s(e.priceScheduleCode, "priceScheduleCode", t),
|
|
269
|
+
priceScheduleVersion: f(e.priceScheduleVersion, "priceScheduleVersion", t)
|
|
99
270
|
};
|
|
100
271
|
}
|
|
101
272
|
});
|
|
102
273
|
}
|
|
103
274
|
}
|
|
104
|
-
const
|
|
275
|
+
const _ = Object.freeze({
|
|
105
276
|
ELIGIBILITY: "ELIGIBILITY",
|
|
106
277
|
INVENTORY: "INVENTORY",
|
|
107
278
|
PREREQUISITE: "PREREQUISITE",
|
|
108
279
|
QUANTITY: "QUANTITY",
|
|
109
280
|
REFUND: "REFUND",
|
|
110
281
|
REQUIREMENT: "REQUIREMENT"
|
|
111
|
-
}),
|
|
282
|
+
}), q = Object.freeze({
|
|
112
283
|
ACQUISITION_SOURCE: "ACQUISITION_SOURCE",
|
|
113
284
|
CATEGORY: "CATEGORY",
|
|
114
285
|
MERCHANDISE: "MERCHANDISE",
|
|
115
286
|
PRODUCT: "PRODUCT"
|
|
116
|
-
}),
|
|
287
|
+
}), M = Object.freeze({
|
|
117
288
|
CATEGORY: "CATEGORY",
|
|
118
289
|
MERCHANDISE: "MERCHANDISE",
|
|
119
290
|
PRODUCT: "PRODUCT"
|
|
120
|
-
}),
|
|
291
|
+
}), ee = Object.freeze({ ACTIVE: "ACTIVE", HOLDING: "HOLDING", ORDER: "ORDER" }), Y = Object.freeze({
|
|
121
292
|
NOT_SUBMITTED: "NOT_SUBMITTED",
|
|
293
|
+
REOPENED: "REOPENED",
|
|
122
294
|
REJECTED: "REJECTED",
|
|
123
295
|
REVOKED: "REVOKED",
|
|
124
296
|
UNDER_REVIEW: "UNDER_REVIEW",
|
|
125
297
|
VALID: "VALID"
|
|
126
|
-
}),
|
|
298
|
+
}), Ee = Object.freeze({
|
|
127
299
|
CAPACITY_ADMISSION: "CAPACITY_ADMISSION",
|
|
128
300
|
PRODUCTION_DEMAND: "PRODUCTION_DEMAND",
|
|
129
301
|
STOCKED_VARIANT: "STOCKED_VARIANT"
|
|
130
|
-
}),
|
|
302
|
+
}), ye = Object.freeze({ ALL: "ALL", ANY: "ANY" }), K = Object.freeze({ EXISTING: "EXISTING", SAME_ORDER: "SAME_ORDER" }), Re = Object.freeze({ BEFORE_ITEM_VALID: "BEFORE_ITEM_VALID" }), j = Object.freeze({
|
|
131
303
|
ALWAYS: "ALWAYS",
|
|
132
304
|
LOCK_AFTER_COMPLETE: "LOCK_AFTER_COMPLETE",
|
|
133
305
|
UNTIL_DEADLINE: "UNTIL_DEADLINE"
|
|
134
|
-
}),
|
|
306
|
+
}), fe = Object.freeze({
|
|
135
307
|
COMPLETE: "COMPLETE",
|
|
136
308
|
INCOMPLETE: "INCOMPLETE",
|
|
137
309
|
OVERDUE: "OVERDUE"
|
|
138
|
-
}),
|
|
310
|
+
}), ne = Object.freeze({
|
|
139
311
|
EDITABLE: "EDITABLE",
|
|
140
312
|
LOCKED: "LOCKED"
|
|
141
|
-
}),
|
|
313
|
+
}), X = Object.freeze({
|
|
142
314
|
EMAIL: "email",
|
|
143
315
|
TEXT: "text",
|
|
144
316
|
VARIANT: "VARIANT"
|
|
145
|
-
}),
|
|
317
|
+
}), S = Object.freeze({
|
|
146
318
|
CANCELLED: "CANCELLED",
|
|
147
319
|
EXPIRED: "EXPIRED",
|
|
148
320
|
PENDING_REQUIREMENT: "PENDING_REQUIREMENT",
|
|
@@ -151,7 +323,7 @@ const S = Object.freeze({
|
|
|
151
323
|
REVOKED: "REVOKED",
|
|
152
324
|
VALID: "VALID"
|
|
153
325
|
});
|
|
154
|
-
class
|
|
326
|
+
class $e extends h {
|
|
155
327
|
constructor(o = {}) {
|
|
156
328
|
super({
|
|
157
329
|
contractName: "RequirementFieldDefinition",
|
|
@@ -165,65 +337,65 @@ class be extends T {
|
|
|
165
337
|
"optionValueKey"
|
|
166
338
|
],
|
|
167
339
|
normalize(e, t) {
|
|
168
|
-
const
|
|
169
|
-
Object.values(
|
|
170
|
-
const
|
|
171
|
-
return
|
|
172
|
-
fieldCode:
|
|
173
|
-
label:
|
|
174
|
-
inputType:
|
|
175
|
-
...
|
|
176
|
-
...
|
|
340
|
+
const r = s(e.inputType, "inputType", t);
|
|
341
|
+
Object.values(X).includes(r) || t.push(`inputType "${r}" is not supported`);
|
|
342
|
+
const i = N(e.autocomplete, "autocomplete", t), d = N(e.deferredLabel, "deferredLabel", t), c = N(e.optionValueKey, "optionValueKey", t);
|
|
343
|
+
return r === X.VARIANT && !c && t.push("optionValueKey is required when inputType is VARIANT"), r !== X.VARIANT && c && t.push("optionValueKey is only supported when inputType is VARIANT"), {
|
|
344
|
+
fieldCode: s(e.fieldCode, "fieldCode", t),
|
|
345
|
+
label: s(e.label, "label", t),
|
|
346
|
+
inputType: r,
|
|
347
|
+
...i ? { autocomplete: i } : {},
|
|
348
|
+
...d ? { deferredLabel: d } : {},
|
|
177
349
|
...c ? { optionValueKey: c } : {}
|
|
178
350
|
};
|
|
179
351
|
}
|
|
180
352
|
});
|
|
181
353
|
}
|
|
182
354
|
}
|
|
183
|
-
class
|
|
355
|
+
class ie extends h {
|
|
184
356
|
constructor(o = {}) {
|
|
185
357
|
super({
|
|
186
358
|
contractName: "RequirementDefinition",
|
|
187
359
|
object: o,
|
|
188
360
|
fields: ["requirementCode", "label", "fields"],
|
|
189
361
|
normalize(e, t) {
|
|
190
|
-
const
|
|
362
|
+
const r = (Array.isArray(e.fields) ? e.fields : []).flatMap((d, c) => {
|
|
191
363
|
try {
|
|
192
|
-
return [(
|
|
193
|
-
} catch (
|
|
194
|
-
return t.push(`fields[${c}]: ${
|
|
364
|
+
return [(d instanceof $e ? d : new $e(d)).toObject()];
|
|
365
|
+
} catch (a) {
|
|
366
|
+
return t.push(`fields[${c}]: ${a.message}`), [];
|
|
195
367
|
}
|
|
196
368
|
});
|
|
197
|
-
Array.isArray(e.fields) || t.push("fields must be an array"),
|
|
198
|
-
const
|
|
199
|
-
return
|
|
200
|
-
|
|
369
|
+
Array.isArray(e.fields) || t.push("fields must be an array"), r.length === 0 && t.push("fields must contain at least one field");
|
|
370
|
+
const i = /* @__PURE__ */ new Set();
|
|
371
|
+
return r.forEach((d, c) => {
|
|
372
|
+
i.has(d.fieldCode) && t.push(`fields[${c}].fieldCode duplicates "${d.fieldCode}"`), i.add(d.fieldCode);
|
|
201
373
|
}), {
|
|
202
|
-
requirementCode:
|
|
203
|
-
label:
|
|
204
|
-
fields:
|
|
374
|
+
requirementCode: s(e.requirementCode, "requirementCode", t),
|
|
375
|
+
label: s(e.label, "label", t),
|
|
376
|
+
fields: r
|
|
205
377
|
};
|
|
206
378
|
}
|
|
207
379
|
});
|
|
208
380
|
}
|
|
209
381
|
}
|
|
210
|
-
function
|
|
211
|
-
n.forEach((
|
|
212
|
-
o.includes(
|
|
382
|
+
function rt({ values: n, allowedValues: o, path: e, issues: t }) {
|
|
383
|
+
n.forEach((r) => {
|
|
384
|
+
o.includes(r) || t.push(`${e} contains unsupported value "${r}"`);
|
|
213
385
|
});
|
|
214
386
|
}
|
|
215
|
-
function
|
|
216
|
-
return !n || typeof n != "object" || Array.isArray(n) ? (e.push(`${o} must be an object`), {}) : new
|
|
387
|
+
function Nt(n, o, e, t) {
|
|
388
|
+
return !n || typeof n != "object" || Array.isArray(n) ? (e.push(`${o} must be an object`), {}) : new h({
|
|
217
389
|
contractName: o,
|
|
218
390
|
object: n,
|
|
219
391
|
fields: ["code", "type"],
|
|
220
|
-
normalize(
|
|
221
|
-
const c = typeof
|
|
222
|
-
return c.trim() ||
|
|
392
|
+
normalize(i, d) {
|
|
393
|
+
const c = typeof i.type == "string" ? i.type : "", a = typeof i.code == "string" ? i.code : "";
|
|
394
|
+
return c.trim() || d.push("type must be a non-empty string"), a.trim() || d.push("code must be a non-empty string"), c && !t.includes(c) && d.push(`type "${c}" is not supported`), { type: c, code: a };
|
|
223
395
|
}
|
|
224
396
|
}).toObject();
|
|
225
397
|
}
|
|
226
|
-
function
|
|
398
|
+
function de(n, o, e) {
|
|
227
399
|
if (!(typeof n > "u" || n === null || n === "")) {
|
|
228
400
|
if (typeof n != "string" || !Number.isFinite(Date.parse(n))) {
|
|
229
401
|
e.push(`${o} must be an ISO-8601 timestamp`);
|
|
@@ -232,7 +404,7 @@ function Z(n, o, e) {
|
|
|
232
404
|
return n;
|
|
233
405
|
}
|
|
234
406
|
}
|
|
235
|
-
class
|
|
407
|
+
class ce extends h {
|
|
236
408
|
constructor(o = {}) {
|
|
237
409
|
super({
|
|
238
410
|
contractName: "RequirementPlan",
|
|
@@ -252,40 +424,40 @@ class ee extends T {
|
|
|
252
424
|
"values"
|
|
253
425
|
],
|
|
254
426
|
normalize(e, t) {
|
|
255
|
-
let
|
|
427
|
+
let r = {};
|
|
256
428
|
try {
|
|
257
|
-
|
|
258
|
-
} catch (
|
|
259
|
-
t.push(`requirement: ${
|
|
429
|
+
r = (e.requirement instanceof ie ? e.requirement : new ie(e.requirement)).toObject();
|
|
430
|
+
} catch (a) {
|
|
431
|
+
t.push(`requirement: ${a.message}`);
|
|
260
432
|
}
|
|
261
|
-
Object.values(
|
|
262
|
-
const
|
|
433
|
+
Object.values(Re).includes(e.completionTiming) || t.push(`completionTiming "${e.completionTiming}" is not supported`), Object.values(j).includes(e.modificationMode) || t.push(`modificationMode "${e.modificationMode}" is not supported`);
|
|
434
|
+
const i = de(e.completionDeadline, "completionDeadline", t), d = de(e.modificationDeadline, "modificationDeadline", t);
|
|
263
435
|
(!Number.isInteger(e.componentIndex) || e.componentIndex < 0) && t.push("componentIndex must be a non-negative integer"), (!Number.isInteger(e.unitIndex) || e.unitIndex < 0) && t.push("unitIndex must be a non-negative integer"), typeof e.complete != "boolean" && t.push("complete must be a boolean");
|
|
264
436
|
let c = {};
|
|
265
437
|
try {
|
|
266
438
|
!e.values || typeof e.values != "object" || Array.isArray(e.values) ? t.push("values must be an object") : c = D(e.values);
|
|
267
|
-
} catch (
|
|
268
|
-
t.push(`values: ${
|
|
439
|
+
} catch (a) {
|
|
440
|
+
t.push(`values: ${a.message}`);
|
|
269
441
|
}
|
|
270
442
|
return {
|
|
271
|
-
ruleCode:
|
|
272
|
-
requirement:
|
|
273
|
-
productCode:
|
|
443
|
+
ruleCode: s(e.ruleCode, "ruleCode", t),
|
|
444
|
+
requirement: r,
|
|
445
|
+
productCode: s(e.productCode, "productCode", t),
|
|
274
446
|
componentIndex: Number.isInteger(e.componentIndex) && e.componentIndex >= 0 ? e.componentIndex : 0,
|
|
275
447
|
unitIndex: Number.isInteger(e.unitIndex) && e.unitIndex >= 0 ? e.unitIndex : 0,
|
|
276
448
|
completionTiming: e.completionTiming,
|
|
277
449
|
modificationMode: e.modificationMode,
|
|
278
|
-
...
|
|
279
|
-
...
|
|
450
|
+
...i ? { completionDeadline: i } : {},
|
|
451
|
+
...d ? { modificationDeadline: d } : {},
|
|
280
452
|
values: c,
|
|
281
|
-
missingFields:
|
|
453
|
+
missingFields: U(e.missingFields || [], "missingFields", t),
|
|
282
454
|
complete: e.complete === !0
|
|
283
455
|
};
|
|
284
456
|
}
|
|
285
457
|
});
|
|
286
458
|
}
|
|
287
459
|
}
|
|
288
|
-
class
|
|
460
|
+
class At extends h {
|
|
289
461
|
constructor(o = {}) {
|
|
290
462
|
super({
|
|
291
463
|
contractName: "AcquisitionSnapshot",
|
|
@@ -311,52 +483,52 @@ class Xe extends T {
|
|
|
311
483
|
"evaluated"
|
|
312
484
|
],
|
|
313
485
|
normalize(e, t) {
|
|
314
|
-
let
|
|
486
|
+
let r = {};
|
|
315
487
|
try {
|
|
316
|
-
|
|
488
|
+
r = (e.priceEvaluationContext instanceof ve ? e.priceEvaluationContext : new ve(e.priceEvaluationContext)).toObject();
|
|
317
489
|
} catch (c) {
|
|
318
490
|
t.push(`priceEvaluationContext: ${c.message}`);
|
|
319
491
|
}
|
|
320
|
-
let
|
|
492
|
+
let i = {};
|
|
321
493
|
try {
|
|
322
|
-
|
|
494
|
+
i = (e.priceScheduleRef instanceof Ue ? e.priceScheduleRef : new Ue(e.priceScheduleRef)).toObject();
|
|
323
495
|
} catch (c) {
|
|
324
496
|
t.push(`priceScheduleRef: ${c.message}`);
|
|
325
497
|
}
|
|
326
|
-
const
|
|
498
|
+
const d = (Array.isArray(e.requirementPlans) ? e.requirementPlans : []).flatMap((c, a) => {
|
|
327
499
|
try {
|
|
328
|
-
return [(c instanceof
|
|
329
|
-
} catch (
|
|
330
|
-
return t.push(`requirementPlans[${
|
|
500
|
+
return [(c instanceof ce ? c : new ce(c)).toObject()];
|
|
501
|
+
} catch (u) {
|
|
502
|
+
return t.push(`requirementPlans[${a}]: ${u.message}`), [];
|
|
331
503
|
}
|
|
332
504
|
});
|
|
333
505
|
return Array.isArray(e.requirementPlans) || t.push("requirementPlans must be an array"), {
|
|
334
|
-
id:
|
|
335
|
-
contractVersion:
|
|
336
|
-
eventRegistrationCode:
|
|
337
|
-
purchaserEventRegistrationCode:
|
|
506
|
+
id: s(e.id, "id", t),
|
|
507
|
+
contractVersion: f(e.contractVersion, "contractVersion", t, 2),
|
|
508
|
+
eventRegistrationCode: s(e.eventRegistrationCode, "eventRegistrationCode", t),
|
|
509
|
+
purchaserEventRegistrationCode: s(
|
|
338
510
|
e.purchaserEventRegistrationCode,
|
|
339
511
|
"purchaserEventRegistrationCode",
|
|
340
512
|
t
|
|
341
513
|
),
|
|
342
|
-
payerEventRegistrationCode:
|
|
514
|
+
payerEventRegistrationCode: s(
|
|
343
515
|
e.payerEventRegistrationCode,
|
|
344
516
|
"payerEventRegistrationCode",
|
|
345
517
|
t
|
|
346
518
|
),
|
|
347
|
-
acquisitionSource:
|
|
519
|
+
acquisitionSource: s(e.acquisitionSource, "acquisitionSource", t),
|
|
348
520
|
merchandise: e.merchandise || {},
|
|
349
|
-
quantity:
|
|
521
|
+
quantity: f(e.quantity, "quantity", t),
|
|
350
522
|
products: e.products || [],
|
|
351
|
-
priceScheduleRef:
|
|
523
|
+
priceScheduleRef: i,
|
|
352
524
|
matchedPriceRow: e.matchedPriceRow || {},
|
|
353
|
-
priceEvaluationContext:
|
|
525
|
+
priceEvaluationContext: r,
|
|
354
526
|
effectiveRules: e.effectiveRules || {},
|
|
355
527
|
eligibilityDecisions: e.eligibilityDecisions || [],
|
|
356
|
-
requirementPlans:
|
|
528
|
+
requirementPlans: d,
|
|
357
529
|
inventoryDecisions: e.inventoryDecisions || [],
|
|
358
530
|
variantSelections: e.variantSelections || [],
|
|
359
|
-
evaluated:
|
|
531
|
+
evaluated: s(e.evaluated, "evaluated", t)
|
|
360
532
|
};
|
|
361
533
|
}
|
|
362
534
|
});
|
|
@@ -365,103 +537,7 @@ class Xe extends T {
|
|
|
365
537
|
return this.id;
|
|
366
538
|
}
|
|
367
539
|
}
|
|
368
|
-
|
|
369
|
-
"_id",
|
|
370
|
-
"_tenant",
|
|
371
|
-
"_type",
|
|
372
|
-
"id",
|
|
373
|
-
"meta",
|
|
374
|
-
"metadata",
|
|
375
|
-
"remarks",
|
|
376
|
-
"tenantCode"
|
|
377
|
-
], Ye = [
|
|
378
|
-
"active",
|
|
379
|
-
"created",
|
|
380
|
-
"creator",
|
|
381
|
-
"deleted",
|
|
382
|
-
"modified",
|
|
383
|
-
"owner",
|
|
384
|
-
"revision"
|
|
385
|
-
];
|
|
386
|
-
class L extends Ke {
|
|
387
|
-
constructor({ contractName: o, object: e, fields: t, normalize: i }) {
|
|
388
|
-
var l;
|
|
389
|
-
if (!e || typeof e != "object" || Array.isArray(e))
|
|
390
|
-
throw new G({ contractName: o, issues: ["input must be an object"] });
|
|
391
|
-
xe({ contractName: o, object: e, fields: [...Ze, ...t] });
|
|
392
|
-
const r = [], s = u(e.tenantCode, "tenantCode", r);
|
|
393
|
-
et(e.meta, r), Ne(e.metadata, "metadata", r), Ne(e.remarks, "remarks", r);
|
|
394
|
-
const c = D(Object.fromEntries(t.flatMap((f) => Object.hasOwn(e, f) ? [[f, e[f]]] : []))), d = i(c, r);
|
|
395
|
-
if (r.length > 0)
|
|
396
|
-
throw new G({ contractName: o, issues: r });
|
|
397
|
-
super({ ...e, tenantCode: s });
|
|
398
|
-
const a = (l = e.meta) == null ? void 0 : l.revision;
|
|
399
|
-
Number.isInteger(a) && a >= 0 && (this.meta.revision = a), this._type = e._type || o, Object.assign(this, d), Object.defineProperty(this, "_storeContractFields", {
|
|
400
|
-
configurable: !1,
|
|
401
|
-
enumerable: !1,
|
|
402
|
-
value: Object.freeze([...t]),
|
|
403
|
-
writable: !1
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
getId() {
|
|
407
|
-
return this.id === null || typeof this.id > "u" ? "" : this.id.toString();
|
|
408
|
-
}
|
|
409
|
-
toJSON() {
|
|
410
|
-
return this.toObject();
|
|
411
|
-
}
|
|
412
|
-
toObject() {
|
|
413
|
-
const o = {
|
|
414
|
-
_type: this._type,
|
|
415
|
-
meta: De(this.meta, Ye),
|
|
416
|
-
metadata: Oe(this.metadata),
|
|
417
|
-
remarks: Oe(this.remarks),
|
|
418
|
-
tenantCode: this.tenantCode,
|
|
419
|
-
...De(this, this._storeContractFields)
|
|
420
|
-
}, e = this.getId();
|
|
421
|
-
return e && (o.id = e), D(o);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
function et(n, o) {
|
|
425
|
-
if (!(typeof n > "u")) {
|
|
426
|
-
if (!n || typeof n != "object" || Array.isArray(n)) {
|
|
427
|
-
o.push("meta must be an object");
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
Object.keys(n).forEach((e) => {
|
|
431
|
-
Ye.includes(e) || o.push(`meta contains unknown field "${e}"`);
|
|
432
|
-
}), ["active", "deleted"].forEach((e) => {
|
|
433
|
-
typeof n[e] < "u" && typeof n[e] != "boolean" && o.push(`meta.${e} must be a boolean`);
|
|
434
|
-
}), ["created", "modified"].forEach((e) => {
|
|
435
|
-
typeof n[e] < "u" && (!Number.isFinite(n[e]) || n[e] < 0) && o.push(`meta.${e} must be a non-negative finite number`);
|
|
436
|
-
}), ["creator", "owner"].forEach((e) => {
|
|
437
|
-
typeof n[e] < "u" && typeof n[e] != "string" && o.push(`meta.${e} must be a string`);
|
|
438
|
-
}), typeof n.revision < "u" && (!Number.isInteger(n.revision) || n.revision < 0) && o.push("meta.revision must be a non-negative integer");
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
function Oe(n) {
|
|
442
|
-
return Array.isArray(n) ? n.map((o) => ({ key: o.key, value: D(o.value) })) : [];
|
|
443
|
-
}
|
|
444
|
-
function De(n, o) {
|
|
445
|
-
return Object.fromEntries(o.flatMap((e) => typeof n[e] > "u" ? [] : [[e, D(n[e])]]));
|
|
446
|
-
}
|
|
447
|
-
function Ne(n, o, e) {
|
|
448
|
-
if (!(typeof n > "u")) {
|
|
449
|
-
if (!Array.isArray(n)) {
|
|
450
|
-
e.push(`${o} must be an array`);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
n.forEach((t, i) => {
|
|
454
|
-
if (!t || typeof t != "object" || Array.isArray(t)) {
|
|
455
|
-
e.push(`${o}[${i}] must be an object`);
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
Object.keys(t).forEach((r) => {
|
|
459
|
-
["key", "value"].includes(r) || e.push(`${o}[${i}] contains unknown field "${r}"`);
|
|
460
|
-
}), u(t.key, `${o}[${i}].key`, e), Object.hasOwn(t, "value") ? D(t.value, `${o}[${i}].value`) : e.push(`${o}[${i}].value is required`);
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
class Lt extends L {
|
|
540
|
+
class ln extends O {
|
|
465
541
|
constructor(o = {}) {
|
|
466
542
|
super({
|
|
467
543
|
contractName: "Category",
|
|
@@ -469,10 +545,10 @@ class Lt extends L {
|
|
|
469
545
|
fields: ["categoryCode", "version", "name", "description"],
|
|
470
546
|
normalize(e, t) {
|
|
471
547
|
return {
|
|
472
|
-
categoryCode:
|
|
473
|
-
version:
|
|
474
|
-
name:
|
|
475
|
-
...
|
|
548
|
+
categoryCode: s(e.categoryCode, "categoryCode", t),
|
|
549
|
+
version: f(e.version, "version", t),
|
|
550
|
+
name: s(e.name, "name", t),
|
|
551
|
+
...N(e.description, "description", t) ? { description: e.description } : {}
|
|
476
552
|
};
|
|
477
553
|
}
|
|
478
554
|
});
|
|
@@ -481,20 +557,46 @@ class Lt extends L {
|
|
|
481
557
|
return this.categoryCode;
|
|
482
558
|
}
|
|
483
559
|
}
|
|
484
|
-
class
|
|
560
|
+
class we extends h {
|
|
561
|
+
constructor(o = {}) {
|
|
562
|
+
super({
|
|
563
|
+
contractName: "CommercialLifecycle",
|
|
564
|
+
object: o,
|
|
565
|
+
fields: ["stateCode", "changed", "reasonCode", "initiatedBy"],
|
|
566
|
+
normalize(e, t) {
|
|
567
|
+
const r = N(e.reasonCode, "reasonCode", t), i = N(e.initiatedBy, "initiatedBy", t);
|
|
568
|
+
return {
|
|
569
|
+
stateCode: s(e.stateCode, "stateCode", t),
|
|
570
|
+
changed: $(e.changed, "changed", t),
|
|
571
|
+
...r ? { reasonCode: r } : {},
|
|
572
|
+
...i ? { initiatedBy: i } : {}
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
function he(n, o, e, t) {
|
|
579
|
+
try {
|
|
580
|
+
const r = n instanceof we ? n : new we(n);
|
|
581
|
+
return e.includes(r.stateCode) || t.push(`${o}.stateCode "${r.stateCode}" is not supported`), r.toObject();
|
|
582
|
+
} catch (r) {
|
|
583
|
+
return t.push(`${o}: ${r.message}`), { stateCode: "", changed: ae(void 0, o, t) };
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
class mn extends O {
|
|
485
587
|
constructor(o = {}) {
|
|
486
588
|
super({
|
|
487
589
|
contractName: "Currency",
|
|
488
590
|
object: o,
|
|
489
591
|
fields: ["currencyCode", "name", "symbol", "factor", "unit"],
|
|
490
592
|
normalize(e, t) {
|
|
491
|
-
const
|
|
593
|
+
const r = N(e.symbol, "symbol", t);
|
|
492
594
|
return {
|
|
493
|
-
currencyCode:
|
|
494
|
-
name:
|
|
495
|
-
...
|
|
496
|
-
factor:
|
|
497
|
-
unit:
|
|
595
|
+
currencyCode: s(e.currencyCode, "currencyCode", t),
|
|
596
|
+
name: s(e.name, "name", t),
|
|
597
|
+
...r ? { symbol: r } : {},
|
|
598
|
+
factor: f(e.factor, "factor", t),
|
|
599
|
+
unit: s(e.unit, "unit", t)
|
|
498
600
|
};
|
|
499
601
|
}
|
|
500
602
|
});
|
|
@@ -503,7 +605,7 @@ class Ut extends L {
|
|
|
503
605
|
return this.currencyCode;
|
|
504
606
|
}
|
|
505
607
|
}
|
|
506
|
-
class
|
|
608
|
+
class Cn extends h {
|
|
507
609
|
constructor(o = {}) {
|
|
508
610
|
super({
|
|
509
611
|
contractName: "EligibilityFact",
|
|
@@ -516,19 +618,120 @@ class vt extends T {
|
|
|
516
618
|
"reasonCode"
|
|
517
619
|
],
|
|
518
620
|
normalize(e, t) {
|
|
519
|
-
const
|
|
520
|
-
return Object.values(
|
|
521
|
-
eligibilityType:
|
|
522
|
-
state:
|
|
621
|
+
const r = s(e.state, "state", t);
|
|
622
|
+
return Object.values(Y).includes(r) || t.push(`state "${r}" is not supported`), (!Number.isInteger(e.revision) || e.revision < 0) && t.push("revision must be a non-negative integer"), {
|
|
623
|
+
eligibilityType: s(e.eligibilityType, "eligibilityType", t),
|
|
624
|
+
state: r,
|
|
523
625
|
revision: Number.isInteger(e.revision) && e.revision >= 0 ? e.revision : 0,
|
|
524
|
-
...
|
|
525
|
-
...
|
|
626
|
+
...N(e.decisionReference, "decisionReference", t) ? { decisionReference: e.decisionReference } : {},
|
|
627
|
+
...N(e.reasonCode, "reasonCode", t) ? { reasonCode: e.reasonCode } : {}
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
class fn extends O {
|
|
634
|
+
constructor(o = {}) {
|
|
635
|
+
super({
|
|
636
|
+
contractName: "InventoryBalance",
|
|
637
|
+
object: o,
|
|
638
|
+
fields: ["inventoryBalanceCode", "inventoryPoolCode", "productCode", "variantCode", "capacity", "heldQuantity", "consumedQuantity"],
|
|
639
|
+
normalize(e, t) {
|
|
640
|
+
const r = N(e.variantCode, "variantCode", t), i = e.capacity === null ? null : oe(e.capacity, "capacity", t), d = oe(e.heldQuantity, "heldQuantity", t), c = oe(e.consumedQuantity, "consumedQuantity", t);
|
|
641
|
+
return i !== null && d + c > i && t.push("heldQuantity plus consumedQuantity must not exceed capacity"), {
|
|
642
|
+
inventoryBalanceCode: s(e.inventoryBalanceCode, "inventoryBalanceCode", t),
|
|
643
|
+
inventoryPoolCode: s(e.inventoryPoolCode, "inventoryPoolCode", t),
|
|
644
|
+
productCode: s(e.productCode, "productCode", t),
|
|
645
|
+
...r ? { variantCode: r } : {},
|
|
646
|
+
capacity: i,
|
|
647
|
+
heldQuantity: d,
|
|
648
|
+
consumedQuantity: c
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
getCode() {
|
|
654
|
+
return this.inventoryBalanceCode;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const Ot = Object.freeze({ HELD: "HELD", CONSUMED: "CONSUMED", RELEASED: "RELEASED" });
|
|
658
|
+
class En extends O {
|
|
659
|
+
constructor(o = {}) {
|
|
660
|
+
super({
|
|
661
|
+
contractName: "InventoryLedgerEntry",
|
|
662
|
+
object: o,
|
|
663
|
+
fields: ["inventoryLedgerEntryCode", "inventoryBalanceCode", "reservationCode", "orderCode", "action", "quantity", "occurred"],
|
|
664
|
+
normalize(e, t) {
|
|
665
|
+
const r = s(e.action, "action", t);
|
|
666
|
+
Object.values(Ot).includes(r) || t.push(`action "${r}" is not supported`);
|
|
667
|
+
const i = N(e.orderCode, "orderCode", t);
|
|
668
|
+
return {
|
|
669
|
+
inventoryLedgerEntryCode: s(e.inventoryLedgerEntryCode, "inventoryLedgerEntryCode", t),
|
|
670
|
+
inventoryBalanceCode: s(e.inventoryBalanceCode, "inventoryBalanceCode", t),
|
|
671
|
+
reservationCode: s(e.reservationCode, "reservationCode", t),
|
|
672
|
+
...i ? { orderCode: i } : {},
|
|
673
|
+
action: r,
|
|
674
|
+
quantity: f(e.quantity, "quantity", t),
|
|
675
|
+
occurred: $(e.occurred, "occurred", t)
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
getCode() {
|
|
681
|
+
return this.inventoryLedgerEntryCode;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
class yn extends O {
|
|
685
|
+
constructor(o = {}) {
|
|
686
|
+
super({
|
|
687
|
+
contractName: "Invoice",
|
|
688
|
+
object: o,
|
|
689
|
+
fields: ["invoiceCode", "invoiceNumber", "orderCode", "currentRevisionCode", "currentRevisionNumber", "issued"],
|
|
690
|
+
normalize(e, t) {
|
|
691
|
+
return {
|
|
692
|
+
invoiceCode: s(e.invoiceCode, "invoiceCode", t),
|
|
693
|
+
invoiceNumber: s(e.invoiceNumber, "invoiceNumber", t),
|
|
694
|
+
orderCode: s(e.orderCode, "orderCode", t),
|
|
695
|
+
currentRevisionCode: s(e.currentRevisionCode, "currentRevisionCode", t),
|
|
696
|
+
currentRevisionNumber: f(e.currentRevisionNumber, "currentRevisionNumber", t),
|
|
697
|
+
issued: $(e.issued, "issued", t)
|
|
526
698
|
};
|
|
527
699
|
}
|
|
528
700
|
});
|
|
529
701
|
}
|
|
702
|
+
getCode() {
|
|
703
|
+
return this.invoiceCode;
|
|
704
|
+
}
|
|
530
705
|
}
|
|
531
|
-
class
|
|
706
|
+
class Rn extends O {
|
|
707
|
+
constructor(o = {}) {
|
|
708
|
+
super({
|
|
709
|
+
contractName: "InvoiceRevision",
|
|
710
|
+
object: o,
|
|
711
|
+
fields: ["invoiceRevisionCode", "invoiceCode", "revisionNumber", "currency", "amount", "issuer", "billTo", "lines", "instructions", "issued", "due"],
|
|
712
|
+
normalize(e, t) {
|
|
713
|
+
const r = ae(e.due, "due", t);
|
|
714
|
+
return {
|
|
715
|
+
invoiceRevisionCode: s(e.invoiceRevisionCode, "invoiceRevisionCode", t),
|
|
716
|
+
invoiceCode: s(e.invoiceCode, "invoiceCode", t),
|
|
717
|
+
revisionNumber: f(e.revisionNumber, "revisionNumber", t),
|
|
718
|
+
currency: s(e.currency, "currency", t),
|
|
719
|
+
amount: x(e.amount, "amount", t),
|
|
720
|
+
issuer: B(e.issuer, "issuer", t),
|
|
721
|
+
billTo: B(e.billTo, "billTo", t),
|
|
722
|
+
lines: Z(e.lines, "lines", t),
|
|
723
|
+
instructions: B(e.instructions || {}, "instructions", t),
|
|
724
|
+
issued: $(e.issued, "issued", t),
|
|
725
|
+
...r ? { due: r } : {}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
getCode() {
|
|
731
|
+
return this.invoiceRevisionCode;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
class je extends h {
|
|
532
735
|
constructor(o = {}) {
|
|
533
736
|
super({
|
|
534
737
|
contractName: "MerchandiseComponent",
|
|
@@ -536,34 +739,34 @@ class Ae extends T {
|
|
|
536
739
|
fields: ["productCode", "productVersion", "quantityPerUnit"],
|
|
537
740
|
normalize(e, t) {
|
|
538
741
|
return {
|
|
539
|
-
productCode:
|
|
540
|
-
productVersion:
|
|
541
|
-
quantityPerUnit:
|
|
742
|
+
productCode: s(e.productCode, "productCode", t),
|
|
743
|
+
productVersion: f(e.productVersion, "productVersion", t),
|
|
744
|
+
quantityPerUnit: f(e.quantityPerUnit, "quantityPerUnit", t)
|
|
542
745
|
};
|
|
543
746
|
}
|
|
544
747
|
});
|
|
545
748
|
}
|
|
546
749
|
}
|
|
547
|
-
class
|
|
750
|
+
class hn extends O {
|
|
548
751
|
constructor(o = {}) {
|
|
549
752
|
super({
|
|
550
753
|
contractName: "Merchandise",
|
|
551
754
|
object: o,
|
|
552
755
|
fields: ["merchandiseCode", "version", "name", "description", "components", "priceScheduleCode"],
|
|
553
756
|
normalize(e, t) {
|
|
554
|
-
let
|
|
757
|
+
let r = [];
|
|
555
758
|
try {
|
|
556
|
-
|
|
557
|
-
} catch (
|
|
558
|
-
t.push(`components: ${
|
|
759
|
+
r = (e.components || []).map((i) => (i instanceof je ? i : new je(i)).toObject());
|
|
760
|
+
} catch (i) {
|
|
761
|
+
t.push(`components: ${i.message}`);
|
|
559
762
|
}
|
|
560
|
-
return
|
|
561
|
-
merchandiseCode:
|
|
562
|
-
version:
|
|
563
|
-
name:
|
|
564
|
-
...
|
|
565
|
-
components:
|
|
566
|
-
priceScheduleCode:
|
|
763
|
+
return r.length === 0 && t.push("components must contain at least one component"), {
|
|
764
|
+
merchandiseCode: s(e.merchandiseCode, "merchandiseCode", t),
|
|
765
|
+
version: f(e.version, "version", t),
|
|
766
|
+
name: s(e.name, "name", t),
|
|
767
|
+
...N(e.description, "description", t) ? { description: e.description } : {},
|
|
768
|
+
components: r,
|
|
769
|
+
priceScheduleCode: s(e.priceScheduleCode, "priceScheduleCode", t)
|
|
567
770
|
};
|
|
568
771
|
}
|
|
569
772
|
});
|
|
@@ -572,47 +775,227 @@ class wt extends L {
|
|
|
572
775
|
return this.merchandiseCode;
|
|
573
776
|
}
|
|
574
777
|
}
|
|
575
|
-
|
|
778
|
+
class xe extends h {
|
|
779
|
+
constructor(o = {}) {
|
|
780
|
+
super({
|
|
781
|
+
contractName: "OrderLine",
|
|
782
|
+
object: o,
|
|
783
|
+
fields: ["orderLineCode", "merchandiseCode", "merchandiseVersion", "quantity", "currency", "unitAmount", "totalAmount", "products", "commercialDecision"],
|
|
784
|
+
normalize(e, t) {
|
|
785
|
+
return {
|
|
786
|
+
orderLineCode: s(e.orderLineCode, "orderLineCode", t),
|
|
787
|
+
merchandiseCode: s(e.merchandiseCode, "merchandiseCode", t),
|
|
788
|
+
merchandiseVersion: f(e.merchandiseVersion, "merchandiseVersion", t),
|
|
789
|
+
quantity: f(e.quantity, "quantity", t),
|
|
790
|
+
currency: s(e.currency, "currency", t),
|
|
791
|
+
unitAmount: x(e.unitAmount, "unitAmount", t),
|
|
792
|
+
totalAmount: x(e.totalAmount, "totalAmount", t),
|
|
793
|
+
products: Z(e.products, "products", t),
|
|
794
|
+
commercialDecision: B(e.commercialDecision, "commercialDecision", t)
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
class ze extends h {
|
|
801
|
+
constructor(o = {}) {
|
|
802
|
+
super({
|
|
803
|
+
contractName: "Reservation",
|
|
804
|
+
object: o,
|
|
805
|
+
fields: ["reservationCode", "lifecycle", "heldUntil", "inventoryCommitments"],
|
|
806
|
+
normalize(e, t) {
|
|
807
|
+
const r = ae(e.heldUntil, "heldUntil", t);
|
|
808
|
+
return {
|
|
809
|
+
reservationCode: s(e.reservationCode, "reservationCode", t),
|
|
810
|
+
lifecycle: he(e.lifecycle, "lifecycle", Object.values(It), t),
|
|
811
|
+
...r ? { heldUntil: r } : {},
|
|
812
|
+
inventoryCommitments: Z(e.inventoryCommitments, "inventoryCommitments", t)
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
class In extends O {
|
|
819
|
+
constructor(o = {}) {
|
|
820
|
+
super({
|
|
821
|
+
contractName: "Order",
|
|
822
|
+
object: o,
|
|
823
|
+
fields: ["orderCode", "submissionCode", "eventRegistrationCode", "purchaserEventRegistrationCode", "payerEventRegistrationCode", "currency", "amount", "catalogDecisionRevision", "lines", "lifecycle", "reservation", "invoiceCode", "paymentAttemptCodes", "settlementCode", "acquisitionCodes", "submitted"],
|
|
824
|
+
normalize(e, t) {
|
|
825
|
+
const r = (Array.isArray(e.lines) ? e.lines : []).flatMap((c, a) => {
|
|
826
|
+
try {
|
|
827
|
+
return [(c instanceof xe ? c : new xe(c)).toObject()];
|
|
828
|
+
} catch (u) {
|
|
829
|
+
return t.push(`lines[${a}]: ${u.message}`), [];
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
r.length === 0 && t.push("lines must contain at least one line");
|
|
833
|
+
let i = {};
|
|
834
|
+
try {
|
|
835
|
+
i = (e.reservation instanceof ze ? e.reservation : new ze(e.reservation)).toObject();
|
|
836
|
+
} catch (c) {
|
|
837
|
+
t.push(`reservation: ${c.message}`);
|
|
838
|
+
}
|
|
839
|
+
const d = N(e.settlementCode, "settlementCode", t);
|
|
840
|
+
return {
|
|
841
|
+
orderCode: s(e.orderCode, "orderCode", t),
|
|
842
|
+
submissionCode: s(e.submissionCode, "submissionCode", t),
|
|
843
|
+
eventRegistrationCode: s(e.eventRegistrationCode, "eventRegistrationCode", t),
|
|
844
|
+
purchaserEventRegistrationCode: s(e.purchaserEventRegistrationCode, "purchaserEventRegistrationCode", t),
|
|
845
|
+
payerEventRegistrationCode: s(e.payerEventRegistrationCode, "payerEventRegistrationCode", t),
|
|
846
|
+
currency: s(e.currency, "currency", t),
|
|
847
|
+
amount: x(e.amount, "amount", t),
|
|
848
|
+
catalogDecisionRevision: s(e.catalogDecisionRevision, "catalogDecisionRevision", t),
|
|
849
|
+
lines: r,
|
|
850
|
+
lifecycle: he(e.lifecycle, "lifecycle", Object.values(ht), t),
|
|
851
|
+
reservation: i,
|
|
852
|
+
invoiceCode: s(e.invoiceCode, "invoiceCode", t),
|
|
853
|
+
paymentAttemptCodes: U(e.paymentAttemptCodes || [], "paymentAttemptCodes", t),
|
|
854
|
+
...d ? { settlementCode: d } : {},
|
|
855
|
+
acquisitionCodes: U(e.acquisitionCodes || [], "acquisitionCodes", t),
|
|
856
|
+
submitted: $(e.submitted, "submitted", t)
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
getCode() {
|
|
862
|
+
return this.orderCode;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
function St({ paymentAttemptMeta: n, salesPeriodEnd: o }) {
|
|
866
|
+
const e = it(n), t = dt(o, "salesPeriodEnd");
|
|
867
|
+
return e < t;
|
|
868
|
+
}
|
|
869
|
+
function Qe({ paymentAttemptMeta: n, defaultPaymentDuration: o }) {
|
|
870
|
+
const e = it(n);
|
|
871
|
+
if (!Number.isInteger(o) || o <= 0)
|
|
872
|
+
throw new TypeError("defaultPaymentDuration must be a positive integer in milliseconds");
|
|
873
|
+
return new Date(e + o).toISOString();
|
|
874
|
+
}
|
|
875
|
+
function it(n) {
|
|
876
|
+
if (!n || typeof n != "object")
|
|
877
|
+
throw new TypeError("paymentAttemptMeta must be an object");
|
|
878
|
+
return dt(n.created, "paymentAttemptMeta.created");
|
|
879
|
+
}
|
|
880
|
+
function dt(n, o) {
|
|
881
|
+
const e = typeof n == "number" ? n : Date.parse(n);
|
|
882
|
+
if (!Number.isFinite(e) || e < 0)
|
|
883
|
+
throw new TypeError(`${o} must be an ISO-compatible timestamp`);
|
|
884
|
+
return e;
|
|
885
|
+
}
|
|
886
|
+
class Be extends h {
|
|
887
|
+
constructor(o = {}) {
|
|
888
|
+
super({
|
|
889
|
+
contractName: "PaymentMethodConfigurationSnapshot",
|
|
890
|
+
object: o,
|
|
891
|
+
fields: ["paymentMethodCode", "version", "adapterCode", "display", "supportedCurrencyCodes", "defaultPaymentDuration", "integrationBindingCode"],
|
|
892
|
+
normalize(e, t) {
|
|
893
|
+
const r = oe(e.defaultPaymentDuration, "defaultPaymentDuration", t);
|
|
894
|
+
return r === 0 && t.push("defaultPaymentDuration must be greater than zero"), {
|
|
895
|
+
paymentMethodCode: s(e.paymentMethodCode, "paymentMethodCode", t),
|
|
896
|
+
version: f(e.version, "version", t),
|
|
897
|
+
adapterCode: s(e.adapterCode, "adapterCode", t),
|
|
898
|
+
display: B(e.display, "display", t),
|
|
899
|
+
supportedCurrencyCodes: U(e.supportedCurrencyCodes, "supportedCurrencyCodes", t),
|
|
900
|
+
defaultPaymentDuration: r,
|
|
901
|
+
integrationBindingCode: s(e.integrationBindingCode, "integrationBindingCode", t)
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
class Tn extends O {
|
|
908
|
+
constructor(o = {}) {
|
|
909
|
+
super({
|
|
910
|
+
contractName: "PaymentAttempt",
|
|
911
|
+
object: o,
|
|
912
|
+
fields: ["paymentAttemptCode", "orderCode", "invoiceCode", "invoiceRevisionCode", "currency", "amount", "paymentMethodConfigurationSnapshot", "matchedCommercialDecision", "paymentDeadline", "lifecycle", "providerReference", "providerSession", "providerState", "providerOutcomeTime"],
|
|
913
|
+
normalize(e, t, { meta: r }) {
|
|
914
|
+
let i = {};
|
|
915
|
+
try {
|
|
916
|
+
i = (e.paymentMethodConfigurationSnapshot instanceof Be ? e.paymentMethodConfigurationSnapshot : new Be(e.paymentMethodConfigurationSnapshot)).toObject();
|
|
917
|
+
} catch (m) {
|
|
918
|
+
t.push(`paymentMethodConfigurationSnapshot: ${m.message}`);
|
|
919
|
+
}
|
|
920
|
+
let d = "";
|
|
921
|
+
try {
|
|
922
|
+
d = i.defaultPaymentDuration ? Qe({ paymentAttemptMeta: r, defaultPaymentDuration: i.defaultPaymentDuration }) : "";
|
|
923
|
+
} catch (m) {
|
|
924
|
+
t.push(m.message);
|
|
925
|
+
}
|
|
926
|
+
const c = $(e.paymentDeadline, "paymentDeadline", t);
|
|
927
|
+
d && c !== d && t.push("paymentDeadline must equal meta.created plus paymentMethodConfigurationSnapshot.defaultPaymentDuration");
|
|
928
|
+
const a = N(e.providerReference, "providerReference", t), u = N(e.providerState, "providerState", t), l = ae(e.providerOutcomeTime, "providerOutcomeTime", t);
|
|
929
|
+
return {
|
|
930
|
+
paymentAttemptCode: s(e.paymentAttemptCode, "paymentAttemptCode", t),
|
|
931
|
+
orderCode: s(e.orderCode, "orderCode", t),
|
|
932
|
+
invoiceCode: s(e.invoiceCode, "invoiceCode", t),
|
|
933
|
+
invoiceRevisionCode: s(e.invoiceRevisionCode, "invoiceRevisionCode", t),
|
|
934
|
+
currency: s(e.currency, "currency", t),
|
|
935
|
+
amount: x(e.amount, "amount", t),
|
|
936
|
+
paymentMethodConfigurationSnapshot: i,
|
|
937
|
+
matchedCommercialDecision: B(e.matchedCommercialDecision, "matchedCommercialDecision", t),
|
|
938
|
+
paymentDeadline: c,
|
|
939
|
+
lifecycle: he(e.lifecycle, "lifecycle", Object.values(Tt), t),
|
|
940
|
+
...a ? { providerReference: a } : {},
|
|
941
|
+
providerSession: B(e.providerSession || {}, "providerSession", t),
|
|
942
|
+
...u ? { providerState: u } : {},
|
|
943
|
+
...l ? { providerOutcomeTime: l } : {}
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
getCode() {
|
|
949
|
+
return this.paymentAttemptCode;
|
|
950
|
+
}
|
|
951
|
+
static canStart(o) {
|
|
952
|
+
return St(o);
|
|
953
|
+
}
|
|
954
|
+
static calculateDeadline(o) {
|
|
955
|
+
return Qe(o);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
function Ye(n, o, e) {
|
|
576
959
|
if (!(typeof n > "u" || n === null))
|
|
577
|
-
return
|
|
960
|
+
return f(n, o, e);
|
|
578
961
|
}
|
|
579
|
-
class
|
|
962
|
+
class Fe extends h {
|
|
580
963
|
constructor(o = {}) {
|
|
581
964
|
super({
|
|
582
965
|
contractName: "PriceMatchCriteria",
|
|
583
966
|
object: o,
|
|
584
967
|
fields: ["countryCodes", "excludedCountryCodes", "countryRank"],
|
|
585
968
|
normalize(e, t) {
|
|
586
|
-
const
|
|
969
|
+
const r = U(e.countryCodes || [], "countryCodes", t), i = U(
|
|
587
970
|
e.excludedCountryCodes || [],
|
|
588
971
|
"excludedCountryCodes",
|
|
589
972
|
t
|
|
590
|
-
),
|
|
591
|
-
|
|
592
|
-
`countryCodes and excludedCountryCodes overlap: ${[...new Set(
|
|
973
|
+
), d = r.filter((a) => i.includes(a));
|
|
974
|
+
d.length > 0 && t.push(
|
|
975
|
+
`countryCodes and excludedCountryCodes overlap: ${[...new Set(d)].join(", ")}`
|
|
593
976
|
);
|
|
594
977
|
let c;
|
|
595
978
|
if (typeof e.countryRank < "u" && e.countryRank !== null)
|
|
596
979
|
if (typeof e.countryRank != "object" || Array.isArray(e.countryRank))
|
|
597
980
|
t.push("countryRank must be an object");
|
|
598
981
|
else {
|
|
599
|
-
Object.keys(e.countryRank).filter((
|
|
600
|
-
const
|
|
601
|
-
typeof
|
|
602
|
-
...
|
|
982
|
+
Object.keys(e.countryRank).filter((m) => !["min", "max"].includes(m)).forEach((m) => t.push(`countryRank contains unknown field "${m}"`));
|
|
983
|
+
const u = Ye(e.countryRank.min, "countryRank.min", t), l = Ye(e.countryRank.max, "countryRank.max", t);
|
|
984
|
+
typeof u > "u" && typeof l > "u" && t.push("countryRank must contain min or max"), u && l && u > l && t.push("countryRank.max must be greater than or equal to countryRank.min"), c = {
|
|
985
|
+
...u ? { min: u } : {},
|
|
603
986
|
...l ? { max: l } : {}
|
|
604
987
|
};
|
|
605
988
|
}
|
|
606
989
|
return {
|
|
607
|
-
countryCodes:
|
|
608
|
-
excludedCountryCodes:
|
|
990
|
+
countryCodes: r,
|
|
991
|
+
excludedCountryCodes: i,
|
|
609
992
|
...c ? { countryRank: c } : {}
|
|
610
993
|
};
|
|
611
994
|
}
|
|
612
995
|
});
|
|
613
996
|
}
|
|
614
997
|
}
|
|
615
|
-
class
|
|
998
|
+
class ke extends h {
|
|
616
999
|
constructor(o = {}) {
|
|
617
1000
|
super({
|
|
618
1001
|
contractName: "SalesPeriodRef",
|
|
@@ -620,20 +1003,20 @@ class _e extends T {
|
|
|
620
1003
|
fields: ["salesPeriodCode", "salesPeriodVersion"],
|
|
621
1004
|
normalize(e, t) {
|
|
622
1005
|
return {
|
|
623
|
-
salesPeriodCode:
|
|
624
|
-
salesPeriodVersion:
|
|
1006
|
+
salesPeriodCode: s(e.salesPeriodCode, "salesPeriodCode", t),
|
|
1007
|
+
salesPeriodVersion: f(e.salesPeriodVersion, "salesPeriodVersion", t)
|
|
625
1008
|
};
|
|
626
1009
|
}
|
|
627
1010
|
});
|
|
628
1011
|
}
|
|
629
1012
|
}
|
|
630
|
-
function
|
|
1013
|
+
function We(n, o, e) {
|
|
631
1014
|
if (typeof n > "u" || n === null)
|
|
632
1015
|
return;
|
|
633
|
-
const t =
|
|
1016
|
+
const t = N(n, o, e);
|
|
634
1017
|
return t && !Number.isFinite(Date.parse(t)) && e.push(`${o} must be an ISO-compatible timestamp`), t;
|
|
635
1018
|
}
|
|
636
|
-
class
|
|
1019
|
+
class Ge extends h {
|
|
637
1020
|
constructor(o = {}) {
|
|
638
1021
|
super({
|
|
639
1022
|
contractName: "PriceRow",
|
|
@@ -649,54 +1032,52 @@ class Me extends T {
|
|
|
649
1032
|
"acquisitionSources"
|
|
650
1033
|
],
|
|
651
1034
|
normalize(e, t) {
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
let
|
|
655
|
-
if (e.salesPeriodRef !== null && typeof e.salesPeriodRef < "u")
|
|
1035
|
+
const r = We(e.validFrom, "validFrom", t), i = We(e.validUntil, "validUntil", t);
|
|
1036
|
+
r && i && Date.parse(r) >= Date.parse(i) && t.push("validUntil must be later than validFrom");
|
|
1037
|
+
let d;
|
|
1038
|
+
if (e.salesPeriodRef !== null && typeof e.salesPeriodRef < "u")
|
|
656
1039
|
try {
|
|
657
|
-
|
|
658
|
-
} catch (
|
|
659
|
-
t.push(`salesPeriodRef: ${
|
|
1040
|
+
d = (e.salesPeriodRef instanceof ke ? e.salesPeriodRef : new ke(e.salesPeriodRef)).toObject();
|
|
1041
|
+
} catch (a) {
|
|
1042
|
+
t.push(`salesPeriodRef: ${a.message}`);
|
|
660
1043
|
}
|
|
661
|
-
(!i || !r) && t.push("salesPeriodRef requires validFrom and validUntil snapshots");
|
|
662
|
-
}
|
|
663
1044
|
let c = {};
|
|
664
1045
|
try {
|
|
665
|
-
c = (e.match instanceof
|
|
666
|
-
} catch (
|
|
667
|
-
t.push(`match: ${
|
|
1046
|
+
c = (e.match instanceof Fe ? e.match : new Fe(e.match || {})).toObject();
|
|
1047
|
+
} catch (a) {
|
|
1048
|
+
t.push(`match: ${a.message}`);
|
|
668
1049
|
}
|
|
669
1050
|
return {
|
|
670
|
-
priceRowCode:
|
|
671
|
-
currency:
|
|
672
|
-
amount:
|
|
1051
|
+
priceRowCode: s(e.priceRowCode, "priceRowCode", t),
|
|
1052
|
+
currency: s(e.currency, "currency", t),
|
|
1053
|
+
amount: x(e.amount, "amount", t),
|
|
673
1054
|
match: c,
|
|
674
|
-
...
|
|
675
|
-
...
|
|
676
|
-
...
|
|
677
|
-
acquisitionSources:
|
|
1055
|
+
...d ? { salesPeriodRef: d } : {},
|
|
1056
|
+
...r ? { validFrom: r } : {},
|
|
1057
|
+
...i ? { validUntil: i } : {},
|
|
1058
|
+
acquisitionSources: U(e.acquisitionSources || [], "acquisitionSources", t)
|
|
678
1059
|
};
|
|
679
1060
|
}
|
|
680
1061
|
});
|
|
681
1062
|
}
|
|
682
1063
|
}
|
|
683
|
-
class
|
|
1064
|
+
class gn extends O {
|
|
684
1065
|
constructor(o = {}) {
|
|
685
1066
|
super({
|
|
686
1067
|
contractName: "PriceSchedule",
|
|
687
1068
|
object: o,
|
|
688
1069
|
fields: ["priceScheduleCode", "version", "rows"],
|
|
689
1070
|
normalize(e, t) {
|
|
690
|
-
let
|
|
1071
|
+
let r = [];
|
|
691
1072
|
try {
|
|
692
|
-
|
|
693
|
-
} catch (
|
|
694
|
-
t.push(`rows: ${
|
|
1073
|
+
r = (e.rows || []).map((i) => (i instanceof Ge ? i : new Ge(i)).toObject());
|
|
1074
|
+
} catch (i) {
|
|
1075
|
+
t.push(`rows: ${i.message}`);
|
|
695
1076
|
}
|
|
696
|
-
return
|
|
697
|
-
priceScheduleCode:
|
|
698
|
-
version:
|
|
699
|
-
rows:
|
|
1077
|
+
return r.length === 0 && t.push("rows must contain at least one row"), {
|
|
1078
|
+
priceScheduleCode: s(e.priceScheduleCode, "priceScheduleCode", t),
|
|
1079
|
+
version: f(e.version, "version", t),
|
|
1080
|
+
rows: r
|
|
700
1081
|
};
|
|
701
1082
|
}
|
|
702
1083
|
});
|
|
@@ -705,7 +1086,7 @@ class jt extends L {
|
|
|
705
1086
|
return this.priceScheduleCode;
|
|
706
1087
|
}
|
|
707
1088
|
}
|
|
708
|
-
class
|
|
1089
|
+
class bn extends O {
|
|
709
1090
|
constructor(o = {}) {
|
|
710
1091
|
super({
|
|
711
1092
|
contractName: "Product",
|
|
@@ -713,11 +1094,11 @@ class xt extends L {
|
|
|
713
1094
|
fields: ["productCode", "version", "name", "description", "categoryCodes"],
|
|
714
1095
|
normalize(e, t) {
|
|
715
1096
|
return {
|
|
716
|
-
productCode:
|
|
717
|
-
version:
|
|
718
|
-
name:
|
|
719
|
-
...
|
|
720
|
-
categoryCodes:
|
|
1097
|
+
productCode: s(e.productCode, "productCode", t),
|
|
1098
|
+
version: f(e.version, "version", t),
|
|
1099
|
+
name: s(e.name, "name", t),
|
|
1100
|
+
...N(e.description, "description", t) ? { description: e.description } : {},
|
|
1101
|
+
categoryCodes: U(e.categoryCodes || [], "categoryCodes", t)
|
|
721
1102
|
};
|
|
722
1103
|
}
|
|
723
1104
|
});
|
|
@@ -726,43 +1107,43 @@ class xt extends L {
|
|
|
726
1107
|
return this.productCode;
|
|
727
1108
|
}
|
|
728
1109
|
}
|
|
729
|
-
class
|
|
1110
|
+
class Pt extends h {
|
|
730
1111
|
constructor(o = {}) {
|
|
731
1112
|
super({
|
|
732
1113
|
contractName: "EligibilityRuleDetails",
|
|
733
1114
|
object: o,
|
|
734
1115
|
fields: ["acceptedStates", "eligibilityType"],
|
|
735
1116
|
normalize(e, t) {
|
|
736
|
-
const
|
|
737
|
-
return
|
|
738
|
-
values:
|
|
739
|
-
allowedValues: Object.values(
|
|
1117
|
+
const r = U(e.acceptedStates || [], "acceptedStates", t);
|
|
1118
|
+
return r.length === 0 && t.push("acceptedStates must contain at least one state"), rt({
|
|
1119
|
+
values: r,
|
|
1120
|
+
allowedValues: Object.values(Y),
|
|
740
1121
|
path: "acceptedStates",
|
|
741
1122
|
issues: t
|
|
742
1123
|
}), {
|
|
743
|
-
eligibilityType:
|
|
744
|
-
acceptedStates:
|
|
1124
|
+
eligibilityType: s(e.eligibilityType, "eligibilityType", t),
|
|
1125
|
+
acceptedStates: r
|
|
745
1126
|
};
|
|
746
1127
|
}
|
|
747
1128
|
});
|
|
748
1129
|
}
|
|
749
1130
|
}
|
|
750
|
-
class
|
|
1131
|
+
class _t extends h {
|
|
751
1132
|
constructor(o = {}) {
|
|
752
1133
|
super({
|
|
753
1134
|
contractName: "InventoryRuleDetails",
|
|
754
1135
|
object: o,
|
|
755
1136
|
fields: ["inventoryMode", "inventoryPoolCode"],
|
|
756
1137
|
normalize(e, t) {
|
|
757
|
-
return Object.values(
|
|
1138
|
+
return Object.values(Ee).includes(e.inventoryMode) || t.push(`inventoryMode "${e.inventoryMode}" is not supported`), {
|
|
758
1139
|
inventoryMode: e.inventoryMode,
|
|
759
|
-
inventoryPoolCode:
|
|
1140
|
+
inventoryPoolCode: s(e.inventoryPoolCode, "inventoryPoolCode", t)
|
|
760
1141
|
};
|
|
761
1142
|
}
|
|
762
1143
|
});
|
|
763
1144
|
}
|
|
764
1145
|
}
|
|
765
|
-
class
|
|
1146
|
+
class Mt extends h {
|
|
766
1147
|
constructor(o = {}) {
|
|
767
1148
|
super({
|
|
768
1149
|
contractName: "PrerequisiteRuleDetails",
|
|
@@ -770,46 +1151,46 @@ class ot extends T {
|
|
|
770
1151
|
fields: ["continuous", "evidenceSources", "matchMode", "requires"],
|
|
771
1152
|
normalize(e, t) {
|
|
772
1153
|
(!Array.isArray(e.requires) || e.requires.length === 0) && t.push("requires must contain at least one target");
|
|
773
|
-
const
|
|
1154
|
+
const r = (e.requires || []).map((d, c) => {
|
|
774
1155
|
try {
|
|
775
|
-
return
|
|
776
|
-
} catch (
|
|
777
|
-
return t.push(`requires[${c}]: ${
|
|
1156
|
+
return Nt(d, `requires[${c}]`, t, Object.values(M));
|
|
1157
|
+
} catch (a) {
|
|
1158
|
+
return t.push(`requires[${c}]: ${a.message}`), {};
|
|
778
1159
|
}
|
|
779
1160
|
});
|
|
780
|
-
Object.values(
|
|
781
|
-
const
|
|
782
|
-
return
|
|
783
|
-
values:
|
|
784
|
-
allowedValues: Object.values(
|
|
1161
|
+
Object.values(ye).includes(e.matchMode) || t.push(`matchMode "${e.matchMode}" is not supported`);
|
|
1162
|
+
const i = U(e.evidenceSources || [], "evidenceSources", t);
|
|
1163
|
+
return rt({
|
|
1164
|
+
values: i,
|
|
1165
|
+
allowedValues: Object.values(K),
|
|
785
1166
|
path: "evidenceSources",
|
|
786
1167
|
issues: t
|
|
787
1168
|
}), {
|
|
788
|
-
requires:
|
|
1169
|
+
requires: r,
|
|
789
1170
|
matchMode: e.matchMode,
|
|
790
|
-
evidenceSources:
|
|
1171
|
+
evidenceSources: i,
|
|
791
1172
|
continuous: e.continuous === !0
|
|
792
1173
|
};
|
|
793
1174
|
}
|
|
794
1175
|
});
|
|
795
1176
|
}
|
|
796
1177
|
}
|
|
797
|
-
class
|
|
1178
|
+
class qt extends h {
|
|
798
1179
|
constructor(o = {}) {
|
|
799
1180
|
super({
|
|
800
1181
|
contractName: "QuantityRuleDetails",
|
|
801
1182
|
object: o,
|
|
802
1183
|
fields: ["limit", "limitType"],
|
|
803
1184
|
normalize(e, t) {
|
|
804
|
-
return Object.values(
|
|
1185
|
+
return Object.values(ee).includes(e.limitType) || t.push(`limitType "${e.limitType}" is not supported`), {
|
|
805
1186
|
limitType: e.limitType,
|
|
806
|
-
limit:
|
|
1187
|
+
limit: f(e.limit, "limit", t)
|
|
807
1188
|
};
|
|
808
1189
|
}
|
|
809
1190
|
});
|
|
810
1191
|
}
|
|
811
1192
|
}
|
|
812
|
-
class
|
|
1193
|
+
class He extends h {
|
|
813
1194
|
constructor(o = {}) {
|
|
814
1195
|
super({
|
|
815
1196
|
contractName: "RefundPolicyRef",
|
|
@@ -817,14 +1198,14 @@ class qe extends T {
|
|
|
817
1198
|
fields: ["refundPolicyCode", "refundPolicyVersion"],
|
|
818
1199
|
normalize(e, t) {
|
|
819
1200
|
return {
|
|
820
|
-
refundPolicyCode:
|
|
821
|
-
refundPolicyVersion:
|
|
1201
|
+
refundPolicyCode: s(e.refundPolicyCode, "refundPolicyCode", t),
|
|
1202
|
+
refundPolicyVersion: f(e.refundPolicyVersion, "refundPolicyVersion", t)
|
|
822
1203
|
};
|
|
823
1204
|
}
|
|
824
1205
|
});
|
|
825
1206
|
}
|
|
826
1207
|
}
|
|
827
|
-
class
|
|
1208
|
+
class Lt extends h {
|
|
828
1209
|
constructor(o = {}) {
|
|
829
1210
|
super({
|
|
830
1211
|
contractName: "RefundRuleDetails",
|
|
@@ -832,15 +1213,15 @@ class rt extends T {
|
|
|
832
1213
|
fields: ["refundPolicyRef"],
|
|
833
1214
|
normalize(e, t) {
|
|
834
1215
|
try {
|
|
835
|
-
return { refundPolicyRef: (e.refundPolicyRef instanceof
|
|
836
|
-
} catch (
|
|
837
|
-
return t.push(`refundPolicyRef: ${
|
|
1216
|
+
return { refundPolicyRef: (e.refundPolicyRef instanceof He ? e.refundPolicyRef : new He(e.refundPolicyRef)).toObject() };
|
|
1217
|
+
} catch (r) {
|
|
1218
|
+
return t.push(`refundPolicyRef: ${r.message}`), { refundPolicyRef: {} };
|
|
838
1219
|
}
|
|
839
1220
|
}
|
|
840
1221
|
});
|
|
841
1222
|
}
|
|
842
1223
|
}
|
|
843
|
-
class
|
|
1224
|
+
class Vt extends h {
|
|
844
1225
|
constructor(o = {}) {
|
|
845
1226
|
super({
|
|
846
1227
|
contractName: "RequirementRuleDetails",
|
|
@@ -853,48 +1234,48 @@ class st extends T {
|
|
|
853
1234
|
"requirement"
|
|
854
1235
|
],
|
|
855
1236
|
normalize(e, t) {
|
|
856
|
-
let
|
|
1237
|
+
let r = {};
|
|
857
1238
|
try {
|
|
858
|
-
|
|
1239
|
+
r = (e.requirement instanceof ie ? e.requirement : new ie(e.requirement)).toObject();
|
|
859
1240
|
} catch (c) {
|
|
860
1241
|
t.push(`requirement: ${c.message}`);
|
|
861
1242
|
}
|
|
862
|
-
Object.values(
|
|
863
|
-
const
|
|
864
|
-
return e.modificationMode ===
|
|
865
|
-
requirement:
|
|
1243
|
+
Object.values(Re).includes(e.completionTiming) || t.push(`completionTiming "${e.completionTiming}" is not supported`), Object.values(j).includes(e.modificationMode) || t.push(`modificationMode "${e.modificationMode}" is not supported`);
|
|
1244
|
+
const i = de(e.completionDeadline, "completionDeadline", t), d = de(e.modificationDeadline, "modificationDeadline", t);
|
|
1245
|
+
return e.modificationMode === j.UNTIL_DEADLINE && !d && t.push("modificationDeadline is required when modificationMode is UNTIL_DEADLINE"), e.modificationMode !== j.UNTIL_DEADLINE && d && t.push("modificationDeadline is only supported when modificationMode is UNTIL_DEADLINE"), {
|
|
1246
|
+
requirement: r,
|
|
866
1247
|
completionTiming: e.completionTiming,
|
|
867
1248
|
modificationMode: e.modificationMode,
|
|
868
|
-
...
|
|
869
|
-
...
|
|
1249
|
+
...i ? { completionDeadline: i } : {},
|
|
1250
|
+
...d ? { modificationDeadline: d } : {}
|
|
870
1251
|
};
|
|
871
1252
|
}
|
|
872
1253
|
});
|
|
873
1254
|
}
|
|
874
1255
|
}
|
|
875
|
-
const
|
|
876
|
-
[
|
|
877
|
-
[
|
|
878
|
-
[
|
|
879
|
-
[
|
|
880
|
-
[
|
|
881
|
-
[
|
|
1256
|
+
const vt = Object.freeze({
|
|
1257
|
+
[_.ELIGIBILITY]: Pt,
|
|
1258
|
+
[_.INVENTORY]: _t,
|
|
1259
|
+
[_.PREREQUISITE]: Mt,
|
|
1260
|
+
[_.QUANTITY]: qt,
|
|
1261
|
+
[_.REFUND]: Lt,
|
|
1262
|
+
[_.REQUIREMENT]: Vt
|
|
882
1263
|
});
|
|
883
|
-
function
|
|
884
|
-
const e =
|
|
1264
|
+
function Ut(n, o) {
|
|
1265
|
+
const e = vt[n];
|
|
885
1266
|
if (!e)
|
|
886
1267
|
throw new TypeError(`Rule type "${n}" does not have a details contract`);
|
|
887
1268
|
return new e(o);
|
|
888
1269
|
}
|
|
889
|
-
function
|
|
1270
|
+
function $t(n, o, e) {
|
|
890
1271
|
if (!n || typeof n != "object" || Array.isArray(n))
|
|
891
1272
|
return e.push(`${o} must be an object`), {};
|
|
892
|
-
const t =
|
|
893
|
-
return Object.keys(n).forEach((
|
|
894
|
-
["code", "type"].includes(
|
|
895
|
-
}), Object.values(
|
|
1273
|
+
const t = s(n.type, `${o}.type`, e), r = s(n.code, `${o}.code`, e);
|
|
1274
|
+
return Object.keys(n).forEach((i) => {
|
|
1275
|
+
["code", "type"].includes(i) || e.push(`${o} contains unknown field "${i}"`);
|
|
1276
|
+
}), Object.values(M).includes(t) || e.push(`${o}.type "${t}" is not supported`), { type: t, code: r };
|
|
896
1277
|
}
|
|
897
|
-
class
|
|
1278
|
+
class Dn extends O {
|
|
898
1279
|
constructor(o = {}) {
|
|
899
1280
|
super({
|
|
900
1281
|
contractName: "PublishedRule",
|
|
@@ -910,24 +1291,24 @@ class zt extends L {
|
|
|
910
1291
|
"reason"
|
|
911
1292
|
],
|
|
912
1293
|
normalize(e, t) {
|
|
913
|
-
const
|
|
914
|
-
Object.values(
|
|
915
|
-
const
|
|
916
|
-
Object.values(
|
|
917
|
-
const
|
|
1294
|
+
const r = s(e.ruleType, "ruleType", t);
|
|
1295
|
+
Object.values(_).includes(r) || t.push(`ruleType "${r}" is not supported`);
|
|
1296
|
+
const i = s(e.sourceType, "sourceType", t);
|
|
1297
|
+
Object.values(q).includes(i) || t.push(`sourceType "${i}" is not supported`);
|
|
1298
|
+
const d = $t(e.appliesTo, "appliesTo", t);
|
|
918
1299
|
let c = {};
|
|
919
1300
|
try {
|
|
920
|
-
c =
|
|
921
|
-
} catch (
|
|
922
|
-
t.push(`details: ${
|
|
1301
|
+
c = Ut(r, e.details).toObject();
|
|
1302
|
+
} catch (a) {
|
|
1303
|
+
t.push(`details: ${a.message}`);
|
|
923
1304
|
}
|
|
924
1305
|
return {
|
|
925
|
-
publishedRuleCode:
|
|
926
|
-
version:
|
|
927
|
-
ruleType:
|
|
928
|
-
sourceType:
|
|
929
|
-
sourceCode:
|
|
930
|
-
appliesTo:
|
|
1306
|
+
publishedRuleCode: s(e.publishedRuleCode, "publishedRuleCode", t),
|
|
1307
|
+
version: f(e.version, "version", t),
|
|
1308
|
+
ruleType: r,
|
|
1309
|
+
sourceType: i,
|
|
1310
|
+
sourceCode: s(e.sourceCode, "sourceCode", t),
|
|
1311
|
+
appliesTo: d,
|
|
931
1312
|
details: c,
|
|
932
1313
|
...e.reason ? { reason: e.reason } : {}
|
|
933
1314
|
};
|
|
@@ -938,7 +1319,7 @@ class zt extends L {
|
|
|
938
1319
|
return this.publishedRuleCode;
|
|
939
1320
|
}
|
|
940
1321
|
}
|
|
941
|
-
class
|
|
1322
|
+
class Nn extends h {
|
|
942
1323
|
constructor(o = {}) {
|
|
943
1324
|
super({
|
|
944
1325
|
contractName: "PublishedRuleRef",
|
|
@@ -946,14 +1327,39 @@ class Yt extends T {
|
|
|
946
1327
|
fields: ["publishedRuleCode", "publishedRuleVersion"],
|
|
947
1328
|
normalize(e, t) {
|
|
948
1329
|
return {
|
|
949
|
-
publishedRuleCode:
|
|
950
|
-
publishedRuleVersion:
|
|
1330
|
+
publishedRuleCode: s(e.publishedRuleCode, "publishedRuleCode", t),
|
|
1331
|
+
publishedRuleVersion: f(e.publishedRuleVersion, "publishedRuleVersion", t)
|
|
951
1332
|
};
|
|
952
1333
|
}
|
|
953
1334
|
});
|
|
954
1335
|
}
|
|
955
1336
|
}
|
|
956
|
-
class
|
|
1337
|
+
class An extends O {
|
|
1338
|
+
constructor(o = {}) {
|
|
1339
|
+
super({
|
|
1340
|
+
contractName: "Receipt",
|
|
1341
|
+
object: o,
|
|
1342
|
+
fields: ["receiptCode", "receiptNumber", "settlementCode", "orderCode", "invoiceCode", "invoiceRevisionCode", "currency", "amount", "issued"],
|
|
1343
|
+
normalize(e, t) {
|
|
1344
|
+
return {
|
|
1345
|
+
receiptCode: s(e.receiptCode, "receiptCode", t),
|
|
1346
|
+
receiptNumber: s(e.receiptNumber, "receiptNumber", t),
|
|
1347
|
+
settlementCode: s(e.settlementCode, "settlementCode", t),
|
|
1348
|
+
orderCode: s(e.orderCode, "orderCode", t),
|
|
1349
|
+
invoiceCode: s(e.invoiceCode, "invoiceCode", t),
|
|
1350
|
+
invoiceRevisionCode: s(e.invoiceRevisionCode, "invoiceRevisionCode", t),
|
|
1351
|
+
currency: s(e.currency, "currency", t),
|
|
1352
|
+
amount: x(e.amount, "amount", t),
|
|
1353
|
+
issued: $(e.issued, "issued", t)
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
getCode() {
|
|
1359
|
+
return this.receiptCode;
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
class On extends O {
|
|
957
1363
|
constructor(o = {}) {
|
|
958
1364
|
super({
|
|
959
1365
|
contractName: "RefundPolicy",
|
|
@@ -961,9 +1367,9 @@ class Qt extends L {
|
|
|
961
1367
|
fields: ["refundPolicyCode", "version", "name"],
|
|
962
1368
|
normalize(e, t) {
|
|
963
1369
|
return {
|
|
964
|
-
refundPolicyCode:
|
|
965
|
-
version:
|
|
966
|
-
name:
|
|
1370
|
+
refundPolicyCode: s(e.refundPolicyCode, "refundPolicyCode", t),
|
|
1371
|
+
version: f(e.version, "version", t),
|
|
1372
|
+
name: s(e.name, "name", t)
|
|
967
1373
|
};
|
|
968
1374
|
}
|
|
969
1375
|
});
|
|
@@ -972,24 +1378,24 @@ class Qt extends L {
|
|
|
972
1378
|
return this.refundPolicyCode;
|
|
973
1379
|
}
|
|
974
1380
|
}
|
|
975
|
-
function
|
|
976
|
-
const t =
|
|
1381
|
+
function Ke(n, o, e) {
|
|
1382
|
+
const t = s(n, o, e);
|
|
977
1383
|
return t && !Number.isFinite(Date.parse(t)) && e.push(`${o} must be an ISO-compatible timestamp`), t;
|
|
978
1384
|
}
|
|
979
|
-
class
|
|
1385
|
+
class Sn extends O {
|
|
980
1386
|
constructor(o = {}) {
|
|
981
1387
|
super({
|
|
982
1388
|
contractName: "SalesPeriod",
|
|
983
1389
|
object: o,
|
|
984
1390
|
fields: ["salesPeriodCode", "version", "name", "validFrom", "validUntil"],
|
|
985
1391
|
normalize(e, t) {
|
|
986
|
-
const
|
|
987
|
-
return
|
|
988
|
-
salesPeriodCode:
|
|
989
|
-
version:
|
|
990
|
-
name:
|
|
991
|
-
validFrom:
|
|
992
|
-
validUntil:
|
|
1392
|
+
const r = Ke(e.validFrom, "validFrom", t), i = Ke(e.validUntil, "validUntil", t);
|
|
1393
|
+
return r && i && Date.parse(r) >= Date.parse(i) && t.push("validUntil must be later than validFrom"), {
|
|
1394
|
+
salesPeriodCode: s(e.salesPeriodCode, "salesPeriodCode", t),
|
|
1395
|
+
version: f(e.version, "version", t),
|
|
1396
|
+
name: s(e.name, "name", t),
|
|
1397
|
+
validFrom: r,
|
|
1398
|
+
validUntil: i
|
|
993
1399
|
};
|
|
994
1400
|
}
|
|
995
1401
|
});
|
|
@@ -998,7 +1404,35 @@ class Bt extends L {
|
|
|
998
1404
|
return this.salesPeriodCode;
|
|
999
1405
|
}
|
|
1000
1406
|
}
|
|
1001
|
-
class
|
|
1407
|
+
class Pn extends O {
|
|
1408
|
+
constructor(o = {}) {
|
|
1409
|
+
super({
|
|
1410
|
+
contractName: "Settlement",
|
|
1411
|
+
object: o,
|
|
1412
|
+
fields: ["settlementCode", "settlementCommandCode", "paymentAttemptCode", "orderCode", "invoiceCode", "invoiceRevisionCode", "currency", "amount", "providerCode", "providerReference", "providerEventCode", "confirmed"],
|
|
1413
|
+
normalize(e, t) {
|
|
1414
|
+
return {
|
|
1415
|
+
settlementCode: s(e.settlementCode, "settlementCode", t),
|
|
1416
|
+
settlementCommandCode: s(e.settlementCommandCode, "settlementCommandCode", t),
|
|
1417
|
+
paymentAttemptCode: s(e.paymentAttemptCode, "paymentAttemptCode", t),
|
|
1418
|
+
orderCode: s(e.orderCode, "orderCode", t),
|
|
1419
|
+
invoiceCode: s(e.invoiceCode, "invoiceCode", t),
|
|
1420
|
+
invoiceRevisionCode: s(e.invoiceRevisionCode, "invoiceRevisionCode", t),
|
|
1421
|
+
currency: s(e.currency, "currency", t),
|
|
1422
|
+
amount: x(e.amount, "amount", t),
|
|
1423
|
+
providerCode: s(e.providerCode, "providerCode", t),
|
|
1424
|
+
providerReference: s(e.providerReference, "providerReference", t),
|
|
1425
|
+
providerEventCode: s(e.providerEventCode, "providerEventCode", t),
|
|
1426
|
+
confirmed: $(e.confirmed, "confirmed", t)
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
getCode() {
|
|
1432
|
+
return this.settlementCode;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
class _n extends O {
|
|
1002
1436
|
constructor(o = {}) {
|
|
1003
1437
|
super({
|
|
1004
1438
|
contractName: "Variant",
|
|
@@ -1006,11 +1440,11 @@ class Ft extends L {
|
|
|
1006
1440
|
fields: ["variantCode", "version", "productCode", "productVersion", "name", "optionValues"],
|
|
1007
1441
|
normalize(e, t) {
|
|
1008
1442
|
return (!e.optionValues || typeof e.optionValues != "object" || Array.isArray(e.optionValues)) && t.push("optionValues must be an object"), {
|
|
1009
|
-
variantCode:
|
|
1010
|
-
version:
|
|
1011
|
-
productCode:
|
|
1012
|
-
productVersion:
|
|
1013
|
-
name:
|
|
1443
|
+
variantCode: s(e.variantCode, "variantCode", t),
|
|
1444
|
+
version: f(e.version, "version", t),
|
|
1445
|
+
productCode: s(e.productCode, "productCode", t),
|
|
1446
|
+
productVersion: f(e.productVersion, "productVersion", t),
|
|
1447
|
+
name: s(e.name, "name", t),
|
|
1014
1448
|
optionValues: e.optionValues || {}
|
|
1015
1449
|
};
|
|
1016
1450
|
}
|
|
@@ -1020,7 +1454,7 @@ class Ft extends L {
|
|
|
1020
1454
|
return this.variantCode;
|
|
1021
1455
|
}
|
|
1022
1456
|
}
|
|
1023
|
-
class
|
|
1457
|
+
class Xe extends h {
|
|
1024
1458
|
constructor(o = {}) {
|
|
1025
1459
|
super({
|
|
1026
1460
|
contractName: "VariantRef",
|
|
@@ -1028,14 +1462,14 @@ class Le extends T {
|
|
|
1028
1462
|
fields: ["variantCode", "variantVersion"],
|
|
1029
1463
|
normalize(e, t) {
|
|
1030
1464
|
return {
|
|
1031
|
-
variantCode:
|
|
1032
|
-
variantVersion:
|
|
1465
|
+
variantCode: s(e.variantCode, "variantCode", t),
|
|
1466
|
+
variantVersion: f(e.variantVersion, "variantVersion", t)
|
|
1033
1467
|
};
|
|
1034
1468
|
}
|
|
1035
1469
|
});
|
|
1036
1470
|
}
|
|
1037
1471
|
}
|
|
1038
|
-
class
|
|
1472
|
+
class se extends O {
|
|
1039
1473
|
constructor(o = {}) {
|
|
1040
1474
|
super({
|
|
1041
1475
|
contractName: "WalletItem",
|
|
@@ -1053,26 +1487,26 @@ class kt extends L {
|
|
|
1053
1487
|
"requirementPlans"
|
|
1054
1488
|
],
|
|
1055
1489
|
normalize(e, t) {
|
|
1056
|
-
const
|
|
1057
|
-
(
|
|
1058
|
-
const
|
|
1059
|
-
Object.values(
|
|
1060
|
-
const c = (Array.isArray(e.requirementPlans) ? e.requirementPlans : []).flatMap((
|
|
1490
|
+
const r = N(e.variantCode, "variantCode", t), i = typeof e.variantVersion > "u" || e.variantVersion === null ? void 0 : f(e.variantVersion, "variantVersion", t);
|
|
1491
|
+
(r && typeof i > "u" || !r && typeof i < "u") && t.push("variantCode and variantVersion must be provided together"), Array.isArray(e.requirementPlans || []) || t.push("requirementPlans must be an array");
|
|
1492
|
+
const d = s(e.state, "state", t);
|
|
1493
|
+
Object.values(S).includes(d) || t.push(`state "${d}" is not supported`);
|
|
1494
|
+
const c = (Array.isArray(e.requirementPlans) ? e.requirementPlans : []).flatMap((a, u) => {
|
|
1061
1495
|
try {
|
|
1062
|
-
return [(
|
|
1496
|
+
return [(a instanceof ce ? a : new ce(a)).toObject()];
|
|
1063
1497
|
} catch (l) {
|
|
1064
|
-
return t.push(`requirementPlans[${
|
|
1498
|
+
return t.push(`requirementPlans[${u}]: ${l.message}`), [];
|
|
1065
1499
|
}
|
|
1066
1500
|
});
|
|
1067
1501
|
return {
|
|
1068
|
-
walletItemCode:
|
|
1069
|
-
productCode:
|
|
1070
|
-
productVersion:
|
|
1071
|
-
state:
|
|
1072
|
-
quantity:
|
|
1073
|
-
acquisitionCode:
|
|
1074
|
-
...
|
|
1075
|
-
...
|
|
1502
|
+
walletItemCode: s(e.walletItemCode, "walletItemCode", t),
|
|
1503
|
+
productCode: s(e.productCode, "productCode", t),
|
|
1504
|
+
productVersion: f(e.productVersion, "productVersion", t),
|
|
1505
|
+
state: d,
|
|
1506
|
+
quantity: f(e.quantity, "quantity", t),
|
|
1507
|
+
acquisitionCode: s(e.acquisitionCode, "acquisitionCode", t),
|
|
1508
|
+
...N(e.eventRegistrationCode, "eventRegistrationCode", t) ? { eventRegistrationCode: e.eventRegistrationCode } : {},
|
|
1509
|
+
...r ? { variantCode: r, variantVersion: i } : {},
|
|
1076
1510
|
requirementPlans: c
|
|
1077
1511
|
};
|
|
1078
1512
|
}
|
|
@@ -1082,118 +1516,118 @@ class kt extends L {
|
|
|
1082
1516
|
return this.walletItemCode;
|
|
1083
1517
|
}
|
|
1084
1518
|
}
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1519
|
+
const Je = [
|
|
1520
|
+
q.CATEGORY,
|
|
1521
|
+
q.PRODUCT,
|
|
1522
|
+
q.MERCHANDISE,
|
|
1523
|
+
q.ACQUISITION_SOURCE
|
|
1090
1524
|
];
|
|
1091
|
-
function
|
|
1525
|
+
function Ze(n, o) {
|
|
1092
1526
|
return `${n}:${o}`;
|
|
1093
1527
|
}
|
|
1094
|
-
function
|
|
1095
|
-
if (n.sourceType ===
|
|
1096
|
-
return n.appliesTo.type ===
|
|
1097
|
-
if (n.sourceType ===
|
|
1098
|
-
return n.appliesTo.type ===
|
|
1099
|
-
if (n.sourceType ===
|
|
1100
|
-
return n.appliesTo.type ===
|
|
1101
|
-
if (n.sourceType ===
|
|
1102
|
-
if (n.appliesTo.type ===
|
|
1528
|
+
function wt({ rule: n, relevantCategoryCodes: o, relevantProductCodes: e, merchandise: t }) {
|
|
1529
|
+
if (n.sourceType === q.CATEGORY)
|
|
1530
|
+
return n.appliesTo.type === M.CATEGORY && n.appliesTo.code === n.sourceCode;
|
|
1531
|
+
if (n.sourceType === q.PRODUCT)
|
|
1532
|
+
return n.appliesTo.type === M.PRODUCT && n.appliesTo.code === n.sourceCode;
|
|
1533
|
+
if (n.sourceType === q.MERCHANDISE)
|
|
1534
|
+
return n.appliesTo.type === M.MERCHANDISE ? n.appliesTo.code === t.merchandiseCode : n.appliesTo.type === M.PRODUCT ? e.has(n.appliesTo.code) : n.appliesTo.type === M.CATEGORY ? o.has(n.appliesTo.code) : !1;
|
|
1535
|
+
if (n.sourceType === q.ACQUISITION_SOURCE) {
|
|
1536
|
+
if (n.appliesTo.type === M.MERCHANDISE)
|
|
1103
1537
|
return n.appliesTo.code === t.merchandiseCode;
|
|
1104
|
-
if (n.appliesTo.type ===
|
|
1538
|
+
if (n.appliesTo.type === M.PRODUCT)
|
|
1105
1539
|
return e.has(n.appliesTo.code);
|
|
1106
|
-
if (n.appliesTo.type ===
|
|
1540
|
+
if (n.appliesTo.type === M.CATEGORY)
|
|
1107
1541
|
return o.has(n.appliesTo.code);
|
|
1108
1542
|
}
|
|
1109
1543
|
return !1;
|
|
1110
1544
|
}
|
|
1111
|
-
function
|
|
1112
|
-
const
|
|
1113
|
-
...n.filter((p) =>
|
|
1114
|
-
sourceType:
|
|
1545
|
+
function jt({ categories: n = [], products: o = [], merchandise: e, acquisitionSource: t, publishedRules: r = [] }) {
|
|
1546
|
+
const i = new Set(e.components.map((p) => `${p.productCode}@${p.productVersion}`)), d = o.filter((p) => i.has(`${p.productCode}@${p.version}`)), c = new Set(d.map((p) => p.productCode)), a = new Set(d.flatMap((p) => p.categoryCodes || [])), l = [
|
|
1547
|
+
...n.filter((p) => a.has(p.categoryCode)).map((p) => ({
|
|
1548
|
+
sourceType: q.CATEGORY,
|
|
1115
1549
|
sourceCode: p.categoryCode
|
|
1116
1550
|
})),
|
|
1117
|
-
...
|
|
1118
|
-
sourceType:
|
|
1551
|
+
...d.map((p) => ({
|
|
1552
|
+
sourceType: q.PRODUCT,
|
|
1119
1553
|
sourceCode: p.productCode
|
|
1120
1554
|
})),
|
|
1121
1555
|
{
|
|
1122
|
-
sourceType:
|
|
1556
|
+
sourceType: q.MERCHANDISE,
|
|
1123
1557
|
sourceCode: e.merchandiseCode
|
|
1124
1558
|
},
|
|
1125
1559
|
{
|
|
1126
|
-
sourceType:
|
|
1560
|
+
sourceType: q.ACQUISITION_SOURCE,
|
|
1127
1561
|
sourceCode: t
|
|
1128
1562
|
}
|
|
1129
|
-
],
|
|
1130
|
-
const
|
|
1131
|
-
return
|
|
1132
|
-
}, /* @__PURE__ */ new Map()),
|
|
1133
|
-
|
|
1563
|
+
], m = new Set(l.map((p) => Ze(p.sourceType, p.sourceCode))), y = r.filter((p) => m.has(Ze(p.sourceType, p.sourceCode))).reduce((p, R) => {
|
|
1564
|
+
const b = p.get(R.publishedRuleCode) || [];
|
|
1565
|
+
return b.push(R), p.set(R.publishedRuleCode, b), p;
|
|
1566
|
+
}, /* @__PURE__ */ new Map()), T = [], C = [], E = [], g = /* @__PURE__ */ new Set();
|
|
1567
|
+
y.forEach((p, R) => {
|
|
1134
1568
|
if (p.length > 1) {
|
|
1135
|
-
|
|
1569
|
+
T.push({
|
|
1136
1570
|
code: "RULE_PUBLICATION_AMBIGUOUS",
|
|
1137
|
-
ruleCode:
|
|
1138
|
-
sources: p.map((
|
|
1139
|
-
sourceType:
|
|
1140
|
-
sourceCode:
|
|
1571
|
+
ruleCode: R,
|
|
1572
|
+
sources: p.map((F) => ({
|
|
1573
|
+
sourceType: F.sourceType,
|
|
1574
|
+
sourceCode: F.sourceCode
|
|
1141
1575
|
})),
|
|
1142
|
-
versions: p.map((
|
|
1576
|
+
versions: p.map((F) => F.version)
|
|
1143
1577
|
});
|
|
1144
1578
|
return;
|
|
1145
1579
|
}
|
|
1146
|
-
const [
|
|
1147
|
-
if (
|
|
1148
|
-
|
|
1580
|
+
const [b] = p;
|
|
1581
|
+
if (b.tenantCode !== e.tenantCode) {
|
|
1582
|
+
T.push({
|
|
1149
1583
|
code: "RULE_TENANT_MISMATCH",
|
|
1150
|
-
ruleCode:
|
|
1151
|
-
ruleTenantCode:
|
|
1584
|
+
ruleCode: b.publishedRuleCode,
|
|
1585
|
+
ruleTenantCode: b.tenantCode,
|
|
1152
1586
|
expectedTenantCode: e.tenantCode
|
|
1153
1587
|
});
|
|
1154
1588
|
return;
|
|
1155
1589
|
}
|
|
1156
|
-
if (!
|
|
1157
|
-
|
|
1590
|
+
if (!wt({ rule: b, relevantCategoryCodes: a, relevantProductCodes: c, merchandise: e })) {
|
|
1591
|
+
T.push({
|
|
1158
1592
|
code: "RULE_TARGET_MISMATCH",
|
|
1159
|
-
ruleCode:
|
|
1160
|
-
sourceType:
|
|
1161
|
-
sourceCode:
|
|
1162
|
-
appliesTo: D(
|
|
1593
|
+
ruleCode: b.publishedRuleCode,
|
|
1594
|
+
sourceType: b.sourceType,
|
|
1595
|
+
sourceCode: b.sourceCode,
|
|
1596
|
+
appliesTo: D(b.appliesTo)
|
|
1163
1597
|
});
|
|
1164
1598
|
return;
|
|
1165
1599
|
}
|
|
1166
|
-
const
|
|
1167
|
-
|
|
1168
|
-
ruleCode:
|
|
1169
|
-
ruleVersion:
|
|
1170
|
-
ruleType:
|
|
1171
|
-
sourceType:
|
|
1172
|
-
sourceCode:
|
|
1600
|
+
const te = `${b.publishedRuleCode}@${b.version}`;
|
|
1601
|
+
g.has(te) || (g.add(te), E.push(b)), C.push({
|
|
1602
|
+
ruleCode: b.publishedRuleCode,
|
|
1603
|
+
ruleVersion: b.version,
|
|
1604
|
+
ruleType: b.ruleType,
|
|
1605
|
+
sourceType: b.sourceType,
|
|
1606
|
+
sourceCode: b.sourceCode
|
|
1173
1607
|
});
|
|
1174
|
-
}), E.sort((p,
|
|
1175
|
-
const
|
|
1608
|
+
}), E.sort((p, R) => Je.indexOf(p.sourceType) - Je.indexOf(R.sourceType) || p.publishedRuleCode.localeCompare(R.publishedRuleCode));
|
|
1609
|
+
const A = E.map((p) => typeof p.toObject == "function" ? p.toObject() : D(p)), v = Object.fromEntries(Object.values(_).map((p) => [
|
|
1176
1610
|
p,
|
|
1177
|
-
|
|
1611
|
+
A.filter((R) => R.ruleType === p)
|
|
1178
1612
|
]));
|
|
1179
|
-
return
|
|
1180
|
-
passed:
|
|
1181
|
-
rules:
|
|
1182
|
-
byType:
|
|
1183
|
-
trace:
|
|
1184
|
-
errors:
|
|
1613
|
+
return L({
|
|
1614
|
+
passed: T.length === 0,
|
|
1615
|
+
rules: A,
|
|
1616
|
+
byType: v,
|
|
1617
|
+
trace: C,
|
|
1618
|
+
errors: T
|
|
1185
1619
|
});
|
|
1186
1620
|
}
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
]),
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
]),
|
|
1621
|
+
const xt = Object.freeze([
|
|
1622
|
+
S.CANCELLED,
|
|
1623
|
+
S.EXPIRED,
|
|
1624
|
+
S.REFUNDED,
|
|
1625
|
+
S.REVOKED
|
|
1626
|
+
]), zt = Object.freeze([
|
|
1627
|
+
S.PENDING_REQUIREMENT,
|
|
1628
|
+
S.RESERVED,
|
|
1629
|
+
S.VALID
|
|
1630
|
+
]), P = Object.freeze({
|
|
1197
1631
|
DEFINITION_INVALID: "DEFINITION_INVALID",
|
|
1198
1632
|
ELIGIBILITY_REJECTED: "ELIGIBILITY_REJECTED",
|
|
1199
1633
|
ELIGIBILITY_REQUIRED: "ELIGIBILITY_REQUIRED",
|
|
@@ -1210,71 +1644,71 @@ const pt = Object.freeze([
|
|
|
1210
1644
|
REVISION_CONFLICT: "REVISION_CONFLICT",
|
|
1211
1645
|
VARIANT_SELECTION_REQUIRED: "VARIANT_SELECTION_REQUIRED"
|
|
1212
1646
|
});
|
|
1213
|
-
function
|
|
1214
|
-
return
|
|
1647
|
+
function V({ passed: n, code: o = null, message: e, details: t = {} }) {
|
|
1648
|
+
return L({ passed: n, code: o, message: e, details: D(t) });
|
|
1215
1649
|
}
|
|
1216
|
-
function
|
|
1217
|
-
return n.type ===
|
|
1650
|
+
function z(n, o) {
|
|
1651
|
+
return n.type === M.PRODUCT ? o.productCode === n.code : n.type === M.CATEGORY ? (o.categoryCodes || []).includes(n.code) : n.type === M.MERCHANDISE ? o.merchandiseCode === n.code : !1;
|
|
1218
1652
|
}
|
|
1219
|
-
function
|
|
1220
|
-
return n.reduce((t,
|
|
1653
|
+
function re(n, o, e) {
|
|
1654
|
+
return n.reduce((t, r) => !z(o, r) || e && !e.includes(r.state) ? t : t + (r.quantity || 1), 0);
|
|
1221
1655
|
}
|
|
1222
|
-
function
|
|
1223
|
-
return (n == null ? void 0 : n.state) ===
|
|
1656
|
+
function Qt(n) {
|
|
1657
|
+
return (n == null ? void 0 : n.state) === S.VALID;
|
|
1224
1658
|
}
|
|
1225
|
-
function
|
|
1226
|
-
const
|
|
1227
|
-
const
|
|
1659
|
+
function Bt({ rules: n = [], existingItems: o = [], candidateItems: e = [], activeItemStates: t = zt }) {
|
|
1660
|
+
const r = n.filter((i) => i.ruleType === _.QUANTITY).filter((i) => e.some((d) => z(i.appliesTo, d))).map((i) => {
|
|
1661
|
+
const d = re(e, i.appliesTo);
|
|
1228
1662
|
let c = 0;
|
|
1229
|
-
|
|
1230
|
-
o.filter((l) => !
|
|
1231
|
-
|
|
1232
|
-
) :
|
|
1233
|
-
const
|
|
1234
|
-
return
|
|
1235
|
-
passed:
|
|
1236
|
-
...
|
|
1237
|
-
message:
|
|
1663
|
+
i.details.limitType === ee.HOLDING ? c = re(
|
|
1664
|
+
o.filter((l) => !xt.includes(l.state)),
|
|
1665
|
+
i.appliesTo
|
|
1666
|
+
) : i.details.limitType === ee.ACTIVE && (c = re(o, i.appliesTo, t));
|
|
1667
|
+
const a = c + d, u = a <= i.details.limit;
|
|
1668
|
+
return V({
|
|
1669
|
+
passed: u,
|
|
1670
|
+
...u ? {} : { code: P.QUANTITY_LIMIT_EXCEEDED },
|
|
1671
|
+
message: u ? "Quantity rule passed" : "Quantity limit would be exceeded",
|
|
1238
1672
|
details: {
|
|
1239
|
-
ruleCode:
|
|
1240
|
-
ruleVersion:
|
|
1241
|
-
limitType:
|
|
1242
|
-
target:
|
|
1673
|
+
ruleCode: i.publishedRuleCode,
|
|
1674
|
+
ruleVersion: i.version,
|
|
1675
|
+
limitType: i.details.limitType,
|
|
1676
|
+
target: i.appliesTo,
|
|
1243
1677
|
current: c,
|
|
1244
|
-
addition:
|
|
1245
|
-
resulting:
|
|
1246
|
-
limit:
|
|
1247
|
-
remaining: Math.max(0,
|
|
1678
|
+
addition: d,
|
|
1679
|
+
resulting: a,
|
|
1680
|
+
limit: i.details.limit,
|
|
1681
|
+
remaining: Math.max(0, i.details.limit - c)
|
|
1248
1682
|
}
|
|
1249
1683
|
});
|
|
1250
1684
|
});
|
|
1251
|
-
return
|
|
1252
|
-
}
|
|
1253
|
-
function
|
|
1254
|
-
return n ===
|
|
1255
|
-
}
|
|
1256
|
-
function
|
|
1257
|
-
const
|
|
1258
|
-
const
|
|
1259
|
-
return
|
|
1260
|
-
passed:
|
|
1261
|
-
...
|
|
1262
|
-
message:
|
|
1685
|
+
return L({ passed: r.every((i) => i.passed), decisions: r });
|
|
1686
|
+
}
|
|
1687
|
+
function Yt(n) {
|
|
1688
|
+
return n === Y.UNDER_REVIEW ? P.ELIGIBILITY_UNDER_REVIEW : n === Y.REJECTED ? P.ELIGIBILITY_REJECTED : n === Y.REVOKED ? P.ELIGIBILITY_REVOKED : P.ELIGIBILITY_REQUIRED;
|
|
1689
|
+
}
|
|
1690
|
+
function Ft({ rules: n = [], eligibilityFacts: o = [], eventRegistrationCode: e, candidateItems: t = [] }) {
|
|
1691
|
+
const r = n.filter((i) => i.ruleType === _.ELIGIBILITY).filter((i) => t.some((d) => z(i.appliesTo, d))).map((i) => {
|
|
1692
|
+
const d = o.find((u) => u.eligibilityType === i.details.eligibilityType && (!e || !u.eventRegistrationCode || u.eventRegistrationCode === e)), c = (d == null ? void 0 : d.state) || Y.NOT_SUBMITTED, a = (i.details.acceptedStates || [Y.VALID]).includes(c);
|
|
1693
|
+
return V({
|
|
1694
|
+
passed: a,
|
|
1695
|
+
...a ? {} : { code: Yt(c) },
|
|
1696
|
+
message: a ? "Eligibility rule passed" : "Required eligibility is not valid",
|
|
1263
1697
|
details: {
|
|
1264
|
-
ruleCode:
|
|
1265
|
-
eligibilityType:
|
|
1698
|
+
ruleCode: i.publishedRuleCode,
|
|
1699
|
+
eligibilityType: i.details.eligibilityType,
|
|
1266
1700
|
eventRegistrationCode: e || null,
|
|
1267
1701
|
state: c,
|
|
1268
|
-
factRevision: (
|
|
1702
|
+
factRevision: (d == null ? void 0 : d.revision) || null
|
|
1269
1703
|
}
|
|
1270
1704
|
});
|
|
1271
1705
|
});
|
|
1272
|
-
return
|
|
1706
|
+
return L({ passed: r.every((i) => i.passed), decisions: r });
|
|
1273
1707
|
}
|
|
1274
|
-
function
|
|
1275
|
-
return
|
|
1708
|
+
function kt(n, o) {
|
|
1709
|
+
return Qt(n) && z(o, n);
|
|
1276
1710
|
}
|
|
1277
|
-
function
|
|
1711
|
+
function Wt(n) {
|
|
1278
1712
|
return Object.fromEntries([
|
|
1279
1713
|
"walletItemCode",
|
|
1280
1714
|
"acquisitionCode",
|
|
@@ -1287,469 +1721,493 @@ function Rt(n) {
|
|
|
1287
1721
|
"componentIndex"
|
|
1288
1722
|
].flatMap((e) => typeof n[e] > "u" ? [] : [[e, D(n[e])]]));
|
|
1289
1723
|
}
|
|
1290
|
-
function
|
|
1291
|
-
const t = n.filter((
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
],
|
|
1296
|
-
...
|
|
1297
|
-
...
|
|
1298
|
-
], c = (
|
|
1299
|
-
requirement:
|
|
1300
|
-
matched:
|
|
1301
|
-
})),
|
|
1302
|
-
return
|
|
1303
|
-
passed:
|
|
1304
|
-
...
|
|
1305
|
-
message:
|
|
1724
|
+
function Gt({ rules: n = [], existingItems: o = [], candidateItems: e = [] }) {
|
|
1725
|
+
const t = n.filter((r) => r.ruleType === _.PREREQUISITE).filter((r) => e.some((i) => z(r.appliesTo, i))).map((r) => {
|
|
1726
|
+
const i = r.details.evidenceSources || [
|
|
1727
|
+
K.EXISTING,
|
|
1728
|
+
K.SAME_ORDER
|
|
1729
|
+
], d = [
|
|
1730
|
+
...i.includes(K.EXISTING) ? o : [],
|
|
1731
|
+
...i.includes(K.SAME_ORDER) ? e : []
|
|
1732
|
+
], c = (r.details.requires || []).map((u) => ({
|
|
1733
|
+
requirement: u,
|
|
1734
|
+
matched: d.filter((l) => kt(l, u)).map(Wt)
|
|
1735
|
+
})), a = r.details.matchMode === ye.ALL ? c.every((u) => u.matched.length > 0) : c.some((u) => u.matched.length > 0);
|
|
1736
|
+
return V({
|
|
1737
|
+
passed: a,
|
|
1738
|
+
...a ? {} : { code: P.PREREQUISITE_NOT_MET },
|
|
1739
|
+
message: a ? "Prerequisite rule passed" : "Prerequisite item was not found",
|
|
1306
1740
|
details: {
|
|
1307
|
-
ruleCode:
|
|
1308
|
-
matchMode:
|
|
1309
|
-
continuous:
|
|
1741
|
+
ruleCode: r.publishedRuleCode,
|
|
1742
|
+
matchMode: r.details.matchMode || ye.ANY,
|
|
1743
|
+
continuous: r.details.continuous || !1,
|
|
1310
1744
|
requirementResults: c
|
|
1311
1745
|
}
|
|
1312
1746
|
});
|
|
1313
1747
|
});
|
|
1314
|
-
return
|
|
1748
|
+
return L({ passed: t.every((r) => r.passed), decisions: t });
|
|
1315
1749
|
}
|
|
1316
|
-
function
|
|
1750
|
+
function Ht({
|
|
1317
1751
|
rules: n = [],
|
|
1318
1752
|
candidateItems: o = [],
|
|
1319
1753
|
requirementInputs: e = [],
|
|
1320
1754
|
requirementValues: t = {},
|
|
1321
|
-
variantSelections:
|
|
1755
|
+
variantSelections: r = []
|
|
1322
1756
|
}) {
|
|
1323
|
-
const
|
|
1757
|
+
const i = n.filter((d) => d.ruleType === _.REQUIREMENT).filter((d) => o.some((c) => z(d.appliesTo, c))).flatMap((d) => o.filter((c) => z(d.appliesTo, c)).flatMap((c) => Array.from({ length: c.quantity }, (a, u) => {
|
|
1324
1758
|
var p;
|
|
1325
|
-
const l =
|
|
1759
|
+
const l = d.details.requirement, m = l.requirementCode, I = e.find((R) => R.productCode === c.productCode && R.requirementCode === m), y = t[m], T = Array.isArray(y) ? y : [y || {}], E = I && u < I.inputs.length ? I.inputs[u] || {} : T[u] || {}, g = (p = r.find((R) => R.productCode === c.productCode)) == null ? void 0 : p.selections[u], A = Object.fromEntries(l.fields.map((R) => R.inputType === "VARIANT" ? [R.fieldCode, (g == null ? void 0 : g.variantCode) || ""] : [R.fieldCode, E[R.fieldCode] || ""])), v = l.fields.map((R) => R.fieldCode).filter((R) => typeof A[R] != "string" || A[R].trim().length === 0);
|
|
1326
1760
|
return {
|
|
1327
|
-
ruleCode:
|
|
1761
|
+
ruleCode: d.publishedRuleCode,
|
|
1328
1762
|
requirement: l,
|
|
1329
1763
|
productCode: c.productCode,
|
|
1330
1764
|
componentIndex: c.componentIndex,
|
|
1331
|
-
unitIndex:
|
|
1332
|
-
completionTiming:
|
|
1333
|
-
modificationMode:
|
|
1334
|
-
...
|
|
1335
|
-
...
|
|
1336
|
-
values: D(
|
|
1337
|
-
missingFields:
|
|
1338
|
-
complete:
|
|
1765
|
+
unitIndex: u,
|
|
1766
|
+
completionTiming: d.details.completionTiming || Re.BEFORE_ITEM_VALID,
|
|
1767
|
+
modificationMode: d.details.modificationMode,
|
|
1768
|
+
...d.details.completionDeadline ? { completionDeadline: d.details.completionDeadline } : {},
|
|
1769
|
+
...d.details.modificationDeadline ? { modificationDeadline: d.details.modificationDeadline } : {},
|
|
1770
|
+
values: D(A),
|
|
1771
|
+
missingFields: v,
|
|
1772
|
+
complete: v.length === 0
|
|
1339
1773
|
};
|
|
1340
1774
|
})));
|
|
1341
|
-
return
|
|
1775
|
+
return L({
|
|
1342
1776
|
passed: !0,
|
|
1343
|
-
itemValid:
|
|
1344
|
-
code:
|
|
1345
|
-
plans:
|
|
1777
|
+
itemValid: i.every((d) => d.complete),
|
|
1778
|
+
code: i.every((d) => d.complete) ? null : P.REQUIREMENT_INCOMPLETE,
|
|
1779
|
+
plans: i
|
|
1346
1780
|
});
|
|
1347
1781
|
}
|
|
1348
|
-
function
|
|
1349
|
-
if (!o || o.ruleType !==
|
|
1782
|
+
function Mn({ requirementPlan: n = {}, rule: o, instant: e }) {
|
|
1783
|
+
if (!o || o.ruleType !== _.REQUIREMENT)
|
|
1350
1784
|
throw new TypeError("rule must be a REQUIREMENT PublishedRule");
|
|
1351
1785
|
const t = Date.parse(e);
|
|
1352
1786
|
if (!Number.isFinite(t))
|
|
1353
1787
|
throw new TypeError("instant must be an ISO-8601 timestamp");
|
|
1354
|
-
const
|
|
1355
|
-
let c =
|
|
1356
|
-
return
|
|
1357
|
-
requirementCode:
|
|
1358
|
-
completionState:
|
|
1788
|
+
const r = o.details, i = !!(r.completionDeadline && t >= Date.parse(r.completionDeadline)), d = n.complete ? fe.COMPLETE : i ? fe.OVERDUE : fe.INCOMPLETE;
|
|
1789
|
+
let c = ne.EDITABLE, a = null;
|
|
1790
|
+
return r.modificationMode === j.LOCK_AFTER_COMPLETE && n.complete ? (c = ne.LOCKED, a = "REQUIREMENT_COMPLETE") : r.modificationMode === j.UNTIL_DEADLINE && t >= Date.parse(r.modificationDeadline) && (c = ne.LOCKED, a = "MODIFICATION_DEADLINE_PASSED"), L({
|
|
1791
|
+
requirementCode: r.requirement.requirementCode,
|
|
1792
|
+
completionState: d,
|
|
1359
1793
|
modificationState: c,
|
|
1360
|
-
canModify: c ===
|
|
1361
|
-
modificationReason:
|
|
1362
|
-
completionDeadline:
|
|
1363
|
-
modificationDeadline:
|
|
1794
|
+
canModify: c === ne.EDITABLE,
|
|
1795
|
+
modificationReason: a,
|
|
1796
|
+
completionDeadline: r.completionDeadline || null,
|
|
1797
|
+
modificationDeadline: r.modificationDeadline || null,
|
|
1364
1798
|
evaluated: e
|
|
1365
1799
|
});
|
|
1366
1800
|
}
|
|
1367
|
-
function
|
|
1801
|
+
function Kt(n, o) {
|
|
1368
1802
|
const e = Date.parse(o);
|
|
1369
1803
|
return !(!Number.isFinite(e) || n.validFrom && e < Date.parse(n.validFrom) || n.validUntil && e >= Date.parse(n.validUntil));
|
|
1370
1804
|
}
|
|
1371
|
-
function
|
|
1372
|
-
|
|
1373
|
-
|
|
1805
|
+
function Xt({ row: n, salesPeriods: o }) {
|
|
1806
|
+
if (!n.salesPeriodRef) return { available: !0, salesPeriod: null, window: n };
|
|
1807
|
+
const e = o.find((r) => r.salesPeriodCode === n.salesPeriodRef.salesPeriodCode && r.version === n.salesPeriodRef.salesPeriodVersion);
|
|
1808
|
+
if (e) {
|
|
1809
|
+
const r = {
|
|
1810
|
+
salesPeriodCode: e.salesPeriodCode,
|
|
1811
|
+
version: e.version,
|
|
1812
|
+
validFrom: e.validFrom,
|
|
1813
|
+
validUntil: e.validUntil
|
|
1814
|
+
};
|
|
1815
|
+
return { available: !0, salesPeriod: r, window: r };
|
|
1816
|
+
}
|
|
1817
|
+
const t = !!n.validFrom || !!n.validUntil;
|
|
1818
|
+
return o.length === 0 && t ? { available: !0, salesPeriod: null, window: n } : { available: !1, salesPeriod: null, window: null };
|
|
1819
|
+
}
|
|
1820
|
+
function Jt(n = {}, o, e) {
|
|
1821
|
+
const t = n.countryCodes || [], r = n.excludedCountryCodes || [];
|
|
1822
|
+
return t.length > 0 && !t.includes(o) || r.includes(o) ? !1 : n.countryRank ? !(!Number.isInteger(e) || e < 1 || n.countryRank.min && e < n.countryRank.min || n.countryRank.max && e > n.countryRank.max) : !0;
|
|
1374
1823
|
}
|
|
1375
|
-
function
|
|
1824
|
+
function et({ match: n = {}, countryCode: o, countryRank: e }) {
|
|
1376
1825
|
if (typeof o != "string" || o.trim().length === 0 || !Number.isInteger(e) || e < 1)
|
|
1377
|
-
return
|
|
1826
|
+
return V({
|
|
1378
1827
|
passed: !1,
|
|
1379
|
-
code:
|
|
1828
|
+
code: P.PRICE_COUNTRY_UNRESOLVED,
|
|
1380
1829
|
message: "Country code and rank are required to evaluate price match criteria",
|
|
1381
1830
|
details: { countryCode: o || null, countryRank: e ?? null }
|
|
1382
1831
|
});
|
|
1383
|
-
const t =
|
|
1384
|
-
return
|
|
1832
|
+
const t = Jt(n, o, e);
|
|
1833
|
+
return V({
|
|
1385
1834
|
passed: t,
|
|
1386
|
-
...t ? {} : { code:
|
|
1835
|
+
...t ? {} : { code: P.PRICE_MATCH_CRITERIA_NOT_MET },
|
|
1387
1836
|
message: t ? "Price match criteria passed" : "Price match criteria were not met",
|
|
1388
1837
|
details: { countryCode: o, countryRank: e }
|
|
1389
1838
|
});
|
|
1390
1839
|
}
|
|
1391
|
-
function
|
|
1392
|
-
const
|
|
1393
|
-
if (!
|
|
1394
|
-
return
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1840
|
+
function Zt({ priceSchedule: n, salesPeriods: o = [], currency: e, countryCode: t, countryRank: r, acquisitionSource: i, instant: d }) {
|
|
1841
|
+
const c = et({ match: {}, countryCode: t, countryRank: r });
|
|
1842
|
+
if (!c.passed)
|
|
1843
|
+
return c;
|
|
1844
|
+
const a = n.rows.flatMap((u) => {
|
|
1845
|
+
const l = Xt({ row: u, salesPeriods: o });
|
|
1846
|
+
return u.currency === e && et({ match: u.match, countryCode: t, countryRank: r }).passed && (u.acquisitionSources.length === 0 || u.acquisitionSources.includes(i)) && l.available && Kt(l.window, d) ? [{ row: u, salesPeriod: l.salesPeriod }] : [];
|
|
1847
|
+
});
|
|
1848
|
+
return a.length === 0 ? V({
|
|
1397
1849
|
passed: !1,
|
|
1398
|
-
code:
|
|
1850
|
+
code: P.PRICE_ROW_NOT_FOUND,
|
|
1399
1851
|
message: "No price row matches the acquisition context",
|
|
1400
|
-
details: { currency:
|
|
1401
|
-
}) :
|
|
1852
|
+
details: { currency: e, countryCode: t, countryRank: r, acquisitionSource: i, instant: d }
|
|
1853
|
+
}) : a.length > 1 ? V({
|
|
1402
1854
|
passed: !1,
|
|
1403
|
-
code:
|
|
1855
|
+
code: P.PRICE_ROW_AMBIGUOUS,
|
|
1404
1856
|
message: "More than one price row matches the acquisition context",
|
|
1405
|
-
details: { matchingPriceRowCodes:
|
|
1406
|
-
}) :
|
|
1857
|
+
details: { matchingPriceRowCodes: a.map(({ row: u }) => u.priceRowCode) }
|
|
1858
|
+
}) : V({
|
|
1407
1859
|
passed: !0,
|
|
1408
1860
|
message: "Price row resolved",
|
|
1409
|
-
details: {
|
|
1861
|
+
details: {
|
|
1862
|
+
countryCode: t,
|
|
1863
|
+
countryRank: r,
|
|
1864
|
+
matchedPriceRow: a[0].row,
|
|
1865
|
+
matchedSalesPeriod: a[0].salesPeriod
|
|
1866
|
+
}
|
|
1410
1867
|
});
|
|
1411
1868
|
}
|
|
1412
|
-
function
|
|
1413
|
-
const
|
|
1414
|
-
const
|
|
1415
|
-
const
|
|
1416
|
-
return
|
|
1417
|
-
}, /* @__PURE__ */ new Map())].map(([
|
|
1418
|
-
const
|
|
1869
|
+
function en({ rules: n = [], candidateItems: o = [], inventoryFacts: e = [], variantSelections: t = [] }) {
|
|
1870
|
+
const r = n.filter((i) => i.ruleType === _.INVENTORY).filter((i) => o.some((d) => z(i.appliesTo, d))).map((i) => {
|
|
1871
|
+
const d = re(o, i.appliesTo), c = t.find((C) => C.productCode === i.appliesTo.code), a = Array.from({ length: d }, (C, E) => (c == null ? void 0 : c.selections[E]) || null), u = a.length === d && a.every(Boolean), m = [...a.reduce((C, E) => {
|
|
1872
|
+
const A = (E == null ? void 0 : E.variantCode) || "UNSELECTED";
|
|
1873
|
+
return C.set(A, (C.get(A) || 0) + 1), C;
|
|
1874
|
+
}, /* @__PURE__ */ new Map())].map(([C, E]) => {
|
|
1875
|
+
const g = e.find((A) => A.inventoryPoolCode === i.details.inventoryPoolCode && (C === "UNSELECTED" || A.variantCode === C));
|
|
1419
1876
|
return {
|
|
1420
|
-
variantCode:
|
|
1877
|
+
variantCode: C === "UNSELECTED" ? null : C,
|
|
1421
1878
|
requested: E,
|
|
1422
|
-
available: (
|
|
1423
|
-
revision: (
|
|
1879
|
+
available: (g == null ? void 0 : g.available) ?? 0,
|
|
1880
|
+
revision: (g == null ? void 0 : g.revision) ?? null
|
|
1424
1881
|
};
|
|
1425
|
-
}),
|
|
1426
|
-
return
|
|
1427
|
-
passed:
|
|
1428
|
-
...
|
|
1429
|
-
message:
|
|
1882
|
+
}), I = i.details.inventoryMode === Ee.STOCKED_VARIANT && !u, y = m.every((C) => C.available >= C.requested), T = i.details.inventoryMode === Ee.PRODUCTION_DEMAND || !I && y;
|
|
1883
|
+
return V({
|
|
1884
|
+
passed: T,
|
|
1885
|
+
...T ? {} : { code: I ? P.VARIANT_SELECTION_REQUIRED : P.INVENTORY_UNAVAILABLE },
|
|
1886
|
+
message: T ? "Inventory rule passed" : I ? "A Variant must be selected for every unit" : "Inventory is unavailable",
|
|
1430
1887
|
details: {
|
|
1431
|
-
ruleCode:
|
|
1432
|
-
inventoryMode:
|
|
1433
|
-
inventoryPoolCode:
|
|
1434
|
-
requested:
|
|
1435
|
-
requests:
|
|
1436
|
-
intent:
|
|
1888
|
+
ruleCode: i.publishedRuleCode,
|
|
1889
|
+
inventoryMode: i.details.inventoryMode,
|
|
1890
|
+
inventoryPoolCode: i.details.inventoryPoolCode,
|
|
1891
|
+
requested: d,
|
|
1892
|
+
requests: m,
|
|
1893
|
+
intent: T ? { type: "RESERVE_OR_RECORD_DEMAND", requests: m } : null
|
|
1437
1894
|
}
|
|
1438
1895
|
});
|
|
1439
1896
|
});
|
|
1440
|
-
return
|
|
1441
|
-
}
|
|
1442
|
-
function
|
|
1443
|
-
const t = new Map(o.map((
|
|
1444
|
-
return n.components.map((
|
|
1445
|
-
const
|
|
1446
|
-
if (!
|
|
1447
|
-
throw new Error(`Product ${
|
|
1897
|
+
return L({ passed: r.every((i) => i.passed), decisions: r });
|
|
1898
|
+
}
|
|
1899
|
+
function tn({ merchandise: n, products: o, quantity: e }) {
|
|
1900
|
+
const t = new Map(o.map((r) => [r.productCode, r]));
|
|
1901
|
+
return n.components.map((r, i) => {
|
|
1902
|
+
const d = t.get(r.productCode);
|
|
1903
|
+
if (!d)
|
|
1904
|
+
throw new Error(`Product ${r.productCode} is not available for Merchandise ${n.merchandiseCode}`);
|
|
1448
1905
|
return {
|
|
1449
|
-
productCode:
|
|
1450
|
-
productVersion:
|
|
1451
|
-
categoryCodes:
|
|
1906
|
+
productCode: d.productCode,
|
|
1907
|
+
productVersion: d.version,
|
|
1908
|
+
categoryCodes: d.categoryCodes,
|
|
1452
1909
|
merchandiseCode: n.merchandiseCode,
|
|
1453
|
-
componentIndex:
|
|
1454
|
-
quantity: e *
|
|
1455
|
-
state:
|
|
1910
|
+
componentIndex: i,
|
|
1911
|
+
quantity: e * r.quantityPerUnit,
|
|
1912
|
+
state: S.VALID
|
|
1456
1913
|
};
|
|
1457
1914
|
});
|
|
1458
1915
|
}
|
|
1459
|
-
function
|
|
1460
|
-
return n.flatMap((e) => Array.from({ length: e.quantity }, (t,
|
|
1461
|
-
const
|
|
1916
|
+
function nn(n, o) {
|
|
1917
|
+
return n.flatMap((e) => Array.from({ length: e.quantity }, (t, r) => {
|
|
1918
|
+
const i = o.filter((d) => d.componentIndex === e.componentIndex && d.unitIndex === r);
|
|
1462
1919
|
return {
|
|
1463
1920
|
...e,
|
|
1464
1921
|
quantity: 1,
|
|
1465
|
-
state:
|
|
1922
|
+
state: i.every((d) => d.complete) ? S.VALID : S.PENDING_REQUIREMENT
|
|
1466
1923
|
};
|
|
1467
1924
|
}));
|
|
1468
1925
|
}
|
|
1469
|
-
function
|
|
1470
|
-
return n.map((
|
|
1471
|
-
const
|
|
1472
|
-
return
|
|
1473
|
-
path: `${o}[${
|
|
1474
|
-
message:
|
|
1926
|
+
function tt({ items: n, path: o, productDefinitions: e }, t) {
|
|
1927
|
+
return n.map((r, i) => {
|
|
1928
|
+
const d = e.filter((a) => a.productCode === r.productCode && a.version === r.productVersion);
|
|
1929
|
+
return d.length !== 1 && t.push({
|
|
1930
|
+
path: `${o}[${i}].productCode`,
|
|
1931
|
+
message: d.length === 0 ? `Product ${r.productCode}@${r.productVersion} is missing from recipient Product definitions` : `Product ${r.productCode}@${r.productVersion} is ambiguous in recipient Product definitions`
|
|
1475
1932
|
}), {
|
|
1476
|
-
...typeof
|
|
1477
|
-
categoryCodes:
|
|
1933
|
+
...typeof r.toObject == "function" ? r.toObject() : r,
|
|
1934
|
+
categoryCodes: d.length === 1 ? [...d[0].categoryCodes] : []
|
|
1478
1935
|
};
|
|
1479
1936
|
});
|
|
1480
1937
|
}
|
|
1481
|
-
function
|
|
1482
|
-
return o.map((
|
|
1483
|
-
var
|
|
1484
|
-
const
|
|
1485
|
-
return (
|
|
1486
|
-
path: `${e}[${
|
|
1487
|
-
message:
|
|
1938
|
+
function on({ acquisitionSnapshots: n, items: o, path: e }, t) {
|
|
1939
|
+
return o.map((r, i) => {
|
|
1940
|
+
var a, u;
|
|
1941
|
+
const d = n.filter((l) => l.id === r.acquisitionCode), c = (u = (a = d[0]) == null ? void 0 : a.merchandise) == null ? void 0 : u.merchandiseCode;
|
|
1942
|
+
return (d.length !== 1 || !c) && t.push({
|
|
1943
|
+
path: `${e}[${i}].acquisitionCode`,
|
|
1944
|
+
message: d.length === 0 ? `Acquisition ${r.acquisitionCode} is missing from recipient Acquisition snapshots` : d.length > 1 ? `Acquisition ${r.acquisitionCode} is ambiguous in recipient Acquisition snapshots` : `Acquisition ${r.acquisitionCode} does not contain a Merchandise code`
|
|
1488
1945
|
}), {
|
|
1489
|
-
...
|
|
1946
|
+
...r,
|
|
1490
1947
|
...c ? { merchandiseCode: c } : {}
|
|
1491
1948
|
};
|
|
1492
1949
|
});
|
|
1493
1950
|
}
|
|
1494
|
-
function
|
|
1951
|
+
function rn(n, o) {
|
|
1495
1952
|
if (!Array.isArray(n))
|
|
1496
1953
|
return o.push({ path: "variantSelections", message: "variantSelections must be an array" }), [];
|
|
1497
1954
|
const e = /* @__PURE__ */ new Set();
|
|
1498
|
-
return n.flatMap((t,
|
|
1499
|
-
const
|
|
1955
|
+
return n.flatMap((t, r) => {
|
|
1956
|
+
const i = `variantSelections[${r}]`;
|
|
1500
1957
|
if (!t || typeof t != "object" || Array.isArray(t))
|
|
1501
|
-
return o.push({ path:
|
|
1502
|
-
const
|
|
1503
|
-
if (
|
|
1504
|
-
return o.push({ path: `${
|
|
1505
|
-
const c = t.selections.flatMap((
|
|
1506
|
-
if (
|
|
1958
|
+
return o.push({ path: i, message: "variant selection group must be an object" }), [];
|
|
1959
|
+
const d = typeof t.productCode == "string" ? t.productCode.trim() : "";
|
|
1960
|
+
if (d ? e.has(d) ? o.push({ path: `${i}.productCode`, message: `duplicate Product ${d}` }) : e.add(d) : o.push({ path: `${i}.productCode`, message: "productCode must be a non-empty string" }), !Array.isArray(t.selections))
|
|
1961
|
+
return o.push({ path: `${i}.selections`, message: "selections must be an array" }), [{ productCode: d, selections: [] }];
|
|
1962
|
+
const c = t.selections.flatMap((a, u) => {
|
|
1963
|
+
if (a === null)
|
|
1507
1964
|
return [null];
|
|
1508
1965
|
try {
|
|
1509
|
-
return [(
|
|
1966
|
+
return [(a instanceof Xe ? a : new Xe(a)).toObject()];
|
|
1510
1967
|
} catch (l) {
|
|
1511
|
-
return o.push({ path: `${
|
|
1968
|
+
return o.push({ path: `${i}.selections[${u}]`, message: l.message }), [];
|
|
1512
1969
|
}
|
|
1513
1970
|
});
|
|
1514
|
-
return [{ productCode:
|
|
1971
|
+
return [{ productCode: d, selections: c }];
|
|
1515
1972
|
});
|
|
1516
1973
|
}
|
|
1517
|
-
function
|
|
1974
|
+
function dn(n, o) {
|
|
1518
1975
|
if (!Array.isArray(n))
|
|
1519
1976
|
return o.push({ path: "requirementInputs", message: "requirementInputs must be an array" }), [];
|
|
1520
1977
|
const e = /* @__PURE__ */ new Set();
|
|
1521
|
-
return n.flatMap((t,
|
|
1522
|
-
const
|
|
1978
|
+
return n.flatMap((t, r) => {
|
|
1979
|
+
const i = `requirementInputs[${r}]`;
|
|
1523
1980
|
if (!t || typeof t != "object" || Array.isArray(t))
|
|
1524
|
-
return o.push({ path:
|
|
1525
|
-
const
|
|
1526
|
-
|
|
1527
|
-
const
|
|
1528
|
-
if (
|
|
1529
|
-
return o.push({ path: `${
|
|
1530
|
-
const
|
|
1531
|
-
return [{ productCode:
|
|
1981
|
+
return o.push({ path: i, message: "requirement input group must be an object" }), [];
|
|
1982
|
+
const d = typeof t.productCode == "string" ? t.productCode.trim() : "", c = typeof t.requirementCode == "string" ? t.requirementCode.trim() : "";
|
|
1983
|
+
d || o.push({ path: `${i}.productCode`, message: "productCode must be a non-empty string" }), c || o.push({ path: `${i}.requirementCode`, message: "requirementCode must be a non-empty string" });
|
|
1984
|
+
const a = `${d}:${c}`;
|
|
1985
|
+
if (d && c && e.has(a) && o.push({ path: i, message: `duplicate Requirement ${c} for Product ${d}` }), e.add(a), !Array.isArray(t.inputs))
|
|
1986
|
+
return o.push({ path: `${i}.inputs`, message: "inputs must be an array" }), [{ productCode: d, requirementCode: c, inputs: [] }];
|
|
1987
|
+
const u = t.inputs.map((l, m) => l === null ? null : !l || typeof l != "object" || Array.isArray(l) ? (o.push({ path: `${i}.inputs[${m}]`, message: "input must be an object or null" }), null) : D(l));
|
|
1988
|
+
return [{ productCode: d, requirementCode: c, inputs: u }];
|
|
1532
1989
|
});
|
|
1533
1990
|
}
|
|
1534
|
-
function
|
|
1535
|
-
const
|
|
1536
|
-
[e, ...n, ...t, ...
|
|
1537
|
-
var
|
|
1538
|
-
|
|
1539
|
-
path: `${
|
|
1540
|
-
message: `expected ${
|
|
1991
|
+
function cn({ categories: n, merchandise: o, priceSchedule: e, products: t, variants: r }, i) {
|
|
1992
|
+
const d = o.tenantCode;
|
|
1993
|
+
[e, ...n, ...t, ...r].forEach((a) => {
|
|
1994
|
+
var u;
|
|
1995
|
+
a.tenantCode !== d && i.push({
|
|
1996
|
+
path: `${a._type || ((u = a.constructor) == null ? void 0 : u.name) || "definition"}.tenantCode`,
|
|
1997
|
+
message: `expected ${d} but received ${a.tenantCode}`
|
|
1541
1998
|
});
|
|
1542
1999
|
});
|
|
1543
2000
|
}
|
|
1544
|
-
function
|
|
1545
|
-
const
|
|
1546
|
-
e.forEach((
|
|
1547
|
-
const { productCode: c, selections:
|
|
2001
|
+
function sn({ merchandise: n, variants: o, variantSelections: e }, t) {
|
|
2002
|
+
const r = new Map(n.components.map((i) => [i.productCode, i]));
|
|
2003
|
+
e.forEach((i, d) => {
|
|
2004
|
+
const { productCode: c, selections: a } = i, u = `variantSelections[${d}]`, l = r.get(c);
|
|
1548
2005
|
if (!l) {
|
|
1549
2006
|
t.push({
|
|
1550
|
-
path: `${
|
|
2007
|
+
path: `${u}.productCode`,
|
|
1551
2008
|
message: `Product ${c} is not a Merchandise component`
|
|
1552
2009
|
});
|
|
1553
2010
|
return;
|
|
1554
2011
|
}
|
|
1555
|
-
|
|
1556
|
-
const
|
|
1557
|
-
if (
|
|
2012
|
+
a.filter(Boolean).forEach((m, I) => {
|
|
2013
|
+
const y = o.filter((C) => C.variantCode === m.variantCode && C.version === m.variantVersion);
|
|
2014
|
+
if (y.length !== 1) {
|
|
1558
2015
|
t.push({
|
|
1559
|
-
path: `${
|
|
1560
|
-
message:
|
|
2016
|
+
path: `${u}.selections[${I}]`,
|
|
2017
|
+
message: y.length === 0 ? `Variant ${m.variantCode}@${m.variantVersion} is missing` : `Variant ${m.variantCode}@${m.variantVersion} is ambiguous`
|
|
1561
2018
|
});
|
|
1562
2019
|
return;
|
|
1563
2020
|
}
|
|
1564
|
-
const [
|
|
1565
|
-
(
|
|
1566
|
-
path: `${
|
|
1567
|
-
message: `Variant ${
|
|
2021
|
+
const [T] = y;
|
|
2022
|
+
(T.productCode !== c || T.productVersion !== l.productVersion) && t.push({
|
|
2023
|
+
path: `${u}.selections[${I}]`,
|
|
2024
|
+
message: `Variant ${m.variantCode}@${m.variantVersion} does not belong to Product ${c}@${l.productVersion}`
|
|
1568
2025
|
});
|
|
1569
2026
|
});
|
|
1570
2027
|
});
|
|
1571
2028
|
}
|
|
1572
|
-
function
|
|
2029
|
+
function an({
|
|
1573
2030
|
categories: n = [],
|
|
1574
2031
|
merchandise: o,
|
|
1575
2032
|
priceSchedule: e,
|
|
1576
2033
|
products: t = [],
|
|
1577
|
-
quantity:
|
|
1578
|
-
requirementInputs:
|
|
1579
|
-
variants:
|
|
2034
|
+
quantity: r,
|
|
2035
|
+
requirementInputs: i = [],
|
|
2036
|
+
variants: d = [],
|
|
1580
2037
|
variantSelections: c = []
|
|
1581
2038
|
}) {
|
|
1582
|
-
const
|
|
1583
|
-
(!Number.isInteger(
|
|
2039
|
+
const a = [], u = rn(c, a), l = dn(i, a);
|
|
2040
|
+
(!Number.isInteger(r) || r < 1) && a.push({ path: "quantity", message: "quantity must be a positive integer" }), cn({ categories: n, merchandise: o, priceSchedule: e, products: t, variants: d }, a), e.priceScheduleCode !== o.priceScheduleCode && a.push({
|
|
1584
2041
|
path: "priceSchedule.priceScheduleCode",
|
|
1585
2042
|
message: `expected ${o.priceScheduleCode} but received ${e.priceScheduleCode}`
|
|
1586
2043
|
});
|
|
1587
|
-
const
|
|
1588
|
-
const
|
|
1589
|
-
return
|
|
1590
|
-
}, /* @__PURE__ */ new Map()),
|
|
1591
|
-
o.components.forEach((
|
|
1592
|
-
const
|
|
1593
|
-
|
|
2044
|
+
const m = t.reduce((C, E) => {
|
|
2045
|
+
const g = C.get(E.productCode) || [];
|
|
2046
|
+
return g.push(E), C.set(E.productCode, g), C;
|
|
2047
|
+
}, /* @__PURE__ */ new Map()), I = n.reduce((C, E) => (C.set(E.categoryCode, (C.get(E.categoryCode) || 0) + 1), C), /* @__PURE__ */ new Map()), y = /* @__PURE__ */ new Set();
|
|
2048
|
+
o.components.forEach((C, E) => {
|
|
2049
|
+
const g = `${C.productCode}@${C.productVersion}`;
|
|
2050
|
+
y.has(g) && a.push({
|
|
1594
2051
|
path: `merchandise.components[${E}]`,
|
|
1595
|
-
message: `duplicate component ${
|
|
1596
|
-
}),
|
|
1597
|
-
const
|
|
1598
|
-
|
|
2052
|
+
message: `duplicate component ${g}; use quantityPerUnit instead`
|
|
2053
|
+
}), y.add(g);
|
|
2054
|
+
const A = m.get(C.productCode) || [];
|
|
2055
|
+
A.length === 0 ? a.push({
|
|
1599
2056
|
path: `merchandise.components[${E}].productCode`,
|
|
1600
|
-
message: `Product ${
|
|
1601
|
-
}) :
|
|
2057
|
+
message: `Product ${C.productCode} is missing`
|
|
2058
|
+
}) : A.length > 1 ? a.push({
|
|
1602
2059
|
path: `merchandise.components[${E}].productCode`,
|
|
1603
|
-
message: `Product ${
|
|
1604
|
-
}) :
|
|
2060
|
+
message: `Product ${C.productCode} is ambiguous`
|
|
2061
|
+
}) : A[0].version !== C.productVersion ? a.push({
|
|
1605
2062
|
path: `merchandise.components[${E}].productVersion`,
|
|
1606
|
-
message: `expected Product version ${
|
|
1607
|
-
}) :
|
|
1608
|
-
const p =
|
|
1609
|
-
p !== 1 &&
|
|
1610
|
-
path: `products.${
|
|
1611
|
-
message: p === 0 ? `Category ${
|
|
2063
|
+
message: `expected Product version ${C.productVersion} but received ${A[0].version}`
|
|
2064
|
+
}) : A[0].categoryCodes.forEach((v) => {
|
|
2065
|
+
const p = I.get(v) || 0;
|
|
2066
|
+
p !== 1 && a.push({
|
|
2067
|
+
path: `products.${C.productCode}.categoryCodes`,
|
|
2068
|
+
message: p === 0 ? `Category ${v} is missing` : `Category ${v} is ambiguous`
|
|
1612
2069
|
});
|
|
1613
2070
|
});
|
|
1614
|
-
}),
|
|
2071
|
+
}), sn({
|
|
1615
2072
|
merchandise: o,
|
|
1616
|
-
variants:
|
|
1617
|
-
variantSelections:
|
|
1618
|
-
},
|
|
1619
|
-
const
|
|
1620
|
-
return l.forEach((
|
|
1621
|
-
|
|
2073
|
+
variants: d,
|
|
2074
|
+
variantSelections: u
|
|
2075
|
+
}, a);
|
|
2076
|
+
const T = new Set(o.components.map((C) => C.productCode));
|
|
2077
|
+
return l.forEach((C, E) => {
|
|
2078
|
+
T.has(C.productCode) || a.push({
|
|
1622
2079
|
path: `requirementInputs[${E}].productCode`,
|
|
1623
|
-
message: `Product ${
|
|
2080
|
+
message: `Product ${C.productCode} is not a Merchandise component`
|
|
1624
2081
|
});
|
|
1625
|
-
}),
|
|
1626
|
-
passed:
|
|
1627
|
-
...
|
|
1628
|
-
message:
|
|
2082
|
+
}), V({
|
|
2083
|
+
passed: a.length === 0,
|
|
2084
|
+
...a.length === 0 ? {} : { code: P.DEFINITION_INVALID },
|
|
2085
|
+
message: a.length === 0 ? "Acquisition definitions are consistent" : "Acquisition definitions are inconsistent",
|
|
1629
2086
|
details: {
|
|
1630
|
-
issues:
|
|
2087
|
+
issues: a,
|
|
1631
2088
|
requirementInputs: l,
|
|
1632
|
-
variantSelections:
|
|
2089
|
+
variantSelections: u
|
|
1633
2090
|
}
|
|
1634
2091
|
});
|
|
1635
2092
|
}
|
|
1636
|
-
function
|
|
2093
|
+
function qn({
|
|
1637
2094
|
acquisitionSource: n,
|
|
1638
2095
|
categories: o,
|
|
1639
2096
|
countryCode: e,
|
|
1640
2097
|
countryRank: t,
|
|
1641
|
-
currency:
|
|
1642
|
-
eligibilityFacts:
|
|
1643
|
-
eventRegistrationCode:
|
|
2098
|
+
currency: r,
|
|
2099
|
+
eligibilityFacts: i = [],
|
|
2100
|
+
eventRegistrationCode: d,
|
|
1644
2101
|
existingItems: c = [],
|
|
1645
|
-
instant:
|
|
1646
|
-
inventoryFacts:
|
|
2102
|
+
instant: a,
|
|
2103
|
+
inventoryFacts: u = [],
|
|
1647
2104
|
merchandise: l,
|
|
1648
|
-
priceSchedule:
|
|
1649
|
-
products:
|
|
1650
|
-
publishedRules:
|
|
1651
|
-
quantity:
|
|
1652
|
-
requirementInputs:
|
|
2105
|
+
priceSchedule: m,
|
|
2106
|
+
products: I,
|
|
2107
|
+
publishedRules: y,
|
|
2108
|
+
quantity: T = 1,
|
|
2109
|
+
requirementInputs: C = [],
|
|
1653
2110
|
requirementValues: E = {},
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
2111
|
+
salesPeriods: g = [],
|
|
2112
|
+
variants: A = [],
|
|
2113
|
+
variantSelections: v = [],
|
|
2114
|
+
recipientFacts: p
|
|
1657
2115
|
}) {
|
|
1658
|
-
const
|
|
2116
|
+
const R = (p == null ? void 0 : p.eligibilityFacts) || i, b = (p == null ? void 0 : p.existingWalletItems) || (p == null ? void 0 : p.existingItems) || c, te = (p == null ? void 0 : p.projectedItems) || [], F = (p == null ? void 0 : p.eventRegistrationCode) || d, ue = an({
|
|
1659
2117
|
categories: o,
|
|
1660
2118
|
merchandise: l,
|
|
1661
|
-
priceSchedule:
|
|
1662
|
-
products:
|
|
1663
|
-
quantity:
|
|
1664
|
-
requirementInputs:
|
|
1665
|
-
variants:
|
|
1666
|
-
variantSelections:
|
|
1667
|
-
}),
|
|
1668
|
-
items:
|
|
2119
|
+
priceSchedule: m,
|
|
2120
|
+
products: I,
|
|
2121
|
+
quantity: T,
|
|
2122
|
+
requirementInputs: C,
|
|
2123
|
+
variants: A,
|
|
2124
|
+
variantSelections: v
|
|
2125
|
+
}), G = [], Ie = (p == null ? void 0 : p.productDefinitions) || I, mt = tt({
|
|
2126
|
+
items: b,
|
|
1669
2127
|
path: "recipientFacts.existingWalletItems",
|
|
1670
|
-
productDefinitions:
|
|
1671
|
-
},
|
|
1672
|
-
acquisitionSnapshots: (
|
|
1673
|
-
items:
|
|
2128
|
+
productDefinitions: Ie
|
|
2129
|
+
}, G), Te = on({
|
|
2130
|
+
acquisitionSnapshots: (p == null ? void 0 : p.acquisitionSnapshots) || [],
|
|
2131
|
+
items: mt,
|
|
1674
2132
|
path: "recipientFacts.existingWalletItems"
|
|
1675
|
-
},
|
|
1676
|
-
items:
|
|
2133
|
+
}, G), Ct = tt({
|
|
2134
|
+
items: te,
|
|
1677
2135
|
path: "recipientFacts.projectedItems",
|
|
1678
|
-
productDefinitions:
|
|
1679
|
-
},
|
|
1680
|
-
...
|
|
1681
|
-
...
|
|
1682
|
-
],
|
|
2136
|
+
productDefinitions: Ie
|
|
2137
|
+
}, G), ft = [
|
|
2138
|
+
...ue.details.issues,
|
|
2139
|
+
...G
|
|
2140
|
+
], k = G.length === 0 ? ue : V({
|
|
1683
2141
|
passed: !1,
|
|
1684
|
-
code:
|
|
2142
|
+
code: P.DEFINITION_INVALID,
|
|
1685
2143
|
message: "Acquisition definitions are inconsistent",
|
|
1686
2144
|
details: {
|
|
1687
|
-
...
|
|
1688
|
-
issues:
|
|
2145
|
+
...ue.details,
|
|
2146
|
+
issues: ft
|
|
1689
2147
|
}
|
|
1690
|
-
}),
|
|
1691
|
-
rules:
|
|
1692
|
-
eligibilityFacts:
|
|
1693
|
-
eventRegistrationCode:
|
|
1694
|
-
candidateItems:
|
|
1695
|
-
}),
|
|
1696
|
-
rules:
|
|
1697
|
-
candidateItems:
|
|
1698
|
-
requirementInputs:
|
|
2148
|
+
}), w = jt({ categories: o, products: I, merchandise: l, acquisitionSource: n, publishedRules: y }), H = k.passed ? tn({ merchandise: l, products: I, quantity: T }) : [], pe = k.details.variantSelections, ge = k.details.requirementInputs, be = Ft({
|
|
2149
|
+
rules: w.rules,
|
|
2150
|
+
eligibilityFacts: R,
|
|
2151
|
+
eventRegistrationCode: F,
|
|
2152
|
+
candidateItems: H
|
|
2153
|
+
}), le = Ht({
|
|
2154
|
+
rules: w.rules,
|
|
2155
|
+
candidateItems: H,
|
|
2156
|
+
requirementInputs: ge,
|
|
1699
2157
|
requirementValues: E,
|
|
1700
|
-
variantSelections:
|
|
1701
|
-
}),
|
|
1702
|
-
...
|
|
1703
|
-
...
|
|
1704
|
-
],
|
|
1705
|
-
rules:
|
|
1706
|
-
existingItems:
|
|
1707
|
-
candidateItems:
|
|
1708
|
-
}),
|
|
1709
|
-
rules:
|
|
1710
|
-
existingItems:
|
|
1711
|
-
candidateItems:
|
|
1712
|
-
}),
|
|
1713
|
-
rules:
|
|
1714
|
-
candidateItems:
|
|
1715
|
-
inventoryFacts:
|
|
1716
|
-
variantSelections:
|
|
1717
|
-
}),
|
|
1718
|
-
return
|
|
1719
|
-
passed:
|
|
1720
|
-
canPurchase:
|
|
1721
|
-
canAcquire:
|
|
1722
|
-
canHold:
|
|
1723
|
-
itemValid:
|
|
1724
|
-
candidateItems:
|
|
1725
|
-
requirementInputs:
|
|
1726
|
-
variantSelections:
|
|
1727
|
-
effectiveRules:
|
|
2158
|
+
variantSelections: pe
|
|
2159
|
+
}), De = [
|
|
2160
|
+
...Ct,
|
|
2161
|
+
...nn(H, le.plans)
|
|
2162
|
+
], me = Bt({
|
|
2163
|
+
rules: w.rules,
|
|
2164
|
+
existingItems: Te,
|
|
2165
|
+
candidateItems: De
|
|
2166
|
+
}), Ne = Gt({
|
|
2167
|
+
rules: w.rules,
|
|
2168
|
+
existingItems: Te,
|
|
2169
|
+
candidateItems: De
|
|
2170
|
+
}), Ae = Zt({ priceSchedule: m, salesPeriods: g, currency: r, countryCode: e, countryRank: t, acquisitionSource: n, instant: a }), Oe = en({
|
|
2171
|
+
rules: w.rules,
|
|
2172
|
+
candidateItems: H,
|
|
2173
|
+
inventoryFacts: u,
|
|
2174
|
+
variantSelections: pe
|
|
2175
|
+
}), Et = me.decisions.filter((Q) => Q.details.limitType === ee.ORDER).every((Q) => Q.passed), yt = me.decisions.filter((Q) => Q.details.limitType !== ee.ORDER).every((Q) => Q.passed), Se = k.passed && w.passed && Et && Ae.passed && Oe.passed, Pe = yt, _e = k.passed && w.passed && be.passed && Pe && Ne.passed, Me = Se && _e;
|
|
2176
|
+
return L({
|
|
2177
|
+
passed: Me,
|
|
2178
|
+
canPurchase: Se,
|
|
2179
|
+
canAcquire: _e,
|
|
2180
|
+
canHold: Pe,
|
|
2181
|
+
itemValid: Me && le.itemValid,
|
|
2182
|
+
candidateItems: H,
|
|
2183
|
+
requirementInputs: ge,
|
|
2184
|
+
variantSelections: pe,
|
|
2185
|
+
effectiveRules: w,
|
|
1728
2186
|
evaluations: {
|
|
1729
|
-
definitions:
|
|
1730
|
-
eligibility:
|
|
1731
|
-
quantity:
|
|
1732
|
-
prerequisites:
|
|
1733
|
-
requirements:
|
|
1734
|
-
price:
|
|
1735
|
-
inventory:
|
|
2187
|
+
definitions: k,
|
|
2188
|
+
eligibility: be,
|
|
2189
|
+
quantity: me,
|
|
2190
|
+
prerequisites: Ne,
|
|
2191
|
+
requirements: le,
|
|
2192
|
+
price: Ae,
|
|
2193
|
+
inventory: Oe
|
|
1736
2194
|
}
|
|
1737
2195
|
});
|
|
1738
2196
|
}
|
|
1739
|
-
function
|
|
2197
|
+
function Ln({ id: n, evaluated: o, preview: e, context: t }) {
|
|
1740
2198
|
if (!e.passed)
|
|
1741
2199
|
throw new Error("Cannot snapshot a failed acquisition preview");
|
|
1742
|
-
const
|
|
1743
|
-
return new
|
|
2200
|
+
const r = typeof t.merchandise.toObject == "function" ? t.merchandise.toObject() : D(t.merchandise), i = t.products.map((d) => typeof d.toObject == "function" ? d.toObject() : D(d));
|
|
2201
|
+
return new At({
|
|
1744
2202
|
id: n,
|
|
1745
2203
|
contractVersion: 2,
|
|
1746
2204
|
eventRegistrationCode: t.eventRegistrationCode,
|
|
1747
2205
|
purchaserEventRegistrationCode: t.purchaserEventRegistrationCode || t.eventRegistrationCode,
|
|
1748
2206
|
payerEventRegistrationCode: t.payerEventRegistrationCode || t.eventRegistrationCode,
|
|
1749
2207
|
acquisitionSource: t.acquisitionSource,
|
|
1750
|
-
merchandise:
|
|
2208
|
+
merchandise: r,
|
|
1751
2209
|
quantity: t.quantity,
|
|
1752
|
-
products:
|
|
2210
|
+
products: i,
|
|
1753
2211
|
priceScheduleRef: {
|
|
1754
2212
|
priceScheduleCode: t.priceSchedule.priceScheduleCode,
|
|
1755
2213
|
priceScheduleVersion: t.priceSchedule.version
|
|
@@ -1770,86 +2228,182 @@ function Wt({ id: n, evaluated: o, preview: e, context: t }) {
|
|
|
1770
2228
|
evaluated: o
|
|
1771
2229
|
});
|
|
1772
2230
|
}
|
|
1773
|
-
function
|
|
2231
|
+
function Vn({ acquisitionSnapshot: n, walletItemIdFactory: o }) {
|
|
1774
2232
|
const e = [];
|
|
1775
|
-
return n.merchandise.components.forEach((t,
|
|
1776
|
-
const
|
|
1777
|
-
for (let
|
|
1778
|
-
const c = n.requirementPlans.filter((l) => l.componentIndex ===
|
|
2233
|
+
return n.merchandise.components.forEach((t, r) => {
|
|
2234
|
+
const i = n.quantity * t.quantityPerUnit;
|
|
2235
|
+
for (let d = 0; d < i; d += 1) {
|
|
2236
|
+
const c = n.requirementPlans.filter((l) => l.componentIndex === r && l.unitIndex === d), a = n.variantSelections.find((l) => l.productCode === t.productCode), u = a == null ? void 0 : a.selections[d];
|
|
1779
2237
|
e.push({
|
|
1780
|
-
walletItemCode: o({ component: t, index:
|
|
2238
|
+
walletItemCode: o({ component: t, index: d, acquisitionSnapshot: n }),
|
|
1781
2239
|
eventRegistrationCode: n.eventRegistrationCode,
|
|
1782
2240
|
productCode: t.productCode,
|
|
1783
2241
|
productVersion: t.productVersion,
|
|
1784
2242
|
acquisitionCode: n.id,
|
|
1785
2243
|
quantity: 1,
|
|
1786
|
-
variantCode: (
|
|
1787
|
-
variantVersion: (
|
|
1788
|
-
state: c.every((l) => l.complete) ?
|
|
2244
|
+
variantCode: (u == null ? void 0 : u.variantCode) || null,
|
|
2245
|
+
variantVersion: (u == null ? void 0 : u.variantVersion) || null,
|
|
2246
|
+
state: c.every((l) => l.complete) ? S.VALID : S.PENDING_REQUIREMENT,
|
|
1789
2247
|
requirementPlans: c.map((l) => ({ ...l, unitIndex: 0 }))
|
|
1790
2248
|
});
|
|
1791
2249
|
}
|
|
1792
|
-
}),
|
|
2250
|
+
}), L(e);
|
|
2251
|
+
}
|
|
2252
|
+
function vn({ now: n = Date.now(), requirementCode: o, values: e, walletItem: t }) {
|
|
2253
|
+
const r = st(t), i = ut(e, "values"), d = pt(o, "requirementCode"), c = r.requirementPlans.findIndex((y) => {
|
|
2254
|
+
var T;
|
|
2255
|
+
return ((T = y.requirement) == null ? void 0 : T.requirementCode) === d;
|
|
2256
|
+
});
|
|
2257
|
+
if (c < 0)
|
|
2258
|
+
throw W("WALLET_ITEM_REQUIREMENT_NOT_FOUND", "The Wallet Item Requirement was not found.");
|
|
2259
|
+
const a = r.requirementPlans[c];
|
|
2260
|
+
ct({ now: n, plan: a });
|
|
2261
|
+
const u = a.requirement.fields || [], l = new Set(u.map((y) => y.fieldCode)), m = Object.keys(i).find((y) => !l.has(y));
|
|
2262
|
+
if (m)
|
|
2263
|
+
throw W("WALLET_ITEM_REQUIREMENT_FIELD_UNKNOWN", `Requirement field "${m}" is not defined.`);
|
|
2264
|
+
const I = u.map((y) => y.fieldCode).filter((y) => !lt(i[y]));
|
|
2265
|
+
return r.requirementPlans[c] = {
|
|
2266
|
+
...a,
|
|
2267
|
+
complete: I.length === 0,
|
|
2268
|
+
missingFields: I,
|
|
2269
|
+
values: structuredClone(i)
|
|
2270
|
+
}, r.state = at(r.requirementPlans), new se(r).toObject();
|
|
2271
|
+
}
|
|
2272
|
+
function Un({ now: n = Date.now(), variant: o, walletItem: e }) {
|
|
2273
|
+
const t = st(e), r = ut(o, "variant"), i = pt(r.variantCode, "variant.variantCode"), d = Number(r.version);
|
|
2274
|
+
if (!Number.isSafeInteger(d) || d <= 0)
|
|
2275
|
+
throw new TypeError("variant.version must be a positive integer.");
|
|
2276
|
+
if (r.productCode !== t.productCode || r.productVersion !== t.productVersion)
|
|
2277
|
+
throw W("WALLET_ITEM_VARIANT_PRODUCT_MISMATCH", "The selected Variant does not belong to this Wallet Item Product version.");
|
|
2278
|
+
const c = t.requirementPlans.findIndex((m) => {
|
|
2279
|
+
var I;
|
|
2280
|
+
return (((I = m.requirement) == null ? void 0 : I.fields) || []).some((y) => y.inputType === X.VARIANT);
|
|
2281
|
+
});
|
|
2282
|
+
if (c < 0)
|
|
2283
|
+
throw W("WALLET_ITEM_VARIANT_REQUIREMENT_NOT_FOUND", "The Wallet Item does not have a Variant Requirement.");
|
|
2284
|
+
const a = t.requirementPlans[c];
|
|
2285
|
+
ct({ now: n, plan: a });
|
|
2286
|
+
const u = { ...a.values || {} };
|
|
2287
|
+
a.requirement.fields.filter((m) => m.inputType === X.VARIANT).forEach((m) => {
|
|
2288
|
+
u[m.fieldCode] = r[m.optionValueKey];
|
|
2289
|
+
});
|
|
2290
|
+
const l = a.requirement.fields.map((m) => m.fieldCode).filter((m) => !lt(u[m]));
|
|
2291
|
+
return t.requirementPlans[c] = {
|
|
2292
|
+
...a,
|
|
2293
|
+
complete: l.length === 0,
|
|
2294
|
+
missingFields: l,
|
|
2295
|
+
values: u
|
|
2296
|
+
}, t.state = at(t.requirementPlans), t.variantCode = i, t.variantVersion = d, new se(t).toObject();
|
|
2297
|
+
}
|
|
2298
|
+
function ct({ now: n, plan: o }) {
|
|
2299
|
+
if (o.modificationMode === j.LOCK_AFTER_COMPLETE && o.complete)
|
|
2300
|
+
throw W("WALLET_ITEM_REQUIREMENT_LOCKED", "The completed Wallet Item Requirement is locked.");
|
|
2301
|
+
if (o.modificationMode === j.UNTIL_DEADLINE && (!o.modificationDeadline || Number(n) >= Date.parse(o.modificationDeadline)))
|
|
2302
|
+
throw W("WALLET_ITEM_REQUIREMENT_DEADLINE_PASSED", "The Wallet Item Requirement modification deadline has passed.");
|
|
2303
|
+
}
|
|
2304
|
+
function st(n) {
|
|
2305
|
+
return n instanceof se ? n.toObject() : new se(n).toObject();
|
|
2306
|
+
}
|
|
2307
|
+
function at(n) {
|
|
2308
|
+
return n.every((o) => o.complete) ? S.VALID : S.PENDING_REQUIREMENT;
|
|
2309
|
+
}
|
|
2310
|
+
function ut(n, o) {
|
|
2311
|
+
if (!n || typeof n != "object" || Array.isArray(n))
|
|
2312
|
+
throw new TypeError(`${o} must be an object.`);
|
|
2313
|
+
return structuredClone(n);
|
|
2314
|
+
}
|
|
2315
|
+
function pt(n, o) {
|
|
2316
|
+
if (typeof n != "string" || n.trim().length === 0)
|
|
2317
|
+
throw new TypeError(`${o} is required.`);
|
|
2318
|
+
return n.trim();
|
|
2319
|
+
}
|
|
2320
|
+
function lt(n) {
|
|
2321
|
+
return !(n === null || typeof n > "u" || typeof n == "string" && n.trim().length === 0);
|
|
2322
|
+
}
|
|
2323
|
+
function W(n, o) {
|
|
2324
|
+
return Object.assign(new Error(o), { code: n });
|
|
1793
2325
|
}
|
|
1794
|
-
const
|
|
2326
|
+
const $n = 2;
|
|
1795
2327
|
export {
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
2328
|
+
Ce as ACQUISITION_SOURCES,
|
|
2329
|
+
pn as Acquisition,
|
|
2330
|
+
At as AcquisitionSnapshot,
|
|
2331
|
+
ln as Category,
|
|
2332
|
+
we as CommercialLifecycle,
|
|
2333
|
+
mn as Currency,
|
|
2334
|
+
P as DECISION_CODES,
|
|
2335
|
+
zt as DEFAULT_ACTIVE_ITEM_STATES,
|
|
2336
|
+
Y as ELIGIBILITY_STATES,
|
|
2337
|
+
Cn as EligibilityFact,
|
|
2338
|
+
Ot as INVENTORY_LEDGER_ACTIONS,
|
|
2339
|
+
Ee as INVENTORY_MODES,
|
|
2340
|
+
fn as InventoryBalance,
|
|
2341
|
+
En as InventoryLedgerEntry,
|
|
2342
|
+
yn as Invoice,
|
|
2343
|
+
Rn as InvoiceRevision,
|
|
2344
|
+
ye as MATCH_MODES,
|
|
2345
|
+
hn as Merchandise,
|
|
2346
|
+
je as MerchandiseComponent,
|
|
2347
|
+
ht as ORDER_STATES,
|
|
2348
|
+
In as Order,
|
|
2349
|
+
xe as OrderLine,
|
|
2350
|
+
Tt as PAYMENT_ATTEMPT_STATES,
|
|
2351
|
+
K as PREREQUISITE_EVIDENCE_SOURCES,
|
|
2352
|
+
Tn as PaymentAttempt,
|
|
2353
|
+
Be as PaymentMethodConfigurationSnapshot,
|
|
2354
|
+
ve as PriceEvaluationContext,
|
|
2355
|
+
Fe as PriceMatchCriteria,
|
|
2356
|
+
Ge as PriceRow,
|
|
2357
|
+
gn as PriceSchedule,
|
|
2358
|
+
Ue as PriceScheduleRef,
|
|
2359
|
+
bn as Product,
|
|
2360
|
+
Dn as PublishedRule,
|
|
2361
|
+
Nn as PublishedRuleRef,
|
|
2362
|
+
ee as QUANTITY_LIMIT_TYPES,
|
|
2363
|
+
fe as REQUIREMENT_COMPLETION_STATES,
|
|
2364
|
+
Re as REQUIREMENT_COMPLETION_TIMINGS,
|
|
2365
|
+
X as REQUIREMENT_INPUT_TYPES,
|
|
2366
|
+
j as REQUIREMENT_MODIFICATION_MODES,
|
|
2367
|
+
ne as REQUIREMENT_MODIFICATION_STATES,
|
|
2368
|
+
It as RESERVATION_STATES,
|
|
2369
|
+
q as RULE_SOURCES,
|
|
2370
|
+
_ as RULE_TYPES,
|
|
2371
|
+
An as Receipt,
|
|
2372
|
+
On as RefundPolicy,
|
|
2373
|
+
He as RefundPolicyRef,
|
|
2374
|
+
ie as RequirementDefinition,
|
|
2375
|
+
$e as RequirementFieldDefinition,
|
|
2376
|
+
ce as RequirementPlan,
|
|
2377
|
+
ze as Reservation,
|
|
2378
|
+
$n as STORE_MODEL_V2_CONTRACT_VERSION,
|
|
2379
|
+
Sn as SalesPeriod,
|
|
2380
|
+
ke as SalesPeriodRef,
|
|
2381
|
+
Pn as Settlement,
|
|
2382
|
+
J as StoreContractValidationError,
|
|
2383
|
+
O as StoreEntity,
|
|
2384
|
+
M as TARGET_TYPES,
|
|
2385
|
+
xt as TERMINAL_ITEM_STATES,
|
|
2386
|
+
_n as Variant,
|
|
2387
|
+
Xe as VariantRef,
|
|
2388
|
+
S as WALLET_ITEM_STATES,
|
|
2389
|
+
se as WalletItem,
|
|
2390
|
+
vn as applyWalletItemRequirementValues,
|
|
2391
|
+
Un as applyWalletItemVariantSelection,
|
|
2392
|
+
Qe as calculatePaymentDeadline,
|
|
2393
|
+
St as canStartPaymentAttempt,
|
|
2394
|
+
jt as collectEffectiveRules,
|
|
2395
|
+
Ln as createAcquisitionSnapshot,
|
|
2396
|
+
qn as evaluateAcquisitionPreview,
|
|
2397
|
+
Ft as evaluateEligibilityRules,
|
|
2398
|
+
en as evaluateInventoryRules,
|
|
2399
|
+
Gt as evaluatePrerequisiteRules,
|
|
2400
|
+
et as evaluatePriceMatchCriteria,
|
|
2401
|
+
Bt as evaluateQuantityRules,
|
|
2402
|
+
Mn as evaluateRequirementConfigurationState,
|
|
2403
|
+
tn as expandCandidateItems,
|
|
2404
|
+
Ht as planItemRequirements,
|
|
2405
|
+
Vn as projectWalletItems,
|
|
2406
|
+
Zt as resolvePrice,
|
|
2407
|
+
an as validateAcquisitionDefinitions
|
|
1854
2408
|
};
|
|
1855
2409
|
//# sourceMappingURL=q-store-model-v2.esm.js.map
|