@medusajs/core-flows 0.0.2-next-20231124140416
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/definition/cart/create-cart.d.ts +9 -0
- package/dist/definition/cart/create-cart.js +148 -0
- package/dist/definition/cart/create-cart.js.map +1 -0
- package/dist/definition/cart/index.d.ts +1 -0
- package/dist/definition/cart/index.js +18 -0
- package/dist/definition/cart/index.js.map +1 -0
- package/dist/definition/index.d.ts +4 -0
- package/dist/definition/index.js +21 -0
- package/dist/definition/index.js.map +1 -0
- package/dist/definition/inventory/create-inventory-item.d.ts +14 -0
- package/dist/definition/inventory/create-inventory-item.js +41 -0
- package/dist/definition/inventory/create-inventory-item.js.map +1 -0
- package/dist/definition/inventory/index.d.ts +1 -0
- package/dist/definition/inventory/index.js +18 -0
- package/dist/definition/inventory/index.js.map +1 -0
- package/dist/definition/price-list/create-price-lists.d.ts +13 -0
- package/dist/definition/price-list/create-price-lists.js +55 -0
- package/dist/definition/price-list/create-price-lists.js.map +1 -0
- package/dist/definition/price-list/index.d.ts +6 -0
- package/dist/definition/price-list/index.js +23 -0
- package/dist/definition/price-list/index.js.map +1 -0
- package/dist/definition/price-list/remove-price-list-prices.d.ts +11 -0
- package/dist/definition/price-list/remove-price-list-prices.js +50 -0
- package/dist/definition/price-list/remove-price-list-prices.js.map +1 -0
- package/dist/definition/price-list/remove-price-lists.d.ts +12 -0
- package/dist/definition/price-list/remove-price-lists.js +40 -0
- package/dist/definition/price-list/remove-price-lists.js.map +1 -0
- package/dist/definition/price-list/remove-product-prices.d.ts +11 -0
- package/dist/definition/price-list/remove-product-prices.js +51 -0
- package/dist/definition/price-list/remove-product-prices.js.map +1 -0
- package/dist/definition/price-list/remove-variant-prices.d.ts +11 -0
- package/dist/definition/price-list/remove-variant-prices.js +51 -0
- package/dist/definition/price-list/remove-variant-prices.js.map +1 -0
- package/dist/definition/price-list/update-price-lists.d.ts +13 -0
- package/dist/definition/price-list/update-price-lists.js +51 -0
- package/dist/definition/price-list/update-price-lists.js.map +1 -0
- package/dist/definition/product/create-product-variants.d.ts +15 -0
- package/dist/definition/product/create-product-variants.js +91 -0
- package/dist/definition/product/create-product-variants.js.map +1 -0
- package/dist/definition/product/create-products.d.ts +18 -0
- package/dist/definition/product/create-products.js +211 -0
- package/dist/definition/product/create-products.js.map +1 -0
- package/dist/definition/product/index.d.ts +4 -0
- package/dist/definition/product/index.js +34 -0
- package/dist/definition/product/index.js.map +1 -0
- package/dist/definition/product/prepare-create-inventory-items.d.ts +23 -0
- package/dist/definition/product/prepare-create-inventory-items.js +28 -0
- package/dist/definition/product/prepare-create-inventory-items.js.map +1 -0
- package/dist/definition/product/update-product-variants.d.ts +15 -0
- package/dist/definition/product/update-product-variants.js +81 -0
- package/dist/definition/product/update-product-variants.js.map +1 -0
- package/dist/definition/product/update-products.d.ts +19 -0
- package/dist/definition/product/update-products.js +328 -0
- package/dist/definition/product/update-products.js.map +1 -0
- package/dist/definitions.d.ts +27 -0
- package/dist/definitions.js +37 -0
- package/dist/definitions.js.map +1 -0
- package/dist/handlers/address/find-or-create-addresses.d.ts +24 -0
- package/dist/handlers/address/find-or-create-addresses.js +66 -0
- package/dist/handlers/address/find-or-create-addresses.js.map +1 -0
- package/dist/handlers/address/index.d.ts +1 -0
- package/dist/handlers/address/index.js +18 -0
- package/dist/handlers/address/index.js.map +1 -0
- package/dist/handlers/cart/attach-line-items-to-cart.d.ts +21 -0
- package/dist/handlers/cart/attach-line-items-to-cart.js +35 -0
- package/dist/handlers/cart/attach-line-items-to-cart.js.map +1 -0
- package/dist/handlers/cart/create-cart.d.ts +36 -0
- package/dist/handlers/cart/create-cart.js +27 -0
- package/dist/handlers/cart/create-cart.js.map +1 -0
- package/dist/handlers/cart/index.d.ts +4 -0
- package/dist/handlers/cart/index.js +21 -0
- package/dist/handlers/cart/index.js.map +1 -0
- package/dist/handlers/cart/remove-cart.d.ts +14 -0
- package/dist/handlers/cart/remove-cart.js +17 -0
- package/dist/handlers/cart/remove-cart.js.map +1 -0
- package/dist/handlers/cart/retrieve-cart.d.ts +22 -0
- package/dist/handlers/cart/retrieve-cart.js +18 -0
- package/dist/handlers/cart/retrieve-cart.js.map +1 -0
- package/dist/handlers/common/index.d.ts +1 -0
- package/dist/handlers/common/index.js +18 -0
- package/dist/handlers/common/index.js.map +1 -0
- package/dist/handlers/common/set-context.d.ts +17 -0
- package/dist/handlers/common/set-context.js +16 -0
- package/dist/handlers/common/set-context.js.map +1 -0
- package/dist/handlers/customer/find-or-create-customer.d.ts +19 -0
- package/dist/handlers/customer/find-or-create-customer.js +38 -0
- package/dist/handlers/customer/find-or-create-customer.js.map +1 -0
- package/dist/handlers/customer/index.d.ts +1 -0
- package/dist/handlers/customer/index.js +18 -0
- package/dist/handlers/customer/index.js.map +1 -0
- package/dist/handlers/index.d.ts +10 -0
- package/dist/handlers/index.js +37 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/inventory/attach-inventory-items.d.ts +16 -0
- package/dist/handlers/inventory/attach-inventory-items.js +23 -0
- package/dist/handlers/inventory/attach-inventory-items.js.map +1 -0
- package/dist/handlers/inventory/create-inventory-items.d.ts +17 -0
- package/dist/handlers/inventory/create-inventory-items.js +31 -0
- package/dist/handlers/inventory/create-inventory-items.js.map +1 -0
- package/dist/handlers/inventory/detach-inventory-items.d.ts +16 -0
- package/dist/handlers/inventory/detach-inventory-items.js +22 -0
- package/dist/handlers/inventory/detach-inventory-items.js.map +1 -0
- package/dist/handlers/inventory/index.d.ts +5 -0
- package/dist/handlers/inventory/index.js +22 -0
- package/dist/handlers/inventory/index.js.map +1 -0
- package/dist/handlers/inventory/remove-inventory-items.d.ts +14 -0
- package/dist/handlers/inventory/remove-inventory-items.js +18 -0
- package/dist/handlers/inventory/remove-inventory-items.js.map +1 -0
- package/dist/handlers/inventory/restore-inventory-items.d.ts +12 -0
- package/dist/handlers/inventory/restore-inventory-items.js +18 -0
- package/dist/handlers/inventory/restore-inventory-items.js.map +1 -0
- package/dist/handlers/middlewares/create-products-prepare-create-prices-compensation.d.ts +26 -0
- package/dist/handlers/middlewares/create-products-prepare-create-prices-compensation.js +31 -0
- package/dist/handlers/middlewares/create-products-prepare-create-prices-compensation.js.map +1 -0
- package/dist/handlers/middlewares/extract-variants.d.ts +18 -0
- package/dist/handlers/middlewares/extract-variants.js +23 -0
- package/dist/handlers/middlewares/extract-variants.js.map +1 -0
- package/dist/handlers/middlewares/index.d.ts +6 -0
- package/dist/handlers/middlewares/index.js +23 -0
- package/dist/handlers/middlewares/index.js.map +1 -0
- package/dist/handlers/middlewares/map-data.d.ts +11 -0
- package/dist/handlers/middlewares/map-data.js +19 -0
- package/dist/handlers/middlewares/map-data.js.map +1 -0
- package/dist/handlers/middlewares/update-products-extract-created-variants.d.ts +19 -0
- package/dist/handlers/middlewares/update-products-extract-created-variants.js +27 -0
- package/dist/handlers/middlewares/update-products-extract-created-variants.js.map +1 -0
- package/dist/handlers/middlewares/update-products-extract-deleted-variants.d.ts +19 -0
- package/dist/handlers/middlewares/update-products-extract-deleted-variants.js +29 -0
- package/dist/handlers/middlewares/update-products-extract-deleted-variants.js.map +1 -0
- package/dist/handlers/middlewares/use-variants-inventory-items.d.ts +24 -0
- package/dist/handlers/middlewares/use-variants-inventory-items.js +31 -0
- package/dist/handlers/middlewares/use-variants-inventory-items.js.map +1 -0
- package/dist/handlers/price-list/create-price-list.d.ts +18 -0
- package/dist/handlers/price-list/create-price-list.js +18 -0
- package/dist/handlers/price-list/create-price-list.js.map +1 -0
- package/dist/handlers/price-list/index.d.ts +10 -0
- package/dist/handlers/price-list/index.js +27 -0
- package/dist/handlers/price-list/index.js.map +1 -0
- package/dist/handlers/price-list/prepare-create-price-list.d.ts +17 -0
- package/dist/handlers/price-list/prepare-create-price-list.js +57 -0
- package/dist/handlers/price-list/prepare-create-price-list.js.map +1 -0
- package/dist/handlers/price-list/prepare-remove-price-list-prices.d.ts +15 -0
- package/dist/handlers/price-list/prepare-remove-price-list-prices.js +23 -0
- package/dist/handlers/price-list/prepare-remove-price-list-prices.js.map +1 -0
- package/dist/handlers/price-list/prepare-remove-product-prices.d.ts +10 -0
- package/dist/handlers/price-list/prepare-remove-product-prices.js +35 -0
- package/dist/handlers/price-list/prepare-remove-product-prices.js.map +1 -0
- package/dist/handlers/price-list/prepare-remove-variant-prices.d.ts +10 -0
- package/dist/handlers/price-list/prepare-remove-variant-prices.js +33 -0
- package/dist/handlers/price-list/prepare-remove-variant-prices.js.map +1 -0
- package/dist/handlers/price-list/prepare-update-price-lists.d.ts +15 -0
- package/dist/handlers/price-list/prepare-update-price-lists.js +58 -0
- package/dist/handlers/price-list/prepare-update-price-lists.js.map +1 -0
- package/dist/handlers/price-list/remove-price-list.d.ts +14 -0
- package/dist/handlers/price-list/remove-price-list.js +14 -0
- package/dist/handlers/price-list/remove-price-list.js.map +1 -0
- package/dist/handlers/price-list/remove-price-set-price-list-prices.d.ts +5 -0
- package/dist/handlers/price-list/remove-price-set-price-list-prices.js +25 -0
- package/dist/handlers/price-list/remove-price-set-price-list-prices.js.map +1 -0
- package/dist/handlers/price-list/remove-prices.d.ts +13 -0
- package/dist/handlers/price-list/remove-prices.js +17 -0
- package/dist/handlers/price-list/remove-prices.js.map +1 -0
- package/dist/handlers/price-list/update-price-lists.d.ts +15 -0
- package/dist/handlers/price-list/update-price-lists.js +38 -0
- package/dist/handlers/price-list/update-price-lists.js.map +1 -0
- package/dist/handlers/product/attach-sales-channel-to-products.d.ts +18 -0
- package/dist/handlers/product/attach-sales-channel-to-products.js +30 -0
- package/dist/handlers/product/attach-sales-channel-to-products.js.map +1 -0
- package/dist/handlers/product/attach-shipping-profile-to-products.d.ts +18 -0
- package/dist/handlers/product/attach-shipping-profile-to-products.js +28 -0
- package/dist/handlers/product/attach-shipping-profile-to-products.js.map +1 -0
- package/dist/handlers/product/create-product-variants-prepare-data.d.ts +21 -0
- package/dist/handlers/product/create-product-variants-prepare-data.js +35 -0
- package/dist/handlers/product/create-product-variants-prepare-data.js.map +1 -0
- package/dist/handlers/product/create-product-variants.d.ts +23 -0
- package/dist/handlers/product/create-product-variants.js +22 -0
- package/dist/handlers/product/create-product-variants.js.map +1 -0
- package/dist/handlers/product/create-products-prepare-data.d.ts +28 -0
- package/dist/handlers/product/create-products-prepare-data.js +77 -0
- package/dist/handlers/product/create-products-prepare-data.js.map +1 -0
- package/dist/handlers/product/create-products.d.ts +12 -0
- package/dist/handlers/product/create-products.js +14 -0
- package/dist/handlers/product/create-products.js.map +1 -0
- package/dist/handlers/product/detach-sales-channel-from-products.d.ts +18 -0
- package/dist/handlers/product/detach-sales-channel-from-products.js +30 -0
- package/dist/handlers/product/detach-sales-channel-from-products.js.map +1 -0
- package/dist/handlers/product/detach-shipping-profile-from-products.d.ts +18 -0
- package/dist/handlers/product/detach-shipping-profile-from-products.js +28 -0
- package/dist/handlers/product/detach-shipping-profile-from-products.js.map +1 -0
- package/dist/handlers/product/index.d.ts +19 -0
- package/dist/handlers/product/index.js +36 -0
- package/dist/handlers/product/index.js.map +1 -0
- package/dist/handlers/product/list-products.d.ts +13 -0
- package/dist/handlers/product/list-products.js +31 -0
- package/dist/handlers/product/list-products.js.map +1 -0
- package/dist/handlers/product/remove-product-variants.d.ts +13 -0
- package/dist/handlers/product/remove-product-variants.js +16 -0
- package/dist/handlers/product/remove-product-variants.js.map +1 -0
- package/dist/handlers/product/remove-products.d.ts +13 -0
- package/dist/handlers/product/remove-products.js +16 -0
- package/dist/handlers/product/remove-products.js.map +1 -0
- package/dist/handlers/product/revert-update-products.d.ts +14 -0
- package/dist/handlers/product/revert-update-products.js +20 -0
- package/dist/handlers/product/revert-update-products.js.map +1 -0
- package/dist/handlers/product/revert-variant-prices.d.ts +14 -0
- package/dist/handlers/product/revert-variant-prices.js +28 -0
- package/dist/handlers/product/revert-variant-prices.js.map +1 -0
- package/dist/handlers/product/update-product-variants-prepare-data.d.ts +21 -0
- package/dist/handlers/product/update-product-variants-prepare-data.js +48 -0
- package/dist/handlers/product/update-product-variants-prepare-data.js.map +1 -0
- package/dist/handlers/product/update-product-variants.d.ts +12 -0
- package/dist/handlers/product/update-product-variants.js +23 -0
- package/dist/handlers/product/update-product-variants.js.map +1 -0
- package/dist/handlers/product/update-products-prepare-data.d.ts +25 -0
- package/dist/handlers/product/update-products-prepare-data.js +65 -0
- package/dist/handlers/product/update-products-prepare-data.js.map +1 -0
- package/dist/handlers/product/update-products-variants-prices.d.ts +18 -0
- package/dist/handlers/product/update-products-variants-prices.js +90 -0
- package/dist/handlers/product/update-products-variants-prices.js.map +1 -0
- package/dist/handlers/product/update-products.d.ts +12 -0
- package/dist/handlers/product/update-products.js +29 -0
- package/dist/handlers/product/update-products.js.map +1 -0
- package/dist/handlers/product/upsert-variant-prices.d.ts +25 -0
- package/dist/handlers/product/upsert-variant-prices.js +122 -0
- package/dist/handlers/product/upsert-variant-prices.js.map +1 -0
- package/dist/handlers/region/find-region.d.ts +17 -0
- package/dist/handlers/region/find-region.js +29 -0
- package/dist/handlers/region/find-region.js.map +1 -0
- package/dist/handlers/region/index.d.ts +1 -0
- package/dist/handlers/region/index.js +18 -0
- package/dist/handlers/region/index.js.map +1 -0
- package/dist/handlers/sales-channel/find-sales-channel.d.ts +20 -0
- package/dist/handlers/sales-channel/find-sales-channel.js +41 -0
- package/dist/handlers/sales-channel/find-sales-channel.js.map +1 -0
- package/dist/handlers/sales-channel/index.d.ts +1 -0
- package/dist/handlers/sales-channel/index.js +18 -0
- package/dist/handlers/sales-channel/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProductsPrepareData = void 0;
|
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
|
5
|
+
async function createProductsPrepareData({ container, context, data, }) {
|
|
6
|
+
const { manager } = context;
|
|
7
|
+
let products = data.products;
|
|
8
|
+
const shippingProfileService = container
|
|
9
|
+
.resolve("shippingProfileService")
|
|
10
|
+
.withTransaction(manager);
|
|
11
|
+
const featureFlagRouter = container.resolve("featureFlagRouter");
|
|
12
|
+
const salesChannelService = container
|
|
13
|
+
.resolve("salesChannelService")
|
|
14
|
+
.withTransaction(manager);
|
|
15
|
+
const salesChannelFeatureFlagKey = utils_1.FeatureFlagUtils.SalesChannelFeatureFlag.key;
|
|
16
|
+
const shippingProfileServiceTx = shippingProfileService.withTransaction(manager);
|
|
17
|
+
const shippingProfiles = await shippingProfileServiceTx.list({
|
|
18
|
+
type: [
|
|
19
|
+
utils_1.ShippingProfileUtils.ShippingProfileType.DEFAULT,
|
|
20
|
+
utils_1.ShippingProfileUtils.ShippingProfileType.GIFT_CARD,
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
const defaultShippingProfile = shippingProfiles.find((sp) => sp.type === utils_1.ShippingProfileUtils.ShippingProfileType.DEFAULT);
|
|
24
|
+
const gitCardShippingProfile = shippingProfiles.find((sp) => sp.type === utils_1.ShippingProfileUtils.ShippingProfileType.GIFT_CARD);
|
|
25
|
+
let defaultSalesChannel;
|
|
26
|
+
if (featureFlagRouter.isFeatureEnabled(salesChannelFeatureFlagKey)) {
|
|
27
|
+
defaultSalesChannel = await salesChannelService
|
|
28
|
+
.withTransaction(manager)
|
|
29
|
+
.retrieveDefault();
|
|
30
|
+
}
|
|
31
|
+
const productsHandleShippingProfileIdMap = new Map();
|
|
32
|
+
const productsHandleSalesChannelsMap = new Map();
|
|
33
|
+
const productsHandleVariantsIndexPricesMap = new Map();
|
|
34
|
+
for (const product of products) {
|
|
35
|
+
product.handle ?? (product.handle = (0, utils_1.kebabCase)(product.title));
|
|
36
|
+
if (product.is_giftcard) {
|
|
37
|
+
productsHandleShippingProfileIdMap.set(product.handle, gitCardShippingProfile.id);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
productsHandleShippingProfileIdMap.set(product.handle, defaultShippingProfile.id);
|
|
41
|
+
}
|
|
42
|
+
if (featureFlagRouter.isFeatureEnabled(salesChannelFeatureFlagKey) &&
|
|
43
|
+
!product.sales_channels?.length) {
|
|
44
|
+
productsHandleSalesChannelsMap.set(product.handle, [
|
|
45
|
+
defaultSalesChannel.id,
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
productsHandleSalesChannelsMap.set(product.handle, product.sales_channels.map((s) => s.id));
|
|
50
|
+
}
|
|
51
|
+
if (product.variants) {
|
|
52
|
+
const items = productsHandleVariantsIndexPricesMap.get(product.handle) ?? [];
|
|
53
|
+
product.variants.forEach((variant, index) => {
|
|
54
|
+
items.push({
|
|
55
|
+
index,
|
|
56
|
+
prices: variant.prices,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
productsHandleVariantsIndexPricesMap.set(product.handle, items);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
products = products.map((productData) => {
|
|
63
|
+
delete productData.sales_channels;
|
|
64
|
+
return productData;
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
products: products,
|
|
68
|
+
productsHandleShippingProfileIdMap,
|
|
69
|
+
productsHandleSalesChannelsMap,
|
|
70
|
+
productsHandleVariantsIndexPricesMap,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
exports.createProductsPrepareData = createProductsPrepareData;
|
|
74
|
+
createProductsPrepareData.aliases = {
|
|
75
|
+
payload: "payload",
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=create-products-prepare-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-products-prepare-data.js","sourceRoot":"","sources":["../../../src/handlers/product/create-products-prepare-data.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProductTypes } from "@medusajs/types";
|
|
2
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
3
|
+
type HandlerInput = {
|
|
4
|
+
products: ProductTypes.CreateProductDTO[];
|
|
5
|
+
};
|
|
6
|
+
export declare function createProducts({ container, data, }: WorkflowArguments<HandlerInput>): Promise<ProductTypes.ProductDTO[]>;
|
|
7
|
+
export declare namespace createProducts {
|
|
8
|
+
var aliases: {
|
|
9
|
+
payload: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProducts = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
async function createProducts({ container, data, }) {
|
|
6
|
+
const data_ = data.products;
|
|
7
|
+
const productModuleService = container.resolve(modules_sdk_1.ModulesDefinition[modules_sdk_1.Modules.PRODUCT].registrationName);
|
|
8
|
+
return await productModuleService.create(data_);
|
|
9
|
+
}
|
|
10
|
+
exports.createProducts = createProducts;
|
|
11
|
+
createProducts.aliases = {
|
|
12
|
+
payload: "payload",
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=create-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-products.js","sourceRoot":"","sources":["../../../src/handlers/product/create-products.ts"],"names":[],"mappings":";;;AAEA,uDAAkE;AAM3D,KAAK,UAAU,cAAc,CAAC,EACnC,SAAS,EACT,IAAI,GAC4B;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAA;IAE3B,MAAM,oBAAoB,GACxB,SAAS,CAAC,OAAO,CAAC,+BAAiB,CAAC,qBAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAExE,OAAO,MAAM,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACjD,CAAC;AAVD,wCAUC;AAED,cAAc,CAAC,OAAO,GAAG;IACvB,OAAO,EAAE,SAAS;CACnB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
2
|
+
type ProductHandle = string;
|
|
3
|
+
type SalesChannelId = string;
|
|
4
|
+
type PartialProduct = {
|
|
5
|
+
handle: string;
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
type HandlerInput = {
|
|
9
|
+
productsHandleSalesChannelsMap: Map<ProductHandle, SalesChannelId[]>;
|
|
10
|
+
products: PartialProduct[];
|
|
11
|
+
};
|
|
12
|
+
export declare function detachSalesChannelFromProducts({ container, context, data, }: WorkflowArguments<HandlerInput>): Promise<void>;
|
|
13
|
+
export declare namespace detachSalesChannelFromProducts {
|
|
14
|
+
var aliases: {
|
|
15
|
+
products: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detachSalesChannelFromProducts = void 0;
|
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
|
5
|
+
async function detachSalesChannelFromProducts({ container, context, data, }) {
|
|
6
|
+
const { manager } = context;
|
|
7
|
+
const productsHandleSalesChannelsMap = data.productsHandleSalesChannelsMap;
|
|
8
|
+
const products = data.products;
|
|
9
|
+
const salesChannelService = container.resolve("salesChannelService");
|
|
10
|
+
const salesChannelServiceTx = salesChannelService.withTransaction(manager);
|
|
11
|
+
const salesChannelIdProductIdsMap = new Map();
|
|
12
|
+
products.forEach((product) => {
|
|
13
|
+
const salesChannelIds = productsHandleSalesChannelsMap.get(product.handle);
|
|
14
|
+
if (salesChannelIds) {
|
|
15
|
+
salesChannelIds.forEach((salesChannelId) => {
|
|
16
|
+
const productIds = salesChannelIdProductIdsMap.get(salesChannelId) || [];
|
|
17
|
+
productIds.push(product.id);
|
|
18
|
+
salesChannelIdProductIdsMap.set(salesChannelId, productIds);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
await (0, utils_1.promiseAll)(Array.from(salesChannelIdProductIdsMap.entries()).map(async ([salesChannelId, productIds]) => {
|
|
23
|
+
return await salesChannelServiceTx.removeProducts(salesChannelId, productIds);
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
exports.detachSalesChannelFromProducts = detachSalesChannelFromProducts;
|
|
27
|
+
detachSalesChannelFromProducts.aliases = {
|
|
28
|
+
products: "products",
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=detach-sales-channel-from-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detach-sales-channel-from-products.js","sourceRoot":"","sources":["../../../src/handlers/product/detach-sales-channel-from-products.ts"],"names":[],"mappings":";;;AACA,2CAA4C;AAUrC,KAAK,UAAU,8BAA8B,CAAC,EACnD,SAAS,EACT,OAAO,EACP,IAAI,GAC4B;IAChC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAC3B,MAAM,8BAA8B,GAAG,IAAI,CAAC,8BAA8B,CAAA;IAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAE9B,MAAM,mBAAmB,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACpE,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAE1E,MAAM,2BAA2B,GAAG,IAAI,GAAG,EAAmC,CAAA;IAC9E,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,eAAe,GAAG,8BAA8B,CAAC,GAAG,CAAC,OAAO,CAAC,MAAO,CAAC,CAAA;QAC3E,IAAI,eAAe,EAAE;YACnB,eAAe,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE;gBACzC,MAAM,UAAU,GAAG,2BAA2B,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAA;gBACxE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;gBAC3B,2BAA2B,CAAC,GAAG,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;YAC7D,CAAC,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,IAAA,kBAAU,EACd,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CACnD,KAAK,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,EAAE;QACrC,OAAO,MAAM,qBAAqB,CAAC,cAAc,CAC/C,cAAc,EACd,UAAU,CACX,CAAA;IACH,CAAC,CACF,CACF,CAAA;AACH,CAAC;AAlCD,wEAkCC;AAED,8BAA8B,CAAC,OAAO,GAAG;IACvC,QAAQ,EAAE,UAAU;CACrB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
2
|
+
type ProductHandle = string;
|
|
3
|
+
type ShippingProfileId = string;
|
|
4
|
+
type PartialProduct = {
|
|
5
|
+
handle: string;
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
type HandlerInput = {
|
|
9
|
+
productsHandleShippingProfileIdMap: Map<ProductHandle, ShippingProfileId>;
|
|
10
|
+
products: PartialProduct[];
|
|
11
|
+
};
|
|
12
|
+
export declare function detachShippingProfileFromProducts({ container, context, data, }: WorkflowArguments<HandlerInput>): Promise<void>;
|
|
13
|
+
export declare namespace detachShippingProfileFromProducts {
|
|
14
|
+
var aliases: {
|
|
15
|
+
products: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detachShippingProfileFromProducts = void 0;
|
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
|
5
|
+
async function detachShippingProfileFromProducts({ container, context, data, }) {
|
|
6
|
+
const { manager } = context;
|
|
7
|
+
const productsHandleShippingProfileIdMap = data.productsHandleShippingProfileIdMap;
|
|
8
|
+
const products = data.products;
|
|
9
|
+
const shippingProfileService = container.resolve("shippingProfileService");
|
|
10
|
+
const shippingProfileServiceTx = shippingProfileService.withTransaction(manager);
|
|
11
|
+
const profileIdProductIdsMap = new Map();
|
|
12
|
+
products.forEach((product) => {
|
|
13
|
+
const profileId = productsHandleShippingProfileIdMap.get(product.handle);
|
|
14
|
+
if (profileId) {
|
|
15
|
+
const productIds = profileIdProductIdsMap.get(profileId) || [];
|
|
16
|
+
productIds.push(product.id);
|
|
17
|
+
profileIdProductIdsMap.set(profileId, productIds);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
await (0, utils_1.promiseAll)(Array.from(profileIdProductIdsMap.entries()).map(async ([profileId, productIds]) => {
|
|
21
|
+
return await shippingProfileServiceTx.removeProducts(profileId, productIds);
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
exports.detachShippingProfileFromProducts = detachShippingProfileFromProducts;
|
|
25
|
+
detachShippingProfileFromProducts.aliases = {
|
|
26
|
+
products: "products",
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=detach-shipping-profile-from-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detach-shipping-profile-from-products.js","sourceRoot":"","sources":["../../../src/handlers/product/detach-shipping-profile-from-products.ts"],"names":[],"mappings":";;;AACA,2CAA4C;AAUrC,KAAK,UAAU,iCAAiC,CAAC,EACtD,SAAS,EACT,OAAO,EACP,IAAI,GAC4B;IAChC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAC3B,MAAM,kCAAkC,GACtC,IAAI,CAAC,kCAAkC,CAAA;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAE9B,MAAM,sBAAsB,GAAG,SAAS,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAA;IAC1E,MAAM,wBAAwB,GAC5B,sBAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAEjD,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAsC,CAAA;IAC5E,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,SAAS,GAAG,kCAAkC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAO,CAAC,CAAA;QACzE,IAAI,SAAS,EAAE;YACb,MAAM,UAAU,GAAG,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;YAC9D,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC3B,sBAAsB,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;SAClD;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,IAAA,kBAAU,EACd,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAC9C,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE;QAChC,OAAO,MAAM,wBAAwB,CAAC,cAAc,CAClD,SAAS,EACT,UAAU,CACX,CAAA;IACH,CAAC,CACF,CACF,CAAA;AACH,CAAC;AAlCD,8EAkCC;AAED,iCAAiC,CAAC,OAAO,GAAG;IAC1C,QAAQ,EAAE,UAAU;CACrB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./attach-sales-channel-to-products";
|
|
2
|
+
export * from "./attach-shipping-profile-to-products";
|
|
3
|
+
export * from "./create-product-variants";
|
|
4
|
+
export * from "./create-product-variants-prepare-data";
|
|
5
|
+
export * from "./create-products";
|
|
6
|
+
export * from "./create-products-prepare-data";
|
|
7
|
+
export * from "./detach-sales-channel-from-products";
|
|
8
|
+
export * from "./detach-shipping-profile-from-products";
|
|
9
|
+
export * from "./list-products";
|
|
10
|
+
export * from "./remove-product-variants";
|
|
11
|
+
export * from "./remove-products";
|
|
12
|
+
export * from "./revert-update-products";
|
|
13
|
+
export * from "./revert-variant-prices";
|
|
14
|
+
export * from "./update-product-variants";
|
|
15
|
+
export * from "./update-product-variants-prepare-data";
|
|
16
|
+
export * from "./update-products";
|
|
17
|
+
export * from "./update-products-prepare-data";
|
|
18
|
+
export * from "./update-products-variants-prices";
|
|
19
|
+
export * from "./upsert-variant-prices";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./attach-sales-channel-to-products"), exports);
|
|
18
|
+
__exportStar(require("./attach-shipping-profile-to-products"), exports);
|
|
19
|
+
__exportStar(require("./create-product-variants"), exports);
|
|
20
|
+
__exportStar(require("./create-product-variants-prepare-data"), exports);
|
|
21
|
+
__exportStar(require("./create-products"), exports);
|
|
22
|
+
__exportStar(require("./create-products-prepare-data"), exports);
|
|
23
|
+
__exportStar(require("./detach-sales-channel-from-products"), exports);
|
|
24
|
+
__exportStar(require("./detach-shipping-profile-from-products"), exports);
|
|
25
|
+
__exportStar(require("./list-products"), exports);
|
|
26
|
+
__exportStar(require("./remove-product-variants"), exports);
|
|
27
|
+
__exportStar(require("./remove-products"), exports);
|
|
28
|
+
__exportStar(require("./revert-update-products"), exports);
|
|
29
|
+
__exportStar(require("./revert-variant-prices"), exports);
|
|
30
|
+
__exportStar(require("./update-product-variants"), exports);
|
|
31
|
+
__exportStar(require("./update-product-variants-prepare-data"), exports);
|
|
32
|
+
__exportStar(require("./update-products"), exports);
|
|
33
|
+
__exportStar(require("./update-products-prepare-data"), exports);
|
|
34
|
+
__exportStar(require("./update-products-variants-prices"), exports);
|
|
35
|
+
__exportStar(require("./upsert-variant-prices"), exports);
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/product/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qEAAkD;AAClD,wEAAqD;AACrD,4DAAyC;AACzC,yEAAsD;AACtD,oDAAiC;AACjC,iEAA8C;AAC9C,uEAAoD;AACpD,0EAAuD;AACvD,kDAA+B;AAC/B,4DAAyC;AACzC,oDAAiC;AACjC,2DAAwC;AACxC,0DAAuC;AACvC,4DAAyC;AACzC,yEAAsD;AACtD,oDAAiC;AACjC,iEAA8C;AAC9C,oEAAiD;AACjD,0DAAuC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ProductTypes, WorkflowTypes } from "@medusajs/types";
|
|
2
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
3
|
+
type HandlerInput = {
|
|
4
|
+
ids: string[];
|
|
5
|
+
config?: WorkflowTypes.CommonWorkflow.WorkflowInputConfig;
|
|
6
|
+
};
|
|
7
|
+
export declare function listProducts({ container, context, data, }: WorkflowArguments<HandlerInput>): Promise<ProductTypes.ProductDTO[]>;
|
|
8
|
+
export declare namespace listProducts {
|
|
9
|
+
var aliases: {
|
|
10
|
+
ids: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listProducts = void 0;
|
|
4
|
+
async function listProducts({ container, context, data, }) {
|
|
5
|
+
const { manager } = context;
|
|
6
|
+
const productIds = data.ids;
|
|
7
|
+
const listConfig = data.config?.listConfig ?? {};
|
|
8
|
+
const productService = container.resolve("productService");
|
|
9
|
+
const pricingService = container.resolve("pricingService");
|
|
10
|
+
const config = {};
|
|
11
|
+
let shouldUseConfig = false;
|
|
12
|
+
if (listConfig.select) {
|
|
13
|
+
shouldUseConfig = !!listConfig.select.length;
|
|
14
|
+
Object.assign(config, { select: listConfig.select });
|
|
15
|
+
}
|
|
16
|
+
if (listConfig.relations) {
|
|
17
|
+
shouldUseConfig = shouldUseConfig || !!listConfig.relations.length;
|
|
18
|
+
Object.assign(config, { relations: listConfig.relations });
|
|
19
|
+
}
|
|
20
|
+
const rawProducts = await productService
|
|
21
|
+
.withTransaction(manager)
|
|
22
|
+
.list({ id: productIds }, shouldUseConfig ? config : undefined);
|
|
23
|
+
return await pricingService
|
|
24
|
+
.withTransaction(manager)
|
|
25
|
+
.setProductPrices(rawProducts);
|
|
26
|
+
}
|
|
27
|
+
exports.listProducts = listProducts;
|
|
28
|
+
listProducts.aliases = {
|
|
29
|
+
ids: "ids",
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=list-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-products.js","sourceRoot":"","sources":["../../../src/handlers/product/list-products.ts"],"names":[],"mappings":";;;AAQO,KAAK,UAAU,YAAY,CAAC,EACjC,SAAS,EACT,OAAO,EACP,IAAI,GAEyB;IAC7B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAE3B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAA;IAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,IAAI,EAAE,CAAA;IAEhD,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC1D,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAE1D,MAAM,MAAM,GAAG,EAAE,CAAA;IACjB,IAAI,eAAe,GAAG,KAAK,CAAA;IAE3B,IAAI,UAAU,CAAC,MAAM,EAAE;QACrB,eAAe,GAAG,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAA;QAC5C,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAA;KACrD;IAED,IAAI,UAAU,CAAC,SAAS,EAAE;QACxB,eAAe,GAAG,eAAe,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAA;QAClE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC,CAAA;KAC3D;IAED,MAAM,WAAW,GAAG,MAAM,cAAc;SACrC,eAAe,CAAC,OAAc,CAAC;SAC/B,IAAI,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAEjE,OAAO,MAAM,cAAc;SACxB,eAAe,CAAC,OAAc,CAAC;SAC/B,gBAAgB,CAAC,WAAW,CAAC,CAAA;AAClC,CAAC;AAlCD,oCAkCC;AAED,YAAY,CAAC,OAAO,GAAG;IACrB,GAAG,EAAE,KAAK;CACX,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
2
|
+
type HandlerInput = {
|
|
3
|
+
productVariants: {
|
|
4
|
+
id: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
|
+
export declare function removeProductVariants({ container, data, }: WorkflowArguments<HandlerInput>): Promise<void>;
|
|
8
|
+
export declare namespace removeProductVariants {
|
|
9
|
+
var aliases: {
|
|
10
|
+
productVariants: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeProductVariants = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
async function removeProductVariants({ container, data, }) {
|
|
6
|
+
if (!data.productVariants.length) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const productModuleService = container.resolve(modules_sdk_1.ModulesDefinition[modules_sdk_1.Modules.PRODUCT].registrationName);
|
|
10
|
+
await productModuleService.deleteVariants(data.productVariants.map((p) => p.id));
|
|
11
|
+
}
|
|
12
|
+
exports.removeProductVariants = removeProductVariants;
|
|
13
|
+
removeProductVariants.aliases = {
|
|
14
|
+
productVariants: "productVariants",
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=remove-product-variants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-product-variants.js","sourceRoot":"","sources":["../../../src/handlers/product/remove-product-variants.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAM3D,KAAK,UAAU,qBAAqB,CAAC,EAC1C,SAAS,EACT,IAAI,GAC4B;IAChC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;QAChC,OAAM;KACP;IAED,MAAM,oBAAoB,GAA0B,SAAS,CAAC,OAAO,CACnE,+BAAiB,CAAC,qBAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CACpD,CAAA;IAED,MAAM,oBAAoB,CAAC,cAAc,CACvC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACtC,CAAA;AACH,CAAC;AAfD,sDAeC;AAED,qBAAqB,CAAC,OAAO,GAAG;IAC9B,eAAe,EAAE,iBAAiB;CACnC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
2
|
+
type HandlerInput = {
|
|
3
|
+
products: {
|
|
4
|
+
id: string;
|
|
5
|
+
}[];
|
|
6
|
+
};
|
|
7
|
+
export declare function removeProducts({ container, data, }: WorkflowArguments<HandlerInput>): Promise<void>;
|
|
8
|
+
export declare namespace removeProducts {
|
|
9
|
+
var aliases: {
|
|
10
|
+
products: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeProducts = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
async function removeProducts({ container, data, }) {
|
|
6
|
+
if (!data.products.length) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const productModuleService = container.resolve(modules_sdk_1.ModulesDefinition[modules_sdk_1.Modules.PRODUCT].registrationName);
|
|
10
|
+
await productModuleService.softDelete(data.products.map((p) => p.id));
|
|
11
|
+
}
|
|
12
|
+
exports.removeProducts = removeProducts;
|
|
13
|
+
removeProducts.aliases = {
|
|
14
|
+
products: "products",
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=remove-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-products.js","sourceRoot":"","sources":["../../../src/handlers/product/remove-products.ts"],"names":[],"mappings":";;;AAEA,uDAAkE;AAI3D,KAAK,UAAU,cAAc,CAAC,EACnC,SAAS,EACT,IAAI,GAC4B;IAChC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;QACzB,OAAM;KACP;IAED,MAAM,oBAAoB,GACxB,SAAS,CAAC,OAAO,CAAC,+BAAiB,CAAC,qBAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAExE,MAAM,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACvE,CAAC;AAZD,wCAYC;AAED,cAAc,CAAC,OAAO,GAAG;IACvB,QAAQ,EAAE,UAAU;CACrB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ProductDTO, ProductVariantDTO } from "@medusajs/types";
|
|
2
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
3
|
+
import { UpdateProductsPreparedData } from "./update-products-prepare-data";
|
|
4
|
+
type HandlerInput = UpdateProductsPreparedData & {
|
|
5
|
+
variants: ProductVariantDTO[];
|
|
6
|
+
};
|
|
7
|
+
export declare function revertUpdateProducts({ container, data, }: WorkflowArguments<HandlerInput>): Promise<ProductDTO[]>;
|
|
8
|
+
export declare namespace revertUpdateProducts {
|
|
9
|
+
var aliases: {
|
|
10
|
+
preparedData: string;
|
|
11
|
+
variants: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.revertUpdateProducts = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
async function revertUpdateProducts({ container, data, }) {
|
|
6
|
+
const productModuleService = container.resolve(modules_sdk_1.ModulesDefinition[modules_sdk_1.Modules.PRODUCT].registrationName);
|
|
7
|
+
// restore variants that have been soft deleted during update products step
|
|
8
|
+
await productModuleService.restoreVariants(data.variants.map((v) => v.id));
|
|
9
|
+
data.originalProducts.forEach((product) => {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
product.variants = product.variants.map((v) => ({ id: v.id }));
|
|
12
|
+
});
|
|
13
|
+
return await productModuleService.update(data.originalProducts);
|
|
14
|
+
}
|
|
15
|
+
exports.revertUpdateProducts = revertUpdateProducts;
|
|
16
|
+
revertUpdateProducts.aliases = {
|
|
17
|
+
preparedData: "preparedData",
|
|
18
|
+
variants: "variants",
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=revert-update-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revert-update-products.js","sourceRoot":"","sources":["../../../src/handlers/product/revert-update-products.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAe3D,KAAK,UAAU,oBAAoB,CAAC,EACzC,SAAS,EACT,IAAI,GAC4B;IAChC,MAAM,oBAAoB,GACxB,SAAS,CAAC,OAAO,CAAC,+BAAiB,CAAC,qBAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAExE,2EAA2E;IAC3E,MAAM,oBAAoB,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC1E,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACxC,aAAa;QACb,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IAChE,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,oBAAoB,CAAC,MAAM,CACtC,IAAI,CAAC,gBAAiD,CACvD,CAAA;AACH,CAAC;AAjBD,oDAiBC;AAED,oBAAoB,CAAC,OAAO,GAAG;IAC7B,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,UAAU;CACrB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PricingTypes } from "@medusajs/types";
|
|
2
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
3
|
+
type HandlerInput = {
|
|
4
|
+
createdLinks: Record<any, any>[];
|
|
5
|
+
originalMoneyAmounts: PricingTypes.MoneyAmountDTO[];
|
|
6
|
+
createdPriceSets: PricingTypes.PriceSetDTO[];
|
|
7
|
+
};
|
|
8
|
+
export declare function revertVariantPrices({ container, context, data, }: WorkflowArguments<HandlerInput>): Promise<void>;
|
|
9
|
+
export declare namespace revertVariantPrices {
|
|
10
|
+
var aliases: {
|
|
11
|
+
productVariantsPrices: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.revertVariantPrices = void 0;
|
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
|
5
|
+
async function revertVariantPrices({ container, context, data, }) {
|
|
6
|
+
const { createdLinks = [], originalMoneyAmounts = [], createdPriceSets = [], } = data;
|
|
7
|
+
const featureFlagRouter = container.resolve("featureFlagRouter");
|
|
8
|
+
const isPricingDomainEnabled = featureFlagRouter.isFeatureEnabled(utils_1.MedusaV2Flag.key);
|
|
9
|
+
if (!isPricingDomainEnabled) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const pricingModuleService = container.resolve("pricingModuleService");
|
|
13
|
+
const remoteLink = container.resolve("remoteLink");
|
|
14
|
+
await remoteLink.remove(createdLinks);
|
|
15
|
+
if (originalMoneyAmounts.length) {
|
|
16
|
+
await pricingModuleService.updateMoneyAmounts(originalMoneyAmounts);
|
|
17
|
+
}
|
|
18
|
+
if (createdPriceSets.length) {
|
|
19
|
+
await pricingModuleService.delete({
|
|
20
|
+
id: createdPriceSets.map((cps) => cps.id),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.revertVariantPrices = revertVariantPrices;
|
|
25
|
+
revertVariantPrices.aliases = {
|
|
26
|
+
productVariantsPrices: "productVariantsPrices",
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=revert-variant-prices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revert-variant-prices.js","sourceRoot":"","sources":["../../../src/handlers/product/revert-variant-prices.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AASvC,KAAK,UAAU,mBAAmB,CAAC,EACxC,SAAS,EACT,OAAO,EACP,IAAI,GAC4B;IAChC,MAAM,EACJ,YAAY,GAAG,EAAE,EACjB,oBAAoB,GAAG,EAAE,EACzB,gBAAgB,GAAG,EAAE,GACtB,GAAG,IAAI,CAAA;IAER,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAChE,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,gBAAgB,CAC/D,oBAAY,CAAC,GAAG,CACjB,CAAA;IAED,IAAI,CAAC,sBAAsB,EAAE;QAC3B,OAAM;KACP;IAED,MAAM,oBAAoB,GAAG,SAAS,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAA;IACtE,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAElD,MAAM,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAErC,IAAI,oBAAoB,CAAC,MAAM,EAAE;QAC/B,MAAM,oBAAoB,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAA;KACpE;IAED,IAAI,gBAAgB,CAAC,MAAM,EAAE;QAC3B,MAAM,oBAAoB,CAAC,MAAM,CAAC;YAChC,EAAE,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;SAC1C,CAAC,CAAA;KACH;AACH,CAAC;AAlCD,kDAkCC;AAED,mBAAmB,CAAC,OAAO,GAAG;IAC5B,qBAAqB,EAAE,uBAAuB;CAC/C,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ProductWorkflow, WorkflowTypes } from "@medusajs/types";
|
|
2
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
3
|
+
type VariantPrice = {
|
|
4
|
+
region_id?: string;
|
|
5
|
+
currency_code?: string;
|
|
6
|
+
amount: number;
|
|
7
|
+
min_quantity?: number;
|
|
8
|
+
max_quantity?: number;
|
|
9
|
+
};
|
|
10
|
+
export type UpdateProductVariantsPreparedData = {
|
|
11
|
+
productVariants: ProductWorkflow.UpdateProductVariantsInputDTO[];
|
|
12
|
+
variantPricesMap: Map<string, VariantPrice[]>;
|
|
13
|
+
productVariantsMap: Map<string, ProductWorkflow.UpdateProductVariantsInputDTO[]>;
|
|
14
|
+
};
|
|
15
|
+
export declare function updateProductVariantsPrepareData({ container, context, data, }: WorkflowArguments<WorkflowTypes.ProductWorkflow.UpdateProductVariantsWorkflowInputDTO>): Promise<UpdateProductVariantsPreparedData>;
|
|
16
|
+
export declare namespace updateProductVariantsPrepareData {
|
|
17
|
+
var aliases: {
|
|
18
|
+
payload: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateProductVariantsPrepareData = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
const utils_1 = require("@medusajs/utils");
|
|
6
|
+
async function updateProductVariantsPrepareData({ container, context, data, }) {
|
|
7
|
+
const featureFlagRouter = container.resolve("featureFlagRouter");
|
|
8
|
+
const isPricingDomainEnabled = featureFlagRouter.isFeatureEnabled(utils_1.MedusaV2Flag.key);
|
|
9
|
+
let productVariants = data.productVariants || [];
|
|
10
|
+
const variantsDataMap = new Map(productVariants.map((productVariantData) => [
|
|
11
|
+
productVariantData.id,
|
|
12
|
+
productVariantData,
|
|
13
|
+
]));
|
|
14
|
+
const variantIds = productVariants.map((pv) => pv.id);
|
|
15
|
+
const productVariantsMap = new Map();
|
|
16
|
+
const variantPricesMap = new Map();
|
|
17
|
+
const productModuleService = container.resolve(modules_sdk_1.ModulesDefinition[modules_sdk_1.Modules.PRODUCT].registrationName);
|
|
18
|
+
const variantsWithProductIds = await productModuleService.listVariants({
|
|
19
|
+
id: variantIds,
|
|
20
|
+
}, {
|
|
21
|
+
select: ["id", "product_id"],
|
|
22
|
+
});
|
|
23
|
+
for (const variantWithProductID of variantsWithProductIds) {
|
|
24
|
+
const variantData = variantsDataMap.get(variantWithProductID.id);
|
|
25
|
+
if (!variantData) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
variantPricesMap.set(variantWithProductID.id, variantData.prices || []);
|
|
29
|
+
if (isPricingDomainEnabled) {
|
|
30
|
+
delete variantData.prices;
|
|
31
|
+
}
|
|
32
|
+
const variantsData = productVariantsMap.get(variantWithProductID.product_id) || [];
|
|
33
|
+
if (variantData) {
|
|
34
|
+
variantsData.push(variantData);
|
|
35
|
+
}
|
|
36
|
+
productVariantsMap.set(variantWithProductID.product_id, variantsData);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
productVariants,
|
|
40
|
+
variantPricesMap,
|
|
41
|
+
productVariantsMap,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.updateProductVariantsPrepareData = updateProductVariantsPrepareData;
|
|
45
|
+
updateProductVariantsPrepareData.aliases = {
|
|
46
|
+
payload: "payload",
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=update-product-variants-prepare-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-product-variants-prepare-data.js","sourceRoot":"","sources":["../../../src/handlers/product/update-product-variants-prepare-data.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAElE,2CAA8C;AAoBvC,KAAK,UAAU,gCAAgC,CAAC,EACrD,SAAS,EACT,OAAO,EACP,IAAI,GACmF;IACvF,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAChE,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,gBAAgB,CAC/D,oBAAY,CAAC,GAAG,CACjB,CAAA;IACD,IAAI,eAAe,GACjB,IAAI,CAAC,eAAe,IAAI,EAAE,CAAA;IAE5B,MAAM,eAAe,GAAG,IAAI,GAAG,CAI7B,eAAe,CAAC,GAAG,CAAC,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAC1C,kBAAkB,CAAC,EAAE;QACrB,kBAAkB;KACnB,CAAC,CACH,CAAA;IAED,MAAM,UAAU,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAa,CAAA;IACjE,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAG/B,CAAA;IACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAA;IAE1D,MAAM,oBAAoB,GACxB,SAAS,CAAC,OAAO,CAAC,+BAAiB,CAAC,qBAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAExE,MAAM,sBAAsB,GAAG,MAAM,oBAAoB,CAAC,YAAY,CACpE;QACE,EAAE,EAAE,UAAU;KACf,EACD;QACE,MAAM,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC;KAC7B,CACF,CAAA;IAED,KAAK,MAAM,oBAAoB,IAAI,sBAAsB,EAAE;QACzD,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAA;QAEhE,IAAI,CAAC,WAAW,EAAE;YAChB,SAAQ;SACT;QAED,gBAAgB,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,EAAE,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;QACvE,IAAI,sBAAsB,EAAE;YAC1B,OAAO,WAAW,CAAC,MAAM,CAAA;SAC1B;QAED,MAAM,YAAY,GAChB,kBAAkB,CAAC,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QAE/D,IAAI,WAAW,EAAE;YACf,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;SAC/B;QAED,kBAAkB,CAAC,GAAG,CAAC,oBAAoB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAA;KACtE;IAED,OAAO;QACL,eAAe;QACf,gBAAgB;QAChB,kBAAkB;KACnB,CAAA;AACH,CAAC;AApED,4EAoEC;AAED,gCAAgC,CAAC,OAAO,GAAG;IACzC,OAAO,EAAE,SAAS;CACnB,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ProductTypes } from "@medusajs/types";
|
|
2
|
+
import { WorkflowArguments } from "@medusajs/workflows-sdk";
|
|
3
|
+
type HandlerInput = {
|
|
4
|
+
productVariantsMap: Map<string, ProductTypes.UpdateProductVariantDTO[]>;
|
|
5
|
+
};
|
|
6
|
+
export declare function updateProductVariants({ container, data, }: WorkflowArguments<HandlerInput>): Promise<ProductTypes.UpdateProductVariantDTO[]>;
|
|
7
|
+
export declare namespace updateProductVariants {
|
|
8
|
+
var aliases: {
|
|
9
|
+
payload: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateProductVariants = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
async function updateProductVariants({ container, data, }) {
|
|
6
|
+
const { productVariantsMap } = data;
|
|
7
|
+
const productsVariants = [];
|
|
8
|
+
const updateVariantsData = [];
|
|
9
|
+
const productModuleService = container.resolve(modules_sdk_1.ModulesDefinition[modules_sdk_1.Modules.PRODUCT].registrationName);
|
|
10
|
+
for (const [product_id, variantsUpdateData = []] of productVariantsMap) {
|
|
11
|
+
updateVariantsData.push(...variantsUpdateData.map((update) => ({ ...update, product_id })));
|
|
12
|
+
productsVariants.push(...variantsUpdateData);
|
|
13
|
+
}
|
|
14
|
+
if (updateVariantsData.length) {
|
|
15
|
+
await productModuleService.updateVariants(updateVariantsData);
|
|
16
|
+
}
|
|
17
|
+
return productsVariants;
|
|
18
|
+
}
|
|
19
|
+
exports.updateProductVariants = updateProductVariants;
|
|
20
|
+
updateProductVariants.aliases = {
|
|
21
|
+
payload: "payload",
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=update-product-variants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-product-variants.js","sourceRoot":"","sources":["../../../src/handlers/product/update-product-variants.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAQ3D,KAAK,UAAU,qBAAqB,CAAC,EAC1C,SAAS,EACT,IAAI,GAC4B;IAGhC,MAAM,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAA;IACnC,MAAM,gBAAgB,GAA2C,EAAE,CAAA;IACnE,MAAM,kBAAkB,GAA+C,EAAE,CAAA;IACzE,MAAM,oBAAoB,GACxB,SAAS,CAAC,OAAO,CAAC,+BAAiB,CAAC,qBAAO,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAExE,KAAK,MAAM,CAAC,UAAU,EAAE,kBAAkB,GAAG,EAAE,CAAC,IAAI,kBAAkB,EAAE;QACtE,kBAAkB,CAAC,IAAI,CACrB,GAAI,kBAA+D,CAAC,GAAG,CACrE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,CAAC,CACxC,CACF,CAAA;QAED,gBAAgB,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAA;KAC7C;IAED,IAAI,kBAAkB,CAAC,MAAM,EAAE;QAC7B,MAAM,oBAAoB,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAA;KAC9D;IAED,OAAO,gBAAgB,CAAA;AACzB,CAAC;AA3BD,sDA2BC;AAED,qBAAqB,CAAC,OAAO,GAAG;IAC9B,OAAO,EAAE,SAAS;CACnB,CAAA"}
|