@projitect/cli-internals 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/dist/applier.d.ts +12 -0
- package/dist/applier.d.ts.map +1 -0
- package/dist/applier.js +69 -0
- package/dist/applier.js.map +1 -0
- package/dist/commands/add.d.ts +34 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +64 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/build.d.ts +39 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +108 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dispatch.d.ts +5 -0
- package/dist/commands/dispatch.d.ts.map +1 -0
- package/dist/commands/dispatch.js +211 -0
- package/dist/commands/dispatch.js.map +1 -0
- package/dist/commands/explain.d.ts +10 -0
- package/dist/commands/explain.d.ts.map +1 -0
- package/dist/commands/explain.js +46 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/init.d.ts +33 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +128 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect-json.d.ts +51 -0
- package/dist/commands/inspect-json.d.ts.map +1 -0
- package/dist/commands/inspect-json.js +58 -0
- package/dist/commands/inspect-json.js.map +1 -0
- package/dist/commands/inspect.d.ts +41 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +74 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/remodel.d.ts +22 -0
- package/dist/commands/remodel.d.ts.map +1 -0
- package/dist/commands/remodel.js +49 -0
- package/dist/commands/remodel.js.map +1 -0
- package/dist/config-cascade.d.ts +25 -0
- package/dist/config-cascade.d.ts.map +1 -0
- package/dist/config-cascade.js +45 -0
- package/dist/config-cascade.js.map +1 -0
- package/dist/differ.d.ts +31 -0
- package/dist/differ.d.ts.map +1 -0
- package/dist/differ.js +134 -0
- package/dist/differ.js.map +1 -0
- package/dist/edit-pjt.d.ts +19 -0
- package/dist/edit-pjt.d.ts.map +1 -0
- package/dist/edit-pjt.js +40 -0
- package/dist/edit-pjt.js.map +1 -0
- package/dist/filesystem-impl.d.ts +25 -0
- package/dist/filesystem-impl.d.ts.map +1 -0
- package/dist/filesystem-impl.js +153 -0
- package/dist/filesystem-impl.js.map +1 -0
- package/dist/git.d.ts +29 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +63 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc/client.d.ts +11 -0
- package/dist/ipc/client.d.ts.map +1 -0
- package/dist/ipc/client.js +45 -0
- package/dist/ipc/client.js.map +1 -0
- package/dist/ipc/index.d.ts +5 -0
- package/dist/ipc/index.d.ts.map +1 -0
- package/dist/ipc/index.js +5 -0
- package/dist/ipc/index.js.map +1 -0
- package/dist/ipc/protocol.d.ts +251 -0
- package/dist/ipc/protocol.d.ts.map +1 -0
- package/dist/ipc/protocol.js +41 -0
- package/dist/ipc/protocol.js.map +1 -0
- package/dist/ipc/server.d.ts +9 -0
- package/dist/ipc/server.d.ts.map +1 -0
- package/dist/ipc/server.js +23 -0
- package/dist/ipc/server.js.map +1 -0
- package/dist/ipc/transport.d.ts +12 -0
- package/dist/ipc/transport.d.ts.map +1 -0
- package/dist/ipc/transport.js +19 -0
- package/dist/ipc/transport.js.map +1 -0
- package/dist/loader.d.ts +45 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +65 -0
- package/dist/loader.js.map +1 -0
- package/dist/lockfile.d.ts +22 -0
- package/dist/lockfile.d.ts.map +1 -0
- package/dist/lockfile.js +59 -0
- package/dist/lockfile.js.map +1 -0
- package/dist/permissions.d.ts +20 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +86 -0
- package/dist/permissions.js.map +1 -0
- package/dist/plan.d.ts +278 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +212 -0
- package/dist/plan.js.map +1 -0
- package/dist/platform/file-system.d.ts +3 -0
- package/dist/platform/file-system.d.ts.map +1 -0
- package/dist/platform/file-system.js +109 -0
- package/dist/platform/file-system.js.map +1 -0
- package/dist/platform/index.d.ts +17 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +20 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/process-runner.d.ts +41 -0
- package/dist/platform/process-runner.d.ts.map +1 -0
- package/dist/platform/process-runner.js +120 -0
- package/dist/platform/process-runner.js.map +1 -0
- package/dist/platform/stdio.d.ts +9 -0
- package/dist/platform/stdio.d.ts.map +1 -0
- package/dist/platform/stdio.js +11 -0
- package/dist/platform/stdio.js.map +1 -0
- package/dist/platform/terminal.d.ts +3 -0
- package/dist/platform/terminal.d.ts.map +1 -0
- package/dist/platform/terminal.js +81 -0
- package/dist/platform/terminal.js.map +1 -0
- package/dist/pm.d.ts +31 -0
- package/dist/pm.d.ts.map +1 -0
- package/dist/pm.js +91 -0
- package/dist/pm.js.map +1 -0
- package/dist/post-apply.d.ts +20 -0
- package/dist/post-apply.d.ts.map +1 -0
- package/dist/post-apply.js +29 -0
- package/dist/post-apply.js.map +1 -0
- package/dist/project-file.d.ts +8 -0
- package/dist/project-file.d.ts.map +1 -0
- package/dist/project-file.js +12 -0
- package/dist/project-file.js.map +1 -0
- package/dist/region.d.ts +105 -0
- package/dist/region.d.ts.map +1 -0
- package/dist/region.js +94 -0
- package/dist/region.js.map +1 -0
- package/dist/remover.d.ts +16 -0
- package/dist/remover.d.ts.map +1 -0
- package/dist/remover.js +88 -0
- package/dist/remover.js.map +1 -0
- package/package.json +52 -3
- package/src/applier.ts +91 -0
- package/src/commands/add.ts +88 -0
- package/src/commands/build.ts +156 -0
- package/src/commands/dispatch.ts +345 -0
- package/src/commands/explain.ts +81 -0
- package/src/commands/init.ts +193 -0
- package/src/commands/inspect-json.ts +68 -0
- package/src/commands/inspect.ts +106 -0
- package/src/commands/remodel.ts +72 -0
- package/src/config-cascade.ts +60 -0
- package/src/differ.ts +188 -0
- package/src/edit-pjt.ts +56 -0
- package/src/filesystem-impl.ts +230 -0
- package/src/git.ts +87 -0
- package/src/index.ts +54 -0
- package/src/ipc/client.ts +108 -0
- package/src/ipc/index.ts +12 -0
- package/src/ipc/protocol.ts +48 -0
- package/src/ipc/server.ts +62 -0
- package/src/ipc/transport.ts +28 -0
- package/src/loader.ts +115 -0
- package/src/lockfile.ts +81 -0
- package/src/permissions.ts +106 -0
- package/src/plan.ts +459 -0
- package/src/platform/file-system.ts +155 -0
- package/src/platform/index.ts +26 -0
- package/src/platform/process-runner.ts +150 -0
- package/src/platform/stdio.ts +11 -0
- package/src/platform/terminal.ts +89 -0
- package/src/pm.ts +131 -0
- package/src/post-apply.ts +45 -0
- package/src/project-file.ts +15 -0
- package/src/region.ts +139 -0
- package/src/remover.ts +127 -0
- package/README.md +0 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { rootCommand } from "./commands/dispatch.js";
|
|
2
|
+
export { inspect } from "./commands/inspect.js";
|
|
3
|
+
export { remodel } from "./commands/remodel.js";
|
|
4
|
+
export { init } from "./commands/init.js";
|
|
5
|
+
export { explain } from "./commands/explain.js";
|
|
6
|
+
export { build } from "./commands/build.js";
|
|
7
|
+
export { add } from "./commands/add.js";
|
|
8
|
+
export { resolveConfig, parseEnv } from "./config-cascade.js";
|
|
9
|
+
export { loadBlueprintFile, pjt, isEffectTree, } from "./loader.js";
|
|
10
|
+
export { buildPlan, diffLockfile, } from "./plan.js";
|
|
11
|
+
export { diffPlan, renderPlanDiff, renderInspectReport, } from "./differ.js";
|
|
12
|
+
export { applyPlan } from "./applier.js";
|
|
13
|
+
export { applyRemovals } from "./remover.js";
|
|
14
|
+
export { readLockfile, writeLockfile, blueprintIds } from "./lockfile.js";
|
|
15
|
+
export { makeRealLayer, makeProjectRootLayer } from "./filesystem-impl.js";
|
|
16
|
+
export { NodePlatformLive, FileSystemLive, StdioLive, TerminalLive, runCommand, nodeSpawner, } from "./platform/index.js";
|
|
17
|
+
export { splice } from "./edit-pjt.js";
|
|
18
|
+
export { detect as detectPackageManager, installDev, readProjitectMetadata, } from "./pm.js";
|
|
19
|
+
export { isGitRepo, gitStatus, ensureGitRepo } from "./git.js";
|
|
20
|
+
export * as Ipc from "./ipc/index.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoB,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,OAAO,EAAsB,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,OAAO,EAAsB,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,IAAI,EAAmB,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EACL,iBAAiB,EACjB,GAAG,EACH,YAAY,GAGb,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,SAAS,EACT,YAAY,GAKb,MAAM,WAAW,CAAA;AAClB,OAAO,EACL,QAAQ,EACR,cAAc,EACd,mBAAmB,GAGpB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC1E,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,YAAY,EACZ,UAAU,EACV,WAAW,GAGZ,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EACL,MAAM,IAAI,oBAAoB,EAC9B,UAAU,EACV,qBAAqB,GAEtB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC9D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { BlueprintFileSystem } from "@projitect/core";
|
|
3
|
+
import type { BlueprintFileSystemShape } from "@projitect/core";
|
|
4
|
+
import type { Transport } from "./transport.js";
|
|
5
|
+
/**
|
|
6
|
+
* Child side: a `BlueprintFileSystemShape` that forwards each call to the parent-side server over
|
|
7
|
+
* `transport` and decodes the reply, re-raising failures as the original typed error.
|
|
8
|
+
*/
|
|
9
|
+
export declare const makeClient: (transport: Transport) => BlueprintFileSystemShape;
|
|
10
|
+
export declare const makeClientLayer: (transport: Transport) => Layer.Layer<BlueprintFileSystem>;
|
|
11
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/ipc/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAS,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAG/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI/C;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,WAAW,SAAS,KAAG,wBAyFjD,CAAA;AAID,eAAO,MAAM,eAAe,GAAI,WAAW,SAAS,KAAG,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAC3B,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Effect, Layer, Match } from "effect";
|
|
2
|
+
import { BlueprintFileSystem } from "@projitect/core";
|
|
3
|
+
import { decodeResponse, encodeRequest } from "./protocol.js";
|
|
4
|
+
/**
|
|
5
|
+
* Child side: a `BlueprintFileSystemShape` that forwards each call to the parent-side server over
|
|
6
|
+
* `transport` and decodes the reply, re-raising failures as the original typed error.
|
|
7
|
+
*/
|
|
8
|
+
export const makeClient = (transport) => {
|
|
9
|
+
const pending = new Map();
|
|
10
|
+
let nextId = 0;
|
|
11
|
+
transport.onMessage((frame) => {
|
|
12
|
+
Effect.runFork(decodeResponse(frame).pipe(Effect.tap((response) => Effect.sync(() => {
|
|
13
|
+
pending.get(response.id)?.(response);
|
|
14
|
+
pending.delete(response.id);
|
|
15
|
+
})), Effect.ignore));
|
|
16
|
+
});
|
|
17
|
+
const call = (build) => Effect.gen(function* () {
|
|
18
|
+
const id = nextId++;
|
|
19
|
+
const encoded = yield* Effect.orDie(encodeRequest(build(id)));
|
|
20
|
+
const response = yield* Effect.callback((resume) => {
|
|
21
|
+
pending.set(id, (reply) => {
|
|
22
|
+
resume(Effect.succeed(reply));
|
|
23
|
+
});
|
|
24
|
+
transport.send(encoded);
|
|
25
|
+
return Effect.sync(() => pending.delete(id));
|
|
26
|
+
});
|
|
27
|
+
return yield* Match.value(response).pipe(Match.tag("Failure", ({ error }) => Effect.fail(error)), Match.orElse((ok) => Effect.succeed(ok)));
|
|
28
|
+
});
|
|
29
|
+
// The server only emits a method's own failure tags; the other tag is unreachable by protocol.
|
|
30
|
+
const noRead = (effect) => Effect.catch(effect, (error) => Match.value(error).pipe(Match.tag("FsReadFailed", (unreachable) => Effect.die(unreachable)), Match.orElse((rest) => Effect.fail(rest))));
|
|
31
|
+
const noWrite = (effect) => Effect.catch(effect, (error) => Match.value(error).pipe(Match.tag("FsWriteFailed", (unreachable) => Effect.die(unreachable)), Match.orElse((rest) => Effect.fail(rest))));
|
|
32
|
+
const onlyDenied = (effect) => Effect.catch(effect, (error) => Match.value(error).pipe(Match.tag("FsReadFailed", "FsWriteFailed", (unreachable) => Effect.die(unreachable)), Match.orElse((rest) => Effect.fail(rest))));
|
|
33
|
+
return {
|
|
34
|
+
readFile: (path) => call((id) => ({ _tag: "ReadFile", id, path })).pipe(Effect.flatMap((r) => r._tag === "ReadFileOk" ? Effect.succeed(r.value) : Effect.die(unexpected(r))), noWrite),
|
|
35
|
+
writeFile: (path, content) => call((id) => ({ _tag: "WriteFile", id, path, content })).pipe(Effect.asVoid, noRead),
|
|
36
|
+
exists: (path) => call((id) => ({ _tag: "Exists", id, path })).pipe(Effect.flatMap((r) => r._tag === "ExistsOk" ? Effect.succeed(r.value) : Effect.die(unexpected(r))), onlyDenied),
|
|
37
|
+
remove: (path) => call((id) => ({ _tag: "Remove", id, path })).pipe(Effect.asVoid, noRead),
|
|
38
|
+
removeEmptyDir: (path) => call((id) => ({ _tag: "RemoveEmptyDir", id, path })).pipe(Effect.asVoid, noRead),
|
|
39
|
+
mkdir: (path) => call((id) => ({ _tag: "Mkdir", id, path })).pipe(Effect.asVoid, noRead),
|
|
40
|
+
listDir: (path) => call((id) => ({ _tag: "ListDir", id, path })).pipe(Effect.flatMap((r) => r._tag === "ListDirOk" ? Effect.succeed(r.value) : Effect.die(unexpected(r))), noWrite),
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const unexpected = (response) => `Unexpected IPC response: ${response._tag}`;
|
|
44
|
+
export const makeClientLayer = (transport) => Layer.succeed(BlueprintFileSystem, makeClient(transport));
|
|
45
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/ipc/client.ts"],"names":[],"mappings":"AA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AAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAChD,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CACnB,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAC7E,EACD,OAAO,CACR;KACJ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,QAAkB,EAAU,EAAE,CAAC,4BAA4B,QAAQ,CAAC,IAAI,EAAE,CAAA;AAE9F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAoB,EAAoC,EAAE,CACxF,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { makeClient, makeClientLayer } from "./client.js";
|
|
2
|
+
export { serve } from "./server.js";
|
|
3
|
+
export { makeInProcessPair, type Transport } from "./transport.js";
|
|
4
|
+
export { Request, Response, FsError, encodeRequest, decodeRequest, encodeResponse, decodeResponse, } from "./protocol.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ipc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EACL,OAAO,EACP,QAAQ,EACR,OAAO,EACP,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { makeClient, makeClientLayer } from "./client.js";
|
|
2
|
+
export { serve } from "./server.js";
|
|
3
|
+
export { makeInProcessPair } from "./transport.js";
|
|
4
|
+
export { Request, Response, FsError, encodeRequest, decodeRequest, encodeResponse, decodeResponse, } from "./protocol.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ipc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAkB,MAAM,gBAAgB,CAAA;AAClE,OAAO,EACL,OAAO,EACP,QAAQ,EACR,OAAO,EACP,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { Errors } from "@projitect/core";
|
|
3
|
+
/**
|
|
4
|
+
* Wire frames for marshalling `BlueprintFileSystem` calls across a process boundary. Every frame
|
|
5
|
+
* carries a correlation `id`; one request form exists per service method. Failures travel as the
|
|
6
|
+
* existing `Schema.TaggedError` classes, so class, id and fields survive the round trip.
|
|
7
|
+
*/
|
|
8
|
+
export declare const Request: Schema.Union<readonly [Schema.TaggedStruct<"ReadFile", {
|
|
9
|
+
readonly id: Schema.Number;
|
|
10
|
+
readonly path: Schema.String;
|
|
11
|
+
}>, Schema.TaggedStruct<"WriteFile", {
|
|
12
|
+
readonly id: Schema.Number;
|
|
13
|
+
readonly path: Schema.String;
|
|
14
|
+
readonly content: Schema.String;
|
|
15
|
+
}>, Schema.TaggedStruct<"Exists", {
|
|
16
|
+
readonly id: Schema.Number;
|
|
17
|
+
readonly path: Schema.String;
|
|
18
|
+
}>, Schema.TaggedStruct<"Remove", {
|
|
19
|
+
readonly id: Schema.Number;
|
|
20
|
+
readonly path: Schema.String;
|
|
21
|
+
}>, Schema.TaggedStruct<"RemoveEmptyDir", {
|
|
22
|
+
readonly id: Schema.Number;
|
|
23
|
+
readonly path: Schema.String;
|
|
24
|
+
}>, Schema.TaggedStruct<"Mkdir", {
|
|
25
|
+
readonly id: Schema.Number;
|
|
26
|
+
readonly path: Schema.String;
|
|
27
|
+
}>, Schema.TaggedStruct<"ListDir", {
|
|
28
|
+
readonly id: Schema.Number;
|
|
29
|
+
readonly path: Schema.String;
|
|
30
|
+
}>]>;
|
|
31
|
+
export type Request = typeof Request.Type;
|
|
32
|
+
export declare const FsError: Schema.Union<readonly [typeof Errors.FsPermissionDenied, typeof Errors.FsReadFailed, typeof Errors.FsWriteFailed]>;
|
|
33
|
+
export type FsError = typeof FsError.Type;
|
|
34
|
+
export declare const Response: Schema.Union<readonly [Schema.TaggedStruct<"ReadFileOk", {
|
|
35
|
+
readonly id: Schema.Number;
|
|
36
|
+
readonly value: Schema.String;
|
|
37
|
+
}>, Schema.TaggedStruct<"WriteFileOk", {
|
|
38
|
+
readonly id: Schema.Number;
|
|
39
|
+
}>, Schema.TaggedStruct<"ExistsOk", {
|
|
40
|
+
readonly id: Schema.Number;
|
|
41
|
+
readonly value: Schema.Boolean;
|
|
42
|
+
}>, Schema.TaggedStruct<"RemoveOk", {
|
|
43
|
+
readonly id: Schema.Number;
|
|
44
|
+
}>, Schema.TaggedStruct<"RemoveEmptyDirOk", {
|
|
45
|
+
readonly id: Schema.Number;
|
|
46
|
+
}>, Schema.TaggedStruct<"MkdirOk", {
|
|
47
|
+
readonly id: Schema.Number;
|
|
48
|
+
}>, Schema.TaggedStruct<"ListDirOk", {
|
|
49
|
+
readonly id: Schema.Number;
|
|
50
|
+
readonly value: Schema.$Array<Schema.String>;
|
|
51
|
+
}>, Schema.TaggedStruct<"Failure", {
|
|
52
|
+
readonly id: Schema.Number;
|
|
53
|
+
readonly error: Schema.Union<readonly [typeof Errors.FsPermissionDenied, typeof Errors.FsReadFailed, typeof Errors.FsWriteFailed]>;
|
|
54
|
+
}>]>;
|
|
55
|
+
export type Response = typeof Response.Type;
|
|
56
|
+
/** Frames cross the transport in their encoded (JSON-compatible) form. */
|
|
57
|
+
export declare const encodeRequest: (input: {
|
|
58
|
+
readonly _tag: "ReadFile";
|
|
59
|
+
readonly id: number;
|
|
60
|
+
readonly path: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly _tag: "WriteFile";
|
|
63
|
+
readonly id: number;
|
|
64
|
+
readonly path: string;
|
|
65
|
+
readonly content: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly _tag: "Exists";
|
|
68
|
+
readonly id: number;
|
|
69
|
+
readonly path: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly _tag: "Remove";
|
|
72
|
+
readonly id: number;
|
|
73
|
+
readonly path: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly _tag: "RemoveEmptyDir";
|
|
76
|
+
readonly id: number;
|
|
77
|
+
readonly path: string;
|
|
78
|
+
} | {
|
|
79
|
+
readonly _tag: "Mkdir";
|
|
80
|
+
readonly id: number;
|
|
81
|
+
readonly path: string;
|
|
82
|
+
} | {
|
|
83
|
+
readonly _tag: "ListDir";
|
|
84
|
+
readonly id: number;
|
|
85
|
+
readonly path: string;
|
|
86
|
+
}, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
87
|
+
readonly _tag: "ReadFile";
|
|
88
|
+
readonly id: number;
|
|
89
|
+
readonly path: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly _tag: "WriteFile";
|
|
92
|
+
readonly id: number;
|
|
93
|
+
readonly path: string;
|
|
94
|
+
readonly content: string;
|
|
95
|
+
} | {
|
|
96
|
+
readonly _tag: "Exists";
|
|
97
|
+
readonly id: number;
|
|
98
|
+
readonly path: string;
|
|
99
|
+
} | {
|
|
100
|
+
readonly _tag: "Remove";
|
|
101
|
+
readonly id: number;
|
|
102
|
+
readonly path: string;
|
|
103
|
+
} | {
|
|
104
|
+
readonly _tag: "RemoveEmptyDir";
|
|
105
|
+
readonly id: number;
|
|
106
|
+
readonly path: string;
|
|
107
|
+
} | {
|
|
108
|
+
readonly _tag: "Mkdir";
|
|
109
|
+
readonly id: number;
|
|
110
|
+
readonly path: string;
|
|
111
|
+
} | {
|
|
112
|
+
readonly _tag: "ListDir";
|
|
113
|
+
readonly id: number;
|
|
114
|
+
readonly path: string;
|
|
115
|
+
}, Schema.SchemaError, never>;
|
|
116
|
+
export declare const decodeRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
117
|
+
readonly _tag: "ReadFile";
|
|
118
|
+
readonly id: number;
|
|
119
|
+
readonly path: string;
|
|
120
|
+
} | {
|
|
121
|
+
readonly _tag: "WriteFile";
|
|
122
|
+
readonly id: number;
|
|
123
|
+
readonly path: string;
|
|
124
|
+
readonly content: string;
|
|
125
|
+
} | {
|
|
126
|
+
readonly _tag: "Exists";
|
|
127
|
+
readonly id: number;
|
|
128
|
+
readonly path: string;
|
|
129
|
+
} | {
|
|
130
|
+
readonly _tag: "Remove";
|
|
131
|
+
readonly id: number;
|
|
132
|
+
readonly path: string;
|
|
133
|
+
} | {
|
|
134
|
+
readonly _tag: "RemoveEmptyDir";
|
|
135
|
+
readonly id: number;
|
|
136
|
+
readonly path: string;
|
|
137
|
+
} | {
|
|
138
|
+
readonly _tag: "Mkdir";
|
|
139
|
+
readonly id: number;
|
|
140
|
+
readonly path: string;
|
|
141
|
+
} | {
|
|
142
|
+
readonly _tag: "ListDir";
|
|
143
|
+
readonly id: number;
|
|
144
|
+
readonly path: string;
|
|
145
|
+
}, Schema.SchemaError, never>;
|
|
146
|
+
export declare const encodeResponse: (input: {
|
|
147
|
+
readonly _tag: "ReadFileOk";
|
|
148
|
+
readonly id: number;
|
|
149
|
+
readonly value: string;
|
|
150
|
+
} | {
|
|
151
|
+
readonly _tag: "WriteFileOk";
|
|
152
|
+
readonly id: number;
|
|
153
|
+
} | {
|
|
154
|
+
readonly _tag: "ExistsOk";
|
|
155
|
+
readonly id: number;
|
|
156
|
+
readonly value: boolean;
|
|
157
|
+
} | {
|
|
158
|
+
readonly _tag: "RemoveOk";
|
|
159
|
+
readonly id: number;
|
|
160
|
+
} | {
|
|
161
|
+
readonly _tag: "RemoveEmptyDirOk";
|
|
162
|
+
readonly id: number;
|
|
163
|
+
} | {
|
|
164
|
+
readonly _tag: "MkdirOk";
|
|
165
|
+
readonly id: number;
|
|
166
|
+
} | {
|
|
167
|
+
readonly _tag: "ListDirOk";
|
|
168
|
+
readonly id: number;
|
|
169
|
+
readonly value: readonly string[];
|
|
170
|
+
} | {
|
|
171
|
+
readonly _tag: "Failure";
|
|
172
|
+
readonly id: number;
|
|
173
|
+
readonly error: Errors.FsPermissionDenied | Errors.FsReadFailed | Errors.FsWriteFailed;
|
|
174
|
+
}, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
175
|
+
readonly _tag: "ReadFileOk";
|
|
176
|
+
readonly id: number;
|
|
177
|
+
readonly value: string;
|
|
178
|
+
} | {
|
|
179
|
+
readonly _tag: "WriteFileOk";
|
|
180
|
+
readonly id: number;
|
|
181
|
+
} | {
|
|
182
|
+
readonly _tag: "ExistsOk";
|
|
183
|
+
readonly id: number;
|
|
184
|
+
readonly value: boolean;
|
|
185
|
+
} | {
|
|
186
|
+
readonly _tag: "RemoveOk";
|
|
187
|
+
readonly id: number;
|
|
188
|
+
} | {
|
|
189
|
+
readonly _tag: "RemoveEmptyDirOk";
|
|
190
|
+
readonly id: number;
|
|
191
|
+
} | {
|
|
192
|
+
readonly _tag: "MkdirOk";
|
|
193
|
+
readonly id: number;
|
|
194
|
+
} | {
|
|
195
|
+
readonly _tag: "ListDirOk";
|
|
196
|
+
readonly id: number;
|
|
197
|
+
readonly value: readonly string[];
|
|
198
|
+
} | {
|
|
199
|
+
readonly _tag: "Failure";
|
|
200
|
+
readonly id: number;
|
|
201
|
+
readonly error: {
|
|
202
|
+
readonly _tag: "FsReadFailed";
|
|
203
|
+
readonly id: "pjt.fs.read-failed";
|
|
204
|
+
readonly path: string;
|
|
205
|
+
readonly cause: string;
|
|
206
|
+
readonly message: string;
|
|
207
|
+
} | {
|
|
208
|
+
readonly _tag: "FsPermissionDenied";
|
|
209
|
+
readonly id: "pjt.fs.permission-denied";
|
|
210
|
+
readonly path: string;
|
|
211
|
+
readonly operation: "read" | "write" | "exists" | "remove" | "removeEmptyDir" | "mkdir" | "listDir";
|
|
212
|
+
readonly blueprintId: string;
|
|
213
|
+
readonly message: string;
|
|
214
|
+
} | {
|
|
215
|
+
readonly _tag: "FsWriteFailed";
|
|
216
|
+
readonly id: "pjt.fs.write-failed";
|
|
217
|
+
readonly path: string;
|
|
218
|
+
readonly cause: string;
|
|
219
|
+
readonly message: string;
|
|
220
|
+
};
|
|
221
|
+
}, Schema.SchemaError, never>;
|
|
222
|
+
export declare const decodeResponse: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
223
|
+
readonly _tag: "ReadFileOk";
|
|
224
|
+
readonly id: number;
|
|
225
|
+
readonly value: string;
|
|
226
|
+
} | {
|
|
227
|
+
readonly _tag: "WriteFileOk";
|
|
228
|
+
readonly id: number;
|
|
229
|
+
} | {
|
|
230
|
+
readonly _tag: "ExistsOk";
|
|
231
|
+
readonly id: number;
|
|
232
|
+
readonly value: boolean;
|
|
233
|
+
} | {
|
|
234
|
+
readonly _tag: "RemoveOk";
|
|
235
|
+
readonly id: number;
|
|
236
|
+
} | {
|
|
237
|
+
readonly _tag: "RemoveEmptyDirOk";
|
|
238
|
+
readonly id: number;
|
|
239
|
+
} | {
|
|
240
|
+
readonly _tag: "MkdirOk";
|
|
241
|
+
readonly id: number;
|
|
242
|
+
} | {
|
|
243
|
+
readonly _tag: "ListDirOk";
|
|
244
|
+
readonly id: number;
|
|
245
|
+
readonly value: readonly string[];
|
|
246
|
+
} | {
|
|
247
|
+
readonly _tag: "Failure";
|
|
248
|
+
readonly id: number;
|
|
249
|
+
readonly error: Errors.FsPermissionDenied | Errors.FsReadFailed | Errors.FsWriteFailed;
|
|
250
|
+
}, Schema.SchemaError, never>;
|
|
251
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/ipc/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC;;;;GAIG;AAEH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;IAYlB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,OAAO,oHAIlB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;IASnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAE3C,0EAA0E;AAC1E,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAA+B,CAAA;AACzD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAAsC,CAAA;AAChE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAAgC,CAAA;AAC3D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAAuC,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { Errors } from "@projitect/core";
|
|
3
|
+
/**
|
|
4
|
+
* Wire frames for marshalling `BlueprintFileSystem` calls across a process boundary. Every frame
|
|
5
|
+
* carries a correlation `id`; one request form exists per service method. Failures travel as the
|
|
6
|
+
* existing `Schema.TaggedError` classes, so class, id and fields survive the round trip.
|
|
7
|
+
*/
|
|
8
|
+
export const Request = Schema.Union([
|
|
9
|
+
Schema.TaggedStruct("ReadFile", { id: Schema.Number, path: Schema.String }),
|
|
10
|
+
Schema.TaggedStruct("WriteFile", {
|
|
11
|
+
id: Schema.Number,
|
|
12
|
+
path: Schema.String,
|
|
13
|
+
content: Schema.String,
|
|
14
|
+
}),
|
|
15
|
+
Schema.TaggedStruct("Exists", { id: Schema.Number, path: Schema.String }),
|
|
16
|
+
Schema.TaggedStruct("Remove", { id: Schema.Number, path: Schema.String }),
|
|
17
|
+
Schema.TaggedStruct("RemoveEmptyDir", { id: Schema.Number, path: Schema.String }),
|
|
18
|
+
Schema.TaggedStruct("Mkdir", { id: Schema.Number, path: Schema.String }),
|
|
19
|
+
Schema.TaggedStruct("ListDir", { id: Schema.Number, path: Schema.String }),
|
|
20
|
+
]);
|
|
21
|
+
export const FsError = Schema.Union([
|
|
22
|
+
Errors.FsPermissionDenied,
|
|
23
|
+
Errors.FsReadFailed,
|
|
24
|
+
Errors.FsWriteFailed,
|
|
25
|
+
]);
|
|
26
|
+
export const Response = Schema.Union([
|
|
27
|
+
Schema.TaggedStruct("ReadFileOk", { id: Schema.Number, value: Schema.String }),
|
|
28
|
+
Schema.TaggedStruct("WriteFileOk", { id: Schema.Number }),
|
|
29
|
+
Schema.TaggedStruct("ExistsOk", { id: Schema.Number, value: Schema.Boolean }),
|
|
30
|
+
Schema.TaggedStruct("RemoveOk", { id: Schema.Number }),
|
|
31
|
+
Schema.TaggedStruct("RemoveEmptyDirOk", { id: Schema.Number }),
|
|
32
|
+
Schema.TaggedStruct("MkdirOk", { id: Schema.Number }),
|
|
33
|
+
Schema.TaggedStruct("ListDirOk", { id: Schema.Number, value: Schema.Array(Schema.String) }),
|
|
34
|
+
Schema.TaggedStruct("Failure", { id: Schema.Number, error: FsError }),
|
|
35
|
+
]);
|
|
36
|
+
/** Frames cross the transport in their encoded (JSON-compatible) form. */
|
|
37
|
+
export const encodeRequest = Schema.encodeEffect(Request);
|
|
38
|
+
export const decodeRequest = Schema.decodeUnknownEffect(Request);
|
|
39
|
+
export const encodeResponse = Schema.encodeEffect(Response);
|
|
40
|
+
export const decodeResponse = Schema.decodeUnknownEffect(Response);
|
|
41
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/ipc/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC;;;;GAIG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;IAClC,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IAC3E,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;QAC/B,EAAE,EAAE,MAAM,CAAC,MAAM;QACjB,IAAI,EAAE,MAAM,CAAC,MAAM;QACnB,OAAO,EAAE,MAAM,CAAC,MAAM;KACvB,CAAC;IACF,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACzE,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IACzE,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE,EAA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E,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IAC3F,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;CACtE,CAAC,CAAA;AAGF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;AACzD,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BlueprintFileSystemShape } from "@projitect/core";
|
|
2
|
+
import type { Transport } from "./transport.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parent side: decode each request frame, run it against the (permission-gated) `shape` and send
|
|
5
|
+
* the encoded response back. Frames that fail to decode are dropped — the client only ever sends
|
|
6
|
+
* well-formed frames, and a correlation id cannot be recovered from a malformed one.
|
|
7
|
+
*/
|
|
8
|
+
export declare const serve: (transport: Transport, shape: BlueprintFileSystemShape) => void;
|
|
9
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/ipc/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAG/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAqC/C;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,WAAW,SAAS,EAAE,OAAO,wBAAwB,KAAG,IAe7E,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Effect, Match, pipe } from "effect";
|
|
2
|
+
import { decodeRequest, encodeResponse } from "./protocol.js";
|
|
3
|
+
const respond = (shape, request) => {
|
|
4
|
+
const failure = (error) => ({
|
|
5
|
+
_tag: "Failure",
|
|
6
|
+
id: request.id,
|
|
7
|
+
error,
|
|
8
|
+
});
|
|
9
|
+
return pipe(request, Match.value, Match.tag("ReadFile", ({ id, path }) => Effect.map(shape.readFile(path), (value) => ({ _tag: "ReadFileOk", id, value }))), Match.tag("WriteFile", ({ id, path, content }) => Effect.map(shape.writeFile(path, content), () => ({ _tag: "WriteFileOk", id }))), Match.tag("Exists", ({ id, path }) => Effect.map(shape.exists(path), (value) => ({ _tag: "ExistsOk", id, value }))), Match.tag("Remove", ({ id, path }) => Effect.map(shape.remove(path), () => ({ _tag: "RemoveOk", id }))), Match.tag("RemoveEmptyDir", ({ id, path }) => Effect.map(shape.removeEmptyDir(path), () => ({ _tag: "RemoveEmptyDirOk", id }))), Match.tag("Mkdir", ({ id, path }) => Effect.map(shape.mkdir(path), () => ({ _tag: "MkdirOk", id }))), Match.tag("ListDir", ({ id, path }) => Effect.map(shape.listDir(path), (value) => ({ _tag: "ListDirOk", id, value }))), Match.exhaustive, Effect.catch((error) => Effect.succeed(failure(error))));
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Parent side: decode each request frame, run it against the (permission-gated) `shape` and send
|
|
13
|
+
* the encoded response back. Frames that fail to decode are dropped — the client only ever sends
|
|
14
|
+
* well-formed frames, and a correlation id cannot be recovered from a malformed one.
|
|
15
|
+
*/
|
|
16
|
+
export const serve = (transport, shape) => {
|
|
17
|
+
transport.onMessage((frame) => {
|
|
18
|
+
Effect.runFork(decodeRequest(frame).pipe(Effect.flatMap((request) => respond(shape, request)), Effect.flatMap(encodeResponse), Effect.tap((encoded) => Effect.sync(() => {
|
|
19
|
+
transport.send(encoded);
|
|
20
|
+
})), Effect.ignore));
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/ipc/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE5C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAI7D,MAAM,OAAO,GAAG,CAAC,KAA+B,EAAE,OAAgB,EAA2B,EAAE;IAC7F,MAAM,OAAO,GAAG,CAAC,KAA+D,EAAY,EAAE,CAAC,CAAC;QAC9F,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,KAAK;KACN,CAAC,CAAA;IACF,OAAO,IAAI,CACT,OAAO,EACP,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CACrC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAC3F,EACD,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAC/C,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,GAAa,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC,CAC1F,EACD,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CACnC,MA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K,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CACxD,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,SAAoB,EAAE,KAA+B,EAAQ,EAAE;IACnF,SAAS,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5B,MAAM,CAAC,OAAO,CACZ,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CACvB,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,EACpD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAC9B,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACrB,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACf,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzB,CAAC,CAAC,CACH,EACD,MAAM,CAAC,MAAM,CACd,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal message channel between the parent-side server and the child-side client. Frames are
|
|
3
|
+
* JSON-compatible values, so any process IPC channel can implement it; `makeInProcessPair` backs
|
|
4
|
+
* the tests.
|
|
5
|
+
*/
|
|
6
|
+
export interface Transport {
|
|
7
|
+
readonly send: (frame: unknown) => void;
|
|
8
|
+
readonly onMessage: (handler: (frame: unknown) => void) => void;
|
|
9
|
+
}
|
|
10
|
+
/** Two connected transports: whatever one end sends, the other end's handler receives. */
|
|
11
|
+
export declare const makeInProcessPair: () => readonly [Transport, Transport];
|
|
12
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/ipc/transport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACvC,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAA;CAChE;AAED,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,QAAO,SAAS,CAAC,SAAS,EAAE,SAAS,CAgBlE,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Two connected transports: whatever one end sends, the other end's handler receives. */
|
|
2
|
+
export const makeInProcessPair = () => {
|
|
3
|
+
const handlers = [[], []];
|
|
4
|
+
const endpoint = (self) => ({
|
|
5
|
+
send: (frame) => {
|
|
6
|
+
const peer = self === 0 ? 1 : 0;
|
|
7
|
+
queueMicrotask(() => {
|
|
8
|
+
for (const handler of handlers[peer]) {
|
|
9
|
+
handler(frame);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
onMessage: (handler) => {
|
|
14
|
+
handlers[self].push(handler);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return [endpoint(0), endpoint(1)];
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/ipc/transport.ts"],"names":[],"mappings":"AAUA,0FAA0F;AAC1F,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAoC,EAAE;IACrE,MAAM,QAAQ,GAAiE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACvF,MAAM,QAAQ,GAAG,CAAC,IAAW,EAAa,EAAE,CAAC,CAAC;QAC5C,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;YACd,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC/B,cAAc,CAAC,GAAG,EAAE;gBAClB,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;oBACrC,OAAO,CAAC,KAAK,CAAC,CAAA;gBAChB,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;YACrB,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9B,CAAC;KACF,CAAC,CAAA;IACF,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AACnC,CAAC,CAAA"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Errors } from "@projitect/core";
|
|
3
|
+
import type { BlueprintFileSystem, Blueprint } from "@projitect/core";
|
|
4
|
+
import type { DirectoryBlueprint } from "@projitect/blueprint";
|
|
5
|
+
/**
|
|
6
|
+
* The shape `.pjt.ts` produces when the user calls `pjt({ blueprints, config })`. Either an
|
|
7
|
+
* array of blueprints or an Effect that builds the array. The runner unwraps the Effect form
|
|
8
|
+
* inside the planner so blueprint-tree construction itself can be a typed pipeline.
|
|
9
|
+
*
|
|
10
|
+
* The Effect form may fail with any `BlueprintError` and may require `BlueprintFileSystem` —
|
|
11
|
+
* the CLI provides a "config-time" FS layer with broad read permissions before invoking it.
|
|
12
|
+
*/
|
|
13
|
+
export type BlueprintTree = readonly (Blueprint.Blueprint | DirectoryBlueprint)[];
|
|
14
|
+
export interface ProjitectFile {
|
|
15
|
+
readonly _tag: "ProjitectConfig";
|
|
16
|
+
readonly blueprints: BlueprintTree | Effect.Effect<BlueprintTree, Errors.BlueprintError, BlueprintFileSystem>;
|
|
17
|
+
readonly config?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The user calls this in `.pjt.ts`:
|
|
21
|
+
*
|
|
22
|
+
* export default pjt({ blueprints: [...] })
|
|
23
|
+
*
|
|
24
|
+
* It's an identity tag — we only inspect the default export for the `_tag` marker so we can
|
|
25
|
+
* distinguish accidental other exports from a real projitect config.
|
|
26
|
+
*/
|
|
27
|
+
export declare const pjt: (input: {
|
|
28
|
+
readonly blueprints: ProjitectFile["blueprints"];
|
|
29
|
+
readonly config?: Record<string, unknown>;
|
|
30
|
+
}) => ProjitectFile;
|
|
31
|
+
/** Type guard: did the user pass an Effect, or a literal array? */
|
|
32
|
+
export declare const isEffectTree: (v: ProjitectFile["blueprints"]) => v is Effect.Effect<BlueprintTree, Errors.BlueprintError, BlueprintFileSystem>;
|
|
33
|
+
/**
|
|
34
|
+
* Dynamic-import the user's `.pjt.ts` and return the typed default export.
|
|
35
|
+
*
|
|
36
|
+
* The user's file is TypeScript. On Node 23.6+ with `--experimental-strip-types`, the import
|
|
37
|
+
* succeeds natively. On older Node, the binary shim in `packages/projitect` registers `tsx` as
|
|
38
|
+
* a loader before reaching this function. Either way, by the time we get here, `import(path)`
|
|
39
|
+
* Just Works.
|
|
40
|
+
*/
|
|
41
|
+
export declare const loadBlueprintFile: (params: {
|
|
42
|
+
readonly blueprintFile: string;
|
|
43
|
+
readonly projectRoot: string;
|
|
44
|
+
}) => Effect.Effect<ProjitectFile, Errors.LoaderImportFailed | Errors.LoaderInvalidDefaultExport | Errors.ConfigBlueprintFileNotFound>;
|
|
45
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAS,MAAM,EAAoB,MAAM,QAAQ,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;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|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { Array, Effect, Match, Predicate } from "effect";
|
|
5
|
+
import { PredicateX, StructX } from "@nunofyobiz/effect-extras";
|
|
6
|
+
import { Errors } from "@projitect/core";
|
|
7
|
+
/**
|
|
8
|
+
* The user calls this in `.pjt.ts`:
|
|
9
|
+
*
|
|
10
|
+
* export default pjt({ blueprints: [...] })
|
|
11
|
+
*
|
|
12
|
+
* It's an identity tag — we only inspect the default export for the `_tag` marker so we can
|
|
13
|
+
* distinguish accidental other exports from a real projitect config.
|
|
14
|
+
*/
|
|
15
|
+
export const pjt = (input) => ({
|
|
16
|
+
_tag: "ProjitectConfig",
|
|
17
|
+
blueprints: input.blueprints,
|
|
18
|
+
...StructX.defined("config", input.config),
|
|
19
|
+
});
|
|
20
|
+
/** Type guard: did the user pass an Effect, or a literal array? */
|
|
21
|
+
export const isEffectTree = (v) => !Array.isArray(v);
|
|
22
|
+
/**
|
|
23
|
+
* Dynamic-import the user's `.pjt.ts` and return the typed default export.
|
|
24
|
+
*
|
|
25
|
+
* The user's file is TypeScript. On Node 23.6+ with `--experimental-strip-types`, the import
|
|
26
|
+
* succeeds natively. On older Node, the binary shim in `packages/projitect` registers `tsx` as
|
|
27
|
+
* a loader before reaching this function. Either way, by the time we get here, `import(path)`
|
|
28
|
+
* Just Works.
|
|
29
|
+
*/
|
|
30
|
+
export const loadBlueprintFile = (params) => {
|
|
31
|
+
const { blueprintFile, projectRoot } = params;
|
|
32
|
+
const full = path.resolve(projectRoot, blueprintFile);
|
|
33
|
+
return Effect.gen(function* () {
|
|
34
|
+
const exists = yield* Effect.promise(() => fs.access(full).then(() => true, () => false));
|
|
35
|
+
if (!exists) {
|
|
36
|
+
return yield* new Errors.ConfigBlueprintFileNotFound({
|
|
37
|
+
id: "pjt.config.blueprint-file-not-found",
|
|
38
|
+
blueprintFile,
|
|
39
|
+
message: `No blueprint file found at ${full}. Run \`pjt init\` to create one.`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const module_ = yield* Effect.tryPromise({
|
|
43
|
+
try: () => import(pathToFileURL(full).href),
|
|
44
|
+
catch: (e) => new Errors.LoaderImportFailed({
|
|
45
|
+
id: "pjt.loader.import-failed",
|
|
46
|
+
blueprintFile,
|
|
47
|
+
cause: e instanceof Error ? e.message : String(e),
|
|
48
|
+
message: `Failed to import ${blueprintFile}: ${e instanceof Error ? e.message : String(e)}`,
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
const value = module_.default;
|
|
52
|
+
if (!isProjitectFile(value)) {
|
|
53
|
+
return yield* new Errors.LoaderInvalidDefaultExport({
|
|
54
|
+
id: "pjt.loader.invalid-default-export",
|
|
55
|
+
blueprintFile,
|
|
56
|
+
received: describe(value),
|
|
57
|
+
message: `${blueprintFile} must \`export default pjt({...})\`. Received ${describe(value)}.`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const isProjitectFile = (v) => PredicateX.unsafeIsRecord(v) && v["_tag"] === "ProjitectConfig";
|
|
64
|
+
const describe = (v) => Match.value(v).pipe(Match.when(Predicate.isUndefined, () => "undefined"), Match.when(Predicate.isNull, () => "null"), Match.when(Array.isArray, () => "Array"), Match.when(PredicateX.unsafeIsRecord, () => 'object without `_tag: "ProjitectConfig"`'), Match.orElse((value) => typeof value));
|
|
65
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACxD,O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