@planning-inspectorate/data-model 1.12.0 → 1.14.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.
package/.husky/pre-commit CHANGED
@@ -1 +1 @@
1
- npx lint-staged && npm run format
1
+ npx lint-staged
package/README.md CHANGED
@@ -9,6 +9,7 @@ All messages over the enterprise service bus are in Data Model compliant formats
9
9
  * Messages broadcast over the service bus must be pre-validated against the schema.
10
10
  * Each service bus topic corresponds to one schema.
11
11
  * Each message encompasses the complete state of an entity (as defined by [ECST](https://blogs.mulesoft.com/api-integration/strategy/event-carried-state-messages/)) and does not delineate specific changes (the delta).
12
+ * Each message will include a message event type, which is sent as `applicationProperties.type` (see [applicationProperties](https://learn.microsoft.com/en-us/javascript/api/%40azure/service-bus/servicebusmessage?view=azure-node-latest#@azure-service-bus-servicebusmessage-applicationproperties)), and is one of the values defined by the `eventType` enum in [enums-static.schema.json](./src/lib/enums-static.schema.json)
12
13
  * Consumers must support processing related messages received through different topics regardless of the order in which they are sent.
13
14
  * Values required by the Data Model cannot be null, while optional values must be null if they have no value.
14
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planning-inspectorate/data-model",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "JSON Schemas for the Planning Inspectorate's Data Model",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -11,9 +11,9 @@
11
11
  "scripts": {
12
12
  "commitlint": "commitlint --from=$(git cherry origin/main | head -n 1 | cut -c 3-)",
13
13
  "gen": "npm run gen-docs && npm run gen-enums && npm run gen-types && npm run gen-cjs",
14
- "gen-docs": "node src/gen-docs.js",
15
- "gen-enums": "node src/gen-enums.js",
16
- "gen-types": "node src/gen-types.js",
14
+ "gen-docs": "node src/lib/gen-docs.js",
15
+ "gen-enums": "node src/lib/gen-enums.js",
16
+ "gen-types": "node src/lib/gen-types.js",
17
17
  "gen-cjs": "npx rollup ./src/index.js --file ./src/index.cjs --format cjs && npx rollup ./src/enums.js --file ./src/enums.cjs --format cjs",
18
18
  "lint": "npx eslint .",
19
19
  "format": "prettier --write .",
@@ -50,6 +50,9 @@
50
50
  "lint-staged": {
51
51
  "*.js": [
52
52
  "eslint --fix"
53
+ ],
54
+ "*.{js,ts,json,md,prisma,yml,yaml,scss}": [
55
+ "prettier --write"
53
56
  ]
54
57
  }
55
58
  }
@@ -16,6 +16,12 @@
16
16
  {
17
17
  "allOf": [{ "properties": { "caseType": { "const": "D" } } }, { "$ref": "appeal-has-submission.schema.json" }]
18
18
  },
19
+ {
20
+ "allOf": [
21
+ { "properties": { "caseType": { "const": "ZP" } } },
22
+ { "$ref": "appeal-has-submission.schema.json" }
23
+ ]
24
+ },
19
25
  {
20
26
  "allOf": [{ "properties": { "caseType": { "const": "W" } } }, { "$ref": "appeal-s78-submission.schema.json" }]
21
27
  },
@@ -27,6 +27,12 @@
27
27
  },
28
28
  {
29
29
  "allOf": [{ "properties": { "caseType": { "const": "D" } } }, { "$ref": "lpa-questionnaire-has.schema.json" }]
30
+ },
31
+ {
32
+ "allOf": [
33
+ { "properties": { "caseType": { "const": "ZP" } } },
34
+ { "$ref": "lpa-questionnaire-has.schema.json" }
35
+ ]
30
36
  }
31
37
  ]
32
38
  },
package/src/enums.cjs CHANGED
@@ -340,6 +340,14 @@ const CASE_STAGE = Object.freeze({
340
340
  WITHDRAWN: 'withdrawn',
341
341
  });
342
342
 
343
+ const MESSAGE_EVENT_TYPE = Object.freeze({
344
+ CREATE: 'Create',
345
+ DELETE: 'Delete',
346
+ PUBLISH: 'Publish',
347
+ UNPUBLISH: 'Unpublish',
348
+ UPDATE: 'Update',
349
+ });
350
+
343
351
  const METHOD = Object.freeze({
344
352
  EMAIL: 'email',
345
353
  FAX: 'fax',
@@ -605,6 +613,7 @@ exports.APPEAL_SOURCE_SYSTEM = APPEAL_SOURCE_SYSTEM;
605
613
  exports.APPEAL_TYPE_OF_PLANNING_APPLICATION = APPEAL_TYPE_OF_PLANNING_APPLICATION;
606
614
  exports.APPEAL_VIRUS_CHECK_STATUS = APPEAL_VIRUS_CHECK_STATUS;
607
615
  exports.CASE_STAGE = CASE_STAGE;
616
+ exports.MESSAGE_EVENT_TYPE = MESSAGE_EVENT_TYPE;
608
617
  exports.METHOD = METHOD;
609
618
  exports.NSIP_CASE_TYPE = NSIP_CASE_TYPE;
610
619
  exports.NSIP_DECISION = NSIP_DECISION;
package/src/enums.d.ts CHANGED
@@ -338,6 +338,14 @@ export const CASE_STAGE = {
338
338
  WITHDRAWN: 'withdrawn',
339
339
  };
340
340
 
341
+ export const MESSAGE_EVENT_TYPE = {
342
+ CREATE: 'Create',
343
+ DELETE: 'Delete',
344
+ PUBLISH: 'Publish',
345
+ UNPUBLISH: 'Unpublish',
346
+ UPDATE: 'Update',
347
+ };
348
+
341
349
  export const METHOD = {
342
350
  EMAIL: 'email',
343
351
  FAX: 'fax',
package/src/enums.js CHANGED
@@ -338,6 +338,14 @@ export const CASE_STAGE = Object.freeze({
338
338
  WITHDRAWN: 'withdrawn',
339
339
  });
340
340
 
341
+ export const MESSAGE_EVENT_TYPE = Object.freeze({
342
+ CREATE: 'Create',
343
+ DELETE: 'Delete',
344
+ PUBLISH: 'Publish',
345
+ UNPUBLISH: 'Unpublish',
346
+ UPDATE: 'Update',
347
+ });
348
+
341
349
  export const METHOD = Object.freeze({
342
350
  EMAIL: 'email',
343
351
  FAX: 'fax',
package/src/index.cjs CHANGED
@@ -421,6 +421,14 @@ const CASE_STAGE = Object.freeze({
421
421
  WITHDRAWN: 'withdrawn',
422
422
  });
423
423
 
424
+ const MESSAGE_EVENT_TYPE = Object.freeze({
425
+ CREATE: 'Create',
426
+ DELETE: 'Delete',
427
+ PUBLISH: 'Publish',
428
+ UNPUBLISH: 'Unpublish',
429
+ UPDATE: 'Update',
430
+ });
431
+
424
432
  const METHOD = Object.freeze({
425
433
  EMAIL: 'email',
426
434
  FAX: 'fax',
@@ -715,6 +723,7 @@ exports.APPEAL_SOURCE_SYSTEM = APPEAL_SOURCE_SYSTEM;
715
723
  exports.APPEAL_TYPE_OF_PLANNING_APPLICATION = APPEAL_TYPE_OF_PLANNING_APPLICATION;
716
724
  exports.APPEAL_VIRUS_CHECK_STATUS = APPEAL_VIRUS_CHECK_STATUS;
717
725
  exports.CASE_STAGE = CASE_STAGE;
726
+ exports.MESSAGE_EVENT_TYPE = MESSAGE_EVENT_TYPE;
718
727
  exports.METHOD = METHOD;
719
728
  exports.NSIP_CASE_TYPE = NSIP_CASE_TYPE;
720
729
  exports.NSIP_DECISION = NSIP_DECISION;
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "enums-static.schema.json",
4
+ "title": "Static Enums",
5
+ "description": "Static enums to add to generated types that are not directly references in schemas",
6
+ "type": "object",
7
+ "properties": {
8
+ "eventType": {
9
+ "type": "string",
10
+ "enum": ["Create", "Update", "Delete", "Publish", "Unpublish"],
11
+ "description": "The type of Service Bus event"
12
+ }
13
+ }
14
+ }
@@ -1,5 +1,5 @@
1
1
  import { jsonschema2md } from '@adobe/jsonschema2md';
2
- import { loadAllSchemas } from './index.js';
2
+ import { loadAllSchemas } from '../index.js';
3
3
  import fs from 'fs/promises';
4
4
 
5
5
  /**
@@ -1,13 +1,14 @@
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 { loadAllSchemas } from '../index.js';
5
5
  import snakeCase from 'lodash.snakecase';
6
+ import { loadSchema } from './load.js';
6
7
 
7
8
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
8
9
 
9
- export const constPath = path.join(__dirname, 'enums.js');
10
- export const constTsPath = path.join(__dirname, 'enums.d.ts');
10
+ export const constPath = path.join(__dirname, '..', 'enums.js');
11
+ export const constTsPath = path.join(__dirname, '..', 'enums.d.ts');
11
12
 
12
13
  const SPACING = ' ';
13
14
  const NEW_LINE = '\r\n';
@@ -26,6 +27,9 @@ async function run() {
26
27
  collectEnumProps(enumProps, schema.properties, schemaPrefix(schemaName));
27
28
  }
28
29
 
30
+ const staticEnums = await loadSchema(path.join(__dirname, 'enums-static.schema.json'));
31
+ collectEnumProps(enumProps, staticEnums.properties, 'message');
32
+
29
33
  let output = '';
30
34
  let tsOutput = '';
31
35
 
@@ -1,13 +1,13 @@
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 { loadAllSchemas } from '../index.js';
5
5
  import { compile } from 'json-schema-to-typescript';
6
- import { schemasPath, commandsPath } from './index.js';
6
+ import { schemasPath, commandsPath } from '../index.js';
7
7
 
8
8
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
9
9
 
10
- export const typesPath = path.join(__dirname, 'schemas.d.ts');
10
+ export const typesPath = path.join(__dirname, '..', 'schemas.d.ts');
11
11
 
12
12
  /**
13
13
  * Load all schemas and generate TypeScript definitions
package/src/lib/load.js CHANGED
@@ -29,7 +29,7 @@ export async function loadSchemas(dirPath) {
29
29
  * @param {string} filePath
30
30
  * @returns {Promise<any>}
31
31
  */
32
- async function loadSchema(filePath) {
32
+ export async function loadSchema(filePath) {
33
33
  const content = await readFile(filePath);
34
34
  return parse(content.toString());
35
35
  }
package/src/schemas.d.ts CHANGED
@@ -3381,6 +3381,9 @@ export interface AppellantSubmissionCommand {
3381
3381
  | ({
3382
3382
  caseType?: 'D';
3383
3383
  } & AppellantHASSubmissionProperties)
3384
+ | ({
3385
+ caseType?: 'ZP';
3386
+ } & AppellantHASSubmissionProperties)
3384
3387
  | ({
3385
3388
  caseType?: 'W';
3386
3389
  } & AppellantS78SubmissionProperties)
@@ -4262,6 +4265,9 @@ export interface LPAQuestionnaireCommand {
4262
4265
  } & LPAQS78SubmissionProperties)
4263
4266
  | ({
4264
4267
  caseType?: 'D';
4268
+ } & LPAQHASSubmissionProperties)
4269
+ | ({
4270
+ caseType?: 'ZP';
4265
4271
  } & LPAQHASSubmissionProperties);
4266
4272
  documents: {
4267
4273
  /**