@effect-vfs/core 0.3.0 → 0.3.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.
Files changed (53) hide show
  1. package/dist/BytePath.d.ts +33 -2
  2. package/dist/BytePath.d.ts.map +1 -1
  3. package/dist/BytePath.js +1 -1
  4. package/dist/Snapshot.d.ts +58 -2
  5. package/dist/Snapshot.d.ts.map +1 -1
  6. package/dist/Snapshot.js +57 -1
  7. package/dist/SnapshotDelta.d.ts +113 -3
  8. package/dist/SnapshotDelta.d.ts.map +1 -1
  9. package/dist/SnapshotDelta.js +112 -2
  10. package/dist/VirtualFileSystem.d.ts +919 -10
  11. package/dist/VirtualFileSystem.d.ts.map +1 -1
  12. package/dist/VirtualFileSystem.js +575 -7
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/internal/bytePath.d.ts.map +1 -1
  16. package/dist/internal/bytePath.js +5 -10
  17. package/dist/internal/bytes.d.ts +6 -0
  18. package/dist/internal/bytes.d.ts.map +1 -0
  19. package/dist/internal/bytes.js +17 -0
  20. package/dist/internal/canonicalBase64.d.ts +13 -5
  21. package/dist/internal/canonicalBase64.d.ts.map +1 -1
  22. package/dist/internal/canonicalBase64.js +28 -6
  23. package/dist/internal/image.d.ts +76 -90
  24. package/dist/internal/image.d.ts.map +1 -1
  25. package/dist/internal/image.js +98 -89
  26. package/dist/internal/metadata.d.ts +28 -0
  27. package/dist/internal/metadata.d.ts.map +1 -0
  28. package/dist/internal/metadata.js +29 -0
  29. package/dist/internal/snapshotDelta.d.ts.map +1 -1
  30. package/dist/internal/snapshotDelta.js +346 -300
  31. package/dist/internal/snapshotDeltaModel.d.ts +2 -2
  32. package/dist/internal/snapshotDeltaModel.d.ts.map +1 -1
  33. package/dist/internal/snapshotDeltaModel.js +3 -1
  34. package/dist/internal/virtualFileSystem/errors.d.ts +5 -0
  35. package/dist/internal/virtualFileSystem/errors.d.ts.map +1 -1
  36. package/dist/internal/virtualFileSystem/errors.js +19 -0
  37. package/dist/internal/virtualFileSystem/fixture.d.ts.map +1 -1
  38. package/dist/internal/virtualFileSystem/fixture.js +74 -74
  39. package/dist/internal/virtualFileSystem/overlayContent.d.ts.map +1 -1
  40. package/dist/internal/virtualFileSystem/overlayContent.js +9 -2
  41. package/dist/internal/virtualFileSystem/overlayDiff.d.ts +2 -11
  42. package/dist/internal/virtualFileSystem/overlayDiff.d.ts.map +1 -1
  43. package/dist/internal/virtualFileSystem/overlayDiff.js +45 -71
  44. package/dist/internal/virtualFileSystem/path.d.ts +15 -14
  45. package/dist/internal/virtualFileSystem/path.d.ts.map +1 -1
  46. package/dist/internal/virtualFileSystem/path.js +57 -54
  47. package/dist/internal/virtualFileSystem/testHooks.d.ts.map +1 -1
  48. package/dist/internal/virtualFileSystem/watchHub.d.ts.map +1 -1
  49. package/dist/internal/virtualFileSystem/watchHub.js +13 -13
  50. package/dist/internal/virtualFileSystem.d.ts +91 -15
  51. package/dist/internal/virtualFileSystem.d.ts.map +1 -1
  52. package/dist/internal/virtualFileSystem.js +470 -392
  53. package/package.json +15 -5
@@ -1,23 +1,54 @@
1
+ /**
2
+ * Opaque, byte-preserving filesystem paths.
3
+ *
4
+ * A `BytePath` stores the exact bytes of a path component so that names which
5
+ * are not valid UTF-8 survive a round trip through the virtual filesystem.
6
+ *
7
+ * @since 0.1.0
8
+ */
1
9
  import type * as Equal from "effect/Equal";
2
10
  import type { Pipeable } from "effect/Pipeable";
3
11
  import * as Schema from "effect/Schema";
