@planning-inspectorate/data-model 2.26.0 → 2.28.0

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 (37) hide show
  1. package/.azure/ci.yml +1 -1
  2. package/docs/appeal-document.md +1 -0
  3. package/docs/nsip-document.md +11 -9
  4. package/package.json +1 -1
  5. package/pins_data_model/models/model_appeal_document.py +2 -1
  6. package/pins_data_model/models/model_appeal_event.py +1 -1
  7. package/pins_data_model/models/model_appeal_event_estimate.py +1 -1
  8. package/pins_data_model/models/model_appeal_has.py +1 -1
  9. package/pins_data_model/models/model_appeal_representation.py +1 -1
  10. package/pins_data_model/models/model_appeal_s78.py +1 -1
  11. package/pins_data_model/models/model_dart_response.py +1 -1
  12. package/pins_data_model/models/model_entraid.py +1 -1
  13. package/pins_data_model/models/model_folder.py +1 -1
  14. package/pins_data_model/models/model_gettimesheets_response.py +1 -1
  15. package/pins_data_model/models/model_listed_building.py +1 -1
  16. package/pins_data_model/models/model_listed_buildings.py +1 -1
  17. package/pins_data_model/models/model_nsip_document.py +4 -2
  18. package/pins_data_model/models/model_nsip_exam_timetable.py +1 -1
  19. package/pins_data_model/models/model_nsip_invoice.py +1 -1
  20. package/pins_data_model/models/model_nsip_meeting.py +1 -1
  21. package/pins_data_model/models/model_nsip_project.py +1 -1
  22. package/pins_data_model/models/model_nsip_project_update.py +1 -1
  23. package/pins_data_model/models/model_nsip_representation.py +1 -1
  24. package/pins_data_model/models/model_nsip_subscription.py +1 -1
  25. package/pins_data_model/models/model_pins_inspector.py +1 -1
  26. package/pins_data_model/models/model_pins_lpa.py +1 -1
  27. package/pins_data_model/models/model_s51_advice.py +1 -1
  28. package/pins_data_model/models/model_service_user.py +1 -1
  29. package/schemas/appeal-document.schema.json +1 -0
  30. package/schemas/nsip-document.schema.json +3 -1
  31. package/src/enums.cjs +4 -1
  32. package/src/enums.d.ts +4 -1
  33. package/src/enums.js +4 -1
  34. package/src/index.cjs +4 -1
  35. package/src/index.d.ts +1 -11
  36. package/src/lib/gen-types.js +71 -25
  37. package/src/schemas.d.ts +69 -1
package/.azure/ci.yml CHANGED
@@ -16,7 +16,7 @@ resources:
16
16
  type: github
17
17
  endpoint: Planning-Inspectorate
18
18
  name: Planning-Inspectorate/common-pipeline-templates
19
- ref: refs/tags/release/3.24.2
19
+ ref: refs/tags/release/3.25.2
20
20
 
21
21
  extends:
22
22
  template: stages/wrapper_ci.yml@templates
@@ -626,6 +626,7 @@ The type of document, used for exchange, migrations and consumption from the app
626
626
  | `"groundISupporting"` | |
627
627
  | `"groundJSupporting"` | |
628
628
  | `"groundKSupporting"` | |
629
+ | `"lpaEnforcementNoticeWithdrawal"` | |
629
630
  | `null` | |
630
631
 
631
632
  ## sourceSystem
@@ -516,15 +516,17 @@ The location of the published document. Only applicable to documents which are p
516
516
 
517
517
  **enum**: the value of this property must be equal to one of the following values:
518
518
 
