@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/internal/image.js
CHANGED
|
@@ -1,42 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
* Snapshot validation and serialization used by `VirtualFileSystem`.
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
1
|
+
// Snapshot validation and serialization used by VirtualFileSystem.
|
|
6
2
|
import * as ByteSize from "effect/ByteSize";
|
|
7
3
|
import * as Effect from "effect/Effect";
|
|
8
|
-
import * as
|
|
4
|
+
import * as Match from "effect/Match";
|
|
9
5
|
import * as Result from "effect/Result";
|
|
10
6
|
import * as Schema from "effect/Schema";
|
|
11
7
|
import { DecodeLimits, ImageError, SnapshotTypeId } from "../Snapshot.js";
|
|
12
|
-
import
|
|
13
|
-
|
|
8
|
+
import { CanonicalBase64 } from "./canonicalBase64.js";
|
|
9
|
+
import { StoredMetadata, WireStoredMetadata } from "./metadata.js";
|
|
14
10
|
class SnapshotImpl {
|
|
15
11
|
[SnapshotTypeId] = SnapshotTypeId;
|
|
16
12
|
}
|
|
17
|
-
const integer = Schema.String.check(Schema.isPattern(/^(?:0|-?[1-9][0-9]{0,127})(?![\s\S])/));
|
|
18
13
|
/** @internal */
|
|
19
|
-
export
|
|
20
|
-
uid: natural,
|
|
21
|
-
gid: natural,
|
|
22
|
-
mode: natural.check(Schema.isLessThanOrEqualTo(0o7777)),
|
|
23
|
-
atimeNs: integer,
|
|
24
|
-
mtimeNs: integer,
|
|
25
|
-
ctimeNs: integer,
|
|
26
|
-
birthtimeNs: integer
|
|
27
|
-
});
|
|
14
|
+
export { StoredMetadata };
|
|
28
15
|
const id = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(128));
|
|
29
16
|
/** @internal */
|
|
30
|
-
export const Record = Schema.
|
|
31
|
-
|
|
17
|
+
export const Record = Schema.TaggedUnion({
|
|
18
|
+
directory: {
|
|
32
19
|
id,
|
|
33
|
-
kind: Schema.Literal("directory"),
|
|
34
20
|
metadata: StoredMetadata,
|
|
35
|
-
entries: Schema.Array(Schema.Struct({ name:
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
entries: Schema.Array(Schema.Struct({ name: CanonicalBase64.Encoded, target: id }))
|
|
22
|
+
},
|
|
23
|
+
file: { id, metadata: StoredMetadata, data: CanonicalBase64.Encoded },
|
|
24
|
+
symlink: { id, metadata: StoredMetadata, target: CanonicalBase64.Encoded }
|
|
25
|
+
});
|
|
40
26
|
/** @internal */
|
|
41
27
|
export const Document = Schema.Struct({
|
|
42
28
|
format: Schema.Literal("effect-vfs"),
|
|
@@ -44,97 +30,111 @@ export const Document = Schema.Struct({
|
|
|
44
30
|
root: id,
|
|
45
31
|
records: Schema.Array(Record)
|
|
46
32
|
});
|
|
33
|
+
const WireRecord = Schema.TaggedUnion({
|
|
34
|
+
directory: {
|
|
35
|
+
id,
|
|
36
|
+
metadata: WireStoredMetadata,
|
|
37
|
+
entries: Schema.Array(Schema.Struct({ name: Schema.String, target: id }))
|
|
38
|
+
},
|
|
39
|
+
file: { id, metadata: WireStoredMetadata, data: Schema.String },
|
|
40
|
+
symlink: { id, metadata: WireStoredMetadata, target: Schema.String }
|
|
41
|
+
});
|
|
42
|
+
const WireDocument = Schema.Struct({
|
|
43
|
+
format: Schema.Literal("effect-vfs"),
|
|
44
|
+
version: Schema.Literal(1),
|
|
45
|
+
root: id,
|
|
46
|
+
records: Schema.Array(WireRecord)
|
|
47
|
+
});
|
|
48
|
+
const VersionProbe = Schema.Struct({
|
|
49
|
+
format: Schema.Literal("effect-vfs"),
|
|
50
|
+
version: Schema.Unknown
|
|
51
|
+
});
|
|
47
52
|
const snapshots = new WeakMap();
|
|
48
53
|
/** @internal */
|
|
49
|
-
export const decodedLength = CanonicalBase64.decodedLength;
|
|
50
|
-
/** @internal */
|
|
51
|
-
export const base64 = (input) => {
|
|
52
|
-
// Effect's encoder concatenates individual characters. Join bounded chunks so snapshots
|
|
53
|
-
// retain flat strings instead of those intermediate string chains. A multiple of three
|
|
54
|
-
// keeps padding in the final chunk only, preserving canonical base64.
|
|
55
|
-
const chunkBytes = 12_288;
|
|
56
|
-
const chunks = [];
|
|
57
|
-
for (let offset = 0; offset < input.length; offset += chunkBytes) {
|
|
58
|
-
chunks.push(Encoding.encodeBase64(input.subarray(offset, offset + chunkBytes)));
|
|
59
|
-
}
|
|
60
|
-
return chunks.join("");
|
|
61
|
-
};
|
|
62
|
-
const error = (code, field) => new ImageError({ code, ...(field === undefined ? {} : { field }) });
|
|
63
|
-
/** @internal */
|
|
64
|
-
export const bytes = (value) => {
|
|
65
|
-
return CanonicalBase64.decodeTrusted(value);
|
|
66
|
-
};
|
|
67
|
-
/** @internal */
|
|
68
54
|
export const inspect = (snapshot) => Effect.suspend(() => {
|
|
69
55
|
const document = snapshots.get(snapshot);
|
|
70
|
-
return document === undefined
|
|
56
|
+
return document === undefined
|
|
57
|
+
? new ImageError({ code: "InvalidStructure", field: "snapshot" })
|
|
58
|
+
: Effect.succeed(document);
|
|
71
59
|
});
|
|
72
60
|
/** @internal */
|
|
73
|
-
export const capture = Effect.fnUntraced(function* (input, limits) {
|
|
74
|
-
const
|
|
75
|
-
if (Result.isFailure(
|
|
76
|
-
return yield*
|
|
77
|
-
|
|
61
|
+
export const capture = Effect.fnUntraced(function* (input, limits, trusted = false) {
|
|
62
|
+
const wire = trusted ? undefined : Schema.decodeUnknownResult(WireDocument, { onExcessProperty: "error" })(input);
|
|
63
|
+
if (wire !== undefined && Result.isFailure(wire)) {
|
|
64
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "document" });
|
|
65
|
+
}
|
|
66
|
+
const decoded = trusted ? undefined : Schema.decodeUnknownResult(Document, { onExcessProperty: "error" })(input);
|
|
67
|
+
if (decoded !== undefined && Result.isFailure(decoded)) {
|
|
68
|
+
return yield* new ImageError({ code: "InvalidEncoding", field: "document" });
|
|
69
|
+
}
|
|
70
|
+
// SAFETY: a trusted caller passes a Document it built; an untrusted one has just been decoded.
|
|
71
|
+
const document = decoded === undefined ? input : decoded.success;
|
|
78
72
|
const records = new Map();
|
|
79
73
|
let entries = 0;
|
|
80
74
|
let payload = ByteSize.zero;
|
|
81
75
|
if (limits !== undefined && document.records.length > limits.maxRecords) {
|
|
82
|
-
return yield*
|
|
76
|
+
return yield* new ImageError({ code: "LimitExceeded", field: "records" });
|
|
83
77
|
}
|
|
84
78
|
for (const record of document.records) {
|
|
85
79
|
if (records.has(record.id))
|
|
86
|
-
return yield*
|
|
80
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "id" });
|
|
87
81
|
records.set(record.id, record);
|
|
88
|
-
|
|
82
|
+
Match.value(record).pipe(Match.tag("directory", (record) => {
|
|
89
83
|
entries += record.entries.length;
|
|
84
|
+
}), Match.undefined);
|
|
90
85
|
}
|
|
91
|
-
if (limits !== undefined && entries > limits.maxEntries)
|
|
92
|
-
return yield*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
86
|
+
if (limits !== undefined && entries > limits.maxEntries) {
|
|
87
|
+
return yield* new ImageError({ code: "LimitExceeded", field: "entries" });
|
|
88
|
+
}
|
|
89
|
+
// Count every payload before allocating any decoded payload buffer. Trusted records carry
|
|
90
|
+
// base64 this module produced, so the scan only runs when a limit depends on the tally.
|
|
91
|
+
if (!trusted || limits !== undefined) {
|
|
92
|
+
for (const record of document.records) {
|
|
93
|
+
const values = Match.value(record).pipe(Match.tag("directory", (record) => record.entries.map((entry) => entry.name)), Match.tag("file", (record) => [record.data]), Match.tag("symlink", (record) => [record.target]), Match.exhaustive);
|
|
94
|
+
for (const value of values) {
|
|
95
|
+
if (!CanonicalBase64.is(value)) {
|
|
96
|
+
return yield* new ImageError({ code: "InvalidEncoding", field: record.id });
|
|
97
|
+
}
|
|
98
|
+
payload = ByteSize.sum(payload, ByteSize.bytes(CanonicalBase64.decodedLength(value)));
|
|
99
|
+
if (limits !== undefined && ByteSize.isGreaterThan(payload, limits.maxDecodedBytes)) {
|
|
100
|
+
return yield* new ImageError({ code: "LimitExceeded", field: "bytes" });
|
|
101
|
+
}
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
105
|
const root = records.get(document.root);
|
|
108
|
-
if (root
|
|
109
|
-
return yield*
|
|
106
|
+
if (root === undefined || !Record.guards.directory(root)) {
|
|
107
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "root" });
|
|
108
|
+
}
|
|
110
109
|
const parents = new Map();
|
|
111
110
|
for (const record of document.records) {
|
|
112
|
-
if (
|
|
111
|
+
if (Record.guards.directory(record)) {
|
|
113
112
|
const names = new Set();
|
|
114
113
|
for (const entry of record.entries) {
|
|
115
|
-
if (names.has(entry.name) || decodedLength(entry.name) < 1 ||
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
if (names.has(entry.name) || CanonicalBase64.decodedLength(entry.name) < 1 ||
|
|
115
|
+
CanonicalBase64.decodedLength(entry.name) > 255)
|
|
116
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "name" });
|
|
118
117
|
names.add(entry.name);
|
|
119
|
-
const name =
|
|
118
|
+
const name = yield* CanonicalBase64.decode(entry.name);
|
|
120
119
|
if (name.includes(0) || name.includes(47) || (name.length === 1 && name[0] === 46) ||
|
|
121
120
|
(name.length === 2 && name[0] === 46 && name[1] === 46))
|
|
122
|
-
return yield*
|
|
121
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "name" });
|
|
123
122
|
const target = records.get(entry.target);
|
|
124
123
|
if (target === undefined)
|
|
125
|
-
return yield*
|
|
124
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "target" });
|
|
126
125
|
parents.set(target.id, (parents.get(target.id) ?? 0) + 1);
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
|
-
else if (
|
|
130
|
-
return yield*
|
|
128
|
+
else if (Record.guards.symlink(record) && (yield* CanonicalBase64.decode(record.target)).includes(0)) {
|
|
129
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "symlink" });
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
if (parents.has(root.id))
|
|
134
|
-
return yield*
|
|
133
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "root" });
|
|
135
134
|
for (const record of document.records) {
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
const invalidParent = Match.value(record).pipe(Match.tag("directory", (record) => parents.get(record.id) !== 1), Match.tag("file", (record) => !parents.has(record.id)), Match.tag("symlink", (record) => !parents.has(record.id)), Match.exhaustive);
|
|
136
|
+
if (record !== root && invalidParent) {
|
|
137
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "parent" });
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
const visited = new Set();
|
|
@@ -145,39 +145,43 @@ export const capture = Effect.fnUntraced(function* (input, limits) {
|
|
|
145
145
|
continue;
|
|
146
146
|
visited.add(next);
|
|
147
147
|
const record = records.get(next);
|
|
148
|
-
if (record
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
if (record !== undefined) {
|
|
149
|
+
Match.value(record).pipe(Match.tag("directory", (record) => {
|
|
150
|
+
for (const entry of record.entries)
|
|
151
|
+
pending.push(entry.target);
|
|
152
|
+
}), Match.tag("file", () => undefined), Match.tag("symlink", () => undefined), Match.exhaustive);
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
if (visited.size !== records.size)
|
|
154
|
-
return yield*
|
|
156
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "reachability" });
|
|
155
157
|
const snapshot = Object.freeze(new SnapshotImpl());
|
|
156
158
|
snapshots.set(snapshot, document);
|
|
157
159
|
return snapshot;
|
|
158
160
|
});
|
|
159
161
|
/** @internal */
|
|
160
162
|
export const encodeSnapshot = Effect.fn("VirtualFileSystem.encodeSnapshot")(function* (snapshot) {
|
|
161
|
-
const text = yield* Schema.encodeEffect(Schema.fromJsonString(
|
|
163
|
+
const text = yield* Schema.encodeEffect(Schema.fromJsonString(Document))(yield* inspect(snapshot)).pipe(Effect.mapError(() => new ImageError({ code: "InvalidStructure", field: "text" })));
|
|
162
164
|
return new TextEncoder().encode(text);
|
|
163
165
|
});
|
|
164
166
|
/** @internal */
|
|
165
167
|
export const decodeSnapshot = Effect.fn("VirtualFileSystem.decodeSnapshot")(function* (input, limits) {
|
|
166
168
|
const checked = Schema.decodeResult(DecodeLimits, { onExcessProperty: "error" })(limits);
|
|
167
169
|
if (Result.isFailure(checked))
|
|
168
|
-
return yield*
|
|
169
|
-
if (!(input instanceof Uint8Array) || !(input.buffer instanceof ArrayBuffer))
|
|
170
|
-
return yield*
|
|
170
|
+
return yield* new ImageError({ code: "InvalidStructure", field: "limits" });
|
|
171
|
+
if (!(input instanceof Uint8Array) || !(input.buffer instanceof ArrayBuffer)) {
|
|
172
|
+
return yield* new ImageError({ code: "InvalidEncoding", field: "input" });
|
|
173
|
+
}
|
|
171
174
|
if (ByteSize.isGreaterThan(ByteSize.bytes(input.byteLength), checked.success.maxEncodedBytes)) {
|
|
172
|
-
return yield*
|
|
175
|
+
return yield* new ImageError({ code: "LimitExceeded", field: "encodedBytes" });
|
|
173
176
|
}
|
|
174
177
|
const text = yield* Effect.try({
|
|
175
178
|
try: () => new TextDecoder("utf-8", { fatal: true }).decode(new Uint8Array(input)),
|
|
176
|
-
catch: () =>
|
|
179
|
+
catch: () => new ImageError({ code: "InvalidEncoding", field: "text" })
|
|
177
180
|
});
|
|
178
|
-
const value = yield* Schema.decodeEffect(Schema.fromJsonString(Schema.Unknown))(text).pipe(Effect.mapError(() =>
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return yield*
|
|
181
|
+
const value = yield* Schema.decodeEffect(Schema.fromJsonString(Schema.Unknown))(text).pipe(Effect.mapError(() => new ImageError({ code: "InvalidEncoding", field: "text" })));
|
|
182
|
+
const version = Schema.decodeUnknownResult(VersionProbe)(value);
|
|
183
|
+
if (Result.isSuccess(version) && version.success.version !== 1) {
|
|
184
|
+
return yield* new ImageError({ code: "UnsupportedVersion", field: "version" });
|
|
185
|
+
}
|
|
182
186
|
return yield* capture(value, checked.success);
|
|
183
187
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const Timestamp: Schema.BigInt;
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare const TimestampFromString: Schema.decodeTo<Schema.BigInt, Schema.String, never, never>;
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare const WireStoredMetadata: Schema.Struct<{
|
|
8
|
+
readonly uid: Schema.Natural;
|
|
9
|
+
readonly gid: Schema.Natural;
|
|
10
|
+
readonly mode: Schema.Natural;
|
|
11
|
+
readonly atimeNs: Schema.String;
|
|
12
|
+
readonly mtimeNs: Schema.String;
|
|
13
|
+
readonly ctimeNs: Schema.String;
|
|
14
|
+
readonly birthtimeNs: Schema.String;
|
|
15
|
+
}>;
|
|
16
|
+
/** @internal */
|
|
17
|
+
export declare const StoredMetadata: Schema.Struct<{
|
|
18
|
+
readonly uid: Schema.Natural;
|
|
19
|
+
readonly gid: Schema.Natural;
|
|
20
|
+
readonly mode: Schema.Natural;
|
|
21
|
+
readonly atimeNs: Schema.decodeTo<Schema.BigInt, Schema.String, never, never>;
|
|
22
|
+
readonly mtimeNs: Schema.decodeTo<Schema.BigInt, Schema.String, never, never>;
|
|
23
|
+
readonly ctimeNs: Schema.decodeTo<Schema.BigInt, Schema.String, never, never>;
|
|
24
|
+
readonly birthtimeNs: Schema.decodeTo<Schema.BigInt, Schema.String, never, never>;
|
|
25
|
+
}>;
|
|
26
|
+
/** @internal */
|
|
27
|
+
export type StoredMetadata = typeof StoredMetadata.Type;
|
|
28
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/internal/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC,gBAAgB;AAChB,eAAO,MAAM,SAAS,eAGrB,CAAA;AAED,gBAAgB;AAChB,eAAO,MAAM,mBAAmB,6DAE0C,CAAA;AAE1E,gBAAgB;AAChB,eAAO,MAAM,kBAAkB;;;;;;;;EAQ7B,CAAA;AAEF,gBAAgB;AAChB,eAAO,MAAM,cAAc;;;;;;;;EAQzB,CAAA;AAEF,gBAAgB;AAChB,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import * as SchemaTransformation from "effect/SchemaTransformation";
|
|
3
|
+
const MAX_TIMESTAMP = 10n ** 128n - 1n;
|
|
4
|
+
/** @internal */
|
|
5
|
+
export const Timestamp = Schema.BigInt.check(Schema.isGreaterThanOrEqualToBigInt(-MAX_TIMESTAMP), Schema.isLessThanOrEqualToBigInt(MAX_TIMESTAMP));
|
|
6
|
+
/** @internal */
|
|
7
|
+
export const TimestampFromString = Schema.String
|
|
8
|
+
.check(Schema.isPattern(/^-?[0-9]{1,128}$/))
|
|
9
|
+
.pipe(Schema.decodeTo(Timestamp, SchemaTransformation.bigintFromString));
|
|
10
|
+
/** @internal */
|
|
11
|
+
export const WireStoredMetadata = Schema.Struct({
|
|
12
|
+
uid: Schema.Natural,
|
|
13
|
+
gid: Schema.Natural,
|
|
14
|
+
mode: Schema.Natural.check(Schema.isLessThanOrEqualTo(0o7777)),
|
|
15
|
+
atimeNs: Schema.String,
|
|
16
|
+
mtimeNs: Schema.String,
|
|
17
|
+
ctimeNs: Schema.String,
|
|
18
|
+
birthtimeNs: Schema.String
|
|
19
|
+
});
|
|
20
|
+
/** @internal */
|
|
21
|
+
export const StoredMetadata = Schema.Struct({
|
|
22
|
+
uid: Schema.Natural,
|
|
23
|
+
gid: Schema.Natural,
|
|
24
|
+
mode: Schema.Natural.check(Schema.isLessThanOrEqualTo(0o7777)),
|
|
25
|
+
atimeNs: TimestampFromString,
|
|
26
|
+
mtimeNs: TimestampFromString,
|
|
27
|
+
ctimeNs: TimestampFromString,
|
|
28
|
+
birthtimeNs: TimestampFromString
|
|
29
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotDelta.d.ts","sourceRoot":"","sources":["../../src/internal/snapshotDelta.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"snapshotDelta.d.ts","sourceRoot":"","sources":["../../src/internal/snapshotDelta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAOvC,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAGL,KAAK,aAAa,EAClB,kBAAkB,EAInB,MAAM,qBAAqB,CAAA;AAmuB5B,gBAAgB;AAChB,eAAO,MAAM,aAAa;;;;;;;;;;;4GAgDzB,CAAA;AAyBD,gBAAgB;AAChB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;oGAoBhC,CAAA;AAED,gBAAgB;AAChB,eAAO,MAAM,mBAAmB;;;;;;;;;;;+DAe9B,CAAA;AAEF,gBAAgB;AAChB,eAAO,MAAM,mBAAmB;;;;;;;;;;;qDAkC9B,CAAA;AAEF,gBAAgB;AAChB,eAAO,MAAM,kBAAkB;;;;;;;;;;;4HAI9B,CAAA"}
|