@projitect/test-kit 0.0.0-stage → 1.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kapil Easwar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,22 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { BlueprintFileSystem } from "@projitect/core";
3
+ /**
4
+ * Build a fresh in-memory `BlueprintFileSystem` Layer seeded with the given files.
5
+ * Use it inside `it.effect(...)` tests:
6
+ *
7
+ * it.effect("creates a region", () =>
8
+ * myBlueprint.plan.pipe(
9
+ * Effect.provide(makeInMemoryLayer({ ".gitignore": "" }))
10
+ * )
11
+ * )
12
+ *
13
+ * Reads outside the seeded set return `FsReadFailed`; permission checks are skipped (this is a
14
+ * unit-test fixture, not the production permission gate).
15
+ */
16
+ export declare const makeInMemoryLayer: (initial?: Readonly<Record<string, string>>) => Layer.Layer<BlueprintFileSystem>;
17
+ /**
18
+ * Inspect helper for tests: read all paths currently held by an in-memory layer. Useful for
19
+ * snapshot-style assertions about what a blueprint wrote.
20
+ */
21
+ export declare const dumpFs: (layer: Layer.Layer<BlueprintFileSystem>) => Effect.Effect<Readonly<Record<string, string>>>;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAU,MAAM,iBAAiB,CAAA;AAG7D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,KAC7C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CA2DjC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,GACjB,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,KACtC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAc9C,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,73 @@
1
+ import { Effect, Layer } from "effect";
2
+ import { BlueprintFileSystem, Errors } from "@projitect/core";
3
+ /**
4
+ * Build a fresh in-memory `BlueprintFileSystem` Layer seeded with the given files.
5
+ * Use it inside `it.effect(...)` tests:
6
+ *
7
+ * it.effect("creates a region", () =>
8
+ * myBlueprint.plan.pipe(
9
+ * Effect.provide(makeInMemoryLayer({ ".gitignore": "" }))
10
+ * )
11
+ * )
12
+ *
13
+ * Reads outside the seeded set return `FsReadFailed`; permission checks are skipped (this is a
14
+ * unit-test fixture, not the production permission gate).
15
+ */
16
+ export const makeInMemoryLayer = (initial = {}) => {
17
+ const state = new Map(Object.entries(initial));
18
+ const shape = {
19
+ readFile: (path) => Effect.suspend(() => {
20
+ const v = state.get(path);
21
+ return v === undefined
22
+ ? Effect.fail(new Errors.FsReadFailed({
23
+ id: "pjt.fs.read-failed",
24
+ path,
25
+ cause: "ENOENT",
26
+ message: `In-memory FS: no file at ${path}`,
27
+ }))
28
+ : Effect.succeed(v);
29
+ }),
30
+ writeFile: (path, content) => Effect.sync(() => {
31
+ state.set(path, content);
32
+ }),
33
+ exists: (path) => Effect.sync(() => state.has(path)),
34
+ remove: (path) => Effect.suspend(() => {
35
+ const prefix = `${path}/`;
36
+ return !state.has(path) && Array.from(state.keys()).some((k) => k.startsWith(prefix))
37
+ ? Effect.fail(new Errors.FsWriteFailed({
38
+ id: "pjt.fs.write-failed",
39
+ path,
40
+ cause: "EISDIR",
41
+ message: `In-memory FS: ${path} is a directory`,
42
+ }))
43
+ : Effect.sync(() => {
44
+ state.delete(path);
45
+ });
46
+ }),
47
+ removeEmptyDir: (path) => Effect.suspend(() => {
48
+ const prefix = `${path}/`;
49
+ return Array.from(state.keys()).some((k) => k.startsWith(prefix))
50
+ ? Effect.fail(new Errors.FsWriteFailed({
51
+ id: "pjt.fs.write-failed",
52
+ path,
53
+ cause: "ENOTEMPTY",
54
+ message: `In-memory FS: ${path} is not empty`,
55
+ }))
56
+ : Effect.void;
57
+ }),
58
+ mkdir: (_path) => Effect.void,
59
+ listDir: (prefix) => Effect.sync(() => Array.from(state.keys()).filter((k) => k.startsWith(prefix))),
60
+ };
61
+ return Layer.succeed(BlueprintFileSystem, shape);
62
+ };
63
+ /**
64
+ * Inspect helper for tests: read all paths currently held by an in-memory layer. Useful for
65
+ * snapshot-style assertions about what a blueprint wrote.
66
+ */
67
+ export const dumpFs = (layer) => Effect.gen(function* () {
68
+ const fs = yield* BlueprintFileSystem;
69
+ const keys = yield* fs.listDir("");
70
+ const entries = yield* Effect.forEach(keys, (k) => fs.readFile(k).pipe(Effect.map((v) => [k, v]), Effect.orElseSucceed(() => [k, ""])));
71
+ return Object.fromEntries(entries);
72
+ }).pipe(Effect.provide(layer), Effect.orElseSucceed(() => ({})));
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAG7D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAA4C,EAAE,EACZ,EAAE;IACpC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAiB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;IAE9D,MAAM,KAAK,GAA6B;QACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CACjB,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;YAClB,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACzB,OAAO,CAAC,KAAK,SAAS;gBACpB,CAAC,CAAC,MAAM,CAAC,IAAI,CACT,IAAI,MAAM,CAAC,YAAY,CAAC;oBACtB,EAAE,EAAE,oBAAoB;oBACxB,IAAI;oBACJ,KAAK,EAAE,QAAQ;oBACf,OAAO,EAAE,4BAA4B,IAAI,EAAE;iBAC5C,CAAC,CACH;gBACH,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QACvB,CAAC,CAAC;QACJ,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAC3B,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACf,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAC1B,CAAC,CAAC;QACJ,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,C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AAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CACjC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@projitect/test-kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.1",
4
+ "description": "Testing helpers for blueprint authors — in-memory BlueprintFileSystem Layer, ChangeSet snapshot helpers.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/projitect/projitect.git",
8
+ "directory": "packages/test-kit"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "src",
21
+ "!**/*.tsbuildinfo"
22
+ ],
23
+ "devDependencies": {
24
+ "effect": "4.0.0-rc.111",
25
+ "typescript": "5.9.3",
26
+ "@projitect/core": "1.0.1"
27
+ },
28
+ "peerDependencies": {
29
+ "effect": "4.0.0-rc.111",
30
+ "@projitect/core": "1.0.1"
31
+ },
32
+ "engines": {
33
+ "node": ">=22.12.0"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc --build",
37
+ "build:clean": "tsc --build --clean",
38
+ "tc": "tsc --build"
39
+ }
6
40
  }
