@opencrvs/toolkit 2.1.0-rc.462d2a9 → 2.1.0-rc.468b2be

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.
Files changed (32) hide show
  1. package/dist/application-config/index.js +190 -200
  2. package/dist/commons/api/router.d.ts +111 -7
  3. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  4. package/dist/commons/conditionals/validate.d.ts +4 -5
  5. package/dist/commons/events/ActionConfig.d.ts +0 -21
  6. package/dist/commons/events/ActionDocument.d.ts +7 -1
  7. package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -6
  8. package/dist/commons/events/AuditLog.d.ts +37 -0
  9. package/dist/commons/events/CountryConfigQueryInput.d.ts +0 -18
  10. package/dist/commons/events/EventIndex.d.ts +24 -5
  11. package/dist/commons/events/EventMetadata.d.ts +0 -1
  12. package/dist/commons/events/FieldConfig.d.ts +5 -5
  13. package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
  14. package/dist/commons/events/FieldValue.d.ts +2 -2
  15. package/dist/commons/events/Flag.d.ts +0 -48
  16. package/dist/commons/events/PlainDate.d.ts +8 -0
  17. package/dist/commons/events/WorkqueueConfig.d.ts +12 -27
  18. package/dist/commons/events/index.d.ts +1 -0
  19. package/dist/commons/events/locationPayloads.d.ts +95 -0
  20. package/dist/commons/events/locations.d.ts +191 -11
  21. package/dist/commons/events/mocks.test.utils.d.ts +46 -2
  22. package/dist/commons/events/test.utils.d.ts +5 -5
  23. package/dist/conditionals/index.js +56 -303
  24. package/dist/events/index.js +3617 -3507
  25. package/dist/notification/index.js +1067 -1529
  26. package/dist/scopes/index.d.ts +3 -251
  27. package/dist/scopes/index.js +56 -304
  28. package/opencrvs-toolkit-2.1.0-rc.468b2be.tgz +0 -0
  29. package/package.json +3 -2
  30. package/tsconfig.tsbuildinfo +1 -1
  31. package/dist/commons/events/ActionStatus.d.ts +0 -14
  32. package/opencrvs-toolkit-2.1.0-rc.462d2a9.tgz +0 -0
@@ -314,7 +314,6 @@ export declare const WorkqueueConfig: z.ZodObject<{
314
314
  readonly CORRECTION_REQUESTED: 'correction-requested';
315
315
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
316
316
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
317
- readonly SEALED: 'sealed';
318
317
  }>]>, z.ZodString]>>>;
319
318
  noneOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
320
319
  readonly INCOMPLETE: 'incomplete';
@@ -322,7 +321,6 @@ export declare const WorkqueueConfig: z.ZodObject<{
322
321
  readonly CORRECTION_REQUESTED: 'correction-requested';
323
322
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
324
323
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
325
- readonly SEALED: 'sealed';
326
324
  }>]>, z.ZodString]>>>;
327
325
  allOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
328
326
  readonly INCOMPLETE: 'incomplete';
@@ -330,7 +328,6 @@ export declare const WorkqueueConfig: z.ZodObject<{
330
328
  readonly CORRECTION_REQUESTED: 'correction-requested';
331
329
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
332
330
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
333
- readonly SEALED: 'sealed';
334
331
  }>]>, z.ZodString]>>>;
335
332
  }, z.core.$strip>>>;
336
333
  data: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
@@ -634,7 +631,6 @@ export declare const WorkqueueConfig: z.ZodObject<{
634
631
  readonly CORRECTION_REQUESTED: 'correction-requested';
635
632
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
636
633
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
637
- readonly SEALED: 'sealed';
638
634
  }>]>, z.ZodString]>>>;
639
635
  noneOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
640
636
  readonly INCOMPLETE: 'incomplete';
