@medusajs/utils 1.9.0 → 1.9.1-next-20230615175034

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.
Files changed (52) hide show
  1. package/dist/cli/clear-project.d.ts +1 -0
  2. package/dist/cli/clear-project.js +27 -0
  3. package/dist/cli/clear-project.js.map +1 -0
  4. package/dist/cli/index.d.ts +1 -0
  5. package/dist/{totals → cli}/index.js +1 -1
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/common/handle-postgres-database-error.d.ts +8 -0
  8. package/dist/common/handle-postgres-database-error.js +31 -0
  9. package/dist/common/handle-postgres-database-error.js.map +1 -0
  10. package/dist/common/index.d.ts +7 -1
  11. package/dist/common/index.js +7 -1
  12. package/dist/common/index.js.map +1 -1
  13. package/dist/common/simple-hash.d.ts +1 -0
  14. package/dist/common/simple-hash.js +13 -0
  15. package/dist/common/simple-hash.js.map +1 -0
  16. package/dist/common/stringify-circular.d.ts +1 -0
  17. package/dist/common/stringify-circular.js +52 -0
  18. package/dist/common/stringify-circular.js.map +1 -0
  19. package/dist/common/to-kebab-case.d.ts +1 -0
  20. package/dist/common/to-kebab-case.js +11 -0
  21. package/dist/common/to-kebab-case.js.map +1 -0
  22. package/dist/common/wrap-handler.js.map +1 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +1 -0
  25. package/dist/index.js.map +1 -1
  26. package/package.json +5 -3
  27. package/dist/common/db-aware-column.d.ts +0 -4
  28. package/dist/common/db-aware-column.js +0 -26
  29. package/dist/common/db-aware-column.js.map +0 -1
  30. package/dist/common/models/base-entity.d.ts +0 -8
  31. package/dist/common/models/base-entity.js +0 -36
  32. package/dist/common/models/base-entity.js.map +0 -1
  33. package/dist/common/models/index.d.ts +0 -2
  34. package/dist/common/models/index.js +0 -19
  35. package/dist/common/models/index.js.map +0 -1
  36. package/dist/common/models/soft-deletable-entity.d.ts +0 -4
  37. package/dist/common/models/soft-deletable-entity.js +0 -43
  38. package/dist/common/models/soft-deletable-entity.js.map +0 -1
  39. package/dist/common/transaction-base-service.d.ts +0 -25
  40. package/dist/common/transaction-base-service.js +0 -205
  41. package/dist/common/transaction-base-service.js.map +0 -1
  42. package/dist/tax/calculate-price-tax-amount.d.ts +0 -13
  43. package/dist/tax/calculate-price-tax-amount.js +0 -20
  44. package/dist/tax/calculate-price-tax-amount.js.map +0 -1
  45. package/dist/tax/index.d.ts +0 -1
  46. package/dist/tax/index.js +0 -18
  47. package/dist/tax/index.js.map +0 -1
  48. package/dist/totals/index.d.ts +0 -1
  49. package/dist/totals/index.js.map +0 -1
  50. package/dist/totals/totals.d.ts +0 -191
  51. package/dist/totals/totals.js +0 -508
  52. package/dist/totals/totals.js.map +0 -1
