@effect-vfs/core 0.5.0 → 0.7.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.
Files changed (130) hide show
  1. package/README.md +29 -21
  2. package/dist/BytePath.d.ts +115 -4
  3. package/dist/BytePath.d.ts.map +1 -1
  4. package/dist/BytePath.js +155 -0
  5. package/dist/Caller.d.ts +391 -0
  6. package/dist/Caller.d.ts.map +1 -0
  7. package/dist/Caller.js +199 -0
  8. package/dist/FileHandle.d.ts +50 -0
  9. package/dist/FileHandle.d.ts.map +1 -0
  10. package/dist/FileHandle.js +28 -0
  11. package/dist/Fixture.d.ts +155 -0
  12. package/dist/Fixture.d.ts.map +1 -0
  13. package/dist/Fixture.js +65 -0
  14. package/dist/LiveVolume.d.ts +13 -20
  15. package/dist/LiveVolume.d.ts.map +1 -1
  16. package/dist/LiveVolume.js +19 -14
  17. package/dist/Metadata.d.ts +186 -0
  18. package/dist/Metadata.d.ts.map +1 -0
  19. package/dist/Metadata.js +125 -0
  20. package/dist/Snapshot.d.ts +32 -53
  21. package/dist/Snapshot.d.ts.map +1 -1
  22. package/dist/Snapshot.js +27 -49
  23. package/dist/SnapshotDelta.d.ts +24 -39
  24. package/dist/SnapshotDelta.d.ts.map +1 -1
  25. package/dist/SnapshotDelta.js +14 -35
  26. package/dist/Target.d.ts +225 -0
  27. package/dist/Target.d.ts.map +1 -0
  28. package/dist/Target.js +92 -0
  29. package/dist/Testing.d.ts +132 -0
  30. package/dist/Testing.d.ts.map +1 -0
  31. package/dist/Testing.js +100 -0
  32. package/dist/VfsError.d.ts +200 -0
  33. package/dist/VfsError.d.ts.map +1 -0
  34. package/dist/VfsError.js +165 -0
  35. package/dist/VirtualFileSystem.d.ts +676 -353
  36. package/dist/VirtualFileSystem.d.ts.map +1 -1
  37. package/dist/VirtualFileSystem.js +487 -121
  38. package/dist/Volume.d.ts +211 -0
  39. package/dist/Volume.d.ts.map +1 -0
  40. package/dist/Volume.js +172 -0
  41. package/dist/Watch.d.ts +68 -0
  42. package/dist/Watch.d.ts.map +1 -0
  43. package/dist/Watch.js +46 -0
  44. package/dist/index.d.ts +56 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +56 -1
  47. package/dist/internal/budget.d.ts +90 -0
  48. package/dist/internal/budget.d.ts.map +1 -0
  49. package/dist/internal/budget.js +70 -0
  50. package/dist/internal/bytePath.d.ts +2 -0
  51. package/dist/internal/bytePath.d.ts.map +1 -1
  52. package/dist/internal/bytePath.js +3 -2
  53. package/dist/internal/bytes.d.ts +3 -0
  54. package/dist/internal/bytes.d.ts.map +1 -1
  55. package/dist/internal/bytes.js +4 -2
  56. package/dist/internal/canonicalBase64.d.ts +1 -4
  57. package/dist/internal/canonicalBase64.d.ts.map +1 -1
  58. package/dist/internal/canonicalBase64.js +9 -13
  59. package/dist/internal/errors.d.ts +47 -5
  60. package/dist/internal/errors.d.ts.map +1 -1
  61. package/dist/internal/errors.js +80 -36
  62. package/dist/internal/fixture.d.ts +2 -2
  63. package/dist/internal/fixture.d.ts.map +1 -1
  64. package/dist/internal/fixture.js +57 -74
  65. package/dist/internal/hex128.d.ts +12 -0
  66. package/dist/internal/hex128.d.ts.map +1 -0
  67. package/dist/internal/hex128.js +7 -0
  68. package/dist/internal/hmac.d.ts +5 -0
  69. package/dist/internal/hmac.d.ts.map +1 -0
  70. package/dist/internal/hmac.js +150 -0
  71. package/dist/internal/image.d.ts +14 -117
  72. package/dist/internal/image.d.ts.map +1 -1
  73. package/dist/internal/image.js +137 -167
  74. package/dist/internal/inodeTable.d.ts +20 -0
  75. package/dist/internal/inodeTable.d.ts.map +1 -0
  76. package/dist/internal/inodeTable.js +48 -0
  77. package/dist/internal/lines.d.ts +36 -0
  78. package/dist/internal/lines.d.ts.map +1 -0
  79. package/dist/internal/lines.js +115 -0
  80. package/dist/internal/liveImage.d.ts +19 -278
  81. package/dist/internal/liveImage.d.ts.map +1 -1
  82. package/dist/internal/liveImage.js +75 -166
  83. package/dist/internal/merkle.d.ts +45 -0
  84. package/dist/internal/merkle.d.ts.map +1 -0
  85. package/dist/internal/merkle.js +179 -0
  86. package/dist/internal/metadata.d.ts +2 -13
  87. package/dist/internal/metadata.d.ts.map +1 -1
  88. package/dist/internal/metadata.js +5 -15
  89. package/dist/internal/overlayDiff.d.ts +2 -2
  90. package/dist/internal/overlayDiff.d.ts.map +1 -1
  91. package/dist/internal/overlayDiff.js +4 -15
  92. package/dist/internal/path.d.ts +17 -5
  93. package/dist/internal/path.d.ts.map +1 -1
  94. package/dist/internal/path.js +38 -24
  95. package/dist/internal/snapshotDelta.d.ts +61 -60
  96. package/dist/internal/snapshotDelta.d.ts.map +1 -1
  97. package/dist/internal/snapshotDelta.js +605 -503
  98. package/dist/internal/snapshotDeltaModel.d.ts.map +1 -1
  99. package/dist/internal/snapshotDeltaModel.js +0 -1
  100. package/dist/internal/testSeams.d.ts +17 -0
  101. package/dist/internal/testSeams.d.ts.map +1 -0
  102. package/dist/internal/testSeams.js +20 -0
  103. package/dist/internal/tree.d.ts +225 -0
  104. package/dist/internal/tree.d.ts.map +1 -0
  105. package/dist/internal/tree.js +385 -0
  106. package/dist/internal/turnstile.d.ts +8 -0
  107. package/dist/internal/turnstile.d.ts.map +1 -0
  108. package/dist/internal/turnstile.js +43 -0
  109. package/dist/internal/virtualFileSystem.d.ts +44 -488
  110. package/dist/internal/virtualFileSystem.d.ts.map +1 -1
  111. package/dist/internal/virtualFileSystem.js +2111 -2466
  112. package/dist/internal/volumeState.d.ts +111 -0
  113. package/dist/internal/volumeState.d.ts.map +1 -0
  114. package/dist/internal/volumeState.js +202 -0
  115. package/dist/internal/watchHub.d.ts +15 -6
  116. package/dist/internal/watchHub.d.ts.map +1 -1
  117. package/dist/internal/watchHub.js +56 -42
  118. package/package.json +54 -10
  119. package/dist/VirtualFileSystemError.d.ts +0 -54
  120. package/dist/VirtualFileSystemError.d.ts.map +0 -1
  121. package/dist/VirtualFileSystemError.js +0 -49
  122. package/dist/internal/overlayContent.d.ts +0 -15
  123. package/dist/internal/overlayContent.d.ts.map +0 -1
  124. package/dist/internal/overlayContent.js +0 -29
  125. package/dist/internal/stagedState.d.ts +0 -22
  126. package/dist/internal/stagedState.d.ts.map +0 -1
  127. package/dist/internal/stagedState.js +0 -62
  128. package/dist/internal/testHooks.d.ts +0 -20
  129. package/dist/internal/testHooks.d.ts.map +0 -1
  130. package/dist/internal/testHooks.js +0 -23
