@veriforms/webapp-vite 0.0.0-stage → 0.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.
@@ -0,0 +1,94 @@
1
+ import { type Plugin } from 'vite';
2
+ /** The module server code imports `defineServerFunction` from (VeriForms.Ai.CwaServerFunctions.SdkModule). */
3
+ export declare const SERVER_SDK_MODULE = "@veriforms/webapp-sdk/server";
4
+ export declare const DEFINE_NAME = "defineServerFunction";
5
+ /** Where the build writes the manifest (beside server/, never uploaded as a file: `vf app push` sends it as the manifest). */
6
+ export declare const SERVER_MANIFEST_FILE = "server-manifest.json";
7
+ /** The types file that registers the functions for the pages (project root, next to vf-app.d.ts). */
8
+ export declare const SERVER_TYPES_FILE = "vf-server.d.ts";
9
+ /** Where shared server code goes in the build. */
10
+ export declare const SERVER_SHARED_DIR = "_shared";
11
+ /** The route-name rule (VeriForms.Ai.CwaServerFunctions.NamePattern). */
12
+ export declare const SERVER_FUNCTION_NAME: RegExp;
13
+ /** The keys a definition may have (ServerManifestReader.DefinitionKeys). */
14
+ export declare const DEFINITION_KEYS: readonly ["access", "sources", "input", "handler"];
15
+ /** The JSON-Schema subset of the input contract (ServerManifestReader.SchemaKeywords). */
16
+ export declare const SCHEMA_KEYWORDS: readonly ["type", "properties", "required", "items", "maxLength", "maximum", "enum"];
17
+ export declare const SCHEMA_TYPES: readonly ["object", "array", "string", "number", "integer", "boolean", "null"];
18
+ /** Globals server code may not name (ServerManifestReader.ForbiddenGlobals). */
19
+ export declare const FORBIDDEN_GLOBALS: readonly ["eval", "Function", "WebAssembly", "SharedArrayBuffer", "Atomics"];
20
+ /** At most this many functions (CwaServerFunctions.MaxFunctions). */
21
+ export declare const MAX_FUNCTIONS = 50;
22
+ /**
23
+ * camelCase → kebab-case route name — the SDK's `kebabOf` (tools/webapp-sdk/src/serverRoute.ts), the same
24
+ * rule; test/serverBuild.test.ts maps one table through both.
25
+ */
26
+ export declare function kebabOf(name: string): string;
27
+ /** One function in the manifest, in the gateway's shape (VeriForms.Ai.ServerFunctions.ServerFunctionEntry, camelCase JSON). */
28
+ export interface ServerFunctionEntry {
29
+ name: string;
30
+ file: string;
31
+ sources: string[];
32
+ access: 'signedIn' | 'anyone';
33
+ inputSchemaJson: string | null;
34
+ }
35
+ /** The manifest (VeriForms.Ai.ServerFunctions.ServerManifest): version 1, functions by name. */
36
+ export interface ServerManifest {
37
+ version: 1;
38
+ functions: ServerFunctionEntry[];
39
+ }
40
+ /** The function files of src/server/: entry name (path below server/ without extension) → file. Shared code (a "_" file or folder) is not one. */
41
+ export declare function findServerFunctionFiles(serverDir: string): Record<string, string>;
42
+ /** True when `file` is inside `dir`. */
43
+ export declare function isInside(dir: string, file: string): boolean;
44
+ /** True for a function file of src/server/ (not shared code): no "_" segment below server/. */
45
+ export declare function isFunctionFile(serverDir: string, file: string): boolean;
46
+ /** The data-source keys of a config.json ("dataSources", without "_" notes); null when it does not parse (then not checked). */
47
+ export declare function configSourceKeys(configJson: string | undefined): string[] | null;
48
+ /** Sorted keys, compact (ServerManifestReader.Canonical) — so two writings of one schema compare equal. */
49
+ export declare function canonical(value: unknown): string;
50
+ /** The result of reading the built server code: the manifest, and every refusal the gateway would give (file:line — sentence). */
51
+ export interface DerivedManifest {
52
+ manifest: ServerManifest;
53
+ errors: string[];
54
+ }
55
+ /**
56
+ * The manifest of the built server files (path under the build → code), read with the gateway's rules
57
+ * (ServerManifestReader.Derive). `configSources`: the config's source keys; null = not checked.
58
+ */
59
+ export declare function deriveServerManifest(files: Array<{
60
+ path: string;
61
+ code: string;
62
+ }>, configSources: string[] | null): DerivedManifest;
63
+ /**
64
+ * The built entry chunk with every export list naming its kebab-case route: `export { placeOrder }` →
65
+ * `export { placeOrder as "place-order" }`. Names already routes stay as they are. Returns the code and the
66
+ * renames (export name → route) for the types file and the errors (two exports on one route).
67
+ */
68
+ export declare function renameExportsToRoutes(code: string): {
69
+ code: string;
70
+ renamed: Array<{
71
+ from: string;
72
+ to: string;
73
+ }>;
74
+ errors: string[];
75
+ };
76
+ /**
77
+ * The exported definitions of a function file's source, by export name — read with a pattern (types only:
78
+ * a definition it misses is a compile error in the page, never a wrong route; the route and the manifest
79
+ * come from the built code).
80
+ */
81
+ export declare function definedExports(source: string): string[];
82
+ /** The contents of vf-server.d.ts for the function files (entry name → file) of a project rooted at `root`. */
83
+ export declare function serverTypes(root: string, files: Record<string, string>): string;
84
+ /**
85
+ * The plugin of the server build: SDK import external, the import rules, the routes. `serverDir` and
86
+ * `pagesDir` are absolute.
87
+ */
88
+ export declare function serverBuildPlugin(serverDir: string, pagesDir: string): Plugin;
89
+ /**
90
+ * Builds the function files (entry name → file) of the project at `root` into <outDir>/server/ and writes
91
+ * <outDir>/server-manifest.json — the manifest read from the built code with the gateway's rules. Throws,
92
+ * naming every problem, when the gateway would refuse it.
93
+ */
94
+ export declare function buildServerFunctions(root: string, outDir: string, files: Record<string, string>, mode: string, pagesDir?: string): Promise<ServerManifest>;