@niscorp/cli 0.9.1 → 0.10.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shape/source.ts","../src/shape/app-data.ts","../src/shape/typescript.ts","../src/shape/index.ts"],"names":["relative","sep","join","readdirSync","path","readFileSync","resolve","require","createRequire","existsSync"],"mappings":";;;;;;;AASA,IAAM,MAAA,GAAS,qBAAA;AAER,IAAM,MAAA,GAAS,CAAC,IAAA,EAAc,IAAA,KAAyBA,aAAA,CAAS,IAAA,EAAM,IAAI,CAAA,CAAE,KAAA,CAAMC,QAAG,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAE/F,IAAM,gBAAgB,CAAC,IAAA,EAAc,MAAMC,SAAA,CAAK,IAAA,EAAM,KAAK,CAAA,KAAgB;AAChF,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAUC,cAAA,CAAY,GAAA,EAAK,EAAE,aAAA,EAAe,MAAM,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,CAAC,KAAA,KAAU;AAChC,IAAA,IAAI,KAAA,CAAM,IAAA,KAAS,cAAA,EAAgB,OAAO,EAAC;AAC3C,IAAA,MAAMC,MAAA,GAAOF,SAAA,CAAK,GAAA,EAAK,KAAA,CAAM,IAAI,CAAA;AACjC,IAAA,IAAI,MAAM,WAAA,EAAY,EAAG,OAAO,aAAA,CAAc,MAAME,MAAI,CAAA;AACxD,IAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,IAAI,KAAK,CAAC,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,OAAO,CAAA,GAAI,CAACA,MAAI,IAAI,EAAC;AAAA,EAC9E,CAAC,CAAA;AACH,CAAA;AAEA,IAAM,SAAA,uBAAgB,GAAA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,MAAA,CAAO,CAAC,EAAE,QAAA,EAAS,KAAM,OAAO,QAAA,CAAS,IAAI,CAAA,KAAM,QAAQ,CAAA,CAAE,MAAA;AACrF,EAAA,GAAA,CAAI,CAAA,qCAAA,EAAwC,KAAK,CAAA,sBAAA,EAAyB,OAAA,CAAQ,MAAM,CAAA,MAAA,CAAQ,CAAA;AAChG,EAAA,GAAA,CAAI,CAAA,OAAA,EAAU,KAAA,CAAM,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,OAAA,KAAY,MAAS,CAAA,CAAE,MAAM,CAAA,IAAA,EAAO,KAAA,CAAM,MAAM,CAAA,2CAAA,CAA6C,CAAA;AACzI,EAAA,MAAM,UAAU,KAAA,CAAM,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,YAAY,UAAA,IAAc,CAAC,MAAM,GAAA,CAAI,KAAA,CAAM,WAAW,CAAC,CAAA,CAAE,IAAI,CAAC,KAAA,KAAU,MAAM,WAAW,CAAA;AACvI,EAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG,GAAA,CAAI,oDAAoD,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACpG,EAAA,OAAO,IAAA,EAAK;AACd","file":"shape.cjs","sourcesContent":["import { readdirSync, readFileSync } from 'node:fs';\nimport { join, relative, sep } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { TypeScript } from './typescript';\n\nexport type SourceRule = 'style' | 'formatting' | 'roles' | 'files' | 'address' | 'dom';\n\nexport type Finding = { rule: SourceRule | 'data'; file: string; line: number; what: string };\n\nconst SOURCE = /\\.(ts|tsx|mts|cts)$/;\n\nexport const pathOf = (root: string, file: string): string => relative(root, file).split(sep).join('/');\n\nexport const sourceFilesOf = (root: string, dir = join(root, 'src')): string[] => {\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return [];\n }\n return entries.flatMap((entry) => {\n if (entry.name === 'node_modules') return [];\n const path = join(dir, entry.name);\n if (entry.isDirectory()) return sourceFilesOf(root, path);\n return SOURCE.test(entry.name) && !entry.name.endsWith('.d.ts') ? [path] : [];\n });\n};\n\nconst READ_FILE = new Set(['readAsDataURL', 'readAsText', 'readAsArrayBuffer', 'readAsBinaryString']);\nconst FIND_ELEMENTS = new Set(['querySelector', 'querySelectorAll', 'getElementById', 'getElementsByClassName', 'getElementsByTagName', 'getElementsByName']);\nconst ADDRESS_CHANGE = new Set(['pushState', 'replaceState']);\n\nconst lastName = (ts: TypeScript, node: TS.Expression): string | undefined => {\n if (ts.isIdentifier(node)) return node.text;\n if (ts.isPropertyAccessExpression(node)) return node.name.text;\n return undefined;\n};\n\nconst hasModifier = (ts: TypeScript, node: TS.Node, kind: TS.SyntaxKind): boolean => ts.canHaveModifiers(node) && (ts.getModifiers(node) ?? []).some((modifier) => modifier.kind === kind);\n\n// Each rule reads the syntax tree, so a word in a comment or a string is never a finding.\nconst findingsIn = (ts: TypeScript, file: string, source: TS.SourceFile): Finding[] => {\n const found: Finding[] = [];\n const inSrc = (folder: string): boolean => file.startsWith(`src/${folder}/`);\n const at = (rule: SourceRule, node: TS.Node, what: string): void => {\n found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, what });\n };\n const visit = (node: TS.Node): void => {\n if (ts.isAsExpression(node) && !(ts.isTypeReferenceNode(node.type) && ts.isIdentifier(node.type.typeName) && node.type.typeName.text === 'const')) at('style', node, `\"as ${node.type.getText(source)}\"`);\n if (ts.isTypeAssertionExpression(node)) at('style', node, 'a \"<T>\" assertion');\n if (ts.isNonNullExpression(node)) at('style', node, 'a non-null \"!\"');\n if (ts.isFunctionDeclaration(node) && !hasModifier(ts, node, ts.SyntaxKind.DeclareKeyword)) at('style', node, 'a function declaration');\n if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) at('style', node, 'a class');\n if (ts.isEnumDeclaration(node)) at('style', node, 'an enum');\n if (node.kind === ts.SyntaxKind.AnyKeyword) at('style', node, '\"any\"');\n if ((ts.isExportAssignment(node) && node.isExportEquals !== true) || (ts.isExportSpecifier(node) && node.name.text === 'default') || hasModifier(ts, node, ts.SyntaxKind.DefaultKeyword)) at('style', node, 'a default export');\n\n if (!inSrc('dev')) {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'Intl') at('formatting', node, `Intl.${node.name.text}`);\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text.startsWith('toLocale')) at('formatting', node, `.${node.expression.name.text}()`);\n }\n if (inSrc('server') && ts.isPropertyAccessExpression(node) && node.name.text === 'roles') {\n const whose = lastName(ts, node.expression);\n if (whose === 'session' || whose === 'principal') at('roles', node, `${whose}.roles`);\n }\n if (inSrc('ui')) {\n if (ts.isIdentifier(node) && node.text === 'FileReader' && !ts.isTypeReferenceNode(node.parent)) at('files', node, 'FileReader');\n if (ts.isPropertyAccessExpression(node) && READ_FILE.has(node.name.text)) at('files', node, node.name.text);\n if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === 'location') at('address', node, `location.${node.name.text}`);\n if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === 'history' && ADDRESS_CHANGE.has(node.name.text)) at('address', node, `history.${node.name.text}`);\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && FIND_ELEMENTS.has(node.expression.name.text) && lastName(ts, node.expression.expression) === 'document') {\n at('dom', node, `document.${node.expression.name.text}`);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n return found;\n};\n\nexport const sourceFindings = (ts: TypeScript, root: string): Finding[] =>\n sourceFilesOf(root).flatMap((path) => {\n const file = pathOf(root, path);\n const source = ts.createSourceFile(file, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true, path.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS);\n return findingsIn(ts, file, source);\n });\n","import { resolve } from 'node:path';\nimport type * as TS from 'typescript';\nimport { pathOf } from './source';\nimport type { Finding } from './source';\nimport type { TypeScript } from './typescript';\n\n// The manifest's factory takes the server's code seams and answers the manifest: setup, not code in the artifact tree.\nconst MANIFEST = /^(Promise<)?NiscApp>?$/;\n\nconst programOf = (ts: TypeScript, root: string): TS.Program => {\n const config = ts.findConfigFile(root, ts.sys.fileExists, 'tsconfig.json');\n if (config === undefined || !resolve(config).startsWith(resolve(root))) throw new Error(`the shape check reads the app as its tsconfig.json says, and ${root} has none.`);\n const parsed = ts.getParsedCommandLineOfConfigFile(config, {}, { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => undefined });\n if (parsed === undefined) throw new Error(`${config} could not be read.`);\n return ts.createProgram({ rootNames: parsed.fileNames, options: parsed.options });\n};\n\nconst importedNames = (ts: TypeScript, clause: TS.ImportClause | undefined): TS.Identifier[] => {\n if (clause === undefined || clause.isTypeOnly) return [];\n const bindings = clause.namedBindings;\n const named = bindings !== undefined && ts.isNamedImports(bindings) ? bindings.elements.filter((element) => !element.isTypeOnly).map((element) => element.name) : [];\n return [...(clause.name === undefined ? [] : [clause.name]), ...named];\n};\n\n// What code outside src/app calls of it, read by the compiler under the app's own tsconfig, so a path alias counts.\nexport const appDataFindings = (ts: TypeScript, root: string): Finding[] => {\n const program = programOf(ts, root);\n const checker = program.getTypeChecker();\n const options = program.getCompilerOptions();\n return program.getSourceFiles().flatMap((source) => {\n const file = pathOf(root, resolve(source.fileName));\n if (!file.startsWith('src/') || file.startsWith('src/app/') || file.startsWith('src/dev/') || source.isDeclarationFile) return [];\n return source.statements.flatMap((statement) => {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) return [];\n const target = ts.resolveModuleName(statement.moduleSpecifier.text, source.fileName, options, ts.sys).resolvedModule?.resolvedFileName;\n if (target === undefined) return [];\n const from = pathOf(root, resolve(target));\n if (!from.startsWith('src/app/')) return [];\n return importedNames(ts, statement.importClause).flatMap((name) => {\n const calls = checker.getTypeAtLocation(name).getCallSignatures();\n if (calls.length === 0 || calls.every((call) => MANIFEST.test(checker.typeToString(call.getReturnType())))) return [];\n const line = source.getLineAndCharacterOfPosition(name.getStart(source)).line + 1;\n return [{ rule: 'data' as const, file, line, what: `${name.text}, a function of ${from}` }];\n });\n });\n });\n};\n","import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\n\nexport type TypeScript = typeof TS;\n\nconst isTypeScript = (value: unknown): value is TypeScript =>\n value !== null && typeof value === 'object' && typeof Reflect.get(value, 'createProgram') === 'function' && typeof Reflect.get(value, 'version') === 'string';\n\n// The app's own compiler, as `nisc build` uses the app's own jsdom: the gate adds no dependency to the cli.\nexport const loadTypeScript = (root: string): TypeScript => {\n const require = createRequire(join(root, 'package.json'));\n let library: unknown;\n try {\n library = require('typescript');\n } catch {\n throw new Error(`the shape check reads the source with TypeScript, and this app has none installed (looked from ${root}). pnpm add -D typescript`);\n }\n if (!isTypeScript(library)) throw new Error('the \"typescript\" this app has installed is not the TypeScript compiler.');\n if (!library.version.startsWith('6.')) throw new Error(`the shape check is written against TypeScript 6, and this app has ${library.version}.`);\n return library;\n};\n","import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { appDataFindings } from './app-data';\nimport { sourceFindings } from './source';\nimport type { Finding } from './source';\nimport { loadTypeScript } from './typescript';\n\nexport type ShapeRule = 'style' | 'formatting' | 'roles' | 'files' | 'address' | 'dom' | 'data';\n\nexport type ShapeAction = { id: string; endpoints?: Readonly<Record<string, unknown>> };\n\nexport type ShapeEntry = { fingerprint: string; refresh?: string; dsl?: unknown; mapping?: unknown };\n\nexport type ShapeCheckConfig = {\n root: string;\n actions: readonly ShapeAction[];\n entries?: readonly ShapeEntry[];\n functions?: Readonly<Record<string, string>>;\n allow?: Readonly<Partial<Record<ShapeRule, Readonly<Record<string, string>>>>>;\n log?: (line: string) => void;\n};\n\nconst RULES: readonly (readonly [rule: ShapeRule, what: string])[] = [\n ['style', 'rule 16: no assertion but \"as const\", no non-null \"!\", no function declaration, class, enum, \"any\" or default export in src/'],\n ['formatting', 'rule 9: no Intl and no toLocale… outside Prism (src/, but src/dev/)'],\n ['roles', 'rule 11: no server code reads the caller’s roles (src/server/)'],\n ['files', 'rule 9a: the kit reads no file into data (src/ui/)'],\n ['address', 'rule 4: the kit neither reads nor changes the address (src/ui/)'],\n ['dom', 'rule 2: no component finds elements in the document (src/ui/)'],\n ['data', 'src/app is data: no code outside it calls a function of it, but the manifest’s factory'],\n];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst endpointsOf = (actions: readonly ShapeAction[]): { action: string; endpoint: Record<string, unknown> }[] =>\n actions.flatMap((action) => Object.values(action.endpoints ?? {}).flatMap((endpoint) => (isRecord(endpoint) ? [{ action: action.id, endpoint }] : [])));\n\nconst replayOf = (endpoint: Record<string, unknown>): { fingerprint?: string } | undefined => {\n const request = endpoint['request'];\n if (!isRecord(request) || !('fingerprint' in request)) return undefined;\n const fingerprint = request['fingerprint'];\n return typeof fingerprint === 'string' ? { fingerprint } : {};\n};\n\nexport const runShapeCheck = (config: ShapeCheckConfig): number => {\n const log = config.log ?? ((line: string) => console.log(line));\n let failures = 0;\n const check = (what: string, passed: boolean, detail: readonly string[] = []): void => {\n log(`${passed ? '[pass]' : '[fail]'} ${what}${passed || detail.length === 0 ? '' : ` — ${detail.join('; ')}`}`);\n if (!passed) failures += 1;\n };\n const done = (): number => {\n log(failures === 0 ? '[pass] shape: all checks passed' : `[fail] shape: ${failures} check(s) failed`);\n return failures === 0 ? 0 : 1;\n };\n\n let findings: Finding[];\n try {\n const ts = loadTypeScript(config.root);\n findings = [...sourceFindings(ts, config.root), ...appDataFindings(ts, config.root)];\n } catch (error) {\n check('the source is read', false, [error instanceof Error ? error.message : String(error)]);\n return done();\n }\n\n const allow = config.allow ?? {};\n for (const [rule, what] of RULES) {\n const allowed = allow[rule] ?? {};\n const left = findings.filter((finding) => finding.rule === rule && allowed[finding.file] === undefined);\n check(what, left.length === 0, left.map((finding) => `${finding.file}:${finding.line} ${finding.what}`));\n }\n const idle = RULES.flatMap(([rule]) =>\n Object.entries(allow[rule] ?? {}).flatMap(([file, reason]) => {\n if (reason.trim() === '') return [`${rule}: ${file} gives no reason`];\n if (!existsSync(join(config.root, file))) return [`${rule}: ${file} does not exist`];\n return findings.some((finding) => finding.rule === rule && finding.file === file) ? [] : [`${rule}: ${file} has nothing to allow`];\n }),\n );\n check('every allowance names a file there is, why, and something it allows', idle.length === 0, idle);\n\n const endpoints = endpointsOf(config.actions);\n const ledger = config.functions ?? {};\n const called = new Set(endpoints.flatMap(({ endpoint }) => (typeof endpoint['fn'] === 'string' ? [endpoint['fn']] : [])));\n const unexplained = [...called].filter((id) => (ledger[id] ?? '').trim() === '').sort();\n check('every server function an action calls is named in `functions`, with what it does that a vex read or write cannot', unexplained.length === 0, unexplained);\n const uncalled = Object.keys(ledger).filter((id) => !called.has(id)).sort();\n check('every function named in `functions` is called by an action', uncalled.length === 0, uncalled);\n\n const replays = endpoints.flatMap(({ endpoint }) => {\n const replay = replayOf(endpoint);\n return replay === undefined ? [] : [replay];\n });\n const named = new Set(replays.flatMap((replay) => (replay.fingerprint === undefined ? [] : [replay.fingerprint])));\n const reads = (config.entries ?? []).filter((entry) => entry.dsl !== undefined);\n const calls = endpoints.filter(({ endpoint }) => typeof endpoint['fn'] === 'string').length;\n log(`[info] actions call server functions ${calls} times and replay vex ${replays.length} times`);\n log(`[info] ${reads.filter((entry) => entry.mapping !== undefined).length} of ${reads.length} reads word their rows with a Prism mapping`);\n const unnamed = reads.filter((entry) => entry.refresh === 'reactive' && !named.has(entry.fingerprint)).map((entry) => entry.fingerprint);\n if (unnamed.length > 0) log(`[info] reactive reads no action replays by name: ${unnamed.join(', ')}`);\n return done();\n};\n"]}
1
+ {"version":3,"sources":["../src/shape/source.ts","../src/shape/app-data.ts","../src/shape/references.ts","../src/shape/typescript.ts","../src/shape/index.ts"],"names":["relative","sep","join","readdirSync","path","readFileSync","resolve","dirname","require","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EAAA,GAAA,CAAI,CAAA,qCAAA,EAAwC,KAAK,CAAA,sBAAA,EAAyB,OAAA,CAAQ,MAAM,CAAA,MAAA,CAAQ,CAAA;AAChG,EAAA,GAAA,CAAI,CAAA,OAAA,EAAU,KAAA,CAAM,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,OAAA,KAAY,MAAS,CAAA,CAAE,MAAM,CAAA,IAAA,EAAO,KAAA,CAAM,MAAM,CAAA,2CAAA,CAA6C,CAAA;AACzI,EAAA,MAAM,UAAU,KAAA,CAAM,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,YAAY,UAAA,IAAc,CAAC,MAAM,GAAA,CAAI,KAAA,CAAM,WAAW,CAAC,CAAA,CAAE,IAAI,CAAC,KAAA,KAAU,MAAM,WAAW,CAAA;AACvI,EAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG,GAAA,CAAI,oDAAoD,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACpG,EAAA,OAAO,IAAA,EAAK;AACd","file":"shape.cjs","sourcesContent":["import { readdirSync, readFileSync } from 'node:fs';\nimport { join, relative, sep } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { TypeScript } from './typescript';\n\nexport type SourceRule = 'style' | 'formatting' | 'roles' | 'files' | 'address' | 'dom';\n\nexport type Finding = { rule: SourceRule | 'data'; file: string; line: number; name: string; what: string };\n\nconst SOURCE = /\\.(ts|tsx|mts|cts)$/;\n\nexport const pathOf = (root: string, file: string): string => relative(root, file).split(sep).join('/');\n\nexport const sourceFilesOf = (root: string, dir = join(root, 'src')): string[] => {\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return [];\n }\n return entries.flatMap((entry) => {\n if (entry.name === 'node_modules') return [];\n const path = join(dir, entry.name);\n if (entry.isDirectory()) return sourceFilesOf(root, path);\n return SOURCE.test(entry.name) && !entry.name.endsWith('.d.ts') ? [path] : [];\n });\n};\n\nconst READ_FILE = new Set(['readAsDataURL', 'readAsText', 'readAsArrayBuffer', 'readAsBinaryString']);\nexport const FIND_ELEMENTS = new Set(['querySelector', 'querySelectorAll', 'getElementById', 'getElementsByClassName', 'getElementsByTagName', 'getElementsByName']);\nexport const ADDRESS_CHANGE = new Set(['pushState', 'replaceState']);\n\nconst lastName = (ts: TypeScript, node: TS.Expression): string | undefined => {\n if (ts.isIdentifier(node)) return node.text;\n if (ts.isPropertyAccessExpression(node)) return node.name.text;\n return undefined;\n};\n\nconst isConst = (ts: TypeScript, type: TS.TypeNode): boolean => ts.isTypeReferenceNode(type) && ts.isIdentifier(type.typeName) && type.typeName.text === 'const';\n\nconst hasModifier = (ts: TypeScript, node: TS.Node, kind: TS.SyntaxKind): boolean => ts.canHaveModifiers(node) && (ts.getModifiers(node) ?? []).some((modifier) => modifier.kind === kind);\n\n// Each rule reads the syntax tree, so a word in a comment or a string is never a finding.\nconst findingsIn = (ts: TypeScript, file: string, source: TS.SourceFile): Finding[] => {\n const found: Finding[] = [];\n const inSrc = (folder: string): boolean => file.startsWith(`src/${folder}/`);\n const at = (rule: SourceRule, node: TS.Node, what: string, name = what): void => {\n found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, name, what });\n };\n const visit = (node: TS.Node): void => {\n if (ts.isAsExpression(node) && !isConst(ts, node.type)) at('style', node, `\"as ${node.type.getText(source)}\"`);\n if (ts.isTypeAssertionExpression(node) && !isConst(ts, node.type)) at('style', node, 'a \"<T>\" assertion');\n if (ts.isNonNullExpression(node)) at('style', node, 'a non-null \"!\"');\n if (ts.isFunctionDeclaration(node) && !hasModifier(ts, node, ts.SyntaxKind.DeclareKeyword)) at('style', node, 'a function declaration');\n if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) at('style', node, 'a class');\n if (ts.isEnumDeclaration(node)) at('style', node, 'an enum');\n if (node.kind === ts.SyntaxKind.AnyKeyword) at('style', node, '\"any\"');\n if ((ts.isExportAssignment(node) && node.isExportEquals !== true) || (ts.isExportSpecifier(node) && node.name.text === 'default') || hasModifier(ts, node, ts.SyntaxKind.DefaultKeyword)) at('style', node, 'a default export');\n\n if (!inSrc('dev')) {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'Intl') at('formatting', node, `Intl.${node.name.text}`, 'Intl');\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text.startsWith('toLocale')) {\n at('formatting', node, `.${node.expression.name.text}()`, node.expression.name.text);\n }\n }\n if (inSrc('server') && ts.isPropertyAccessExpression(node) && node.name.text === 'roles') {\n const whose = lastName(ts, node.expression);\n if (whose === 'session' || whose === 'principal') at('roles', node, `${whose}.roles`, 'roles');\n }\n if (inSrc('ui')) {\n if (ts.isIdentifier(node) && node.text === 'FileReader' && !ts.isTypeReferenceNode(node.parent)) at('files', node, 'FileReader');\n if (ts.isPropertyAccessExpression(node) && READ_FILE.has(node.name.text)) at('files', node, node.name.text);\n if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === 'location') at('address', node, `location.${node.name.text}`, 'location');\n if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === 'history' && ADDRESS_CHANGE.has(node.name.text)) at('address', node, `history.${node.name.text}`, node.name.text);\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && FIND_ELEMENTS.has(node.expression.name.text) && lastName(ts, node.expression.expression) === 'document') {\n at('dom', node, `document.${node.expression.name.text}`, node.expression.name.text);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n return found;\n};\n\nexport const sourceFindings = (ts: TypeScript, root: string): Finding[] =>\n sourceFilesOf(root).flatMap((path) => {\n const file = pathOf(root, path);\n const source = ts.createSourceFile(file, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true, path.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS);\n return findingsIn(ts, file, source);\n });\n","import { resolve } from 'node:path';\nimport type * as TS from 'typescript';\nimport { pathOf } from './source';\nimport type { Finding } from './source';\nimport type { TypeScript } from './typescript';\n\n// The manifest's factory takes the server's code seams and answers the manifest: setup, not code in the artifact tree.\nexport const MANIFEST = /^(Promise<)?NiscApp>?$/;\n\nexport const programOf = (ts: TypeScript, root: string): TS.Program => {\n const config = ts.findConfigFile(root, ts.sys.fileExists, 'tsconfig.json');\n if (config === undefined || !resolve(config).startsWith(resolve(root))) throw new Error(`the shape check reads the app as its tsconfig.json says, and ${root} has none.`);\n const parsed = ts.getParsedCommandLineOfConfigFile(config, {}, { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => undefined });\n if (parsed === undefined) throw new Error(`${config} could not be read.`);\n return ts.createProgram({ rootNames: parsed.fileNames, options: parsed.options });\n};\n\nconst importedNames = (ts: TypeScript, clause: TS.ImportClause | undefined): TS.Identifier[] => {\n if (clause === undefined || clause.isTypeOnly) return [];\n const bindings = clause.namedBindings;\n const named = bindings !== undefined && ts.isNamedImports(bindings) ? bindings.elements.filter((element) => !element.isTypeOnly).map((element) => element.name) : [];\n return [...(clause.name === undefined ? [] : [clause.name]), ...named];\n};\n\n// What code outside src/app calls of it, read by the compiler under the app's own tsconfig, so a path alias counts.\nexport const appDataFindings = (ts: TypeScript, root: string, program: TS.Program): Finding[] => {\n const checker = program.getTypeChecker();\n const options = program.getCompilerOptions();\n return program.getSourceFiles().flatMap((source) => {\n const file = pathOf(root, resolve(source.fileName));\n if (!file.startsWith('src/') || file.startsWith('src/app/') || file.startsWith('src/dev/') || source.isDeclarationFile) return [];\n return source.statements.flatMap((statement) => {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) return [];\n const target = ts.resolveModuleName(statement.moduleSpecifier.text, source.fileName, options, ts.sys).resolvedModule?.resolvedFileName;\n if (target === undefined) return [];\n const from = pathOf(root, resolve(target));\n if (!from.startsWith('src/app/')) return [];\n return importedNames(ts, statement.importClause).flatMap((name) => {\n const calls = checker.getTypeAtLocation(name).getCallSignatures();\n if (calls.length === 0 || calls.every((call) => MANIFEST.test(checker.typeToString(call.getReturnType())))) return [];\n const line = source.getLineAndCharacterOfPosition(name.getStart(source)).line + 1;\n const symbol = checker.getSymbolAtLocation(name);\n const declared = symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol).getName() : name.text;\n return [{ rule: 'data' as const, file, line, name: declared, what: `${name.text}, a function of ${from}` }];\n });\n });\n });\n};\n","import { dirname, join, resolve, sep } from 'node:path';\nimport type * as TS from 'typescript';\nimport { MANIFEST } from './app-data';\nimport { ADDRESS_CHANGE, FIND_ELEMENTS, pathOf } from './source';\nimport type { Finding, SourceRule } from './source';\nimport type { TypeScript } from './typescript';\n\nconst packageRootOf = (ts: TypeScript, file: string): string | undefined => {\n const up = dirname(file);\n if (ts.sys.fileExists(join(up, 'package.json'))) return up;\n return up === file ? undefined : packageRootOf(ts, up);\n};\n\n// The reaches the source rules find by spelling, found again by what each name refers to.\nexport const referenceFindings = (ts: TypeScript, root: string, program: TS.Program): Finding[] => {\n const checker = program.getTypeChecker();\n const moss = ts.resolveModuleName('@niscorp/moss', join(root, 'package.json'), program.getCompilerOptions(), ts.sys).resolvedModule?.resolvedFileName;\n const mossRoot = moss === undefined ? undefined : packageRootOf(ts, resolve(moss));\n const isDeclaredIn = (symbol: TS.Symbol | undefined, where: (source: TS.SourceFile) => boolean): boolean => (symbol?.declarations ?? []).some((declaration) => where(declaration.getSourceFile()));\n const isLibrary = (symbol: TS.Symbol | undefined): boolean => isDeclaredIn(symbol, (source) => program.isSourceFileDefaultLibrary(source));\n const isMoss = (symbol: TS.Symbol | undefined): boolean => mossRoot !== undefined && isDeclaredIn(symbol, (source) => resolve(source.fileName).startsWith(`${mossRoot}${sep}`));\n const typeIs = (node: TS.Node, name: string): boolean => {\n const symbol = checker.getTypeAtLocation(node).getSymbol();\n return symbol?.getName() === name && isLibrary(symbol);\n };\n const unaliased = (symbol: TS.Symbol | undefined): TS.Symbol | undefined => (symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol);\n // A name a destructuring binds refers to the property it takes.\n const referredOf = (node: TS.Identifier | TS.StringLiteral): TS.Symbol | undefined => {\n const bound = node.parent;\n if (ts.isBindingElement(bound) && bound.name === node && ts.isObjectBindingPattern(bound.parent)) {\n const property = bound.propertyName ?? node;\n return ts.isIdentifier(property) || ts.isStringLiteral(property) ? unaliased(checker.getTypeAtLocation(bound.parent).getProperty(property.text)) : undefined;\n }\n return unaliased(checker.getSymbolAtLocation(node));\n };\n const isAppFunction = (symbol: TS.Symbol, node: TS.Node): boolean => {\n const declared = symbol.valueDeclaration;\n if (declared === undefined || !pathOf(root, resolve(declared.getSourceFile().fileName)).startsWith('src/app/')) return false;\n const calls = checker.getTypeOfSymbolAtLocation(symbol, node).getCallSignatures();\n return calls.length > 0 && !calls.every((call) => MANIFEST.test(checker.typeToString(call.getReturnType())));\n };\n\n return program.getSourceFiles().flatMap((source) => {\n const file = pathOf(root, resolve(source.fileName));\n if (!file.startsWith('src/') || source.isDeclarationFile) return [];\n const inSrc = (folder: string): boolean => file.startsWith(`src/${folder}/`);\n const found: Finding[] = [];\n const at = (rule: SourceRule | 'data', node: TS.Node, name: string, what = name): void => {\n found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, name, what });\n };\n const isTypeOnly = (node: TS.Node): boolean => (ts.isImportClause(node) || ts.isImportSpecifier(node) || ts.isExportDeclaration(node) || ts.isExportSpecifier(node)) && node.isTypeOnly;\n const visit = (node: TS.Node, isType: boolean): void => {\n const isName = ts.isIdentifier(node) || (ts.isStringLiteral(node) && ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node);\n const referred = !isType && isName ? referredOf(node) : undefined;\n if (referred !== undefined) {\n if (!inSrc('dev') && referred.getName() === 'Intl' && isLibrary(referred)) at('formatting', node, 'Intl', 'Intl, the global one');\n if (inSrc('server') && referred.getName() === 'roles' && isMoss(referred)) at('roles', node, 'roles', 'roles, read off a moss session');\n if (!inSrc('app') && !inSrc('dev') && isAppFunction(referred, node)) {\n at('data', node, referred.getName(), `${referred.getName()}, a function of ${pathOf(root, resolve(referred.valueDeclaration?.getSourceFile().fileName ?? ''))}`);\n }\n }\n if (!isType && inSrc('ui')) {\n const isLocation = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && typeIs(node, 'Location');\n if (isLocation && !(ts.isExpression(node.parent) && typeIs(node.parent, 'Location'))) at('address', node, 'location', `location, as ${node.getText(source)}`);\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {\n const { name, expression } = node.expression;\n if (ADDRESS_CHANGE.has(name.text) && typeIs(expression, 'History')) at('address', node, name.text, `${name.text} on a History`);\n if (FIND_ELEMENTS.has(name.text) && typeIs(expression, 'Document')) at('dom', node, name.text, `${name.text} on a Document`);\n }\n }\n ts.forEachChild(node, (child) => visit(child, isType || ts.isTypeNode(node) || isTypeOnly(node)));\n };\n visit(source, false);\n return found;\n });\n};\n","import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\n\nexport type TypeScript = typeof TS;\n\nconst isTypeScript = (value: unknown): value is TypeScript =>\n value !== null && typeof value === 'object' && typeof Reflect.get(value, 'createProgram') === 'function' && typeof Reflect.get(value, 'version') === 'string';\n\n// The app's own compiler, as `nisc build` uses the app's own jsdom: the gate adds no dependency to the cli.\nexport const loadTypeScript = (root: string): TypeScript => {\n const require = createRequire(join(root, 'package.json'));\n let library: unknown;\n try {\n library = require('typescript');\n } catch {\n throw new Error(`the shape check reads the source with TypeScript, and this app has none installed (looked from ${root}). pnpm add -D typescript`);\n }\n if (!isTypeScript(library)) throw new Error('the \"typescript\" this app has installed is not the TypeScript compiler.');\n if (!library.version.startsWith('6.')) throw new Error(`the shape check is written against TypeScript 6, and this app has ${library.version}.`);\n return library;\n};\n","import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\nimport { appDataFindings, programOf } from './app-data';\nimport { referenceFindings } from './references';\nimport { sourceFindings } from './source';\nimport type { Finding } from './source';\nimport { loadTypeScript } from './typescript';\nimport type { TypeScript } from './typescript';\n\nexport type ShapeRule = 'style' | 'formatting' | 'roles' | 'files' | 'address' | 'dom' | 'data';\n\nexport type ShapeAction = { id: string; endpoints?: Readonly<Record<string, unknown>> };\n\nexport type ShapeEntry = { fingerprint: string; refresh?: string; dsl?: unknown; mapping?: unknown };\n\nexport type ShapeCheckConfig = {\n root: string;\n actions: readonly ShapeAction[];\n entries?: readonly ShapeEntry[];\n functions?: Readonly<Record<string, string>>;\n allow?: Readonly<Partial<Record<ShapeRule, Readonly<Record<string, string>>>>>;\n log?: (line: string) => void;\n};\n\nconst RULES: readonly (readonly [rule: ShapeRule, what: string])[] = [\n ['style', 'rule 16: no assertion but \"as const\", no non-null \"!\", no function declaration, class, enum, \"any\" or default export in src/'],\n ['formatting', 'rule 9: no Intl and no toLocale… outside Prism (src/, but src/dev/)'],\n ['roles', 'rule 11: no server code reads the caller’s roles (src/server/)'],\n ['files', 'rule 9a: the kit reads no file into data (src/ui/)'],\n ['address', 'rule 4: the kit neither reads nor changes the address (src/ui/)'],\n ['dom', 'rule 2: no component finds elements in the document (src/ui/)'],\n ['data', 'src/app is data: no code outside it calls a function of it, but the manifest’s factory'],\n];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst endpointsOf = (actions: readonly ShapeAction[]): { action: string; endpoint: Record<string, unknown> }[] =>\n actions.flatMap((action) => Object.values(action.endpoints ?? {}).flatMap((endpoint) => (isRecord(endpoint) ? [{ action: action.id, endpoint }] : [])));\n\nconst replayOf = (endpoint: Record<string, unknown>): { fingerprint?: string } | undefined => {\n const request = endpoint['request'];\n if (!isRecord(request) || !('fingerprint' in request)) return undefined;\n const fingerprint = request['fingerprint'];\n return typeof fingerprint === 'string' ? { fingerprint } : {};\n};\n\nconst messageOf = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\nconst readSource = (root: string): { ts: TypeScript; program: TS.Program; findings: Finding[] } | string => {\n try {\n const ts = loadTypeScript(root);\n const program = programOf(ts, root);\n return { ts, program, findings: [...sourceFindings(ts, root), ...appDataFindings(ts, root, program)] };\n } catch (error) {\n return messageOf(error);\n }\n};\n\nexport const runShapeCheck = (config: ShapeCheckConfig): number => {\n const log = config.log ?? ((line: string) => console.log(line));\n let failures = 0;\n const check = (what: string, passed: boolean, detail: readonly string[] = []): void => {\n log(`${passed ? '[pass]' : '[fail]'} ${what}${passed || detail.length === 0 ? '' : ` — ${detail.join('; ')}`}`);\n if (!passed) failures += 1;\n };\n const done = (): number => {\n log(failures === 0 ? '[pass] shape: all checks passed' : `[fail] shape: ${failures} check(s) failed`);\n return failures === 0 ? 0 : 1;\n };\n\n const read = readSource(config.root);\n if (typeof read === 'string') {\n check('the source is read', false, [read]);\n return done();\n }\n const { findings } = read;\n\n const allow = config.allow ?? {};\n for (const [rule, what] of RULES) {\n const allowed = allow[rule] ?? {};\n const left = findings.filter((finding) => finding.rule === rule && allowed[finding.file] === undefined);\n check(what, left.length === 0, left.map((finding) => `${finding.file}:${finding.line} ${finding.what}`));\n }\n try {\n const failed = new Set(findings.map((finding) => `${finding.rule} ${finding.file} ${finding.name}`));\n const shown = new Set<string>();\n const others = referenceFindings(read.ts, config.root, read.program).filter((finding) => {\n const key = `${finding.rule} ${finding.file} ${finding.name}`;\n if (failed.has(key) || allow[finding.rule]?.[finding.file] !== undefined || shown.has(`${key} ${finding.line}`)) return false;\n shown.add(`${key} ${finding.line}`);\n return true;\n });\n const ruleOf = new Map(RULES.map(([rule, what]) => [rule, what.split(':')[0] ?? what]));\n for (const finding of others) {\n log(`[info] ${ruleOf.get(finding.rule) ?? finding.rule}: ${finding.file}:${finding.line} ${finding.what} — another spelling of what the rule fails on; reported, not failed`);\n }\n } catch (error) {\n log(`[info] what names refer to could not be read, so other spellings are not reported: ${messageOf(error)}`);\n }\n const idle = RULES.flatMap(([rule]) =>\n Object.entries(allow[rule] ?? {}).flatMap(([file, reason]) => {\n if (reason.trim() === '') return [`${rule}: ${file} gives no reason`];\n if (!existsSync(join(config.root, file))) return [`${rule}: ${file} does not exist`];\n return findings.some((finding) => finding.rule === rule && finding.file === file) ? [] : [`${rule}: ${file} has nothing to allow`];\n }),\n );\n check('every allowance names a file there is, why, and something it allows', idle.length === 0, idle);\n\n const endpoints = endpointsOf(config.actions);\n const ledger = config.functions ?? {};\n const called = new Set(endpoints.flatMap(({ endpoint }) => (typeof endpoint['fn'] === 'string' ? [endpoint['fn']] : [])));\n const unexplained = [...called].filter((id) => (ledger[id] ?? '').trim() === '').sort();\n check('every server function an action calls is named in `functions`, with what it does that a vex read or write cannot', unexplained.length === 0, unexplained);\n const uncalled = Object.keys(ledger).filter((id) => !called.has(id)).sort();\n check('every function named in `functions` is called by an action', uncalled.length === 0, uncalled);\n\n const replays = endpoints.flatMap(({ endpoint }) => {\n const replay = replayOf(endpoint);\n return replay === undefined ? [] : [replay];\n });\n const named = new Set(replays.flatMap((replay) => (replay.fingerprint === undefined ? [] : [replay.fingerprint])));\n const reads = (config.entries ?? []).filter((entry) => entry.dsl !== undefined);\n const calls = endpoints.filter(({ endpoint }) => typeof endpoint['fn'] === 'string').length;\n log(`[info] actions call server functions ${calls} times and replay vex ${replays.length} times`);\n log(`[info] ${reads.filter((entry) => entry.mapping !== undefined).length} of ${reads.length} reads word their rows with a Prism mapping`);\n const unnamed = reads.filter((entry) => entry.refresh === 'reactive' && !named.has(entry.fingerprint)).map((entry) => entry.fingerprint);\n if (unnamed.length > 0) log(`[info] reactive reads no action replays by name: ${unnamed.join(', ')}`);\n return done();\n};\n"]}
package/dist/shape.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync, readdirSync } from 'fs';
2
- import { join, resolve, relative, sep } from 'path';
2
+ import { join, resolve, dirname, relative, sep } from 'path';
3
3
  import { createRequire } from 'module';