@@ -642,7 +638,6 @@ export declare const WorkqueueConfig: z.ZodObject<{
642
638
  readonly CORRECTION_REQUESTED: 'correction-requested';
643
639
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
644
640
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
645
- readonly SEALED: 'sealed';
646
641
  }>]>, z.ZodString]>>>;
647
642
  allOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
648
643
  readonly INCOMPLETE: 'incomplete';
@@ -650,7 +645,6 @@ export declare const WorkqueueConfig: z.ZodObject<{
650
645
  readonly CORRECTION_REQUESTED: 'correction-requested';
651
646
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
652
647
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
653
- readonly SEALED: 'sealed';
654
648
  }>]>, z.ZodString]>>>;
655
649
  }, z.core.$strip>>>;
656
650
  data: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
@@ -1376,7 +1370,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
1376
1370
  readonly CORRECTION_REQUESTED: 'correction-requested';
1377
1371
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
1378
1372
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
1379
- readonly SEALED: 'sealed';
1380
1373
  }>]>, z.ZodString]>>>;
1381
1374
  noneOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
1382
1375
  readonly INCOMPLETE: 'incomplete';
@@ -1384,7 +1377,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
1384
1377
  readonly CORRECTION_REQUESTED: 'correction-requested';
1385
1378
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
1386
1379
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
1387
- readonly SEALED: 'sealed';
1388
1380
  }>]>, z.ZodString]>>>;
1389
1381
  allOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
1390
1382
  readonly INCOMPLETE: 'incomplete';
@@ -1392,7 +1384,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
1392
1384
  readonly CORRECTION_REQUESTED: 'correction-requested';
1393
1385
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
1394
1386
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
1395
- readonly SEALED: 'sealed';
1396
1387
  }>]>, z.ZodString]>>>;
1397
1388
  }, z.core.$strip>>>;
1398
1389
  data: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
@@ -1695,7 +1686,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
1695
1686
  readonly CORRECTION_REQUESTED: 'correction-requested';
1696
1687
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
1697
1688
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
1698
- readonly SEALED: 'sealed';
1699
1689
  }>]>, z.ZodString]>>>;
1700
1690
  noneOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
1701
1691
  readonly INCOMPLETE: 'incomplete';
@@ -1703,7 +1693,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
1703
1693
  readonly CORRECTION_REQUESTED: 'correction-requested';
1704
1694
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
1705
1695
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
1706
- readonly SEALED: 'sealed';
1707
1696
  }>]>, z.ZodString]>>>;
1708
1697
  allOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
1709
1698
  readonly INCOMPLETE: 'incomplete';
@@ -1711,7 +1700,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
1711
1700
  readonly CORRECTION_REQUESTED: 'correction-requested';
1712
1701
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
1713
1702
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
1714
- readonly SEALED: 'sealed';
1715
1703
  }>]>, z.ZodString]>>>;
1716
1704
  }, z.core.$strip>>>;
1717
1705
  data: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
@@ -2015,7 +2003,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
2015
2003
  readonly CORRECTION_REQUESTED: 'correction-requested';
2016
2004
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
2017
2005
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
2018
- readonly SEALED: 'sealed';
2019
2006
  }>]>, z.ZodString]>>>;
2020
2007
  noneOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
2021
2008
  readonly INCOMPLETE: 'incomplete';
@@ -2023,7 +2010,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
2023
2010
  readonly CORRECTION_REQUESTED: 'correction-requested';
2024
2011
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
2025
2012
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
2026
- readonly SEALED: 'sealed';
2027
2013
  }>]>, z.ZodString]>>>;
2028
2014
  allOf: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodEnum<{
2029
2015
  readonly INCOMPLETE: 'incomplete';
@@ -2031,7 +2017,6 @@ export declare const WorkqueueConfigInput: z.ZodObject<{
2031
2017
  readonly CORRECTION_REQUESTED: 'correction-requested';
2032
2018
  readonly POTENTIAL_DUPLICATE: 'potential-duplicate';
2033
2019
  readonly EDIT_IN_PROGRESS: 'edit-in-progress';
2034
- readonly SEALED: 'sealed';
2035
2020
  }>]>, z.ZodString]>>>;
