@opencrvs/toolkit 1.9.6-rc.3f7d879 → 1.9.6-rc.3fe98ad

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.
@@ -1768,7 +1768,13 @@ declare const DateField: z.ZodObject<z.objectUtil.extendShape<{
1768
1768
  analytics: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
1769
1769
  }, {
1770
1770
  type: z.ZodLiteral<"DATE">;
1771
- defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"$$now">, z.ZodString]>>;
1771
+ defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
1772
+ $$now: z.ZodLiteral<true>;
1773
+ }, "strip", z.ZodTypeAny, {
1774
+ $$now: true;
1775
+ }, {
1776
+ $$now: true;
1777
+ }>, z.ZodString]>>;
1772
1778
  configuration: z.ZodOptional<z.ZodObject<{
1773
1779
  notice: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
1774
1780
  id: string;
@@ -1825,7 +1831,9 @@ declare const DateField: z.ZodObject<z.objectUtil.extendShape<{
1825
1831
  hideLabel?: boolean | undefined;
1826
1832
  uncorrectable?: boolean | undefined;
1827
1833
  analytics?: boolean | undefined;
1828
- defaultValue?: string | undefined;
1834
+ defaultValue?: string | {
1835
+ $$now: true;
1836
+ } | undefined;
1829
1837
  configuration?: {
1830
1838
  notice?: TranslationConfig | undefined;
1831
1839
  } | undefined;
@@ -1890,7 +1898,9 @@ declare const DateField: z.ZodObject<z.objectUtil.extendShape<{
1890
1898
  hideLabel?: boolean | undefined;
1891
1899
  uncorrectable?: boolean | undefined;
1892
1900
  analytics?: boolean | undefined;
1893
- defaultValue?: string | undefined;
1901
+ defaultValue?: string | {
1902
+ $$now: true;
1903
+ } | undefined;
1894
1904
  configuration?: {
1895
1905
  notice?: {
1896
1906
  id: string;
@@ -2265,7 +2275,13 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
2265
2275
  analytics: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
2266
2276
  }, {
2267
2277
  type: z.ZodLiteral<"TIME">;
2268
- defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"$$now">, z.ZodString]>>;
2278
+ defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
2279
+ $$now: z.ZodLiteral<true>;
2280
+ }, "strip", z.ZodTypeAny, {
2281
+ $$now: true;
2282
+ }, {
2283
+ $$now: true;
2284
+ }>, z.ZodString]>>;
2269
2285
  configuration: z.ZodOptional<z.ZodObject<{
2270
2286
  use12HourFormat: z.ZodOptional<z.ZodBoolean>;
2271
2287
  notice: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
@@ -2325,7 +2341,9 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
2325
2341
  hideLabel?: boolean | undefined;
2326
2342
  uncorrectable?: boolean | undefined;
2327
2343
  analytics?: boolean | undefined;
2328
- defaultValue?: string | undefined;
2344
+ defaultValue?: string | {
2345
+ $$now: true;
2346
+ } | undefined;
2329
2347
  configuration?: {
2330
2348
  notice?: TranslationConfig | undefined;
2331
2349
  use12HourFormat?: boolean | undefined;
@@ -2391,7 +2409,9 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
2391
2409
  hideLabel?: boolean | undefined;
2392
2410
  uncorrectable?: boolean | undefined;
2393
2411
  analytics?: boolean | undefined;
2394
- defaultValue?: string | undefined;
2412
+ defaultValue?: string | {
2413
+ $$now: true;
2414
+ } | undefined;
2395
2415
  configuration?: {
2396
2416
  notice?: {
2397
2417
  id: string;
@@ -230,6 +230,15 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
230
230
  }, {
231
231
  data?: any;
232
232
  }>>> | z.ZodObject<{
233
+ numericValue: z.ZodNumber;
234
+ unit: z.ZodString;
235
+ }, "strip", z.ZodTypeAny, {
236
+ numericValue: number;
237
+ unit: string;
238
+ }, {
239
+ numericValue: number;
240
+ unit: string;
241
+ }> | z.ZodObject<{
233
242
  numericValue: z.ZodOptional<z.ZodNumber>;
234
243
  unit: z.ZodOptional<z.ZodString>;
235
244
  }, "strip", z.ZodTypeAny, {
@@ -239,6 +248,15 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
239
248
  numericValue?: number | undefined;
240
249
  unit?: string | undefined;
241
250
  }> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
251
+ numericValue: z.ZodNumber;
252
+ unit: z.ZodString;
253
+ }, "strip", z.ZodTypeAny, {
254
+ numericValue: number;
255
+ unit: string;
256
+ }, {
257
+ numericValue: number;
258
+ unit: string;
259
+ }>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
242
260
  numericValue: z.ZodOptional<z.ZodNumber>;
243
261
  unit: z.ZodOptional<z.ZodString>;
244
262
  }, "strip", z.ZodTypeAny, {
@@ -109,9 +109,11 @@ function omitKeyDeep(obj, keyToRemove) {
109
109
 
110
110
  // ../commons/src/events/serializers/date/serializer.ts
111
111
  var import_zod2 = require("zod");
112
- var SerializedNowDateTime = import_zod2.z.literal("$$now");
112
+ var SerializedNowDateTime = import_zod2.z.object({
113
+ $$now: import_zod2.z.literal(true)
114
+ });
113
115
  function todayDateTimeValueSerializer() {
114
- return "$$now";
116
+ return { $$now: true };
115
117
  }
116
118
 
117
119
  // ../commons/src/conditionals/conditionals.ts
@@ -1908,9 +1908,11 @@ var SearchScopeAccessLevels = {
1908
1908
 
1909
1909
  // ../commons/src/events/serializers/date/serializer.ts
1910
1910
  var import_zod15 = require("zod");
1911
- var SerializedNowDateTime = import_zod15.z.literal("$$now");
1911
+ var SerializedNowDateTime = import_zod15.z.object({
1912
+ $$now: import_zod15.z.literal(true)
1913
+ });
1912
1914
  function todayDateTimeValueSerializer() {
1913
- return "$$now";
1915
+ return { $$now: true };
1914
1916
  }
1915
1917
 
1916
1918
  // ../commons/src/events/FieldConfig.ts
@@ -3007,7 +3009,7 @@ function mapFieldTypeToZod(field3, actionType) {
3007
3009
  schema = NumberFieldValue;
3008
3010
  break;
3009
3011
  case FieldType.NUMBER_WITH_UNIT:
3010
- schema = NumberWithUnitFieldUpdateValue;
3012
+ schema = field3.required ? NumberWithUnitFieldValue : NumberWithUnitFieldUpdateValue;
3011
3013
  break;
3012
3014
  case FieldType.CHECKBOX:
3013
3015
  schema = CheckboxFieldValue;
@@ -3398,7 +3400,7 @@ function isFieldVisible(field3, form, context) {
3398
3400
  }
3399
3401
  function isFieldEmptyAndNotRequired(field3, form) {
3400
3402
  const fieldValue = form[field3.id];
3401
- return !field3.required && (fieldValue === void 0 || fieldValue === "");
3403
+ return !field3.required && (fieldValue === void 0 || fieldValue === "" || fieldValue && typeof fieldValue === "object" && Object.values(fieldValue).every((v) => v === void 0 || v === ""));
3402
3404
  }
3403
3405
  function isFieldEnabled(field3, form, context) {
3404
3406
  return isFieldConditionMet(field3, form, ConditionalType.ENABLE, context);
@@ -8887,12 +8889,8 @@ var window2 = () => ({
8887
8889
  }
8888
8890
  }
8889
8891
  });
8890
- var KNOWN_SYSTEM_KEYS = ["$$date", "$$time"];
8891
8892
  function isTemplateVariable(value) {
8892
- if (typeof value === "string" && KNOWN_SYSTEM_KEYS.includes(value)) {
8893
- return true;
8894
- }
8895
- return false;
8893
+ return typeof value === "string" && value.startsWith("$");
8896
8894
  }
8897
8895
  function isFieldValue(value) {
8898
8896
  return FieldValue.safeParse(value).success;
@@ -1430,9 +1430,11 @@ var SearchQuery = import_zod14.z.object({
1430
1430
 
1431
1431
  // ../commons/src/events/serializers/date/serializer.ts
1432
1432
  var import_zod15 = require("zod");
1433
- var SerializedNowDateTime = import_zod15.z.literal("$$now");
1433
+ var SerializedNowDateTime = import_zod15.z.object({
1434
+ $$now: import_zod15.z.literal(true)
1435
+ });
1434
1436
  function todayDateTimeValueSerializer() {
1435
- return "$$now";
1437
+ return { $$now: true };
1436
1438
  }
1437
1439
 
1438
1440
  // ../commons/src/events/FieldConfig.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.9.6-rc.3f7d879",
3
+ "version": "1.9.6-rc.3fe98ad",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {