av6-core 1.7.18 → 1.8.1
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 +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +90 -12
- package/dist/index.mjs +89 -12
- package/dist/prisma-client.d.ts +28 -0
- package/package.json +2 -2
- package/scripts/prepare-prisma-types.mjs +26 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="./prisma-client.d.ts" />
|
|
1
2
|
import { JsonValue, Decimal, DecimalJsLike, InputJsonValue } from '@prisma/client/runtime/library';
|
|
2
3
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
4
|
import { AxiosResponse } from 'axios';
|
|
@@ -537,6 +538,10 @@ declare enum FlowType {
|
|
|
537
538
|
REFUND = 5
|
|
538
539
|
}
|
|
539
540
|
type StepType = "MIN_MAX" | "NORMAL";
|
|
541
|
+
declare enum ActionMode {
|
|
542
|
+
CONFIG_EVENT = "CONFIG_EVENT",
|
|
543
|
+
WEBHOOK = "WEBHOOK"
|
|
544
|
+
}
|
|
540
545
|
type ApprovalStep = {
|
|
541
546
|
id?: number;
|
|
542
547
|
flowId: number;
|
|
@@ -592,6 +597,10 @@ type ApprovalFlow = {
|
|
|
592
597
|
createdAt: Date;
|
|
593
598
|
updatedAt: Date;
|
|
594
599
|
flowType: FlowType;
|
|
600
|
+
actionType: ActionMode;
|
|
601
|
+
approveActionUrl: string | null;
|
|
602
|
+
rejectActionUrl: string | null;
|
|
603
|
+
partiallyApproveActionUrl: string | null;
|
|
595
604
|
};
|
|
596
605
|
type ApprovalAction = {
|
|
597
606
|
id: number;
|
|
@@ -1016,4 +1025,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
|
|
|
1016
1025
|
createAuditedService<T extends object>(serviceName: string, service: T): T;
|
|
1017
1026
|
}
|
|
1018
1027
|
|
|
1019
|
-
export { type ActInput, type ApprovalAction, type ApprovalActionDto, type ApprovalDeps, type ApprovalFlow, type ApprovalInstance, type ApprovalInstanceByUser, ApprovalService, ApprovalStatus, type ApprovalStep, type ApproverMapping, type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonApproveReq, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonGetApprovalActionReq, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateApprovalFlow, 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 EventInstance, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, FlowType, type FlowWithSelectedStepResponse, type FlowWithStepsResponse, type GetMyApprovalFlow, type GetPendingApprovalReq, type Helpers, type IApprovalStep, type IChildConfigData, type IChildConfigJSON, type ICommonApprovalUpdate, type IParentConfigData, type IParentConfigJSON, type ImportExcel, type ImportExcelRequestService, type LevelDoneEvt, type LevelReadyEvt, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type NotificationEvent, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type PrismaTransactionClient, type RawFlowWithSelectedStepResponse, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type StartFlowReq, type StepType, 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 UpdateApprovalFlow, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, approvalRepository, commonService, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
|
1028
|
+
export { type ActInput, ActionMode, type ApprovalAction, type ApprovalActionDto, type ApprovalDeps, type ApprovalFlow, type ApprovalInstance, type ApprovalInstanceByUser, ApprovalService, ApprovalStatus, type ApprovalStep, type ApproverMapping, type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonApproveReq, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonGetApprovalActionReq, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateApprovalFlow, 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 EventInstance, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, FlowType, type FlowWithSelectedStepResponse, type FlowWithStepsResponse, type GetMyApprovalFlow, type GetPendingApprovalReq, type Helpers, type IApprovalStep, type IChildConfigData, type IChildConfigJSON, type ICommonApprovalUpdate, type IParentConfigData, type IParentConfigJSON, type ImportExcel, type ImportExcelRequestService, type LevelDoneEvt, type LevelReadyEvt, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type NotificationEvent, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type PrismaTransactionClient, type RawFlowWithSelectedStepResponse, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type StartFlowReq, type StepType, 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 UpdateApprovalFlow, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, approvalRepository, 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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference path="./prisma-client.d.ts" />
|
|
1
2
|
import { JsonValue, Decimal, DecimalJsLike, InputJsonValue } from '@prisma/client/runtime/library';
|
|
2
3
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
4
|
import { AxiosResponse } from 'axios';
|
|
@@ -537,6 +538,10 @@ declare enum FlowType {
|
|
|
537
538
|
REFUND = 5
|
|
538
539
|
}
|
|
539
540
|
type StepType = "MIN_MAX" | "NORMAL";
|
|
541
|
+
declare enum ActionMode {
|
|
542
|
+
CONFIG_EVENT = "CONFIG_EVENT",
|
|
543
|
+
WEBHOOK = "WEBHOOK"
|
|
544
|
+
}
|
|
540
545
|
type ApprovalStep = {
|
|
541
546
|
id?: number;
|
|
542
547
|
flowId: number;
|
|
@@ -592,6 +597,10 @@ type ApprovalFlow = {
|
|
|
592
597
|
createdAt: Date;
|
|
593
598
|
updatedAt: Date;
|
|
594
599
|
flowType: FlowType;
|
|
600
|
+
actionType: ActionMode;
|
|
601
|
+
approveActionUrl: string | null;
|
|
602
|
+
rejectActionUrl: string | null;
|
|
603
|
+
partiallyApproveActionUrl: string | null;
|
|
595
604
|
};
|
|
596
605
|
type ApprovalAction = {
|
|
597
606
|
id: number;
|
|
@@ -1016,4 +1025,4 @@ declare class AuditProxy<Module extends string = "OPD" | "PROCEDURE" | "GENERAL_
|
|
|
1016
1025
|
createAuditedService<T extends object>(serviceName: string, service: T): T;
|
|
1017
1026
|
}
|
|
1018
1027
|
|
|
1019
|
-
export { type ActInput, type ApprovalAction, type ApprovalActionDto, type ApprovalDeps, type ApprovalFlow, type ApprovalInstance, type ApprovalInstanceByUser, ApprovalService, ApprovalStatus, type ApprovalStep, type ApproverMapping, type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonApproveReq, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonGetApprovalActionReq, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateApprovalFlow, 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 EventInstance, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, FlowType, type FlowWithSelectedStepResponse, type FlowWithStepsResponse, type GetMyApprovalFlow, type GetPendingApprovalReq, type Helpers, type IApprovalStep, type IChildConfigData, type IChildConfigJSON, type ICommonApprovalUpdate, type IParentConfigData, type IParentConfigJSON, type ImportExcel, type ImportExcelRequestService, type LevelDoneEvt, type LevelReadyEvt, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type NotificationEvent, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type PrismaTransactionClient, type RawFlowWithSelectedStepResponse, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type StartFlowReq, type StepType, 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 UpdateApprovalFlow, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, approvalRepository, commonService, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
|
1028
|
+
export { type ActInput, ActionMode, type ApprovalAction, type ApprovalActionDto, type ApprovalDeps, type ApprovalFlow, type ApprovalInstance, type ApprovalInstanceByUser, ApprovalService, ApprovalStatus, type ApprovalStep, type ApproverMapping, type AuditContext, type AuditContextProvider, AuditCore, type AuditLogPayload, AuditLogger, AuditProxy, type BulkAtomicResult, type BulkConfig, type BulkConflictConfig, type BulkOnConflict, type CacheAdapter, type CalculationRes, type ColValue, type CommonApproveReq, type CommonCreateRequestRepository, type CommonExcelRequest, type CommonFilterRequest, type CommonFilterWithDate, type CommonGetApprovalActionReq, type CommonServiceResponse, type CommonUpdateRequestRepository, type Config, type Context, type CreateApprovalFlow, 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 EventInstance, type ExcelConfig, type ExportExcel, type ExportExcelRequestService, type FetchRequest, type FetchRequestRepository, type FieldConfig, type FieldRules, type FieldType, type FixedMap, type FixedSearchRequest, type FixedSearchRequestService, FlowType, type FlowWithSelectedStepResponse, type FlowWithStepsResponse, type GetMyApprovalFlow, type GetPendingApprovalReq, type Helpers, type IApprovalStep, type IChildConfigData, type IChildConfigJSON, type ICommonApprovalUpdate, type IParentConfigData, type IParentConfigJSON, type ImportExcel, type ImportExcelRequestService, type LevelDoneEvt, type LevelReadyEvt, type LockUnlockParams, type LockUnlockRequestRepository, type LogicNode, type Mapper, type MergeAll, type NewFixedSearchRequest, type NewFixedSearchRequestService, type NewSearchRequest, NotificationEmitter, type NotificationEvent, type Op, type PaginatedResponse, type PathToSelectWithSelect, type PathValue, type PathsToSelectWithSelect, type Presence, type PrismaTransactionClient, type RawFlowWithSelectedStepResponse, type Recipient, type RelationConfig, type RelationStrategy, type RelationWriteConfig, type SearchRequest, type SearchRequestService, type ServiceCacheAdapter, type SingleValidationMapping, type SourcePath, type StartFlowReq, type StepType, 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 UpdateApprovalFlow, type UpdateConfigByCodeInput, type UpdateStatusRequestRepository, type UpdateUINConfigRequest, type ValidationErrorItem, approvalRepository, commonService, convertArrayPatternToEachBlocksGeneric, customOmit, findDifferences, formatDatesDeep, fromTimestampToSqlDatetime, getDynamicValue, getNestedValue, getNestedValueV2, getPattern, interpolate, objectTo2DArray, renderEmailTemplate, renderTemplate, toNumberOrNull, toUINConfigDTO, uinConfigService, type updateStatusParams };
|
package/dist/index.js
CHANGED
|
@@ -54,6 +54,7 @@ var require_default = __commonJS({
|
|
|
54
54
|
// src/index.ts
|
|
55
55
|
var index_exports = {};
|
|
56
56
|
__export(index_exports, {
|
|
57
|
+
ActionMode: () => ActionMode,
|
|
57
58
|
ApprovalService: () => ApprovalService,
|
|
58
59
|
ApprovalStatus: () => ApprovalStatus,
|
|
59
60
|
AuditCore: () => AuditCore,
|
|
@@ -2369,6 +2370,11 @@ var FlowType = /* @__PURE__ */ ((FlowType3) => {
|
|
|
2369
2370
|
FlowType3[FlowType3["REFUND"] = 5] = "REFUND";
|
|
2370
2371
|
return FlowType3;
|
|
2371
2372
|
})(FlowType || {});
|
|
2373
|
+
var ActionMode = /* @__PURE__ */ ((ActionMode2) => {
|
|
2374
|
+
ActionMode2["CONFIG_EVENT"] = "CONFIG_EVENT";
|
|
2375
|
+
ActionMode2["WEBHOOK"] = "WEBHOOK";
|
|
2376
|
+
return ActionMode2;
|
|
2377
|
+
})(ActionMode || {});
|
|
2372
2378
|
|
|
2373
2379
|
// src/repository/approval.repository.ts
|
|
2374
2380
|
var import_client = __toESM(require_default());
|
|
@@ -2610,7 +2616,16 @@ var ApprovalService = class {
|
|
|
2610
2616
|
status: newStatus
|
|
2611
2617
|
}
|
|
2612
2618
|
});
|
|
2613
|
-
setImmediate(
|
|
2619
|
+
setImmediate(
|
|
2620
|
+
() => this.emitEvents({
|
|
2621
|
+
instance: updated,
|
|
2622
|
+
flowType: inst.flow?.flowType,
|
|
2623
|
+
approverId,
|
|
2624
|
+
step,
|
|
2625
|
+
comment,
|
|
2626
|
+
approvalFlow: inst.flow
|
|
2627
|
+
})
|
|
2628
|
+
);
|
|
2614
2629
|
this.deps.eventBus.emit("approval:LEVEL_DONE", {
|
|
2615
2630
|
instanceId: inst.id,
|
|
2616
2631
|
level: step.level,
|
|
@@ -2693,17 +2708,79 @@ var ApprovalService = class {
|
|
|
2693
2708
|
// });
|
|
2694
2709
|
// }
|
|
2695
2710
|
// }
|
|
2696
|
-
emitEvents(
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2711
|
+
async emitEvents({
|
|
2712
|
+
instance,
|
|
2713
|
+
flowType,
|
|
2714
|
+
approverId,
|
|
2715
|
+
step,
|
|
2716
|
+
comment,
|
|
2717
|
+
approvalFlow
|
|
2718
|
+
}) {
|
|
2719
|
+
if (approvalFlow.actionType === "CONFIG_EVENT" /* CONFIG_EVENT */) {
|
|
2720
|
+
this.deps.eventBus.emit(`approval:${instance.status}`, {
|
|
2721
|
+
instanceId: instance.id,
|
|
2722
|
+
flowType,
|
|
2723
|
+
subjectId: instance.subjectId,
|
|
2724
|
+
approverId,
|
|
2725
|
+
step,
|
|
2726
|
+
comment,
|
|
2727
|
+
subjectType: instance.subjectType,
|
|
2728
|
+
service: instance.service
|
|
2729
|
+
});
|
|
2730
|
+
} else {
|
|
2731
|
+
switch (instance.status) {
|
|
2732
|
+
case 2 /* APPROVED */:
|
|
2733
|
+
if (approvalFlow.approveActionUrl) {
|
|
2734
|
+
const res = await fetch(approvalFlow.approveActionUrl, {
|
|
2735
|
+
method: "POST",
|
|
2736
|
+
headers: {
|
|
2737
|
+
"Content-Type": "application/json"
|
|
2738
|
+
},
|
|
2739
|
+
body: JSON.stringify({ id: instance.id, subjectId: instance.subjectId })
|
|
2740
|
+
});
|
|
2741
|
+
if (!res.ok) {
|
|
2742
|
+
this.deps.logger.error(
|
|
2743
|
+
"[Approval Service] Approve action URL webhook failed",
|
|
2744
|
+
res.status,
|
|
2745
|
+
res.statusText
|
|
2746
|
+
);
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
break;
|
|
2750
|
+
case 3 /* REJECTED */:
|
|
2751
|
+
if (approvalFlow.rejectActionUrl) {
|
|
2752
|
+
const res = await fetch(approvalFlow.rejectActionUrl, {
|
|
2753
|
+
method: "POST",
|
|
2754
|
+
headers: {
|
|
2755
|
+
"Content-Type": "application/json"
|
|
2756
|
+
}
|
|
2757
|
+
});
|
|
2758
|
+
if (!res.ok) {
|
|
2759
|
+
this.deps.logger.error("[Approval Service] Reject action URL webhook failed", res.status, res.statusText);
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
break;
|
|
2763
|
+
case 1 /* PARTIALLY_APPROVED */:
|
|
2764
|
+
if (approvalFlow.partiallyApproveActionUrl) {
|
|
2765
|
+
const res = await fetch(approvalFlow.partiallyApproveActionUrl, {
|
|
2766
|
+
method: "POST",
|
|
2767
|
+
headers: {
|
|
2768
|
+
"Content-Type": "application/json"
|
|
2769
|
+
}
|
|
2770
|
+
});
|
|
2771
|
+
if (!res.ok) {
|
|
2772
|
+
this.deps.logger.error(
|
|
2773
|
+
"[Approval Service] Partially approve action URL webhook failed",
|
|
2774
|
+
res.status,
|
|
2775
|
+
res.statusText
|
|
2776
|
+
);
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
break;
|
|
2780
|
+
default:
|
|
2781
|
+
break;
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2707
2784
|
}
|
|
2708
2785
|
async assertPermission(step, approverId, instanceId, ccId, tx) {
|
|
2709
2786
|
const result = await tx.$queryRaw(`
|
|
@@ -4813,6 +4890,7 @@ var AuditProxy = class {
|
|
|
4813
4890
|
};
|
|
4814
4891
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4815
4892
|
0 && (module.exports = {
|
|
4893
|
+
ActionMode,
|
|
4816
4894
|
ApprovalService,
|
|
4817
4895
|
ApprovalStatus,
|
|
4818
4896
|
AuditCore,
|
package/dist/index.mjs
CHANGED
|
@@ -2342,6 +2342,11 @@ var FlowType = /* @__PURE__ */ ((FlowType3) => {
|
|
|
2342
2342
|
FlowType3[FlowType3["REFUND"] = 5] = "REFUND";
|
|
2343
2343
|
return FlowType3;
|
|
2344
2344
|
})(FlowType || {});
|
|
2345
|
+
var ActionMode = /* @__PURE__ */ ((ActionMode2) => {
|
|
2346
|
+
ActionMode2["CONFIG_EVENT"] = "CONFIG_EVENT";
|
|
2347
|
+
ActionMode2["WEBHOOK"] = "WEBHOOK";
|
|
2348
|
+
return ActionMode2;
|
|
2349
|
+
})(ActionMode || {});
|
|
2345
2350
|
|
|
2346
2351
|
// src/repository/approval.repository.ts
|
|
2347
2352
|
var import_client = __toESM(require_default());
|
|
@@ -2583,7 +2588,16 @@ var ApprovalService = class {
|
|
|
2583
2588
|
status: newStatus
|
|
2584
2589
|
}
|
|
2585
2590
|
});
|
|
2586
|
-
setImmediate(
|
|
2591
|
+
setImmediate(
|
|
2592
|
+
() => this.emitEvents({
|
|
2593
|
+
instance: updated,
|
|
2594
|
+
flowType: inst.flow?.flowType,
|
|
2595
|
+
approverId,
|
|
2596
|
+
step,
|
|
2597
|
+
comment,
|
|
2598
|
+
approvalFlow: inst.flow
|
|
2599
|
+
})
|
|
2600
|
+
);
|
|
2587
2601
|
this.deps.eventBus.emit("approval:LEVEL_DONE", {
|
|
2588
2602
|
instanceId: inst.id,
|
|
2589
2603
|
level: step.level,
|
|
@@ -2666,17 +2680,79 @@ var ApprovalService = class {
|
|
|
2666
2680
|
// });
|
|
2667
2681
|
// }
|
|
2668
2682
|
// }
|
|
2669
|
-
emitEvents(
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2683
|
+
async emitEvents({
|
|
2684
|
+
instance,
|
|
2685
|
+
flowType,
|
|
2686
|
+
approverId,
|
|
2687
|
+
step,
|
|
2688
|
+
comment,
|
|
2689
|
+
approvalFlow
|
|
2690
|
+
}) {
|
|
2691
|
+
if (approvalFlow.actionType === "CONFIG_EVENT" /* CONFIG_EVENT */) {
|
|
2692
|
+
this.deps.eventBus.emit(`approval:${instance.status}`, {
|
|
2693
|
+
instanceId: instance.id,
|
|
2694
|
+
flowType,
|
|
2695
|
+
subjectId: instance.subjectId,
|
|
2696
|
+
approverId,
|
|
2697
|
+
step,
|
|
2698
|
+
comment,
|
|
2699
|
+
subjectType: instance.subjectType,
|
|
2700
|
+
service: instance.service
|
|
2701
|
+
});
|
|
2702
|
+
} else {
|
|
2703
|
+
switch (instance.status) {
|
|
2704
|
+
case 2 /* APPROVED */:
|
|
2705
|
+
if (approvalFlow.approveActionUrl) {
|
|
2706
|
+
const res = await fetch(approvalFlow.approveActionUrl, {
|
|
2707
|
+
method: "POST",
|
|
2708
|
+
headers: {
|
|
2709
|
+
"Content-Type": "application/json"
|
|
2710
|
+
},
|
|
2711
|
+
body: JSON.stringify({ id: instance.id, subjectId: instance.subjectId })
|
|
2712
|
+
});
|
|
2713
|
+
if (!res.ok) {
|
|
2714
|
+
this.deps.logger.error(
|
|
2715
|
+
"[Approval Service] Approve action URL webhook failed",
|
|
2716
|
+
res.status,
|
|
2717
|
+
res.statusText
|
|
2718
|
+
);
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
break;
|
|
2722
|
+
case 3 /* REJECTED */:
|
|
2723
|
+
if (approvalFlow.rejectActionUrl) {
|
|
2724
|
+
const res = await fetch(approvalFlow.rejectActionUrl, {
|
|
2725
|
+
method: "POST",
|
|
2726
|
+
headers: {
|
|
2727
|
+
"Content-Type": "application/json"
|
|
2728
|
+
}
|
|
2729
|
+
});
|
|
2730
|
+
if (!res.ok) {
|
|
2731
|
+
this.deps.logger.error("[Approval Service] Reject action URL webhook failed", res.status, res.statusText);
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
break;
|
|
2735
|
+
case 1 /* PARTIALLY_APPROVED */:
|
|
2736
|
+
if (approvalFlow.partiallyApproveActionUrl) {
|
|
2737
|
+
const res = await fetch(approvalFlow.partiallyApproveActionUrl, {
|
|
2738
|
+
method: "POST",
|
|
2739
|
+
headers: {
|
|
2740
|
+
"Content-Type": "application/json"
|
|
2741
|
+
}
|
|
2742
|
+
});
|
|
2743
|
+
if (!res.ok) {
|
|
2744
|
+
this.deps.logger.error(
|
|
2745
|
+
"[Approval Service] Partially approve action URL webhook failed",
|
|
2746
|
+
res.status,
|
|
2747
|
+
res.statusText
|
|
2748
|
+
);
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
break;
|
|
2752
|
+
default:
|
|
2753
|
+
break;
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2680
2756
|
}
|
|
2681
2757
|
async assertPermission(step, approverId, instanceId, ccId, tx) {
|
|
2682
2758
|
const result = await tx.$queryRaw(`
|
|
@@ -4785,6 +4861,7 @@ var AuditProxy = class {
|
|
|
4785
4861
|
}
|
|
4786
4862
|
};
|
|
4787
4863
|
export {
|
|
4864
|
+
ActionMode,
|
|
4788
4865
|
ApprovalService,
|
|
4789
4866
|
ApprovalStatus,
|
|
4790
4867
|
AuditCore,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare module "@prisma/client" {
|
|
2
|
+
export class PrismaClient {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export namespace Prisma {
|
|
7
|
+
export type TransactionClient = any;
|
|
8
|
+
export type JsonValue = any;
|
|
9
|
+
export type JsonObject = any;
|
|
10
|
+
export type JsonArray = any;
|
|
11
|
+
|
|
12
|
+
export interface Sql {
|
|
13
|
+
readonly values: unknown[];
|
|
14
|
+
readonly strings: string[];
|
|
15
|
+
readonly sql: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const empty: Sql;
|
|
19
|
+
export function sql(strings: readonly string[], ...values: unknown[]): Sql;
|
|
20
|
+
export function join(
|
|
21
|
+
values: readonly unknown[],
|
|
22
|
+
separator?: string,
|
|
23
|
+
prefix?: string,
|
|
24
|
+
suffix?: string
|
|
25
|
+
): Sql;
|
|
26
|
+
export function raw(value: string): Sql;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "av6-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"author": "Aniket Sarkar",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "npm run format && tsup",
|
|
11
|
+
"build": "npm run format && tsup && node scripts/prepare-prisma-types.mjs",
|
|
12
12
|
"p:gen": "prisma generate",
|
|
13
13
|
"format": "prettier --write **/*.ts"
|
|
14
14
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
const rootDir = dirname(fileURLToPath(new URL("../package.json", import.meta.url)));
|
|
6
|
+
const distDir = join(rootDir, "dist");
|
|
7
|
+
const sourceShim = join(rootDir, "prisma-client.d.ts");
|
|
8
|
+
const distShim = join(distDir, "prisma-client.d.ts");
|
|
9
|
+
const reference = '/// <reference path="./prisma-client.d.ts" />\n';
|
|
10
|
+
|
|
11
|
+
mkdirSync(distDir, { recursive: true });
|
|
12
|
+
copyFileSync(sourceShim, distShim);
|
|
13
|
+
|
|
14
|
+
for (const fileName of ["index.d.ts", "index.d.mts"]) {
|
|
15
|
+
const declarationPath = join(distDir, fileName);
|
|
16
|
+
|
|
17
|
+
if (!existsSync(declarationPath)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const declaration = readFileSync(declarationPath, "utf8");
|
|
22
|
+
|
|
23
|
+
if (!declaration.startsWith(reference)) {
|
|
24
|
+
writeFileSync(declarationPath, `${reference}${declaration}`);
|
|
25
|
+
}
|
|
26
|
+
}
|