@medusajs/pricing 0.1.13-preview-20240705030508 → 0.1.13-preview-20240705090550
Sign up to get free protection for your applications and to get access to all the features.
package/dist/joiner-config.js
CHANGED
@@ -4,7 +4,7 @@ exports.joinerConfig = void 0;
|
|
4
4
|
const utils_1 = require("@medusajs/utils");
|
5
5
|
const _models_1 = require("./models");
|
6
6
|
exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.PRICING, {
|
7
|
-
models: [_models_1.PriceSet, _models_1.PriceList, _models_1.Price],
|
7
|
+
models: [_models_1.PriceSet, _models_1.PriceList, _models_1.Price, _models_1.PricePreference],
|
8
8
|
linkableKeys: {
|
9
9
|
price_set_id: _models_1.PriceSet.name,
|
10
10
|
price_list_id: _models_1.PriceList.name,
|
@@ -321,7 +321,8 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.MedusaService(generat
|
|
321
321
|
}
|
322
322
|
async createPricePreferences(data, sharedContext = {}) {
|
323
323
|
const preferences = await this.pricePreferenceService_.create(data, sharedContext);
|
324
|
-
|
324
|
+
const serialized = await this.baseRepository_.serialize(preferences);
|
325
|
+
return Array.isArray(data) ? serialized : serialized[0];
|
325
326
|
}
|
326
327
|
async upsertPricePreferences(data, sharedContext = {}) {
|
327
328
|
const input = Array.isArray(data) ? data : [data];
|
@@ -338,8 +339,22 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.MedusaService(generat
|
|
338
339
|
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0]);
|
339
340
|
}
|
340
341
|
async updatePricePreferences(idOrSelector, data, sharedContext = {}) {
|
341
|
-
|
342
|
-
|
342
|
+
let normalizedInput = [];
|
343
|
+
if ((0, utils_1.isString)(idOrSelector)) {
|
344
|
+
// Check if the ID exists, it will throw if not.
|
345
|
+
await this.pricePreferenceService_.retrieve(idOrSelector, {}, sharedContext);
|
346
|
+
normalizedInput = [{ id: idOrSelector, ...data }];
|
347
|
+
}
|
348
|
+
else {
|
349
|
+
const pricePreferences = await this.pricePreferenceService_.list(idOrSelector, {}, sharedContext);
|
350
|
+
normalizedInput = pricePreferences.map((pricePreference) => ({
|
351
|
+
id: pricePreference.id,
|
352
|
+
...data,
|
353
|
+
}));
|
354
|
+
}
|
355
|
+
const updateResult = await this.pricePreferenceService_.update(normalizedInput, sharedContext);
|
356
|
+
const pricePreferences = await this.baseRepository_.serialize(updateResult);
|
357
|
+
return (0, utils_1.isString)(idOrSelector) ? pricePreferences[0] : pricePreferences;
|
343
358
|
}
|
344
359
|
async createPriceSets_(data, sharedContext = {}) {
|
345
360
|
const input = Array.isArray(data) ? data : [data];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/pricing",
|
3
|
-
"version": "0.1.13-preview-
|
3
|
+
"version": "0.1.13-preview-20240705090550",
|
4
4
|
"description": "Medusa Pricing module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"@mikro-orm/cli": "5.9.7",
|
38
38
|
"cross-env": "^5.2.1",
|
39
39
|
"jest": "^29.7.0",
|
40
|
-
"medusa-test-utils": "1.1.45-preview-
|
40
|
+
"medusa-test-utils": "1.1.45-preview-20240705090550",
|
41
41
|
"rimraf": "^3.0.2",
|
42
42
|
"ts-jest": "^29.1.1",
|
43
43
|
"ts-node": "^10.9.1",
|
@@ -45,9 +45,9 @@
|
|
45
45
|
"typescript": "^5.1.6"
|
46
46
|
},
|
47
47
|
"dependencies": {
|
48
|
-
"@medusajs/modules-sdk": "1.13.0-preview-
|
49
|
-
"@medusajs/types": "1.12.0-preview-
|
50
|
-
"@medusajs/utils": "1.12.0-preview-
|
48
|
+
"@medusajs/modules-sdk": "1.13.0-preview-20240705090550",
|
49
|
+
"@medusajs/types": "1.12.0-preview-20240705090550",
|
50
|
+
"@medusajs/utils": "1.12.0-preview-20240705090550",
|
51
51
|
"@mikro-orm/core": "5.9.7",
|
52
52
|
"@mikro-orm/migrations": "5.9.7",
|
53
53
|
"@mikro-orm/postgresql": "5.9.7",
|