@valbuild/server 0.97.3 → 0.97.5

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.
@@ -1,5 +1,8 @@
1
1
  import { FileMetadata, ImageMetadata, SerializedSchema, Source, SourcePath, ValidationError } from "@valbuild/core";
2
2
  import { Patch } from "@valbuild/core/patch";
3
+ export type FixPatchRemainingError = ValidationError & {
4
+ sourcePath?: SourcePath;
5
+ };
3
6
  export declare function createFixPatch(config: {
4
7
  projectRoot: string;
5
8
  remoteHost: string;
@@ -10,7 +13,7 @@ export declare function createFixPatch(config: {
10
13
  };
11
14
  }, moduleSource?: Source, moduleSchema?: SerializedSchema): Promise<{
12
15
  patch: Patch;
13
- remainingErrors: ValidationError[];
16
+ remainingErrors: FixPatchRemainingError[];
14
17
  } | undefined>;
15
18
  export declare function getImageMetadata(projectRoot: string, validationError: ValidationError): Promise<ImageMetadata>;
16
19
  export declare function getFileMetadata(projectRoot: string, validationError: ValidationError): Promise<FileMetadata>;
@@ -0,0 +1,54 @@
1
+ import { ModuleFilePath, PatchId } from "@valbuild/core";
2
+ /**
3
+ * Replays a `val debug` snapshot: applies its patches the way /save does and
4
+ * validates the result.
5
+ *
6
+ * A snapshot is a minimal Val project (the modules the patches touch plus the
7
+ * ones they reference, a generated val.modules.ts, and the patch chain under
8
+ * .val/patches), so replaying it is just a ValOpsFS pointed at the directory -
9
+ * no snapshot-specific code paths, which is the point: if the replay reproduces
10
+ * the bug, the bug is in the ordinary code.
11
+ */
12
+ export type ReplayResult = {
13
+ patches: {
14
+ patchId: PatchId;
15
+ moduleFilePath: ModuleFilePath;
16
+ createdAt: string;
17
+ authorId: string | null;
18
+ /** The error, if this patch could not be applied. */
19
+ error?: string;
20
+ }[];
21
+ unappliablePatches: Record<PatchId, {
22
+ moduleFilePath: ModuleFilePath;
23
+ message: string;
24
+ }>;
25
+ sourceFilePatchErrors: Record<ModuleFilePath, string[]>;
26
+ binaryFilePatchErrors: Record<string, {
27
+ message: string;
28
+ }>;
29
+ validationErrors: Record<string, unknown>;
30
+ /** What the source files look like with the appliable patches applied. */
31
+ patchedSourceFiles: Record<string, string>;
32
+ hasErrors: boolean;
33
+ };
34
+ export type ReplayComparison = {
35
+ /** Patch ids that failed at capture time and still fail. */
36
+ stillFailing: string[];
37
+ /** Patch ids that failed at capture time but apply now (a fix, or a drift). */
38
+ nowApplying: string[];
39
+ /** Patch ids that apply at capture time but fail now (a regression). */
40
+ newlyFailing: string[];
41
+ reproduced: boolean;
42
+ };
43
+ export declare function replaySnapshot(snapshotDir: string): Promise<ReplayResult>;
44
+ /**
45
+ * Compares a replay against the report captured when the snapshot was taken, so
46
+ * "reproduced the customer's bug" is distinguishable from "behaves differently
47
+ * on this version".
48
+ */
49
+ export declare function compareWithCapturedReport(result: ReplayResult, capturedReport: {
50
+ unappliablePatches?: Record<string, unknown>;
51
+ }): ReplayComparison;
52
+ export declare function readCapturedReport(snapshotDir: string): {
53
+ unappliablePatches?: Record<string, unknown>;
54
+ } | null;
@@ -1,4 +1,3 @@
1
- export type { ServiceOptions } from "./Service.js";
2
1
  export { createService, Service } from "./Service.js";
3
2
  export { createValApiRouter, createValServer, safeReadGit } from "./ValRouter.js";
4
3
  export { ValModuleLoader } from "./ValModuleLoader.js";
@@ -15,3 +14,12 @@ export type { ValServer } from "./ValServer.js";
15
14
  export { getSettings } from "./getSettings.js";
16
15
  export { getPersonalAccessTokenPath, parsePersonalAccessTokenFile, } from "./personalAccessTokens.js";
17
16
  export { uploadRemoteFile } from "./uploadRemoteFile.js";
17
+ export { createModulePathMap, getModulePathRange } from "./modulePathMap.js";
18
+ export type { ModulePathMap } from "./modulePathMap.js";
19
+ export { ValOpsFS } from "./ValOpsFS.js";
20
+ export { ValOpsHttp } from "./ValOpsHttp.js";
21
+ export { loadValModules } from "./loadValModules.js";
22
+ export { formatPatchSourceError } from "./ValOps.js";
23
+ export { compareWithCapturedReport, readCapturedReport, replaySnapshot, } from "./debug/replaySnapshot.js";
24
+ export type { ReplayComparison, ReplayResult } from "./debug/replaySnapshot.js";
25
+ export type { OrderedPatches, PatchAnalysis, PatchSourceError, PreparedCommit, } from "./ValOps.js";
@@ -0,0 +1,23 @@
1
+ import type { ValModules } from "@valbuild/core";
2
+ /**
3
+ * Loads the project's root `val.modules.ts` (or `.js`) using Node's `vm`
4
+ * module and returns its default export (a `ValModules` registry).
5
+ *
6
+ * This is a recursive CommonJS loader: the root modules file and every
7
+ * relative `*.val.ts` / `val.config.ts` it (dynamically) imports are
8
+ * transpiled to CommonJS and evaluated in a `vm` sandbox. Bare specifiers
9
+ * (e.g. `@valbuild/core`) are resolved with the real Node `require` so the
10
+ * user modules share the exact same `@valbuild/core` instance that
11
+ * `extractValModules` uses.
12
+ *
13
+ * Mirrors the pattern already used by the CLI's `evalValConfigFile`.
14
+ *
15
+ * SECURITY: The `vm` context is NOT a security sandbox. It deliberately exposes
16
+ * `process` and a `require` that falls back to the real Node resolver (so user
17
+ * modules share the same `@valbuild/core` instance). This loader must therefore
18
+ * only ever be used to evaluate the project's own first-party, trusted files
19
+ * (`val.modules` and the local `*.val.ts`/`val.config.ts` it imports) — i.e. the
20
+ * same trust level as running the project's build. It must never be used to
21
+ * evaluate untrusted or third-party modules.
22
+ */
23
+ export declare function loadValModules(projectRoot: string): ValModules;
@@ -0,0 +1,25 @@
1
+ import ts from "typescript";
2
+ export type ModulePathMap = {
3
+ [modulePath: string]: {
4
+ children: ModulePathMap;
5
+ start: {
6
+ line: number;
7
+ character: number;
8
+ };
9
+ end: {
10
+ line: number;
11
+ character: number;
12
+ };
13
+ };
14
+ };
15
+ export declare function getModulePathRange(modulePath: string, modulePathMap: ModulePathMap, target?: "key" | "value"): {
16
+ start: {
17
+ line: number;
18
+ character: number;
19
+ };
20
+ end: {
21
+ line: number;
22
+ character: number;
23
+ };
24
+ } | undefined;
25
+ export declare function createModulePathMap(sourceFile: ts.SourceFile): ModulePathMap | undefined;
@@ -2,7 +2,6 @@ import { Patch, PatchError } from "@valbuild/core/patch";
2
2
  import { result } from "@valbuild/core/fp";
3
3
  import { type ValSyntaxErrorTree } from "./patch/ts/syntax.js";
4
4
  import { ValSourceFileHandler } from "./ValSourceFileHandler.js";
5
- import { QuickJSRuntime } from "quickjs-emscripten";
6
5
  import ts from "typescript";
7
- export declare const patchValFile: (id: string, rootDir: string, patch: Patch, sourceFileHandler: ValSourceFileHandler, runtime: QuickJSRuntime) => Promise<void>;
6
+ export declare const patchValFile: (id: string, rootDir: string, patch: Patch, sourceFileHandler: ValSourceFileHandler) => Promise<void>;
8
7
  export declare const patchSourceFile: (sourceFile: ts.SourceFile | string, patch: Patch) => result.Result<ts.SourceFile, ValSyntaxErrorTree | PatchError>;