av6-core 1.0.4 → 1.0.6

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/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as PrismaNamespace from '@prisma/client';
1
2
  import { PrismaClient } from '@prisma/client';
2
3
  import winston from 'winston';
3
4
  import { AsyncLocalStorage } from 'async_hooks';
@@ -263,6 +264,7 @@ declare function toNumberOrNull(value: unknown): number | null;
263
264
  declare const getPattern: {
264
265
  [key: string]: RegExp;
265
266
  };
267
+ declare const interpolate: (template: string, vars: Record<string, unknown>) => string;
266
268
 
267
269
  interface CreateTransaction {
268
270
  field: string;
@@ -282,4 +284,104 @@ interface CreateTransaction {
282
284
  */
283
285
  declare function findDifferences<T extends Record<string, any>>(obj1: T, obj2: T): CreateTransaction[];
284
286
 
285
- export { type CacheAdapter, type CalculationRes, type ColValue, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type Store, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, objectTo2DArray, toNumberOrNull, type updateStatusParams };
287
+ interface ServiceCacheAdapter extends CacheAdapter {
288
+ addToCache(key: string, id: number | string, data: unknown): Promise<void>;
289
+ checkIsCacheable(shortCode: string): Promise<boolean>;
290
+ }
291
+ interface UinDeps {
292
+ cacheKey: string;
293
+ shortCode: string;
294
+ helpers: Helpers;
295
+ logger: winston.Logger;
296
+ cacheAdapter: ServiceCacheAdapter;
297
+ requestStorage: AsyncLocalStorage<Store>;
298
+ db: PrismaClient;
299
+ prisma: typeof PrismaNamespace;
300
+ }
301
+ type UINSegmentType = "text" | "separator" | "dateFormat" | "sequenceNo";
302
+ type UIN_RESET_POLICY = "daily" | "weekly" | "monthly" | "yearly" | "no";
303
+ interface UINSegment {
304
+ order: number;
305
+ type: UINSegmentType;
306
+ value?: string;
307
+ minSeqLength?: number;
308
+ }
309
+ interface UINPreviewRequest {
310
+ uinSegments: UINSegment[];
311
+ }
312
+ interface CreateUINConfigRequest {
313
+ shortCode: string;
314
+ seqResetPolicy: UIN_RESET_POLICY;
315
+ description?: string;
316
+ uinSegments: UINSegment[];
317
+ }
318
+ interface UpdateUINConfigRequest extends CreateUINConfigRequest {
319
+ id: number;
320
+ }
321
+ interface UINConfigDTO {
322
+ id: number;
323
+ shortCode: string;
324
+ sequenceNo: string;
325
+ seqResetDate: Date;
326
+ seqResetPolicy: UIN_RESET_POLICY;
327
+ description?: string;
328
+ uinSegments: UINSegment[];
329
+ createdAt: Date;
330
+ updatedAt: Date;
331
+ createdBy: number | null;
332
+ updatedBy?: number | null;
333
+ }
334
+
335
+ declare const uinConfigService: (uinDeps: UinDeps) => {
336
+ createUINConfig(input: CreateUINConfigRequest): Promise<UINConfigDTO>;
337
+ loadConfig(shortCode: string): Promise<any>;
338
+ generateUIN(shortCode: string): Promise<string>;
339
+ previewConfig(shortCode: string): Promise<string>;
340
+ previewCustom(body: UINPreviewRequest): string;
341
+ updateUINConfig(req: UpdateUINConfigRequest): Promise<UINConfigDTO>;
342
+ deleteUINConfig(id: number): Promise<void>;
343
+ getAllEnumCodes(): Promise<string[]>;
344
+ };
345
+
346
+ type Recipient = {
347
+ email?: string;
348
+ phone?: string;
349
+ whatsapp?: string;
350
+ appUserId?: string;
351
+ };
352
+ type EmitPayload = {
353
+ serviceEventId: number;
354
+ eventName: string;
355
+ recipient: Recipient;
356
+ data: Record<string, any>;
357
+ };
358
+ interface ILogger {
359
+ info: (...args: any[]) => void;
360
+ error: (...args: any[]) => void;
361
+ }
362
+ type NotificationEmitterDeps = {
363
+ prisma: PrismaClient;
364
+ logger?: ILogger;
365
+ envMode?: "Production" | "Development";
366
+ };
367
+
368
+ /**
369
+ * You (host service) create ONE instance of this class on startup and reuse it.
370
+ */
371
+ declare class NotificationEmitter {
372
+ private emitter;
373
+ private service;
374
+ constructor(deps: NotificationEmitterDeps);
375
+ /**
376
+ * Call this from application code.
377
+ * This is async fire-and-forget style: we emit and return immediately.
378
+ * If you WANT to await the notifications, you can just call service.handleEvent directly.
379
+ */
380
+ emitEvent(eventName: string, body: Omit<EmitPayload, "eventName">): void;
381
+ /**
382
+ * Optional helper if some flows DO want to wait for completion.
383
+ */
384
+ notifyNow(eventName: string, body: Omit<EmitPayload, "eventName">): Promise<void>;
385
+ }
386
+
387
+ export { type CacheAdapter, type CalculationRes, type ColValue, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type CreateUINConfigRequest, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type EmitPayload, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type PaginatedResponse, type Recipient, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type Store, type ToggleActive, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, interpolate, objectTo2DArray, toNumberOrNull, uinConfigService, type updateStatusParams };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as PrismaNamespace from '@prisma/client';
1
2
  import { PrismaClient } from '@prisma/client';
2
3
  import winston from 'winston';
3
4
  import { AsyncLocalStorage } from 'async_hooks';
@@ -263,6 +264,7 @@ declare function toNumberOrNull(value: unknown): number | null;
263
264
  declare const getPattern: {
264
265
  [key: string]: RegExp;
265
266
  };
267
+ declare const interpolate: (template: string, vars: Record<string, unknown>) => string;
266
268
 
267
269
  interface CreateTransaction {
268
270
  field: string;
@@ -282,4 +284,104 @@ interface CreateTransaction {
282
284
  */
283
285
  declare function findDifferences<T extends Record<string, any>>(obj1: T, obj2: T): CreateTransaction[];
284
286
 
285
- export { type CacheAdapter, type CalculationRes, type ColValue, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, type PaginatedResponse, type SearchRequest, type SearchRequestService, type Store, type ToggleActive, type UpdateStatusRequestRepository, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, objectTo2DArray, toNumberOrNull, type updateStatusParams };
287
+ interface ServiceCacheAdapter extends CacheAdapter {
288
+ addToCache(key: string, id: number | string, data: unknown): Promise<void>;
289
+ checkIsCacheable(shortCode: string): Promise<boolean>;
290
+ }
291
+ interface UinDeps {
292
+ cacheKey: string;
293
+ shortCode: string;
294
+ helpers: Helpers;
295
+ logger: winston.Logger;
296
+ cacheAdapter: ServiceCacheAdapter;
297
+ requestStorage: AsyncLocalStorage<Store>;
298
+ db: PrismaClient;
299
+ prisma: typeof PrismaNamespace;
300
+ }
301
+ type UINSegmentType = "text" | "separator" | "dateFormat" | "sequenceNo";
302
+ type UIN_RESET_POLICY = "daily" | "weekly" | "monthly" | "yearly" | "no";
303
+ interface UINSegment {
304
+ order: number;
305
+ type: UINSegmentType;
306
+ value?: string;
307
+ minSeqLength?: number;
308
+ }
309
+ interface UINPreviewRequest {
310
+ uinSegments: UINSegment[];
311
+ }
312
+ interface CreateUINConfigRequest {
313
+ shortCode: string;
314
+ seqResetPolicy: UIN_RESET_POLICY;
315
+ description?: string;
316
+ uinSegments: UINSegment[];
317
+ }
318
+ interface UpdateUINConfigRequest extends CreateUINConfigRequest {
319
+ id: number;
320
+ }
321
+ interface UINConfigDTO {
322
+ id: number;
323
+ shortCode: string;
324
+ sequenceNo: string;
325
+ seqResetDate: Date;
326
+ seqResetPolicy: UIN_RESET_POLICY;
327
+ description?: string;
328
+ uinSegments: UINSegment[];
329
+ createdAt: Date;
330
+ updatedAt: Date;
331
+ createdBy: number | null;
332
+ updatedBy?: number | null;
333
+ }
334
+
335
+ declare const uinConfigService: (uinDeps: UinDeps) => {
336
+ createUINConfig(input: CreateUINConfigRequest): Promise<UINConfigDTO>;
337
+ loadConfig(shortCode: string): Promise<any>;
338
+ generateUIN(shortCode: string): Promise<string>;
339
+ previewConfig(shortCode: string): Promise<string>;
340
+ previewCustom(body: UINPreviewRequest): string;
341
+ updateUINConfig(req: UpdateUINConfigRequest): Promise<UINConfigDTO>;
342
+ deleteUINConfig(id: number): Promise<void>;
343
+ getAllEnumCodes(): Promise<string[]>;
344
+ };
345
+
346
+ type Recipient = {
347
+ email?: string;
348
+ phone?: string;
349
+ whatsapp?: string;
350
+ appUserId?: string;
351
+ };
352
+ type EmitPayload = {
353
+ serviceEventId: number;
354
+ eventName: string;
355
+ recipient: Recipient;
356
+ data: Record<string, any>;
357
+ };
358
+ interface ILogger {
359
+ info: (...args: any[]) => void;
360
+ error: (...args: any[]) => void;
361
+ }
362
+ type NotificationEmitterDeps = {
363
+ prisma: PrismaClient;
364
+ logger?: ILogger;
365
+ envMode?: "Production" | "Development";
366
+ };
367
+
368
+ /**
369
+ * You (host service) create ONE instance of this class on startup and reuse it.
370
+ */
371
+ declare class NotificationEmitter {
372
+ private emitter;
373
+ private service;
374
+ constructor(deps: NotificationEmitterDeps);
375
+ /**
376
+ * Call this from application code.
377
+ * This is async fire-and-forget style: we emit and return immediately.
378
+ * If you WANT to await the notifications, you can just call service.handleEvent directly.
379
+ */
380
+ emitEvent(eventName: string, body: Omit<EmitPayload, "eventName">): void;
381
+ /**
382
+ * Optional helper if some flows DO want to wait for completion.
383
+ */
384
+ notifyNow(eventName: string, body: Omit<EmitPayload, "eventName">): Promise<void>;
385
+ }
386
+
387
+ export { type CacheAdapter, type CalculationRes, type ColValue, type CommonExcelRequest, type CommonFilterRequest, type CommonServiceResponse, type Config, type Context, type CreateUINConfigRequest, type DataType, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DynamicShortCode, type EmitPayload, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type Mapper, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type PaginatedResponse, type Recipient, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type Store, type ToggleActive, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, getDynamicValue, getPattern, interpolate, objectTo2DArray, toNumberOrNull, uinConfigService, type updateStatusParams };