4
4
 
5
5
  // src/shape/index.ts
@@ -27,16 +27,17 @@ var lastName = (ts, node) => {
27
27
  if (ts.isPropertyAccessExpression(node)) return node.name.text;
28
28
  return void 0;
29
29
  };
30
+ var isConst = (ts, type) => ts.isTypeReferenceNode(type) && ts.isIdentifier(type.typeName) && type.typeName.text === "const";
30
31
  var hasModifier = (ts, node, kind) => ts.canHaveModifiers(node) && (ts.getModifiers(node) ?? []).some((modifier) => modifier.kind === kind);
31
32
  var findingsIn = (ts, file, source) => {
32
33
  const found = [];
33
34
  const inSrc = (folder) => file.startsWith(`src/${folder}/`);
34
- const at = (rule, node, what) => {
35
- found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, what });
35
+ const at = (rule, node, what, name = what) => {
36
+ found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, name, what });
36
37
  };
37
38
  const visit = (node) => {
38
- if (ts.isAsExpression(node) && !(ts.isTypeReferenceNode(node.type) && ts.isIdentifier(node.type.typeName) && node.type.typeName.text === "const")) at("style", node, `"as ${node.type.getText(source)}"`);
39
- if (ts.isTypeAssertionExpression(node)) at("style", node, 'a "<T>" assertion');
39
+ if (ts.isAsExpression(node) && !isConst(ts, node.type)) at("style", node, `"as ${node.type.getText(source)}"`);
40
+ if (ts.isTypeAssertionExpression(node) && !isConst(ts, node.type)) at("style", node, 'a "<T>" assertion');
40
41
  if (ts.isNonNullExpression(node)) at("style", node, 'a non-null "!"');
41
42
  if (ts.isFunctionDeclaration(node) && !hasModifier(ts, node, ts.SyntaxKind.DeclareKeyword)) at("style", node, "a function declaration");
42
43
  if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) at("style", node, "a class");
