@medusajs/order 0.1.0

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.
Files changed (60) hide show
  1. package/README.md +1 -0
  2. package/dist/index.d.ts +8 -0
  3. package/dist/index.js +29 -0
  4. package/dist/joiner-config.d.ts +5 -0
  5. package/dist/joiner-config.js +23 -0
  6. package/dist/models/address.d.ts +24 -0
  7. package/dist/models/address.js +125 -0
  8. package/dist/models/adjustment-line.d.ts +21 -0
  9. package/dist/models/adjustment-line.js +73 -0
  10. package/dist/models/index.d.ts +8 -0
  11. package/dist/models/index.js +22 -0
  12. package/dist/models/line-item-adjustment.d.ts +8 -0
  13. package/dist/models/line-item-adjustment.js +57 -0
  14. package/dist/models/line-item-tax-line.d.ts +8 -0
  15. package/dist/models/line-item-tax-line.js +54 -0
  16. package/dist/models/line-item.d.ts +45 -0
  17. package/dist/models/line-item.js +241 -0
  18. package/dist/models/order.d.ts +32 -0
  19. package/dist/models/order.js +195 -0
  20. package/dist/models/shipping-method-adjustment.d.ts +8 -0
  21. package/dist/models/shipping-method-adjustment.js +55 -0
  22. package/dist/models/shipping-method-tax-line.d.ts +8 -0
  23. package/dist/models/shipping-method-tax-line.js +55 -0
  24. package/dist/models/shipping-method.d.ts +26 -0
  25. package/dist/models/shipping-method.js +157 -0
  26. package/dist/models/tax-line.d.ts +17 -0
  27. package/dist/models/tax-line.js +67 -0
  28. package/dist/module-definition.d.ts +2 -0
  29. package/dist/module-definition.js +58 -0
  30. package/dist/repositories/index.d.ts +1 -0
  31. package/dist/repositories/index.js +5 -0
  32. package/dist/scripts/bin/run-seed.d.ts +3 -0
  33. package/dist/scripts/bin/run-seed.js +48 -0
  34. package/dist/services/index.d.ts +1 -0
  35. package/dist/services/index.js +8 -0
  36. package/dist/services/order-module-service.d.ts +114 -0
  37. package/dist/services/order-module-service.js +671 -0
  38. package/dist/types/UpdateOrderShippingMethodDTO.d.ts +7 -0
  39. package/dist/types/UpdateOrderShippingMethodDTO.js +2 -0
  40. package/dist/types/address.d.ts +19 -0
  41. package/dist/types/address.js +2 -0
  42. package/dist/types/index.d.ts +13 -0
  43. package/dist/types/index.js +24 -0
  44. package/dist/types/line-item-adjustment.d.ts +12 -0
  45. package/dist/types/line-item-adjustment.js +2 -0
  46. package/dist/types/line-item-tax-line.d.ts +7 -0
  47. package/dist/types/line-item-tax-line.js +2 -0
  48. package/dist/types/line-item.d.ts +31 -0
  49. package/dist/types/line-item.js +2 -0
  50. package/dist/types/order.d.ts +24 -0
  51. package/dist/types/order.js +2 -0
  52. package/dist/types/shipping-method-adjustment.d.ts +17 -0
  53. package/dist/types/shipping-method-adjustment.js +2 -0
  54. package/dist/types/shipping-method-tax-line.d.ts +7 -0
  55. package/dist/types/shipping-method-tax-line.js +2 -0
  56. package/dist/types/shipping-method.d.ts +13 -0
  57. package/dist/types/shipping-method.js +2 -0
  58. package/dist/types/tax-line.d.ts +16 -0
  59. package/dist/types/tax-line.js +2 -0
  60. package/package.json +61 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Order Module
