av6-core 1.0.3 → 1.0.4

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 (2) hide show
  1. package/README.md +78 -0
  2. package/package.json +5 -2
package/README.md CHANGED
@@ -10,6 +10,7 @@ A comprehensive utility library for AV6 Node.js projects, providing common funct
10
10
  - **Pagination**: Built-in pagination for search results
11
11
  - **DTO Mapping**: Support for Data Transfer Object mapping
12
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
13
14
 
14
15
  ## Installation
15
16
 
@@ -123,6 +124,71 @@ const workbook = await service.commonExcelExport({
123
124
  });
124
125
  ```
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
+
126
192
  ## API Reference
127
193
 
128
194
  ### Common Service
@@ -141,6 +207,18 @@ The library provides a comprehensive service for common operations:
141
207
  - `updateStatus`: Update the status of a record
142
208
  - `fetchImageStream`: Fetch an image as a stream
143
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
+
144
222
  ### Utility Functions
145
223
 
146
224
  The library also provides utility functions:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "av6-core",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -16,10 +16,13 @@
16
16
  "typescript": "^5.9.2"
17
17
  },
18
18
  "peerDependencies": {
19
- "prisma": "^6.14.0",
20
19
  "@prisma/client": "^6.14.0",
21
20
  "axios": "^1.11.0",
22
21
  "exceljs": "^4.4.0",
22
+ "prisma": "^6.14.0",
23
23
  "winston": "^3.17.0"
24
+ },
25
+ "dependencies": {
26
+ "node-cron": "^4.2.1"
24
27
  }
25
28
  }