@estiva-app/ui 0.21.1 → 0.23.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/README.md +21 -0
- package/dist/Avatar.d.ts +3 -0
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/Banner.d.ts +20 -2
- package/dist/Banner.d.ts.map +1 -1
- package/dist/ChipInput.d.ts +3 -0
- package/dist/ChipInput.d.ts.map +1 -1
- package/dist/CommandPalette.d.ts +6 -0
- package/dist/CommandPalette.d.ts.map +1 -1
- package/dist/ContainerHeader.d.ts +25 -0
- package/dist/ContainerHeader.d.ts.map +1 -0
- package/dist/EmptyState.d.ts +10 -1
- package/dist/EmptyState.d.ts.map +1 -1
- package/dist/IdentityMenu.d.ts +3 -0
- package/dist/IdentityMenu.d.ts.map +1 -1
- package/dist/Menu.d.ts +7 -0
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Skeleton.d.ts +2 -0
- package/dist/Skeleton.d.ts.map +1 -1
- package/dist/Toast.d.ts +5 -0
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toolbar.d.ts +4 -0
- package/dist/Toolbar.d.ts.map +1 -1
- package/dist/Tooltip.d.ts +4 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/gates/app-checks.d.ts.map +1 -1
- package/dist/gates/{chunk-ZGJ2J5NU.js → chunk-EA33NP5B.js} +275 -11
- package/dist/gates/chunk-EA33NP5B.js.map +7 -0
- package/dist/gates/{chunk-AUXD4GCY.js → chunk-GTQZEHPC.js} +15 -1
- package/dist/gates/chunk-GTQZEHPC.js.map +7 -0
- package/dist/gates/cli.js +1 -1
- package/dist/gates/create-app.d.ts +2 -0
- package/dist/gates/create-app.d.ts.map +1 -1
- package/dist/gates/create-app.js +1 -1
- package/dist/gates/index.js +25 -3
- package/dist/gates/index.js.map +2 -2
- package/dist/gates/status.d.ts +2 -0
- package/dist/gates/status.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -48
- package/dist/index.js.map +4 -4
- package/dist/registry/app-DQI6WLHR.js +10 -0
- package/dist/registry/app-DQI6WLHR.js.map +7 -0
- package/dist/registry/app.d.ts +21 -0
- package/dist/registry/app.d.ts.map +1 -0
- package/dist/registry/build-LGFCCOLR.js +27 -0
- package/dist/registry/build-LGFCCOLR.js.map +7 -0
- package/dist/registry/build.d.ts +95 -0
- package/dist/registry/build.d.ts.map +1 -0
- package/dist/registry/chunk-E4JNV7PC.js +155 -0
- package/dist/registry/chunk-E4JNV7PC.js.map +7 -0
- package/dist/registry/chunk-NJN4MQAM.js +397 -0
- package/dist/registry/chunk-NJN4MQAM.js.map +7 -0
- package/dist/registry/chunk-W2B2G7OE.js +188 -0
- package/dist/registry/chunk-W2B2G7OE.js.map +7 -0
- package/dist/registry/chunk-WMFF3MPP.js +648 -0
- package/dist/registry/chunk-WMFF3MPP.js.map +7 -0
- package/dist/registry/cli.d.ts +2 -0
- package/dist/registry/cli.d.ts.map +1 -0
- package/dist/registry/cli.js +176 -0
- package/dist/registry/cli.js.map +7 -0
- package/dist/registry/find.d.ts +54 -0
- package/dist/registry/find.d.ts.map +1 -0
- package/dist/registry/index.d.ts +17 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +34 -0
- package/dist/registry/index.js.map +7 -0
- package/dist/registry/schema.d.ts +224 -0
- package/dist/registry/schema.d.ts.map +1 -0
- package/package.json +15 -2
- package/registry.json +4615 -0
- package/src/Avatar.tsx +3 -0
- package/src/Banner.mdx +17 -4
- package/src/Banner.stories.tsx +22 -0
- package/src/Banner.test.tsx +35 -0
- package/src/Banner.tsx +34 -9
- package/src/ChipInput.tsx +3 -0
- package/src/CommandPalette.tsx +6 -0
- package/src/ContainerHeader.mdx +56 -0
- package/src/ContainerHeader.stories.tsx +62 -0
- package/src/ContainerHeader.test.tsx +47 -0
- package/src/ContainerHeader.tsx +45 -0
- package/src/EmptyState.mdx +12 -0
- package/src/EmptyState.stories.tsx +6 -1
- package/src/EmptyState.test.tsx +18 -1
- package/src/EmptyState.tsx +14 -1
- package/src/IdentityMenu.tsx +3 -0
- package/src/Menu.tsx +7 -0
- package/src/Skeleton.tsx +2 -0
- package/src/Toast.tsx +5 -0
- package/src/Toolbar.tsx +4 -0
- package/src/Tooltip.tsx +4 -0
- package/src/gates/app-checks.ts +23 -1
- package/src/gates/create-app.test.ts +77 -6
- package/src/gates/create-app.ts +288 -15
- package/src/gates/status.ts +16 -0
- package/src/index.ts +1 -0
- package/src/registry/app.test.ts +562 -0
- package/src/registry/app.ts +854 -0
- package/src/registry/build.ts +679 -0
- package/src/registry/cli.ts +204 -0
- package/src/registry/find.ts +232 -0
- package/src/registry/index.ts +31 -0
- package/src/registry/registry.test.ts +448 -0
- package/src/registry/schema.ts +419 -0
- package/dist/gates/chunk-AUXD4GCY.js.map +0 -7
- package/dist/gates/chunk-ZGJ2J5NU.js.map +0 -7
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Registry } from './schema';
|
|
2
|
+
export interface AppBuildOptions {
|
|
3
|
+
/** The app's folder: where its `package.json` and `src/` are. Ship's is `web`. */
|
|
4
|
+
root?: string;
|
|
5
|
+
/** The name its entries are recorded under — `peek`, `ship`. Defaults to the app's package name. */
|
|
6
|
+
repo?: string;
|
|
7
|
+
/** The package's own catalogue, for the parts an app part shares a name with. Defaults to the one this builder ships beside. */
|
|
8
|
+
packageRegistry?: Registry | null;
|
|
9
|
+
/** The packages the package itself depends on. An import of one never ties a part to its app. Defaults to the package's own. */
|
|
10
|
+
packageDependencies?: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Read one app and return its catalogue.
|
|
14
|
+
*
|
|
15
|
+
* Throws on anything it cannot explain, with every problem at once: a part with
|
|
16
|
+
* no purpose, a written kind it does not know. A catalogue that quietly drops
|
|
17
|
+
* what it could not read would answer "we have nothing for that" when the
|
|
18
|
+
* truth is "the builder gave up".
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildAppRegistry({ root, repo, packageRegistry, packageDependencies }?: AppBuildOptions): Registry;
|
|
21
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/registry/app.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAwE,KAAK,QAAQ,EAAsB,MAAM,UAAU,CAAA;AAElI,MAAM,WAAW,eAAe;IAC9B,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oGAAoG;IACpG,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gIAAgI;IAChI,eAAe,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;IACjC,gIAAgI;IAChI,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC/B;AAwQD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,IAAoB,EAAE,IAAI,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAE,eAAoB,GAAG,QAAQ,CAmhBrI"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
PACKAGE_IMPORT,
|
|
4
|
+
buildRegistry,
|
|
5
|
+
firstSentence,
|
|
6
|
+
pageOpening,
|
|
7
|
+
readIndexExports,
|
|
8
|
+
readModule,
|
|
9
|
+
readStories,
|
|
10
|
+
sanitize,
|
|
11
|
+
serializeRegistry,
|
|
12
|
+
toId
|
|
13
|
+
} from "./chunk-NJN4MQAM.js";
|
|
14
|
+
import "./chunk-E4JNV7PC.js";
|
|
15
|
+
export {
|
|
16
|
+
PACKAGE_IMPORT,
|
|
17
|
+
buildRegistry,
|
|
18
|
+
firstSentence,
|
|
19
|
+
pageOpening,
|
|
20
|
+
readIndexExports,
|
|
21
|
+
readModule,
|
|
22
|
+
readStories,
|
|
23
|
+
sanitize,
|
|
24
|
+
serializeRegistry,
|
|
25
|
+
toId
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=build-LGFCCOLR.js.map
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { type EntryProp, type EntryVariant, type Registry } from './schema';
|
|
3
|
+
export interface BuildOptions {
|
|
4
|
+
/** The repository's top folder. */
|
|
5
|
+
root?: string;
|
|
6
|
+
/** The name this registry's entries are recorded under. */
|
|
7
|
+
repo?: string;
|
|
8
|
+
}
|
|
9
|
+
/** One name as `index.ts` exports it. */
|
|
10
|
+
interface RawExport {
|
|
11
|
+
name: string;
|
|
12
|
+
/** The sibling it comes from, without `./`. */
|
|
13
|
+
module: string;
|
|
14
|
+
isType: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** What the parser found above and about one top-level declaration. */
|
|
17
|
+
interface Declared {
|
|
18
|
+
/** The doc comment, cleaned, or `''`. */
|
|
19
|
+
doc: string;
|
|
20
|
+
deprecated: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Its first parameter's type, as written. Kept as the node and resolved after
|
|
23
|
+
* the whole file is walked: a props interface is often declared *below* the
|
|
24
|
+
* component that takes it.
|
|
25
|
+
*/
|
|
26
|
+
propsType?: ts.TypeNode;
|
|
27
|
+
}
|
|
28
|
+
export declare const PACKAGE_IMPORT = "@estiva-app/ui";
|
|
29
|
+
/**
|
|
30
|
+
* Storybook's own `sanitize`, which is what turns a title and a story's export
|
|
31
|
+
* name into the id in the URL. Copied rather than imported: `storybook` is a
|
|
32
|
+
* dev dependency of this repo and must not become a runtime dependency of the
|
|
33
|
+
* builder, which apps run. A test holds this to the ids a real Storybook build
|
|
34
|
+
* produces.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sanitize(name: string): string;
|
|
37
|
+
export declare const toId: (title: string, name: string) => string;
|
|
38
|
+
/** Read `src/index.ts`. Its `export { … } from './Sibling'` statements are the target set. */
|
|
39
|
+
export declare function readIndexExports(source: string): RawExport[];
|
|
40
|
+
/**
|
|
41
|
+
* The first sentence of a block of prose, which is the purpose.
|
|
42
|
+
*
|
|
43
|
+
* A sentence ends at `.`, `!` or `?` followed by a space and something that
|
|
44
|
+
* starts a new one. A very short first sentence takes the next as well —
|
|
45
|
+
* "A list of actions from a trigger." is a purpose; "One row, two parts." is
|
|
46
|
+
* not, on its own.
|
|
47
|
+
*/
|
|
48
|
+
export declare function firstSentence(prose: string): string;
|
|
49
|
+
/** A page's opening paragraph: everything between its `# Heading` and the first blank line. */
|
|
50
|
+
export declare function pageOpening(mdx: string): string;
|
|
51
|
+
/** A type’s finished props and word-choices, read by the module that declares them. */
|
|
52
|
+
export interface Resolved {
|
|
53
|
+
props: EntryProp[];
|
|
54
|
+
variants: EntryVariant[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Ask another file for a type it declares, already resolved. `specifier` is the
|
|
58
|
+
* import as written (`./IconButton`, `@/lib/types`); the caller decides what it
|
|
59
|
+
* points at, and answers `undefined` for anything outside the library it reads.
|
|
60
|
+
*/
|
|
61
|
+
export type Sibling = (specifier: string, typeName: string) => Resolved | undefined;
|
|
62
|
+
export interface ReadOptions {
|
|
63
|
+
/**
|
|
64
|
+
* Whether a file with no comment of its own at the top lends the comment on
|
|
65
|
+
* its first declaration to the file. The package: yes — `Skeleton.tsx`'s
|
|
66
|
+
* family paragraph sits there, and taking it as `SkeletonBar`'s was wrong. An
|
|
67
|
+
* app: no — a comment directly above a part is that part's, which is what a
|
|
68
|
+
* person writing one expects; a file's own goes at the very top.
|
|
69
|
+
*/
|
|
70
|
+
lendFirstComment?: boolean;
|
|
71
|
+
}
|
|
72
|
+
export declare function readModule(source: string, sibling?: Sibling, { lendFirstComment }?: ReadOptions): {
|
|
73
|
+
declarations: Map<string, Declared>;
|
|
74
|
+
headerDoc: string;
|
|
75
|
+
resolve: (propsType: ts.TypeNode | undefined) => Resolved;
|
|
76
|
+
resolveName: (name: string) => Resolved;
|
|
77
|
+
};
|
|
78
|
+
/** The `title` a stories file gives Storybook, and the stories it exports. */
|
|
79
|
+
export declare function readStories(source: string): {
|
|
80
|
+
title: string | null;
|
|
81
|
+
stories: string[];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Read the repository and return the catalogue.
|
|
85
|
+
*
|
|
86
|
+
* Throws on anything it cannot explain — a missing sibling, a name with no
|
|
87
|
+
* purpose anywhere. A registry that quietly drops what it could not read is
|
|
88
|
+
* worse than no registry, because a reader cannot tell the difference between
|
|
89
|
+
* "we have nothing for that" and "the builder gave up".
|
|
90
|
+
*/
|
|
91
|
+
export declare function buildRegistry({ root, repo }?: BuildOptions): Registry;
|
|
92
|
+
/** The committed file's text, so a check and a write produce the same bytes. */
|
|
93
|
+
export declare function serializeRegistry(registry: Registry): string;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/registry/build.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAuD,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAsB,MAAM,UAAU,CAAA;AAEpJ,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,yCAAyC;AACzC,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,uEAAuE;AACvE,UAAU,QAAQ;IAChB,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,OAAO,CAAA;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAA;CACxB;AAED,eAAO,MAAM,cAAc,mBAAmB,CAAA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AiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/registry/schema.ts
|
|
4
|
+
var SCHEMA_VERSION = 2;
|
|
5
|
+
var KINDS = ["component", "hook", "helper"];
|
|
6
|
+
var STATUSES = ["stable", "migrating", "deprecated"];
|
|
7
|
+
var SOURCES = ["page", "comment", "file", "package"];
|
|
8
|
+
var CLASSES = ["re-export", "reusable", "one-off", "promote-candidate", "unused"];
|
|
9
|
+
var isString = (v) => typeof v === "string";
|
|
10
|
+
var isFilledString = (v) => isString(v) && v.trim().length > 0;
|
|
11
|
+
function validateRegistry(value) {
|
|
12
|
+
const problems = [];
|
|
13
|
+
const fail = (message) => problems.push(message);
|
|
14
|
+
if (typeof value !== "object" || value === null) return ["the registry is not an object"];
|
|
15
|
+
const registry = value;
|
|
16
|
+
if (registry.schemaVersion !== SCHEMA_VERSION) fail(`schemaVersion is ${String(registry.schemaVersion)}, expected ${SCHEMA_VERSION}`);
|
|
17
|
+
const built = registry.builtFrom;
|
|
18
|
+
let isApp = false;
|
|
19
|
+
if (typeof built !== "object" || built === null) fail("builtFrom is missing");
|
|
20
|
+
else {
|
|
21
|
+
if (built.kind !== "package" && built.kind !== "app") fail(`builtFrom.kind is ${String(built.kind)}, expected package or app`);
|
|
22
|
+
isApp = built.kind === "app";
|
|
23
|
+
if (!isFilledString(built.repo)) fail("builtFrom.repo is missing");
|
|
24
|
+
if (!isFilledString(built.package)) fail("builtFrom.package is missing");
|
|
25
|
+
if (!isFilledString(built.packageVersion)) fail("builtFrom.packageVersion is missing");
|
|
26
|
+
if (typeof built.exports !== "number") fail("builtFrom.exports is not a number");
|
|
27
|
+
if (typeof built.typeExports !== "number") fail("builtFrom.typeExports is not a number");
|
|
28
|
+
if (isApp ? typeof built.files !== "number" : built.files !== null) fail(`builtFrom.files is ${String(built.files)}: a number for an app, null for the package`);
|
|
29
|
+
}
|
|
30
|
+
const book = registry.storybook;
|
|
31
|
+
if (typeof book !== "object" || book === null) fail("storybook is missing");
|
|
32
|
+
else {
|
|
33
|
+
for (const key of ["docsPath", "storyPath", "devUrl"]) {
|
|
34
|
+
if (!isFilledString(book[key])) fail(`storybook.${key} is missing`);
|
|
35
|
+
}
|
|
36
|
+
if (isString(book.docsPath) && !book.docsPath.includes("{docsId}")) fail("storybook.docsPath does not carry {docsId}");
|
|
37
|
+
if (isString(book.storyPath) && !book.storyPath.includes("{storyId}")) fail("storybook.storyPath does not carry {storyId}");
|
|
38
|
+
}
|
|
39
|
+
const entries = registry.entries;
|
|
40
|
+
const excluded = registry.excluded;
|
|
41
|
+
const withoutParts = registry.filesWithoutParts;
|
|
42
|
+
if (!Array.isArray(entries)) return [...problems, "entries is not an array"];
|
|
43
|
+
if (!Array.isArray(excluded)) return [...problems, "excluded is not an array"];
|
|
44
|
+
if (!Array.isArray(withoutParts)) return [...problems, "filesWithoutParts is not an array"];
|
|
45
|
+
if (entries.length === 0 && !isApp) fail("entries is empty");
|
|
46
|
+
const seen = /* @__PURE__ */ new Set();
|
|
47
|
+
const seenNames = /* @__PURE__ */ new Set();
|
|
48
|
+
for (const [i, raw] of entries.entries()) {
|
|
49
|
+
const at = (field) => `entries[${i}] (${isString(raw?.name) ? raw.name : "?"}).${field}`;
|
|
50
|
+
if (typeof raw !== "object" || raw === null) {
|
|
51
|
+
fail(`entries[${i}] is not an object`);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const entry = raw;
|
|
55
|
+
const key = isApp ? `${String(entry.sourceFile)}#${String(entry.name)}` : String(entry.name);
|
|
56
|
+
if (!isFilledString(entry.name)) fail(at("name") + " is missing");
|
|
57
|
+
else if (seen.has(key)) fail(`${entry.name} appears twice${isApp ? ` in ${String(entry.sourceFile)}` : ""}`);
|
|
58
|
+
else {
|
|
59
|
+
seen.add(key);
|
|
60
|
+
seenNames.add(entry.name);
|
|
61
|
+
}
|
|
62
|
+
if (!isFilledString(entry.repo)) fail(at("repo") + " is missing");
|
|
63
|
+
if (!isFilledString(entry.importPath)) fail(at("importPath") + " is missing");
|
|
64
|
+
if (!isFilledString(entry.sourceFile)) fail(at("sourceFile") + " is missing");
|
|
65
|
+
if (!isFilledString(entry.purpose)) fail(at("purpose") + " is empty");
|
|
66
|
+
if (!KINDS.includes(entry.kind)) fail(at("kind") + ` is ${String(entry.kind)}`);
|
|
67
|
+
if (!SOURCES.includes(entry.purposeFrom)) fail(at("purposeFrom") + ` is ${String(entry.purposeFrom)}`);
|
|
68
|
+
if (!STATUSES.includes(entry.status)) fail(at("status") + ` is ${String(entry.status)}`);
|
|
69
|
+
if (!(entry.migrationStage === null || typeof entry.migrationStage === "number")) fail(at("migrationStage") + " is neither a number nor null");
|
|
70
|
+
if (!Array.isArray(entry.props)) fail(at("props") + " is not an array");
|
|
71
|
+
else
|
|
72
|
+
for (const prop of entry.props) {
|
|
73
|
+
if (!isFilledString(prop?.name) || !isFilledString(prop?.takes) || typeof prop?.required !== "boolean") fail(at("props") + " has a malformed entry");
|
|
74
|
+
else if (!(prop.note === null || isFilledString(prop.note))) fail(at("props") + `.${prop.name}.note is neither a string nor null`);
|
|
75
|
+
}
|
|
76
|
+
if (!Array.isArray(entry.variants)) fail(at("variants") + " is not an array");
|
|
77
|
+
else
|
|
78
|
+
for (const variant of entry.variants) {
|
|
79
|
+
if (!isFilledString(variant?.prop) || !Array.isArray(variant?.values) || variant.values.length === 0) fail(at("variants") + " has a malformed entry");
|
|
80
|
+
else if (Array.isArray(entry.props) && !entry.props.some((prop) => prop?.name === variant.prop)) fail(at("variants") + `.${variant.prop} is not one of its props`);
|
|
81
|
+
}
|
|
82
|
+
if (!Array.isArray(entry.ownsBehaviours)) fail(at("ownsBehaviours") + " is not an array");
|
|
83
|
+
else for (const behaviour of entry.ownsBehaviours) {
|
|
84
|
+
if (!isFilledString(behaviour?.id) || !isFilledString(behaviour?.behaviour)) fail(at("ownsBehaviours") + " has a malformed entry");
|
|
85
|
+
}
|
|
86
|
+
for (const key2 of ["docsId", "storyId", "docPage"]) {
|
|
87
|
+
const held = entry[key2];
|
|
88
|
+
if (!(held === null || isFilledString(held))) fail(at(key2) + " is neither a string nor null");
|
|
89
|
+
}
|
|
90
|
+
if (!isApp && entry.kind === "component" && (entry.docsId === null || entry.storyId === null)) {
|
|
91
|
+
fail(at("docsId") + " is null, and only a helper or a hook may have no page or story");
|
|
92
|
+
}
|
|
93
|
+
if (!isApp) {
|
|
94
|
+
if (entry.app !== null) fail(at("app") + " is set on a package entry");
|
|
95
|
+
} else {
|
|
96
|
+
problems.push(...validateAppFacts(entry, at));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const [i, raw] of excluded.entries()) {
|
|
100
|
+
const gap = raw;
|
|
101
|
+
if (!isFilledString(gap?.name)) fail(`excluded[${i}].name is missing`);
|
|
102
|
+
if (!isFilledString(gap?.reason)) fail(`excluded[${i}].reason is missing`);
|
|
103
|
+
if (!isApp && isString(gap?.name) && seenNames.has(gap.name)) fail(`${gap.name} is both an entry and excluded`);
|
|
104
|
+
}
|
|
105
|
+
const counted = entries.length + excluded.length;
|
|
106
|
+
if (typeof built === "object" && built !== null && typeof built.exports === "number" && counted !== built.exports) {
|
|
107
|
+
fail(`${entries.length} entries + ${excluded.length} excluded = ${counted}, but ${isApp ? "the app has" : "index.ts exports"} ${built.exports} ${isApp ? "parts" : "values"}`);
|
|
108
|
+
}
|
|
109
|
+
const fileProblems = [];
|
|
110
|
+
const withParts = new Set(entries.map((entry) => entry.sourceFile));
|
|
111
|
+
for (const [i, raw] of withoutParts.entries()) {
|
|
112
|
+
const gap = raw;
|
|
113
|
+
if (!isFilledString(gap?.file)) fileProblems.push(`filesWithoutParts[${i}].file is missing`);
|
|
114
|
+
else if (withParts.has(gap.file)) fileProblems.push(`${gap.file} holds a part and is listed as holding none`);
|
|
115
|
+
if (!isFilledString(gap?.reason)) fileProblems.push(`filesWithoutParts[${i}].reason is missing`);
|
|
116
|
+
}
|
|
117
|
+
if (!isApp && withoutParts.length) fileProblems.push("filesWithoutParts is for an app; the package lists its exports instead");
|
|
118
|
+
if (isApp && typeof built === "object" && built !== null && typeof built.files === "number" && withParts.size + withoutParts.length !== built.files) {
|
|
119
|
+
fileProblems.push(`${withParts.size} files hold a part + ${withoutParts.length} hold none = ${withParts.size + withoutParts.length}, but the app has ${built.files} files`);
|
|
120
|
+
}
|
|
121
|
+
problems.push(...fileProblems);
|
|
122
|
+
return problems;
|
|
123
|
+
}
|
|
124
|
+
function validateAppFacts(entry, at) {
|
|
125
|
+
const problems = [];
|
|
126
|
+
const fail = (message) => problems.push(message);
|
|
127
|
+
const facts = entry.app;
|
|
128
|
+
if (typeof facts !== "object" || facts === null) return [at("app") + " is missing on an app entry"];
|
|
129
|
+
if (!CLASSES.includes(facts.class)) fail(at("app.class") + ` is ${String(facts.class)}`);
|
|
130
|
+
if (!isFilledString(facts.reason)) fail(at("app.reason") + " is empty");
|
|
131
|
+
if (typeof facts.written !== "boolean") fail(at("app.written") + " is not true/false");
|
|
132
|
+
if (typeof facts.defaultExport !== "boolean") fail(at("app.defaultExport") + " is not true/false");
|
|
133
|
+
if (!Array.isArray(facts.usedIn) || !facts.usedIn.every(isFilledString)) fail(at("app.usedIn") + " is not a list of files");
|
|
134
|
+
if (!Array.isArray(facts.tiedTo) || !facts.tiedTo.every(isFilledString)) fail(at("app.tiedTo") + " is not a list");
|
|
135
|
+
if (!(facts.handsOn === null || isFilledString(facts.handsOn))) fail(at("app.handsOn") + " is neither a name nor null");
|
|
136
|
+
if (!(facts.packageNamesake === null || isFilledString(facts.packageNamesake))) fail(at("app.packageNamesake") + " is neither a name nor null");
|
|
137
|
+
if (problems.length) return problems;
|
|
138
|
+
const passOn = facts.class === "re-export";
|
|
139
|
+
if (passOn !== (facts.handsOn !== null)) fail(at("app.handsOn") + (passOn ? " is missing on a pass-on" : " is set on a part that is not a pass-on"));
|
|
140
|
+
if (passOn !== (entry.purposeFrom === "package")) fail(at("purposeFrom") + (passOn ? " must be package on a pass-on" : " is package on a part that is not a pass-on"));
|
|
141
|
+
if (passOn && facts.written) fail(at("app.written") + ": a pass-on is read from the file, never written");
|
|
142
|
+
if (!facts.written && !passOn) {
|
|
143
|
+
const uses = facts.usedIn.length;
|
|
144
|
+
const expected = uses === 0 ? "unused" : uses === 1 ? "one-off" : facts.tiedTo.length ? "reusable" : "promote-candidate";
|
|
145
|
+
if (facts.class !== expected) fail(at("app.class") + ` is ${facts.class}, but its evidence (${uses} uses, ${facts.tiedTo.length} ties) says ${expected}`);
|
|
146
|
+
}
|
|
147
|
+
return problems;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
SCHEMA_VERSION,
|
|
152
|
+
CLASSES,
|
|
153
|
+
validateRegistry
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=chunk-E4JNV7PC.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/registry/schema.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The catalogue's shape (UIG-12, seam S2 in docs/GATES.md \u00A716).\n *\n * A **data source read by machines first** and rendered second \u2014 not a\n * documentation generator. The skill (UIG-20), the copy detector (UIG-25) and\n * the merged search (UIG-19) all read this and nothing else, so the field\n * names are the contract and `schemaVersion` is what makes a change to them\n * detectable.\n *\n * Names are plain and ours. Open-sourcing is far off; when it comes, a\n * renaming pass is one version bump, and guessing at a public vocabulary now\n * would cost every reader between here and there.\n */\n\n/**\n * Raise this whenever a field is added, removed or given a new meaning. A\n * reader that knows version N and is handed N+1 must be able to say so rather\n * than silently read a field that moved.\n */\nexport const SCHEMA_VERSION = 2\n\n/** What a name is, which decides how a reader offers it. */\nexport type EntryKind =\n /** Draws something. Used in JSX. */\n | 'component'\n /** A React hook: `use\u2026`, callable only inside a component. */\n | 'hook'\n /** A function or a constant. Neither of the above. */\n | 'helper'\n\n/** Where an entry's one-line purpose was read from. */\nexport type PurposeSource =\n /** The `.mdx` page's opening paragraph \u2014 the name has a page of its own. */\n | 'page'\n /** The doc comment above the export \u2014 the name is documented on a sibling's page. */\n | 'comment'\n /** An app's file that holds this one part: the comment at the top of the file (UIG-13). */\n | 'file'\n /** An app's pass-on: the part is the package's, and says so (UIG-13). */\n | 'package'\n\n/**\n * Which of four kinds an app's part is (UIG-13), or that nothing uses it.\n *\n * Worked out from the code, never from the folder a file sits in: Peek's\n * `components/ui` holds one-line pass-ons beside 187-line components.\n */\nexport type EntryClass =\n /** Its file only hands a package part on, so the app keeps its own import path. */\n | 're-export'\n /** Used in two or more places in the app. Gets a usage page (UIG-17, UIG-18). */\n | 'reusable'\n /** Used in one place. Needs only its purpose line. */\n | 'one-off'\n /** Reusable, and everything it uses is already in the package: it could move there. Katerina rules. */\n | 'promote-candidate'\n /** No file of the app uses it: only its stories or tests, or nothing. Listed, never deleted by the catalogue. */\n | 'unused'\n\n/**\n * What the catalogue knows about a part that lives in an app (UIG-13). `null`\n * on the package's own entries.\n */\nexport interface AppFacts {\n class: EntryClass\n /** Why it has that class, in words: the evidence, or the written reason. */\n reason: string\n /**\n * `true` when the class is written beside the part (`@registry <class>: <reason>`\n * in its comment) rather than worked out \u2014 \"general, though one screen uses it yet\".\n */\n written: boolean\n /** A pass-on's part, as `Name` for the package's and `Name from <package>` for another's. `null` otherwise. */\n handsOn: string | null\n /**\n * The app's files that use it, relative to the app: every file that imports it,\n * and its own file when something else there draws it. Stories and tests are not\n * uses \u2014 a part only they reach is unused.\n */\n usedIn: string[]\n /**\n * What ties it to this app: each import that is neither in the package's own\n * dependencies nor an app file that is itself untied. Empty means it could\n * live in the package as it is.\n */\n tiedTo: string[]\n /** The package part with the same name, when there is one: the reader should see both. */\n packageNamesake: string | null\n /** Imported as `import X from \u2026` rather than `import { X } from \u2026`. */\n defaultExport: boolean\n}\n\n/** A file in an app's target set that holds no part, and why, in words. */\nexport interface FileWithoutPart {\n file: string\n reason: string\n}\n\nexport type EntryStatus = 'stable' | 'migrating' | 'deprecated'\n\n/** A prop that takes one of a known set of words, and the set. */\nexport interface EntryVariant {\n prop: string\n values: string[]\n}\n\n/**\n * One prop a component declares itself.\n *\n * **Itself**, not what it inherits: a component that extends\n * `ComponentPropsWithRef<'div'>` would otherwise drag in every DOM attribute,\n * which is noise in a catalogue whose whole point is a short answer.\n */\nexport interface EntryProp {\n name: string\n /**\n * What it takes, in a word a person reads: `true/false`, `number`, `text`,\n * `anything`, `a handler`, the words themselves for a set (`left | right`),\n * or the type as written where none of those fit.\n */\n takes: string\n required: boolean\n /** The first sentence of the prop's own comment, where it has one. */\n note: string | null\n}\n\n/** A behaviour this component owns, from UIG-8's enumeration. */\nexport interface EntryBehaviour {\n /** `OwnedBehaviour.id` \u2014 `portal`, `walking`, `scroll`\u2026 */\n id: string\n /** What a person notices it doing, in words. */\n behaviour: string\n}\n\nexport interface RegistryEntry {\n /** The exported name, exactly as `index.ts` exports it. */\n name: string\n /** Which library it came from: `estiva-ui`, or the app that owns it. */\n repo: string\n kind: EntryKind\n /** What a caller actually types. */\n importPath: string\n /** The file the name is declared in, relative to the repo. Several names share one file. */\n sourceFile: string\n /** One line: what it is for. Never empty \u2014 the build fails instead. */\n purpose: string\n purposeFrom: PurposeSource\n /**\n * Every prop it declares itself \u2014 what it can do. This is the field a reader\n * asks \"does it already do X?\" of, before writing X by hand.\n */\n props: EntryProp[]\n /**\n * The subset of `props` that takes one of a known set of words, structured.\n * Kept beside `props` because it is what a search ranks well on, and what a\n * caller most often needs named back at them.\n */\n variants: EntryVariant[]\n /** What it owns, so a caller never rebuilds it (UIG-8). Empty for most. */\n ownsBehaviours: EntryBehaviour[]\n status: EntryStatus\n /**\n * Which migration stage plans to change it.\n *\n * Always `null` here. The migration's plan lives in `K:/Estiva/migration\n * docs`, which is not in this repo and is not in CI \u2014 and a copy kept here by\n * hand is the drifting list this whole project exists to remove. The field\n * stays in the schema because a later ticket may have a source a build can\n * read; until then a reader gets an honest `null` rather than a stale number.\n */\n migrationStage: number | null\n /** The `.mdx` page's Storybook id, or `null` where the name has no page of its own. */\n docsId: string | null\n /** A story that shows it, by Storybook id. `null` where nothing renders it alone. */\n storyId: string | null\n /** The `.mdx` path, relative to the repo, or `null`. */\n docPage: string | null\n /** An app's part: its class and the evidence for it (UIG-13). `null` on the package's own entries. */\n app: AppFacts | null\n}\n\n/** A name that is exported and deliberately not an entry. Empty today; the count still has to reconcile. */\nexport interface RegistryExclusion {\n name: string\n reason: string\n}\n\nexport interface Registry {\n schemaVersion: number\n builtFrom: {\n /**\n * `package`: the package's catalogue, committed and shipped. `app`: one app's,\n * built fresh from its code each time and never committed \u2014 Peek and Ship are\n * private, the package is public (Katerina, 18 September 2026).\n */\n kind: 'package' | 'app'\n repo: string\n /** The package the entries are imported from, or the app's own name. */\n package: string\n packageVersion: string\n /**\n * The package: value exports counted in `index.ts`. An app: parts found in its\n * files. `entries + excluded` must equal it.\n */\n exports: number\n /** Type-only exports, which are not entries. Recorded so the count reconciles. `0` for an app. */\n typeExports: number\n /**\n * An app only: its `.tsx` files outside stories and tests. Each one either holds\n * an entry or is in `filesWithoutParts`. `null` for the package.\n */\n files: number | null\n }\n /**\n * How to turn an id into a link. There is no Storybook on the internet yet\n * (UIG-19), so an absolute URL committed here would resolve nowhere: the\n * reader joins its own base to these.\n */\n storybook: {\n docsPath: string\n storyPath: string\n devUrl: string\n }\n entries: RegistryEntry[]\n excluded: RegistryExclusion[]\n /** An app's `.tsx` files that hold no part, each with its reason. Empty for the package. */\n filesWithoutParts: FileWithoutPart[]\n}\n\nconst KINDS: EntryKind[] = ['component', 'hook', 'helper']\nconst STATUSES: EntryStatus[] = ['stable', 'migrating', 'deprecated']\nconst SOURCES: PurposeSource[] = ['page', 'comment', 'file', 'package']\nexport const CLASSES: EntryClass[] = ['re-export', 'reusable', 'one-off', 'promote-candidate', 'unused']\n\nconst isString = (v: unknown): v is string => typeof v === 'string'\nconst isFilledString = (v: unknown): v is string => isString(v) && v.trim().length > 0\n\n/**\n * Check a registry against this schema. Returns every problem, not the first:\n * a build that reports one missing purpose per run costs one run per entry.\n *\n * An empty list is the only pass. CI runs this on the committed file.\n */\nexport function validateRegistry(value: unknown): string[] {\n const problems: string[] = []\n const fail = (message: string) => problems.push(message)\n\n if (typeof value !== 'object' || value === null) return ['the registry is not an object']\n const registry = value as Partial<Registry>\n\n if (registry.schemaVersion !== SCHEMA_VERSION) fail(`schemaVersion is ${String(registry.schemaVersion)}, expected ${SCHEMA_VERSION}`)\n\n const built = registry.builtFrom\n let isApp = false\n if (typeof built !== 'object' || built === null) fail('builtFrom is missing')\n else {\n if (built.kind !== 'package' && built.kind !== 'app') fail(`builtFrom.kind is ${String(built.kind)}, expected package or app`)\n isApp = built.kind === 'app'\n if (!isFilledString(built.repo)) fail('builtFrom.repo is missing')\n if (!isFilledString(built.package)) fail('builtFrom.package is missing')\n if (!isFilledString(built.packageVersion)) fail('builtFrom.packageVersion is missing')\n if (typeof built.exports !== 'number') fail('builtFrom.exports is not a number')\n if (typeof built.typeExports !== 'number') fail('builtFrom.typeExports is not a number')\n if (isApp ? typeof built.files !== 'number' : built.files !== null) fail(`builtFrom.files is ${String(built.files)}: a number for an app, null for the package`)\n }\n\n const book = registry.storybook\n if (typeof book !== 'object' || book === null) fail('storybook is missing')\n else {\n for (const key of ['docsPath', 'storyPath', 'devUrl'] as const) {\n if (!isFilledString(book[key])) fail(`storybook.${key} is missing`)\n }\n if (isString(book.docsPath) && !book.docsPath.includes('{docsId}')) fail('storybook.docsPath does not carry {docsId}')\n if (isString(book.storyPath) && !book.storyPath.includes('{storyId}')) fail('storybook.storyPath does not carry {storyId}')\n }\n\n const entries = registry.entries\n const excluded = registry.excluded\n const withoutParts = registry.filesWithoutParts\n if (!Array.isArray(entries)) return [...problems, 'entries is not an array']\n if (!Array.isArray(excluded)) return [...problems, 'excluded is not an array']\n if (!Array.isArray(withoutParts)) return [...problems, 'filesWithoutParts is not an array']\n // An app with no part of its own yet is still an app: only the package must have entries.\n if (entries.length === 0 && !isApp) fail('entries is empty')\n\n // The package's names are unique; an app may have two parts of one name in two\n // files, and the catalogue says which is which rather than refusing the app.\n const seen = new Set<string>()\n const seenNames = new Set<string>()\n for (const [i, raw] of entries.entries()) {\n const at = (field: string) => `entries[${i}] (${isString((raw as RegistryEntry)?.name) ? (raw as RegistryEntry).name : '?'}).${field}`\n if (typeof raw !== 'object' || raw === null) {\n fail(`entries[${i}] is not an object`)\n continue\n }\n const entry = raw as Partial<RegistryEntry>\n const key = isApp ? `${String(entry.sourceFile)}#${String(entry.name)}` : String(entry.name)\n if (!isFilledString(entry.name)) fail(at('name') + ' is missing')\n else if (seen.has(key)) fail(`${entry.name} appears twice${isApp ? ` in ${String(entry.sourceFile)}` : ''}`)\n else {\n seen.add(key)\n seenNames.add(entry.name)\n }\n\n if (!isFilledString(entry.repo)) fail(at('repo') + ' is missing')\n if (!isFilledString(entry.importPath)) fail(at('importPath') + ' is missing')\n if (!isFilledString(entry.sourceFile)) fail(at('sourceFile') + ' is missing')\n // The reason this schema exists: an entry with no purpose is an entry the\n // search cannot find and the skill cannot quote.\n if (!isFilledString(entry.purpose)) fail(at('purpose') + ' is empty')\n if (!KINDS.includes(entry.kind as EntryKind)) fail(at('kind') + ` is ${String(entry.kind)}`)\n if (!SOURCES.includes(entry.purposeFrom as PurposeSource)) fail(at('purposeFrom') + ` is ${String(entry.purposeFrom)}`)\n if (!STATUSES.includes(entry.status as EntryStatus)) fail(at('status') + ` is ${String(entry.status)}`)\n if (!(entry.migrationStage === null || typeof entry.migrationStage === 'number')) fail(at('migrationStage') + ' is neither a number nor null')\n if (!Array.isArray(entry.props)) fail(at('props') + ' is not an array')\n else\n for (const prop of entry.props) {\n if (!isFilledString(prop?.name) || !isFilledString(prop?.takes) || typeof prop?.required !== 'boolean') fail(at('props') + ' has a malformed entry')\n else if (!(prop.note === null || isFilledString(prop.note))) fail(at('props') + `.${prop.name}.note is neither a string nor null`)\n }\n if (!Array.isArray(entry.variants)) fail(at('variants') + ' is not an array')\n else\n for (const variant of entry.variants) {\n if (!isFilledString(variant?.prop) || !Array.isArray(variant?.values) || variant.values.length === 0) fail(at('variants') + ' has a malformed entry')\n // variants is a view of props, never a second source that can disagree.\n else if (Array.isArray(entry.props) && !entry.props.some((prop) => prop?.name === variant.prop)) fail(at('variants') + `.${variant.prop} is not one of its props`)\n }\n if (!Array.isArray(entry.ownsBehaviours)) fail(at('ownsBehaviours') + ' is not an array')\n else for (const behaviour of entry.ownsBehaviours) {\n if (!isFilledString(behaviour?.id) || !isFilledString(behaviour?.behaviour)) fail(at('ownsBehaviours') + ' has a malformed entry')\n }\n for (const key of ['docsId', 'storyId', 'docPage'] as const) {\n const held = entry[key]\n if (!(held === null || isFilledString(held))) fail(at(key) + ' is neither a string nor null')\n }\n // \"Every storyUrl resolves, or is recorded as absent with a reason\" \u2014 the\n // reason is enforced rather than written down: only something that draws\n // nothing may have nowhere to be looked at. A component with no story is\n // already an error of UIG-5's component-has-a-story; this stops the\n // catalogue quietly carrying one.\n //\n // The package only. An app's parts are described before they are drawn:\n // absence of a story says nothing about whether a part is reused, and UIG-19\n // is where a reusable one must have one.\n if (!isApp && entry.kind === 'component' && (entry.docsId === null || entry.storyId === null)) {\n fail(at('docsId') + ' is null, and only a helper or a hook may have no page or story')\n }\n\n if (!isApp) {\n if (entry.app !== null) fail(at('app') + ' is set on a package entry')\n } else {\n problems.push(...validateAppFacts(entry, at))\n }\n }\n\n for (const [i, raw] of excluded.entries()) {\n const gap = raw as Partial<RegistryExclusion>\n if (!isFilledString(gap?.name)) fail(`excluded[${i}].name is missing`)\n if (!isFilledString(gap?.reason)) fail(`excluded[${i}].reason is missing`)\n if (!isApp && isString(gap?.name) && seenNames.has(gap.name)) fail(`${gap.name} is both an entry and excluded`)\n }\n\n // Completeness (the ticket's acceptance): every value export is either an\n // entry or an exclusion with a reason. Averaging the difference away is the\n // failure this check exists to make impossible.\n const counted = entries.length + excluded.length\n if (typeof built === 'object' && built !== null && typeof built.exports === 'number' && counted !== built.exports) {\n fail(`${entries.length} entries + ${excluded.length} excluded = ${counted}, but ${isApp ? 'the app has' : 'index.ts exports'} ${built.exports} ${isApp ? 'parts' : 'values'}`)\n }\n\n // And an app's files: every one either holds a part or says why it does not.\n const fileProblems: string[] = []\n const withParts = new Set(entries.map((entry) => (entry as RegistryEntry).sourceFile))\n for (const [i, raw] of withoutParts.entries()) {\n const gap = raw as Partial<FileWithoutPart>\n if (!isFilledString(gap?.file)) fileProblems.push(`filesWithoutParts[${i}].file is missing`)\n else if (withParts.has(gap.file)) fileProblems.push(`${gap.file} holds a part and is listed as holding none`)\n if (!isFilledString(gap?.reason)) fileProblems.push(`filesWithoutParts[${i}].reason is missing`)\n }\n if (!isApp && withoutParts.length) fileProblems.push('filesWithoutParts is for an app; the package lists its exports instead')\n if (isApp && typeof built === 'object' && built !== null && typeof built.files === 'number' && withParts.size + withoutParts.length !== built.files) {\n fileProblems.push(`${withParts.size} files hold a part + ${withoutParts.length} hold none = ${withParts.size + withoutParts.length}, but the app has ${built.files} files`)\n }\n problems.push(...fileProblems)\n\n return problems\n}\n\n/**\n * An app entry's class must be what its own evidence says, unless it is written\n * beside the part with a reason. A pass-on is a fact about the file, so it can\n * never be written, and only a pass-on hands a part on.\n */\nfunction validateAppFacts(entry: Partial<RegistryEntry>, at: (field: string) => string): string[] {\n const problems: string[] = []\n const fail = (message: string) => problems.push(message)\n const facts = entry.app\n if (typeof facts !== 'object' || facts === null) return [at('app') + ' is missing on an app entry']\n if (!CLASSES.includes(facts.class)) fail(at('app.class') + ` is ${String(facts.class)}`)\n if (!isFilledString(facts.reason)) fail(at('app.reason') + ' is empty')\n if (typeof facts.written !== 'boolean') fail(at('app.written') + ' is not true/false')\n if (typeof facts.defaultExport !== 'boolean') fail(at('app.defaultExport') + ' is not true/false')\n if (!Array.isArray(facts.usedIn) || !facts.usedIn.every(isFilledString)) fail(at('app.usedIn') + ' is not a list of files')\n if (!Array.isArray(facts.tiedTo) || !facts.tiedTo.every(isFilledString)) fail(at('app.tiedTo') + ' is not a list')\n if (!(facts.handsOn === null || isFilledString(facts.handsOn))) fail(at('app.handsOn') + ' is neither a name nor null')\n if (!(facts.packageNamesake === null || isFilledString(facts.packageNamesake))) fail(at('app.packageNamesake') + ' is neither a name nor null')\n if (problems.length) return problems\n\n const passOn = facts.class === 're-export'\n if (passOn !== (facts.handsOn !== null)) fail(at('app.handsOn') + (passOn ? ' is missing on a pass-on' : ' is set on a part that is not a pass-on'))\n if (passOn !== (entry.purposeFrom === 'package')) fail(at('purposeFrom') + (passOn ? ' must be package on a pass-on' : ' is package on a part that is not a pass-on'))\n if (passOn && facts.written) fail(at('app.written') + ': a pass-on is read from the file, never written')\n if (!facts.written && !passOn) {\n const uses = facts.usedIn.length\n const expected: EntryClass = uses === 0 ? 'unused' : uses === 1 ? 'one-off' : facts.tiedTo.length ? 'reusable' : 'promote-candidate'\n if (facts.class !== expected) fail(at('app.class') + ` is ${facts.class}, but its evidence (${uses} uses, ${facts.tiedTo.length} ties) says ${expected}`)\n }\n return problems\n}\n"],
|
|
5
|
+
"mappings": ";;;AAmBO,IAAM,iBAAiB;AAkN9B,IAAM,QAAqB,CAAC,aAAa,QAAQ,QAAQ;AACzD,IAAM,WAA0B,CAAC,UAAU,aAAa,YAAY;AACpE,IAAM,UAA2B,CAAC,QAAQ,WAAW,QAAQ,SAAS;AAC/D,IAAM,UAAwB,CAAC,aAAa,YAAY,WAAW,qBAAqB,QAAQ;AAEvG,IAAM,WAAW,CAAC,MAA4B,OAAO,MAAM;AAC3D,IAAM,iBAAiB,CAAC,MAA4B,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS;AAQ9E,SAAS,iBAAiB,OAA0B;AACzD,QAAM,WAAqB,CAAC;AAC5B,QAAM,OAAO,CAAC,YAAoB,SAAS,KAAK,OAAO;AAEvD,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO,CAAC,+BAA+B;AACxF,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