@lark-base-open/base-database-toolchain 0.0.0-stage → 1.1.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +6 -0
  3. package/README.md +82 -2
  4. package/bin/base-database-dev.mjs +4 -0
  5. package/bin/base-database-toolchain.mjs +22 -0
  6. package/dist/app-builder/core.d.mts +37 -0
  7. package/dist/app-builder/core.mjs +716 -0
  8. package/dist/app-builder/package.json +1 -0
  9. package/dist/app-builder/schema.d.ts +3 -0
  10. package/dist/app-builder/schema.js +71 -0
  11. package/dist/contract-conversion.d.ts +41 -0
  12. package/dist/contract-conversion.js +116 -0
  13. package/dist/contract-extractor.d.ts +23 -0
  14. package/dist/contract-extractor.js +245 -0
  15. package/dist/data/development-pairing.json +11 -0
  16. package/dist/data/template-hmr-scripts.json +9 -0
  17. package/dist/dependency-inputs.d.ts +3 -0
  18. package/dist/dependency-inputs.js +18 -0
  19. package/dist/dev-ipc-worker.d.ts +1 -0
  20. package/dist/dev-ipc-worker.js +35 -0
  21. package/dist/dev-redaction.d.ts +1 -0
  22. package/dist/dev-redaction.js +3 -0
  23. package/dist/dev-snapshot.d.ts +3 -0
  24. package/dist/dev-snapshot.js +98 -0
  25. package/dist/dev-vite-server.d.ts +14 -0
  26. package/dist/dev-vite-server.js +213 -0
  27. package/dist/dev-worker.d.mts +1 -0
  28. package/dist/dev-worker.mjs +134 -0
  29. package/dist/development-pairing.generated.d.ts +11 -0
  30. package/dist/development-pairing.generated.js +12 -0
  31. package/dist/development.d.ts +6 -0
  32. package/dist/development.js +6 -0
  33. package/dist/durable-runner.d.ts +102 -0
  34. package/dist/durable-runner.js +128 -0
  35. package/dist/function-batch.d.ts +48 -0
  36. package/dist/function-batch.js +99 -0
  37. package/dist/go-adapter.d.mts +11 -0
  38. package/dist/go-adapter.mjs +847 -0
  39. package/dist/index.d.ts +8 -0
  40. package/dist/index.js +8 -0
  41. package/dist/page-bootstrap.d.ts +3 -0
  42. package/dist/page-bootstrap.js +178 -0
  43. package/dist/page-inspection.d.ts +11 -0
  44. package/dist/page-inspection.js +49 -0
  45. package/dist/page-link-guard.d.ts +12 -0
  46. package/dist/page-link-guard.js +137 -0
  47. package/dist/sdk-codegen.d.ts +16 -0
  48. package/dist/sdk-codegen.js +208 -0
  49. package/dist/trigger-validation.d.ts +75 -0
  50. package/dist/trigger-validation.js +73 -0
  51. package/npm-shrinkwrap.json +1193 -0
  52. package/package.json +87 -4
