@fougere/core 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/binding.d.ts +63 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/binding.js +107 -0
- package/dist/binding.js.map +1 -0
- package/dist/boot.d.ts +38 -0
- package/dist/boot.d.ts.map +1 -0
- package/dist/boot.js +53 -0
- package/dist/boot.js.map +1 -0
- package/dist/bootstrap.d.ts +4 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +825 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/builtins/config.d.ts +4 -0
- package/dist/builtins/config.d.ts.map +1 -0
- package/dist/builtins/config.js +6 -0
- package/dist/builtins/config.js.map +1 -0
- package/dist/builtins/logger.d.ts +28 -0
- package/dist/builtins/logger.d.ts.map +1 -0
- package/dist/builtins/logger.js +76 -0
- package/dist/builtins/logger.js.map +1 -0
- package/dist/call.d.ts +172 -0
- package/dist/call.d.ts.map +1 -0
- package/dist/call.js +209 -0
- package/dist/call.js.map +1 -0
- package/dist/collector.d.ts +28 -0
- package/dist/collector.d.ts.map +1 -0
- package/dist/collector.js +32 -0
- package/dist/collector.js.map +1 -0
- package/dist/config-loader.d.ts +59 -0
- package/dist/config-loader.d.ts.map +1 -0
- package/dist/config-loader.js +97 -0
- package/dist/config-loader.js.map +1 -0
- package/dist/contract.d.ts +43 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +29 -0
- package/dist/contract.js.map +1 -0
- package/dist/crud.d.ts +61 -0
- package/dist/crud.d.ts.map +1 -0
- package/dist/crud.js +85 -0
- package/dist/crud.js.map +1 -0
- package/dist/define.d.ts +8 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +9 -0
- package/dist/define.js.map +1 -0
- package/dist/egress.d.ts +78 -0
- package/dist/egress.d.ts.map +1 -0
- package/dist/egress.js +185 -0
- package/dist/egress.js.map +1 -0
- package/dist/emit.d.ts +51 -0
- package/dist/emit.d.ts.map +1 -0
- package/dist/emit.js +57 -0
- package/dist/emit.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +74 -0
- package/dist/errors.js.map +1 -0
- package/dist/frond-config.d.ts +80 -0
- package/dist/frond-config.d.ts.map +1 -0
- package/dist/frond-config.js +32 -0
- package/dist/frond-config.js.map +1 -0
- package/dist/graph.d.ts +33 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +142 -0
- package/dist/graph.js.map +1 -0
- package/dist/handler-parser.d.ts +82 -0
- package/dist/handler-parser.d.ts.map +1 -0
- package/dist/handler-parser.js +505 -0
- package/dist/handler-parser.js.map +1 -0
- package/dist/imports.d.ts +22 -0
- package/dist/imports.d.ts.map +1 -0
- package/dist/imports.js +80 -0
- package/dist/imports.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/invocation.d.ts +20 -0
- package/dist/invocation.d.ts.map +1 -0
- package/dist/invocation.js +15 -0
- package/dist/invocation.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +15 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +29 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/logger.d.ts +14 -0
- package/dist/middleware/logger.d.ts.map +1 -0
- package/dist/middleware/logger.js +25 -0
- package/dist/middleware/logger.js.map +1 -0
- package/dist/middleware.d.ts +75 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +89 -0
- package/dist/middleware.js.map +1 -0
- package/dist/operation.d.ts +87 -0
- package/dist/operation.d.ts.map +1 -0
- package/dist/operation.js +95 -0
- package/dist/operation.js.map +1 -0
- package/dist/orm.d.ts +96 -0
- package/dist/orm.d.ts.map +1 -0
- package/dist/orm.js +33 -0
- package/dist/orm.js.map +1 -0
- package/dist/presenter.d.ts +63 -0
- package/dist/presenter.d.ts.map +1 -0
- package/dist/presenter.js +72 -0
- package/dist/presenter.js.map +1 -0
- package/dist/remote.d.ts +48 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +135 -0
- package/dist/remote.js.map +1 -0
- package/dist/repository.d.ts +55 -0
- package/dist/repository.d.ts.map +1 -0
- package/dist/repository.js +26 -0
- package/dist/repository.js.map +1 -0
- package/dist/scan-cache.d.ts +10 -0
- package/dist/scan-cache.d.ts.map +1 -0
- package/dist/scan-cache.js +92 -0
- package/dist/scan-cache.js.map +1 -0
- package/dist/scanner.d.ts +34 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +595 -0
- package/dist/scanner.js.map +1 -0
- package/dist/seed.d.ts +28 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +110 -0
- package/dist/seed.js.map +1 -0
- package/dist/types.d.ts +387 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/verify.d.ts +57 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +147 -0
- package/dist/verify.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scan cache — caches parse results per file.
|
|
3
|
+
*
|
|
4
|
+
* Stores in .fougere/scan-cache.json.
|
|
5
|
+
* Key: cache key (file path + suffix) → { hash, data }.
|
|
6
|
+
* Hash: content hash of the source file.
|
|
7
|
+
* If hash matches, skip parsing entirely → TypeScript never loaded.
|
|
8
|
+
*
|
|
9
|
+
* The envelope carries PARSER_VERSION, and a mismatch drops the whole file. The hash
|
|
10
|
+
* answers "did this source change?"; it cannot answer "does the parser still read it the
|
|
11
|
+
* same way?". A parser fix therefore left every unchanged handler serving the OLD parse,
|
|
12
|
+
* indefinitely and without a word — that is how `Crud`'s inherited ops stayed silently
|
|
13
|
+
* underived for weeks, until someone deleted `.fougere/` by hand and the tests went red.
|
|
14
|
+
*
|
|
15
|
+
* Bump PARSER_VERSION whenever the parser's OUTPUT for unchanged source can differ.
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from 'node:crypto';
|
|
18
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
19
|
+
import { join } from 'node:path';
|
|
20
|
+
/**
|
|
21
|
+
* Bump when the parser can read unchanged source differently.
|
|
22
|
+
*
|
|
23
|
+
* 2 — `handler-parser` unwraps a class returned through a call/assertion, so a mixin
|
|
24
|
+
* like `asCrudConstructor(class { … })` yields its methods again.
|
|
25
|
+
* 3 — parsed array types carry `arrayDepth`, used to distinguish a presenter page
|
|
26
|
+
* returning scalar fields from one returning list fields.
|
|
27
|
+
*/
|
|
28
|
+
// 4 — the parse became a pair (methods + unresolvedHeritage); a v3 entry
|
|
29
|
+
// would answer with an array and lose the half that reports what it could not open.
|
|
30
|
+
const PARSER_VERSION = 4;
|
|
31
|
+
let root = process.cwd();
|
|
32
|
+
let cache = null;
|
|
33
|
+
let dirty = false;
|
|
34
|
+
function cachePath() {
|
|
35
|
+
return join(root, '.fougere', 'scan-cache.json');
|
|
36
|
+
}
|
|
37
|
+
export function setCacheRoot(dir) {
|
|
38
|
+
root = dir;
|
|
39
|
+
cache = null;
|
|
40
|
+
}
|
|
41
|
+
function load() {
|
|
42
|
+
if (cache)
|
|
43
|
+
return cache;
|
|
44
|
+
const path = cachePath();
|
|
45
|
+
if (existsSync(path)) {
|
|
46
|
+
try {
|
|
47
|
+
const file = JSON.parse(readFileSync(path, 'utf-8'));
|
|
48
|
+
// A stamp from another parser is not stale data to refresh entry by entry — every
|
|
49
|
+
// entry in the file was produced by it. Drop the lot; the next scan is cold once.
|
|
50
|
+
if (file.parser === PARSER_VERSION && file.entries) {
|
|
51
|
+
cache = file.entries;
|
|
52
|
+
return cache;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Corrupted cache — start fresh
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
cache = {};
|
|
60
|
+
return cache;
|
|
61
|
+
}
|
|
62
|
+
export function hashFile(filePath) {
|
|
63
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
64
|
+
return createHash('sha1').update(content).digest('hex').slice(0, 16);
|
|
65
|
+
}
|
|
66
|
+
/** Get cached parse result. Returns null if cache miss. */
|
|
67
|
+
export function getCached(key, hash) {
|
|
68
|
+
const data = load();
|
|
69
|
+
const entry = data[key];
|
|
70
|
+
if (entry && entry.hash === hash)
|
|
71
|
+
return entry.data;
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/** Store parse result in cache. */
|
|
75
|
+
export function setCached(key, hash, data) {
|
|
76
|
+
const store = load();
|
|
77
|
+
store[key] = { hash, data };
|
|
78
|
+
dirty = true;
|
|
79
|
+
}
|
|
80
|
+
// Legacy aliases — used by existing callers
|
|
81
|
+
export { getCached as getCachedMethods, setCached as setCachedMethods };
|
|
82
|
+
/** Write cache to disk if modified. */
|
|
83
|
+
export function flushCache() {
|
|
84
|
+
if (!dirty || !cache)
|
|
85
|
+
return;
|
|
86
|
+
const path = cachePath();
|
|
87
|
+
mkdirSync(join(root, '.fougere'), { recursive: true });
|
|
88
|
+
const file = { parser: PARSER_VERSION, entries: cache };
|
|
89
|
+
writeFileSync(path, JSON.stringify(file, null, 2));
|
|
90
|
+
dirty = false;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=scan-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-cache.js","sourceRoot":"","sources":["../src/scan-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,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
|
3
|
+
export type ModuleLoader = (filePath: string) => Promise<Record<string, unknown>>;
|
|
4
|
+
/** Override the module loader used by the scanner (e.g. for jiti/tsx support). */
|
|
5
|
+
export declare function setModuleLoader(loader: ModuleLoader): void;
|
|
6
|
+
/** Used by config-loader to load fougere.config.ts via the same TS-aware loader. */
|
|
7
|
+
export declare function getModuleLoader(): ModuleLoader;
|
|
8
|
+
/**
|
|
9
|
+
* The frond vocabulary — every directory {@link scanFrond} reads. A frond directory says
|
|
10
|
+
* nothing else, which is why this list is what a reader needs to bound one: the Nuxt
|
|
11
|
+
* module watches these for the root frond (watching the root itself would match every
|
|
12
|
+
* write), and a flat app's tsconfig lists them instead of `["."]`, which would swallow
|
|
13
|
+
* `app/` and `nuxt.config.ts`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const FROND_DIRS: readonly ["entities", "handlers", "presenters", "collectors", "seeds", "services", "repositories"];
|
|
16
|
+
export { toRegistrationName } from './contract.js';
|
|
17
|
+
/**
|
|
18
|
+
* `@frond/<name>` → the directory it names, for every frond of a project.
|
|
19
|
+
*
|
|
20
|
+
* The framework states this convention — `FrondSource.package` has always spelled it, and
|
|
21
|
+
* `fougere sync` writes it into a consumer's tsconfig — and until now its own reader could
|
|
22
|
+
* not resolve it. The Nuxt module registered a Vite alias, so a `.vue` page could import
|
|
23
|
+
* `@frond/blog/entities/Post`, while the SCAN loaded sources through a bare jiti: a frond
|
|
24
|
+
* naming its neighbour got `Cannot find module '@frond/user/entities/User.js'`. So the one
|
|
25
|
+
* form that survives a split was the one form that did not run.
|
|
26
|
+
*
|
|
27
|
+
* Hand it to the module loader — `createJiti(url, { alias: await frondAliases(root) })` —
|
|
28
|
+
* and the named form resolves everywhere the framework reads. A directory listing and a
|
|
29
|
+
* `package.json` read, no parsing: it is deliberately callable BEFORE the loader exists,
|
|
30
|
+
* which is what makes the chicken-and-egg go away.
|
|
31
|
+
*/
|
|
32
|
+
export declare function frondAliases(root: string): Promise<Record<string, string>>;
|
|
33
|
+
export declare function scanProject(root: string, filter?: string[]): Promise<ScanResult>;
|
|
34
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAwG,UAAU,EAAkB,MAAM,YAAY,CAAC;AAanK,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAOlF,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAE1D;AAED,oFAAoF;AACpF,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AA6FD;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,oGAEb,CAAC;AAEX,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAgcnD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsChF;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAgCtF"}
|