@opencrvs/toolkit 1.9.6-rc.7b05346 → 1.9.6-rc.8a2de14

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.
@@ -4,6 +4,7 @@ import { ITokenPayload as TokenPayload, Scope } from '../authentication';
4
4
  import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
5
5
  import { userSerializer } from '../events/serializers/user/serializer';
6
6
  import { UUID } from '../uuid';
7
+ import { todayDateTimeValueSerializer } from '../events/serializers/date/serializer';
7
8
  /** @knipignore */
8
9
  export type JSONSchema = {
9
10
  $id: string;
@@ -64,6 +65,10 @@ type FieldReference = {
64
65
  $$field: string;
65
66
  $$subfield: string[];
66
67
  };
68
+ /**
69
+ * Generate conditional rules for current date
70
+ */
71
+ export declare const now: typeof todayDateTimeValueSerializer;
67
72
  /**
68
73
  *
69
74
  * Generate conditional rules for user.
@@ -1768,7 +1768,21 @@ 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.ZodString>;
1771
+ defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
1772
+ $$date: z.ZodOptional<z.ZodLiteral<"now">>;
1773
+ $$time: z.ZodOptional<z.ZodLiteral<"now">>;
1774
+ }, "strip", z.ZodTypeAny, {
1775
+ $$date?: "now" | undefined;
1776
+ $$time?: "now" | undefined;
1777
+ }, {
1778
+ $$date?: "now" | undefined;
1779
+ $$time?: "now" | undefined;
1780
+ }>, {
1781
+ $$date: "now";
1782
+ }, {
1783
+ $$date?: "now" | undefined;
1784
+ $$time?: "now" | undefined;
1785
+ }>, z.ZodString]>>;
1772
1786
  configuration: z.ZodOptional<z.ZodObject<{
1773
1787
  notice: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
1774
1788
  id: string;
@@ -1825,7 +1839,9 @@ declare const DateField: z.ZodObject<z.objectUtil.extendShape<{
1825
1839
  hideLabel?: boolean | undefined;
1826
1840
  uncorrectable?: boolean | undefined;
1827
1841
  analytics?: boolean | undefined;
1828
- defaultValue?: string | undefined;
1842
+ defaultValue?: string | {
1843
+ $$date: "now";
1844
+ } | undefined;
1829
1845
  configuration?: {
1830
1846
  notice?: TranslationConfig | undefined;
1831
1847
  } | undefined;
@@ -1890,7 +1906,10 @@ declare const DateField: z.ZodObject<z.objectUtil.extendShape<{
1890
1906
  hideLabel?: boolean | undefined;
1891
1907
  uncorrectable?: boolean | undefined;
1892
1908
  analytics?: boolean | undefined;
1893
- defaultValue?: string | undefined;
1909
+ defaultValue?: string | {
1910
+ $$date?: "now" | undefined;
1911
+ $$time?: "now" | undefined;
1912
+ } | undefined;
1894
1913
  configuration?: {
1895
1914
  notice?: {
1896
1915
  id: string;
@@ -2265,7 +2284,21 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
2265
2284
  analytics: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
2266
2285
  }, {
2267
2286
  type: z.ZodLiteral<"TIME">;
2268
- defaultValue: z.ZodOptional<z.ZodString>;
2287
+ defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodObject<{
2288
+ $$date: z.ZodOptional<z.ZodLiteral<"now">>;
2289
+ $$time: z.ZodOptional<z.ZodLiteral<"now">>;
2290
+ }, "strip", z.ZodTypeAny, {
2291
+ $$date?: "now" | undefined;
2292
+ $$time?: "now" | undefined;
2293
+ }, {
2294
+ $$date?: "now" | undefined;
2295
+ $$time?: "now" | undefined;
2296
+ }>, {
2297
+ $$time: "now";
2298
+ }, {
2299
+ $$date?: "now" | undefined;
2300
+ $$time?: "now" | undefined;
2301
+ }>, z.ZodString]>>;
2269
2302
  configuration: z.ZodOptional<z.ZodObject<{
2270
2303
  use12HourFormat: z.ZodOptional<z.ZodBoolean>;
2271
2304
  notice: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
@@ -2325,7 +2358,9 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
2325
2358
  hideLabel?: boolean | undefined;
2326
2359
  uncorrectable?: boolean | undefined;
2327
2360
  analytics?: boolean | undefined;
2328
- defaultValue?: string | undefined;
2361
+ defaultValue?: string | {
2362
+ $$time: "now";
2363
+ } | undefined;
2329
2364
  configuration?: {
2330
2365
  notice?: TranslationConfig | undefined;
2331
2366
  use12HourFormat?: boolean | undefined;
@@ -2391,7 +2426,10 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
2391
2426
  hideLabel?: boolean | undefined;
2392
2427
  uncorrectable?: boolean | undefined;
2393
2428
  analytics?: boolean | undefined;
2394
- defaultValue?: string | undefined;
2429
+ defaultValue?: string | {
2430
+ $$date?: "now" | undefined;
2431
+ $$time?: "now" | undefined;
2432
+ } | undefined;
2395
2433
  configuration?: {
2396
2434
  notice?: {
2397
2435
  id: string;
@@ -2402,6 +2440,7 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
2402
2440
  } | undefined;
2403
2441
  }>;
2404
2442
  export type TimeField = z.infer<typeof TimeField>;
2443
+ export type TimeField2 = z.input<typeof TimeField>;
2405
2444
  declare const DateRangeField: z.ZodObject<z.objectUtil.extendShape<{
2406
2445
  id: z.ZodEffects<z.ZodString, string, string>;
2407
2446
  label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
@@ -8,6 +8,8 @@ import { FieldValue } from './FieldValue';
8
8
  * Available system variables for configuration.
9
9
  */
10
10
  export type SystemVariables = {
11
+ $$date: string;
12
+ $$time: string;
11
13
  user: {
12
14
  id: string;
13
15
  province?: string;
@@ -38,6 +38,7 @@ __export(conditionals_exports, {
38
38
  isFieldReference: () => isFieldReference,
39
39
  never: () => never,
40
40
  not: () => not,
41
+ now: () => now,
41
42
  or: () => or,
42
43
  user: () => user
43
44
  });
@@ -106,6 +107,19 @@ function omitKeyDeep(obj, keyToRemove) {
106
107
  return newObj;
107
108
  }
108
109
 
110
+ // ../commons/src/events/serializers/date/serializer.ts
111
+ var import_zod2 = require("zod");
112
+ var SerializedNowDateTime = import_zod2.z.object({
113
+ $$date: import_zod2.z.literal("now").optional(),
114
+ $$time: import_zod2.z.literal("now").optional()
115
+ });
116
+ function todayDateTimeValueSerializer() {
117
+ return {
118
+ $$date: "now",
119
+ $$time: "now"
120
+ };
121
+ }
122
+
109
123
  // ../commons/src/conditionals/conditionals.ts
110
124
  function defineConditional(schema) {
111
125
  const schemaWithooutIDRef = omitKeyDeep(schema, "$id");
@@ -179,6 +193,7 @@ function wrapToPathOptional(condition, path) {
179
193
  };
180
194
  }, condition);
181
195
  }
196
+ var now = Object.assign(todayDateTimeValueSerializer, {});
182
197
  var user = Object.assign(userSerializer, {
183
198
  hasScope: (scope) => defineConditional({
184
199
  type: "object",