tt-entities 0.0.28 → 0.0.30
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/dist/libs/tatayab-entities-library/entities/bundle-product.entity.d.ts +13 -0
- package/dist/libs/tatayab-entities-library/entities/bundle-product.entity.js +54 -0
- package/dist/libs/tatayab-entities-library/entities/bundle-product.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/entities/bundle-store.entity.d.ts +11 -0
- package/dist/libs/tatayab-entities-library/entities/bundle-store.entity.js +56 -0
- package/dist/libs/tatayab-entities-library/entities/bundle-store.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/entities/bundle.entity.d.ts +27 -0
- package/dist/libs/tatayab-entities-library/entities/bundle.entity.js +102 -0
- package/dist/libs/tatayab-entities-library/entities/bundle.entity.js.map +1 -0
- package/dist/libs/tatayab-entities-library/entities/country.entity.d.ts +1 -1
- package/dist/libs/tatayab-entities-library/entities/country.entity.js +2 -2
- package/dist/libs/tatayab-entities-library/entities/country.entity.js.map +1 -1
- package/dist/libs/tatayab-entities-library/entities/store.entity.d.ts +1 -1
- package/dist/libs/tatayab-entities-library/entities/store.entity.js +2 -2
- package/dist/libs/tatayab-entities-library/entities/store.entity.js.map +1 -1
- package/dist/libs/tatayab-entities-library/index.d.ts +3 -0
- package/dist/libs/tatayab-entities-library/index.js +14 -1
- package/dist/libs/tatayab-entities-library/index.js.map +1 -1
- package/dist/src/main.js +261 -6
- package/libs/tatayab-entities-library/src/entities/bundle-product.entity.ts +38 -0
- package/libs/tatayab-entities-library/src/entities/bundle-store.entity.ts +37 -0
- package/libs/tatayab-entities-library/src/entities/bundle.entity.ts +77 -0
- package/libs/tatayab-entities-library/src/entities/country.entity.ts +2 -2
- package/libs/tatayab-entities-library/src/entities/store.entity.ts +2 -2
- package/libs/tatayab-entities-library/src/index.ts +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table, Column, Model, ForeignKey, BelongsTo, DataType,
|
|
3
|
+
} from 'sequelize-typescript';
|
|
4
|
+
import { Bundle } from './bundle.entity';
|
|
5
|
+
import { Product } from './product.entity';
|
|
6
|
+
import { ProductVariant } from './product-variant.entity';
|
|
7
|
+
|
|
8
|
+
@Table
|
|
9
|
+
export class BundleProduct extends Model {
|
|
10
|
+
@ForeignKey(() => Bundle)
|
|
11
|
+
@Column({ allowNull: false })
|
|
12
|
+
declare bundleId: number;
|
|
13
|
+
|
|
14
|
+
@ForeignKey(() => Product)
|
|
15
|
+
@Column({ allowNull: false })
|
|
16
|
+
declare productId: number;
|
|
17
|
+
|
|
18
|
+
// Optional — if set, only this specific variant is part of the bundle
|
|
19
|
+
// null = customer can pick any variant of this product
|
|
20
|
+
@ForeignKey(() => ProductVariant)
|
|
21
|
+
@Column({ allowNull: true })
|
|
22
|
+
declare productVariantId?: number;
|
|
23
|
+
|
|
24
|
+
// Display order inside the bundle picker UI
|
|
25
|
+
@Column({ defaultValue: 0 })
|
|
26
|
+
declare sortOrder: number;
|
|
27
|
+
|
|
28
|
+
// ─── Associations ─────────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
@BelongsTo(() => Bundle)
|
|
31
|
+
declare bundle: Bundle;
|
|
32
|
+
|
|
33
|
+
@BelongsTo(() => Product)
|
|
34
|
+
declare product: Product;
|
|
35
|
+
|
|
36
|
+
@BelongsTo(() => ProductVariant)
|
|
37
|
+
declare variant?: ProductVariant;
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table, Column, Model, ForeignKey, DataType,
|
|
3
|
+
} from 'sequelize-typescript';
|
|
4
|
+
import { Bundle } from './bundle.entity';
|
|
5
|
+
import { Store } from './store.entity';
|
|
6
|
+
import { Status } from '../utils/enums/status';
|
|
7
|
+
|
|
8
|
+
@Table
|
|
9
|
+
export class BundleStore extends Model {
|
|
10
|
+
@ForeignKey(() => Bundle)
|
|
11
|
+
@Column({ allowNull: false })
|
|
12
|
+
declare bundleId: number;
|
|
13
|
+
|
|
14
|
+
@ForeignKey(() => Store)
|
|
15
|
+
@Column({ allowNull: false })
|
|
16
|
+
declare storeId: number;
|
|
17
|
+
|
|
18
|
+
// Store-specific regular price — null = use bundle.defaultPrice
|
|
19
|
+
@Column({ type: DataType.DECIMAL(10, 3), allowNull: true })
|
|
20
|
+
declare price?: number;
|
|
21
|
+
|
|
22
|
+
// Sale price — active only within saleStartDate → saleEndDate
|
|
23
|
+
@Column({ type: DataType.DECIMAL(10, 3), allowNull: true })
|
|
24
|
+
declare salePrice?: number;
|
|
25
|
+
|
|
26
|
+
@Column({ type: DataType.DATE, allowNull: true })
|
|
27
|
+
declare saleStartDate?: Date;
|
|
28
|
+
|
|
29
|
+
@Column({ type: DataType.DATE, allowNull: true })
|
|
30
|
+
declare saleEndDate?: Date;
|
|
31
|
+
|
|
32
|
+
@Column({
|
|
33
|
+
type: DataType.ENUM(...Object.values(Status)),
|
|
34
|
+
defaultValue: Status.ACTIVE,
|
|
35
|
+
})
|
|
36
|
+
declare status: Status;
|
|
37
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Table, Column, Model, ForeignKey, BelongsTo,
|
|
3
|
+
HasMany, BelongsToMany, DataType,
|
|
4
|
+
} from 'sequelize-typescript';
|
|
5
|
+
import { Category } from './category.entity';
|
|
6
|
+
import { Store } from './store.entity';
|
|
7
|
+
import { BundleProduct } from './bundle-product.entity';
|
|
8
|
+
import { BundleStore } from './bundle-store.entity';
|
|
9
|
+
import { Product } from './product.entity';
|
|
10
|
+
import { Status } from '../utils/enums/status';
|
|
11
|
+
|
|
12
|
+
@Table
|
|
13
|
+
export class Bundle extends Model {
|
|
14
|
+
@Column({ allowNull: false, unique: true })
|
|
15
|
+
declare sku: string; // Bundle SKU e.g. BNDL-001
|
|
16
|
+
|
|
17
|
+
@Column({ allowNull: false })
|
|
18
|
+
declare nameEn: string;
|
|
19
|
+
|
|
20
|
+
@Column({ allowNull: false })
|
|
21
|
+
declare nameAr: string;
|
|
22
|
+
|
|
23
|
+
@Column({ type: DataType.TEXT, allowNull: true })
|
|
24
|
+
declare descriptionEn?: string;
|
|
25
|
+
|
|
26
|
+
@Column({ type: DataType.TEXT, allowNull: true })
|
|
27
|
+
declare descriptionAr?: string;
|
|
28
|
+
|
|
29
|
+
@Column({ allowNull: true })
|
|
30
|
+
declare image?: string;
|
|
31
|
+
|
|
32
|
+
// Total products available to choose from in this bundle
|
|
33
|
+
@Column({ allowNull: false, defaultValue: 0 })
|
|
34
|
+
declare totalProducts: number;
|
|
35
|
+
|
|
36
|
+
// How many the customer must choose
|
|
37
|
+
// e.g. totalProducts=10, choiceCount=3 → pick any 3 from 10
|
|
38
|
+
@Column({ allowNull: false, defaultValue: 1 })
|
|
39
|
+
declare choiceCount: number;
|
|
40
|
+
|
|
41
|
+
// Default price (fallback if no store-specific price)
|
|
42
|
+
@Column({ type: DataType.DECIMAL(10, 3), allowNull: false, defaultValue: 0 })
|
|
43
|
+
declare defaultPrice: number;
|
|
44
|
+
|
|
45
|
+
@ForeignKey(() => Category)
|
|
46
|
+
@Column({ allowNull: true })
|
|
47
|
+
declare categoryId?: number;
|
|
48
|
+
|
|
49
|
+
@Column({ defaultValue: 0 })
|
|
50
|
+
declare sortOrder: number;
|
|
51
|
+
|
|
52
|
+
@Column({ defaultValue: false })
|
|
53
|
+
declare isFeatured: boolean;
|
|
54
|
+
|
|
55
|
+
@Column({
|
|
56
|
+
type: DataType.ENUM(...Object.values(Status)),
|
|
57
|
+
defaultValue: Status.ACTIVE,
|
|
58
|
+
})
|
|
59
|
+
declare status: Status;
|
|
60
|
+
|
|
61
|
+
// ─── Associations ─────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
@BelongsTo(() => Category)
|
|
64
|
+
declare category?: Category;
|
|
65
|
+
|
|
66
|
+
@HasMany(() => BundleProduct)
|
|
67
|
+
declare bundleProducts: BundleProduct[];
|
|
68
|
+
|
|
69
|
+
@BelongsToMany(() => Product, () => BundleProduct)
|
|
70
|
+
declare products: Product[];
|
|
71
|
+
|
|
72
|
+
@HasMany(() => BundleStore)
|
|
73
|
+
declare bundleStores: BundleStore[];
|
|
74
|
+
|
|
75
|
+
@BelongsToMany(() => Store, () => BundleStore)
|
|
76
|
+
declare stores: Store[];
|
|
77
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BelongsToMany, Column, Model, Table } from 'sequelize-typescript';
|
|
2
|
-
import { PaymentMethod } from '
|
|
3
|
-
import { PaymentMethodCountry } from '
|
|
2
|
+
import { PaymentMethod } from './payment-method.entity';
|
|
3
|
+
import { PaymentMethodCountry } from './payment-method-country.entity';
|
|
4
4
|
|
|
5
5
|
@Table
|
|
6
6
|
export class Country extends Model {
|
|
@@ -14,8 +14,8 @@ import { Product } from './product.entity';
|
|
|
14
14
|
import { StoreInventory } from './store-inventory.entity';
|
|
15
15
|
import { Inventory } from './inventory.entity';
|
|
16
16
|
import { Status } from '../utils/enums/status';
|
|
17
|
-
import { PaymentMethod } from '
|
|
18
|
-
import { StorePaymentMethod } from '
|
|
17
|
+
import { PaymentMethod } from './payment-method.entity';
|
|
18
|
+
import { StorePaymentMethod } from './store-payment-method.entity';
|
|
19
19
|
|
|
20
20
|
@Table
|
|
21
21
|
export class Store extends Model {
|
|
@@ -22,6 +22,9 @@ import { ProductVariant } from './entities/product-variant.entity';
|
|
|
22
22
|
import { ProductVariantOption } from './entities/product-variant-option.entity';
|
|
23
23
|
import { Tag } from './entities/tag.entity';
|
|
24
24
|
import { ProductTag } from './entities/product-tag.entity';
|
|
25
|
+
import { Bundle } from './entities/bundle.entity';
|
|
26
|
+
import { BundleProduct } from './entities/bundle-product.entity';
|
|
27
|
+
import { BundleStore } from './entities/bundle-store.entity';
|
|
25
28
|
|
|
26
29
|
// ─── Stores ───────────────────────────────────────────────────────────────────
|
|
27
30
|
import { Store } from './entities/store.entity';
|
|
@@ -76,6 +79,9 @@ export { ProductVariant } from './entities/product-variant.entity';
|
|
|
76
79
|
export { ProductVariantOption } from './entities/product-variant-option.entity';
|
|
77
80
|
export { Tag } from './entities/tag.entity';
|
|
78
81
|
export { ProductTag } from './entities/product-tag.entity';
|
|
82
|
+
export { Bundle } from './entities/bundle.entity';
|
|
83
|
+
export { BundleProduct } from './entities/bundle-product.entity';
|
|
84
|
+
export { BundleStore } from './entities/bundle-store.entity';
|
|
79
85
|
|
|
80
86
|
// ─── Stores ───────────────────────────────────────────────────────────────────
|
|
81
87
|
export { Store } from './entities/store.entity';
|
|
@@ -152,6 +158,9 @@ export function getDbModels(): ModelCtor[] {
|
|
|
152
158
|
ProductVariantOption,
|
|
153
159
|
Tag,
|
|
154
160
|
ProductTag,
|
|
161
|
+
Bundle,
|
|
162
|
+
BundleProduct,
|
|
163
|
+
BundleStore,
|
|
155
164
|
|
|
156
165
|
// Stores
|
|
157
166
|
Store,
|