4
12
  /**
5
13
  * Type identifier for opaque byte-preserving filesystem paths.
6
14
  *
7
- * @category type ids
15
+ * @category type IDs
8
16
  * @since 0.1.0
9
17
  */
10
18
  export declare const BytePathId: "@effect-vfs/core/BytePath";
11
19
  /**
12
20
  * Type identifier for opaque byte-preserving filesystem paths.
13
21
  *
14
- * @category type ids
22
+ * @category type IDs
15
23
  * @since 0.1.0
16
24
  */
17
25
  export type BytePathId = typeof BytePathId;
18
26
  /**
19
27
  * An opaque path that preserves arbitrary non-NUL bytes without UTF-8 conversion.
20
28
  *
29
+ * @example
30
+ * ```ts
31
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
32
+ * import { Effect } from "effect"
33
+ *
34
+ * // A name that is not valid UTF-8 still round-trips exactly.
35
+ * const program = Effect.gen(function*() {
36
+ * const caller = yield* (yield* Vfs.make()).caller()
37
+ * const path = yield* Vfs.pathFromBytes(new Uint8Array([47, 0xff, 0xfe]))
38
+ *
39
+ * yield* caller.writeFile(path, new Uint8Array([1]), {
40
+ * access: "write",
41
+ * create: "exclusive"
42
+ * })
43
+ *
44
+ * // `readDirectory` fails `UnrepresentableName` here; the byte variant keeps it.
45
+ * return yield* caller.readDirectoryBytes("/")
46
+ * })
47
+ *
48
+ * Effect.runPromise(program).then(console.log)
49
+ * // [ Uint8Array(2) [ 255, 254 ] ]
50
+ * ```
51
+ *
21
52
  * @category models
22
53
  * @since 0.1.0
23
54
  */
