@reactionary/feeds 0.10.54 → 0.10.55
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/cli.cjs +127 -20
- package/package.json +9 -9
package/cli.cjs
CHANGED
|
@@ -37422,7 +37422,7 @@ var init_profile_model = __esm({
|
|
|
37422
37422
|
});
|
|
37423
37423
|
|
|
37424
37424
|
// packages/core/src/schemas/models/shipping-method.model.ts
|
|
37425
|
-
var ShippingFulfillmentTypeSchema, ShippingProtocolDataSchema, PickupPointSchema, ShippingMethodSchema, ShippingInstructionSchema;
|
|
37425
|
+
var ShippingFulfillmentTypeSchema, ShippingProtocolDataSchema, SHIPPING_PROTOCOL_DATA_KEYS, PickupPointSchema, ShippingMethodSchema, ShippingInstructionSchema;
|
|
37426
37426
|
var init_shipping_method_model = __esm({
|
|
37427
37427
|
"packages/core/src/schemas/models/shipping-method.model.ts"() {
|
|
37428
37428
|
"use strict";
|
|
@@ -37436,6 +37436,13 @@ var init_shipping_method_model = __esm({
|
|
|
37436
37436
|
key: string2().meta({ description: 'The protocol-specific key, e.g. "timeSlotId".' }),
|
|
37437
37437
|
value: union([string2(), record(string2(), json())]).meta({ description: "The protocol-specific value: either a plain string, or a JSON-serializable object for richer structures." })
|
|
37438
37438
|
});
|
|
37439
|
+
SHIPPING_PROTOCOL_DATA_KEYS = {
|
|
37440
|
+
/**
|
|
37441
|
+
* The identifier (Store.identifier.key) of the brand's own store an
|
|
37442
|
+
* in-store pickup (BOPIS) shipping method is fulfilled from.
|
|
37443
|
+
*/
|
|
37444
|
+
pickupStore: "pickup_store"
|
|
37445
|
+
};
|
|
37439
37446
|
PickupPointSchema = looseObject({
|
|
37440
37447
|
identifier: object({
|
|
37441
37448
|
key: string2()
|
|
@@ -37457,7 +37464,7 @@ var init_shipping_method_model = __esm({
|
|
|
37457
37464
|
deliveryTime: string2(),
|
|
37458
37465
|
carrier: string2().optional(),
|
|
37459
37466
|
fulfillmentType: ShippingFulfillmentTypeSchema.optional().meta({ description: `How this shipping method fulfills the order: "delivery" for shipment to an address (including third-party carrier service points selected via the shipping instruction's pickupPoint), "pickup" for collection at one of the brand's own stores (BOPIS). When absent, "delivery" can be assumed.` }),
|
|
37460
|
-
protocolData: array(ShippingProtocolDataSchema).optional().meta({ description:
|
|
37467
|
+
protocolData: array(ShippingProtocolDataSchema).optional().meta({ description: `Additional provider-populated, protocol-specific data for this shipping method, e.g. available pickup time slots. Conventional keys (see SHIPPING_PROTOCOL_DATA_KEYS) include "pickup_store": the identifier of the brand's own store a pickup method is fulfilled from.` })
|
|
37461
37468
|
});
|
|
37462
37469
|
ShippingInstructionSchema = BaseModelSchema.extend({
|
|
37463
37470
|
shippingMethod: ShippingMethodIdentifierSchema,
|
|
@@ -159542,17 +159549,17 @@ var init_checkout_capability5 = __esm({
|
|
|
159542
159549
|
*
|
|
159543
159550
|
* example: this.includedFields = [includedFields, '+discounts.*'].join(',');
|
|
159544
159551
|
*/
|
|
159545
|
-
includedFields = ["+items.*", "+order.id", "+order.display_id", "+order.custom_display_id"].join(",");
|
|
159552
|
+
includedFields = ["+items.*", "+order.id", "+order.display_id", "+order.custom_display_id", "+shipping_methods.data"].join(",");
|
|
159546
159553
|
/**
|
|
159547
159554
|
* This controls which fields are requested for the cart's shipping options.
|
|
159548
159555
|
* You can override this in a subclass to add more fields as needed.
|
|
159549
159556
|
*
|
|
159550
159557
|
* The service zone's fulfillment set tells us whether an option is in-store
|
|
159551
|
-
* pickup (BOPIS) or a delivery, and the option
|
|
159552
|
-
*
|
|
159553
|
-
* protocolData.
|
|
159558
|
+
* pickup (BOPIS) or a delivery, and the option data is the fulfillment
|
|
159559
|
+
* provider's payload (e.g. nShift option/carrier ids) that is mapped to the
|
|
159560
|
+
* shipping method's protocolData.
|
|
159554
159561
|
*/
|
|
159555
|
-
shippingOptionFields = ["*service_zone.fulfillment_set", "+
|
|
159562
|
+
shippingOptionFields = ["*service_zone.fulfillment_set", "+data"].join(",");
|
|
159556
159563
|
initiateCheckoutForCartPayload(payload) {
|
|
159557
159564
|
return {
|
|
159558
159565
|
billing_address: payload.billingAddress ? this.mapAddressToStoreAddress(payload.billingAddress) : void 0,
|
|
@@ -159757,12 +159764,19 @@ var init_checkout_capability5 = __esm({
|
|
|
159757
159764
|
throw new Error("Method not implemented.");
|
|
159758
159765
|
}
|
|
159759
159766
|
setShippingInstructionPayload(payload) {
|
|
159767
|
+
const data = {
|
|
159768
|
+
consent_for_unattended_delivery: payload.shippingInstruction.consentForUnattendedDelivery + "",
|
|
159769
|
+
instructions: payload.shippingInstruction.instructions || ""
|
|
159770
|
+
};
|
|
159771
|
+
for (const entry of payload.shippingInstruction.protocolData ?? []) {
|
|
159772
|
+
data[entry.key] = entry.value;
|
|
159773
|
+
}
|
|
159774
|
+
if (payload.shippingInstruction.pickupPoint) {
|
|
159775
|
+
data["pickup_point"] = payload.shippingInstruction.pickupPoint;
|
|
159776
|
+
}
|
|
159760
159777
|
return {
|
|
159761
159778
|
option_id: payload.shippingInstruction.shippingMethod.key,
|
|
159762
|
-
data
|
|
159763
|
-
consent_for_unattended_delivery: payload.shippingInstruction.consentForUnattendedDelivery + "",
|
|
159764
|
-
instructions: payload.shippingInstruction.instructions || ""
|
|
159765
|
-
}
|
|
159779
|
+
data
|
|
159766
159780
|
};
|
|
159767
159781
|
}
|
|
159768
159782
|
/**
|
|
@@ -162658,7 +162672,7 @@ var init_checkout_factory5 = __esm({
|
|
|
162658
162672
|
instructions = sm.data["instructions"] != null ? String(sm.data["instructions"]) : "";
|
|
162659
162673
|
consentForUnattendedDelivery = sm.data["consent_for_unattended_delivery"] === "true";
|
|
162660
162674
|
pickupStore = sm.data["pickup_store"] != null && sm.data["pickup_store"] !== "" ? String(sm.data["pickup_store"]) : void 0;
|
|
162661
|
-
protocolData = this.
|
|
162675
|
+
protocolData = this.parseInstructionProtocolData(sm.data);
|
|
162662
162676
|
}
|
|
162663
162677
|
if (!pickupPoint) {
|
|
162664
162678
|
pickupPoint = backupPickupPoint || "";
|
|
@@ -162746,11 +162760,46 @@ var init_checkout_factory5 = __esm({
|
|
|
162746
162760
|
currency: data.calculated_price.currency_code?.toUpperCase() || _context.languageContext.currencyCode
|
|
162747
162761
|
}),
|
|
162748
162762
|
deliveryTime: "",
|
|
162763
|
+
carrier: this.parseShippingMethodCarrier(_context, data),
|
|
162749
162764
|
fulfillmentType: this.parseFulfillmentType(_context, data),
|
|
162750
|
-
protocolData: this.
|
|
162765
|
+
protocolData: this.mergeShippingMethodProtocolData(
|
|
162766
|
+
this.parseShippingMethodProtocolData(_context, data),
|
|
162767
|
+
this.parseShippingMethodStoreReference(_context, data)
|
|
162768
|
+
)
|
|
162751
162769
|
};
|
|
162752
162770
|
return this.shippingMethodSchema.parse(sm);
|
|
162753
162771
|
}
|
|
162772
|
+
/**
|
|
162773
|
+
* Appends a conventional entry to the provider-derived protocol data,
|
|
162774
|
+
* unless the provider data already carries the same key (explicit provider
|
|
162775
|
+
* data wins).
|
|
162776
|
+
*/
|
|
162777
|
+
mergeShippingMethodProtocolData(protocolData, entry) {
|
|
162778
|
+
if (!entry) {
|
|
162779
|
+
return protocolData;
|
|
162780
|
+
}
|
|
162781
|
+
if ((protocolData ?? []).some((existing) => existing.key === entry.key)) {
|
|
162782
|
+
return protocolData;
|
|
162783
|
+
}
|
|
162784
|
+
return [...protocolData ?? [], entry];
|
|
162785
|
+
}
|
|
162786
|
+
/**
|
|
162787
|
+
* Extension point emitting the conventional "pickup_store" protocol data
|
|
162788
|
+
* entry for in-store pickup options: the stock location id of the service
|
|
162789
|
+
* zone's fulfillment set, which equals the store capability's
|
|
162790
|
+
* Store.identifier.key. Delivery options also carry a location (the
|
|
162791
|
+
* warehouse), so the entry is emitted for pickup options only.
|
|
162792
|
+
*/
|
|
162793
|
+
parseShippingMethodStoreReference(_context, data) {
|
|
162794
|
+
if (this.parseFulfillmentType(_context, data) !== "pickup") {
|
|
162795
|
+
return void 0;
|
|
162796
|
+
}
|
|
162797
|
+
const locationId = data.service_zone?.fulfillment_set?.location?.id;
|
|
162798
|
+
if (!locationId) {
|
|
162799
|
+
return void 0;
|
|
162800
|
+
}
|
|
162801
|
+
return { key: SHIPPING_PROTOCOL_DATA_KEYS.pickupStore, value: locationId };
|
|
162802
|
+
}
|
|
162754
162803
|
/**
|
|
162755
162804
|
* Extension point to control how a Medusa shipping option maps to the core
|
|
162756
162805
|
* fulfillment type. A shipping option belonging to a fulfillment set of type
|
|
@@ -162760,18 +162809,33 @@ var init_checkout_factory5 = __esm({
|
|
|
162760
162809
|
return data.service_zone?.fulfillment_set?.type === "pickup" ? "pickup" : "delivery";
|
|
162761
162810
|
}
|
|
162762
162811
|
/**
|
|
162763
|
-
* Extension point mapping a Medusa shipping option's
|
|
162764
|
-
*
|
|
162765
|
-
*
|
|
162766
|
-
* client. String and JSON-object values are kept as-is, other
|
|
162767
|
-
* are stringified, and arrays/null entries are skipped.
|
|
162812
|
+
* Extension point mapping a Medusa shipping option's `data` - the payload
|
|
162813
|
+
* the fulfillment provider works with (e.g. nShift's option/carrier ids) -
|
|
162814
|
+
* to the shipping method's protocolData, so provider-protocol data reaches
|
|
162815
|
+
* the client. String and JSON-object values are kept as-is, other
|
|
162816
|
+
* primitives are stringified, and arrays/null entries are skipped.
|
|
162817
|
+
*
|
|
162818
|
+
* Option `metadata` is deliberately NOT mapped: it is merchant free-form
|
|
162819
|
+
* annotation, not protocol data. Override this hook to surface it.
|
|
162768
162820
|
*/
|
|
162769
162821
|
parseShippingMethodProtocolData(_context, data) {
|
|
162770
|
-
if (!data.
|
|
162822
|
+
if (!data.data) {
|
|
162771
162823
|
return void 0;
|
|
162772
162824
|
}
|
|
162825
|
+
const entries = this.convertToProtocolDataEntries(data.data);
|
|
162826
|
+
return entries.length > 0 ? entries : void 0;
|
|
162827
|
+
}
|
|
162828
|
+
/**
|
|
162829
|
+
* Converts a Medusa key-value record into protocol data entries: string and
|
|
162830
|
+
* JSON-object values are kept as-is, other primitives are stringified, and
|
|
162831
|
+
* arrays/null entries are skipped. Keys listed in skipKeys are left out.
|
|
162832
|
+
*/
|
|
162833
|
+
convertToProtocolDataEntries(record2, skipKeys = []) {
|
|
162773
162834
|
const entries = [];
|
|
162774
|
-
for (const [key, value] of Object.entries(
|
|
162835
|
+
for (const [key, value] of Object.entries(record2)) {
|
|
162836
|
+
if (skipKeys.includes(key)) {
|
|
162837
|
+
continue;
|
|
162838
|
+
}
|
|
162775
162839
|
if (typeof value === "string") {
|
|
162776
162840
|
entries.push({ key, value });
|
|
162777
162841
|
} else if (typeof value === "number" || typeof value === "boolean") {
|
|
@@ -162780,6 +162844,49 @@ var init_checkout_factory5 = __esm({
|
|
|
162780
162844
|
entries.push({ key, value });
|
|
162781
162845
|
}
|
|
162782
162846
|
}
|
|
162847
|
+
return entries;
|
|
162848
|
+
}
|
|
162849
|
+
/**
|
|
162850
|
+
* Extension point resolving the carrier of a shipping option from its
|
|
162851
|
+
* provider data (e.g. nShift's carrier_id), when present.
|
|
162852
|
+
*/
|
|
162853
|
+
parseShippingMethodCarrier(_context, data) {
|
|
162854
|
+
const carrierId = data.data?.["carrier_id"];
|
|
162855
|
+
return typeof carrierId === "string" && carrierId.length > 0 ? carrierId : void 0;
|
|
162856
|
+
}
|
|
162857
|
+
/**
|
|
162858
|
+
* The persisted shipping method data keys that are NOT surfaced as
|
|
162859
|
+
* instruction protocol data: keys already represented as first-class
|
|
162860
|
+
* instruction fields, the legacy JSON blob, and provider-side values that
|
|
162861
|
+
* would mislead (nShift's data.price is not the charged amount).
|
|
162862
|
+
*/
|
|
162863
|
+
instructionProtocolDataSkipKeys = [
|
|
162864
|
+
"pickup_store",
|
|
162865
|
+
"pickup_point",
|
|
162866
|
+
"instructions",
|
|
162867
|
+
"consent_for_unattended_delivery",
|
|
162868
|
+
"shipping_protocol_data",
|
|
162869
|
+
"price",
|
|
162870
|
+
"currency_code"
|
|
162871
|
+
];
|
|
162872
|
+
/**
|
|
162873
|
+
* Builds the shipping instruction's protocolData from the persisted
|
|
162874
|
+
* shipping method data: the provider payload enriched by the backend (e.g.
|
|
162875
|
+
* nShift's session_id, carrier ids and optional delivery_time) merged with
|
|
162876
|
+
* whatever the client sent when setting the instruction. First-class and
|
|
162877
|
+
* misleading keys are skipped; the legacy shipping_protocol_data JSON blob
|
|
162878
|
+
* still contributes entries whose keys are not already present.
|
|
162879
|
+
*/
|
|
162880
|
+
parseInstructionProtocolData(smData) {
|
|
162881
|
+
const entries = this.convertToProtocolDataEntries(
|
|
162882
|
+
smData,
|
|
162883
|
+
this.instructionProtocolDataSkipKeys
|
|
162884
|
+
);
|
|
162885
|
+
for (const legacyEntry of this.parseShippingProtocolData(smData["shipping_protocol_data"]) ?? []) {
|
|
162886
|
+
if (!entries.some((entry) => entry.key === legacyEntry.key)) {
|
|
162887
|
+
entries.push(legacyEntry);
|
|
162888
|
+
}
|
|
162889
|
+
}
|
|
162783
162890
|
return entries.length > 0 ? entries : void 0;
|
|
162784
162891
|
}
|
|
162785
162892
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/feeds",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.55",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"url": "git+https://github.com/Solteq/reactionary.git"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@reactionary/algolia": "0.10.
|
|
16
|
-
"@reactionary/commercetools": "0.10.
|
|
17
|
-
"@reactionary/core": "0.10.
|
|
18
|
-
"@reactionary/fake": "0.10.
|
|
19
|
-
"@reactionary/magento": "0.10.
|
|
20
|
-
"@reactionary/medusa": "0.10.
|
|
21
|
-
"@reactionary/meilisearch": "0.10.
|
|
22
|
-
"@reactionary/unomi": "0.10.
|
|
15
|
+
"@reactionary/algolia": "0.10.55",
|
|
16
|
+
"@reactionary/commercetools": "0.10.55",
|
|
17
|
+
"@reactionary/core": "0.10.55",
|
|
18
|
+
"@reactionary/fake": "0.10.55",
|
|
19
|
+
"@reactionary/magento": "0.10.55",
|
|
20
|
+
"@reactionary/medusa": "0.10.55",
|
|
21
|
+
"@reactionary/meilisearch": "0.10.55",
|
|
22
|
+
"@reactionary/unomi": "0.10.55",
|
|
23
23
|
"commander": "^15.0.0",
|
|
24
24
|
"dotenv": "^17.2.2",
|
|
25
25
|
"sitemap": "^9.0.1",
|