@medusajs/product 0.0.1
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/index.d.ts +8 -0
- package/dist/index.js +24 -0
- package/dist/initialize/index.d.ts +4 -0
- package/dist/initialize/index.js +11 -0
- package/dist/loaders/connection.d.ts +4 -0
- package/dist/loaders/connection.js +56 -0
- package/dist/loaders/container.d.ts +4 -0
- package/dist/loaders/container.js +76 -0
- package/dist/loaders/index.d.ts +2 -0
- package/dist/loaders/index.js +18 -0
- package/dist/migrations/Migration20230609132805.d.ts +4 -0
- package/dist/migrations/Migration20230609132805.js +42 -0
- package/dist/models/index.d.ts +6 -0
- package/dist/models/index.js +18 -0
- package/dist/models/product-category.d.ts +20 -0
- package/dist/models/product-category.js +123 -0
- package/dist/models/product-collection.d.ts +9 -0
- package/dist/models/product-collection.js +55 -0
- package/dist/models/product-option-value.d.ts +12 -0
- package/dist/models/product-option-value.js +59 -0
- package/dist/models/product-option.d.ts +14 -0
- package/dist/models/product-option.js +68 -0
- package/dist/models/product-tag.d.ts +11 -0
- package/dist/models/product-tag.js +55 -0
- package/dist/models/product-type.d.ts +8 -0
- package/dist/models/product-type.js +44 -0
- package/dist/models/product-variant.d.ts +34 -0
- package/dist/models/product-variant.js +162 -0
- package/dist/models/product.d.ts +43 -0
- package/dist/models/product.js +177 -0
- package/dist/module-definition.d.ts +2 -0
- package/dist/module-definition.js +44 -0
- package/dist/repositories/index.d.ts +5 -0
- package/dist/repositories/index.js +13 -0
- package/dist/repositories/product-category.d.ts +16 -0
- package/dist/repositories/product-category.js +86 -0
- package/dist/repositories/product-collection.d.ts +15 -0
- package/dist/repositories/product-collection.js +46 -0
- package/dist/repositories/product-tag.d.ts +15 -0
- package/dist/repositories/product-tag.js +46 -0
- package/dist/repositories/product-variant.d.ts +15 -0
- package/dist/repositories/product-variant.js +46 -0
- package/dist/repositories/product.d.ts +21 -0
- package/dist/repositories/product.js +72 -0
- package/dist/scripts/bin/run-migration-down.d.ts +2 -0
- package/dist/scripts/bin/run-migration-down.js +31 -0
- package/dist/scripts/bin/run-migration-up.d.ts +2 -0
- package/dist/scripts/bin/run-migration-up.js +31 -0
- package/dist/scripts/bin/run-seed.d.ts +2 -0
- package/dist/scripts/bin/run-seed.js +37 -0
- package/dist/scripts/index.d.ts +2 -0
- package/dist/scripts/index.js +18 -0
- package/dist/scripts/migration-down.d.ts +10 -0
- package/dist/scripts/migration-down.js +51 -0
- package/dist/scripts/migration-up.d.ts +10 -0
- package/dist/scripts/migration-up.js +51 -0
- package/dist/scripts/seed.d.ts +5 -0
- package/dist/scripts/seed.js +87 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/index.js +18 -0
- package/dist/services/product-category.d.ts +11 -0
- package/dist/services/product-category.js +18 -0
- package/dist/services/product-collection.d.ts +11 -0
- package/dist/services/product-collection.js +17 -0
- package/dist/services/product-module-service.d.ts +25 -0
- package/dist/services/product-module-service.js +36 -0
- package/dist/services/product-tag.d.ts +11 -0
- package/dist/services/product-tag.js +16 -0
- package/dist/services/product-variant.d.ts +11 -0
- package/dist/services/product-variant.js +13 -0
- package/dist/services/product.d.ts +15 -0
- package/dist/services/product.js +43 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/create-connection.d.ts +3 -0
- package/dist/utils/create-connection.js +35 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/load-database-config.d.ts +7 -0
- package/dist/utils/load-database-config.js +59 -0
- package/dist/utils/query/index.d.ts +6 -0
- package/dist/utils/query/index.js +35 -0
- package/package.json +62 -0
|
@@ -0,0 +1,68 @@
|
|
|
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 core_1 = require("@mikro-orm/core");
|
|
16
|
+
const utils_1 = require("@medusajs/utils");
|
|
17
|
+
const index_1 = require("./index");
|
|
18
|
+
const product_option_value_1 = __importDefault(require("./product-option-value"));
|
|
19
|
+
let ProductOption = class ProductOption {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.values = new core_1.Collection(this);
|
|
22
|
+
}
|
|
23
|
+
beforeCreate() {
|
|
24
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "opt");
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], ProductOption.prototype, "id", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], ProductOption.prototype, "title", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, core_1.Property)({ persist: false }),
|
|
37
|
+
__metadata("design:type", Number)
|
|
38
|
+
], ProductOption.prototype, "product_id", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, core_1.ManyToOne)(() => index_1.Product, {
|
|
41
|
+
index: "IDX_product_option_product_id",
|
|
42
|
+
}),
|
|
43
|
+
__metadata("design:type", index_1.Product)
|
|
44
|
+
], ProductOption.prototype, "product", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, core_1.OneToMany)(() => product_option_value_1.default, (value) => value.option, {
|
|
47
|
+
cascade: [core_1.Cascade.REMOVE],
|
|
48
|
+
}),
|
|
49
|
+
__metadata("design:type", Object)
|
|
50
|
+
], ProductOption.prototype, "values", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
|
53
|
+
__metadata("design:type", Object)
|
|
54
|
+
], ProductOption.prototype, "metadata", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
57
|
+
__metadata("design:type", Date)
|
|
58
|
+
], ProductOption.prototype, "deleted_at", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, core_1.BeforeCreate)(),
|
|
61
|
+
__metadata("design:type", Function),
|
|
62
|
+
__metadata("design:paramtypes", []),
|
|
63
|
+
__metadata("design:returntype", void 0)
|
|
64
|
+
], ProductOption.prototype, "beforeCreate", null);
|
|
65
|
+
ProductOption = __decorate([
|
|
66
|
+
(0, core_1.Entity)({ tableName: "product_option" })
|
|
67
|
+
], ProductOption);
|
|
68
|
+
exports.default = ProductOption;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Collection } from "@mikro-orm/core";
|
|
2
|
+
import Product from "./product";
|
|
3
|
+
declare class ProductTag {
|
|
4
|
+
id: string;
|
|
5
|
+
value: string;
|
|
6
|
+
metadata?: Record<string, unknown> | null;
|
|
7
|
+
deleted_at: Date;
|
|
8
|
+
products: Collection<Product, object>;
|
|
9
|
+
onCreate(): void;
|
|
10
|
+
}
|
|
11
|
+
export default ProductTag;
|
|
@@ -0,0 +1,55 @@
|
|
|
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 core_1 = require("@mikro-orm/core");
|
|
16
|
+
const utils_1 = require("@medusajs/utils");
|
|
17
|
+
const product_1 = __importDefault(require("./product"));
|
|
18
|
+
let ProductTag = class ProductTag {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.products = new core_1.Collection(this);
|
|
21
|
+
}
|
|
22
|
+
onCreate() {
|
|
23
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "ptag");
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], ProductTag.prototype, "id", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], ProductTag.prototype, "value", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
|
36
|
+
__metadata("design:type", Object)
|
|
37
|
+
], ProductTag.prototype, "metadata", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
40
|
+
__metadata("design:type", Date)
|
|
41
|
+
], ProductTag.prototype, "deleted_at", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, core_1.ManyToMany)(() => product_1.default, (product) => product.tags),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
|
+
], ProductTag.prototype, "products", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, core_1.BeforeCreate)(),
|
|
48
|
+
__metadata("design:type", Function),
|
|
49
|
+
__metadata("design:paramtypes", []),
|
|
50
|
+
__metadata("design:returntype", void 0)
|
|
51
|
+
], ProductTag.prototype, "onCreate", null);
|
|
52
|
+
ProductTag = __decorate([
|
|
53
|
+
(0, core_1.Entity)({ tableName: "product_tag" })
|
|
54
|
+
], ProductTag);
|
|
55
|
+
exports.default = ProductTag;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const core_1 = require("@mikro-orm/core");
|
|
13
|
+
const utils_1 = require("@medusajs/utils");
|
|
14
|
+
let ProductType = class ProductType {
|
|
15
|
+
onCreate() {
|
|
16
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "ptyp");
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], ProductType.prototype, "id", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], ProductType.prototype, "value", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, core_1.Property)({ columnType: "json", nullable: true }),
|
|
29
|
+
__metadata("design:type", Object)
|
|
30
|
+
], ProductType.prototype, "metadata", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
33
|
+
__metadata("design:type", Date)
|
|
34
|
+
], ProductType.prototype, "deleted_at", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, core_1.BeforeCreate)(),
|
|
37
|
+
__metadata("design:type", Function),
|
|
38
|
+
__metadata("design:paramtypes", []),
|
|
39
|
+
__metadata("design:returntype", void 0)
|
|
40
|
+
], ProductType.prototype, "onCreate", null);
|
|
41
|
+
ProductType = __decorate([
|
|
42
|
+
(0, core_1.Entity)({ tableName: "product_type" })
|
|
43
|
+
], ProductType);
|
|
44
|
+
exports.default = ProductType;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Collection, OptionalProps } from "@mikro-orm/core";
|
|
2
|
+
import { Product } from ".";
|
|
3
|
+
import ProductOptionValue from "./product-option-value";
|
|
4
|
+
declare type OptionalFields = "created_at" | "updated_at" | "updated_at" | "deleted_at" | "allow_backorder" | "manage_inventory" | "product" | "product_id";
|
|
5
|
+
declare class ProductVariant {
|
|
6
|
+
[OptionalProps]?: OptionalFields;
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
sku?: string | null;
|
|
10
|
+
barcode?: string | null;
|
|
11
|
+
ean?: string | null;
|
|
12
|
+
upc?: string | null;
|
|
13
|
+
inventory_quantity: number;
|
|
14
|
+
allow_backorder: boolean;
|
|
15
|
+
manage_inventory: boolean;
|
|
16
|
+
hs_code?: string | null;
|
|
17
|
+
origin_country?: string | null;
|
|
18
|
+
mid_code?: string | null;
|
|
19
|
+
material?: string | null;
|
|
20
|
+
weight?: number | null;
|
|
21
|
+
length?: number | null;
|
|
22
|
+
height?: number | null;
|
|
23
|
+
width?: number | null;
|
|
24
|
+
metadata?: Record<string, unknown> | null;
|
|
25
|
+
variant_rank?: number | null;
|
|
26
|
+
product_id: string;
|
|
27
|
+
created_at: Date;
|
|
28
|
+
updated_at: Date;
|
|
29
|
+
deleted_at: Date;
|
|
30
|
+
product: Product;
|
|
31
|
+
options: Collection<ProductOptionValue, object>;
|
|
32
|
+
onCreate(): void;
|
|
33
|
+
}
|
|
34
|
+
export default ProductVariant;
|
|
@@ -0,0 +1,162 @@
|
|
|
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 core_1 = require("@mikro-orm/core");
|
|
16
|
+
const utils_1 = require("@medusajs/utils");
|
|
17
|
+
const _models_1 = require(".");
|
|
18
|
+
const product_option_value_1 = __importDefault(require("./product-option-value"));
|
|
19
|
+
let ProductVariant = class ProductVariant {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.options = new core_1.Collection(this);
|
|
22
|
+
}
|
|
23
|
+
onCreate() {
|
|
24
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "variant");
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], ProductVariant.prototype, "id", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], ProductVariant.prototype, "title", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
37
|
+
(0, core_1.Unique)({
|
|
38
|
+
name: "IDX_product_variant_sku_unique",
|
|
39
|
+
properties: ["sku"],
|
|
40
|
+
}),
|
|
41
|
+
__metadata("design:type", Object)
|
|
42
|
+
], ProductVariant.prototype, "sku", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
45
|
+
(0, core_1.Unique)({
|
|
46
|
+
name: "IDX_product_variant_barcode_unique",
|
|
47
|
+
properties: ["barcode"],
|
|
48
|
+
}),
|
|
49
|
+
__metadata("design:type", Object)
|
|
50
|
+
], ProductVariant.prototype, "barcode", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
53
|
+
(0, core_1.Unique)({
|
|
54
|
+
name: "IDX_product_variant_ean_unique",
|
|
55
|
+
properties: ["ean"],
|
|
56
|
+
}),
|
|
57
|
+
__metadata("design:type", Object)
|
|
58
|
+
], ProductVariant.prototype, "ean", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
61
|
+
(0, core_1.Unique)({
|
|
62
|
+
name: "IDX_product_variant_upc_unique",
|
|
63
|
+
properties: ["upc"],
|
|
64
|
+
}),
|
|
65
|
+
__metadata("design:type", Object)
|
|
66
|
+
], ProductVariant.prototype, "upc", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, core_1.Property)({ columnType: "numeric" }),
|
|
69
|
+
__metadata("design:type", Number)
|
|
70
|
+
], ProductVariant.prototype, "inventory_quantity", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, core_1.Property)({ columnType: "boolean", default: false }),
|
|
73
|
+
__metadata("design:type", Boolean)
|
|
74
|
+
], ProductVariant.prototype, "allow_backorder", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, core_1.Property)({ columnType: "boolean", default: true }),
|
|
77
|
+
__metadata("design:type", Boolean)
|
|
78
|
+
], ProductVariant.prototype, "manage_inventory", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
81
|
+
__metadata("design:type", Object)
|
|
82
|
+
], ProductVariant.prototype, "hs_code", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], ProductVariant.prototype, "origin_country", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
89
|
+
__metadata("design:type", Object)
|
|
90
|
+
], ProductVariant.prototype, "mid_code", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
93
|
+
__metadata("design:type", Object)
|
|
94
|
+
], ProductVariant.prototype, "material", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, core_1.Property)({ columnType: "numeric", nullable: true }),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], ProductVariant.prototype, "weight", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, core_1.Property)({ columnType: "numeric", nullable: true }),
|
|
101
|
+
__metadata("design:type", Object)
|
|
102
|
+
], ProductVariant.prototype, "length", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, core_1.Property)({ columnType: "numeric", nullable: true }),
|
|
105
|
+
__metadata("design:type", Object)
|
|
106
|
+
], ProductVariant.prototype, "height", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, core_1.Property)({ columnType: "numeric", nullable: true }),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], ProductVariant.prototype, "width", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
|
113
|
+
__metadata("design:type", Object)
|
|
114
|
+
], ProductVariant.prototype, "metadata", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
(0, core_1.Property)({ columnType: "numeric", nullable: true }),
|
|
117
|
+
__metadata("design:type", Object)
|
|
118
|
+
], ProductVariant.prototype, "variant_rank", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, core_1.Property)({ persist: false }),
|
|
121
|
+
__metadata("design:type", String)
|
|
122
|
+
], ProductVariant.prototype, "product_id", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, core_1.Property)({ onCreate: () => new Date(), columnType: "timestamptz" }),
|
|
125
|
+
__metadata("design:type", Date)
|
|
126
|
+
], ProductVariant.prototype, "created_at", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, core_1.Property)({
|
|
129
|
+
onCreate: () => new Date(),
|
|
130
|
+
onUpdate: () => new Date(),
|
|
131
|
+
columnType: "timestamptz",
|
|
132
|
+
}),
|
|
133
|
+
__metadata("design:type", Date)
|
|
134
|
+
], ProductVariant.prototype, "updated_at", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
137
|
+
__metadata("design:type", Date)
|
|
138
|
+
], ProductVariant.prototype, "deleted_at", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
(0, core_1.ManyToOne)(() => _models_1.Product, {
|
|
141
|
+
onDelete: "cascade",
|
|
142
|
+
index: "IDX_product_variant_product_id_index",
|
|
143
|
+
fieldName: "product_id",
|
|
144
|
+
}),
|
|
145
|
+
__metadata("design:type", _models_1.Product)
|
|
146
|
+
], ProductVariant.prototype, "product", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
(0, core_1.OneToMany)(() => product_option_value_1.default, (optionValue) => optionValue.variant, {
|
|
149
|
+
cascade: [core_1.Cascade.PERSIST, core_1.Cascade.REMOVE],
|
|
150
|
+
}),
|
|
151
|
+
__metadata("design:type", Object)
|
|
152
|
+
], ProductVariant.prototype, "options", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, core_1.BeforeCreate)(),
|
|
155
|
+
__metadata("design:type", Function),
|
|
156
|
+
__metadata("design:paramtypes", []),
|
|
157
|
+
__metadata("design:returntype", void 0)
|
|
158
|
+
], ProductVariant.prototype, "onCreate", null);
|
|
159
|
+
ProductVariant = __decorate([
|
|
160
|
+
(0, core_1.Entity)({ tableName: "product_variant" })
|
|
161
|
+
], ProductVariant);
|
|
162
|
+
exports.default = ProductVariant;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Collection, OptionalProps } from "@mikro-orm/core";
|
|
2
|
+
import { ProductTypes } from "@medusajs/types";
|
|
3
|
+
import ProductCategory from "./product-category";
|
|
4
|
+
import ProductCollection from "./product-collection";
|
|
5
|
+
import ProductOption from "./product-option";
|
|
6
|
+
import ProductTag from "./product-tag";
|
|
7
|
+
import ProductType from "./product-type";
|
|
8
|
+
import ProductVariant from "./product-variant";
|
|
9
|
+
declare type OptionalRelations = "collection" | "type";
|
|
10
|
+
declare type OptionalFields = "is_giftcard" | "discountable" | "created_at" | "updated_at" | "deleted_at";
|
|
11
|
+
declare class Product {
|
|
12
|
+
[OptionalProps]?: OptionalRelations | OptionalFields;
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
handle?: string | null;
|
|
16
|
+
subtitle?: string | null;
|
|
17
|
+
description?: string | null;
|
|
18
|
+
is_giftcard: boolean;
|
|
19
|
+
status: ProductTypes.ProductStatus;
|
|
20
|
+
thumbnail?: string | null;
|
|
21
|
+
options: Collection<ProductOption, object>;
|
|
22
|
+
variants: Collection<ProductVariant, object>;
|
|
23
|
+
weight?: number | null;
|
|
24
|
+
length?: number | null;
|
|
25
|
+
height?: number | null;
|
|
26
|
+
width?: number | null;
|
|
27
|
+
origin_country?: string | null;
|
|
28
|
+
hs_code?: string | null;
|
|
29
|
+
mid_code?: string | null;
|
|
30
|
+
material?: string | null;
|
|
31
|
+
collection: ProductCollection;
|
|
32
|
+
type: ProductType;
|
|
33
|
+
tags: Collection<ProductTag, object>;
|
|
34
|
+
categories: Collection<ProductCategory, object>;
|
|
35
|
+
discountable: boolean;
|
|
36
|
+
external_id?: string | null;
|
|
37
|
+
created_at: Date;
|
|
38
|
+
updated_at: Date;
|
|
39
|
+
deleted_at: Date;
|
|
40
|
+
metadata?: Record<string, unknown> | null;
|
|
41
|
+
beforeCreate(): void;
|
|
42
|
+
}
|
|
43
|
+
export default Product;
|
|
@@ -0,0 +1,177 @@
|
|
|
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 core_1 = require("@mikro-orm/core");
|
|
16
|
+
const types_1 = require("@medusajs/types");
|
|
17
|
+
const utils_1 = require("@medusajs/utils");
|
|
18
|
+
const product_category_1 = __importDefault(require("./product-category"));
|
|
19
|
+
const product_collection_1 = __importDefault(require("./product-collection"));
|
|
20
|
+
const product_option_1 = __importDefault(require("./product-option"));
|
|
21
|
+
const product_tag_1 = __importDefault(require("./product-tag"));
|
|
22
|
+
const product_type_1 = __importDefault(require("./product-type"));
|
|
23
|
+
const product_variant_1 = __importDefault(require("./product-variant"));
|
|
24
|
+
let Product = class Product {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.options = new core_1.Collection(this);
|
|
27
|
+
this.variants = new core_1.Collection(this);
|
|
28
|
+
this.tags = new core_1.Collection(this);
|
|
29
|
+
this.categories = new core_1.Collection(this);
|
|
30
|
+
}
|
|
31
|
+
beforeCreate() {
|
|
32
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "prod");
|
|
33
|
+
if (!this.handle) {
|
|
34
|
+
this.handle = (0, utils_1.kebabCase)(this.title);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], Product.prototype, "id", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], Product.prototype, "title", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
48
|
+
(0, core_1.Unique)({
|
|
49
|
+
name: "IDX_product_handle_unique",
|
|
50
|
+
properties: ["handle"],
|
|
51
|
+
}),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], Product.prototype, "handle", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
56
|
+
__metadata("design:type", Object)
|
|
57
|
+
], Product.prototype, "subtitle", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
60
|
+
__metadata("design:type", Object)
|
|
61
|
+
], Product.prototype, "description", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, core_1.Property)({ columnType: "boolean", default: false }),
|
|
64
|
+
__metadata("design:type", Boolean)
|
|
65
|
+
], Product.prototype, "is_giftcard", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, core_1.Enum)(() => types_1.ProductTypes.ProductStatus),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], Product.prototype, "status", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
72
|
+
__metadata("design:type", Object)
|
|
73
|
+
], Product.prototype, "thumbnail", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, core_1.OneToMany)(() => product_option_1.default, (o) => o.product),
|
|
76
|
+
__metadata("design:type", Object)
|
|
77
|
+
], Product.prototype, "options", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, core_1.OneToMany)(() => product_variant_1.default, (variant) => variant.product),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], Product.prototype, "variants", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
84
|
+
__metadata("design:type", Object)
|
|
85
|
+
], Product.prototype, "weight", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], Product.prototype, "length", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
92
|
+
__metadata("design:type", Object)
|
|
93
|
+
], Product.prototype, "height", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
96
|
+
__metadata("design:type", Object)
|
|
97
|
+
], Product.prototype, "width", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
100
|
+
__metadata("design:type", Object)
|
|
101
|
+
], Product.prototype, "origin_country", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
104
|
+
__metadata("design:type", Object)
|
|
105
|
+
], Product.prototype, "hs_code", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
108
|
+
__metadata("design:type", Object)
|
|
109
|
+
], Product.prototype, "mid_code", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
112
|
+
__metadata("design:type", Object)
|
|
113
|
+
], Product.prototype, "material", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, core_1.ManyToOne)(() => product_collection_1.default, { nullable: true }),
|
|
116
|
+
__metadata("design:type", product_collection_1.default)
|
|
117
|
+
], Product.prototype, "collection", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, core_1.ManyToOne)(() => product_type_1.default, {
|
|
120
|
+
nullable: true,
|
|
121
|
+
index: "IDX_product_type_id",
|
|
122
|
+
}),
|
|
123
|
+
__metadata("design:type", product_type_1.default)
|
|
124
|
+
], Product.prototype, "type", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, core_1.ManyToMany)(() => product_tag_1.default, "products", {
|
|
127
|
+
owner: true,
|
|
128
|
+
pivotTable: "product_tags",
|
|
129
|
+
index: "IDX_product_tag_id",
|
|
130
|
+
}),
|
|
131
|
+
__metadata("design:type", Object)
|
|
132
|
+
], Product.prototype, "tags", void 0);
|
|
133
|
+
__decorate([
|
|
134
|
+
(0, core_1.ManyToMany)(() => product_category_1.default, "products", {
|
|
135
|
+
owner: true,
|
|
136
|
+
pivotTable: "product_category_product",
|
|
137
|
+
}),
|
|
138
|
+
__metadata("design:type", Object)
|
|
139
|
+
], Product.prototype, "categories", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
(0, core_1.Property)({ columnType: "boolean", default: true }),
|
|
142
|
+
__metadata("design:type", Boolean)
|
|
143
|
+
], Product.prototype, "discountable", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
146
|
+
__metadata("design:type", Object)
|
|
147
|
+
], Product.prototype, "external_id", void 0);
|
|
148
|
+
__decorate([
|
|
149
|
+
(0, core_1.Property)({ onCreate: () => new Date(), columnType: "timestamptz" }),
|
|
150
|
+
__metadata("design:type", Date)
|
|
151
|
+
], Product.prototype, "created_at", void 0);
|
|
152
|
+
__decorate([
|
|
153
|
+
(0, core_1.Property)({
|
|
154
|
+
onCreate: () => new Date(),
|
|
155
|
+
onUpdate: () => new Date(),
|
|
156
|
+
columnType: "timestamptz",
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", Date)
|
|
159
|
+
], Product.prototype, "updated_at", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
|
162
|
+
__metadata("design:type", Date)
|
|
163
|
+
], Product.prototype, "deleted_at", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
|
166
|
+
__metadata("design:type", Object)
|
|
167
|
+
], Product.prototype, "metadata", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
(0, core_1.BeforeCreate)(),
|
|
170
|
+
__metadata("design:type", Function),
|
|
171
|
+
__metadata("design:paramtypes", []),
|
|
172
|
+
__metadata("design:returntype", void 0)
|
|
173
|
+
], Product.prototype, "beforeCreate", null);
|
|
174
|
+
Product = __decorate([
|
|
175
|
+
(0, core_1.Entity)({ tableName: "product" })
|
|
176
|
+
], Product);
|
|
177
|
+
exports.default = Product;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.moduleDefinition = void 0;
|
|
30
|
+
const _services_1 = require("./services");
|
|
31
|
+
const container_1 = __importDefault(require("./loaders/container"));
|
|
32
|
+
const connection_1 = __importDefault(require("./loaders/connection"));
|
|
33
|
+
const ProductModels = __importStar(require("./models"));
|
|
34
|
+
const scripts_1 = require("./scripts");
|
|
35
|
+
const service = _services_1.ProductModuleService;
|
|
36
|
+
const loaders = [container_1.default, connection_1.default];
|
|
37
|
+
const models = Object.values(ProductModels);
|
|
38
|
+
exports.moduleDefinition = {
|
|
39
|
+
service,
|
|
40
|
+
loaders,
|
|
41
|
+
models,
|
|
42
|
+
runMigrations: scripts_1.runMigrations,
|
|
43
|
+
revertMigration: scripts_1.revertMigration,
|
|
44
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ProductRepository } from "./product";
|
|
2
|
+
export { ProductTagRepository } from "./product-tag";
|
|
3
|
+
export { ProductVariantRepository } from "./product-variant";
|
|
4
|
+
export { ProductCollectionRepository } from "./product-collection";
|
|
5
|
+
export { ProductCategoryRepository } from "./product-category";
|