@opencrvs/toolkit 2.1.0-rc.9cfaa26 → 2.1.0-rc.9dce8c0

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.
@@ -647,6 +647,7 @@ var PlainScopeType = z11.enum([
647
647
  "integration.create",
648
648
  "record.import",
649
649
  "config.update-all",
650
+ "location.edit",
650
651
  "attachment.upload",
651
652
  "profile.electronic-signature",
652
653
  "user.read-only-my-audit",
@@ -7834,8 +7834,8 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
7834
7834
  email?: string | undefined;
7835
7835
  status?: string | undefined;
7836
7836
  primaryOfficeId?: string | undefined;
7837
- count: number;
7838
- skip: number;
7837
+ count?: number | undefined;
7838
+ skip?: number | undefined;
7839
7839
  sortBy?: "createdAt" | "email" | "firstname" | "role" | "status" | "surname" | "username" | undefined;
7840
7840
  sortOrder: "asc" | "desc";
7841
7841
  };
@@ -8242,6 +8242,37 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
8242
8242
  responseSummary: {
8243
8243
  clientId: string;
8244
8244
  };
8245
+ } | {
8246
+ id: string;
8247
+ clientId: string;
8248
+ clientType: "system" | "user";
8249
+ createdAt: string;
8250
+ operation: "locations.create";
8251
+ requestData: {
8252
+ id: string;
8253
+ versionId: string;
8254
+ name: string;
8255
+ externalId?: string | null | undefined;
8256
+ effectiveFrom: string;
8257
+ status: string;
8258
+ administrativeAreaId?: string | null | undefined;
8259
+ locationType?: string | null | undefined;
8260
+ };
8261
+ } | {
8262
+ id: string;
8263
+ clientId: string;
8264
+ clientType: "system" | "user";
8265
+ createdAt: string;
8266
+ operation: "administrativeAreas.create";
8267
+ requestData: {
8268
+ id: string;
8269
+ versionId: string;
8270
+ name: string;
8271
+ externalId?: string | null | undefined;
8272
+ effectiveFrom: string;
8273
+ status: string;
8274
+ parentId?: string | null | undefined;
8275
+ };
8245
8276
  } | {
8246
8277
  id: string;
8247
8278
  clientId: string;
@@ -8353,7 +8384,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
8353
8384
  administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
8354
8385
  locationType: string | null;
8355
8386
  status: "active" | "inactive";
8356
- effectiveFrom: string;
8357
8387
  versions: {
8358
8388
  versionId: string & import("zod").$brand<"UUID">;
8359
8389
  effectiveFrom: string;
@@ -8375,6 +8405,34 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
8375
8405
  output: void;
8376
8406
  meta: object;
8377
8407
  }>;
8408
+ create: import("@trpc/server").TRPCMutationProcedure<{
8409
+ input: {
8410
+ id?: string | undefined;
8411
+ versionId?: string | undefined;
8412
+ name: string;
8413
+ externalId?: string | null | undefined;
8414
+ administrativeAreaId: string | null;
8415
+ locationType: string | null;
8416
+ effectiveFrom?: string | undefined;
8417
+ status?: "active" | "inactive" | undefined;
8418
+ };
8419
+ output: {
8420
+ id: string & import("zod").$brand<"UUID">;
8421
+ name: string;
8422
+ externalId?: string | null | undefined;
8423
+ administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
8424
+ locationType: string | null;
8425
+ status: "active" | "inactive";
8426
+ versions: {
8427
+ versionId: string & import("zod").$brand<"UUID">;
8428
+ effectiveFrom: string;
8429
+ name: string;
8430
+ externalId?: string | null | undefined;
8431
+ status: "active" | "inactive";
8432
+ }[];
8433
+ };
8434
+ meta: import("trpc-to-openapi").OpenApiMeta;
8435
+ }>;
8378
8436
  get: import("@trpc/server").TRPCQueryProcedure<{
8379
8437
  input: {
8380
8438
  id: string;
@@ -8386,7 +8444,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
8386
8444
  administrativeAreaId: (string & import("zod").$brand<"UUID">) | null;
8387
8445
  locationType: string | null;
8388
8446
  status: "active" | "inactive";
8389
- effectiveFrom: string;
8390
8447
  versions: {
8391
8448
  versionId: string & import("zod").$brand<"UUID">;
8392
8449
  effectiveFrom: string;
@@ -8802,7 +8859,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
8802
8859
  externalId?: string | null | undefined;
8803
8860
  parentId: (string & import("zod").$brand<"UUID">) | null;
8804
8861
  status: "active" | "inactive";
8805
- effectiveFrom: string;
8806
8862
  versions: {
8807
8863
  versionId: string & import("zod").$brand<"UUID">;
8808
8864
  effectiveFrom: string;
@@ -8823,6 +8879,32 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
8823
8879
  output: void;
8824
8880
  meta: object;
8825
8881
  }>;
8882
+ create: import("@trpc/server").TRPCMutationProcedure<{
8883
+ input: {
8884
+ id?: string | undefined;
8885
+ versionId?: string | undefined;
8886
+ name: string;
8887
+ externalId?: string | null | undefined;
8888
+ parentId: string | null;
8889
+ effectiveFrom?: string | undefined;
8890
+ status?: "active" | "inactive" | undefined;
8891
+ };
8892
+ output: {
8893
+ id: string & import("zod").$brand<"UUID">;
8894
+ name: string;
8895
+ externalId?: string | null | undefined;
8896
+ parentId: (string & import("zod").$brand<"UUID">) | null;
8897
+ status: "active" | "inactive";
8898
+ versions: {
8899
+ versionId: string & import("zod").$brand<"UUID">;
8900
+ effectiveFrom: string;
8901
+ name: string;
8902
+ externalId?: string | null | undefined;
8903
+ status: "active" | "inactive";
8904
+ }[];
8905
+ };
8906
+ meta: import("trpc-to-openapi").OpenApiMeta;
8907
+ }>;
8826
8908
  }>>;
8827
8909
  integrations: import("@trpc/server").TRPCBuiltRouter<{
8828
8910
  ctx: Partial<{
@@ -85,16 +85,16 @@ export declare const now: typeof todayDateTimeValueSerializer;
85
85
  export declare const user: typeof userSerializer & {
86
86
  scope: (scope: import("../scopes").ScopeType) => {
87
87
  attribute: (option: import("../scopes").ScopeOptionKey) => {
88
- $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
88
+ $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "location.edit" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
89
89
  $option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
90
90
  };
91
91
  };
92
92
  jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
93
- $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
93
+ $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "location.edit" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
94
94
  $option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
95
95
  }) => {
96
96
  $jurisdiction: "administrativeArea" | "all" | "location" | {
97
- $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
97
+ $scope: "attachment.upload" | "bypassratelimit" | "config.update-all" | "dashboard.view" | "integration.create" | "location.edit" | "organisation.read-locations" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "profile.electronic-signature" | "record.archive" | "record.confirm-registration" | "record.correct" | "record.create" | "record.custom-action" | "record.declare" | "record.edit" | "record.import" | "record.notify" | "record.print-certified-copies" | "record.read" | "record.register" | "record.reindex" | "record.reject" | "record.reject-registration" | "record.request-correction" | "record.review-duplicates" | "record.search" | "record.unarchive" | "record.unassign-others" | "user.create" | "user.data-seeding" | "user.edit" | "user.read" | "user.read-only-my-audit" | "user.search" | "workqueue";
98
98
  $option: "accessLevel" | "declaredBy" | "declaredIn" | "event" | "ids" | "notifiedBy" | "notifiedIn" | "placeOfEvent" | "registeredBy" | "registeredIn" | "role";
99
99
  };
100
100
  };
@@ -2,7 +2,7 @@ import { ConditionalParameters, JSONSchema } from './conditionals';
2
2
  import { ActionUpdate, EventState } from '../events/ActionDocument';
3
3
  import { FieldConditional } from '../events/Conditional';
4
4
  import { FieldConfig } from '../events/FieldConfig';
5
- import { FieldUpdateValue, FieldValue } from '../events/FieldValue';
5
+ import { PlainDate, FieldUpdateValue, FieldValue } from '../events/FieldValue';
6
6
  import { TranslationConfig } from '../events/TranslationConfig';
7
7
  import { ITokenPayload } from '../authentication';
8
8
  import { UUID } from '../uuid';
@@ -14,8 +14,8 @@ import { EventDocument } from '../events/EventDocument';
14
14
  import { EventIndex } from '../events/EventIndex';
15
15
  import { Location } from '../events/locations';
16
16
  import { SystemVariables } from '../events/TemplateConfig';
17
- /** Returns today's date as an ISO date string (YYYY-MM-DD). */
18
- export declare function todayISO(): string;
17
+ /** Returns today's date as a {@link PlainDate} (YYYY-MM-DD), device-local. */
18
+ export declare function todayISO(): PlainDate;
19
19
  /**
20
20
  * Context passed to every serialised client-side function ({@link runClientFunction}).
21
21
  *
@@ -103,6 +103,7 @@ export declare const FieldConfigSchema: z.ZodObject<{
103
103
  "config.update-all": "config.update-all";
104
104
  "dashboard.view": "dashboard.view";
105
105
  "integration.create": "integration.create";
106
+ "location.edit": "location.edit";
106
107
  "organisation.read-locations": "organisation.read-locations";
107
108
  "performance.read": "performance.read";
108
109
  "performance.read-dashboards": "performance.read-dashboards";
@@ -283,6 +284,7 @@ export declare const EventFieldConfigSchema: z.ZodObject<{
283
284
  "config.update-all": "config.update-all";
284
285
  "dashboard.view": "dashboard.view";
285
286
  "integration.create": "integration.create";
287
+ "location.edit": "location.edit";
286
288
  "organisation.read-locations": "organisation.read-locations";
287
289
  "performance.read": "performance.read";
288
290
  "performance.read-dashboards": "performance.read-dashboards";
@@ -439,6 +441,7 @@ export declare const AdvancedSearchField: z.ZodDiscriminatedUnion<[z.ZodObject<{
439
441
  "config.update-all": "config.update-all";
440
442
  "dashboard.view": "dashboard.view";
441
443
  "integration.create": "integration.create";
444
+ "location.edit": "location.edit";
442
445
  "organisation.read-locations": "organisation.read-locations";
443
446
  "performance.read": "performance.read";
444
447
  "performance.read-dashboards": "performance.read-dashboards";
@@ -587,6 +590,7 @@ export declare const AdvancedSearchField: z.ZodDiscriminatedUnion<[z.ZodObject<{
587
590
  "config.update-all": "config.update-all";
588
591
  "dashboard.view": "dashboard.view";
589
592
  "integration.create": "integration.create";
593
+ "location.edit": "location.edit";
590
594
  "organisation.read-locations": "organisation.read-locations";
591
595
  "performance.read": "performance.read";
592
596
  "performance.read-dashboards": "performance.read-dashboards";
@@ -746,6 +750,7 @@ export declare const AdvancedSearchConfig: z.ZodObject<{
746
750
  "config.update-all": "config.update-all";
747
751
  "dashboard.view": "dashboard.view";
748
752
  "integration.create": "integration.create";
753
+ "location.edit": "location.edit";
749
754
  "organisation.read-locations": "organisation.read-locations";
750
755
  "performance.read": "performance.read";
751
756
  "performance.read-dashboards": "performance.read-dashboards";
@@ -894,6 +899,7 @@ export declare const AdvancedSearchConfig: z.ZodObject<{
894
899
  "config.update-all": "config.update-all";
895
900
  "dashboard.view": "dashboard.view";
896
901
  "integration.create": "integration.create";
902
+ "location.edit": "location.edit";
897
903
  "organisation.read-locations": "organisation.read-locations";
898
904
  "performance.read": "performance.read";
899
905
  "performance.read-dashboards": "performance.read-dashboards";
@@ -281,6 +281,43 @@ export declare const AuditLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
281
281
  responseSummary: z.ZodObject<{
282
282
  clientId: z.ZodString;
283
283
  }, z.core.$strip>;
284
+ }, z.core.$strip>, z.ZodObject<{
285
+ id: z.ZodString;
286
+ clientId: z.ZodString;
287
+ clientType: z.ZodEnum<{
288
+ system: "system";
289
+ user: "user";
290
+ }>;
291
+ createdAt: z.ZodString;
292
+ operation: z.ZodLiteral<"locations.create">;
293
+ requestData: z.ZodObject<{
294
+ id: z.ZodString;
295
+ versionId: z.ZodString;
296
+ name: z.ZodString;
297
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
298
+ effectiveFrom: z.ZodString;
299
+ status: z.ZodString;
300
+ administrativeAreaId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
301
+ locationType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
302
+ }, z.core.$strip>;
303
+ }, z.core.$strip>, z.ZodObject<{
304
+ id: z.ZodString;
305
+ clientId: z.ZodString;
306
+ clientType: z.ZodEnum<{
307
+ system: "system";
308
+ user: "user";
309
+ }>;
310
+ createdAt: z.ZodString;
311
+ operation: z.ZodLiteral<"administrativeAreas.create">;
312
+ requestData: z.ZodObject<{
313
+ id: z.ZodString;
314
+ versionId: z.ZodString;
315
+ name: z.ZodString;
316
+ externalId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
317
+ effectiveFrom: z.ZodString;
318
+ status: z.ZodString;
319
+ parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
320
+ }, z.core.$strip>;
284
321
  }, z.core.$strip>, z.ZodObject<{
285
322
  id: z.ZodString;
286
323
  clientId: z.ZodString;
@@ -1883,6 +1883,7 @@ declare const AdministrativeAreaField: z.ZodObject<{
1883
1883
  "config.update-all": "config.update-all";
1884
1884
  "dashboard.view": "dashboard.view";
1885
1885
  "integration.create": "integration.create";
1886
+ "location.edit": "location.edit";
1886
1887
  "organisation.read-locations": "organisation.read-locations";
1887
1888
  "performance.read": "performance.read";
1888
1889
  "performance.read-dashboards": "performance.read-dashboards";
@@ -2012,6 +2013,7 @@ declare const LocationInput: z.ZodObject<{
2012
2013
  "config.update-all": "config.update-all";
2013
2014
  "dashboard.view": "dashboard.view";
2014
2015
  "integration.create": "integration.create";
2016
+ "location.edit": "location.edit";
2015
2017
  "organisation.read-locations": "organisation.read-locations";
2016
2018
  "performance.read": "performance.read";
2017
2019
  "performance.read-dashboards": "performance.read-dashboards";
@@ -2212,6 +2214,7 @@ declare const Facility: z.ZodObject<{
2212
2214
  "config.update-all": "config.update-all";
2213
2215
  "dashboard.view": "dashboard.view";
2214
2216
  "integration.create": "integration.create";
2217
+ "location.edit": "location.edit";
2215
2218
  "organisation.read-locations": "organisation.read-locations";
2216
2219
  "performance.read": "performance.read";
2217
2220
  "performance.read-dashboards": "performance.read-dashboards";
@@ -2327,6 +2330,7 @@ declare const Office: z.ZodObject<{
2327
2330
  "config.update-all": "config.update-all";
2328
2331
  "dashboard.view": "dashboard.view";
2329
2332
  "integration.create": "integration.create";
2333
+ "location.edit": "location.edit";
2330
2334
  "organisation.read-locations": "organisation.read-locations";
2331
2335
  "performance.read": "performance.read";
2332
2336
  "performance.read-dashboards": "performance.read-dashboards";
@@ -2528,6 +2532,7 @@ declare const Address: z.ZodObject<{
2528
2532
  "config.update-all": "config.update-all";
2529
2533
  "dashboard.view": "dashboard.view";
2530
2534
  "integration.create": "integration.create";
2535
+ "location.edit": "location.edit";
2531
2536
  "organisation.read-locations": "organisation.read-locations";
2532
2537
  "performance.read": "performance.read";
2533
2538
  "performance.read-dashboards": "performance.read-dashboards";
@@ -1,7 +1,7 @@
1
1
  import * as z from 'zod/v4';
2
2
  import { AddressFieldUpdateValue, AddressFieldValue, CustomFieldValue, FileFieldValue, FileFieldWithOptionValue, HttpFieldUpdateValue, IdReaderFieldValue, NameFieldUpdateValue, NameFieldValue, NumberWithUnitFieldUpdateValue, NumberWithUnitFieldValue, QrReaderFieldValue, QueryParamReaderFieldUpdateValue } from './CompositeFieldValue';
3
- import { PlainDate, plainDateToLocalDate } from './PlainDate';
4
- export { PlainDate, plainDateToLocalDate };
3
+ import { PlainDate, plainDateToLocalDate, toPlainDate } from './PlainDate';
4
+ export { PlainDate, plainDateToLocalDate, toPlainDate };
5
5
  /**
6
6
  * FieldValues defined in this file are primitive field values.
7
7
  * FieldValues defined in CompositeFieldValue.ts are composed of multiple primitive field values (Address, File etc).
@@ -9,6 +9,14 @@ import { z } from 'zod';
9
9
  */
10
10
  export declare const PlainDate: z.core.$ZodBranded<z.ZodString, "PlainDate", "out">;
11
11
  export type PlainDate = z.infer<typeof PlainDate>;
12
+ /**
13
+ * Extracts the plain calendar date from an ISO 8601 datetime (or passes an
14
+ * already-plain YYYY-MM-DD through) as a {@link PlainDate}. This is the single
15
+ * conversion from a timestamp to a location-resolution anchor — comparing
16
+ * plain dates as strings, with no timezone conversion. Assumes a valid ISO /
17
+ * YYYY-MM-DD input, as produced by the event metadata and date fields.
18
+ */
19
+ export declare function toPlainDate(dateTime: string): PlainDate;
12
20
  /**
13
21
  * Converts a {@link PlainDate} (YYYY-MM-DD) to a local `Date` at midnight.
14
22
  *
@@ -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';
@@ -41,7 +42,6 @@ export declare const AdministrativeArea: z.ZodObject<{
41
42
  active: "active";
42
43
  inactive: "inactive";
43
44
  }>;
44
- effectiveFrom: z.ZodISODate;
45
45
  versions: z.ZodArray<z.ZodObject<{
46
46
  versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
47
47
  effectiveFrom: z.ZodISODate;
@@ -64,7 +64,6 @@ export declare const Location: z.ZodObject<{
64
64
  active: "active";
65
65
  inactive: "inactive";
66
66
  }>;
67
- effectiveFrom: z.ZodISODate;
68
67
  versions: z.ZodArray<z.ZodObject<{
69
68
  versionId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
70
69
  effectiveFrom: z.ZodISODate;
@@ -77,6 +76,61 @@ export declare const Location: z.ZodObject<{
77
76
  }, z.core.$strip>>;
78
77
  }, z.core.$strip>;
79
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;
80
134
  /**
81
135
  * Input payload for the locations `set` mutation. Carries only the seedable
82
136
  * identity and hierarchy fields — version history is managed by the server.
@@ -113,6 +167,13 @@ export type SetAdministrativeAreaPayload = z.infer<typeof SetAdministrativeAreaP
113
167
  export declare function resolveVersion<T extends {
114
168
  effectiveFrom: string;
115
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;
116
177
  type WrapArrayPreserveNullish<V> = V extends readonly any[] ? V : NonNullable<V>[] | Extract<V, null | undefined>;
117
178
  /**
118
179
  * For type T, convert fields K to arrays. If field is string, convert to string[].
@@ -159,21 +220,10 @@ export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, use
159
220
  * One of the scopes must allow access for the event to be accessible.
160
221
  */
161
222
  export declare function userCanAccessEventWithScopes(event: Partial<EventIndexWithAdministrativeHierarchy>, scopes: RecordScopeV2[], user: UserContext | SystemContext, customActionType?: string): boolean;
162
- export declare function getAdministrativeAreaHierarchy(administrativeAreaId: string | undefined | null, administrativeAreas: Map<UUID, AdministrativeArea>): {
163
- id: string & z.$brand<"UUID">;
164
- name: string;
165
- externalId?: string | null | undefined;
166
- parentId: (string & z.$brand<"UUID">) | null;
167
- status: "active" | "inactive";
168
- effectiveFrom: string;
169
- versions: {
170
- versionId: string & z.$brand<"UUID">;
171
- effectiveFrom: string;
172
- name: string;
173
- externalId?: string | null | undefined;
174
- status: "active" | "inactive";
175
- }[];
176
- }[];
223
+ export declare function getAdministrativeAreaHierarchy<A extends {
224
+ id: UUID;
225
+ parentId: UUID | null;
226
+ }>(administrativeAreaId: string | undefined | null, administrativeAreas: Map<UUID, A>): A[];
177
227
  /**
178
228
  * Resolves a location or administrative area UUID into a root-first hierarchy of UUIDs.
179
229
  *
@@ -185,8 +235,45 @@ export declare function getAdministrativeAreaHierarchy(administrativeAreaId: str
185
235
  * so the result is reversed to match the root-first convention used by the server.
186
236
  */
187
237
  export declare function getLocationHierarchy(selectedId: UUID, context: {
188
- administrativeAreas: Map<UUID, AdministrativeArea>;
189
- 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
+ }>;
190
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[];
191
278
  export {};
192
279
  //# sourceMappingURL=locations.d.ts.map