@valbuild/server 0.33.0 → 0.35.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/dist/declarations/src/LocalValServer.d.ts +26 -16
- package/dist/declarations/src/SerializedModuleContent.d.ts +1 -1
- package/dist/declarations/src/Service.d.ts +1 -1
- package/dist/declarations/src/ValServer.d.ts +45 -14
- package/dist/declarations/src/{hosting.d.ts → createValApiRouter.d.ts} +4 -3
- package/dist/declarations/src/index.d.ts +1 -2
- package/dist/declarations/src/patchValFile.d.ts +1 -2
- package/dist/valbuild-server.cjs.dev.js +660 -412
- package/dist/valbuild-server.cjs.prod.js +660 -412
- package/dist/valbuild-server.esm.js +658 -409
- package/package.json +7 -6
- package/dist/declarations/src/createRequestHandler.d.ts +0 -3
@@ -1,8 +1,11 @@
|
|
1
|
-
import express from "express";
|
2
1
|
import { Service } from "./Service.js";
|
3
|
-
import {
|
2
|
+
import { ApiGetPatchResponse, ApiPostPatchResponse, ApiTreeResponse } from "@valbuild/core";
|
3
|
+
import { VAL_ENABLE_COOKIE_NAME, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, ValServerJsonResult, ValServerRedirectResult, ValServerResult, ValSession } from "@valbuild/shared/internal";
|
4
|
+
import { ValServer, ValServerCallbacks } from "./ValServer.js";
|
4
5
|
export type LocalValServerOptions = {
|
5
6
|
service: Service;
|
7
|
+
valEnableRedirectUrl?: string;
|
8
|
+
valDisableRedirectUrl?: string;
|
6
9
|
git: {
|
7
10
|
commit?: string;
|
8
11
|
branch?: string;
|
@@ -10,19 +13,26 @@ export type LocalValServerOptions = {
|
|
10
13
|
};
|
11
14
|
export declare class LocalValServer implements ValServer {
|
12
15
|
readonly options: LocalValServerOptions;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
16
|
+
readonly callbacks: ValServerCallbacks;
|
17
|
+
constructor(options: LocalValServerOptions, callbacks: ValServerCallbacks);
|
18
|
+
session(): Promise<ValServerJsonResult<ValSession>>;
|
19
|
+
getTree(treePath: string, query: {
|
20
|
+
patch?: string;
|
21
|
+
schema?: string;
|
22
|
+
source?: string;
|
23
|
+
}): Promise<ValServerJsonResult<ApiTreeResponse>>;
|
24
|
+
enable(query: {
|
25
|
+
redirect_to?: string;
|
26
|
+
}): Promise<ValServerRedirectResult<VAL_ENABLE_COOKIE_NAME>>;
|
27
|
+
disable(query: {
|
28
|
+
redirect_to?: string;
|
29
|
+
}): Promise<ValServerRedirectResult<VAL_ENABLE_COOKIE_NAME>>;
|
30
|
+
postPatches(body: unknown): Promise<ValServerJsonResult<ApiPostPatchResponse>>;
|
21
31
|
private badRequest;
|
22
|
-
|
23
|
-
authorize(
|
24
|
-
callback(
|
25
|
-
logout(
|
26
|
-
getFiles(
|
27
|
-
getPatches(
|
32
|
+
postCommit(): Promise<ValServerJsonResult<{}>>;
|
33
|
+
authorize(): Promise<ValServerRedirectResult<VAL_STATE_COOKIE>>;
|
34
|
+
callback(): Promise<ValServerRedirectResult<VAL_STATE_COOKIE | VAL_SESSION_COOKIE>>;
|
35
|
+
logout(): Promise<ValServerResult<VAL_STATE_COOKIE | VAL_SESSION_COOKIE>>;
|
36
|
+
getFiles(): Promise<ValServerResult<never, ReadableStream<Uint8Array>>>;
|
37
|
+
getPatches(): Promise<ValServerJsonResult<ApiGetPatchResponse>>;
|
28
38
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { type Source, type SerializedSchema, ValidationErrors } from "@valbuild/core";
|
2
|
-
import { ModuleId,
|
2
|
+
import type { ModuleId, SourcePath } from "@valbuild/core";
|
3
3
|
export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module"];
|
4
4
|
export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
|
5
5
|
export type SerializedModuleContent = {
|
@@ -26,6 +26,6 @@ export declare class Service {
|
|
26
26
|
readonly valConfigPath: string;
|
27
27
|
constructor({ valConfigPath }: ServiceOptions, sourceFileHandler: ValSourceFileHandler, runtime: QuickJSRuntime);
|
28
28
|
get(moduleId: ModuleId, modulePath: ModulePath): Promise<SerializedModuleContent>;
|
29
|
-
patch(moduleId: string, patch: Patch): Promise<
|
29
|
+
patch(moduleId: string, patch: Patch): Promise<void>;
|
30
30
|
dispose(): void;
|
31
31
|
}
|
@@ -1,16 +1,47 @@
|
|
1
|
-
import
|
1
|
+
import { ApiGetPatchResponse, ApiPostPatchResponse, ApiTreeResponse } from "@valbuild/core";
|
2
|
+
import { VAL_ENABLE_COOKIE_NAME, VAL_SESSION_COOKIE, VAL_STATE_COOKIE, ValCookies, ValServerError, ValServerJsonResult, ValServerRedirectResult, ValServerResult, ValSession } from "@valbuild/shared/internal";
|
3
|
+
export declare const ENABLE_COOKIE_VALUE: {
|
4
|
+
readonly value: "true";
|
5
|
+
readonly options: {
|
6
|
+
readonly httpOnly: false;
|
7
|
+
readonly sameSite: "lax";
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export declare function getRedirectUrl(query: {
|
11
|
+
redirect_to?: string | undefined;
|
12
|
+
}, overrideHost: string | undefined): string | ValServerError;
|
13
|
+
export type ValServerCallbacks = {
|
14
|
+
isEnabled: () => Promise<boolean>;
|
15
|
+
onEnable: (success: boolean) => Promise<void>;
|
16
|
+
onDisable: (success: boolean) => Promise<void>;
|
17
|
+
};
|
2
18
|
export interface ValServer {
|
3
|
-
authorize(
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
19
|
+
authorize(query: {
|
20
|
+
redirect_to?: string;
|
21
|
+
}): Promise<ValServerRedirectResult<VAL_STATE_COOKIE>>;
|
22
|
+
callback(query: {
|
23
|
+
code?: string;
|
24
|
+
state?: string;
|
25
|
+
}, cookies: ValCookies<VAL_STATE_COOKIE>): Promise<ValServerRedirectResult<VAL_STATE_COOKIE | VAL_SESSION_COOKIE>>;
|
26
|
+
enable(query: {
|
27
|
+
redirect_to?: string;
|
28
|
+
}): Promise<ValServerRedirectResult<VAL_ENABLE_COOKIE_NAME>>;
|
29
|
+
disable(query: {
|
30
|
+
redirect_to?: string;
|
31
|
+
}): Promise<ValServerRedirectResult<VAL_ENABLE_COOKIE_NAME>>;
|
32
|
+
logout(): Promise<ValServerResult<VAL_STATE_COOKIE | VAL_SESSION_COOKIE>>;
|
33
|
+
session(cookies: ValCookies<VAL_SESSION_COOKIE>): Promise<ValServerJsonResult<ValSession>>;
|
34
|
+
getTree(treePath: string, query: {
|
35
|
+
patch?: string;
|
36
|
+
schema?: string;
|
37
|
+
source?: string;
|
38
|
+
}, cookies: ValCookies<VAL_SESSION_COOKIE>): Promise<ValServerJsonResult<ApiTreeResponse>>;
|
39
|
+
getPatches(query: {
|
40
|
+
id?: string[];
|
41
|
+
}, cookies: ValCookies<VAL_SESSION_COOKIE>): Promise<ValServerJsonResult<ApiGetPatchResponse>>;
|
42
|
+
postPatches(body: unknown, cookies: ValCookies<VAL_SESSION_COOKIE>): Promise<ValServerJsonResult<ApiPostPatchResponse>>;
|
43
|
+
postCommit(cookies: ValCookies<VAL_SESSION_COOKIE>): Promise<ValServerJsonResult<{}>>;
|
44
|
+
getFiles(treePath: string, query: {
|
45
|
+
sha256?: string;
|
46
|
+
}, cookies: ValCookies<VAL_SESSION_COOKIE>): Promise<ValServerResult<never, ReadableStream<Uint8Array>>>;
|
16
47
|
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import type { RequestListener } from "node:http";
|
3
1
|
import { ServiceOptions } from "./Service.js";
|
2
|
+
import { ValServer, ValServerCallbacks } from "./ValServer.js";
|
3
|
+
import { ValServerGenericResult } from "@valbuild/shared/internal";
|
4
4
|
type Opts = ValServerOverrides & ServiceOptions;
|
5
5
|
type ValServerOverrides = Partial<{
|
6
6
|
/**
|
@@ -105,9 +105,10 @@ type ValServerOverrides = Partial<{
|
|
105
105
|
*/
|
106
106
|
valDisableRedirectUrl?: string;
|
107
107
|
}>;
|
108
|
+
export declare function createValServer(route: string, opts: Opts, callbacks: ValServerCallbacks): Promise<ValServer>;
|
108
109
|
export declare function safeReadGit(cwd: string): Promise<{
|
109
110
|
commit?: string;
|
110
111
|
branch?: string;
|
111
112
|
}>;
|
112
|
-
export declare function
|
113
|
+
export declare function createValApiRouter<Res>(route: string, valServerPromise: Promise<ValServer>, convert: (valServerRes: ValServerGenericResult) => Res): (req: Request) => Promise<Res>;
|
113
114
|
export {};
|
@@ -1,7 +1,6 @@
|
|
1
1
|
export type { ServiceOptions } from "./Service.js";
|
2
2
|
export { createService, Service } from "./Service.js";
|
3
|
-
export {
|
4
|
-
export { createRequestListener, safeReadGit } from "./hosting.js";
|
3
|
+
export { createValApiRouter, createValServer, safeReadGit, } from "./createValApiRouter.js";
|
5
4
|
export { ValModuleLoader } from "./ValModuleLoader.js";
|
6
5
|
export { getCompilerOptions } from "./getCompilerOptions.js";
|
7
6
|
export { ValSourceFileHandler } from "./ValSourceFileHandler.js";
|
@@ -4,6 +4,5 @@ import { type ValSyntaxErrorTree } from "./patch/ts/syntax.js";
|
|
4
4
|
import { ValSourceFileHandler } from "./ValSourceFileHandler.js";
|
5
5
|
import { QuickJSRuntime } from "quickjs-emscripten";
|
6
6
|
import ts from "typescript";
|
7
|
-
|
8
|
-
export declare const patchValFile: (id: string, valConfigPath: string, patch: Patch, sourceFileHandler: ValSourceFileHandler, runtime: QuickJSRuntime) => Promise<SerializedModuleContent>;
|
7
|
+
export declare const patchValFile: (id: string, valConfigPath: string, patch: Patch, sourceFileHandler: ValSourceFileHandler, runtime: QuickJSRuntime) => Promise<void>;
|
9
8
|
export declare const patchSourceFile: (sourceFile: ts.SourceFile | string, patch: Patch) => result.Result<ts.SourceFile, ValSyntaxErrorTree | PatchError>;
|