tt-entities 0.0.16 → 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 (39) hide show
  1. package/dist/libs/tatayab-entities-library/src/entities/permission.entity.d.ts +8 -0
  2. package/dist/libs/tatayab-entities-library/src/entities/permission.entity.js +38 -0
  3. package/dist/libs/tatayab-entities-library/src/entities/permission.entity.js.map +1 -0
  4. package/dist/libs/tatayab-entities-library/src/entities/product-store.entity.d.ts +3 -0
  5. package/dist/libs/tatayab-entities-library/src/entities/product-store.entity.js +12 -0
  6. package/dist/libs/tatayab-entities-library/src/entities/product-store.entity.js.map +1 -1
  7. package/dist/libs/tatayab-entities-library/src/entities/product-tag.entity.d.ts +5 -0
  8. package/dist/libs/tatayab-entities-library/src/entities/product-tag.entity.js +32 -0
  9. package/dist/libs/tatayab-entities-library/src/entities/product-tag.entity.js.map +1 -0
  10. package/dist/libs/tatayab-entities-library/src/entities/product.entity.d.ts +2 -0
  11. package/dist/libs/tatayab-entities-library/src/entities/product.entity.js +6 -0
  12. package/dist/libs/tatayab-entities-library/src/entities/product.entity.js.map +1 -1
  13. package/dist/libs/tatayab-entities-library/src/entities/role-permission.entity.d.ts +5 -0
  14. package/dist/libs/tatayab-entities-library/src/entities/role-permission.entity.js +32 -0
  15. package/dist/libs/tatayab-entities-library/src/entities/role-permission.entity.js.map +1 -0
  16. package/dist/libs/tatayab-entities-library/src/entities/sys.role.entity.d.ts +3 -0
  17. package/dist/libs/tatayab-entities-library/src/entities/sys.role.entity.js +11 -1
  18. package/dist/libs/tatayab-entities-library/src/entities/sys.role.entity.js.map +1 -1
  19. package/dist/libs/tatayab-entities-library/src/entities/sys.user.entity.d.ts +6 -6
  20. package/dist/libs/tatayab-entities-library/src/entities/sys.user.entity.js +15 -15
  21. package/dist/libs/tatayab-entities-library/src/entities/sys.user.entity.js.map +1 -1
  22. package/dist/libs/tatayab-entities-library/src/entities/tag.entity.d.ts +12 -0
  23. package/dist/libs/tatayab-entities-library/src/entities/tag.entity.js +54 -0
  24. package/dist/libs/tatayab-entities-library/src/entities/tag.entity.js.map +1 -0
  25. package/dist/libs/tatayab-entities-library/src/index.d.ts +4 -1
  26. package/dist/libs/tatayab-entities-library/src/index.js +17 -5
  27. package/dist/libs/tatayab-entities-library/src/index.js.map +1 -1
  28. package/dist/src/main.js +392 -224
  29. package/libs/tatayab-entities-library/src/entities/permission.entity.ts +26 -0
  30. package/libs/tatayab-entities-library/src/entities/product-store.entity.ts +11 -1
  31. package/libs/tatayab-entities-library/src/entities/product-tag.entity.ts +19 -0
  32. package/libs/tatayab-entities-library/src/entities/product.entity.ts +5 -0
  33. package/libs/tatayab-entities-library/src/entities/role-permission.entity.ts +19 -0
  34. package/libs/tatayab-entities-library/src/entities/sys.role.entity.ts +16 -2
  35. package/libs/tatayab-entities-library/src/entities/sys.user.entity.ts +22 -21
  36. package/libs/tatayab-entities-library/src/entities/tag.entity.ts +38 -0
  37. package/libs/tatayab-entities-library/src/index.ts +20 -3
  38. package/package.json +1 -1
  39. package/libs/tatayab-entities-library/src/entities/translation.entity.ts +0 -17
@@ -0,0 +1,26 @@
1
+ import {
2
+ Table,
3
+ Column,
4
+ Model,
5
+ BelongsToMany,
6
+ } from 'sequelize-typescript';
7
+ import { SysRole } from './sys.role.entity';
8
+ import { RolePermission } from './role-permission.entity';
9
+
10
+ @Table
11
+ export class Permission extends Model {
12
+ // e.g. 'products.view', 'products.create', 'inventory.adjust'
13
+ @Column({ allowNull: false, unique: true })
14
+ declare name: string;
15
+
16
+ // Human readable e.g. 'View Products'
17
+ @Column({ allowNull: false })
18
+ declare displayName: string;
19
+
20
+ // Grouping for UI e.g. 'Products', 'Inventory', 'Purchasing'
21
+ @Column({ allowNull: false })
22
+ declare group: string;
23
+
24
+ @BelongsToMany(() => SysRole, () => RolePermission)
25
+ declare roles: SysRole[];
26
+ }
@@ -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,19 @@
1
+ import {
2
+ Table,
3
+ Column,
4
+ Model,
5
+ ForeignKey,
6
+ } from 'sequelize-typescript';
7
+ import { SysRole } from './sys.role.entity';
8
+ import { Permission } from './permission.entity';
9
+
10
+ @Table
11
+ export class RolePermission extends Model {
12
+ @ForeignKey(() => SysRole)
13
+ @Column({ allowNull: false })
14
+ declare sysRoleId: number;
15
+
16
+ @ForeignKey(() => Permission)
17
+ @Column({ allowNull: false })
18
+ declare permissionId: number;
19
+ }
@@ -1,7 +1,21 @@
1
- import { Column, Model, Table } from 'sequelize-typescript';
1
+ import {
2
+ Table,
3
+ Column,
4
+ Model,
5
+ BelongsToMany,
6
+ HasMany,
7
+ } from 'sequelize-typescript';
8
+ import { Permission } from './permission.entity';
9
+ import { RolePermission } from './role-permission.entity';
2
10
 
