@effect-vfs/core 0.2.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.
- package/dist/BytePath.d.ts +49 -5
- package/dist/BytePath.d.ts.map +1 -1
- package/dist/BytePath.js +9 -9
- package/dist/Snapshot.d.ts +61 -5
- package/dist/Snapshot.d.ts.map +1 -1
- package/dist/Snapshot.js +60 -5
- package/dist/SnapshotDelta.d.ts +208 -31
- package/dist/SnapshotDelta.d.ts.map +1 -1
- package/dist/SnapshotDelta.js +162 -25
- package/dist/VirtualFileSystem.d.ts +1035 -348
- package/dist/VirtualFileSystem.d.ts.map +1 -1
- package/dist/VirtualFileSystem.js +620 -1772
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/bytePath.d.ts +10 -0
- package/dist/internal/bytePath.d.ts.map +1 -0
- package/dist/internal/bytePath.js +41 -0
- package/dist/internal/bytes.d.ts +6 -0
- package/dist/internal/bytes.d.ts.map +1 -0
- package/dist/internal/bytes.js +17 -0
- package/dist/internal/canonicalBase64.d.ts +14 -6
- package/dist/internal/canonicalBase64.d.ts.map +1 -1
- package/dist/internal/canonicalBase64.js +29 -7
- package/dist/internal/image.d.ts +85 -104
- package/dist/internal/image.d.ts.map +1 -1
- package/dist/internal/image.js +99 -95
- package/dist/internal/metadata.d.ts +28 -0
- package/dist/internal/metadata.d.ts.map +1 -0
- package/dist/internal/metadata.js +29 -0
- package/dist/internal/snapshotDelta.d.ts +0 -1
- package/dist/internal/snapshotDelta.d.ts.map +1 -1
- package/dist/internal/snapshotDelta.js +358 -325
- package/dist/internal/snapshotDeltaModel.d.ts +10 -0
- package/dist/internal/snapshotDeltaModel.d.ts.map +1 -0
- package/dist/internal/snapshotDeltaModel.js +15 -0
- package/dist/internal/virtualFileSystem/errors.d.ts +31 -0
- package/dist/internal/virtualFileSystem/errors.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/errors.js +51 -0
- package/dist/internal/virtualFileSystem/fixture.d.ts +63 -0
- package/dist/internal/virtualFileSystem/fixture.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/fixture.js +144 -0
- package/dist/internal/{content.d.ts → virtualFileSystem/overlayContent.d.ts} +4 -14
- package/dist/internal/virtualFileSystem/overlayContent.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/overlayContent.js +29 -0
- package/dist/internal/{overlayChanges.d.ts → virtualFileSystem/overlayDiff.d.ts} +3 -12
- package/dist/internal/virtualFileSystem/overlayDiff.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/overlayDiff.js +120 -0
- package/dist/internal/virtualFileSystem/path.d.ts +44 -0
- package/dist/internal/virtualFileSystem/path.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/path.js +127 -0
- package/dist/internal/virtualFileSystem/testHooks.d.ts +20 -0
- package/dist/internal/virtualFileSystem/testHooks.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/testHooks.js +23 -0
- package/dist/internal/virtualFileSystem/watchHub.d.ts +16 -0
- package/dist/internal/virtualFileSystem/watchHub.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/watchHub.js +33 -0
- package/dist/internal/virtualFileSystem.d.ts +366 -0
- package/dist/internal/virtualFileSystem.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem.js +1755 -0
- package/package.json +15 -5
- package/dist/internal/content.d.ts.map +0 -1
- package/dist/internal/content.js +0 -26
- package/dist/internal/overlayChanges.d.ts.map +0 -1
- package/dist/internal/overlayChanges.js +0 -146
- package/dist/internal/overlayTesting.d.ts +0 -12
- package/dist/internal/overlayTesting.d.ts.map +0 -1
- package/dist/internal/overlayTesting.js +0 -12
package/dist/SnapshotDelta.js
CHANGED
|
@@ -7,23 +7,34 @@ import * as ByteSize from "effect/ByteSize";
|
|
|
7
7
|
import * as Data from "effect/Data";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
9
|
import { BytePath } from "./BytePath.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
import * as Internal from "./internal/snapshotDeltaModel.js";
|
|
11
|
+
/**
|
|
12
|
+
* Type identifier for opaque snapshot deltas.
|
|
13
|
+
*
|
|
14
|
+
* @category type IDs
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
*/
|
|
17
|
+
export const SnapshotDeltaTypeId = Internal.SnapshotDeltaTypeId;
|
|
18
|
+
/**
|
|
19
|
+
* Schema for an already validated opaque snapshot delta.
|
|
20
|
+
*
|
|
21
|
+
* @category schemas
|
|
22
|
+
* @since 0.1.0
|
|
23
|
+
*/
|
|
24
|
+
export const SnapshotDelta = Schema.declare(Internal.isSnapshotDelta);
|
|
25
|
+
/**
|
|
26
|
+
* Schema for filesystem entry kinds reported by snapshot inspection.
|
|
27
|
+
*
|
|
28
|
+
* @category schemas
|
|
29
|
+
* @since 0.1.0
|
|
30
|
+
*/
|
|
25
31
|
export const SnapshotNodeKind = Schema.Literals(["directory", "file", "symlink"]);
|
|
26
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Schema for semantic fields that can differ between snapshots.
|
|
34
|
+
*
|
|
35
|
+
* @category schemas
|
|
36
|
+
* @since 0.1.0
|
|
37
|
+
*/
|
|
27
38
|
export const SnapshotDifference = Schema.Literals([
|
|
28
39
|
"kind",
|
|
29
40
|
"content",
|
|
@@ -43,6 +54,42 @@ const SnapshotDifferences = Schema.Array(SnapshotDifference).check(Schema.isMinL
|
|
|
43
54
|
*
|
|
44
55
|
* Independent snapshots do not preserve shared lineage, so moves are reported
|
|
45
56
|
* as a removal and an addition rather than an inferred rename.
|
|
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
|
+
*
|
|
91
|
+
* @category schemas
|
|
92
|
+
* @since 0.1.0
|
|
46
93
|
*/
|
|
47
94
|
export const SnapshotChange = Schema.Union([
|
|
48
95
|
Schema.TaggedStruct("Added", { path: BytePath, kind: SnapshotNodeKind }),
|
|
@@ -54,27 +101,93 @@ export const SnapshotChange = Schema.Union([
|
|
|
54
101
|
differences: SnapshotDifferences
|
|
55
102
|
})
|
|
56
103
|
]);
|
|
57
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* Schema for snapshot-delta inspection options.
|
|
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
|
+
*
|
|
133
|
+
* @category schemas
|
|
134
|
+
* @since 0.1.0
|
|
135
|
+
*/
|
|
58
136
|
export const SnapshotChangesOptions = Schema.Struct({
|
|
59
137
|
/** Include access, modification, change, and birth-time differences. Defaults to `false`. */
|
|
60
138
|
includeTimestamps: Schema.optionalKey(Schema.Boolean)
|
|
61
139
|
});
|
|
62
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* A valid snapshot delta was inspected or applied against a valid but semantically different base.
|
|
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
|
+
*
|
|
169
|
+
* @category errors
|
|
170
|
+
* @since 0.1.0
|
|
171
|
+
*/
|
|
63
172
|
export class SnapshotDeltaError extends Data.TaggedError("SnapshotDeltaError") {
|
|
64
173
|
}
|
|
65
174
|
const SnapshotDeltaLimitsSchema = Schema.Struct({
|
|
66
175
|
maxEncodedBytes: Schema.ByteSize,
|
|
67
176
|
maxIdentityBytes: Schema.ByteSize,
|
|
68
|
-
maxDeltaRecords: Natural,
|
|
177
|
+
maxDeltaRecords: Schema.Natural,
|
|
69
178
|
maxDecodedDeltaBytes: Schema.ByteSize,
|
|
70
|
-
maxBaseRecords: Natural,
|
|
71
|
-
maxTargetRecords: Natural,
|
|
72
|
-
maxEntries: Natural,
|
|
73
|
-
maxOutputRecords: Natural,
|
|
179
|
+
maxBaseRecords: Schema.Natural,
|
|
180
|
+
maxTargetRecords: Schema.Natural,
|
|
181
|
+
maxEntries: Schema.Natural,
|
|
182
|
+
maxOutputRecords: Schema.Natural,
|
|
74
183
|
maxOutputBytes: Schema.ByteSize,
|
|
75
|
-
maxInheritedRecords: Natural
|
|
184
|
+
maxInheritedRecords: Schema.Natural
|
|
76
185
|
});
|
|
77
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* Constructs and freezes a complete snapshot-delta resource policy.
|
|
188
|
+
*
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
78
191
|
export const makeSnapshotDeltaLimits = (limits) => Object.freeze({ ...limits });
|
|
79
192
|
const constrained = makeSnapshotDeltaLimits({
|
|
80
193
|
maxEncodedBytes: ByteSize.mebibytes(2),
|
|
@@ -105,6 +218,30 @@ const defaultLimits = makeSnapshotDeltaLimits({
|
|
|
105
218
|
*
|
|
106
219
|
* The constrained preset is intended for memory-sensitive environments. The
|
|
107
220
|
* default preset permits larger snapshots and payloads while remaining finite.
|
|
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
|
+
*
|
|
243
|
+
* @category schemas
|
|
244
|
+
* @since 0.1.0
|
|
108
245
|
*/
|
|
109
246
|
export const SnapshotDeltaLimits = Object.assign(SnapshotDeltaLimitsSchema, {
|
|
110
247
|
constrained,
|