@medusajs/product 0.0.1 → 0.0.2-beta-20230619170349
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/models/product-variant.d.ts +1 -1
- package/dist/models/product.d.ts +2 -2
- package/dist/scripts/bin/run-migration-down.d.ts +1 -0
- package/dist/scripts/bin/run-migration-down.js +3 -2
- package/dist/scripts/bin/run-migration-up.d.ts +1 -0
- package/dist/scripts/bin/run-migration-up.js +3 -2
- package/dist/scripts/bin/run-seed.d.ts +1 -0
- package/dist/scripts/bin/run-seed.js +2 -1
- package/dist/scripts/migration-up.js +7 -3
- package/dist/scripts/seed.js +2 -1
- package/dist/services/product-category.d.ts +1 -1
- package/dist/services/product-collection.d.ts +1 -1
- package/dist/services/product-module-service.d.ts +1 -1
- package/dist/services/product-tag.d.ts +1 -1
- package/dist/services/product-variant.d.ts +1 -1
- package/dist/services/product.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/utils/create-connection.js +4 -13
- package/package.json +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Collection, OptionalProps } from "@mikro-orm/core";
|
|
2
2
|
import { Product } from ".";
|
|
3
3
|
import ProductOptionValue from "./product-option-value";
|
|
4
|
-
|
|
4
|
+
type OptionalFields = "created_at" | "updated_at" | "updated_at" | "deleted_at" | "allow_backorder" | "manage_inventory" | "product" | "product_id";
|
|
5
5
|
declare class ProductVariant {
|
|
6
6
|
[OptionalProps]?: OptionalFields;
|
|
7
7
|
id: string;
|
package/dist/models/product.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import ProductOption from "./product-option";
|
|
|
6
6
|
import ProductTag from "./product-tag";
|
|
7
7
|
import ProductType from "./product-type";
|
|
8
8
|
import ProductVariant from "./product-variant";
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
type OptionalRelations = "collection" | "type";
|
|
10
|
+
type OptionalFields = "is_giftcard" | "discountable" | "created_at" | "updated_at" | "deleted_at";
|
|
11
11
|
declare class Product {
|
|
12
12
|
[OptionalProps]?: OptionalRelations | OptionalFields;
|
|
13
13
|
id: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
@@ -23,9 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
25
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const migration_down_1 = require("../migration-down");
|
|
27
27
|
exports.default = (async () => {
|
|
28
|
+
const { revertMigration } = await Promise.resolve().then(() => __importStar(require("../migration-down")));
|
|
28
29
|
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
|
29
30
|
config();
|
|
30
|
-
await
|
|
31
|
+
await revertMigration();
|
|
31
32
|
})();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
@@ -23,9 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
24
|
return result;
|
|
24
25
|
};
|
|
25
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const migration_up_1 = require("../migration-up");
|
|
27
27
|
exports.default = (async () => {
|
|
28
|
+
const { runMigrations } = await Promise.resolve().then(() => __importStar(require("../migration-up")));
|
|
28
29
|
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
|
29
30
|
config();
|
|
30
|
-
await
|
|
31
|
+
await runMigrations();
|
|
31
32
|
})();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
4
|
if (k2 === undefined) k2 = k;
|
|
@@ -31,7 +32,7 @@ exports.default = (async () => {
|
|
|
31
32
|
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
|
32
33
|
config();
|
|
33
34
|
if (!path) {
|
|
34
|
-
throw new Error(`filePath is required.${os_1.EOL}Example:
|
|
35
|
+
throw new Error(`filePath is required.${os_1.EOL}Example: medusa-product-seed <filePath>`);
|
|
35
36
|
}
|
|
36
37
|
await (0, seed_1.run)({ path });
|
|
37
38
|
})();
|
|
@@ -40,11 +40,15 @@ async function runMigrations({ options, logger, } = {}) {
|
|
|
40
40
|
const orm = await (0, utils_1.createConnection)(dbData, entities);
|
|
41
41
|
try {
|
|
42
42
|
const migrator = orm.getMigrator();
|
|
43
|
-
await migrator.
|
|
44
|
-
logger
|
|
43
|
+
const pendingMigrations = await migrator.getPendingMigrations();
|
|
44
|
+
logger.info("Running pending migrations:", pendingMigrations);
|
|
45
|
+
await migrator.up({
|
|
46
|
+
migrations: pendingMigrations.map((m) => m.name),
|
|
47
|
+
});
|
|
48
|
+
logger.info("Product module migration executed");
|
|
45
49
|
}
|
|
46
50
|
catch (error) {
|
|
47
|
-
logger
|
|
51
|
+
logger.error(`Product module migration failed to run - Error: ${error}`);
|
|
48
52
|
}
|
|
49
53
|
await orm.close();
|
|
50
54
|
}
|
package/dist/scripts/seed.js
CHANGED
|
@@ -22,6 +22,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var _a;
|
|
25
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
27
|
exports.run = void 0;
|
|
27
28
|
const utils_1 = require("../utils");
|
|
@@ -31,7 +32,7 @@ const os_1 = require("os");
|
|
|
31
32
|
const path_1 = require("path");
|
|
32
33
|
async function run({ options, logger, path, }) {
|
|
33
34
|
logger?.info(`Loading seed data from ${path}...`);
|
|
34
|
-
const { productCategoriesData, productsData, variantsData } = await
|
|
35
|
+
const { productCategoriesData, productsData, variantsData } = await (_a = (0, path_1.resolve)(process.cwd(), path), Promise.resolve().then(() => __importStar(require(_a)))).catch((e) => {
|
|
35
36
|
logger?.error(`Failed to load seed data from ${path}. Please, provide a relative path and check that you export the following productCategoriesData, productsData, variantsData.${os_1.EOL}${e}`);
|
|
36
37
|
throw e;
|
|
37
38
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProductCategory } from "../models";
|
|
2
2
|
import { DAL, FindConfig, ProductTypes, SharedContext } from "@medusajs/types";
|
|
3
|
-
|
|
3
|
+
type InjectedDependencies = {
|
|
4
4
|
productCategoryRepository: DAL.RepositoryService;
|
|
5
5
|
};
|
|
6
6
|
export default class ProductCategoryService<TEntity = ProductCategory> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProductCollection } from "../models";
|
|
2
2
|
import { DAL, FindConfig, ProductTypes, SharedContext } from "@medusajs/types";
|
|
3
|
-
|
|
3
|
+
type InjectedDependencies = {
|
|
4
4
|
productCollectionRepository: DAL.RepositoryService;
|
|
5
5
|
};
|
|
6
6
|
export default class ProductCollectionService<TEntity = ProductCollection> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProductCategoryService, ProductCollectionService, ProductService, ProductTagService, ProductVariantService } from ".";
|
|
2
2
|
import { Product, ProductCategory, ProductCollection, ProductTag, ProductVariant } from "../models";
|
|
3
3
|
import { FindConfig, ProductTypes, SharedContext } from "@medusajs/types";
|
|
4
|
-
|
|
4
|
+
type InjectedDependencies = {
|
|
5
5
|
productService: ProductService<any>;
|
|
6
6
|
productVariantService: ProductVariantService<any>;
|
|
7
7
|
productTagService: ProductTagService<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProductTag } from "../models";
|
|
2
2
|
import { DAL, FindConfig, ProductTypes, SharedContext } from "@medusajs/types";
|
|
3
|
-
|
|
3
|
+
type InjectedDependencies = {
|
|
4
4
|
productTagRepository: DAL.RepositoryService;
|
|
5
5
|
};
|
|
6
6
|
export default class ProductTagService<TEntity = ProductTag> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProductVariant } from "../models";
|
|
2
2
|
import { DAL, FindConfig, ProductTypes, SharedContext } from "@medusajs/types";
|
|
3
|
-
|
|
3
|
+
type InjectedDependencies = {
|
|
4
4
|
productVariantRepository: DAL.RepositoryService;
|
|
5
5
|
};
|
|
6
6
|
export default class ProductVariantService<TEntity = ProductVariant> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProductTagService, ProductVariantService } from ".";
|
|
2
2
|
import { Product } from "../models";
|
|
3
3
|
import { DAL, FindConfig, ProductTypes, SharedContext } from "@medusajs/types";
|
|
4
|
-
|
|
4
|
+
type InjectedDependencies = {
|
|
5
5
|
productRepository: DAL.RepositoryService;
|
|
6
6
|
productVariantService: ProductVariantService;
|
|
7
7
|
productTagService: ProductTagService;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Constructor, DAL, IEventBusService } from "@medusajs/types";
|
|
2
|
-
export
|
|
2
|
+
export type ProductServiceInitializeOptions = {
|
|
3
3
|
database: {
|
|
4
4
|
clientUrl: string;
|
|
5
5
|
schema?: string;
|
|
6
6
|
driverOptions?: Record<string, unknown>;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type ProductServiceInitializeCustomDataLayerOptions = {
|
|
10
10
|
manager?: any;
|
|
11
11
|
repositories?: {
|
|
12
12
|
[key: string]: Constructor<DAL.RepositoryService>;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type InitializeModuleInjectableDependencies = {
|
|
16
16
|
eventBusService?: IEventBusService;
|
|
17
17
|
};
|
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createConnection = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
4
|
const postgresql_1 = require("@mikro-orm/postgresql");
|
|
6
|
-
const
|
|
5
|
+
const core_1 = require("@mikro-orm/core");
|
|
7
6
|
async function createConnection(database, entities) {
|
|
7
|
+
const schema = database.schema || "public";
|
|
8
8
|
const orm = await postgresql_1.MikroORM.init({
|
|
9
9
|
discovery: { disableDynamicFileAccess: true },
|
|
10
10
|
entities,
|
|
11
11
|
debug: process.env.NODE_ENV === "development",
|
|
12
12
|
baseDir: process.cwd(),
|
|
13
13
|
clientUrl: database.clientUrl,
|
|
14
|
-
schema
|
|
14
|
+
schema,
|
|
15
15
|
driverOptions: database.driverOptions ?? {
|
|
16
16
|
connection: { ssl: true },
|
|
17
17
|
},
|
|
18
18
|
tsNode: process.env.APP_ENV === "development",
|
|
19
19
|
type: "postgresql",
|
|
20
20
|
migrations: {
|
|
21
|
-
path: (
|
|
22
|
-
pathTs: (0, path_1.resolve)(__dirname, "../../src/migrations"),
|
|
23
|
-
glob: "!(*.d).{js,ts}",
|
|
24
|
-
disableForeignKeys: false,
|
|
25
|
-
silent: false,
|
|
26
|
-
dropTables: false,
|
|
27
|
-
transactional: true,
|
|
28
|
-
allOrNothing: true,
|
|
29
|
-
safe: true,
|
|
30
|
-
generator: migrations_1.TSMigrationGenerator,
|
|
21
|
+
path: core_1.Utils.detectTsNode() ? "src/migrations" : "dist/migrations",
|
|
31
22
|
},
|
|
32
23
|
});
|
|
33
24
|
return orm;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/product",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-beta-20230619170349",
|
|
4
4
|
"description": "Medusa Product module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,25 +36,25 @@
|
|
|
36
36
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@mikro-orm/cli": "5.7.
|
|
40
|
-
"@mikro-orm/migrations": "5.7.
|
|
39
|
+
"@mikro-orm/cli": "5.7.12",
|
|
40
|
+
"@mikro-orm/migrations": "5.7.12",
|
|
41
41
|
"cross-env": "^5.2.1",
|
|
42
42
|
"jest": "^25.5.4",
|
|
43
43
|
"medusa-test-utils": "^1.1.40",
|
|
44
44
|
"pg-god": "^1.0.12",
|
|
45
|
-
"rimraf": "^
|
|
45
|
+
"rimraf": "^3.0.2",
|
|
46
46
|
"ts-jest": "^25.5.1",
|
|
47
47
|
"ts-node": "^10.9.1",
|
|
48
48
|
"tsc-alias": "^1.8.6",
|
|
49
49
|
"typescript": "^4.4.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@medusajs/modules-sdk": "
|
|
53
|
-
"@medusajs/types": "
|
|
54
|
-
"@medusajs/utils": "
|
|
55
|
-
"@mikro-orm/core": "5.7.
|
|
56
|
-
"@mikro-orm/migrations": "5.7.
|
|
57
|
-
"@mikro-orm/postgresql": "5.7.
|
|
52
|
+
"@medusajs/modules-sdk": "1.8.8-beta-20230619170349",
|
|
53
|
+
"@medusajs/types": "1.8.8-beta-20230619170349",
|
|
54
|
+
"@medusajs/utils": "1.9.1-beta-20230619170349",
|
|
55
|
+
"@mikro-orm/core": "5.7.12",
|
|
56
|
+
"@mikro-orm/migrations": "5.7.12",
|
|
57
|
+
"@mikro-orm/postgresql": "5.7.12",
|
|
58
58
|
"awilix": "^8.0.0",
|
|
59
59
|
"dotenv": "^16.1.4",
|
|
60
60
|
"lodash": "^4.17.21"
|