@valbuild/server 0.12.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.
- package/.babelrc.json +5 -0
- package/CHANGELOG.md +0 -0
- package/dist/declarations/src/LocalValServer.d.ts +22 -0
- package/dist/declarations/src/ProxyValServer.d.ts +52 -0
- package/dist/declarations/src/SerializedModuleContent.d.ts +7 -0
- package/dist/declarations/src/Service.d.ts +24 -0
- package/dist/declarations/src/ValFS.d.ts +12 -0
- package/dist/declarations/src/ValFSHost.d.ts +23 -0
- package/dist/declarations/src/ValModuleLoader.d.ts +14 -0
- package/dist/declarations/src/ValQuickJSRuntime.d.ts +7 -0
- package/dist/declarations/src/ValServer.d.ts +14 -0
- package/dist/declarations/src/ValSourceFileHandler.d.ts +12 -0
- package/dist/declarations/src/createRequestHandler.d.ts +3 -0
- package/dist/declarations/src/expressHelpers.d.ts +4 -0
- package/dist/declarations/src/getCompilerOptions.d.ts +2 -0
- package/dist/declarations/src/hosting.d.ts +71 -0
- package/dist/declarations/src/index.d.ts +12 -0
- package/dist/declarations/src/jwt.d.ts +3 -0
- package/dist/declarations/src/patch/ts/ops.d.ts +27 -0
- package/dist/declarations/src/patch/ts/syntax.d.ts +49 -0
- package/dist/declarations/src/patch/ts/valModule.d.ts +8 -0
- package/dist/declarations/src/patch/validation.d.ts +4 -0
- package/dist/declarations/src/patchValFile.d.ts +9 -0
- package/dist/declarations/src/readValFile.d.ts +3 -0
- package/dist/valbuild-server.cjs.d.ts +2 -0
- package/dist/valbuild-server.cjs.d.ts.map +1 -0
- package/dist/valbuild-server.cjs.dev.js +1500 -0
- package/dist/valbuild-server.cjs.js +7 -0
- package/dist/valbuild-server.cjs.prod.js +1500 -0
- package/dist/valbuild-server.esm.js +1478 -0
- package/package.json +37 -0
- package/test/example-projects/basic-next-javascript/jsconfig.json +8 -0
- package/test/example-projects/basic-next-javascript/package.json +23 -0
- package/test/example-projects/basic-next-javascript/pages/blogs.val.js +20 -0
- package/test/example-projects/basic-next-javascript/val.config.js +4 -0
- package/test/example-projects/basic-next-src-typescript/package.json +23 -0
- package/test/example-projects/basic-next-src-typescript/src/pages/blogs.val.ts +20 -0
- package/test/example-projects/basic-next-src-typescript/src/val.config.ts +5 -0
- package/test/example-projects/basic-next-src-typescript/tsconfig.json +24 -0
- package/test/example-projects/basic-next-typescript/package.json +23 -0
- package/test/example-projects/basic-next-typescript/pages/blogs.val.ts +20 -0
- package/test/example-projects/basic-next-typescript/tsconfig.json +25 -0
- package/test/example-projects/basic-next-typescript/val.config.ts +5 -0
- package/test/example-projects/typescript-description-files/README.md +2 -0
- package/test/example-projects/typescript-description-files/jsconfig.json +8 -0
- package/test/example-projects/typescript-description-files/package.json +23 -0
- package/test/example-projects/typescript-description-files/pages/blogs.val.d.ts +7 -0
- package/test/example-projects/typescript-description-files/pages/blogs.val.js +19 -0
- package/test/example-projects/typescript-description-files/val.config.d.ts +3 -0
- package/test/example-projects/typescript-description-files/val.config.js +5 -0
- package/tsconfig.json +11 -0
package/CHANGELOG.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { Service } from "./Service";
|
|
3
|
+
import { ValServer } from "./ValServer";
|
|
4
|
+
export type LocalValServerOptions = {
|
|
5
|
+
service: Service;
|
|
6
|
+
};
|
|
7
|
+
export declare class LocalValServer implements ValServer {
|
|
8
|
+
readonly options: LocalValServerOptions;
|
|
9
|
+
constructor(options: LocalValServerOptions);
|
|
10
|
+
session(_req: express.Request, res: express.Response): Promise<void>;
|
|
11
|
+
getIds(req: express.Request<{
|
|
12
|
+
0: string;
|
|
13
|
+
}>, res: express.Response): Promise<void>;
|
|
14
|
+
patchIds(req: express.Request<{
|
|
15
|
+
0: string;
|
|
16
|
+
}>, res: express.Response): Promise<void>;
|
|
17
|
+
private badRequest;
|
|
18
|
+
commit(req: express.Request, res: express.Response): Promise<void>;
|
|
19
|
+
authorize(req: express.Request, res: express.Response): Promise<void>;
|
|
20
|
+
callback(req: express.Request, res: express.Response): Promise<void>;
|
|
21
|
+
logout(req: express.Request, res: express.Response): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { ValServer } from "./ValServer";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
export type ProxyValServerOptions = {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
route: string;
|
|
7
|
+
valSecret: string;
|
|
8
|
+
valBuildUrl: string;
|
|
9
|
+
gitCommit: string;
|
|
10
|
+
gitBranch: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class ProxyValServer implements ValServer {
|
|
13
|
+
readonly options: ProxyValServerOptions;
|
|
14
|
+
constructor(options: ProxyValServerOptions);
|
|
15
|
+
authorize(req: express.Request, res: express.Response): Promise<void>;
|
|
16
|
+
callback(req: express.Request, res: express.Response): Promise<void>;
|
|
17
|
+
logout(_req: express.Request, res: express.Response): Promise<void>;
|
|
18
|
+
withAuth<T>(req: express.Request, res: express.Response, handler: (data: IntegratedServerJwtPayload) => Promise<T>): Promise<T | undefined>;
|
|
19
|
+
session(req: express.Request, res: express.Response): Promise<void>;
|
|
20
|
+
getIds(req: express.Request<{
|
|
21
|
+
0: string;
|
|
22
|
+
}>, res: express.Response): Promise<void>;
|
|
23
|
+
patchIds(req: express.Request<{
|
|
24
|
+
0: string;
|
|
25
|
+
}>, res: express.Response): Promise<void>;
|
|
26
|
+
commit(req: express.Request, res: express.Response): Promise<void>;
|
|
27
|
+
private getAuthHeaders;
|
|
28
|
+
private consumeCode;
|
|
29
|
+
private getAuthorizeUrl;
|
|
30
|
+
private getAppErrorUrl;
|
|
31
|
+
}
|
|
32
|
+
declare const IntegratedServerJwtPayload: z.ZodObject<{
|
|
33
|
+
sub: z.ZodString;
|
|
34
|
+
exp: z.ZodNumber;
|
|
35
|
+
token: z.ZodString;
|
|
36
|
+
org: z.ZodString;
|
|
37
|
+
project: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
project: string;
|
|
40
|
+
sub: string;
|
|
41
|
+
exp: number;
|
|
42
|
+
token: string;
|
|
43
|
+
org: string;
|
|
44
|
+
}, {
|
|
45
|
+
project: string;
|
|
46
|
+
sub: string;
|
|
47
|
+
exp: number;
|
|
48
|
+
token: string;
|
|
49
|
+
org: string;
|
|
50
|
+
}>;
|
|
51
|
+
export type IntegratedServerJwtPayload = z.infer<typeof IntegratedServerJwtPayload>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QuickJSRuntime } from "quickjs-emscripten";
|
|
2
|
+
import { Patch } from "@valbuild/core/patch";
|
|
3
|
+
import { ValSourceFileHandler } from "./ValSourceFileHandler";
|
|
4
|
+
import { IValFSHost } from "./ValFSHost";
|
|
5
|
+
import { SerializedModuleContent } from "./SerializedModuleContent";
|
|
6
|
+
import { ModuleId, ModulePath } from "@valbuild/core";
|
|
7
|
+
export type ServiceOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Relative path to the val.config.js file from the root directory.
|
|
10
|
+
*
|
|
11
|
+
* @example src/val.config
|
|
12
|
+
*/
|
|
13
|
+
valConfigPath: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function createService(projectRoot: string, opts: ServiceOptions, host?: IValFSHost): Promise<Service>;
|
|
16
|
+
export declare class Service {
|
|
17
|
+
private readonly sourceFileHandler;
|
|
18
|
+
private readonly runtime;
|
|
19
|
+
readonly valConfigPath: string;
|
|
20
|
+
constructor({ valConfigPath }: ServiceOptions, sourceFileHandler: ValSourceFileHandler, runtime: QuickJSRuntime);
|
|
21
|
+
get(moduleId: ModuleId, modulePath: ModulePath): Promise<SerializedModuleContent>;
|
|
22
|
+
patch(moduleId: string, patch: Patch): Promise<SerializedModuleContent>;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A filesystem that can update and read files.
|
|
3
|
+
* It does not support creating new files or directories.
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export interface ValFS {
|
|
7
|
+
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number | undefined): readonly string[];
|
|
8
|
+
writeFile(filePath: string, data: string, encoding: "binary" | "utf8"): void;
|
|
9
|
+
fileExists(filePath: string): boolean;
|
|
10
|
+
readFile(filePath: string): string | undefined;
|
|
11
|
+
realpath(path: string): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { ValFS } from "./ValFS";
|
|
3
|
+
/**
|
|
4
|
+
* An implementation of methods in the various ts.*Host interfaces
|
|
5
|
+
* that uses ValFS to resolve modules and read/write files.
|
|
6
|
+
*/
|
|
7
|
+
export interface IValFSHost extends ts.ParseConfigHost, ts.ModuleResolutionHost {
|
|
8
|
+
useCaseSensitiveFileNames: boolean;
|
|
9
|
+
writeFile(fileName: string, text: string, encoding: "binary" | "utf8"): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class ValFSHost implements IValFSHost {
|
|
12
|
+
protected readonly valFS: ValFS;
|
|
13
|
+
protected readonly currentDirectory: string;
|
|
14
|
+
constructor(valFS: ValFS, currentDirectory: string);
|
|
15
|
+
useCaseSensitiveFileNames: boolean;
|
|
16
|
+
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number | undefined): readonly string[];
|
|
17
|
+
writeFile(fileName: string, text: string, encoding: "binary" | "utf8"): void;
|
|
18
|
+
getCurrentDirectory(): string;
|
|
19
|
+
getCanonicalFileName(fileName: string): string;
|
|
20
|
+
fileExists(fileName: string): boolean;
|
|
21
|
+
readFile(fileName: string): string | undefined;
|
|
22
|
+
realpath(path: string): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import type { IValFSHost } from "./ValFSHost";
|
|
3
|
+
import { ValSourceFileHandler } from "./ValSourceFileHandler";
|
|
4
|
+
export declare const createModuleLoader: (rootDir: string, host?: IValFSHost) => ValModuleLoader;
|
|
5
|
+
export declare class ValModuleLoader {
|
|
6
|
+
readonly projectRoot: string;
|
|
7
|
+
private readonly compilerOptions;
|
|
8
|
+
private readonly sourceFileHandler;
|
|
9
|
+
private readonly host;
|
|
10
|
+
constructor(projectRoot: string, compilerOptions: ts.CompilerOptions, sourceFileHandler: ValSourceFileHandler, host?: IValFSHost);
|
|
11
|
+
getModule(modulePath: string): string;
|
|
12
|
+
resolveModulePath(containingFilePath: string, requestedModuleName: string): string;
|
|
13
|
+
private findMatchingJsFile;
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { QuickJSWASMModule } from "quickjs-emscripten";
|
|
2
|
+
import { ValModuleLoader } from "./ValModuleLoader";
|
|
3
|
+
export declare function newValQuickJSRuntime(quickJSModule: Pick<QuickJSWASMModule, "newRuntime">, moduleLoader: ValModuleLoader, { maxStackSize, // TODO: these were randomly chosen, we should figure out what the right values are:
|
|
4
|
+
memoryLimit, }?: {
|
|
5
|
+
maxStackSize?: number;
|
|
6
|
+
memoryLimit?: number;
|
|
7
|
+
}): Promise<import("quickjs-emscripten").QuickJSRuntime>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
export interface ValServer {
|
|
3
|
+
authorize(req: express.Request, res: express.Response): Promise<void>;
|
|
4
|
+
callback(req: express.Request, res: express.Response): Promise<void>;
|
|
5
|
+
logout(req: express.Request, res: express.Response): Promise<void>;
|
|
6
|
+
session(req: express.Request, res: express.Response): Promise<void>;
|
|
7
|
+
getIds(req: express.Request<{
|
|
8
|
+
0: string;
|
|
9
|
+
}>, res: express.Response): Promise<void>;
|
|
10
|
+
patchIds(req: express.Request<{
|
|
11
|
+
0: string;
|
|
12
|
+
}>, res: express.Response): Promise<void>;
|
|
13
|
+
commit(req: express.Request, res: express.Response): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { IValFSHost } from "./ValFSHost";
|
|
3
|
+
export declare class ValSourceFileHandler {
|
|
4
|
+
private readonly projectRoot;
|
|
5
|
+
private readonly compilerOptions;
|
|
6
|
+
private readonly host;
|
|
7
|
+
constructor(projectRoot: string, compilerOptions: ts.CompilerOptions, host?: IValFSHost);
|
|
8
|
+
getSourceFile(filePath: string): ts.SourceFile | undefined;
|
|
9
|
+
writeSourceFile(sourceFile: ts.SourceFile): void;
|
|
10
|
+
writeFile(filePath: string, content: string, encoding: "binary" | "utf8"): void;
|
|
11
|
+
resolveSourceModulePath(containingFilePath: string, requestedModuleName: string): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { RequestListener } from "node:http";
|
|
3
|
+
import { ServiceOptions } from "./Service";
|
|
4
|
+
type Opts = ValServerOverrides & ServiceOptions;
|
|
5
|
+
type ValServerOverrides = Partial<{
|
|
6
|
+
/**
|
|
7
|
+
* Override the Val API key.
|
|
8
|
+
*
|
|
9
|
+
* Typically this is set using VAL_API_KEY env var.
|
|
10
|
+
*
|
|
11
|
+
* NOTE: if this is set you must also set valSecret or VAL_SECRET env var.
|
|
12
|
+
*/
|
|
13
|
+
apiKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* Override the Val session key.
|
|
16
|
+
*
|
|
17
|
+
* This can be any randomly generated string.
|
|
18
|
+
* It will be used for authentication between the frontend and val api
|
|
19
|
+
* endpoints in this app.
|
|
20
|
+
*
|
|
21
|
+
* Typically this is set using VAL_SECRET env var.
|
|
22
|
+
*
|
|
23
|
+
* NOTE: if this is set you must also set apiKey or VAL_API_KEY env var.
|
|
24
|
+
*/
|
|
25
|
+
valSecret: string;
|
|
26
|
+
/**
|
|
27
|
+
* Override the default the mode of operation.
|
|
28
|
+
*
|
|
29
|
+
* Typically this should not be set.
|
|
30
|
+
*
|
|
31
|
+
* "local" means that changes will be written to the local filesystem,
|
|
32
|
+
* which is what you want when developing locally.
|
|
33
|
+
*
|
|
34
|
+
* "proxy" means that changes will proxied to https://app.val.build
|
|
35
|
+
* and eventually be committed in the Git repository.
|
|
36
|
+
*
|
|
37
|
+
* It will automatically be "proxy" if both VAL_API_KEY env var (or the apiKey property) and VAL_SECRET env var (or the valSecret property)
|
|
38
|
+
* is set.
|
|
39
|
+
*
|
|
40
|
+
* If both is missing, it will default to "local".
|
|
41
|
+
*/
|
|
42
|
+
mode: "proxy" | "local";
|
|
43
|
+
/**
|
|
44
|
+
* Current git commit.
|
|
45
|
+
*
|
|
46
|
+
* Required if mode is "proxy".
|
|
47
|
+
*
|
|
48
|
+
* @example "e83c5163316f89bfbde7d9ab23ca2e25604af290"
|
|
49
|
+
*/
|
|
50
|
+
gitCommit: string;
|
|
51
|
+
/**
|
|
52
|
+
* Current git branch.
|
|
53
|
+
*
|
|
54
|
+
* Required if mode is "proxy".
|
|
55
|
+
*
|
|
56
|
+
* @example "main"
|
|
57
|
+
*/
|
|
58
|
+
gitBranch: string;
|
|
59
|
+
/**
|
|
60
|
+
* The base url of Val.
|
|
61
|
+
*
|
|
62
|
+
* Typically this should not be set.
|
|
63
|
+
*
|
|
64
|
+
* Can also be overridden using the VAL_BUILD_URL env var.
|
|
65
|
+
*
|
|
66
|
+
* @example "https://app.val.build"
|
|
67
|
+
*/
|
|
68
|
+
valBuildUrl: string;
|
|
69
|
+
}>;
|
|
70
|
+
export declare function createRequestListener(route: string, opts: Opts): RequestListener;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { ServiceOptions } from "./Service";
|
|
2
|
+
export { createService, Service } from "./Service";
|
|
3
|
+
export { createRequestHandler } from "./createRequestHandler";
|
|
4
|
+
export { createRequestListener } from "./hosting";
|
|
5
|
+
export { ValModuleLoader } from "./ValModuleLoader";
|
|
6
|
+
export { getCompilerOptions } from "./getCompilerOptions";
|
|
7
|
+
export { ValSourceFileHandler } from "./ValSourceFileHandler";
|
|
8
|
+
export { ValFSHost } from "./ValFSHost";
|
|
9
|
+
export type { IValFSHost } from "./ValFSHost";
|
|
10
|
+
export type { ValFS } from "./ValFS";
|
|
11
|
+
export { patchSourceFile } from "./patchValFile";
|
|
12
|
+
export { formatSyntaxErrorTree } from "./patch/ts/syntax";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { result, array } from "@valbuild/core/fp";
|
|
3
|
+
import { ValSyntaxErrorTree } from "./syntax";
|
|
4
|
+
import { Ops, PatchError, JSONValue } from "@valbuild/core/patch";
|
|
5
|
+
type TSOpsResult<T> = result.Result<T, PatchError | ValSyntaxErrorTree>;
|
|
6
|
+
declare module "typescript" {
|
|
7
|
+
interface PrinterOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Internal option that stops printing unnecessary ASCII escape sequences
|
|
10
|
+
* in strings, though it might have unintended effects. Might be useful?
|
|
11
|
+
*/
|
|
12
|
+
neverAsciiEscape?: boolean;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare function getFromNode(node: ts.Expression, key: string): TSOpsResult<ts.Expression | undefined>;
|
|
16
|
+
export declare class TSOps implements Ops<ts.SourceFile, ValSyntaxErrorTree> {
|
|
17
|
+
private findRoot;
|
|
18
|
+
constructor(findRoot: (document: ts.SourceFile) => result.Result<ts.Expression, ValSyntaxErrorTree>);
|
|
19
|
+
get(document: ts.SourceFile, path: string[]): TSOpsResult<JSONValue>;
|
|
20
|
+
add(document: ts.SourceFile, path: string[], value: JSONValue): TSOpsResult<ts.SourceFile>;
|
|
21
|
+
remove(document: ts.SourceFile, path: array.NonEmptyArray<string>): TSOpsResult<ts.SourceFile>;
|
|
22
|
+
replace(document: ts.SourceFile, path: string[], value: JSONValue): TSOpsResult<ts.SourceFile>;
|
|
23
|
+
move(document: ts.SourceFile, from: array.NonEmptyArray<string>, path: string[]): TSOpsResult<ts.SourceFile>;
|
|
24
|
+
copy(document: ts.SourceFile, from: string[], path: string[]): TSOpsResult<ts.SourceFile>;
|
|
25
|
+
test(document: ts.SourceFile, path: string[], value: JSONValue): TSOpsResult<boolean>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { result } from "@valbuild/core/fp";
|
|
3
|
+
import { JSONValue } from "@valbuild/core/patch";
|
|
4
|
+
export declare class ValSyntaxError {
|
|
5
|
+
message: string;
|
|
6
|
+
node: ts.Node;
|
|
7
|
+
constructor(message: string, node: ts.Node);
|
|
8
|
+
}
|
|
9
|
+
export type ValSyntaxErrorTree = ValSyntaxError | [ValSyntaxErrorTree, ...ValSyntaxErrorTree[]];
|
|
10
|
+
export declare function flattenErrors(tree: ValSyntaxErrorTree): [ValSyntaxError, ...ValSyntaxError[]];
|
|
11
|
+
export declare function flatMapErrors<T>(tree: ValSyntaxErrorTree, cb: (error: ValSyntaxError) => T): [T, ...T[]];
|
|
12
|
+
export declare function formatSyntaxError(error: ValSyntaxError, sourceFile: ts.SourceFile): string;
|
|
13
|
+
export declare function formatSyntaxErrorTree(tree: ValSyntaxErrorTree, sourceFile: ts.SourceFile): string[];
|
|
14
|
+
type LiteralPropertyName = (ts.Identifier | ts.StringLiteral | ts.NumericLiteral) & {
|
|
15
|
+
/**
|
|
16
|
+
* The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral,
|
|
17
|
+
* or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters.
|
|
18
|
+
* For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1".
|
|
19
|
+
* https://github.com/microsoft/TypeScript/blob/4b794fe1dd0d184d3f8f17e94d8187eace57c91e/src/compiler/types.ts#L2127-L2131
|
|
20
|
+
*/
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
type LiteralPropertyAssignment = ts.PropertyAssignment & {
|
|
24
|
+
name: LiteralPropertyName;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Validates that the expression is a JSON compatible type of expression without
|
|
28
|
+
* validating its children.
|
|
29
|
+
*/
|
|
30
|
+
export declare function shallowValidateExpression(value: ts.Expression): ValSyntaxError | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Validates that the expression is JSON compatible.
|
|
33
|
+
*/
|
|
34
|
+
export declare function deepValidateExpression(value: ts.Expression): result.Result<void, ValSyntaxErrorTree>;
|
|
35
|
+
/**
|
|
36
|
+
* Evaluates the expression as a JSON value
|
|
37
|
+
*/
|
|
38
|
+
export declare function evaluateExpression(value: ts.Expression): result.Result<JSONValue, ValSyntaxErrorTree>;
|
|
39
|
+
export declare function findObjectPropertyAssignment(value: ts.ObjectLiteralExpression, key: string): result.Result<LiteralPropertyAssignment | undefined, ValSyntaxErrorTree>;
|
|
40
|
+
export declare function isValFileMethodCall(node: ts.Expression): node is ts.CallExpression;
|
|
41
|
+
export declare function findValFileNodeArg(node: ts.CallExpression): result.Result<ts.StringLiteral, ValSyntaxErrorTree>;
|
|
42
|
+
export declare function findValFileMetadataArg(node: ts.CallExpression): result.Result<ts.ObjectLiteralExpression | undefined, ValSyntaxErrorTree>;
|
|
43
|
+
/**
|
|
44
|
+
* Given a list of expressions, validates that all the expressions are not
|
|
45
|
+
* spread elements. In other words, it ensures that the expressions are the
|
|
46
|
+
* initializers of the values at their respective indices in the evaluated list.
|
|
47
|
+
*/
|
|
48
|
+
export declare function validateInitializers(nodes: ReadonlyArray<ts.Expression>): ValSyntaxErrorTree | undefined;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { result } from "@valbuild/core/fp";
|
|
3
|
+
import { ValSyntaxErrorTree } from "./syntax";
|
|
4
|
+
export type ValModuleAnalysis = {
|
|
5
|
+
schema: ts.Expression;
|
|
6
|
+
source: ts.Expression;
|
|
7
|
+
};
|
|
8
|
+
export declare function analyzeValModule(sourceFile: ts.SourceFile): result.Result<ValModuleAnalysis, ValSyntaxErrorTree>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Patch, PatchError } from "@valbuild/core/patch";
|
|
2
|
+
import { result } from "@valbuild/core/fp";
|
|
3
|
+
import { type ValSyntaxErrorTree } from "./patch/ts/syntax";
|
|
4
|
+
import { ValSourceFileHandler } from "./ValSourceFileHandler";
|
|
5
|
+
import { QuickJSRuntime } from "quickjs-emscripten";
|
|
6
|
+
import ts from "typescript";
|
|
7
|
+
import { SerializedModuleContent } from "./SerializedModuleContent";
|
|
8
|
+
export declare const patchValFile: (id: string, valConfigPath: string, patch: Patch, sourceFileHandler: ValSourceFileHandler, runtime: QuickJSRuntime) => Promise<SerializedModuleContent>;
|
|
9
|
+
export declare const patchSourceFile: (sourceFile: ts.SourceFile, patch: Patch) => result.Result<ts.SourceFile, ValSyntaxErrorTree | PatchError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valbuild-server.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
|