@sketchscreens/core-schema 0.1.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/LICENSE +21 -0
- package/dist/audit.d.ts +28 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +42 -0
- package/dist/audit.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/schema.d.ts +625 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +231 -0
- package/dist/schema.js.map +1 -0
- package/dist/validate.d.ts +36 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +111 -0
- package/dist/validate.js.map +1 -0
- package/package.json +40 -0
- package/src/audit.ts +67 -0
- package/src/index.ts +47 -0
- package/src/schema.ts +256 -0
- package/src/validate.ts +165 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Houston IT Developers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/audit.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ProjectMap } from "./schema.js";
|
|
2
|
+
import type { ValidationIssue } from "./validate.js";
|
|
3
|
+
/**
|
|
4
|
+
* NODE-ONLY provenance audit. Separate from validate.ts (which stays
|
|
5
|
+
* browser-safe) because this touches the filesystem — only the CLI imports it.
|
|
6
|
+
*
|
|
7
|
+
* Verifies each screen's `sourceFile` actually exists under the repo root, so a
|
|
8
|
+
* hallucinated path can't masquerade as real provenance. Missing files are
|
|
9
|
+
* WARNINGS, not errors: a modal/dialog screen may legitimately have no file.
|
|
10
|
+
*/
|
|
11
|
+
export interface AuditResult {
|
|
12
|
+
/** Repo root the sourceFiles were resolved against. */
|
|
13
|
+
repoRoot: string;
|
|
14
|
+
/** How many screens declared a sourceFile. */
|
|
15
|
+
withSourceFile: number;
|
|
16
|
+
/** How many of those resolved to a real file. */
|
|
17
|
+
resolved: number;
|
|
18
|
+
/** sourceFiles that didn't resolve (repo-relative as written). */
|
|
19
|
+
missing: string[];
|
|
20
|
+
/** Warning issues (one per missing sourceFile). */
|
|
21
|
+
issues: ValidationIssue[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Audit a map's `sourceFile`s against `repoRoot`. Pass the root from the map's
|
|
25
|
+
* `meta.repoRoot` (or the cwd the extraction ran in). `~` is expanded.
|
|
26
|
+
*/
|
|
27
|
+
export declare function auditSourceFiles(map: ProjectMap, repoRoot: string): AuditResult;
|
|
28
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;GAOG;AAEH,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mDAAmD;IACnD,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CA0B/E"}
|
package/dist/audit.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, resolve } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Audit a map's `sourceFile`s against `repoRoot`. Pass the root from the map's
|
|
5
|
+
* `meta.repoRoot` (or the cwd the extraction ran in). `~` is expanded.
|
|
6
|
+
*/
|
|
7
|
+
export function auditSourceFiles(map, repoRoot) {
|
|
8
|
+
const root = expandHome(repoRoot);
|
|
9
|
+
const missing = [];
|
|
10
|
+
const issues = [];
|
|
11
|
+
let withSourceFile = 0;
|
|
12
|
+
let resolved = 0;
|
|
13
|
+
for (const screen of map.screens) {
|
|
14
|
+
const sf = screen.sourceFile;
|
|
15
|
+
if (!sf)
|
|
16
|
+
continue;
|
|
17
|
+
withSourceFile++;
|
|
18
|
+
const abs = isAbsolute(sf) ? sf : resolve(root, sf);
|
|
19
|
+
if (existsSync(abs) && statSync(abs).isFile()) {
|
|
20
|
+
resolved++;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
missing.push(sf);
|
|
24
|
+
issues.push({
|
|
25
|
+
code: "sourcefile_missing",
|
|
26
|
+
severity: "warning",
|
|
27
|
+
message: `Screen "${screen.id}" sourceFile does not exist: ${sf}`,
|
|
28
|
+
path: `screens[id=${screen.id}].sourceFile`,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return { repoRoot: root, withSourceFile, resolved, missing, issues };
|
|
33
|
+
}
|
|
34
|
+
/** Expand a leading ~ to the user's home directory. */
|
|
35
|
+
function expandHome(p) {
|
|
36
|
+
if (p === "~" || p.startsWith("~/")) {
|
|
37
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
38
|
+
return home + p.slice(1);
|
|
39
|
+
}
|
|
40
|
+
return p;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0BhD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAe,EAAE,QAAgB;IAChE,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACjC,MAAM,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;QAC7B,IAAI,CAAC,EAAE;YAAE,SAAS;QAClB,cAAc,EAAE,CAAC;QACjB,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpD,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9C,QAAQ,EAAE,CAAC;QACb,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjB,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,oBAAoB;gBAC1B,QAAQ,EAAE,SAAS;gBACnB,OAAO,EAAE,WAAW,MAAM,CAAC,EAAE,gCAAgC,EAAE,EAAE;gBACjE,IAAI,EAAE,cAAc,MAAM,CAAC,EAAE,cAAc;aAC5C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACvE,CAAC;AAED,uDAAuD;AACvD,SAAS,UAAU,CAAC,CAAS;IAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;QAC/D,OAAO,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sketchscreens/core-schema
|
|
3
|
+
*
|
|
4
|
+
* The contract at the center of SketchScreens: the `ProjectMap` shape that the
|
|
5
|
+
* extractor produces and the renderer consumes. Import the zod schemas to
|
|
6
|
+
* validate, or the inferred types to build maps in TypeScript.
|
|
7
|
+
*/
|
|
8
|
+
export { ElementType, ElementVariant, ElementRegion, ElementAlign, ScreenElement, ScreenSpec, Edge, Surface, ProjectMapMeta, ProjectMap, groupSegments, } from "./schema.js";
|
|
9
|
+
export type { ElementType as ElementTypeT, ElementVariant as ElementVariantT, ElementRegion as ElementRegionT, ElementAlign as ElementAlignT, ScreenElement as ScreenElementT, ScreenSpec as ScreenSpecT, Edge as EdgeT, Surface as SurfaceT, ProjectMapMeta as ProjectMapMetaT, ProjectMap as ProjectMapT, } from "./schema.js";
|
|
10
|
+
export { validateProjectMap, parseProjectMap, type ValidationIssue, type ValidationResult, type IssueSeverity, } from "./validate.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,IAAI,EACJ,OAAO,EACP,cAAc,EACd,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,WAAW,IAAI,YAAY,EAC3B,cAAc,IAAI,eAAe,EACjC,aAAa,IAAI,cAAc,EAC/B,YAAY,IAAI,aAAa,EAC7B,aAAa,IAAI,cAAc,EAC/B,UAAU,IAAI,WAAW,EACzB,IAAI,IAAI,KAAK,EACb,OAAO,IAAI,QAAQ,EACnB,cAAc,IAAI,eAAe,EACjC,UAAU,IAAI,WAAW,GAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sketchscreens/core-schema
|
|
3
|
+
*
|
|
4
|
+
* The contract at the center of SketchScreens: the `ProjectMap` shape that the
|
|
5
|
+
* extractor produces and the renderer consumes. Import the zod schemas to
|
|
6
|
+
* validate, or the inferred types to build maps in TypeScript.
|
|
7
|
+
*/
|
|
8
|
+
export { ElementType, ElementVariant, ElementRegion, ElementAlign, ScreenElement, ScreenSpec, Edge, Surface, ProjectMapMeta, ProjectMap, groupSegments, } from "./schema.js";
|
|
9
|
+
export { validateProjectMap, parseProjectMap, } from "./validate.js";
|
|
10
|
+
// NOTE: the filesystem audit (auditSourceFiles) lives in ./audit.js and is
|
|
11
|
+
// intentionally NOT re-exported here — it imports node:fs and would pollute the
|
|
12
|
+
// browser bundle. CLIs import it via the "@sketchscreens/core-schema/audit"
|
|
13
|
+
// subpath export (see package.json).
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,IAAI,EACJ,OAAO,EACP,cAAc,EACd,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAerB,OAAO,EACL,kBAAkB,EAClB,eAAe,GAIhB,MAAM,eAAe,CAAC;AAEvB,2EAA2E;AAC3E,gFAAgF;AAChF,4EAA4E;AAC5E,qCAAqC"}
|