@vev-software/atlas-contracts 0.1.7 → 0.1.8

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/dist/index.d.ts CHANGED
@@ -60,6 +60,7 @@ export interface Asset {
60
60
  kind: AssetKind;
61
61
  name: string;
62
62
  lifecycle: Lifecycle;
63
+ inUsePeriod?: InUsePeriod | null;
63
64
  description?: string | null;
64
65
  tags?: Tag[];
65
66
  application?: ApplicationDetails;
@@ -105,6 +106,7 @@ export interface ImportAsset {
105
106
  kind: AssetKind;
106
107
  name: string;
107
108
  lifecycle: Lifecycle;
109
+ inUsePeriod?: InUsePeriod | null;
108
110
  description?: string | null;
109
111
  tags?: Tag[];
110
112
  application?: ApplicationDetails;
@@ -504,3 +506,12 @@ export interface TargetArchitectureDocument {
504
506
  versions: TargetVersion[];
505
507
  transitions?: TargetTransition[];
506
508
  }
509
+ /** Calendar dates (YYYY-MM-DD), start inclusive/end exclusive; omitted/null means unknown. */
510
+ export interface InUsePeriod {
511
+ plannedStart?: string | null;
512
+ plannedEnd?: string | null;
513
+ actualStart?: string | null;
514
+ actualEnd?: string | null;
515
+ }
516
+ /** Validate dates and pair ordering. Does not infer lifecycle or replace raw JSON Schema validation. */
517
+ export declare function validateInUsePeriod(period?: InUsePeriod | null): string[];
package/dist/index.js CHANGED
@@ -48,3 +48,31 @@ export function validateLandscapeDigestV2(digest) {
48
48
  }
49
49
  return errors;
50
50
  }
51
+ /** Validate dates and pair ordering. Does not infer lifecycle or replace raw JSON Schema validation. */
52
+ export function validateInUsePeriod(period) {
53
+ if (period == null)
54
+ return [];
55
+ const errors = [];
56
+ const valid = (value) => {
57
+ if (!/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.test(value))
58
+ return false;
59
+ const year = Number(value.slice(0, 4));
60
+ const month = Number(value.slice(5, 7));
61
+ const day = Number(value.slice(8, 10));
62
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
63
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
64
+ return year >= 1 && month >= 1 && month <= 12 && day >= 1 && day <= days[month - 1];
65
+ };
66
+ for (const key of ["plannedStart", "plannedEnd", "actualStart", "actualEnd"]) {
67
+ const value = period[key];
68
+ if (value != null && (typeof value !== "string" || !valid(value)))
69
+ errors.push(`${key} must be a valid YYYY-MM-DD date.`);
70
+ }
71
+ for (const prefix of ["planned", "actual"]) {
72
+ const start = period[`${prefix}Start`];
73
+ const end = period[`${prefix}End`];
74
+ if (typeof start === "string" && typeof end === "string" && valid(start) && valid(end) && start > end)
75
+ errors.push(`${prefix}Start must be on or before ${prefix}End.`);
76
+ }
77
+ return errors;
78
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vev-software/atlas-contracts",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Public, versioned data model and interop contracts for VEV Atlas — the catalogue asset model plus manual relationships, tags and the landscape import/export document.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "scripts": {
18
18
  "build": "tsc -p tsconfig.json",
19
- "test": "npm run build && tsc --ignoreConfig --noEmit --strict --target ES2022 --module nodenext test/landscape-digest-v2.types.ts && node --test test/*.test.mjs",
19
+ "test": "npm run build && tsc --ignoreConfig --noEmit --strict --target ES2022 --module nodenext test/landscape-digest-v2.types.ts test/in-use-period.types.ts && node --test test/*.test.mjs",
20
20
  "prepack": "node scripts/prepack.mjs"
21
21
  },
22
22
  "devDependencies": {
@@ -24,6 +24,7 @@
24
24
  "maxLength": 4096
25
25
  },
26
26
  "lifecycle": { "$ref": "common.schema.json#/$defs/Lifecycle" },
27
+ "inUsePeriod": { "oneOf": [{ "type": "null" }, { "$ref": "common.schema.json#/$defs/InUsePeriod" }] },
27
28
  "tags": {
28
29
  "type": "array",
29
30
  "items": { "$ref": "common.schema.json#/$defs/Tag" },
@@ -4,6 +4,17 @@
4
4
  "title": "Atlas contracts — common types (v1)",
5
5
  "description": "Shared catalogue vocabulary for the Atlas asset model. Catalogue concepts only: no integration-criticality, EOL risk, portfolio scoring or AI review (those work with the data and live in the private Atlas core). See handbook 11 §1.",
6
6
  "$defs": {
7
+ "InUsePeriod": {
8
+ "type": "object",
9
+ "additionalProperties": false,
10
+ "description": "Planned and actual calendar-date periods, start inclusive and end exclusive. Missing/null dates are unknown. Same-day boundaries are allowed. Validate start <= end separately for each pair; no cross-pair or lifecycle constraint.",
11
+ "properties": {
12
+ "plannedStart": { "type": ["string", "null"], "format": "date", "pattern": "^(?!0000)[0-9]{4}-[0-9]{2}-[0-9]{2}$" },
13
+ "plannedEnd": { "type": ["string", "null"], "format": "date", "pattern": "^(?!0000)[0-9]{4}-[0-9]{2}-[0-9]{2}$" },
14
+ "actualStart": { "type": ["string", "null"], "format": "date", "pattern": "^(?!0000)[0-9]{4}-[0-9]{2}-[0-9]{2}$" },
15
+ "actualEnd": { "type": ["string", "null"], "format": "date", "pattern": "^(?!0000)[0-9]{4}-[0-9]{2}-[0-9]{2}$" }
16
+ }
17
+ },
7
18
  "AssetKind": {
8
19
  "type": "string",
9
20
  "description": "The kind of asset held in the catalogue. The data-layer kinds (data-area, dataset, column) model the data architecture beneath a system, down to the column. The AI kinds (ai-service, ai-model) catalogue AI platforms and models as first-class assets.",
@@ -50,6 +50,7 @@
50
50
  "name": { "type": "string", "minLength": 1, "maxLength": 256 },
51
51
  "description": { "type": ["string", "null"], "maxLength": 4096 },
52
52
  "lifecycle": { "$ref": "common.schema.json#/$defs/Lifecycle" },
53
+ "inUsePeriod": { "oneOf": [{ "type": "null" }, { "$ref": "common.schema.json#/$defs/InUsePeriod" }] },
53
54
  "tags": {
54
55
  "type": "array",
55
56
  "items": { "$ref": "common.schema.json#/$defs/Tag" },