@medusajs/pricing 0.1.13-snapshot-20240503181318 → 0.1.13-snapshot-20240516152256

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { moduleDefinition, revertMigration, runMigrations } from "./module-definition";
1
+ import { moduleDefinition } from "./module-definition";
2
2
  export default moduleDefinition;
3
- export { revertMigration, runMigrations };
4
- export * from "./initialize";
5
3
  export * from "./models";
6
4
  export * from "./services";
7
5
  export * from "./types";
package/dist/index.js CHANGED
@@ -14,13 +14,8 @@ 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
- exports.runMigrations = exports.revertMigration = void 0;
18
17
  const module_definition_1 = require("./module-definition");
19
- Object.defineProperty(exports, "revertMigration", { enumerable: true, get: function () { return module_definition_1.revertMigration; } });
20
- Object.defineProperty(exports, "runMigrations", { enumerable: true, get: function () { return module_definition_1.runMigrations; } });
21
18
  exports.default = module_definition_1.moduleDefinition;
22
- __exportStar(require("./initialize"), exports);
23
- // TODO: remove export from models and services
24
19
  __exportStar(require("./models"), exports);
25
20
  __exportStar(require("./services"), exports);
26
21
  __exportStar(require("./types"), exports);
@@ -15,7 +15,7 @@ exports.LinkableKeys = {
15
15
  };
16
16
  const entityLinkableKeysMap = {};
17
17
  Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