package/src/index.ts ADDED
@@ -0,0 +1,101 @@
1
+ import { Effect, Layer } from "effect"
2
+ import { BlueprintFileSystem, Errors } from "@projitect/core"
3
+ import type { BlueprintFileSystemShape } from "@projitect/core"
4
+
5
+ /**
6
+ * Build a fresh in-memory `BlueprintFileSystem` Layer seeded with the given files.
7
+ * Use it inside `it.effect(...)` tests:
8
+ *
9
+ * it.effect("creates a region", () =>
10
+ * myBlueprint.plan.pipe(
11
+ * Effect.provide(makeInMemoryLayer({ ".gitignore": "" }))
12
+ * )
13
+ * )
14
+ *
15
+ * Reads outside the seeded set return `FsReadFailed`; permission checks are skipped (this is a
16
+ * unit-test fixture, not the production permission gate).
17
+ */
18
+ export const makeInMemoryLayer = (
19
+ initial: Readonly<Record<string, string>> = {},
20
+ ): Layer.Layer<BlueprintFileSystem> => {
21
+ const state = new Map<string, string>(Object.entries(initial))
22
+
23
+ const shape: BlueprintFileSystemShape = {
24
+ readFile: (path) =>
25
+ Effect.suspend(() => {
26
+ const v = state.get(path)
27
+ return v === undefined
28
+ ? Effect.fail(
29
+ new Errors.FsReadFailed({
30
+ id: "pjt.fs.read-failed",
31
+ path,
32
+ cause: "ENOENT",
33
+ message: `In-memory FS: no file at ${path}`,
34
+ }),
35
+ )
36
+ : Effect.succeed(v)
37
+ }),
38
+ writeFile: (path, content) =>
39
+ Effect.sync(() => {
40
+ state.set(path, content)
41
+ }),
42
+ exists: (path) => Effect.sync(() => state.has(path)),
43
+ remove: (path) =>
44
+ Effect.suspend(() => {
45
+ const prefix = `${path}/`
46
+ return !state.has(path) && Array.from(state.keys()).some((k) => k.startsWith(prefix))
47
+ ? Effect.fail(
48
+ new Errors.FsWriteFailed({
49
+ id: "pjt.fs.write-failed",
50
+ path,
51
+ cause: "EISDIR",
52
+ message: `In-memory FS: ${path} is a directory`,
53
+ }),
54
+ )
55
+ : Effect.sync(() => {
56
+ state.delete(path)
57
+ })
58
+ }),
59
+ removeEmptyDir: (path) =>
60
+ Effect.suspend(() => {
61
+ const prefix = `${path}/`
62
+ return Array.from(state.keys()).some((k) => k.startsWith(prefix))
63
+ ? Effect.fail(
64
+ new Errors.FsWriteFailed({
65
+ id: "pjt.fs.write-failed",
66
+ path,
67
+ cause: "ENOTEMPTY",
68
+ message: `In-memory FS: ${path} is not empty`,
69
+ }),
70
+ )
71
+ : Effect.void
72
+ }),
73
+ mkdir: (_path) => Effect.void,
74
+ listDir: (prefix) =>
75
+ Effect.sync(() => Array.from(state.keys()).filter((k) => k.startsWith(prefix))),
76
+ }
77
+
78
+ return Layer.succeed(BlueprintFileSystem, shape)
79
+ }
80
+
81
+ /**
82
+ * Inspect helper for tests: read all paths currently held by an in-memory layer. Useful for
83
+ * snapshot-style assertions about what a blueprint wrote.
84
+ */
85
+ export const dumpFs = (
86
+ layer: Layer.Layer<BlueprintFileSystem>,
87
+ ): Effect.Effect<Readonly<Record<string, string>>> =>
88
+ Effect.gen(function* () {
89
+ const fs = yield* BlueprintFileSystem
90
+ const keys = yield* fs.listDir("")
91
+ const entries = yield* Effect.forEach(keys, (k) =>
92
+ fs.readFile(k).pipe(
93
+ Effect.map((v) => [k, v] as const),
94
+ Effect.orElseSucceed(() => [k, ""] as const),
95
+ ),
96
+ )
97
+ return Object.fromEntries(entries)
98
+ }).pipe(
99
+ Effect.provide(layer),
100
+ Effect.orElseSucceed(() => ({})),
101
+ )
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.