@tabletennisshop/common 1.0.26 → 1.0.29
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/build/enums/product-status.enum.d.ts +5 -0
- package/build/enums/product-status.enum.js +9 -0
- package/build/enums/{product.enum.d.ts → product-type.enum.d.ts} +1 -1
- package/build/enums/product-type.enum.js +9 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/models/cart.model.d.ts +2 -2
- package/build/models/product.model.d.ts +10 -3
- package/build/models/product.model.js +7 -4
- package/build/models/racket.model.d.ts +3 -3
- package/build/models/racket.model.js +4 -2
- package/build/models/shirt.model.d.ts +3 -3
- package/build/models/shirt.model.js +2 -2
- package/build/models/sponge.model.d.ts +3 -3
- package/build/models/sponge.model.js +2 -2
- package/package.json +1 -1
- package/build/enums/product.enum.js +0 -9
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ProductStatus = void 0;
|
4
|
+
var ProductStatus;
|
5
|
+
(function (ProductStatus) {
|
6
|
+
ProductStatus["ENABLE"] = "enable";
|
7
|
+
ProductStatus["DISABLE"] = "disable";
|
8
|
+
ProductStatus["OUT_OF_STOCK"] = "out_of_stock";
|
9
|
+
})(ProductStatus || (exports.ProductStatus = ProductStatus = {}));
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ProductTypeEnum = void 0;
|
4
|
+
var ProductTypeEnum;
|
5
|
+
(function (ProductTypeEnum) {
|
6
|
+
ProductTypeEnum["Racket"] = "racket";
|
7
|
+
ProductTypeEnum["Shirt"] = "shirt";
|
8
|
+
ProductTypeEnum["Sponge"] = "sponge";
|
9
|
+
})(ProductTypeEnum || (exports.ProductTypeEnum = ProductTypeEnum = {}));
|
package/build/index.d.ts
CHANGED
@@ -18,7 +18,7 @@ export * from './models/status-timestamp.schema';
|
|
18
18
|
export * from './models/vendor.model';
|
19
19
|
export * from './models/vendor-purchased.model';
|
20
20
|
export * from './services/password';
|
21
|
-
export * from './enums/product.enum';
|
21
|
+
export * from './enums/product-type.enum';
|
22
22
|
export * from './enums/order-status.enum';
|
23
23
|
export * from './enums/payment-method.enum';
|
24
24
|
export * from './enums/user-status.enum';
|
package/build/index.js
CHANGED
@@ -34,7 +34,7 @@ __exportStar(require("./models/status-timestamp.schema"), exports);
|
|
34
34
|
__exportStar(require("./models/vendor.model"), exports);
|
35
35
|
__exportStar(require("./models/vendor-purchased.model"), exports);
|
36
36
|
__exportStar(require("./services/password"), exports);
|
37
|
-
__exportStar(require("./enums/product.enum"), exports);
|
37
|
+
__exportStar(require("./enums/product-type.enum"), exports);
|
38
38
|
__exportStar(require("./enums/order-status.enum"), exports);
|
39
39
|
__exportStar(require("./enums/payment-method.enum"), exports);
|
40
40
|
__exportStar(require("./enums/user-status.enum"), exports);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Document, Model, Types } from "mongoose";
|
2
|
-
export interface
|
2
|
+
export interface ICartAttrs {
|
3
3
|
user_id: Types.ObjectId;
|
4
4
|
products: [
|
5
5
|
{
|
@@ -18,7 +18,7 @@ interface CartDoc extends Document {
|
|
18
18
|
];
|
19
19
|
}
|
20
20
|
interface CartModel extends Model<CartDoc> {
|
21
|
-
build(attrs:
|
21
|
+
build(attrs: ICartAttrs): CartDoc;
|
22
22
|
}
|
23
23
|
export declare const CartModel: CartModel;
|
24
24
|
export {};
|
@@ -1,22 +1,29 @@
|
|
1
1
|
import mongoose, { Document } from 'mongoose';
|
2
|
-
import {
|
2
|
+
import { ProductTypeEnum } from '../enums/product-type.enum';
|
3
|
+
import { ProductStatus } from '../enums/product-status.enum';
|
3
4
|
export interface ProductAttrsBase {
|
4
5
|
name: string;
|
6
|
+
slug: string;
|
5
7
|
brand: string;
|
6
8
|
description: string;
|
9
|
+
type: ProductTypeEnum;
|
7
10
|
sport: string;
|
8
11
|
attributes: any;
|
12
|
+
status: ProductStatus;
|
9
13
|
price: number;
|
10
14
|
}
|
11
15
|
export interface ProductDoc extends Document {
|
12
16
|
name: string;
|
17
|
+
slug: string;
|
13
18
|
brand: string;
|
14
19
|
description: string;
|
15
|
-
type:
|
20
|
+
type: ProductTypeEnum;
|
16
21
|
sport: string;
|
17
22
|
attributes: any;
|
18
|
-
|
23
|
+
status: ProductStatus;
|
19
24
|
price: number;
|
25
|
+
createdAt: Date;
|
26
|
+
updatedAt: Date;
|
20
27
|
}
|
21
28
|
export declare const ProductModel: mongoose.Model<ProductDoc, {}, {}, {}, mongoose.Document<unknown, {}, ProductDoc, {}> & ProductDoc & Required<{
|
22
29
|
_id: unknown;
|
@@ -45,6 +45,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.ProductModel = void 0;
|
46
46
|
// src/models/product.model.ts
|
47
47
|
const mongoose_1 = __importStar(require("mongoose"));
|
48
|
+
const product_type_enum_1 = require("../enums/product-type.enum");
|
49
|
+
const product_status_enum_1 = require("../enums/product-status.enum");
|
48
50
|
//We don't need "interface ProductModel extends Model<>" for this
|
49
51
|
// because we don't have any static methods or custom instance methods
|
50
52
|
// like "build" or "findById" in this model.
|
@@ -56,13 +58,14 @@ const baseOptions = {
|
|
56
58
|
};
|
57
59
|
const ProductSchema = new mongoose_1.Schema({
|
58
60
|
name: { type: String, required: true, unique: true },
|
61
|
+
slug: { type: String, required: true, unique: true },
|
59
62
|
brand: { type: String, required: true },
|
60
63
|
description: { type: String, required: false },
|
61
|
-
type: { type: String, required: true },
|
64
|
+
type: { type: String, enum: Object.values(product_type_enum_1.ProductTypeEnum), required: true },
|
62
65
|
sport: { type: String, required: true },
|
63
|
-
attributes: { type: [mongoose_1.Schema.Types.Mixed],
|
64
|
-
|
65
|
-
price: { type: Number,
|
66
|
+
attributes: { type: [mongoose_1.Schema.Types.Mixed], required: false },
|
67
|
+
status: { type: String, enum: Object.values(product_status_enum_1.ProductStatus), default: product_status_enum_1.ProductStatus.ENABLE },
|
68
|
+
price: { type: Number, required: true },
|
66
69
|
}, baseOptions);
|
67
70
|
ProductSchema.pre("save", function (next) {
|
68
71
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { Model } from "mongoose";
|
2
|
-
import {
|
2
|
+
import { ProductTypeEnum } from "../enums/product-type.enum";
|
3
3
|
import { ProductAttrsBase, ProductDoc } from "./product.model";
|
4
4
|
export interface RacketAttrs extends ProductAttrsBase {
|
5
|
-
type:
|
5
|
+
type: ProductTypeEnum.Racket;
|
6
6
|
}
|
7
7
|
export interface RacketDoc extends ProductDoc {
|
8
|
-
type:
|
8
|
+
type: ProductTypeEnum.Racket;
|
9
9
|
}
|
10
10
|
interface RacketModel extends Model<RacketDoc> {
|
11
11
|
build(attrs: RacketAttrs): RacketDoc;
|
@@ -2,10 +2,12 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.RacketModel = void 0;
|
4
4
|
const mongoose_1 = require("mongoose");
|
5
|
-
const
|
5
|
+
const product_type_enum_1 = require("../enums/product-type.enum");
|
6
6
|
const product_model_1 = require("./product.model");
|
7
|
+
;
|
8
|
+
;
|
7
9
|
const racketSchema = new mongoose_1.Schema({});
|
8
10
|
racketSchema.statics.build = (attrs) => {
|
9
11
|
return new exports.RacketModel(attrs);
|
10
12
|
};
|
11
|
-
exports.RacketModel = product_model_1.ProductModel.discriminator(
|
13
|
+
exports.RacketModel = product_model_1.ProductModel.discriminator(product_type_enum_1.ProductTypeEnum.Racket, racketSchema);
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { ProductTypeEnum } from "../enums/product-type.enum";
|
2
2
|
import { ProductAttrsBase, ProductDoc } from "./product.model";
|
3
3
|
export interface ShirtAttrs extends ProductAttrsBase {
|
4
|
-
type:
|
4
|
+
type: ProductTypeEnum.Shirt;
|
5
5
|
}
|
6
6
|
export interface ShirtDoc extends ProductDoc {
|
7
|
-
type:
|
7
|
+
type: ProductTypeEnum.Shirt;
|
8
8
|
}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const mongoose_1 = require("mongoose");
|
4
|
-
const
|
4
|
+
const product_type_enum_1 = require("../enums/product-type.enum");
|
5
5
|
const product_model_1 = require("./product.model");
|
6
6
|
const shirtSchema = new mongoose_1.Schema({});
|
7
7
|
shirtSchema.statics.build = (attrs) => {
|
8
8
|
return new ShirtModel(attrs);
|
9
9
|
};
|
10
|
-
const ShirtModel = product_model_1.ProductModel.discriminator(
|
10
|
+
const ShirtModel = product_model_1.ProductModel.discriminator(product_type_enum_1.ProductTypeEnum.Shirt, new mongoose_1.Schema({}));
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { ProductTypeEnum } from "../enums/product-type.enum";
|
2
2
|
import { ProductAttrsBase, ProductDoc } from "./product.model";
|
3
3
|
export interface SpongeAttrs extends ProductAttrsBase {
|
4
|
-
type:
|
4
|
+
type: ProductTypeEnum.Sponge;
|
5
5
|
}
|
6
6
|
export interface SpongeDoc extends ProductDoc {
|
7
|
-
type:
|
7
|
+
type: ProductTypeEnum.Sponge;
|
8
8
|
}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const mongoose_1 = require("mongoose");
|
4
|
-
const
|
4
|
+
const product_type_enum_1 = require("../enums/product-type.enum");
|
5
5
|
const product_model_1 = require("./product.model");
|
6
6
|
const spongeSchema = new mongoose_1.Schema({});
|
7
7
|
spongeSchema.statics.build = (attrs) => {
|
8
8
|
return new SpongeModel(attrs);
|
9
9
|
};
|
10
10
|
// ─────────── Sponge ───────────
|
11
|
-
const SpongeModel = product_model_1.ProductModel.discriminator(
|
11
|
+
const SpongeModel = product_model_1.ProductModel.discriminator(product_type_enum_1.ProductTypeEnum.Sponge, new mongoose_1.Schema({}));
|
package/package.json
CHANGED
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ProductEnum = void 0;
|
4
|
-
var ProductEnum;
|
5
|
-
(function (ProductEnum) {
|
6
|
-
ProductEnum["Racket"] = "racket";
|
7
|
-
ProductEnum["Shirt"] = "shirt";
|
8
|
-
ProductEnum["Sponge"] = "sponge";
|
9
|
-
})(ProductEnum || (exports.ProductEnum = ProductEnum = {}));
|