@@ -44,20 +45,22 @@ var findingsIn = (ts, file, source) => {
44
45
  if (node.kind === ts.SyntaxKind.AnyKeyword) at("style", node, '"any"');
45
46
  if (ts.isExportAssignment(node) && node.isExportEquals !== true || ts.isExportSpecifier(node) && node.name.text === "default" || hasModifier(ts, node, ts.SyntaxKind.DefaultKeyword)) at("style", node, "a default export");
46
47
  if (!inSrc("dev")) {
47
- if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "Intl") at("formatting", node, `Intl.${node.name.text}`);
48
- if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text.startsWith("toLocale")) at("formatting", node, `.${node.expression.name.text}()`);
48
+ if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "Intl") at("formatting", node, `Intl.${node.name.text}`, "Intl");
49
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text.startsWith("toLocale")) {
50
+ at("formatting", node, `.${node.expression.name.text}()`, node.expression.name.text);
51
+ }
49
52
  }
50
53
  if (inSrc("server") && ts.isPropertyAccessExpression(node) && node.name.text === "roles") {
51
54
  const whose = lastName(ts, node.expression);
52
- if (whose === "session" || whose === "principal") at("roles", node, `${whose}.roles`);
55
+ if (whose === "session" || whose === "principal") at("roles", node, `${whose}.roles`, "roles");
53
56
  }
