@mesofact/runtime 0.8.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/adapters/r2.d.ts +24 -0
- package/dist/adapters/r2.d.ts.map +1 -0
- package/dist/adapters/r2.js +136 -0
- package/dist/adapters/r2.js.map +1 -0
- package/dist/adapters/sqlite.d.ts +25 -0
- package/dist/adapters/sqlite.d.ts.map +1 -0
- package/dist/adapters/sqlite.js +131 -0
- package/dist/adapters/sqlite.js.map +1 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +139 -0
- package/dist/config.js.map +1 -0
- package/dist/contract.d.ts +40 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +5 -0
- package/dist/contract.js.map +1 -0
- package/dist/errors.d.ts +29 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +40 -0
- package/dist/errors.js.map +1 -0
- package/dist/head.d.ts +32 -0
- package/dist/head.d.ts.map +1 -0
- package/dist/head.js +93 -0
- package/dist/head.js.map +1 -0
- package/dist/health.d.ts +14 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +85 -0
- package/dist/health.js.map +1 -0
- package/dist/hooks.d.ts +28 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +64 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hydration.d.ts +6 -0
- package/dist/hydration.d.ts.map +1 -0
- package/dist/hydration.js +68 -0
- package/dist/hydration.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +68 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +9 -0
- package/dist/manifest.js.map +1 -0
- package/dist/routes.d.ts +67 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +130 -0
- package/dist/routes.js.map +1 -0
- package/dist/source.d.ts +36 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +52 -0
- package/dist/source.js.map +1 -0
- package/dist/track-ctx.d.ts +13 -0
- package/dist/track-ctx.d.ts.map +1 -0
- package/dist/track-ctx.js +15 -0
- package/dist/track-ctx.js.map +1 -0
- package/dist/validate.d.ts +20 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +333 -0
- package/dist/validate.js.map +1 -0
- package/package.json +40 -0
- package/src/adapters/r2.ts +163 -0
- package/src/adapters/sqlite.ts +182 -0
- package/src/config.ts +213 -0
- package/src/contract.ts +82 -0
- package/src/errors.ts +52 -0
- package/src/head.ts +130 -0
- package/src/health.ts +99 -0
- package/src/hooks.ts +72 -0
- package/src/hydration.ts +72 -0
- package/src/index.ts +113 -0
- package/src/manifest.ts +104 -0
- package/src/routes.ts +320 -0
- package/src/source.ts +91 -0
- package/src/track-ctx.ts +29 -0
- package/src/validate.ts +388 -0
package/dist/routes.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type HooksConfig } from "./hooks.js";
|
|
2
|
+
export type RouteMode = "static" | "ssr" | "spa";
|
|
3
|
+
export type Placement = "host" | "edge" | "auto";
|
|
4
|
+
export type Requires = "user" | "project" | "region";
|
|
5
|
+
export type CachePolicyConfig = {
|
|
6
|
+
ttl: number;
|
|
7
|
+
swr?: number;
|
|
8
|
+
negative_ttl?: number;
|
|
9
|
+
vary?: readonly string[];
|
|
10
|
+
};
|
|
11
|
+
export type RetryOn = "connection" | "5xx" | "any";
|
|
12
|
+
export type RetryPolicy = {
|
|
13
|
+
attempts: number;
|
|
14
|
+
backoff_ms: readonly number[];
|
|
15
|
+
retry_on?: RetryOn;
|
|
16
|
+
budget_ms?: number;
|
|
17
|
+
};
|
|
18
|
+
export type QueuePolicy = {
|
|
19
|
+
queue: string;
|
|
20
|
+
ack: "on_enqueue" | "on_origin_2xx";
|
|
21
|
+
max_delay_ms?: number;
|
|
22
|
+
};
|
|
23
|
+
export type ResiliencePolicy = {
|
|
24
|
+
retry?: RetryPolicy;
|
|
25
|
+
queue?: QueuePolicy;
|
|
26
|
+
timeout_ms?: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const DEFAULT_RESILIENCE_TIMEOUT_MS = 30000;
|
|
29
|
+
export type PrerenderConfig = {
|
|
30
|
+
params: ReadonlyArray<Record<string, string>>;
|
|
31
|
+
} | {
|
|
32
|
+
from: string;
|
|
33
|
+
query: string;
|
|
34
|
+
param: string;
|
|
35
|
+
} | {
|
|
36
|
+
from_data: string;
|
|
37
|
+
items_key: string;
|
|
38
|
+
param: string;
|
|
39
|
+
} | {
|
|
40
|
+
deferred: true;
|
|
41
|
+
};
|
|
42
|
+
export type RouteEntry = {
|
|
43
|
+
route: string;
|
|
44
|
+
mode: RouteMode;
|
|
45
|
+
entrypoint: string;
|
|
46
|
+
client_entrypoint?: string;
|
|
47
|
+
requires?: readonly Requires[];
|
|
48
|
+
source_reads?: readonly string[];
|
|
49
|
+
data_inputs?: readonly string[];
|
|
50
|
+
cache_policy: CachePolicyConfig;
|
|
51
|
+
concurrency?: number;
|
|
52
|
+
prerender?: PrerenderConfig;
|
|
53
|
+
placement?: Placement;
|
|
54
|
+
resilience?: ResiliencePolicy;
|
|
55
|
+
};
|
|
56
|
+
export type ErrorRoutes = {
|
|
57
|
+
"404"?: string;
|
|
58
|
+
"5xx"?: string;
|
|
59
|
+
};
|
|
60
|
+
export type RoutesConfig = {
|
|
61
|
+
routes: readonly RouteEntry[];
|
|
62
|
+
error_routes?: ErrorRoutes;
|
|
63
|
+
hooks?: HooksConfig;
|
|
64
|
+
site_url?: string;
|
|
65
|
+
};
|
|
66
|
+
export declare function defineRoutes(config: RoutesConfig): RoutesConfig;
|
|
67
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAiC,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
|
4
|
+
//! @yah:next("W173 lives in the yah parent camp at .yah/docs/working/W173-mesofact-render-cube.md (relative from mesofact root: ../../.yah/docs/working/W173-mesofact-render-cube.md). Read § 'v1 schema delta' and § 'SSR_PREFIXES derivation rule' before T1/T2.")
|
|
5
|
+
//! @yah:next("yah-side consumer relay is R434 in the parent camp — R434-F3 (mesofact-dev SSR subprocess), R434-F4 (pond reconciler ssr_runtime), R434-F5 (first SSR consumer route) all assume this relay ships first.")
|
|
6
|
+
//! @yah:next("Coordinate handoff via @mesofact/runtime version bump: yah-side consumes via packages/yah/workload-spec/index.ts and crates/yah/cloud/src/reconciler/mesofact_static.rs.")
|
|
7
|
+
//! @yah:next("Order: T1 (schema) → T2 (build path) → then T3 + T4 unblock once a real SSR consumer exists on the yah side (R434-F5).")
|
|
8
|
+
//!
|
|
9
|
+
//! @yah:ticket(R015-F1, "Add Placement axis + placement?: field to RouteEntry + defineRoutes validation")
|
|
10
|
+
//! @yah:assignee(agent:claude)
|
|
11
|
+
//! @yah:at(2026-06-04T19:32:10Z)
|
|
12
|
+
//! @yah:status(review)
|
|
13
|
+
//! @yah:phase(P1)
|
|
14
|
+
//! @yah:parent(R015)
|
|
15
|
+
//! @yah:next("Add `export type Placement = \"host\" | \"edge\" | \"auto\"` alongside the existing RouteMode at routes.ts:5.")
|
|
16
|
+
//! @yah:next("Add `placement?: Placement` to RouteEntry. ssr-only — reject (loud, at defineRoutes call site) on any non-\"ssr\" mode. Default \"auto\" → \"host\" today (auto-classifier deferred per W173).")
|
|
17
|
+
//! @yah:next("RouteMode \"ssr\" slot already exists in this file — do NOT regress it. Do not remove or rename existing fields (requires, source_reads, concurrency, prerender, cache_policy.negative_ttl/vary).")
|
|
18
|
+
//! @yah:next("Add a unit test that defineRoutes throws when placement is set on a static or spa route.")
|
|
19
|
+
//! @yah:next("Place where the build classifier eventually slots in: comment that `placement: \"auto\"` resolves to \"host\" until the auto-classifier (W173 § 'Future auto-classifier criteria') lands.")
|
|
20
|
+
//! @yah:verify("defineRoutes accepts every existing yah-side routes file (../../app/yah/web/marketing/mesofact.routes.ts and ../../app/yah/web/dashboard/mesofact.routes.ts) unchanged")
|
|
21
|
+
//! @yah:verify("defineRoutes throws on `mode:\"static\", placement:\"host\"` etc.")
|
|
22
|
+
//! @yah:verify("bun test passes for the new placement validation cases")
|
|
23
|
+
//! @yah:handoff("Placement axis shipped. Changes to packages/mesofact-runtime/src/routes.ts: added `export type Placement = \"host\" | \"edge\" | \"auto\"`; added `placement?: Placement` to RouteEntry; defineRoutes now throws when placement is set on a non-ssr route (loud, names the offending route, default left undefined — auto-resolution happens at build time per W173). Exported Placement from src/index.ts. New tests/routes.test.ts covers 8 cases (ssr+host/edge/auto/undefined accepted; static+placement and spa+placement rejected; error message names route; mixed-mode workload accepted). Verified: bun test → 57 pass across 7 files; tsc --noEmit clean for runtime + build + worker; existing yah-side route files (marketing 5, dashboard 7, yah-dev 3) still parse unchanged.")
|
|
24
|
+
//! @yah:verify("cd packages/mesofact-runtime && bun test — 57 pass")
|
|
25
|
+
//! @yah:verify("cd packages/mesofact-runtime && bun run typecheck — clean")
|
|
26
|
+
//! @yah:verify("cd packages/mesofact-build && bun run typecheck — clean")
|
|
27
|
+
//! @yah:verify("cd packages/mesofact-worker && bun run typecheck — clean")
|
|
28
|
+
// `mesofact.routes.ts` — user-authored route table. Build phase 2 reads this,
|
|
29
|
+
// phase 3 infers `source_reads`, phase 4 validates, phase 6 emits the manifest.
|
|
30
|
+
// See `.yah/docs/architecture/mesofact.md` §"Build pipeline".
|
|
31
|
+
import { HOOK_NAMES, HOOK_ROUTE_CLAIMS, isHookName } from "./hooks.js";
|
|
32
|
+
// Default per-attempt timeout used when `resilience.timeout_ms` is omitted.
|
|
33
|
+
export const DEFAULT_RESILIENCE_TIMEOUT_MS = 30_000;
|
|
34
|
+
export function defineRoutes(config) {
|
|
35
|
+
if (config.site_url !== undefined && !/^https?:\/\/[^/]+/.test(config.site_url)) {
|
|
36
|
+
throw new Error(`defineRoutes: site_url=${JSON.stringify(config.site_url)} must be an absolute origin like "https://yah.dev" (scheme + host, no trailing path) — the sitemap emitter joins it with each route's path`);
|
|
37
|
+
}
|
|
38
|
+
for (const r of config.routes) {
|
|
39
|
+
if (r.placement !== undefined && r.mode !== "ssr") {
|
|
40
|
+
throw new Error(`defineRoutes: route ${r.route} has placement=${JSON.stringify(r.placement)} but mode=${JSON.stringify(r.mode)}; placement is only valid on mode:"ssr"`);
|
|
41
|
+
}
|
|
42
|
+
if (r.prerender && "from_data" in r.prerender) {
|
|
43
|
+
const declared = r.data_inputs ?? [];
|
|
44
|
+
if (!declared.includes(r.prerender.from_data)) {
|
|
45
|
+
throw new Error(`defineRoutes: route ${r.route} has prerender.from_data=${JSON.stringify(r.prerender.from_data)} but that path is not in data_inputs (${JSON.stringify(declared)}); declare the file in data_inputs first so the build reads it once`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (r.prerender && "deferred" in r.prerender) {
|
|
49
|
+
if (r.prerender.deferred !== true) {
|
|
50
|
+
throw new Error(`defineRoutes: route ${r.route} has prerender.deferred=${JSON.stringify(r.prerender.deferred)} — omit prerender (render once at build) or set deferred: true`);
|
|
51
|
+
}
|
|
52
|
+
if (r.mode !== "static") {
|
|
53
|
+
throw new Error(`defineRoutes: route ${r.route} has prerender.deferred but mode=${JSON.stringify(r.mode)}; deferred (publish-time) params are only valid on mode:"static" — ssr renders per request, spa shells are not instance-addressed`);
|
|
54
|
+
}
|
|
55
|
+
if (!r.route.includes(":")) {
|
|
56
|
+
throw new Error(`defineRoutes: route ${r.route} has prerender.deferred but no ":param" segment — a literal route has exactly one instance, rendered at build`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (r.resilience !== undefined)
|
|
60
|
+
validateResilience(r);
|
|
61
|
+
}
|
|
62
|
+
if (config.hooks !== undefined)
|
|
63
|
+
validateHooks(config);
|
|
64
|
+
return config;
|
|
65
|
+
}
|
|
66
|
+
// Mode 2 hook declaration (R756-F6). Same fail-fast home as placement and
|
|
67
|
+
// resilience: throw at config import, before any bundling work.
|
|
68
|
+
function validateHooks(config) {
|
|
69
|
+
const hooks = config.hooks;
|
|
70
|
+
for (const [name, entrypoint] of Object.entries(hooks)) {
|
|
71
|
+
if (!isHookName(name)) {
|
|
72
|
+
throw new Error(`defineRoutes: unknown hook ${JSON.stringify(name)} — known hooks are ${HOOK_NAMES.map((h) => JSON.stringify(h)).join(", ")}. A hook name is engine-defined: only mesofact invokes hooks, so a name it ` +
|
|
73
|
+
`does not know would never be called.`);
|
|
74
|
+
}
|
|
75
|
+
if (typeof entrypoint !== "string" || entrypoint.trim() === "") {
|
|
76
|
+
throw new Error(`defineRoutes: hooks.${name}=${JSON.stringify(entrypoint)} must be a non-empty entrypoint ` +
|
|
77
|
+
`path relative to the project root (e.g. "src/${name}.ts")`);
|
|
78
|
+
}
|
|
79
|
+
const claimed = HOOK_ROUTE_CLAIMS[name];
|
|
80
|
+
if (claimed !== undefined && config.routes.some((r) => r.route === claimed)) {
|
|
81
|
+
throw new Error(`defineRoutes: hook ${JSON.stringify(name)} is declared twice — as hooks.${name} and by ` +
|
|
82
|
+
`claiming the route ${JSON.stringify(claimed)}. Both mean "this app contributes a ` +
|
|
83
|
+
`${name} verdict"; pick one. The hooks declaration is usually the one you want — the ` +
|
|
84
|
+
`module stays out of ssr_prefixes, so the edge never forwards ${claimed} to the SSR ` +
|
|
85
|
+
`origin and the Rust probe route never shadows it.`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const RETRY_ON = new Set(["connection", "5xx", "any"]);
|
|
90
|
+
// W181 validation rules. Throws at defineRoutes time (fail fast at config
|
|
91
|
+
// import, before any bundling work — same home as placement rejection).
|
|
92
|
+
function validateResilience(r) {
|
|
93
|
+
const res = r.resilience;
|
|
94
|
+
if (r.mode !== "ssr") {
|
|
95
|
+
throw new Error(`defineRoutes: route ${r.route} declares resilience but mode=${JSON.stringify(r.mode)}; resilience is only valid on mode:"ssr" (the policy wraps the edge→origin proxy hop, which only exists for SSR routes)`);
|
|
96
|
+
}
|
|
97
|
+
if (r.placement === "edge") {
|
|
98
|
+
throw new Error(`defineRoutes: route ${r.route} declares resilience on placement:"edge" — retrying the Worker from the Worker is circular (W181 OQ1); remove the block or use placement:"host"`);
|
|
99
|
+
}
|
|
100
|
+
if (res.queue !== undefined) {
|
|
101
|
+
throw new Error(`defineRoutes: route ${r.route} declares resilience.queue — queue policy is reserved for v2 and not implemented yet (W181 § "v1 scope"); remove the block (the type slot exists so v1 routes won't break when v2 lands)`);
|
|
102
|
+
}
|
|
103
|
+
if (res.timeout_ms !== undefined && (!Number.isFinite(res.timeout_ms) || res.timeout_ms <= 0)) {
|
|
104
|
+
throw new Error(`defineRoutes: route ${r.route} has resilience.timeout_ms=${String(res.timeout_ms)}; expected a positive number of milliseconds`);
|
|
105
|
+
}
|
|
106
|
+
const retry = res.retry;
|
|
107
|
+
if (retry === undefined)
|
|
108
|
+
return;
|
|
109
|
+
if (!Number.isInteger(retry.attempts) || retry.attempts < 1) {
|
|
110
|
+
throw new Error(`defineRoutes: route ${r.route} has resilience.retry.attempts=${String(retry.attempts)}; expected an integer >= 1 (1 = no retry)`);
|
|
111
|
+
}
|
|
112
|
+
if (!Array.isArray(retry.backoff_ms) || retry.backoff_ms.length !== retry.attempts - 1) {
|
|
113
|
+
throw new Error(`defineRoutes: route ${r.route} has resilience.retry.backoff_ms of length ${Array.isArray(retry.backoff_ms) ? retry.backoff_ms.length : "?"}; expected attempts - 1 = ${retry.attempts - 1} entries (one gap between each pair of attempts)`);
|
|
114
|
+
}
|
|
115
|
+
if (retry.backoff_ms.some((b) => !Number.isFinite(b) || b < 0)) {
|
|
116
|
+
throw new Error(`defineRoutes: route ${r.route} has a negative or non-numeric resilience.retry.backoff_ms entry`);
|
|
117
|
+
}
|
|
118
|
+
if (retry.retry_on !== undefined && !RETRY_ON.has(retry.retry_on)) {
|
|
119
|
+
throw new Error(`defineRoutes: route ${r.route} has resilience.retry.retry_on=${JSON.stringify(retry.retry_on)}; expected "connection" | "5xx" | "any"`);
|
|
120
|
+
}
|
|
121
|
+
if (retry.budget_ms !== undefined) {
|
|
122
|
+
const perAttempt = res.timeout_ms ?? DEFAULT_RESILIENCE_TIMEOUT_MS;
|
|
123
|
+
const backoffSum = retry.backoff_ms.reduce((a, b) => a + b, 0);
|
|
124
|
+
const floor = backoffSum + retry.attempts * perAttempt;
|
|
125
|
+
if (retry.budget_ms < floor) {
|
|
126
|
+
throw new Error(`defineRoutes: route ${r.route} has resilience.retry.budget_ms=${retry.budget_ms} < ${floor} (sum(backoff_ms)=${backoffSum} + attempts=${retry.attempts} × per-attempt timeout=${perAttempt}); raise budget_ms or lower the attempt/timeout shape`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,iCAAiC;AACjC,qBAAqB;AACrB,qQAAqQ;AACrQ,yNAAyN;AACzN,yLAAyL;AACzL,uIAAuI;AACvI,GAAG;AACH,0GAA0G;AAC1G,+BAA+B;AAC/B,iCAAiC;AACjC,uBAAuB;AACvB,kBAAkB;AAClB,qBAAqB;AACrB,8HAA8H;AAC9H,+MAA+M;AAC/M,kNAAkN;AAClN,yGAAyG;AACzG,0MAA0M;AAC1M,yLAAyL;AACzL,oFAAoF;AACpF,yEAAyE;AACzE,+wBAA+wB;AAC/wB,qEAAqE;AACrE,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAE3E,8EAA8E;AAC9E,gFAAgF;AAChF,8DAA8D;AAE9D,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAoB,UAAU,EAAE,MAAM,YAAY,CAAC;AAyDzF,4EAA4E;AAC5E,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC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or?: string;
|
|
4
|
+
delimiter?: string;
|
|
5
|
+
};
|
|
6
|
+
export type R2Object = {
|
|
7
|
+
key: string;
|
|
8
|
+
size: number;
|
|
9
|
+
last_modified: string;
|
|
10
|
+
etag?: string;
|
|
11
|
+
};
|
|
12
|
+
export interface Source {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
noTrack(): this;
|
|
15
|
+
timeout(ms: number): this;
|
|
16
|
+
}
|
|
17
|
+
export interface BlobSource extends Source {
|
|
18
|
+
fetch(key: string): Promise<Uint8Array | null>;
|
|
19
|
+
list(prefix: string, opts?: ListOpts): Promise<R2Object[]>;
|
|
20
|
+
}
|
|
21
|
+
export interface KeyValueSource extends Source {
|
|
22
|
+
get<T>(table: string, id: string): Promise<T | null>;
|
|
23
|
+
query<T>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
24
|
+
}
|
|
25
|
+
export declare abstract class BaseSource implements Source {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
constructor(name: string);
|
|
28
|
+
noTrack(): this;
|
|
29
|
+
timeout(ms: number): this;
|
|
30
|
+
protected consumeOverrides(defaultTimeoutMs: number): {
|
|
31
|
+
track: boolean;
|
|
32
|
+
timeout_ms: number;
|
|
33
|
+
};
|
|
34
|
+
protected emitTag(tag: string, track: boolean): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAGF,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAItB,OAAO,IAAI,IAAI,CAAC;IAIhB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAGD,MAAM,WAAW,UAAW,SAAQ,MAAM;IACxC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC/C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;CAC5D;AAGD,MAAM,WAAW,cAAe,SAAQ,MAAM;IAC5C,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACrD,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;CACzD;AAID,8BAAsB,UAAW,YAAW,MAAM;aACpB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;IAExC,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAUzB,SAAS,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG;QACpD,KAAK,EAAE,OAAO,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB;IAcD,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;CAIrD"}
|
package/dist/source.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Adapter API surface. Read-only by design — mesofact has no write API.
|
|
2
|
+
// See `.yah/docs/architecture/mesofact.md` §"Adapter API surface".
|
|
3
|
+
//
|
|
4
|
+
// The design doc lists `get`/`query`/`fetch`/`list` on a single interface with
|
|
5
|
+
// per-backend annotations. We split them into BlobSource (r2) and
|
|
6
|
+
// KeyValueSource (sqlite/pg) so callers get type-safety on what they hold:
|
|
7
|
+
// `r2('assets').get(...)` is a type error, not a runtime trap.
|
|
8
|
+
import { currentTrackCtx } from "./track-ctx.js";
|
|
9
|
+
// Shared impl for `.noTrack()` / `.timeout(ms)` and tag emission. Adapters
|
|
10
|
+
// extend this and implement the read methods their backend supports.
|
|
11
|
+
export class BaseSource {
|
|
12
|
+
name;
|
|
13
|
+
constructor(name) {
|
|
14
|
+
this.name = name;
|
|
15
|
+
}
|
|
16
|
+
noTrack() {
|
|
17
|
+
const ctx = currentTrackCtx();
|
|
18
|
+
if (ctx)
|
|
19
|
+
ctx.next.track = false;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
timeout(ms) {
|
|
23
|
+
const ctx = currentTrackCtx();
|
|
24
|
+
if (ctx)
|
|
25
|
+
ctx.next.timeout_ms = ms;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
// Consume per-call overrides applied by the most recent `.noTrack()` /
|
|
29
|
+
// `.timeout(ms)` and return the effective settings for a single read. The
|
|
30
|
+
// override slot resets after this call, so two chained reads only carry the
|
|
31
|
+
// override on the first.
|
|
32
|
+
consumeOverrides(defaultTimeoutMs) {
|
|
33
|
+
const ctx = currentTrackCtx();
|
|
34
|
+
if (!ctx)
|
|
35
|
+
return { track: true, timeout_ms: defaultTimeoutMs };
|
|
36
|
+
const effective = {
|
|
37
|
+
track: ctx.next.track,
|
|
38
|
+
timeout_ms: ctx.next.timeout_ms ?? defaultTimeoutMs,
|
|
39
|
+
};
|
|
40
|
+
ctx.next = { track: true };
|
|
41
|
+
return effective;
|
|
42
|
+
}
|
|
43
|
+
// Add a read-set tag to the ambient trackCtx, unless tracking was disabled
|
|
44
|
+
// for this call or there is no ctx (e.g. test harness running render outside
|
|
45
|
+
// `runInTrackCtx`).
|
|
46
|
+
emitTag(tag, track) {
|
|
47
|
+
if (!track)
|
|
48
|
+
return;
|
|
49
|
+
currentTrackCtx()?.tags.add(tag);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,mEAAmE;AACnE,EAAE;AACF,+EAA+E;AAC/E,kEAAkE;AAClE,2EAA2E;AAC3E,+DAA+D;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAwCjD,2EAA2E;AAC3E,qEAAqE;AACrE,MAAM,OAAgB,UAAU;IACF;IAA5B,YAA4B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAE5C,OAAO;QACL,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC;QAC9B,IAAI,GAAG;YAAE,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC;QAC9B,IAAI,GAAG;YAAE,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,uEAAuE;IACvE,0EAA0E;IAC1E,4EAA4E;IAC5E,yBAAyB;IACf,gBAAgB,CAAC,gBAAwB;QAIjD,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC;QAC9B,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;QAC/D,MAAM,SAAS,GAAG;YAChB,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK;YACrB,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,gBAAgB;SACpD,CAAC;QACF,GAAG,CAAC,IAAI,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,2EAA2E;IAC3E,6EAA6E;IAC7E,oBAAoB;IACV,OAAO,CAAC,GAAW,EAAE,KAAc;QAC3C,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,eAAe,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type TrackCtx = {
|
|
2
|
+
readonly tags: Set<string>;
|
|
3
|
+
next: {
|
|
4
|
+
track: boolean;
|
|
5
|
+
timeout_ms?: number;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function runInTrackCtx<T>(fn: () => Promise<T>): Promise<{
|
|
9
|
+
value: T;
|
|
10
|
+
ctx: TrackCtx;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function currentTrackCtx(): TrackCtx | undefined;
|
|
13
|
+
//# sourceMappingURL=track-ctx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-ctx.d.ts","sourceRoot":"","sources":["../src/track-ctx.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAI3B,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAIF,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,GAAG,EAAE,QAAQ,CAAA;CAAE,CAAC,CAG3F;AAED,wBAAgB,eAAe,IAAI,QAAQ,GAAG,SAAS,CAEtD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Per-render ambient context. Adapters in this package read it to register
|
|
2
|
+
// read-set tags and honor `.noTrack()` / `.timeout(ms)` overrides. The worker
|
|
3
|
+
// re-exports it for backward compatibility with R005's surface.
|
|
4
|
+
//
|
|
5
|
+
// See `.yah/docs/architecture/mesofact.md` §"Adapter read-set provenance".
|
|
6
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
|
+
const storage = new AsyncLocalStorage();
|
|
8
|
+
export function runInTrackCtx(fn) {
|
|
9
|
+
const ctx = { tags: new Set(), next: { track: true } };
|
|
10
|
+
return storage.run(ctx, async () => ({ value: await fn(), ctx }));
|
|
11
|
+
}
|
|
12
|
+
export function currentTrackCtx() {
|
|
13
|
+
return storage.getStore();
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=track-ctx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track-ctx.js","sourceRoot":"","sources":["../src/track-ctx.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,8EAA8E;AAC9E,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAE3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAarD,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAY,CAAC;AAElD,MAAM,UAAU,aAAa,CAAI,EAAoB;IACnD,MAAM,GAAG,GAAa,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;IACjE,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Manifest } from "./manifest.js";
|
|
2
|
+
export type SourceScope = "global" | "project" | "user";
|
|
3
|
+
export type SourceCatalog = Record<string, {
|
|
4
|
+
scope: SourceScope;
|
|
5
|
+
}>;
|
|
6
|
+
export type ValidationErrorKind = "shape" | "unsupported_version" | "mode1_scoped_source" | "mode1_requires_user" | "unknown_hook";
|
|
7
|
+
export type ValidationError = {
|
|
8
|
+
kind: ValidationErrorKind;
|
|
9
|
+
path: string;
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
export type ValidationResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
manifest: Manifest;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
errors: ValidationError[];
|
|
18
|
+
};
|
|
19
|
+
export declare function validate(input: unknown, catalog?: SourceCatalog): ValidationResult;
|
|
20
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,QAAQ,EAKT,MAAM,eAAe,CAAC;AAIvB,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AAEnE,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,qBAAqB,GACrB,qBAAqB,GACrB,qBAAqB,GAKrB,cAAc,CAAC;AAEnB,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAChC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AAkR7C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,aAAkB,GAAG,gBAAgB,CAoEtF"}
|