@tabletennisshop/common 1.0.25 → 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.
@@ -0,0 +1,5 @@
1
+ export declare enum ProductStatus {
2
+ ENABLE = "enable",
3
+ DISABLE = "disable",
4
+ OUT_OF_STOCK = "out_of_stock"
5
+ }
@@ -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 = {}));
@@ -1,4 +1,4 @@
1
- export declare enum ProductEnum {
1
+ export declare enum ProductTypeEnum {
2
2
  Racket = "racket",
3
3
  Shirt = "shirt",
4
4
  Sponge = "sponge"
@@ -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 CartAttrs {
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: CartAttrs): CartDoc;
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 { ProductEnum } from '../enums/product.enum';
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: ProductEnum;
20
+ type: ProductTypeEnum;
16
21
  sport: string;
17
22
  attributes: any;
18
- slug: string;
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], require: false },
64
- slug: { type: String, required: true, unique: true },
65
- price: { type: Number, require: true }
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 { ProductEnum } from "../enums/product.enum";
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: ProductEnum.Racket;
5
+ type: ProductTypeEnum.Racket;
6
6
  }
7
7
  export interface RacketDoc extends ProductDoc {
8
- type: ProductEnum.Racket;
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 product_enum_1 = require("../enums/product.enum");
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(product_enum_1.ProductEnum.Racket, racketSchema);
13
+ exports.RacketModel = product_model_1.ProductModel.discriminator(product_type_enum_1.ProductTypeEnum.Racket, racketSchema);
@@ -1,8 +1,8 @@
1
- import { ProductEnum } from "../enums/product.enum";
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: ProductEnum.Shirt;
4
+ type: ProductTypeEnum.Shirt;
5
5
  }
6
6
  export interface ShirtDoc extends ProductDoc {
7
- type: ProductEnum.Shirt;
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 product_enum_1 = require("../enums/product.enum");
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(product_enum_1.ProductEnum.Shirt, new mongoose_1.Schema({}));
10
+ const ShirtModel = product_model_1.ProductModel.discriminator(product_type_enum_1.ProductTypeEnum.Shirt, new mongoose_1.Schema({}));
@@ -1,8 +1,8 @@
1
- import { ProductEnum } from "../enums/product.enum";
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: ProductEnum.Sponge;
4
+ type: ProductTypeEnum.Sponge;
5
5
  }
6
6
  export interface SpongeDoc extends ProductDoc {
7
- type: ProductEnum.Sponge;
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 product_enum_1 = require("../enums/product.enum");
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(product_enum_1.ProductEnum.Sponge, new mongoose_1.Schema({}));
11
+ const SpongeModel = product_model_1.ProductModel.discriminator(product_type_enum_1.ProductTypeEnum.Sponge, new mongoose_1.Schema({}));
@@ -2,11 +2,11 @@ import { Document, Model } from "mongoose";
2
2
  import { IAddress } from "./address.schema";
3
3
  export interface VendorAttrs {
4
4
  name: string;
5
- address: IAddress[];
5
+ addresses: IAddress[];
6
6
  }
7
7
  interface VendorDoc extends Document {
8
8
  name: string;
9
- address: IAddress[];
9
+ addresses: IAddress[];
10
10
  }
11
11
  interface VendorModel extends Model<VendorDoc> {
12
12
  build(attr: VendorAttrs): VendorDoc;
@@ -5,7 +5,7 @@ const mongoose_1 = require("mongoose");
5
5
  const address_schema_1 = require("./address.schema");
6
6
  const VendorSchema = new mongoose_1.Schema({
7
7
  name: { type: String, required: true },
8
- address: [
8
+ addresses: [
9
9
  { type: address_schema_1.AddressSchema, required: true }
10
10
  ]
11
11
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tabletennisshop/common",
3
- "version": "1.0.25",
3
+ "version": "1.0.29",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -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 = {}));