@medusajs/utils 1.10.5 → 1.11.0-next-20231120154105

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.
@@ -0,0 +1,3 @@
1
+ type ArrayDifferenceElement = string | number;
2
+ export declare function arrayDifference(mainArray: ArrayDifferenceElement[], differingArray: ArrayDifferenceElement[]): ArrayDifferenceElement[];
3
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.arrayDifference = void 0;
29
+ function arrayDifference(mainArray, differingArray) {
30
+ var mainArraySet = new Set(mainArray);
31
+ var differingArraySet = new Set(differingArray);
32
+ var difference = __spreadArray([], __read(mainArraySet), false).filter(function (element) { return !differingArraySet.has(element); });
33
+ return difference;
34
+ }
35
+ exports.arrayDifference = arrayDifference;
36
+ //# sourceMappingURL=array-difference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-difference.js","sourceRoot":"","sources":["../../src/common/array-difference.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAgB,eAAe,CAC7B,SAAmC,EACnC,cAAwC;IAExC,IAAM,YAAY,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAA;IACvC,IAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAA;IAEjD,IAAM,UAAU,GAAG,yBAAI,YAAY,UAAE,MAAM,CACzC,UAAC,OAAO,IAAK,OAAA,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAA/B,CAA+B,CAC7C,CAAA;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AAZD,0CAYC"}
@@ -1,6 +1,9 @@
1
+ export * from "./array-difference";
1
2
  export * from "./build-query";
3
+ export * from "./camel-to-snake-case";
2
4
  export * from "./container";
3
5
  export * from "./deduplicate";
6
+ export * from "./deep-equal-obj";
4
7
  export * from "./errors";
5
8
  export * from "./generate-entity-id";
6
9
  export * from "./get-config-file";
@@ -24,11 +27,9 @@ export * from "./set-metadata";
24
27
  export * from "./simple-hash";
25
28
  export * from "./string-to-select-relation-object";
26
29
  export * from "./stringify-circular";
27
- export * from "./camel-to-snake-case";
28
30
  export * from "./to-camel-case";
29
31
  export * from "./to-kebab-case";
30
32
  export * from "./to-pascal-case";
31
33
  export * from "./transaction";
32
34
  export * from "./upper-case-first";
33
35
  export * from "./wrap-handler";
34
- export * from "./deep-equal-obj";
@@ -14,9 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./array-difference"), exports);
17
18
  __exportStar(require("./build-query"), exports);
19
+ __exportStar(require("./camel-to-snake-case"), exports);
18
20
  __exportStar(require("./container"), exports);
19
21
  __exportStar(require("./deduplicate"), exports);
22
+ __exportStar(require("./deep-equal-obj"), exports);
20
23
  __exportStar(require("./errors"), exports);
21
24
  __exportStar(require("./generate-entity-id"), exports);
22
25
  __exportStar(require("./get-config-file"), exports);
@@ -40,12 +43,10 @@ __exportStar(require("./set-metadata"), exports);
40
43
  __exportStar(require("./simple-hash"), exports);
41
44
  __exportStar(require("./string-to-select-relation-object"), exports);
42
45
  __exportStar(require("./stringify-circular"), exports);
43
- __exportStar(require("./camel-to-snake-case"), exports);
44
46
  __exportStar(require("./to-camel-case"), exports);
45
47
  __exportStar(require("./to-kebab-case"), exports);
46
48
  __exportStar(require("./to-pascal-case"), exports);
47
49
  __exportStar(require("./transaction"), exports);
48
50
  __exportStar(require("./upper-case-first"), exports);
49
51
  __exportStar(require("./wrap-handler"), exports);
