Vendor the IO engine from docmost-sync into packages/git-sync/src/engine: - git.ts (VaultGit, execFile shell-out — verbatim) - pull.ts (readExisting, computePullActions, applyPullActions) - push.ts (classifyRenameMoves, computePushActions, applyPushActions, runPush) - settings.ts adapted (pure parseSettings + Settings type; no process.env binding — the server builds Settings from EnvironmentService later), config-errors.ts. CLI main()/import.meta entrypoints dropped (server drives in-process). Client seam: new engine/client.types.ts defines GitSyncClient; pull.ts/push.ts now use Pick<GitSyncClient, ...> instead of the non-vendored DocmostClient. Engine logic byte-identical except a zod4-compat fix in config-errors (zod4 dropped the issue.received==='undefined' signal; match /received undefined/ on the message). Ported the engine unit tests (compute/apply pull+push actions, classify-rename- moves, run-push, settings, config-errors) incl. real-git temp-repo tests: 431 pass / 3 expected-fail (was 314/3). REST/CLI-coupled upstream tests skipped (noted). CJS build clean. No apps/server wiring yet (next step). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
/**
|
|
* Engine settings (plan §2.1 / §7.2 — ADAPTED for vendoring).
|
|
*
|
|
* Upstream this module also loaded `.env` (`dotenv`) and bound `parseSettings`
|
|
* to `process.env` via a `loadSettings()` entry point. In gitmost the engine is
|
|
* driven IN-PROCESS by the NestJS server, which builds the `Settings` object
|
|
* from `EnvironmentService` (plan §7.2) — so the engine must NOT reach into
|
|
* `process.env` here. We therefore vendor ONLY:
|
|
* - the `Settings` type the engine consumes, and
|
|
* - `parseSettings(env)` as a PURE function (validate a raw env object -> typed
|
|
* `Settings`), kept for unit tests and for the server to reuse if it wants
|
|
* to validate an env-shaped object.
|
|
* The `loadSettings()` / `loadDotenv()` side-effecting entry point is dropped.
|
|
*/
|
|
import { z } from 'zod';
|
|
export declare const envSchema: z.ZodObject<{
|
|
DOCMOST_API_URL: z.ZodString;
|
|
DOCMOST_EMAIL: z.ZodString;
|
|
DOCMOST_PASSWORD: z.ZodString;
|
|
DOCMOST_SPACE_ID: z.ZodString;
|
|
VAULT_PATH: z.ZodDefault<z.ZodString>;
|
|
GIT_REMOTE: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
POLL_INTERVAL_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
DEBOUNCE_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
LOG_LEVEL: z.ZodDefault<z.ZodEnum<{
|
|
info: "info";
|
|
error: "error";
|
|
debug: "debug";
|
|
warn: "warn";
|
|
}>>;
|
|
}, z.core.$strip>;
|
|
export type Settings = {
|
|
docmostApiUrl: string;
|
|
docmostEmail: string;
|
|
docmostPassword: string;
|
|
docmostSpaceId: string;
|
|
vaultPath: string;
|
|
gitRemote?: string;
|
|
pollIntervalMs: number;
|
|
debounceMs: number;
|
|
logLevel: 'debug' | 'info' | 'warn' | 'error';
|
|
};
|
|
export declare function parseSettings(env: NodeJS.ProcessEnv): Settings;
|