av6-core 1.7.10 → 1.7.12
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/.prettierignore +4 -4
- package/.prettierrc +6 -6
- package/README.md +234 -234
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +27 -9
- package/dist/index.mjs +27 -9
- package/package.json +38 -38
package/.prettierignore
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
build
|
|
3
|
-
dist
|
|
4
|
-
.vscode
|
|
1
|
+
node_modules
|
|
2
|
+
build
|
|
3
|
+
dist
|
|
4
|
+
.vscode
|
package/.prettierrc
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"semi": true,
|
|
3
|
-
"singleQuote": false,
|
|
4
|
-
"trailingComma": "es5",
|
|
5
|
-
"printWidth": 120
|
|
6
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"semi": true,
|
|
3
|
+
"singleQuote": false,
|
|
4
|
+
"trailingComma": "es5",
|
|
5
|
+
"printWidth": 120
|
|
6
|
+
}
|
package/README.md
CHANGED
|
@@ -1,234 +1,234 @@
|
|
|
1
|
-
# AV6 Core
|
|
2
|
-
|
|
3
|
-
A comprehensive utility library for AV6 Node.js projects, providing common functionality for data operations, caching, and Excel handling.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Dynamic Data Operations**: Flexible search, fetch, and CRUD operations with support for dynamic models
|
|
8
|
-
- **Caching Support**: Built-in Redis caching for improved performance
|
|
9
|
-
- **Excel Import/Export**: Seamless Excel file handling for data import and export
|
|
10
|
-
- **Pagination**: Built-in pagination for search results
|
|
11
|
-
- **DTO Mapping**: Support for Data Transfer Object mapping
|
|
12
|
-
- **Type Safety**: Written in TypeScript with comprehensive type definitions
|
|
13
|
-
- **UIN Config Management**: Unique Identification Number generation with configurable segments and automatic reset policies
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install av6-core
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
### Basic Setup
|
|
24
|
-
|
|
25
|
-
To use the library, you need to provide the necessary dependencies:
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
import { commonService, Deps } from 'av6-core';
|
|
29
|
-
import { PrismaClient } from '@prisma/client';
|
|
30
|
-
import winston from 'winston';
|
|
31
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
32
|
-
|
|
33
|
-
// Initialize dependencies
|
|
34
|
-
const deps: Deps = {
|
|
35
|
-
config: {
|
|
36
|
-
REDIS_PREFIX: 'your-prefix:',
|
|
37
|
-
CACHE_KEY_NAME: 'your-cache-key'
|
|
38
|
-
},
|
|
39
|
-
mapper: {
|
|
40
|
-
dtoMapping: {}, // Your DTO mapping functions
|
|
41
|
-
mappingExport: {}, // Your export mapping functions
|
|
42
|
-
mappingImport: {}, // Your import mapping functions
|
|
43
|
-
},
|
|
44
|
-
helpers: {
|
|
45
|
-
generateErrorMessage: (type, ...variables) => {
|
|
46
|
-
// Your error message generation logic
|
|
47
|
-
},
|
|
48
|
-
ErrorHandler: class ErrorHandler extends Error {
|
|
49
|
-
// Your error handler implementation
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
logger: winston.createLogger({
|
|
53
|
-
// Your logger configuration
|
|
54
|
-
}),
|
|
55
|
-
cacheAdapter: {
|
|
56
|
-
// Your cache adapter implementation
|
|
57
|
-
},
|
|
58
|
-
requestStorage: new AsyncLocalStorage(),
|
|
59
|
-
db: new PrismaClient()
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// Initialize the service
|
|
63
|
-
const service = commonService(deps);
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Search Operations
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
// Perform a search operation
|
|
70
|
-
const searchResult = await service.search({
|
|
71
|
-
pageNo: 1,
|
|
72
|
-
pageSize: 10,
|
|
73
|
-
shortCode: 'USER',
|
|
74
|
-
searchColumns: ['name', 'email'],
|
|
75
|
-
searchText: 'john',
|
|
76
|
-
sortBy: 'createdAt',
|
|
77
|
-
sortDir: 'DESC',
|
|
78
|
-
shortCodeData: {
|
|
79
|
-
shortCode: 'USER',
|
|
80
|
-
tableName: 'user',
|
|
81
|
-
isDTO: true,
|
|
82
|
-
isCacheable: true
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Fetch Record
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
// Fetch a specific record
|
|
91
|
-
const record = await service.fetch({
|
|
92
|
-
shortCode: 'USER',
|
|
93
|
-
id: 123,
|
|
94
|
-
shortCodeData: {
|
|
95
|
-
shortCode: 'USER',
|
|
96
|
-
tableName: 'user',
|
|
97
|
-
isDTO: true,
|
|
98
|
-
isCacheable: true
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Excel Operations
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
// Import data from Excel
|
|
107
|
-
const importResult = await service.commonExcelImport({
|
|
108
|
-
shortCode: 'USER',
|
|
109
|
-
file: excelFile, // File object from upload
|
|
110
|
-
shortCodeData: {
|
|
111
|
-
shortCode: 'USER',
|
|
112
|
-
tableName: 'user'
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
// Export data to Excel
|
|
117
|
-
const workbook = await service.commonExcelExport({
|
|
118
|
-
shortCode: 'USER',
|
|
119
|
-
isSample: false,
|
|
120
|
-
shortCodeData: {
|
|
121
|
-
shortCode: 'USER',
|
|
122
|
-
tableName: 'user'
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### UIN Config Operations
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
import { uinConfigService, UinDeps, UIN_RESET_POLICY, UinShortCode } from 'av6-core';
|
|
131
|
-
|
|
132
|
-
// Initialize UIN Config dependencies
|
|
133
|
-
const uinDeps: UinDeps = {
|
|
134
|
-
config: {
|
|
135
|
-
REDIS_PREFIX: 'your-prefix:',
|
|
136
|
-
CACHE_KEY_NAME: 'your-cache-key'
|
|
137
|
-
},
|
|
138
|
-
helpers: {
|
|
139
|
-
generateErrorMessage: (type, ...variables) => {
|
|
140
|
-
// Your error message generation logic
|
|
141
|
-
},
|
|
142
|
-
ErrorHandler: class ErrorHandler extends Error {
|
|
143
|
-
// Your error handler implementation
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
logger: winston.createLogger({
|
|
147
|
-
// Your logger configuration
|
|
148
|
-
}),
|
|
149
|
-
cacheAdapter: {
|
|
150
|
-
// Your cache adapter implementation
|
|
151
|
-
},
|
|
152
|
-
requestStorage: new AsyncLocalStorage(),
|
|
153
|
-
db: new PrismaClient(),
|
|
154
|
-
prisma: PrismaNamespace,
|
|
155
|
-
shortCode: 'UIN_CONFIG',
|
|
156
|
-
cacheKey: 'uin-config'
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// Initialize the UIN Config service
|
|
160
|
-
const uinService = uinConfigService(uinDeps);
|
|
161
|
-
|
|
162
|
-
// Create a new UIN Config
|
|
163
|
-
const newUinConfig = await uinService.createUINConfig({
|
|
164
|
-
shortCode: UinShortCode.INVOICE,
|
|
165
|
-
seqResetPolicy: UIN_RESET_POLICY.monthly,
|
|
166
|
-
description: 'Invoice number generator',
|
|
167
|
-
uinSegments: [
|
|
168
|
-
{ order: 1, type: 'text', value: 'INV-' },
|
|
169
|
-
{ order: 2, type: 'dateFormat', value: 'YYYYMM' },
|
|
170
|
-
{ order: 3, type: 'separator', value: '-' },
|
|
171
|
-
{ order: 4, type: 'sequenceNo', minSeqLength: 5 }
|
|
172
|
-
]
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
// Generate a UIN preview
|
|
176
|
-
const uinPreview = await uinService.previewUIN({
|
|
177
|
-
uinSegments: [
|
|
178
|
-
{ order: 1, type: 'text', value: 'INV-' },
|
|
179
|
-
{ order: 2, type: 'dateFormat', value: 'YYYYMM' },
|
|
180
|
-
{ order: 3, type: 'separator', value: '-' },
|
|
181
|
-
{ order: 4, type: 'sequenceNo', minSeqLength: 5 }
|
|
182
|
-
]
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
// Get a UIN Config by ID
|
|
186
|
-
const uinConfig = await uinService.getUINConfigById(1);
|
|
187
|
-
|
|
188
|
-
// Generate a new UIN
|
|
189
|
-
const generatedUin = await uinService.generateUIN(UinShortCode.INVOICE);
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## API Reference
|
|
193
|
-
|
|
194
|
-
### Common Service
|
|
195
|
-
|
|
196
|
-
The library provides a comprehensive service for common operations:
|
|
197
|
-
|
|
198
|
-
- `search`: Search records with pagination and filtering
|
|
199
|
-
- `dropdownSearch`: Search records for dropdown components
|
|
200
|
-
- `fixedSearch`: Search with fixed criteria
|
|
201
|
-
- `fixedSearchWoPaginationService`: Search with fixed criteria without pagination
|
|
202
|
-
- `commonExcelService`: Generate Excel workbooks
|
|
203
|
-
- `fetch`: Fetch a specific record by ID
|
|
204
|
-
- `commonExcelImport`: Import data from Excel files
|
|
205
|
-
- `commonExcelExport`: Export data to Excel files
|
|
206
|
-
- `delete`: Delete a record
|
|
207
|
-
- `updateStatus`: Update the status of a record
|
|
208
|
-
- `fetchImageStream`: Fetch an image as a stream
|
|
209
|
-
|
|
210
|
-
### UIN Config Service
|
|
211
|
-
|
|
212
|
-
The library provides a service for managing Unique Identification Numbers:
|
|
213
|
-
|
|
214
|
-
- `createUINConfig`: Create a new UIN configuration
|
|
215
|
-
- `updateUINConfig`: Update an existing UIN configuration
|
|
216
|
-
- `getUINConfigById`: Retrieve a UIN configuration by ID
|
|
217
|
-
- `getAllUINConfig`: Retrieve all UIN configurations
|
|
218
|
-
- `deleteUINConfig`: Delete a UIN configuration
|
|
219
|
-
- `generateUIN`: Generate a new UIN based on a shortcode
|
|
220
|
-
- `previewUIN`: Preview a UIN based on segment configuration
|
|
221
|
-
|
|
222
|
-
### Utility Functions
|
|
223
|
-
|
|
224
|
-
The library also provides utility functions:
|
|
225
|
-
|
|
226
|
-
- `customOmit`: Omit specific keys from an object
|
|
227
|
-
- `objectTo2DArray`: Convert an object to a 2D array
|
|
228
|
-
- `toRelativeImageUrl`: Convert an absolute path to a relative image URL
|
|
229
|
-
|
|
230
|
-
## License
|
|
231
|
-
|
|
232
|
-
ISC
|
|
233
|
-
|
|
234
|
-
|
|
1
|
+
# AV6 Core
|
|
2
|
+
|
|
3
|
+
A comprehensive utility library for AV6 Node.js projects, providing common functionality for data operations, caching, and Excel handling.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Dynamic Data Operations**: Flexible search, fetch, and CRUD operations with support for dynamic models
|
|
8
|
+
- **Caching Support**: Built-in Redis caching for improved performance
|
|
9
|
+
- **Excel Import/Export**: Seamless Excel file handling for data import and export
|
|
10
|
+
- **Pagination**: Built-in pagination for search results
|
|
11
|
+
- **DTO Mapping**: Support for Data Transfer Object mapping
|
|
12
|
+
- **Type Safety**: Written in TypeScript with comprehensive type definitions
|
|
13
|
+
- **UIN Config Management**: Unique Identification Number generation with configurable segments and automatic reset policies
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install av6-core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Basic Setup
|
|
24
|
+
|
|
25
|
+
To use the library, you need to provide the necessary dependencies:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { commonService, Deps } from 'av6-core';
|
|
29
|
+
import { PrismaClient } from '@prisma/client';
|
|
30
|
+
import winston from 'winston';
|
|
31
|
+
import { AsyncLocalStorage } from 'async_hooks';
|
|
32
|
+
|
|
33
|
+
// Initialize dependencies
|
|
34
|
+
const deps: Deps = {
|
|
35
|
+
config: {
|
|
36
|
+
REDIS_PREFIX: 'your-prefix:',
|
|
37
|
+
CACHE_KEY_NAME: 'your-cache-key'
|
|
38
|
+
},
|
|
39
|
+
mapper: {
|
|
40
|
+
dtoMapping: {}, // Your DTO mapping functions
|
|
41
|
+
mappingExport: {}, // Your export mapping functions
|
|
42
|
+
mappingImport: {}, // Your import mapping functions
|
|
43
|
+
},
|
|
44
|
+
helpers: {
|
|
45
|
+
generateErrorMessage: (type, ...variables) => {
|
|
46
|
+
// Your error message generation logic
|
|
47
|
+
},
|
|
48
|
+
ErrorHandler: class ErrorHandler extends Error {
|
|
49
|
+
// Your error handler implementation
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
logger: winston.createLogger({
|
|
53
|
+
// Your logger configuration
|
|
54
|
+
}),
|
|
55
|
+
cacheAdapter: {
|
|
56
|
+
// Your cache adapter implementation
|
|
57
|
+
},
|
|
58
|
+
requestStorage: new AsyncLocalStorage(),
|
|
59
|
+
db: new PrismaClient()
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// Initialize the service
|
|
63
|
+
const service = commonService(deps);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Search Operations
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// Perform a search operation
|
|
70
|
+
const searchResult = await service.search({
|
|
71
|
+
pageNo: 1,
|
|
72
|
+
pageSize: 10,
|
|
73
|
+
shortCode: 'USER',
|
|
74
|
+
searchColumns: ['name', 'email'],
|
|
75
|
+
searchText: 'john',
|
|
76
|
+
sortBy: 'createdAt',
|
|
77
|
+
sortDir: 'DESC',
|
|
78
|
+
shortCodeData: {
|
|
79
|
+
shortCode: 'USER',
|
|
80
|
+
tableName: 'user',
|
|
81
|
+
isDTO: true,
|
|
82
|
+
isCacheable: true
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Fetch Record
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Fetch a specific record
|
|
91
|
+
const record = await service.fetch({
|
|
92
|
+
shortCode: 'USER',
|
|
93
|
+
id: 123,
|
|
94
|
+
shortCodeData: {
|
|
95
|
+
shortCode: 'USER',
|
|
96
|
+
tableName: 'user',
|
|
97
|
+
isDTO: true,
|
|
98
|
+
isCacheable: true
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Excel Operations
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// Import data from Excel
|
|
107
|
+
const importResult = await service.commonExcelImport({
|
|
108
|
+
shortCode: 'USER',
|
|
109
|
+
file: excelFile, // File object from upload
|
|
110
|
+
shortCodeData: {
|
|
111
|
+
shortCode: 'USER',
|
|
112
|
+
tableName: 'user'
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Export data to Excel
|
|
117
|
+
const workbook = await service.commonExcelExport({
|
|
118
|
+
shortCode: 'USER',
|
|
119
|
+
isSample: false,
|
|
120
|
+
shortCodeData: {
|
|
121
|
+
shortCode: 'USER',
|
|
122
|
+
tableName: 'user'
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### UIN Config Operations
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { uinConfigService, UinDeps, UIN_RESET_POLICY, UinShortCode } from 'av6-core';
|
|
131
|
+
|
|
132
|
+
// Initialize UIN Config dependencies
|
|
133
|
+
const uinDeps: UinDeps = {
|
|
134
|
+
config: {
|
|
135
|
+
REDIS_PREFIX: 'your-prefix:',
|
|
136
|
+
CACHE_KEY_NAME: 'your-cache-key'
|
|
137
|
+
},
|
|
138
|
+
helpers: {
|
|
139
|
+
generateErrorMessage: (type, ...variables) => {
|
|
140
|
+
// Your error message generation logic
|
|
141
|
+
},
|
|
142
|
+
ErrorHandler: class ErrorHandler extends Error {
|
|
143
|
+
// Your error handler implementation
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
logger: winston.createLogger({
|
|
147
|
+
// Your logger configuration
|
|
148
|
+
}),
|
|
149
|
+
cacheAdapter: {
|
|
150
|
+
// Your cache adapter implementation
|
|
151
|
+
},
|
|
152
|
+
requestStorage: new AsyncLocalStorage(),
|
|
153
|
+
db: new PrismaClient(),
|
|
154
|
+
prisma: PrismaNamespace,
|
|
155
|
+
shortCode: 'UIN_CONFIG',
|
|
156
|
+
cacheKey: 'uin-config'
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// Initialize the UIN Config service
|
|
160
|
+
const uinService = uinConfigService(uinDeps);
|
|
161
|
+
|
|
162
|
+
// Create a new UIN Config
|
|
163
|
+
const newUinConfig = await uinService.createUINConfig({
|
|
164
|
+
shortCode: UinShortCode.INVOICE,
|
|
165
|
+
seqResetPolicy: UIN_RESET_POLICY.monthly,
|
|
166
|
+
description: 'Invoice number generator',
|
|
167
|
+
uinSegments: [
|
|
168
|
+
{ order: 1, type: 'text', value: 'INV-' },
|
|
169
|
+
{ order: 2, type: 'dateFormat', value: 'YYYYMM' },
|
|
170
|
+
{ order: 3, type: 'separator', value: '-' },
|
|
171
|
+
{ order: 4, type: 'sequenceNo', minSeqLength: 5 }
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Generate a UIN preview
|
|
176
|
+
const uinPreview = await uinService.previewUIN({
|
|
177
|
+
uinSegments: [
|
|
178
|
+
{ order: 1, type: 'text', value: 'INV-' },
|
|
179
|
+
{ order: 2, type: 'dateFormat', value: 'YYYYMM' },
|
|
180
|
+
{ order: 3, type: 'separator', value: '-' },
|
|
181
|
+
{ order: 4, type: 'sequenceNo', minSeqLength: 5 }
|
|
182
|
+
]
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Get a UIN Config by ID
|
|
186
|
+
const uinConfig = await uinService.getUINConfigById(1);
|
|
187
|
+
|
|
188
|
+
// Generate a new UIN
|
|
189
|
+
const generatedUin = await uinService.generateUIN(UinShortCode.INVOICE);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## API Reference
|
|
193
|
+
|
|
194
|
+
### Common Service
|
|
195
|
+
|
|
196
|
+
The library provides a comprehensive service for common operations:
|
|
197
|
+
|
|
198
|
+
- `search`: Search records with pagination and filtering
|
|
199
|
+
- `dropdownSearch`: Search records for dropdown components
|
|
200
|
+
- `fixedSearch`: Search with fixed criteria
|
|
201
|
+
- `fixedSearchWoPaginationService`: Search with fixed criteria without pagination
|
|
202
|
+
- `commonExcelService`: Generate Excel workbooks
|
|
203
|
+
- `fetch`: Fetch a specific record by ID
|
|
204
|
+
- `commonExcelImport`: Import data from Excel files
|
|
205
|
+
- `commonExcelExport`: Export data to Excel files
|
|
206
|
+
- `delete`: Delete a record
|
|
207
|
+
- `updateStatus`: Update the status of a record
|
|
208
|
+
- `fetchImageStream`: Fetch an image as a stream
|
|
209
|
+
|
|
210
|
+
### UIN Config Service
|
|
211
|
+
|
|
212
|
+
The library provides a service for managing Unique Identification Numbers:
|
|
213
|
+
|
|
214
|
+
- `createUINConfig`: Create a new UIN configuration
|
|
215
|
+
- `updateUINConfig`: Update an existing UIN configuration
|
|
216
|
+
- `getUINConfigById`: Retrieve a UIN configuration by ID
|
|
217
|
+
- `getAllUINConfig`: Retrieve all UIN configurations
|
|
218
|
+
- `deleteUINConfig`: Delete a UIN configuration
|
|
219
|
+
- `generateUIN`: Generate a new UIN based on a shortcode
|
|
220
|
+
- `previewUIN`: Preview a UIN based on segment configuration
|
|
221
|
+
|
|
222
|
+
### Utility Functions
|
|
223
|
+
|
|
224
|
+
The library also provides utility functions:
|
|
225
|
+
|
|
226
|
+
- `customOmit`: Omit specific keys from an object
|
|
227
|
+
- `objectTo2DArray`: Convert an object to a 2D array
|
|
228
|
+
- `toRelativeImageUrl`: Convert an absolute path to a relative image URL
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
ISC
|
|
233
|
+
|
|
234
|
+
|
package/dist/index.d.mts
CHANGED
|
@@ -577,6 +577,7 @@ interface UinDeps {
|
|
|
577
577
|
requestStorage: AsyncLocalStorage<Store>;
|
|
578
578
|
db: PrismaClient;
|
|
579
579
|
prisma: typeof PrismaNamespace;
|
|
580
|
+
modelName?: string;
|
|
580
581
|
}
|
|
581
582
|
type UINSegmentType = "text" | "separator" | "dateFormat" | "sequenceNo";
|
|
582
583
|
type UIN_RESET_POLICY = "daily" | "weekly" | "monthly" | "yearly" | "no";
|
package/dist/index.d.ts
CHANGED
|
@@ -577,6 +577,7 @@ interface UinDeps {
|
|
|
577
577
|
requestStorage: AsyncLocalStorage<Store>;
|
|
578
578
|
db: PrismaClient;
|
|
579
579
|
prisma: typeof PrismaNamespace;
|
|
580
|
+
modelName?: string;
|
|
580
581
|
}
|
|
581
582
|
type UINSegmentType = "text" | "separator" | "dateFormat" | "sequenceNo";
|
|
582
583
|
type UIN_RESET_POLICY = "daily" | "weekly" | "monthly" | "yearly" | "no";
|
package/dist/index.js
CHANGED
|
@@ -2403,12 +2403,13 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2403
2403
|
const db = uinDeps.db;
|
|
2404
2404
|
const logger = uinDeps.logger;
|
|
2405
2405
|
const requestStorage = uinDeps.requestStorage;
|
|
2406
|
+
const modelName = uinDeps.modelName || "uINConfig";
|
|
2406
2407
|
return {
|
|
2407
2408
|
async createUINConfigInDb(uinReq) {
|
|
2408
2409
|
logger.info("entering::createUINConfigInDb::repository");
|
|
2409
2410
|
const storage = requestStorage.getStore();
|
|
2410
2411
|
const { uinSegments, ...uinData } = uinReq;
|
|
2411
|
-
return db.
|
|
2412
|
+
return db[modelName].create({
|
|
2412
2413
|
data: {
|
|
2413
2414
|
...uinData,
|
|
2414
2415
|
uinSegments: JSON.stringify(uinSegments),
|
|
@@ -2420,7 +2421,7 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2420
2421
|
async updateUINConfigInDb(updatedConfig, prevConfig) {
|
|
2421
2422
|
logger.info("entering::updateUINConfig::repository");
|
|
2422
2423
|
const storage = requestStorage.getStore();
|
|
2423
|
-
const updated = await db.
|
|
2424
|
+
const updated = await db[modelName].update({
|
|
2424
2425
|
where: { id: updatedConfig.id },
|
|
2425
2426
|
data: {
|
|
2426
2427
|
shortCode: updatedConfig.shortCode,
|
|
@@ -2436,32 +2437,32 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2436
2437
|
},
|
|
2437
2438
|
async getUINConfigByIdFromDb(id) {
|
|
2438
2439
|
logger.info("entering::getUINConfigByIdFromDb::repository");
|
|
2439
|
-
return db.
|
|
2440
|
+
return db[modelName].findUnique({
|
|
2440
2441
|
where: { id, isActive: true }
|
|
2441
2442
|
});
|
|
2442
2443
|
},
|
|
2443
2444
|
async getUINConfigByShortCodeFromDb(shortCode) {
|
|
2444
2445
|
logger.info("entering::getUINConfigByShortCodeFromDb::repository");
|
|
2445
|
-
return db.
|
|
2446
|
+
return db[modelName].findFirst({
|
|
2446
2447
|
where: { shortCode, isActive: true }
|
|
2447
2448
|
});
|
|
2448
2449
|
},
|
|
2449
2450
|
async getAllUINConfigFromDb() {
|
|
2450
2451
|
logger.info("entering::getAllUINConfigFromDb::repository");
|
|
2451
|
-
return db.
|
|
2452
|
+
return db[modelName].findMany({
|
|
2452
2453
|
where: { isActive: true }
|
|
2453
2454
|
});
|
|
2454
2455
|
},
|
|
2455
2456
|
async updateSequenceNo(shortCode, next) {
|
|
2456
2457
|
logger.info("entering::updateSequenceNo::repository");
|
|
2457
|
-
await db.
|
|
2458
|
+
await db[modelName].updateMany({
|
|
2458
2459
|
where: { shortCode, isActive: true },
|
|
2459
2460
|
data: { sequenceNo: next }
|
|
2460
2461
|
});
|
|
2461
2462
|
},
|
|
2462
2463
|
async updateSequenceNoAndResetDate(shortCode, next, resetDate) {
|
|
2463
2464
|
logger.info("entering::updateSequenceNoAndResetDate::repository");
|
|
2464
|
-
await db.
|
|
2465
|
+
await db[modelName].updateMany({
|
|
2465
2466
|
where: { shortCode, isActive: true },
|
|
2466
2467
|
data: { sequenceNo: next, seqResetDate: resetDate }
|
|
2467
2468
|
});
|
|
@@ -2469,7 +2470,7 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2469
2470
|
async deleteUINConfigById(id) {
|
|
2470
2471
|
logger.info("entering::deleteUINConfigById::repository");
|
|
2471
2472
|
const storage = requestStorage.getStore();
|
|
2472
|
-
await db.
|
|
2473
|
+
await db[modelName].update({
|
|
2473
2474
|
where: { id },
|
|
2474
2475
|
data: {
|
|
2475
2476
|
isActive: false,
|
|
@@ -2690,6 +2691,8 @@ var ExpoAppNotificationProvider = class {
|
|
|
2690
2691
|
this.logger = logger;
|
|
2691
2692
|
this.url = url;
|
|
2692
2693
|
}
|
|
2694
|
+
logger;
|
|
2695
|
+
url;
|
|
2693
2696
|
/**
|
|
2694
2697
|
* Bulk send: one HTTP request with many messages.
|
|
2695
2698
|
*/
|
|
@@ -2739,6 +2742,10 @@ var EmailProvider = class {
|
|
|
2739
2742
|
this.serviceDomain = serviceDomain;
|
|
2740
2743
|
this.EMAIL_USERNAME = EMAIL_USERNAME;
|
|
2741
2744
|
}
|
|
2745
|
+
prisma;
|
|
2746
|
+
logger;
|
|
2747
|
+
serviceDomain;
|
|
2748
|
+
EMAIL_USERNAME;
|
|
2742
2749
|
async send({
|
|
2743
2750
|
body,
|
|
2744
2751
|
recipient,
|
|
@@ -2821,6 +2828,8 @@ var SmsProvider = class {
|
|
|
2821
2828
|
this.sender = args.senderId || "AlmaMedLab";
|
|
2822
2829
|
this.countryCode = (args.countryCode || "+233").trim();
|
|
2823
2830
|
}
|
|
2831
|
+
logger;
|
|
2832
|
+
args;
|
|
2824
2833
|
url;
|
|
2825
2834
|
token;
|
|
2826
2835
|
sender;
|
|
@@ -2959,6 +2968,8 @@ var WebNotificationProvider = class {
|
|
|
2959
2968
|
this.prisma = prisma;
|
|
2960
2969
|
this.logger = logger;
|
|
2961
2970
|
}
|
|
2971
|
+
prisma;
|
|
2972
|
+
logger;
|
|
2962
2973
|
async sendBulk(args) {
|
|
2963
2974
|
const rows = (args.recipients ?? []).map((r) => {
|
|
2964
2975
|
let data = {
|
|
@@ -3352,6 +3363,8 @@ var WhatsAppProvider = class {
|
|
|
3352
3363
|
this.apiUrl = args.apiUrl ?? "";
|
|
3353
3364
|
this.apiKey = args.apiKey;
|
|
3354
3365
|
}
|
|
3366
|
+
args;
|
|
3367
|
+
logger;
|
|
3355
3368
|
apiKey;
|
|
3356
3369
|
apiUrl;
|
|
3357
3370
|
/**
|
|
@@ -3509,6 +3522,9 @@ var NotificationService = class {
|
|
|
3509
3522
|
this.logger = logger;
|
|
3510
3523
|
this.helpers = helpers;
|
|
3511
3524
|
}
|
|
3525
|
+
prisma;
|
|
3526
|
+
logger;
|
|
3527
|
+
helpers;
|
|
3512
3528
|
/**
|
|
3513
3529
|
* Main entry: handle one business event.
|
|
3514
3530
|
* Creates parent EventDelivery and one child EventDeliveryItem per attempt.
|
|
@@ -3736,7 +3752,9 @@ var NotificationService = class {
|
|
|
3736
3752
|
if (!userIds.length) return /* @__PURE__ */ new Map();
|
|
3737
3753
|
const rows = await this.prisma.session.findMany({
|
|
3738
3754
|
where: {
|
|
3739
|
-
|
|
3755
|
+
user: {
|
|
3756
|
+
userId: { in: userIds }
|
|
3757
|
+
},
|
|
3740
3758
|
deviceNotificationToken: { not: null },
|
|
3741
3759
|
logoutAt: null
|
|
3742
3760
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -2347,12 +2347,13 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2347
2347
|
const db = uinDeps.db;
|
|
2348
2348
|
const logger = uinDeps.logger;
|
|
2349
2349
|
const requestStorage = uinDeps.requestStorage;
|
|
2350
|
+
const modelName = uinDeps.modelName || "uINConfig";
|
|
2350
2351
|
return {
|
|
2351
2352
|
async createUINConfigInDb(uinReq) {
|
|
2352
2353
|
logger.info("entering::createUINConfigInDb::repository");
|
|
2353
2354
|
const storage = requestStorage.getStore();
|
|
2354
2355
|
const { uinSegments, ...uinData } = uinReq;
|
|
2355
|
-
return db.
|
|
2356
|
+
return db[modelName].create({
|
|
2356
2357
|
data: {
|
|
2357
2358
|
...uinData,
|
|
2358
2359
|
uinSegments: JSON.stringify(uinSegments),
|
|
@@ -2364,7 +2365,7 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2364
2365
|
async updateUINConfigInDb(updatedConfig, prevConfig) {
|
|
2365
2366
|
logger.info("entering::updateUINConfig::repository");
|
|
2366
2367
|
const storage = requestStorage.getStore();
|
|
2367
|
-
const updated = await db.
|
|
2368
|
+
const updated = await db[modelName].update({
|
|
2368
2369
|
where: { id: updatedConfig.id },
|
|
2369
2370
|
data: {
|
|
2370
2371
|
shortCode: updatedConfig.shortCode,
|
|
@@ -2380,32 +2381,32 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2380
2381
|
},
|
|
2381
2382
|
async getUINConfigByIdFromDb(id) {
|
|
2382
2383
|
logger.info("entering::getUINConfigByIdFromDb::repository");
|
|
2383
|
-
return db.
|
|
2384
|
+
return db[modelName].findUnique({
|
|
2384
2385
|
where: { id, isActive: true }
|
|
2385
2386
|
});
|
|
2386
2387
|
},
|
|
2387
2388
|
async getUINConfigByShortCodeFromDb(shortCode) {
|
|
2388
2389
|
logger.info("entering::getUINConfigByShortCodeFromDb::repository");
|
|
2389
|
-
return db.
|
|
2390
|
+
return db[modelName].findFirst({
|
|
2390
2391
|
where: { shortCode, isActive: true }
|
|
2391
2392
|
});
|
|
2392
2393
|
},
|
|
2393
2394
|
async getAllUINConfigFromDb() {
|
|
2394
2395
|
logger.info("entering::getAllUINConfigFromDb::repository");
|
|
2395
|
-
return db.
|
|
2396
|
+
return db[modelName].findMany({
|
|
2396
2397
|
where: { isActive: true }
|
|
2397
2398
|
});
|
|
2398
2399
|
},
|
|
2399
2400
|
async updateSequenceNo(shortCode, next) {
|
|
2400
2401
|
logger.info("entering::updateSequenceNo::repository");
|
|
2401
|
-
await db.
|
|
2402
|
+
await db[modelName].updateMany({
|
|
2402
2403
|
where: { shortCode, isActive: true },
|
|
2403
2404
|
data: { sequenceNo: next }
|
|
2404
2405
|
});
|
|
2405
2406
|
},
|
|
2406
2407
|
async updateSequenceNoAndResetDate(shortCode, next, resetDate) {
|
|
2407
2408
|
logger.info("entering::updateSequenceNoAndResetDate::repository");
|
|
2408
|
-
await db.
|
|
2409
|
+
await db[modelName].updateMany({
|
|
2409
2410
|
where: { shortCode, isActive: true },
|
|
2410
2411
|
data: { sequenceNo: next, seqResetDate: resetDate }
|
|
2411
2412
|
});
|
|
@@ -2413,7 +2414,7 @@ var uinConfigRepository = (uinDeps) => {
|
|
|
2413
2414
|
async deleteUINConfigById(id) {
|
|
2414
2415
|
logger.info("entering::deleteUINConfigById::repository");
|
|
2415
2416
|
const storage = requestStorage.getStore();
|
|
2416
|
-
await db.
|
|
2417
|
+
await db[modelName].update({
|
|
2417
2418
|
where: { id },
|
|
2418
2419
|
data: {
|
|
2419
2420
|
isActive: false,
|
|
@@ -2634,6 +2635,8 @@ var ExpoAppNotificationProvider = class {
|
|
|
2634
2635
|
this.logger = logger;
|
|
2635
2636
|
this.url = url;
|
|
2636
2637
|
}
|
|
2638
|
+
logger;
|
|
2639
|
+
url;
|
|
2637
2640
|
/**
|
|
2638
2641
|
* Bulk send: one HTTP request with many messages.
|
|
2639
2642
|
*/
|
|
@@ -2683,6 +2686,10 @@ var EmailProvider = class {
|
|
|
2683
2686
|
this.serviceDomain = serviceDomain;
|
|
2684
2687
|
this.EMAIL_USERNAME = EMAIL_USERNAME;
|
|
2685
2688
|
}
|
|
2689
|
+
prisma;
|
|
2690
|
+
logger;
|
|
2691
|
+
serviceDomain;
|
|
2692
|
+
EMAIL_USERNAME;
|
|
2686
2693
|
async send({
|
|
2687
2694
|
body,
|
|
2688
2695
|
recipient,
|
|
@@ -2765,6 +2772,8 @@ var SmsProvider = class {
|
|
|
2765
2772
|
this.sender = args.senderId || "AlmaMedLab";
|
|
2766
2773
|
this.countryCode = (args.countryCode || "+233").trim();
|
|
2767
2774
|
}
|
|
2775
|
+
logger;
|
|
2776
|
+
args;
|
|
2768
2777
|
url;
|
|
2769
2778
|
token;
|
|
2770
2779
|
sender;
|
|
@@ -2903,6 +2912,8 @@ var WebNotificationProvider = class {
|
|
|
2903
2912
|
this.prisma = prisma;
|
|
2904
2913
|
this.logger = logger;
|
|
2905
2914
|
}
|
|
2915
|
+
prisma;
|
|
2916
|
+
logger;
|
|
2906
2917
|
async sendBulk(args) {
|
|
2907
2918
|
const rows = (args.recipients ?? []).map((r) => {
|
|
2908
2919
|
let data = {
|
|
@@ -3296,6 +3307,8 @@ var WhatsAppProvider = class {
|
|
|
3296
3307
|
this.apiUrl = args.apiUrl ?? "";
|
|
3297
3308
|
this.apiKey = args.apiKey;
|
|
3298
3309
|
}
|
|
3310
|
+
args;
|
|
3311
|
+
logger;
|
|
3299
3312
|
apiKey;
|
|
3300
3313
|
apiUrl;
|
|
3301
3314
|
/**
|
|
@@ -3453,6 +3466,9 @@ var NotificationService = class {
|
|
|
3453
3466
|
this.logger = logger;
|
|
3454
3467
|
this.helpers = helpers;
|
|
3455
3468
|
}
|
|
3469
|
+
prisma;
|
|
3470
|
+
logger;
|
|
3471
|
+
helpers;
|
|
3456
3472
|
/**
|
|
3457
3473
|
* Main entry: handle one business event.
|
|
3458
3474
|
* Creates parent EventDelivery and one child EventDeliveryItem per attempt.
|
|
@@ -3680,7 +3696,9 @@ var NotificationService = class {
|
|
|
3680
3696
|
if (!userIds.length) return /* @__PURE__ */ new Map();
|
|
3681
3697
|
const rows = await this.prisma.session.findMany({
|
|
3682
3698
|
where: {
|
|
3683
|
-
|
|
3699
|
+
user: {
|
|
3700
|
+
userId: { in: userIds }
|
|
3701
|
+
},
|
|
3684
3702
|
deviceNotificationToken: { not: null },
|
|
3685
3703
|
logoutAt: null
|
|
3686
3704
|
},
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "av6-core",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"module": "dist/index.mjs",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"description": "All utility function for av6 node js projects.",
|
|
8
|
-
"author": "Aniket Sarkar",
|
|
9
|
-
"license": "ISC",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "npm run format && tsup",
|
|
12
|
-
"p:gen": "prisma generate",
|
|
13
|
-
"format": "prettier --write **/*.ts"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@types/lodash.merge": "^4.6.9",
|
|
17
|
-
"@types/nodemailer": "^7.0.3",
|
|
18
|
-
"tsup": "^8.5.0",
|
|
19
|
-
"typescript": "^5.9.2"
|
|
20
|
-
},
|
|
21
|
-
"peerDependencies": {
|
|
22
|
-
"@prisma/client": "^6.19.0",
|
|
23
|
-
"winston": "^3.17.0"
|
|
24
|
-
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"av6-utils": "^1.0.4",
|
|
27
|
-
"axios": "^1.11.0",
|
|
28
|
-
"dayjs": "^1.11.19",
|
|
29
|
-
"exceljs": "^4.4.0",
|
|
30
|
-
"handlebars": "^4.7.8",
|
|
31
|
-
"joi": "^17.13.3",
|
|
32
|
-
"lodash.merge": "^4.6.2",
|
|
33
|
-
"node-cron": "^4.2.1",
|
|
34
|
-
"nodemailer": "^7.0.10",
|
|
35
|
-
"prettier": "^3.6.2",
|
|
36
|
-
"prisma": "^6.19.0"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "av6-core",
|
|
3
|
+
"version": "1.7.12",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.mjs",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"description": "All utility function for av6 node js projects.",
|
|
8
|
+
"author": "Aniket Sarkar",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "npm run format && tsup",
|
|
12
|
+
"p:gen": "prisma generate",
|
|
13
|
+
"format": "prettier --write **/*.ts"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/lodash.merge": "^4.6.9",
|
|
17
|
+
"@types/nodemailer": "^7.0.3",
|
|
18
|
+
"tsup": "^8.5.0",
|
|
19
|
+
"typescript": "^5.9.2"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@prisma/client": "^6.19.0",
|
|
23
|
+
"winston": "^3.17.0"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"av6-utils": "^1.0.4",
|
|
27
|
+
"axios": "^1.11.0",
|
|
28
|
+
"dayjs": "^1.11.19",
|
|
29
|
+
"exceljs": "^4.4.0",
|
|
30
|
+
"handlebars": "^4.7.8",
|
|
31
|
+
"joi": "^17.13.3",
|
|
32
|
+
"lodash.merge": "^4.6.2",
|
|
33
|
+
"node-cron": "^4.2.1",
|
|
34
|
+
"nodemailer": "^7.0.10",
|
|
35
|
+
"prettier": "^3.6.2",
|
|
36
|
+
"prisma": "^6.19.0"
|
|
37
|
+
}
|
|
38
|
+
}
|