@earendil-works/pi-env 0.0.1 → 1.0.4

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,67 @@
1
+ import { type PlatformPath } from "node:path";
2
+ import type { Context } from "@earendil-works/chord";
3
+ import { type BinaryReader, type DirReader, type ExecutionEnv, ExecutionError, FileError, type FileInfo, type FileWatcher, type Result, type ShellExecOptions, type ShellExecResult, type TextLineReader, type WatchChange, type WatchTarget } from "@earendil-works/pi-durable/env";
4
+ import { type Connection, type RemoteInfo } from "./connection.ts";
5
+ import { type RemoteWatchOptions } from "./watch.ts";
6
+ export interface RemoteExecutionEnvOptions {
7
+ connection: Connection;
8
+ /** The file namespace: equal ids see the same files (`FileSystem.id`), e.g. `pi-env:<env name>`. */
9
+ id: string;
10
+ cwd: string;
11
+ shellPath?: string;
12
+ /** Added to the remote environment of every command that inherits it, like `NodeExecutionEnv`'s `shellEnv`. */
13
+ shellEnv?: Record<string, string>;
14
+ /** How the daemon watches, like `NodeExecutionEnv`'s `watch` option. */
15
+ watch?: RemoteWatchOptions;
16
+ }
17
+ /** Node's path rules of the remote system. */
18
+ export declare function remotePath(connection: Connection): Promise<PlatformPath>;
19
+ /**
20
+ * An `ExecutionEnv` on another machine, reached through a pi-env daemon. Results match `NodeExecutionEnv` running on
21
+ * that machine: the daemon performs the system calls, and this class applies Node's path, error, and result rules.
22
+ */
23
+ export declare class RemoteExecutionEnv implements ExecutionEnv {
24
+ #private;
25
+ readonly id: string;
26
+ cwd: string;
27
+ readonly connection: Connection;
28
+ constructor(options: RemoteExecutionEnvOptions);
29
+ absolutePath(path: string, _context: Context): Promise<Result<string, FileError>>;
30
+ joinPath(parts: string[], _context: Context): Promise<Result<string, FileError>>;
31
+ readTextFile(path: string, context: Context): Promise<Result<string, FileError>>;
32
+ readBinaryFile(path: string, context: Context): Promise<Result<Uint8Array, FileError>>;
33
+ openBinaryReader(path: string, options: {
34
+ noFollow?: boolean;
35
+ } | undefined, context: Context): Promise<Result<BinaryReader, FileError>>;
36
+ openTextLineReader(path: string, context: Context): Promise<Result<TextLineReader, FileError>>;
37
+ readTextLines(path: string, options: {
38
+ maxLines?: number;
39
+ } | undefined, context: Context): Promise<Result<string[], FileError>>;
40
+ writeFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;
41
+ appendFile(path: string, content: string | Uint8Array, context: Context): Promise<Result<void, FileError>>;
42
+ truncateFile(path: string, size: number, context: Context): Promise<Result<void, FileError>>;
43
+ flushFile(path: string, context: Context): Promise<Result<void, FileError>>;
44
+ renameFile(sourcePath: string, destinationPath: string, context: Context): Promise<Result<void, FileError>>;
45
+ fileInfo(path: string, context: Context): Promise<Result<FileInfo, FileError>>;
46
+ listDir(path: string, context: Context): Promise<Result<FileInfo[], FileError>>;
47
+ openDirReader(path: string, context: Context): Promise<Result<DirReader, FileError>>;
48
+ canonicalPath(path: string, context: Context): Promise<Result<string, FileError>>;
49
+ exists(path: string, context: Context): Promise<Result<boolean, FileError>>;
50
+ createDir(path: string, options: {
51
+ recursive?: boolean;
52
+ } | undefined, context: Context): Promise<Result<void, FileError>>;
53
+ remove(path: string, options: {
54
+ recursive?: boolean;
55
+ force?: boolean;
56
+ } | undefined, context: Context): Promise<Result<void, FileError>>;
57
+ createTempDir(prefix: string | undefined, context: Context): Promise<Result<string, FileError>>;
58
+ createTempFile(options: {
59
+ prefix?: string;
60
+ suffix?: string;
61
+ } | undefined, context: Context): Promise<Result<string, FileError>>;
62
+ watch(targets: readonly WatchTarget[], onChange: (change: WatchChange) => void, context: Context): Promise<Result<FileWatcher, FileError>>;
63
+ exec(command: string | readonly string[], options: ShellExecOptions | undefined, context: Context): Promise<Result<ShellExecResult, ExecutionError>>;
64
+ cleanup(_context: Context): Promise<void>;
65
+ }
66
+ export type { RemoteInfo };
67
+ //# sourceMappingURL=remote-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-env.d.ts","sourceRoot":"","sources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