519
- | Value | Explanation |
520
- | :------------------------------- | :---------- |
521
- | `"not_redacted"` | |
522
- | `"redacted"` | |
523
- | `"awaiting_ai_redaction"` | |
524
- | `"ai_redaction_review_required"` | |
525
- | `"ai_redaction_failed"` | |
526
- | `"no_redaction_required"` | |
527
- | `null` | |
519
+ | Value | Explanation |
520
+ | :--------------------------------- | :---------- |
521
+ | `"not_redacted"` | |
522
+ | `"redacted"` | |
523
+ | `"awaiting_ai_redaction"` | |
524
+ | `"awaiting_ai_suggestions"` | |
525
+ | `"ai_suggestions_reviewed"` | |
526
+ | `"ai_suggestions_review_required"` | |
527
+ | `"ai_redaction_failed"` | |
528
+ | `"no_redaction_required"` | |
529
+ | `null` | |
528
530
 
529
531
  ## publishedStatus
530
532
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planning-inspectorate/data-model",
3
- "version": "2.26.0",
3
+ "version": "2.28.0",
4
4
  "description": "JSON Schemas for the Planning Inspectorate's Data Model",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: appeal-document.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:31+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -148,6 +148,7 @@ class DocumentType(Enum):
148
148
  groundISupporting = "groundISupporting"
149
149
  groundJSupporting = "groundJSupporting"
150
150
  groundKSupporting = "groundKSupporting"
151
+ lpaEnforcementNoticeWithdrawal = "lpaEnforcementNoticeWithdrawal"
151
152
  NoneType_None = None
152
153
 
153
154
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: appeal-event.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: appeal-event-estimate.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: appeal-has.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: appeal-representation.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: appeal-s78.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:31+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: dart-response.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: entraid.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: folder.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: gettimesheets-response.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: listed-building.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: listed-buildings.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:31+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: nsip-document.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -26,7 +26,9 @@ class RedactedStatus(Enum):
26
26
  not_redacted = "not_redacted"
27
27
  redacted = "redacted"
28
28
  awaiting_ai_redaction = "awaiting_ai_redaction"
29
- ai_redaction_review_required = "ai_redaction_review_required"
29
+ awaiting_ai_suggestions = "awaiting_ai_suggestions"
30
+ ai_suggestions_reviewed = "ai_suggestions_reviewed"
31
+ ai_suggestions_review_required = "ai_suggestions_review_required"
30
32
  ai_redaction_failed = "ai_redaction_failed"
31
33
  no_redaction_required = "no_redaction_required"
32
34
  NoneType_None = None
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: nsip-exam-timetable.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:31+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: nsip-invoice.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: nsip-meeting.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: nsip-project.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: nsip-project-update.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: nsip-representation.schema.json
3
- # timestamp: 2026-02-20T13:48:33+00:00
3
+ # timestamp: 2026-03-03T17:10:31+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: nsip-subscription.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: pins-inspector.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: pins-lpa.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: s51-advice.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -1,6 +1,6 @@
1
1
  # generated by datamodel-codegen:
2
2
  # filename: service-user.schema.json
3
- # timestamp: 2026-02-20T13:48:32+00:00
3
+ # timestamp: 2026-03-03T17:10:30+00:00
4
4
 
5
5
  from __future__ import annotations
6
6
 
@@ -226,6 +226,7 @@
226
226
  "groundISupporting",
227
227
  "groundJSupporting",
228
228
  "groundKSupporting",
229
+ "lpaEnforcementNoticeWithdrawal",
229
230
  null
230
231
  ],
231
232
  "description": "The type of document, used for exchange, migrations and consumption from the appeal back-office system"
@@ -133,7 +133,9 @@
133
133
  "not_redacted",
134
134
  "redacted",
135
135
  "awaiting_ai_redaction",
136
- "ai_redaction_review_required",
136
+ "awaiting_ai_suggestions",
137
+ "ai_suggestions_reviewed",
138
+ "ai_suggestions_review_required",
137
139
  "ai_redaction_failed",
138
140
  "no_redaction_required",
139
141
  null
