tt-entities 0.0.17 → 0.0.18

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 (23) hide show
  1. package/dist/libs/tatayab-entities-library/src/entities/product-store.entity.d.ts +3 -0
  2. package/dist/libs/tatayab-entities-library/src/entities/product-store.entity.js +12 -0
  3. package/dist/libs/tatayab-entities-library/src/entities/product-store.entity.js.map +1 -1
  4. package/dist/libs/tatayab-entities-library/src/entities/product-tag.entity.d.ts +5 -0
  5. package/dist/libs/tatayab-entities-library/src/entities/product-tag.entity.js +32 -0
  6. package/dist/libs/tatayab-entities-library/src/entities/product-tag.entity.js.map +1 -0
  7. package/dist/libs/tatayab-entities-library/src/entities/product.entity.d.ts +2 -0
  8. package/dist/libs/tatayab-entities-library/src/entities/product.entity.js +6 -0
  9. package/dist/libs/tatayab-entities-library/src/entities/product.entity.js.map +1 -1
  10. package/dist/libs/tatayab-entities-library/src/entities/tag.entity.d.ts +12 -0
  11. package/dist/libs/tatayab-entities-library/src/entities/tag.entity.js +54 -0
  12. package/dist/libs/tatayab-entities-library/src/entities/tag.entity.js.map +1 -0
  13. package/dist/libs/tatayab-entities-library/src/index.d.ts +2 -1
  14. package/dist/libs/tatayab-entities-library/src/index.js +9 -5
  15. package/dist/libs/tatayab-entities-library/src/index.js.map +1 -1
  16. package/dist/src/main.js +290 -220
  17. package/libs/tatayab-entities-library/src/entities/product-store.entity.ts +11 -1
  18. package/libs/tatayab-entities-library/src/entities/product-tag.entity.ts +19 -0
  19. package/libs/tatayab-entities-library/src/entities/product.entity.ts +5 -0
  20. package/libs/tatayab-entities-library/src/entities/tag.entity.ts +38 -0
  21. package/libs/tatayab-entities-library/src/index.ts +7 -3
  22. package/package.json +1 -1
  23. package/libs/tatayab-entities-library/src/entities/translation.entity.ts +0 -17
