@opencrvs/toolkit 1.9.5-rc.4858075 → 1.9.5-rc.4d0fc4f

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.
@@ -6,6 +6,7 @@ export declare const FieldType: {
6
6
  readonly ADDRESS: "ADDRESS";
7
7
  readonly TEXT: "TEXT";
8
8
  readonly NUMBER: "NUMBER";
9
+ readonly NUMBER_WITH_UNIT: "NUMBER_WITH_UNIT";
9
10
  readonly TEXTAREA: "TEXTAREA";
10
11
  readonly EMAIL: "EMAIL";
11
12
  readonly DATE: "DATE";
@@ -44,11 +45,11 @@ export declare const FieldType: {
44
45
  * Union of types that handle files. Using common type should help with compiler to know where to add new cases.
45
46
  */
46
47
  export declare const FileFieldType: z.ZodEnum<["FILE", "FILE_WITH_OPTIONS", "SIGNATURE"]>;
47
- export declare const fieldTypes: ("NAME" | "PHONE" | "ID" | "ADDRESS" | "TEXT" | "NUMBER" | "TEXTAREA" | "EMAIL" | "DATE" | "AGE" | "DATE_RANGE" | "SELECT_DATE_RANGE" | "TIME" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE" | "DATA" | "BUTTON" | "SEARCH" | "ALPHA_PRINT_BUTTON" | "HTTP" | "LINK_BUTTON" | "VERIFICATION_STATUS" | "QUERY_PARAM_READER" | "QR_READER" | "ID_READER" | "LOADER")[];
48
+ export declare const fieldTypes: ("NAME" | "PHONE" | "ID" | "ADDRESS" | "TEXT" | "NUMBER" | "NUMBER_WITH_UNIT" | "TEXTAREA" | "EMAIL" | "DATE" | "AGE" | "DATE_RANGE" | "SELECT_DATE_RANGE" | "TIME" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE" | "DATA" | "BUTTON" | "SEARCH" | "ALPHA_PRINT_BUTTON" | "HTTP" | "LINK_BUTTON" | "VERIFICATION_STATUS" | "QUERY_PARAM_READER" | "QR_READER" | "ID_READER" | "LOADER")[];
48
49
  export type FieldType = (typeof fieldTypes)[number];
49
50
  /**
50
51
  * Composite field types are field types that consist of multiple field values.
51
52
  */
52
- export declare const compositeFieldTypes: ("ADDRESS" | "DATE_RANGE" | "FILE" | "FILE_WITH_OPTIONS" | "DATA" | "ID_READER")[];
53
+ export declare const compositeFieldTypes: ("NAME" | "ADDRESS" | "DATE_RANGE" | "FILE" | "FILE_WITH_OPTIONS" | "DATA" | "ID_READER")[];
53
54
  export declare const FieldTypesToHideInReview: ("PARAGRAPH" | "PAGE_HEADER" | "BULLET_LIST" | "DIVIDER" | "DATA" | "HTTP" | "QUERY_PARAM_READER" | "ID_READER" | "LOADER")[];
54
55
  //# sourceMappingURL=FieldType.d.ts.map
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { AddressField, AdministrativeArea, BulletList, Checkbox, Country, DateField, Divider, Facility, EmailField, FieldConfig, File, FileUploadWithOptions, LocationInput, Office, PageHeader, Paragraph, RadioGroup, SelectField, SignatureField, TextAreaField, TextField, NumberField, DataField, NameField, PhoneField, IdField, DateRangeField, SelectDateRangeField, TimeField, AlphaPrintButton, HttpField, SearchField, ButtonField, LinkButtonField, VerificationStatus, QueryParamReaderField, QrReaderField, IdReaderField, LoaderField, AgeField } from './FieldConfig';
3
- import { FieldValue, DataFieldValue, DateRangeFieldValue, SelectDateRangeValue, VerificationStatusValue, AgeValue } from './FieldValue';
2
+ import { AddressField, AdministrativeArea, BulletList, Checkbox, Country, DateField, Divider, Facility, EmailField, FieldConfig, File, FileUploadWithOptions, LocationInput, Office, PageHeader, Paragraph, RadioGroup, SelectField, SignatureField, TextAreaField, TextField, NumberField, NumberWithUnitField, DataField, NameField, PhoneField, IdField, DateRangeField, SelectDateRangeField, TimeField, AlphaPrintButton, HttpField, SearchField, ButtonField, LinkButtonField, VerificationStatus, QueryParamReaderField, QrReaderField, IdReaderField, LoaderField, AgeField } from './FieldConfig';
3
+ import { FieldValue, DataFieldValue, DateRangeFieldValue, SelectDateRangeValue, VerificationStatusValue, AgeValue, FieldUpdateValue } from './FieldValue';
4
4
  import { FullDocumentPath } from '../documents';
5
- import { AddressFieldValue, FileFieldValue, FileFieldWithOptionValue, NameFieldValue } from './CompositeFieldValue';
5
+ import { AddressFieldValue, FileFieldValue, FileFieldWithOptionValue, NameFieldValue, NumberWithUnitFieldValue } from './CompositeFieldValue';
6
6
  import { ActionType } from './ActionType';
7
7
  /**
8
8
  * Mapping of field types to Zod schema.
@@ -229,6 +229,24 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
229
229
  data?: any;
230
230
  }, {
231
231
  data?: any;
232
+ }>>> | z.ZodObject<{
233
+ numericValue: z.ZodOptional<z.ZodNumber>;
234
+ unit: z.ZodOptional<z.ZodString>;
235
+ }, "strip", z.ZodTypeAny, {
236
+ numericValue?: number | undefined;
237
+ unit?: string | undefined;
238
+ }, {
239
+ numericValue?: number | undefined;
240
+ unit?: string | undefined;
241
+ }> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
242
+ numericValue: z.ZodOptional<z.ZodNumber>;
243
+ unit: z.ZodOptional<z.ZodString>;
244
+ }, "strip", z.ZodTypeAny, {
245
+ numericValue?: number | undefined;
246
+ unit?: string | undefined;
247
+ }, {
248
+ numericValue?: number | undefined;
249
+ unit?: string | undefined;
232
250
  }>>> | z.ZodObject<{
233
251
  age: z.ZodNumber;
234
252
  asOfDateRef: z.ZodString;
@@ -409,6 +427,24 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
409
427
  data?: any;
410
428
  }, {
411
429
  data?: any;
430
+ }>, z.ZodObject<{
431
+ numericValue: z.ZodNumber;
432
+ unit: z.ZodString;
433
+ }, "strip", z.ZodTypeAny, {
434
+ numericValue: number;
435
+ unit: string;
436
+ }, {
437
+ numericValue: number;
438
+ unit: string;
439
+ }>, z.ZodObject<{
440
+ numericValue: z.ZodOptional<z.ZodNumber>;
441
+ unit: z.ZodOptional<z.ZodString>;
442
+ }, "strip", z.ZodTypeAny, {
443
+ numericValue?: number | undefined;
444
+ unit?: string | undefined;
445
+ }, {
446
+ numericValue?: number | undefined;
447
+ unit?: string | undefined;
412
448
  }>]>>;
413
449
  }, "strip", z.ZodTypeAny, {
414
450
  data: Record<string, string | number | boolean | {
@@ -448,6 +484,12 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
448
484
  data: Record<string, string>;
449
485
  } | {
450
486
  data?: any;
487
+ } | {
488
+ numericValue: number;
489
+ unit: string;
490
+ } | {
491
+ numericValue?: number | undefined;
492
+ unit?: string | undefined;
451
493
  } | {
452
494
  age: number;
453
495
  asOfDateRef: string;
@@ -493,6 +535,12 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
493
535
  data: Record<string, string>;
494
536
  } | {
495
537
  data?: any;
538
+ } | {
539
+ numericValue: number;
540
+ unit: string;
541
+ } | {
542
+ numericValue?: number | undefined;
543
+ unit?: string | undefined;
496
544
  } | {
497
545
  age: number;
498
546
  asOfDateRef: string;
@@ -644,6 +692,24 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
644
692
  data?: any;
645
693
  }, {
646
694
  data?: any;
695
+ }>, z.ZodObject<{
696
+ numericValue: z.ZodNumber;
697
+ unit: z.ZodString;
698
+ }, "strip", z.ZodTypeAny, {
699
+ numericValue: number;
700
+ unit: string;
701
+ }, {
702
+ numericValue: number;
703
+ unit: string;
704
+ }>, z.ZodObject<{
705
+ numericValue: z.ZodOptional<z.ZodNumber>;
706
+ unit: z.ZodOptional<z.ZodString>;
707
+ }, "strip", z.ZodTypeAny, {
708
+ numericValue?: number | undefined;
709
+ unit?: string | undefined;
710
+ }, {
711
+ numericValue?: number | undefined;
712
+ unit?: string | undefined;
647
713
  }>]>>;
648
714
  }, "strip", z.ZodTypeAny, {
649
715
  data: Record<string, string | number | boolean | {
@@ -683,6 +749,12 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
683
749
  data: Record<string, string>;
684
750
  } | {
685
751
  data?: any;
752
+ } | {
753
+ numericValue: number;
754
+ unit: string;
755
+ } | {
756
+ numericValue?: number | undefined;
757
+ unit?: string | undefined;
686
758
  } | {
687
759
  age: number;
688
760
  asOfDateRef: string;
@@ -728,6 +800,12 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
728
800
  data: Record<string, string>;
729
801
  } | {
730
802
  data?: any;
803
+ } | {
804
+ numericValue: number;
805
+ unit: string;
806
+ } | {
807
+ numericValue?: number | undefined;
808
+ unit?: string | undefined;
731
809
  } | {
732
810
  age: number;
733
811
  asOfDateRef: string;
@@ -970,6 +1048,13 @@ export declare const isNumberFieldType: (field: {
970
1048
  value: number;
971
1049
  config: NumberField;
972
1050
  };
1051
+ export declare const isNumberWithUnitFieldType: (field: {
1052
+ config: FieldConfig;
1053
+ value: FieldValue | FieldUpdateValue;
1054
+ }) => field is {
1055
+ value: NumberWithUnitFieldValue;
1056
+ config: NumberWithUnitField;
1057
+ };
973
1058
  export declare const isNameFieldType: (field: {
974
1059
  config: FieldConfig;
975
1060
  value: FieldValue;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AddressFieldValue, AddressFieldUpdateValue, FileFieldValue, FileFieldWithOptionValue, NameFieldValue, NameFieldUpdateValue, HttpFieldUpdateValue, QueryParamReaderFieldUpdateValue, QrReaderFieldValue, IdReaderFieldValue } from './CompositeFieldValue';
2
+ import { AddressFieldValue, AddressFieldUpdateValue, FileFieldValue, FileFieldWithOptionValue, NameFieldValue, NameFieldUpdateValue, NumberWithUnitFieldValue, NumberWithUnitFieldUpdateValue, HttpFieldUpdateValue, QueryParamReaderFieldUpdateValue, QrReaderFieldValue, IdReaderFieldValue } from './CompositeFieldValue';
3
3
  /**
4
4
  * FieldValues defined in this file are primitive field values.
5
5
  * FieldValues defined in CompositeFieldValue.ts are composed of multiple primitive field values (Address, File etc).
@@ -206,6 +206,24 @@ declare const FieldValuesWithoutDataField: z.ZodUnion<[z.ZodDiscriminatedUnion<"
206
206
  data?: any;
207
207
  }, {
208
208
  data?: any;
209
+ }>, z.ZodObject<{
210
+ numericValue: z.ZodNumber;
211
+ unit: z.ZodString;
212
+ }, "strip", z.ZodTypeAny, {
213
+ numericValue: number;
214
+ unit: string;
215
+ }, {
216
+ numericValue: number;
217
+ unit: string;
218
+ }>, z.ZodObject<{
219
+ numericValue: z.ZodOptional<z.ZodNumber>;
220
+ unit: z.ZodOptional<z.ZodString>;
221
+ }, "strip", z.ZodTypeAny, {
222
+ numericValue?: number | undefined;
223
+ unit?: string | undefined;
224
+ }, {
225
+ numericValue?: number | undefined;
226
+ unit?: string | undefined;
209
227
  }>]>;
210
228
  type FieldValuesWithoutDataField = z.infer<typeof FieldValuesWithoutDataField>;
211
229
  export declare const DataFieldValue: z.ZodOptional<z.ZodNullable<z.ZodObject<{
@@ -352,6 +370,24 @@ export declare const DataFieldValue: z.ZodOptional<z.ZodNullable<z.ZodObject<{
352
370
  data?: any;
353
371
  }, {
354
372
  data?: any;
373
+ }>, z.ZodObject<{
374
+ numericValue: z.ZodNumber;
375
+ unit: z.ZodString;
376
+ }, "strip", z.ZodTypeAny, {
377
+ numericValue: number;
378
+ unit: string;
379
+ }, {
380
+ numericValue: number;
381
+ unit: string;
382
+ }>, z.ZodObject<{
383
+ numericValue: z.ZodOptional<z.ZodNumber>;
384
+ unit: z.ZodOptional<z.ZodString>;
385
+ }, "strip", z.ZodTypeAny, {
386
+ numericValue?: number | undefined;
387
+ unit?: string | undefined;
388
+ }, {
389
+ numericValue?: number | undefined;
390
+ unit?: string | undefined;
355
391
  }>]>>;
356
392
  }, "strip", z.ZodTypeAny, {
357
393
  data: Record<string, string | number | boolean | {
@@ -391,6 +427,12 @@ export declare const DataFieldValue: z.ZodOptional<z.ZodNullable<z.ZodObject<{
391
427
  data: Record<string, string>;
392
428
  } | {
393
429
  data?: any;
430
+ } | {
431
+ numericValue: number;
432
+ unit: string;
433
+ } | {
434
+ numericValue?: number | undefined;
435
+ unit?: string | undefined;
394
436
  } | {
395
437
  age: number;
396
438
  asOfDateRef: string;
@@ -436,6 +478,12 @@ export declare const DataFieldValue: z.ZodOptional<z.ZodNullable<z.ZodObject<{
436
478
  data: Record<string, string>;
437
479
  } | {
438
480
  data?: any;
481
+ } | {
482
+ numericValue: number;
483
+ unit: string;
484
+ } | {
485
+ numericValue?: number | undefined;
486
+ unit?: string | undefined;
439
487
  } | {
440
488
  age: number;
441
489
  asOfDateRef: string;
@@ -448,17 +496,17 @@ export type DataFieldValue = z.infer<typeof DataFieldValue>;
448
496
  export type FieldValue = FieldValuesWithoutDataField | DataFieldValue;
449
497
  export declare const FieldValue: z.ZodType<FieldValue>;
450
498
  export declare function safeUnion<T extends [z.ZodTypeAny, ...z.ZodTypeAny[]]>(schemas: T): z.ZodType<z.TypeOf<T[number]>, z.ZodTypeDef, z.TypeOf<T[number]>>;
451
- export type FieldUpdateValue = z.infer<typeof TextValue> | z.infer<typeof DateValue> | z.infer<typeof TimeValue> | z.infer<typeof AgeUpdateValue> | z.infer<typeof AddressFieldUpdateValue> | z.infer<typeof DateRangeFieldValue> | z.infer<typeof SelectDateRangeValue> | z.infer<typeof CheckboxFieldValue> | z.infer<typeof NumberFieldValue> | z.infer<typeof FileFieldValue> | z.infer<typeof FileFieldWithOptionValue> | z.infer<typeof DataFieldValue> | z.infer<typeof NameFieldUpdateValue> | z.infer<typeof HttpFieldUpdateValue> | z.infer<typeof QueryParamReaderFieldUpdateValue>;
499
+ export type FieldUpdateValue = z.infer<typeof TextValue> | z.infer<typeof DateValue> | z.infer<typeof TimeValue> | z.infer<typeof AgeUpdateValue> | z.infer<typeof AddressFieldUpdateValue> | z.infer<typeof DateRangeFieldValue> | z.infer<typeof SelectDateRangeValue> | z.infer<typeof CheckboxFieldValue> | z.infer<typeof NumberFieldValue> | z.infer<typeof NumberWithUnitFieldUpdateValue> | z.infer<typeof FileFieldValue> | z.infer<typeof FileFieldWithOptionValue> | z.infer<typeof DataFieldValue> | z.infer<typeof NameFieldUpdateValue> | z.infer<typeof HttpFieldUpdateValue> | z.infer<typeof QueryParamReaderFieldUpdateValue>;
452
500
  export declare const FieldUpdateValue: z.ZodType<FieldUpdateValue>;
453
501
  /**
454
502
  * NOTE: This is an exception. We need schema as a type in order to generate schema dynamically.
455
503
  * */
456
- export type FieldValueSchema = typeof FileFieldValue | typeof FileFieldWithOptionValue | typeof CheckboxFieldValue | typeof AddressFieldValue | typeof NumberFieldValue | typeof DataFieldValue | typeof NameFieldValue | z.ZodString | z.ZodBoolean;
504
+ export type FieldValueSchema = typeof FileFieldValue | typeof FileFieldWithOptionValue | typeof CheckboxFieldValue | typeof AddressFieldValue | typeof NumberFieldValue | typeof NumberWithUnitFieldValue | typeof DataFieldValue | typeof NameFieldValue | z.ZodString | z.ZodBoolean;
457
505
  /**
458
506
  * NOTE: This is an exception. We need schema as a type in order to generate schema dynamically.
459
507
  *
460
508
  * FieldValueInputSchema uses Input types which have set optional values as nullish
461
509
  * */
462
- export type FieldUpdateValueSchema = typeof DateRangeFieldValue | typeof AgeValue | typeof SelectDateRangeValue | typeof FileFieldValue | typeof FileFieldWithOptionValue | typeof CheckboxFieldValue | typeof AddressFieldUpdateValue | typeof NumberFieldValue | typeof DataFieldValue | typeof NameFieldValue | typeof NameFieldUpdateValue | typeof HttpFieldUpdateValue | typeof QueryParamReaderFieldUpdateValue | typeof ButtonFieldValue | typeof QrReaderFieldValue | typeof IdReaderFieldValue | z.ZodString | z.ZodBoolean;
510
+ export type FieldUpdateValueSchema = typeof DateRangeFieldValue | typeof AgeValue | typeof SelectDateRangeValue | typeof FileFieldValue | typeof FileFieldWithOptionValue | typeof CheckboxFieldValue | typeof AddressFieldUpdateValue | typeof NumberFieldValue | typeof NumberWithUnitFieldValue | typeof NumberWithUnitFieldUpdateValue | typeof DataFieldValue | typeof NameFieldValue | typeof NameFieldUpdateValue | typeof HttpFieldUpdateValue | typeof QueryParamReaderFieldUpdateValue | typeof ButtonFieldValue | typeof QrReaderFieldValue | typeof IdReaderFieldValue | z.ZodString | z.ZodBoolean;
463
511
  export {};
464
512
  //# sourceMappingURL=FieldValue.d.ts.map
@@ -2,14 +2,26 @@
2
2
  * TemplateConfig defines configuration rules for system-based variables (e.g. $user.province).
3
3
  * They are currently used for providing default values in FieldConfig.
4
4
  */
5
+ import { UUID } from '../uuid';
5
6
  import { FieldValue } from './FieldValue';
6
7
  /**
7
8
  * Available system variables for configuration.
8
9
  */
9
10
  export type SystemVariables = {
10
- $user: {
11
- province: string;
12
- district: string;
11
+ user: {
12
+ id: string;
13
+ province?: string;
14
+ district?: string;
15
+ name?: string;
16
+ role?: string;
17
+ firstname?: string;
18
+ middlename?: string;
19
+ surname?: string;
20
+ primaryOfficeId?: UUID;
21
+ fullHonorificName?: string;
22
+ device?: string;
23
+ avatar?: string;
24
+ signature?: string;
13
25
  };
14
26
  $window: {
15
27
  location: {