@medusajs/sales-channel 0.1.2-snapshot-20240718073308 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +9 -6
- package/dist/index.js +43 -4
- package/dist/initialize/index.d.ts +4 -0
- package/dist/initialize/index.js +17 -0
- package/dist/joiner-config.d.ts +7 -0
- package/dist/joiner-config.js +28 -0
- package/dist/loaders/connection.d.ts +4 -0
- package/dist/loaders/connection.js +41 -0
- package/dist/loaders/container.d.ts +2 -0
- package/dist/loaders/container.js +34 -0
- package/dist/loaders/index.d.ts +2 -0
- package/dist/loaders/index.js +18 -0
- package/dist/migrations/Migration20240115152146.d.ts +0 -1
- package/dist/models/index.d.ts +0 -1
- package/dist/models/sales-channel.d.ts +1 -2
- package/dist/models/sales-channel.js +1 -1
- package/dist/module-definition.d.ts +2 -0
- package/dist/module-definition.js +15 -0
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.js +5 -0
- package/dist/scripts/bin/run-seed.d.ts +3 -0
- package/dist/scripts/bin/run-seed.js +50 -0
- package/dist/scripts/seed-utils.d.ts +4 -0
- package/dist/scripts/seed-utils.js +12 -0
- package/dist/services/index.d.ts +0 -1
- package/dist/services/sales-channel-module.d.ts +16 -18
- package/dist/services/sales-channel-module.js +19 -17
- package/dist/types/index.d.ts +0 -1
- package/package.json +14 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/migrations/Migration20240115152146.d.ts.map +0 -1
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/sales-channel.d.ts.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/sales-channel-module.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
}
|
5
|
-
export
|
6
|
-
|
1
|
+
import { moduleDefinition } from "./module-definition";
|
2
|
+
export default moduleDefinition;
|
3
|
+
export declare const runMigrations: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
|
4
|
+
export declare const revertMigration: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
|
5
|
+
export * from "./initialize";
|
6
|
+
export * from "./types";
|
7
|
+
export * from "./loaders";
|
8
|
+
export * from "./models";
|
9
|
+
export * from "./services";
|
package/dist/index.js
CHANGED
@@ -1,7 +1,46 @@
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
27
|
+
};
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.revertMigration = exports.runMigrations = void 0;
|
30
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
3
31
|
const utils_1 = require("@medusajs/utils");
|
4
|
-
const
|
5
|
-
|
6
|
-
|
7
|
-
|
32
|
+
const SalesChannelModels = __importStar(require("./models"));
|
33
|
+
const module_definition_1 = require("./module-definition");
|
34
|
+
exports.default = module_definition_1.moduleDefinition;
|
35
|
+
const migrationScriptOptions = {
|
36
|
+
moduleName: modules_sdk_1.Modules.SALES_CHANNEL,
|
37
|
+
models: SalesChannelModels,
|
38
|
+
pathToMigrations: __dirname + "/migrations",
|
39
|
+
};
|
40
|
+
exports.runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
|
41
|
+
exports.revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
|
42
|
+
__exportStar(require("./initialize"), exports);
|
43
|
+
__exportStar(require("./types"), exports);
|
44
|
+
__exportStar(require("./loaders"), exports);
|
45
|
+
__exportStar(require("./models"), exports);
|
46
|
+
__exportStar(require("./services"), exports);
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
|
2
|
+
import { ModulesSdkTypes, ISalesChannelModuleService } from "@medusajs/types";
|
3
|
+
import { InitializeModuleInjectableDependencies } from "../types";
|
4
|
+
export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<ISalesChannelModuleService>;
|
@@ -0,0 +1,17 @@
|
|
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.SALES_CHANNEL;
|
8
|
+
const loaded = await modules_sdk_1.MedusaModule.bootstrap({
|
9
|
+
moduleKey: serviceKey,
|
10
|
+
defaultPath: modules_sdk_1.MODULE_PACKAGE_NAMES[modules_sdk_1.Modules.SALES_CHANNEL],
|
11
|
+
declaration: options,
|
12
|
+
injectedDependencies,
|
13
|
+
moduleExports: module_definition_1.moduleDefinition,
|
14
|
+
});
|
15
|
+
return loaded[serviceKey];
|
16
|
+
};
|
17
|
+
exports.initialize = initialize;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { ModuleJoinerConfig } from "@medusajs/types";
|
2
|
+
import { MapToConfig } from "@medusajs/utils";
|
3
|
+
export declare const LinkableKeys: {
|
4
|
+
sales_channel_id: string;
|
5
|
+
};
|
6
|
+
export declare const entityNameToLinkableKeysMap: MapToConfig;
|
7
|
+
export declare const joinerConfig: ModuleJoinerConfig;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
5
|
+
const _models_1 = require("./models");
|
6
|
+
exports.LinkableKeys = {
|
7
|
+
sales_channel_id: _models_1.SalesChannel.name,
|
8
|
+
};
|
9
|
+
const entityLinkableKeysMap = {};
|
10
|
+
Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
|
11
|
+
entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
|
12
|
+
entityLinkableKeysMap[value].push({
|
13
|
+
mapTo: key,
|
14
|
+
valueFrom: key.split("_").pop(),
|
15
|
+
});
|
16
|
+
});
|
17
|
+
exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
|
18
|
+
exports.joinerConfig = {
|
19
|
+
serviceName: modules_sdk_1.Modules.SALES_CHANNEL,
|
20
|
+
primaryKeys: ["id"],
|
21
|
+
linkableKeys: exports.LinkableKeys,
|
22
|
+
alias: [
|
23
|
+
{
|
24
|
+
name: ["sales_channel", "sales_channels"],
|
25
|
+
args: { entity: "SalesChannel" },
|
26
|
+
},
|
27
|
+
],
|
28
|
+
};
|
@@ -0,0 +1,4 @@
|
|
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;
|
@@ -0,0 +1,41 @@
|
|
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 modules_sdk_1 = require("@medusajs/modules-sdk");
|
27
|
+
const utils_1 = require("@medusajs/utils");
|
28
|
+
const SalesChannelModels = __importStar(require("../models"));
|
29
|
+
exports.default = async ({ options, container, logger, }, moduleDeclaration) => {
|
30
|
+
const entities = Object.values(SalesChannelModels);
|
31
|
+
const pathToMigrations = __dirname + "/../migrations";
|
32
|
+
await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
|
33
|
+
moduleName: modules_sdk_1.Modules.SALES_CHANNEL,
|
34
|
+
entities,
|
35
|
+
container,
|
36
|
+
options,
|
37
|
+
moduleDeclaration,
|
38
|
+
logger,
|
39
|
+
pathToMigrations,
|
40
|
+
});
|
41
|
+
};
|
@@ -0,0 +1,34 @@
|
|
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
|
+
});
|
@@ -0,0 +1,18 @@
|
|
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);
|
package/dist/models/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
2
2
|
import { OptionalProps } from "@mikro-orm/core";
|
3
|
-
type SalesChannelOptionalProps = "is_disabled" | DAL.
|
3
|
+
type SalesChannelOptionalProps = "is_disabled" | DAL.EntityDateColumns;
|
4
4
|
export default class SalesChannel {
|
5
5
|
[OptionalProps]?: SalesChannelOptionalProps;
|
6
6
|
id: string;
|
@@ -15,4 +15,3 @@ export default class SalesChannel {
|
|
15
15
|
onInit(): void;
|
16
16
|
}
|
17
17
|
export {};
|
18
|
-
//# sourceMappingURL=sales-channel.d.ts.map
|
@@ -41,7 +41,7 @@ __decorate([
|
|
41
41
|
], SalesChannel.prototype, "description", void 0);
|
42
42
|
__decorate([
|
43
43
|
(0, core_1.Property)({ columnType: "boolean", default: false }),
|
44
|
-
__metadata("design:type",
|
44
|
+
__metadata("design:type", Object)
|
45
45
|
], SalesChannel.prototype, "is_disabled", void 0);
|
46
46
|
__decorate([
|
47
47
|
(0, core_1.Property)({
|
@@ -0,0 +1,15 @@
|
|
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.moduleDefinition = void 0;
|
7
|
+
const _services_1 = require("./services");
|
8
|
+
const connection_1 = __importDefault(require("./loaders/connection"));
|
9
|
+
const container_1 = __importDefault(require("./loaders/container"));
|
10
|
+
const service = _services_1.SalesChannelModuleService;
|
11
|
+
const loaders = [container_1.default, connection_1.default];
|
12
|
+
exports.moduleDefinition = {
|
13
|
+
service,
|
14
|
+
loaders,
|
15
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
|
@@ -0,0 +1,5 @@
|
|
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; } });
|
@@ -0,0 +1,50 @@
|
|
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 ProductModels = __importStar(require("../../models"));
|
30
|
+
const seed_utils_1 = require("../seed-utils");
|
31
|
+
const os_1 = require("os");
|
32
|
+
const args = process.argv;
|
33
|
+
const path = args.pop();
|
34
|
+
exports.default = (async () => {
|
35
|
+
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
36
|
+
config();
|
37
|
+
if (!path) {
|
38
|
+
throw new Error(`filePath is required.${os_1.EOL}Example: medusa-product-seed <filePath>`);
|
39
|
+
}
|
40
|
+
const run = utils_1.ModulesSdkUtils.buildSeedScript({
|
41
|
+
moduleName: modules_sdk_1.Modules.PRODUCT,
|
42
|
+
models: ProductModels,
|
43
|
+
pathToMigrations: __dirname + "/../../migrations",
|
44
|
+
seedHandler: async ({ manager, data }) => {
|
45
|
+
const { salesChannelData } = data;
|
46
|
+
await (0, seed_utils_1.createSalesChannels)(manager, salesChannelData);
|
47
|
+
},
|
48
|
+
});
|
49
|
+
await run({ path });
|
50
|
+
})();
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { SalesChannel } from "../models";
|
2
|
+
import { RequiredEntityData } from "@mikro-orm/core";
|
3
|
+
import { SqlEntityManager } from "@mikro-orm/postgresql";
|
4
|
+
export declare function createSalesChannels(manager: SqlEntityManager, data: RequiredEntityData<SalesChannel>[]): Promise<SalesChannel[]>;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createSalesChannels = void 0;
|
4
|
+
const _models_1 = require("../models");
|
5
|
+
async function createSalesChannels(manager, data) {
|
6
|
+
const channels = data.map((channel) => {
|
7
|
+
return manager.create(_models_1.SalesChannel, channel);
|
8
|
+
});
|
9
|
+
await manager.persistAndFlush(channels);
|
10
|
+
return channels;
|
11
|
+
}
|
12
|
+
exports.createSalesChannels = createSalesChannels;
|
package/dist/services/index.d.ts
CHANGED
@@ -1,27 +1,25 @@
|
|
1
|
-
import { Context, CreateSalesChannelDTO, DAL, FilterableSalesChannelProps, InternalModuleDeclaration, ISalesChannelModuleService, ModulesSdkTypes, SalesChannelDTO, UpdateSalesChannelDTO
|
1
|
+
import { Context, CreateSalesChannelDTO, DAL, FilterableSalesChannelProps, InternalModuleDeclaration, ISalesChannelModuleService, ModuleJoinerConfig, ModulesSdkTypes, SalesChannelDTO, UpdateSalesChannelDTO } from "@medusajs/types";
|
2
|
+
import { ModulesSdkUtils } from "@medusajs/utils";
|
2
3
|
import { SalesChannel } from "../models";
|
4
|
+
import { UpsertSalesChannelDTO } from "@medusajs/types";
|
3
5
|
type InjectedDependencies = {
|
4
6
|
baseRepository: DAL.RepositoryService;
|
5
|
-
salesChannelService: ModulesSdkTypes.
|
7
|
+
salesChannelService: ModulesSdkTypes.InternalModuleService<any>;
|
6
8
|
};
|
7
|
-
declare const SalesChannelModuleService_base:
|
8
|
-
|
9
|
-
dto: SalesChannelDTO;
|
10
|
-
};
|
11
|
-
}>;
|
12
|
-
export default class SalesChannelModuleService extends SalesChannelModuleService_base implements ISalesChannelModuleService {
|
9
|
+
declare const SalesChannelModuleService_base: new (container: InjectedDependencies) => ModulesSdkUtils.AbstractModuleService<InjectedDependencies, SalesChannelDTO, {}>;
|
10
|
+
export default class SalesChannelModuleService<TEntity extends SalesChannel = SalesChannel> extends SalesChannelModuleService_base implements ISalesChannelModuleService {
|
13
11
|
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
14
12
|
protected baseRepository_: DAL.RepositoryService;
|
15
|
-
protected readonly salesChannelService_: ModulesSdkTypes.
|
13
|
+
protected readonly salesChannelService_: ModulesSdkTypes.InternalModuleService<TEntity>;
|
16
14
|
constructor({ baseRepository, salesChannelService }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
__joinerConfig(): ModuleJoinerConfig;
|
16
|
+
create(data: CreateSalesChannelDTO[], sharedContext?: Context): Promise<SalesChannelDTO[]>;
|
17
|
+
create(data: CreateSalesChannelDTO, sharedContext?: Context): Promise<SalesChannelDTO>;
|
18
|
+
create_(data: CreateSalesChannelDTO[], sharedContext: Context): Promise<SalesChannel[]>;
|
19
|
+
update(id: string, data: UpdateSalesChannelDTO, sharedContext?: Context): Promise<SalesChannelDTO>;
|
20
|
+
update(selector: FilterableSalesChannelProps, data: UpdateSalesChannelDTO, sharedContext?: Context): Promise<SalesChannelDTO[]>;
|
21
|
+
update_(data: UpdateSalesChannelDTO[], sharedContext: Context): Promise<TEntity[]>;
|
22
|
+
upsert(data: UpsertSalesChannelDTO[], sharedContext?: Context): Promise<SalesChannelDTO[]>;
|
23
|
+
upsert(data: UpsertSalesChannelDTO, sharedContext?: Context): Promise<SalesChannelDTO>;
|
25
24
|
}
|
26
25
|
export {};
|
27
|
-
//# sourceMappingURL=sales-channel-module.d.ts.map
|
@@ -14,9 +14,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const utils_1 = require("@medusajs/utils");
|
16
16
|
const _models_1 = require("../models");
|
17
|
-
|
18
|
-
|
19
|
-
}) {
|
17
|
+
const joiner_config_1 = require("../joiner-config");
|
18
|
+
class SalesChannelModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.SalesChannel, [], joiner_config_1.entityNameToLinkableKeysMap) {
|
20
19
|
constructor({ baseRepository, salesChannelService }, moduleDeclaration) {
|
21
20
|
// @ts-ignore
|
22
21
|
super(...arguments);
|
@@ -24,17 +23,20 @@ class SalesChannelModuleService extends (0, utils_1.MedusaService)({
|
|
24
23
|
this.baseRepository_ = baseRepository;
|
25
24
|
this.salesChannelService_ = salesChannelService;
|
26
25
|
}
|
27
|
-
|
26
|
+
__joinerConfig() {
|
27
|
+
return joiner_config_1.joinerConfig;
|
28
|
+
}
|
29
|
+
async create(data, sharedContext = {}) {
|
28
30
|
const input = Array.isArray(data) ? data : [data];
|
29
|
-
const result = await this.
|
31
|
+
const result = await this.create_(input, sharedContext);
|
30
32
|
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0], {
|
31
33
|
populate: true,
|
32
34
|
});
|
33
35
|
}
|
34
|
-
async
|
36
|
+
async create_(data, sharedContext) {
|
35
37
|
return await this.salesChannelService_.create(data, sharedContext);
|
36
38
|
}
|
37
|
-
async
|
39
|
+
async update(idOrSelector, data, sharedContext = {}) {
|
38
40
|
let normalizedInput = [];
|
39
41
|
if ((0, utils_1.isString)(idOrSelector)) {
|
40
42
|
normalizedInput = [{ id: idOrSelector, ...data }];
|
@@ -46,24 +48,24 @@ class SalesChannelModuleService extends (0, utils_1.MedusaService)({
|
|
46
48
|
...data,
|
47
49
|
}));
|
48
50
|
}
|
49
|
-
const result = await this.
|
51
|
+
const result = await this.update_(normalizedInput, sharedContext);
|
50
52
|
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0], {
|
51
53
|
populate: true,
|
52
54
|
});
|
53
55
|
}
|
54
|
-
async
|
56
|
+
async update_(data, sharedContext) {
|
55
57
|
return await this.salesChannelService_.update(data, sharedContext);
|
56
58
|
}
|
57
|
-
async
|
59
|
+
async upsert(data, sharedContext = {}) {
|
58
60
|
const input = Array.isArray(data) ? data : [data];
|
59
61
|
const forUpdate = input.filter((channel) => !!channel.id);
|
60
62
|
const forCreate = input.filter((channel) => !channel.id);
|
61
63
|
const operations = [];
|
62
64
|
if (forCreate.length) {
|
63
|
-
operations.push(this.
|
65
|
+
operations.push(this.create_(forCreate, sharedContext));
|
64
66
|
}
|
65
67
|
if (forUpdate.length) {
|
66
|
-
operations.push(this.
|
68
|
+
operations.push(this.update_(forUpdate, sharedContext));
|
67
69
|
}
|
68
70
|
const result = (await (0, utils_1.promiseAll)(operations)).flat();
|
69
71
|
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0]);
|
@@ -76,31 +78,31 @@ __decorate([
|
|
76
78
|
__metadata("design:type", Function),
|
77
79
|
__metadata("design:paramtypes", [Object, Object]),
|
78
80
|
__metadata("design:returntype", Promise)
|
79
|
-
], SalesChannelModuleService.prototype, "
|
81
|
+
], SalesChannelModuleService.prototype, "create", null);
|
80
82
|
__decorate([
|
81
83
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
82
84
|
__param(1, (0, utils_1.MedusaContext)()),
|
83
85
|
__metadata("design:type", Function),
|
84
86
|
__metadata("design:paramtypes", [Array, Object]),
|
85
87
|
__metadata("design:returntype", Promise)
|
86
|
-
], SalesChannelModuleService.prototype, "
|
88
|
+
], SalesChannelModuleService.prototype, "create_", null);
|
87
89
|
__decorate([
|
88
90
|
(0, utils_1.InjectManager)("baseRepository_"),
|
89
91
|
__param(2, (0, utils_1.MedusaContext)()),
|
90
92
|
__metadata("design:type", Function),
|
91
93
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
92
94
|
__metadata("design:returntype", Promise)
|
93
|
-
], SalesChannelModuleService.prototype, "
|
95
|
+
], SalesChannelModuleService.prototype, "update", null);
|
94
96
|
__decorate([
|
95
97
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
96
98
|
__metadata("design:type", Function),
|
97
99
|
__metadata("design:paramtypes", [Array, Object]),
|
98
100
|
__metadata("design:returntype", Promise)
|
99
|
-
], SalesChannelModuleService.prototype, "
|
101
|
+
], SalesChannelModuleService.prototype, "update_", null);
|
100
102
|
__decorate([
|
101
103
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
102
104
|
__param(1, (0, utils_1.MedusaContext)()),
|
103
105
|
__metadata("design:type", Function),
|
104
106
|
__metadata("design:paramtypes", [Object, Object]),
|
105
107
|
__metadata("design:returntype", Promise)
|
106
|
-
], SalesChannelModuleService.prototype, "
|
108
|
+
], SalesChannelModuleService.prototype, "upsert", null);
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/sales-channel",
|
3
|
-
"version": "0.1.2
|
3
|
+
"version": "0.1.2",
|
4
4
|
"description": "Medusa Sales Channel module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -8,7 +8,10 @@
|
|
8
8
|
"dist"
|
9
9
|
],
|
10
10
|
"engines": {
|
11
|
-
"node": ">=
|
11
|
+
"node": ">=16"
|
12
|
+
},
|
13
|
+
"bin": {
|
14
|
+
"medusa-sales-channel-seed": "dist/scripts/bin/run-seed.js"
|
12
15
|
},
|
13
16
|
"repository": {
|
14
17
|
"type": "git",
|
@@ -34,22 +37,25 @@
|
|
34
37
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
35
38
|
},
|
36
39
|
"devDependencies": {
|
37
|
-
"@medusajs/modules-sdk": "1.13.0-snapshot-20240718073308",
|
38
|
-
"@medusajs/types": "1.12.0-snapshot-20240718073308",
|
39
40
|
"@mikro-orm/cli": "5.9.7",
|
40
41
|
"cross-env": "^5.2.1",
|
41
|
-
"jest": "^29.
|
42
|
-
"medusa-test-utils": "1.1.45
|
42
|
+
"jest": "^29.6.3",
|
43
|
+
"medusa-test-utils": "^1.1.45",
|
43
44
|
"rimraf": "^3.0.2",
|
45
|
+
"ts-jest": "^29.1.1",
|
44
46
|
"ts-node": "^10.9.1",
|
45
47
|
"tsc-alias": "^1.8.6",
|
46
48
|
"typescript": "^5.1.6"
|
47
49
|
},
|
48
50
|
"dependencies": {
|
49
|
-
"@medusajs/
|
51
|
+
"@medusajs/modules-sdk": "^1.12.12",
|
52
|
+
"@medusajs/types": "^1.11.17",
|
53
|
+
"@medusajs/utils": "^1.11.10",
|
50
54
|
"@mikro-orm/core": "5.9.7",
|
51
55
|
"@mikro-orm/migrations": "5.9.7",
|
52
56
|
"@mikro-orm/postgresql": "5.9.7",
|
53
|
-
"awilix": "^8.0.0"
|
57
|
+
"awilix": "^8.0.0",
|
58
|
+
"dotenv": "^16.4.5",
|
59
|
+
"knex": "2.4.2"
|
54
60
|
}
|
55
61
|
}
|
package/dist/index.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAA;;;;AAErD,wBAEE"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Migration20240115152146.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240115152146.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ1B"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"sales-channel.d.ts","sourceRoot":"","sources":["../../src/models/sales-channel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAML,aAAa,EAGd,MAAM,iBAAiB,CAAA;AAExB,KAAK,yBAAyB,GAAG,aAAa,GAAG,GAAG,CAAC,gBAAgB,CAAA;AAIrE,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,CAAC,aAAa,CAAC,CAAC,EAAE,yBAAyB,CAAA;IAG3C,EAAE,EAAG,MAAM,CAAA;IAIX,IAAI,EAAG,MAAM,CAAA;IAIb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;IAGjC,WAAW,EAAE,OAAO,CAAQ;IAO5B,UAAU,EAAE,IAAI,CAAA;IAGhB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAO;IAQ/C,UAAU,EAAE,IAAI,CAAA;IAIhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,wBAAwB,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"sales-channel-module.d.ts","sourceRoot":"","sources":["../../src/services/sales-channel-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,qBAAqB,EACrB,GAAG,EACH,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,iBAAiB,CAAA;AAUxB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAGtC,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,GAAG,CAAC,iBAAiB,CAAA;IACrC,mBAAmB,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAA;CACjE,CAAA;;kBAGuC;QAAE,GAAG,EAAE,eAAe,CAAA;KAAE;;AADhE,MAAM,CAAC,OAAO,OAAO,yBACnB,SAAQ,8BAGR,YAAW,0BAA0B;IAOnC,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,yBAAyB;IALjE,SAAS,CAAC,eAAe,EAAE,GAAG,CAAC,iBAAiB,CAAA;IAChD,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,eAAe,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAA;gBAG3F,EAAE,cAAc,EAAE,mBAAmB,EAAE,EAAE,oBAAoB,EAC1C,iBAAiB,EAAE,yBAAyB;IAS3D,mBAAmB,CACvB,IAAI,EAAE,qBAAqB,EAAE,EAC7B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC;IACvB,mBAAmB,CACvB,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,eAAe,CAAC;IAoBrB,oBAAoB,CACxB,IAAI,EAAE,qBAAqB,EAAE,EACZ,aAAa,EAAE,OAAO,GACtC,OAAO,CAAC,YAAY,EAAE,CAAC;IAKpB,mBAAmB,CACvB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,eAAe,CAAC;IACrB,mBAAmB,CACvB,QAAQ,EAAE,2BAA2B,EACrC,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC;IAsCvB,oBAAoB,CACxB,IAAI,EAAE,qBAAqB,EAAE,EAC7B,aAAa,EAAE,OAAO;IAKlB,mBAAmB,CACvB,IAAI,EAAE,qBAAqB,EAAE,EAC7B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC;IACvB,mBAAmB,CACvB,IAAI,EAAE,qBAAqB,EAC3B,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,eAAe,CAAC;CA4B5B"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAE/D,MAAM,MAAM,sCAAsC,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA"}
|