@@ -0,0 +1,211 @@
1
+ import * as Order from "effect/Order";
2
+ import * as Schema from "effect/Schema";
3
+ import { BytePath } from "./BytePath.js";
4
+ /**
5
+ * Brand key that marks a volume.
6
+ *
7
+ * @category type IDs
8
+ * @since 0.6.0
9
+ */
10
+ export declare const VolumeId: unique symbol;
11
+ /**
12
+ * Brand key that marks a volume.
13
+ *
14
+ * @category type IDs
15
+ * @since 0.6.0
16
+ */
17
+ export type VolumeId = typeof VolumeId;
18
+ /**
19
+ * Schema for the failure boundary a volume's committed mutations survive.
20
+ *
21
+ * @category schemas
22
+ * @since 0.6.0
23
+ */
24
+ export declare const VolumeDurability: Schema.Literals<readonly ["memory-only", "survives-process-crash", "survives-operating-system-crash", "survives-power-loss"]>;
25
+ /**
26
+ * The failure boundary a volume's committed mutations survive.
27
+ *
28
+ * @category models
29
+ * @since 0.6.0
30
+ */
31
+ export type VolumeDurability = typeof VolumeDurability.Type;
32
+ /**
33
+ * Weakest-to-strongest ordering for volume durability guarantees.
34
+ *
35
+ * @category ordering
36
+ * @since 0.6.0
37
+ */
38
+ export declare const VolumeDurabilityOrder: Order.Order<VolumeDurability>;
39
+ /**
40
+ * Returns whether `actual` survives at least the failure boundary required by `required`.
41
+ *
42
+ * @category predicates
43
+ * @since 0.6.0
44
+ */
45
+ export declare const isVolumeDurabilityAtLeast: (actual: VolumeDurability, required: VolumeDurability) => boolean;
46
+ /**
47
+ * Schema for a volume identity: 128 bits as lowercase hexadecimal, stable
48
+ * across restarts of a durable volume.
49
+ *
50
+ * @category schemas
51
+ * @since 0.6.0
52
+ */
53
+ export declare const VolumeIdentity: Schema.brand<Schema.String, "@effect-vfs/core/VolumeIdentity">;
54
+ /**
55
+ * A volume identity.
56
+ *
57
+ * @category models
58
+ * @since 0.6.0
59
+ */
60
+ export type VolumeIdentity = typeof VolumeIdentity.Type;
61
+ /**
62
+ * Schema for a volume incarnation: 128 bits as lowercase hexadecimal, minted
63
+ * on every construction.
64
+ *
65
+ * @category schemas
66
+ * @since 0.6.0
67
+ */
68
+ export declare const VolumeIncarnation: Schema.brand<Schema.String, "@effect-vfs/core/VolumeIncarnation">;
69
+ /**
70
+ * A volume incarnation.
71
+ *
72
+ * @category models
73
+ * @since 0.6.0
74
+ */
75
+ export type VolumeIncarnation = typeof VolumeIncarnation.Type;
76
+ /**
77
+ * Schema for a reference key: the serialisable name of one object in one
78
+ * volume, for adapters that must name an object outside the process, such as
79
+ * an NFS filehandle.
80
+ *
81
+ * **Details**
82
+ *
83
+ * `identity` is the volume's identity and `epoch` the inode-number namespace
84
+ * the object was numbered in, both as 16 bytes encoded as base64; `ino` is
85
+ * the object's inode number, encoded as a decimal string; `tag` is 16 bytes of
86
+ * HMAC-SHA-256 over the identity, epoch and inode number under a secret only
87
+ * the volume holds, encoded as base64. Inode numbers are small and sequential,
88
+ * so the tag is what keeps a holder of one key from naming a neighbouring
89
+ * object: a key with another inode number or an altered tag fails
90
+ * `InvalidReference`. A volume mints a new epoch and secret whenever its inode
91
+ * numbers start over: a new volume, a snapshot or fixture restore, and an
92
+ * overlay. A live volume keeps both across a reopen, so its keys outlive the
93
+ * process. Turning a key into bytes of a fixed layout stays the adapter's job.
94
+ *
95
+ * @category schemas
96
+ * @since 0.6.0
97
+ */
98
+ export declare const ReferenceKey: Schema.Struct<{
99
+ readonly identity: Schema.Uint8ArrayFromBase64;
100
+ readonly epoch: Schema.Uint8ArrayFromBase64;
101
+ readonly ino: Schema.BigIntFromString;
102
+ readonly tag: Schema.Uint8ArrayFromBase64;
103
+ }>;
104
+ /**
105
+ * The serialisable name of one object in one volume.
106
+ *
107
+ * @category models
108
+ * @since 0.6.0
109
+ */
110
+ export type ReferenceKey = typeof ReferenceKey.Type;
111
+ /**
112
+ * Schema for volume construction options.
113
+ *
114
+ * @category schemas
115
+ * @since 0.6.0
116
+ */
117
+ export declare const VolumeOptions: Schema.Struct<{
118
+ readonly identity: Schema.optionalKey<Schema.brand<Schema.String, "@effect-vfs/core/VolumeIdentity">>;
119
+ readonly maxEntries: Schema.optionalKey<Schema.Natural>;
120
+ readonly maxPendingOperations: Schema.optionalKey<Schema.Int>;
121
+ readonly maxWatchEvents: Schema.optionalKey<Schema.Int>;
122
+ readonly maxBytes: Schema.optionalKey<Schema.ByteSize>;
123
+ readonly maxFileBytes: Schema.optionalKey<Schema.ByteSize>;
124
+ readonly maxPathBytes: Schema.optionalKey<Schema.ByteSize>;
125
+ }>;
126
+ /**
127
+ * Volume construction options.
128
+ *
129
+ * @category models
130
+ * @since 0.6.0
131
+ */
132
+ export type VolumeOptions = typeof VolumeOptions.Type;
133
+ /**
134
+ * Schema for the kinds of filesystem entry an overlay summary reports.
135
+ *
136
+ * @category schemas
137
+ * @since 0.6.0
138
+ */
139
+ export declare const OverlayNodeKind: Schema.Literals<readonly ["directory", "file", "symlink"]>;
140
+ /**
141
+ * A kind of filesystem entry in an overlay summary.
142
+ *
143
+ * @category models
144
+ * @since 0.6.0
145
+ */
146
+ export type OverlayNodeKind = typeof OverlayNodeKind.Type;
147
+ /**
148
+ * Schema for one way an overlay entry differs from its base.
149
+ *
150
+ * @category schemas
151
+ * @since 0.6.0
152
+ */
153
+ export declare const OverlayDifference: Schema.Literals<readonly ["content", "mode", "uid", "gid", "atimeNs", "mtimeNs", "ctimeNs", "birthtimeNs"]>;
154
+ /**
155
+ * One way an overlay entry differs from its base.
156
+ *
157
+ * @category models
158
+ * @since 0.6.0
159
+ */
160
+ export type OverlayDifference = typeof OverlayDifference.Type;
161
+ /**
162
+ * Schema for one summarised change between an overlay and its base.
163
+ *
164
+ * @category schemas
165
+ * @since 0.6.0
166
+ */
167
+ export declare const OverlayChange: Schema.Union<readonly [Schema.TaggedStruct<"Added", {
168
+ readonly path: Schema.declare<BytePath, BytePath>;
169
+ readonly kind: Schema.Literals<readonly ["directory", "file", "symlink"]>;
170
+ }>, Schema.TaggedStruct<"Removed", {
171
+ readonly path: Schema.declare<BytePath, BytePath>;
172
+ readonly kind: Schema.Literals<readonly ["directory", "file", "symlink"]>;
173
+ }>, Schema.TaggedStruct<"Replaced", {
174
+ readonly path: Schema.declare<BytePath, BytePath>;
175
+ readonly beforeKind: Schema.Literals<readonly ["directory", "file", "symlink"]>;
176
+ readonly afterKind: Schema.Literals<readonly ["directory", "file", "symlink"]>;
177
+ readonly differences: Schema.$Array<Schema.Literals<readonly ["content", "mode", "uid", "gid", "atimeNs", "mtimeNs", "ctimeNs", "birthtimeNs"]>>;
178
+ }>, Schema.TaggedStruct<"Renamed", {
179
+ readonly from: Schema.declare<BytePath, BytePath>;
180
+ readonly to: Schema.declare<BytePath, BytePath>;
181
+ readonly kind: Schema.Literals<readonly ["directory", "file", "symlink"]>;
182
+ readonly differences: Schema.$Array<Schema.Literals<readonly ["content", "mode", "uid", "gid", "atimeNs", "mtimeNs", "ctimeNs", "birthtimeNs"]>>;
183
+ }>, Schema.TaggedStruct<"Updated", {
184
+ readonly path: Schema.declare<BytePath, BytePath>;
185
+ readonly kind: Schema.Literals<readonly ["directory", "file", "symlink"]>;
186
+ readonly differences: Schema.$Array<Schema.Literals<readonly ["content", "mode", "uid", "gid", "atimeNs", "mtimeNs", "ctimeNs", "birthtimeNs"]>>;
187
+ }>]>;
188
+ /**
189
+ * One summarised change between an overlay and its base.
190
+ *
191
+ * @category models
192
+ * @since 0.6.0
193
+ */
194
+ export type OverlayChange = typeof OverlayChange.Type;
195
+ /**
196
+ * Schema for the options of an overlay change summary.
197
+ *
198
+ * @category schemas
199
+ * @since 0.6.0
200
+ */
201
+ export declare const OverlayChangesOptions: Schema.Struct<{
202
+ readonly includeTimestamps: Schema.optionalKey<Schema.Boolean>;
203
+ }>;
204
+ /**
205
+ * Options of an overlay change summary.
206
+ *
207
+ * @category models
208
+ * @since 0.6.0
209
+ */
210
+ export type OverlayChangesOptions = typeof OverlayChangesOptions.Type;
211
+ //# sourceMappingURL=Volume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Volume.d.ts","sourceRoot":"","sources":["../src/Volume.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAIxC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,MAA8C,CAAA;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAA;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,+HAK3B,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAA;AAS3D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAG/D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,WAAY,gBAAgB,YAAY,gBAAgB,KAAG,OACnD,CAAA;AAE9C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,gEAA+D,CAAA;AAE1F;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,mEAAkE,CAAA;AAEhG;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAO7D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,YAAY;;;;;EAKvB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;EAsBxB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;AAErD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,4DAAoD,CAAA;AAEhF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,6GAS5B,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAM7D;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;IAgBxB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;AAErD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;EAEhC,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAC,IAAI,CAAA"}
package/dist/Volume.js ADDED
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Volume identity brands and schemas: durability, identity tokens, reference
3
+ * keys, construction options, and the change summaries an overlay volume
4
+ * reports.
5
+ *
6
+ * @since 0.6.0
7
+ */
8
+ import * as ByteSize from "effect/ByteSize";
9
+ import * as Order from "effect/Order";
10
+ import * as Schema from "effect/Schema";
11
+ import { BytePath } from "./BytePath.js";
12
+ import { Hex128 } from "./internal/hex128.js";
13
+ import { MAX_FILE_BYTES, MAX_INO, ROOT_INO } from "./internal/volumeState.js";
14
+ /**
15
+ * Brand key that marks a volume.
16
+ *
17
+ * @category type IDs
18
+ * @since 0.6.0
19
+ */
20
+ export const VolumeId = Symbol.for("@effect-vfs/core/Volume");
21
+ /**
22
+ * Schema for the failure boundary a volume's committed mutations survive.
23
+ *
24
+ * @category schemas
25
+ * @since 0.6.0
26
+ */
27
+ export const VolumeDurability = Schema.Literals([
28
+ "memory-only",
29
+ "survives-process-crash",
30
+ "survives-operating-system-crash",
31
+ "survives-power-loss"
32
+ ]);
33
+ const durabilityRank = {
34
+ "memory-only": 0,
35
+ "survives-process-crash": 1,
36
+ "survives-operating-system-crash": 2,
37
+ "survives-power-loss": 3
38
+ };
39
+ /**
40
+ * Weakest-to-strongest ordering for volume durability guarantees.
41
+ *
42
+ * @category ordering
43
+ * @since 0.6.0
44
+ */
45
+ export const VolumeDurabilityOrder = Order.mapInput(Order.Number, (durability) => durabilityRank[durability]);
46
+ /**
47
+ * Returns whether `actual` survives at least the failure boundary required by `required`.
48
+ *
49
+ * @category predicates
50
+ * @since 0.6.0
51
+ */
52
+ export const isVolumeDurabilityAtLeast = (actual, required) => VolumeDurabilityOrder(actual, required) >= 0;
53
+ /**
54
+ * Schema for a volume identity: 128 bits as lowercase hexadecimal, stable
55
+ * across restarts of a durable volume.
56
+ *
57
+ * @category schemas
58
+ * @since 0.6.0
59
+ */
60
+ export const VolumeIdentity = Hex128.pipe(Schema.brand("@effect-vfs/core/VolumeIdentity"));
61
+ /**
62
+ * Schema for a volume incarnation: 128 bits as lowercase hexadecimal, minted
63
+ * on every construction.
64
+ *
65
+ * @category schemas
66
+ * @since 0.6.0
67
+ */
68
+ export const VolumeIncarnation = Hex128.pipe(Schema.brand("@effect-vfs/core/VolumeIncarnation"));
69
+ // 128 bits as bytes, carried as base64 like every other byte field on a wire.
70
+ const KeyBytes = Schema.Uint8ArrayFromBase64.check(Schema.makeFilter((bytes) => bytes.length === 16 ? undefined : "must hold exactly 16 bytes"));
71
+ /**
72
+ * Schema for a reference key: the serialisable name of one object in one
73
+ * volume, for adapters that must name an object outside the process, such as
74
+ * an NFS filehandle.
75
+ *
76
+ * **Details**
77
+ *
78
+ * `identity` is the volume's identity and `epoch` the inode-number namespace
79
+ * the object was numbered in, both as 16 bytes encoded as base64; `ino` is
80
+ * the object's inode number, encoded as a decimal string; `tag` is 16 bytes of
81
+ * HMAC-SHA-256 over the identity, epoch and inode number under a secret only
82
+ * the volume holds, encoded as base64. Inode numbers are small and sequential,
83
+ * so the tag is what keeps a holder of one key from naming a neighbouring
84
+ * object: a key with another inode number or an altered tag fails
85
+ * `InvalidReference`. A volume mints a new epoch and secret whenever its inode
86
+ * numbers start over: a new volume, a snapshot or fixture restore, and an
87
+ * overlay. A live volume keeps both across a reopen, so its keys outlive the
88
+ * process. Turning a key into bytes of a fixed layout stays the adapter's job.
89
+ *
90
+ * @category schemas
91
+ * @since 0.6.0
92
+ */
93
+ export const ReferenceKey = Schema.Struct({
94
+ identity: KeyBytes,
95
+ epoch: KeyBytes,
96
+ ino: Schema.BigIntFromString.check(Schema.isBetweenBigInt({ minimum: BigInt(ROOT_INO), maximum: BigInt(MAX_INO) })),
97
+ tag: KeyBytes
98
+ });
99
+ /**
100
+ * Schema for volume construction options.
101
+ *
102
+ * @category schemas
103
+ * @since 0.6.0
104
+ */
105
+ export const VolumeOptions = Schema.Struct({
106
+ identity: Schema.optionalKey(VolumeIdentity),
107
+ maxEntries: Schema.optionalKey(Schema.Natural),
108
+ maxPendingOperations: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(1))),
109
+ maxWatchEvents: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThanOrEqualTo(2))),
110
+ maxBytes: Schema.optionalKey(Schema.ByteSize),
111
+ maxFileBytes: Schema.optionalKey(Schema.ByteSize.check(Schema.makeFilter((size) => ByteSize.isLessThanOrEqualTo(size, ByteSize.bytes(MAX_FILE_BYTES))
112
+ ? undefined
113
+ : `must be at most ${MAX_FILE_BYTES} bytes`))),
114
+ maxPathBytes: Schema.optionalKey(Schema.ByteSize.check(Schema.makeFilter((size) => ByteSize.isGreaterThanOrEqualTo(size, ByteSize.bytes(1)) ? undefined : "must be at least 1 byte")))
115
+ });
116
+ /**
117
+ * Schema for the kinds of filesystem entry an overlay summary reports.
118
+ *
119
+ * @category schemas
120
+ * @since 0.6.0
121
+ */
122
+ export const OverlayNodeKind = Schema.Literals(["directory", "file", "symlink"]);
123
+ /**
124
+ * Schema for one way an overlay entry differs from its base.
125
+ *
126
+ * @category schemas
127
+ * @since 0.6.0
128
+ */
129
+ export const OverlayDifference = Schema.Literals([
130
+ "content",
131
+ "mode",
132
+ "uid",
133
+ "gid",
134
+ "atimeNs",
135
+ "mtimeNs",
136
+ "ctimeNs",
137
+ "birthtimeNs"
138
+ ]);
139
+ const OverlayDifferences = Schema.Array(OverlayDifference);
140
+ const NonEmptyOverlayDifferences = OverlayDifferences.check(Schema.isMinLength(1));
141
+ /**
142
+ * Schema for one summarised change between an overlay and its base.
143
+ *
144
+ * @category schemas
145
+ * @since 0.6.0
146
+ */
147
+ export const OverlayChange = Schema.Union([
148
+ Schema.TaggedStruct("Added", { path: BytePath, kind: OverlayNodeKind }),
149
+ Schema.TaggedStruct("Removed", { path: BytePath, kind: OverlayNodeKind }),
150
+ Schema.TaggedStruct("Replaced", {
151
+ path: BytePath,
152
+ beforeKind: OverlayNodeKind,
153
+ afterKind: OverlayNodeKind,
154
+ differences: OverlayDifferences
155
+ }),
156
+ Schema.TaggedStruct("Renamed", {
157
+ from: BytePath,
158
+ to: BytePath,
159
+ kind: OverlayNodeKind,
160
+ differences: OverlayDifferences
161
+ }),
162
+ Schema.TaggedStruct("Updated", { path: BytePath, kind: OverlayNodeKind, differences: NonEmptyOverlayDifferences })
163
+ ]);
164
+ /**
165
+ * Schema for the options of an overlay change summary.
166
+ *
167
+ * @category schemas
168
+ * @since 0.6.0
169
+ */
170
+ export const OverlayChangesOptions = Schema.Struct({
171
+ includeTimestamps: Schema.optionalKey(Schema.Boolean)
172
+ });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Change events published by a volume's watch stream, and the options that
3
+ * narrow a watch to one object's subtree.
4
+ *
5
+ * @since 0.6.0
6
+ */
7
+ import * as Schema from "effect/Schema";
8
+ import { BytePath } from "./BytePath.js";
9
+ import type { ObjectReference } from "./VirtualFileSystem.js";
10
+ /**
11
+ * Schema for one committed change. `Rescan` means the subscriber lost events
12
+ * and must rescan what it watches, whose path it names; events are never
13
+ * replayed.
14
+ *
15
+ * @category schemas
16
+ * @since 0.6.0
17
+ */
18
+ export declare const Change: Schema.TaggedUnion<{
19
+ readonly Create: Schema.TaggedStruct<"Create", {
20
+ readonly path: Schema.declare<BytePath, BytePath>;
21
+ }>;
22
+ readonly Remove: Schema.TaggedStruct<"Remove", {
23
+ readonly path: Schema.declare<BytePath, BytePath>;
24
+ }>;
25
+ readonly Rescan: Schema.TaggedStruct<"Rescan", {
26
+ readonly path: Schema.declare<BytePath, BytePath>;
27
+ }>;
28
+ readonly Update: Schema.TaggedStruct<"Update", {
29
+ readonly path: Schema.declare<BytePath, BytePath>;
30
+ }>;
31
+ }>;
32
+ /**
33
+ * One committed change observed through a watch subscription.
34
+ *
35
+ * @category models
36
+ * @since 0.6.0
37
+ */
38
+ export type Change = typeof Change.Type;
39
+ /**
40
+ * Schema for the options of a watch. `scope` narrows the watch to one object
41
+ * and, when `recursive` is not `false`, everything below it; without a scope
42
+ * the watch covers the volume.
43
+ *
44
+ * **Details**
45
+ *
46
+ * The scope is an object, not a path: a watch on a directory keeps receiving
47
+ * its changes, at their current paths, after the directory or one of its
48
+ * ancestors is renamed. Each change is tested against the scope on its own,
49
+ * so a move out of the scope arrives as `Remove` and a move into it as
50
+ * `Create`. With `recursive: false` only the object itself and its direct
51
+ * children are reported. When the object's last name is removed the watch
52
+ * reports `Remove` for it and ends.
53
+ *
54
+ * @category schemas
55
+ * @since 0.6.0
56
+ */
57
+ export declare const WatchOptions: Schema.Struct<{
58
+ readonly scope: Schema.optionalKey<Schema.declare<ObjectReference, ObjectReference>>;
59
+ readonly recursive: Schema.optionalKey<Schema.Boolean>;
60
+ }>;
61
+ /**
62
+ * Options of a watch.
63
+ *
64
+ * @category models
65
+ * @since 0.6.0
66
+ */
67
+ export type WatchOptions = typeof WatchOptions.Type;
68
+ //# sourceMappingURL=Watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Watch.d.ts","sourceRoot":"","sources":["../src/Watch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;EAKjB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY;;;EAIvB,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA"}
package/dist/Watch.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Change events published by a volume's watch stream, and the options that
3
+ * narrow a watch to one object's subtree.
4
+ *
5
+ * @since 0.6.0
6
+ */
7
+ import * as Schema from "effect/Schema";
8
+ import { BytePath } from "./BytePath.js";
9
+ import { ObjectReferenceSchema } from "./Caller.js";
10
+ /**
11
+ * Schema for one committed change. `Rescan` means the subscriber lost events
12
+ * and must rescan what it watches, whose path it names; events are never
13
+ * replayed.
14
+ *
15
+ * @category schemas
16
+ * @since 0.6.0
17
+ */
18
+ export const Change = Schema.TaggedUnion({
19
+ Create: { path: BytePath },
20
+ Update: { path: BytePath },
21
+ Remove: { path: BytePath },
22
+ Rescan: { path: BytePath }
23
+ });
24
+ /**
25
+ * Schema for the options of a watch. `scope` narrows the watch to one object
26
+ * and, when `recursive` is not `false`, everything below it; without a scope
27
+ * the watch covers the volume.
28
+ *
29
+ * **Details**
30
+ *
31
+ * The scope is an object, not a path: a watch on a directory keeps receiving
32
+ * its changes, at their current paths, after the directory or one of its
33
+ * ancestors is renamed. Each change is tested against the scope on its own,
34
+ * so a move out of the scope arrives as `Remove` and a move into it as
35
+ * `Create`. With `recursive: false` only the object itself and its direct
36
+ * children are reported. When the object's last name is removed the watch
37
+ * reports `Remove` for it and ends.
38
+ *
39
+ * @category schemas
40
+ * @since 0.6.0
41
+ */
42
+ export const WatchOptions = Schema.Struct({
43
+ // Naming the type keeps `ObjectReference` in the rendered `WatchOptions` type.
44
+ scope: Schema.optionalKey(ObjectReferenceSchema),
45
+ recursive: Schema.optionalKey(Schema.Boolean)
46
+ });
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export * as VirtualFileSystem from "./VirtualFileSystem.js";
16
16
  * @category re-exports