@@ -0,0 +1 @@
1
+ export declare function clearProject(directory: string): void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.clearProject = void 0;
7
+ var fs_1 = __importDefault(require("fs"));
8
+ var path_1 = __importDefault(require("path"));
9
+ var glob_1 = require("glob");
10
+ function clearProject(directory) {
11
+ var files = (0, glob_1.globSync)([
12
+ path_1.default.join(directory, "src", "admin/**/*"),
13
+ path_1.default.join(directory, "src", "**/onboarding/"),
14
+ path_1.default.join(directory, "src", "types"),
15
+ path_1.default.join(directory, "src", "**/*.{ts,tsx,js,jsx}"),
16
+ ]);
17
+ files.forEach(function (file) {
18
+ return fs_1.default.rmSync(file, {
19
+ recursive: true,
20
+ force: true,
21
+ });
22
+ });
23
+ // add empty typescript file to avoid build errors
24
+ fs_1.default.openSync(path_1.default.join(directory, "src", "index.ts"), "w");
25
+ }
26
+ exports.clearProject = clearProject;
27
+ //# sourceMappingURL=clear-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-project.js","sourceRoot":"","sources":["../../src/cli/clear-project.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAmB;AACnB,8CAAuB;AACvB,6BAA+B;AAE/B,SAAgB,YAAY,CAAE,SAAiB;IAC7C,IAAM,KAAK,GAAG,IAAA,eAAQ,EAAC;QACrB,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,CAAC;QACzC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,gBAAgB,CAAC;QAC7C,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC;QACpC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,sBAAsB,CAAC;KACpD,CAAC,CAAA;IACF,KAAK,CAAC,OAAO,CAAC,UAAC,IAAI;QACjB,OAAA,YAAE,CAAC,MAAM,CAAC,IAAI,EAAE;YACd,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,IAAI;SACZ,CAAC;IAHF,CAGE,CACH,CAAA;IACD,kDAAkD;IAClD,YAAE,CAAC,QAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,CAAA;AAC3D,CAAC;AAfD,oCAeC"}
@@ -0,0 +1 @@
1
+ export * from "./clear-project";
@@ -14,5 +14,5 @@ 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("./totals"), exports);
17
+ __exportStar(require("./clear-project"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA+B"}
@@ -0,0 +1,8 @@
1
+ export declare const DatabaseErrorCode: {
2
+ databaseDoesNotExist: string;
3
+ connectionFailure: string;
4
+ wrongCredentials: string;
5
+ notFound: string;
6
+ migrationMissing: string;
7
+ };
8
+ export declare function handlePostgresDatabaseError(err: any): never;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handlePostgresDatabaseError = exports.DatabaseErrorCode = void 0;
4
+ var os_1 = require("os");
5
+ exports.DatabaseErrorCode = {
6
+ databaseDoesNotExist: "3D000",
7
+ connectionFailure: "ECONNREFUSED",
8
+ wrongCredentials: "28000",
9
+ notFound: "ENOTFOUND",
10
+ migrationMissing: "42P01",
11
+ };
12
+ function handlePostgresDatabaseError(err) {
13
+ if (exports.DatabaseErrorCode.databaseDoesNotExist === err.code) {
14
+ throw new Error("The specified PostgreSQL database does not exist. Please create it and try again.".concat(os_1.EOL).concat(err.message));
15
+ }
16
+ if (exports.DatabaseErrorCode.connectionFailure === err.code) {
17
+ throw new Error("Failed to establish a connection to PostgreSQL. Please ensure the following is true and try again:\n - You have a PostgreSQL database running\n - You have passed the correct credentials in medusa-config.js\n - You have formatted the database connection string correctly. See below:\n \"postgres://[username]:[password]@[host]:[post]/[db_name]\" - If there is no password, you can omit it from the connection string\n ".concat(os_1.EOL, "\n ").concat(err.message));
18
+ }
19
+ if (exports.DatabaseErrorCode.wrongCredentials === err.code) {
20
+ throw new Error("The specified credentials does not exists for the specified PostgreSQL database.".concat(os_1.EOL).concat(err.message));
21
+ }
22
+ if (exports.DatabaseErrorCode.notFound === err.code) {
23
+ throw new Error("The specified connection string for your PostgreSQL database might have illegal characters. Please check that it only contains allowed characters [a-zA-Z0-9]".concat(os_1.EOL).concat(err.message));
24
+ }
25
+ if (exports.DatabaseErrorCode.migrationMissing === err.code) {
26
+ throw new Error("Migrations missing. Please run 'medusa migrations run' and try again.");
27
+ }
28
+ throw err;
29
+ }
30
+ exports.handlePostgresDatabaseError = handlePostgresDatabaseError;
31
+ //# sourceMappingURL=handle-postgres-database-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-postgres-database-error.js","sourceRoot":"","sources":["../../src/common/handle-postgres-database-error.ts"],"names":[],"mappings":";;;AAAA,yBAAwB;AAEX,QAAA,iBAAiB,GAAG;IAC/B,oBAAoB,EAAE,OAAO;IAC7B,iBAAiB,EAAE,cAAc;IACjC,gBAAgB,EAAE,OAAO;IACzB,QAAQ,EAAE,WAAW;IACrB,gBAAgB,EAAE,OAAO;CAC1B,CAAA;AAED,SAAgB,2BAA2B,CAAC,GAAQ;IAClD,IAAI,yBAAiB,CAAC,oBAAoB,KAAK,GAAG,CAAC,IAAI,EAAE;QACvD,MAAM,IAAI,KAAK,CACb,2FAAoF,QAAG,SAAG,GAAG,CAAC,OAAO,CAAE,CACxG,CAAA;KACF;IAED,IAAI,yBAAiB,CAAC,iBAAiB,KAAK,GAAG,CAAC,IAAI,EAAE;QACpD,MAAM,IAAI,KAAK,CACb,ocAKE,QAAG,qBACH,GAAG,CAAC,OAAO,CAAE,CAChB,CAAA;KACF;IAED,IAAI,yBAAiB,CAAC,gBAAgB,KAAK,GAAG,CAAC,IAAI,EAAE;QACnD,MAAM,IAAI,KAAK,CACb,0FAAmF,QAAG,SAAG,GAAG,CAAC,OAAO,CAAE,CACvG,CAAA;KACF;IAED,IAAI,yBAAiB,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,EAAE;QAC3C,MAAM,IAAI,KAAK,CACb,uKAAgK,QAAG,SAAG,GAAG,CAAC,OAAO,CAAE,CACpL,CAAA;KACF;IAED,IAAI,yBAAiB,CAAC,gBAAgB,KAAK,GAAG,CAAC,IAAI,EAAE;QACnD,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAA;KACF;IAED,MAAM,GAAG,CAAA;AACX,CAAC;AAtCD,kEAsCC"}
@@ -1,3 +1,4 @@
1
+ export * from "./build-query";
1
2
  export * from "./errors";
2
3
  export * from "./generate-entity-id";
3
4
  export * from "./get-config-file";
@@ -6,8 +7,13 @@ export * from "./is-defined";
6
7
  export * from "./is-email";
7
8
  export * from "./is-object";
8
9
  export * from "./is-string";
9
- export * from "./object-to-string-path";
10
+ export * from "./lower-case-first";
10
11
  export * from "./medusa-container";
12
+ export * from "./object-to-string-path";
11
13
  export * from "./set-metadata";
14
+ export * from "./simple-hash";
12
15
  export * from "./wrap-handler";
16
+ export * from "./to-kebab-case";
17
+ export * from "./stringify-circular";
13
18
  export * from "./build-query";
19
+ export * from "./handle-postgres-database-error";
@@ -14,6 +14,7 @@ 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("./build-query"), exports);
17
18
  __exportStar(require("./errors"), exports);
18
19
  __exportStar(require("./generate-entity-id"), exports);
19
20
  __exportStar(require("./get-config-file"), exports);
@@ -22,9 +23,14 @@ __exportStar(require("./is-defined"), exports);
22
23
  __exportStar(require("./is-email"), exports);
23
24
  __exportStar(require("./is-object"), exports);
24
25
  __exportStar(require("./is-string"), exports);
25
- __exportStar(require("./object-to-string-path"), exports);
26
+ __exportStar(require("./lower-case-first"), exports);
26
27
  __exportStar(require("./medusa-container"), exports);
28
+ __exportStar(require("./object-to-string-path"), exports);
27
29
  __exportStar(require("./set-metadata"), exports);
30
+ __exportStar(require("./simple-hash"), exports);
28
31
  __exportStar(require("./wrap-handler"), exports);
32
+ __exportStar(require("./to-kebab-case"), exports);
33
+ __exportStar(require("./stringify-circular"), exports);
29
34
  __exportStar(require("./build-query"), exports);
35
+ __exportStar(require("./handle-postgres-database-error"), exports);
30
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,uDAAoC;AACpC,oDAAiC;AACjC,4CAAyB;AACzB,+CAA4B;AAC5B,6CAA0B;AAC1B,8CAA2B;AAC3B,8CAA2B;AAC3B,0DAAuC;AACvC,qDAAkC;AAClC,iDAA8B;AAC9B,iDAA8B;AAC9B,gDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,2CAAwB;AACxB,uDAAoC;AACpC,oDAAiC;AACjC,4CAAyB;AACzB,+CAA4B;AAC5B,6CAA0B;AAC1B,8CAA2B;AAC3B,8CAA2B;AAC3B,qDAAkC;AAClC,qDAAkC;AAClC,0DAAuC;AACvC,iDAA8B;AAC9B,gDAA6B;AAC7B,iDAA8B;AAC9B,kDAA+B;AAC/B,uDAAoC;AACpC,gDAA6B;AAC7B,mEAAgD"}
@@ -0,0 +1 @@
1
+ export declare function simpleHash(text: string): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.simpleHash = void 0;
4
+ // DJB2 hash function
5
+ function simpleHash(text) {
6
+ var hash = 5381;
7
+ for (var i = 0; i < text.length; i++) {
8
+ hash = (hash << 5) + hash + text.charCodeAt(i);
9
+ }
10
+ return hash.toString(16);
11
+ }
12
+ exports.simpleHash = simpleHash;
13
+ //# sourceMappingURL=simple-hash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-hash.js","sourceRoot":"","sources":["../../src/common/simple-hash.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAI,IAAI,GAAG,IAAI,CAAA;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;KAC/C;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AAC1B,CAAC;AAND,gCAMC"}
@@ -0,0 +1 @@
1
+ export declare function stringifyCircular(object: any, replacer?: Function | null, space?: number): string;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringifyCircular = void 0;
4
+ var isObject = function (value) {
5
+ return typeof value === "object" &&
6
+ value != null &&
7
+ !(value instanceof Boolean) &&
8
+ !(value instanceof Date) &&
9
+ !(value instanceof Number) &&
10
+ !(value instanceof RegExp) &&
11
+ !(value instanceof String);
12
+ };
13
+ var isPrimitive = function (val) {
14
+ return val !== Object(val);
15
+ };
16
+ function decycle(object, replacer) {
17
+ var objects = new WeakMap();
18
+ function deepCopy(value, path) {
19
+ var oldPath;
20
+ var newObj;
21
+ if (replacer != null) {
22
+ value = replacer(value);
23
+ }
24
+ if (isObject(value)) {
25
+ oldPath = objects.get(value);
26
+ if (oldPath !== undefined) {
27
+ return { $ref: oldPath };
28
+ }
29
+ objects.set(value, path);
30
+ if (Array.isArray(value)) {
31
+ newObj = [];
32
+ value.forEach(function (el, idx) {
33
+ newObj[idx] = deepCopy(el, path + "[" + idx + "]");
34
+ });
35
+ }
36
+ else {
37
+ newObj = {};
38
+ Object.keys(value).forEach(function (name) {
39
+ newObj[name] = deepCopy(value[name], path + "[" + JSON.stringify(name) + "]");
40
+ });
41
+ }
42
+ return newObj;
43
+ }
44
+ return !isPrimitive(value) ? value + "" : value;
45
+ }
46
+ return deepCopy(object, "$");
47
+ }
48
+ function stringifyCircular(object, replacer, space) {
49
+ return JSON.stringify(decycle(object, replacer), null, space);
50
+ }
51
+ exports.stringifyCircular = stringifyCircular;
52
+ //# sourceMappingURL=stringify-circular.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-circular.js","sourceRoot":"","sources":["../../src/common/stringify-circular.ts"],"names":[],"mappings":";;;AAAA,IAAM,QAAQ,GAAG,UAAC,KAAU;IAC1B,OAAA,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,IAAI,IAAI;QACb,CAAC,CAAC,KAAK,YAAY,OAAO,CAAC;QAC3B,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC;QACxB,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC;QAC1B,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC;QAC1B,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC;AAN1B,CAM0B,CAAA;AAE5B,IAAM,WAAW,GAAG,UAAC,GAAG;IACtB,OAAO,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,SAAS,OAAO,CAAC,MAAW,EAAE,QAA0B;IACtD,IAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;IAE7B,SAAS,QAAQ,CAAC,KAAK,EAAE,IAAI;QAC3B,IAAI,OAAO,CAAA;QACX,IAAI,MAAM,CAAA;QAEV,IAAI,QAAQ,IAAI,IAAI,EAAE;YACpB,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;SACxB;QAED,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnB,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YAC5B,IAAI,OAAO,KAAK,SAAS,EAAE;gBACzB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;aACzB;YAED,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAExB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACxB,MAAM,GAAG,EAAE,CAAA;gBACX,KAAK,CAAC,OAAO,CAAC,UAAC,EAAE,EAAE,GAAG;oBACpB,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,EAAE,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,CAAA;gBACpD,CAAC,CAAC,CAAA;aACH;iBAAM;gBACL,MAAM,GAAG,EAAE,CAAA;gBACX,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAC,IAAI;oBAC9B,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CACrB,KAAK,CAAC,IAAI,CAAC,EACX,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,GAAG,CACxC,CAAA;gBACH,CAAC,CAAC,CAAA;aACH;YACD,OAAO,MAAM,CAAA;SACd;QAED,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;IACjD,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAC9B,CAAC;AAED,SAAgB,iBAAiB,CAC/B,MAAW,EACX,QAA0B,EAC1B,KAAc;IAEd,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;AAC/D,CAAC;AAND,8CAMC"}
@@ -0,0 +1 @@
1
+ export declare const kebabCase: (string: any) => any;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kebabCase = void 0;
4
+ var kebabCase = function (string) {
5
+ return string
6
+ .replace(/([a-z])([A-Z])/g, "$1-$2")
7
+ .replace(/[\s_]+/g, "-")
8
+ .toLowerCase();
9
+ };
10
+ exports.kebabCase = kebabCase;
11
+ //# sourceMappingURL=to-kebab-case.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-kebab-case.js","sourceRoot":"","sources":["../../src/common/to-kebab-case.ts"],"names":[],"mappings":";;;AAAO,IAAM,SAAS,GAAG,UAAC,MAAM;IAC9B,OAAA,MAAM;SACH,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,WAAW,EAAE;AAHhB,CAGgB,CAAA;AAJL,QAAA,SAAS,aAIJ"}
@@ -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,UACL,GAAmC,EACnC,GAAa,EACb,IAAkB;;QAElB,IAAI,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,MAAM,EAAE;YACvB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC1B,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,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;AAhBY,QAAA,WAAW,eAgBvB;AAED;;;;;;;;;;;;;GAaG"}
1
+ {"version":3,"file":"wrap-handler.js","sourceRoot":"","sources":["../../src/common/wrap-handler.ts"],"names":[],"mappings":";;;AAIO,IAAM,WAAW,GAAG,UAAC,EAAW;IACvC,OAAO,UACH,GAAmC,EACnC,GAAa,EACb,IAAkB;;QAElB,IAAI,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,MAAM,EAAE;YACvB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBAC1B,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,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;AAhBY,QAAA,WAAW,eAgBvB;AAED;;;;;;;;;;;;;GAaG"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./bundles";
2
+ export * from "./cli";
2
3
  export * from "./common";
3
4
  export * from "./decorators";
4
5
  export * from "./event-bus";
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./bundles"), exports);
18
+ __exportStar(require("./cli"), exports);
18
19
  __exportStar(require("./common"), exports);
19
20
  __exportStar(require("./decorators"), exports);
20
21
  __exportStar(require("./event-bus"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,2CAAwB;AACxB,+CAA4B;AAC5B,8CAA2B;AAC3B,2CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,wCAAqB;AACrB,2CAAwB;AACxB,+CAA4B;AAC5B,8CAA2B;AAC3B,2CAAwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/utils",
3
- "version": "1.9.0",
3
+ "version": "1.9.1-next-20230615175034",
4
4
  "description": "Medusa utilities functions shared by Medusa core and Modules",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -17,15 +17,17 @@
17
17
  "author": "Medusa",
18
18
  "license": "MIT",
19
19
  "devDependencies": {
20
- "@medusajs/types": "1.8.7",
20
+ "@medusajs/types": "1.8.8-next-20230615175034",
21
21
  "@types/express": "^4.17.17",
22
22
  "cross-env": "^5.2.1",
23
+ "express": "^4.18.2",
23
24
  "jest": "^25.5.4",
24
25
  "ts-jest": "^25.5.1",
25
26
  "typescript": "^4.4.4"
26
27
  },
27
28
  "dependencies": {
28
- "awilix": "^8.0.0",
29
+ "awilix": "^8.0.1",
30
+ "glob": "^10.2.7",
29
31
  "ulid": "^2.3.0"
30
32
  },
31
33
  "scripts": {
@@ -1,4 +0,0 @@
1
- import { ColumnOptions, ColumnType } from "typeorm";
2
- export declare function resolveDbType(pgSqlType: ColumnType): ColumnType;
3
- export declare function resolveDbGenerationStrategy(pgSqlType: "increment" | "uuid" | "rowid"): "increment" | "uuid" | "rowid";
4
- export declare function DbAwareColumn(columnOptions: ColumnOptions): PropertyDecorator;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DbAwareColumn = exports.resolveDbGenerationStrategy = exports.resolveDbType = void 0;
4
- var typeorm_1 = require("typeorm");
5
- function resolveDbType(pgSqlType) {
6
- return pgSqlType;
7
- }
8
- exports.resolveDbType = resolveDbType;
9
- function resolveDbGenerationStrategy(pgSqlType) {
10
- return pgSqlType;
11
- }
12
- exports.resolveDbGenerationStrategy = resolveDbGenerationStrategy;
13
- function DbAwareColumn(columnOptions) {
14
- var pre = columnOptions.type;
15
- if (columnOptions.type) {
16
- columnOptions.type = resolveDbType(columnOptions.type);
17
- }
18
- if (pre === "jsonb" && pre !== columnOptions.type) {
19
- if ("default" in columnOptions) {
20
- columnOptions.default = JSON.stringify(columnOptions.default);
21
- }
22
- }
23
- return (0, typeorm_1.Column)(columnOptions);
24
- }
25
- exports.DbAwareColumn = DbAwareColumn;
26
- //# sourceMappingURL=db-aware-column.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-aware-column.js","sourceRoot":"","sources":["../../src/common/db-aware-column.ts"],"names":[],"mappings":";;;AAAA,mCAA2D;AAE3D,SAAgB,aAAa,CAAC,SAAqB;IACjD,OAAO,SAAS,CAAA;AAClB,CAAC;AAFD,sCAEC;AAED,SAAgB,2BAA2B,CACzC,SAAyC;IAEzC,OAAO,SAAS,CAAA;AAClB,CAAC;AAJD,kEAIC;AAED,SAAgB,aAAa,CAAC,aAA4B;IACxD,IAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAA;IAC9B,IAAI,aAAa,CAAC,IAAI,EAAE;QACtB,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;KACvD;IAED,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,aAAa,CAAC,IAAI,EAAE;QACjD,IAAI,SAAS,IAAI,aAAa,EAAE;YAC9B,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;SAC9D;KACF;IAED,OAAO,IAAA,gBAAM,EAAC,aAAa,CAAC,CAAA;AAC9B,CAAC;AAbD,sCAaC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Base abstract entity for all entities
3
- */
4
- export declare abstract class BaseEntity {
5
- id: string;
6
- created_at: Date;
7
- updated_at: Date;
8
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BaseEntity = void 0;
13
- var typeorm_1 = require("typeorm");
14
- var db_aware_column_1 = require("../db-aware-column");
15
- /**
16
- * Base abstract entity for all entities
17
- */
18
- var BaseEntity = /** @class */ (function () {
19
- function BaseEntity() {
20
- }
21
- __decorate([
22
- (0, typeorm_1.PrimaryColumn)(),
23
- __metadata("design:type", String)
24
- ], BaseEntity.prototype, "id", void 0);
25
- __decorate([
26
- (0, typeorm_1.CreateDateColumn)({ type: (0, db_aware_column_1.resolveDbType)("timestamptz") }),
27
- __metadata("design:type", Date)
28
- ], BaseEntity.prototype, "created_at", void 0);
29
- __decorate([
30
- (0, typeorm_1.UpdateDateColumn)({ type: (0, db_aware_column_1.resolveDbType)("timestamptz") }),
31
- __metadata("design:type", Date)
32
- ], BaseEntity.prototype, "updated_at", void 0);
33
- return BaseEntity;
34
- }());
35
- exports.BaseEntity = BaseEntity;
36
- //# sourceMappingURL=base-entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-entity.js","sourceRoot":"","sources":["../../../src/common/models/base-entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA2E;AAC3E,sDAAkD;AAElD;;GAEG;AACH;IAAA;IASA,CAAC;IAPC;QADC,IAAA,uBAAa,GAAE;;0CACN;IAGV;QADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,IAAA,+BAAa,EAAC,aAAa,CAAC,EAAE,CAAC;kCAC7C,IAAI;kDAAA;IAGhB;QADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,IAAA,+BAAa,EAAC,aAAa,CAAC,EAAE,CAAC;kCAC7C,IAAI;kDAAA;IAClB,iBAAC;CAAA,AATD,IASC;AATqB,gCAAU"}
@@ -1,2 +0,0 @@
1
- export * from "./base-entity";
2
- export * from "./soft-deletable-entity";
@@ -1,19 +0,0 @@
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("./base-entity"), exports);
18
- __exportStar(require("./soft-deletable-entity"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA6B;AAC7B,0DAAuC"}
@@ -1,4 +0,0 @@
1
- import { BaseEntity } from "./base-entity";
2
- export declare abstract class SoftDeletableEntity extends BaseEntity {
3
- deleted_at: Date | null;
4
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.SoftDeletableEntity = void 0;
28
- var typeorm_1 = require("typeorm");
29
- var db_aware_column_1 = require("../db-aware-column");
30
- var base_entity_1 = require("./base-entity");
31
- var SoftDeletableEntity = /** @class */ (function (_super) {
32
- __extends(SoftDeletableEntity, _super);
33
- function SoftDeletableEntity() {
34
- return _super !== null && _super.apply(this, arguments) || this;
35
- }
36
- __decorate([
37
- (0, typeorm_1.DeleteDateColumn)({ type: (0, db_aware_column_1.resolveDbType)("timestamptz") }),
38
- __metadata("design:type", Object)
39
- ], SoftDeletableEntity.prototype, "deleted_at", void 0);
40
- return SoftDeletableEntity;
41
- }(base_entity_1.BaseEntity));
42
- exports.SoftDeletableEntity = SoftDeletableEntity;
43
- //# sourceMappingURL=soft-deletable-entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"soft-deletable-entity.js","sourceRoot":"","sources":["../../../src/common/models/soft-deletable-entity.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA0C;AAC1C,sDAAkD;AAClD,6CAA0C;AAE1C;IAAkD,uCAAU;IAA5D;;IAGA,CAAC;IADC;QADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,IAAA,+BAAa,EAAC,aAAa,CAAC,EAAE,CAAC;;2DAClC;IACzB,0BAAC;CAAA,AAHD,CAAkD,wBAAU,GAG3D;AAHqB,kDAAmB"}
@@ -1,25 +0,0 @@
1
- import { EntityManager } from "typeorm";
2
- import { IsolationLevel } from "typeorm/driver/types/IsolationLevel";
3
- export declare abstract class TransactionBaseService {
4
- protected readonly __container__: any;
5
- protected readonly __configModule__?: Record<string, unknown> | undefined;
6
- protected readonly __moduleDeclaration__?: Record<string, unknown> | undefined;
7
- protected manager_: EntityManager;
8
- protected transactionManager_: EntityManager | undefined;
9
- protected get activeManager_(): EntityManager;
10
- protected constructor(__container__: any, __configModule__?: Record<string, unknown> | undefined, __moduleDeclaration__?: Record<string, unknown> | undefined);
11
- withTransaction(transactionManager?: EntityManager): this;
12
- protected shouldRetryTransaction_(err: {
13
- code: string;
14
- } | Record<string, unknown>): boolean;
15
- /**
16
- * Wraps some work within a transactional block. If the service already has
17
- * a transaction manager attached this will be reused, otherwise a new
18
- * transaction manager is created.
19
- * @param work - the transactional work to be done
20
- * @param isolationOrErrorHandler - the isolation level to be used for the work.
21
- * @param maybeErrorHandlerOrDontFail Potential error handler
22
- * @return the result of the transactional work
23
- */
24
- protected atomicPhase_<TResult, TError>(work: (transactionManager: EntityManager) => Promise<TResult | never>, isolationOrErrorHandler?: IsolationLevel | ((error: TError) => Promise<never | TResult | void>), maybeErrorHandlerOrDontFail?: (error: TError) => Promise<never | TResult | void>): Promise<never | TResult>;
25
- }