18
- entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
18
+ entityLinkableKeysMap[value] ??= [];
19
19
  entityLinkableKeysMap[value].push({
20
20
  mapTo: key,
21
21
  valueFrom: key.split("_").pop(),
@@ -32,11 +32,11 @@ let PriceListRuleValue = class PriceListRuleValue {
32
32
  }
33
33
  onCreate() {
34
34
  this.id = (0, utils_1.generateEntityId)(this.id, "plrv");
35
- this.price_list_rule_id ?? (this.price_list_rule_id = this.price_list_rule?.id);
35
+ this.price_list_rule_id ??= this.price_list_rule?.id;
36
36
  }
37
37
  onInit() {
38
38
  this.id = (0, utils_1.generateEntityId)(this.id, "plrv");
39
- this.price_list_rule_id ?? (this.price_list_rule_id = this.price_list_rule?.id);
39
+ this.price_list_rule_id ??= this.price_list_rule?.id;
40
40
  }
41
41
  };
42
42
  __decorate([
@@ -41,13 +41,13 @@ let PriceListRule = class PriceListRule {
41
41
  }
42
42
  beforeCreate() {
43
43
  this.id = (0, utils_1.generateEntityId)(this.id, "plrule");
44
- this.price_list_id ?? (this.price_list_id = this.price_list?.id);
45
- this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
44
+ this.price_list_id ??= this.price_list?.id;
45
+ this.rule_type_id ??= this.rule_type?.id;
46
46
  }
47
47
  onInit() {
48
48
  this.id = (0, utils_1.generateEntityId)(this.id, "plrule");
49
- this.price_list_id ?? (this.price_list_id = this.price_list?.id);
50
- this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
49
+ this.price_list_id ??= this.price_list?.id;
50
+ this.rule_type_id ??= this.rule_type?.id;
51
51
  }
52
52
  };
53
53
  __decorate([
@@ -46,15 +46,15 @@ let PriceRule = class PriceRule {
46
46
  }
47
47
  beforeCreate() {
48
48
  this.id = (0, utils_1.generateEntityId)(this.id, "prule");
49
- this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
50
- this.price_set_id ?? (this.price_set_id = this.price_set?.id);
51
- this.price_id ?? (this.price_id = this.price?.id);
49
+ this.rule_type_id ??= this.rule_type?.id;
50
+ this.price_set_id ??= this.price_set?.id;
51
+ this.price_id ??= this.price?.id;
52
52
  }
53
53
  onInit() {
54
54
  this.id = (0, utils_1.generateEntityId)(this.id, "prule");
55
- this.rule_type_id ?? (this.rule_type_id = this.rule_type?.id);
56
- this.price_set_id ?? (this.price_set_id = this.price_set?.id);
57
- this.price_id ?? (this.price_id = this.price?.id);
55
+ this.rule_type_id ??= this.rule_type?.id;
56
+ this.price_set_id ??= this.price_set?.id;
57
+ this.price_id ??= this.price?.id;
58
58
  }
59
59
  };
60
60
  __decorate([
@@ -51,13 +51,13 @@ let Price = class Price {
51
51
  }
52
52
  onCreate() {
53
53
  this.id = (0, utils_1.generateEntityId)(this.id, "price");
54
- this.price_set_id ?? (this.price_set_id = this.price_set?.id);
55
- this.price_list_id ?? (this.price_list_id = this.price_list?.id);
54
+ this.price_set_id ??= this.price_set?.id;
55
+ this.price_list_id ??= this.price_list?.id;
56
56
  }
57
57
  onInit() {
58
58
  this.id = (0, utils_1.generateEntityId)(this.id, "price");
59
- this.price_set_id ?? (this.price_set_id = this.price_set?.id);
60
- this.price_list_id ?? (this.price_list_id = this.price_list?.id);
59
+ this.price_set_id ??= this.price_set?.id;
60
+ this.price_list_id ??= this.price_list?.id;
61
61
  }
62
62
  };
63
63
  __decorate([
@@ -1,4 +1,2 @@
1
1
  import { ModuleExports } from "@medusajs/types";
2
- export declare const runMigrations: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
3
- export declare const revertMigration: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
4
2
  export declare const moduleDefinition: ModuleExports;
@@ -1,50 +1,8 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
2
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.moduleDefinition = exports.revertMigration = exports.runMigrations = void 0;
30
- const modules_sdk_1 = require("@medusajs/modules-sdk");
31
- const utils_1 = require("@medusajs/utils");
32
- const Models = __importStar(require("./models"));
3
+ exports.moduleDefinition = void 0;
33
4
  const _services_1 = require("./services");
34
- const connection_1 = __importDefault(require("./loaders/connection"));
35
- const container_1 = __importDefault(require("./loaders/container"));
36
- const migrationScriptOptions = {
37
- moduleName: modules_sdk_1.Modules.PRICING,
38
- models: Models,
39
- pathToMigrations: __dirname + "/migrations",
40
- };
41
- exports.runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
42
- exports.revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
43
5
  const service = _services_1.PricingModuleService;
44
- const loaders = [container_1.default, connection_1.default];
45
6
  exports.moduleDefinition = {
46
7
  service,
47
- loaders,
48
- runMigrations: exports.runMigrations,
49
- revertMigration: exports.revertMigration,
50
8
  };
@@ -29,7 +29,7 @@ const PricingModels = __importStar(require("../models"));
29
29
  const os_1 = require("os");
30
30
  const path_1 = require("path");
31
31
  async function run({ options, logger, path, }) {
32
- logger ?? (logger = console);
32
+ logger ??= console;
33
33
  logger.info(`Loading seed data from ${path}...`);
34
34
  const { priceSetsData, pricesData } = await Promise.resolve(`${(0, path_1.resolve)(process.cwd(), path)}`).then(s => __importStar(require(s))).catch((e) => {
35
35
  logger?.error(`Failed to load seed data from ${path}. Please, provide a relative path and check that you export the following: priceSetsData and pricesData.${os_1.EOL}${e}`);
@@ -364,7 +364,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
364
364
  });
365
365
  return {
366
366
  ...rest,
367
- title: "",
367
+ title: "", // TODO: accept title
368
368
  rules_count: numberOfRules,
369
369
  price_rules: Array.from(rulesDataMap.values()),
370
370
  };
@@ -456,7 +456,7 @@ class PricingModuleService extends utils_1.ModulesSdkUtils.abstractModuleService
456
456
  return {
457
457
  ...price,
458
458
  price_set_id: priceSetId,
459
- title: "test",
459
+ title: "test", // TODO: accept title
460
460
  rules_count: numberOfRules,
461
461
  priceRules,
462
462
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/pricing",
3
- "version": "0.1.13-snapshot-20240503181318",
3
+ "version": "0.1.13-snapshot-20240516152256",
4
4
  "description": "Medusa Pricing module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "@mikro-orm/cli": "5.9.7",
41
41
  "cross-env": "^5.2.1",
42
42
  "jest": "^29.6.3",
43
- "medusa-test-utils": "^1.1.44",
43
+ "medusa-test-utils": "1.1.45-snapshot-20240516152256",
44
44
  "rimraf": "^3.0.2",
45
45
  "ts-jest": "^29.1.1",
46
46
  "ts-node": "^10.9.1",
@@ -48,9 +48,9 @@
48
48
  "typescript": "^5.1.6"
49
49
  },
50
50
  "dependencies": {
51
- "@medusajs/modules-sdk": "1.12.12-snapshot-20240503181318",
52
- "@medusajs/types": "1.11.17-snapshot-20240503181318",
53
- "@medusajs/utils": "1.11.10-snapshot-20240503181318",
51
+ "@medusajs/modules-sdk": "1.13.0-snapshot-20240516152256",
52
+ "@medusajs/types": "1.12.0-snapshot-20240516152256",
53
+ "@medusajs/utils": "1.12.0-snapshot-20240516152256",
54
54
  "@mikro-orm/core": "5.9.7",
55
55
  "@mikro-orm/migrations": "5.9.7",
56
56
  "@mikro-orm/postgresql": "5.9.7",
@@ -1,4 +0,0 @@
1
- import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
2
- import { IPricingModuleService, ModulesSdkTypes } from "@medusajs/types";
3
- import { InitializeModuleInjectableDependencies } from "../types";
4
- export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<IPricingModuleService>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialize = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
- const module_definition_1 = require("../module-definition");
6
- const initialize = async (options, injectedDependencies) => {
7
- const serviceKey = modules_sdk_1.Modules.PRICING;
8
- const loaded = await modules_sdk_1.MedusaModule.bootstrap({
9
- moduleKey: serviceKey,
10
- defaultPath: modules_sdk_1.MODULE_PACKAGE_NAMES[modules_sdk_1.Modules.PRICING],
11
- declaration: options,
12
- injectedDependencies,
13
- moduleExports: module_definition_1.moduleDefinition,
14
- });
15
- return loaded[serviceKey];
16
- };
17
- exports.initialize = initialize;
@@ -1,4 +0,0 @@
1
- import { InternalModuleDeclaration, LoaderOptions } from "@medusajs/modules-sdk";
2
- import { ModulesSdkTypes } from "@medusajs/types";
3
- declare const _default: ({ options, container, logger, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
4
- export default _default;
@@ -1,40 +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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const utils_1 = require("@medusajs/utils");
27
- const PricingModels = __importStar(require("../models"));
28
- exports.default = async ({ options, container, logger, }, moduleDeclaration) => {
29
- const entities = Object.values(PricingModels);
30
- const pathToMigrations = __dirname + "/../migrations";
31
- await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
32
- moduleName: "pricing",
33
- entities,
34
- container,
35
- options,
36
- moduleDeclaration,
37
- logger,
38
- pathToMigrations,
39
- });
40
- };
@@ -1,2 +0,0 @@
1
- declare const _default: ({ container, options }: import("@medusajs/types").LoaderOptions) => Promise<void>;
2
- export default _default;
@@ -1,34 +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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const utils_1 = require("@medusajs/utils");
27
- const ModuleModels = __importStar(require("../models"));
28
- const ModuleRepositories = __importStar(require("../repositories"));
29
- const ModuleServices = __importStar(require("../services"));
30
- exports.default = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
31
- moduleModels: ModuleModels,
32
- moduleRepositories: ModuleRepositories,
33
- moduleServices: ModuleServices,
34
- });
@@ -1,2 +0,0 @@
1
- export * from "./connection";
2
- export * from "./container";
@@ -1,18 +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("./connection"), exports);
18
- __exportStar(require("./container"), exports);