17
17
  * @since 0.4.0
18
18
  */
19
- export * as VirtualFileSystemError from "./VirtualFileSystemError.js";
19
+ export * as VfsError from "./VfsError.js";
20
20
  /**
21
21
  * Live volume image boundary for storage adapters.
22
22
  *
@@ -24,4 +24,59 @@ export * as VirtualFileSystemError from "./VirtualFileSystemError.js";
24
24
  * @since 0.4.0
25
25
  */
26
26
  export * as LiveVolume from "./LiveVolume.js";
27
+ /**
28
+ * @since 0.6.0
29
+ * @category re-exports
30
+ */
31
+ export * as BytePath from "./BytePath.js";
32
+ /**
33
+ * @since 0.6.0
34
+ * @category re-exports
35
+ */
36
+ export * as Caller from "./Caller.js";
37
+ /**
38
+ * @since 0.6.0
39
+ * @category re-exports
40
+ */
41
+ export * as FileHandle from "./FileHandle.js";
42
+ /**
43
+ * @since 0.6.0
44
+ * @category re-exports
45
+ */
46
+ export * as Fixture from "./Fixture.js";
47
+ /**
48
+ * @since 0.6.0
49
+ * @category re-exports
50
+ */
51
+ export * as Metadata from "./Metadata.js";
52
+ /**
53
+ * @since 0.6.0
54
+ * @category re-exports
55
+ */
56
+ export * as Snapshot from "./Snapshot.js";
57
+ /**
58
+ * @since 0.6.0
59
+ * @category re-exports
60
+ */
61
+ export * as SnapshotDelta from "./SnapshotDelta.js";
62
+ /**
63
+ * @since 0.6.0
64
+ * @category re-exports
65
+ */
66
+ export * as Target from "./Target.js";
67
+ /**
68
+ * @since 0.6.0
69
+ * @category re-exports
70
+ */
71
+ export * as Testing from "./Testing.js";
72
+ /**
73
+ * @since 0.6.0
74
+ * @category re-exports
75
+ */
76
+ export * as Volume from "./Volume.js";
77
+ /**
78
+ * @since 0.6.0
79
+ * @category re-exports
80
+ */
81
+ export * as Watch from "./Watch.js";
27
82
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAE3D;;;;;GAKG;AACH,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAA;AAErE;;;;;GAKG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAE3D;;;;;GAKG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;;;GAKG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;GAGG;AACH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ export * as VirtualFileSystem from "./VirtualFileSystem.js";
16
16
  * @category re-exports