@@ -19,10 +19,20 @@ export class ProductStore extends Model {
19
19
  @Column({ allowNull: false })
20
20
  declare storeId: number;
21
21
 
22
- // Store-specific price override — null means use product defaultPrice
22
+ // Store-specific regular price — null means use product.defaultPrice
23
23
  @Column({ type: DataType.DECIMAL(10, 3), allowNull: true })
24
24
  declare price?: number;
25
25
 
26
+ // Sale price — only active when today is between saleStartDate and saleEndDate
27
+ @Column({ type: DataType.DECIMAL(10, 3), allowNull: true })
28
+ declare salePrice?: number;
29
+
30
+ @Column({ type: DataType.DATE, allowNull: true })
31
+ declare saleStartDate?: Date;
32
+
33
+ @Column({ type: DataType.DATE, allowNull: true })
34
+ declare saleEndDate?: Date;
35
+
26
36
  @Column({
27
37
  type: DataType.ENUM(...Object.values(Status)),
28
38
  defaultValue: Status.ACTIVE,
@@ -0,0 +1,19 @@
1
+ import {
2
+ Table,
3
+ Column,
4
+ Model,
5
+ ForeignKey,
6
+ } from 'sequelize-typescript';
7
+ import { Product } from './product.entity';
8
+ import { Tag } from './tag.entity';
9
+
10
+ @Table
11
+ export class ProductTag extends Model {
12
+ @ForeignKey(() => Product)
13
+ @Column({ allowNull: false })
14
+ declare productId: number;
15
+
16
+ @ForeignKey(() => Tag)
17
+ @Column({ allowNull: false })
18
+ declare tagId: number;
19
+ }
@@ -13,7 +13,9 @@ import { Category } from './category.entity';
13
13
  import { ProductMedia } from './product-media.entity';
14
14
  import { ProductVariant } from './product-variant.entity';
15
15
  import { ProductStore } from './product-store.entity';
16
+ import { ProductTag } from './product-tag.entity';
16
17
  import { Store } from './store.entity';
18
+ import { Tag } from './tag.entity';
17
19
  import { Status } from '../utils/enums/status';
18
20
 
19
21
  @Table
@@ -79,4 +81,7 @@ export class Product extends Model {
79
81
 
80
82
  @BelongsToMany(() => Store, () => ProductStore)
81
83
  declare stores: Store[];
84
+
85
+ @BelongsToMany(() => Tag, () => ProductTag)
86
+ declare tags: Tag[];
82
87
  }
@@ -0,0 +1,38 @@
1
+ import {
2
+ Table,
3
+ Column,
4
+ Model,
5
+ BelongsToMany,
6
+ DataType,
7
+ } from 'sequelize-typescript';
8
+ import { Product } from './product.entity';
9
+ import { ProductTag } from './product-tag.entity';
10
+ import { Status } from '../utils/enums/status';
11
+
12
+ @Table
13
+ export class Tag extends Model {
14
+ @Column({ allowNull: false, unique: true })
15
+ declare slug: string; // e.g. 'best_seller', 'new_arrival', 'discount'
16
+
17
+ @Column({ allowNull: false })
18
+ declare nameEn: string;
19
+
20
+ @Column({ allowNull: false })
21
+ declare nameAr: string;
22
+
23
+ // Optional color for UI badge display e.g. '#FF0000'
24
+ @Column({ allowNull: true })
25
+ declare color?: string;
26
+
27
+ @Column({ defaultValue: 0 })
28
+ declare sortOrder: number;
29
+
30
+ @Column({
31
+ type: DataType.ENUM(...Object.values(Status)),
32
+ defaultValue: Status.ACTIVE,
33
+ })
34
+ declare status: Status;
35
+
36
+ @BelongsToMany(() => Product, () => ProductTag)
37
+ declare products: Product[];
38
+ }
@@ -2,7 +2,6 @@ import { ModelCtor } from 'sequelize-typescript';
2
2
 
3
3
  // ─── Existing ─────────────────────────────────────────────────────────────────
4
4
  import { Country } from './entities/country.entity';
5
- import { Translation } from './entities/translation.entity';
6
5
  import { Area } from './entities/area.entity';
7
6
  import { SysRole } from './entities/sys.role.entity';
8
7
  import { SysUser } from './entities/sys.user.entity';
@@ -19,6 +18,8 @@ import { Product } from './entities/product.entity';
19
18
  import { ProductMedia } from './entities/product-media.entity';
20
19
  import { ProductVariant } from './entities/product-variant.entity';
21
20
  import { ProductVariantOption } from './entities/product-variant-option.entity';
21
+ import { Tag } from './entities/tag.entity';
22
+ import { ProductTag } from './entities/product-tag.entity';
22
23
 
23
24
  // ─── Stores ───────────────────────────────────────────────────────────────────
24
25
  import { Store } from './entities/store.entity';
@@ -47,7 +48,6 @@ import { RolePermission } from '@app/tatayab-entities-library/entities/role-perm
47
48
  // ─── Existing ─────────────────────────────────────────────────────────────────
48
49
  export { ApiKey } from './entities/apikey.entity';
49
50
  export { Country } from './entities/country.entity';
50
- export { Translation } from './entities/translation.entity';
51
51
  export { Area } from './entities/area.entity';
52
52
  export { SysRole } from './entities/sys.role.entity';
53
53
  export { SysUser } from './entities/sys.user.entity';
@@ -63,6 +63,9 @@ export { Product } from './entities/product.entity';
63
63
  export { ProductMedia, MediaType } from './entities/product-media.entity';
64
64
  export { ProductVariant } from './entities/product-variant.entity';
65
65
  export { ProductVariantOption } from './entities/product-variant-option.entity';
66
+ export { Tag } from './entities/tag.entity';
67
+ export { ProductTag } from './entities/product-tag.entity';
68
+
66
69
 
67
70
  // ─── Stores ───────────────────────────────────────────────────────────────────
68
71
  export { Store } from './entities/store.entity';
@@ -110,7 +113,6 @@ export function getDbModels(): ModelCtor[] {
110
113
  Country,
111
114
  SysRole,
112
115
  SysUser,
113
- Translation,
114
116
  User,
115
117
  UserDevice,
116
118
 
@@ -123,6 +125,8 @@ export function getDbModels(): ModelCtor[] {
123
125
  ProductMedia,
124
126
  ProductVariant,
125
127
  ProductVariantOption,
128
+ Tag,
129
+ ProductTag,
126
130
 
127
131
  // Stores
128
132
  Store,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-entities",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Tatayab entities library",
5
5
  "main": "dist/libs/tatayab-entities-library/src/index.js",
6
6
  "types": "dist/libs/tatayab-entities-library/src/index.d.ts",
@@ -1,17 +0,0 @@
1
- import { Column, Model, Table } from 'sequelize-typescript';
2
-
3
- @Table
4
- export class Translation extends Model {
5
- @Column
6
- declare text: string;
7
- @Column
8
- declare shortDesc?: string;
9
- @Column
10
- declare longDesc?: string;
11
- @Column
12
- declare locale: string;
13
- @Column
14
- declare entityId: string;
15
- @Column
16
- declare entityName: string;
17
- }