3
11
  @Table
4
12
  export class SysRole extends Model {
5
- @Column
13
+ @Column({ allowNull: false, unique: true })
6
14
  declare name: string;
15
+
16
+ @Column({ allowNull: true })
17
+ declare displayName?: string;
18
+
19
+ @BelongsToMany(() => Permission, () => RolePermission)
20
+ declare permissions: Permission[];
7
21
  }
@@ -1,49 +1,50 @@
1
1
  import {
2
- BelongsTo,
2
+ Table,
3
3
  Column,
4
- DataType,
5
- ForeignKey,
6
4
  Model,
7
- Table,
5
+ ForeignKey,
6
+ BelongsTo,
7
+ DataType,
8
8
  } from 'sequelize-typescript';
9
- import { Status } from '../utils/enums/status';
10
9
  import { SysRole } from './sys.role.entity';
10
+ import { Status } from '../utils/enums/status';
11
11
 
12
12
  @Table
13
13
  export class SysUser extends Model {
14
14
  @Column
15
15
  declare name: string;
16
16
 
17
- @Column({ allowNull: false, validate: { unique: true } })
17
+ @Column({ allowNull: false })
18
18
  declare username: string;
19
19
 
20
- @Column
20
+ @Column({ allowNull: false, unique: true })
21
21
  declare email: string;
22
22
 
23
- @Column
23
+ @Column({ allowNull: false })
24
24
  declare phoneExt: string;
25
25
 
26
- @Column
26
+ @Column({ allowNull: false })
27
27
  declare phone: string;
28
28
 
29
- @Column
29
+ @Column({ allowNull: false })
30
30
  declare password: string;
31
+
32
+ @Column
33
+ declare profilePicture?: string;
34
+
35
+ @ForeignKey(() => SysRole)
36
+ @Column({ allowNull: true })
37
+ declare roleId?: number;
38
+
31
39
  @Column({
32
40
  type: DataType.ENUM(...Object.values(Status)),
33
41
  defaultValue: Status.ACTIVE,
34
42
  })
35
- declare status?: Status;
43
+ declare status: Status;
36
44
 
37
- @ForeignKey(() => SysRole)
38
- @Column
39
- declare roleId: number;
40
-
41
- @Column
42
- declare profilePicture: string;
43
-
44
- @Column
45
- declare lastLogin: Date;
45
+ @Column({ allowNull: true })
46
+ declare lastLogin?: Date;
46
47
 
47
48
  @BelongsTo(() => SysRole)
48
- declare role: SysRole;
49
+ declare role?: SysRole;
49
50
  }
@@ -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';
@@ -36,6 +37,10 @@ import { VendorProduct } from './entities/vendor-product.entity';
36
37
  import { PurchaseOrder } from './entities/purchase-order.entity';
37
38
  import { PurchaseOrderItem } from './entities/purchase-order-item.entity';
38
39
 
40
+ // ─── Permissions ──────────────────────────────────────────────────────────────
41
+ import { Permission } from '@app/tatayab-entities-library/entities/permission.entity';
42
+ import { RolePermission } from '@app/tatayab-entities-library/entities/role-permission.entity';
43
+
39
44
  // =============================================================================
40
45
  // EXPORTS
41
46
  // =============================================================================
@@ -43,7 +48,6 @@ import { PurchaseOrderItem } from './entities/purchase-order-item.entity';
43
48
  // ─── Existing ─────────────────────────────────────────────────────────────────
44
49
  export { ApiKey } from './entities/apikey.entity';
45
50
  export { Country } from './entities/country.entity';
46
- export { Translation } from './entities/translation.entity';
47
51
  export { Area } from './entities/area.entity';
48
52
  export { SysRole } from './entities/sys.role.entity';
49
53
  export { SysUser } from './entities/sys.user.entity';
@@ -59,6 +63,9 @@ export { Product } from './entities/product.entity';
59
63
  export { ProductMedia, MediaType } from './entities/product-media.entity';
60
64
  export { ProductVariant } from './entities/product-variant.entity';
61
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
+
62
69
 
63
70
  // ─── Stores ───────────────────────────────────────────────────────────────────
64
71
  export { Store } from './entities/store.entity';
@@ -79,6 +86,11 @@ export {
79
86
  PurchaseOrderItemStatus,
80
87
  } from './entities/purchase-order-item.entity';
81
88
 
89
+ // ─── Permissions ──────────────────────────────────────────────────────────────
90
+
91
+ export { Permission } from './entities/permission.entity';
92
+ export { RolePermission } from './entities/role-permission.entity';
93
+
82
94
  // ─── Enums ────────────────────────────────────────────────────────────────────
83
95
  export { OsName } from './utils/enums/osName';
84
96
  export { ProductApp } from './utils/enums/productApp';
@@ -101,7 +113,6 @@ export function getDbModels(): ModelCtor[] {
101
113
  Country,
102
114
  SysRole,
103
115
  SysUser,
104
- Translation,
105
116
  User,
106
117
  UserDevice,
107
118
 
@@ -114,6 +125,8 @@ export function getDbModels(): ModelCtor[] {
114
125
  ProductMedia,
115
126
  ProductVariant,
116
127
  ProductVariantOption,
128
+ Tag,
129
+ ProductTag,
117
130
 
118
131
  // Stores
119
132
  Store,
@@ -130,5 +143,9 @@ export function getDbModels(): ModelCtor[] {
130
143
  VendorProduct,
131
144
  PurchaseOrder,
132
145
  PurchaseOrderItem,
146
+
147
+ // Permissions
148
+ Permission,
149
+ RolePermission,
133
150
  ];
134
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-entities",
3
- "version": "0.0.16",
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
- }