av6-core 1.7.6 → 1.7.8
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +35 -5
- package/dist/index.mjs +34 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -526,6 +526,7 @@ declare function customOmit<T extends object, K extends keyof T>(obj: T, keys: K
|
|
|
526
526
|
};
|
|
527
527
|
declare function getDynamicValue(obj: Record<string, any> | null | undefined, accessorKey: string): any | null;
|
|
528
528
|
declare function getNestedValue<T = unknown>(obj: unknown, path?: string | null, defaultValue?: T): T | undefined;
|
|
529
|
+
declare function getNestedValueV2<T = unknown>(obj: unknown, path?: string | null, defaultValue?: T): T | undefined;
|
|
529
530
|
declare function objectTo2DArray<T>(obj: Record<string, T>, maxCols: number): (string | T)[][];
|
|
530
531
|
declare function toNumberOrNull(value: unknown): number | null;
|
|
531
532
|
declare const getPattern: {
|
|
@@ -701,4 +702,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
|
|
|
701
702
|
createAuditedService<T extends object>(serviceName: string, service: T): T;
|
|
702
703
|
}
|
|
703
704
|
|
|
704
|
-
export { type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateUINConfigRequest, type CrudContext, type CrudDelegate, type DataType, type DeepMerge, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DtoFromMapping, type DtoNullOnMissing, type DynamicCreateInput, type DynamicCrudConfig, type DynamicShortCode, type DynamicUpdateInput, type EmitPayload, type EmployeeCache, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type Store, type ToggleActive, type TxClient, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UnionToIntersection, type UniqueConfig, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getPattern, interpolate, objectTo2DArray, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
|
705
|
+
export { type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateUINConfigRequest, type CrudContext, type CrudDelegate, type DataType, type DeepMerge, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DtoFromMapping, type DtoNullOnMissing, type DynamicCreateInput, type DynamicCrudConfig, type DynamicShortCode, type DynamicUpdateInput, type EmitPayload, type EmployeeCache, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type Store, type ToggleActive, type TxClient, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UnionToIntersection, type UniqueConfig, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -526,6 +526,7 @@ declare function customOmit<T extends object, K extends keyof T>(obj: T, keys: K
|
|
|
526
526
|
};
|
|
527
527
|
declare function getDynamicValue(obj: Record<string, any> | null | undefined, accessorKey: string): any | null;
|
|
528
528
|
declare function getNestedValue<T = unknown>(obj: unknown, path?: string | null, defaultValue?: T): T | undefined;
|
|
529
|
+
declare function getNestedValueV2<T = unknown>(obj: unknown, path?: string | null, defaultValue?: T): T | undefined;
|
|
529
530
|
declare function objectTo2DArray<T>(obj: Record<string, T>, maxCols: number): (string | T)[][];
|
|
530
531
|
declare function toNumberOrNull(value: unknown): number | null;
|
|
531
532
|
declare const getPattern: {
|
|
@@ -701,4 +702,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
|
|
|
701
702
|
createAuditedService<T extends object>(serviceName: string, service: T): T;
|
|
702
703
|
}
|
|
703
704
|
|
|
704
|
-
export { type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateUINConfigRequest, type CrudContext, type CrudDelegate, type DataType, type DeepMerge, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DtoFromMapping, type DtoNullOnMissing, type DynamicCreateInput, type DynamicCrudConfig, type DynamicShortCode, type DynamicUpdateInput, type EmitPayload, type EmployeeCache, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type Store, type ToggleActive, type TxClient, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UnionToIntersection, type UniqueConfig, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getPattern, interpolate, objectTo2DArray, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
|
705
|
+
export { type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateUINConfigRequest, type CrudContext, type CrudDelegate, type DataType, type DeepMerge, type DeleteParams, type DeleteRequestRepository, type Deps, type DropdownRequest, type DropdownRequestService, type DtoFromMapping, type DtoNullOnMissing, type DynamicCreateInput, type DynamicCrudConfig, type DynamicShortCode, type DynamicUpdateInput, type EmitPayload, type EmployeeCache, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, type Helpers, type ImportExcel, type ImportExcelRequestService, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type Store, type ToggleActive, type TxClient, type UINConfigDTO, type UINPreviewRequest, type UINSegment, type UINSegmentType, type UIN_RESET_POLICY, type UinDeps, type UnionToIntersection, type UniqueConfig, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, commonService, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
fromTimestampToSqlDatetime: () => fromTimestampToSqlDatetime,
|
|
42
42
|
getDynamicValue: () => getDynamicValue,
|
|
43
43
|
getNestedValue: () => getNestedValue,
|
|
44
|
+
getNestedValueV2: () => getNestedValueV2,
|
|
44
45
|
getPattern: () => getPattern,
|
|
45
46
|
interpolate: () => interpolate,
|
|
46
47
|
objectTo2DArray: () => objectTo2DArray,
|
|
@@ -1343,6 +1344,25 @@ function getNestedValue(obj, path, defaultValue) {
|
|
|
1343
1344
|
}, obj);
|
|
1344
1345
|
return result === void 0 ? defaultValue : result;
|
|
1345
1346
|
}
|
|
1347
|
+
function getNestedValueV2(obj, path, defaultValue) {
|
|
1348
|
+
if (!obj || !path) return defaultValue;
|
|
1349
|
+
const normalizedPath = path.replace(/\[(\d+)\]/g, ".$1");
|
|
1350
|
+
const keys = normalizedPath.split(".");
|
|
1351
|
+
const resolve = (current, index) => {
|
|
1352
|
+
if (current == null) return void 0;
|
|
1353
|
+
if (index >= keys.length) return current;
|
|
1354
|
+
const key = keys[index];
|
|
1355
|
+
if (key.endsWith("[]")) {
|
|
1356
|
+
const arrayKey = key.replace("[]", "");
|
|
1357
|
+
const arr = current[arrayKey];
|
|
1358
|
+
if (!Array.isArray(arr)) return void 0;
|
|
1359
|
+
return arr.map((item) => resolve(item, index + 1));
|
|
1360
|
+
}
|
|
1361
|
+
return resolve(current[key], index + 1);
|
|
1362
|
+
};
|
|
1363
|
+
const result = resolve(obj, 0);
|
|
1364
|
+
return result === void 0 ? defaultValue : result;
|
|
1365
|
+
}
|
|
1346
1366
|
function objectTo2DArray(obj, maxCols) {
|
|
1347
1367
|
if (maxCols < 2) {
|
|
1348
1368
|
throw new Error("maxCols must be at least 2");
|
|
@@ -3204,9 +3224,9 @@ async function resolveAllRecipients(args) {
|
|
|
3204
3224
|
}
|
|
3205
3225
|
if (r.sourceType === "KEY_VALUE") {
|
|
3206
3226
|
const recs = toArray(cfg.recipients).map((x) => {
|
|
3207
|
-
const userIdVal =
|
|
3208
|
-
const level1Val =
|
|
3209
|
-
const level2Val = x.level2Id ?
|
|
3227
|
+
const userIdVal = getNestedValueV2(args.evtData, x.userId);
|
|
3228
|
+
const level1Val = getNestedValueV2(args.evtData, x.level1Id);
|
|
3229
|
+
const level2Val = x.level2Id ? getNestedValueV2(args.evtData, x.level2Id) : void 0;
|
|
3210
3230
|
return {
|
|
3211
3231
|
userId: userIdVal != null ? Number(userIdVal) : null,
|
|
3212
3232
|
level1Id: level1Val != null ? Number(level1Val) : null,
|
|
@@ -3241,7 +3261,7 @@ async function resolveAllRecipients(args) {
|
|
|
3241
3261
|
}
|
|
3242
3262
|
if (r.sourceType === "KEY_VALUE") {
|
|
3243
3263
|
for (const k of toArray(cfg.recipients)) {
|
|
3244
|
-
const v =
|
|
3264
|
+
const v = getNestedValueV2(args.evtData, k);
|
|
3245
3265
|
if (typeof v === "string") res[type].push(v);
|
|
3246
3266
|
if (Array.isArray(v)) res[type].push(...v.filter((x) => typeof x === "string"));
|
|
3247
3267
|
}
|
|
@@ -3934,7 +3954,7 @@ var NotificationService = class {
|
|
|
3934
3954
|
fileUrls
|
|
3935
3955
|
});
|
|
3936
3956
|
for (const it of bulk.items) {
|
|
3937
|
-
await this.prisma.eventDeliveryItem.create({
|
|
3957
|
+
const deliveryItem = await this.prisma.eventDeliveryItem.create({
|
|
3938
3958
|
data: {
|
|
3939
3959
|
deliveryId,
|
|
3940
3960
|
notificationType: "WHATSAPP" /* WHATSAPP */,
|
|
@@ -3947,6 +3967,15 @@ var NotificationService = class {
|
|
|
3947
3967
|
error: it.ok ? null : it.error ?? "failed"
|
|
3948
3968
|
}
|
|
3949
3969
|
});
|
|
3970
|
+
if (it.ok && tpl.webHookUrl) {
|
|
3971
|
+
const res = await fetch(tpl.webHookUrl, {
|
|
3972
|
+
method: "POST",
|
|
3973
|
+
body: JSON.stringify({ id: deliveryItem.id })
|
|
3974
|
+
});
|
|
3975
|
+
if (!res.ok) {
|
|
3976
|
+
this.logger.error("[NotificationService] WhatsApp webhook failed", res.statusText);
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3950
3979
|
}
|
|
3951
3980
|
}
|
|
3952
3981
|
// --------------------------------------------------------------------------------------
|
|
@@ -4243,6 +4272,7 @@ var AuditProxy = class {
|
|
|
4243
4272
|
fromTimestampToSqlDatetime,
|
|
4244
4273
|
getDynamicValue,
|
|
4245
4274
|
getNestedValue,
|
|
4275
|
+
getNestedValueV2,
|
|
4246
4276
|
getPattern,
|
|
4247
4277
|
interpolate,
|
|
4248
4278
|
objectTo2DArray,
|
package/dist/index.mjs
CHANGED
|
@@ -1291,6 +1291,25 @@ function getNestedValue(obj, path, defaultValue) {
|
|
|
1291
1291
|
}, obj);
|
|
1292
1292
|
return result === void 0 ? defaultValue : result;
|
|
1293
1293
|
}
|
|
1294
|
+
function getNestedValueV2(obj, path, defaultValue) {
|
|
1295
|
+
if (!obj || !path) return defaultValue;
|
|
1296
|
+
const normalizedPath = path.replace(/\[(\d+)\]/g, ".$1");
|
|
1297
|
+
const keys = normalizedPath.split(".");
|
|
1298
|
+
const resolve = (current, index) => {
|
|
1299
|
+
if (current == null) return void 0;
|
|
1300
|
+
if (index >= keys.length) return current;
|
|
1301
|
+
const key = keys[index];
|
|
1302
|
+
if (key.endsWith("[]")) {
|
|
1303
|
+
const arrayKey = key.replace("[]", "");
|
|
1304
|
+
const arr = current[arrayKey];
|
|
1305
|
+
if (!Array.isArray(arr)) return void 0;
|
|
1306
|
+
return arr.map((item) => resolve(item, index + 1));
|
|
1307
|
+
}
|
|
1308
|
+
return resolve(current[key], index + 1);
|
|
1309
|
+
};
|
|
1310
|
+
const result = resolve(obj, 0);
|
|
1311
|
+
return result === void 0 ? defaultValue : result;
|
|
1312
|
+
}
|
|
1294
1313
|
function objectTo2DArray(obj, maxCols) {
|
|
1295
1314
|
if (maxCols < 2) {
|
|
1296
1315
|
throw new Error("maxCols must be at least 2");
|
|
@@ -3152,9 +3171,9 @@ async function resolveAllRecipients(args) {
|
|
|
3152
3171
|
}
|
|
3153
3172
|
if (r.sourceType === "KEY_VALUE") {
|
|
3154
3173
|
const recs = toArray(cfg.recipients).map((x) => {
|
|
3155
|
-
const userIdVal =
|
|
3156
|
-
const level1Val =
|
|
3157
|
-
const level2Val = x.level2Id ?
|
|
3174
|
+
const userIdVal = getNestedValueV2(args.evtData, x.userId);
|
|
3175
|
+
const level1Val = getNestedValueV2(args.evtData, x.level1Id);
|
|
3176
|
+
const level2Val = x.level2Id ? getNestedValueV2(args.evtData, x.level2Id) : void 0;
|
|
3158
3177
|
return {
|
|
3159
3178
|
userId: userIdVal != null ? Number(userIdVal) : null,
|
|
3160
3179
|
level1Id: level1Val != null ? Number(level1Val) : null,
|
|
@@ -3189,7 +3208,7 @@ async function resolveAllRecipients(args) {
|
|
|
3189
3208
|
}
|
|
3190
3209
|
if (r.sourceType === "KEY_VALUE") {
|
|
3191
3210
|
for (const k of toArray(cfg.recipients)) {
|
|
3192
|
-
const v =
|
|
3211
|
+
const v = getNestedValueV2(args.evtData, k);
|
|
3193
3212
|
if (typeof v === "string") res[type].push(v);
|
|
3194
3213
|
if (Array.isArray(v)) res[type].push(...v.filter((x) => typeof x === "string"));
|
|
3195
3214
|
}
|
|
@@ -3882,7 +3901,7 @@ var NotificationService = class {
|
|
|
3882
3901
|
fileUrls
|
|
3883
3902
|
});
|
|
3884
3903
|
for (const it of bulk.items) {
|
|
3885
|
-
await this.prisma.eventDeliveryItem.create({
|
|
3904
|
+
const deliveryItem = await this.prisma.eventDeliveryItem.create({
|
|
3886
3905
|
data: {
|
|
3887
3906
|
deliveryId,
|
|
3888
3907
|
notificationType: "WHATSAPP" /* WHATSAPP */,
|
|
@@ -3895,6 +3914,15 @@ var NotificationService = class {
|
|
|
3895
3914
|
error: it.ok ? null : it.error ?? "failed"
|
|
3896
3915
|
}
|
|
3897
3916
|
});
|
|
3917
|
+
if (it.ok && tpl.webHookUrl) {
|
|
3918
|
+
const res = await fetch(tpl.webHookUrl, {
|
|
3919
|
+
method: "POST",
|
|
3920
|
+
body: JSON.stringify({ id: deliveryItem.id })
|
|
3921
|
+
});
|
|
3922
|
+
if (!res.ok) {
|
|
3923
|
+
this.logger.error("[NotificationService] WhatsApp webhook failed", res.statusText);
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3898
3926
|
}
|
|
3899
3927
|
}
|
|
3900
3928
|
// --------------------------------------------------------------------------------------
|
|
@@ -4190,6 +4218,7 @@ export {
|
|
|
4190
4218
|
fromTimestampToSqlDatetime,
|
|
4191
4219
|
getDynamicValue,
|
|
4192
4220
|
getNestedValue,
|
|
4221
|
+
getNestedValueV2,
|
|
4193
4222
|
getPattern,
|
|
4194
4223
|
interpolate,
|
|
4195
4224
|
objectTo2DArray,
|