package/src/enums.cjs CHANGED
@@ -220,6 +220,7 @@ const APPEAL_DOCUMENT_TYPE = Object.freeze({
220
220
  LPA_COSTS_WITHDRAWAL: 'lpaCostsWithdrawal',
221
221
  LPA_ENFORCEMENT_NOTICE: 'lpaEnforcementNotice',
222
222
  LPA_ENFORCEMENT_NOTICE_PLAN: 'lpaEnforcementNoticePlan',
223
+ LPA_ENFORCEMENT_NOTICE_WITHDRAWAL: 'lpaEnforcementNoticeWithdrawal',
223
224
  LPA_FINAL_COMMENT: 'lpaFinalComment',
224
225
  LPA_PROOF_OF_EVIDENCE: 'lpaProofOfEvidence',
225
226
  LPA_STATEMENT: 'lpaStatement',
@@ -630,8 +631,10 @@ const NSIP_RECOMMENDATION = Object.freeze({
630
631
 
631
632
  const NSIP_REDACTED_STATUS = Object.freeze({
632
633
  AI_REDACTION_FAILED: 'ai_redaction_failed',
633
- AI_REDACTION_REVIEW_REQUIRED: 'ai_redaction_review_required',
634
+ AI_SUGGESTIONS_REVIEW_REQUIRED: 'ai_suggestions_review_required',
635
+ AI_SUGGESTIONS_REVIEWED: 'ai_suggestions_reviewed',
634
636
  AWAITING_AI_REDACTION: 'awaiting_ai_redaction',
637
+ AWAITING_AI_SUGGESTIONS: 'awaiting_ai_suggestions',
635
638
  NO_REDACTION_REQUIRED: 'no_redaction_required',
636
639
  NOT_REDACTED: 'not_redacted',
637
640
  REDACTED: 'redacted',
package/src/enums.d.ts CHANGED
@@ -218,6 +218,7 @@ export const APPEAL_DOCUMENT_TYPE = {
218
218
  LPA_COSTS_WITHDRAWAL: 'lpaCostsWithdrawal',
219
219
  LPA_ENFORCEMENT_NOTICE: 'lpaEnforcementNotice',
220
220
  LPA_ENFORCEMENT_NOTICE_PLAN: 'lpaEnforcementNoticePlan',
221
+ LPA_ENFORCEMENT_NOTICE_WITHDRAWAL: 'lpaEnforcementNoticeWithdrawal',
221
222
  LPA_FINAL_COMMENT: 'lpaFinalComment',
222
223
  LPA_PROOF_OF_EVIDENCE: 'lpaProofOfEvidence',
223
224
  LPA_STATEMENT: 'lpaStatement',
@@ -628,8 +629,10 @@ export const NSIP_RECOMMENDATION = {
628
629
 
629
630
  export const NSIP_REDACTED_STATUS = {
630
631
  AI_REDACTION_FAILED: 'ai_redaction_failed',
631
- AI_REDACTION_REVIEW_REQUIRED: 'ai_redaction_review_required',
632
+ AI_SUGGESTIONS_REVIEW_REQUIRED: 'ai_suggestions_review_required',
633
+ AI_SUGGESTIONS_REVIEWED: 'ai_suggestions_reviewed',
632
634
  AWAITING_AI_REDACTION: 'awaiting_ai_redaction',
635
+ AWAITING_AI_SUGGESTIONS: 'awaiting_ai_suggestions',
633
636
  NO_REDACTION_REQUIRED: 'no_redaction_required',
634
637
  NOT_REDACTED: 'not_redacted',
635
638
  REDACTED: 'redacted',
package/src/enums.js CHANGED
@@ -218,6 +218,7 @@ export const APPEAL_DOCUMENT_TYPE = Object.freeze({
218
218
  LPA_COSTS_WITHDRAWAL: 'lpaCostsWithdrawal',
219
219
  LPA_ENFORCEMENT_NOTICE: 'lpaEnforcementNotice',
220
220
  LPA_ENFORCEMENT_NOTICE_PLAN: 'lpaEnforcementNoticePlan',
221
+ LPA_ENFORCEMENT_NOTICE_WITHDRAWAL: 'lpaEnforcementNoticeWithdrawal',
221
222
  LPA_FINAL_COMMENT: 'lpaFinalComment',
222
223
  LPA_PROOF_OF_EVIDENCE: 'lpaProofOfEvidence',
223
224
  LPA_STATEMENT: 'lpaStatement',
@@ -628,8 +629,10 @@ export const NSIP_RECOMMENDATION = Object.freeze({
628
629
 
629
630
  export const NSIP_REDACTED_STATUS = Object.freeze({
630
631
  AI_REDACTION_FAILED: 'ai_redaction_failed',
631
- AI_REDACTION_REVIEW_REQUIRED: 'ai_redaction_review_required',
632
+ AI_SUGGESTIONS_REVIEW_REQUIRED: 'ai_suggestions_review_required',
633
+ AI_SUGGESTIONS_REVIEWED: 'ai_suggestions_reviewed',
632
634
  AWAITING_AI_REDACTION: 'awaiting_ai_redaction',
635
+ AWAITING_AI_SUGGESTIONS: 'awaiting_ai_suggestions',
633
636
  NO_REDACTION_REQUIRED: 'no_redaction_required',
634
637
  NOT_REDACTED: 'not_redacted',
635
638
  REDACTED: 'redacted',
package/src/index.cjs CHANGED
@@ -301,6 +301,7 @@ const APPEAL_DOCUMENT_TYPE = Object.freeze({
301
301
  LPA_COSTS_WITHDRAWAL: 'lpaCostsWithdrawal',
302
302
  LPA_ENFORCEMENT_NOTICE: 'lpaEnforcementNotice',
303
303
  LPA_ENFORCEMENT_NOTICE_PLAN: 'lpaEnforcementNoticePlan',
304
+ LPA_ENFORCEMENT_NOTICE_WITHDRAWAL: 'lpaEnforcementNoticeWithdrawal',
304
305
  LPA_FINAL_COMMENT: 'lpaFinalComment',
305
306
  LPA_PROOF_OF_EVIDENCE: 'lpaProofOfEvidence',
306
307
  LPA_STATEMENT: 'lpaStatement',
@@ -711,8 +712,10 @@ const NSIP_RECOMMENDATION = Object.freeze({
711
712
 
712
713
  const NSIP_REDACTED_STATUS = Object.freeze({
713
714
  AI_REDACTION_FAILED: 'ai_redaction_failed',
714
- AI_REDACTION_REVIEW_REQUIRED: 'ai_redaction_review_required',
715
+ AI_SUGGESTIONS_REVIEW_REQUIRED: 'ai_suggestions_review_required',
716
+ AI_SUGGESTIONS_REVIEWED: 'ai_suggestions_reviewed',
715
717
  AWAITING_AI_REDACTION: 'awaiting_ai_redaction',
718
+ AWAITING_AI_SUGGESTIONS: 'awaiting_ai_suggestions',
716
719
  NO_REDACTION_REQUIRED: 'no_redaction_required',
717
720
  NOT_REDACTED: 'not_redacted',
718
721
  REDACTED: 'redacted',
package/src/index.d.ts CHANGED
@@ -1,17 +1,7 @@
1
1
  import * as Schemas from './schemas.js';
2
2
  export * from './enums.js';
3
3
 
4
- export interface LoadedSchemas {
5
- schemas: {
6
- [name: string]: any;
7
- };
8
- commands: {
9
- [name: string]: any;
10
- };
11
- appealsComponents: {
12
- [name: string]: any;
13
- };
14
- }
4
+ export type LoadedSchemas = Schemas.SchemaMap;
15
5
 
16
6
  export const schemasPath: string;
17
7
  export const commandsPath: string;
@@ -1,55 +1,101 @@
1
1
  import fs from 'fs/promises';
2
2
  import path from 'path';
3
3
  import url from 'url';
4
- import { loadAllSchemas } from '../index.js';
4
+ import { commandsPath, loadAllSchemas, schemasPath } from '../index.js';
5
5
  import { compile } from 'json-schema-to-typescript';
6
- import { schemasPath, commandsPath } from '../index.js';
6
+ import { generateName } from 'json-schema-to-typescript/dist/src/utils.js';
7
7
 
8
8
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
9
9
 
10
10
  export const typesPath = path.join(__dirname, '..', 'schemas.d.ts');
11
11
 
12
+ const schemaTypeNames = new Map();
13
+
12
14
  /**
13
15
  * Load all schemas and generate TypeScript definitions
14
16
  */
15
17
  async function run() {
16
18
  const s = await loadAllSchemas();
19
+ const schemaKeys = Object.keys(s.schemas).sort();
20
+ const commandKeys = Object.keys(s.commands).sort();
21
+ const appealsComponentKeys = Object.keys(s.appealsComponents).sort();
17
22
 
18
- let types = '';
19
- let first = true;
23
+ /** @type {string[]} */
24
+ const typeDefinitions = [];
25
+ const typesMap = {
26
+ schemas: {},
27
+ commands: {},
28
+ appealsComponents: {}
29
+ };
20
30
 
21
- for (const schemaName of Object.keys(s.schemas).sort()) {
22
- const schema = s.schemas[schemaName];
23
- types += await compile(schema, schema['$id'], options(first));
24
- types += '\n';
25
- first = false;
31
+ for (let i = 0; i < schemaKeys.length; i++) {
32
+ const schemaKey = schemaKeys[i];
33
+ const schema = s.schemas[schemaKey];
34
+ typeDefinitions.push(await compile(schema, schema['$id'], options(i === 0)));
35
+ typesMap.schemas[schemaKey] = schemaTypeName(schema, typeDefinitions);
26
36
  }
27
37
 
28
- for (const commandName of Object.keys(s.commands).sort()) {
29
- const schema = s.commands[commandName];
38
+ for (const schemaKey of commandKeys) {
39
+ const schema = s.commands[schemaKey];
40
+ typeDefinitions.push(await commandSchemaToTypeString(schema, schemaKey));
41
+ typesMap.commands[schemaKey] = schemaTypeName(schema, typeDefinitions);
42
+ }
30
43
 
31
- if (
32
- commandName.startsWith('appeal') ||
33
- commandName.startsWith('appellant') ||
34
- commandName.startsWith('lpa-questionnaire')
35
- ) {
36
- // hack to allow nested $ref links to function in tests and gen types,
37
- // can we leverage a better means to resolve $refs that aligns with how tests/appeals references this
38
- types += await compile(schema, schema['$id'], options(first, commandsPath));
39
- } else {
40
- types += await compile(schema, schema['$id'], options(first));
41
- }
44
+ for (const schemaKey of appealsComponentKeys) {
45
+ const schema = s.appealsComponents[schemaKey];
46
+ // no need to generate types, will be included by the schemas and commands
47
+ typesMap.appealsComponents[schemaKey] = schemaTypeName(schema, typeDefinitions);
48
+ }
42
49
 
43
- types += '\n';
44
- first = false;
50
+ let types = typeDefinitions.join('\n');
51
+ types += `\nexport type SchemaMap = {`;
52
+ for (const [k, map] of Object.entries(typesMap)) {
53
+ types += `\n ${k}: {\n `;
54
+ types += Object.entries(map)
55
+ .map(([a, b]) => `'${a}': ${b};`)
56
+ .join('\n ');
57
+ types += `\n }`;
45
58
  }
59
+ types += `\n};\n`;
46
60
 
47
61
  await fs.writeFile(typesPath, types);
48
62
  }
49
63
 
64
+ function commandSchemaToTypeString(schema, name) {
65
+ let refPath;
66
+ // hack to allow nested $ref links to function in tests and gen types,
67
+ // can we leverage a better means to resolve $refs that aligns with how tests/appeals references this
68
+ if (['appeal', 'appellant', 'lpa-questionnaire'].some((prefix) => name.startsWith(prefix))) {
69
+ refPath = commandsPath;
70
+ }
71
+ return compile(schema, schema['$id'], options(false, refPath));
72
+ }
73
+
74
+ /**
75
+ * @param {any} schema
76
+ * @param {string[]} types
77
+ * @returns {string}
78
+ */
79
+ function schemaTypeName(schema, types) {
80
+ const name = generateName(schema.title || schema['$id'], new Set());
81
+ if (schemaTypeNames.has(name)) {
82
+ throw new Error(
83
+ `Schema with type name ${name} already exists (schemas ${schema['$id']}, ${schemaTypeNames.get(name)})\nEnsure schema title fields are unique and match the ID`
84
+ );
85
+ }
86
+ // check the type name is in the generated types
87
+ if (
88
+ types.some((typeStr) => typeStr.includes(`export interface ${name}`) || typeStr.includes(`export type ${name}`))
89
+ ) {
90
+ schemaTypeNames.set(name, schema['$id']);
91
+ return name;
92
+ }
93
+ throw new Error(`${name} not found in type definition`);
94
+ }
95
+
50
96
  /**
51
- *
52
97
  * @param {boolean} first
98
+ * @param {string} [refPath]
53
99
  * @returns {Partial<import('json-schema-to-typescript').Options>}
54
100
  */
55
101
  function options(first, refPath = schemasPath) {
package/src/schemas.d.ts CHANGED
@@ -174,6 +174,7 @@ export interface AppealDocument {
174
174
  | 'groundISupporting'
175
175
  | 'groundJSupporting'
176
176
  | 'groundKSupporting'
177
+ | 'lpaEnforcementNoticeWithdrawal'
177
178
  | null;
178
179
  /**
179
180
  * The system mastering the metadata for the current document
@@ -2153,7 +2154,9 @@ export interface NSIPDocument {
2153
2154
  | 'not_redacted'
2154
2155
  | 'redacted'
2155
2156
  | 'awaiting_ai_redaction'
2156
- | 'ai_redaction_review_required'
2157
+ | 'awaiting_ai_suggestions'
2158
+ | 'ai_suggestions_reviewed'
2159
+ | 'ai_suggestions_review_required'
2157
2160
  | 'ai_redaction_failed'
2158
2161
  | 'no_redaction_required'
2159
2162
  | null;
@@ -5057,3 +5060,68 @@ export interface InterestedParty1 {
5057
5060
  [k: string]: unknown;
5058
5061
  }
5059
5062
 
5063
+ export type SchemaMap = {
5064
+ schemas: {
5065
+ 'appeal-document.schema.json': AppealDocument;
5066
+ 'appeal-event-estimate.schema.json': AppealEventEstimate;
5067
+ 'appeal-event.schema.json': AppealEvent;
5068
+ 'appeal-has.schema.json': AppealHASCase;
5069
+ 'appeal-representation.schema.json': AppealRepresentation;
5070
+ 'appeal-s78.schema.json': AppealS78Case;
5071
+ 'dart-response.schema.json': DaRTAPIResponse;
5072
+ 'entraid.schema.json': EntraIDUserObjects;
5073
+ 'folder.schema.json': Folder;
5074
+ 'gettimesheets-response.schema.json': GetTimesheetsAPIResponse;
5075
+ 'listed-building.schema.json': ListedBuilding;
5076
+ 'listed-buildings.schema.json': ListedBuildings;
5077
+ 'nsip-document.schema.json': NSIPDocument;
5078
+ 'nsip-exam-timetable.schema.json': ExaminationTimetable;
5079
+ 'nsip-invoice.schema.json': NSIPInvoice;
5080
+ 'nsip-meeting.schema.json': NSIPMeeting;
5081
+ 'nsip-project-update.schema.json': NSIPProjectUpdate;
5082
+ 'nsip-project.schema.json': NSIPProject;
5083
+ 'nsip-representation.schema.json': Representation;
5084
+ 'nsip-subscription.schema.json': NsipSubscription;
5085
+ 'pins-inspector.schema.json': PINSInspector;
5086
+ 'pins-lpa.schema.json': PINSLPA;
5087
+ 's51-advice.schema.json': S51Advice;
5088
+ 'service-user.schema.json': ServiceUser;
5089
+ }
5090
+ commands: {
5091
+ 'appeal-representation-submission.schema.json': AppealRepresentationSubmission;
5092
+ 'appellant-submission.schema.json': AppellantSubmissionCommand;
5093
+ 'interested-party.schema.json': InterestedParty;
5094
+ 'lpa-questionnaire.schema.json': LPAQuestionnaireCommand;
5095
+ 'new-deadline-submission.schema.json': NewDeadlineSubmission;
5096
+ 'nsip-exam-timetable-submission.schema.json': NsipExamTimetableSubmission;
5097
+ 'register-nsip-subscription.schema.json': RegisterNsipSubscription;
5098
+ 'register-representation.schema.json': RegisterRepresentation;
5099
+ }
5100
+ appealsComponents: {
5101
+ 'appeal-advert.submission.schema.json': AdvertSpecificProperties;
5102
+ 'appeal-common-planning.schema.json': AppellantCommonPlanningProperties;
5103
+ 'appeal-common-submission.schema.json': AppellantCommonSubmissionProperties;
5104
+ 'appeal-enforcement-common-submission.schema.json': AppellantEnforcementCommonSubmissionProperties;
5105
+ 'appeal-enforcement-listed-submission.schema.json': AppellantEnforcementListedBuildingSubmissionProperties;
5106
+ 'appeal-enforcement-notice-submission.schema.json': AppellantEnforcementNoticeSpecificSubmissionProperties;
5107
+ 'appeal-land-ownership.schema.json': AppealLandOwnershipProperties;
5108
+ 'appeal-ldc.submission.schema.json': LDCSpecificProperties;
5109
+ 'appeal-planning-obligation.submission.schema.json': PlanningObligationSpecificProperties;
5110
+ 'appeal-s78-submission.schema.json': AppellantS78SubmissionProperties;
5111
+ 'appeal-site-area.schema.json': SiteAreaProperties;
5112
+ 'appellant-procedure-preference.schema.json': AppellantProcedurePreferenceProperties;
5113
+ 'changed-listed-building-number.schema.json': ChangedListedBuildingNumbersProperties;
5114
+ 'environmental-impact-assessment.schema.json': EnvironmentalImpactAssessmentProperties;
5115
+ 'infrastructure-levy.schema.json': InfrastructureLevyProperties;
5116
+ 'lpa-procedure-preference.schema.json': LPAProcedurePreferenceProperties;
5117
+ 'lpa-questionnaire-advert.schema.json': LPAQCasAdvertSubmissionProperties;
5118
+ 'lpa-questionnaire-common.schema.json': LPAQCommonSubmissionProperties;
5119
+ 'lpa-questionnaire-enforcement-common.schema.json': LPAQEnforcementCommonSubmissionProperties;
5120
+ 'lpa-questionnaire-enforcement.schema.json': LPAQEnforcementSubmissionProperties;
5121
+ 'lpa-questionnaire-has.schema.json': LPAQHASSubmissionProperties;
5122
+ 'lpa-questionnaire-ldc.schema.json': LPAQLDCSubmissionProperties;
5123
+ 'lpa-questionnaire-listed-building.schema.json': LPAQListedBuildingSubmissionProperties;
5124
+ 'lpa-questionnaire-s78.schema.json': LPAQS78SubmissionProperties;
5125
+ 'site-designations-protection.schema.json': SiteDesignationsAndProtectionSpecificProperties;
5126
+ }
5127
+ };