54
57
  if (inSrc("ui")) {
55
58
  if (ts.isIdentifier(node) && node.text === "FileReader" && !ts.isTypeReferenceNode(node.parent)) at("files", node, "FileReader");
56
59
  if (ts.isPropertyAccessExpression(node) && READ_FILE.has(node.name.text)) at("files", node, node.name.text);
57
- if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === "location") at("address", node, `location.${node.name.text}`);
58
- if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === "history" && ADDRESS_CHANGE.has(node.name.text)) at("address", node, `history.${node.name.text}`);
60
+ if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === "location") at("address", node, `location.${node.name.text}`, "location");
61
+ if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === "history" && ADDRESS_CHANGE.has(node.name.text)) at("address", node, `history.${node.name.text}`, node.name.text);
59
62
  if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && FIND_ELEMENTS.has(node.expression.name.text) && lastName(ts, node.expression.expression) === "document") {
60
- at("dom", node, `document.${node.expression.name.text}`);
63
+ at("dom", node, `document.${node.expression.name.text}`, node.expression.name.text);
61
64
  }
62
65
  }
63
66
  ts.forEachChild(node, visit);
@@ -86,8 +89,7 @@ var importedNames = (ts, clause) => {
86
89
  const named = bindings !== void 0 && ts.isNamedImports(bindings) ? bindings.elements.filter((element) => !element.isTypeOnly).map((element) => element.name) : [];
87
90
  return [...clause.name === void 0 ? [] : [clause.name], ...named];
88
91
  };
89
- var appDataFindings = (ts, root) => {
90
- const program = programOf(ts, root);
92
+ var appDataFindings = (ts, root, program) => {
91
93
  const checker = program.getTypeChecker();
92
94
  const options = program.getCompilerOptions();
93
95
  return program.getSourceFiles().flatMap((source) => {
@@ -103,11 +105,78 @@ var appDataFindings = (ts, root) => {
103
105
  const calls = checker.getTypeAtLocation(name).getCallSignatures();
104
106
  if (calls.length === 0 || calls.every((call) => MANIFEST.test(checker.typeToString(call.getReturnType())))) return [];
105
107
  const line = source.getLineAndCharacterOfPosition(name.getStart(source)).line + 1;
106
- return [{ rule: "data", file, line, what: `${name.text}, a function of ${from}` }];
108
+ const symbol = checker.getSymbolAtLocation(name);
109
+ const declared = symbol !== void 0 && (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol).getName() : name.text;
110
+ return [{ rule: "data", file, line, name: declared, what: `${name.text}, a function of ${from}` }];
107
111
  });
108
112
  });
109
113
  });
110
114
  };
115
+ var packageRootOf = (ts, file) => {
116
+ const up = dirname(file);
117
+ if (ts.sys.fileExists(join(up, "package.json"))) return up;
118
+ return up === file ? void 0 : packageRootOf(ts, up);
119
+ };
120
+ var referenceFindings = (ts, root, program) => {
121
+ const checker = program.getTypeChecker();
122
+ const moss = ts.resolveModuleName("@niscorp/moss", join(root, "package.json"), program.getCompilerOptions(), ts.sys).resolvedModule?.resolvedFileName;
123
+ const mossRoot = moss === void 0 ? void 0 : packageRootOf(ts, resolve(moss));
124
+ const isDeclaredIn = (symbol, where) => (symbol?.declarations ?? []).some((declaration) => where(declaration.getSourceFile()));
125
+ const isLibrary = (symbol) => isDeclaredIn(symbol, (source) => program.isSourceFileDefaultLibrary(source));
126
+ const isMoss = (symbol) => mossRoot !== void 0 && isDeclaredIn(symbol, (source) => resolve(source.fileName).startsWith(`${mossRoot}${sep}`));
127
+ const typeIs = (node, name) => {
128
+ const symbol = checker.getTypeAtLocation(node).getSymbol();
129
+ return symbol?.getName() === name && isLibrary(symbol);
130
+ };
131
+ const unaliased = (symbol) => symbol !== void 0 && (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol;
132
+ const referredOf = (node) => {
133
+ const bound = node.parent;
134
+ if (ts.isBindingElement(bound) && bound.name === node && ts.isObjectBindingPattern(bound.parent)) {
135
+ const property = bound.propertyName ?? node;
136
+ return ts.isIdentifier(property) || ts.isStringLiteral(property) ? unaliased(checker.getTypeAtLocation(bound.parent).getProperty(property.text)) : void 0;
137
+ }
138
+ return unaliased(checker.getSymbolAtLocation(node));
139
+ };
140
+ const isAppFunction = (symbol, node) => {
141
+ const declared = symbol.valueDeclaration;
142
+ if (declared === void 0 || !pathOf(root, resolve(declared.getSourceFile().fileName)).startsWith("src/app/")) return false;
143
+ const calls = checker.getTypeOfSymbolAtLocation(symbol, node).getCallSignatures();
144
+ return calls.length > 0 && !calls.every((call) => MANIFEST.test(checker.typeToString(call.getReturnType())));
145
+ };
146
+ return program.getSourceFiles().flatMap((source) => {
147
+ const file = pathOf(root, resolve(source.fileName));
148
+ if (!file.startsWith("src/") || source.isDeclarationFile) return [];
149
+ const inSrc = (folder) => file.startsWith(`src/${folder}/`);
150
+ const found = [];
151
+ const at = (rule, node, name, what = name) => {
152
+ found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, name, what });
153
+ };
154
+ const isTypeOnly = (node) => (ts.isImportClause(node) || ts.isImportSpecifier(node) || ts.isExportDeclaration(node) || ts.isExportSpecifier(node)) && node.isTypeOnly;
155
+ const visit = (node, isType) => {
156
+ const isName = ts.isIdentifier(node) || ts.isStringLiteral(node) && ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node;
157
+ const referred = !isType && isName ? referredOf(node) : void 0;
158
+ if (referred !== void 0) {
159
+ if (!inSrc("dev") && referred.getName() === "Intl" && isLibrary(referred)) at("formatting", node, "Intl", "Intl, the global one");
160
+ if (inSrc("server") && referred.getName() === "roles" && isMoss(referred)) at("roles", node, "roles", "roles, read off a moss session");
161
+ if (!inSrc("app") && !inSrc("dev") && isAppFunction(referred, node)) {
162
+ at("data", node, referred.getName(), `${referred.getName()}, a function of ${pathOf(root, resolve(referred.valueDeclaration?.getSourceFile().fileName ?? ""))}`);
163
+ }
164
+ }
165
+ if (!isType && inSrc("ui")) {
166
+ const isLocation = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && typeIs(node, "Location");
167
+ if (isLocation && !(ts.isExpression(node.parent) && typeIs(node.parent, "Location"))) at("address", node, "location", `location, as ${node.getText(source)}`);
168
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
169
+ const { name, expression } = node.expression;
170
+ if (ADDRESS_CHANGE.has(name.text) && typeIs(expression, "History")) at("address", node, name.text, `${name.text} on a History`);
171
+ if (FIND_ELEMENTS.has(name.text) && typeIs(expression, "Document")) at("dom", node, name.text, `${name.text} on a Document`);
172
+ }
173
+ }
174
+ ts.forEachChild(node, (child) => visit(child, isType || ts.isTypeNode(node) || isTypeOnly(node)));
175
+ };
176
+ visit(source, false);
177
+ return found;
178
+ });
179
+ };
111
180
  var isTypeScript = (value) => value !== null && typeof value === "object" && typeof Reflect.get(value, "createProgram") === "function" && typeof Reflect.get(value, "version") === "string";
