@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## [1.1.0] - 2026-11-20
4
+
5
+ ### Added
6
+
7
+ - SQL batch metadata helpers that bind discovered capabilities to the selected site, environment and local SQL sources, with warnings for unsupported SDK versions.
8
+ - Optional verified batch snapshots and contract reports in the JSON subprocess interface, while preserving ordinary contract generation.
9
+ - HTML and JavaScript/TypeScript source inspection for Page bootstrap, registered template HMR and external-link warnings, with source positions.
10
+ - A long-running `base-database-dev` subprocess for paired local Page development, with current backend snapshots, file-change events and graceful shutdown.
11
+
12
+ ## [1.0.0] - 2026-11-18
13
+
14
+ ### Added
15
+
16
+ - Shared contract conversion, SDK code generation, server compilation, Timer validation and local Durable execution for Base Database application CLIs.
17
+ - A Node API and a versioned JSON subprocess interface for Go callers.
package/LICENSE ADDED
@@ -0,0 +1,6 @@
1
+ ©Lark Technologies Pte. Ltd. All rights reserved. Use is subject to the Legal Agreements outlined here:
2
+ [Feishu User Terms of Service](https://www.feishu.cn/terms)
3
+ [Feishu Privacy Policy](https://www.feishu.cn/privacy)
4
+ [Feishu Open Platform App Service Provider Security Management Specifications](https://open.feishu.cn/document/uAjLw4CM/uMzNwEjLzcDMx4yM3ATM/management-practice/app-service-provider-security-management-specifications)
5
+ [Lark User Terms of Service](https://www.larksuite.com/user-terms-of-service)
6
+ [Lark Privacy Policy](https://www.larksuite.com/privacy-policy)
package/README.md CHANGED
@@ -1,3 +1,83 @@
1
- # Temporary Holding Version
1
+ # Base Database toolchain
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Local development tools for Base Database applications: contract extraction and conversion, SDK code generation, server compilation, Timer declaration validation and local Durable execution. Requires Node.js 20.19 or newer; subprocess callers should use Node.js 22.12 or newer.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install --save-exact @lark-base-open/base-database-toolchain --registry=https://registry.npmjs.org/
9
+ ```
10
+
11
+ Authentication, platform API calls, project dependency installation, source uploads and publication belong to the calling application. Local validation does not establish cloud validation or publication. Only compile and execute projects you trust: local compilation and contract evaluation execute project code.
12
+
13
+ ## Node API
14
+
15
+ ```js
16
+ import {
17
+ extractContract,
18
+ convertContract,
19
+ } from '@lark-base-open/base-database-toolchain';
20
+ import { buildProject } from '@lark-base-open/base-database-toolchain/builder';
21
+
22
+ const contract = await convertContract(
23
+ extractContract('/absolute/project/server/functions/hello/index.ts'),
24
+ );
25
+ const result = await buildProject('/absolute/project');
26
+ ```
27
+
28
+ Additional exports are `convertLoadedContract`, `runSDKCodegen`, `validateTriggerDeclarations`, `parseDurableEvents` and `driveLocalDurable`. The caller supplies project dependencies, explicit runtime context and compatibility checks; the compiler never supplies a user identity.
29
+
30
+ The `./batch` export provides shared SQL batch capability/execution-snapshot normalization, local-source binding and SDK compatibility warnings. Platform discovery remains the caller's responsibility. These metadata helpers do not authorize invocation.
31
+
32
+ ## JSON subprocess protocol
33
+
34
+ Run `base-database-toolchain` with one JSON object on stdin. It exits after one operation:
35
+
36
+ ```json
37
+ {
38
+ "protocolVersion": 1,
39
+ "operation": "contracts",
40
+ "root": "/absolute/project",
41
+ "server": "server",
42
+ "stateDirectory": ".lark-cli/base-site",
43
+ "brand": "feishu"
44
+ }
45
+ ```
46
+
47
+ Supported operations: `contracts`, `verify-contracts`, `build`, `durable-dev`. `inputMode`, `runtimeOnly`, `legacyBuild` and `durableDev` select project compatibility options. Page builds remain the caller's responsibility.
48
+
49
+ For SQL batch clients, supply an authenticated, consistently discovered `batchSnapshot` with the siteToken, environment, versionId, skillHash and per-Function detail. The toolchain binds it to the actual project token, `runtimeProfile` (default online), and current local SQL source hashes. Verification reuses that bound observation; edited declarations lose the cached capability until a new discovery. An execution view is provenance, not a future lock. An older SDK can still generate single-call clients and returns a `BATCH_SDK_UNSUPPORTED` warning; no batch types are synthesized.
50
+
51
+ Successful contract operations write `lark-site-contract-report.json` under stateDirectory with protocolVersion 1 and warnings, and include nonempty warnings in the stdout success object. Callers requesting batch generation must check that report before claiming the snapshot was consumed; older workers ignore unknown request fields. The shared report is local state, not a deploy artifact.
52
+
53
+ Success emits `{"ok":true,"operation":"contracts"}` on stdout. Failure emits a bounded JSON error on stderr and exits nonzero. Callers must not pass access tokens or application secrets to the process. SQL is not executed here; local Timer checks do not establish platform quota or calendar semantics. Durable local execution cannot invoke hosted Functions without a real host context.
54
+
55
+ For `1.x`, compatible fixes increment patch, compatible features increment minor and incompatible APIs/protocols increment major. Published versions are immutable.
56
+
57
+ ## Page source inspection
58
+
59
+ The `./page-inspection` API and the Go adapter's `inspect-page` operation inspect HTML and JavaScript/TypeScript syntax without executing application code. The result contains bootstrap detection and LinkGuard warnings with one-based source positions. Only registered template HMR is accepted as known inline module code. Unsupported source trees return an inspection warning.
60
+
61
+ These results do not prove that initialization executes successfully, that an external-link guard works in a browser, or that a site is published. The adapter writes the same report to the caller's state directory as `lark-site-page-inspection.json`.
62
+
63
+ ## Local Page development worker
64
+
65
+ `base-database-dev` provides a long-running, newline-delimited JSON subprocess interface to the same Vite server used by the Node CLI. It uses the project's installed Vite and SDK. The caller supplies only a pairing token through `BASE_APP_DEV_PAIRING_TOKEN`; authentication, host URL discovery, locking, Preview publication and decisions about automatic deployment remain with the caller.
66
+
67
+ Keep stdin open and send one startup line:
68
+
69
+ ```json
70
+ {"protocolVersion":1,"workspace":"/absolute/project","port":43100,"hostOrigin":"https://example.test","templateVersion":2}
71
+ ```
72
+
73
+ Only loopback ports 43100–43109 and an exact HTTPS host origin are accepted. Events on stdout include `snapshot`, `listening`, `ready`, `changed`, `error` and `stopped`, each with `protocolVersion: 1`. `ready` only reports that the SDK observed the local origin; it does not establish authentication or successful application behavior. Tokens are excluded from event payloads and redacted from errors.
74
+
75
+ The backend snapshot excludes generated contract projections and observes source declarations, dependencies, bindings and authored Skill metadata. Individual input files are limited to 2 MiB, the tree to 20,000 entries and total content to 64 MiB. Changed-file lists have a byte/count budget; `filesTruncated: true` requires manual review rather than automatic publication. Request a fresh snapshot before a build or remote write:
76
+
77
+ ```json
78
+ {"protocolVersion":1,"command":"snapshot","requestId":"before-write"}
79
+ ```
80
+
81
+ The response echoes `requestId` with the current `fingerprint`. A matching snapshot alone does not authorize publication; the caller must also check its own reviewed publication inputs. Stop with `{"protocolVersion":1,"command":"stop"}`, stdin EOF or SIGINT/SIGTERM. The worker closes its Vite server before exiting. Each input line is limited to 64 KiB.
82
+
83
+ Node hosts can import `startVite`, `watchSnapshot`, `changedFiles`, `snapshotFingerprint` and `runViteIPCWorker` from `@lark-base-open/base-database-toolchain/development`. The IPC worker uses Node child-process messages; `base-database-dev` retains the newline-delimited JSON interface. Both use the same server and snapshot implementation. Hosts remain responsible for authentication, deployment and process supervision.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { runDevelopmentWorker } from '../dist/dev-worker.mjs';
3
+
4
+ runDevelopmentWorker();
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ import { runCompiler } from '../dist/index.js';
3
+ try {
4
+ const chunks = [];
5
+ let bytes = 0;
6
+ for await (const chunk of process.stdin) {
7
+ bytes += chunk.length;
8
+ if (bytes > 4 * 1024 * 1024)
9
+ throw new Error('Compiler request exceeds 4 MiB');
10
+ chunks.push(chunk);
11
+ }
12
+ const request = JSON.parse(Buffer.concat(chunks).toString('utf8'));
13
+ process.stdout.write(JSON.stringify(await runCompiler(request)) + '\n');
14
+ } catch (error) {
15
+ process.stderr.write(
16
+ JSON.stringify({
17
+ ok: false,
18
+ error: { message: String(error?.message ?? error).slice(0, 8192) },
19
+ }) + '\n',
20
+ );
21
+ process.exitCode = 1;
22
+ }
@@ -0,0 +1,37 @@
1
+ export declare function defineFunctionCall(ast: any, definitionName?: string): any;
2
+ export declare function classifyFunctionAST(ast: any): "handler" | "sdk" | "unknown";
3
+ export declare function isDefineFunctionSource(source: any): boolean;
4
+ export declare function parseProjectConfig(source: any, label?: string): any;
5
+ export declare const BUILDER_VERSION: any;
6
+ export declare const ERROR_MARKER = "BASE_DATABASE_BUILD_ERROR:";
7
+ export declare function diagnostic(error: any, stage?: string, functionId?: null): {
8
+ builderVersion: any;
9
+ stage: string;
10
+ functionId: null;
11
+ file: any;
12
+ line: any;
13
+ column: any;
14
+ message: string;
15
+ hint: string;
16
+ };
17
+ export declare function layout(root: any): {
18
+ version: any;
19
+ server: string;
20
+ config: any;
21
+ };
22
+ export declare function safePath(root: any, name: any): any;
23
+ export declare function inventory(root: any, exclude?: any[]): any[];
24
+ export declare function functionInventory(directory: any, requiredFiles?: any[]): string[];
25
+ export declare function ids(root: any, server: any): string[];
26
+ export declare function durableIds(root: any, server: any): string[];
27
+ export declare function run(command: any, args: any, cwd: any): void;
28
+ export declare function buildProject(root: any, options?: {}): Promise<{
29
+ ok: boolean;
30
+ functions: number;
31
+ rebuilt: number;
32
+ output: string;
33
+ builderVersion: any;
34
+ stubbedModules: any[];
35
+ }>;
36
+ /** Local cache integrity only; deployment policy belongs to the platform. */
37
+ export declare function readBuildCache(output: any, expectedIds: any, expectedDurableIds: any): any;