@@ -0,0 +1,98 @@
1
+ import { DEPENDENCY_INPUTS } from './dependency-inputs.js';
2
+ import { usesDefineFunction } from './contract-extractor.js';
3
+ import { createHash } from 'node:crypto';
4
+ import { existsSync, readdirSync, readFileSync, lstatSync } from 'node:fs';
5
+ import { join } from 'node:path';
6
+ export function watchSnapshot(workspace) {
7
+ const files = new Map();
8
+ let entries = 0;
9
+ let bytes = 0;
10
+ const read = (file) => {
11
+ const info = lstatSync(file);
12
+ if (!info.isFile() || info.nlink !== 1 || info.size > 2 * 1024 * 1024)
13
+ throw new Error('DEV_SOURCE_INVALID: Development files must be regular, unlinked files no larger than 2 MiB.');
14
+ bytes += info.size;
15
+ if (bytes > 64 * 1024 * 1024)
16
+ throw new Error('DEV_SOURCE_TOO_LARGE: Development inputs exceed 64 MiB.');
17
+ return readFileSync(file);
18
+ };
19
+ // An empty AI root declares a replacement set, unlike a missing root.
20
+ if (existsSync(join(workspace, 'ai')))
21
+ files.set('ai/', 'present');
22
+ const visit = (path) => {
23
+ const absolute = join(workspace, path);
24
+ if (!existsSync(absolute))
25
+ return;
26
+ if (!lstatSync(absolute).isDirectory())
27
+ throw new Error('DEV_SOURCE_INVALID: Development source roots must be regular directories.');
28
+ const children = readdirSync(absolute, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
29
+ for (const entry of children) {
30
+ if ([
31
+ 'node_modules',
32
+ 'dist',
33
+ 'generated',
34
+ '.git',
35
+ '.base-database-cli',
36
+ '.lark-cli',
37
+ 'contracts.generated.json',
38
+ ].includes(entry.name))
39
+ continue;
40
+ if (++entries > 20000)
41
+ throw new Error('DEV_SOURCE_TOO_LARGE: Development inputs exceed 20000 entries.');
42
+ const child = join(path, entry.name);
43
+ if (entry.isSymbolicLink())
44
+ throw new Error('DEV_SOURCE_INVALID: Development source links are not supported.');
45
+ if (entry.isDirectory())
46
+ visit(child);
47
+ else if (entry.isFile()) {
48
+ let contents = read(join(workspace, child));
49
+ if (entry.name === 'meta.json' &&
50
+ existsSync(join(workspace, path, 'index.ts'))) {
51
+ read(join(workspace, path, 'index.ts'));
52
+ if (usesDefineFunction(join(workspace, path, 'index.ts'))) {
53
+ const meta = JSON.parse(contents.toString());
54
+ delete meta.contract;
55
+ delete meta.inputSchema;
56
+ delete meta.outputSchema;
57
+ contents = Buffer.from(JSON.stringify(meta));
58
+ }
59
+ }
60
+ files.set(child.replaceAll('\\', '/'), createHash('sha256').update(contents).digest('hex'));
61
+ }
62
+ }
63
+ };
64
+ for (const root of [
65
+ 'server',
66
+ 'server-functions',
67
+ 'contract',
68
+ 'contracts',
69
+ 'database-functions',
70
+ 'sql',
71
+ 'mutations',
72
+ 'ai',
73
+ 'skill',
74
+ ])
75
+ visit(root);
76
+ for (const file of [
77
+ 'base-database.jsonc',
78
+ 'base-app.config.ts',
79
+ 'catalog.json',
80
+ 'agent-tools.json',
81
+ 'README.md',
82
+ ...DEPENDENCY_INPUTS,
83
+ ...DEPENDENCY_INPUTS.map((file) => 'page/' + file),
84
+ ])
85
+ if (existsSync(join(workspace, file)))
86
+ files.set(file, createHash('sha256')
87
+ .update(read(join(workspace, file)))
88
+ .digest('hex'));
89
+ return files;
90
+ }
91
+ export function changedFiles(a, b) {
92
+ return [...new Set([...a.keys(), ...b.keys()])].filter((key) => a.get(key) !== b.get(key));
93
+ }
94
+ export function snapshotFingerprint(snapshot) {
95
+ return createHash('sha256')
96
+ .update(JSON.stringify([...snapshot].sort(([a], [b]) => a.localeCompare(b))))
97
+ .digest('hex');
98
+ }
@@ -0,0 +1,14 @@
1
+ import path from 'node:path';
2
+ export interface ViteStart {
3
+ workspace: string;
4
+ port: number;
5
+ hostOrigin: string;
6
+ templateVersion: number;
7
+ }
8
+ export declare function resolveSDKViteEntry(packageRoot: string, entry: unknown, paths?: path.PlatformPath): string;
9
+ export declare function injectDevObserver(html: string): string;
10
+ export interface ViteLifecycleEvent {
11
+ event: 'listening' | 'ready';
12
+ localOrigin?: string;
13
+ }
14
+ export declare function startVite(input: ViteStart, observe?: (event: ViteLifecycleEvent) => void, sdkMissingMessage?: () => string): Promise<any>;
@@ -0,0 +1,213 @@
1
+ import { parse as parseHTML, parseFragment, serialize, } from 'parse5';
2
+ import { DEVELOPMENT_PAIRING } from './development-pairing.generated.js';
3
+ // Runs in a separate process with an allowlisted environment. Never receives CLI credentials.
4
+ import { createRequire } from 'node:module';
5
+ import { pathToFileURL } from 'node:url';
6
+ import path, { join } from 'node:path';
7
+ import { existsSync, readFileSync } from 'node:fs';
8
+ export function resolveSDKViteEntry(packageRoot, entry, paths = path) {
9
+ if (typeof entry === 'string' && entry.startsWith('./')) {
10
+ const resolved = paths.resolve(packageRoot, entry);
11
+ const relative = paths.relative(packageRoot, resolved);
12
+ if (relative !== '' &&
13
+ relative !== '..' &&
14
+ !relative.startsWith(`..${paths.sep}`) &&
15
+ !paths.isAbsolute(relative))
16
+ return resolved;
17
+ }
18
+ throw new Error('DEV_SDK_VITE_UNSUPPORTED: The project SDK does not export a Vite plugin.');
19
+ }
20
+ export function injectDevObserver(html) {
21
+ const document = parseHTML(html, { sourceCodeLocationInfo: true });
22
+ const find = (node) => {
23
+ if (node.nodeName === 'head')
24
+ return node;
25
+ if ('childNodes' in node)
26
+ for (const child of node.childNodes) {
27
+ const found = find(child);
28
+ if (found)
29
+ return found;
30
+ }
31
+ return undefined;
32
+ };
33
+ const head = find(document);
34
+ if (!head)
35
+ throw new Error('DEV_HTML_UNKNOWN: cannot locate HTML head; repair index.html before dev');
36
+ // Vite's own head injection can also hit a comment. Import its client from this real module.
37
+ const module = '<script type="module">import "/@vite/client"; import "virtual:base-app-dev-observer";</script>';
38
+ const offset = head.sourceCodeLocation?.startTag?.endOffset;
39
+ if (offset !== undefined)
40
+ return html.slice(0, offset) + module + html.slice(offset);
41
+ const script = parseFragment(module).childNodes[0];
42
+ script.parentNode = head;
43
+ head.childNodes.unshift(script);
44
+ return serialize(document);
45
+ }
46
+ export async function startVite(input, observe = (event) => process.send?.(event), sdkMissingMessage = () => 'DEV_SDK_MISSING: Install the project SDK and Vite dependencies before starting local development.') {
47
+ const require = createRequire(join(input.workspace, 'page/package.json'));
48
+ const vite = await import(pathToFileURL(require.resolve('vite')).href);
49
+ const origin = `http://${DEVELOPMENT_PAIRING.host}:${input.port}`;
50
+ const base = '/';
51
+ const control = `${base}__lifecycle`;
52
+ const plugins = [];
53
+ {
54
+ const packageName = '@lark-base-open/base-database-app-sdk';
55
+ const packageRoot = require.resolve
56
+ .paths(packageName)
57
+ ?.map((p) => join(p, packageName))
58
+ .find((p) => existsSync(join(p, 'package.json')));
59
+ if (!packageRoot)
60
+ throw new Error(sdkMissingMessage());
61
+ const manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'));
62
+ const entry = resolveSDKViteEntry(packageRoot, manifest.exports?.['./vite']?.import);
63
+ const sdk = await import(pathToFileURL(entry).href);
64
+ if (typeof sdk.baseAppDevelopmentPairingPlugin !== 'function')
65
+ throw new Error('DEV_SDK_PAIRING_UNSUPPORTED: Upgrade the project SDK before using the paired development entry.');
66
+ plugins.push(sdk.baseAppDevelopmentPairingPlugin());
67
+ }
68
+ // Both templates load the SDK boundary; legacy helpers share its channel singleton.
69
+ const runtime = '@lark-base-open/base-database-app-sdk/page';
70
+ plugins.push({
71
+ name: 'base-app-dev-boundary',
72
+ enforce: 'pre',
73
+ configResolved(config) {
74
+ if (config.server.host !== '127.0.0.1' ||
75
+ config.server.port !== input.port ||
76
+ config.server.strictPort !== true ||
77
+ config.server.https ||
78
+ config.server.middlewareMode ||
79
+ config.server.open ||
80
+ config.server.cors !== false ||
81
+ Object.keys(config.server.proxy ?? {}).length ||
82
+ config.base !== base)
83
+ throw new Error('DEV_VITE_UNSAFE_CONFIG: Project configuration overrides local development boundaries.');
84
+ },
85
+ resolveId(id) {
86
+ if (id === 'virtual:base-app-dev-observer')
87
+ return '\0base-app-dev-observer';
88
+ },
89
+ load(id) {
90
+ if (id !== '\0base-app-dev-observer')
91
+ return;
92
+ return `import {siteRuntime} from ${JSON.stringify(runtime)};
93
+ const original = siteRuntime.ready.bind(siteRuntime);
94
+ siteRuntime.ready = async (...args) => { const result = await original(...args); const context = await siteRuntime.getRuntimeContext(); if (context.development?.localOrigin === ${JSON.stringify(origin)}) await globalThis.fetch(${JSON.stringify(control)}, {method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({localOrigin:context.development.localOrigin})}); return result; };`;
95
+ },
96
+ transformIndexHtml: {
97
+ order: 'pre',
98
+ handler: injectDevObserver,
99
+ },
100
+ configureServer(server) {
101
+ server.middlewares.use((req, res, next) => {
102
+ if (req.headers.host !== `127.0.0.1:${input.port}` ||
103
+ (req.headers.origin !== undefined && req.headers.origin !== origin)) {
104
+ res.writeHead(403).end();
105
+ return;
106
+ }
107
+ if (req.headers.accept?.includes('text/html')) {
108
+ const dest = req.headers['sec-fetch-dest'];
109
+ let validReferer = true;
110
+ if (req.headers.referer) {
111
+ try {
112
+ validReferer =
113
+ new URL(req.headers.referer).origin === input.hostOrigin;
114
+ }
115
+ catch {
116
+ validReferer = false;
117
+ }
118
+ }
119
+ if ((dest !== undefined && dest !== 'iframe') || !validReferer) {
120
+ res.writeHead(403).end();
121
+ return;
122
+ }
123
+ }
124
+ if (req.url === control) {
125
+ if (req.method !== 'POST' ||
126
+ req.headers.origin !== origin ||
127
+ req.headers['content-type'] !== 'application/json') {
128
+ res.writeHead(403).end();
129
+ return;
130
+ }
131
+ let body = '';
132
+ req.on('data', (data) => {
133
+ body += data;
134
+ if (body.length > 1024)
135
+ req.destroy();
136
+ });
137
+ req.on('end', () => {
138
+ try {
139
+ if (JSON.parse(body).localOrigin !== origin)
140
+ throw new Error();
141
+ observe({ event: 'ready', localOrigin: origin });
142
+ res.writeHead(204).end();
143
+ }
144
+ catch {
145
+ res.writeHead(400).end();
146
+ }
147
+ });
148
+ return;
149
+ }
150
+ if (req.url === `${base}__health`) {
151
+ res.setHeader('Content-Type', 'application/json');
152
+ res.end('{"ready":true}');
153
+ return;
154
+ }
155
+ if (req.headers['sec-fetch-dest'] === 'document') {
156
+ res.writeHead(403).end();
157
+ return;
158
+ }
159
+ if (req.headers.accept?.includes('text/html') &&
160
+ req.url?.split('?')[0] !== base) {
161
+ res.writeHead(404).end();
162
+ return;
163
+ }
164
+ res.setHeader('Content-Security-Policy', `frame-ancestors ${input.hostOrigin ?? "'none'"}; connect-src 'self' ws://127.0.0.1:${input.port}; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'`);
165
+ next();
166
+ });
167
+ server.httpServer?.prependListener('upgrade', (req, socket) => {
168
+ if (req.headers.host !== `127.0.0.1:${input.port}` ||
169
+ req.headers.origin !== origin ||
170
+ req.url?.split('?')[0] !== `${base}__hmr`)
171
+ socket.destroy();
172
+ });
173
+ },
174
+ });
175
+ const server = await vite.createServer({
176
+ root: join(input.workspace, 'page'),
177
+ base,
178
+ plugins,
179
+ logLevel: 'silent',
180
+ clearScreen: false,
181
+ server: {
182
+ host: '127.0.0.1',
183
+ port: input.port,
184
+ strictPort: true,
185
+ open: false,
186
+ cors: false,
187
+ proxy: {},
188
+ hmr: {
189
+ host: '127.0.0.1',
190
+ port: input.port,
191
+ clientPort: input.port,
192
+ path: '__hmr',
193
+ },
194
+ fs: {
195
+ strict: true,
196
+ deny: [
197
+ '.env',
198
+ '.env.*',
199
+ '*.{crt,pem}',
200
+ '**/.git/**',
201
+ '**/.base-database-cli/**',
202
+ '**/.lark-cli/**',
203
+ '**/server/**',
204
+ '**/server-functions/**',
205
+ '**/database-functions/**',
206
+ ],
207
+ },
208
+ },
209
+ });
210
+ await server.listen();
211
+ observe({ event: 'listening' });
212
+ return server;
213
+ }
@@ -0,0 +1 @@
1
+ export declare function runDevelopmentWorker(): void;
@@ -0,0 +1,134 @@
1
+ // Long-running, credential-free Vite worker. The Go host owns auth and publishing.
2
+ import { isAbsolute } from 'node:path';
3
+ import { createInterface } from 'node:readline';
4
+ import { startVite } from './dev-vite-server.js';
5
+ import { watchSnapshot, changedFiles, snapshotFingerprint, } from './dev-snapshot.js';
6
+ import { DEVELOPMENT_PAIRING as protocol } from './development-pairing.generated.js';
7
+ import { redactPairing } from './dev-redaction.js';
8
+ export function runDevelopmentWorker() {
9
+ const token = process.env[protocol.tokenEnv];
10
+ const redact = (value) => redactPairing(String(value), token).slice(0, 4096);
11
+ const emit = (value) => process.stdout.write(JSON.stringify({ protocolVersion: 1, ...value }) + '\n');
12
+ let server;
13
+ let started = false;
14
+ let stopping = false;
15
+ let startup = Promise.resolve();
16
+ let scanTimer;
17
+ let workspace;
18
+ let snapshot;
19
+ const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
20
+ async function stop(code = 0) {
21
+ if (stopping)
22
+ return;
23
+ stopping = true;
24
+ clearInterval(scanTimer);
25
+ lines.close();
26
+ process.stdin.pause();
27
+ await startup.catch(() => { });
28
+ await server?.close();
29
+ emit({ event: 'stopped' });
30
+ process.exit(code);
31
+ }
32
+ function fail(error) {
33
+ emit({ event: 'error', message: redact(error?.message ?? error) });
34
+ setImmediate(() => void stop(1));
35
+ }
36
+ process.once('SIGINT', () => void stop());
37
+ process.once('SIGTERM', () => void stop());
38
+ lines.once('close', () => {
39
+ if (!stopping)
40
+ void stop();
41
+ });
42
+ let inputBytes = 0;
43
+ process.stdin.prependListener('data', (chunk) => {
44
+ for (const byte of chunk) {
45
+ if (byte === 10)
46
+ inputBytes = 0;
47
+ else if (++inputBytes > 64 * 1024) {
48
+ fail(Error('DEV_INPUT_TOO_LARGE: Development input exceeds its line budget.'));
49
+ break;
50
+ }
51
+ }
52
+ });
53
+ lines.on('line', (line) => {
54
+ if (stopping)
55
+ return;
56
+ try {
57
+ const input = JSON.parse(line);
58
+ if (input.protocolVersion !== 1)
59
+ throw Error('DEV_PROTOCOL_UNSUPPORTED: Unsupported development protocol.');
60
+ if (started) {
61
+ if (input.command === 'snapshot' &&
62
+ typeof input.requestId === 'string' &&
63
+ /^[A-Za-z0-9-]{1,64}$/.test(input.requestId)) {
64
+ const current = watchSnapshot(workspace);
65
+ emit({
66
+ event: 'snapshot',
67
+ requestId: input.requestId,
68
+ fingerprint: snapshotFingerprint(current),
69
+ });
70
+ return;
71
+ }
72
+ if (input.command !== 'stop')
73
+ throw Error('DEV_CONTROL_INVALID: Expected stop or an identified snapshot request.');
74
+ void stop();
75
+ return;
76
+ }
77
+ started = true;
78
+ const host = new URL(input.hostOrigin);
79
+ if (!isAbsolute(input.workspace) ||
80
+ !Number.isInteger(input.port) ||
81
+ input.port < protocol.portMin ||
82
+ input.port > protocol.portMax ||
83
+ host.protocol !== 'https:' ||
84
+ host.origin !== input.hostOrigin ||
85
+ host.username ||
86
+ host.password ||
87
+ ![1, 2].includes(input.templateVersion) ||
88
+ !/^[A-Za-z0-9_-]{43}$/.test(token ?? ''))
89
+ throw Error('DEV_INPUT_INVALID: Invalid project, loopback port, host origin or pairing token.');
90
+ workspace = input.workspace;
91
+ snapshot = watchSnapshot(workspace);
92
+ emit({ event: 'snapshot', fingerprint: snapshotFingerprint(snapshot) });
93
+ startup = (async () => {
94
+ try {
95
+ server = await startVite(input, emit);
96
+ if (!stopping)
97
+ scanTimer = setInterval(() => {
98
+ try {
99
+ const current = watchSnapshot(workspace);
100
+ const changed = changedFiles(snapshot, current);
101
+ snapshot = current;
102
+ if (changed.length) {
103
+ const files = [];
104
+ let size = 0;
105
+ for (const file of changed) {
106
+ const bytes = Buffer.byteLength(JSON.stringify(file)) + 1;
107
+ if (files.length === 100 || size + bytes > 8192)
108
+ break;
109
+ files.push(file);
110
+ size += bytes;
111
+ }
112
+ emit({
113
+ event: 'changed',
114
+ files,
115
+ filesTruncated: files.length !== changed.length,
116
+ fingerprint: snapshotFingerprint(current),
117
+ });
118
+ }
119
+ }
120
+ catch (error) {
121
+ fail(error);
122
+ }
123
+ }, 200);
124
+ }
125
+ catch (error) {
126
+ fail(error);
127
+ }
128
+ })();
129
+ }
130
+ catch (error) {
131
+ fail(error);
132
+ }
133
+ });
134
+ }
@@ -0,0 +1,11 @@
1
+ export declare const DEVELOPMENT_PAIRING: {
2
+ readonly tokenEnv: 'BASE_APP_DEV_PAIRING_TOKEN';
3
+ readonly endpoint: '/__base_app/dev-pair';
4
+ readonly proofPrefix: 'base-app-dev-pair.v1';
5
+ readonly pairApi: 'site.v1.development.pair';
6
+ readonly pairedEvent: 'site.v1.development.paired';
7
+ readonly host: '127.0.0.1';
8
+ readonly portMin: 43100;
9
+ readonly portMax: 43109;
10
+ readonly secretBytes: 32;
11
+ };
@@ -0,0 +1,12 @@
1
+ // Generated from SDK development-pairing.json; run scripts/sync-development-pairing.mjs.
2
+ export const DEVELOPMENT_PAIRING = {
3
+ tokenEnv: 'BASE_APP_DEV_PAIRING_TOKEN',
4
+ endpoint: '/__base_app/dev-pair',
5
+ proofPrefix: 'base-app-dev-pair.v1',
6
+ pairApi: 'site.v1.development.pair',
7
+ pairedEvent: 'site.v1.development.paired',
8
+ host: '127.0.0.1',
9
+ portMin: 43100,
10
+ portMax: 43109,
11
+ secretBytes: 32,
12
+ };
@@ -0,0 +1,6 @@
1
+ export { startVite, resolveSDKViteEntry, injectDevObserver, type ViteStart, type ViteLifecycleEvent, } from './dev-vite-server.js';
2
+ export { watchSnapshot, changedFiles, snapshotFingerprint, } from './dev-snapshot.js';
3
+ export { runViteIPCWorker } from './dev-ipc-worker.js';
4
+ export { DEVELOPMENT_PAIRING } from './development-pairing.generated.js';
5
+ export { redactPairing } from './dev-redaction.js';
6
+ export { DEPENDENCY_INPUTS, isDependencyInput, blocksAutomaticPreview, } from './dependency-inputs.js';
@@ -0,0 +1,6 @@
1
+ export { startVite, resolveSDKViteEntry, injectDevObserver, } from './dev-vite-server.js';
2
+ export { watchSnapshot, changedFiles, snapshotFingerprint, } from './dev-snapshot.js';
3
+ export { runViteIPCWorker } from './dev-ipc-worker.js';
4
+ export { DEVELOPMENT_PAIRING } from './development-pairing.generated.js';
5
+ export { redactPairing } from './dev-redaction.js';
6
+ export { DEPENDENCY_INPUTS, isDependencyInput, blocksAutomaticPreview, } from './dependency-inputs.js';
@@ -0,0 +1,102 @@
1
+ type OpError = {
2
+ message: string;
3
+ code?: string;
4
+ retryable?: boolean;
5
+ [key: string]: unknown;
6
+ };
7
+ type Step = {
8
+ key: string;
9
+ kind: 'run' | 'sleep' | 'wait';
10
+ ok: boolean;
11
+ value?: unknown;
12
+ error?: OpError;
13
+ timedOut?: boolean;
14
+ attempts: number;
15
+ startedAt: number;
16
+ endedAt: number;
17
+ };
18
+ type Op = {
19
+ v: 1;
20
+ seq: number;
21
+ progress?: unknown;
22
+ } & ({
23
+ op: 'step';
24
+ key: string;
25
+ ok: true;
26
+ value: unknown;
27
+ durationMs: number;
28
+ } | {
29
+ op: 'step';
30
+ key: string;
31
+ ok: false;
32
+ error: OpError;
33
+ policy: {
34
+ retries: number;
35
+ };
36
+ durationMs: number;
37
+ } | {
38
+ op: 'sleep';
39
+ key: string;
40
+ durationMs: number;
41
+ } | {
42
+ op: 'wait';
43
+ key: string;
44
+ event: string;
45
+ timeoutMs: number;
46
+ } | {
47
+ op: 'done';
48
+ output: unknown;
49
+ } | {
50
+ op: 'fail';
51
+ error: OpError;
52
+ });
53
+ export interface LocalDurableExecutor {
54
+ v: 1;
55
+ execute(request: {
56
+ v: 1;
57
+ runId: string;
58
+ functionId: string;
59
+ input: unknown;
60
+ steps: Step[];
61
+ invocation: {
62
+ seq: number;
63
+ attempt: number;
64
+ issuedAt: number;
65
+ deadline: number;
66
+ expiresAt: number;
67
+ };
68
+ }, host: {
69
+ signal: AbortSignal;
70
+ deadline: number;
71
+ ctx: object;
72
+ }): Promise<Op>;
73
+ }
74
+ export interface LocalDurableOptions {
75
+ fast?: boolean;
76
+ realSleep?: boolean;
77
+ events?: {
78
+ name: string;
79
+ data: unknown;
80
+ }[];
81
+ onOp?: (op: Op) => void;
82
+ wait?: (ms: number) => Promise<unknown>;
83
+ }
84
+ export declare function parseDurableEvents(values: string[]): {
85
+ name: string;
86
+ data: unknown;
87
+ }[];
88
+ /** In-memory P0 drive loop; the caller supplies its request context, never an identity. */
89
+ export declare function driveLocalDurable(executor: LocalDurableExecutor, functionId: string, input: unknown, ctx: object, options?: LocalDurableOptions): Promise<{
90
+ ok: boolean;
91
+ output: unknown;
92
+ steps: Step[];
93
+ progress: unknown;
94
+ error?: undefined;
95
+ } | {
96
+ output?: undefined;
97
+ ok: boolean;
98
+ error: OpError;
99
+ steps: Step[];
100
+ progress: unknown;
101
+ }>;
102
+ export {};