17
17
  * @since 0.4.0
18
18
  */
19
- export * as VirtualFileSystemError from "./VirtualFileSystemError.js";
19
+ export * as VfsError from "./VfsError.js";
20
20
  /**
21
21
  * Live volume image boundary for storage adapters.
22
22
  *
@@ -24,3 +24,58 @@ export * as VirtualFileSystemError from "./VirtualFileSystemError.js";
24
24
  * @since 0.4.0
25
25
  */
26
26
  export * as LiveVolume from "./LiveVolume.js";
27
+ /**
28
+ * @since 0.6.0
29
+ * @category re-exports
30
+ */
31
+ export * as BytePath from "./BytePath.js";
32
+ /**
33
+ * @since 0.6.0
34
+ * @category re-exports
35
+ */
36
+ export * as Caller from "./Caller.js";
37
+ /**
38
+ * @since 0.6.0
39
+ * @category re-exports
40
+ */
41
+ export * as FileHandle from "./FileHandle.js";
42
+ /**
43
+ * @since 0.6.0
44
+ * @category re-exports
45
+ */
46
+ export * as Fixture from "./Fixture.js";
47
+ /**
48
+ * @since 0.6.0
49
+ * @category re-exports
50
+ */
51
+ export * as Metadata from "./Metadata.js";
52
+ /**
53
+ * @since 0.6.0
54
+ * @category re-exports
55
+ */
56
+ export * as Snapshot from "./Snapshot.js";
57
+ /**
58
+ * @since 0.6.0
59
+ * @category re-exports
60
+ */
61
+ export * as SnapshotDelta from "./SnapshotDelta.js";
62
+ /**
63
+ * @since 0.6.0
64
+ * @category re-exports
65
+ */
66
+ export * as Target from "./Target.js";
67
+ /**
68
+ * @since 0.6.0
69
+ * @category re-exports
70
+ */
71
+ export * as Testing from "./Testing.js";
72
+ /**
73
+ * @since 0.6.0
74
+ * @category re-exports
75
+ */
76
+ export * as Volume from "./Volume.js";
77
+ /**
78
+ * @since 0.6.0
79
+ * @category re-exports
80
+ */
81
+ export * as Watch from "./Watch.js";