@effect-dynamodb/schema 1.39.0 → 1.41.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.
- package/dist/Aggregate.d.ts +11 -4
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js +12 -2
- package/dist/Aggregate.js.map +1 -1
- package/dist/DynamoModel.d.ts +48 -7
- package/dist/DynamoModel.d.ts.map +1 -1
- package/dist/DynamoModel.js +34 -16
- package/dist/DynamoModel.js.map +1 -1
- package/dist/DynamoSchema.d.ts +25 -0
- package/dist/DynamoSchema.d.ts.map +1 -1
- package/dist/DynamoSchema.js.map +1 -1
- package/dist/Entity.d.ts +66 -11
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +261 -34
- package/dist/Entity.js.map +1 -1
- package/dist/Errors.d.ts +61 -4
- package/dist/Errors.d.ts.map +1 -1
- package/dist/Errors.js +83 -6
- package/dist/Errors.js.map +1 -1
- package/dist/KeyComposer.d.ts +196 -5
- package/dist/KeyComposer.d.ts.map +1 -1
- package/dist/KeyComposer.js +490 -54
- package/dist/KeyComposer.js.map +1 -1
- package/dist/VectorIndex.d.ts.map +1 -1
- package/dist/VectorIndex.js +5 -4
- package/dist/VectorIndex.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/AggregateEdges.d.ts +3 -3
- package/dist/internal/AggregateSchemas.d.ts +306 -14
- package/dist/internal/AggregateSchemas.d.ts.map +1 -1
- package/dist/internal/AggregateSchemas.js +733 -54
- package/dist/internal/AggregateSchemas.js.map +1 -1
- package/dist/internal/AggregateTypes.d.ts +396 -36
- package/dist/internal/AggregateTypes.d.ts.map +1 -1
- package/dist/internal/CompositeCodec.d.ts +298 -8
- package/dist/internal/CompositeCodec.d.ts.map +1 -1
- package/dist/internal/CompositeCodec.js +940 -34
- package/dist/internal/CompositeCodec.js.map +1 -1
- package/dist/internal/EffectInstances.d.ts +87 -0
- package/dist/internal/EffectInstances.d.ts.map +1 -0
- package/dist/internal/EffectInstances.js +662 -0
- package/dist/internal/EffectInstances.js.map +1 -0
- package/dist/internal/EntityPacked.d.ts.map +1 -1
- package/dist/internal/EntityPacked.js +5 -4
- package/dist/internal/EntityPacked.js.map +1 -1
- package/dist/internal/EntitySchemas.d.ts +239 -30
- package/dist/internal/EntitySchemas.d.ts.map +1 -1
- package/dist/internal/EntitySchemas.js +1600 -197
- package/dist/internal/EntitySchemas.js.map +1 -1
- package/dist/internal/EntityTypes.d.ts +114 -25
- package/dist/internal/EntityTypes.d.ts.map +1 -1
- package/dist/internal/FailingAsBefore.d.ts +25 -0
- package/dist/internal/FailingAsBefore.d.ts.map +1 -0
- package/dist/internal/FailingAsBefore.js +42 -0
- package/dist/internal/FailingAsBefore.js.map +1 -0
- package/dist/internal/InstanceReads.d.ts +40 -0
- package/dist/internal/InstanceReads.d.ts.map +1 -0
- package/dist/internal/InstanceReads.js +183 -0
- package/dist/internal/InstanceReads.js.map +1 -0
- package/dist/internal/KeyReadings.d.ts +30 -0
- package/dist/internal/KeyReadings.d.ts.map +1 -0
- package/dist/internal/KeyReadings.js +99 -0
- package/dist/internal/KeyReadings.js.map +1 -0
- package/dist/internal/KeyText136.d.ts +4 -2
- package/dist/internal/KeyText136.d.ts.map +1 -1
- package/dist/internal/KeyText136.js +46 -13
- package/dist/internal/KeyText136.js.map +1 -1
- package/dist/internal/LostValues.d.ts +50 -0
- package/dist/internal/LostValues.d.ts.map +1 -0
- package/dist/internal/LostValues.js +465 -0
- package/dist/internal/LostValues.js.map +1 -0
- package/dist/internal/NumericKey.d.ts +21 -2
- package/dist/internal/NumericKey.d.ts.map +1 -1
- package/dist/internal/NumericKey.js +19 -1
- package/dist/internal/NumericKey.js.map +1 -1
- package/dist/internal/ObjectKeyText.d.ts +29 -0
- package/dist/internal/ObjectKeyText.d.ts.map +1 -0
- package/dist/internal/ObjectKeyText.js +50 -0
- package/dist/internal/ObjectKeyText.js.map +1 -0
- package/dist/internal/OwnNames.d.ts +205 -0
- package/dist/internal/OwnNames.d.ts.map +1 -0
- package/dist/internal/OwnNames.js +415 -0
- package/dist/internal/OwnNames.js.map +1 -0
- package/dist/internal/PackedCodec.d.ts +7 -1
- package/dist/internal/PackedCodec.d.ts.map +1 -1
- package/dist/internal/PackedCodec.js +83 -21
- package/dist/internal/PackedCodec.js.map +1 -1
- package/dist/internal/RestoredKeyText.d.ts +10 -0
- package/dist/internal/RestoredKeyText.d.ts.map +1 -0
- package/dist/internal/RestoredKeyText.js +50 -0
- package/dist/internal/RestoredKeyText.js.map +1 -0
- package/dist/internal/SchemaAccessors.d.ts +280 -1
- package/dist/internal/SchemaAccessors.d.ts.map +1 -1
- package/dist/internal/SchemaAccessors.js +1717 -1
- package/dist/internal/SchemaAccessors.js.map +1 -1
- package/dist/internal/SchemaIssue.d.ts +21 -0
- package/dist/internal/SchemaIssue.d.ts.map +1 -0
- package/dist/internal/SchemaIssue.js +34 -0
- package/dist/internal/SchemaIssue.js.map +1 -0
- package/dist/internal/SharedKeyAttribute.d.ts +60 -6
- package/dist/internal/SharedKeyAttribute.d.ts.map +1 -1
- package/dist/internal/SharedKeyAttribute.js +129 -13
- package/dist/internal/SharedKeyAttribute.js.map +1 -1
- package/dist/internal/SparseKey.d.ts +46 -0
- package/dist/internal/SparseKey.d.ts.map +1 -0
- package/dist/internal/SparseKey.js +69 -0
- package/dist/internal/SparseKey.js.map +1 -0
- package/dist/internal/StoredForm.d.ts +139 -0
- package/dist/internal/StoredForm.d.ts.map +1 -0
- package/dist/internal/StoredForm.js +503 -0
- package/dist/internal/StoredForm.js.map +1 -0
- package/dist/internal/ZOrderCurve.d.ts.map +1 -1
- package/dist/internal/ZOrderCurve.js +2 -1
- package/dist/internal/ZOrderCurve.js.map +1 -1
- package/dist/internal/ZoneKeyText.d.ts +55 -0
- package/dist/internal/ZoneKeyText.d.ts.map +1 -0
- package/dist/internal/ZoneKeyText.js +264 -0
- package/dist/internal/ZoneKeyText.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal Effect's own declarations whose values DynamoDB hands back as plain maps, and how each
|
|
3
|
+
* is rebuilt from that map.
|
|
4
|
+
*
|
|
5
|
+
* The marshaller stores a class instance as the map of its enumerable properties, its prototype's
|
|
6
|
+
* included, so a `BigDecimal`, a `Duration`, a zone, a cookie, a version, an address or a DNS record
|
|
7
|
+
* is stored as a map carrying its marker. Each declaration's guard looks for that marker, so it takes
|
|
8
|
+
* the map back as it is: a value that passes the guard and isn't one (`BigDecimal` arithmetic throws,
|
|
9
|
+
* a named zone can't format, a key composed from it is `[object Object]`).
|
|
10
|
+
*
|
|
11
|
+
* {@link effectDeclarationOf} is the one place that decides whether a declaration is one of Effect's:
|
|
12
|
+
* every path that treats these types differently asks it, so none can recognise a type another
|
|
13
|
+
* doesn't. A declaration is Effect's when its parse function is the one Effect's exported schema has.
|
|
14
|
+
* A `.check()`, an annotation and a brand keep that function, and a refinement Effect builds on one of
|
|
15
|
+
* these keeps its base's; a `Schema.declare` of one's own has its own, whatever it's named, and so has
|
|
16
|
+
* a declaration from another copy of `effect`. Those are read as they always were.
|
|
17
|
+
*/
|
|
18
|
+
import { BigDecimal, DateTime, Duration, Effect, Result, Schema, SchemaAST } from "effect";
|
|
19
|
+
import * as Cookies from "effect/http/Cookies";
|
|
20
|
+
import * as UrlParams from "effect/http/UrlParams";
|
|
21
|
+
import * as Dns from "effect/net/Dns";
|
|
22
|
+
import * as Host from "effect/net/Host";
|
|
23
|
+
import * as IpInterface from "effect/net/IpInterface";
|
|
24
|
+
import * as IpNetwork from "effect/net/IpNetwork";
|
|
25
|
+
import * as NetAddress from "effect/net/NetAddress";
|
|
26
|
+
import * as SemVer from "effect/SemVer";
|
|
27
|
+
import * as SemVerRange from "effect/SemVerRange";
|
|
28
|
+
import { BETA_DATE_MARKER, BIG_DECIMAL_MARKER as BIG_DECIMAL, COOKIE_MARKER as COOKIE, COOKIE_PROTO, COOKIES_MARKER as COOKIES, DATE_MARKER, DNS_RECORD_MARKER as DNS_RECORD, DURATION_MARKER as DURATION, expiryText, HOST_MARKER as HOST, IP_INTERFACE_MARKER as IP_INTERFACE, IP_NETWORK_MARKER as IP_NETWORK, NET_ADDRESS_MARKER as NET_ADDRESS, SEMVER_MARKER as SEMVER, SEMVER_RANGE_MARKER as SEMVER_RANGE, storedZoneName, URL_PARAMS_MARKER as URL_PARAMS, ZONE_MARKER, zoneEntriesWritten, } from "./StoredForm.js";
|
|
29
|
+
const DECLARATIONS = [
|
|
30
|
+
[Schema.DateTimeUtc, "DateTime"],
|
|
31
|
+
[Schema.DateTimeZoned, "DateTime"],
|
|
32
|
+
[Schema.BigDecimal, "BigDecimal"],
|
|
33
|
+
[Schema.Duration, "Duration"],
|
|
34
|
+
[Schema.TimeZone, "TimeZone"],
|
|
35
|
+
[Schema.TimeZoneNamed, "TimeZone"],
|
|
36
|
+
[Schema.TimeZoneOffset, "TimeZone"],
|
|
37
|
+
[Schema.Cookie, "Cookie"],
|
|
38
|
+
[Schema.Cookies, "Cookies"],
|
|
39
|
+
[Schema.UrlParams, "UrlParams"],
|
|
40
|
+
[Schema.SemVer, "SemVer"],
|
|
41
|
+
[Schema.SemVerRange, "SemVerRange"],
|
|
42
|
+
[Schema.Ipv4Address, "NetAddress"],
|
|
43
|
+
[Schema.Ipv6Address, "NetAddress"],
|
|
44
|
+
[Schema.IpAddress, "NetAddress"],
|
|
45
|
+
[Schema.MacAddress, "NetAddress"],
|
|
46
|
+
[Schema.Ipv4Network, "NetAddress"],
|
|
47
|
+
[Schema.Ipv6Network, "NetAddress"],
|
|
48
|
+
[Schema.IpNetwork, "NetAddress"],
|
|
49
|
+
[Schema.Ipv4Interface, "NetAddress"],
|
|
50
|
+
[Schema.Ipv6Interface, "NetAddress"],
|
|
51
|
+
[Schema.IpInterface, "NetAddress"],
|
|
52
|
+
[Schema.InetAddressV4, "NetAddress"],
|
|
53
|
+
[Schema.InetAddressV6, "NetAddress"],
|
|
54
|
+
[Schema.InetAddress, "NetAddress"],
|
|
55
|
+
[Schema.HostPort, "NetAddress"],
|
|
56
|
+
[Schema.SocketAddress, "NetAddress"],
|
|
57
|
+
[Schema.UnixPathAddress, "NetAddress"],
|
|
58
|
+
[Schema.DnsARecord, "DnsRecord"],
|
|
59
|
+
[Schema.DnsAaaaRecord, "DnsRecord"],
|
|
60
|
+
[Schema.DnsCaaRecord, "DnsRecord"],
|
|
61
|
+
[Schema.DnsCnameRecord, "DnsRecord"],
|
|
62
|
+
[Schema.DnsMxRecord, "DnsRecord"],
|
|
63
|
+
[Schema.DnsNaptrRecord, "DnsRecord"],
|
|
64
|
+
[Schema.DnsNsRecord, "DnsRecord"],
|
|
65
|
+
[Schema.DnsPtrRecord, "DnsRecord"],
|
|
66
|
+
[Schema.DnsSoaRecord, "DnsRecord"],
|
|
67
|
+
[Schema.DnsSrvRecord, "DnsRecord"],
|
|
68
|
+
[Schema.DnsTlsaRecord, "DnsRecord"],
|
|
69
|
+
[Schema.DnsTxtRecord, "DnsRecord"],
|
|
70
|
+
];
|
|
71
|
+
const representationIdOf = (ast) => ast.annotations?.representation?.id;
|
|
72
|
+
/** Each declaration's parse function, with its kind and, where it has one, its representation. */
|
|
73
|
+
const KNOWN = new Map(DECLARATIONS.map(([schema, kind]) => [
|
|
74
|
+
schema.ast.run,
|
|
75
|
+
{ kind, id: representationIdOf(schema.ast) },
|
|
76
|
+
]));
|
|
77
|
+
/** Each read node's parser ({@link readingDeclaration}), with the declaration's own it runs. */
|
|
78
|
+
const READ_PARSERS = new WeakMap();
|
|
79
|
+
/**
|
|
80
|
+
* Which of Effect's declarations this node is, or `undefined` for any other node. Only the
|
|
81
|
+
* declaration itself counts: a transformation over one stores what it encodes to, and is reached
|
|
82
|
+
* through its encoding. A declaration's read node ({@link readingDeclaration}) is the declaration it
|
|
83
|
+
* reads.
|
|
84
|
+
*/
|
|
85
|
+
export const effectDeclarationOf = (ast) => {
|
|
86
|
+
if (!SchemaAST.isDeclaration(ast) || ast.encoding !== undefined)
|
|
87
|
+
return undefined;
|
|
88
|
+
const known = KNOWN.get(READ_PARSERS.get(ast.run) ?? ast.run);
|
|
89
|
+
if (known === undefined)
|
|
90
|
+
return undefined;
|
|
91
|
+
if (known.id !== undefined && representationIdOf(ast) !== known.id)
|
|
92
|
+
return undefined;
|
|
93
|
+
return known.kind;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The last step each of Effect's own codecs takes onto one of these declarations
|
|
97
|
+
* (`Schema.DateTimeUtcFromString`, `Schema.DurationFromMillis`, ...): it makes the instance itself,
|
|
98
|
+
* so the declaration's parser is never handed a stored map, and there's nothing to rebuild.
|
|
99
|
+
*/
|
|
100
|
+
const INSTANCE_STEPS = new WeakSet();
|
|
101
|
+
for (const exported of Object.values(Schema)) {
|
|
102
|
+
const ast = exported?.ast;
|
|
103
|
+
if (ast === undefined || !SchemaAST.isDeclaration(ast) || !KNOWN.has(ast.run))
|
|
104
|
+
continue;
|
|
105
|
+
const step = ast.encoding?.[0]?.transformation;
|
|
106
|
+
if (step !== undefined)
|
|
107
|
+
INSTANCE_STEPS.add(step);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Which of Effect's declarations a read takes this node's parser for, whether or not the node has an
|
|
111
|
+
* encoding: a transformation onto one hands its parser whatever its steps make of what's stored, and
|
|
112
|
+
* a step that passes the stored map through leaves the parser taking it for an instance. One of
|
|
113
|
+
* Effect's own codecs isn't one: its step makes the instance ({@link INSTANCE_STEPS}).
|
|
114
|
+
*/
|
|
115
|
+
export const readDeclarationOf = (ast) => {
|
|
116
|
+
if (!SchemaAST.isDeclaration(ast))
|
|
117
|
+
return undefined;
|
|
118
|
+
if (ast.encoding !== undefined && INSTANCE_STEPS.has(ast.encoding[0].transformation)) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
const known = KNOWN.get(READ_PARSERS.get(ast.run) ?? ast.run);
|
|
122
|
+
if (known === undefined)
|
|
123
|
+
return undefined;
|
|
124
|
+
if (known.id !== undefined && representationIdOf(ast) !== known.id)
|
|
125
|
+
return undefined;
|
|
126
|
+
return known.kind;
|
|
127
|
+
};
|
|
128
|
+
/** Whether a node is a read node {@link readingDeclaration} built. */
|
|
129
|
+
export const isReadingDeclaration = (ast) => SchemaAST.isDeclaration(ast) && READ_PARSERS.has(ast.run);
|
|
130
|
+
const isMap = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
131
|
+
/** A plain record, what unmarshalling produces, as opposed to a class instance. */
|
|
132
|
+
const isPlain = (value) => {
|
|
133
|
+
if (value === null || typeof value !== "object")
|
|
134
|
+
return false;
|
|
135
|
+
const proto = Object.getPrototypeOf(value);
|
|
136
|
+
return proto === Object.prototype || proto === null;
|
|
137
|
+
};
|
|
138
|
+
const markedBy = (value, marker) => isMap(value) && Object.hasOwn(value, marker);
|
|
139
|
+
const resultOf = (result) => Result.isSuccess(result) ? result.success : undefined;
|
|
140
|
+
const attempt = (make) => {
|
|
141
|
+
try {
|
|
142
|
+
return make();
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* A stored integer as a bigint. The unmarshaller hands an integer back as a number while it's a safe
|
|
150
|
+
* one and as a bigint past that, so either is exact; a number that isn't a safe integer is no integer
|
|
151
|
+
* this was written from.
|
|
152
|
+
*/
|
|
153
|
+
const exactInteger = (value) => typeof value === "bigint"
|
|
154
|
+
? value
|
|
155
|
+
: typeof value === "number" && Number.isSafeInteger(value)
|
|
156
|
+
? BigInt(value)
|
|
157
|
+
: undefined;
|
|
158
|
+
const isUint32 = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 0xffffffff;
|
|
159
|
+
/**
|
|
160
|
+
* A stored `normalized` is left where it is, in the map: on an instance it's the slot
|
|
161
|
+
* `BigDecimal.normalize` caches in, and a map there would be handed out as the normalized decimal.
|
|
162
|
+
*/
|
|
163
|
+
const rebuildBigDecimal = (value) => {
|
|
164
|
+
if (!markedBy(value, BIG_DECIMAL) || Object.hasOwn(value, "normalized"))
|
|
165
|
+
return undefined;
|
|
166
|
+
const unscaled = exactInteger(value.value);
|
|
167
|
+
const scale = value.scale;
|
|
168
|
+
if (unscaled === undefined || typeof scale !== "number" || !Number.isSafeInteger(scale)) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
return BigDecimal.make(unscaled, scale);
|
|
172
|
+
};
|
|
173
|
+
const rebuildDuration = (value) => {
|
|
174
|
+
if (!markedBy(value, DURATION) || !isMap(value.value))
|
|
175
|
+
return undefined;
|
|
176
|
+
const stored = value.value;
|
|
177
|
+
switch (stored._tag) {
|
|
178
|
+
case "Millis":
|
|
179
|
+
return typeof stored.millis === "number" && Number.isFinite(stored.millis)
|
|
180
|
+
? Duration.millis(stored.millis)
|
|
181
|
+
: undefined;
|
|
182
|
+
case "Nanos": {
|
|
183
|
+
const nanos = exactInteger(stored.nanos);
|
|
184
|
+
return nanos === undefined ? undefined : Duration.nanos(nanos);
|
|
185
|
+
}
|
|
186
|
+
case "Infinity":
|
|
187
|
+
return Duration.infinity;
|
|
188
|
+
case "NegativeInfinity":
|
|
189
|
+
return Duration.negativeInfinity;
|
|
190
|
+
default:
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* A zone from its stored form: a named one from its name, an offset one from its offset. A named
|
|
196
|
+
* zone's map holds the name as `id`, as 4.1.2 held it, or as `resolvedId` beside the name it was made
|
|
197
|
+
* from, as 4.1.3 does: it's the zone {@link storedZoneName} names either way.
|
|
198
|
+
*/
|
|
199
|
+
export const reviveTimeZone = (zone) => {
|
|
200
|
+
if (!isPlain(zone))
|
|
201
|
+
return undefined;
|
|
202
|
+
try {
|
|
203
|
+
const name = zone._tag === "Named" ? storedZoneName(zone.id, zone.resolvedId) : undefined;
|
|
204
|
+
if (name !== undefined)
|
|
205
|
+
return DateTime.zoneMakeNamedUnsafe(name);
|
|
206
|
+
if (zone._tag === "Named" && typeof zone.id === "string") {
|
|
207
|
+
return DateTime.zoneMakeNamedUnsafe(zone.id);
|
|
208
|
+
}
|
|
209
|
+
if (zone._tag === "Offset" && typeof zone.offset === "number") {
|
|
210
|
+
return DateTime.zoneMakeOffset(zone.offset);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
return undefined;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Rebuild a `DateTime` from a MARSHALLED instance (#133).
|
|
220
|
+
*
|
|
221
|
+
* Before #133 an aggregate stored some `DateTime`s by marshalling the instance
|
|
222
|
+
* itself, which keeps its own enumerable properties:
|
|
223
|
+
*
|
|
224
|
+
* - `Utc`: `{ epochMilliseconds, <type-id>, _tag: "Utc" }`
|
|
225
|
+
* - `Zoned`: the same plus `zone`, itself `{ id, _tag: "Named" }` or
|
|
226
|
+
* `{ offset, _tag: "Offset" }` (a named zone's `Intl` formatter marshals to
|
|
227
|
+
* an empty map and is not needed).
|
|
228
|
+
*
|
|
229
|
+
* The type-id key is `~effect/time/DateTime` on effect 4.0.0-rc and
|
|
230
|
+
* `~effect/DateTime` on 4.0.0, so it is deliberately NOT inspected: the instant
|
|
231
|
+
* and the tag are what identify the value, and they are all a `DateTime` holds.
|
|
232
|
+
* A zoned value is rebuilt only when its zone is recoverable.
|
|
233
|
+
*
|
|
234
|
+
* Returns `undefined` for anything else — including a genuine `DateTime`, which
|
|
235
|
+
* needs no rebuilding.
|
|
236
|
+
*/
|
|
237
|
+
export const reviveMarshalledDateTime = (value) => {
|
|
238
|
+
if (!isPlain(value))
|
|
239
|
+
return undefined;
|
|
240
|
+
const epochMs = value.epochMilliseconds;
|
|
241
|
+
if (typeof epochMs !== "number" || !Number.isFinite(epochMs))
|
|
242
|
+
return undefined;
|
|
243
|
+
if (value._tag === "Utc")
|
|
244
|
+
return DateTime.makeUnsafe(epochMs);
|
|
245
|
+
if (value._tag === "Zoned") {
|
|
246
|
+
const timeZone = reviveTimeZone(value.zone);
|
|
247
|
+
return timeZone === undefined ? undefined : DateTime.makeZonedUnsafe(epochMs, { timeZone });
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
};
|
|
251
|
+
const rebuildDateTime = (value) => isMap(value) && (DATE_MARKER in value || BETA_DATE_MARKER in value)
|
|
252
|
+
? reviveMarshalledDateTime(value)
|
|
253
|
+
: undefined;
|
|
254
|
+
const rebuildTimeZone = (value) => markedBy(value, ZONE_MARKER) ? reviveTimeZone(value) : undefined;
|
|
255
|
+
/** An expiry as it's stored, ISO text, back as the `Date` it was written from. */
|
|
256
|
+
const expiryOf = (text) => {
|
|
257
|
+
const date = new Date(text);
|
|
258
|
+
return Number.isNaN(date.getTime()) || date.toISOString() !== text ? undefined : date;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* A cookie's options as stored: `expires` is the ISO text of the `Date` written, and a `maxAge`
|
|
262
|
+
* that's a `Duration` is one again. An `expires` that's anything else isn't one this can rebuild:
|
|
263
|
+
* 1.39.0 stored a `Date` as the empty map the marshaller makes of one, and the cookie it stood for
|
|
264
|
+
* would be written back without it, so that cookie stays the map it was read as.
|
|
265
|
+
*/
|
|
266
|
+
const cookieOptions = (options) => {
|
|
267
|
+
if (!isMap(options))
|
|
268
|
+
return undefined;
|
|
269
|
+
const rebuilt = {};
|
|
270
|
+
for (const [key, value] of Object.entries(options)) {
|
|
271
|
+
if (key === "expires") {
|
|
272
|
+
const expires = typeof value === "string" ? expiryOf(value) : undefined;
|
|
273
|
+
if (expires === undefined)
|
|
274
|
+
return undefined;
|
|
275
|
+
rebuilt[key] = expires;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (key === "maxAge" && markedBy(value, DURATION)) {
|
|
279
|
+
const maxAge = rebuildDuration(value);
|
|
280
|
+
if (maxAge === undefined)
|
|
281
|
+
return undefined;
|
|
282
|
+
rebuilt[key] = maxAge;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
rebuilt[key] = value;
|
|
286
|
+
}
|
|
287
|
+
return rebuilt;
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* A cookie on its own prototype with the fields stored, so `valueEncoded` stays exactly what was
|
|
291
|
+
* written: rebuilding it from `value` could encode it otherwise.
|
|
292
|
+
*/
|
|
293
|
+
const rebuildCookie = (value) => {
|
|
294
|
+
if (!markedBy(value, COOKIE))
|
|
295
|
+
return undefined;
|
|
296
|
+
const { name, valueEncoded } = value;
|
|
297
|
+
if (typeof name !== "string" ||
|
|
298
|
+
typeof value.value !== "string" ||
|
|
299
|
+
typeof valueEncoded !== "string") {
|
|
300
|
+
return undefined;
|
|
301
|
+
}
|
|
302
|
+
const fields = { name, value: value.value, valueEncoded };
|
|
303
|
+
if (Object.hasOwn(value, "options")) {
|
|
304
|
+
const options = value.options === undefined ? undefined : cookieOptions(value.options);
|
|
305
|
+
if (value.options !== undefined && options === undefined)
|
|
306
|
+
return undefined;
|
|
307
|
+
fields.options = options;
|
|
308
|
+
}
|
|
309
|
+
return Object.assign(Object.create(COOKIE_PROTO), fields);
|
|
310
|
+
};
|
|
311
|
+
const rebuildCookies = (value) => {
|
|
312
|
+
if (!markedBy(value, COOKIES) || !isMap(value.cookies))
|
|
313
|
+
return undefined;
|
|
314
|
+
const cookies = [];
|
|
315
|
+
for (const stored of Object.values(value.cookies)) {
|
|
316
|
+
const cookie = rebuildCookie(stored);
|
|
317
|
+
if (cookie === undefined)
|
|
318
|
+
return undefined;
|
|
319
|
+
cookies.push(cookie);
|
|
320
|
+
}
|
|
321
|
+
return Cookies.fromIterable(cookies);
|
|
322
|
+
};
|
|
323
|
+
const rebuildUrlParams = (value) => {
|
|
324
|
+
if (!markedBy(value, URL_PARAMS) || !Array.isArray(value.params))
|
|
325
|
+
return undefined;
|
|
326
|
+
const params = [];
|
|
327
|
+
for (const pair of value.params) {
|
|
328
|
+
if (!Array.isArray(pair) || pair.length !== 2)
|
|
329
|
+
return undefined;
|
|
330
|
+
const [key, text] = pair;
|
|
331
|
+
if (typeof key !== "string" || typeof text !== "string")
|
|
332
|
+
return undefined;
|
|
333
|
+
params.push([key, text]);
|
|
334
|
+
}
|
|
335
|
+
return UrlParams.make(params);
|
|
336
|
+
};
|
|
337
|
+
const rebuildSemVer = (value) => {
|
|
338
|
+
if (!markedBy(value, SEMVER))
|
|
339
|
+
return undefined;
|
|
340
|
+
const { major, minor, patch, prerelease, build } = value;
|
|
341
|
+
if (!Array.isArray(prerelease) || !Array.isArray(build))
|
|
342
|
+
return undefined;
|
|
343
|
+
return attempt(() => SemVer.make({ major, minor, patch, prerelease, build }));
|
|
344
|
+
};
|
|
345
|
+
const RANGE_PROTO = Object.getPrototypeOf(SemVerRange.any);
|
|
346
|
+
const isComparator = (value) => isMap(value) &&
|
|
347
|
+
value._tag === "Comparator" &&
|
|
348
|
+
typeof value.operator === "string" &&
|
|
349
|
+
isMap(value.version) &&
|
|
350
|
+
Array.isArray(value.version.components) &&
|
|
351
|
+
value.version.components.every((part) => typeof part === "number") &&
|
|
352
|
+
Array.isArray(value.version.prerelease);
|
|
353
|
+
/** A range is its comparator sets, plain data: the range module has no constructor for them. */
|
|
354
|
+
const rebuildSemVerRange = (value) => {
|
|
355
|
+
if (!markedBy(value, SEMVER_RANGE) || !Array.isArray(value.sets))
|
|
356
|
+
return undefined;
|
|
357
|
+
const sets = [];
|
|
358
|
+
for (const set of value.sets) {
|
|
359
|
+
if (!Array.isArray(set) || !set.every(isComparator))
|
|
360
|
+
return undefined;
|
|
361
|
+
sets.push(set.map((comparator) => {
|
|
362
|
+
const version = comparator.version;
|
|
363
|
+
return {
|
|
364
|
+
_tag: "Comparator",
|
|
365
|
+
operator: comparator.operator,
|
|
366
|
+
version: { components: version.components, prerelease: version.prerelease },
|
|
367
|
+
};
|
|
368
|
+
}));
|
|
369
|
+
}
|
|
370
|
+
return Object.assign(Object.create(RANGE_PROTO), { sets });
|
|
371
|
+
};
|
|
372
|
+
const ipv4 = (value) => {
|
|
373
|
+
if (!markedBy(value, NET_ADDRESS) || !isUint32(value.value))
|
|
374
|
+
return undefined;
|
|
375
|
+
const word = value.value;
|
|
376
|
+
return resultOf(NetAddress.ipv4FromOctets([
|
|
377
|
+
word >>> 24,
|
|
378
|
+
(word >>> 16) & 0xff,
|
|
379
|
+
(word >>> 8) & 0xff,
|
|
380
|
+
word & 0xff,
|
|
381
|
+
]));
|
|
382
|
+
};
|
|
383
|
+
const ipv6 = (value) => {
|
|
384
|
+
if (!markedBy(value, NET_ADDRESS))
|
|
385
|
+
return undefined;
|
|
386
|
+
const words = [value.w0, value.w1, value.w2, value.w3];
|
|
387
|
+
if (!words.every(isUint32))
|
|
388
|
+
return undefined;
|
|
389
|
+
return resultOf(NetAddress.ipv6FromSegments(words.flatMap((word) => [word >>> 16, word & 0xffff])));
|
|
390
|
+
};
|
|
391
|
+
const ipAddress = (value) => {
|
|
392
|
+
if (!isMap(value))
|
|
393
|
+
return undefined;
|
|
394
|
+
return value._tag === "Ipv4Address"
|
|
395
|
+
? ipv4(value)
|
|
396
|
+
: value._tag === "Ipv6Address"
|
|
397
|
+
? ipv6(value)
|
|
398
|
+
: undefined;
|
|
399
|
+
};
|
|
400
|
+
const isPort = (value) => typeof value === "number";
|
|
401
|
+
/** An address, network, interface, socket address or host and port, by its tag. */
|
|
402
|
+
const rebuildNetAddress = (value) => {
|
|
403
|
+
if (!isMap(value))
|
|
404
|
+
return undefined;
|
|
405
|
+
switch (value._tag) {
|
|
406
|
+
case "Ipv4Address":
|
|
407
|
+
case "Ipv6Address":
|
|
408
|
+
return ipAddress(value);
|
|
409
|
+
case "MacAddress":
|
|
410
|
+
return markedBy(value, NET_ADDRESS) && value.bytes instanceof Uint8Array
|
|
411
|
+
? resultOf(NetAddress.macAddressFromOctets([...value.bytes]))
|
|
412
|
+
: undefined;
|
|
413
|
+
case "IpNetwork":
|
|
414
|
+
case "IpInterface": {
|
|
415
|
+
const marker = value._tag === "IpNetwork" ? IP_NETWORK : IP_INTERFACE;
|
|
416
|
+
const address = ipAddress(value.address);
|
|
417
|
+
if (!markedBy(value, marker) || address === undefined)
|
|
418
|
+
return undefined;
|
|
419
|
+
if (typeof value.prefixLength !== "number")
|
|
420
|
+
return undefined;
|
|
421
|
+
return value._tag === "IpNetwork"
|
|
422
|
+
? resultOf(IpNetwork.make(address, value.prefixLength))
|
|
423
|
+
: resultOf(IpInterface.make(address, value.prefixLength));
|
|
424
|
+
}
|
|
425
|
+
case "InetAddressV4": {
|
|
426
|
+
const address = ipAddress(value.address);
|
|
427
|
+
if (!markedBy(value, NET_ADDRESS) || !isPort(value.port))
|
|
428
|
+
return undefined;
|
|
429
|
+
return address !== undefined && address._tag === "Ipv4Address"
|
|
430
|
+
? resultOf(NetAddress.inetAddressV4(address, value.port))
|
|
431
|
+
: undefined;
|
|
432
|
+
}
|
|
433
|
+
case "InetAddressV6": {
|
|
434
|
+
const address = ipAddress(value.address);
|
|
435
|
+
if (!markedBy(value, NET_ADDRESS) || !isPort(value.port))
|
|
436
|
+
return undefined;
|
|
437
|
+
if (typeof value.scopeId !== "number")
|
|
438
|
+
return undefined;
|
|
439
|
+
return address !== undefined && address._tag === "Ipv6Address"
|
|
440
|
+
? resultOf(NetAddress.inetAddressV6(address, value.port, { scopeId: value.scopeId }))
|
|
441
|
+
: undefined;
|
|
442
|
+
}
|
|
443
|
+
case "HostPort": {
|
|
444
|
+
if (!markedBy(value, HOST) || !isPort(value.port))
|
|
445
|
+
return undefined;
|
|
446
|
+
const host = typeof value.host === "string" ? value.host : ipAddress(value.host);
|
|
447
|
+
return host === undefined ? undefined : resultOf(Host.hostPort(host, value.port));
|
|
448
|
+
}
|
|
449
|
+
case "UnixPathAddress":
|
|
450
|
+
return markedBy(value, NET_ADDRESS) && typeof value.path === "string"
|
|
451
|
+
? NetAddress.unixPathAddress(value.path)
|
|
452
|
+
: undefined;
|
|
453
|
+
default:
|
|
454
|
+
return undefined;
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
/** A value inside a DNS record: an address or a `Duration` is rebuilt, anything else kept. */
|
|
458
|
+
const recordField = (value) => markedBy(value, DURATION)
|
|
459
|
+
? rebuildDuration(value)
|
|
460
|
+
: isMap(value) && (Object.hasOwn(value, NET_ADDRESS) || Object.hasOwn(value, HOST))
|
|
461
|
+
? rebuildNetAddress(value)
|
|
462
|
+
: value;
|
|
463
|
+
const rebuildDnsRecord = (value) => {
|
|
464
|
+
if (!markedBy(value, DNS_RECORD) || typeof value._tag !== "string")
|
|
465
|
+
return undefined;
|
|
466
|
+
const fields = {};
|
|
467
|
+
for (const [key, field] of Object.entries(value)) {
|
|
468
|
+
if (key === "_tag" || key === DNS_RECORD)
|
|
469
|
+
continue;
|
|
470
|
+
const rebuilt = recordField(field);
|
|
471
|
+
if (rebuilt === undefined && field !== undefined)
|
|
472
|
+
return undefined;
|
|
473
|
+
fields[key] = rebuilt;
|
|
474
|
+
}
|
|
475
|
+
return resultOf(Dns.makeRecord(value._tag, fields));
|
|
476
|
+
};
|
|
477
|
+
const REBUILDS = {
|
|
478
|
+
DateTime: rebuildDateTime,
|
|
479
|
+
BigDecimal: rebuildBigDecimal,
|
|
480
|
+
Duration: rebuildDuration,
|
|
481
|
+
TimeZone: rebuildTimeZone,
|
|
482
|
+
Cookie: rebuildCookie,
|
|
483
|
+
Cookies: rebuildCookies,
|
|
484
|
+
UrlParams: rebuildUrlParams,
|
|
485
|
+
SemVer: rebuildSemVer,
|
|
486
|
+
SemVerRange: rebuildSemVerRange,
|
|
487
|
+
NetAddress: rebuildNetAddress,
|
|
488
|
+
DnsRecord: rebuildDnsRecord,
|
|
489
|
+
};
|
|
490
|
+
/**
|
|
491
|
+
* What a native write stores of an object: its enumerable properties, its prototype's included, and
|
|
492
|
+
* a named zone's holding `resolvedId` as 4.1.2 held them ({@link zoneEntriesWritten}).
|
|
493
|
+
*/
|
|
494
|
+
const writtenProperties = (value) => {
|
|
495
|
+
const properties = [];
|
|
496
|
+
for (const key in value) {
|
|
497
|
+
const property = value[key];
|
|
498
|
+
if (property !== undefined && typeof property !== "function")
|
|
499
|
+
properties.push([key, property]);
|
|
500
|
+
}
|
|
501
|
+
return zoneEntriesWritten(properties, ZONE_MARKER in value, (property) => property, (name) => name);
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* A stored map as a write stores it again: a named zone's holding `resolvedId` as 4.1.2 held it
|
|
505
|
+
* ({@link zoneEntriesWritten}), anything else as it is.
|
|
506
|
+
*/
|
|
507
|
+
const asWrittenAgain = (kind, value) => {
|
|
508
|
+
if (kind !== "TimeZone")
|
|
509
|
+
return value;
|
|
510
|
+
const entries = Object.entries(value);
|
|
511
|
+
const written = zoneEntriesWritten(entries, true, (entry) => entry, (name) => name);
|
|
512
|
+
return written === entries ? value : Object.fromEntries(written);
|
|
513
|
+
};
|
|
514
|
+
const sameNumber = (written, stored) => {
|
|
515
|
+
if (typeof stored !== "number" && typeof stored !== "bigint")
|
|
516
|
+
return false;
|
|
517
|
+
if (typeof written === typeof stored)
|
|
518
|
+
return written === stored;
|
|
519
|
+
const [integer, float] = typeof written === "bigint" ? [written, stored] : [stored, written];
|
|
520
|
+
return Number.isSafeInteger(float) && BigInt(float) === integer;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Whether a cookie's options, written, are what's stored. The marshaller writes the expiry of one
|
|
524
|
+
* of Effect's cookies as the ISO text of its `Date`, where the `Date`, valid and holding nothing of
|
|
525
|
+
* its own, would be an empty map; everything else is marshalled as it is.
|
|
526
|
+
*/
|
|
527
|
+
const optionsWriteAs = (options, stored) => {
|
|
528
|
+
if (options === null || typeof options !== "object" || !isPlain(stored)) {
|
|
529
|
+
return writesAs(options, stored);
|
|
530
|
+
}
|
|
531
|
+
const properties = writtenProperties(options);
|
|
532
|
+
return (properties.length === Object.keys(stored).length &&
|
|
533
|
+
properties.every(([key, property]) => {
|
|
534
|
+
if (!Object.hasOwn(stored, key))
|
|
535
|
+
return false;
|
|
536
|
+
const expiry = key === "expires" ? expiryText(property) : undefined;
|
|
537
|
+
return expiry !== undefined ? stored[key] === expiry : writesAs(property, stored[key]);
|
|
538
|
+
}));
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Whether a value, written, is what's stored: the marshaller's walk of it, against what the
|
|
542
|
+
* unmarshaller handed back. Anything this can't say for sure isn't the same.
|
|
543
|
+
*/
|
|
544
|
+
const writesAs = (written, stored) => {
|
|
545
|
+
if (typeof written === "number" || typeof written === "bigint")
|
|
546
|
+
return sameNumber(written, stored);
|
|
547
|
+
if (written === null || typeof written !== "object")
|
|
548
|
+
return written === stored;
|
|
549
|
+
if (written instanceof Uint8Array) {
|
|
550
|
+
return (stored instanceof Uint8Array &&
|
|
551
|
+
stored.length === written.length &&
|
|
552
|
+
written.every((byte, index) => byte === stored[index]));
|
|
553
|
+
}
|
|
554
|
+
if (written instanceof Set) {
|
|
555
|
+
if (!(stored instanceof Set) || stored.size !== written.size)
|
|
556
|
+
return false;
|
|
557
|
+
const members = [...stored];
|
|
558
|
+
return [...written].every((member) => members.some((other) => writesAs(member, other)));
|
|
559
|
+
}
|
|
560
|
+
if (Array.isArray(written)) {
|
|
561
|
+
const elements = written.filter((element) => element !== undefined && typeof element !== "function");
|
|
562
|
+
return (Array.isArray(stored) &&
|
|
563
|
+
stored.length === elements.length &&
|
|
564
|
+
elements.every((element, index) => writesAs(element, stored[index])));
|
|
565
|
+
}
|
|
566
|
+
if (!isPlain(stored))
|
|
567
|
+
return false;
|
|
568
|
+
const properties = written instanceof Map ? [...written] : writtenProperties(written);
|
|
569
|
+
const cookie = Object.getPrototypeOf(written) === COOKIE_PROTO;
|
|
570
|
+
return (properties.length === Object.keys(stored).length &&
|
|
571
|
+
properties.every(([key, property]) => typeof key === "string" &&
|
|
572
|
+
Object.hasOwn(stored, key) &&
|
|
573
|
+
(cookie && key === "options"
|
|
574
|
+
? optionsWriteAs(property, stored[key])
|
|
575
|
+
: writesAs(property, stored[key]))));
|
|
576
|
+
};
|
|
577
|
+
/**
|
|
578
|
+
* The instance with every stored property its rebuild made no use of, as its own: what an instance
|
|
579
|
+
* was given on top of its fields (`Object.assign(duration, { source })`) was stored with it, and is
|
|
580
|
+
* written again with it. On a copy of the instance, so nothing shared is touched; the instance
|
|
581
|
+
* itself when there's nothing to carry.
|
|
582
|
+
*/
|
|
583
|
+
const carrying = (instance, stored) => {
|
|
584
|
+
const written = new Set();
|
|
585
|
+
for (const key in instance)
|
|
586
|
+
written.add(key);
|
|
587
|
+
const carried = Object.keys(stored).filter((key) => !written.has(key));
|
|
588
|
+
if (carried.length === 0)
|
|
589
|
+
return instance;
|
|
590
|
+
const copy = Object.create(Object.getPrototypeOf(instance), Object.getOwnPropertyDescriptors(instance));
|
|
591
|
+
for (const key of carried) {
|
|
592
|
+
Object.defineProperty(copy, key, {
|
|
593
|
+
value: stored[key],
|
|
594
|
+
enumerable: true,
|
|
595
|
+
writable: true,
|
|
596
|
+
configurable: true,
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
return copy;
|
|
600
|
+
};
|
|
601
|
+
/**
|
|
602
|
+
* The kinds whose instance is rebuilt only if writing it stores what was read. A date's marker
|
|
603
|
+
* changed between releases, so a date is rebuilt as it always was. A cookie's expiry is held as a
|
|
604
|
+
* `Date` and written as its ISO text, which is how {@link optionsWriteAs} compares it.
|
|
605
|
+
*/
|
|
606
|
+
const EXACT = {
|
|
607
|
+
DateTime: false,
|
|
608
|
+
BigDecimal: true,
|
|
609
|
+
Duration: true,
|
|
610
|
+
TimeZone: true,
|
|
611
|
+
Cookie: true,
|
|
612
|
+
Cookies: true,
|
|
613
|
+
UrlParams: true,
|
|
614
|
+
SemVer: true,
|
|
615
|
+
SemVerRange: true,
|
|
616
|
+
NetAddress: true,
|
|
617
|
+
DnsRecord: true,
|
|
618
|
+
};
|
|
619
|
+
/**
|
|
620
|
+
* The instance a stored value of this kind stands for, or `undefined` when the value isn't the map
|
|
621
|
+
* one is stored as, or holds what can't be rebuilt exactly. A real instance is never one: it carries
|
|
622
|
+
* its marker on its prototype, where the map carries it as its own.
|
|
623
|
+
*
|
|
624
|
+
* The instance carries every stored property its rebuild made no use of ({@link carrying}), so
|
|
625
|
+
* writing it again stores what was read. Where it still wouldn't (a property the rebuild dropped
|
|
626
|
+
* from inside the map), the value isn't rebuilt, and stays the map it always was. A named zone's
|
|
627
|
+
* map holding `resolvedId` is the exception, and the one: it's read as the zone it names, and
|
|
628
|
+
* written as 4.1.2 held it ({@link asWrittenAgain}).
|
|
629
|
+
*/
|
|
630
|
+
export const rebuildStored = (kind, value) => {
|
|
631
|
+
const rebuilt = REBUILDS[kind](value);
|
|
632
|
+
if (kind === "DateTime" || typeof rebuilt !== "object" || rebuilt === null || !isMap(value)) {
|
|
633
|
+
return rebuilt;
|
|
634
|
+
}
|
|
635
|
+
const stored = asWrittenAgain(kind, value);
|
|
636
|
+
const instance = carrying(rebuilt, stored);
|
|
637
|
+
return EXACT[kind] && !writesAs(instance, stored) ? undefined : instance;
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* One of Effect's declarations as a read takes it: its own parser decides on what's stored, exactly
|
|
641
|
+
* as it always did, and what it takes is returned as the instance it stands for. Where that can't be
|
|
642
|
+
* rebuilt exactly, it's returned as the parser returned it. A value the parser refuses is refused as
|
|
643
|
+
* it was. The declaration's checks, and everything holding it, see what's returned.
|
|
644
|
+
*
|
|
645
|
+
* Encoding goes through the declaration's own parser, untouched. Annotations, checks, context and
|
|
646
|
+
* the encoding chain are the declaration's: a transformation onto one runs its steps as it did, and
|
|
647
|
+
* only what its parser then returns is rebuilt. A step that made a real instance itself has made
|
|
648
|
+
* what's returned, the same object.
|
|
649
|
+
*/
|
|
650
|
+
export const readingDeclaration = (ast, kind) => {
|
|
651
|
+
const parse = ast.run;
|
|
652
|
+
const read = (typeParameters) => {
|
|
653
|
+
const parser = parse(typeParameters);
|
|
654
|
+
return (input, self, options) => Effect.map(parser(input, self, options), (parsed) => {
|
|
655
|
+
const rebuilt = attempt(() => rebuildStored(kind, parsed));
|
|
656
|
+
return rebuilt === undefined ? parsed : rebuilt;
|
|
657
|
+
});
|
|
658
|
+
};
|
|
659
|
+
READ_PARSERS.set(read, parse);
|
|
660
|
+
return new SchemaAST.Declaration(ast.typeParameters, read, ast.annotations, ast.checks, ast.encoding, ast.context, ast.encodingChecks, ast.encodingRun ?? parse);
|
|
661
|
+
};
|
|
662
|
+
//# sourceMappingURL=EffectInstances.js.map
|