@persei/perseed-api 5.0.21 → 5.0.23
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/client.cjs +678 -37
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +678 -37
- package/dist/client.mjs.map +1 -1
- package/dist/{lib-CDM5aEJG.cjs → dates.helper-CDM5aEJG.cjs} +1 -1
- package/dist/dates.helper-CDM5aEJG.cjs.map +1 -0
- package/dist/{lib-XRCJ_UAQ.js → dates.helper-XRCJ_UAQ.js} +1 -1
- package/dist/dates.helper-XRCJ_UAQ.js.map +1 -0
- package/dist/ecosystem-action-system.cjs +42 -32
- package/dist/ecosystem-action-system.cjs.map +1 -1
- package/dist/ecosystem-action-system.mjs +42 -32
- package/dist/ecosystem-action-system.mjs.map +1 -1
- package/dist/ecosystem-container-widget.cjs +6 -6
- package/dist/ecosystem-container-widget.cjs.map +1 -1
- package/dist/ecosystem-container-widget.mjs +1 -1
- package/dist/global-dates.cjs +9 -3
- package/dist/global-dates.cjs.map +1 -1
- package/dist/global-dates.mjs +7 -1
- package/dist/global-dates.mjs.map +1 -1
- package/dist/lib/src/generated/client.d.ts +5338 -879
- package/dist/lib/src/generated/client.d.ts.map +1 -1
- package/dist/src/Services/TriggerService.d.ts.map +1 -1
- package/dist/src/config/apiPublicKey.d.ts +19 -4
- package/dist/src/config/apiPublicKey.d.ts.map +1 -1
- package/dist/src/config/apiPublicKey.test.d.ts +2 -0
- package/dist/src/config/apiPublicKey.test.d.ts.map +1 -0
- package/dist/src/constants/SeedPrivilege.d.ts +1 -0
- package/dist/src/constants/SeedPrivilege.d.ts.map +1 -1
- package/dist/src/controllers/IntrospectionController.d.ts.map +1 -1
- package/dist/src/controllers/UserController.d.ts.map +1 -1
- package/dist/src/schemas/container_widget/create_widget_payload.schema.json +1 -1
- package/dist/src/schemas/container_widget/update_widget_payload.schema.json +1 -1
- package/dist/src/schemas/container_widget/widgetTypes/PatientListProps.d.ts +2 -1
- package/dist/src/schemas/container_widget/widgetTypes/PatientListProps.d.ts.map +1 -1
- package/dist/src/test/e2e-permissions.d.ts +32 -3
- package/dist/src/test/e2e-permissions.d.ts.map +1 -1
- package/dist/src/test/test-helpers.d.ts +12 -0
- package/dist/src/test/test-helpers.d.ts.map +1 -1
- package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/action-system.helper.d.ts +1 -1
- package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/action-system.helper.d.ts.map +1 -1
- package/dist/src/v2/modules/ecosystem/action-system/action-system.helper/manual-trigger.helper.d.ts.map +1 -1
- package/dist/src/v2/modules/ecosystem/action-system/action-system.model.d.ts +5 -2
- package/dist/src/v2/modules/ecosystem/action-system/action-system.model.d.ts.map +1 -1
- package/dist/src/v2/modules/ecosystem/action-system/action-system.model.test.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/action-system/action-system.model.test.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/action-system/action-system.schema.d.ts +69 -58
- package/dist/src/v2/modules/ecosystem/action-system/action-system.schema.d.ts.map +1 -1
- package/dist/src/v2/modules/ecosystem/action-system/action-system.service/automatic-trigger.service.d.ts +14 -6
- package/dist/src/v2/modules/ecosystem/action-system/action-system.service/automatic-trigger.service.d.ts.map +1 -1
- package/dist/src/v2/modules/ecosystem/action-system/action-system.service/manual-trigger.service.d.ts +18 -10
- package/dist/src/v2/modules/ecosystem/action-system/action-system.service/manual-trigger.service.d.ts.map +1 -1
- package/dist/src/v2/modules/ecosystem/action-system/action-system.service/trigger-engine.service.d.ts +1 -0
- package/dist/src/v2/modules/ecosystem/action-system/action-system.service/trigger-engine.service.d.ts.map +1 -1
- package/dist/src/v2/modules/ecosystem/alert/alert.controller.d.ts +12 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.controller.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.controller.e2e.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.controller.e2e.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.controller.test.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.controller.test.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.helper.d.ts +55 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.helper.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.helper.test.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.helper.test.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.model.d.ts +61 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.model.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.model.test.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.model.test.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.schema.d.ts +134 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.schema.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.service.d.ts +73 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.service.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.service.test.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert/alert.service.test.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert/index.d.ts +7 -0
- package/dist/src/v2/modules/ecosystem/alert/index.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.controller.d.ts +6 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.controller.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.controller.e2e.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.controller.e2e.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.controller.test.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.controller.test.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.helper.d.ts +14 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.helper.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.helper.test.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.helper.test.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.model.d.ts +18 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.model.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.schema.d.ts +29 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.schema.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.service.d.ts +38 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.service.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.service.test.d.ts +2 -0
- package/dist/src/v2/modules/ecosystem/alert-type/alert-type.service.test.d.ts.map +1 -0
- package/dist/src/v2/modules/ecosystem/alert-type/index.d.ts +6 -0
- package/dist/src/v2/modules/ecosystem/alert-type/index.d.ts.map +1 -0
- package/dist/src/v2/modules/global/auth-token/auth-token.controller.d.ts.map +1 -1
- package/dist/src/v2/modules/global/dates/dates.helper.d.ts.map +1 -1
- package/dist/src/v2/modules/global/dates/dates.schema.d.ts +39 -0
- package/dist/src/v2/modules/global/dates/dates.schema.d.ts.map +1 -1
- package/dist/src/v2/modules/global/permissions/index.d.ts +2 -0
- package/dist/src/v2/modules/global/permissions/index.d.ts.map +1 -0
- package/dist/src/v2/modules/global/permissions/permissions.helper.d.ts +32 -0
- package/dist/src/v2/modules/global/permissions/permissions.helper.d.ts.map +1 -0
- package/dist/src/v2/modules/global/permissions/permissions.helper.test.d.ts +2 -0
- package/dist/src/v2/modules/global/permissions/permissions.helper.test.d.ts.map +1 -0
- package/dist/src/v2/routes/v2/ecosystem/_ecosystemName/alert/index.d.ts +3 -0
- package/dist/src/v2/routes/v2/ecosystem/_ecosystemName/alert/index.d.ts.map +1 -0
- package/dist/src/v2/routes/v2/ecosystem/_ecosystemName/alert-type/index.d.ts +3 -0
- package/dist/src/v2/routes/v2/ecosystem/_ecosystemName/alert-type/index.d.ts.map +1 -0
- package/dist/src/v2/routes/v2/ecosystem/_ecosystemName/project/_projectName/alert/index.d.ts +3 -0
- package/dist/src/v2/routes/v2/ecosystem/_ecosystemName/project/_projectName/alert/index.d.ts.map +1 -0
- package/dist/v1/perseed-api.cjs +2 -0
- package/dist/v1/perseed-api.cjs.map +1 -1
- package/dist/v1/perseed-api.mjs +2 -0
- package/dist/v1/perseed-api.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/lib-CDM5aEJG.cjs.map +0 -1
- package/dist/lib-XRCJ_UAQ.js.map +0 -1
- package/dist/src/test/global-setup.d.ts +0 -2
- package/dist/src/test/global-setup.d.ts.map +0 -1
|
@@ -5,6 +5,8 @@ import { CreateManualTriggerData, UpdateManualTriggerData } from '../action-syst
|
|
|
5
5
|
declare function listManualTriggers(ctx: RequestContext, pagination: PaginatedQuery, includeActions?: boolean): Promise<import('objection').Page<ManualTrigger> | {
|
|
6
6
|
results: ({
|
|
7
7
|
enabled?: boolean | undefined;
|
|
8
|
+
name?: string | null | undefined;
|
|
9
|
+
description?: string | null | undefined;
|
|
8
10
|
project_id?: number | null | undefined;
|
|
9
11
|
conditions?: object | null | undefined;
|
|
10
12
|
config?: {
|
|
@@ -12,6 +14,7 @@ declare function listManualTriggers(ctx: RequestContext, pagination: PaginatedQu
|
|
|
12
14
|
styles?: {
|
|
13
15
|
text?: string | undefined;
|
|
14
16
|
icon?: string | undefined;
|
|
17
|
+
tooltip?: string | undefined;
|
|
15
18
|
textColor?: string | undefined;
|
|
16
19
|
bgColor?: string | undefined;
|
|
17
20
|
iconPosition?: "left" | "right" | undefined;
|
|
@@ -19,6 +22,7 @@ declare function listManualTriggers(ctx: RequestContext, pagination: PaginatedQu
|
|
|
19
22
|
conditionalStyles?: ({
|
|
20
23
|
text?: string | undefined;
|
|
21
24
|
icon?: string | undefined;
|
|
25
|
+
tooltip?: string | undefined;
|
|
22
26
|
textColor?: string | undefined;
|
|
23
27
|
bgColor?: string | undefined;
|
|
24
28
|
iconPosition?: "left" | "right" | undefined;
|
|
@@ -32,17 +36,16 @@ declare function listManualTriggers(ctx: RequestContext, pagination: PaginatedQu
|
|
|
32
36
|
join?: string[] | undefined;
|
|
33
37
|
} | null | undefined;
|
|
34
38
|
id: number;
|
|
35
|
-
name: string;
|
|
36
39
|
target: string;
|
|
37
|
-
source: "model" | "
|
|
40
|
+
source: "model" | "displayer";
|
|
38
41
|
} & {
|
|
39
42
|
actions?: {
|
|
43
|
+
name?: string | null | undefined;
|
|
40
44
|
project_id?: number | null | undefined;
|
|
41
45
|
retention_days?: number | null | undefined;
|
|
42
46
|
library?: boolean | undefined;
|
|
43
47
|
id: number;
|
|
44
48
|
type: "ApiAction";
|
|
45
|
-
name: string;
|
|
46
49
|
config: {
|
|
47
50
|
default?: Record<string, unknown> | undefined;
|
|
48
51
|
location?: string | undefined;
|
|
@@ -57,6 +60,8 @@ declare function listManualTriggers(ctx: RequestContext, pagination: PaginatedQu
|
|
|
57
60
|
}>;
|
|
58
61
|
declare function getManualTriggerById(ctx: RequestContext, id: number, includeActions?: boolean): Promise<({
|
|
59
62
|
enabled?: boolean | undefined;
|
|
63
|
+
name?: string | null | undefined;
|
|
64
|
+
description?: string | null | undefined;
|
|
60
65
|
project_id?: number | null | undefined;
|
|
61
66
|
conditions?: object | null | undefined;
|
|
62
67
|
config?: {
|
|
@@ -64,6 +69,7 @@ declare function getManualTriggerById(ctx: RequestContext, id: number, includeAc
|
|
|
64
69
|
styles?: {
|
|
65
70
|
text?: string | undefined;
|
|
66
71
|
icon?: string | undefined;
|
|
72
|
+
tooltip?: string | undefined;
|
|
67
73
|
textColor?: string | undefined;
|
|
68
74
|
bgColor?: string | undefined;
|
|
69
75
|
iconPosition?: "left" | "right" | undefined;
|
|
@@ -71,6 +77,7 @@ declare function getManualTriggerById(ctx: RequestContext, id: number, includeAc
|
|
|
71
77
|
conditionalStyles?: ({
|
|
72
78
|
text?: string | undefined;
|
|
73
79
|
icon?: string | undefined;
|
|
80
|
+
tooltip?: string | undefined;
|
|
74
81
|
textColor?: string | undefined;
|
|
75
82
|
bgColor?: string | undefined;
|
|
76
83
|
iconPosition?: "left" | "right" | undefined;
|
|
@@ -84,17 +91,16 @@ declare function getManualTriggerById(ctx: RequestContext, id: number, includeAc
|
|
|
84
91
|
join?: string[] | undefined;
|
|
85
92
|
} | null | undefined;
|
|
86
93
|
id: number;
|
|
87
|
-
name: string;
|
|
88
94
|
target: string;
|
|
89
|
-
source: "model" | "
|
|
95
|
+
source: "model" | "displayer";
|
|
90
96
|
} & {
|
|
91
97
|
actions?: {
|
|
98
|
+
name?: string | null | undefined;
|
|
92
99
|
project_id?: number | null | undefined;
|
|
93
100
|
retention_days?: number | null | undefined;
|
|
94
101
|
library?: boolean | undefined;
|
|
95
102
|
id: number;
|
|
96
103
|
type: "ApiAction";
|
|
97
|
-
name: string;
|
|
98
104
|
config: {
|
|
99
105
|
default?: Record<string, unknown> | undefined;
|
|
100
106
|
location?: string | undefined;
|
|
@@ -107,12 +113,12 @@ declare function getManualTriggerById(ctx: RequestContext, id: number, includeAc
|
|
|
107
113
|
}) | ManualTrigger | undefined>;
|
|
108
114
|
declare function createManualTrigger(ctx: RequestContext, data: CreateManualTriggerData): Promise<ManualTrigger | {
|
|
109
115
|
actions: {
|
|
116
|
+
name?: string | null | undefined;
|
|
110
117
|
project_id?: number | null | undefined;
|
|
111
118
|
retention_days?: number | null | undefined;
|
|
112
119
|
library?: boolean | undefined;
|
|
113
120
|
id: number;
|
|
114
121
|
type: "ApiAction";
|
|
115
|
-
name: string;
|
|
116
122
|
config: {
|
|
117
123
|
default?: Record<string, unknown> | undefined;
|
|
118
124
|
location?: string | undefined;
|
|
@@ -123,7 +129,8 @@ declare function createManualTrigger(ctx: RequestContext, data: CreateManualTrig
|
|
|
123
129
|
};
|
|
124
130
|
}[];
|
|
125
131
|
project_id?: number | null;
|
|
126
|
-
name
|
|
132
|
+
name?: string | null;
|
|
133
|
+
description?: string | null;
|
|
127
134
|
source: import('../action-system.schema').TriggerSource;
|
|
128
135
|
target: string;
|
|
129
136
|
conditions?: object | null;
|
|
@@ -138,12 +145,12 @@ declare function createManualTrigger(ctx: RequestContext, data: CreateManualTrig
|
|
|
138
145
|
}>;
|
|
139
146
|
declare function updateManualTrigger(ctx: RequestContext, id: number, data: UpdateManualTriggerData): Promise<ManualTrigger | {
|
|
140
147
|
actions: {
|
|
148
|
+
name?: string | null | undefined;
|
|
141
149
|
project_id?: number | null | undefined;
|
|
142
150
|
retention_days?: number | null | undefined;
|
|
143
151
|
library?: boolean | undefined;
|
|
144
152
|
id: number;
|
|
145
153
|
type: "ApiAction";
|
|
146
|
-
name: string;
|
|
147
154
|
config: {
|
|
148
155
|
default?: Record<string, unknown> | undefined;
|
|
149
156
|
location?: string | undefined;
|
|
@@ -154,7 +161,8 @@ declare function updateManualTrigger(ctx: RequestContext, id: number, data: Upda
|
|
|
154
161
|
};
|
|
155
162
|
}[];
|
|
156
163
|
project_id?: number | null;
|
|
157
|
-
name
|
|
164
|
+
name?: string | null;
|
|
165
|
+
description?: string | null;
|
|
158
166
|
source: import('../action-system.schema').TriggerSource;
|
|
159
167
|
target: string;
|
|
160
168
|
conditions?: object | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manual-trigger.service.d.ts","sourceRoot":"","sources":["../../../../../../../../src/v2/modules/ecosystem/action-system/action-system.service/manual-trigger.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAiB,MAAM,6BAA6B,CAAA;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EACV,uBAAuB,EAEvB,uBAAuB,EACxB,MAAM,yBAAyB,CAAA;AAiBhC,iBAAe,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,UAAQ
|
|
1
|
+
{"version":3,"file":"manual-trigger.service.d.ts","sourceRoot":"","sources":["../../../../../../../../src/v2/modules/ecosystem/action-system/action-system.service/manual-trigger.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAiB,MAAM,6BAA6B,CAAA;AAG3E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EACV,uBAAuB,EAEvB,uBAAuB,EACxB,MAAM,yBAAyB,CAAA;AAiBhC,iBAAe,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,UAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAWxG;AAED,iBAAe,oBAAoB,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,cAAc,UAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAW1F;AAID,iBAAe,mBAAmB,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsBpF;AAyBD,iBAAe,mBAAmB,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqBhG;AAED,iBAAe,mBAAmB,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,oBAEjE;AAED,eAAO,MAAM,oBAAoB;;;;;;CAMhC,CAAA"}
|
|
@@ -36,6 +36,7 @@ export declare function evaluateConditions(context: ApiActionContextData, trigge
|
|
|
36
36
|
export declare function executeTriggerActions(ctx: RequestContext, trigger: EvaluableTrigger, context: ApiActionContextData, now: Date): Promise<{
|
|
37
37
|
actionsRun: number;
|
|
38
38
|
actionsAborted: number;
|
|
39
|
+
actionsFailed: number;
|
|
39
40
|
}>;
|
|
40
41
|
/**
|
|
41
42
|
* Runs a batch of already-resolved trigger candidates: per trigger, assembles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-engine.service.d.ts","sourceRoot":"","sources":["../../../../../../../../src/v2/modules/ecosystem/action-system/action-system.service/trigger-engine.service.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,mCAAmC,CAAA;AAI9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAGjF,OAAO,EAKL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAA;AAoBhC;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACnC,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAClC,OAAO,CAAC;IAAE,OAAO,EAAE,oBAAoB,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAavE;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,YAAY,CAAC,GACnD,OAAO,CAAC,OAAO,CAAC,CAIlB;
|
|
1
|
+
{"version":3,"file":"trigger-engine.service.d.ts","sourceRoot":"","sources":["../../../../../../../../src/v2/modules/ecosystem/action-system/action-system.service/trigger-engine.service.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,mCAAmC,CAAA;AAI9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAGjF,OAAO,EAKL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,yBAAyB,CAAA;AAoBhC;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACnC,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAClC,OAAO,CAAC;IAAE,OAAO,EAAE,oBAAoB,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAavE;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,GAAG,YAAY,CAAC,GACnD,OAAO,CAAC,OAAO,CAAC,CAIlB;AAgDD;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,oBAAoB,EAC7B,GAAG,EAAE,IAAI,GACR,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,CAkDhF;AAID;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,cAAc,EACnB,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,IAAI,GACR,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAsDnC;AAED,eAAO,MAAM,oBAAoB;;;;;CAKhC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';
|
|
2
|
+
/**
|
|
3
|
+
* Suffix of every ecosystem-level name, as a constant rather than a literal in `ECOSYSTEM_LEVEL`:
|
|
4
|
+
* a second ecosystem-mounted resource has to carry the same word for the generated client to read
|
|
5
|
+
* as one family, and a constant is what makes that a reference instead of a convention to remember.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ECOSYSTEM_OPERATION_SUFFIX = "Ecosystem";
|
|
8
|
+
export declare const AlertController: {
|
|
9
|
+
alertRouter: FastifyPluginAsyncTypebox;
|
|
10
|
+
ecosystemAlertRouter: FastifyPluginAsyncTypebox;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=alert.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.controller.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAiD1E;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,cAAc,CAAA;AAqJrD,eAAO,MAAM,eAAe;;;CAG3B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.controller.e2e.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.controller.e2e.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.controller.test.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.controller.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { default as RequestContext } from '../../../../models/request/RequestContext';
|
|
2
|
+
/**
|
|
3
|
+
* Permission preHandler of the write endpoints of this module (create, update, resolve). Reads go
|
|
4
|
+
* through `resolveAlertReadScope` instead, which narrows what is returned rather than refusing.
|
|
5
|
+
*
|
|
6
|
+
* `alerts_management` is its own privilege rather than a reuse of `triggers_management`: managing
|
|
7
|
+
* the rules that fire and managing the alerts they raise are different jobs given to different
|
|
8
|
+
* profiles. Without the privilege row, `checkPermission` matches nothing and every endpoint answers
|
|
9
|
+
* 403 for everyone.
|
|
10
|
+
*
|
|
11
|
+
* The administrator role stands in for the privilege on both mounts, the same way
|
|
12
|
+
* `requireTriggersManagement` does it: seed privileges are granted per profiling and a profiling
|
|
13
|
+
* belongs to a project, so an administrator — who has no profiling row there — could never be given
|
|
14
|
+
* this one. See `hasPrivilege` for the full argument.
|
|
15
|
+
*/
|
|
16
|
+
export declare const requireAlertsManagement: (req: import('fastify').FastifyRequest) => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* How much of the alerts in reach the caller may read.
|
|
19
|
+
*
|
|
20
|
+
* `null` means all of them — the caller manages alerts, so narrowing would hide rows from their own
|
|
21
|
+
* guard. Otherwise the reach is the union of the two things that make someone party to an alert:
|
|
22
|
+
* being its `user_id`, or having access to its `patient_id`.
|
|
23
|
+
*/
|
|
24
|
+
export interface AlertReadScope {
|
|
25
|
+
/** Alerts whose `user_id` is this user. Always the caller. */
|
|
26
|
+
ownUserId: number;
|
|
27
|
+
/**
|
|
28
|
+
* Alerts whose `patient_id` is one of these — the patients the caller has access to. Empty when
|
|
29
|
+
* the caller reaches no patient, and at the ecosystem level, where there is no project to resolve
|
|
30
|
+
* patients against.
|
|
31
|
+
*/
|
|
32
|
+
patientIds: number[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolves what the caller may read, instead of refusing outright as the write endpoints do.
|
|
36
|
+
*
|
|
37
|
+
* Two levels: a caller who manages alerts reads everything in reach; anyone else reads the alerts
|
|
38
|
+
* they are the `user_id` of, plus the alerts about a patient they have access to.
|
|
39
|
+
*
|
|
40
|
+
* There is no third level for "no user on the context": the request never reaches a handler in that
|
|
41
|
+
* state. `authProtectedHook` refuses a request with no token, and a token that resolves no user for
|
|
42
|
+
* the ecosystem of the URL is refused by `validateParams` with `no-user-for-ecosystem`; the project
|
|
43
|
+
* mount adds `checkProjectAccess` on top. `hasPrivilege` reads the user with `getUser(false)` and so
|
|
44
|
+
* answers `false` rather than throwing, which leaves `ctx.getUserId()` as the one place that would
|
|
45
|
+
* notice — and it is unreachable for the same reason.
|
|
46
|
+
*
|
|
47
|
+
* The two halves are a union and not a branch on whether the caller is a professional: a person can
|
|
48
|
+
* be both the subject of an alert and the clinician of another patient, and choosing one of the two
|
|
49
|
+
* would hide the other set from them.
|
|
50
|
+
*
|
|
51
|
+
* Returning a scope rather than filtering here keeps the decision (who may see what) apart from the
|
|
52
|
+
* query that enforces it (`alert.service.ts`), so each can be tested without the other.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveAlertReadScope(ctx: RequestContext): Promise<AlertReadScope | null>;
|
|
55
|
+
//# sourceMappingURL=alert.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.helper.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAA;AAKnE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,0DAGnC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAsBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAO/F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.helper.test.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.helper.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { default as Objection } from 'objection';
|
|
2
|
+
import { default as BaseModel } from '../../../../models/BaseModel';
|
|
3
|
+
import { default as RequestContext } from '../../../../models/request/RequestContext';
|
|
4
|
+
import { TypedQueryBuilder } from '../../global/objection';
|
|
5
|
+
import { AlertData, AlertEmitterData, AlertEntityRefData, AlertSeverity, AlertStatus } from './alert.schema';
|
|
6
|
+
export declare class Alert extends BaseModel implements AlertData {
|
|
7
|
+
project_id?: number | null;
|
|
8
|
+
alert_type_id?: number | null;
|
|
9
|
+
user_id?: number | null;
|
|
10
|
+
patient_id?: number | null;
|
|
11
|
+
severity?: AlertSeverity | null;
|
|
12
|
+
status?: AlertStatus;
|
|
13
|
+
title?: string | null;
|
|
14
|
+
summary?: string | null;
|
|
15
|
+
emitter: AlertEmitterData;
|
|
16
|
+
recipients?: AlertEntityRefData[] | null;
|
|
17
|
+
related_entities?: AlertEntityRefData[] | null;
|
|
18
|
+
payload?: Record<string, unknown> | null;
|
|
19
|
+
metadata?: Record<string, unknown> | null;
|
|
20
|
+
dedup_key?: string;
|
|
21
|
+
triggered_at?: string | null;
|
|
22
|
+
viewed_at?: string | null;
|
|
23
|
+
viewed_by?: number | null;
|
|
24
|
+
resolved_at?: string | null;
|
|
25
|
+
resolved_by?: number | null;
|
|
26
|
+
resolution_note?: string | null;
|
|
27
|
+
created_user?: number | null;
|
|
28
|
+
created_at?: string;
|
|
29
|
+
mod_time?: string;
|
|
30
|
+
static tableName: string;
|
|
31
|
+
static jsonAttributes: string[];
|
|
32
|
+
static jsonSchema: Objection.JSONSchema;
|
|
33
|
+
static QueryBuilder: typeof Objection.QueryBuilder;
|
|
34
|
+
static query(): TypedQueryBuilder<Alert, typeof Alert, never>;
|
|
35
|
+
static getModel(ctx: RequestContext): typeof Alert;
|
|
36
|
+
static getModelByPool(ecosystemPool: Objection.TransactionOrKnex): typeof Alert;
|
|
37
|
+
/**
|
|
38
|
+
* Writes an alert and announces it, so an alert is a trigger source like any other model: the
|
|
39
|
+
* `MODEL_AFTER_SAVE` event is what lets a trigger fire *from* an alert.
|
|
40
|
+
*
|
|
41
|
+
* Every write goes through `insert`/`patch` rather than `query().insert()` — a bare query writes
|
|
42
|
+
* the row without emitting, and the trigger silently never fires. `trx` lets the caller keep the
|
|
43
|
+
* write inside the dedup transaction of the service; it defaults to the request's ecosystem
|
|
44
|
+
* transaction, as `ProcessLog` does.
|
|
45
|
+
*/
|
|
46
|
+
static insert(ctx: RequestContext, data: Objection.PartialModelObject<Alert>, trx?: Objection.TransactionOrKnex): Promise<Alert>;
|
|
47
|
+
/**
|
|
48
|
+
* Patches an alert the request reaches and announces it.
|
|
49
|
+
*
|
|
50
|
+
* The scoping lives here and not only in the service: the table is ecosystem-wide and holds the
|
|
51
|
+
* alerts of every project in it, so a `patchAndFetchById` on its own writes across tenants. Both
|
|
52
|
+
* service callers already check ownership before calling, but leaving the isolation as an
|
|
53
|
+
* invariant of the caller means a future one that forgets it writes across projects in silence.
|
|
54
|
+
*
|
|
55
|
+
* With no project in the request — the ecosystem-level routes — the reachable rows are the ones
|
|
56
|
+
* belonging to no project, so the narrowing becomes `IS NULL`. `= NULL` would never match and the
|
|
57
|
+
* patch would silently write nothing.
|
|
58
|
+
*/
|
|
59
|
+
static patch(ctx: RequestContext, data: Objection.PartialModelObject<Alert>, id: number): Promise<Alert>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=alert.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.model.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.model.ts"],"names":[],"mappings":"AAAA,OAAO,SAA2B,MAAM,WAAW,CAAA;AACnD,OAAO,SAAS,MAAM,sBAAsB,CAAA;AAC5C,OAAO,cAAc,MAAM,mCAAmC,CAAA;AAI9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAG9D,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAA;AAUvB,qBAAa,KAAM,SAAQ,SAAU,YAAW,SAAS;IACvD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;IAC/B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,OAAO,EAAG,gBAAgB,CAAA;IAC1B,UAAU,CAAC,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAA;IACxC,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAA;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IACzC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,MAAM,CAAC,SAAS,SAAU;IAK1B,MAAM,CAAC,cAAc,WAAuE;IAS5F,MAAM,CAAC,UAAU,uBAA0C;IAE3D,MAAM,CAAC,YAAY,gCAAyC;IAE5D,MAAM,CAAC,KAAK;IAIZ,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc;IAInC,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,SAAS,CAAC,iBAAiB;IAIhE;;;;;;;;OAQG;WACU,MAAM,CACjB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,SAAS,CAAC,kBAAkB,CAAC,KAAK,CAAC,EACzC,GAAG,CAAC,EAAE,SAAS,CAAC,iBAAiB;IAYnC;;;;;;;;;;;OAWG;WACU,KAAK,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,MAAM;CAqB9F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.model.test.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.model.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Type, Static } from 'typebox';
|
|
2
|
+
export declare const AlertStatus: {
|
|
3
|
+
readonly ACTIVE: "active";
|
|
4
|
+
readonly RESOLVED: "resolved";
|
|
5
|
+
};
|
|
6
|
+
export declare const alertStatusSchema: Type.TEnum<("active" | "resolved")[]>;
|
|
7
|
+
export type AlertStatus = Static<typeof alertStatusSchema>;
|
|
8
|
+
export declare const AlertSeverity: {
|
|
9
|
+
readonly INFO: "info";
|
|
10
|
+
readonly LOW: "low";
|
|
11
|
+
readonly MEDIUM: "medium";
|
|
12
|
+
readonly HIGH: "high";
|
|
13
|
+
readonly CRITICAL: "critical";
|
|
14
|
+
};
|
|
15
|
+
export declare const alertSeveritySchema: Type.TEnum<("info" | "low" | "medium" | "high" | "critical")[]>;
|
|
16
|
+
export type AlertSeverity = Static<typeof alertSeveritySchema>;
|
|
17
|
+
export declare const AlertEmitterType: {
|
|
18
|
+
readonly TRIGGER: "trigger";
|
|
19
|
+
readonly API: "api";
|
|
20
|
+
readonly WEBHOOK: "webhook";
|
|
21
|
+
};
|
|
22
|
+
export declare const alertEmitterTypeSchema: Type.TEnum<("trigger" | "api" | "webhook")[]>;
|
|
23
|
+
export type AlertEmitterType = Static<typeof alertEmitterTypeSchema>;
|
|
24
|
+
export declare const alertEmitterSchema: Type.TObject<{
|
|
25
|
+
type: Type.TEnum<("trigger" | "api" | "webhook")[]>;
|
|
26
|
+
id: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
27
|
+
name: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
28
|
+
reference: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
29
|
+
}>;
|
|
30
|
+
export type AlertEmitterData = Static<typeof alertEmitterSchema>;
|
|
31
|
+
export declare const alertEntityRefSchema: Type.TObject<{
|
|
32
|
+
type: Type.TString;
|
|
33
|
+
value: Type.TString;
|
|
34
|
+
}>;
|
|
35
|
+
export type AlertEntityRefData = Static<typeof alertEntityRefSchema>;
|
|
36
|
+
export declare const alertSchema: Type.TObject<{
|
|
37
|
+
id: Type.TNumber;
|
|
38
|
+
project_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
39
|
+
alert_type_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
40
|
+
user_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
41
|
+
patient_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
42
|
+
severity: Type.TOptional<Type.TUnion<[Type.TEnum<("info" | "low" | "medium" | "high" | "critical")[]>, Type.TNull]>>;
|
|
43
|
+
status: Type.TOptional<Type.TEnum<("active" | "resolved")[]>>;
|
|
44
|
+
title: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
45
|
+
summary: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
46
|
+
emitter: Type.TObject<{
|
|
47
|
+
type: Type.TEnum<("trigger" | "api" | "webhook")[]>;
|
|
48
|
+
id: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
49
|
+
name: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
50
|
+
reference: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
51
|
+
}>;
|
|
52
|
+
recipients: Type.TOptional<Type.TUnion<[Type.TArray<Type.TObject<{
|
|
53
|
+
type: Type.TString;
|
|
54
|
+
value: Type.TString;
|
|
55
|
+
}>>, Type.TNull]>>;
|
|
56
|
+
related_entities: Type.TOptional<Type.TUnion<[Type.TArray<Type.TObject<{
|
|
57
|
+
type: Type.TString;
|
|
58
|
+
value: Type.TString;
|
|
59
|
+
}>>, Type.TNull]>>;
|
|
60
|
+
payload: Type.TOptional<Type.TUnion<[Type.TRecord<"^.*$", Type.TUnknown>, Type.TNull]>>;
|
|
61
|
+
metadata: Type.TOptional<Type.TUnion<[Type.TRecord<"^.*$", Type.TUnknown>, Type.TNull]>>;
|
|
62
|
+
dedup_key: Type.TOptional<Type.TString>;
|
|
63
|
+
triggered_at: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
64
|
+
viewed_at: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
65
|
+
viewed_by: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
66
|
+
resolved_at: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
67
|
+
resolved_by: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
68
|
+
resolution_note: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
69
|
+
created_user: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
70
|
+
created_at: Type.TOptional<Type.TString>;
|
|
71
|
+
mod_time: Type.TOptional<Type.TString>;
|
|
72
|
+
}>;
|
|
73
|
+
export type AlertData = Static<typeof alertSchema>;
|
|
74
|
+
export declare const createAlertSchema: Type.TObject<{
|
|
75
|
+
alert_type_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
76
|
+
user_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
77
|
+
patient_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
78
|
+
severity: Type.TOptional<Type.TUnion<[Type.TEnum<("info" | "low" | "medium" | "high" | "critical")[]>, Type.TNull]>>;
|
|
79
|
+
title: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
80
|
+
summary: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
81
|
+
emitter: Type.TObject<{
|
|
82
|
+
type: Type.TEnum<("trigger" | "api" | "webhook")[]>;
|
|
83
|
+
id: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
84
|
+
name: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
85
|
+
reference: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
86
|
+
}>;
|
|
87
|
+
recipients: Type.TOptional<Type.TUnion<[Type.TArray<Type.TObject<{
|
|
88
|
+
type: Type.TString;
|
|
89
|
+
value: Type.TString;
|
|
90
|
+
}>>, Type.TNull]>>;
|
|
91
|
+
related_entities: Type.TOptional<Type.TUnion<[Type.TArray<Type.TObject<{
|
|
92
|
+
type: Type.TString;
|
|
93
|
+
value: Type.TString;
|
|
94
|
+
}>>, Type.TNull]>>;
|
|
95
|
+
payload: Type.TOptional<Type.TUnion<[Type.TRecord<"^.*$", Type.TUnknown>, Type.TNull]>>;
|
|
96
|
+
metadata: Type.TOptional<Type.TUnion<[Type.TRecord<"^.*$", Type.TUnknown>, Type.TNull]>>;
|
|
97
|
+
dedup_key: Type.TOptional<Type.TString>;
|
|
98
|
+
triggered_at: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
99
|
+
}>;
|
|
100
|
+
export type CreateAlertData = Static<typeof createAlertSchema>;
|
|
101
|
+
export declare const updateAlertSchema: Type.TObject<{
|
|
102
|
+
patient_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
103
|
+
user_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
104
|
+
title: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
105
|
+
summary: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
106
|
+
alert_type_id: Type.TOptional<Type.TUnion<[Type.TNumber, Type.TNull]>>;
|
|
107
|
+
severity: Type.TOptional<Type.TUnion<[Type.TEnum<("info" | "low" | "medium" | "high" | "critical")[]>, Type.TNull]>>;
|
|
108
|
+
recipients: Type.TOptional<Type.TUnion<[Type.TArray<Type.TObject<{
|
|
109
|
+
type: Type.TString;
|
|
110
|
+
value: Type.TString;
|
|
111
|
+
}>>, Type.TNull]>>;
|
|
112
|
+
related_entities: Type.TOptional<Type.TUnion<[Type.TArray<Type.TObject<{
|
|
113
|
+
type: Type.TString;
|
|
114
|
+
value: Type.TString;
|
|
115
|
+
}>>, Type.TNull]>>;
|
|
116
|
+
payload: Type.TOptional<Type.TUnion<[Type.TRecord<"^.*$", Type.TUnknown>, Type.TNull]>>;
|
|
117
|
+
metadata: Type.TOptional<Type.TUnion<[Type.TRecord<"^.*$", Type.TUnknown>, Type.TNull]>>;
|
|
118
|
+
dedup_key: Type.TOptional<Type.TString>;
|
|
119
|
+
triggered_at: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
120
|
+
}>;
|
|
121
|
+
export type UpdateAlertData = Static<typeof updateAlertSchema>;
|
|
122
|
+
export declare const resolveAlertSchema: Type.TObject<{
|
|
123
|
+
resolution_note: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
124
|
+
}>;
|
|
125
|
+
export type ResolveAlertData = Static<typeof resolveAlertSchema>;
|
|
126
|
+
export declare const listAlertQuerySchema: Type.TObject<{
|
|
127
|
+
status: Type.TOptional<Type.TEnum<("active" | "resolved")[]>>;
|
|
128
|
+
severity: Type.TOptional<Type.TEnum<("info" | "low" | "medium" | "high" | "critical")[]>>;
|
|
129
|
+
user_id: Type.TOptional<Type.TNumber>;
|
|
130
|
+
patient_id: Type.TOptional<Type.TNumber>;
|
|
131
|
+
alert_type_id: Type.TOptional<Type.TNumber>;
|
|
132
|
+
}>;
|
|
133
|
+
export type ListAlertQuery = Static<typeof listAlertQuerySchema>;
|
|
134
|
+
//# sourceMappingURL=alert.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.schema.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAWtC,eAAO,MAAM,WAAW;;;CAGd,CAAA;AACV,eAAO,MAAM,iBAAiB,uCAG5B,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE1D,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAA;AACV,eAAO,MAAM,mBAAmB,iEAG9B,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAM9D,eAAO,MAAM,gBAAgB;;;;CAInB,CAAA;AACV,eAAO,MAAM,sBAAsB,+CAGjC,CAAA;AACF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAIpE,eAAO,MAAM,kBAAkB;;;;;EAoB9B,CAAA;AACD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAUhE,eAAO,MAAM,oBAAoB;;;EAUhC,CAAA;AACD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAIpE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2GvB,CAAA;AACD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA;AAQlD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;EAqB7B,CAAA;AACD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAQ9D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;EAI5B,CAAA;AACF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAO9D,eAAO,MAAM,kBAAkB;;EAO9B,CAAA;AACD,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAIhE,eAAO,MAAM,oBAAoB;;;;;;EAShC,CAAA;AACD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { default as RequestContext } from '../../../../models/request/RequestContext';
|
|
2
|
+
import { PaginatedQuery } from '../../global/pagination';
|
|
3
|
+
import { AlertReadScope } from './alert.helper';
|
|
4
|
+
import { Alert } from './alert.model';
|
|
5
|
+
import { CreateAlertData, ListAlertQuery, UpdateAlertData } from './alert.schema';
|
|
6
|
+
/**
|
|
7
|
+
* Lists the alerts the request reaches, newest first, narrowed by the optional filters.
|
|
8
|
+
*
|
|
9
|
+
* `scope` is the caller's read reach (see `resolveAlertReadScope`): `null` for everything in reach,
|
|
10
|
+
* otherwise only the alerts the caller is party to.
|
|
11
|
+
*/
|
|
12
|
+
declare function listAlerts(ctx: RequestContext, pagination: PaginatedQuery, filters: ListAlertQuery, scope: AlertReadScope | null): Promise<import('objection').Page<Alert>>;
|
|
13
|
+
/**
|
|
14
|
+
* Reads one alert the request reaches, narrowed by `scope`.
|
|
15
|
+
*
|
|
16
|
+
* An alert outside the caller's scope comes back `undefined`, exactly like one that does not exist,
|
|
17
|
+
* and the controller turns both into the same 404. Deliberate: a 403 here would confirm to anyone
|
|
18
|
+
* that an alert exists for that id, which on clinical data is itself the leak.
|
|
19
|
+
*/
|
|
20
|
+
declare function getAlertById(ctx: RequestContext, id: number, scope: AlertReadScope | null): Promise<Alert | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an alert, idempotent by `dedup_key`: a second create carrying a key that is already open
|
|
23
|
+
* in the same scope — the project, or the alerts belonging to no project — answers with the stored
|
|
24
|
+
* alert instead of raising a duplicate. That is what lets an
|
|
25
|
+
* emitter retry — a webhook redelivery, a trigger re-firing on the same event — without the same
|
|
26
|
+
* incident being raised twice.
|
|
27
|
+
*
|
|
28
|
+
* `open` is the operative word: the lookup is narrowed to `status = 'active'`, so **a resolved alert
|
|
29
|
+
* does not shadow its key**. A condition that is dealt with and happens again raises a new alert,
|
|
30
|
+
* which is what an alert is for; without the narrowing the key stayed burnt for good and the
|
|
31
|
+
* recurrence came back as a 200 carrying the alert that was closed months ago — an incident lost in
|
|
32
|
+
* silence, and indistinguishable to the caller from a successful create.
|
|
33
|
+
*
|
|
34
|
+
* The cost is that a retry arriving *after* the alert was resolved raises a second one. That is the
|
|
35
|
+
* right way round: a duplicate alert is visible and can be resolved, a swallowed recurrence is
|
|
36
|
+
* neither.
|
|
37
|
+
*
|
|
38
|
+
* The check runs in code, not as a UNIQUE index: the index would have to span
|
|
39
|
+
* `(project_id, dedup_key)`, and `project_id` is nullable, so MySQL treats each NULL as distinct
|
|
40
|
+
* and the constraint would not hold for the ecosystem-wide alerts the column is nullable for.
|
|
41
|
+
*
|
|
42
|
+
* Check and insert share one transaction, and the check locks with `FOR UPDATE`: without the lock
|
|
43
|
+
* two concurrent creates carrying the same key both read "absent" and both insert. The lock is
|
|
44
|
+
* taken over `idx_alert_dedup`, so it is a range lock on the key rather than a table scan. Note
|
|
45
|
+
* this bounds the race, it does not remove it the way a unique index would: the DB no longer
|
|
46
|
+
* backstops the invariant, so a write reaching the table by any path other than this service can
|
|
47
|
+
* still duplicate a key.
|
|
48
|
+
*
|
|
49
|
+
* A client that sends no `dedup_key` gets a generated UUID — unique by construction, so the alert
|
|
50
|
+
* is always stored, and the column always carries a usable value.
|
|
51
|
+
*
|
|
52
|
+
* A `patient_id` without a project is rejected with a 400 (see `assertPatientHasProject`).
|
|
53
|
+
*/
|
|
54
|
+
declare function createAlert(ctx: RequestContext, data: CreateAlertData): Promise<Alert>;
|
|
55
|
+
declare function updateAlert(ctx: RequestContext, id: number, data: UpdateAlertData): Promise<Alert>;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves an alert: the single transition of its lifecycle, writing `status`, `resolved_at` and
|
|
58
|
+
* `resolved_by` together so the three never disagree — which is why it is an endpoint of its own
|
|
59
|
+
* and not a `status` field on the update payload.
|
|
60
|
+
*
|
|
61
|
+
* Resolving an already-resolved alert answers with it unchanged rather than failing: the caller
|
|
62
|
+
* asked for a state that already holds, and re-stamping would overwrite who closed it and when.
|
|
63
|
+
*/
|
|
64
|
+
declare function resolveAlert(ctx: RequestContext, id: number, resolutionNote?: string | null): Promise<Alert>;
|
|
65
|
+
export declare const AlertService: {
|
|
66
|
+
list: typeof listAlerts;
|
|
67
|
+
getById: typeof getAlertById;
|
|
68
|
+
create: typeof createAlert;
|
|
69
|
+
update: typeof updateAlert;
|
|
70
|
+
resolve: typeof resolveAlert;
|
|
71
|
+
};
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=alert.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.service.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAA;AAKnE,OAAO,EAAE,cAAc,EAAiB,MAAM,6BAA6B,CAAA;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAe,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAyC7G;;;;;GAKG;AACH,iBAAe,UAAU,CACvB,GAAG,EAAE,cAAc,EACnB,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,cAAc,GAAG,IAAI,4CAe7B;AAED;;;;;;GAMG;AACH,iBAAe,YAAY,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,8BAMxF;AAwFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,iBAAe,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,kBAkBpE;AA0FD,iBAAe,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,kBAmBhF;AAED;;;;;;;GAOG;AACH,iBAAe,YAAY,CAAC,GAAG,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,kBAyB1F;AAED,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.service.test.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/alert.service.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AlertService } from './alert.service';
|
|
2
|
+
export { Alert } from './alert.model';
|
|
3
|
+
export { AlertController } from './alert.controller';
|
|
4
|
+
export { requireAlertsManagement } from './alert.helper';
|
|
5
|
+
export { AlertStatus, AlertSeverity, AlertEmitterType } from './alert.schema';
|
|
6
|
+
export type { AlertData, AlertEmitterData, AlertEntityRefData, CreateAlertData, UpdateAlertData } from './alert.schema';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC7E,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';
|
|
2
|
+
export declare const alertTypeRouter: FastifyPluginAsyncTypebox;
|
|
3
|
+
export declare const AlertTypeController: {
|
|
4
|
+
alertTypeRouter: FastifyPluginAsyncTypebox;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=alert-type.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-type.controller.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert-type/alert-type.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAmB1E,eAAO,MAAM,eAAe,EAAE,yBAsH7B,CAAA;AAED,eAAO,MAAM,mBAAmB;;CAE/B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-type.controller.e2e.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert-type/alert-type.controller.e2e.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-type.controller.test.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert-type/alert-type.controller.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permission preHandler of the write endpoints of the alert type catalog.
|
|
3
|
+
*
|
|
4
|
+
* It checks the administrator role rather than the `alerts_management` privilege the alert
|
|
5
|
+
* endpoints use, and the reason is structural: seed privileges are granted per profiling, and a
|
|
6
|
+
* profiling belongs to a project (`user_profiling.project_id`). This catalog has no project — it is
|
|
7
|
+
* ecosystem-wide — so there is no profiling row to look up and `User.checkPermission` would answer
|
|
8
|
+
* `false` for everyone, locking the endpoints for good.
|
|
9
|
+
*
|
|
10
|
+
* Reads carry no guard of their own: the catalog is a list of names, every alert reader needs it to
|
|
11
|
+
* render an alert, and it carries no clinical data.
|
|
12
|
+
*/
|
|
13
|
+
export declare const requireAlertTypeAdmin: (req: import('fastify').FastifyRequest) => Promise<void>;
|
|
14
|
+
//# sourceMappingURL=alert-type.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-type.helper.d.ts","sourceRoot":"","sources":["../../../../../../../src/v2/modules/ecosystem/alert-type/alert-type.helper.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,0DAEjC,CAAA"}
|