50
- __exportStar(require("./deep-equal-obj"), exports);
51
52
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,8CAA2B;AAC3B,gDAA6B;AAC7B,2CAAwB;AACxB,uDAAoC;AACpC,oDAAiC;AACjC,6CAA0B;AAC1B,mEAAgD;AAChD,4CAAyB;AACzB,+CAA4B;AAC5B,6CAA0B;AAC1B,8CAA2B;AAC3B,8CAA2B;AAC3B,qDAAkC;AAClC,kDAA+B;AAC/B,qDAAkC;AAClC,4DAAyC;AACzC,0DAAuC;AACvC,gDAA6B;AAC7B,oEAAiD;AACjD,kEAA+C;AAC/C,oDAAiC;AACjC,iDAA8B;AAC9B,gDAA6B;AAC7B,qEAAkD;AAClD,uDAAoC;AACpC,wDAAqC;AACrC,kDAA+B;AAC/B,kDAA+B;AAC/B,mDAAgC;AAChC,gDAA6B;AAC7B,qDAAkC;AAClC,iDAA8B;AAC9B,mDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkC;AAClC,gDAA6B;AAC7B,wDAAqC;AACrC,8CAA2B;AAC3B,gDAA6B;AAC7B,mDAAgC;AAChC,2CAAwB;AACxB,uDAAoC;AACpC,oDAAiC;AACjC,6CAA0B;AAC1B,mEAAgD;AAChD,4CAAyB;AACzB,+CAA4B;AAC5B,6CAA0B;AAC1B,8CAA2B;AAC3B,8CAA2B;AAC3B,qDAAkC;AAClC,kDAA+B;AAC/B,qDAAkC;AAClC,4DAAyC;AACzC,0DAAuC;AACvC,gDAA6B;AAC7B,oEAAiD;AACjD,kEAA+C;AAC/C,oDAAiC;AACjC,iDAA8B;AAC9B,gDAA6B;AAC7B,qEAAkD;AAClD,uDAAoC;AACpC,kDAA+B;AAC/B,kDAA+B;AAC/B,mDAAgC;AAChC,gDAA6B;AAC7B,qDAAkC;AAClC,iDAA8B"}
@@ -1,18 +1,69 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.wrapHandler = void 0;
4
40
  var wrapHandler = function (fn) {
5
- return function (req, res, next) {
41
+ return function (req, res, next) { return __awaiter(void 0, void 0, void 0, function () {
42
+ var req_, err_1;
6
43
  var _a;
7
- var req_ = req;
8
- if ((_a = req_ === null || req_ === void 0 ? void 0 : req_.errors) === null || _a === void 0 ? void 0 : _a.length) {
9
- return res.status(400).json({
10
- errors: req_.errors,
11
- message: "Provided request body contains errors. Please check the data and retry the request",
12
- });
13
- }
14
- return fn(req, res).catch(next);
15
- };
44
+ return __generator(this, function (_b) {
45
+ switch (_b.label) {
46
+ case 0:
47
+ req_ = req;
48
+ if ((_a = req_ === null || req_ === void 0 ? void 0 : req_.errors) === null || _a === void 0 ? void 0 : _a.length) {
49
+ return [2 /*return*/, res.status(400).json({
50
+ errors: req_.errors,
51
+ message: "Provided request body contains errors. Please check the data and retry the request",
52
+ })];
53
+ }
54
+ _b.label = 1;
55
+ case 1:
56
+ _b.trys.push([1, 3, , 4]);
57
+ return [4 /*yield*/, fn(req, res)];
58
+ case 2: return [2 /*return*/, _b.sent()];
59
+ case 3:
60
+ err_1 = _b.sent();
61
+ next(err_1);
62
+ return [3 /*break*/, 4];
63
+ case 4: return [2 /*return*/];
64
+ }
65
+ });
66
+ }); };
16
67
  };
17
68
  exports.wrapHandler = wrapHandler;