112
181
  var loadTypeScript = (root) => {
113
182
  const require2 = createRequire(join(root, "package.json"));
@@ -140,6 +209,16 @@ var replayOf = (endpoint) => {
140
209
  const fingerprint = request["fingerprint"];
141
210
  return typeof fingerprint === "string" ? { fingerprint } : {};
142
211
  };
212
+ var messageOf = (error) => error instanceof Error ? error.message : String(error);
213
+ var readSource = (root) => {
214
+ try {
215
+ const ts = loadTypeScript(root);
216
+ const program = programOf(ts, root);
217
+ return { ts, program, findings: [...sourceFindings(ts, root), ...appDataFindings(ts, root, program)] };
218
+ } catch (error) {
219
+ return messageOf(error);
220
+ }
221
+ };
143
222
  var runShapeCheck = (config) => {
144
223
  const log = config.log ?? ((line) => console.log(line));
145
224
  let failures = 0;
@@ -151,20 +230,34 @@ var runShapeCheck = (config) => {
151
230
  log(failures === 0 ? "[pass] shape: all checks passed" : `[fail] shape: ${failures} check(s) failed`);
152
231
  return failures === 0 ? 0 : 1;
153
232
  };
154
- let findings;
155
- try {
156
- const ts = loadTypeScript(config.root);
157
- findings = [...sourceFindings(ts, config.root), ...appDataFindings(ts, config.root)];
158
- } catch (error) {
159
- check("the source is read", false, [error instanceof Error ? error.message : String(error)]);
233
+ const read = readSource(config.root);
234
+ if (typeof read === "string") {
235
+ check("the source is read", false, [read]);
160
236
  return done();
161
237
  }
238
+ const { findings } = read;
162
239
  const allow = config.allow ?? {};
163
240
  for (const [rule, what] of RULES) {
164
241
  const allowed = allow[rule] ?? {};
165
242
  const left = findings.filter((finding) => finding.rule === rule && allowed[finding.file] === void 0);
166
243
  check(what, left.length === 0, left.map((finding) => `${finding.file}:${finding.line} ${finding.what}`));
167
244
  }
245
+ try {
246
+ const failed = new Set(findings.map((finding) => `${finding.rule} ${finding.file} ${finding.name}`));
247
+ const shown = /* @__PURE__ */ new Set();
248
+ const others = referenceFindings(read.ts, config.root, read.program).filter((finding) => {
249
+ const key = `${finding.rule} ${finding.file} ${finding.name}`;
250
+ if (failed.has(key) || allow[finding.rule]?.[finding.file] !== void 0 || shown.has(`${key} ${finding.line}`)) return false;
251
+ shown.add(`${key} ${finding.line}`);
252
+ return true;
253
+ });
254
+ const ruleOf = new Map(RULES.map(([rule, what]) => [rule, what.split(":")[0] ?? what]));
255
+ for (const finding of others) {
256
+ log(`[info] ${ruleOf.get(finding.rule) ?? finding.rule}: ${finding.file}:${finding.line} ${finding.what} \u2014 another spelling of what the rule fails on; reported, not failed`);
257
+ }
258
+ } catch (error) {
259
+ log(`[info] what names refer to could not be read, so other spellings are not reported: ${messageOf(error)}`);
260
+ }
168
261
  const idle = RULES.flatMap(
169
262
  ([rule]) => Object.entries(allow[rule] ?? {}).flatMap(([file, reason]) => {
170
263
  if (reason.trim() === "") return [`${rule}: ${file} gives no reason`];
package/dist/shape.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shape/source.ts","../src/shape/app-data.ts","../src/shape/typescript.ts","../src/shape/index.ts"],"names":["require","join"],"mappings":";;;;;AASA,IAAM,MAAA,GAAS,qBAAA;AAER,IAAM,MAAA,GAAS,CAAC,IAAA,EAAc,IAAA,KAAyB,QAAA,CAAS,IAAA,EAAM,IAAI,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAE/F,IAAM,gBAAgB,CAAC,IAAA,EAAc,MAAM,IAAA,CAAK,IAAA,EAAM,KAAK,CAAA,KAAgB;AAChF,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,WAAA,CAAY,GAAA,EAAK,EAAE,aAAA,EAAe,MAAM,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,CAAC,KAAA,KAAU;AAChC,IAAA,IAAI,KAAA,CAAM,IAAA,KAAS,cAAA,EAAgB,OAAO,EAAC;AAC3C,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,EAAK,KAAA,CAAM,IAAI,CAAA;AACjC,IAAA,IAAI,MAAM,WAAA,EAAY,EAAG,OAAO,aAAA,CAAc,MAAM,IAAI,CAAA;AACxD,IAAA,OAAO,MAAA,C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,CAAA;AACjH,EAAA,MAAM,KAAA,GAAA,CAAS,MAAA,CAAO,OAAA,IAAW,EAAC,EAAG,OAAO,CAAC,KAAA,KAAU,KAAA,CAAM,GAAA,KAAQ,MAAS,CAAA;AAC9E,EAAA,MAAM,KAAA,GAAQ,SAAA,CAAU,MAAA,CAAO,CAAC,EAAE,QAAA,EAAS,KAAM,OAAO,QAAA,CAAS,IAAI,CAAA,KAAM,QAAQ,CAAA,CAAE,MAAA;AACrF,EAAA,GAAA,CAAI,CAAA,qCAAA,EAAwC,KAAK,CAAA,sBAAA,EAAyB,OAAA,CAAQ,MAAM,CAAA,MAAA,CAAQ,CAAA;AAChG,EAAA,GAAA,CAAI,CAAA,OAAA,EAAU,KAAA,CAAM,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,OAAA,KAAY,MAAS,CAAA,CAAE,MAAM,CAAA,IAAA,EAAO,KAAA,CAAM,MAAM,CAAA,2CAAA,CAA6C,CAAA;AACzI,EAAA,MAAM,UAAU,KAAA,CAAM,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,YAAY,UAAA,IAAc,CAAC,MAAM,GAAA,CAAI,KAAA,CAAM,WAAW,CAAC,CAAA,CAAE,IAAI,CAAC,KAAA,KAAU,MAAM,WAAW,CAAA;AACvI,EAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG,GAAA,CAAI,oDAAoD,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACpG,EAAA,OAAO,IAAA,EAAK;AACd","file":"shape.js","sourcesContent":["import { readdirSync, readFileSync } from 'node:fs';\nimport { join, relative, sep } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { TypeScript } from './typescript';\n\nexport type SourceRule = 'style' | 'formatting' | 'roles' | 'files' | 'address' | 'dom';\n\nexport type Finding = { rule: SourceRule | 'data'; file: string; line: number; what: string };\n\nconst SOURCE = /\\.(ts|tsx|mts|cts)$/;\n\nexport const pathOf = (root: string, file: string): string => relative(root, file).split(sep).join('/');\n\nexport const sourceFilesOf = (root: string, dir = join(root, 'src')): string[] => {\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return [];\n }\n return entries.flatMap((entry) => {\n if (entry.name === 'node_modules') return [];\n const path = join(dir, entry.name);\n if (entry.isDirectory()) return sourceFilesOf(root, path);\n return SOURCE.test(entry.name) && !entry.name.endsWith('.d.ts') ? [path] : [];\n });\n};\n\nconst READ_FILE = new Set(['readAsDataURL', 'readAsText', 'readAsArrayBuffer', 'readAsBinaryString']);\nconst FIND_ELEMENTS = new Set(['querySelector', 'querySelectorAll', 'getElementById', 'getElementsByClassName', 'getElementsByTagName', 'getElementsByName']);\nconst ADDRESS_CHANGE = new Set(['pushState', 'replaceState']);\n\nconst lastName = (ts: TypeScript, node: TS.Expression): string | undefined => {\n if (ts.isIdentifier(node)) return node.text;\n if (ts.isPropertyAccessExpression(node)) return node.name.text;\n return undefined;\n};\n\nconst hasModifier = (ts: TypeScript, node: TS.Node, kind: TS.SyntaxKind): boolean => ts.canHaveModifiers(node) && (ts.getModifiers(node) ?? []).some((modifier) => modifier.kind === kind);\n\n// Each rule reads the syntax tree, so a word in a comment or a string is never a finding.\nconst findingsIn = (ts: TypeScript, file: string, source: TS.SourceFile): Finding[] => {\n const found: Finding[] = [];\n const inSrc = (folder: string): boolean => file.startsWith(`src/${folder}/`);\n const at = (rule: SourceRule, node: TS.Node, what: string): void => {\n found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, what });\n };\n const visit = (node: TS.Node): void => {\n if (ts.isAsExpression(node) && !(ts.isTypeReferenceNode(node.type) && ts.isIdentifier(node.type.typeName) && node.type.typeName.text === 'const')) at('style', node, `\"as ${node.type.getText(source)}\"`);\n if (ts.isTypeAssertionExpression(node)) at('style', node, 'a \"<T>\" assertion');\n if (ts.isNonNullExpression(node)) at('style', node, 'a non-null \"!\"');\n if (ts.isFunctionDeclaration(node) && !hasModifier(ts, node, ts.SyntaxKind.DeclareKeyword)) at('style', node, 'a function declaration');\n if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) at('style', node, 'a class');\n if (ts.isEnumDeclaration(node)) at('style', node, 'an enum');\n if (node.kind === ts.SyntaxKind.AnyKeyword) at('style', node, '\"any\"');\n if ((ts.isExportAssignment(node) && node.isExportEquals !== true) || (ts.isExportSpecifier(node) && node.name.text === 'default') || hasModifier(ts, node, ts.SyntaxKind.DefaultKeyword)) at('style', node, 'a default export');\n\n if (!inSrc('dev')) {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'Intl') at('formatting', node, `Intl.${node.name.text}`);\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text.startsWith('toLocale')) at('formatting', node, `.${node.expression.name.text}()`);\n }\n if (inSrc('server') && ts.isPropertyAccessExpression(node) && node.name.text === 'roles') {\n const whose = lastName(ts, node.expression);\n if (whose === 'session' || whose === 'principal') at('roles', node, `${whose}.roles`);\n }\n if (inSrc('ui')) {\n if (ts.isIdentifier(node) && node.text === 'FileReader' && !ts.isTypeReferenceNode(node.parent)) at('files', node, 'FileReader');\n if (ts.isPropertyAccessExpression(node) && READ_FILE.has(node.name.text)) at('files', node, node.name.text);\n if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === 'location') at('address', node, `location.${node.name.text}`);\n if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === 'history' && ADDRESS_CHANGE.has(node.name.text)) at('address', node, `history.${node.name.text}`);\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && FIND_ELEMENTS.has(node.expression.name.text) && lastName(ts, node.expression.expression) === 'document') {\n at('dom', node, `document.${node.expression.name.text}`);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n return found;\n};\n\nexport const sourceFindings = (ts: TypeScript, root: string): Finding[] =>\n sourceFilesOf(root).flatMap((path) => {\n const file = pathOf(root, path);\n const source = ts.createSourceFile(file, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true, path.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS);\n return findingsIn(ts, file, source);\n });\n","import { resolve } from 'node:path';\nimport type * as TS from 'typescript';\nimport { pathOf } from './source';\nimport type { Finding } from './source';\nimport type { TypeScript } from './typescript';\n\n// The manifest's factory takes the server's code seams and answers the manifest: setup, not code in the artifact tree.\nconst MANIFEST = /^(Promise<)?NiscApp>?$/;\n\nconst programOf = (ts: TypeScript, root: string): TS.Program => {\n const config = ts.findConfigFile(root, ts.sys.fileExists, 'tsconfig.json');\n if (config === undefined || !resolve(config).startsWith(resolve(root))) throw new Error(`the shape check reads the app as its tsconfig.json says, and ${root} has none.`);\n const parsed = ts.getParsedCommandLineOfConfigFile(config, {}, { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => undefined });\n if (parsed === undefined) throw new Error(`${config} could not be read.`);\n return ts.createProgram({ rootNames: parsed.fileNames, options: parsed.options });\n};\n\nconst importedNames = (ts: TypeScript, clause: TS.ImportClause | undefined): TS.Identifier[] => {\n if (clause === undefined || clause.isTypeOnly) return [];\n const bindings = clause.namedBindings;\n const named = bindings !== undefined && ts.isNamedImports(bindings) ? bindings.elements.filter((element) => !element.isTypeOnly).map((element) => element.name) : [];\n return [...(clause.name === undefined ? [] : [clause.name]), ...named];\n};\n\n// What code outside src/app calls of it, read by the compiler under the app's own tsconfig, so a path alias counts.\nexport const appDataFindings = (ts: TypeScript, root: string): Finding[] => {\n const program = programOf(ts, root);\n const checker = program.getTypeChecker();\n const options = program.getCompilerOptions();\n return program.getSourceFiles().flatMap((source) => {\n const file = pathOf(root, resolve(source.fileName));\n if (!file.startsWith('src/') || file.startsWith('src/app/') || file.startsWith('src/dev/') || source.isDeclarationFile) return [];\n return source.statements.flatMap((statement) => {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) return [];\n const target = ts.resolveModuleName(statement.moduleSpecifier.text, source.fileName, options, ts.sys).resolvedModule?.resolvedFileName;\n if (target === undefined) return [];\n const from = pathOf(root, resolve(target));\n if (!from.startsWith('src/app/')) return [];\n return importedNames(ts, statement.importClause).flatMap((name) => {\n const calls = checker.getTypeAtLocation(name).getCallSignatures();\n if (calls.length === 0 || calls.every((call) => MANIFEST.test(checker.typeToString(call.getReturnType())))) return [];\n const line = source.getLineAndCharacterOfPosition(name.getStart(source)).line + 1;\n return [{ rule: 'data' as const, file, line, what: `${name.text}, a function of ${from}` }];\n });\n });\n });\n};\n","import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\n\nexport type TypeScript = typeof TS;\n\nconst isTypeScript = (value: unknown): value is TypeScript =>\n value !== null && typeof value === 'object' && typeof Reflect.get(value, 'createProgram') === 'function' && typeof Reflect.get(value, 'version') === 'string';\n\n// The app's own compiler, as `nisc build` uses the app's own jsdom: the gate adds no dependency to the cli.\nexport const loadTypeScript = (root: string): TypeScript => {\n const require = createRequire(join(root, 'package.json'));\n let library: unknown;\n try {\n library = require('typescript');\n } catch {\n throw new Error(`the shape check reads the source with TypeScript, and this app has none installed (looked from ${root}). pnpm add -D typescript`);\n }\n if (!isTypeScript(library)) throw new Error('the \"typescript\" this app has installed is not the TypeScript compiler.');\n if (!library.version.startsWith('6.')) throw new Error(`the shape check is written against TypeScript 6, and this app has ${library.version}.`);\n return library;\n};\n","import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { appDataFindings } from './app-data';\nimport { sourceFindings } from './source';\nimport type { Finding } from './source';\nimport { loadTypeScript } from './typescript';\n\nexport type ShapeRule = 'style' | 'formatting' | 'roles' | 'files' | 'address' | 'dom' | 'data';\n\nexport type ShapeAction = { id: string; endpoints?: Readonly<Record<string, unknown>> };\n\nexport type ShapeEntry = { fingerprint: string; refresh?: string; dsl?: unknown; mapping?: unknown };\n\nexport type ShapeCheckConfig = {\n root: string;\n actions: readonly ShapeAction[];\n entries?: readonly ShapeEntry[];\n functions?: Readonly<Record<string, string>>;\n allow?: Readonly<Partial<Record<ShapeRule, Readonly<Record<string, string>>>>>;\n log?: (line: string) => void;\n};\n\nconst RULES: readonly (readonly [rule: ShapeRule, what: string])[] = [\n ['style', 'rule 16: no assertion but \"as const\", no non-null \"!\", no function declaration, class, enum, \"any\" or default export in src/'],\n ['formatting', 'rule 9: no Intl and no toLocale… outside Prism (src/, but src/dev/)'],\n ['roles', 'rule 11: no server code reads the caller’s roles (src/server/)'],\n ['files', 'rule 9a: the kit reads no file into data (src/ui/)'],\n ['address', 'rule 4: the kit neither reads nor changes the address (src/ui/)'],\n ['dom', 'rule 2: no component finds elements in the document (src/ui/)'],\n ['data', 'src/app is data: no code outside it calls a function of it, but the manifest’s factory'],\n];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst endpointsOf = (actions: readonly ShapeAction[]): { action: string; endpoint: Record<string, unknown> }[] =>\n actions.flatMap((action) => Object.values(action.endpoints ?? {}).flatMap((endpoint) => (isRecord(endpoint) ? [{ action: action.id, endpoint }] : [])));\n\nconst replayOf = (endpoint: Record<string, unknown>): { fingerprint?: string } | undefined => {\n const request = endpoint['request'];\n if (!isRecord(request) || !('fingerprint' in request)) return undefined;\n const fingerprint = request['fingerprint'];\n return typeof fingerprint === 'string' ? { fingerprint } : {};\n};\n\nexport const runShapeCheck = (config: ShapeCheckConfig): number => {\n const log = config.log ?? ((line: string) => console.log(line));\n let failures = 0;\n const check = (what: string, passed: boolean, detail: readonly string[] = []): void => {\n log(`${passed ? '[pass]' : '[fail]'} ${what}${passed || detail.length === 0 ? '' : ` — ${detail.join('; ')}`}`);\n if (!passed) failures += 1;\n };\n const done = (): number => {\n log(failures === 0 ? '[pass] shape: all checks passed' : `[fail] shape: ${failures} check(s) failed`);\n return failures === 0 ? 0 : 1;\n };\n\n let findings: Finding[];\n try {\n const ts = loadTypeScript(config.root);\n findings = [...sourceFindings(ts, config.root), ...appDataFindings(ts, config.root)];\n } catch (error) {\n check('the source is read', false, [error instanceof Error ? error.message : String(error)]);\n return done();\n }\n\n const allow = config.allow ?? {};\n for (const [rule, what] of RULES) {\n const allowed = allow[rule] ?? {};\n const left = findings.filter((finding) => finding.rule === rule && allowed[finding.file] === undefined);\n check(what, left.length === 0, left.map((finding) => `${finding.file}:${finding.line} ${finding.what}`));\n }\n const idle = RULES.flatMap(([rule]) =>\n Object.entries(allow[rule] ?? {}).flatMap(([file, reason]) => {\n if (reason.trim() === '') return [`${rule}: ${file} gives no reason`];\n if (!existsSync(join(config.root, file))) return [`${rule}: ${file} does not exist`];\n return findings.some((finding) => finding.rule === rule && finding.file === file) ? [] : [`${rule}: ${file} has nothing to allow`];\n }),\n );\n check('every allowance names a file there is, why, and something it allows', idle.length === 0, idle);\n\n const endpoints = endpointsOf(config.actions);\n const ledger = config.functions ?? {};\n const called = new Set(endpoints.flatMap(({ endpoint }) => (typeof endpoint['fn'] === 'string' ? [endpoint['fn']] : [])));\n const unexplained = [...called].filter((id) => (ledger[id] ?? '').trim() === '').sort();\n check('every server function an action calls is named in `functions`, with what it does that a vex read or write cannot', unexplained.length === 0, unexplained);\n const uncalled = Object.keys(ledger).filter((id) => !called.has(id)).sort();\n check('every function named in `functions` is called by an action', uncalled.length === 0, uncalled);\n\n const replays = endpoints.flatMap(({ endpoint }) => {\n const replay = replayOf(endpoint);\n return replay === undefined ? [] : [replay];\n });\n const named = new Set(replays.flatMap((replay) => (replay.fingerprint === undefined ? [] : [replay.fingerprint])));\n const reads = (config.entries ?? []).filter((entry) => entry.dsl !== undefined);\n const calls = endpoints.filter(({ endpoint }) => typeof endpoint['fn'] === 'string').length;\n log(`[info] actions call server functions ${calls} times and replay vex ${replays.length} times`);\n log(`[info] ${reads.filter((entry) => entry.mapping !== undefined).length} of ${reads.length} reads word their rows with a Prism mapping`);\n const unnamed = reads.filter((entry) => entry.refresh === 'reactive' && !named.has(entry.fingerprint)).map((entry) => entry.fingerprint);\n if (unnamed.length > 0) log(`[info] reactive reads no action replays by name: ${unnamed.join(', ')}`);\n return done();\n};\n"]}
1
+ {"version":3,"sources":["../src/shape/source.ts","../src/shape/app-data.ts","../src/shape/references.ts","../src/shape/typescript.ts","../src/shape/index.ts"],"names":["join","resolve","sep","require"],"mappings":";;;;;AASA,IAAM,MAAA,GAAS,qBAAA;AAER,IAAM,MAAA,GAAS,CAAC,IAAA,EAAc,IAAA,KAAyB,QAAA,CAAS,IAAA,EAAM,IAAI,CAAA,CAAE,KAAA,CAAM,GAAG,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAE/F,IAAM,gBAAgB,CAAC,IAAA,EAAc,MAAM,IAAA,CAAK,IAAA,EAAM,KAAK,CAAA,KAAgB;AAChF,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,WAAA,CAAY,GAAA,EAAK,EAAE,aAAA,EAAe,MAAM,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,CAAC,KAAA,KAAU;AAChC,IAAA,IAAI,KAAA,CAAM,IAAA,KAAS,cAAA,EAAgB,OAAO,EAAC;AAC3C,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,EAAK,KAAA,CAAM,IAAI,CAAA;AACjC,IAAA,IAAI,MAAM,WAAA,EAAY,EAAG,OAAO,aAAA,CAAc,MAAM,IAAI,CAAA;AACxD,IAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,IAAI,KAAK,CAAC,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,OAAO,CAAA,GAAI,CAAC,IAAI,IAAI,EAAC;AAAA,EAC9E,CAAC,CAAA;AACH,CAAA;AAEA,IAAM,SAAA,uBAAgB,GAAA,CAAI,CAAC,iBAAiB,YAAA,EAAc,mBAAA,EAAqB,oBAAoB,CAAC,CAAA;AAC7F,IAAM,aAAA,mBAAgB,IAAI,GA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AQ,SAAA,CAAU,MAAA,CAAO,CAAC,EAAE,QAAA,EAAS,KAAM,OAAO,QAAA,CAAS,IAAI,CAAA,KAAM,QAAQ,CAAA,CAAE,MAAA;AACrF,EAAA,GAAA,CAAI,CAAA,qCAAA,EAAwC,KAAK,CAAA,sBAAA,EAAyB,OAAA,CAAQ,MAAM,CAAA,MAAA,CAAQ,CAAA;AAChG,EAAA,GAAA,CAAI,CAAA,OAAA,EAAU,KAAA,CAAM,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,OAAA,KAAY,MAAS,CAAA,CAAE,MAAM,CAAA,IAAA,EAAO,KAAA,CAAM,MAAM,CAAA,2CAAA,CAA6C,CAAA;AACzI,EAAA,MAAM,UAAU,KAAA,CAAM,MAAA,CAAO,CAAC,KAAA,KAAU,KAAA,CAAM,YAAY,UAAA,IAAc,CAAC,MAAM,GAAA,CAAI,KAAA,CAAM,WAAW,CAAC,CAAA,CAAE,IAAI,CAAC,KAAA,KAAU,MAAM,WAAW,CAAA;AACvI,EAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG,GAAA,CAAI,oDAAoD,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACpG,EAAA,OAAO,IAAA,EAAK;AACd","file":"shape.js","sourcesContent":["import { readdirSync, readFileSync } from 'node:fs';\nimport { join, relative, sep } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { TypeScript } from './typescript';\n\nexport type SourceRule = 'style' | 'formatting' | 'roles' | 'files' | 'address' | 'dom';\n\nexport type Finding = { rule: SourceRule | 'data'; file: string; line: number; name: string; what: string };\n\nconst SOURCE = /\\.(ts|tsx|mts|cts)$/;\n\nexport const pathOf = (root: string, file: string): string => relative(root, file).split(sep).join('/');\n\nexport const sourceFilesOf = (root: string, dir = join(root, 'src')): string[] => {\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return [];\n }\n return entries.flatMap((entry) => {\n if (entry.name === 'node_modules') return [];\n const path = join(dir, entry.name);\n if (entry.isDirectory()) return sourceFilesOf(root, path);\n return SOURCE.test(entry.name) && !entry.name.endsWith('.d.ts') ? [path] : [];\n });\n};\n\nconst READ_FILE = new Set(['readAsDataURL', 'readAsText', 'readAsArrayBuffer', 'readAsBinaryString']);\nexport const FIND_ELEMENTS = new Set(['querySelector', 'querySelectorAll', 'getElementById', 'getElementsByClassName', 'getElementsByTagName', 'getElementsByName']);\nexport const ADDRESS_CHANGE = new Set(['pushState', 'replaceState']);\n\nconst lastName = (ts: TypeScript, node: TS.Expression): string | undefined => {\n if (ts.isIdentifier(node)) return node.text;\n if (ts.isPropertyAccessExpression(node)) return node.name.text;\n return undefined;\n};\n\nconst isConst = (ts: TypeScript, type: TS.TypeNode): boolean => ts.isTypeReferenceNode(type) && ts.isIdentifier(type.typeName) && type.typeName.text === 'const';\n\nconst hasModifier = (ts: TypeScript, node: TS.Node, kind: TS.SyntaxKind): boolean => ts.canHaveModifiers(node) && (ts.getModifiers(node) ?? []).some((modifier) => modifier.kind === kind);\n\n// Each rule reads the syntax tree, so a word in a comment or a string is never a finding.\nconst findingsIn = (ts: TypeScript, file: string, source: TS.SourceFile): Finding[] => {\n const found: Finding[] = [];\n const inSrc = (folder: string): boolean => file.startsWith(`src/${folder}/`);\n const at = (rule: SourceRule, node: TS.Node, what: string, name = what): void => {\n found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, name, what });\n };\n const visit = (node: TS.Node): void => {\n if (ts.isAsExpression(node) && !isConst(ts, node.type)) at('style', node, `\"as ${node.type.getText(source)}\"`);\n if (ts.isTypeAssertionExpression(node) && !isConst(ts, node.type)) at('style', node, 'a \"<T>\" assertion');\n if (ts.isNonNullExpression(node)) at('style', node, 'a non-null \"!\"');\n if (ts.isFunctionDeclaration(node) && !hasModifier(ts, node, ts.SyntaxKind.DeclareKeyword)) at('style', node, 'a function declaration');\n if (ts.isClassDeclaration(node) || ts.isClassExpression(node)) at('style', node, 'a class');\n if (ts.isEnumDeclaration(node)) at('style', node, 'an enum');\n if (node.kind === ts.SyntaxKind.AnyKeyword) at('style', node, '\"any\"');\n if ((ts.isExportAssignment(node) && node.isExportEquals !== true) || (ts.isExportSpecifier(node) && node.name.text === 'default') || hasModifier(ts, node, ts.SyntaxKind.DefaultKeyword)) at('style', node, 'a default export');\n\n if (!inSrc('dev')) {\n if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === 'Intl') at('formatting', node, `Intl.${node.name.text}`, 'Intl');\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text.startsWith('toLocale')) {\n at('formatting', node, `.${node.expression.name.text}()`, node.expression.name.text);\n }\n }\n if (inSrc('server') && ts.isPropertyAccessExpression(node) && node.name.text === 'roles') {\n const whose = lastName(ts, node.expression);\n if (whose === 'session' || whose === 'principal') at('roles', node, `${whose}.roles`, 'roles');\n }\n if (inSrc('ui')) {\n if (ts.isIdentifier(node) && node.text === 'FileReader' && !ts.isTypeReferenceNode(node.parent)) at('files', node, 'FileReader');\n if (ts.isPropertyAccessExpression(node) && READ_FILE.has(node.name.text)) at('files', node, node.name.text);\n if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === 'location') at('address', node, `location.${node.name.text}`, 'location');\n if (ts.isPropertyAccessExpression(node) && lastName(ts, node.expression) === 'history' && ADDRESS_CHANGE.has(node.name.text)) at('address', node, `history.${node.name.text}`, node.name.text);\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && FIND_ELEMENTS.has(node.expression.name.text) && lastName(ts, node.expression.expression) === 'document') {\n at('dom', node, `document.${node.expression.name.text}`, node.expression.name.text);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n return found;\n};\n\nexport const sourceFindings = (ts: TypeScript, root: string): Finding[] =>\n sourceFilesOf(root).flatMap((path) => {\n const file = pathOf(root, path);\n const source = ts.createSourceFile(file, readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true, path.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS);\n return findingsIn(ts, file, source);\n });\n","import { resolve } from 'node:path';\nimport type * as TS from 'typescript';\nimport { pathOf } from './source';\nimport type { Finding } from './source';\nimport type { TypeScript } from './typescript';\n\n// The manifest's factory takes the server's code seams and answers the manifest: setup, not code in the artifact tree.\nexport const MANIFEST = /^(Promise<)?NiscApp>?$/;\n\nexport const programOf = (ts: TypeScript, root: string): TS.Program => {\n const config = ts.findConfigFile(root, ts.sys.fileExists, 'tsconfig.json');\n if (config === undefined || !resolve(config).startsWith(resolve(root))) throw new Error(`the shape check reads the app as its tsconfig.json says, and ${root} has none.`);\n const parsed = ts.getParsedCommandLineOfConfigFile(config, {}, { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => undefined });\n if (parsed === undefined) throw new Error(`${config} could not be read.`);\n return ts.createProgram({ rootNames: parsed.fileNames, options: parsed.options });\n};\n\nconst importedNames = (ts: TypeScript, clause: TS.ImportClause | undefined): TS.Identifier[] => {\n if (clause === undefined || clause.isTypeOnly) return [];\n const bindings = clause.namedBindings;\n const named = bindings !== undefined && ts.isNamedImports(bindings) ? bindings.elements.filter((element) => !element.isTypeOnly).map((element) => element.name) : [];\n return [...(clause.name === undefined ? [] : [clause.name]), ...named];\n};\n\n// What code outside src/app calls of it, read by the compiler under the app's own tsconfig, so a path alias counts.\nexport const appDataFindings = (ts: TypeScript, root: string, program: TS.Program): Finding[] => {\n const checker = program.getTypeChecker();\n const options = program.getCompilerOptions();\n return program.getSourceFiles().flatMap((source) => {\n const file = pathOf(root, resolve(source.fileName));\n if (!file.startsWith('src/') || file.startsWith('src/app/') || file.startsWith('src/dev/') || source.isDeclarationFile) return [];\n return source.statements.flatMap((statement) => {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) return [];\n const target = ts.resolveModuleName(statement.moduleSpecifier.text, source.fileName, options, ts.sys).resolvedModule?.resolvedFileName;\n if (target === undefined) return [];\n const from = pathOf(root, resolve(target));\n if (!from.startsWith('src/app/')) return [];\n return importedNames(ts, statement.importClause).flatMap((name) => {\n const calls = checker.getTypeAtLocation(name).getCallSignatures();\n if (calls.length === 0 || calls.every((call) => MANIFEST.test(checker.typeToString(call.getReturnType())))) return [];\n const line = source.getLineAndCharacterOfPosition(name.getStart(source)).line + 1;\n const symbol = checker.getSymbolAtLocation(name);\n const declared = symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol).getName() : name.text;\n return [{ rule: 'data' as const, file, line, name: declared, what: `${name.text}, a function of ${from}` }];\n });\n });\n });\n};\n","import { dirname, join, resolve, sep } from 'node:path';\nimport type * as TS from 'typescript';\nimport { MANIFEST } from './app-data';\nimport { ADDRESS_CHANGE, FIND_ELEMENTS, pathOf } from './source';\nimport type { Finding, SourceRule } from './source';\nimport type { TypeScript } from './typescript';\n\nconst packageRootOf = (ts: TypeScript, file: string): string | undefined => {\n const up = dirname(file);\n if (ts.sys.fileExists(join(up, 'package.json'))) return up;\n return up === file ? undefined : packageRootOf(ts, up);\n};\n\n// The reaches the source rules find by spelling, found again by what each name refers to.\nexport const referenceFindings = (ts: TypeScript, root: string, program: TS.Program): Finding[] => {\n const checker = program.getTypeChecker();\n const moss = ts.resolveModuleName('@niscorp/moss', join(root, 'package.json'), program.getCompilerOptions(), ts.sys).resolvedModule?.resolvedFileName;\n const mossRoot = moss === undefined ? undefined : packageRootOf(ts, resolve(moss));\n const isDeclaredIn = (symbol: TS.Symbol | undefined, where: (source: TS.SourceFile) => boolean): boolean => (symbol?.declarations ?? []).some((declaration) => where(declaration.getSourceFile()));\n const isLibrary = (symbol: TS.Symbol | undefined): boolean => isDeclaredIn(symbol, (source) => program.isSourceFileDefaultLibrary(source));\n const isMoss = (symbol: TS.Symbol | undefined): boolean => mossRoot !== undefined && isDeclaredIn(symbol, (source) => resolve(source.fileName).startsWith(`${mossRoot}${sep}`));\n const typeIs = (node: TS.Node, name: string): boolean => {\n const symbol = checker.getTypeAtLocation(node).getSymbol();\n return symbol?.getName() === name && isLibrary(symbol);\n };\n const unaliased = (symbol: TS.Symbol | undefined): TS.Symbol | undefined => (symbol !== undefined && (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(symbol) : symbol);\n // A name a destructuring binds refers to the property it takes.\n const referredOf = (node: TS.Identifier | TS.StringLiteral): TS.Symbol | undefined => {\n const bound = node.parent;\n if (ts.isBindingElement(bound) && bound.name === node && ts.isObjectBindingPattern(bound.parent)) {\n const property = bound.propertyName ?? node;\n return ts.isIdentifier(property) || ts.isStringLiteral(property) ? unaliased(checker.getTypeAtLocation(bound.parent).getProperty(property.text)) : undefined;\n }\n return unaliased(checker.getSymbolAtLocation(node));\n };\n const isAppFunction = (symbol: TS.Symbol, node: TS.Node): boolean => {\n const declared = symbol.valueDeclaration;\n if (declared === undefined || !pathOf(root, resolve(declared.getSourceFile().fileName)).startsWith('src/app/')) return false;\n const calls = checker.getTypeOfSymbolAtLocation(symbol, node).getCallSignatures();\n return calls.length > 0 && !calls.every((call) => MANIFEST.test(checker.typeToString(call.getReturnType())));\n };\n\n return program.getSourceFiles().flatMap((source) => {\n const file = pathOf(root, resolve(source.fileName));\n if (!file.startsWith('src/') || source.isDeclarationFile) return [];\n const inSrc = (folder: string): boolean => file.startsWith(`src/${folder}/`);\n const found: Finding[] = [];\n const at = (rule: SourceRule | 'data', node: TS.Node, name: string, what = name): void => {\n found.push({ rule, file, line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1, name, what });\n };\n const isTypeOnly = (node: TS.Node): boolean => (ts.isImportClause(node) || ts.isImportSpecifier(node) || ts.isExportDeclaration(node) || ts.isExportSpecifier(node)) && node.isTypeOnly;\n const visit = (node: TS.Node, isType: boolean): void => {\n const isName = ts.isIdentifier(node) || (ts.isStringLiteral(node) && ts.isElementAccessExpression(node.parent) && node.parent.argumentExpression === node);\n const referred = !isType && isName ? referredOf(node) : undefined;\n if (referred !== undefined) {\n if (!inSrc('dev') && referred.getName() === 'Intl' && isLibrary(referred)) at('formatting', node, 'Intl', 'Intl, the global one');\n if (inSrc('server') && referred.getName() === 'roles' && isMoss(referred)) at('roles', node, 'roles', 'roles, read off a moss session');\n if (!inSrc('app') && !inSrc('dev') && isAppFunction(referred, node)) {\n at('data', node, referred.getName(), `${referred.getName()}, a function of ${pathOf(root, resolve(referred.valueDeclaration?.getSourceFile().fileName ?? ''))}`);\n }\n }\n if (!isType && inSrc('ui')) {\n const isLocation = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && typeIs(node, 'Location');\n if (isLocation && !(ts.isExpression(node.parent) && typeIs(node.parent, 'Location'))) at('address', node, 'location', `location, as ${node.getText(source)}`);\n if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {\n const { name, expression } = node.expression;\n if (ADDRESS_CHANGE.has(name.text) && typeIs(expression, 'History')) at('address', node, name.text, `${name.text} on a History`);\n if (FIND_ELEMENTS.has(name.text) && typeIs(expression, 'Document')) at('dom', node, name.text, `${name.text} on a Document`);\n }\n }\n ts.forEachChild(node, (child) => visit(child, isType || ts.isTypeNode(node) || isTypeOnly(node)));\n };\n visit(source, false);\n return found;\n });\n};\n","import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\n\nexport type TypeScript = typeof TS;\n\nconst isTypeScript = (value: unknown): value is TypeScript =>\n value !== null && typeof value === 'object' && typeof Reflect.get(value, 'createProgram') === 'function' && typeof Reflect.get(value, 'version') === 'string';\n\n// The app's own compiler, as `nisc build` uses the app's own jsdom: the gate adds no dependency to the cli.\nexport const loadTypeScript = (root: string): TypeScript => {\n const require = createRequire(join(root, 'package.json'));\n let library: unknown;\n try {\n library = require('typescript');\n } catch {\n throw new Error(`the shape check reads the source with TypeScript, and this app has none installed (looked from ${root}). pnpm add -D typescript`);\n }\n if (!isTypeScript(library)) throw new Error('the \"typescript\" this app has installed is not the TypeScript compiler.');\n if (!library.version.startsWith('6.')) throw new Error(`the shape check is written against TypeScript 6, and this app has ${library.version}.`);\n return library;\n};\n","import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\nimport { appDataFindings, programOf } from './app-data';\nimport { referenceFindings } from './references';\nimport { sourceFindings } from './source';\nimport type { Finding } from './source';\nimport { loadTypeScript } from './typescript';\nimport type { TypeScript } from './typescript';\n\nexport type ShapeRule = 'style' | 'formatting' | 'roles' | 'files' | 'address' | 'dom' | 'data';\n\nexport type ShapeAction = { id: string; endpoints?: Readonly<Record<string, unknown>> };\n\nexport type ShapeEntry = { fingerprint: string; refresh?: string; dsl?: unknown; mapping?: unknown };\n\nexport type ShapeCheckConfig = {\n root: string;\n actions: readonly ShapeAction[];\n entries?: readonly ShapeEntry[];\n functions?: Readonly<Record<string, string>>;\n allow?: Readonly<Partial<Record<ShapeRule, Readonly<Record<string, string>>>>>;\n log?: (line: string) => void;\n};\n\nconst RULES: readonly (readonly [rule: ShapeRule, what: string])[] = [\n ['style', 'rule 16: no assertion but \"as const\", no non-null \"!\", no function declaration, class, enum, \"any\" or default export in src/'],\n ['formatting', 'rule 9: no Intl and no toLocale… outside Prism (src/, but src/dev/)'],\n ['roles', 'rule 11: no server code reads the caller’s roles (src/server/)'],\n ['files', 'rule 9a: the kit reads no file into data (src/ui/)'],\n ['address', 'rule 4: the kit neither reads nor changes the address (src/ui/)'],\n ['dom', 'rule 2: no component finds elements in the document (src/ui/)'],\n ['data', 'src/app is data: no code outside it calls a function of it, but the manifest’s factory'],\n];\n\nconst isRecord = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n\nconst endpointsOf = (actions: readonly ShapeAction[]): { action: string; endpoint: Record<string, unknown> }[] =>\n actions.flatMap((action) => Object.values(action.endpoints ?? {}).flatMap((endpoint) => (isRecord(endpoint) ? [{ action: action.id, endpoint }] : [])));\n\nconst replayOf = (endpoint: Record<string, unknown>): { fingerprint?: string } | undefined => {\n const request = endpoint['request'];\n if (!isRecord(request) || !('fingerprint' in request)) return undefined;\n const fingerprint = request['fingerprint'];\n return typeof fingerprint === 'string' ? { fingerprint } : {};\n};\n\nconst messageOf = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\nconst readSource = (root: string): { ts: TypeScript; program: TS.Program; findings: Finding[] } | string => {\n try {\n const ts = loadTypeScript(root);\n const program = programOf(ts, root);\n return { ts, program, findings: [...sourceFindings(ts, root), ...appDataFindings(ts, root, program)] };\n } catch (error) {\n return messageOf(error);\n }\n};\n\nexport const runShapeCheck = (config: ShapeCheckConfig): number => {\n const log = config.log ?? ((line: string) => console.log(line));\n let failures = 0;\n const check = (what: string, passed: boolean, detail: readonly string[] = []): void => {\n log(`${passed ? '[pass]' : '[fail]'} ${what}${passed || detail.length === 0 ? '' : ` — ${detail.join('; ')}`}`);\n if (!passed) failures += 1;\n };\n const done = (): number => {\n log(failures === 0 ? '[pass] shape: all checks passed' : `[fail] shape: ${failures} check(s) failed`);\n return failures === 0 ? 0 : 1;\n };\n\n const read = readSource(config.root);\n if (typeof read === 'string') {\n check('the source is read', false, [read]);\n return done();\n }\n const { findings } = read;\n\n const allow = config.allow ?? {};\n for (const [rule, what] of RULES) {\n const allowed = allow[rule] ?? {};\n const left = findings.filter((finding) => finding.rule === rule && allowed[finding.file] === undefined);\n check(what, left.length === 0, left.map((finding) => `${finding.file}:${finding.line} ${finding.what}`));\n }\n try {\n const failed = new Set(findings.map((finding) => `${finding.rule} ${finding.file} ${finding.name}`));\n const shown = new Set<string>();\n const others = referenceFindings(read.ts, config.root, read.program).filter((finding) => {\n const key = `${finding.rule} ${finding.file} ${finding.name}`;\n if (failed.has(key) || allow[finding.rule]?.[finding.file] !== undefined || shown.has(`${key} ${finding.line}`)) return false;\n shown.add(`${key} ${finding.line}`);\n return true;\n });\n const ruleOf = new Map(RULES.map(([rule, what]) => [rule, what.split(':')[0] ?? what]));\n for (const finding of others) {\n log(`[info] ${ruleOf.get(finding.rule) ?? finding.rule}: ${finding.file}:${finding.line} ${finding.what} — another spelling of what the rule fails on; reported, not failed`);\n }\n } catch (error) {\n log(`[info] what names refer to could not be read, so other spellings are not reported: ${messageOf(error)}`);\n }\n const idle = RULES.flatMap(([rule]) =>\n Object.entries(allow[rule] ?? {}).flatMap(([file, reason]) => {\n if (reason.trim() === '') return [`${rule}: ${file} gives no reason`];\n if (!existsSync(join(config.root, file))) return [`${rule}: ${file} does not exist`];\n return findings.some((finding) => finding.rule === rule && finding.file === file) ? [] : [`${rule}: ${file} has nothing to allow`];\n }),\n );\n check('every allowance names a file there is, why, and something it allows', idle.length === 0, idle);\n\n const endpoints = endpointsOf(config.actions);\n const ledger = config.functions ?? {};\n const called = new Set(endpoints.flatMap(({ endpoint }) => (typeof endpoint['fn'] === 'string' ? [endpoint['fn']] : [])));\n const unexplained = [...called].filter((id) => (ledger[id] ?? '').trim() === '').sort();\n check('every server function an action calls is named in `functions`, with what it does that a vex read or write cannot', unexplained.length === 0, unexplained);\n const uncalled = Object.keys(ledger).filter((id) => !called.has(id)).sort();\n check('every function named in `functions` is called by an action', uncalled.length === 0, uncalled);\n\n const replays = endpoints.flatMap(({ endpoint }) => {\n const replay = replayOf(endpoint);\n return replay === undefined ? [] : [replay];\n });\n const named = new Set(replays.flatMap((replay) => (replay.fingerprint === undefined ? [] : [replay.fingerprint])));\n const reads = (config.entries ?? []).filter((entry) => entry.dsl !== undefined);\n const calls = endpoints.filter(({ endpoint }) => typeof endpoint['fn'] === 'string').length;\n log(`[info] actions call server functions ${calls} times and replay vex ${replays.length} times`);\n log(`[info] ${reads.filter((entry) => entry.mapping !== undefined).length} of ${reads.length} reads word their rows with a Prism mapping`);\n const unnamed = reads.filter((entry) => entry.refresh === 'reactive' && !named.has(entry.fingerprint)).map((entry) => entry.fingerprint);\n if (unnamed.length > 0) log(`[info] reactive reads no action replays by name: ${unnamed.join(', ')}`);\n return done();\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niscorp/cli",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "nisc — the command for a nisc application: dev, build, export, start. One config file says how the app boots and how its pages are drawn; the command does the rest.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -49,8 +49,8 @@
49
49
  "node": ">=22.12"
50
50
  },
51
51
  "peerDependencies": {
52
- "@niscorp/moss": "^0.9.0",
53
- "@niscorp/nova": "^0.5.1"
52
+ "@niscorp/moss": "^0.10.0",
53
+ "@niscorp/nova": "^0.6.0"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@niscorp/moss": {
@@ -70,9 +70,9 @@
70
70
  "typescript": "^6.0.2",
71
71
  "vite": "^7.1.12",
72
72
  "vitest": "^4.1.2",
73
- "@niscorp/moss": "^0.9.0",
74
- "@niscorp/nova": "^0.5.1",
75
- "@niscorp/vex": "^0.4.3"
73
+ "@niscorp/moss": "^0.10.0",
74
+ "@niscorp/vex": "^0.5.0",
75
+ "@niscorp/nova": "^0.6.0"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "tsup",