av6-core 1.7.8 → 1.7.10
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 +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +44 -35
- package/dist/index.mjs +41 -35
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -554,6 +554,16 @@ interface CreateTransaction {
|
|
|
554
554
|
*/
|
|
555
555
|
declare function findDifferences<T extends Record<string, any>>(obj1: T, obj2: T): CreateTransaction[];
|
|
556
556
|
|
|
557
|
+
declare function renderTemplate(tpl: string, data: any): string;
|
|
558
|
+
declare function renderEmailTemplate(tpl: {
|
|
559
|
+
subject?: string;
|
|
560
|
+
body: string;
|
|
561
|
+
}, data: any): {
|
|
562
|
+
subject: string | undefined;
|
|
563
|
+
body: string;
|
|
564
|
+
};
|
|
565
|
+
declare const convertArrayPatternToEachBlocksGeneric: (html?: string) => string;
|
|
566
|
+
|
|
557
567
|
interface ServiceCacheAdapter extends CacheAdapter {
|
|
558
568
|
addToCache(key: string, id: number | string, data: unknown): Promise<void>;
|
|
559
569
|
checkIsCacheable(shortCode: string): Promise<boolean>;
|
|
@@ -702,4 +712,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
|
|
|
702
712
|
createAuditedService<T extends object>(serviceName: string, service: T): T;
|
|
703
713
|
}
|
|
704
714
|
|
|
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 };
|
|
715
|
+
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, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -554,6 +554,16 @@ interface CreateTransaction {
|
|
|
554
554
|
*/
|
|
555
555
|
declare function findDifferences<T extends Record<string, any>>(obj1: T, obj2: T): CreateTransaction[];
|
|
556
556
|
|
|
557
|
+
declare function renderTemplate(tpl: string, data: any): string;
|
|
558
|
+
declare function renderEmailTemplate(tpl: {
|
|
559
|
+
subject?: string;
|
|
560
|
+
body: string;
|
|
561
|
+
}, data: any): {
|
|
562
|
+
subject: string | undefined;
|
|
563
|
+
body: string;
|
|
564
|
+
};
|
|
565
|
+
declare const convertArrayPatternToEachBlocksGeneric: (html?: string) => string;
|
|
566
|
+
|
|
557
567
|
interface ServiceCacheAdapter extends CacheAdapter {
|
|
558
568
|
addToCache(key: string, id: number | string, data: unknown): Promise<void>;
|
|
559
569
|
checkIsCacheable(shortCode: string): Promise<boolean>;
|
|
@@ -702,4 +712,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
|
|
|
702
712
|
createAuditedService<T extends object>(serviceName: string, service: T): T;
|
|
703
713
|
}
|
|
704
714
|
|
|
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 };
|
|
715
|
+
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, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
AuditProxy: () => AuditProxy,
|
|
36
36
|
NotificationEmitter: () => NotificationEmitter,
|
|
37
37
|
commonService: () => commonService,
|
|
38
|
+
convertArrayPatternToEachBlocksGeneric: () => convertArrayPatternToEachBlocksGeneric,
|
|
38
39
|
customOmit: () => customOmit,
|
|
39
40
|
findDifferences: () => findDifferences,
|
|
40
41
|
formatDatesDeep: () => formatDatesDeep,
|
|
@@ -45,6 +46,8 @@ __export(index_exports, {
|
|
|
45
46
|
getPattern: () => getPattern,
|
|
46
47
|
interpolate: () => interpolate,
|
|
47
48
|
objectTo2DArray: () => objectTo2DArray,
|
|
49
|
+
renderEmailTemplate: () => renderEmailTemplate,
|
|
50
|
+
renderTemplate: () => renderTemplate,
|
|
48
51
|
toNumberOrNull: () => toNumberOrNull,
|
|
49
52
|
toUINConfigDTO: () => toUINConfigDTO,
|
|
50
53
|
uinConfigService: () => uinConfigService
|
|
@@ -2344,6 +2347,40 @@ function findDifferences(obj1, obj2) {
|
|
|
2344
2347
|
return differences;
|
|
2345
2348
|
}
|
|
2346
2349
|
|
|
2350
|
+
// src/utils/renderer.ts
|
|
2351
|
+
var import_handlebars = __toESM(require("handlebars"));
|
|
2352
|
+
function renderTemplate(tpl, data) {
|
|
2353
|
+
return import_handlebars.default.compile(tpl)(data);
|
|
2354
|
+
}
|
|
2355
|
+
function renderEmailTemplate(tpl, data) {
|
|
2356
|
+
return {
|
|
2357
|
+
subject: tpl.subject ? import_handlebars.default.compile(tpl.subject)(data) : void 0,
|
|
2358
|
+
body: import_handlebars.default.compile(convertArrayPatternToEachBlocksGeneric(tpl.body))(data)
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
var convertArrayPatternToEachBlocksGeneric = (html) => {
|
|
2362
|
+
if (!html) return "";
|
|
2363
|
+
const blockTags = ["tr", "div", "li", "section", "tbody"];
|
|
2364
|
+
let output = html;
|
|
2365
|
+
blockTags.forEach((tag) => {
|
|
2366
|
+
const regex = new RegExp(`<${tag}\\b[^>]*>[\\s\\S]*?<\\/${tag}>`, "g");
|
|
2367
|
+
output = output.replace(regex, (blockHtml) => {
|
|
2368
|
+
const matches = [...blockHtml.matchAll(/{{\s*([a-zA-Z0-9_.-]+)\[\]\.([a-zA-Z0-9_.-]+)\s*}}/g)];
|
|
2369
|
+
if (!matches.length) return blockHtml;
|
|
2370
|
+
const uniqueArrays = Array.from(new Set(matches.map((m) => m[1])));
|
|
2371
|
+
if (uniqueArrays.length !== 1) return blockHtml;
|
|
2372
|
+
const arrayName = uniqueArrays[0];
|
|
2373
|
+
const escapedArray = arrayName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2374
|
+
const cleanedBlock = blockHtml.replace(
|
|
2375
|
+
new RegExp(`{{\\s*${escapedArray}\\[\\]\\.([a-zA-Z0-9_.-]+)\\s*}}`, "g"),
|
|
2376
|
+
"{{$1}}"
|
|
2377
|
+
);
|
|
2378
|
+
return `{{#each ${arrayName}}}${cleanedBlock}{{/each}}`;
|
|
2379
|
+
});
|
|
2380
|
+
});
|
|
2381
|
+
return output;
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2347
2384
|
// src/mapper/uinConfig.mapper.ts
|
|
2348
2385
|
var toUINConfigDTO = (model) => {
|
|
2349
2386
|
return {
|
|
@@ -3464,40 +3501,6 @@ var WhatsAppProvider = class {
|
|
|
3464
3501
|
}
|
|
3465
3502
|
};
|
|
3466
3503
|
|
|
3467
|
-
// src/utils/renderer.ts
|
|
3468
|
-
var import_handlebars = __toESM(require("handlebars"));
|
|
3469
|
-
function renderTemplate(tpl, data) {
|
|
3470
|
-
return import_handlebars.default.compile(tpl)(data);
|
|
3471
|
-
}
|
|
3472
|
-
function renderEmailTemplate(tpl, data) {
|
|
3473
|
-
return {
|
|
3474
|
-
subject: tpl.subject ? import_handlebars.default.compile(tpl.subject)(data) : void 0,
|
|
3475
|
-
body: import_handlebars.default.compile(convertArrayPatternToEachBlocksGeneric(tpl.body))(data)
|
|
3476
|
-
};
|
|
3477
|
-
}
|
|
3478
|
-
var convertArrayPatternToEachBlocksGeneric = (html) => {
|
|
3479
|
-
if (!html) return "";
|
|
3480
|
-
const blockTags = ["tr", "div", "li", "section", "tbody"];
|
|
3481
|
-
let output = html;
|
|
3482
|
-
blockTags.forEach((tag) => {
|
|
3483
|
-
const regex = new RegExp(`<${tag}\\b[^>]*>[\\s\\S]*?<\\/${tag}>`, "g");
|
|
3484
|
-
output = output.replace(regex, (blockHtml) => {
|
|
3485
|
-
const matches = [...blockHtml.matchAll(/{{\s*([a-zA-Z0-9_.-]+)\[\]\.([a-zA-Z0-9_.-]+)\s*}}/g)];
|
|
3486
|
-
if (!matches.length) return blockHtml;
|
|
3487
|
-
const uniqueArrays = Array.from(new Set(matches.map((m) => m[1])));
|
|
3488
|
-
if (uniqueArrays.length !== 1) return blockHtml;
|
|
3489
|
-
const arrayName = uniqueArrays[0];
|
|
3490
|
-
const escapedArray = arrayName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3491
|
-
const cleanedBlock = blockHtml.replace(
|
|
3492
|
-
new RegExp(`{{\\s*${escapedArray}\\[\\]\\.([a-zA-Z0-9_.-]+)\\s*}}`, "g"),
|
|
3493
|
-
"{{$1}}"
|
|
3494
|
-
);
|
|
3495
|
-
return `{{#each ${arrayName}}}${cleanedBlock}{{/each}}`;
|
|
3496
|
-
});
|
|
3497
|
-
});
|
|
3498
|
-
return output;
|
|
3499
|
-
};
|
|
3500
|
-
|
|
3501
3504
|
// src/services/notification.service.ts
|
|
3502
3505
|
var import_lodash = __toESM(require("lodash.merge"));
|
|
3503
3506
|
var NotificationService = class {
|
|
@@ -3970,10 +3973,13 @@ var NotificationService = class {
|
|
|
3970
3973
|
if (it.ok && tpl.webHookUrl) {
|
|
3971
3974
|
const res = await fetch(tpl.webHookUrl, {
|
|
3972
3975
|
method: "POST",
|
|
3976
|
+
headers: {
|
|
3977
|
+
"Content-Type": "application/json"
|
|
3978
|
+
},
|
|
3973
3979
|
body: JSON.stringify({ id: deliveryItem.id })
|
|
3974
3980
|
});
|
|
3975
3981
|
if (!res.ok) {
|
|
3976
|
-
this.logger.error("[NotificationService] WhatsApp webhook failed", res.statusText);
|
|
3982
|
+
this.logger.error("[NotificationService] WhatsApp webhook failed", res.status, res.statusText);
|
|
3977
3983
|
}
|
|
3978
3984
|
}
|
|
3979
3985
|
}
|
|
@@ -4266,6 +4272,7 @@ var AuditProxy = class {
|
|
|
4266
4272
|
AuditProxy,
|
|
4267
4273
|
NotificationEmitter,
|
|
4268
4274
|
commonService,
|
|
4275
|
+
convertArrayPatternToEachBlocksGeneric,
|
|
4269
4276
|
customOmit,
|
|
4270
4277
|
findDifferences,
|
|
4271
4278
|
formatDatesDeep,
|
|
@@ -4276,6 +4283,8 @@ var AuditProxy = class {
|
|
|
4276
4283
|
getPattern,
|
|
4277
4284
|
interpolate,
|
|
4278
4285
|
objectTo2DArray,
|
|
4286
|
+
renderEmailTemplate,
|
|
4287
|
+
renderTemplate,
|
|
4279
4288
|
toNumberOrNull,
|
|
4280
4289
|
toUINConfigDTO,
|
|
4281
4290
|
uinConfigService
|
package/dist/index.mjs
CHANGED
|
@@ -2291,6 +2291,40 @@ function findDifferences(obj1, obj2) {
|
|
|
2291
2291
|
return differences;
|
|
2292
2292
|
}
|
|
2293
2293
|
|
|
2294
|
+
// src/utils/renderer.ts
|
|
2295
|
+
import Handlebars from "handlebars";
|
|
2296
|
+
function renderTemplate(tpl, data) {
|
|
2297
|
+
return Handlebars.compile(tpl)(data);
|
|
2298
|
+
}
|
|
2299
|
+
function renderEmailTemplate(tpl, data) {
|
|
2300
|
+
return {
|
|
2301
|
+
subject: tpl.subject ? Handlebars.compile(tpl.subject)(data) : void 0,
|
|
2302
|
+
body: Handlebars.compile(convertArrayPatternToEachBlocksGeneric(tpl.body))(data)
|
|
2303
|
+
};
|
|
2304
|
+
}
|
|
2305
|
+
var convertArrayPatternToEachBlocksGeneric = (html) => {
|
|
2306
|
+
if (!html) return "";
|
|
2307
|
+
const blockTags = ["tr", "div", "li", "section", "tbody"];
|
|
2308
|
+
let output = html;
|
|
2309
|
+
blockTags.forEach((tag) => {
|
|
2310
|
+
const regex = new RegExp(`<${tag}\\b[^>]*>[\\s\\S]*?<\\/${tag}>`, "g");
|
|
2311
|
+
output = output.replace(regex, (blockHtml) => {
|
|
2312
|
+
const matches = [...blockHtml.matchAll(/{{\s*([a-zA-Z0-9_.-]+)\[\]\.([a-zA-Z0-9_.-]+)\s*}}/g)];
|
|
2313
|
+
if (!matches.length) return blockHtml;
|
|
2314
|
+
const uniqueArrays = Array.from(new Set(matches.map((m) => m[1])));
|
|
2315
|
+
if (uniqueArrays.length !== 1) return blockHtml;
|
|
2316
|
+
const arrayName = uniqueArrays[0];
|
|
2317
|
+
const escapedArray = arrayName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2318
|
+
const cleanedBlock = blockHtml.replace(
|
|
2319
|
+
new RegExp(`{{\\s*${escapedArray}\\[\\]\\.([a-zA-Z0-9_.-]+)\\s*}}`, "g"),
|
|
2320
|
+
"{{$1}}"
|
|
2321
|
+
);
|
|
2322
|
+
return `{{#each ${arrayName}}}${cleanedBlock}{{/each}}`;
|
|
2323
|
+
});
|
|
2324
|
+
});
|
|
2325
|
+
return output;
|
|
2326
|
+
};
|
|
2327
|
+
|
|
2294
2328
|
// src/mapper/uinConfig.mapper.ts
|
|
2295
2329
|
var toUINConfigDTO = (model) => {
|
|
2296
2330
|
return {
|
|
@@ -3411,40 +3445,6 @@ var WhatsAppProvider = class {
|
|
|
3411
3445
|
}
|
|
3412
3446
|
};
|
|
3413
3447
|
|
|
3414
|
-
// src/utils/renderer.ts
|
|
3415
|
-
import Handlebars from "handlebars";
|
|
3416
|
-
function renderTemplate(tpl, data) {
|
|
3417
|
-
return Handlebars.compile(tpl)(data);
|
|
3418
|
-
}
|
|
3419
|
-
function renderEmailTemplate(tpl, data) {
|
|
3420
|
-
return {
|
|
3421
|
-
subject: tpl.subject ? Handlebars.compile(tpl.subject)(data) : void 0,
|
|
3422
|
-
body: Handlebars.compile(convertArrayPatternToEachBlocksGeneric(tpl.body))(data)
|
|
3423
|
-
};
|
|
3424
|
-
}
|
|
3425
|
-
var convertArrayPatternToEachBlocksGeneric = (html) => {
|
|
3426
|
-
if (!html) return "";
|
|
3427
|
-
const blockTags = ["tr", "div", "li", "section", "tbody"];
|
|
3428
|
-
let output = html;
|
|
3429
|
-
blockTags.forEach((tag) => {
|
|
3430
|
-
const regex = new RegExp(`<${tag}\\b[^>]*>[\\s\\S]*?<\\/${tag}>`, "g");
|
|
3431
|
-
output = output.replace(regex, (blockHtml) => {
|
|
3432
|
-
const matches = [...blockHtml.matchAll(/{{\s*([a-zA-Z0-9_.-]+)\[\]\.([a-zA-Z0-9_.-]+)\s*}}/g)];
|
|
3433
|
-
if (!matches.length) return blockHtml;
|
|
3434
|
-
const uniqueArrays = Array.from(new Set(matches.map((m) => m[1])));
|
|
3435
|
-
if (uniqueArrays.length !== 1) return blockHtml;
|
|
3436
|
-
const arrayName = uniqueArrays[0];
|
|
3437
|
-
const escapedArray = arrayName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3438
|
-
const cleanedBlock = blockHtml.replace(
|
|
3439
|
-
new RegExp(`{{\\s*${escapedArray}\\[\\]\\.([a-zA-Z0-9_.-]+)\\s*}}`, "g"),
|
|
3440
|
-
"{{$1}}"
|
|
3441
|
-
);
|
|
3442
|
-
return `{{#each ${arrayName}}}${cleanedBlock}{{/each}}`;
|
|
3443
|
-
});
|
|
3444
|
-
});
|
|
3445
|
-
return output;
|
|
3446
|
-
};
|
|
3447
|
-
|
|
3448
3448
|
// src/services/notification.service.ts
|
|
3449
3449
|
import merge from "lodash.merge";
|
|
3450
3450
|
var NotificationService = class {
|
|
@@ -3917,10 +3917,13 @@ var NotificationService = class {
|
|
|
3917
3917
|
if (it.ok && tpl.webHookUrl) {
|
|
3918
3918
|
const res = await fetch(tpl.webHookUrl, {
|
|
3919
3919
|
method: "POST",
|
|
3920
|
+
headers: {
|
|
3921
|
+
"Content-Type": "application/json"
|
|
3922
|
+
},
|
|
3920
3923
|
body: JSON.stringify({ id: deliveryItem.id })
|
|
3921
3924
|
});
|
|
3922
3925
|
if (!res.ok) {
|
|
3923
|
-
this.logger.error("[NotificationService] WhatsApp webhook failed", res.statusText);
|
|
3926
|
+
this.logger.error("[NotificationService] WhatsApp webhook failed", res.status, res.statusText);
|
|
3924
3927
|
}
|
|
3925
3928
|
}
|
|
3926
3929
|
}
|
|
@@ -4212,6 +4215,7 @@ export {
|
|
|
4212
4215
|
AuditProxy,
|
|
4213
4216
|
NotificationEmitter,
|
|
4214
4217
|
commonService,
|
|
4218
|
+
convertArrayPatternToEachBlocksGeneric,
|
|
4215
4219
|
customOmit,
|
|
4216
4220
|
findDifferences,
|
|
4217
4221
|
formatDatesDeep,
|
|
@@ -4222,6 +4226,8 @@ export {
|
|
|
4222
4226
|
getPattern,
|
|
4223
4227
|
interpolate,
|
|
4224
4228
|
objectTo2DArray,
|
|
4229
|
+
renderEmailTemplate,
|
|
4230
|
+
renderTemplate,
|
|
4225
4231
|
toNumberOrNull,
|
|
4226
4232
|
toUINConfigDTO,
|
|
4227
4233
|
uinConfigService
|