@medusajs/store 0.1.2 → 1.0.0-rc-20241001083650
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -0
- package/dist/migrations/InitialSetup20240227075933.d.ts +1 -0
- package/dist/migrations/InitialSetup20240227075933.d.ts.map +1 -0
- package/dist/migrations/InitialSetup20240227075933.js +1 -0
- package/dist/migrations/InitialSetup20240227075933.js.map +1 -0
- package/dist/migrations/Migration20240621145944.d.ts +5 -0
- package/dist/migrations/Migration20240621145944.d.ts.map +1 -0
- package/dist/migrations/Migration20240621145944.js +15 -0
- package/dist/migrations/Migration20240621145944.js.map +1 -0
- package/dist/models/currency.d.ts +14 -0
- package/dist/models/currency.d.ts.map +1 -0
- package/dist/models/currency.js +103 -0
- package/dist/models/currency.js.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +4 -1
- package/dist/models/index.js.map +1 -0
- package/dist/models/store.d.ts +6 -5
- package/dist/models/store.d.ts.map +1 -0
- package/dist/models/store.js +11 -9
- package/dist/models/store.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/store-module-service.d.ts +16 -14
- package/dist/services/store-module-service.d.ts.map +1 -0
- package/dist/services/store-module-service.js +40 -51
- package/dist/services/store-module-service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +20 -21
- package/dist/joiner-config.d.ts +0 -5
- package/dist/joiner-config.js +0 -29
- package/dist/module-definition.d.ts +0 -2
- package/dist/module-definition.js +0 -58
- package/dist/repositories/index.d.ts +0 -1
- package/dist/repositories/index.js +0 -5
- package/dist/scripts/bin/run-seed.d.ts +0 -3
- package/dist/scripts/bin/run-seed.js +0 -48
package/dist/index.d.ts
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
export
|
6
|
-
|
7
|
-
export declare const revertMigration: ((options: import("@medusajs/modules-sdk").LoaderOptions<any>, moduleDeclaration?: import("@medusajs/modules-sdk").InternalModuleDeclaration | undefined) => Promise<void>) | undefined;
|
8
|
-
export default moduleDefinition;
|
1
|
+
import { StoreModuleService } from "./services";
|
2
|
+
declare const _default: import("@medusajs/types").ModuleExports<typeof StoreModuleService> & {
|
3
|
+
linkable: Record<string, any>;
|
4
|
+
};
|
5
|
+
export default _default;
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;;;;AAG9C,wBAEE"}
|
package/dist/index.js
CHANGED
@@ -1,29 +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 __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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
|
18
|
-
const
|
19
|
-
|
20
|
-
|
21
|
-
__exportStar(require("./models"), exports);
|
22
|
-
__exportStar(require("./services"), exports);
|
23
|
-
exports.initialize = (0, modules_sdk_1.initializeFactory)({
|
24
|
-
moduleName: modules_sdk_1.Modules.STORE,
|
25
|
-
moduleDefinition: module_definition_1.moduleDefinition,
|
3
|
+
const _services_1 = require("./services");
|
4
|
+
const utils_1 = require("@medusajs/framework/utils");
|
5
|
+
exports.default = (0, utils_1.Module)(utils_1.Modules.STORE, {
|
6
|
+
service: _services_1.StoreModuleService,
|
26
7
|
});
|
27
|
-
|
28
|
-
exports.revertMigration = module_definition_1.moduleDefinition.revertMigration;
|
29
|
-
exports.default = module_definition_1.moduleDefinition;
|
8
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,yCAA8C;AAC9C,qDAA2D;AAE3D,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,KAAK,EAAE;IACnC,OAAO,EAAE,8BAAkB;CAC5B,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"InitialSetup20240227075933.d.ts","sourceRoot":"","sources":["../../src/migrations/InitialSetup20240227075933.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,0BAA2B,SAAQ,SAAS;IACjD,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CA8D1B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"InitialSetup20240227075933.js","sourceRoot":"","sources":["../../src/migrations/InitialSetup20240227075933.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,0BAA2B,SAAQ,sBAAS;IACvD,KAAK,CAAC,EAAE;QACN,oGAAoG;QACpG,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CACpC,gGAAgG,CACjG,CAAA;QAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,kDAAkD,CAAC,CAAA;YAC/D,IAAI,CAAC,MAAM,CAAC,oDAAoD,CAAC,CAAA;YACjE,IAAI,CAAC,MAAM,CACT,qEAAqE,CACtE,CAAA;YACD,IAAI,CAAC,MAAM,CACT,qEAAqE,CACtE,CAAA;YACD,IAAI,CAAC,MAAM,CACT,yEAAyE,CAC1E,CAAA;YACD,IAAI,CAAC,MAAM,CACT,wEAAwE,CACzE,CAAA;YACD,IAAI,CAAC,MAAM,CACT,mEAAmE,CACpE,CAAA;YAED,IAAI,CAAC,MAAM,CACT,+DAA+D,CAChE,CAAA;YACD,IAAI,CAAC,MAAM,CACT,+DAA+D,CAChE,CAAA;YACD,IAAI,CAAC,MAAM,CACT,2FAA2F,CAC5F,CAAA;YAED,IAAI,CAAC,MAAM,CACT,yGAAyG,CAC1G,CAAA;YAED,IAAI,CAAC,MAAM,CACT,iFAAiF,CAClF,CAAA;YACD,IAAI,CAAC,MAAM,CACT,iFAAiF,CAClF,CAAA;YAED,0EAA0E;YAC1E,uEAAuE;YACvE,0EAA0E;YAC1E,yEAAyE;QAC3E,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC;;;;mDAIiC,CAAC,CAAA;YAE9C,IAAI,CAAC,MAAM,CACT,yGAAyG,CAC1G,CAAA;QACH,CAAC;IACH,CAAC;CACF;AA/DD,gEA+DC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Migration20240621145944.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240621145944.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAiB1B"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Migration20240621145944 = void 0;
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
5
|
+
class Migration20240621145944 extends migrations_1.Migration {
|
6
|
+
async up() {
|
7
|
+
this.addSql('create table if not exists "store_currency" ("id" text not null, "currency_code" text not null, "is_default" boolean not null default false, "store_id" text null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "store_currency_pkey" primary key ("id"));');
|
8
|
+
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_store_currency_deleted_at" ON "store_currency" (deleted_at) WHERE deleted_at IS NOT NULL;');
|
9
|
+
this.addSql('alter table if exists "store_currency" add constraint "store_currency_store_id_foreign" foreign key ("store_id") references "store" ("id") on update cascade on delete cascade;');
|
10
|
+
this.addSql('alter table if exists "store" drop column if exists "supported_currency_codes";');
|
11
|
+
this.addSql('alter table if exists "store" drop column if exists "default_currency_code";');
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.Migration20240621145944 = Migration20240621145944;
|
15
|
+
//# sourceMappingURL=Migration20240621145944.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Migration20240621145944.js","sourceRoot":"","sources":["../../src/migrations/Migration20240621145944.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT,2VAA2V,CAC5V,CAAA;QACD,IAAI,CAAC,MAAM,CACT,2HAA2H,CAC5H,CAAA;QACD,IAAI,CAAC,MAAM,CACT,iLAAiL,CAClL,CAAA;QACD,IAAI,CAAC,MAAM,CACT,iFAAiF,CAClF,CAAA;QACD,IAAI,CAAC,MAAM,CACT,8EAA8E,CAC/E,CAAA;IACH,CAAC;CACF;AAlBD,0DAkBC"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import Store from "./store";
|
2
|
+
export default class StoreCurrency {
|
3
|
+
id: string;
|
4
|
+
currency_code: string;
|
5
|
+
is_default?: boolean;
|
6
|
+
store_id: string | null;
|
7
|
+
store: Store | null;
|
8
|
+
created_at: Date;
|
9
|
+
updated_at: Date;
|
10
|
+
deleted_at: Date | null;
|
11
|
+
onCreate(): void;
|
12
|
+
onInit(): void;
|
13
|
+
}
|
14
|
+
//# sourceMappingURL=currency.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../src/models/currency.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,MAAM,SAAS,CAAA;AAU3B,MAAM,CAAC,OAAO,OAAO,aAAa;IAEhC,EAAE,EAAE,MAAM,CAAA;IAIV,aAAa,EAAE,MAAM,CAAA;IAGrB,UAAU,CAAC,EAAE,OAAO,CAAA;IASpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAMvB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IAOnB,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAIhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
|
@@ -0,0 +1,103 @@
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const utils_1 = require("@medusajs/framework/utils");
|
16
|
+
const core_1 = require("@mikro-orm/core");
|
17
|
+
const store_1 = __importDefault(require("./store"));
|
18
|
+
const StoreCurrencyDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
19
|
+
tableName: "store_currency",
|
20
|
+
columns: "deleted_at",
|
21
|
+
where: "deleted_at IS NOT NULL",
|
22
|
+
});
|
23
|
+
let StoreCurrency = class StoreCurrency {
|
24
|
+
constructor() {
|
25
|
+
this.deleted_at = null;
|
26
|
+
}
|
27
|
+
onCreate() {
|
28
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "stocur");
|
29
|
+
}
|
30
|
+
onInit() {
|
31
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "stocur");
|
32
|
+
}
|
33
|
+
};
|
34
|
+
__decorate([
|
35
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
36
|
+
__metadata("design:type", String)
|
37
|
+
], StoreCurrency.prototype, "id", void 0);
|
38
|
+
__decorate([
|
39
|
+
(0, utils_1.Searchable)(),
|
40
|
+
(0, core_1.Property)({ columnType: "text" }),
|
41
|
+
__metadata("design:type", String)
|
42
|
+
], StoreCurrency.prototype, "currency_code", void 0);
|
43
|
+
__decorate([
|
44
|
+
(0, core_1.Property)({ columnType: "boolean", default: false }),
|
45
|
+
__metadata("design:type", Boolean)
|
46
|
+
], StoreCurrency.prototype, "is_default", void 0);
|
47
|
+
__decorate([
|
48
|
+
(0, core_1.ManyToOne)(() => store_1.default, {
|
49
|
+
columnType: "text",
|
50
|
+
fieldName: "store_id",
|
51
|
+
mapToPk: true,
|
52
|
+
nullable: true,
|
53
|
+
onDelete: "cascade",
|
54
|
+
}),
|
55
|
+
__metadata("design:type", Object)
|
56
|
+
], StoreCurrency.prototype, "store_id", void 0);
|
57
|
+
__decorate([
|
58
|
+
(0, core_1.ManyToOne)(() => store_1.default, {
|
59
|
+
persist: false,
|
60
|
+
nullable: true,
|
61
|
+
}),
|
62
|
+
__metadata("design:type", Object)
|
63
|
+
], StoreCurrency.prototype, "store", void 0);
|
64
|
+
__decorate([
|
65
|
+
(0, core_1.Property)({
|
66
|
+
onCreate: () => new Date(),
|
67
|
+
columnType: "timestamptz",
|
68
|
+
defaultRaw: "now()",
|
69
|
+
}),
|
70
|
+
__metadata("design:type", Date)
|
71
|
+
], StoreCurrency.prototype, "created_at", void 0);
|
72
|
+
__decorate([
|
73
|
+
(0, core_1.Property)({
|
74
|
+
onCreate: () => new Date(),
|
75
|
+
onUpdate: () => new Date(),
|
76
|
+
columnType: "timestamptz",
|
77
|
+
defaultRaw: "now()",
|
78
|
+
}),
|
79
|
+
__metadata("design:type", Date)
|
80
|
+
], StoreCurrency.prototype, "updated_at", void 0);
|
81
|
+
__decorate([
|
82
|
+
StoreCurrencyDeletedAtIndex.MikroORMIndex(),
|
83
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
84
|
+
__metadata("design:type", Object)
|
85
|
+
], StoreCurrency.prototype, "deleted_at", void 0);
|
86
|
+
__decorate([
|
87
|
+
(0, core_1.BeforeCreate)(),
|
88
|
+
__metadata("design:type", Function),
|
89
|
+
__metadata("design:paramtypes", []),
|
90
|
+
__metadata("design:returntype", void 0)
|
91
|
+
], StoreCurrency.prototype, "onCreate", null);
|
92
|
+
__decorate([
|
93
|
+
(0, core_1.OnInit)(),
|
94
|
+
__metadata("design:type", Function),
|
95
|
+
__metadata("design:paramtypes", []),
|
96
|
+
__metadata("design:returntype", void 0)
|
97
|
+
], StoreCurrency.prototype, "onInit", null);
|
98
|
+
StoreCurrency = __decorate([
|
99
|
+
(0, core_1.Entity)(),
|
100
|
+
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
101
|
+
], StoreCurrency);
|
102
|
+
exports.default = StoreCurrency;
|
103
|
+
//# sourceMappingURL=currency.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../src/models/currency.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAKkC;AAElC,0CAQwB;AACxB,oDAA2B;AAE3B,MAAM,2BAA2B,GAAG,IAAA,sCAA8B,EAAC;IACjE,SAAS,EAAE,gBAAgB;IAC3B,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAIa,IAAM,aAAa,GAAnB,MAAM,aAAa;IAAnB;QA2Cb,eAAU,GAAgB,IAAI,CAAA;IAWhC,CAAC;IARC,QAAQ;QACN,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAgB,EAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;IAC/C,CAAC;IAGD,MAAM;QACJ,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAgB,EAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;IAC/C,CAAC;CACF,CAAA;AApDC;IADC,IAAA,iBAAU,EAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;;yCACzB;AAIV;IAFC,IAAA,kBAAU,GAAE;IACZ,IAAA,eAAQ,EAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;;oDACZ;AAGrB;IADC,IAAA,eAAQ,EAAC,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;iDAChC;AASpB;IAPC,IAAA,gBAAS,EAAC,GAAG,EAAE,CAAC,eAAK,EAAE;QACtB,UAAU,EAAE,MAAM;QAClB,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,SAAS;KACpB,CAAC;;+CACqB;AAMvB;IAJC,IAAA,gBAAS,EAAC,GAAG,EAAE,CAAC,eAAK,EAAE;QACtB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,IAAI;KACf,CAAC;;4CACiB;AAOnB;IALC,IAAA,eAAQ,EAAC;QACR,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,OAAO;KACpB,CAAC;8BACU,IAAI;iDAAA;AAQhB;IANC,IAAA,eAAQ,EAAC;QACR,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,OAAO;KACpB,CAAC;8BACU,IAAI;iDAAA;AAIhB;IAFC,2BAA2B,CAAC,aAAa,EAAE;IAC3C,IAAA,eAAQ,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDAC1B;AAG9B;IADC,IAAA,mBAAY,GAAE;;;;6CAGd;AAGD;IADC,IAAA,aAAM,GAAE;;;;2CAGR;AArDkB,aAAa;IAFjC,IAAA,aAAM,GAAE;IACR,IAAA,aAAM,EAAC,gBAAQ,CAAC,kCAAkC,CAAC;GAC/B,aAAa,CAsDjC;kBAtDoB,aAAa"}
|
package/dist/models/index.d.ts
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/models/index.js
CHANGED
@@ -3,6 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.Store = void 0;
|
6
|
+
exports.StoreCurrency = exports.Store = void 0;
|
7
7
|
var store_1 = require("./store");
|
8
8
|
Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return __importDefault(store_1).default; } });
|
9
|
+
var currency_1 = require("./currency");
|
10
|
+
Object.defineProperty(exports, "StoreCurrency", { enumerable: true, get: function () { return __importDefault(currency_1).default; } });
|
11
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAA0C;AAAjC,+GAAA,OAAO,OAAS;AACzB,uCAAqD;AAA5C,0HAAA,OAAO,OAAiB"}
|
package/dist/models/store.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
import { DAL } from "@medusajs/types";
|
2
|
-
import { OptionalProps } from "@mikro-orm/core";
|
3
|
-
|
1
|
+
import { DAL } from "@medusajs/framework/types";
|
2
|
+
import { OptionalProps, Collection } from "@mikro-orm/core";
|
3
|
+
import StoreCurrency from "./currency";
|
4
|
+
type StoreOptionalProps = DAL.SoftDeletableModelDateColumns;
|
4
5
|
export default class Store {
|
5
6
|
[OptionalProps]?: StoreOptionalProps;
|
6
7
|
id: string;
|
7
8
|
name: string;
|
8
|
-
|
9
|
-
default_currency_code: string | null;
|
9
|
+
supported_currencies: Collection<StoreCurrency, object>;
|
10
10
|
default_sales_channel_id: string | null;
|
11
11
|
default_region_id: string | null;
|
12
12
|
default_location_id: string | null;
|
@@ -18,3 +18,4 @@ export default class Store {
|
|
18
18
|
onInit(): void;
|
19
19
|
}
|
20
20
|
export {};
|
21
|
+
//# sourceMappingURL=store.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/models/store.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAA;AAE/C,OAAO,EAOL,aAAa,EAEb,UAAU,EAEX,MAAM,iBAAiB,CAAA;AACxB,OAAO,aAAa,MAAM,YAAY,CAAA;AAEtC,KAAK,kBAAkB,GAAG,GAAG,CAAC,6BAA6B,CAAA;AAU3D,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,CAAC,aAAa,CAAC,CAAC,EAAE,kBAAkB,CAAA;IAGpC,EAAE,EAAE,MAAM,CAAA;IAIV,IAAI,EAAE,MAAM,CAAA;IAKZ,oBAAoB,oCAAsC;IAG1D,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAO;IAG9C,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAO;IAGvC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAO;IAGzC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAO;IAO/C,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAIhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
|
package/dist/models/store.js
CHANGED
@@ -8,9 +8,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const utils_1 = require("@medusajs/utils");
|
15
|
+
const utils_1 = require("@medusajs/framework/utils");
|
13
16
|
const core_1 = require("@mikro-orm/core");
|
17
|
+
const currency_1 = __importDefault(require("./currency"));
|
14
18
|
const StoreDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
15
19
|
tableName: "store",
|
16
20
|
columns: "deleted_at",
|
@@ -18,8 +22,7 @@ const StoreDeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
|
|
18
22
|
});
|
19
23
|
let Store = class Store {
|
20
24
|
constructor() {
|
21
|
-
this.
|
22
|
-
this.default_currency_code = null;
|
25
|
+
this.supported_currencies = new core_1.Collection(this);
|
23
26
|
this.default_sales_channel_id = null;
|
24
27
|
this.default_region_id = null;
|
25
28
|
this.default_location_id = null;
|
@@ -43,13 +46,11 @@ __decorate([
|
|
43
46
|
__metadata("design:type", String)
|
44
47
|
], Store.prototype, "name", void 0);
|
45
48
|
__decorate([
|
46
|
-
(0, core_1.
|
47
|
-
|
48
|
-
|
49
|
-
__decorate([
|
50
|
-
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
49
|
+
(0, core_1.OneToMany)(() => currency_1.default, (o) => o.store, {
|
50
|
+
cascade: [core_1.Cascade.PERSIST, "soft-remove"],
|
51
|
+
}),
|
51
52
|
__metadata("design:type", Object)
|
52
|
-
], Store.prototype, "
|
53
|
+
], Store.prototype, "supported_currencies", void 0);
|
53
54
|
__decorate([
|
54
55
|
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
55
56
|
__metadata("design:type", Object)
|
@@ -105,3 +106,4 @@ Store = __decorate([
|
|
105
106
|
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
106
107
|
], Store);
|
107
108
|
exports.default = Store;
|
109
|
+
//# sourceMappingURL=store.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/models/store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAKkC;AAIlC,0CAWwB;AACxB,0DAAsC;AAItC,MAAM,mBAAmB,GAAG,IAAA,sCAA8B,EAAC;IACzD,SAAS,EAAE,OAAO;IAClB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAIa,IAAM,KAA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AA,eAAQ,EAAC,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACH;AAO/C;IALC,IAAA,eAAQ,EAAC;QACR,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,OAAO;KACpB,CAAC;8BACU,IAAI;yCAAA;AAQhB;IANC,IAAA,eAAQ,EAAC;QACR,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,OAAO;KACpB,CAAC;8BACU,IAAI;yCAAA;AAIhB;IAFC,mBAAmB,CAAC,aAAa,EAAE;IACnC,IAAA,eAAQ,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC1B;AAG9B;IADC,IAAA,mBAAY,GAAE;;;;qCAGd;AAGD;IADC,IAAA,aAAM,GAAE;;;;mCAGR;AAtDkB,KAAK;IAFzB,IAAA,aAAM,GAAE;IACR,IAAA,aAAM,EAAC,gBAAQ,CAAC,kCAAkC,CAAC;GAC/B,KAAK,CAuDzB;kBAvDoB,KAAK"}
|
package/dist/services/index.d.ts
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/services/index.js
CHANGED
@@ -6,3 +6,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.StoreModuleService = void 0;
|
7
7
|
var store_module_service_1 = require("./store-module-service");
|
8
8
|
Object.defineProperty(exports, "StoreModuleService", { enumerable: true, get: function () { return __importDefault(store_module_service_1).default; } });
|
9
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAsE;AAA7D,2IAAA,OAAO,OAAsB"}
|
@@ -1,32 +1,34 @@
|
|
1
|
-
import { DAL, InternalModuleDeclaration,
|
2
|
-
import { ModulesSdkUtils } from "@medusajs/utils";
|
1
|
+
import { Context, DAL, InternalModuleDeclaration, IStoreModuleService, ModulesSdkTypes, StoreTypes } from "@medusajs/framework/types";
|
3
2
|
import { Store } from "../models";
|
4
3
|
import { UpdateStoreInput } from "../types";
|
5
4
|
type InjectedDependencies = {
|
6
5
|
baseRepository: DAL.RepositoryService;
|
7
|
-
storeService: ModulesSdkTypes.
|
6
|
+
storeService: ModulesSdkTypes.IMedusaInternalService<any>;
|
8
7
|
};
|
9
|
-
declare const StoreModuleService_base:
|
8
|
+
declare const StoreModuleService_base: import("@medusajs/framework/utils").MedusaServiceReturnType<{
|
10
9
|
Store: {
|
11
10
|
dto: StoreTypes.StoreDTO;
|
12
11
|
};
|
12
|
+
StoreCurrency: {
|
13
|
+
dto: StoreTypes.StoreCurrencyDTO;
|
14
|
+
};
|
13
15
|
}>;
|
14
|
-
export default class StoreModuleService
|
16
|
+
export default class StoreModuleService extends StoreModuleService_base implements IStoreModuleService {
|
15
17
|
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
16
18
|
protected baseRepository_: DAL.RepositoryService;
|
17
|
-
protected readonly storeService_: ModulesSdkTypes.
|
19
|
+
protected readonly storeService_: ModulesSdkTypes.IMedusaInternalService<Store>;
|
18
20
|
constructor({ baseRepository, storeService }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
19
|
-
|
20
|
-
|
21
|
-
create(data: StoreTypes.CreateStoreDTO, sharedContext?: Context): Promise<StoreTypes.StoreDTO>;
|
21
|
+
createStores(data: StoreTypes.CreateStoreDTO[], sharedContext?: Context): Promise<StoreTypes.StoreDTO[]>;
|
22
|
+
createStores(data: StoreTypes.CreateStoreDTO, sharedContext?: Context): Promise<StoreTypes.StoreDTO>;
|
22
23
|
create_(data: StoreTypes.CreateStoreDTO[], sharedContext?: Context): Promise<Store[]>;
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
upsertStores(data: StoreTypes.UpsertStoreDTO[], sharedContext?: Context): Promise<StoreTypes.StoreDTO[]>;
|
25
|
+
upsertStores(data: StoreTypes.UpsertStoreDTO, sharedContext?: Context): Promise<StoreTypes.StoreDTO>;
|
26
|
+
updateStores(id: string, data: StoreTypes.UpdateStoreDTO, sharedContext?: Context): Promise<StoreTypes.StoreDTO>;
|
27
|
+
updateStores(selector: StoreTypes.FilterableStoreProps, data: StoreTypes.UpdateStoreDTO, sharedContext?: Context): Promise<StoreTypes.StoreDTO[]>;
|
27
28
|
protected update_(data: UpdateStoreInput[], sharedContext?: Context): Promise<Store[]>;
|
28
29
|
private static normalizeInput;
|
29
30
|
private static validateCreateRequest;
|
30
|
-
private validateUpdateRequest;
|
31
|
+
private static validateUpdateRequest;
|
31
32
|
}
|
32
33
|
export {};
|
34
|
+
//# sourceMappingURL=store-module-service.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"store-module-service.d.ts","sourceRoot":"","sources":["../../src/services/store-module-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,UAAU,EACX,MAAM,2BAA2B,CAAA;AAalC,OAAO,EAAE,KAAK,EAAiB,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAEzC,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,GAAG,CAAC,iBAAiB,CAAA;IACrC,YAAY,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAA;CAC1D,CAAA;;WAIU;QAAE,GAAG,EAAE,UAAU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QAAQ,EAAE,UAAU,CAAC,oBAAoB,EACzC,IAAI,EAAE,UAAU,CAAC,cAAc,EAC/B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;cAiCjB,OAAO,CACrB,IAAI,EAAE,gBAAgB,EAAE,EACP,aAAa,GAAE,OAAY,GAC3C,OAAO,CAAC,KAAK,EAAE,CAAC;IAanB,OAAO,CAAC,MAAM,CAAC,cAAc;IAe7B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAuCpC,OAAO,CAAC,MAAM,CAAC,qBAAqB;CAGrC"}
|
@@ -12,12 +12,10 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const types_1 = require("@medusajs/types");
|
16
|
-
const utils_1 = require("@medusajs/utils");
|
15
|
+
const types_1 = require("@medusajs/framework/types");
|
16
|
+
const utils_1 = require("@medusajs/framework/utils");
|
17
17
|
const _models_1 = require("../models");
|
18
|
-
|
19
|
-
const generateMethodForModels = [];
|
20
|
-
class StoreModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.Store, generateMethodForModels, joiner_config_1.entityNameToLinkableKeysMap) {
|
18
|
+
class StoreModuleService extends (0, utils_1.MedusaService)({ Store: _models_1.Store, StoreCurrency: _models_1.StoreCurrency }) {
|
21
19
|
constructor({ baseRepository, storeService }, moduleDeclaration) {
|
22
20
|
// @ts-ignore
|
23
21
|
super(...arguments);
|
@@ -25,10 +23,7 @@ class StoreModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
|
|
25
23
|
this.baseRepository_ = baseRepository;
|
26
24
|
this.storeService_ = storeService;
|
27
25
|
}
|
28
|
-
|
29
|
-
return joiner_config_1.joinerConfig;
|
30
|
-
}
|
31
|
-
async create(data, sharedContext = {}) {
|
26
|
+
async createStores(data, sharedContext = {}) {
|
32
27
|
const input = Array.isArray(data) ? data : [data];
|
33
28
|
const result = await this.create_(input, sharedContext);
|
34
29
|
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0]);
|
@@ -36,9 +31,9 @@ class StoreModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
|
|
36
31
|
async create_(data, sharedContext = {}) {
|
37
32
|
let normalizedInput = StoreModuleService.normalizeInput(data);
|
38
33
|
StoreModuleService.validateCreateRequest(normalizedInput);
|
39
|
-
return await this.storeService_.
|
34
|
+
return (await this.storeService_.upsertWithReplace(normalizedInput, { relations: ["supported_currencies"] }, sharedContext)).entities;
|
40
35
|
}
|
41
|
-
async
|
36
|
+
async upsertStores(data, sharedContext = {}) {
|
42
37
|
const input = Array.isArray(data) ? data : [data];
|
43
38
|
const forUpdate = input.filter((store) => !!store.id);
|
44
39
|
const forCreate = input.filter((store) => !store.id);
|
@@ -52,7 +47,7 @@ class StoreModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
|
|
52
47
|
const result = (await (0, utils_1.promiseAll)(operations)).flat();
|
53
48
|
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0]);
|
54
49
|
}
|
55
|
-
async
|
50
|
+
async updateStores(idOrSelector, data, sharedContext = {}) {
|
56
51
|
let normalizedInput = [];
|
57
52
|
if ((0, utils_1.isString)(idOrSelector)) {
|
58
53
|
normalizedInput = [{ id: idOrSelector, ...data }];
|
@@ -70,85 +65,79 @@ class StoreModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
|
|
70
65
|
}
|
71
66
|
async update_(data, sharedContext = {}) {
|
72
67
|
const normalizedInput = StoreModuleService.normalizeInput(data);
|
73
|
-
|
74
|
-
return await this.storeService_.
|
68
|
+
StoreModuleService.validateUpdateRequest(normalizedInput);
|
69
|
+
return (await this.storeService_.upsertWithReplace(normalizedInput, { relations: ["supported_currencies"] }, sharedContext)).entities;
|
75
70
|
}
|
76
71
|
static normalizeInput(stores) {
|
77
72
|
return stores.map((store) => (0, utils_1.removeUndefined)({
|
78
73
|
...store,
|
74
|
+
supported_currencies: store.supported_currencies?.map((c) => ({
|
75
|
+
...c,
|
76
|
+
currency_code: c.currency_code.toLowerCase(),
|
77
|
+
})),
|
79
78
|
name: store.name?.trim(),
|
80
79
|
}));
|
81
80
|
}
|
82
81
|
static validateCreateRequest(stores) {
|
83
82
|
for (const store of stores) {
|
84
|
-
|
85
|
-
|
86
|
-
if (
|
87
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}
|
92
|
-
async validateUpdateRequest(stores) {
|
93
|
-
const dbStores = await this.storeService_.list({ id: stores.map((s) => s.id) }, { take: null });
|
94
|
-
const dbStoresMap = new Map(dbStores.map((dbStore) => [dbStore.id, dbStore]));
|
95
|
-
for (const store of stores) {
|
96
|
-
const dbStore = dbStoresMap.get(store.id);
|
97
|
-
// If it is updating both the supported currency codes and the default one, look in that list
|
98
|
-
if (store.supported_currency_codes && store.default_currency_code) {
|
99
|
-
if (!store.supported_currency_codes.includes(store.default_currency_code ?? "")) {
|
100
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Store does not have currency: ${store.default_currency_code}`);
|
83
|
+
if (store.supported_currencies?.length) {
|
84
|
+
const duplicates = (0, utils_1.getDuplicates)(store.supported_currencies?.map((c) => c.currency_code));
|
85
|
+
if (duplicates.length) {
|
86
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Duplicate currency codes: ${duplicates.join(", ")}`);
|
101
87
|
}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "You are not allowed to remove default currency from store currencies without replacing it as well");
|
88
|
+
let seenDefault = false;
|
89
|
+
store.supported_currencies?.forEach((c) => {
|
90
|
+
if (c.is_default) {
|
91
|
+
if (seenDefault) {
|
92
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Only one default currency is allowed`);
|
93
|
+
}
|
94
|
+
seenDefault = true;
|
95
|
+
}
|
96
|
+
});
|
97
|
+
if (!seenDefault) {
|
98
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `There should be a default currency set for the store`);
|
114
99
|
}
|
115
100
|
}
|
116
101
|
}
|
117
102
|
}
|
103
|
+
static validateUpdateRequest(stores) {
|
104
|
+
StoreModuleService.validateCreateRequest(stores);
|
105
|
+
}
|
118
106
|
}
|
119
107
|
exports.default = StoreModuleService;
|
120
108
|
__decorate([
|
121
|
-
(0, utils_1.InjectManager)(
|
109
|
+
(0, utils_1.InjectManager)(),
|
122
110
|
__param(1, (0, utils_1.MedusaContext)()),
|
123
111
|
__metadata("design:type", Function),
|
124
112
|
__metadata("design:paramtypes", [Object, Object]),
|
125
113
|
__metadata("design:returntype", Promise)
|
126
|
-
], StoreModuleService.prototype, "
|
114
|
+
], StoreModuleService.prototype, "createStores", null);
|
127
115
|
__decorate([
|
128
|
-
(0, utils_1.InjectTransactionManager)(
|
116
|
+
(0, utils_1.InjectTransactionManager)(),
|
129
117
|
__param(1, (0, utils_1.MedusaContext)()),
|
130
118
|
__metadata("design:type", Function),
|
131
119
|
__metadata("design:paramtypes", [Array, Object]),
|
132
120
|
__metadata("design:returntype", Promise)
|
133
121
|
], StoreModuleService.prototype, "create_", null);
|
134
122
|
__decorate([
|
135
|
-
(0, utils_1.InjectTransactionManager)(
|
123
|
+
(0, utils_1.InjectTransactionManager)(),
|
136
124
|
__param(1, (0, utils_1.MedusaContext)()),
|
137
125
|
__metadata("design:type", Function),
|
138
126
|
__metadata("design:paramtypes", [Object, Object]),
|
139
127
|
__metadata("design:returntype", Promise)
|
140
|
-
], StoreModuleService.prototype, "
|
128
|
+
], StoreModuleService.prototype, "upsertStores", null);
|
141
129
|
__decorate([
|
142
|
-
(0, utils_1.InjectManager)(
|
130
|
+
(0, utils_1.InjectManager)(),
|
143
131
|
__param(2, (0, utils_1.MedusaContext)()),
|
144
132
|
__metadata("design:type", Function),
|
145
133
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
146
134
|
__metadata("design:returntype", Promise)
|
147
|
-
], StoreModuleService.prototype, "
|
135
|
+
], StoreModuleService.prototype, "updateStores", null);
|
148
136
|
__decorate([
|
149
|
-
(0, utils_1.InjectTransactionManager)(
|
137
|
+
(0, utils_1.InjectTransactionManager)(),
|
150
138
|
__param(1, (0, utils_1.MedusaContext)()),
|
151
139
|
__metadata("design:type", Function),
|
152
140
|
__metadata("design:paramtypes", [Array, Object]),
|
153
141
|
__metadata("design:returntype", Promise)
|
154
142
|
], StoreModuleService.prototype, "update_", null);
|
143
|
+
//# sourceMappingURL=store-module-service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"store-module-service.js","sourceRoot":"","sources":["../../src/services/store-module-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,qDAOkC;AAClC,qDAUkC;AAElC,qCAA8C;AAQ9C,MAAqB,kBACnB,SAAQ,IAAA,qBAAa,EAGlB,EAAE,KAAK,EAAL,eAAK,EAAE,aAAa,EAAb,uBAAa,EAAE,CAAC;IAM5B,YACE,EAAE,cAAc,EAAE,YAAY,EAAwB,EACnC,iBAA4C;QAE/D,aAAa;QACb,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QAHA,sBAAiB,GAAjB,iBAAiB,CAA2B;QAI/D,IAAI,CAAC,eAAe,GAAG,cAAc,CAAA;QACrC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAA;IACnC,CAAC;IAYK,AAAN,KAAK,CAAC,YAAY,CAChB,IAA6D,EAC5C,gBAAyB,EAAE;QAE5C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IA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initialsetup20240227075933.ts","../src/migrations/migration20240621145944.ts","../src/models/currency.ts","../src/models/index.ts","../src/models/store.ts","../src/services/index.ts","../src/services/store-module-service.ts","../src/services/__tests__/noop.ts","../src/types/index.ts"],"version":"5.6.2"}
|
package/dist/types/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { StoreTypes } from "@medusajs/types";
|
2
|
-
import { IEventBusModuleService, Logger } from "@medusajs/types";
|
1
|
+
import { IEventBusModuleService, Logger, StoreTypes } from "@medusajs/framework/types";
|
3
2
|
export type InitializeModuleInjectableDependencies = {
|
4
3
|
logger?: Logger;
|
5
|
-
|
4
|
+
EventBus?: IEventBusModuleService;
|
6
5
|
};
|
7
6
|
export type UpdateStoreInput = StoreTypes.UpdateStoreDTO & {
|
8
7
|
id: string;
|
9
8
|
};
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,MAAM,EACN,UAAU,EACX,MAAM,2BAA2B,CAAA;AAElC,MAAM,MAAM,sCAAsC,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,sBAAsB,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
package/dist/types/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/store",
|
3
|
-
"version": "0.
|
3
|
+
"version": "1.0.0-rc-20241001083650",
|
4
4
|
"description": "Medusa Store module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
7
7
|
"files": [
|
8
|
-
"dist"
|
8
|
+
"dist",
|
9
|
+
"!dist/**/__tests__",
|
10
|
+
"!dist/**/__mocks__",
|
11
|
+
"!dist/**/__fixtures__"
|
9
12
|
],
|
10
13
|
"engines": {
|
11
|
-
"node": ">=
|
12
|
-
},
|
13
|
-
"bin": {
|
14
|
-
"medusa-store-seed": "dist/scripts/bin/run-seed.js"
|
14
|
+
"node": ">=20"
|
15
15
|
},
|
16
16
|
"repository": {
|
17
17
|
"type": "git",
|
@@ -26,8 +26,8 @@
|
|
26
26
|
"scripts": {
|
27
27
|
"watch": "tsc --build --watch",
|
28
28
|
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
29
|
-
"
|
30
|
-
"build": "rimraf dist && tsc --build &&
|
29
|
+
"resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
|
30
|
+
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
31
31
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
32
32
|
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
33
33
|
"migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
|
@@ -37,25 +37,24 @@
|
|
37
37
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
|
+
"@medusajs/framework": "1.0.0-rc-20241001083650",
|
40
41
|
"@mikro-orm/cli": "5.9.7",
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
42
|
+
"@mikro-orm/core": "5.9.7",
|
43
|
+
"@mikro-orm/migrations": "5.9.7",
|
44
|
+
"@mikro-orm/postgresql": "5.9.7",
|
45
|
+
"@swc/core": "^1.7.28",
|
46
|
+
"@swc/jest": "^0.2.36",
|
47
|
+
"jest": "^29.7.0",
|
48
|
+
"medusa-test-utils": "2.0.0-rc-20241001083650",
|
44
49
|
"rimraf": "^3.0.2",
|
45
|
-
"ts-jest": "^29.1.1",
|
46
|
-
"ts-node": "^10.9.1",
|
47
50
|
"tsc-alias": "^1.8.6",
|
48
|
-
"typescript": "^5.
|
51
|
+
"typescript": "^5.6.2"
|
49
52
|
},
|
50
|
-
"
|
51
|
-
"@medusajs/
|
52
|
-
"@medusajs/types": "^1.11.17",
|
53
|
-
"@medusajs/utils": "^1.11.10",
|
53
|
+
"peerDependencies": {
|
54
|
+
"@medusajs/framework": "1.0.0-rc-20241001083650",
|
54
55
|
"@mikro-orm/core": "5.9.7",
|
55
56
|
"@mikro-orm/migrations": "5.9.7",
|
56
57
|
"@mikro-orm/postgresql": "5.9.7",
|
57
|
-
"awilix": "^8.0.
|
58
|
-
"dotenv": "^16.4.5",
|
59
|
-
"knex": "2.4.2"
|
58
|
+
"awilix": "^8.0.1"
|
60
59
|
}
|
61
60
|
}
|
package/dist/joiner-config.d.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
import { ModuleJoinerConfig } from "@medusajs/types";
|
2
|
-
import { MapToConfig } from "@medusajs/utils";
|
3
|
-
export declare const LinkableKeys: Record<string, string>;
|
4
|
-
export declare const entityNameToLinkableKeysMap: MapToConfig;
|
5
|
-
export declare const joinerConfig: ModuleJoinerConfig;
|
package/dist/joiner-config.js
DELETED
@@ -1,29 +0,0 @@
|
|
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.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
|
7
|
-
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
8
|
-
const store_1 = __importDefault(require("./models/store"));
|
9
|
-
exports.LinkableKeys = {};
|
10
|
-
const entityLinkableKeysMap = {};
|
11
|
-
Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
|
12
|
-
entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
|
13
|
-
entityLinkableKeysMap[value].push({
|
14
|
-
mapTo: key,
|
15
|
-
valueFrom: key.split("_").pop(),
|
16
|
-
});
|
17
|
-
});
|
18
|
-
exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
|
19
|
-
exports.joinerConfig = {
|
20
|
-
serviceName: modules_sdk_1.Modules.STORE,
|
21
|
-
primaryKeys: ["id"],
|
22
|
-
linkableKeys: exports.LinkableKeys,
|
23
|
-
alias: [
|
24
|
-
{
|
25
|
-
name: ["store", "stores"],
|
26
|
-
args: { entity: store_1.default.name },
|
27
|
-
},
|
28
|
-
],
|
29
|
-
};
|
@@ -1,58 +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
|
-
exports.moduleDefinition = void 0;
|
27
|
-
const ModuleServices = __importStar(require("./services"));
|
28
|
-
const _services_1 = require("./services");
|
29
|
-
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
30
|
-
const Models = __importStar(require("./models"));
|
31
|
-
const ModuleModels = __importStar(require("./models"));
|
32
|
-
const utils_1 = require("@medusajs/utils");
|
33
|
-
const ModuleRepositories = __importStar(require("./repositories"));
|
34
|
-
const migrationScriptOptions = {
|
35
|
-
moduleName: modules_sdk_1.Modules.STORE,
|
36
|
-
models: Models,
|
37
|
-
pathToMigrations: __dirname + "/migrations",
|
38
|
-
};
|
39
|
-
const runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
|
40
|
-
const revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
|
41
|
-
const containerLoader = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
|
42
|
-
moduleModels: ModuleModels,
|
43
|
-
moduleRepositories: ModuleRepositories,
|
44
|
-
moduleServices: ModuleServices,
|
45
|
-
});
|
46
|
-
const connectionLoader = utils_1.ModulesSdkUtils.mikroOrmConnectionLoaderFactory({
|
47
|
-
moduleName: modules_sdk_1.Modules.STORE,
|
48
|
-
moduleModels: Object.values(Models),
|
49
|
-
migrationsPath: __dirname + "/migrations",
|
50
|
-
});
|
51
|
-
const service = _services_1.StoreModuleService;
|
52
|
-
const loaders = [containerLoader, connectionLoader];
|
53
|
-
exports.moduleDefinition = {
|
54
|
-
service,
|
55
|
-
loaders,
|
56
|
-
revertMigration,
|
57
|
-
runMigrations,
|
58
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
|
@@ -1,5 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BaseRepository = void 0;
|
4
|
-
var utils_1 = require("@medusajs/utils");
|
5
|
-
Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
"use strict";
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4
|
-
if (k2 === undefined) k2 = k;
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
8
|
-
}
|
9
|
-
Object.defineProperty(o, k2, desc);
|
10
|
-
}) : (function(o, m, k, k2) {
|
11
|
-
if (k2 === undefined) k2 = k;
|
12
|
-
o[k2] = m[k];
|
13
|
-
}));
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
16
|
-
}) : function(o, v) {
|
17
|
-
o["default"] = v;
|
18
|
-
});
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
20
|
-
if (mod && mod.__esModule) return mod;
|
21
|
-
var result = {};
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
23
|
-
__setModuleDefault(result, mod);
|
24
|
-
return result;
|
25
|
-
};
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
27
|
-
const utils_1 = require("@medusajs/utils");
|
28
|
-
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
29
|
-
const Models = __importStar(require("../../models"));
|
30
|
-
const os_1 = require("os");
|
31
|
-
const args = process.argv;
|
32
|
-
const path = args.pop();
|
33
|
-
exports.default = (async () => {
|
34
|
-
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
35
|
-
config();
|
36
|
-
if (!path) {
|
37
|
-
throw new Error(`filePath is required.${os_1.EOL}Example: medusa-store-seed <filePath>`);
|
38
|
-
}
|
39
|
-
const run = utils_1.ModulesSdkUtils.buildSeedScript({
|
40
|
-
moduleName: modules_sdk_1.Modules.STORE,
|
41
|
-
models: Models,
|
42
|
-
pathToMigrations: __dirname + "/../../migrations",
|
43
|
-
seedHandler: async ({ manager, data }) => {
|
44
|
-
// TODO: Add seed logic
|
45
|
-
},
|
46
|
-
});
|
47
|
-
await run({ path });
|
48
|
-
})();
|