@persei/perseed-api 4.34.17 → 4.34.19

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.ts CHANGED
@@ -78,6 +78,30 @@ export declare type BaseApiServicePayload = {
78
78
  ctx?: RequestContext;
79
79
  } & Partial<ApiActionContextData>;
80
80
 
81
+ export declare type BaseDashboardWidget = BaseDashboardWidgetPayload & ({
82
+ type: DashboardWidgetType.SECTIONCARD;
83
+ params: SectionCardProps;
84
+ } | {
85
+ type: DashboardWidgetType.VALUECARD;
86
+ params: ValueCardProps;
87
+ } | {
88
+ type: DashboardWidgetType.PATIENTLIST;
89
+ params: PatientListProps;
90
+ } | {
91
+ type: DashboardWidgetType.DASHBOARD;
92
+ params: DashboardProps;
93
+ });
94
+
95
+ export declare type BaseDashboardWidgetPayload<T extends DashboardWidgetType | undefined = undefined> = {
96
+ id?: number;
97
+ title: string;
98
+ description?: string;
99
+ type: T | DashboardWidgetType;
100
+ library: boolean;
101
+ config?: WidgetBlockConfig;
102
+ position?: number;
103
+ };
104
+
81
105
  declare class BaseModel extends Model {
82
106
  id: number;
83
107
  static get modelPaths(): string[];
@@ -415,16 +439,16 @@ export declare const CORE: {
415
439
 
416
440
  export declare const CountryPhoneCodes: {};
417
441
 
418
- export declare type CreateDashboardWidgetPayload = (DashboardBaseWidgetPayload & {
442
+ export declare type CreateDashboardWidgetPayload = DashboardBaseWidgetPayload & ({
419
443
  type: DashboardWidgetType.SECTIONCARD;
420
444
  params: SectionCardProps;
421
- }) | (DashboardBaseWidgetPayload & {
445
+ } | {
422
446
  type: DashboardWidgetType.VALUECARD;
423
447
  params: ValueCardProps;
424
- }) | (DashboardBaseWidgetPayload & {
448
+ } | {
425
449
  type: DashboardWidgetType.PATIENTLIST;
426
450
  params: PatientListProps;
427
- }) | (DashboardBaseWidgetPayload & {
451
+ } | {
428
452
  type: DashboardWidgetType.DASHBOARD;
429
453
  params: DashboardProps;
430
454
  });
@@ -462,16 +486,38 @@ export declare type DashboardBaseWidgetPayload = {
462
486
  description?: string;
463
487
  weight?: number;
464
488
  size?: number | ColProps;
489
+ library?: boolean;
490
+ widgetsBlocks?: DashboardWidgetBlockCreatePayload[];
491
+ };
492
+
493
+ export declare type DashboardChildrenWidget<T extends DashboardWidgetType | undefined = undefined> = DashboardBaseWidgetPayload & BaseDashboardWidgetPayload<T> & {
494
+ id: number;
495
+ type: DashboardWidgetType;
496
+ params: GenericParams;
465
497
  };
466
498
 
467
499
  export declare interface DashboardProps {
468
- title: string;
469
500
  active?: boolean;
470
501
  config?: any;
471
502
  icon?: string | null;
472
- weight?: number;
473
503
  }
474
504
 
505
+ export declare type DashboardWidget<T extends DashboardWidgetType | undefined = undefined> = T extends DashboardWidgetType ? {
506
+ id: number;
507
+ widgets?: DashboardChildrenWidget[];
508
+ } & DashboardWidgetTypeToParams[T] & BaseDashboardWidgetPayload<T> : {
509
+ id: number;
510
+ params: any;
511
+ widgets?: DashboardChildrenWidget[];
512
+ } & BaseDashboardWidgetPayload<T>;
513
+
514
+ export declare type DashboardWidgetBlockCreatePayload = {
515
+ parent_id: number | string;
516
+ child_id: number;
517
+ position: number;
518
+ config?: WidgetBlockConfig;
519
+ };
520
+
475
521
  export declare type DashboardWidgetDataLoader<T> = T extends {
476
522
  type: infer Type;
477
523
  params: infer Params;
@@ -487,6 +533,21 @@ export declare enum DashboardWidgetType {
487
533
  DASHBOARD = "Dashboard"
488
534
  }
489
535
 
536
+ export declare type DashboardWidgetTypeToParams = {
537
+ [DashboardWidgetType.SECTIONCARD]: {
538
+ params: SectionCardProps;
539
+ };
540
+ [DashboardWidgetType.VALUECARD]: {
541
+ params: ValueCardProps;
542
+ };
543
+ [DashboardWidgetType.PATIENTLIST]: {
544
+ params: PatientListProps;
545
+ };
546
+ [DashboardWidgetType.DASHBOARD]: {
547
+ params: DashboardProps;
548
+ };
549
+ };
550
+
490
551
  export declare enum DataLoaderType {
491
552
  OUTCOMES = "outcomes"
492
553
  }
@@ -770,6 +831,8 @@ export declare interface GenericDashboardWidgetDataLoader {
770
831
  params: Record<string, any>;
771
832
  }
772
833
 
834
+ export declare type GenericParams = SectionCardProps | ValueCardProps | PatientListProps | DashboardProps;
835
+
773
836
  export declare const HISTORY: {
774
837
  PERMANENT: string;
775
838
  TEMPORARY: string;
@@ -1722,8 +1785,6 @@ export declare interface SectionCardProps {
1722
1785
  icon: string;
1723
1786
  background?: string;
1724
1787
  titleBackground?: string;
1725
- title: I18nTextTranslation;
1726
- widgets: number[];
1727
1788
  }
1728
1789
 
1729
1790
  /**
@@ -2641,7 +2702,6 @@ declare class UserProfile extends BaseModel {
2641
2702
  declare type UserSettingValue = string | number | boolean | Record<string, string | number> | string[] | number[];
2642
2703
 
2643
2704
  export declare interface ValueCardProps {
2644
- title: I18nTextTranslation;
2645
2705
  icon: string;
2646
2706
  text: I18nTextTranslation;
2647
2707
  subtext?: I18nTextTranslation;
@@ -2651,6 +2711,10 @@ export declare interface ValueCardProps {
2651
2711
  dataLoader?: DashboardWidgetDataLoader<WidgetOutcomesDataLoader>;
2652
2712
  }
2653
2713
 
2714
+ export declare type WidgetBlockConfig = {
2715
+ size?: number | ColProps;
2716
+ };
2717
+
2654
2718
  export declare interface WidgetOutcomesDataLoader {
2655
2719
  type: DataLoaderType.OUTCOMES;
2656
2720
  params: OutcomesParams;
@@ -33,6 +33,15 @@
33
33
  "$ref": "#/definitions/ColProps"
34
34
  }
35
35
  ]
36
+ },
37
+ "library": {
38
+ "type": "boolean"
39
+ },
40
+ "widgetsBlocks": {
41
+ "type": "array",
42
+ "items": {
43
+ "$ref": "#/definitions/DashboardWidgetBlockCreatePayload"
44
+ }
36
45
  }
37
46
  },
38
47
  "required": ["params", "title", "type"]
@@ -66,6 +75,15 @@
66
75
  "$ref": "#/definitions/ColProps"
67
76
  }
68
77
  ]
78
+ },
79
+ "library": {
80
+ "type": "boolean"
81
+ },
82
+ "widgetsBlocks": {
83
+ "type": "array",
84
+ "items": {
85
+ "$ref": "#/definitions/DashboardWidgetBlockCreatePayload"
86
+ }
69
87
  }
70
88
  },
71
89
  "required": ["params", "title", "type"]
@@ -99,6 +117,15 @@
99
117
  "$ref": "#/definitions/ColProps"
100
118
  }
101
119
  ]
120
+ },
121
+ "library": {
122
+ "type": "boolean"
123
+ },
124
+ "widgetsBlocks": {
125
+ "type": "array",
126
+ "items": {
127
+ "$ref": "#/definitions/DashboardWidgetBlockCreatePayload"
128
+ }
102
129
  }
103
130
  },
104
131
  "required": ["params", "title", "type"]
@@ -132,6 +159,15 @@
132
159
  "$ref": "#/definitions/ColProps"
133
160
  }
134
161
  ]
162
+ },
163
+ "library": {
164
+ "type": "boolean"
165
+ },
166
+ "widgetsBlocks": {
167
+ "type": "array",
168
+ "items": {
169
+ "$ref": "#/definitions/DashboardWidgetBlockCreatePayload"
170
+ }
135
171
  }
136
172
  },
137
173
  "required": ["params", "title", "type"]
@@ -149,42 +185,11 @@
149
185
  },
150
186
  "titleBackground": {
151
187
  "type": "string"
152
- },
153
- "title": {
154
- "$ref": "#/definitions/I18nTextTranslation"
155
- },
156
- "widgets": {
157
- "type": "array",
158
- "items": {
159
- "type": "number"
160
- }
161
188
  }
162
189
  },
163
- "required": ["icon", "title", "widgets"],
190
+ "required": ["icon"],
164
191
  "additionalProperties": false
165
192
  },
166
- "I18nTextTranslation": {
167
- "anyOf": [
168
- {
169
- "$ref": "#/definitions/I18nTextLocales"
170
- },
171
- {
172
- "type": "string"
173
- }
174
- ]
175
- },
176
- "I18nTextLocales": {
177
- "type": "object",
178
- "properties": {
179
- "default": {
180
- "type": "string"
181
- }
182
- },
183
- "required": ["default"],
184
- "additionalProperties": {
185
- "type": "string"
186
- }
187
- },
188
193
  "ColProps": {
189
194
  "type": "object",
190
195
  "properties": {
@@ -317,12 +322,44 @@
317
322
  },
318
323
  "additionalProperties": false
319
324
  },
320
- "ValueCardProps": {
325
+ "DashboardWidgetBlockCreatePayload": {
321
326
  "type": "object",
322
327
  "properties": {
323
- "title": {
324
- "$ref": "#/definitions/I18nTextTranslation"
328
+ "parent_id": {
329
+ "type": ["number", "string"]
330
+ },
331
+ "child_id": {
332
+ "type": "number"
325
333
  },
334
+ "position": {
335
+ "type": "number"
336
+ },
337
+ "config": {
338
+ "$ref": "#/definitions/WidgetBlockConfig"
339
+ }
340
+ },
341
+ "required": ["parent_id", "child_id", "position"],
342
+ "additionalProperties": false
343
+ },
344
+ "WidgetBlockConfig": {
345
+ "type": "object",
346
+ "properties": {
347
+ "size": {
348
+ "anyOf": [
349
+ {
350
+ "type": "number"
351
+ },
352
+ {
353
+ "$ref": "#/definitions/ColProps"
354
+ }
355
+ ]
356
+ }
357
+ },
358
+ "additionalProperties": false
359
+ },
360
+ "ValueCardProps": {
361
+ "type": "object",
362
+ "properties": {
326
363
  "icon": {
327
364
  "type": "string"
328
365
  },
@@ -345,9 +382,31 @@
345
382
  "$ref": "#/definitions/DashboardWidgetDataLoader%3CWidgetOutcomesDataLoader%3E"
346
383
  }
347
384
  },
348
- "required": ["title", "icon", "text"],
385
+ "required": ["icon", "text"],
349
386
  "additionalProperties": false
350
387
  },
388
+ "I18nTextTranslation": {
389
+ "anyOf": [
390
+ {
391
+ "$ref": "#/definitions/I18nTextLocales"
392
+ },
393
+ {
394
+ "type": "string"
395
+ }
396
+ ]
397
+ },
398
+ "I18nTextLocales": {
399
+ "type": "object",
400
+ "properties": {
401
+ "default": {
402
+ "type": "string"
403
+ }
404
+ },
405
+ "required": ["default"],
406
+ "additionalProperties": {
407
+ "type": "string"
408
+ }
409
+ },
351
410
  "DashboardWidgetDataLoader<WidgetOutcomesDataLoader>": {
352
411
  "type": "object",
353
412
  "properties": {
@@ -563,21 +622,14 @@
563
622
  "DashboardProps": {
564
623
  "type": "object",
565
624
  "properties": {
566
- "title": {
567
- "type": "string"
568
- },
569
625
  "active": {
570
626
  "type": "boolean"
571
627
  },
572
628
  "config": {},
573
629
  "icon": {
574
630
  "type": ["string", "null"]
575
- },
576
- "weight": {
577
- "type": "number"
578
631
  }
579
632
  },
580
- "required": ["title"],
581
633
  "additionalProperties": false
582
634
  }
583
635
  }
@@ -24,6 +24,15 @@
24
24
  }
25
25
  ]
26
26
  },
27
+ "library": {
28
+ "type": "boolean"
29
+ },
30
+ "widgetsBlocks": {
31
+ "type": "array",
32
+ "items": {
33
+ "$ref": "#/definitions/DashboardWidgetBlockCreatePayload"
34
+ }
35
+ },
27
36
  "type": {
28
37
  "anyOf": [
29
38
  {
@@ -195,59 +204,60 @@
195
204
  },
196
205
  "additionalProperties": false
197
206
  },
198
- "SectionCardProps": {
207
+ "DashboardWidgetBlockCreatePayload": {
199
208
  "type": "object",
200
209
  "properties": {
201
- "icon": {
202
- "type": "string"
203
- },
204
- "background": {
205
- "type": "string"
210
+ "parent_id": {
211
+ "type": ["number", "string"]
206
212
  },
207
- "titleBackground": {
208
- "type": "string"
213
+ "child_id": {
214
+ "type": "number"
209
215
  },
210
- "title": {
211
- "$ref": "#/definitions/I18nTextTranslation"
216
+ "position": {
217
+ "type": "number"
212
218
  },
213
- "widgets": {
214
- "type": "array",
215
- "items": {
216
- "type": "number"
217
- }
219
+ "config": {
220
+ "$ref": "#/definitions/WidgetBlockConfig"
218
221
  }
219
222
  },
220
- "required": ["icon", "title", "widgets"],
223
+ "required": ["parent_id", "child_id", "position"],
221
224
  "additionalProperties": false
222
225
  },
223
- "I18nTextTranslation": {
224
- "anyOf": [
225
- {
226
- "$ref": "#/definitions/I18nTextLocales"
227
- },
228
- {
229
- "type": "string"
226
+ "WidgetBlockConfig": {
227
+ "type": "object",
228
+ "properties": {
229
+ "size": {
230
+ "anyOf": [
231
+ {
232
+ "type": "number"
233
+ },
234
+ {
235
+ "$ref": "#/definitions/ColProps"
236
+ }
237
+ ]
230
238
  }
231
- ]
239
+ },
240
+ "additionalProperties": false
232
241
  },
233
- "I18nTextLocales": {
242
+ "SectionCardProps": {
234
243
  "type": "object",
235
244
  "properties": {
236
- "default": {
245
+ "icon": {
246
+ "type": "string"
247
+ },
248
+ "background": {
249
+ "type": "string"
250
+ },
251
+ "titleBackground": {
237
252
  "type": "string"
238
253
  }
239
254
  },
240
- "required": ["default"],
241
- "additionalProperties": {
242
- "type": "string"
243
- }
255
+ "required": ["icon"],
256
+ "additionalProperties": false
244
257
  },
245
258
  "ValueCardProps": {
246
259
  "type": "object",
247
260
  "properties": {
248
- "title": {
249
- "$ref": "#/definitions/I18nTextTranslation"
250
- },
251
261
  "icon": {
252
262
  "type": "string"
253
263
  },
@@ -270,9 +280,31 @@
270
280
  "$ref": "#/definitions/DashboardWidgetDataLoader%3CWidgetOutcomesDataLoader%3E"
271
281
  }
272
282
  },
273
- "required": ["title", "icon", "text"],
283
+ "required": ["icon", "text"],
274
284
  "additionalProperties": false
275
285
  },
286
+ "I18nTextTranslation": {
287
+ "anyOf": [
288
+ {
289
+ "$ref": "#/definitions/I18nTextLocales"
290
+ },
291
+ {
292
+ "type": "string"
293
+ }
294
+ ]
295
+ },
296
+ "I18nTextLocales": {
297
+ "type": "object",
298
+ "properties": {
299
+ "default": {
300
+ "type": "string"
301
+ }
302
+ },
303
+ "required": ["default"],
304
+ "additionalProperties": {
305
+ "type": "string"
306
+ }
307
+ },
276
308
  "DashboardWidgetDataLoader<WidgetOutcomesDataLoader>": {
277
309
  "type": "object",
278
310
  "properties": {
@@ -488,21 +520,14 @@
488
520
  "DashboardProps": {
489
521
  "type": "object",
490
522
  "properties": {
491
- "title": {
492
- "type": "string"
493
- },
494
523
  "active": {
495
524
  "type": "boolean"
496
525
  },
497
526
  "config": {},
498
527
  "icon": {
499
528
  "type": ["string", "null"]
500
- },
501
- "weight": {
502
- "type": "number"
503
529
  }
504
530
  },
505
- "required": ["title"],
506
531
  "additionalProperties": false
507
532
  }
508
533
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@persei/perseed-api",
3
- "version": "4.34.17",
3
+ "version": "4.34.19",
4
4
  "private": false,
5
5
  "main": "./dist/perseed-api.umd.js",
6
6
  "module": "./dist/perseed-api.mjs",
@@ -9,8 +9,7 @@
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
- "publish_package": "npm run precommit && npm run build && npm publish",
13
- "build": "tsc --noEmit && vite build",
12
+ "lib:build": "npm run precommit && tsc --noEmit && vite build",
14
13
  "start": "ts-node src/server.ts",
15
14
  "lint": "npm run test:lint",
16
15
  "jshint": "jshint . > report.txt || true",
@@ -29,10 +28,10 @@
29
28
  "security-packages-report": "npm audit --json | npm-audit-html --output reports/packages-security-report.html",
30
29
  "test:lint": "eslint src/ && prettier --ignore-path .prettierignorefile --check src/",
31
30
  "test:types": "tsc --noEmit",
32
- "test:docs": "pip install esprima && python3 swagger_gen.py",
33
- "dest:docs-unsafe": "pip install esprima --break-system-packages && python3 swagger_gen.py",
34
- "test:security": "pipx install njsscan && pipx install semgrep && njsscan ./src/",
35
- "test:security:report": "pipx install njsscan && pipx install semgrep && njsscan --html -o reports/security-report.html ./src/",
31
+ "test:dependencies": "pipx install njsscan semgrep esprima",
32
+ "test:docs": "python3 swagger_gen.py",
33
+ "test:security": "njsscan ./src/",
34
+ "test:security:report": "njsscan --html -o reports/security-report.html ./src/",
36
35
  "test:security:report2": "./bin/bearer scan perseed-api/src --scanner=sast,secrets --report security --format html --output reports/bearer_api_report",
37
36
  "precommit": "npm run schemas:generate && prettier --ignore-path .prettierignorefile src/ --write && npm run eslintfix && npm run i18n:generate && npm run test:types && npm run test-unit && npm run test:security",
38
37
  "i18n:generate": "npx rimraf src/i18n/api/en.json && i18next && i18next --config i18next-parser.config.js",