@persei/perseed-api 4.34.18 → 4.34.20

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/README.md CHANGED
@@ -10,6 +10,7 @@
10
10
  8. [Redis cache and queue](#8-redis-cache-and-queue)
11
11
  9. [Generating json schema from ts definitions](#9-generating-json-schema-from-ts-definitions)
12
12
  10. [Add a new language](#10-add-a-new-language)
13
+ 11. [Lib package build](#11-lib-package-build)
13
14
 
14
15
  # 1 - Perseed API - NodeJs
15
16
 
@@ -258,3 +259,10 @@ To add a new language:
258
259
  * Run `npm run i18n:generate` to generate the new locale file with the default values (in english). This file should be translated.
259
260
  * Done!
260
261
 
262
+ ## 11 Lib package build
263
+
264
+ To build the lib package:
265
+ * Increase the package.json version
266
+ * Run `npm run lib:build`
267
+ * Commit changes
268
+ * Run `npm publish`
package/dist/index.d.ts CHANGED
@@ -78,16 +78,16 @@ export declare type BaseApiServicePayload = {
78
78
  ctx?: RequestContext;
79
79
  } & Partial<ApiActionContextData>;
80
80
 
81
- export declare type BaseDashboardWidget = (BaseDashboardWidgetPayload & {
81
+ export declare type BaseDashboardWidget = BaseDashboardWidgetPayload & ({
82
82
  type: DashboardWidgetType.SECTIONCARD;
83
83
  params: SectionCardProps;
84
- }) | (BaseDashboardWidgetPayload & {
84
+ } | {
85
85
  type: DashboardWidgetType.VALUECARD;
86
86
  params: ValueCardProps;
87
- }) | (BaseDashboardWidgetPayload & {
87
+ } | {
88
88
  type: DashboardWidgetType.PATIENTLIST;
89
89
  params: PatientListProps;
90
- }) | (BaseDashboardWidgetPayload & {
90
+ } | {
91
91
  type: DashboardWidgetType.DASHBOARD;
92
92
  params: DashboardProps;
93
93
  });
@@ -96,7 +96,6 @@ export declare type BaseDashboardWidgetPayload<T extends DashboardWidgetType | u
96
96
  id?: number;
97
97
  title: string;
98
98
  description?: string;
99
- size?: number | ColProps;
100
99
  type: T | DashboardWidgetType;
101
100
  library: boolean;
102
101
  config?: WidgetBlockConfig;
@@ -121,6 +120,12 @@ declare interface CacheOptions {
121
120
  tags: Record<string, any>;
122
121
  }
123
122
 
123
+ export declare interface CalculatedColumn {
124
+ key: string;
125
+ label: string;
126
+ template: string;
127
+ }
128
+
124
129
  declare class Clinic extends BaseModel {
125
130
  name: string;
126
131
  country: string;
@@ -440,16 +445,16 @@ export declare const CORE: {
440
445
 
441
446
  export declare const CountryPhoneCodes: {};
442
447
 
443
- export declare type CreateDashboardWidgetPayload = (DashboardBaseWidgetPayload & {
448
+ export declare type CreateDashboardWidgetPayload = DashboardBaseWidgetPayload & ({
444
449
  type: DashboardWidgetType.SECTIONCARD;
445
450
  params: SectionCardProps;
446
- }) | (DashboardBaseWidgetPayload & {
451
+ } | {
447
452
  type: DashboardWidgetType.VALUECARD;
448
453
  params: ValueCardProps;
449
- }) | (DashboardBaseWidgetPayload & {
454
+ } | {
450
455
  type: DashboardWidgetType.PATIENTLIST;
451
456
  params: PatientListProps;
452
- }) | (DashboardBaseWidgetPayload & {
457
+ } | {
453
458
  type: DashboardWidgetType.DASHBOARD;
454
459
  params: DashboardProps;
455
460
  });
@@ -484,13 +489,19 @@ declare class CustomQueryBuilder<M extends Model = Model, R = M[]> extends Query
484
489
 
485
490
  export declare type DashboardBaseWidgetPayload = {
486
491
  title: string;
487
- description?: string;
492
+ description?: string | null;
488
493
  weight?: number;
489
494
  size?: number | ColProps;
490
495
  library?: boolean;
491
496
  widgetsBlocks?: DashboardWidgetBlockCreatePayload[];
492
497
  };
493
498
 
499
+ export declare type DashboardChildrenWidget<T extends DashboardWidgetType | undefined = undefined> = DashboardBaseWidgetPayload & BaseDashboardWidgetPayload<T> & {
500
+ id: number;
501
+ type: DashboardWidgetType;
502
+ params: GenericParams;
503
+ };
504
+
494
505
  export declare interface DashboardProps {
495
506
  active?: boolean;
496
507
  config?: any;
@@ -499,18 +510,18 @@ export declare interface DashboardProps {
499
510
 
500
511
  export declare type DashboardWidget<T extends DashboardWidgetType | undefined = undefined> = T extends DashboardWidgetType ? {
501
512
  id: number;
502
- widgets?: BaseDashboardWidgetPayload[];
513
+ widgets?: DashboardChildrenWidget[];
503
514
  } & DashboardWidgetTypeToParams[T] & BaseDashboardWidgetPayload<T> : {
504
515
  id: number;
505
516
  params: any;
506
- widgets?: BaseDashboardWidgetPayload[];
517
+ widgets?: DashboardChildrenWidget[];
507
518
  } & BaseDashboardWidgetPayload<T>;
508
519
 
509
520
  export declare type DashboardWidgetBlockCreatePayload = {
510
521
  parent_id: number | string;
511
522
  child_id: number;
512
523
  position: number;
513
- config?: WidgetBlockConfig;
524
+ config?: WidgetBlockConfig | null;
514
525
  };
515
526
 
516
527
  export declare type DashboardWidgetDataLoader<T> = T extends {
@@ -792,9 +803,6 @@ export declare const FIELDS: {
792
803
 
793
804
  export declare interface FilterParams {
794
805
  conditions?: Record<string, unknown>;
795
- relatedData?: {
796
- join?: string[];
797
- };
798
806
  }
799
807
 
800
808
  export declare type FlexType = number | 'none' | 'auto' | string;
@@ -826,6 +834,8 @@ export declare interface GenericDashboardWidgetDataLoader {
826
834
  params: Record<string, any>;
827
835
  }
828
836
 
837
+ export declare type GenericParams = SectionCardProps | ValueCardProps | PatientListProps | DashboardProps;
838
+
829
839
  export declare const HISTORY: {
830
840
  PERMANENT: string;
831
841
  TEMPORARY: string;
@@ -1092,20 +1102,25 @@ export declare interface OutcomesParams {
1092
1102
 
1093
1103
  export declare const PATIENT_CREATION_ABOUT = "Patient Creation";
1094
1104
 
1105
+ export declare interface PatientListColumn {
1106
+ hidden?: boolean;
1107
+ position?: number;
1108
+ label?: string;
1109
+ key: string;
1110
+ }
1111
+
1095
1112
  export declare interface PatientListProps {
1096
1113
  loadUserProfiles?: boolean;
1097
1114
  loadAdherence?: boolean;
1098
1115
  extraFields?: string[];
1099
1116
  loadPushTokens?: boolean;
1100
1117
  loadUserAccessData?: boolean;
1101
- programId?: number;
1102
- prevAdherenceDays?: number;
1103
- relatedData?: {
1104
- join?: string[];
1105
- };
1106
- filter?: {
1107
- conditions?: Record<string, unknown>;
1108
- };
1118
+ programId?: number | null;
1119
+ prevAdherenceDays?: number | null;
1120
+ filter?: FilterParams;
1121
+ relatedData?: RelatedDataParams;
1122
+ calculatedColumns?: CalculatedColumn[];
1123
+ columns?: PatientListColumn[];
1109
1124
  }
1110
1125
 
1111
1126
  declare class Profiling extends BaseModel {
@@ -1584,6 +1599,10 @@ export declare interface QuestionnaireInfoUpdateOptions {
1584
1599
 
1585
1600
  export declare type QuestionnaireTypeValue = 'QoL' | 'Task';
1586
1601
 
1602
+ export declare interface RelatedDataParams {
1603
+ join?: string[];
1604
+ }
1605
+
1587
1606
  /**
1588
1607
  * req.body object mfa validation
1589
1608
  */
@@ -19,7 +19,7 @@
19
19
  "type": "string"
20
20
  },
21
21
  "description": {
22
- "type": "string"
22
+ "type": ["string", "null"]
23
23
  },
24
24
  "weight": {
25
25
  "type": "number"
@@ -61,7 +61,7 @@
61
61
  "type": "string"
62
62
  },
63
63
  "description": {
64
- "type": "string"
64
+ "type": ["string", "null"]
65
65
  },
66
66
  "weight": {
67
67
  "type": "number"
@@ -103,7 +103,7 @@
103
103
  "type": "string"
104
104
  },
105
105
  "description": {
106
- "type": "string"
106
+ "type": ["string", "null"]
107
107
  },
108
108
  "weight": {
109
109
  "type": "number"
@@ -145,7 +145,7 @@
145
145
  "type": "string"
146
146
  },
147
147
  "description": {
148
- "type": "string"
148
+ "type": ["string", "null"]
149
149
  },
150
150
  "weight": {
151
151
  "type": "number"
@@ -335,7 +335,14 @@
335
335
  "type": "number"
336
336
  },
337
337
  "config": {
338
- "$ref": "#/definitions/WidgetBlockConfig"
338
+ "anyOf": [
339
+ {
340
+ "$ref": "#/definitions/WidgetBlockConfig"
341
+ },
342
+ {
343
+ "type": "null"
344
+ }
345
+ ]
339
346
  }
340
347
  },
341
348
  "required": ["parent_id", "child_id", "position"],
@@ -589,34 +596,87 @@
589
596
  "type": "boolean"
590
597
  },
591
598
  "programId": {
592
- "type": "number"
599
+ "type": ["number", "null"]
593
600
  },
594
601
  "prevAdherenceDays": {
595
- "type": "number"
602
+ "type": ["number", "null"]
603
+ },
604
+ "filter": {
605
+ "$ref": "#/definitions/FilterParams"
596
606
  },
597
607
  "relatedData": {
598
- "type": "object",
599
- "properties": {
600
- "join": {
601
- "type": "array",
602
- "items": {
603
- "type": "string"
604
- }
605
- }
606
- },
607
- "additionalProperties": false
608
+ "$ref": "#/definitions/RelatedDataParams"
608
609
  },
609
- "filter": {
610
+ "calculatedColumns": {
611
+ "type": "array",
612
+ "items": {
613
+ "$ref": "#/definitions/CalculatedColumn"
614
+ }
615
+ },
616
+ "columns": {
617
+ "type": "array",
618
+ "items": {
619
+ "$ref": "#/definitions/PatientListColumn"
620
+ }
621
+ }
622
+ },
623
+ "additionalProperties": false
624
+ },
625
+ "FilterParams": {
626
+ "type": "object",
627
+ "properties": {
628
+ "conditions": {
610
629
  "type": "object",
611
- "properties": {
612
- "conditions": {
613
- "type": "object",
614
- "additionalProperties": {}
615
- }
616
- },
617
- "additionalProperties": false
630
+ "additionalProperties": {}
631
+ }
632
+ },
633
+ "additionalProperties": false
634
+ },
635
+ "RelatedDataParams": {
636
+ "type": "object",
637
+ "properties": {
638
+ "join": {
639
+ "type": "array",
640
+ "items": {
641
+ "type": "string"
642
+ }
643
+ }
644
+ },
645
+ "additionalProperties": false
646
+ },
647
+ "CalculatedColumn": {
648
+ "type": "object",
649
+ "properties": {
650
+ "key": {
651
+ "type": "string"
652
+ },
653
+ "label": {
654
+ "type": "string"
655
+ },
656
+ "template": {
657
+ "type": "string"
658
+ }
659
+ },
660
+ "required": ["key", "label", "template"],
661
+ "additionalProperties": false
662
+ },
663
+ "PatientListColumn": {
664
+ "type": "object",
665
+ "properties": {
666
+ "hidden": {
667
+ "type": "boolean"
668
+ },
669
+ "position": {
670
+ "type": "number"
671
+ },
672
+ "label": {
673
+ "type": "string"
674
+ },
675
+ "key": {
676
+ "type": "string"
618
677
  }
619
678
  },
679
+ "required": ["key"],
620
680
  "additionalProperties": false
621
681
  },
622
682
  "DashboardProps": {
@@ -9,7 +9,7 @@
9
9
  "type": "string"
10
10
  },
11
11
  "description": {
12
- "type": "string"
12
+ "type": ["string", "null"]
13
13
  },
14
14
  "weight": {
15
15
  "type": "number"
@@ -217,7 +217,14 @@
217
217
  "type": "number"
218
218
  },
219
219
  "config": {
220
- "$ref": "#/definitions/WidgetBlockConfig"
220
+ "anyOf": [
221
+ {
222
+ "$ref": "#/definitions/WidgetBlockConfig"
223
+ },
224
+ {
225
+ "type": "null"
226
+ }
227
+ ]
221
228
  }
222
229
  },
223
230
  "required": ["parent_id", "child_id", "position"],
@@ -487,34 +494,87 @@
487
494
  "type": "boolean"
488
495
  },
489
496
  "programId": {
490
- "type": "number"
497
+ "type": ["number", "null"]
491
498
  },
492
499
  "prevAdherenceDays": {
493
- "type": "number"
500
+ "type": ["number", "null"]
501
+ },
502
+ "filter": {
503
+ "$ref": "#/definitions/FilterParams"
494
504
  },
495
505
  "relatedData": {
496
- "type": "object",
497
- "properties": {
498
- "join": {
499
- "type": "array",
500
- "items": {
501
- "type": "string"
502
- }
503
- }
504
- },
505
- "additionalProperties": false
506
+ "$ref": "#/definitions/RelatedDataParams"
506
507
  },
507
- "filter": {
508
+ "calculatedColumns": {
509
+ "type": "array",
510
+ "items": {
511
+ "$ref": "#/definitions/CalculatedColumn"
512
+ }
513
+ },
514
+ "columns": {
515
+ "type": "array",
516
+ "items": {
517
+ "$ref": "#/definitions/PatientListColumn"
518
+ }
519
+ }
520
+ },
521
+ "additionalProperties": false
522
+ },
523
+ "FilterParams": {
524
+ "type": "object",
525
+ "properties": {
526
+ "conditions": {
508
527
  "type": "object",
509
- "properties": {
510
- "conditions": {
511
- "type": "object",
512
- "additionalProperties": {}
513
- }
514
- },
515
- "additionalProperties": false
528
+ "additionalProperties": {}
529
+ }
530
+ },
531
+ "additionalProperties": false
532
+ },
533
+ "RelatedDataParams": {
534
+ "type": "object",
535
+ "properties": {
536
+ "join": {
537
+ "type": "array",
538
+ "items": {
539
+ "type": "string"
540
+ }
541
+ }
542
+ },
543
+ "additionalProperties": false
544
+ },
545
+ "CalculatedColumn": {
546
+ "type": "object",
547
+ "properties": {
548
+ "key": {
549
+ "type": "string"
550
+ },
551
+ "label": {
552
+ "type": "string"
553
+ },
554
+ "template": {
555
+ "type": "string"
556
+ }
557
+ },
558
+ "required": ["key", "label", "template"],
559
+ "additionalProperties": false
560
+ },
561
+ "PatientListColumn": {
562
+ "type": "object",
563
+ "properties": {
564
+ "hidden": {
565
+ "type": "boolean"
566
+ },
567
+ "position": {
568
+ "type": "number"
569
+ },
570
+ "label": {
571
+ "type": "string"
572
+ },
573
+ "key": {
574
+ "type": "string"
516
575
  }
517
576
  },
577
+ "required": ["key"],
518
578
  "additionalProperties": false
519
579
  },
520
580
  "DashboardProps": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@persei/perseed-api",
3
- "version": "4.34.18",
3
+ "version": "4.34.20",
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
- "_prepare": "npm run precommit && npm run build",
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",
@@ -61,6 +60,7 @@
61
60
  }
62
61
  },
63
62
  "dependencies": {
63
+ "@aws-sdk/client-sns": "^3.803.0",
64
64
  "@paralleldrive/cuid2": "^2.2.2",
65
65
  "@persei/debug": "^2.0.0",
66
66
  "@sentry/node": "^6.19.6",