18
69
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-handler.js","sourceRoot":"","sources":["../../src/common/wrap-handler.ts"],"names":[],"mappings":";;;AAIO,IAAM,WAAW,GAAG,UAAC,EAAW;IACrC,OAAO,UAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;;QACrD,IAAM,IAAI,GAAG,GAAqC,CAAA;QAClD,IAAI,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,0CAAE,MAAM,EAAE;YACxB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,OAAO,EACL,oFAAoF;aACvF,CAAC,CAAA;SACH;QAED,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACjC,CAAC,CAAA;AACH,CAAC,CAAA;AAbY,QAAA,WAAW,eAavB;AAED;;;;;;;;;;;;;GAaG"}
1
+ {"version":3,"file":"wrap-handler.js","sourceRoot":"","sources":["../../src/common/wrap-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,IAAM,WAAW,GAAG,UAAC,EAAW;IACrC,OAAO,UAAO,GAAY,EAAE,GAAa,EAAE,IAAkB;;;;;;oBACrD,IAAI,GAAG,GAAqC,CAAA;oBAClD,IAAI,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,0CAAE,MAAM,EAAE;wBACxB,sBAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gCAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;gCACnB,OAAO,EACL,oFAAoF;6BACvF,CAAC,EAAA;qBACH;;;;oBAGQ,qBAAM,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAA;wBAAzB,sBAAO,SAAkB,EAAA;;;oBAEzB,IAAI,CAAC,KAAG,CAAC,CAAA;;;;;SAEZ,CAAA;AACH,CAAC,CAAA;AAjBY,QAAA,WAAW,eAiBvB;AAED;;;;;;;;;;;;;GAaG"}
@@ -1,4 +1,6 @@
1
1
  export * from "./analytics";
2
+ export * from "./many-to-many-inventory";
3
+ export * from "./medusa-v2";
2
4
  export * from "./order-editing";
3
5
  export * from "./product-categories";
4
6
  export * from "./publishable-api-keys";
@@ -6,4 +8,3 @@ export * from "./sales-channels";
6
8
  export * from "./tax-inclusive-pricing";
7
9
  export * from "./utils";
8
10
  export * from "./workflows";
9
- export * from "./many-to-many-inventory";
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./analytics"), exports);
18
+ __exportStar(require("./many-to-many-inventory"), exports);
19
+ __exportStar(require("./medusa-v2"), exports);
18
20
  __exportStar(require("./order-editing"), exports);
19
21
  __exportStar(require("./product-categories"), exports);
20
22
  __exportStar(require("./publishable-api-keys"), exports);
@@ -22,5 +24,4 @@ __exportStar(require("./sales-channels"), exports);
22
24
  __exportStar(require("./tax-inclusive-pricing"), exports);
23
25
  __exportStar(require("./utils"), exports);
24
26
  __exportStar(require("./workflows"), exports);
25
- __exportStar(require("./many-to-many-inventory"), exports);
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-flags/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,kDAA+B;AAC/B,uDAAoC;AACpC,yDAAsC;AACtC,mDAAgC;AAChC,0DAAuC;AACvC,0CAAuB;AACvB,8CAA2B;AAC3B,2DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/feature-flags/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,2DAAwC;AACxC,8CAA2B;AAC3B,kDAA+B;AAC/B,uDAAoC;AACpC,yDAAsC;AACtC,mDAAgC;AAChC,0DAAuC;AACvC,0CAAuB;AACvB,8CAA2B"}
@@ -0,0 +1,2 @@
1
+ import { FeatureFlagTypes } from "@medusajs/types";
2
+ export declare const MedusaV2Flag: FeatureFlagTypes.FlagSettings;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MedusaV2Flag = void 0;
4
+ exports.MedusaV2Flag = {
5
+ key: "medusa_v2",
6
+ default_val: false,
7
+ env_key: "MEDUSA_FF_MEDUSA_V2",
8
+ description: "[WIP] Enable Medusa V2",
9
+ };
10
+ //# sourceMappingURL=medusa-v2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"medusa-v2.js","sourceRoot":"","sources":["../../src/feature-flags/medusa-v2.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAAkC;IACzD,GAAG,EAAE,WAAW;IAChB,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,qBAAqB;IAC9B,WAAW,EAAE,wBAAwB;CACtC,CAAA"}
@@ -17,8 +17,8 @@ export declare class FlagRouter implements FeatureFlagTypes.IFlagRouter {
17
17
  /**
18
18
  * Sets a feature flag.
19
19
  * Flags take two shapes:
20
- * setFlag("myFeatureFlag", true)
21
- * setFlag("myFeatureFlag", { nestedFlag: true })
20
+ * `setFlag("myFeatureFlag", true)`
21
+ * `setFlag("myFeatureFlag", { nestedFlag: true })`
22
22
  * These shapes are used for top-level and nested flags respectively, as explained in isFeatureEnabled.
23
23
  * @param key - The key of the flag to set.
24
24
  * @param value - The value of the flag to set.
@@ -62,8 +62,8 @@ var FlagRouter = /** @class */ (function () {
62
62
  /**
63
63
  * Sets a feature flag.
64
64
  * Flags take two shapes:
65
- * setFlag("myFeatureFlag", true)
66
- * setFlag("myFeatureFlag", { nestedFlag: true })
65
+ * `setFlag("myFeatureFlag", true)`
66
+ * `setFlag("myFeatureFlag", { nestedFlag: true })`
67
67
  * These shapes are used for top-level and nested flags respectively, as explained in isFeatureEnabled.
68
68
  * @param key - The key of the flag to set.
69
69
  * @param value - The value of the flag to set.
@@ -1,5 +1,2 @@
1
- export declare const ReservedPricingRuleAttributes: string[];
2
- type RuleAttributeInput = string | undefined;
3
- export declare const getInvalidRuleAttributes: (ruleAttributes: RuleAttributeInput[]) => string[];
4
- export declare const validateRuleAttributes: (ruleAttributes: RuleAttributeInput[]) => void;
5
- export {};
1
+ export * from "./price-list";
2
+ export * from "./rule-type";
@@ -1,49 +1,19 @@
1
1
  "use strict";
2
- var __values = (this && this.__values) || function(o) {
3
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
- if (m) return m.call(o);
5
- if (o && typeof o.length === "number") return {
6
- next: function () {
7
- if (o && i >= o.length) o = void 0;
8
- return { value: o && o[i++], done: !o };
9
- }
10
- };
11
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.validateRuleAttributes = exports.getInvalidRuleAttributes = exports.ReservedPricingRuleAttributes = void 0;
15
- var common_1 = require("../common");
16
- exports.ReservedPricingRuleAttributes = [
17
- "quantity",
18
- "currency_code",
19
- "price_list_id",
20
- ];
21
- var getInvalidRuleAttributes = function (ruleAttributes) {
22
- var e_1, _a;
23
- var invalidRuleAttributes = [];
24
- try {
25
- for (var ReservedPricingRuleAttributes_1 = __values(exports.ReservedPricingRuleAttributes), ReservedPricingRuleAttributes_1_1 = ReservedPricingRuleAttributes_1.next(); !ReservedPricingRuleAttributes_1_1.done; ReservedPricingRuleAttributes_1_1 = ReservedPricingRuleAttributes_1.next()) {
26
- var attribute = ReservedPricingRuleAttributes_1_1.value;
27
- if (ruleAttributes.indexOf(attribute) > -1) {
28
- invalidRuleAttributes.push(attribute);
29
- }
30
- }
31
- }
32
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
33
- finally {
34
- try {
35
- if (ReservedPricingRuleAttributes_1_1 && !ReservedPricingRuleAttributes_1_1.done && (_a = ReservedPricingRuleAttributes_1.return)) _a.call(ReservedPricingRuleAttributes_1);
36
- }
37
- finally { if (e_1) throw e_1.error; }
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]; } };
38
7
  }
39
- return invalidRuleAttributes;
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);
40
15
  };
41
- exports.getInvalidRuleAttributes = getInvalidRuleAttributes;
42
- var validateRuleAttributes = function (ruleAttributes) {
43
- var invalidRuleAttributes = (0, exports.getInvalidRuleAttributes)(ruleAttributes);
44
- if (invalidRuleAttributes.length) {
45
- throw new common_1.MedusaError(common_1.MedusaError.Types.INVALID_DATA, "Can't create rule_attribute with reserved keywords [".concat(exports.ReservedPricingRuleAttributes.join(", "), "] - ").concat(invalidRuleAttributes.join(", ")));
46
- }
47
- };
48
- exports.validateRuleAttributes = validateRuleAttributes;
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./price-list"), exports);
18
+ __exportStar(require("./rule-type"), exports);
49
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pricing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oCAAuC;AAE1B,QAAA,6BAA6B,GAAG;IAC3C,UAAU;IACV,eAAe;IACf,eAAe;CAChB,CAAA;AAIM,IAAM,wBAAwB,GAAG,UACtC,cAAoC;;IAEpC,IAAM,qBAAqB,GAAa,EAAE,CAAA;;QAE1C,KAAwB,IAAA,kCAAA,SAAA,qCAA6B,CAAA,4EAAA,uHAAE;YAAlD,IAAM,SAAS,0CAAA;YAClB,IAAI,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC1C,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;aACtC;SACF;;;;;;;;;IAED,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA;AAZY,QAAA,wBAAwB,4BAYpC;AAEM,IAAM,sBAAsB,GAAG,UACpC,cAAoC;IAEpC,IAAM,qBAAqB,GAAG,IAAA,gCAAwB,EAAC,cAAc,CAAC,CAAA;IAEtE,IAAI,qBAAqB,CAAC,MAAM,EAAE;QAChC,MAAM,IAAI,oBAAW,CACnB,oBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,8DAAuD,qCAA6B,CAAC,IAAI,CACvF,IAAI,CACL,iBAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CAC3C,CAAA;KACF;AACH,CAAC,CAAA;AAbY,QAAA,sBAAsB,0BAalC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/pricing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,8CAA2B"}
@@ -0,0 +1,8 @@
1
+ export declare enum PriceListStatus {
2
+ ACTIVE = "active",
3
+ DRAFT = "draft"
4
+ }
5
+ export declare enum PriceListType {
6
+ SALE = "sale",
7
+ OVERRIDE = "override"
8
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PriceListType = exports.PriceListStatus = void 0;
4
+ var PriceListStatus;
5
+ (function (PriceListStatus) {
6
+ PriceListStatus["ACTIVE"] = "active";
7
+ PriceListStatus["DRAFT"] = "draft";
8
+ })(PriceListStatus || (exports.PriceListStatus = PriceListStatus = {}));
9
+ var PriceListType;
10
+ (function (PriceListType) {
11
+ PriceListType["SALE"] = "sale";
12
+ PriceListType["OVERRIDE"] = "override";
13
+ })(PriceListType || (exports.PriceListType = PriceListType = {}));
14
+ //# sourceMappingURL=price-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-list.js","sourceRoot":"","sources":["../../src/pricing/price-list.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,sCAAqB,CAAA;AACvB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
@@ -0,0 +1,5 @@
1
+ type RuleAttributeInput = string | undefined;
2
+ export declare const ReservedPricingRuleAttributes: string[];
3
+ export declare const getInvalidRuleAttributes: (ruleAttributes: RuleAttributeInput[]) => string[];
4
+ export declare const validateRuleAttributes: (ruleAttributes: RuleAttributeInput[]) => void;
5
+ export {};
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.validateRuleAttributes = exports.getInvalidRuleAttributes = exports.ReservedPricingRuleAttributes = void 0;
15
+ var common_1 = require("../common");
16
+ exports.ReservedPricingRuleAttributes = [
17
+ "quantity",
18
+ "currency_code",
19
+ "price_list_id",
20
+ ];
21
+ var getInvalidRuleAttributes = function (ruleAttributes) {
22
+ var e_1, _a;
23
+ var invalidRuleAttributes = [];
24
+ try {
25
+ for (var ReservedPricingRuleAttributes_1 = __values(exports.ReservedPricingRuleAttributes), ReservedPricingRuleAttributes_1_1 = ReservedPricingRuleAttributes_1.next(); !ReservedPricingRuleAttributes_1_1.done; ReservedPricingRuleAttributes_1_1 = ReservedPricingRuleAttributes_1.next()) {
26
+ var attribute = ReservedPricingRuleAttributes_1_1.value;
27
+ if (ruleAttributes.indexOf(attribute) > -1) {
28
+ invalidRuleAttributes.push(attribute);
29
+ }
30
+ }
31
+ }
32
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
33
+ finally {
34
+ try {
35
+ if (ReservedPricingRuleAttributes_1_1 && !ReservedPricingRuleAttributes_1_1.done && (_a = ReservedPricingRuleAttributes_1.return)) _a.call(ReservedPricingRuleAttributes_1);
36
+ }
37
+ finally { if (e_1) throw e_1.error; }
38
+ }
39
+ return invalidRuleAttributes;
40
+ };
41
+ exports.getInvalidRuleAttributes = getInvalidRuleAttributes;
42
+ var validateRuleAttributes = function (ruleAttributes) {
43
+ var invalidRuleAttributes = (0, exports.getInvalidRuleAttributes)(ruleAttributes);
44
+ if (invalidRuleAttributes.length) {
45
+ throw new common_1.MedusaError(common_1.MedusaError.Types.INVALID_DATA, "Can't create rule_attribute with reserved keywords [".concat(exports.ReservedPricingRuleAttributes.join(", "), "] - ").concat(invalidRuleAttributes.join(", ")));
46
+ }
47
+ };
48
+ exports.validateRuleAttributes = validateRuleAttributes;
49
+ //# sourceMappingURL=rule-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-type.js","sourceRoot":"","sources":["../../src/pricing/rule-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,oCAAuC;AAG1B,QAAA,6BAA6B,GAAG;IAC3C,UAAU;IACV,eAAe;IACf,eAAe;CAChB,CAAA;AAEM,IAAM,wBAAwB,GAAG,UACtC,cAAoC;;IAEpC,IAAM,qBAAqB,GAAa,EAAE,CAAA;;QAE1C,KAAwB,IAAA,kCAAA,SAAA,qCAA6B,CAAA,4EAAA,uHAAE;YAAlD,IAAM,SAAS,0CAAA;YAClB,IAAI,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC1C,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;aACtC;SACF;;;;;;;;;IAED,OAAO,qBAAqB,CAAA;AAC9B,CAAC,CAAA;AAZY,QAAA,wBAAwB,4BAYpC;AAEM,IAAM,sBAAsB,GAAG,UACpC,cAAoC;IAEpC,IAAM,qBAAqB,GAAG,IAAA,gCAAwB,EAAC,cAAc,CAAC,CAAA;IAEtE,IAAI,qBAAqB,CAAC,MAAM,EAAE;QAChC,MAAM,IAAI,oBAAW,CACnB,oBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,8DAAuD,qCAA6B,CAAC,IAAI,CACvF,IAAI,CACL,iBAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CAC3C,CAAA;KACF;AACH,CAAC,CAAA;AAbY,QAAA,sBAAsB,0BAalC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/utils",
3
- "version": "1.10.5",
3
+ "version": "1.11.0-next-20231120154105",
4
4
  "description": "Medusa utilities functions shared by Medusa core and Modules",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "typescript": "^5.1.6"
28
28
  },
29
29
  "dependencies": {
30
- "@medusajs/types": "^1.11.6",
30
+ "@medusajs/types": "1.11.7-next-20231120154105",
31
31
  "@mikro-orm/core": "5.7.12",
32
32
  "@mikro-orm/migrations": "5.7.12",
33
33
  "@mikro-orm/postgresql": "5.7.12",