@@ -0,0 +1,8 @@
1
+ import { moduleDefinition } from "./module-definition";
2
+ export * from "./models";
3
+ export * from "./services";
4
+ export * from "./types";
5
+ export declare const initialize: (options?: import("@medusajs/modules-sdk").InternalModuleDeclaration | import("@medusajs/modules-sdk").ModuleServiceInitializeOptions | import("@medusajs/modules-sdk").ModuleServiceInitializeCustomDataLayerOptions | import("@medusajs/modules-sdk").ExternalModuleDeclaration | undefined, injectedDependencies?: any) => Promise<unknown>;
6
+ export declare const runMigrations: ((options: import("@medusajs/modules-sdk").LoaderOptions<any>, moduleDeclaration?: import("@medusajs/modules-sdk").InternalModuleDeclaration | undefined) => Promise<void>) | undefined;
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;
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
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
+ exports.revertMigration = exports.runMigrations = exports.initialize = void 0;
18
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
19
+ const module_definition_1 = require("./module-definition");
20
+ __exportStar(require("./models"), exports);
21
+ __exportStar(require("./services"), exports);
22
+ __exportStar(require("./types"), exports);
23
+ exports.initialize = (0, modules_sdk_1.initializeFactory)({
24
+ moduleName: modules_sdk_1.Modules.ORDER,
25
+ moduleDefinition: module_definition_1.moduleDefinition,
26
+ });
27
+ exports.runMigrations = module_definition_1.moduleDefinition.runMigrations;
28
+ exports.revertMigration = module_definition_1.moduleDefinition.revertMigration;
29
+ exports.default = module_definition_1.moduleDefinition;
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,23 @@
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
+ exports.LinkableKeys = {
6
+ order_id: "Order",
7
+ order_item_id: "OrderLineItem",
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.ORDER,
20
+ primaryKeys: ["id"],
21
+ linkableKeys: exports.LinkableKeys,
22
+ alias: [],
23
+ };
@@ -0,0 +1,24 @@
1
+ import { DAL } from "@medusajs/types";
2
+ import { OptionalProps } from "@mikro-orm/core";
3
+ type OptionalAddressProps = DAL.EntityDateColumns;
4
+ export default class Address {
5
+ [OptionalProps]: OptionalAddressProps;
6
+ id: string;
7
+ customer_id: string | null;
8
+ company: string | null;
9
+ first_name: string | null;
10
+ last_name: string | null;
11
+ address_1: string | null;
12
+ address_2: string | null;
13
+ city: string | null;
14
+ country_code: string | null;
15
+ province: string | null;
16
+ postal_code: string | null;
17
+ phone: string | null;
18
+ metadata: Record<string, unknown> | null;
19
+ created_at: Date;
20
+ updated_at: Date;
21
+ onCreate(): void;
22
+ onInit(): void;
23
+ }
24
+ export {};
@@ -0,0 +1,125 @@
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 utils_1 = require("@medusajs/utils");
13
+ const core_1 = require("@mikro-orm/core");
14
+ const customerIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
15
+ tableName: "order_address",
16
+ columns: "customer_id",
17
+ });
18
+ let Address = class Address {
19
+ constructor() {
20
+ this.customer_id = null;
21
+ this.company = null;
22
+ this.first_name = null;
23
+ this.last_name = null;
24
+ this.address_1 = null;
25
+ this.address_2 = null;
26
+ this.city = null;
27
+ this.country_code = null;
28
+ this.province = null;
29
+ this.postal_code = null;
30
+ this.phone = null;
31
+ this.metadata = null;
32
+ }
33
+ onCreate() {
34
+ this.id = (0, utils_1.generateEntityId)(this.id, "ordaddr");
35
+ }
36
+ onInit() {
37
+ this.id = (0, utils_1.generateEntityId)(this.id, "ordaddr");
38
+ }
39
+ };
40
+ __decorate([
41
+ (0, core_1.PrimaryKey)({ columnType: "text" }),
42
+ __metadata("design:type", String)
43
+ ], Address.prototype, "id", void 0);
44
+ __decorate([
45
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
46
+ customerIdIndex.MikroORMIndex(),
47
+ __metadata("design:type", Object)
48
+ ], Address.prototype, "customer_id", void 0);
49
+ __decorate([
50
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
51
+ __metadata("design:type", Object)
52
+ ], Address.prototype, "company", void 0);
53
+ __decorate([
54
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
55
+ __metadata("design:type", Object)
56
+ ], Address.prototype, "first_name", void 0);
57
+ __decorate([
58
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
59
+ __metadata("design:type", Object)
60
+ ], Address.prototype, "last_name", void 0);
61
+ __decorate([
62
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
63
+ __metadata("design:type", Object)
64
+ ], Address.prototype, "address_1", void 0);
65
+ __decorate([
66
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
67
+ __metadata("design:type", Object)
68
+ ], Address.prototype, "address_2", void 0);
69
+ __decorate([
70
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
71
+ __metadata("design:type", Object)
72
+ ], Address.prototype, "city", void 0);
73
+ __decorate([
74
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
75
+ __metadata("design:type", Object)
76
+ ], Address.prototype, "country_code", void 0);
77
+ __decorate([
78
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
79
+ __metadata("design:type", Object)
80
+ ], Address.prototype, "province", void 0);
81
+ __decorate([
82
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
83
+ __metadata("design:type", Object)
84
+ ], Address.prototype, "postal_code", void 0);
85
+ __decorate([
86
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
87
+ __metadata("design:type", Object)
88
+ ], Address.prototype, "phone", void 0);
89
+ __decorate([
90
+ (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
91
+ __metadata("design:type", Object)
92
+ ], Address.prototype, "metadata", void 0);
93
+ __decorate([
94
+ (0, core_1.Property)({
95
+ onCreate: () => new Date(),
96
+ columnType: "timestamptz",
97
+ defaultRaw: "now()",
98
+ }),
99
+ __metadata("design:type", Date)
100
+ ], Address.prototype, "created_at", void 0);
101
+ __decorate([
102
+ (0, core_1.Property)({
103
+ onCreate: () => new Date(),
104
+ onUpdate: () => new Date(),
105
+ columnType: "timestamptz",
106
+ defaultRaw: "now()",
107
+ }),
108
+ __metadata("design:type", Date)
109
+ ], Address.prototype, "updated_at", void 0);
110
+ __decorate([
111
+ (0, core_1.BeforeCreate)(),
112
+ __metadata("design:type", Function),
113
+ __metadata("design:paramtypes", []),
114
+ __metadata("design:returntype", void 0)
115
+ ], Address.prototype, "onCreate", null);
116
+ __decorate([
117
+ (0, core_1.OnInit)(),
118
+ __metadata("design:type", Function),
119
+ __metadata("design:paramtypes", []),
120
+ __metadata("design:returntype", void 0)
121
+ ], Address.prototype, "onInit", null);
122
+ Address = __decorate([
123
+ (0, core_1.Entity)({ tableName: "order_address" })
124
+ ], Address);
125
+ exports.default = Address;
@@ -0,0 +1,21 @@
1
+ import { BigNumberRawValue, DAL } from "@medusajs/types";
2
+ import { BigNumber } from "@medusajs/utils";
3
+ import { OptionalProps } from "@mikro-orm/core";
4
+ type OptionalAdjustmentLineProps = DAL.EntityDateColumns;
5
+ /**
6
+ * As per the Mikro ORM docs, superclasses should use the abstract class definition
7
+ * Source: https://mikro-orm.io/docs/inheritance-mapping
8
+ */
9
+ export default abstract class AdjustmentLine {
10
+ [OptionalProps]: OptionalAdjustmentLineProps;
11
+ id: string;
12
+ description: string | null;
13
+ promotion_id: string | null;
14
+ code: string | null;
15
+ amount: BigNumber | number;
16
+ raw_amount: BigNumberRawValue;
17
+ provider_id: string | null;
18
+ created_at: Date;
19
+ updated_at: Date;
20
+ }
21
+ export {};
@@ -0,0 +1,73 @@
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
+ /**
14
+ * As per the Mikro ORM docs, superclasses should use the abstract class definition
15
+ * Source: https://mikro-orm.io/docs/inheritance-mapping
16
+ */
17
+ class AdjustmentLine {
18
+ constructor() {
19
+ this.description = null;
20
+ this.promotion_id = null;
21
+ this.code = null;
22
+ this.provider_id = null;
23
+ }
24
+ }
25
+ exports.default = AdjustmentLine;
26
+ __decorate([
27
+ (0, core_1.PrimaryKey)({ columnType: "text" }),
28
+ __metadata("design:type", String)
29
+ ], AdjustmentLine.prototype, "id", void 0);
30
+ __decorate([
31
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
32
+ __metadata("design:type", Object)
33
+ ], AdjustmentLine.prototype, "description", void 0);
34
+ __decorate([
35
+ (0, core_1.Property)({
36
+ columnType: "text",
37
+ nullable: true,
38
+ }),
39
+ __metadata("design:type", Object)
40
+ ], AdjustmentLine.prototype, "promotion_id", void 0);
41
+ __decorate([
42
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
43
+ __metadata("design:type", Object)
44
+ ], AdjustmentLine.prototype, "code", void 0);
45
+ __decorate([
46
+ (0, core_1.Property)({ columnType: "numeric" }),
47
+ __metadata("design:type", Object)
48
+ ], AdjustmentLine.prototype, "amount", void 0);
49
+ __decorate([
50
+ (0, core_1.Property)({ columnType: "jsonb" }),
51
+ __metadata("design:type", Object)
52
+ ], AdjustmentLine.prototype, "raw_amount", void 0);
53
+ __decorate([
54
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
55
+ __metadata("design:type", Object)
56
+ ], AdjustmentLine.prototype, "provider_id", void 0);
57
+ __decorate([
58
+ (0, core_1.Property)({
59
+ onCreate: () => new Date(),
60
+ columnType: "timestamptz",
61
+ defaultRaw: "now()",
62
+ }),
63
+ __metadata("design:type", Date)
64
+ ], AdjustmentLine.prototype, "created_at", void 0);
65
+ __decorate([
66
+ (0, core_1.Property)({
67
+ onCreate: () => new Date(),
68
+ onUpdate: () => new Date(),
69
+ columnType: "timestamptz",
70
+ defaultRaw: "now()",
71
+ }),
72
+ __metadata("design:type", Date)
73
+ ], AdjustmentLine.prototype, "updated_at", void 0);
@@ -0,0 +1,8 @@
1
+ export { default as Address } from "./address";
2
+ export { default as LineItem } from "./line-item";
3
+ export { default as LineItemAdjustment } from "./line-item-adjustment";
4
+ export { default as LineItemTaxLine } from "./line-item-tax-line";
5
+ export { default as Order } from "./order";
6
+ export { default as ShippingMethod } from "./shipping-method";
7
+ export { default as ShippingMethodAdjustment } from "./shipping-method-adjustment";
8
+ export { default as ShippingMethodTaxLine } from "./shipping-method-tax-line";
@@ -0,0 +1,22 @@
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.ShippingMethodTaxLine = exports.ShippingMethodAdjustment = exports.ShippingMethod = exports.Order = exports.LineItemTaxLine = exports.LineItemAdjustment = exports.LineItem = exports.Address = void 0;
7
+ var address_1 = require("./address");
8
+ Object.defineProperty(exports, "Address", { enumerable: true, get: function () { return __importDefault(address_1).default; } });
9
+ var line_item_1 = require("./line-item");
10
+ Object.defineProperty(exports, "LineItem", { enumerable: true, get: function () { return __importDefault(line_item_1).default; } });
11
+ var line_item_adjustment_1 = require("./line-item-adjustment");
12
+ Object.defineProperty(exports, "LineItemAdjustment", { enumerable: true, get: function () { return __importDefault(line_item_adjustment_1).default; } });
13
+ var line_item_tax_line_1 = require("./line-item-tax-line");
14
+ Object.defineProperty(exports, "LineItemTaxLine", { enumerable: true, get: function () { return __importDefault(line_item_tax_line_1).default; } });
15
+ var order_1 = require("./order");
16
+ Object.defineProperty(exports, "Order", { enumerable: true, get: function () { return __importDefault(order_1).default; } });
17
+ var shipping_method_1 = require("./shipping-method");
18
+ Object.defineProperty(exports, "ShippingMethod", { enumerable: true, get: function () { return __importDefault(shipping_method_1).default; } });
19
+ var shipping_method_adjustment_1 = require("./shipping-method-adjustment");
20
+ Object.defineProperty(exports, "ShippingMethodAdjustment", { enumerable: true, get: function () { return __importDefault(shipping_method_adjustment_1).default; } });
21
+ var shipping_method_tax_line_1 = require("./shipping-method-tax-line");
22
+ Object.defineProperty(exports, "ShippingMethodTaxLine", { enumerable: true, get: function () { return __importDefault(shipping_method_tax_line_1).default; } });
@@ -0,0 +1,8 @@
1
+ import AdjustmentLine from "./adjustment-line";
2
+ import LineItem from "./line-item";
3
+ export default class LineItemAdjustment extends AdjustmentLine {
4
+ item: LineItem;
5
+ item_id: string;
6
+ onCreate(): void;
7
+ onInit(): void;
8
+ }
@@ -0,0 +1,57 @@
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/utils");
16
+ const core_1 = require("@mikro-orm/core");
17
+ const adjustment_line_1 = __importDefault(require("./adjustment-line"));
18
+ const line_item_1 = __importDefault(require("./line-item"));
19
+ let LineItemAdjustment = class LineItemAdjustment extends adjustment_line_1.default {
20
+ onCreate() {
21
+ this.id = (0, utils_1.generateEntityId)(this.id, "ordliadj");
22
+ }
23
+ onInit() {
24
+ this.id = (0, utils_1.generateEntityId)(this.id, "ordliadj");
25
+ }
26
+ };
27
+ __decorate([
28
+ (0, core_1.ManyToOne)({
29
+ entity: () => line_item_1.default,
30
+ index: "IDX_order_line_item_adjustment_item_id",
31
+ cascade: [core_1.Cascade.REMOVE, core_1.Cascade.PERSIST],
32
+ }),
33
+ __metadata("design:type", line_item_1.default)
34
+ ], LineItemAdjustment.prototype, "item", void 0);
35
+ __decorate([
36
+ (0, core_1.Property)({ columnType: "text" }),
37
+ __metadata("design:type", String)
38
+ ], LineItemAdjustment.prototype, "item_id", void 0);
39
+ __decorate([
40
+ (0, core_1.BeforeCreate)(),
41
+ __metadata("design:type", Function),
42
+ __metadata("design:paramtypes", []),
43
+ __metadata("design:returntype", void 0)
44
+ ], LineItemAdjustment.prototype, "onCreate", null);
45
+ __decorate([
46
+ (0, core_1.OnInit)(),
47
+ __metadata("design:type", Function),
48
+ __metadata("design:paramtypes", []),
49
+ __metadata("design:returntype", void 0)
50
+ ], LineItemAdjustment.prototype, "onInit", null);
51
+ LineItemAdjustment = __decorate([
52
+ (0, core_1.Entity)({ tableName: "order_line_item_adjustment" }),
53
+ (0, core_1.Check)({
54
+ expression: (columns) => `${columns.amount} >= 0`,
55
+ })
56
+ ], LineItemAdjustment);
57
+ exports.default = LineItemAdjustment;
@@ -0,0 +1,8 @@
1
+ import LineItem from "./line-item";
2
+ import TaxLine from "./tax-line";
3
+ export default class LineItemTaxLine extends TaxLine {
4
+ item: LineItem;
5
+ item_id: string;
6
+ onCreate(): void;
7
+ onInit(): void;
8
+ }
@@ -0,0 +1,54 @@
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/utils");
16
+ const core_1 = require("@mikro-orm/core");
17
+ const line_item_1 = __importDefault(require("./line-item"));
18
+ const tax_line_1 = __importDefault(require("./tax-line"));
19
+ let LineItemTaxLine = class LineItemTaxLine extends tax_line_1.default {
20
+ onCreate() {
21
+ this.id = (0, utils_1.generateEntityId)(this.id, "ordlitxl");
22
+ }
23
+ onInit() {
24
+ this.id = (0, utils_1.generateEntityId)(this.id, "ordlitxl");
25
+ }
26
+ };
27
+ __decorate([
28
+ (0, core_1.ManyToOne)({
29
+ entity: () => line_item_1.default,
30
+ index: "IDX_order_line_item_tax_line_item_id",
31
+ cascade: [core_1.Cascade.REMOVE, core_1.Cascade.PERSIST],
32
+ }),
33
+ __metadata("design:type", line_item_1.default)
34
+ ], LineItemTaxLine.prototype, "item", void 0);
35
+ __decorate([
36
+ (0, core_1.Property)({ columnType: "text" }),
37
+ __metadata("design:type", String)
38
+ ], LineItemTaxLine.prototype, "item_id", void 0);
39
+ __decorate([
40
+ (0, core_1.BeforeCreate)(),
41
+ __metadata("design:type", Function),
42
+ __metadata("design:paramtypes", []),
43
+ __metadata("design:returntype", void 0)
44
+ ], LineItemTaxLine.prototype, "onCreate", null);
45
+ __decorate([
46
+ (0, core_1.OnInit)(),
47
+ __metadata("design:type", Function),
48
+ __metadata("design:paramtypes", []),
49
+ __metadata("design:returntype", void 0)
50
+ ], LineItemTaxLine.prototype, "onInit", null);
51
+ LineItemTaxLine = __decorate([
52
+ (0, core_1.Entity)({ tableName: "order_line_item_tax_line" })
53
+ ], LineItemTaxLine);
54
+ exports.default = LineItemTaxLine;
@@ -0,0 +1,45 @@
1
+ import { BigNumberRawValue, DAL } from "@medusajs/types";
2
+ import { BigNumber } from "@medusajs/utils";
3
+ import { Collection, OptionalProps } from "@mikro-orm/core";
4
+ import LineItemAdjustment from "./line-item-adjustment";
5
+ import LineItemTaxLine from "./line-item-tax-line";
6
+ import Order from "./order";
7
+ type OptionalLineItemProps = "is_discoutable" | "is_tax_inclusive" | "compare_at_unit_price" | "requires_shipping" | "order" | DAL.EntityDateColumns;
8
+ export default class LineItem {
9
+ [OptionalProps]?: OptionalLineItemProps;
10
+ id: string;
11
+ order_id: string;
12
+ order: Order;
13
+ title: string;
14
+ subtitle: string | null;
15
+ thumbnail: string | null;
16
+ quantity: BigNumber | number;
17
+ raw_quantity: BigNumberRawValue;
18
+ variant_id: string | null;
19
+ product_id: string | null;
20
+ product_title: string | null;
21
+ product_description: string | null;
22
+ product_subtitle: string | null;
23
+ product_type: string | null;
24
+ product_collection: string | null;
25
+ product_handle: string | null;
26
+ variant_sku: string | null;
27
+ variant_barcode: string | null;
28
+ variant_title: string | null;
29
+ variant_option_values: Record<string, unknown> | null;
30
+ requires_shipping: boolean;
31
+ is_discountable: boolean;
32
+ is_tax_inclusive: boolean;
33
+ compare_at_unit_price?: BigNumber | number | null;
34
+ raw_compare_at_unit_price: BigNumberRawValue | null;
35
+ unit_price: BigNumber | number;
36
+ raw_unit_price: BigNumberRawValue;
37
+ tax_lines: Collection<LineItemTaxLine, object>;
38
+ adjustments: Collection<LineItemAdjustment, object>;
39
+ created_at: Date;
40
+ updated_at: Date;
41
+ onCreate(): void;
42
+ onUpdate(): void;
43
+ onInit(): void;
44
+ }
45
+ export {};