tt-entities 0.1.21 → 0.1.23

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/entities/bundle-product.entity.d.ts +1 -0
  2. package/dist/libs/tatayab-entities-library/entities/bundle-product.entity.js +4 -0
  3. package/dist/libs/tatayab-entities-library/entities/bundle-product.entity.js.map +1 -1
  4. package/dist/libs/tatayab-entities-library/entities/bundle.entity.d.ts +2 -0
  5. package/dist/libs/tatayab-entities-library/entities/bundle.entity.js +9 -0
  6. package/dist/libs/tatayab-entities-library/entities/bundle.entity.js.map +1 -1
  7. package/dist/libs/tatayab-entities-library/entities/payment-method.entity.js +1 -1
  8. package/dist/libs/tatayab-entities-library/entities/payment-method.entity.js.map +1 -1
  9. package/dist/libs/tatayab-entities-library/index.d.ts +1 -0
  10. package/dist/libs/tatayab-entities-library/index.js +4 -2
  11. package/dist/libs/tatayab-entities-library/index.js.map +1 -1
  12. package/dist/libs/tatayab-entities-library/utils/enums/bundleType.d.ts +5 -0
  13. package/dist/libs/tatayab-entities-library/utils/enums/bundleType.js +10 -0
  14. package/dist/libs/tatayab-entities-library/utils/enums/bundleType.js.map +1 -0
  15. package/dist/src/main.js +5226 -3743
  16. package/libs/tatayab-entities-library/src/entities/bundle-product.entity.ts +6 -0
  17. package/libs/tatayab-entities-library/src/entities/bundle.entity.ts +11 -0
  18. package/libs/tatayab-entities-library/src/entities/payment-method.entity.ts +3 -2
  19. package/libs/tatayab-entities-library/src/index.ts +1 -0
  20. package/libs/tatayab-entities-library/src/utils/enums/bundleType.ts +5 -0
  21. package/package.json +1 -1
  22. package/src/database/migrations/20260818100000-add-type-to-bundles.js +21 -0
  23. package/src/database/migrations/20260818110000-add-is-fixed-to-bundle-products.js +17 -0
@@ -25,6 +25,12 @@ export class BundleProduct extends Model {
25
25
  @Column({ defaultValue: 0 })
26
26
  declare sortOrder: number;
27
27
 
28
+ // When true this slot is pre-selected and the customer cannot deselect it.
29
+ // Relevant for flexible bundles (marks mandatory products) and fixed bundles
30
+ // (all products are isFixed = true).
31
+ @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: false })
32
+ declare isFixed: boolean;
33
+
28
34
  // ─── Associations ─────────────────────────────────────────────────────────────
29
35
 
30
36
  @BelongsTo(() => Bundle)
@@ -8,6 +8,7 @@ import { BundleProduct } from './bundle-product.entity';
8
8
  import { BundleStore } from './bundle-store.entity';
9
9
  import { Product } from './product.entity';
10
10
  import { Status } from '../utils/enums/status';
11
+ import { BundleType } from '../utils/enums/bundleType';
11
12
 
12
13
  @Table
13
14
  export class Bundle extends Model {
@@ -58,6 +59,16 @@ export class Bundle extends Model {
58
59
  })
59
60
  declare status: Status;
60
61
 
62
+ // dynamic — customer picks X from Y (classic behaviour)
63
+ // flexible — some products are pre-selected (isFixed); customer fills remaining slots
64
+ // fixed — all selections are predetermined; customer cannot change anything
65
+ @Column({
66
+ type: DataType.ENUM(...Object.values(BundleType)),
67
+ allowNull: false,
68
+ defaultValue: BundleType.DYNAMIC,
69
+ })
70
+ declare type: BundleType;
71
+
61
72
  // ─── Associations ─────────────────────────────────────────────────────────────
62
73
 
63
74
  @BelongsTo(() => Category)
@@ -25,8 +25,9 @@ export class PaymentMethod extends Model {
25
25
  @Column({ allowNull: false })
26
26
  declare paymentGatewayId: number;
27
27
 
28
- @Column({ allowNull: false, unique: true })
29
- declare slug: string; // e.g. 'tabby_pay_later', 'knet', 'visa'
28
+ // The code sent to the payment gateway when initiating a payment — not a unique identifier
29
+ @Column({ allowNull: false })
30
+ declare slug: string;
30
31
 
31
32
  @Column({ allowNull: false })
32
33
  declare nameEn: string;
@@ -173,6 +173,7 @@ export { ProductTag } from './entities/product-tag.entity';
173
173
  export { Bundle } from './entities/bundle.entity';
174
174
  export { BundleProduct } from './entities/bundle-product.entity';
175
175
  export { BundleStore } from './entities/bundle-store.entity';
176
+ export { BundleType } from './utils/enums/bundleType';
176
177
 
177
178
  // ─── Stores ───────────────────────────────────────────────────────────────────
178
179
  export { Store } from './entities/store.entity';
@@ -0,0 +1,5 @@
1
+ export enum BundleType {
2
+ DYNAMIC = 'dynamic',
3
+ FLEXIBLE = 'flexible',
4
+ FIXED = 'fixed',
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-entities",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "Tatayab entities library",
5
5
  "main": "dist/libs/tatayab-entities-library/index.js",
6
6
  "types": "dist/libs/tatayab-entities-library/index.d.ts",
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ /** @type {import('sequelize-cli').Migration} */
4
+ module.exports = {
5
+ async up(queryInterface, Sequelize) {
6
+ await queryInterface.addColumn('Bundles', 'type', {
7
+ type: Sequelize.ENUM('dynamic', 'flexible', 'fixed'),
8
+ allowNull: false,
9
+ defaultValue: 'dynamic',
10
+ after: 'status',
11
+ });
12
+ },
13
+
14
+ async down(queryInterface) {
15
+ await queryInterface.removeColumn('Bundles', 'type');
16
+ // MySQL requires the ENUM type to be dropped separately
17
+ await queryInterface.sequelize.query(
18
+ "ALTER TABLE `Bundles` MODIFY `type` VARCHAR(10) NULL",
19
+ ).catch(() => { /* ignore if already removed */ });
20
+ },
21
+ };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ /** @type {import('sequelize-cli').Migration} */
4
+ module.exports = {
5
+ async up(queryInterface, Sequelize) {
6
+ await queryInterface.addColumn('BundleProducts', 'isFixed', {
7
+ type: Sequelize.BOOLEAN,
8
+ allowNull: false,
9
+ defaultValue: false,
10
+ after: 'sortOrder',
11
+ });
12
+ },
13
+
14
+ async down(queryInterface) {
15
+ await queryInterface.removeColumn('BundleProducts', 'isFixed');
16
+ },
17
+ };