@labdigital/commercetools-mock 2.53.2 → 2.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +107 -77
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +330 -7
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/lib/productSearchFilter.test.ts +1 -0
- package/src/lib/projectionSearchFilter.test.ts +1 -0
- package/src/priceSelector.test.ts +1 -0
- package/src/product-projection-search.ts +2 -0
- package/src/product-search.ts +1 -0
- package/src/repositories/business-unit.ts +157 -2
- package/src/repositories/cart/index.test.ts +2 -0
- package/src/repositories/cart/index.ts +1 -0
- package/src/repositories/cart-discount/index.ts +1 -1
- package/src/repositories/customer/index.ts +2 -0
- package/src/repositories/discount-group/actions.ts +50 -0
- package/src/repositories/discount-group/index.ts +29 -0
- package/src/repositories/index.ts +6 -0
- package/src/repositories/order/index.test.ts +126 -125
- package/src/repositories/payment/actions.ts +87 -0
- package/src/repositories/payment/index.ts +1 -1
- package/src/repositories/product/index.ts +1 -0
- package/src/repositories/product-type.ts +1 -0
- package/src/repositories/quote/index.ts +1 -0
- package/src/repositories/quote-request/index.test.ts +1 -0
- package/src/repositories/quote-request/index.ts +1 -0
- package/src/repositories/recurrence-policy/actions.ts +53 -0
- package/src/repositories/recurrence-policy/index.ts +36 -0
- package/src/repositories/recurring-order/actions.ts +157 -0
- package/src/repositories/recurring-order/index.ts +52 -0
- package/src/repositories/review.test.ts +2 -0
- package/src/repositories/shopping-list/actions.ts +1 -0
- package/src/repositories/shopping-list/index.ts +1 -0
- package/src/services/business-units.test.ts +586 -15
- package/src/services/discount-group.test.ts +270 -0
- package/src/services/discount-group.ts +16 -0
- package/src/services/index.ts +12 -0
- package/src/services/my-cart.test.ts +1 -0
- package/src/services/my-payment.test.ts +1 -0
- package/src/services/payment.test.ts +1 -0
- package/src/services/product-projection.test.ts +4 -0
- package/src/services/product-type.test.ts +1 -0
- package/src/services/product.test.ts +1 -0
- package/src/services/recurrence-policy.test.ts +316 -0
- package/src/services/recurrence-policy.ts +16 -0
- package/src/services/recurring-order.test.ts +424 -0
- package/src/services/recurring-order.ts +16 -0
- package/src/services/shopping-list.test.ts +3 -0
- package/src/storage/in-memory.ts +6 -0
- package/src/testing/business-unit.ts +48 -0
- package/src/testing/type.ts +20 -0
- package/src/types.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -1129,6 +1129,7 @@ var CartRepository = class extends AbstractResourceRepository {
|
|
|
1129
1129
|
itemShippingAddresses: [],
|
|
1130
1130
|
lineItems,
|
|
1131
1131
|
locale: draft.locale,
|
|
1132
|
+
priceRoundingMode: draft.priceRoundingMode ?? "HalfEven",
|
|
1132
1133
|
taxCalculationMode: draft.taxCalculationMode ?? "LineItemLevel",
|
|
1133
1134
|
taxMode: draft.taxMode ?? "Platform",
|
|
1134
1135
|
taxRoundingMode: draft.taxRoundingMode ?? "HalfEven",
|
|
@@ -1565,6 +1566,7 @@ var QuoteRequestRepository = class extends AbstractResourceRepository {
|
|
|
1565
1566
|
directDiscounts: cart.directDiscounts,
|
|
1566
1567
|
lineItems: cart.lineItems,
|
|
1567
1568
|
paymentInfo: cart.paymentInfo,
|
|
1569
|
+
priceRoundingMode: cart.priceRoundingMode,
|
|
1568
1570
|
quoteRequestState: "Submitted",
|
|
1569
1571
|
shippingAddress: cart.shippingAddress,
|
|
1570
1572
|
taxCalculationMode: cart.taxCalculationMode,
|
|
@@ -1747,9 +1749,14 @@ var BusinessUnitUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
1747
1749
|
resource.stores.push(newStore);
|
|
1748
1750
|
}
|
|
1749
1751
|
}
|
|
1750
|
-
changeAddress(context, resource, { address }) {
|
|
1752
|
+
changeAddress(context, resource, { addressId, address }) {
|
|
1753
|
+
const existingAddressIndex = resource.addresses.findIndex((addr) => addr.id === addressId);
|
|
1754
|
+
if (existingAddressIndex === -1) throw new Error(`Address with id ${addressId} not found`);
|
|
1751
1755
|
const newAddress = createAddress(address, context.projectKey, this._storage);
|
|
1752
|
-
if (newAddress) resource.addresses
|
|
1756
|
+
if (newAddress) resource.addresses[existingAddressIndex] = {
|
|
1757
|
+
...newAddress,
|
|
1758
|
+
id: addressId
|
|
1759
|
+
};
|
|
1753
1760
|
}
|
|
1754
1761
|
changeApprovalRuleMode(context, resource, { approvalRuleMode }) {
|
|
1755
1762
|
resource.approvalRuleMode = approvalRuleMode;
|
|
@@ -1770,6 +1777,15 @@ var BusinessUnitUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
1770
1777
|
const newAssociates = associates.map((a) => createAssociate(a, context.projectKey, this._storage)).filter((a) => a !== void 0);
|
|
1771
1778
|
resource.associates = newAssociates || void 0;
|
|
1772
1779
|
}
|
|
1780
|
+
removeAssociate(context, resource, { customer }) {
|
|
1781
|
+
resource.associates = resource.associates.filter((associate) => associate.customer.id !== customer.id);
|
|
1782
|
+
}
|
|
1783
|
+
changeAssociate(context, resource, { associate }) {
|
|
1784
|
+
const existingAssociateIndex = resource.associates.findIndex((a) => a.customer.id === associate.customer.id);
|
|
1785
|
+
if (existingAssociateIndex === -1) throw new Error(`Associate with customer id ${associate.customer.id} not found`);
|
|
1786
|
+
const newAssociate = createAssociate(associate, context.projectKey, this._storage);
|
|
1787
|
+
if (newAssociate) resource.associates[existingAssociateIndex] = newAssociate;
|
|
1788
|
+
}
|
|
1773
1789
|
setContactEmail(context, resource, { contactEmail }) {
|
|
1774
1790
|
resource.contactEmail = contactEmail;
|
|
1775
1791
|
}
|
|
@@ -1790,6 +1806,40 @@ var BusinessUnitUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
1790
1806
|
if (!resource.shippingAddressIds) resource.shippingAddressIds = [];
|
|
1791
1807
|
if (addressId) resource.shippingAddressIds.push(addressId);
|
|
1792
1808
|
}
|
|
1809
|
+
removeShippingAddressId(context, resource, { addressId }) {
|
|
1810
|
+
if (resource.shippingAddressIds) resource.shippingAddressIds = resource.shippingAddressIds.filter((id) => id !== addressId);
|
|
1811
|
+
if (resource.defaultShippingAddressId === addressId) resource.defaultShippingAddressId = void 0;
|
|
1812
|
+
}
|
|
1813
|
+
addBillingAddressId(context, resource, { addressId }) {
|
|
1814
|
+
if (!resource.billingAddressIds) resource.billingAddressIds = [];
|
|
1815
|
+
if (addressId) resource.billingAddressIds.push(addressId);
|
|
1816
|
+
}
|
|
1817
|
+
removeBillingAddressId(context, resource, { addressId }) {
|
|
1818
|
+
if (resource.billingAddressIds) resource.billingAddressIds = resource.billingAddressIds.filter((id) => id !== addressId);
|
|
1819
|
+
if (resource.defaultBillingAddressId === addressId) resource.defaultBillingAddressId = void 0;
|
|
1820
|
+
}
|
|
1821
|
+
setDefaultBillingAddress(context, resource, { addressId }) {
|
|
1822
|
+
resource.defaultBillingAddressId = addressId;
|
|
1823
|
+
}
|
|
1824
|
+
setCustomField(context, resource, { name, value }) {
|
|
1825
|
+
if (!resource.custom) throw new Error("Resource has no custom type");
|
|
1826
|
+
resource.custom.fields[name] = value;
|
|
1827
|
+
}
|
|
1828
|
+
setAddressCustomField(context, resource, { addressId, name, value }) {
|
|
1829
|
+
const address = resource.addresses.find((addr) => addr.id === addressId);
|
|
1830
|
+
if (!address) throw new Error(`Address with id ${addressId} not found`);
|
|
1831
|
+
if (!address.custom) throw new Error("Address has no custom type set. Use setAddressCustomType first.");
|
|
1832
|
+
address.custom.fields[name] = value;
|
|
1833
|
+
}
|
|
1834
|
+
setAddressCustomType(context, resource, { addressId, type, fields }) {
|
|
1835
|
+
const address = resource.addresses.find((addr) => addr.id === addressId);
|
|
1836
|
+
if (!address) throw new Error(`Address with id ${addressId} not found`);
|
|
1837
|
+
if (!type) address.custom = void 0;
|
|
1838
|
+
else address.custom = createCustomFields({
|
|
1839
|
+
type,
|
|
1840
|
+
fields
|
|
1841
|
+
}, context.projectKey, this._storage);
|
|
1842
|
+
}
|
|
1793
1843
|
removeAddress(context, resource, { addressId }) {
|
|
1794
1844
|
resource.addresses = resource.addresses.filter((addr) => addr.id !== addressId);
|
|
1795
1845
|
if (resource.shippingAddressIds) resource.shippingAddressIds = resource.shippingAddressIds.filter((id) => id !== addressId);
|
|
@@ -1874,7 +1924,7 @@ var CartDiscountRepository = class extends AbstractResourceRepository {
|
|
|
1874
1924
|
references: [],
|
|
1875
1925
|
target: draft.target,
|
|
1876
1926
|
requiresDiscountCode: draft.requiresDiscountCode || false,
|
|
1877
|
-
sortOrder: draft.sortOrder,
|
|
1927
|
+
sortOrder: draft.sortOrder ?? "0.1",
|
|
1878
1928
|
stackingMode: draft.stackingMode || "Stacking",
|
|
1879
1929
|
validFrom: draft.validFrom,
|
|
1880
1930
|
validUntil: draft.validUntil,
|
|
@@ -2439,7 +2489,8 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
2439
2489
|
lastModifiedAt: rest.lastModifiedAt,
|
|
2440
2490
|
customerId: customer.id,
|
|
2441
2491
|
expiresAt: expiresAt.toISOString(),
|
|
2442
|
-
value: token
|
|
2492
|
+
value: token,
|
|
2493
|
+
invalidateOlderTokens: request.invalidateOlderTokens || false
|
|
2443
2494
|
};
|
|
2444
2495
|
}
|
|
2445
2496
|
passwordReset(context, resetPassword) {
|
|
@@ -2475,7 +2526,8 @@ var CustomerRepository = class extends AbstractResourceRepository {
|
|
|
2475
2526
|
lastModifiedAt: rest.lastModifiedAt,
|
|
2476
2527
|
customerId: customer.id,
|
|
2477
2528
|
expiresAt: expiresAt.toISOString(),
|
|
2478
|
-
value: token
|
|
2529
|
+
value: token,
|
|
2530
|
+
invalidateOlderTokens: false
|
|
2479
2531
|
};
|
|
2480
2532
|
}
|
|
2481
2533
|
storeReferenceToStoreKeyReference(draftStores, projectKey) {
|
|
@@ -2616,6 +2668,42 @@ var DiscountCodeRepository = class extends AbstractResourceRepository {
|
|
|
2616
2668
|
}
|
|
2617
2669
|
};
|
|
2618
2670
|
|
|
2671
|
+
//#endregion
|
|
2672
|
+
//#region src/repositories/discount-group/actions.ts
|
|
2673
|
+
var DiscountGroupUpdateHandler = class extends AbstractUpdateHandler {
|
|
2674
|
+
setDescription(context, resource, { description }) {
|
|
2675
|
+
resource.description = description;
|
|
2676
|
+
}
|
|
2677
|
+
setKey(context, resource, { key }) {
|
|
2678
|
+
resource.key = key;
|
|
2679
|
+
}
|
|
2680
|
+
setName(context, resource, { name }) {
|
|
2681
|
+
resource.name = name;
|
|
2682
|
+
}
|
|
2683
|
+
setSortOrder(context, resource, { sortOrder }) {
|
|
2684
|
+
resource.sortOrder = sortOrder;
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
|
|
2688
|
+
//#endregion
|
|
2689
|
+
//#region src/repositories/discount-group/index.ts
|
|
2690
|
+
var DiscountGroupRepository = class extends AbstractResourceRepository {
|
|
2691
|
+
constructor(config) {
|
|
2692
|
+
super("discount-group", config);
|
|
2693
|
+
this.actions = new DiscountGroupUpdateHandler(config.storage);
|
|
2694
|
+
}
|
|
2695
|
+
create(context, draft) {
|
|
2696
|
+
const resource = {
|
|
2697
|
+
...getBaseResourceProperties(),
|
|
2698
|
+
description: draft.description,
|
|
2699
|
+
name: draft.name,
|
|
2700
|
+
key: draft.key,
|
|
2701
|
+
sortOrder: draft.sortOrder
|
|
2702
|
+
};
|
|
2703
|
+
return this.saveNew(context, resource);
|
|
2704
|
+
}
|
|
2705
|
+
};
|
|
2706
|
+
|
|
2619
2707
|
//#endregion
|
|
2620
2708
|
//#region src/lib/masking.ts
|
|
2621
2709
|
const maskSecretValue = (resource, path) => {
|
|
@@ -2934,6 +3022,37 @@ var PaymentUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
2934
3022
|
obj: stateObj
|
|
2935
3023
|
};
|
|
2936
3024
|
}
|
|
3025
|
+
setMethodInfo(context, resource, { paymentInterface, method, name, interfaceAccount, token }) {
|
|
3026
|
+
if (paymentInterface !== void 0) resource.paymentMethodInfo.paymentInterface = paymentInterface;
|
|
3027
|
+
if (method !== void 0) resource.paymentMethodInfo.method = method;
|
|
3028
|
+
if (name !== void 0) resource.paymentMethodInfo.name = name;
|
|
3029
|
+
if (interfaceAccount !== void 0) resource.paymentMethodInfo.interfaceAccount = interfaceAccount;
|
|
3030
|
+
if (token !== void 0) resource.paymentMethodInfo.token = token;
|
|
3031
|
+
}
|
|
3032
|
+
setMethodInfoCustomField(context, resource, { name, value }) {
|
|
3033
|
+
if (!resource.paymentMethodInfo.custom) throw new Error("PaymentMethodInfo has no custom field");
|
|
3034
|
+
resource.paymentMethodInfo.custom.fields[name] = value;
|
|
3035
|
+
}
|
|
3036
|
+
setMethodInfoCustomType(context, resource, { type, fields }) {
|
|
3037
|
+
if (!type) resource.paymentMethodInfo.custom = void 0;
|
|
3038
|
+
else {
|
|
3039
|
+
const resolvedType = this._storage.getByResourceIdentifier(context.projectKey, type);
|
|
3040
|
+
if (!resolvedType) throw new Error(`Type ${type} not found`);
|
|
3041
|
+
resource.paymentMethodInfo.custom = {
|
|
3042
|
+
type: {
|
|
3043
|
+
typeId: "type",
|
|
3044
|
+
id: resolvedType.id
|
|
3045
|
+
},
|
|
3046
|
+
fields: fields ?? {}
|
|
3047
|
+
};
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
setMethodInfoInterfaceAccount(_context, resource, { interfaceAccount }) {
|
|
3051
|
+
resource.paymentMethodInfo.interfaceAccount = interfaceAccount;
|
|
3052
|
+
}
|
|
3053
|
+
setMethodInfoToken(_context, resource, { token }) {
|
|
3054
|
+
resource.paymentMethodInfo.token = token;
|
|
3055
|
+
}
|
|
2937
3056
|
};
|
|
2938
3057
|
|
|
2939
3058
|
//#endregion
|
|
@@ -2948,7 +3067,10 @@ var PaymentRepository = class extends AbstractResourceRepository {
|
|
|
2948
3067
|
...getBaseResourceProperties(),
|
|
2949
3068
|
key: draft.key,
|
|
2950
3069
|
amountPlanned: createCentPrecisionMoney(draft.amountPlanned),
|
|
2951
|
-
paymentMethodInfo:
|
|
3070
|
+
paymentMethodInfo: {
|
|
3071
|
+
...draft.paymentMethodInfo,
|
|
3072
|
+
custom: void 0
|
|
3073
|
+
},
|
|
2952
3074
|
paymentStatus: draft.paymentStatus ? {
|
|
2953
3075
|
...draft.paymentStatus,
|
|
2954
3076
|
state: draft.paymentStatus.state ? getReferenceFromResourceIdentifier(draft.paymentStatus.state, context.projectKey, this._storage) : void 0
|
|
@@ -3984,6 +4106,7 @@ var ProductSearch = class {
|
|
|
3984
4106
|
metaDescription: obj.metaDescription,
|
|
3985
4107
|
slug: obj.slug,
|
|
3986
4108
|
categories: obj.categories,
|
|
4109
|
+
attributes: obj.attributes,
|
|
3987
4110
|
masterVariant: {
|
|
3988
4111
|
...obj.masterVariant,
|
|
3989
4112
|
availability: getVariantAvailability(obj.masterVariant.sku)
|
|
@@ -4448,6 +4571,7 @@ var ProductRepository = class extends AbstractResourceRepository {
|
|
|
4448
4571
|
name: draft.name,
|
|
4449
4572
|
slug: draft.slug,
|
|
4450
4573
|
description: draft.description,
|
|
4574
|
+
attributes: draft.attributes ?? [],
|
|
4451
4575
|
categories: categoryReferences,
|
|
4452
4576
|
masterVariant: variantFromDraft(context, this._storage, 1, draft.masterVariant),
|
|
4453
4577
|
variants: draft.variants?.map((variant, index) => variantFromDraft(context, this._storage, index + 2, variant)) ?? [],
|
|
@@ -4859,6 +4983,7 @@ var ProductProjectionSearch = class {
|
|
|
4859
4983
|
return {
|
|
4860
4984
|
id: product.id,
|
|
4861
4985
|
createdAt: product.createdAt,
|
|
4986
|
+
attributes: obj.attributes,
|
|
4862
4987
|
lastModifiedAt: product.lastModifiedAt,
|
|
4863
4988
|
version: product.version,
|
|
4864
4989
|
name: obj.name,
|
|
@@ -5091,6 +5216,7 @@ var ProductTypeRepository = class extends AbstractResourceRepository {
|
|
|
5091
5216
|
};
|
|
5092
5217
|
const attributeDefinitionFromAttributeDefinitionDraft = (_context, draft) => ({
|
|
5093
5218
|
...draft,
|
|
5219
|
+
level: draft.level ?? "Variant",
|
|
5094
5220
|
attributeConstraint: draft.attributeConstraint ?? "None",
|
|
5095
5221
|
inputHint: draft.inputHint ?? "SingleLine",
|
|
5096
5222
|
inputTip: draft.inputTip && Object.keys(draft.inputTip).length > 0 ? draft.inputTip : void 0,
|
|
@@ -5299,6 +5425,7 @@ var QuoteRepository = class extends AbstractResourceRepository {
|
|
|
5299
5425
|
typeId: "staged-quote",
|
|
5300
5426
|
id: staged.id
|
|
5301
5427
|
},
|
|
5428
|
+
priceRoundingMode: cart.priceRoundingMode,
|
|
5302
5429
|
totalPrice: cart.totalPrice,
|
|
5303
5430
|
taxedPrice: cart.taxedPrice,
|
|
5304
5431
|
taxMode: cart.taxMode,
|
|
@@ -5373,6 +5500,152 @@ var StagedQuoteRepository = class extends AbstractResourceRepository {
|
|
|
5373
5500
|
}
|
|
5374
5501
|
};
|
|
5375
5502
|
|
|
5503
|
+
//#endregion
|
|
5504
|
+
//#region src/repositories/recurrence-policy/actions.ts
|
|
5505
|
+
var RecurrencePolicyUpdateHandler = class extends AbstractUpdateHandler {
|
|
5506
|
+
setKey(context, resource, { key }) {
|
|
5507
|
+
if (key) resource.key = key;
|
|
5508
|
+
}
|
|
5509
|
+
setDescription(context, resource, { description }) {
|
|
5510
|
+
resource.description = description;
|
|
5511
|
+
}
|
|
5512
|
+
setName(context, resource, { name }) {
|
|
5513
|
+
resource.name = name;
|
|
5514
|
+
}
|
|
5515
|
+
setSchedule(context, resource, { schedule }) {
|
|
5516
|
+
resource.schedule = schedule;
|
|
5517
|
+
}
|
|
5518
|
+
};
|
|
5519
|
+
|
|
5520
|
+
//#endregion
|
|
5521
|
+
//#region src/repositories/recurrence-policy/index.ts
|
|
5522
|
+
var RecurrencePolicyRepository = class extends AbstractResourceRepository {
|
|
5523
|
+
constructor(config) {
|
|
5524
|
+
super("recurrence-policy", config);
|
|
5525
|
+
this.actions = new RecurrencePolicyUpdateHandler(config.storage);
|
|
5526
|
+
}
|
|
5527
|
+
create(context, draft) {
|
|
5528
|
+
const resource = {
|
|
5529
|
+
...getBaseResourceProperties(),
|
|
5530
|
+
key: draft.key,
|
|
5531
|
+
name: draft.name,
|
|
5532
|
+
description: draft.description,
|
|
5533
|
+
schedule: draft.schedule
|
|
5534
|
+
};
|
|
5535
|
+
return this.saveNew(context, resource);
|
|
5536
|
+
}
|
|
5537
|
+
};
|
|
5538
|
+
|
|
5539
|
+
//#endregion
|
|
5540
|
+
//#region src/repositories/recurring-order/actions.ts
|
|
5541
|
+
var RecurringOrderUpdateHandler = class extends AbstractUpdateHandler {
|
|
5542
|
+
setCustomField(context, resource, { name, value }) {
|
|
5543
|
+
if (!resource.custom) throw new Error("Resource has no custom field");
|
|
5544
|
+
if (value === null) delete resource.custom.fields[name];
|
|
5545
|
+
else resource.custom.fields[name] = value;
|
|
5546
|
+
}
|
|
5547
|
+
setCustomType(context, resource, { type, fields }) {
|
|
5548
|
+
if (!type) resource.custom = void 0;
|
|
5549
|
+
else {
|
|
5550
|
+
const resolvedType = this._storage.getByResourceIdentifier(context.projectKey, type);
|
|
5551
|
+
if (!resolvedType) throw new Error(`Type ${type} not found`);
|
|
5552
|
+
resource.custom = {
|
|
5553
|
+
type: {
|
|
5554
|
+
typeId: "type",
|
|
5555
|
+
id: resolvedType.id
|
|
5556
|
+
},
|
|
5557
|
+
fields: fields || {}
|
|
5558
|
+
};
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
setExpiresAt(context, resource, { expiresAt }) {
|
|
5562
|
+
resource.expiresAt = expiresAt;
|
|
5563
|
+
}
|
|
5564
|
+
setKey(context, resource, { key }) {
|
|
5565
|
+
resource.key = key;
|
|
5566
|
+
}
|
|
5567
|
+
setOrderSkipConfiguration(context, resource, { skipConfiguration, updatedExpiresAt }) {
|
|
5568
|
+
if (skipConfiguration) resource.skipConfiguration = {
|
|
5569
|
+
type: skipConfiguration.type,
|
|
5570
|
+
totalToSkip: skipConfiguration.totalToSkip,
|
|
5571
|
+
skipped: 0,
|
|
5572
|
+
lastSkippedAt: void 0
|
|
5573
|
+
};
|
|
5574
|
+
else resource.skipConfiguration = void 0;
|
|
5575
|
+
if (updatedExpiresAt !== void 0) resource.expiresAt = updatedExpiresAt;
|
|
5576
|
+
}
|
|
5577
|
+
setSchedule(context, resource, { recurrencePolicy }) {
|
|
5578
|
+
resource.schedule = {
|
|
5579
|
+
...resource.schedule,
|
|
5580
|
+
...recurrencePolicy
|
|
5581
|
+
};
|
|
5582
|
+
}
|
|
5583
|
+
setStartsAt(context, resource, { startsAt }) {
|
|
5584
|
+
resource.startsAt = startsAt;
|
|
5585
|
+
}
|
|
5586
|
+
setRecurringOrderState(context, resource, { recurringOrderState }) {
|
|
5587
|
+
switch (recurringOrderState.type) {
|
|
5588
|
+
case "active":
|
|
5589
|
+
resource.recurringOrderState = "Active";
|
|
5590
|
+
if (recurringOrderState.resumesAt) resource.resumesAt = recurringOrderState.resumesAt;
|
|
5591
|
+
break;
|
|
5592
|
+
case "canceled":
|
|
5593
|
+
resource.recurringOrderState = "Canceled";
|
|
5594
|
+
break;
|
|
5595
|
+
case "expired":
|
|
5596
|
+
resource.recurringOrderState = "Expired";
|
|
5597
|
+
break;
|
|
5598
|
+
case "paused":
|
|
5599
|
+
resource.recurringOrderState = "Paused";
|
|
5600
|
+
break;
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
transitionState(context, resource, { state, force }) {
|
|
5604
|
+
resource.state = {
|
|
5605
|
+
typeId: "state",
|
|
5606
|
+
id: state.id
|
|
5607
|
+
};
|
|
5608
|
+
}
|
|
5609
|
+
};
|
|
5610
|
+
|
|
5611
|
+
//#endregion
|
|
5612
|
+
//#region src/repositories/recurring-order/index.ts
|
|
5613
|
+
var RecurringOrderRepository = class extends AbstractResourceRepository {
|
|
5614
|
+
constructor(config) {
|
|
5615
|
+
super("recurring-order", config);
|
|
5616
|
+
this.actions = new RecurringOrderUpdateHandler(config.storage);
|
|
5617
|
+
}
|
|
5618
|
+
create(context, draft) {
|
|
5619
|
+
assert(draft.cart, "draft.cart is missing");
|
|
5620
|
+
const orderRepo = new OrderRepository(this.config);
|
|
5621
|
+
const initialOrder = orderRepo.createFromCart(context, {
|
|
5622
|
+
id: draft.cart.id,
|
|
5623
|
+
typeId: "cart"
|
|
5624
|
+
});
|
|
5625
|
+
const resource = {
|
|
5626
|
+
...getBaseResourceProperties(),
|
|
5627
|
+
key: draft.key,
|
|
5628
|
+
cart: {
|
|
5629
|
+
typeId: "cart",
|
|
5630
|
+
id: draft.cart.id
|
|
5631
|
+
},
|
|
5632
|
+
originOrder: {
|
|
5633
|
+
typeId: "order",
|
|
5634
|
+
id: initialOrder.id
|
|
5635
|
+
},
|
|
5636
|
+
startsAt: draft.startsAt,
|
|
5637
|
+
expiresAt: draft.expiresAt,
|
|
5638
|
+
recurringOrderState: "Active",
|
|
5639
|
+
schedule: {
|
|
5640
|
+
type: "standard",
|
|
5641
|
+
intervalUnit: "month",
|
|
5642
|
+
value: 1
|
|
5643
|
+
}
|
|
5644
|
+
};
|
|
5645
|
+
return this.saveNew(context, resource);
|
|
5646
|
+
}
|
|
5647
|
+
};
|
|
5648
|
+
|
|
5376
5649
|
//#endregion
|
|
5377
5650
|
//#region src/repositories/review.ts
|
|
5378
5651
|
var ReviewRepository = class extends AbstractResourceRepository {
|
|
@@ -5592,7 +5865,8 @@ var ShoppingListUpdateHandler = class extends AbstractUpdateHandler {
|
|
|
5592
5865
|
productType: product.productType,
|
|
5593
5866
|
name: product.masterData.current.name,
|
|
5594
5867
|
variantId: varId,
|
|
5595
|
-
quantity
|
|
5868
|
+
quantity,
|
|
5869
|
+
published: Boolean(product.masterData.current)
|
|
5596
5870
|
});
|
|
5597
5871
|
}
|
|
5598
5872
|
changeLineItemQuantity(context, resource, { lineItemId, lineItemKey, quantity }) {
|
|
@@ -5712,6 +5986,7 @@ var ShoppingListRepository = class extends AbstractResourceRepository {
|
|
|
5712
5986
|
productId: draftLineItem.productId ?? "",
|
|
5713
5987
|
name: {},
|
|
5714
5988
|
variantId,
|
|
5989
|
+
published: true,
|
|
5715
5990
|
quantity: draftLineItem.quantity ?? 1,
|
|
5716
5991
|
productType: {
|
|
5717
5992
|
typeId: "product-type",
|
|
@@ -6113,6 +6388,7 @@ const createRepositories = (config) => ({
|
|
|
6113
6388
|
channel: new ChannelRepository(config),
|
|
6114
6389
|
"customer-group": new CustomerGroupRepository(config),
|
|
6115
6390
|
"discount-code": new DiscountCodeRepository(config),
|
|
6391
|
+
"discount-group": new DiscountGroupRepository(config),
|
|
6116
6392
|
extension: new ExtensionRepository(config),
|
|
6117
6393
|
"inventory-entry": new InventoryEntryRepository(config),
|
|
6118
6394
|
"key-value-document": new CustomObjectRepository(config),
|
|
@@ -6131,6 +6407,8 @@ const createRepositories = (config) => ({
|
|
|
6131
6407
|
"product-selection": new ProductSelectionRepository(config),
|
|
6132
6408
|
"product-tailoring": new ProductTailoringRepository(config),
|
|
6133
6409
|
project: new ProjectRepository(config),
|
|
6410
|
+
"recurring-order": new RecurringOrderRepository(config),
|
|
6411
|
+
"recurrence-policy": new RecurrencePolicyRepository(config),
|
|
6134
6412
|
review: new ReviewRepository(config),
|
|
6135
6413
|
quote: new QuoteRepository(config),
|
|
6136
6414
|
"quote-request": new QuoteRequestRepository(config),
|
|
@@ -6622,6 +6900,19 @@ var DiscountCodeService = class extends AbstractService {
|
|
|
6622
6900
|
}
|
|
6623
6901
|
};
|
|
6624
6902
|
|
|
6903
|
+
//#endregion
|
|
6904
|
+
//#region src/services/discount-group.ts
|
|
6905
|
+
var DiscountGroupService = class extends AbstractService {
|
|
6906
|
+
repository;
|
|
6907
|
+
constructor(parent, repository) {
|
|
6908
|
+
super(parent);
|
|
6909
|
+
this.repository = repository;
|
|
6910
|
+
}
|
|
6911
|
+
getBasePath() {
|
|
6912
|
+
return "discount-groups";
|
|
6913
|
+
}
|
|
6914
|
+
};
|
|
6915
|
+
|
|
6625
6916
|
//#endregion
|
|
6626
6917
|
//#region src/services/extension.ts
|
|
6627
6918
|
var ExtensionServices = class extends AbstractService {
|
|
@@ -7053,6 +7344,32 @@ var StagedQuoteService = class extends AbstractService {
|
|
|
7053
7344
|
}
|
|
7054
7345
|
};
|
|
7055
7346
|
|
|
7347
|
+
//#endregion
|
|
7348
|
+
//#region src/services/recurrence-policy.ts
|
|
7349
|
+
var RecurrencePolicyService = class extends AbstractService {
|
|
7350
|
+
repository;
|
|
7351
|
+
constructor(parent, repository) {
|
|
7352
|
+
super(parent);
|
|
7353
|
+
this.repository = repository;
|
|
7354
|
+
}
|
|
7355
|
+
getBasePath() {
|
|
7356
|
+
return "recurrence-policies";
|
|
7357
|
+
}
|
|
7358
|
+
};
|
|
7359
|
+
|
|
7360
|
+
//#endregion
|
|
7361
|
+
//#region src/services/recurring-order.ts
|
|
7362
|
+
var RecurringOrderService = class extends AbstractService {
|
|
7363
|
+
repository;
|
|
7364
|
+
constructor(parent, repository) {
|
|
7365
|
+
super(parent);
|
|
7366
|
+
this.repository = repository;
|
|
7367
|
+
}
|
|
7368
|
+
getBasePath() {
|
|
7369
|
+
return "recurring-orders";
|
|
7370
|
+
}
|
|
7371
|
+
};
|
|
7372
|
+
|
|
7056
7373
|
//#endregion
|
|
7057
7374
|
//#region src/services/reviews.ts
|
|
7058
7375
|
var ReviewService = class extends AbstractService {
|
|
@@ -7210,6 +7527,7 @@ const createServices = (router, repos) => ({
|
|
|
7210
7527
|
channel: new ChannelService(router, repos.channel),
|
|
7211
7528
|
"customer-group": new CustomerGroupService(router, repos["customer-group"]),
|
|
7212
7529
|
"discount-code": new DiscountCodeService(router, repos["discount-code"]),
|
|
7530
|
+
"discount-group": new DiscountGroupService(router, repos["discount-group"]),
|
|
7213
7531
|
extension: new ExtensionServices(router, repos.extension),
|
|
7214
7532
|
"inventory-entry": new InventoryEntryService(router, repos["inventory-entry"]),
|
|
7215
7533
|
"key-value-document": new CustomObjectService(router, repos["key-value-document"]),
|
|
@@ -7230,6 +7548,8 @@ const createServices = (router, repos) => ({
|
|
|
7230
7548
|
"product-selection": new ProductSelectionService(router, repos["product-selection"]),
|
|
7231
7549
|
quotes: new QuoteService(router, repos.quote),
|
|
7232
7550
|
"quote-request": new QuoteRequestService(router, repos["quote-request"]),
|
|
7551
|
+
"recurrence-policy": new RecurrencePolicyService(router, repos["recurrence-policy"]),
|
|
7552
|
+
"recurring-order": new RecurringOrderService(router, repos["recurring-order"]),
|
|
7233
7553
|
reviews: new ReviewService(router, repos.review),
|
|
7234
7554
|
"shopping-list": new ShoppingListService(router, repos["shopping-list"]),
|
|
7235
7555
|
"staged-quote": new StagedQuoteService(router, repos["staged-quote"]),
|
|
@@ -7354,6 +7674,7 @@ var InMemoryStorage = class extends AbstractStorage {
|
|
|
7354
7674
|
customer: new Map(),
|
|
7355
7675
|
"customer-group": new Map(),
|
|
7356
7676
|
"discount-code": new Map(),
|
|
7677
|
+
"discount-group": new Map(),
|
|
7357
7678
|
extension: new Map(),
|
|
7358
7679
|
"inventory-entry": new Map(),
|
|
7359
7680
|
"key-value-document": new Map(),
|
|
@@ -7368,6 +7689,8 @@ var InMemoryStorage = class extends AbstractStorage {
|
|
|
7368
7689
|
"product-type": new Map(),
|
|
7369
7690
|
"product-projection": new Map(),
|
|
7370
7691
|
"product-tailoring": new Map(),
|
|
7692
|
+
"recurrence-policy": new Map(),
|
|
7693
|
+
"recurring-order": new Map(),
|
|
7371
7694
|
review: new Map(),
|
|
7372
7695
|
"shipping-method": new Map(),
|
|
7373
7696
|
"staged-quote": new Map(),
|