@@ -1 +1 @@
1
- {"version":3,"file":"BytePath.d.ts","sourceRoot":"","sources":["../src/BytePath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,2BAAiD,CAAA;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAA;AAE1C;;;;;GAKG;AACH,MAAM,WAAW,QAAS,SAAQ,KAAK,CAAC,KAAK,EAAE,QAAQ;IACrD,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU,CAAA;CAClC;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,oCAAgD,CAAA"}
1
+ {"version":3,"file":"BytePath.d.ts","sourceRoot":"","sources":["../src/BytePath.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,2BAAiD,CAAA;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAA;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,QAAS,SAAQ,KAAK,CAAC,KAAK,EAAE,QAAQ;IACrD,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU,CAAA;CAClC;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,oCAAgD,CAAA"}
package/dist/BytePath.js CHANGED
@@ -3,7 +3,7 @@ import * as Internal from "./internal/bytePath.js";
3
3
  /**
4
4
  * Type identifier for opaque byte-preserving filesystem paths.
5
5
  *
6
- * @category type ids
6
+ * @category type IDs
7
7
  * @since 0.1.0
8
8
  */
9
9
  export const BytePathId = Internal.BytePathId;
@@ -2,14 +2,14 @@ import * as Schema from "effect/Schema";
2
2
  /**
3
3
  * Type identifier for opaque filesystem snapshots.
4
4
  *
5
- * @category type ids
5
+ * @category type IDs
6
6
  * @since 0.1.0
7
7
  */
8
8
  export declare const SnapshotTypeId: "@effect-vfs/core/Snapshot";
9
9
  /**
10
10
  * Type identifier for opaque filesystem snapshots.
11
11
  *
12
- * @category type ids
12
+ * @category type IDs
13
13
  * @since 0.1.0
14
14
  */
15
15
  export type SnapshotTypeId = typeof SnapshotTypeId;
@@ -28,6 +28,35 @@ declare const ImageError_base: new <A extends Record<string, any> = {}>(args: im
28
28
  /**
29
29
  * Describes a snapshot encoding, decoding, structure, or resource-limit failure.
30
30
  *
31
+ * @example
32
+ * ```ts
33
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
34
+ * import { ByteSize, Effect } from "effect"
35
+ *
36
+ * // Decoding is a trust boundary. `code` says what went wrong and `field` says
37
+ * // which input or limit it was, so a caller can decline just the bad payload.
38
+ * const program = Effect.gen(function*() {
39
+ * const volume = yield* Vfs.make()
40
+ * const bytes = yield* Vfs.encodeSnapshot(yield* volume.snapshot)
41
+ *
42
+ * return yield* Vfs.decodeSnapshot(bytes, {
43
+ * maxEncodedBytes: ByteSize.bytes(16),
44
+ * maxRecords: 10_000,
45
+ * maxEntries: 10_000,
46
+ * maxDecodedBytes: ByteSize.megabytes(16)
47
+ * }).pipe(
48
+ * Effect.as("accepted"),
49
+ * Effect.catchTag("ImageError", (error) =>
50
+ * error.code === "LimitExceeded"
51
+ * ? Effect.succeed(`declined at ${error.field}`)
52
+ * : Effect.fail(error))
53
+ * )
54
+ * })
55
+ *
56
+ * Effect.runPromise(program).then(console.log)
57
+ * // declined at encodedBytes
58
+ * ```
59
+ *
31
60
  * @category errors
32
61
  * @since 0.1.0
33
62
  */
@@ -41,6 +70,33 @@ export declare class ImageError extends ImageError_base<{
41
70
  /**
42
71
  * Schema for the mandatory resource limits applied while decoding a snapshot.
43
72
  *
73
+ * @example
74
+ * ```ts
75
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
76
+ * import { ByteSize, Effect } from "effect"
77
+ *
78
+ * // All four are required: each bounds a different resource. `maxEncodedBytes`
79
+ * // caps the wire payload before parsing; `maxDecodedBytes` caps memory after it.
80
+ * const limits: Vfs.DecodeLimits = {
81
+ * maxEncodedBytes: ByteSize.megabytes(4),
82
+ * maxRecords: 10_000,
83
+ * maxEntries: 10_000,
84
+ * maxDecodedBytes: ByteSize.megabytes(16)
85
+ * }
86
+ *
87
+ * const program = Effect.gen(function*() {
88
+ * const volume = yield* Vfs.make()
89
+ * const bytes = yield* Vfs.encodeSnapshot(yield* volume.snapshot)
90
+ *
91
+ * yield* Vfs.decodeSnapshot(bytes, limits)
92
+ *
93
+ * return "accepted"
94
+ * })
95
+ *
96
+ * Effect.runPromise(program).then(console.log)
97
+ * // accepted
98
+ * ```
99
+ *
44
100
  * @category schemas
45
101
  * @since 0.1.0
46
102
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Snapshot.d.ts","sourceRoot":"","sources":["../src/Snapshot.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAG,2BAAoC,CAAA;AAElE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAA;AAElD;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,cAAc,CAAA;CAC1C;;;;AAED;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,gBAA+B;IAC7D,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,oBAAoB,GAAG,kBAAkB,GAAG,eAAe,CAAA;IAC9F,kFAAkF;IAClF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC;CAAG;AAEL;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACvB,sDAAsD;;IAEtD,6DAA6D;;IAE7D,2CAA2C;;IAE3C,6CAA6C;;EAE7C,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA"}
1
+ {"version":3,"file":"Snapshot.d.ts","sourceRoot":"","sources":["../src/Snapshot.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAG,2BAAoC,CAAA;AAElE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAA;AAElD;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,cAAc,CAAA;CAC1C;;;;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,UAAW,SAAQ,gBAA+B;IAC7D,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,GAAG,oBAAoB,GAAG,kBAAkB,GAAG,eAAe,CAAA;IAC9F,kFAAkF;IAClF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC;CAAG;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,YAAY;IACvB,sDAAsD;;IAEtD,6DAA6D;;IAE7D,2CAA2C;;IAE3C,6CAA6C;;EAE7C,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA"}
package/dist/Snapshot.js CHANGED
@@ -12,13 +12,42 @@ import * as Schema from "effect/Schema";
12
12
  /**
13
13
  * Type identifier for opaque filesystem snapshots.
14
14
  *
15
- * @category type ids
15
+ * @category type IDs
16
16
  * @since 0.1.0
17
17
  */
18
18
  export const SnapshotTypeId = "@effect-vfs/core/Snapshot";
19
19
  /**
20
20
  * Describes a snapshot encoding, decoding, structure, or resource-limit failure.
21
21
  *
22
+ * @example
23
+ * ```ts
24
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
25
+ * import { ByteSize, Effect } from "effect"
26
+ *
27
+ * // Decoding is a trust boundary. `code` says what went wrong and `field` says
28
+ * // which input or limit it was, so a caller can decline just the bad payload.
29
+ * const program = Effect.gen(function*() {
30
+ * const volume = yield* Vfs.make()
31
+ * const bytes = yield* Vfs.encodeSnapshot(yield* volume.snapshot)
32
+ *
33
+ * return yield* Vfs.decodeSnapshot(bytes, {
34
+ * maxEncodedBytes: ByteSize.bytes(16),
35
+ * maxRecords: 10_000,
36
+ * maxEntries: 10_000,
37
+ * maxDecodedBytes: ByteSize.megabytes(16)
38
+ * }).pipe(
39
+ * Effect.as("accepted"),
40
+ * Effect.catchTag("ImageError", (error) =>
41
+ * error.code === "LimitExceeded"
42
+ * ? Effect.succeed(`declined at ${error.field}`)
43
+ * : Effect.fail(error))
44
+ * )
45
+ * })
46
+ *
47
+ * Effect.runPromise(program).then(console.log)
48
+ * // declined at encodedBytes
49
+ * ```
50
+ *
22
51
  * @category errors
23
52
  * @since 0.1.0
24
53
  */
@@ -27,6 +56,33 @@ export class ImageError extends Data.TaggedError("ImageError") {
27
56
  /**
28
57
  * Schema for the mandatory resource limits applied while decoding a snapshot.
29
58
  *
59
+ * @example
60
+ * ```ts
61
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
62
+ * import { ByteSize, Effect } from "effect"
63
+ *
64
+ * // All four are required: each bounds a different resource. `maxEncodedBytes`
65
+ * // caps the wire payload before parsing; `maxDecodedBytes` caps memory after it.
66
+ * const limits: Vfs.DecodeLimits = {
67
+ * maxEncodedBytes: ByteSize.megabytes(4),
68
+ * maxRecords: 10_000,
69
+ * maxEntries: 10_000,
70
+ * maxDecodedBytes: ByteSize.megabytes(16)
71
+ * }
72
+ *
73
+ * const program = Effect.gen(function*() {
74
+ * const volume = yield* Vfs.make()
75
+ * const bytes = yield* Vfs.encodeSnapshot(yield* volume.snapshot)
76
+ *
77
+ * yield* Vfs.decodeSnapshot(bytes, limits)
78
+ *
79
+ * return "accepted"
80
+ * })
81
+ *
82
+ * Effect.runPromise(program).then(console.log)
83
+ * // accepted
84
+ * ```
85
+ *
30
86
  * @category schemas
31
87
  * @since 0.1.0
32
88
  */
@@ -9,14 +9,14 @@ import { BytePath } from "./BytePath.js";
9
9
  /**
10
10
  * Type identifier for opaque snapshot deltas.
11
11
  *
12
- * @category type ids
12
+ * @category type IDs
13
13
  * @since 0.1.0
14
14
  */
15
15
  export declare const SnapshotDeltaTypeId: "@effect-vfs/core/SnapshotDelta";
16
16
  /**
17
17
  * Type identifier for opaque snapshot deltas.
18
18
  *
19
- * @category type ids
19
+ * @category type IDs
20
20
  * @since 0.1.0
21
21
  */
22
22
  export type SnapshotDeltaTypeId = typeof SnapshotDeltaTypeId;
@@ -70,6 +70,39 @@ export type SnapshotDifference = typeof SnapshotDifference.Type;
70
70
  * Independent snapshots do not preserve shared lineage, so moves are reported
71
71
  * as a removal and an addition rather than an inferred rename.
72
72
  *
73
+ * @example
74
+ * ```ts
75
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
76
+ * import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
77
+ * import { Effect } from "effect"
78
+ *
79
+ * const program = Effect.gen(function*() {
80
+ * const volume = yield* Vfs.make()
81
+ * const caller = yield* volume.caller()
82
+ *
83
+ * yield* caller.writeFile("/f", new Uint8Array([1]), {
84
+ * access: "write",
85
+ * create: "exclusive"
86
+ * })
87
+ *
88
+ * const base = yield* volume.snapshot
89
+ *
90
+ * yield* caller.writeFile("/f", new Uint8Array([2, 3]), { access: "write", truncate: true })
91
+ * yield* caller.chmod("/f", 0o600)
92
+ *
93
+ * const delta = yield* Vfs.diffSnapshots(base, yield* volume.snapshot)
94
+ * const changes = yield* Vfs.inspectSnapshotDelta(base, delta)
95
+ *
96
+ * // `Updated` carries which fields moved; `Added` and `Removed` carry a kind.
97
+ * const change = changes[0]!
98
+ *
99
+ * return change._tag === "Updated" ? change.differences : change.kind
100
+ * }).pipe(Effect.provide(NodeCrypto.layer))
101
+ *
102
+ * Effect.runPromise(program).then(console.log)
103
+ * // [ 'content', 'mode' ]
104
+ * ```
105
+ *
73
106
  * @category schemas
74
107
  * @since 0.1.0
75
108
  */
@@ -95,6 +128,32 @@ export type SnapshotChange = typeof SnapshotChange.Type;
95
128
  /**
96
129
  * Schema for snapshot-delta inspection options.
97
130
  *
131
+ * @example
132
+ * ```ts
133
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
134
+ * import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
135
+ * import { Effect } from "effect"
136
+ *
137
+ * const program = Effect.gen(function*() {
138
+ * const volume = yield* Vfs.make()
139
+ * const caller = yield* volume.caller()
140
+ * const base = yield* volume.snapshot
141
+ *
142
+ * yield* caller.mkdir("/work")
143
+ *
144
+ * const delta = yield* Vfs.diffSnapshots(base, yield* volume.snapshot)
145
+ *
146
+ * // Timestamps are excluded by default, since they change on every write.
147
+ * const plain = yield* Vfs.inspectSnapshotDelta(base, delta)
148
+ * const timed = yield* Vfs.inspectSnapshotDelta(base, delta, { includeTimestamps: true })
149
+ *
150
+ * return [plain.length, timed.length]
151
+ * }).pipe(Effect.provide(NodeCrypto.layer))
152
+ *
153
+ * Effect.runPromise(program).then(console.log)
154
+ * // [ 1, 2 ]
155
+ * ```
156
+ *
98
157
  * @category schemas
99
158
  * @since 0.1.0
100
159
  */
@@ -115,6 +174,32 @@ declare const SnapshotDeltaError_base: new <A extends Record<string, any> = {}>(
115
174
  /**
116
175
  * A valid snapshot delta was inspected or applied against a valid but semantically different base.
117
176
  *
177
+ * @example
178
+ * ```ts
179
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
180
+ * import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
181
+ * import { Effect } from "effect"
182
+ *
183
+ * const program = Effect.gen(function*() {
184
+ * const volume = yield* Vfs.make()
185
+ * const caller = yield* volume.caller()
186
+ * const base = yield* volume.snapshot
187
+ *
188
+ * yield* caller.mkdir("/work")
189
+ *
190
+ * // Omitting limits uses `default`; `constrained` suits memory-sensitive hosts.
191
+ * const tight = { ...Vfs.SnapshotDeltaLimits.constrained, maxOutputRecords: 0 }
192
+ *
193
+ * return yield* Vfs.diffSnapshots(base, yield* volume.snapshot, tight).pipe(
194
+ * Effect.as("diffed"),
195
+ * Effect.catchTag("ImageError", (error) => Effect.succeed(`${error.code} at ${error.field}`))
196
+ * )
197
+ * }).pipe(Effect.provide(NodeCrypto.layer))
198
+ *
199
+ * Effect.runPromise(program).then(console.log)
200
+ * // LimitExceeded at outputRecords
201
+ * ```
202
+ *
118
203
  * @category errors
119
204
  * @since 0.1.0
120
205
  */
@@ -141,7 +226,11 @@ declare const SnapshotDeltaLimitsSchema: Schema.Struct<{
141
226
  * @since 0.1.0
142
227
  */
143
228
  export type SnapshotDeltaLimits = typeof SnapshotDeltaLimitsSchema.Type;
144
- /** Constructs and freezes a complete snapshot-delta resource policy. @internal */
229
+ /**
230
+ * Constructs and freezes a complete snapshot-delta resource policy.
231
+ *
232
+ * @internal
233
+ */
145
234
  export declare const makeSnapshotDeltaLimits: (limits: SnapshotDeltaLimits) => SnapshotDeltaLimits;
146
235
  /**
147
236
  * Schema for a complete snapshot-delta resource policy, with frozen presets.
@@ -149,6 +238,27 @@ export declare const makeSnapshotDeltaLimits: (limits: SnapshotDeltaLimits) => S
149
238
  * The constrained preset is intended for memory-sensitive environments. The
150
239
  * default preset permits larger snapshots and payloads while remaining finite.
151
240
  *
241
+ * @example
242
+ * ```ts
243
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
244
+ * import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
245
+ * import { Effect } from "effect"
246
+ *
247
+ * const program = Effect.gen(function*() {
248
+ * const volume = yield* Vfs.make()
249
+ * const base = yield* volume.snapshot
250
+ *
251
+ * yield* (yield* volume.caller()).mkdir("/work")
252
+ *
253
+ * // Omitting limits uses `default`; pass `constrained` where memory is tight.
254
+ * return yield* Vfs.diffSnapshots(
255
+ * base,
256
+ * yield* volume.snapshot,
257
+ * Vfs.SnapshotDeltaLimits.constrained
258
+ * )
259
+ * }).pipe(Effect.provide(NodeCrypto.layer))
260
+ * ```
261
+ *
152
262
  * @category schemas
153
263
  * @since 0.1.0
154
264
  */
@@ -1 +1 @@
1
- {"version":3,"file":"SnapshotDelta.d.ts","sourceRoot":"","sources":["../src/SnapshotDelta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAE3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AA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AAC,IAAI,CAAA;;;;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC7E,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;CAC9B,CAAC;CAAG;AAEL,QAAA,MAAM,yBAAyB;;;;;;;;;;;EAW7B,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,yBAAyB,CAAC,IAAI,CAAA;AAEvE;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,WAAY,mBAAmB,KAAG,mBACxC,CAAA;AA4B9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAG9B,CAAA"}
@@ -11,7 +11,7 @@ import * as Internal from "./internal/snapshotDeltaModel.js";
11
11
  /**
12
12
  * Type identifier for opaque snapshot deltas.
13
13
  *
14
- * @category type ids
14
+ * @category type IDs
15
15
  * @since 0.1.0
16
16
  */
17
17
  export const SnapshotDeltaTypeId = Internal.SnapshotDeltaTypeId;
@@ -55,6 +55,39 @@ const SnapshotDifferences = Schema.Array(SnapshotDifference).check(Schema.isMinL
55
55
  * Independent snapshots do not preserve shared lineage, so moves are reported
56
56
  * as a removal and an addition rather than an inferred rename.
57
57
  *
58
+ * @example
59
+ * ```ts
60
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
61
+ * import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
62
+ * import { Effect } from "effect"
63
+ *
64
+ * const program = Effect.gen(function*() {
65
+ * const volume = yield* Vfs.make()
66
+ * const caller = yield* volume.caller()
67
+ *
68
+ * yield* caller.writeFile("/f", new Uint8Array([1]), {
69
+ * access: "write",
70
+ * create: "exclusive"
71
+ * })
72
+ *
73
+ * const base = yield* volume.snapshot
74
+ *
75
+ * yield* caller.writeFile("/f", new Uint8Array([2, 3]), { access: "write", truncate: true })
76
+ * yield* caller.chmod("/f", 0o600)
77
+ *
78
+ * const delta = yield* Vfs.diffSnapshots(base, yield* volume.snapshot)
79
+ * const changes = yield* Vfs.inspectSnapshotDelta(base, delta)
80
+ *
81
+ * // `Updated` carries which fields moved; `Added` and `Removed` carry a kind.
82
+ * const change = changes[0]!
83
+ *
84
+ * return change._tag === "Updated" ? change.differences : change.kind
85
+ * }).pipe(Effect.provide(NodeCrypto.layer))
86
+ *
87
+ * Effect.runPromise(program).then(console.log)
88
+ * // [ 'content', 'mode' ]
89
+ * ```
90
+ *
58
91
  * @category schemas
59
92
  * @since 0.1.0
60
93
  */
@@ -71,6 +104,32 @@ export const SnapshotChange = Schema.Union([
71
104
  /**
72
105
  * Schema for snapshot-delta inspection options.
73
106
  *
107
+ * @example
108
+ * ```ts
109
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
110
+ * import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
111
+ * import { Effect } from "effect"
112
+ *
113
+ * const program = Effect.gen(function*() {
114
+ * const volume = yield* Vfs.make()
115
+ * const caller = yield* volume.caller()
116
+ * const base = yield* volume.snapshot
117
+ *
118
+ * yield* caller.mkdir("/work")
119
+ *
120
+ * const delta = yield* Vfs.diffSnapshots(base, yield* volume.snapshot)
121
+ *
122
+ * // Timestamps are excluded by default, since they change on every write.
123
+ * const plain = yield* Vfs.inspectSnapshotDelta(base, delta)
124
+ * const timed = yield* Vfs.inspectSnapshotDelta(base, delta, { includeTimestamps: true })
125
+ *
126
+ * return [plain.length, timed.length]
127
+ * }).pipe(Effect.provide(NodeCrypto.layer))
128
+ *
129
+ * Effect.runPromise(program).then(console.log)
130
+ * // [ 1, 2 ]
131
+ * ```
132
+ *
74
133
  * @category schemas
75
134
  * @since 0.1.0
76
135
  */
@@ -81,6 +140,32 @@ export const SnapshotChangesOptions = Schema.Struct({
81
140
  /**
82
141
  * A valid snapshot delta was inspected or applied against a valid but semantically different base.
83
142
  *
143
+ * @example
144
+ * ```ts
145
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
146
+ * import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
147
+ * import { Effect } from "effect"
148
+ *
149
+ * const program = Effect.gen(function*() {
150
+ * const volume = yield* Vfs.make()
151
+ * const caller = yield* volume.caller()
152
+ * const base = yield* volume.snapshot
153
+ *
154
+ * yield* caller.mkdir("/work")
155
+ *
156
+ * // Omitting limits uses `default`; `constrained` suits memory-sensitive hosts.
157
+ * const tight = { ...Vfs.SnapshotDeltaLimits.constrained, maxOutputRecords: 0 }
158
+ *
159
+ * return yield* Vfs.diffSnapshots(base, yield* volume.snapshot, tight).pipe(
160
+ * Effect.as("diffed"),
161
+ * Effect.catchTag("ImageError", (error) => Effect.succeed(`${error.code} at ${error.field}`))
162
+ * )
163
+ * }).pipe(Effect.provide(NodeCrypto.layer))
164
+ *
165
+ * Effect.runPromise(program).then(console.log)
166
+ * // LimitExceeded at outputRecords
167
+ * ```
168
+ *
84
169
  * @category errors
85
170
  * @since 0.1.0
86
171
  */
@@ -98,7 +183,11 @@ const SnapshotDeltaLimitsSchema = Schema.Struct({
98
183
  maxOutputBytes: Schema.ByteSize,
99
184
  maxInheritedRecords: Schema.Natural
100
185
  });
101
- /** Constructs and freezes a complete snapshot-delta resource policy. @internal */
186
+ /**
187
+ * Constructs and freezes a complete snapshot-delta resource policy.
188
+ *
189
+ * @internal
190
+ */
102
191
  export const makeSnapshotDeltaLimits = (limits) => Object.freeze({ ...limits });
103
192
  const constrained = makeSnapshotDeltaLimits({
104
193
  maxEncodedBytes: ByteSize.mebibytes(2),
@@ -130,6 +219,27 @@ const defaultLimits = makeSnapshotDeltaLimits({
130
219
  * The constrained preset is intended for memory-sensitive environments. The
131
220
  * default preset permits larger snapshots and payloads while remaining finite.
132
221
  *
222
+ * @example
223
+ * ```ts
224
+ * import { VirtualFileSystem as Vfs } from "@effect-vfs/core"
225
+ * import * as NodeCrypto from "@effect/platform-node-shared/NodeCrypto"
226
+ * import { Effect } from "effect"
227
+ *
228
+ * const program = Effect.gen(function*() {
229
+ * const volume = yield* Vfs.make()
230
+ * const base = yield* volume.snapshot
231
+ *
232
+ * yield* (yield* volume.caller()).mkdir("/work")
233
+ *
234
+ * // Omitting limits uses `default`; pass `constrained` where memory is tight.
235
+ * return yield* Vfs.diffSnapshots(
236
+ * base,
237
+ * yield* volume.snapshot,
238
+ * Vfs.SnapshotDeltaLimits.constrained
239
+ * )
240
+ * }).pipe(Effect.provide(NodeCrypto.layer))
241
+ * ```
242
+ *
133
243
  * @category schemas
134
244
  * @since 0.1.0
135
245
  */