@driveup/schema 0.1.0
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/README.md +174 -0
- package/lib/catalog/addon/addon.entity.d.ts +109 -0
- package/lib/catalog/addon/addon.entity.js +260 -0
- package/lib/catalog/addon/addon.entity.js.map +1 -0
- package/lib/catalog/addon/country.entity.d.ts +112 -0
- package/lib/catalog/addon/country.entity.js +246 -0
- package/lib/catalog/addon/country.entity.js.map +1 -0
- package/lib/catalog/driving/category.entity.d.ts +122 -0
- package/lib/catalog/driving/category.entity.js +217 -0
- package/lib/catalog/driving/category.entity.js.map +1 -0
- package/lib/catalog/driving/vehicle.entity.d.ts +49 -0
- package/lib/catalog/driving/vehicle.entity.js +97 -0
- package/lib/catalog/driving/vehicle.entity.js.map +1 -0
- package/lib/catalog/priceplan/priceplan.entity.d.ts +123 -0
- package/lib/catalog/priceplan/priceplan.entity.js +288 -0
- package/lib/catalog/priceplan/priceplan.entity.js.map +1 -0
- package/lib/catalog/product/country.entity.d.ts +109 -0
- package/lib/catalog/product/country.entity.js +233 -0
- package/lib/catalog/product/country.entity.js.map +1 -0
- package/lib/catalog/product/priceplan.entity.d.ts +113 -0
- package/lib/catalog/product/priceplan.entity.js +251 -0
- package/lib/catalog/product/priceplan.entity.js.map +1 -0
- package/lib/catalog/product/product.entity.d.ts +104 -0
- package/lib/catalog/product/product.entity.js +262 -0
- package/lib/catalog/product/product.entity.js.map +1 -0
- package/lib/catalog/program/program.entity.d.ts +107 -0
- package/lib/catalog/program/program.entity.js +247 -0
- package/lib/catalog/program/program.entity.js.map +1 -0
- package/lib/catalog/seed/assets/asset.entity.d.ts +68 -0
- package/lib/catalog/seed/assets/asset.entity.js +163 -0
- package/lib/catalog/seed/assets/asset.entity.js.map +1 -0
- package/lib/catalog/seed/courses/course.entity.d.ts +98 -0
- package/lib/catalog/seed/courses/course.entity.js +216 -0
- package/lib/catalog/seed/courses/course.entity.js.map +1 -0
- package/lib/catalog/seed/courses/lesson.entity.d.ts +90 -0
- package/lib/catalog/seed/courses/lesson.entity.js +214 -0
- package/lib/catalog/seed/courses/lesson.entity.js.map +1 -0
- package/lib/catalog/seed/courses/topic.entity.d.ts +77 -0
- package/lib/catalog/seed/courses/topic.entity.js +185 -0
- package/lib/catalog/seed/courses/topic.entity.js.map +1 -0
- package/lib/catalog/seed/expense/category.entity.d.ts +61 -0
- package/lib/catalog/seed/expense/category.entity.js +153 -0
- package/lib/catalog/seed/expense/category.entity.js.map +1 -0
- package/lib/index.d.ts +67 -0
- package/lib/index.js +89 -0
- package/lib/index.js.map +1 -0
- package/lib/profile/agent/agent.entity.d.ts +95 -0
- package/lib/profile/agent/agent.entity.js +223 -0
- package/lib/profile/agent/agent.entity.js.map +1 -0
- package/lib/profile/agent/payout.entity.d.ts +70 -0
- package/lib/profile/agent/payout.entity.js +160 -0
- package/lib/profile/agent/payout.entity.js.map +1 -0
- package/lib/profile/agent/promotion.entity.d.ts +82 -0
- package/lib/profile/agent/promotion.entity.js +174 -0
- package/lib/profile/agent/promotion.entity.js.map +1 -0
- package/lib/profile/company/company.entity.d.ts +234 -0
- package/lib/profile/company/company.entity.js +558 -0
- package/lib/profile/company/company.entity.js.map +1 -0
- package/lib/profile/company/course/appointment.entity.d.ts +111 -0
- package/lib/profile/company/course/appointment.entity.js +240 -0
- package/lib/profile/company/course/appointment.entity.js.map +1 -0
- package/lib/profile/company/course/course.entity.d.ts +156 -0
- package/lib/profile/company/course/course.entity.js +365 -0
- package/lib/profile/company/course/course.entity.js.map +1 -0
- package/lib/profile/company/course/lesson.entity.d.ts +123 -0
- package/lib/profile/company/course/lesson.entity.js +288 -0
- package/lib/profile/company/course/lesson.entity.js.map +1 -0
- package/lib/profile/company/course/topic.entity.d.ts +55 -0
- package/lib/profile/company/course/topic.entity.js +147 -0
- package/lib/profile/company/course/topic.entity.js.map +1 -0
- package/lib/profile/company/finances/billing/bill.entity.d.ts +145 -0
- package/lib/profile/company/finances/billing/bill.entity.js +338 -0
- package/lib/profile/company/finances/billing/bill.entity.js.map +1 -0
- package/lib/profile/company/finances/billing/item.entity.d.ts +75 -0
- package/lib/profile/company/finances/billing/item.entity.js +219 -0
- package/lib/profile/company/finances/billing/item.entity.js.map +1 -0
- package/lib/profile/company/finances/billing/transaction.entity.d.ts +44 -0
- package/lib/profile/company/finances/billing/transaction.entity.js +158 -0
- package/lib/profile/company/finances/billing/transaction.entity.js.map +1 -0
- package/lib/profile/company/finances/expense/category.entity.d.ts +55 -0
- package/lib/profile/company/finances/expense/category.entity.js +117 -0
- package/lib/profile/company/finances/expense/category.entity.js.map +1 -0
- package/lib/profile/company/finances/expense/expense.entity.d.ts +48 -0
- package/lib/profile/company/finances/expense/expense.entity.js +171 -0
- package/lib/profile/company/finances/expense/expense.entity.js.map +1 -0
- package/lib/profile/company/finances/handover/handover.entity.d.ts +44 -0
- package/lib/profile/company/finances/handover/handover.entity.js +202 -0
- package/lib/profile/company/finances/handover/handover.entity.js.map +1 -0
- package/lib/profile/company/finances/invoice/invoice.entity.d.ts +65 -0
- package/lib/profile/company/finances/invoice/invoice.entity.js +296 -0
- package/lib/profile/company/finances/invoice/invoice.entity.js.map +1 -0
- package/lib/profile/company/finances/invoice/item.entity.d.ts +25 -0
- package/lib/profile/company/finances/invoice/item.entity.js +148 -0
- package/lib/profile/company/finances/invoice/item.entity.js.map +1 -0
- package/lib/profile/company/finances/payment/method.entity.d.ts +35 -0
- package/lib/profile/company/finances/payment/method.entity.js +143 -0
- package/lib/profile/company/finances/payment/method.entity.js.map +1 -0
- package/lib/profile/company/finances/peyment/method.entity.d.ts +35 -0
- package/lib/profile/company/finances/peyment/method.entity.js +143 -0
- package/lib/profile/company/finances/peyment/method.entity.js.map +1 -0
- package/lib/profile/company/finances/peyment-method/payment-method.d.ts +34 -0
- package/lib/profile/company/finances/peyment-method/payment-method.js +118 -0
- package/lib/profile/company/finances/peyment-method/payment-method.js.map +1 -0
- package/lib/profile/company/instructor/instructor.entity.d.ts +85 -0
- package/lib/profile/company/instructor/instructor.entity.js +254 -0
- package/lib/profile/company/instructor/instructor.entity.js.map +1 -0
- package/lib/profile/company/instructor/task.entity.d.ts +60 -0
- package/lib/profile/company/instructor/task.entity.js +133 -0
- package/lib/profile/company/instructor/task.entity.js.map +1 -0
- package/lib/profile/company/medical/examination.entity.d.ts +59 -0
- package/lib/profile/company/medical/examination.entity.js +175 -0
- package/lib/profile/company/medical/examination.entity.js.map +1 -0
- package/lib/profile/company/medical/product.entity.d.ts +99 -0
- package/lib/profile/company/medical/product.entity.js +270 -0
- package/lib/profile/company/medical/product.entity.js.map +1 -0
- package/lib/profile/company/metrics/company.metric.d.ts +21 -0
- package/lib/profile/company/metrics/company.metric.js +122 -0
- package/lib/profile/company/metrics/company.metric.js.map +1 -0
- package/lib/profile/company/product/addon.entity.d.ts +93 -0
- package/lib/profile/company/product/addon.entity.js +234 -0
- package/lib/profile/company/product/addon.entity.js.map +1 -0
- package/lib/profile/company/product/priceplan.entity.d.ts +57 -0
- package/lib/profile/company/product/priceplan.entity.js +167 -0
- package/lib/profile/company/product/priceplan.entity.js.map +1 -0
- package/lib/profile/company/product/product.entity.d.ts +171 -0
- package/lib/profile/company/product/product.entity.js +383 -0
- package/lib/profile/company/product/product.entity.js.map +1 -0
- package/lib/profile/company/product/vehicle.entity.d.ts +46 -0
- package/lib/profile/company/product/vehicle.entity.js +144 -0
- package/lib/profile/company/product/vehicle.entity.js.map +1 -0
- package/lib/profile/instructor/instructor.entity.d.ts +80 -0
- package/lib/profile/instructor/instructor.entity.js +186 -0
- package/lib/profile/instructor/instructor.entity.js.map +1 -0
- package/lib/profile/student/program/licence/licence.entity.d.ts +66 -0
- package/lib/profile/student/program/licence/licence.entity.js +187 -0
- package/lib/profile/student/program/licence/licence.entity.js.map +1 -0
- package/lib/profile/student/program/medical/certificate.entity.d.ts +84 -0
- package/lib/profile/student/program/medical/certificate.entity.js +244 -0
- package/lib/profile/student/program/medical/certificate.entity.js.map +1 -0
- package/lib/profile/student/program/medical/examination.model.d.ts +65 -0
- package/lib/profile/student/program/medical/examination.model.js +209 -0
- package/lib/profile/student/program/medical/examination.model.js.map +1 -0
- package/lib/profile/student/program/program.entity.d.ts +78 -0
- package/lib/profile/student/program/program.entity.js +225 -0
- package/lib/profile/student/program/program.entity.js.map +1 -0
- package/lib/profile/student/program/training/appointment.entity.d.ts +151 -0
- package/lib/profile/student/program/training/appointment.entity.js +441 -0
- package/lib/profile/student/program/training/appointment.entity.js.map +1 -0
- package/lib/profile/student/program/training/exam.entity.d.ts +41 -0
- package/lib/profile/student/program/training/exam.entity.js +141 -0
- package/lib/profile/student/program/training/exam.entity.js.map +1 -0
- package/lib/profile/student/program/training/lesson.entity.d.ts +84 -0
- package/lib/profile/student/program/training/lesson.entity.js +221 -0
- package/lib/profile/student/program/training/lesson.entity.js.map +1 -0
- package/lib/profile/student/program/training/request.entity.d.ts +56 -0
- package/lib/profile/student/program/training/request.entity.js +159 -0
- package/lib/profile/student/program/training/request.entity.js.map +1 -0
- package/lib/profile/student/program/training/topic.entity.d.ts +109 -0
- package/lib/profile/student/program/training/topic.entity.js +255 -0
- package/lib/profile/student/program/training/topic.entity.js.map +1 -0
- package/lib/profile/student/program/training/training.entity.d.ts +167 -0
- package/lib/profile/student/program/training/training.entity.js +501 -0
- package/lib/profile/student/program/training/training.entity.js.map +1 -0
- package/lib/profile/student/program/training/transaction.entity.d.ts +111 -0
- package/lib/profile/student/program/training/transaction.entity.js +266 -0
- package/lib/profile/student/program/training/transaction.entity.js.map +1 -0
- package/lib/profile/student/student.entity.d.ts +89 -0
- package/lib/profile/student/student.entity.js +183 -0
- package/lib/profile/student/student.entity.js.map +1 -0
- package/lib/system/campaign/campaign.entity.d.ts +68 -0
- package/lib/system/campaign/campaign.entity.js +150 -0
- package/lib/system/campaign/campaign.entity.js.map +1 -0
- package/lib/system/campaign/gifcode.entity.d.ts +14 -0
- package/lib/system/campaign/gifcode.entity.js +77 -0
- package/lib/system/campaign/gifcode.entity.js.map +1 -0
- package/lib/system/campaigne/campaign.entity.d.ts +69 -0
- package/lib/system/campaigne/campaign.entity.js +179 -0
- package/lib/system/campaigne/campaign.entity.js.map +1 -0
- package/lib/system/campaigne/gifcode.entity.d.ts +54 -0
- package/lib/system/campaigne/gifcode.entity.js +126 -0
- package/lib/system/campaigne/gifcode.entity.js.map +1 -0
- package/lib/system/country/country.entity.d.ts +121 -0
- package/lib/system/country/country.entity.js +284 -0
- package/lib/system/country/country.entity.js.map +1 -0
- package/lib/system/country/country.metric.d.ts +12 -0
- package/lib/system/country/country.metric.js +68 -0
- package/lib/system/country/country.metric.js.map +1 -0
- package/lib/system/currency/currency.entity.d.ts +46 -0
- package/lib/system/currency/currency.entity.js +112 -0
- package/lib/system/currency/currency.entity.js.map +1 -0
- package/lib/system/driving/category.entity.d.ts +146 -0
- package/lib/system/driving/category.entity.js +321 -0
- package/lib/system/driving/category.entity.js.map +1 -0
- package/lib/system/driving/vehicle.entity.d.ts +54 -0
- package/lib/system/driving/vehicle.entity.js +130 -0
- package/lib/system/driving/vehicle.entity.js.map +1 -0
- package/lib/system/event/business.entity.d.ts +75 -0
- package/lib/system/event/business.entity.js +170 -0
- package/lib/system/event/business.entity.js.map +1 -0
- package/lib/system/event/log.entity.d.ts +103 -0
- package/lib/system/event/log.entity.js +202 -0
- package/lib/system/event/log.entity.js.map +1 -0
- package/lib/system/policy/policy.entity.d.ts +90 -0
- package/lib/system/policy/policy.entity.js +226 -0
- package/lib/system/policy/policy.entity.js.map +1 -0
- package/lib/system/staff/staff.entity.d.ts +72 -0
- package/lib/system/staff/staff.entity.js +186 -0
- package/lib/system/staff/staff.entity.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/user/alert.entity.d.ts +95 -0
- package/lib/user/alert.entity.js +223 -0
- package/lib/user/alert.entity.js.map +1 -0
- package/lib/user/blocked.entity.d.ts +42 -0
- package/lib/user/blocked.entity.js +83 -0
- package/lib/user/blocked.entity.js.map +1 -0
- package/lib/user/device.entity.d.ts +72 -0
- package/lib/user/device.entity.js +182 -0
- package/lib/user/device.entity.js.map +1 -0
- package/lib/user/notification.entity.d.ts +87 -0
- package/lib/user/notification.entity.js +219 -0
- package/lib/user/notification.entity.js.map +1 -0
- package/lib/user/ticket.entity.d.ts +85 -0
- package/lib/user/ticket.entity.js +231 -0
- package/lib/user/ticket.entity.js.map +1 -0
- package/lib/user/user.entity.d.ts +235 -0
- package/lib/user/user.entity.js +573 -0
- package/lib/user/user.entity.js.map +1 -0
- package/lib/user/verification.entity.d.ts +75 -0
- package/lib/user/verification.entity.js +142 -0
- package/lib/user/verification.entity.js.map +1 -0
- package/lib/utils/activity.helper.d.ts +26 -0
- package/lib/utils/activity.helper.js +39 -0
- package/lib/utils/activity.helper.js.map +1 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +21 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/json-metrics.transform.d.ts +35 -0
- package/lib/utils/json-metrics.transform.js +83 -0
- package/lib/utils/json-metrics.transform.js.map +1 -0
- package/lib/utils/numeric.transform.d.ts +38 -0
- package/lib/utils/numeric.transform.js +74 -0
- package/lib/utils/numeric.transform.js.map +1 -0
- package/lib/utils/trackable.entity.d.ts +82 -0
- package/lib/utils/trackable.entity.js +100 -0
- package/lib/utils/trackable.entity.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# @driveup/schema
|
|
2
|
+
|
|
3
|
+
TypeORM entity schemas for the Driveup platform ecosystem.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@driveup/schema` provides TypeORM entity definitions and database schemas used across the Driveup platform. This package centralizes all database entity definitions to ensure consistency across microservices and applications.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- 📦 **TypeORM Entities** - Complete database entity definitions with decorators
|
|
12
|
+
- 🔄 **Model Transformations** - Convert between entities and domain models
|
|
13
|
+
- 📊 **Relationship Mappings** - Pre-configured entity relationships
|
|
14
|
+
- 🛡️ **Type Safety** - Full TypeScript support with type definitions
|
|
15
|
+
- 🏗️ **Trackable Entities** - Base entities with audit fields (created/updated by/on)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @driveup/schema
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Peer Dependencies
|
|
24
|
+
|
|
25
|
+
This package requires the following peer dependencies:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install typeorm reflect-metadata @driveup/common nestjs-i18n
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Basic Entity Import
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { CompanyEntity, UserEntity } from '@driveup/schema';
|
|
37
|
+
|
|
38
|
+
// Use in your repository
|
|
39
|
+
const company = await CompanyEntity.findOne({ where: { id: 1 } });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Converting Entities to Models
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { CompanyBillEntity } from '@driveup/schema';
|
|
46
|
+
|
|
47
|
+
const billEntity = await CompanyBillEntity.findOne({
|
|
48
|
+
where: { id: 1 }
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Convert to domain model
|
|
52
|
+
const billModel = billEntity.toModel();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Working with Relationships
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { CompanyBillEntity } from '@driveup/schema';
|
|
59
|
+
|
|
60
|
+
const bill = await CompanyBillEntity.findOne({ where: { id: 1 } });
|
|
61
|
+
|
|
62
|
+
// Access lazy-loaded relationships
|
|
63
|
+
const company = await bill.company;
|
|
64
|
+
const items = await bill.items;
|
|
65
|
+
const transactions = await bill.transactions;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Package Structure
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
src/
|
|
72
|
+
├── catalog/ # Catalog entities (products, programs, addons)
|
|
73
|
+
├── profile/ # Profile entities (agents, companies, students)
|
|
74
|
+
│ ├── agent/
|
|
75
|
+
│ ├── company/
|
|
76
|
+
│ │ └── finances/ # Billing, transactions, credits
|
|
77
|
+
│ └── student/
|
|
78
|
+
├── system/ # System entities (settings, configurations)
|
|
79
|
+
├── user/ # User entities and authentication
|
|
80
|
+
└── utils/ # Utility base classes (TrackableEntity, etc.)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Entity Categories
|
|
84
|
+
|
|
85
|
+
### Catalog
|
|
86
|
+
- **Addon** - Additional services and features
|
|
87
|
+
- **Product** - Core product offerings
|
|
88
|
+
- **Program** - Training programs
|
|
89
|
+
- **PricePlan** - Pricing configurations
|
|
90
|
+
- **Driving/Seed** - Driving-related catalogs
|
|
91
|
+
|
|
92
|
+
### Profile
|
|
93
|
+
- **Agent** - Agent profile and commission data
|
|
94
|
+
- **Company** - Company profiles and settings
|
|
95
|
+
- **Student** - Student profiles and progress
|
|
96
|
+
- **Finances** - Bills, transactions, credits
|
|
97
|
+
|
|
98
|
+
### System
|
|
99
|
+
- System configurations and settings
|
|
100
|
+
|
|
101
|
+
### User
|
|
102
|
+
- User authentication and authorization data
|
|
103
|
+
|
|
104
|
+
## Development
|
|
105
|
+
|
|
106
|
+
### Build
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm run build
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This compiles TypeScript files to the `lib/` directory.
|
|
113
|
+
|
|
114
|
+
### Release
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm run release
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
This builds the package and publishes it to the npm registry.
|
|
121
|
+
|
|
122
|
+
## Environment Requirements
|
|
123
|
+
|
|
124
|
+
- **Node.js**: >= 22
|
|
125
|
+
- **TypeScript**: Configured for ES2022
|
|
126
|
+
- **TypeORM**: ^0.3.21
|
|
127
|
+
|
|
128
|
+
## Integration
|
|
129
|
+
|
|
130
|
+
This package is designed to work with:
|
|
131
|
+
- **NestJS** applications
|
|
132
|
+
- **TypeORM** as the ORM layer
|
|
133
|
+
- **@driveup/common** for shared types and utilities
|
|
134
|
+
|
|
135
|
+
### TypeORM Configuration Example
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { DataSource } from 'typeorm';
|
|
139
|
+
import * as Entities from '@driveup/schema';
|
|
140
|
+
|
|
141
|
+
const dataSource = new DataSource({
|
|
142
|
+
type: 'postgres',
|
|
143
|
+
host: 'localhost',
|
|
144
|
+
port: 5432,
|
|
145
|
+
username: 'user',
|
|
146
|
+
password: 'password',
|
|
147
|
+
database: 'driveup',
|
|
148
|
+
entities: Object.values(Entities),
|
|
149
|
+
synchronize: false,
|
|
150
|
+
migrations: ['./migrations/*.ts']
|
|
151
|
+
});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Versioning
|
|
155
|
+
|
|
156
|
+
This package follows [Semantic Versioning](https://semver.org/). Any changes must be accompanied by an appropriate version bump:
|
|
157
|
+
|
|
158
|
+
- **MAJOR** - Breaking changes to entity structure
|
|
159
|
+
- **MINOR** - New entities or non-breaking additions
|
|
160
|
+
- **PATCH** - Bug fixes and documentation updates
|
|
161
|
+
|
|
162
|
+
Version strategy is defined and managed by the CTO.
|
|
163
|
+
|
|
164
|
+
## Support & Contact
|
|
165
|
+
|
|
166
|
+
- **Author**: [Admir Serifi](https://twitter.com/admirsherifi)
|
|
167
|
+
- **Owner**: [Intelact Solutions Ltd](https://intelact.co)
|
|
168
|
+
- **Repository**: [GitHub](https://github.com/Intelact-Solutions/driveup-schema)
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
**Private & Proprietary**
|
|
173
|
+
|
|
174
|
+
This is private property of Intelact Solutions Ltd and is licensed only for use within Intelact Solutions products. Unauthorized use, distribution, or reproduction is strictly prohibited.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Activity, Addon, AddonType } from '@driveup/common';
|
|
2
|
+
import { ColorContext, Content, Language, ProductType } from '@driveup/common';
|
|
3
|
+
import { ProductEntity } from '../product/product.entity';
|
|
4
|
+
import { AddonCountryEntity } from './country.entity';
|
|
5
|
+
import { TrackableEntity } from '../../utils';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a system-wide addon in the catalog.
|
|
8
|
+
* Addons are optional features or services that can be added to products.
|
|
9
|
+
* Examples include appointment reminders, additional study materials, or premium support.
|
|
10
|
+
*
|
|
11
|
+
* @extends TrackableEntity<Addon>
|
|
12
|
+
*/
|
|
13
|
+
export declare class AddonEntity extends TrackableEntity<Addon> {
|
|
14
|
+
/**
|
|
15
|
+
* The type of addon (e.g., StudentAppointmentReminder, PremiumSupport)
|
|
16
|
+
* @default AddonType.StudentAppointmentReminder
|
|
17
|
+
*/
|
|
18
|
+
type: AddonType;
|
|
19
|
+
/**
|
|
20
|
+
* Offer the addon for these products
|
|
21
|
+
* but the addons should offered separately as well
|
|
22
|
+
*/
|
|
23
|
+
products: ProductType[];
|
|
24
|
+
/**
|
|
25
|
+
* UI color theme context for displaying the addon
|
|
26
|
+
* @default ColorContext.Primary
|
|
27
|
+
*/
|
|
28
|
+
color: ColorContext;
|
|
29
|
+
/**
|
|
30
|
+
* Country localizations
|
|
31
|
+
*/
|
|
32
|
+
translations: Content[];
|
|
33
|
+
/**
|
|
34
|
+
* Addon image
|
|
35
|
+
* Can be rewitten to support multiple images with language codes
|
|
36
|
+
*/
|
|
37
|
+
imageUrl: string;
|
|
38
|
+
/**
|
|
39
|
+
* Addon active status
|
|
40
|
+
* Activating/deactivating an addon will not affect existing customers
|
|
41
|
+
* but will prevent new customers from purchasing the addon.
|
|
42
|
+
* Deactivating must set all country and company addons to enabled=false
|
|
43
|
+
*/
|
|
44
|
+
active: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Sort by relevance
|
|
47
|
+
*/
|
|
48
|
+
sort: number;
|
|
49
|
+
/**
|
|
50
|
+
* ID of the administrator who enabled this addon for the country
|
|
51
|
+
*/
|
|
52
|
+
enabledBy: number;
|
|
53
|
+
/**
|
|
54
|
+
* Timestamp when the addon was enabled for the country
|
|
55
|
+
*/
|
|
56
|
+
enabledOn: Date;
|
|
57
|
+
/**
|
|
58
|
+
* ID of the administrator who disabled this addon for the country
|
|
59
|
+
*/
|
|
60
|
+
disabledBy: number;
|
|
61
|
+
/**
|
|
62
|
+
* Timestamp when the addon was disabled for the country
|
|
63
|
+
*/
|
|
64
|
+
disabledOn: Date;
|
|
65
|
+
/**
|
|
66
|
+
* Country-specific configurations for this addon
|
|
67
|
+
* Each country can have different pricing and settings
|
|
68
|
+
*/
|
|
69
|
+
countries: Promise<AddonCountryEntity[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Creates an instance of AddonEntity
|
|
72
|
+
* @param props - Partial properties to initialize the entity
|
|
73
|
+
*/
|
|
74
|
+
constructor(props?: Partial<AddonEntity>);
|
|
75
|
+
/**
|
|
76
|
+
* Converts the entity to a model object with localized content
|
|
77
|
+
* @param lang - Language code for localization (defaults to current context language)
|
|
78
|
+
* @returns Addon model instance with translated content
|
|
79
|
+
*/
|
|
80
|
+
toModel(lang?: Language): Addon;
|
|
81
|
+
/**
|
|
82
|
+
* Converts the entity to a model object with localized content
|
|
83
|
+
* @param lang - Language code for localization (defaults to current context language)
|
|
84
|
+
* @returns Addon model instance with translated content
|
|
85
|
+
*/
|
|
86
|
+
toSummary(lang?: Language): Addon;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves the translation for a specific language
|
|
89
|
+
* @param lang - Language code (defaults to current context language)
|
|
90
|
+
* @returns Content object with localized strings
|
|
91
|
+
*/
|
|
92
|
+
getTranslation(lang?: Language): Content;
|
|
93
|
+
/**
|
|
94
|
+
* Retrieves all available translations for this addon
|
|
95
|
+
* @returns Array of Content objects for all languages
|
|
96
|
+
*/
|
|
97
|
+
getTranslations(): Content[];
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves all products associated with this addon
|
|
100
|
+
* @returns Array of ProductEntity instances
|
|
101
|
+
*/
|
|
102
|
+
getProducts(): Promise<ProductEntity[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Retrieves all activity records for this addon
|
|
105
|
+
* Includes creation, updates, enable/disable actions
|
|
106
|
+
* @returns Array of Activity objects
|
|
107
|
+
*/
|
|
108
|
+
getActivities(): Promise<Activity[]>;
|
|
109
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AddonEntity = void 0;
|
|
13
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
const common_1 = require("@driveup/common");
|
|
16
|
+
const common_2 = require("@driveup/common");
|
|
17
|
+
const staff_entity_1 = require("../../system/staff/staff.entity");
|
|
18
|
+
const product_entity_1 = require("../product/product.entity");
|
|
19
|
+
const country_entity_1 = require("./country.entity");
|
|
20
|
+
const utils_1 = require("../../utils");
|
|
21
|
+
/**
|
|
22
|
+
* Represents a system-wide addon in the catalog.
|
|
23
|
+
* Addons are optional features or services that can be added to products.
|
|
24
|
+
* Examples include appointment reminders, additional study materials, or premium support.
|
|
25
|
+
*
|
|
26
|
+
* @extends TrackableEntity<Addon>
|
|
27
|
+
*/
|
|
28
|
+
let AddonEntity = class AddonEntity extends utils_1.TrackableEntity {
|
|
29
|
+
/**
|
|
30
|
+
* The type of addon (e.g., StudentAppointmentReminder, PremiumSupport)
|
|
31
|
+
* @default AddonType.StudentAppointmentReminder
|
|
32
|
+
*/
|
|
33
|
+
type;
|
|
34
|
+
/**
|
|
35
|
+
* Offer the addon for these products
|
|
36
|
+
* but the addons should offered separately as well
|
|
37
|
+
*/
|
|
38
|
+
products;
|
|
39
|
+
/**
|
|
40
|
+
* UI color theme context for displaying the addon
|
|
41
|
+
* @default ColorContext.Primary
|
|
42
|
+
*/
|
|
43
|
+
color;
|
|
44
|
+
/**
|
|
45
|
+
* Country localizations
|
|
46
|
+
*/
|
|
47
|
+
translations;
|
|
48
|
+
/**
|
|
49
|
+
* Addon image
|
|
50
|
+
* Can be rewitten to support multiple images with language codes
|
|
51
|
+
*/
|
|
52
|
+
imageUrl;
|
|
53
|
+
/**
|
|
54
|
+
* Addon active status
|
|
55
|
+
* Activating/deactivating an addon will not affect existing customers
|
|
56
|
+
* but will prevent new customers from purchasing the addon.
|
|
57
|
+
* Deactivating must set all country and company addons to enabled=false
|
|
58
|
+
*/
|
|
59
|
+
active;
|
|
60
|
+
/**
|
|
61
|
+
* Sort by relevance
|
|
62
|
+
*/
|
|
63
|
+
sort;
|
|
64
|
+
/**
|
|
65
|
+
* ID of the administrator who enabled this addon for the country
|
|
66
|
+
*/
|
|
67
|
+
enabledBy;
|
|
68
|
+
/**
|
|
69
|
+
* Timestamp when the addon was enabled for the country
|
|
70
|
+
*/
|
|
71
|
+
enabledOn;
|
|
72
|
+
/**
|
|
73
|
+
* ID of the administrator who disabled this addon for the country
|
|
74
|
+
*/
|
|
75
|
+
disabledBy;
|
|
76
|
+
/**
|
|
77
|
+
* Timestamp when the addon was disabled for the country
|
|
78
|
+
*/
|
|
79
|
+
disabledOn;
|
|
80
|
+
/**
|
|
81
|
+
* Country-specific configurations for this addon
|
|
82
|
+
* Each country can have different pricing and settings
|
|
83
|
+
*/
|
|
84
|
+
countries;
|
|
85
|
+
/**
|
|
86
|
+
* Creates an instance of AddonEntity
|
|
87
|
+
* @param props - Partial properties to initialize the entity
|
|
88
|
+
*/
|
|
89
|
+
constructor(props) {
|
|
90
|
+
super();
|
|
91
|
+
Object.assign(this, props);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Converts the entity to a model object with localized content
|
|
95
|
+
* @param lang - Language code for localization (defaults to current context language)
|
|
96
|
+
* @returns Addon model instance with translated content
|
|
97
|
+
*/
|
|
98
|
+
toModel(lang) {
|
|
99
|
+
const translation = this.getTranslation(lang);
|
|
100
|
+
return new common_1.Addon({
|
|
101
|
+
id: this.id,
|
|
102
|
+
type: this.type,
|
|
103
|
+
color: this.color,
|
|
104
|
+
title: translation.title,
|
|
105
|
+
description: translation.description,
|
|
106
|
+
imageUrl: translation?.imageUrl || this.imageUrl,
|
|
107
|
+
active: this.active,
|
|
108
|
+
sort: this.sort,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Converts the entity to a model object with localized content
|
|
113
|
+
* @param lang - Language code for localization (defaults to current context language)
|
|
114
|
+
* @returns Addon model instance with translated content
|
|
115
|
+
*/
|
|
116
|
+
toSummary(lang) {
|
|
117
|
+
return this.toModel(lang);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves the translation for a specific language
|
|
121
|
+
* @param lang - Language code (defaults to current context language)
|
|
122
|
+
* @returns Content object with localized strings
|
|
123
|
+
*/
|
|
124
|
+
getTranslation(lang) {
|
|
125
|
+
const language = lang || nestjs_i18n_1.I18nContext.current()?.lang;
|
|
126
|
+
const translation = this.translations?.find(t => t.language === language);
|
|
127
|
+
return new common_2.Content({
|
|
128
|
+
title: translation?.title,
|
|
129
|
+
description: translation?.description,
|
|
130
|
+
content: translation?.content,
|
|
131
|
+
imageUrl: translation?.imageUrl || this.imageUrl,
|
|
132
|
+
link: translation?.link,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves all available translations for this addon
|
|
137
|
+
* @returns Array of Content objects for all languages
|
|
138
|
+
*/
|
|
139
|
+
getTranslations() {
|
|
140
|
+
return this.translations?.map(t => new common_2.Content({
|
|
141
|
+
title: t.title,
|
|
142
|
+
description: t.description,
|
|
143
|
+
content: t.content,
|
|
144
|
+
imageUrl: t.imageUrl,
|
|
145
|
+
link: t.link,
|
|
146
|
+
language: t.language
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Retrieves all products associated with this addon
|
|
151
|
+
* @returns Array of ProductEntity instances
|
|
152
|
+
*/
|
|
153
|
+
async getProducts() {
|
|
154
|
+
if (!this.products)
|
|
155
|
+
return [];
|
|
156
|
+
return await Promise.all(this.products?.map(async (type) => {
|
|
157
|
+
return await product_entity_1.ProductEntity.findOneBy({ type });
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Retrieves all activity records for this addon
|
|
162
|
+
* Includes creation, updates, enable/disable actions
|
|
163
|
+
* @returns Array of Activity objects
|
|
164
|
+
*/
|
|
165
|
+
async getActivities() {
|
|
166
|
+
const activities = [];
|
|
167
|
+
activities.push(await (0, utils_1.toActivity)(this.createdBy, common_1.ActivityType.createdBy, staff_entity_1.StaffEntity));
|
|
168
|
+
activities.push(await (0, utils_1.toActivity)(this.createdOn, common_1.ActivityType.createdOn));
|
|
169
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedBy, common_1.ActivityType.updatedBy, staff_entity_1.StaffEntity));
|
|
170
|
+
activities.push(await (0, utils_1.toActivity)(this.updatedOn, common_1.ActivityType.updatedOn));
|
|
171
|
+
activities.push(await (0, utils_1.toActivity)(this.enabledBy, common_1.ActivityType.enabledBy, staff_entity_1.StaffEntity));
|
|
172
|
+
activities.push(await (0, utils_1.toActivity)(this.enabledOn, common_1.ActivityType.enabledOn));
|
|
173
|
+
activities.push(await (0, utils_1.toActivity)(this.disabledBy, common_1.ActivityType.disabledBy, staff_entity_1.StaffEntity));
|
|
174
|
+
activities.push(await (0, utils_1.toActivity)(this.disabledOn, common_1.ActivityType.disabledOn));
|
|
175
|
+
return activities.filter(a => a);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
exports.AddonEntity = AddonEntity;
|
|
179
|
+
__decorate([
|
|
180
|
+
(0, typeorm_1.Column)({
|
|
181
|
+
type: 'enum',
|
|
182
|
+
name: 'addonType',
|
|
183
|
+
enum: common_1.AddonType,
|
|
184
|
+
default: common_1.AddonType.StudentAppointmentReminder,
|
|
185
|
+
nullable: false
|
|
186
|
+
}),
|
|
187
|
+
__metadata("design:type", String)
|
|
188
|
+
], AddonEntity.prototype, "type", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
(0, typeorm_1.Column)({
|
|
191
|
+
type: 'set',
|
|
192
|
+
enum: common_2.ProductType,
|
|
193
|
+
default: [common_2.ProductType.DrivingCar],
|
|
194
|
+
nullable: false
|
|
195
|
+
}),
|
|
196
|
+
__metadata("design:type", Array)
|
|
197
|
+
], AddonEntity.prototype, "products", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
(0, typeorm_1.Column)({
|
|
200
|
+
type: 'enum',
|
|
201
|
+
enum: common_2.ColorContext,
|
|
202
|
+
default: common_2.ColorContext.Primary,
|
|
203
|
+
nullable: false
|
|
204
|
+
}),
|
|
205
|
+
__metadata("design:type", String)
|
|
206
|
+
], AddonEntity.prototype, "color", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
(0, typeorm_1.Column)({
|
|
209
|
+
type: 'simple-json',
|
|
210
|
+
nullable: true,
|
|
211
|
+
default: null
|
|
212
|
+
}),
|
|
213
|
+
__metadata("design:type", Array)
|
|
214
|
+
], AddonEntity.prototype, "translations", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
(0, typeorm_1.Column)({
|
|
217
|
+
nullable: true,
|
|
218
|
+
default: null
|
|
219
|
+
}),
|
|
220
|
+
__metadata("design:type", String)
|
|
221
|
+
], AddonEntity.prototype, "imageUrl", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
(0, typeorm_1.Column)({
|
|
224
|
+
nullable: false,
|
|
225
|
+
default: true
|
|
226
|
+
}),
|
|
227
|
+
__metadata("design:type", Boolean)
|
|
228
|
+
], AddonEntity.prototype, "active", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
(0, typeorm_1.Column)({
|
|
231
|
+
nullable: false,
|
|
232
|
+
default: 1
|
|
233
|
+
}),
|
|
234
|
+
__metadata("design:type", Number)
|
|
235
|
+
], AddonEntity.prototype, "sort", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
238
|
+
__metadata("design:type", Number)
|
|
239
|
+
], AddonEntity.prototype, "enabledBy", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
242
|
+
__metadata("design:type", Date)
|
|
243
|
+
], AddonEntity.prototype, "enabledOn", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
246
|
+
__metadata("design:type", Number)
|
|
247
|
+
], AddonEntity.prototype, "disabledBy", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
(0, typeorm_1.Column)({ nullable: true, default: null }),
|
|
250
|
+
__metadata("design:type", Date)
|
|
251
|
+
], AddonEntity.prototype, "disabledOn", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
(0, typeorm_1.OneToMany)(() => country_entity_1.AddonCountryEntity, country => country.addon),
|
|
254
|
+
__metadata("design:type", Promise)
|
|
255
|
+
], AddonEntity.prototype, "countries", void 0);
|
|
256
|
+
exports.AddonEntity = AddonEntity = __decorate([
|
|
257
|
+
(0, typeorm_1.Entity)('systemAddons'),
|
|
258
|
+
__metadata("design:paramtypes", [Object])
|
|
259
|
+
], AddonEntity);
|
|
260
|
+
//# sourceMappingURL=addon.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addon.entity.js","sourceRoot":"","sources":["../../../src/catalog/addon/addon.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0C;AAC1C,qCAAoD;AACpD,4CAA2E;AAC3E,4CAA+E;AAC/E,kEAA8D;AAC9D,8DAA0D;AAC1D,qDAAsD;AACtD,uCAA0D;AAE1D;;;;;;GAMG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,uBAAsB;IAEtD;;;OAGG;IAQH,IAAI,CAAY;IAEhB;;;OAGG;IAOH,QAAQ,CAAgB;IAExB;;;OAGG;IAOH,KAAK,CAAe;IAEpB;;OAEG;IAMH,YAAY,CAAY;IAExB;;;OAGG;IAKH,QAAQ,CAAS;IAEjB;;;;;OAKG;IAKH,MAAM,CAAU;IAEhB;;OAEG;IAKH,IAAI,CAAS;IAEb;;OAEG;IAEH,SAAS,CAAS;IAElB;;OAEG;IAEH,SAAS,CAAO;IAEhB;;OAEG;IAEH,UAAU,CAAS;IAEnB;;OAEG;IAEH,UAAU,CAAO;IAEjB;;;OAGG;IAEH,SAAS,CAAgC;IAEzC;;;OAGG;IACH,YAAY,KAA4B;QACvC,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,IAAe;QACtB,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;QAC7C,OAAO,IAAI,cAAK,CAAC;YAChB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,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AAE,CAAC;KACV,CAAC;;yCACW;AAMb;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;8CACxB;AAMlB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC/B,IAAI;8CAAC;AAMhB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;+CACvB;AAMnB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8BAC9B,IAAI;+CAAC;AAOjB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,mCAAkB,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;;8CACrB;sBA7G7B,WAAW;IADvB,IAAA,gBAAM,EAAC,cAAc,CAAC;;GACV,WAAW,CAgNvB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Activity, Addon, Language, Metadata } from '@driveup/common';
|
|
2
|
+
import { CountryEntity } from '../../system/country/country.entity';
|
|
3
|
+
import { CompanyProductAddonEntity } from '../../profile/company/product/addon.entity';
|
|
4
|
+
import { AddonEntity } from './addon.entity';
|
|
5
|
+
import { TrackableEntity } from '../../utils';
|
|
6
|
+
/**
|
|
7
|
+
* Represents an addon configuration for a specific country.
|
|
8
|
+
* This entity manages the country-specific pricing, availability, and localization
|
|
9
|
+
* of addons within the system. Each addon can have different settings per country.
|
|
10
|
+
*
|
|
11
|
+
* @template T - Type parameter for custom metadata structure
|
|
12
|
+
*/
|
|
13
|
+
export declare class AddonCountryEntity extends TrackableEntity<Addon> {
|
|
14
|
+
/**
|
|
15
|
+
* Unique identifier for the addon-country relationship
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Reference to the addon this configuration belongs to
|
|
19
|
+
*/
|
|
20
|
+
addonId: number;
|
|
21
|
+
/**
|
|
22
|
+
* Reference to the country this configuration applies to
|
|
23
|
+
*/
|
|
24
|
+
countryId: number;
|
|
25
|
+
/**
|
|
26
|
+
* Base price for the addon in the country's currency
|
|
27
|
+
* Precision: 8 digits, Scale: 2 decimal places
|
|
28
|
+
*/
|
|
29
|
+
price: number;
|
|
30
|
+
/**
|
|
31
|
+
* Value Added Tax (VAT) rate applicable to this addon in the specific country
|
|
32
|
+
* Precision: 8 digits, Scale: 2 decimal places
|
|
33
|
+
*/
|
|
34
|
+
vat: number;
|
|
35
|
+
/**
|
|
36
|
+
* Number of free benefits included with the addon
|
|
37
|
+
* Used for promotional purposes or trial periods
|
|
38
|
+
*/
|
|
39
|
+
freeBenefits: number;
|
|
40
|
+
/**
|
|
41
|
+
* Addon active status
|
|
42
|
+
* Activating/deactivating an addon will not affect existing customers
|
|
43
|
+
* but will prevent new customers from purchasing the addon.
|
|
44
|
+
* Deactivating must set all country and company addons to enabled=false
|
|
45
|
+
*/
|
|
46
|
+
active: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Sort by country relevance
|
|
49
|
+
*/
|
|
50
|
+
sort: number;
|
|
51
|
+
/**
|
|
52
|
+
* Additional metadata
|
|
53
|
+
*/
|
|
54
|
+
metadata: Metadata[];
|
|
55
|
+
/**
|
|
56
|
+
* ID of the administrator who enabled this addon for the country
|
|
57
|
+
*/
|
|
58
|
+
enabledBy: number;
|
|
59
|
+
/**
|
|
60
|
+
* Timestamp when the addon was enabled for the country
|
|
61
|
+
*/
|
|
62
|
+
enabledOn: Date;
|
|
63
|
+
/**
|
|
64
|
+
* ID of the administrator who disabled this addon for the country
|
|
65
|
+
*/
|
|
66
|
+
disabledBy: number;
|
|
67
|
+
/**
|
|
68
|
+
* Timestamp when the addon was disabled for the country
|
|
69
|
+
*/
|
|
70
|
+
disabledOn: Date;
|
|
71
|
+
/**
|
|
72
|
+
* Addon relation
|
|
73
|
+
*/
|
|
74
|
+
addon: Promise<AddonEntity>;
|
|
75
|
+
/**
|
|
76
|
+
* Country relation
|
|
77
|
+
*/
|
|
78
|
+
country: Promise<CountryEntity>;
|
|
79
|
+
/**
|
|
80
|
+
* Company addon relation
|
|
81
|
+
* Companies that have this addon assigned
|
|
82
|
+
*/
|
|
83
|
+
companyProducts: Promise<CompanyProductAddonEntity[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Creates an instance of AddonCountryEntity
|
|
86
|
+
* @param props - Partial properties to initialize the entity
|
|
87
|
+
*/
|
|
88
|
+
constructor(props?: Partial<AddonCountryEntity>);
|
|
89
|
+
/**
|
|
90
|
+
* Converts the entity to an Addon model with country-specific pricing and settings
|
|
91
|
+
* @param lang - Language code for localization (defaults to current context language)
|
|
92
|
+
* @returns Addon model instance with country-specific data
|
|
93
|
+
*/
|
|
94
|
+
toModel(lang?: Language): Promise<Addon>;
|
|
95
|
+
/**
|
|
96
|
+
* Converts the entity to an Addon model with country-specific pricing and settings
|
|
97
|
+
* @param lang - Language code for localization (defaults to current context language)
|
|
98
|
+
* @returns Addon model instance with country-specific data
|
|
99
|
+
*/
|
|
100
|
+
toSummary(lang?: Language): Promise<Addon>;
|
|
101
|
+
/**
|
|
102
|
+
* Retrieves metadata as typed Metadata instances
|
|
103
|
+
* @returns Array of Metadata objects
|
|
104
|
+
*/
|
|
105
|
+
getMetadata(): Metadata<any>[];
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves all activity records for this addon-country configuration
|
|
108
|
+
* Includes creation, updates, enable/disable actions
|
|
109
|
+
* @returns Array of Activity objects
|
|
110
|
+
*/
|
|
111
|
+
getActivities(): Promise<Activity[]>;
|
|
112
|
+
}
|