@questwork/q-store-model 0.1.45 → 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 +49 -0
- package/dist/v2/evaluation/effectiveRules.d.ts +7 -0
- package/dist/v2/evaluation/index.d.ts +4 -0
- package/dist/v2/evaluation/ruleEvaluators.d.ts +49 -0
- package/dist/v2/evaluation/shared.d.ts +28 -0
- package/dist/v2/index.d.ts +14 -0
- package/dist/v2/internal/StoreContract.d.ts +10 -0
- package/dist/v2/internal/StoreContractValidationError.d.ts +9 -0
- package/dist/v2/internal/StoreEntity.d.ts +12 -0
- package/dist/v2/internal/validation.d.ts +17 -0
- package/dist/v2/models/Acquisition.d.ts +5 -0
- package/dist/v2/models/AcquisitionSnapshot.d.ts +5 -0
- package/dist/v2/models/Category.d.ts +5 -0
- package/dist/v2/models/CommercialLifecycle.d.ts +5 -0
- package/dist/v2/models/Currency.d.ts +5 -0
- package/dist/v2/models/EligibilityFact.d.ts +4 -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/Merchandise.d.ts +5 -0
- package/dist/v2/models/MerchandiseComponent.d.ts +4 -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/PriceEvaluationContext.d.ts +4 -0
- package/dist/v2/models/PriceMatchCriteria.d.ts +4 -0
- package/dist/v2/models/PriceRow.d.ts +4 -0
- package/dist/v2/models/PriceSchedule.d.ts +5 -0
- package/dist/v2/models/PriceScheduleRef.d.ts +4 -0
- package/dist/v2/models/Product.d.ts +5 -0
- package/dist/v2/models/PublishedRule.d.ts +5 -0
- package/dist/v2/models/PublishedRuleRef.d.ts +4 -0
- package/dist/v2/models/Receipt.d.ts +5 -0
- package/dist/v2/models/RefundPolicy.d.ts +5 -0
- package/dist/v2/models/RefundPolicyRef.d.ts +4 -0
- package/dist/v2/models/RequirementPlan.d.ts +4 -0
- package/dist/v2/models/Reservation.d.ts +4 -0
- package/dist/v2/models/SalesPeriod.d.ts +5 -0
- package/dist/v2/models/SalesPeriodRef.d.ts +4 -0
- package/dist/v2/models/Settlement.d.ts +5 -0
- package/dist/v2/models/Variant.d.ts +5 -0
- package/dist/v2/models/VariantRef.d.ts +4 -0
- package/dist/v2/models/WalletItem.d.ts +5 -0
- package/dist/v2/models/index.d.ts +37 -0
- package/dist/v2/models/ruleDetails/EligibilityRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/InventoryRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/PrerequisiteRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/QuantityRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/RefundRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/RequirementDefinition.d.ts +4 -0
- package/dist/v2/models/ruleDetails/RequirementFieldDefinition.d.ts +4 -0
- package/dist/v2/models/ruleDetails/RequirementRuleDetails.d.ts +4 -0
- package/dist/v2/models/ruleDetails/index.d.ts +1 -0
- package/dist/v2/models/ruleDetails/shared.d.ts +8 -0
- package/dist/v2/paymentTime.d.ts +8 -0
- package/dist/v2/q-store-model-v2.cjs +2 -0
- package/dist/v2/q-store-model-v2.esm.js +2409 -0
- package/dist/v2/ruleVocabulary.d.ts +76 -0
- package/dist/v2/walletItemUpdates.d.ts +11 -0
- package/package.json +14 -6
|
@@ -0,0 +1,2409 @@
|
|
|
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 {
|
|
31
|
+
constructor({ contractName: o, issues: e }) {
|
|
32
|
+
super(`${o} is invalid: ${e.join("; ")}`), this.name = "StoreContractValidationError", this.code = "STORE_CONTRACT_INVALID", this.contractName = o, this.issues = [...e];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const gt = ["boolean", "number", "string"];
|
|
36
|
+
function D(n, o = "value") {
|
|
37
|
+
if (n === null)
|
|
38
|
+
return null;
|
|
39
|
+
if (Array.isArray(n))
|
|
40
|
+
return n.map((e, t) => D(e, `${o}[${t}]`));
|
|
41
|
+
if (gt.includes(typeof n)) {
|
|
42
|
+
if (typeof n == "number" && !Number.isFinite(n))
|
|
43
|
+
throw new TypeError(`${o} must be a finite number`);
|
|
44
|
+
return n;
|
|
45
|
+
}
|
|
46
|
+
if (typeof n == "object" && Object.getPrototypeOf(n) === Object.prototype)
|
|
47
|
+
return Object.fromEntries(Object.entries(n).map(([e, t]) => {
|
|
48
|
+
if (typeof t > "u")
|
|
49
|
+
throw new TypeError(`${o}.${e} must not be undefined`);
|
|
50
|
+
return [e, D(t, `${o}.${e}`)];
|
|
51
|
+
}));
|
|
52
|
+
throw new TypeError(`${o} must contain JSON-safe values only`);
|
|
53
|
+
}
|
|
54
|
+
function L(n) {
|
|
55
|
+
return n && typeof n == "object" && !Object.isFrozen(n) && (Object.values(n).forEach(L), Object.freeze(n)), n;
|
|
56
|
+
}
|
|
57
|
+
function nt({ contractName: n, object: o, fields: e }) {
|
|
58
|
+
const t = Object.keys(o).filter((r) => !e.includes(r));
|
|
59
|
+
if (t.length > 0)
|
|
60
|
+
throw new J({
|
|
61
|
+
contractName: n,
|
|
62
|
+
issues: t.map((r) => `unknown field "${r}"`)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function s(n, o, e) {
|
|
66
|
+
return typeof n != "string" || n.trim().length === 0 ? (e.push(`${o} must be a non-empty string`), "") : n;
|
|
67
|
+
}
|
|
68
|
+
function N(n, o, e) {
|
|
69
|
+
if (!(typeof n > "u" || n === null))
|
|
70
|
+
return s(n, o, e);
|
|
71
|
+
}
|
|
72
|
+
function f(n, o, e, t = 1) {
|
|
73
|
+
return !Number.isInteger(n) || n < 1 ? (e.push(`${o} must be a positive integer`), t) : n;
|
|
74
|
+
}
|
|
75
|
+
function x(n, o, e, t = 0) {
|
|
76
|
+
return typeof n != "number" || !Number.isFinite(n) || n < 0 ? (e.push(`${o} must be a non-negative finite number`), t) : n;
|
|
77
|
+
}
|
|
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
|
+
}
|
|
193
|
+
}
|
|
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 }) {
|
|
226
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
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);
|
|
233
|
+
}
|
|
234
|
+
toObject() {
|
|
235
|
+
return D(Object.fromEntries(Object.entries(this)));
|
|
236
|
+
}
|
|
237
|
+
toJSON() {
|
|
238
|
+
return this.toObject();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
class ve extends h {
|
|
242
|
+
constructor(o = {}) {
|
|
243
|
+
super({
|
|
244
|
+
contractName: "PriceEvaluationContext",
|
|
245
|
+
object: o,
|
|
246
|
+
fields: ["acquisitionSource", "countryCode", "countryRank", "currency", "instant"],
|
|
247
|
+
normalize(e, t) {
|
|
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
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
class Ue extends h {
|
|
261
|
+
constructor(o = {}) {
|
|
262
|
+
super({
|
|
263
|
+
contractName: "PriceScheduleRef",
|
|
264
|
+
object: o,
|
|
265
|
+
fields: ["priceScheduleCode", "priceScheduleVersion"],
|
|
266
|
+
normalize(e, t) {
|
|
267
|
+
return {
|
|
268
|
+
priceScheduleCode: s(e.priceScheduleCode, "priceScheduleCode", t),
|
|
269
|
+
priceScheduleVersion: f(e.priceScheduleVersion, "priceScheduleVersion", t)
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const _ = Object.freeze({
|
|
276
|
+
ELIGIBILITY: "ELIGIBILITY",
|
|
277
|
+
INVENTORY: "INVENTORY",
|
|
278
|
+
PREREQUISITE: "PREREQUISITE",
|
|
279
|
+
QUANTITY: "QUANTITY",
|
|
280
|
+
REFUND: "REFUND",
|
|
281
|
+
REQUIREMENT: "REQUIREMENT"
|
|
282
|
+
}), q = Object.freeze({
|
|
283
|
+
ACQUISITION_SOURCE: "ACQUISITION_SOURCE",
|
|
284
|
+
CATEGORY: "CATEGORY",
|
|
285
|
+
MERCHANDISE: "MERCHANDISE",
|
|
286
|
+
PRODUCT: "PRODUCT"
|
|
287
|
+
}), M = Object.freeze({
|
|
288
|
+
CATEGORY: "CATEGORY",
|
|
289
|
+
MERCHANDISE: "MERCHANDISE",
|
|
290
|
+
PRODUCT: "PRODUCT"
|
|
291
|
+
}), ee = Object.freeze({ ACTIVE: "ACTIVE", HOLDING: "HOLDING", ORDER: "ORDER" }), Y = Object.freeze({
|
|
292
|
+
NOT_SUBMITTED: "NOT_SUBMITTED",
|
|
293
|
+
REOPENED: "REOPENED",
|
|
294
|
+
REJECTED: "REJECTED",
|
|
295
|
+
REVOKED: "REVOKED",
|
|
296
|
+
UNDER_REVIEW: "UNDER_REVIEW",
|
|
297
|
+
VALID: "VALID"
|
|
298
|
+
}), Ee = Object.freeze({
|
|
299
|
+
CAPACITY_ADMISSION: "CAPACITY_ADMISSION",
|
|
300
|
+
PRODUCTION_DEMAND: "PRODUCTION_DEMAND",
|
|
301
|
+
STOCKED_VARIANT: "STOCKED_VARIANT"
|
|
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({
|
|
303
|
+
ALWAYS: "ALWAYS",
|
|
304
|
+
LOCK_AFTER_COMPLETE: "LOCK_AFTER_COMPLETE",
|
|
305
|
+
UNTIL_DEADLINE: "UNTIL_DEADLINE"
|
|
306
|
+
}), fe = Object.freeze({
|
|
307
|
+
COMPLETE: "COMPLETE",
|
|
308
|
+
INCOMPLETE: "INCOMPLETE",
|
|
309
|
+
OVERDUE: "OVERDUE"
|
|
310
|
+
}), ne = Object.freeze({
|
|
311
|
+
EDITABLE: "EDITABLE",
|
|
312
|
+
LOCKED: "LOCKED"
|
|
313
|
+
}), X = Object.freeze({
|
|
314
|
+
EMAIL: "email",
|
|
315
|
+
TEXT: "text",
|
|
316
|
+
VARIANT: "VARIANT"
|
|
317
|
+
}), S = Object.freeze({
|
|
318
|
+
CANCELLED: "CANCELLED",
|
|
319
|
+
EXPIRED: "EXPIRED",
|
|
320
|
+
PENDING_REQUIREMENT: "PENDING_REQUIREMENT",
|
|
321
|
+
REFUNDED: "REFUNDED",
|
|
322
|
+
RESERVED: "RESERVED",
|
|
323
|
+
REVOKED: "REVOKED",
|
|
324
|
+
VALID: "VALID"
|
|
325
|
+
});
|
|
326
|
+
class $e extends h {
|
|
327
|
+
constructor(o = {}) {
|
|
328
|
+
super({
|
|
329
|
+
contractName: "RequirementFieldDefinition",
|
|
330
|
+
object: o,
|
|
331
|
+
fields: [
|
|
332
|
+
"autocomplete",
|
|
333
|
+
"deferredLabel",
|
|
334
|
+
"fieldCode",
|
|
335
|
+
"inputType",
|
|
336
|
+
"label",
|
|
337
|
+
"optionValueKey"
|
|
338
|
+
],
|
|
339
|
+
normalize(e, t) {
|
|
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 } : {},
|
|
349
|
+
...c ? { optionValueKey: c } : {}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
class ie extends h {
|
|
356
|
+
constructor(o = {}) {
|
|
357
|
+
super({
|
|
358
|
+
contractName: "RequirementDefinition",
|
|
359
|
+
object: o,
|
|
360
|
+
fields: ["requirementCode", "label", "fields"],
|
|
361
|
+
normalize(e, t) {
|
|
362
|
+
const r = (Array.isArray(e.fields) ? e.fields : []).flatMap((d, c) => {
|
|
363
|
+
try {
|
|
364
|
+
return [(d instanceof $e ? d : new $e(d)).toObject()];
|
|
365
|
+
} catch (a) {
|
|
366
|
+
return t.push(`fields[${c}]: ${a.message}`), [];
|
|
367
|
+
}
|
|
368
|
+
});
|
|
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);
|
|
373
|
+
}), {
|
|
374
|
+
requirementCode: s(e.requirementCode, "requirementCode", t),
|
|
375
|
+
label: s(e.label, "label", t),
|
|
376
|
+
fields: r
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
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}"`);
|
|
385
|
+
});
|
|
386
|
+
}
|
|
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({
|
|
389
|
+
contractName: o,
|
|
390
|
+
object: n,
|
|
391
|
+
fields: ["code", "type"],
|
|
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 };
|
|
395
|
+
}
|
|
396
|
+
}).toObject();
|
|
397
|
+
}
|
|
398
|
+
function de(n, o, e) {
|
|
399
|
+
if (!(typeof n > "u" || n === null || n === "")) {
|
|
400
|
+
if (typeof n != "string" || !Number.isFinite(Date.parse(n))) {
|
|
401
|
+
e.push(`${o} must be an ISO-8601 timestamp`);
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
return n;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
class ce extends h {
|
|
408
|
+
constructor(o = {}) {
|
|
409
|
+
super({
|
|
410
|
+
contractName: "RequirementPlan",
|
|
411
|
+
object: o,
|
|
412
|
+
fields: [
|
|
413
|
+
"complete",
|
|
414
|
+
"completionDeadline",
|
|
415
|
+
"completionTiming",
|
|
416
|
+
"componentIndex",
|
|
417
|
+
"missingFields",
|
|
418
|
+
"modificationDeadline",
|
|
419
|
+
"modificationMode",
|
|
420
|
+
"productCode",
|
|
421
|
+
"requirement",
|
|
422
|
+
"ruleCode",
|
|
423
|
+
"unitIndex",
|
|
424
|
+
"values"
|
|
425
|
+
],
|
|
426
|
+
normalize(e, t) {
|
|
427
|
+
let r = {};
|
|
428
|
+
try {
|
|
429
|
+
r = (e.requirement instanceof ie ? e.requirement : new ie(e.requirement)).toObject();
|
|
430
|
+
} catch (a) {
|
|
431
|
+
t.push(`requirement: ${a.message}`);
|
|
432
|
+
}
|
|
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);
|
|
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");
|
|
436
|
+
let c = {};
|
|
437
|
+
try {
|
|
438
|
+
!e.values || typeof e.values != "object" || Array.isArray(e.values) ? t.push("values must be an object") : c = D(e.values);
|
|
439
|
+
} catch (a) {
|
|
440
|
+
t.push(`values: ${a.message}`);
|
|
441
|
+
}
|
|
442
|
+
return {
|
|
443
|
+
ruleCode: s(e.ruleCode, "ruleCode", t),
|
|
444
|
+
requirement: r,
|
|
445
|
+
productCode: s(e.productCode, "productCode", t),
|
|
446
|
+
componentIndex: Number.isInteger(e.componentIndex) && e.componentIndex >= 0 ? e.componentIndex : 0,
|
|
447
|
+
unitIndex: Number.isInteger(e.unitIndex) && e.unitIndex >= 0 ? e.unitIndex : 0,
|
|
448
|
+
completionTiming: e.completionTiming,
|
|
449
|
+
modificationMode: e.modificationMode,
|
|
450
|
+
...i ? { completionDeadline: i } : {},
|
|
451
|
+
...d ? { modificationDeadline: d } : {},
|
|
452
|
+
values: c,
|
|
453
|
+
missingFields: U(e.missingFields || [], "missingFields", t),
|
|
454
|
+
complete: e.complete === !0
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
class At extends h {
|
|
461
|
+
constructor(o = {}) {
|
|
462
|
+
super({
|
|
463
|
+
contractName: "AcquisitionSnapshot",
|
|
464
|
+
object: o,
|
|
465
|
+
fields: [
|
|
466
|
+
"id",
|
|
467
|
+
"contractVersion",
|
|
468
|
+
"eventRegistrationCode",
|
|
469
|
+
"purchaserEventRegistrationCode",
|
|
470
|
+
"payerEventRegistrationCode",
|
|
471
|
+
"acquisitionSource",
|
|
472
|
+
"merchandise",
|
|
473
|
+
"quantity",
|
|
474
|
+
"products",
|
|
475
|
+
"priceScheduleRef",
|
|
476
|
+
"matchedPriceRow",
|
|
477
|
+
"priceEvaluationContext",
|
|
478
|
+
"effectiveRules",
|
|
479
|
+
"eligibilityDecisions",
|
|
480
|
+
"requirementPlans",
|
|
481
|
+
"inventoryDecisions",
|
|
482
|
+
"variantSelections",
|
|
483
|
+
"evaluated"
|
|
484
|
+
],
|
|
485
|
+
normalize(e, t) {
|
|
486
|
+
let r = {};
|
|
487
|
+
try {
|
|
488
|
+
r = (e.priceEvaluationContext instanceof ve ? e.priceEvaluationContext : new ve(e.priceEvaluationContext)).toObject();
|
|
489
|
+
} catch (c) {
|
|
490
|
+
t.push(`priceEvaluationContext: ${c.message}`);
|
|
491
|
+
}
|
|
492
|
+
let i = {};
|
|
493
|
+
try {
|
|
494
|
+
i = (e.priceScheduleRef instanceof Ue ? e.priceScheduleRef : new Ue(e.priceScheduleRef)).toObject();
|
|
495
|
+
} catch (c) {
|
|
496
|
+
t.push(`priceScheduleRef: ${c.message}`);
|
|
497
|
+
}
|
|
498
|
+
const d = (Array.isArray(e.requirementPlans) ? e.requirementPlans : []).flatMap((c, a) => {
|
|
499
|
+
try {
|
|
500
|
+
return [(c instanceof ce ? c : new ce(c)).toObject()];
|
|
501
|
+
} catch (u) {
|
|
502
|
+
return t.push(`requirementPlans[${a}]: ${u.message}`), [];
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
return Array.isArray(e.requirementPlans) || t.push("requirementPlans must be an array"), {
|
|
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(
|
|
510
|
+
e.purchaserEventRegistrationCode,
|
|
511
|
+
"purchaserEventRegistrationCode",
|
|
512
|
+
t
|
|
513
|
+
),
|
|
514
|
+
payerEventRegistrationCode: s(
|
|
515
|
+
e.payerEventRegistrationCode,
|
|
516
|
+
"payerEventRegistrationCode",
|
|
517
|
+
t
|
|
518
|
+
),
|
|
519
|
+
acquisitionSource: s(e.acquisitionSource, "acquisitionSource", t),
|
|
520
|
+
merchandise: e.merchandise || {},
|
|
521
|
+
quantity: f(e.quantity, "quantity", t),
|
|
522
|
+
products: e.products || [],
|
|
523
|
+
priceScheduleRef: i,
|
|
524
|
+
matchedPriceRow: e.matchedPriceRow || {},
|
|
525
|
+
priceEvaluationContext: r,
|
|
526
|
+
effectiveRules: e.effectiveRules || {},
|
|
527
|
+
eligibilityDecisions: e.eligibilityDecisions || [],
|
|
528
|
+
requirementPlans: d,
|
|
529
|
+
inventoryDecisions: e.inventoryDecisions || [],
|
|
530
|
+
variantSelections: e.variantSelections || [],
|
|
531
|
+
evaluated: s(e.evaluated, "evaluated", t)
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
getId() {
|
|
537
|
+
return this.id;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
class ln extends O {
|
|
541
|
+
constructor(o = {}) {
|
|
542
|
+
super({
|
|
543
|
+
contractName: "Category",
|
|
544
|
+
object: o,
|
|
545
|
+
fields: ["categoryCode", "version", "name", "description"],
|
|
546
|
+
normalize(e, t) {
|
|
547
|
+
return {
|
|
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 } : {}
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
getCode() {
|
|
557
|
+
return this.categoryCode;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
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 {
|
|
587
|
+
constructor(o = {}) {
|
|
588
|
+
super({
|
|
589
|
+
contractName: "Currency",
|
|
590
|
+
object: o,
|
|
591
|
+
fields: ["currencyCode", "name", "symbol", "factor", "unit"],
|
|
592
|
+
normalize(e, t) {
|
|
593
|
+
const r = N(e.symbol, "symbol", t);
|
|
594
|
+
return {
|
|
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)
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
getCode() {
|
|
605
|
+
return this.currencyCode;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
class Cn extends h {
|
|
609
|
+
constructor(o = {}) {
|
|
610
|
+
super({
|
|
611
|
+
contractName: "EligibilityFact",
|
|
612
|
+
object: o,
|
|
613
|
+
fields: [
|
|
614
|
+
"eligibilityType",
|
|
615
|
+
"state",
|
|
616
|
+
"revision",
|
|
617
|
+
"decisionReference",
|
|
618
|
+
"reasonCode"
|
|
619
|
+
],
|
|
620
|
+
normalize(e, t) {
|
|
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,
|
|
625
|
+
revision: Number.isInteger(e.revision) && e.revision >= 0 ? e.revision : 0,
|
|
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)
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
getCode() {
|
|
703
|
+
return this.invoiceCode;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
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 {
|
|
735
|
+
constructor(o = {}) {
|
|
736
|
+
super({
|
|
737
|
+
contractName: "MerchandiseComponent",
|
|
738
|
+
object: o,
|
|
739
|
+
fields: ["productCode", "productVersion", "quantityPerUnit"],
|
|
740
|
+
normalize(e, t) {
|
|
741
|
+
return {
|
|
742
|
+
productCode: s(e.productCode, "productCode", t),
|
|
743
|
+
productVersion: f(e.productVersion, "productVersion", t),
|
|
744
|
+
quantityPerUnit: f(e.quantityPerUnit, "quantityPerUnit", t)
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
class hn extends O {
|
|
751
|
+
constructor(o = {}) {
|
|
752
|
+
super({
|
|
753
|
+
contractName: "Merchandise",
|
|
754
|
+
object: o,
|
|
755
|
+
fields: ["merchandiseCode", "version", "name", "description", "components", "priceScheduleCode"],
|
|
756
|
+
normalize(e, t) {
|
|
757
|
+
let r = [];
|
|
758
|
+
try {
|
|
759
|
+
r = (e.components || []).map((i) => (i instanceof je ? i : new je(i)).toObject());
|
|
760
|
+
} catch (i) {
|
|
761
|
+
t.push(`components: ${i.message}`);
|
|
762
|
+
}
|
|
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)
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
getCode() {
|
|
775
|
+
return this.merchandiseCode;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
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) {
|
|
959
|
+
if (!(typeof n > "u" || n === null))
|
|
960
|
+
return f(n, o, e);
|
|
961
|
+
}
|
|
962
|
+
class Fe extends h {
|
|
963
|
+
constructor(o = {}) {
|
|
964
|
+
super({
|
|
965
|
+
contractName: "PriceMatchCriteria",
|
|
966
|
+
object: o,
|
|
967
|
+
fields: ["countryCodes", "excludedCountryCodes", "countryRank"],
|
|
968
|
+
normalize(e, t) {
|
|
969
|
+
const r = U(e.countryCodes || [], "countryCodes", t), i = U(
|
|
970
|
+
e.excludedCountryCodes || [],
|
|
971
|
+
"excludedCountryCodes",
|
|
972
|
+
t
|
|
973
|
+
), d = r.filter((a) => i.includes(a));
|
|
974
|
+
d.length > 0 && t.push(
|
|
975
|
+
`countryCodes and excludedCountryCodes overlap: ${[...new Set(d)].join(", ")}`
|
|
976
|
+
);
|
|
977
|
+
let c;
|
|
978
|
+
if (typeof e.countryRank < "u" && e.countryRank !== null)
|
|
979
|
+
if (typeof e.countryRank != "object" || Array.isArray(e.countryRank))
|
|
980
|
+
t.push("countryRank must be an object");
|
|
981
|
+
else {
|
|
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 } : {},
|
|
986
|
+
...l ? { max: l } : {}
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
return {
|
|
990
|
+
countryCodes: r,
|
|
991
|
+
excludedCountryCodes: i,
|
|
992
|
+
...c ? { countryRank: c } : {}
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
class ke extends h {
|
|
999
|
+
constructor(o = {}) {
|
|
1000
|
+
super({
|
|
1001
|
+
contractName: "SalesPeriodRef",
|
|
1002
|
+
object: o,
|
|
1003
|
+
fields: ["salesPeriodCode", "salesPeriodVersion"],
|
|
1004
|
+
normalize(e, t) {
|
|
1005
|
+
return {
|
|
1006
|
+
salesPeriodCode: s(e.salesPeriodCode, "salesPeriodCode", t),
|
|
1007
|
+
salesPeriodVersion: f(e.salesPeriodVersion, "salesPeriodVersion", t)
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
function We(n, o, e) {
|
|
1014
|
+
if (typeof n > "u" || n === null)
|
|
1015
|
+
return;
|
|
1016
|
+
const t = N(n, o, e);
|
|
1017
|
+
return t && !Number.isFinite(Date.parse(t)) && e.push(`${o} must be an ISO-compatible timestamp`), t;
|
|
1018
|
+
}
|
|
1019
|
+
class Ge extends h {
|
|
1020
|
+
constructor(o = {}) {
|
|
1021
|
+
super({
|
|
1022
|
+
contractName: "PriceRow",
|
|
1023
|
+
object: o,
|
|
1024
|
+
fields: [
|
|
1025
|
+
"priceRowCode",
|
|
1026
|
+
"currency",
|
|
1027
|
+
"amount",
|
|
1028
|
+
"match",
|
|
1029
|
+
"salesPeriodRef",
|
|
1030
|
+
"validFrom",
|
|
1031
|
+
"validUntil",
|
|
1032
|
+
"acquisitionSources"
|
|
1033
|
+
],
|
|
1034
|
+
normalize(e, t) {
|
|
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")
|
|
1039
|
+
try {
|
|
1040
|
+
d = (e.salesPeriodRef instanceof ke ? e.salesPeriodRef : new ke(e.salesPeriodRef)).toObject();
|
|
1041
|
+
} catch (a) {
|
|
1042
|
+
t.push(`salesPeriodRef: ${a.message}`);
|
|
1043
|
+
}
|
|
1044
|
+
let c = {};
|
|
1045
|
+
try {
|
|
1046
|
+
c = (e.match instanceof Fe ? e.match : new Fe(e.match || {})).toObject();
|
|
1047
|
+
} catch (a) {
|
|
1048
|
+
t.push(`match: ${a.message}`);
|
|
1049
|
+
}
|
|
1050
|
+
return {
|
|
1051
|
+
priceRowCode: s(e.priceRowCode, "priceRowCode", t),
|
|
1052
|
+
currency: s(e.currency, "currency", t),
|
|
1053
|
+
amount: x(e.amount, "amount", t),
|
|
1054
|
+
match: c,
|
|
1055
|
+
...d ? { salesPeriodRef: d } : {},
|
|
1056
|
+
...r ? { validFrom: r } : {},
|
|
1057
|
+
...i ? { validUntil: i } : {},
|
|
1058
|
+
acquisitionSources: U(e.acquisitionSources || [], "acquisitionSources", t)
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
class gn extends O {
|
|
1065
|
+
constructor(o = {}) {
|
|
1066
|
+
super({
|
|
1067
|
+
contractName: "PriceSchedule",
|
|
1068
|
+
object: o,
|
|
1069
|
+
fields: ["priceScheduleCode", "version", "rows"],
|
|
1070
|
+
normalize(e, t) {
|
|
1071
|
+
let r = [];
|
|
1072
|
+
try {
|
|
1073
|
+
r = (e.rows || []).map((i) => (i instanceof Ge ? i : new Ge(i)).toObject());
|
|
1074
|
+
} catch (i) {
|
|
1075
|
+
t.push(`rows: ${i.message}`);
|
|
1076
|
+
}
|
|
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
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
getCode() {
|
|
1086
|
+
return this.priceScheduleCode;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
class bn extends O {
|
|
1090
|
+
constructor(o = {}) {
|
|
1091
|
+
super({
|
|
1092
|
+
contractName: "Product",
|
|
1093
|
+
object: o,
|
|
1094
|
+
fields: ["productCode", "version", "name", "description", "categoryCodes"],
|
|
1095
|
+
normalize(e, t) {
|
|
1096
|
+
return {
|
|
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)
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
getCode() {
|
|
1107
|
+
return this.productCode;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
class Pt extends h {
|
|
1111
|
+
constructor(o = {}) {
|
|
1112
|
+
super({
|
|
1113
|
+
contractName: "EligibilityRuleDetails",
|
|
1114
|
+
object: o,
|
|
1115
|
+
fields: ["acceptedStates", "eligibilityType"],
|
|
1116
|
+
normalize(e, t) {
|
|
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),
|
|
1121
|
+
path: "acceptedStates",
|
|
1122
|
+
issues: t
|
|
1123
|
+
}), {
|
|
1124
|
+
eligibilityType: s(e.eligibilityType, "eligibilityType", t),
|
|
1125
|
+
acceptedStates: r
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
class _t extends h {
|
|
1132
|
+
constructor(o = {}) {
|
|
1133
|
+
super({
|
|
1134
|
+
contractName: "InventoryRuleDetails",
|
|
1135
|
+
object: o,
|
|
1136
|
+
fields: ["inventoryMode", "inventoryPoolCode"],
|
|
1137
|
+
normalize(e, t) {
|
|
1138
|
+
return Object.values(Ee).includes(e.inventoryMode) || t.push(`inventoryMode "${e.inventoryMode}" is not supported`), {
|
|
1139
|
+
inventoryMode: e.inventoryMode,
|
|
1140
|
+
inventoryPoolCode: s(e.inventoryPoolCode, "inventoryPoolCode", t)
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
class Mt extends h {
|
|
1147
|
+
constructor(o = {}) {
|
|
1148
|
+
super({
|
|
1149
|
+
contractName: "PrerequisiteRuleDetails",
|
|
1150
|
+
object: o,
|
|
1151
|
+
fields: ["continuous", "evidenceSources", "matchMode", "requires"],
|
|
1152
|
+
normalize(e, t) {
|
|
1153
|
+
(!Array.isArray(e.requires) || e.requires.length === 0) && t.push("requires must contain at least one target");
|
|
1154
|
+
const r = (e.requires || []).map((d, c) => {
|
|
1155
|
+
try {
|
|
1156
|
+
return Nt(d, `requires[${c}]`, t, Object.values(M));
|
|
1157
|
+
} catch (a) {
|
|
1158
|
+
return t.push(`requires[${c}]: ${a.message}`), {};
|
|
1159
|
+
}
|
|
1160
|
+
});
|
|
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),
|
|
1166
|
+
path: "evidenceSources",
|
|
1167
|
+
issues: t
|
|
1168
|
+
}), {
|
|
1169
|
+
requires: r,
|
|
1170
|
+
matchMode: e.matchMode,
|
|
1171
|
+
evidenceSources: i,
|
|
1172
|
+
continuous: e.continuous === !0
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
class qt extends h {
|
|
1179
|
+
constructor(o = {}) {
|
|
1180
|
+
super({
|
|
1181
|
+
contractName: "QuantityRuleDetails",
|
|
1182
|
+
object: o,
|
|
1183
|
+
fields: ["limit", "limitType"],
|
|
1184
|
+
normalize(e, t) {
|
|
1185
|
+
return Object.values(ee).includes(e.limitType) || t.push(`limitType "${e.limitType}" is not supported`), {
|
|
1186
|
+
limitType: e.limitType,
|
|
1187
|
+
limit: f(e.limit, "limit", t)
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
class He extends h {
|
|
1194
|
+
constructor(o = {}) {
|
|
1195
|
+
super({
|
|
1196
|
+
contractName: "RefundPolicyRef",
|
|
1197
|
+
object: o,
|
|
1198
|
+
fields: ["refundPolicyCode", "refundPolicyVersion"],
|
|
1199
|
+
normalize(e, t) {
|
|
1200
|
+
return {
|
|
1201
|
+
refundPolicyCode: s(e.refundPolicyCode, "refundPolicyCode", t),
|
|
1202
|
+
refundPolicyVersion: f(e.refundPolicyVersion, "refundPolicyVersion", t)
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
class Lt extends h {
|
|
1209
|
+
constructor(o = {}) {
|
|
1210
|
+
super({
|
|
1211
|
+
contractName: "RefundRuleDetails",
|
|
1212
|
+
object: o,
|
|
1213
|
+
fields: ["refundPolicyRef"],
|
|
1214
|
+
normalize(e, t) {
|
|
1215
|
+
try {
|
|
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: {} };
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
class Vt extends h {
|
|
1225
|
+
constructor(o = {}) {
|
|
1226
|
+
super({
|
|
1227
|
+
contractName: "RequirementRuleDetails",
|
|
1228
|
+
object: o,
|
|
1229
|
+
fields: [
|
|
1230
|
+
"completionDeadline",
|
|
1231
|
+
"completionTiming",
|
|
1232
|
+
"modificationDeadline",
|
|
1233
|
+
"modificationMode",
|
|
1234
|
+
"requirement"
|
|
1235
|
+
],
|
|
1236
|
+
normalize(e, t) {
|
|
1237
|
+
let r = {};
|
|
1238
|
+
try {
|
|
1239
|
+
r = (e.requirement instanceof ie ? e.requirement : new ie(e.requirement)).toObject();
|
|
1240
|
+
} catch (c) {
|
|
1241
|
+
t.push(`requirement: ${c.message}`);
|
|
1242
|
+
}
|
|
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,
|
|
1247
|
+
completionTiming: e.completionTiming,
|
|
1248
|
+
modificationMode: e.modificationMode,
|
|
1249
|
+
...i ? { completionDeadline: i } : {},
|
|
1250
|
+
...d ? { modificationDeadline: d } : {}
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
const vt = Object.freeze({
|
|
1257
|
+
[_.ELIGIBILITY]: Pt,
|
|
1258
|
+
[_.INVENTORY]: _t,
|
|
1259
|
+
[_.PREREQUISITE]: Mt,
|
|
1260
|
+
[_.QUANTITY]: qt,
|
|
1261
|
+
[_.REFUND]: Lt,
|
|
1262
|
+
[_.REQUIREMENT]: Vt
|
|
1263
|
+
});
|
|
1264
|
+
function Ut(n, o) {
|
|
1265
|
+
const e = vt[n];
|
|
1266
|
+
if (!e)
|
|
1267
|
+
throw new TypeError(`Rule type "${n}" does not have a details contract`);
|
|
1268
|
+
return new e(o);
|
|
1269
|
+
}
|
|
1270
|
+
function $t(n, o, e) {
|
|
1271
|
+
if (!n || typeof n != "object" || Array.isArray(n))
|
|
1272
|
+
return e.push(`${o} must be an object`), {};
|
|
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 };
|
|
1277
|
+
}
|
|
1278
|
+
class Dn extends O {
|
|
1279
|
+
constructor(o = {}) {
|
|
1280
|
+
super({
|
|
1281
|
+
contractName: "PublishedRule",
|
|
1282
|
+
object: o,
|
|
1283
|
+
fields: [
|
|
1284
|
+
"publishedRuleCode",
|
|
1285
|
+
"version",
|
|
1286
|
+
"ruleType",
|
|
1287
|
+
"sourceType",
|
|
1288
|
+
"sourceCode",
|
|
1289
|
+
"appliesTo",
|
|
1290
|
+
"details",
|
|
1291
|
+
"reason"
|
|
1292
|
+
],
|
|
1293
|
+
normalize(e, t) {
|
|
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);
|
|
1299
|
+
let c = {};
|
|
1300
|
+
try {
|
|
1301
|
+
c = Ut(r, e.details).toObject();
|
|
1302
|
+
} catch (a) {
|
|
1303
|
+
t.push(`details: ${a.message}`);
|
|
1304
|
+
}
|
|
1305
|
+
return {
|
|
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,
|
|
1312
|
+
details: c,
|
|
1313
|
+
...e.reason ? { reason: e.reason } : {}
|
|
1314
|
+
};
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
getCode() {
|
|
1319
|
+
return this.publishedRuleCode;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
class Nn extends h {
|
|
1323
|
+
constructor(o = {}) {
|
|
1324
|
+
super({
|
|
1325
|
+
contractName: "PublishedRuleRef",
|
|
1326
|
+
object: o,
|
|
1327
|
+
fields: ["publishedRuleCode", "publishedRuleVersion"],
|
|
1328
|
+
normalize(e, t) {
|
|
1329
|
+
return {
|
|
1330
|
+
publishedRuleCode: s(e.publishedRuleCode, "publishedRuleCode", t),
|
|
1331
|
+
publishedRuleVersion: f(e.publishedRuleVersion, "publishedRuleVersion", t)
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
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 {
|
|
1363
|
+
constructor(o = {}) {
|
|
1364
|
+
super({
|
|
1365
|
+
contractName: "RefundPolicy",
|
|
1366
|
+
object: o,
|
|
1367
|
+
fields: ["refundPolicyCode", "version", "name"],
|
|
1368
|
+
normalize(e, t) {
|
|
1369
|
+
return {
|
|
1370
|
+
refundPolicyCode: s(e.refundPolicyCode, "refundPolicyCode", t),
|
|
1371
|
+
version: f(e.version, "version", t),
|
|
1372
|
+
name: s(e.name, "name", t)
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
getCode() {
|
|
1378
|
+
return this.refundPolicyCode;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function Ke(n, o, e) {
|
|
1382
|
+
const t = s(n, o, e);
|
|
1383
|
+
return t && !Number.isFinite(Date.parse(t)) && e.push(`${o} must be an ISO-compatible timestamp`), t;
|
|
1384
|
+
}
|
|
1385
|
+
class Sn extends O {
|
|
1386
|
+
constructor(o = {}) {
|
|
1387
|
+
super({
|
|
1388
|
+
contractName: "SalesPeriod",
|
|
1389
|
+
object: o,
|
|
1390
|
+
fields: ["salesPeriodCode", "version", "name", "validFrom", "validUntil"],
|
|
1391
|
+
normalize(e, t) {
|
|
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
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
getCode() {
|
|
1404
|
+
return this.salesPeriodCode;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
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 {
|
|
1436
|
+
constructor(o = {}) {
|
|
1437
|
+
super({
|
|
1438
|
+
contractName: "Variant",
|
|
1439
|
+
object: o,
|
|
1440
|
+
fields: ["variantCode", "version", "productCode", "productVersion", "name", "optionValues"],
|
|
1441
|
+
normalize(e, t) {
|
|
1442
|
+
return (!e.optionValues || typeof e.optionValues != "object" || Array.isArray(e.optionValues)) && t.push("optionValues must be an object"), {
|
|
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),
|
|
1448
|
+
optionValues: e.optionValues || {}
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
}
|
|
1453
|
+
getCode() {
|
|
1454
|
+
return this.variantCode;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
class Xe extends h {
|
|
1458
|
+
constructor(o = {}) {
|
|
1459
|
+
super({
|
|
1460
|
+
contractName: "VariantRef",
|
|
1461
|
+
object: o,
|
|
1462
|
+
fields: ["variantCode", "variantVersion"],
|
|
1463
|
+
normalize(e, t) {
|
|
1464
|
+
return {
|
|
1465
|
+
variantCode: s(e.variantCode, "variantCode", t),
|
|
1466
|
+
variantVersion: f(e.variantVersion, "variantVersion", t)
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
class se extends O {
|
|
1473
|
+
constructor(o = {}) {
|
|
1474
|
+
super({
|
|
1475
|
+
contractName: "WalletItem",
|
|
1476
|
+
object: o,
|
|
1477
|
+
fields: [
|
|
1478
|
+
"walletItemCode",
|
|
1479
|
+
"productCode",
|
|
1480
|
+
"productVersion",
|
|
1481
|
+
"state",
|
|
1482
|
+
"quantity",
|
|
1483
|
+
"acquisitionCode",
|
|
1484
|
+
"eventRegistrationCode",
|
|
1485
|
+
"variantCode",
|
|
1486
|
+
"variantVersion",
|
|
1487
|
+
"requirementPlans"
|
|
1488
|
+
],
|
|
1489
|
+
normalize(e, t) {
|
|
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) => {
|
|
1495
|
+
try {
|
|
1496
|
+
return [(a instanceof ce ? a : new ce(a)).toObject()];
|
|
1497
|
+
} catch (l) {
|
|
1498
|
+
return t.push(`requirementPlans[${u}]: ${l.message}`), [];
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
return {
|
|
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 } : {},
|
|
1510
|
+
requirementPlans: c
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
getCode() {
|
|
1516
|
+
return this.walletItemCode;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
const Je = [
|
|
1520
|
+
q.CATEGORY,
|
|
1521
|
+
q.PRODUCT,
|
|
1522
|
+
q.MERCHANDISE,
|
|
1523
|
+
q.ACQUISITION_SOURCE
|
|
1524
|
+
];
|
|
1525
|
+
function Ze(n, o) {
|
|
1526
|
+
return `${n}:${o}`;
|
|
1527
|
+
}
|
|
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)
|
|
1537
|
+
return n.appliesTo.code === t.merchandiseCode;
|
|
1538
|
+
if (n.appliesTo.type === M.PRODUCT)
|
|
1539
|
+
return e.has(n.appliesTo.code);
|
|
1540
|
+
if (n.appliesTo.type === M.CATEGORY)
|
|
1541
|
+
return o.has(n.appliesTo.code);
|
|
1542
|
+
}
|
|
1543
|
+
return !1;
|
|
1544
|
+
}
|
|
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,
|
|
1549
|
+
sourceCode: p.categoryCode
|
|
1550
|
+
})),
|
|
1551
|
+
...d.map((p) => ({
|
|
1552
|
+
sourceType: q.PRODUCT,
|
|
1553
|
+
sourceCode: p.productCode
|
|
1554
|
+
})),
|
|
1555
|
+
{
|
|
1556
|
+
sourceType: q.MERCHANDISE,
|
|
1557
|
+
sourceCode: e.merchandiseCode
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
sourceType: q.ACQUISITION_SOURCE,
|
|
1561
|
+
sourceCode: t
|
|
1562
|
+
}
|
|
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) => {
|
|
1568
|
+
if (p.length > 1) {
|
|
1569
|
+
T.push({
|
|
1570
|
+
code: "RULE_PUBLICATION_AMBIGUOUS",
|
|
1571
|
+
ruleCode: R,
|
|
1572
|
+
sources: p.map((F) => ({
|
|
1573
|
+
sourceType: F.sourceType,
|
|
1574
|
+
sourceCode: F.sourceCode
|
|
1575
|
+
})),
|
|
1576
|
+
versions: p.map((F) => F.version)
|
|
1577
|
+
});
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
const [b] = p;
|
|
1581
|
+
if (b.tenantCode !== e.tenantCode) {
|
|
1582
|
+
T.push({
|
|
1583
|
+
code: "RULE_TENANT_MISMATCH",
|
|
1584
|
+
ruleCode: b.publishedRuleCode,
|
|
1585
|
+
ruleTenantCode: b.tenantCode,
|
|
1586
|
+
expectedTenantCode: e.tenantCode
|
|
1587
|
+
});
|
|
1588
|
+
return;
|
|
1589
|
+
}
|
|
1590
|
+
if (!wt({ rule: b, relevantCategoryCodes: a, relevantProductCodes: c, merchandise: e })) {
|
|
1591
|
+
T.push({
|
|
1592
|
+
code: "RULE_TARGET_MISMATCH",
|
|
1593
|
+
ruleCode: b.publishedRuleCode,
|
|
1594
|
+
sourceType: b.sourceType,
|
|
1595
|
+
sourceCode: b.sourceCode,
|
|
1596
|
+
appliesTo: D(b.appliesTo)
|
|
1597
|
+
});
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
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
|
|
1607
|
+
});
|
|
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) => [
|
|
1610
|
+
p,
|
|
1611
|
+
A.filter((R) => R.ruleType === p)
|
|
1612
|
+
]));
|
|
1613
|
+
return L({
|
|
1614
|
+
passed: T.length === 0,
|
|
1615
|
+
rules: A,
|
|
1616
|
+
byType: v,
|
|
1617
|
+
trace: C,
|
|
1618
|
+
errors: T
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
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({
|
|
1631
|
+
DEFINITION_INVALID: "DEFINITION_INVALID",
|
|
1632
|
+
ELIGIBILITY_REJECTED: "ELIGIBILITY_REJECTED",
|
|
1633
|
+
ELIGIBILITY_REQUIRED: "ELIGIBILITY_REQUIRED",
|
|
1634
|
+
ELIGIBILITY_REVOKED: "ELIGIBILITY_REVOKED",
|
|
1635
|
+
ELIGIBILITY_UNDER_REVIEW: "ELIGIBILITY_UNDER_REVIEW",
|
|
1636
|
+
INVENTORY_UNAVAILABLE: "INVENTORY_UNAVAILABLE",
|
|
1637
|
+
PREREQUISITE_NOT_MET: "PREREQUISITE_NOT_MET",
|
|
1638
|
+
PRICE_COUNTRY_UNRESOLVED: "PRICE_COUNTRY_UNRESOLVED",
|
|
1639
|
+
PRICE_MATCH_CRITERIA_NOT_MET: "PRICE_MATCH_CRITERIA_NOT_MET",
|
|
1640
|
+
PRICE_ROW_AMBIGUOUS: "PRICE_ROW_AMBIGUOUS",
|
|
1641
|
+
PRICE_ROW_NOT_FOUND: "PRICE_ROW_NOT_FOUND",
|
|
1642
|
+
QUANTITY_LIMIT_EXCEEDED: "QUANTITY_LIMIT_EXCEEDED",
|
|
1643
|
+
REQUIREMENT_INCOMPLETE: "REQUIREMENT_INCOMPLETE",
|
|
1644
|
+
REVISION_CONFLICT: "REVISION_CONFLICT",
|
|
1645
|
+
VARIANT_SELECTION_REQUIRED: "VARIANT_SELECTION_REQUIRED"
|
|
1646
|
+
});
|
|
1647
|
+
function V({ passed: n, code: o = null, message: e, details: t = {} }) {
|
|
1648
|
+
return L({ passed: n, code: o, message: e, details: D(t) });
|
|
1649
|
+
}
|
|
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;
|
|
1652
|
+
}
|
|
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);
|
|
1655
|
+
}
|
|
1656
|
+
function Qt(n) {
|
|
1657
|
+
return (n == null ? void 0 : n.state) === S.VALID;
|
|
1658
|
+
}
|
|
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);
|
|
1662
|
+
let c = 0;
|
|
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",
|
|
1672
|
+
details: {
|
|
1673
|
+
ruleCode: i.publishedRuleCode,
|
|
1674
|
+
ruleVersion: i.version,
|
|
1675
|
+
limitType: i.details.limitType,
|
|
1676
|
+
target: i.appliesTo,
|
|
1677
|
+
current: c,
|
|
1678
|
+
addition: d,
|
|
1679
|
+
resulting: a,
|
|
1680
|
+
limit: i.details.limit,
|
|
1681
|
+
remaining: Math.max(0, i.details.limit - c)
|
|
1682
|
+
}
|
|
1683
|
+
});
|
|
1684
|
+
});
|
|
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",
|
|
1697
|
+
details: {
|
|
1698
|
+
ruleCode: i.publishedRuleCode,
|
|
1699
|
+
eligibilityType: i.details.eligibilityType,
|
|
1700
|
+
eventRegistrationCode: e || null,
|
|
1701
|
+
state: c,
|
|
1702
|
+
factRevision: (d == null ? void 0 : d.revision) || null
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
});
|
|
1706
|
+
return L({ passed: r.every((i) => i.passed), decisions: r });
|
|
1707
|
+
}
|
|
1708
|
+
function kt(n, o) {
|
|
1709
|
+
return Qt(n) && z(o, n);
|
|
1710
|
+
}
|
|
1711
|
+
function Wt(n) {
|
|
1712
|
+
return Object.fromEntries([
|
|
1713
|
+
"walletItemCode",
|
|
1714
|
+
"acquisitionCode",
|
|
1715
|
+
"merchandiseCode",
|
|
1716
|
+
"productCode",
|
|
1717
|
+
"productVersion",
|
|
1718
|
+
"categoryCodes",
|
|
1719
|
+
"state",
|
|
1720
|
+
"quantity",
|
|
1721
|
+
"componentIndex"
|
|
1722
|
+
].flatMap((e) => typeof n[e] > "u" ? [] : [[e, D(n[e])]]));
|
|
1723
|
+
}
|
|
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",
|
|
1740
|
+
details: {
|
|
1741
|
+
ruleCode: r.publishedRuleCode,
|
|
1742
|
+
matchMode: r.details.matchMode || ye.ANY,
|
|
1743
|
+
continuous: r.details.continuous || !1,
|
|
1744
|
+
requirementResults: c
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
});
|
|
1748
|
+
return L({ passed: t.every((r) => r.passed), decisions: t });
|
|
1749
|
+
}
|
|
1750
|
+
function Ht({
|
|
1751
|
+
rules: n = [],
|
|
1752
|
+
candidateItems: o = [],
|
|
1753
|
+
requirementInputs: e = [],
|
|
1754
|
+
requirementValues: t = {},
|
|
1755
|
+
variantSelections: r = []
|
|
1756
|
+
}) {
|
|
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) => {
|
|
1758
|
+
var p;
|
|
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);
|
|
1760
|
+
return {
|
|
1761
|
+
ruleCode: d.publishedRuleCode,
|
|
1762
|
+
requirement: l,
|
|
1763
|
+
productCode: c.productCode,
|
|
1764
|
+
componentIndex: c.componentIndex,
|
|
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
|
|
1773
|
+
};
|
|
1774
|
+
})));
|
|
1775
|
+
return L({
|
|
1776
|
+
passed: !0,
|
|
1777
|
+
itemValid: i.every((d) => d.complete),
|
|
1778
|
+
code: i.every((d) => d.complete) ? null : P.REQUIREMENT_INCOMPLETE,
|
|
1779
|
+
plans: i
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
function Mn({ requirementPlan: n = {}, rule: o, instant: e }) {
|
|
1783
|
+
if (!o || o.ruleType !== _.REQUIREMENT)
|
|
1784
|
+
throw new TypeError("rule must be a REQUIREMENT PublishedRule");
|
|
1785
|
+
const t = Date.parse(e);
|
|
1786
|
+
if (!Number.isFinite(t))
|
|
1787
|
+
throw new TypeError("instant must be an ISO-8601 timestamp");
|
|
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,
|
|
1793
|
+
modificationState: c,
|
|
1794
|
+
canModify: c === ne.EDITABLE,
|
|
1795
|
+
modificationReason: a,
|
|
1796
|
+
completionDeadline: r.completionDeadline || null,
|
|
1797
|
+
modificationDeadline: r.modificationDeadline || null,
|
|
1798
|
+
evaluated: e
|
|
1799
|
+
});
|
|
1800
|
+
}
|
|
1801
|
+
function Kt(n, o) {
|
|
1802
|
+
const e = Date.parse(o);
|
|
1803
|
+
return !(!Number.isFinite(e) || n.validFrom && e < Date.parse(n.validFrom) || n.validUntil && e >= Date.parse(n.validUntil));
|
|
1804
|
+
}
|
|
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;
|
|
1823
|
+
}
|
|
1824
|
+
function et({ match: n = {}, countryCode: o, countryRank: e }) {
|
|
1825
|
+
if (typeof o != "string" || o.trim().length === 0 || !Number.isInteger(e) || e < 1)
|
|
1826
|
+
return V({
|
|
1827
|
+
passed: !1,
|
|
1828
|
+
code: P.PRICE_COUNTRY_UNRESOLVED,
|
|
1829
|
+
message: "Country code and rank are required to evaluate price match criteria",
|
|
1830
|
+
details: { countryCode: o || null, countryRank: e ?? null }
|
|
1831
|
+
});
|
|
1832
|
+
const t = Jt(n, o, e);
|
|
1833
|
+
return V({
|
|
1834
|
+
passed: t,
|
|
1835
|
+
...t ? {} : { code: P.PRICE_MATCH_CRITERIA_NOT_MET },
|
|
1836
|
+
message: t ? "Price match criteria passed" : "Price match criteria were not met",
|
|
1837
|
+
details: { countryCode: o, countryRank: e }
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
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({
|
|
1849
|
+
passed: !1,
|
|
1850
|
+
code: P.PRICE_ROW_NOT_FOUND,
|
|
1851
|
+
message: "No price row matches the acquisition context",
|
|
1852
|
+
details: { currency: e, countryCode: t, countryRank: r, acquisitionSource: i, instant: d }
|
|
1853
|
+
}) : a.length > 1 ? V({
|
|
1854
|
+
passed: !1,
|
|
1855
|
+
code: P.PRICE_ROW_AMBIGUOUS,
|
|
1856
|
+
message: "More than one price row matches the acquisition context",
|
|
1857
|
+
details: { matchingPriceRowCodes: a.map(({ row: u }) => u.priceRowCode) }
|
|
1858
|
+
}) : V({
|
|
1859
|
+
passed: !0,
|
|
1860
|
+
message: "Price row resolved",
|
|
1861
|
+
details: {
|
|
1862
|
+
countryCode: t,
|
|
1863
|
+
countryRank: r,
|
|
1864
|
+
matchedPriceRow: a[0].row,
|
|
1865
|
+
matchedSalesPeriod: a[0].salesPeriod
|
|
1866
|
+
}
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
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));
|
|
1876
|
+
return {
|
|
1877
|
+
variantCode: C === "UNSELECTED" ? null : C,
|
|
1878
|
+
requested: E,
|
|
1879
|
+
available: (g == null ? void 0 : g.available) ?? 0,
|
|
1880
|
+
revision: (g == null ? void 0 : g.revision) ?? null
|
|
1881
|
+
};
|
|
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",
|
|
1887
|
+
details: {
|
|
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
|
|
1894
|
+
}
|
|
1895
|
+
});
|
|
1896
|
+
});
|
|
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}`);
|
|
1905
|
+
return {
|
|
1906
|
+
productCode: d.productCode,
|
|
1907
|
+
productVersion: d.version,
|
|
1908
|
+
categoryCodes: d.categoryCodes,
|
|
1909
|
+
merchandiseCode: n.merchandiseCode,
|
|
1910
|
+
componentIndex: i,
|
|
1911
|
+
quantity: e * r.quantityPerUnit,
|
|
1912
|
+
state: S.VALID
|
|
1913
|
+
};
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
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);
|
|
1919
|
+
return {
|
|
1920
|
+
...e,
|
|
1921
|
+
quantity: 1,
|
|
1922
|
+
state: i.every((d) => d.complete) ? S.VALID : S.PENDING_REQUIREMENT
|
|
1923
|
+
};
|
|
1924
|
+
}));
|
|
1925
|
+
}
|
|
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`
|
|
1932
|
+
}), {
|
|
1933
|
+
...typeof r.toObject == "function" ? r.toObject() : r,
|
|
1934
|
+
categoryCodes: d.length === 1 ? [...d[0].categoryCodes] : []
|
|
1935
|
+
};
|
|
1936
|
+
});
|
|
1937
|
+
}
|
|
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`
|
|
1945
|
+
}), {
|
|
1946
|
+
...r,
|
|
1947
|
+
...c ? { merchandiseCode: c } : {}
|
|
1948
|
+
};
|
|
1949
|
+
});
|
|
1950
|
+
}
|
|
1951
|
+
function rn(n, o) {
|
|
1952
|
+
if (!Array.isArray(n))
|
|
1953
|
+
return o.push({ path: "variantSelections", message: "variantSelections must be an array" }), [];
|
|
1954
|
+
const e = /* @__PURE__ */ new Set();
|
|
1955
|
+
return n.flatMap((t, r) => {
|
|
1956
|
+
const i = `variantSelections[${r}]`;
|
|
1957
|
+
if (!t || typeof t != "object" || Array.isArray(t))
|
|
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)
|
|
1964
|
+
return [null];
|
|
1965
|
+
try {
|
|
1966
|
+
return [(a instanceof Xe ? a : new Xe(a)).toObject()];
|
|
1967
|
+
} catch (l) {
|
|
1968
|
+
return o.push({ path: `${i}.selections[${u}]`, message: l.message }), [];
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1971
|
+
return [{ productCode: d, selections: c }];
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
function dn(n, o) {
|
|
1975
|
+
if (!Array.isArray(n))
|
|
1976
|
+
return o.push({ path: "requirementInputs", message: "requirementInputs must be an array" }), [];
|
|
1977
|
+
const e = /* @__PURE__ */ new Set();
|
|
1978
|
+
return n.flatMap((t, r) => {
|
|
1979
|
+
const i = `requirementInputs[${r}]`;
|
|
1980
|
+
if (!t || typeof t != "object" || Array.isArray(t))
|
|
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 }];
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
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}`
|
|
1998
|
+
});
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
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);
|
|
2005
|
+
if (!l) {
|
|
2006
|
+
t.push({
|
|
2007
|
+
path: `${u}.productCode`,
|
|
2008
|
+
message: `Product ${c} is not a Merchandise component`
|
|
2009
|
+
});
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
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) {
|
|
2015
|
+
t.push({
|
|
2016
|
+
path: `${u}.selections[${I}]`,
|
|
2017
|
+
message: y.length === 0 ? `Variant ${m.variantCode}@${m.variantVersion} is missing` : `Variant ${m.variantCode}@${m.variantVersion} is ambiguous`
|
|
2018
|
+
});
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
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}`
|
|
2025
|
+
});
|
|
2026
|
+
});
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
function an({
|
|
2030
|
+
categories: n = [],
|
|
2031
|
+
merchandise: o,
|
|
2032
|
+
priceSchedule: e,
|
|
2033
|
+
products: t = [],
|
|
2034
|
+
quantity: r,
|
|
2035
|
+
requirementInputs: i = [],
|
|
2036
|
+
variants: d = [],
|
|
2037
|
+
variantSelections: c = []
|
|
2038
|
+
}) {
|
|
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({
|
|
2041
|
+
path: "priceSchedule.priceScheduleCode",
|
|
2042
|
+
message: `expected ${o.priceScheduleCode} but received ${e.priceScheduleCode}`
|
|
2043
|
+
});
|
|
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({
|
|
2051
|
+
path: `merchandise.components[${E}]`,
|
|
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({
|
|
2056
|
+
path: `merchandise.components[${E}].productCode`,
|
|
2057
|
+
message: `Product ${C.productCode} is missing`
|
|
2058
|
+
}) : A.length > 1 ? a.push({
|
|
2059
|
+
path: `merchandise.components[${E}].productCode`,
|
|
2060
|
+
message: `Product ${C.productCode} is ambiguous`
|
|
2061
|
+
}) : A[0].version !== C.productVersion ? a.push({
|
|
2062
|
+
path: `merchandise.components[${E}].productVersion`,
|
|
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`
|
|
2069
|
+
});
|
|
2070
|
+
});
|
|
2071
|
+
}), sn({
|
|
2072
|
+
merchandise: o,
|
|
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({
|
|
2079
|
+
path: `requirementInputs[${E}].productCode`,
|
|
2080
|
+
message: `Product ${C.productCode} is not a Merchandise component`
|
|
2081
|
+
});
|
|
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",
|
|
2086
|
+
details: {
|
|
2087
|
+
issues: a,
|
|
2088
|
+
requirementInputs: l,
|
|
2089
|
+
variantSelections: u
|
|
2090
|
+
}
|
|
2091
|
+
});
|
|
2092
|
+
}
|
|
2093
|
+
function qn({
|
|
2094
|
+
acquisitionSource: n,
|
|
2095
|
+
categories: o,
|
|
2096
|
+
countryCode: e,
|
|
2097
|
+
countryRank: t,
|
|
2098
|
+
currency: r,
|
|
2099
|
+
eligibilityFacts: i = [],
|
|
2100
|
+
eventRegistrationCode: d,
|
|
2101
|
+
existingItems: c = [],
|
|
2102
|
+
instant: a,
|
|
2103
|
+
inventoryFacts: u = [],
|
|
2104
|
+
merchandise: l,
|
|
2105
|
+
priceSchedule: m,
|
|
2106
|
+
products: I,
|
|
2107
|
+
publishedRules: y,
|
|
2108
|
+
quantity: T = 1,
|
|
2109
|
+
requirementInputs: C = [],
|
|
2110
|
+
requirementValues: E = {},
|
|
2111
|
+
salesPeriods: g = [],
|
|
2112
|
+
variants: A = [],
|
|
2113
|
+
variantSelections: v = [],
|
|
2114
|
+
recipientFacts: p
|
|
2115
|
+
}) {
|
|
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({
|
|
2117
|
+
categories: o,
|
|
2118
|
+
merchandise: l,
|
|
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,
|
|
2127
|
+
path: "recipientFacts.existingWalletItems",
|
|
2128
|
+
productDefinitions: Ie
|
|
2129
|
+
}, G), Te = on({
|
|
2130
|
+
acquisitionSnapshots: (p == null ? void 0 : p.acquisitionSnapshots) || [],
|
|
2131
|
+
items: mt,
|
|
2132
|
+
path: "recipientFacts.existingWalletItems"
|
|
2133
|
+
}, G), Ct = tt({
|
|
2134
|
+
items: te,
|
|
2135
|
+
path: "recipientFacts.projectedItems",
|
|
2136
|
+
productDefinitions: Ie
|
|
2137
|
+
}, G), ft = [
|
|
2138
|
+
...ue.details.issues,
|
|
2139
|
+
...G
|
|
2140
|
+
], k = G.length === 0 ? ue : V({
|
|
2141
|
+
passed: !1,
|
|
2142
|
+
code: P.DEFINITION_INVALID,
|
|
2143
|
+
message: "Acquisition definitions are inconsistent",
|
|
2144
|
+
details: {
|
|
2145
|
+
...ue.details,
|
|
2146
|
+
issues: ft
|
|
2147
|
+
}
|
|
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,
|
|
2157
|
+
requirementValues: E,
|
|
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,
|
|
2186
|
+
evaluations: {
|
|
2187
|
+
definitions: k,
|
|
2188
|
+
eligibility: be,
|
|
2189
|
+
quantity: me,
|
|
2190
|
+
prerequisites: Ne,
|
|
2191
|
+
requirements: le,
|
|
2192
|
+
price: Ae,
|
|
2193
|
+
inventory: Oe
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
function Ln({ id: n, evaluated: o, preview: e, context: t }) {
|
|
2198
|
+
if (!e.passed)
|
|
2199
|
+
throw new Error("Cannot snapshot a failed acquisition preview");
|
|
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({
|
|
2202
|
+
id: n,
|
|
2203
|
+
contractVersion: 2,
|
|
2204
|
+
eventRegistrationCode: t.eventRegistrationCode,
|
|
2205
|
+
purchaserEventRegistrationCode: t.purchaserEventRegistrationCode || t.eventRegistrationCode,
|
|
2206
|
+
payerEventRegistrationCode: t.payerEventRegistrationCode || t.eventRegistrationCode,
|
|
2207
|
+
acquisitionSource: t.acquisitionSource,
|
|
2208
|
+
merchandise: r,
|
|
2209
|
+
quantity: t.quantity,
|
|
2210
|
+
products: i,
|
|
2211
|
+
priceScheduleRef: {
|
|
2212
|
+
priceScheduleCode: t.priceSchedule.priceScheduleCode,
|
|
2213
|
+
priceScheduleVersion: t.priceSchedule.version
|
|
2214
|
+
},
|
|
2215
|
+
matchedPriceRow: e.evaluations.price.details.matchedPriceRow,
|
|
2216
|
+
priceEvaluationContext: {
|
|
2217
|
+
acquisitionSource: t.acquisitionSource,
|
|
2218
|
+
countryCode: e.evaluations.price.details.countryCode,
|
|
2219
|
+
countryRank: e.evaluations.price.details.countryRank,
|
|
2220
|
+
currency: e.evaluations.price.details.matchedPriceRow.currency,
|
|
2221
|
+
instant: t.instant
|
|
2222
|
+
},
|
|
2223
|
+
effectiveRules: e.effectiveRules,
|
|
2224
|
+
eligibilityDecisions: e.evaluations.eligibility.decisions,
|
|
2225
|
+
requirementPlans: e.evaluations.requirements.plans,
|
|
2226
|
+
inventoryDecisions: e.evaluations.inventory.decisions,
|
|
2227
|
+
variantSelections: e.variantSelections,
|
|
2228
|
+
evaluated: o
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2231
|
+
function Vn({ acquisitionSnapshot: n, walletItemIdFactory: o }) {
|
|
2232
|
+
const e = [];
|
|
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];
|
|
2237
|
+
e.push({
|
|
2238
|
+
walletItemCode: o({ component: t, index: d, acquisitionSnapshot: n }),
|
|
2239
|
+
eventRegistrationCode: n.eventRegistrationCode,
|
|
2240
|
+
productCode: t.productCode,
|
|
2241
|
+
productVersion: t.productVersion,
|
|
2242
|
+
acquisitionCode: n.id,
|
|
2243
|
+
quantity: 1,
|
|
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,
|
|
2247
|
+
requirementPlans: c.map((l) => ({ ...l, unitIndex: 0 }))
|
|
2248
|
+
});
|
|
2249
|
+
}
|
|
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 });
|
|
2325
|
+
}
|
|
2326
|
+
const $n = 2;
|
|
2327
|
+
export {
|
|
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
|
|
2408
|
+
};
|
|
2409
|
+
//# sourceMappingURL=q-store-model-v2.esm.js.map
|