2036
2021
  }, z.core.$strip>>>;
2037
2022
  data: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
@@ -2053,11 +2038,11 @@ export declare function defineWorkqueue(workqueueInput: WorkqueueConfigInput): {
2053
2038
  clauses: {
2054
2039
  eventType?: string | undefined;
2055
2040
  status?: {
2056
- type: "exact";
2057
- term: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED";
2058
- } | {
2059
2041
  type: "anyOf";
2060
2042
  terms: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[];
2043
+ } | {
2044
+ type: "exact";
2045
+ term: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED";
2061
2046
  } | undefined;
2062
2047
  createdAt?: {
2063
2048
  type: "range";
@@ -2192,11 +2177,11 @@ export declare function defineWorkqueue(workqueueInput: WorkqueueConfigInput): {
2192
2177
  clauses: {
2193
2178
  eventType?: string | undefined;
2194
2179
  status?: {
2195
- type: "exact";
2196
- term: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED";
2197
- } | {
2198
2180
  type: "anyOf";
2199
2181
  terms: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[];
2182
+ } | {
2183
+ type: "exact";
2184
+ term: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED";
2200
2185
  } | undefined;
2201
2186
  createdAt?: {
2202
2187
  type: "range";
@@ -2364,11 +2349,11 @@ export declare function defineWorkqueues(workqueues: WorkqueueConfigInputWithV19
2364
2349
  clauses: {
2365
2350
  eventType?: string | undefined;
2366
2351
  status?: {
2367
- type: "exact";
2368
- term: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED";
2369
- } | {
2370
2352
  type: "anyOf";
2371
2353
  terms: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[];
2354
+ } | {
2355
+ type: "exact";
2356
+ term: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED";
2372
2357
  } | undefined;
2373
2358
  createdAt?: {
2374
2359
  type: "range";
@@ -2503,11 +2488,11 @@ export declare function defineWorkqueues(workqueues: WorkqueueConfigInputWithV19
2503
2488
  clauses: {
2504
2489
  eventType?: string | undefined;
2505
2490
  status?: {
2506
- type: "exact";
2507
- term: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED";
2508
- } | {
2509
2491
  type: "anyOf";
2510
2492
  terms: ("ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED")[];
2493
+ } | {
2494
+ type: "exact";
2495
+ term: "ARCHIVED" | "CREATED" | "DECLARED" | "NOTIFIED" | "REGISTERED";
2511
2496
  } | undefined;
2512
2497
  createdAt?: {
2513
2498
  type: "range";
@@ -45,6 +45,7 @@ export * from './field';
45
45
  export * from './Flag';
46
46
  export * from './event';
47
47
  export * from './locations';
48
+ export * from './locationPayloads';
48
49
  export { UUID } from '../uuid';
49
50
  export { DocumentPath } from '../documents';
50
51
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,95 @@
1
+ import * as z from 'zod/v4';
2
+ /**
3
+ * Input payload for creating a location: the identity fields (parent and
4
+ * locationType are set once, immutable thereafter) plus the first version.
5
+ * `id` and `versionId` may be supplied by the caller for idempotent retries.
6
+ * `effectiveFrom` defaults to the beginning-of-time sentinel on the server.
7
+ */
8
+ export declare const CreateLocationPayload: z.ZodObject<{
9
+ id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
10
+ versionId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
11
+ name: z.ZodString;
12
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
14
+ locationType: z.ZodNullable<z.ZodString>;
15
+ effectiveFrom: z.ZodOptional<z.ZodISODate>;
16
+ status: z.ZodDefault<z.ZodEnum<{
17
+ active: "active";
18
+ inactive: "inactive";
19
+ }>>;
20
+ }, z.core.$strip>;
21
+ export type CreateLocationPayload = z.infer<typeof CreateLocationPayload>;
22
+ /**
23
+ * Input payload for appending a new version to a location. A full snapshot of
24
+ * every versioned field is required — omitted does not mean unchanged. The
25
+ * schema is strict: identity fields (`administrativeAreaId`, `locationType`)
26
+ * are rejected rather than ignored, as they cannot change. `lastVersionId`
27
+ * is the optimistic-concurrency check: it must be the id of the last element
28
+ * the caller observed. `effectiveFrom` defaults to today on the server;
29
+ * supply it explicitly for idempotent retries.
30
+ */
31
+ export declare const UpdateLocationPayload: z.ZodObject<{
32
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
33
+ versionId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
34
+ name: z.ZodString;
35
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ status: z.ZodEnum<{
37
+ active: "active";
38
+ inactive: "inactive";
39
+ }>;
40
+ effectiveFrom: z.ZodOptional<z.ZodISODate>;
41
+ lastVersionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
42
+ }, z.core.$strict>;
43
+ export type UpdateLocationPayload = z.infer<typeof UpdateLocationPayload>;
44
+ /**
45
+ * Input payload for withdrawing a pending (future-dated) version element.
46
+ * Only elements whose `effectiveFrom` has not yet passed can be withdrawn.
47
+ */
48
+ export declare const WithdrawLocationVersionPayload: z.ZodObject<{
49
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
50
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
51
+ }, z.core.$strip>;
52
+ export type WithdrawLocationVersionPayload = z.infer<typeof WithdrawLocationVersionPayload>;
53
+ /**
54
+ * Administrative-area twin of {@link CreateLocationPayload}: `parentId`
55
+ * instead of `administrativeAreaId`, no `locationType`.
56
+ */
57
+ export declare const CreateAdministrativeAreaPayload: z.ZodObject<{
58
+ id: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
59
+ versionId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
60
+ name: z.ZodString;
61
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
62
+ parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
63
+ effectiveFrom: z.ZodOptional<z.ZodISODate>;
64
+ status: z.ZodDefault<z.ZodEnum<{
65
+ active: "active";
66
+ inactive: "inactive";
67
+ }>>;
68
+ }, z.core.$strip>;
69
+ export type CreateAdministrativeAreaPayload = z.infer<typeof CreateAdministrativeAreaPayload>;
70
+ /**
71
+ * Administrative-area twin of {@link UpdateLocationPayload} — strict for the
72
+ * same reason: the identity field (`parentId`) is rejected, not ignored.
73
+ */
74
+ export declare const UpdateAdministrativeAreaPayload: z.ZodObject<{
75
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
76
+ versionId: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
77
+ name: z.ZodString;
78
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
79
+ status: z.ZodEnum<{
80
+ active: "active";
81
+ inactive: "inactive";
82
+ }>;
83
+ effectiveFrom: z.ZodOptional<z.ZodISODate>;
84
+ lastVersionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
85
+ }, z.core.$strict>;
86
+ export type UpdateAdministrativeAreaPayload = z.infer<typeof UpdateAdministrativeAreaPayload>;
87
+ /**
88
+ * Administrative-area twin of {@link WithdrawLocationVersionPayload}.
89
+ */
90
+ export declare const WithdrawAdministrativeAreaVersionPayload: z.ZodObject<{
91
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
92
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
93
+ }, z.core.$strip>;
94
+ export type WithdrawAdministrativeAreaVersionPayload = z.infer<typeof WithdrawAdministrativeAreaVersionPayload>;
95
+ //# sourceMappingURL=locationPayloads.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { UUID } from '../uuid';
2
2
  import * as z from 'zod/v4';
3
+ import { PlainDate } from './PlainDate';
3
4
  import { EventIndex } from './EventIndex';
4
5
  import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
5
6
  import { RecordScopeV2, UserScopeV2 } from '../scopes';
@@ -11,12 +12,46 @@ export declare const LocationTypeV1: z.ZodEnum<{
11
12
  HEALTH_FACILITY: "HEALTH_FACILITY";
12
13
  }>;
13
14
  export type LocationTypeV1 = z.infer<typeof LocationTypeV1>;
15
+ export declare const LocationStatus: z.ZodEnum<{
16
+ active: "active";
17
+ inactive: "inactive";
18
+ }>;
19
+ export type LocationStatus = z.infer<typeof LocationStatus>;
20
+ /**
21
+ * A single element of the append-only `versions` history of a location or
22
+ * administrative area. Versions are sorted ascending by `effectiveFrom`
23
+ * ('0001-01-01' is used as the beginning-of-time sentinel).
24
+ */
25
+ export declare const LocationVersion: z.ZodObject<{
26
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
27
+ effectiveFrom: z.ZodISODate;
28
+ name: z.ZodString;
29
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ status: z.ZodEnum<{
31
+ active: "active";
32
+ inactive: "inactive";
33
+ }>;
34
+ }, z.core.$strip>;
35
+ export type LocationVersion = z.infer<typeof LocationVersion>;
14
36
  export declare const AdministrativeArea: z.ZodObject<{
15
37
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
16
38
  name: z.ZodString;
17
39
  externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
40
  parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
19
- validUntil: z.ZodNullable<z.ZodISODateTime>;
41
+ status: z.ZodEnum<{
42
+ active: "active";
43
+ inactive: "inactive";
44
+ }>;
45
+ versions: z.ZodArray<z.ZodObject<{
46
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
47
+ effectiveFrom: z.ZodISODate;
48
+ name: z.ZodString;
49
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ status: z.ZodEnum<{
51
+ active: "active";
52
+ inactive: "inactive";
53
+ }>;
54
+ }, z.core.$strip>>;
20
55
  }, z.core.$strip>;
21
56
  export type AdministrativeArea = z.infer<typeof AdministrativeArea>;
22
57
  export declare const Location: z.ZodObject<{
@@ -24,10 +59,121 @@ export declare const Location: z.ZodObject<{
24
59
  name: z.ZodString;
25
60
  externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
61
  administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
27
- validUntil: z.ZodNullable<z.ZodISODateTime>;
28
62
  locationType: z.ZodNullable<z.ZodString>;
63
+ status: z.ZodEnum<{
64
+ active: "active";
65
+ inactive: "inactive";
66
+ }>;
67
+ versions: z.ZodArray<z.ZodObject<{
68
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
69
+ effectiveFrom: z.ZodISODate;
70
+ name: z.ZodString;
71
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
+ status: z.ZodEnum<{
73
+ active: "active";
74
+ inactive: "inactive";
75
+ }>;
76
+ }, z.core.$strip>>;
29
77
  }, z.core.$strip>;
30
78
  export type Location = z.infer<typeof Location>;
79
+ /**
80
+ * TEMPORARY — client-side view of {@link AdministrativeArea} with the
81
+ * server-flattened `name`, `status` and `externalId` removed, leaving exactly
82
+ * identity + versions. Every name/status read is thereby forced through the
83
+ * anchored resolution utilities ({@link resolveVersion}, {@link resolvePath})
84
+ * at compile time. Delete this type when the contract migration removes the
85
+ * flat fields from the server schema, at which point the wire type itself
86
+ * becomes identity + versions.
87
+ */
88
+ export declare const ClientAdministrativeArea: z.ZodObject<{
89
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
90
+ parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
91
+ versions: z.ZodArray<z.ZodObject<{
92
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
93
+ effectiveFrom: z.ZodISODate;
94
+ name: z.ZodString;
95
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
96
+ status: z.ZodEnum<{
97
+ active: "active";
98
+ inactive: "inactive";
99
+ }>;
100
+ }, z.core.$strip>>;
101
+ }, z.core.$strip>;
102
+ export type ClientAdministrativeArea = z.infer<typeof ClientAdministrativeArea>;
103
+ /**
104
+ * TEMPORARY — client-side view of {@link Location} with the server-flattened
105
+ * `name`, `status` and `externalId` removed, leaving exactly identity +
106
+ * versions. See {@link ClientAdministrativeArea} for the full rationale and
107
+ * deletion condition.
108
+ */
109
+ export declare const ClientLocation: z.ZodObject<{
110
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
111
+ administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
112
+ locationType: z.ZodNullable<z.ZodString>;
113
+ versions: z.ZodArray<z.ZodObject<{
114
+ versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
115
+ effectiveFrom: z.ZodISODate;
116
+ name: z.ZodString;
117
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
118
+ status: z.ZodEnum<{
119
+ active: "active";
120
+ inactive: "inactive";
121
+ }>;
122
+ }, z.core.$strip>>;
123
+ }, z.core.$strip>;
124
+ export type ClientLocation = z.infer<typeof ClientLocation>;
125
+ /**
126
+ * Strips the server-flattened fields from a location as it enters the
127
+ * client's cached maps. The wire format keeps the flat fields for
128
+ * compatibility; the cache must not, or devices would keep rendering names
129
+ * flattened before a future-dated version takes effect.
130
+ */
131
+ export declare function toClientLocation(location: Location): ClientLocation;
132
+ /** See {@link toClientLocation}. */
133
+ export declare function toClientAdministrativeArea(area: AdministrativeArea): ClientAdministrativeArea;
134
+ /**
135
+ * Input payload for the locations `set` mutation. Carries only the seedable
136
+ * identity and hierarchy fields — version history is managed by the server.
137
+ */
138
+ export declare const SetLocationPayload: z.ZodObject<{
139
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
140
+ name: z.ZodString;
141
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
142
+ administrativeAreaId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
143
+ locationType: z.ZodNullable<z.ZodString>;
144
+ }, z.core.$strip>;
145
+ export type SetLocationPayload = z.infer<typeof SetLocationPayload>;
146
+ /**
147
+ * Input payload for the administrative areas `set` mutation. Carries only the
148
+ * seedable identity and hierarchy fields — version history is managed by the
149
+ * server.
150
+ */
151
+ export declare const SetAdministrativeAreaPayload: z.ZodObject<{
152
+ id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
153
+ name: z.ZodString;
154
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
155
+ parentId: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>;
156
+ }, z.core.$strip>;
157
+ export type SetAdministrativeAreaPayload = z.infer<typeof SetAdministrativeAreaPayload>;
158
+ /**
159
+ * Resolves the version in effect at the given anchor date.
160
+ *
161
+ * Returns the element with the greatest `effectiveFrom` that is less than or
162
+ * equal to `anchor`, falling back to the earliest element when the anchor
163
+ * precedes all versions. Assumes `versions` is sorted ascending by
164
+ * `effectiveFrom`. Both `effectiveFrom` and `anchor` are 'YYYY-MM-DD' strings,
165
+ * so plain string comparison is correct.
166
+ */
167
+ export declare function resolveVersion<T extends {
168
+ effectiveFrom: string;
169
+ }>(versions: T[], anchor: string): T;
170
+ /**
171
+ * Whether the entity holds the given externalId with active status at the
172
+ * anchor date or at any point after it. Used for point-in-time uniqueness of
173
+ * external codes: a new holder starting at `anchor` collides when an existing
174
+ * holder is (or is scheduled to be) active with the code from then on.
175
+ */
176
+ export declare function hasActiveExternalIdOnOrAfter(versions: LocationVersion[], externalId: string, anchor: string): boolean;
31
177
  type WrapArrayPreserveNullish<V> = V extends readonly any[] ? V : NonNullable<V>[] | Extract<V, null | undefined>;
32
178
  /**
33
179
  * For type T, convert fields K to arrays. If field is string, convert to string[].
@@ -74,13 +220,10 @@ export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, use
74
220
  * One of the scopes must allow access for the event to be accessible.
75
221
  */
76
222
  export declare function userCanAccessEventWithScopes(event: Partial<EventIndexWithAdministrativeHierarchy>, scopes: RecordScopeV2[], user: UserContext | SystemContext, customActionType?: string): boolean;
77
- export declare function getAdministrativeAreaHierarchy(administrativeAreaId: string | undefined | null, administrativeAreas: Map<UUID, AdministrativeArea>): {
78
- id: string & z.$brand<"UUID">;
79
- name: string;
80
- externalId?: string | null | undefined;
81
- parentId: (string & z.$brand<"UUID">) | null;
82
- validUntil: string | null;
83
- }[];
223
+ export declare function getAdministrativeAreaHierarchy<A extends {
224
+ id: UUID;
225
+ parentId: UUID | null;
226
+ }>(administrativeAreaId: string | undefined | null, administrativeAreas: Map<UUID, A>): A[];
84
227
  /**
85
228
  * Resolves a location or administrative area UUID into a root-first hierarchy of UUIDs.
86
229
  *
@@ -92,8 +235,45 @@ export declare function getAdministrativeAreaHierarchy(administrativeAreaId: str
92
235
  * so the result is reversed to match the root-first convention used by the server.
93
236
  */
94
237
  export declare function getLocationHierarchy(selectedId: UUID, context: {
95
- administrativeAreas: Map<UUID, AdministrativeArea>;
96
- locations: Map<UUID, Location>;
238
+ administrativeAreas: Map<UUID, {
239
+ id: UUID;
240
+ parentId: UUID | null;
241
+ }>;
242
+ locations: Map<UUID, {
243
+ id: UUID;
244
+ administrativeAreaId: UUID | null;
245
+ }>;
97
246
  }): UUID[];
247
+ /**
248
+ * A node of an anchored hierarchy path: the identity id plus the name and
249
+ * status in effect at the anchor date.
250
+ */
251
+ export type ResolvedPathNode = {
252
+ id: UUID;
253
+ name: string;
254
+ status: LocationStatus;
255
+ };
256
+ /**
257
+ * Resolves a location or administrative area id into its root-first
258
+ * hierarchy path — leaf included — with every node's name and status
259
+ * resolved at the anchor date.
260
+ *
261
+ * The parent chain is identity-level and fixed for life, so the chain is
262
+ * constant and only each node's name/status varies with the anchor. Status is
263
+ * returned for callers that filter on it; an inactive node still resolves to
264
+ * its name. Returns an empty array for an unknown id.
265
+ */
266
+ export declare function resolvePath(locationId: UUID, anchor: PlainDate, context: {
267
+ administrativeAreas: Map<UUID, {
268
+ id: UUID;
269
+ parentId: UUID | null;
270
+ versions: LocationVersion[];
271
+ }>;
272
+ locations: Map<UUID, {
273
+ id: UUID;
274
+ administrativeAreaId: UUID | null;
275
+ versions: LocationVersion[];
276
+ }>;
277
+ }): ResolvedPathNode[];
98
278
  export {};
99
279
  //# sourceMappingURL=locations.d.ts.map
@@ -6,14 +6,58 @@ export declare const V2_DEFAULT_MOCK_LOCATIONS_MAP: Map<string & import("zod").$
6
6
  name: string;
7
7
  externalId?: string | null | undefined;
8
8
  administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
9
- validUntil: string | null;
10
9
  locationType: string | null;
10
+ status: "active" | "inactive";
11
+ versions: {
12
+ versionId: string & import("zod").$brand<"UUID">;
13
+ effectiveFrom: string;
14
+ name: string;
15
+ externalId?: string | null | undefined;
16
+ status: "active" | "inactive";
17
+ }[];
11
18
  }>;
12
19
  export declare const V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: Map<string & import("zod").$brand<"UUID">, {
13
20
  id: string & import("zod").$brand<"UUID">;
14
21
  name: string;
15
22
  externalId?: string | null | undefined;
16
23
  parentId: (string & import("zod").$brand<"UUID">) | null;
17
- validUntil: string | null;
24
+ status: "active" | "inactive";
25
+ versions: {
26
+ versionId: string & import("zod").$brand<"UUID">;
27
+ effectiveFrom: string;
28
+ name: string;
29
+ externalId?: string | null | undefined;
30
+ status: "active" | "inactive";
31
+ }[];
32
+ }>;
33
+ /**
34
+ * Stripped view of {@link V2_DEFAULT_MOCK_LOCATIONS_MAP} matching what the
35
+ * client's cached location map actually holds at runtime (identity +
36
+ * versions only). Use this — not the wire-format map above — wherever a test
37
+ * stands in for `useLocations().getLocations.useSuspenseQuery()`.
38
+ */
39
+ export declare const V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP: Map<string & import("zod").$brand<"UUID">, {
40
+ id: string & import("zod").$brand<"UUID">;
41
+ administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
42
+ locationType: string | null;
43
+ versions: {
44
+ versionId: string & import("zod").$brand<"UUID">;
45
+ effectiveFrom: string;
46
+ name: string;
47
+ externalId?: string | null | undefined;
48
+ status: "active" | "inactive";
49
+ }[];
50
+ }>;
51
+ /** See {@link V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP}. */
52
+ export declare const V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP: Map<string & import("zod").$brand<"UUID">, {
53
+ id: string & import("zod").$brand<"UUID">;
54
+ parentId: (string & import("zod").$brand<"UUID">) | null;
55
+ versions: {
56
+ versionId: string & import("zod").$brand<"UUID">;
57
+ effectiveFrom: string;
58
+ name: string;
59
+ externalId?: string | null | undefined;
60
+ status: "active" | "inactive";
61
+ }[];
18
62
  }>;
19
63
  //# sourceMappingURL=mocks.test.utils.d.ts.map
@@ -9,7 +9,7 @@ import { EventIndex } from './EventIndex';
9
9
  import { EventInput } from './EventInput';
10
10
  import { TranslationConfig } from './TranslationConfig';
11
11
  import { FieldConfig } from './FieldConfig';
12
- import { Location, AdministrativeArea } from './locations';
12
+ import { SetLocationPayload, SetAdministrativeAreaPayload } from './locations';
13
13
  import { WorkqueueConfig } from './WorkqueueConfig';
14
14
  import * as z from 'zod/v4';
15
15
  import { DocumentPath } from '../documents';
@@ -48,16 +48,16 @@ export declare function fieldConfigsToActionPayload(fields: FieldConfig[], rng:
48
48
  * Given hierarchy, ensures that related fields (e.g. location and administrative area) have valid values based on the hierarchy.
49
49
  */
50
50
  administrativeHierarchy?: {
51
- administrativeAreas: AdministrativeArea[];
52
- locations: Location[];
51
+ administrativeAreas: SetAdministrativeAreaPayload[];
52
+ locations: SetLocationPayload[];
53
53
  }): ActionUpdate;
54
54
  export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType, rng: () => number, overrides?: ActionUpdate,
55
55
  /**
56
56
  * Given hierarchy, ensures that related fields (e.g. location and administrative area) have valid values based on the hierarchy.
57
57
  */
58
58
  administrativeHierarchy?: {
59
- administrativeAreas: AdministrativeArea[];
60
- locations: Location[];
59
+ administrativeAreas: SetAdministrativeAreaPayload[];
60
+ locations: SetLocationPayload[];
61
61
  }): ActionUpdate;
62
62
  export declare function generateActionDuplicateDeclarationInput(...args: Parameters<typeof generateActionDeclarationInput>): ReturnType<typeof generateActionDeclarationInput>;
63
63
  export declare function eventPayloadGenerator(rng: () => number, configuration?: EventConfig): {