@ketvietlab/ketjs 0.1.2 → 0.1.5
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 +1 -1
- package/README.md +8 -2
- package/dist/agent/capabilities.d.ts +1 -3
- package/dist/agent/capabilities.d.ts.map +1 -1
- package/dist/agent/capabilities.js +10 -1
- package/dist/agent/capabilities.js.map +1 -1
- package/dist/agent/permissions.d.ts +43 -1
- package/dist/agent/permissions.d.ts.map +1 -1
- package/dist/agent/permissions.js +50 -2
- package/dist/agent/permissions.js.map +1 -1
- package/dist/cli.js +246 -97
- package/dist/cli.js.map +1 -1
- package/dist/codegen/dts.d.ts.map +1 -1
- package/dist/codegen/dts.js +1 -0
- package/dist/codegen/dts.js.map +1 -1
- package/dist/data/changeset.d.ts +12 -0
- package/dist/data/changeset.d.ts.map +1 -1
- package/dist/data/changeset.js +73 -17
- package/dist/data/changeset.js.map +1 -1
- package/dist/data/expr.d.ts +25 -1
- package/dist/data/expr.d.ts.map +1 -1
- package/dist/data/expr.js +47 -6
- package/dist/data/expr.js.map +1 -1
- package/dist/data/fleet.d.ts +41 -1
- package/dist/data/fleet.d.ts.map +1 -1
- package/dist/data/fleet.js +100 -11
- package/dist/data/fleet.js.map +1 -1
- package/dist/data/migrate.d.ts +20 -0
- package/dist/data/migrate.d.ts.map +1 -1
- package/dist/data/migrate.js +86 -3
- package/dist/data/migrate.js.map +1 -1
- package/dist/data/physical.d.ts +5 -0
- package/dist/data/physical.d.ts.map +1 -0
- package/dist/data/physical.js +196 -0
- package/dist/data/physical.js.map +1 -0
- package/dist/data/pool.d.ts +2 -1
- package/dist/data/pool.d.ts.map +1 -1
- package/dist/data/pool.js +159 -31
- package/dist/data/pool.js.map +1 -1
- package/dist/data/query.d.ts +10 -1
- package/dist/data/query.d.ts.map +1 -1
- package/dist/data/query.js +136 -27
- package/dist/data/query.js.map +1 -1
- package/dist/data/sqlite.d.ts.map +1 -1
- package/dist/data/sqlite.js +350 -52
- package/dist/data/sqlite.js.map +1 -1
- package/dist/data/time.d.ts +13 -0
- package/dist/data/time.d.ts.map +1 -1
- package/dist/data/time.js +61 -17
- package/dist/data/time.js.map +1 -1
- package/dist/index.d.ts +45 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -18
- package/dist/index.js.map +1 -1
- package/dist/kernel/audit.d.ts +27 -0
- package/dist/kernel/audit.d.ts.map +1 -0
- package/dist/kernel/audit.js +67 -0
- package/dist/kernel/audit.js.map +1 -0
- package/dist/kernel/classification.d.ts +26 -0
- package/dist/kernel/classification.d.ts.map +1 -0
- package/dist/kernel/classification.js +73 -0
- package/dist/kernel/classification.js.map +1 -0
- package/dist/kernel/compose.d.ts +6 -2
- package/dist/kernel/compose.d.ts.map +1 -1
- package/dist/kernel/compose.js +269 -15
- package/dist/kernel/compose.js.map +1 -1
- package/dist/kernel/define.d.ts +2 -3
- package/dist/kernel/define.d.ts.map +1 -1
- package/dist/kernel/define.js +22 -12
- package/dist/kernel/define.js.map +1 -1
- package/dist/kernel/diff.d.ts.map +1 -1
- package/dist/kernel/diff.js +28 -4
- package/dist/kernel/diff.js.map +1 -1
- package/dist/kernel/graph.js +1 -1
- package/dist/kernel/graph.js.map +1 -1
- package/dist/kernel/i18n.d.ts +10 -1
- package/dist/kernel/i18n.d.ts.map +1 -1
- package/dist/kernel/i18n.js +34 -1
- package/dist/kernel/i18n.js.map +1 -1
- package/dist/kernel/layout.d.ts +97 -0
- package/dist/kernel/layout.d.ts.map +1 -1
- package/dist/kernel/layout.js +294 -12
- package/dist/kernel/layout.js.map +1 -1
- package/dist/kernel/menu.d.ts +33 -2
- package/dist/kernel/menu.d.ts.map +1 -1
- package/dist/kernel/menu.js +99 -7
- package/dist/kernel/menu.js.map +1 -1
- package/dist/kernel/modules.d.ts +3 -3
- package/dist/kernel/modules.d.ts.map +1 -1
- package/dist/kernel/modules.js +21 -21
- package/dist/kernel/modules.js.map +1 -1
- package/dist/kernel/permissions.d.ts +10 -0
- package/dist/kernel/permissions.d.ts.map +1 -0
- package/dist/kernel/permissions.js +365 -0
- package/dist/kernel/permissions.js.map +1 -0
- package/dist/kernel/schedule.d.ts +23 -0
- package/dist/kernel/schedule.d.ts.map +1 -0
- package/dist/kernel/schedule.js +83 -0
- package/dist/kernel/schedule.js.map +1 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/kernel/types.js +5 -4
- package/dist/kernel/types.js.map +1 -1
- package/dist/kernel/workspace.d.ts +92 -14
- package/dist/kernel/workspace.d.ts.map +1 -1
- package/dist/kernel/workspace.js +128 -49
- package/dist/kernel/workspace.js.map +1 -1
- package/dist/pdf/assets/Inter-Bold.ttf +0 -0
- package/dist/pdf/assets/Inter-Regular.ttf +0 -0
- package/dist/pdf/assets/Inter-SemiBold.ttf +0 -0
- package/dist/pdf/assets/LICENSE.txt +92 -0
- package/dist/pdf/font.d.ts +10 -0
- package/dist/pdf/font.d.ts.map +1 -0
- package/dist/pdf/font.js +83 -0
- package/dist/pdf/font.js.map +1 -0
- package/dist/pdf/image.d.ts +8 -0
- package/dist/pdf/image.d.ts.map +1 -0
- package/dist/pdf/image.js +94 -0
- package/dist/pdf/image.js.map +1 -0
- package/dist/pdf/index.d.ts +15 -0
- package/dist/pdf/index.d.ts.map +1 -0
- package/dist/pdf/index.js +17 -0
- package/dist/pdf/index.js.map +1 -0
- package/dist/pdf/markup.d.ts +19 -0
- package/dist/pdf/markup.d.ts.map +1 -0
- package/dist/pdf/markup.js +146 -0
- package/dist/pdf/markup.js.map +1 -0
- package/dist/pdf/render.d.ts +14 -0
- package/dist/pdf/render.d.ts.map +1 -0
- package/dist/pdf/render.js +387 -0
- package/dist/pdf/render.js.map +1 -0
- package/dist/scaffold/index.js +6 -6
- package/dist/scaffold/index.js.map +1 -1
- package/dist/scaffold/templates/{app.test.ts.tmpl → deployment.test.ts.tmpl} +3 -3
- package/dist/scaffold/templates/ket.workspace.ts.tmpl +4 -6
- package/dist/scaffold/templates/module.ts.tmpl +1 -4
- package/dist/server/assets.d.ts +23 -0
- package/dist/server/assets.d.ts.map +1 -0
- package/dist/server/assets.js +97 -0
- package/dist/server/assets.js.map +1 -0
- package/dist/server/boot.d.ts +174 -38
- package/dist/server/boot.d.ts.map +1 -1
- package/dist/server/boot.js +399 -140
- package/dist/server/boot.js.map +1 -1
- package/dist/server/config.d.ts +30 -10
- package/dist/server/config.d.ts.map +1 -1
- package/dist/server/config.js +73 -17
- package/dist/server/config.js.map +1 -1
- package/dist/server/ctx.d.ts +10 -0
- package/dist/server/ctx.d.ts.map +1 -1
- package/dist/server/ctx.js +284 -48
- package/dist/server/ctx.js.map +1 -1
- package/dist/server/development.d.ts +10 -0
- package/dist/server/development.d.ts.map +1 -0
- package/dist/server/development.js +15 -0
- package/dist/server/development.js.map +1 -0
- package/dist/server/fn.d.ts +22 -3
- package/dist/server/fn.d.ts.map +1 -1
- package/dist/server/fn.js +116 -32
- package/dist/server/fn.js.map +1 -1
- package/dist/server/form.d.ts +33 -0
- package/dist/server/form.d.ts.map +1 -0
- package/dist/server/form.js +47 -0
- package/dist/server/form.js.map +1 -0
- package/dist/server/http.d.ts +82 -3
- package/dist/server/http.d.ts.map +1 -1
- package/dist/server/http.js +373 -37
- package/dist/server/http.js.map +1 -1
- package/dist/server/idem.d.ts +3 -2
- package/dist/server/idem.d.ts.map +1 -1
- package/dist/server/idem.js +12 -4
- package/dist/server/idem.js.map +1 -1
- package/dist/server/jobs.js +1 -1
- package/dist/server/jobs.js.map +1 -1
- package/dist/server/log/combinators.d.ts +42 -0
- package/dist/server/log/combinators.d.ts.map +1 -0
- package/dist/server/log/combinators.js +270 -0
- package/dist/server/log/combinators.js.map +1 -0
- package/dist/server/log/console.d.ts +12 -0
- package/dist/server/log/console.d.ts.map +1 -0
- package/dist/server/log/console.js +96 -0
- package/dist/server/log/console.js.map +1 -0
- package/dist/server/log/file.d.ts +11 -0
- package/dist/server/log/file.d.ts.map +1 -0
- package/dist/server/log/file.js +61 -0
- package/dist/server/log/file.js.map +1 -0
- package/dist/server/log/index.d.ts +23 -0
- package/dist/server/log/index.d.ts.map +1 -0
- package/dist/server/log/index.js +45 -0
- package/dist/server/log/index.js.map +1 -0
- package/dist/server/log/logger.d.ts +53 -0
- package/dist/server/log/logger.d.ts.map +1 -0
- package/dist/server/log/logger.js +94 -0
- package/dist/server/log/logger.js.map +1 -0
- package/dist/server/log/memory.d.ts +11 -0
- package/dist/server/log/memory.d.ts.map +1 -0
- package/dist/server/log/memory.js +25 -0
- package/dist/server/log/memory.js.map +1 -0
- package/dist/server/log/types.d.ts +112 -0
- package/dist/server/log/types.d.ts.map +1 -0
- package/dist/server/log/types.js +58 -0
- package/dist/server/log/types.js.map +1 -0
- package/dist/server/policy.d.ts +29 -0
- package/dist/server/policy.d.ts.map +1 -0
- package/dist/server/policy.js +29 -0
- package/dist/server/policy.js.map +1 -0
- package/dist/server/queue.d.ts +1 -1
- package/dist/server/queue.d.ts.map +1 -1
- package/dist/server/queue.js.map +1 -1
- package/dist/server/ratelimit.d.ts +48 -0
- package/dist/server/ratelimit.d.ts.map +1 -0
- package/dist/server/ratelimit.js +102 -0
- package/dist/server/ratelimit.js.map +1 -0
- package/dist/server/respond.d.ts.map +1 -1
- package/dist/server/respond.js +16 -1
- package/dist/server/respond.js.map +1 -1
- package/dist/server/runtime.d.ts +18 -3
- package/dist/server/runtime.d.ts.map +1 -1
- package/dist/server/runtime.js +32 -2
- package/dist/server/runtime.js.map +1 -1
- package/dist/server/schedule.d.ts +18 -0
- package/dist/server/schedule.d.ts.map +1 -0
- package/dist/server/schedule.js +70 -0
- package/dist/server/schedule.js.map +1 -0
- package/dist/server/sequence.d.ts +42 -0
- package/dist/server/sequence.d.ts.map +1 -0
- package/dist/server/sequence.js +97 -0
- package/dist/server/sequence.js.map +1 -0
- package/dist/server/session.d.ts +21 -0
- package/dist/server/session.d.ts.map +1 -1
- package/dist/server/session.js +84 -10
- package/dist/server/session.js.map +1 -1
- package/dist/server/sessionstore.d.ts +3 -1
- package/dist/server/sessionstore.d.ts.map +1 -1
- package/dist/server/sessionstore.js +7 -3
- package/dist/server/sessionstore.js.map +1 -1
- package/dist/server/storage/index.d.ts +1 -1
- package/dist/server/storage/index.d.ts.map +1 -1
- package/dist/server/storage/index.js +61 -1
- package/dist/server/storage/index.js.map +1 -1
- package/dist/server/storage/types.d.ts +8 -0
- package/dist/server/storage/types.d.ts.map +1 -1
- package/dist/server/storage/types.js +58 -0
- package/dist/server/storage/types.js.map +1 -1
- package/dist/server/stream.d.ts +8 -2
- package/dist/server/stream.d.ts.map +1 -1
- package/dist/server/stream.js +44 -4
- package/dist/server/stream.js.map +1 -1
- package/dist/server/streamstore.d.ts +10 -0
- package/dist/server/streamstore.d.ts.map +1 -1
- package/dist/server/streamstore.js +72 -6
- package/dist/server/streamstore.js.map +1 -1
- package/dist/server/tenants.d.ts +20 -18
- package/dist/server/tenants.d.ts.map +1 -1
- package/dist/server/tenants.js +133 -84
- package/dist/server/tenants.js.map +1 -1
- package/dist/server/transport/types.js +2 -2
- package/dist/server/transport/types.js.map +1 -1
- package/dist/server/worker.d.ts +19 -3
- package/dist/server/worker.d.ts.map +1 -1
- package/dist/server/worker.js +168 -21
- package/dist/server/worker.js.map +1 -1
- package/dist/testing.d.ts +26 -10
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +41 -14
- package/dist/testing.js.map +1 -1
- package/dist/theme/contracts.d.ts +14 -1
- package/dist/theme/contracts.d.ts.map +1 -1
- package/dist/theme/contracts.js +35 -6
- package/dist/theme/contracts.js.map +1 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/joint-runtime.d.ts +33 -0
- package/dist/theme/joint-runtime.d.ts.map +1 -0
- package/dist/theme/joint-runtime.js +121 -0
- package/dist/theme/joint-runtime.js.map +1 -0
- package/dist/theme/joints.d.ts.map +1 -1
- package/dist/theme/joints.js +15 -97
- package/dist/theme/joints.js.map +1 -1
- package/dist/theme/ktl/compile.d.ts +4 -0
- package/dist/theme/ktl/compile.d.ts.map +1 -1
- package/dist/theme/ktl/compile.js +54 -1
- package/dist/theme/ktl/compile.js.map +1 -1
- package/dist/theme/ktl/parser.d.ts +4 -0
- package/dist/theme/ktl/parser.d.ts.map +1 -1
- package/dist/theme/ktl/parser.js +8 -0
- package/dist/theme/ktl/parser.js.map +1 -1
- package/dist/theme/render.d.ts +8 -0
- package/dist/theme/render.d.ts.map +1 -1
- package/dist/theme/render.js +88 -118
- package/dist/theme/render.js.map +1 -1
- package/dist/theme/tokens.d.ts +18 -0
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +33 -0
- package/dist/theme/tokens.js.map +1 -1
- package/dist/theme/viewmodel.d.ts +24 -0
- package/dist/theme/viewmodel.d.ts.map +1 -1
- package/dist/theme/viewmodel.js +75 -6
- package/dist/theme/viewmodel.js.map +1 -1
- package/dist/types.d.ts +320 -56
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -2
- package/dist/kernel/apps.d.ts +0 -43
- package/dist/kernel/apps.d.ts.map +0 -1
- package/dist/kernel/apps.js +0 -234
- package/dist/kernel/apps.js.map +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Static assets a browser may keep.
|
|
2
|
+
//
|
|
3
|
+
// Every asset used to be served from its own name with `cache-control:
|
|
4
|
+
// no-cache`, and no `ETag` or `Last-Modified` beside it. That pair is the worst
|
|
5
|
+
// of both: `no-cache` tells a cache it must revalidate before reusing anything,
|
|
6
|
+
// and with nothing to revalidate *against* the revalidation cannot answer 304 —
|
|
7
|
+
// so every page load re-fetched every stylesheet and every island bundle in
|
|
8
|
+
// full, and a CDN in front of it had nothing it was allowed to do.
|
|
9
|
+
//
|
|
10
|
+
// A file's own content is the only honest version of it, so that is what goes
|
|
11
|
+
// in the URL. A build that changes nothing changes no URL; a build that changes
|
|
12
|
+
// one bundle changes one URL, and the rest of a deployment's assets stay in
|
|
13
|
+
// caches where they are.
|
|
14
|
+
import { createHash } from 'node:crypto';
|
|
15
|
+
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
16
|
+
import { join, relative } from 'node:path';
|
|
17
|
+
/** How much of the digest goes in the path. Eight hex is 4 billion; a file is not adversarial. */
|
|
18
|
+
const DIGEST = 8;
|
|
19
|
+
/**
|
|
20
|
+
* The marker that says a path segment is a version rather than a directory.
|
|
21
|
+
*
|
|
22
|
+
* Explicit, because `assetMount` has to strip it back off to find the file on
|
|
23
|
+
* disk, and "the first segment, if it looks like hex" is a rule that breaks the
|
|
24
|
+
* day somebody ships a directory named `deadbeef`.
|
|
25
|
+
*/
|
|
26
|
+
export const VERSION_PREFIX = 'v';
|
|
27
|
+
const versionSegment = /^v[0-9a-f]{8,}$/;
|
|
28
|
+
/** Splits `v1a2b3c4d/live-doc.mjs` back into the file it names. */
|
|
29
|
+
export const withoutVersion = (path) => {
|
|
30
|
+
const slash = path.indexOf('/');
|
|
31
|
+
if (slash <= 0)
|
|
32
|
+
return path;
|
|
33
|
+
return versionSegment.test(path.slice(0, slash)) ? path.slice(slash + 1) : path;
|
|
34
|
+
};
|
|
35
|
+
/** True when this request named a version, and so may be cached forever. */
|
|
36
|
+
export const isVersioned = (path) => path.split('/').some((segment) => versionSegment.test(segment));
|
|
37
|
+
const walk = async (dir, base = dir) => {
|
|
38
|
+
const found = [];
|
|
39
|
+
let entries;
|
|
40
|
+
try {
|
|
41
|
+
entries = await readdir(dir);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return found;
|
|
45
|
+
}
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
const full = join(dir, entry);
|
|
48
|
+
const info = await stat(full).catch(() => null);
|
|
49
|
+
if (!info)
|
|
50
|
+
continue;
|
|
51
|
+
if (info.isDirectory())
|
|
52
|
+
found.push(...(await walk(full, base)));
|
|
53
|
+
else
|
|
54
|
+
found.push(relative(base, full));
|
|
55
|
+
}
|
|
56
|
+
return found;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Rewrites every asset URL in the manifest to carry its file's digest.
|
|
60
|
+
*
|
|
61
|
+
* Done at boot rather than in `compose`, which is synchronous and runs in tests
|
|
62
|
+
* that have no business reading a disk. A deployment that cannot read one of
|
|
63
|
+
* its own asset directories simply keeps the unversioned URL: the page still
|
|
64
|
+
* works, it just revalidates the way it always did.
|
|
65
|
+
*/
|
|
66
|
+
export async function fingerprintAssets(manifest) {
|
|
67
|
+
const versions = new Map();
|
|
68
|
+
await Promise.all(Object.entries(manifest.assets).map(async ([owner, dir]) => {
|
|
69
|
+
for (const file of await walk(dir)) {
|
|
70
|
+
const bytes = await readFile(join(dir, file)).catch(() => null);
|
|
71
|
+
if (!bytes)
|
|
72
|
+
continue;
|
|
73
|
+
const digest = createHash('sha256').update(bytes).digest('hex').slice(0, DIGEST);
|
|
74
|
+
versions.set(`${owner}/${file}`, `${VERSION_PREFIX}${digest}`);
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
const versioned = (href) => {
|
|
78
|
+
const prefix = '/_ket/asset/';
|
|
79
|
+
if (!href.startsWith(prefix))
|
|
80
|
+
return href;
|
|
81
|
+
const rest = href.slice(prefix.length);
|
|
82
|
+
const version = versions.get(rest);
|
|
83
|
+
if (!version)
|
|
84
|
+
return href;
|
|
85
|
+
const slash = rest.indexOf('/');
|
|
86
|
+
return `${prefix}${rest.slice(0, slash)}/${version}/${rest.slice(slash + 1)}`;
|
|
87
|
+
};
|
|
88
|
+
for (const style of manifest.styles)
|
|
89
|
+
style.href = versioned(style.href);
|
|
90
|
+
for (const island of Object.values(manifest.islands)) {
|
|
91
|
+
const client = island.client;
|
|
92
|
+
if (client)
|
|
93
|
+
client.src = versioned(client.src);
|
|
94
|
+
}
|
|
95
|
+
return versions;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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AAuC,CAAC,MAAM,CAAA;QAC9D,IAAI,MAAM;YAAE,MAAM,CAAC,GAAG,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAChD,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
package/dist/server/boot.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { MenuNode } from '../kernel/menu.ts';
|
|
2
2
|
import type { Markup } from '@ketvietlab/ketjs-view';
|
|
3
3
|
import type { Tenants, TenantSpec } from './tenants.ts';
|
|
4
|
-
import type { AppInfo } from '../kernel/apps.ts';
|
|
5
4
|
import type { SessionContext, Sessions, SessionOptions, SessionRecord } from './session.ts';
|
|
5
|
+
import type { RatePolicy } from './ratelimit.ts';
|
|
6
|
+
import type { Logger, OpenLog } from './log/index.ts';
|
|
6
7
|
import type { RuntimeConfig, OpenStore } from './config.ts';
|
|
7
8
|
import type { OpenStorage, Storage } from './storage/index.ts';
|
|
8
9
|
import type { OpenTransport } from './transport/index.ts';
|
|
9
|
-
import type {
|
|
10
|
-
import type { AppRegistry } from '../kernel/apps.ts';
|
|
10
|
+
import type { DeploymentSpec, NavigationSpec } from '../kernel/workspace.ts';
|
|
11
11
|
import type { Translator } from '../kernel/i18n.ts';
|
|
12
12
|
import type { Adapter, Manifest, Scope } from '../types.ts';
|
|
13
13
|
import type { IncomingMessage } from 'node:http';
|
|
14
14
|
import type { RouteParams } from '../kernel/routes.ts';
|
|
15
|
+
import type { Streams, StreamStore } from './stream.ts';
|
|
15
16
|
export type { Html, RouteResult } from './respond.ts';
|
|
16
17
|
export { page, fragment, navigablePage, isNavigationRequest, text, bytes, streamed, raw, withHeaders, } from './respond.ts';
|
|
17
18
|
export { json } from './respond.ts';
|
|
@@ -19,27 +20,27 @@ import type { Html, RouteResult } from './respond.ts';
|
|
|
19
20
|
export type Route = (url: URL, req: IncomingMessage, params: RouteParams) => Promise<RouteResult> | RouteResult;
|
|
20
21
|
/**
|
|
21
22
|
* What a route needs that only the running server has. Handed to `serve.routes` so
|
|
22
|
-
*
|
|
23
|
+
* deployment screens can read live state without reaching for module-level globals.
|
|
23
24
|
*/
|
|
24
25
|
export type ServeContext = {
|
|
25
|
-
/**
|
|
26
|
+
/** The immutable manifest selected by this deployment. */
|
|
26
27
|
manifest: Manifest;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* boot is what would show one tenant the module set of another — and that does
|
|
32
|
-
* not fail, it answers wrongly, which is worse.
|
|
33
|
-
*/
|
|
28
|
+
/** The authored deployment and its external-client compatibility policy. */
|
|
29
|
+
deploymentName: string;
|
|
30
|
+
clientCompatibility: ClientCompatibilityPolicy | null;
|
|
31
|
+
/** Same manifest for every tenant; request-shaped for convenient route composition. */
|
|
34
32
|
live: (req: IncomingMessage) => Promise<Manifest>;
|
|
35
|
-
/** The app list for this request's tenant. The registry itself stays leased. */
|
|
36
|
-
appsOf: (req: IncomingMessage) => Promise<AppInfo[]>;
|
|
37
33
|
config: RuntimeConfig;
|
|
38
34
|
scopeOf: (url: URL, req: IncomingMessage) => Promise<Scope>;
|
|
39
35
|
localeOf: (url: URL, req: IncomingMessage) => string;
|
|
40
36
|
translate: (locale: string) => Translator;
|
|
41
37
|
/** A function call carrying this request's tenant, live manifest and scope. */
|
|
42
|
-
call: (name: string, input: Record<string, unknown>, url: URL, req: IncomingMessage
|
|
38
|
+
call: (name: string, input: Record<string, unknown>, url: URL, req: IncomingMessage, options?: {
|
|
39
|
+
idempotencyKey?: string | null;
|
|
40
|
+
idempotencyNamespace?: string | null;
|
|
41
|
+
idempotencyDigest?: string | null;
|
|
42
|
+
correlationId?: string | null;
|
|
43
|
+
}) => Promise<unknown>;
|
|
43
44
|
/**
|
|
44
45
|
* The same call with the permission check off.
|
|
45
46
|
*
|
|
@@ -48,7 +49,32 @@ export type ServeContext = {
|
|
|
48
49
|
* a permission resolver that went through the check would be asking permission
|
|
49
50
|
* to find out whether it has permission. Nothing else has that excuse.
|
|
50
51
|
*/
|
|
51
|
-
callUnchecked: (name: string, input: Record<string, unknown>, url: URL, req: IncomingMessage
|
|
52
|
+
callUnchecked: (name: string, input: Record<string, unknown>, url: URL, req: IncomingMessage, options?: {
|
|
53
|
+
idempotencyKey?: string | null;
|
|
54
|
+
idempotencyNamespace?: string | null;
|
|
55
|
+
idempotencyDigest?: string | null;
|
|
56
|
+
correlationId?: string | null;
|
|
57
|
+
}) => Promise<unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* Call inside exactly one company after this route has authenticated an
|
|
60
|
+
* external credential that is bound to that company.
|
|
61
|
+
*
|
|
62
|
+
* This is intentionally separate from `callUnchecked`: provider callbacks
|
|
63
|
+
* arrive without a staff session, so their request scope cannot select the
|
|
64
|
+
* legal entity. The company id must come from verified credential material,
|
|
65
|
+
* never from an unsigned path, query, header, or body field alone. The call
|
|
66
|
+
* remains in the request's tenant and cannot widen to another company.
|
|
67
|
+
*/
|
|
68
|
+
callUncheckedForVerifiedCompany: (name: string, input: Record<string, unknown>, companyId: string, url: URL, req: IncomingMessage, options?: {
|
|
69
|
+
idempotencyKey?: string | null;
|
|
70
|
+
idempotencyNamespace?: string | null;
|
|
71
|
+
idempotencyDigest?: string | null;
|
|
72
|
+
correlationId?: string | null;
|
|
73
|
+
}) => Promise<unknown>;
|
|
74
|
+
/** Whether this request's effective allow-list contains one exact function key. */
|
|
75
|
+
allows: (name: string, url: URL, req: IncomingMessage) => Promise<boolean>;
|
|
76
|
+
/** What this deployment declared its navigation to mean. Null when it declared nothing. */
|
|
77
|
+
navigation: NavigationSpec | null;
|
|
52
78
|
/** The document every screen sits in. Markup, not a string — see respond.ts. */
|
|
53
79
|
document: (o: {
|
|
54
80
|
lang: string;
|
|
@@ -56,23 +82,24 @@ export type ServeContext = {
|
|
|
56
82
|
head?: Html;
|
|
57
83
|
body: Html;
|
|
58
84
|
}) => Html;
|
|
59
|
-
/**
|
|
85
|
+
/** Composed modules' stylesheets for this tenant, in dependency order. */
|
|
60
86
|
styles: (req: IncomingMessage) => Promise<Html>;
|
|
61
87
|
/**
|
|
62
|
-
* Render an extension point: every
|
|
88
|
+
* Render an extension point: every composed module's fills, in dependency
|
|
63
89
|
* order, as markup a template inserts verbatim.
|
|
64
90
|
*
|
|
65
|
-
* Empty when nobody fills it, and empty when
|
|
91
|
+
* Empty when nobody fills it, and empty when a composed module omitted it.
|
|
66
92
|
*/
|
|
67
93
|
joint: (url: URL, req: IncomingMessage, key: string, props?: Record<string, unknown>) => Promise<Markup>;
|
|
68
|
-
/** False when
|
|
94
|
+
/** False when a composed module omitted this joint — see jointShows in screens. */
|
|
69
95
|
jointShows: (url: URL, req: IncomingMessage, key: string) => Promise<boolean>;
|
|
70
96
|
/**
|
|
71
|
-
* The navigation tree as this viewer sees it: what the deployment
|
|
72
|
-
*
|
|
73
|
-
* because each filter depends on the one before.
|
|
97
|
+
* The navigation tree as this viewer sees it: what the deployment composes and
|
|
98
|
+
* what this request may call.
|
|
74
99
|
*/
|
|
75
100
|
menu: (url: URL, req: IncomingMessage) => Promise<MenuNode[]>;
|
|
101
|
+
/** Printable reports for a model whose read-only source this viewer may call. */
|
|
102
|
+
reportsOf: (url: URL, req: IncomingMessage, target: string) => Promise<import('../types.ts').ComposedReport[]>;
|
|
76
103
|
/**
|
|
77
104
|
* This request's sessions. A function because with subdomain tenants they live
|
|
78
105
|
* in that tenant's database — one per tenant, not one per deployment.
|
|
@@ -93,6 +120,23 @@ export type PagesSpec = {
|
|
|
93
120
|
resolve: string;
|
|
94
121
|
/** Optional function taking `{ host }` and returning site id, title, locale and theme. */
|
|
95
122
|
siteResolve?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Optional function taking `{ siteId }` and returning the site's navigation.
|
|
125
|
+
* Its answer reaches a theme as `menu`; without it a theme that draws
|
|
126
|
+
* navigation draws nothing, which is a blank nav rather than an error.
|
|
127
|
+
*/
|
|
128
|
+
menuResolve?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Optional function taking `{ token }` and answering the same shape as
|
|
131
|
+
* `resolve`, for a draft nobody has published yet. Without it a deployment
|
|
132
|
+
* can mint preview links and has nowhere to spend them.
|
|
133
|
+
*/
|
|
134
|
+
previewResolve?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Where a preview link points. Defaults to `/_ket/preview`, inside the
|
|
137
|
+
* namespace the framework already owns, so no published page can claim it.
|
|
138
|
+
*/
|
|
139
|
+
previewPath?: string;
|
|
96
140
|
/** Theme region whose host carries the same data-ket-slot name. */
|
|
97
141
|
region?: string;
|
|
98
142
|
/** Message key for the title of a path that has no page. */
|
|
@@ -106,14 +150,34 @@ export type SessionResolveContext = {
|
|
|
106
150
|
url: URL;
|
|
107
151
|
req: IncomingMessage;
|
|
108
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* Identity established by infrastructure in front of the deployment.
|
|
155
|
+
*
|
|
156
|
+
* The resolver is the trust boundary: callers must verify the proxy credential
|
|
157
|
+
* (for example a short-lived signed assertion) before returning an identity.
|
|
158
|
+
* KetJS then applies the same actor, scope and permission pipeline used by a
|
|
159
|
+
* cookie session without persisting a second login session in the tenant DB.
|
|
160
|
+
*/
|
|
161
|
+
export type RequestIdentity = {
|
|
162
|
+
userId: string;
|
|
163
|
+
companies: string[];
|
|
164
|
+
company: string | null;
|
|
165
|
+
branch?: string | null;
|
|
166
|
+
branches?: string[] | null;
|
|
167
|
+
securityVersion?: number;
|
|
168
|
+
};
|
|
169
|
+
export type RequestIdentityResolveContext = {
|
|
170
|
+
adapter: Adapter;
|
|
171
|
+
manifest: Manifest;
|
|
172
|
+
url: URL;
|
|
173
|
+
req: IncomingMessage;
|
|
174
|
+
};
|
|
109
175
|
export type ServeSpec = {
|
|
110
176
|
pages?: PagesSpec;
|
|
111
177
|
assets?: {
|
|
112
178
|
prefix: string;
|
|
113
179
|
dir: string;
|
|
114
180
|
};
|
|
115
|
-
/** Installed on an empty database so a first run has something to look at. */
|
|
116
|
-
bootstrap?: string[];
|
|
117
181
|
routes?: (ctx: ServeContext) => Record<string, Route>;
|
|
118
182
|
/** Anything other than SQLite; the framework cannot depend on a driver. */
|
|
119
183
|
openStore?: OpenStore;
|
|
@@ -121,6 +185,46 @@ export type ServeSpec = {
|
|
|
121
185
|
openStorage?: OpenStorage;
|
|
122
186
|
/** Inject a deployment-owned outbound provider for durable worker jobs. */
|
|
123
187
|
openTransport?: OpenTransport;
|
|
188
|
+
/**
|
|
189
|
+
* Send operational records somewhere the framework does not know how to reach.
|
|
190
|
+
*
|
|
191
|
+
* The built-ins need nothing but Node, so anything requiring a client library
|
|
192
|
+
* belongs here rather than in the framework — the same fence as `openStore`.
|
|
193
|
+
* Level filtering, redaction and failure isolation are applied around whatever
|
|
194
|
+
* this returns, so a sink cannot break the work it is describing.
|
|
195
|
+
*
|
|
196
|
+
* Return a fresh driver per call rather than one memoised instance. A process
|
|
197
|
+
* that runs both roles — `ket dev` — opens the sink once for HTTP and once for
|
|
198
|
+
* the worker and closes each with its own role; a shared instance is closed by
|
|
199
|
+
* whichever shuts down first, and the other role's last records are written to a
|
|
200
|
+
* handle that is already gone.
|
|
201
|
+
*/
|
|
202
|
+
openLog?: OpenLog;
|
|
203
|
+
/** Version and maintenance policy published by profile bootstrap routes. */
|
|
204
|
+
clientCompatibility?: ClientCompatibilityPolicy;
|
|
205
|
+
/** Backing store for the built-in resumable stream transport. */
|
|
206
|
+
streamStore?: StreamStore;
|
|
207
|
+
/**
|
|
208
|
+
* Authorize a public stream id and map it to the exact tenant-namespaced topic
|
|
209
|
+
* used by `BootedDeployment.streams`. Absent or null keeps the endpoint closed.
|
|
210
|
+
*/
|
|
211
|
+
resolveStream?: (ctx: ServeContext, id: string, url: URL, req: IncomingMessage) => string | null | Promise<string | null>;
|
|
212
|
+
/**
|
|
213
|
+
* How long a stream connection is held open, and how long its tail waits
|
|
214
|
+
* before reading again when nothing woke it. See `ServerOptions`.
|
|
215
|
+
*/
|
|
216
|
+
streamTimeoutMs?: number;
|
|
217
|
+
streamPollMs?: number;
|
|
218
|
+
/** Maximum buffered body accepted by the generic JSON function transport. */
|
|
219
|
+
maxJsonBodyBytes?: number;
|
|
220
|
+
/**
|
|
221
|
+
* A ceiling on how often one caller may reach a route, or null for no ceiling.
|
|
222
|
+
*
|
|
223
|
+
* Per-request rather than global on purpose: a durable check costs a database
|
|
224
|
+
* round trip, so pointing it at everything hands an attacker a lever. Name the
|
|
225
|
+
* routes where repetition is the abuse.
|
|
226
|
+
*/
|
|
227
|
+
rateLimit?: (ctx: ServeContext, url: URL, req: IncomingMessage) => RatePolicy | null;
|
|
124
228
|
/**
|
|
125
229
|
* Turn on sessions. Present means the X-Ket-Company shim is gone and identity
|
|
126
230
|
* comes from a signed cookie; absent means the shim stays and the banner says so.
|
|
@@ -130,44 +234,76 @@ export type ServeSpec = {
|
|
|
130
234
|
};
|
|
131
235
|
/** Revalidate live account state and memberships before scope and permissions. */
|
|
132
236
|
resolveSession?: (ctx: SessionResolveContext) => Promise<SessionContext | null>;
|
|
237
|
+
/** Verify and resolve identity asserted by a trusted gateway for this request. */
|
|
238
|
+
resolveIdentity?: (ctx: RequestIdentityResolveContext) => Promise<RequestIdentity | null>;
|
|
239
|
+
/** Classify non-staff credentials so the generic function transport can fail closed. */
|
|
240
|
+
resolveAudience?: (url: URL, req: IncomingMessage) => string | null | Promise<string | null>;
|
|
133
241
|
/**
|
|
134
|
-
* Serve several tenants, one database each
|
|
135
|
-
* makes per-tenant module sets work. Absent, the app has a single datastore.
|
|
242
|
+
* Serve several tenants, one database each. Every tenant runs this same deployment.
|
|
136
243
|
*/
|
|
137
244
|
tenants?: TenantSpec;
|
|
138
245
|
/**
|
|
139
246
|
* Which functions a signed-in user may call. Absent means no restriction, which
|
|
140
|
-
* is what
|
|
247
|
+
* is what a deployment without roles is. Returning a list restricts every call the
|
|
141
248
|
* request makes, including the ones a route makes on its behalf.
|
|
249
|
+
*
|
|
250
|
+
* The request is handed over because answering the question almost always means
|
|
251
|
+
* asking the database, and which database that is comes from the request. A
|
|
252
|
+
* resolver that had to invent one could only reach the tenant a bare URL happens
|
|
253
|
+
* to resolve to — which is the wrong one for every tenant but the default.
|
|
142
254
|
*/
|
|
143
|
-
permissions?: (ctx: ServeContext, userId: string) => Promise<readonly string[] | null>;
|
|
255
|
+
permissions?: (ctx: ServeContext, userId: string, url: URL, req: IncomingMessage) => Promise<readonly string[] | null>;
|
|
144
256
|
defaults?: Partial<RuntimeConfig>;
|
|
145
257
|
};
|
|
146
|
-
export type
|
|
258
|
+
export type ClientCompatibilityPolicy = {
|
|
259
|
+
minimumVersions: {
|
|
260
|
+
ios: string;
|
|
261
|
+
android: string;
|
|
262
|
+
};
|
|
263
|
+
recommendedVersions?: {
|
|
264
|
+
ios: string;
|
|
265
|
+
android: string;
|
|
266
|
+
};
|
|
267
|
+
maintenance?: {
|
|
268
|
+
enabled: boolean;
|
|
269
|
+
messages?: Record<string, string>;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
export type BootedDeployment = {
|
|
147
273
|
name: string;
|
|
148
274
|
manifest: Manifest;
|
|
149
|
-
/** The datastore, when there is exactly one. Null when the
|
|
275
|
+
/** The datastore, when there is exactly one. Null when the deployment serves tenants. */
|
|
150
276
|
adapter: Adapter | null;
|
|
151
|
-
/** Likewise: with tenants, "which apps" is a question about a tenant. */
|
|
152
|
-
apps: AppRegistry | null;
|
|
153
277
|
/** Per-tenant access, and the only form that works in both modes. */
|
|
154
278
|
tenants: Tenants;
|
|
155
279
|
config: RuntimeConfig;
|
|
280
|
+
/** Writers for the same store served by the authorized stream endpoint. */
|
|
281
|
+
streams: Streams;
|
|
282
|
+
/**
|
|
283
|
+
* This deployment's logger, carrying its name and process role.
|
|
284
|
+
*
|
|
285
|
+
* A host that calls functions in process — a seeding script, a test harness —
|
|
286
|
+
* narrows it with `child` and hands it to `callFn`, so those calls are recorded
|
|
287
|
+
* the same way a served one is instead of silently escaping the pipeline.
|
|
288
|
+
*/
|
|
289
|
+
logger: Logger;
|
|
156
290
|
port: number;
|
|
157
291
|
banner: () => Promise<string>;
|
|
158
292
|
close: () => Promise<void>;
|
|
159
293
|
};
|
|
160
|
-
export type
|
|
294
|
+
export type BootDeploymentOptions = {
|
|
161
295
|
env?: Record<string, string | undefined>;
|
|
162
296
|
port?: number;
|
|
163
297
|
/** Boot progress. Long-running serve keeps its banner separate. */
|
|
164
298
|
log?: (line: string) => void;
|
|
299
|
+
/** Redirect this process's operational records, without editing the spec. */
|
|
300
|
+
openLog?: OpenLog;
|
|
165
301
|
};
|
|
166
302
|
/**
|
|
167
|
-
* Opens, migrates,
|
|
303
|
+
* Opens, migrates, and serves. Returns before listening is announced so a
|
|
168
304
|
* caller can print its own banner, or a test can boot on port 0 and never print.
|
|
169
305
|
*/
|
|
170
|
-
export declare function
|
|
171
|
-
/**
|
|
172
|
-
export declare function
|
|
306
|
+
export declare function bootDeployment(spec: DeploymentSpec, o?: BootDeploymentOptions): Promise<BootedDeployment>;
|
|
307
|
+
/** bootDeployment, plus the banner and the signal handling a long-running process wants. */
|
|
308
|
+
export declare function serveDeployment(spec: DeploymentSpec, o?: BootDeploymentOptions): Promise<BootedDeployment>;
|
|
173
309
|
//# sourceMappingURL=boot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../../../../packages/ketjs/src/server/boot.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAkB,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEvD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../../../../packages/ketjs/src/server/boot.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAk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