@dxos/effect 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef
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/lib/browser/chunk-CGS2ULMK.mjs +11 -0
- package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +478 -303
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing.mjs +31 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +478 -303
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing.mjs +31 -0
- package/dist/lib/node-esm/testing.mjs.map +7 -0
- package/dist/types/src/Performance.d.ts +25 -0
- package/dist/types/src/Performance.d.ts.map +1 -0
- package/dist/types/src/RuntimeProvider.d.ts +21 -0
- package/dist/types/src/RuntimeProvider.d.ts.map +1 -0
- package/dist/types/src/ast.d.ts +42 -22
- package/dist/types/src/ast.d.ts.map +1 -1
- package/dist/types/src/async-task-tagging.d.ts +6 -0
- package/dist/types/src/async-task-tagging.d.ts.map +1 -0
- package/dist/types/src/atom-kvs.d.ts +19 -0
- package/dist/types/src/atom-kvs.d.ts.map +1 -0
- package/dist/types/src/context.d.ts +2 -1
- package/dist/types/src/context.d.ts.map +1 -1
- package/dist/types/src/dynamic-runtime.d.ts +56 -0
- package/dist/types/src/dynamic-runtime.d.ts.map +1 -0
- package/dist/types/src/dynamic-runtime.test.d.ts +2 -0
- package/dist/types/src/dynamic-runtime.test.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +15 -1
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +8 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/{jsonPath.d.ts → json-path.d.ts} +12 -4
- package/dist/types/src/json-path.d.ts.map +1 -0
- package/dist/types/src/json-path.test.d.ts +2 -0
- package/dist/types/src/json-path.test.d.ts.map +1 -0
- package/dist/types/src/otel.d.ts +5 -4
- package/dist/types/src/otel.d.ts.map +1 -1
- package/dist/types/src/resource.d.ts +6 -2
- package/dist/types/src/resource.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +5 -13
- package/dist/types/src/testing.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +8 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/src/url.d.ts +3 -1
- package/dist/types/src/url.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -14
- package/src/Performance.ts +45 -0
- package/src/RuntimeProvider.ts +35 -0
- package/src/ast.test.ts +37 -9
- package/src/ast.ts +136 -93
- package/src/async-task-tagging.ts +51 -0
- package/src/atom-kvs.ts +35 -0
- package/src/context.ts +2 -1
- package/src/dynamic-runtime.test.ts +465 -0
- package/src/dynamic-runtime.ts +195 -0
- package/src/errors.test.ts +1 -1
- package/src/errors.ts +77 -11
- package/src/index.ts +8 -3
- package/src/interrupt.test.ts +6 -2
- package/src/{jsonPath.test.ts → json-path.test.ts} +47 -8
- package/src/{jsonPath.ts → json-path.ts} +29 -4
- package/src/layers.test.ts +9 -3
- package/src/otel.test.ts +3 -1
- package/src/otel.ts +9 -5
- package/src/resource.test.ts +3 -3
- package/src/resource.ts +10 -5
- package/src/sanity.test.ts +30 -15
- package/src/testing.ts +5 -28
- package/src/types.ts +11 -0
- package/src/url.test.ts +1 -1
- package/src/url.ts +5 -2
- package/dist/types/src/jsonPath.d.ts.map +0 -1
- package/dist/types/src/jsonPath.test.d.ts +0 -2
- package/dist/types/src/jsonPath.test.d.ts.map +0 -1
|
@@ -1,70 +1,68 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
__export
|
|
4
|
+
} from "./chunk-CGS2ULMK.mjs";
|
|
2
5
|
|
|
3
6
|
// src/ast.ts
|
|
4
|
-
import
|
|
5
|
-
import
|
|
7
|
+
import * as Function from "effect/Function";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
6
11
|
import { invariant } from "@dxos/invariant";
|
|
7
12
|
import { isNonNullable } from "@dxos/util";
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
if (SchemaAST.isBooleanKeyword(node)) {
|
|
24
|
-
return "boolean";
|
|
25
|
-
}
|
|
26
|
-
if (SchemaAST.isEnums(node)) {
|
|
27
|
-
return "enum";
|
|
28
|
-
}
|
|
29
|
-
if (SchemaAST.isLiteral(node)) {
|
|
30
|
-
return "literal";
|
|
13
|
+
var reduceRefinements = (type, refinements = []) => {
|
|
14
|
+
if (SchemaAST.isRefinement(type)) {
|
|
15
|
+
const filter = type.filter;
|
|
16
|
+
const nextType = {
|
|
17
|
+
...type.from,
|
|
18
|
+
annotations: {
|
|
19
|
+
...type.from.annotations,
|
|
20
|
+
...type.annotations
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return reduceRefinements(nextType, [
|
|
24
|
+
...refinements,
|
|
25
|
+
filter
|
|
26
|
+
]);
|
|
31
27
|
}
|
|
28
|
+
return {
|
|
29
|
+
type,
|
|
30
|
+
refinements
|
|
31
|
+
};
|
|
32
32
|
};
|
|
33
|
-
var
|
|
34
|
-
(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
default: {
|
|
50
|
-
throw new Error(`Unsupported type for default value: ${type}`);
|
|
33
|
+
var getBaseType = (prop) => {
|
|
34
|
+
const encoded = SchemaAST.encodedBoundAST(prop.type);
|
|
35
|
+
const unwrapped = prop.isOptional && encoded._tag === "Union" ? encoded.types[0] : encoded;
|
|
36
|
+
return reduceRefinements(unwrapped);
|
|
37
|
+
};
|
|
38
|
+
var getProperties = (ast) => {
|
|
39
|
+
const properties = SchemaAST.getPropertySignatures(ast);
|
|
40
|
+
return properties.map((prop) => {
|
|
41
|
+
const { type, refinements } = getBaseType(prop);
|
|
42
|
+
const mergedType = prop.annotations && Reflect.ownKeys(prop.annotations).length > 0 ? {
|
|
43
|
+
...type,
|
|
44
|
+
annotations: {
|
|
45
|
+
...type.annotations,
|
|
46
|
+
...prop.annotations
|
|
51
47
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
} : type;
|
|
49
|
+
return {
|
|
50
|
+
type: mergedType,
|
|
51
|
+
refinements,
|
|
52
|
+
name: prop.name,
|
|
53
|
+
isOptional: prop.isOptional,
|
|
54
|
+
isReadonly: prop.isReadonly
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
};
|
|
55
58
|
var VisitResult = /* @__PURE__ */ (function(VisitResult2) {
|
|
56
59
|
VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
|
|
57
60
|
VisitResult2[VisitResult2["SKIP"] = 1] = "SKIP";
|
|
58
61
|
VisitResult2[VisitResult2["EXIT"] = 2] = "EXIT";
|
|
59
62
|
return VisitResult2;
|
|
60
63
|
})({});
|
|
61
|
-
var defaultTest = isSimpleType;
|
|
62
64
|
var visit = (node, testOrVisitor, visitor) => {
|
|
63
|
-
|
|
64
|
-
visitNode(node, defaultTest, testOrVisitor);
|
|
65
|
-
} else {
|
|
66
|
-
visitNode(node, testOrVisitor, visitor);
|
|
67
|
-
}
|
|
65
|
+
visitNode(node, testOrVisitor, visitor);
|
|
68
66
|
};
|
|
69
67
|
var visitNode = (node, test, visitor, path = [], depth = 0) => {
|
|
70
68
|
const $result = test?.(node, path, depth);
|
|
@@ -121,6 +119,12 @@ var findNode = (node, test) => {
|
|
|
121
119
|
return child;
|
|
122
120
|
}
|
|
123
121
|
}
|
|
122
|
+
for (const prop of getIndexSignatures(node)) {
|
|
123
|
+
const child = findNode(prop.type, test);
|
|
124
|
+
if (child) {
|
|
125
|
+
return child;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
124
128
|
} else if (SchemaAST.isTupleType(node)) {
|
|
125
129
|
for (const [_, element] of node.elements.entries()) {
|
|
126
130
|
const child = findNode(element.type, test);
|
|
@@ -146,15 +150,7 @@ var findProperty = (schema, path) => {
|
|
|
146
150
|
const getProp = (node, path2) => {
|
|
147
151
|
const [name, ...rest] = path2;
|
|
148
152
|
const typeNode = findNode(node, SchemaAST.isTypeLiteral);
|
|
149
|
-
invariant(typeNode
|
|
150
|
-
F: __dxlog_file,
|
|
151
|
-
L: 257,
|
|
152
|
-
S: void 0,
|
|
153
|
-
A: [
|
|
154
|
-
"typeNode",
|
|
155
|
-
""
|
|
156
|
-
]
|
|
157
|
-
});
|
|
153
|
+
invariant(typeNode);
|
|
158
154
|
for (const prop of SchemaAST.getPropertySignatures(typeNode)) {
|
|
159
155
|
if (prop.name === name) {
|
|
160
156
|
if (rest.length) {
|
|
@@ -168,21 +164,21 @@ var findProperty = (schema, path) => {
|
|
|
168
164
|
return getProp(schema.ast, path.split("."));
|
|
169
165
|
};
|
|
170
166
|
var defaultAnnotations = {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
};
|
|
176
|
-
var
|
|
177
|
-
const id = pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
178
|
-
const value = pipe(SchemaAST.getAnnotation(annotationId)(node), Option.getOrUndefined);
|
|
167
|
+
ObjectKeyword: SchemaAST.objectKeyword,
|
|
168
|
+
StringKeyword: SchemaAST.stringKeyword,
|
|
169
|
+
NumberKeyword: SchemaAST.numberKeyword,
|
|
170
|
+
BooleanKeyword: SchemaAST.booleanKeyword
|
|
171
|
+
};
|
|
172
|
+
var getAnnotation2 = (annotationId, noDefault = true) => (node) => {
|
|
173
|
+
const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);
|
|
174
|
+
const value = Function.pipe(SchemaAST.getAnnotation(annotationId)(node), Option.getOrUndefined);
|
|
179
175
|
if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {
|
|
180
176
|
return void 0;
|
|
181
177
|
}
|
|
182
178
|
return value;
|
|
183
179
|
};
|
|
184
180
|
var findAnnotation = (node, annotationId, noDefault = true) => {
|
|
185
|
-
const getAnnotationById =
|
|
181
|
+
const getAnnotationById = getAnnotation2(annotationId, noDefault);
|
|
186
182
|
const getBaseAnnotation = (node2) => {
|
|
187
183
|
const value = getAnnotationById(node2);
|
|
188
184
|
if (value !== void 0) {
|
|
@@ -202,19 +198,26 @@ var isOption = (node) => {
|
|
|
202
198
|
var isLiteralUnion = (node) => {
|
|
203
199
|
return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);
|
|
204
200
|
};
|
|
201
|
+
var getLiteralValues = (schema) => {
|
|
202
|
+
if (!isLiteralUnion(schema.ast)) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
return schema.ast.types.map((node) => node.literal);
|
|
206
|
+
};
|
|
207
|
+
var isArrayType = (node) => {
|
|
208
|
+
return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;
|
|
209
|
+
};
|
|
210
|
+
var getArrayElementType = (node) => {
|
|
211
|
+
return isArrayType(node) ? node.rest.at(0)?.type : void 0;
|
|
212
|
+
};
|
|
213
|
+
var isTupleType2 = (node) => {
|
|
214
|
+
return SchemaAST.isTupleType(node) && node.elements.length > 0;
|
|
215
|
+
};
|
|
205
216
|
var isDiscriminatedUnion = (node) => {
|
|
206
217
|
return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
|
|
207
218
|
};
|
|
208
219
|
var getDiscriminatingProps = (node) => {
|
|
209
|
-
invariant(SchemaAST.isUnion(node)
|
|
210
|
-
F: __dxlog_file,
|
|
211
|
-
L: 354,
|
|
212
|
-
S: void 0,
|
|
213
|
-
A: [
|
|
214
|
-
"SchemaAST.isUnion(node)",
|
|
215
|
-
""
|
|
216
|
-
]
|
|
217
|
-
});
|
|
220
|
+
invariant(SchemaAST.isUnion(node));
|
|
218
221
|
if (isOption(node)) {
|
|
219
222
|
return;
|
|
220
223
|
}
|
|
@@ -224,39 +227,15 @@ var getDiscriminatingProps = (node) => {
|
|
|
224
227
|
}, []);
|
|
225
228
|
};
|
|
226
229
|
var getDiscriminatedType = (node, value = {}) => {
|
|
227
|
-
invariant(SchemaAST.isUnion(node)
|
|
228
|
-
|
|
229
|
-
L: 378,
|
|
230
|
-
S: void 0,
|
|
231
|
-
A: [
|
|
232
|
-
"SchemaAST.isUnion(node)",
|
|
233
|
-
""
|
|
234
|
-
]
|
|
235
|
-
});
|
|
236
|
-
invariant(value, void 0, {
|
|
237
|
-
F: __dxlog_file,
|
|
238
|
-
L: 379,
|
|
239
|
-
S: void 0,
|
|
240
|
-
A: [
|
|
241
|
-
"value",
|
|
242
|
-
""
|
|
243
|
-
]
|
|
244
|
-
});
|
|
230
|
+
invariant(SchemaAST.isUnion(node));
|
|
231
|
+
invariant(value);
|
|
245
232
|
const props = getDiscriminatingProps(node);
|
|
246
233
|
if (!props?.length) {
|
|
247
234
|
return;
|
|
248
235
|
}
|
|
249
236
|
for (const type of node.types) {
|
|
250
237
|
const match = SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
|
|
251
|
-
invariant(SchemaAST.isLiteral(prop.type)
|
|
252
|
-
F: __dxlog_file,
|
|
253
|
-
L: 390,
|
|
254
|
-
S: void 0,
|
|
255
|
-
A: [
|
|
256
|
-
"SchemaAST.isLiteral(prop.type)",
|
|
257
|
-
""
|
|
258
|
-
]
|
|
259
|
-
});
|
|
238
|
+
invariant(SchemaAST.isLiteral(prop.type));
|
|
260
239
|
return prop.type.literal === value[prop.name.toString()];
|
|
261
240
|
});
|
|
262
241
|
if (match) {
|
|
@@ -266,15 +245,7 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
266
245
|
const fields = Object.fromEntries(props.map((prop) => {
|
|
267
246
|
const literals = node.types.map((type) => {
|
|
268
247
|
const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
|
|
269
|
-
invariant(SchemaAST.isLiteral(literal.type)
|
|
270
|
-
F: __dxlog_file,
|
|
271
|
-
L: 408,
|
|
272
|
-
S: void 0,
|
|
273
|
-
A: [
|
|
274
|
-
"SchemaAST.isLiteral(literal.type)",
|
|
275
|
-
""
|
|
276
|
-
]
|
|
277
|
-
});
|
|
248
|
+
invariant(SchemaAST.isLiteral(literal.type));
|
|
278
249
|
return literal.type.literal;
|
|
279
250
|
}).filter(isNonNullable);
|
|
280
251
|
return literals.length ? [
|
|
@@ -285,10 +256,14 @@ var getDiscriminatedType = (node, value = {}) => {
|
|
|
285
256
|
const schema = Schema.Struct(fields);
|
|
286
257
|
return schema.ast;
|
|
287
258
|
};
|
|
259
|
+
var isNestedType = (node) => {
|
|
260
|
+
return SchemaAST.isDeclaration(node) || SchemaAST.isObjectKeyword(node) || SchemaAST.isTypeLiteral(node) || // TODO(wittjosiah): Tuples are actually arrays.
|
|
261
|
+
isTupleType2(node) || isDiscriminatedUnion(node);
|
|
262
|
+
};
|
|
288
263
|
var mapAst = (ast, f) => {
|
|
289
264
|
switch (ast._tag) {
|
|
290
265
|
case "TypeLiteral": {
|
|
291
|
-
return new SchemaAST.TypeLiteral(ast.propertySignatures.map((prop) => new SchemaAST.PropertySignature(prop.name, f(prop.type, prop.name), prop.isOptional, prop.isReadonly, prop.annotations)), ast.indexSignatures);
|
|
266
|
+
return new SchemaAST.TypeLiteral(ast.propertySignatures.map((prop) => new SchemaAST.PropertySignature(prop.name, f(prop.type, prop.name), prop.isOptional, prop.isReadonly, prop.annotations)), ast.indexSignatures, ast.annotations);
|
|
292
267
|
}
|
|
293
268
|
case "Union": {
|
|
294
269
|
return SchemaAST.Union.make(ast.types.map(f), ast.annotations);
|
|
@@ -305,165 +280,75 @@ var mapAst = (ast, f) => {
|
|
|
305
280
|
}
|
|
306
281
|
}
|
|
307
282
|
};
|
|
308
|
-
var
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// src/jsonPath.ts
|
|
314
|
-
import { Option as Option2, Schema as Schema2 } from "effect";
|
|
315
|
-
import { JSONPath } from "jsonpath-plus";
|
|
316
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
317
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/effect/src/jsonPath.ts";
|
|
318
|
-
var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
|
|
319
|
-
var PROP_REGEX = /^\w+$/;
|
|
320
|
-
var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
|
|
321
|
-
title: "JSON path",
|
|
322
|
-
description: "JSON path to a property"
|
|
323
|
-
});
|
|
324
|
-
var JsonProp = Schema2.NonEmptyString.pipe(Schema2.pattern(PROP_REGEX, {
|
|
325
|
-
message: () => "Property name must contain only letters, numbers, and underscores"
|
|
326
|
-
}));
|
|
327
|
-
var isJsonPath = (value) => {
|
|
328
|
-
return Option2.isSome(Schema2.validateOption(JsonPath)(value));
|
|
329
|
-
};
|
|
330
|
-
var createJsonPath = (path) => {
|
|
331
|
-
const candidatePath = path.map((p, i) => {
|
|
332
|
-
if (typeof p === "number") {
|
|
333
|
-
return `[${p}]`;
|
|
334
|
-
} else {
|
|
335
|
-
return i === 0 ? p : `.${p}`;
|
|
336
|
-
}
|
|
337
|
-
}).join("");
|
|
338
|
-
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
|
|
339
|
-
F: __dxlog_file2,
|
|
340
|
-
L: 63,
|
|
341
|
-
S: void 0,
|
|
342
|
-
A: [
|
|
343
|
-
"isJsonPath(candidatePath)",
|
|
344
|
-
"`Invalid JsonPath: ${candidatePath}`"
|
|
345
|
-
]
|
|
346
|
-
});
|
|
347
|
-
return candidatePath;
|
|
348
|
-
};
|
|
349
|
-
var fromEffectValidationPath = (effectPath) => {
|
|
350
|
-
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
351
|
-
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
|
|
352
|
-
F: __dxlog_file2,
|
|
353
|
-
L: 74,
|
|
354
|
-
S: void 0,
|
|
355
|
-
A: [
|
|
356
|
-
"isJsonPath(jsonPath)",
|
|
357
|
-
"`Invalid JsonPath: ${jsonPath}`"
|
|
358
|
-
]
|
|
359
|
-
});
|
|
360
|
-
return jsonPath;
|
|
361
|
-
};
|
|
362
|
-
var splitJsonPath = (path) => {
|
|
363
|
-
if (!isJsonPath(path)) {
|
|
364
|
-
return [];
|
|
283
|
+
var getIndexSignatures = (ast) => {
|
|
284
|
+
const annotation = SchemaAST.getSurrogateAnnotation(ast);
|
|
285
|
+
if (Option.isSome(annotation)) {
|
|
286
|
+
return getIndexSignatures(annotation.value);
|
|
365
287
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
288
|
+
switch (ast._tag) {
|
|
289
|
+
case "TypeLiteral":
|
|
290
|
+
return ast.indexSignatures.slice();
|
|
291
|
+
case "Suspend":
|
|
292
|
+
return getIndexSignatures(ast.f());
|
|
293
|
+
case "Refinement":
|
|
294
|
+
return getIndexSignatures(ast.from);
|
|
295
|
+
}
|
|
296
|
+
return [];
|
|
373
297
|
};
|
|
374
298
|
|
|
375
|
-
// src/
|
|
376
|
-
import {
|
|
377
|
-
import
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
obj[key] = value;
|
|
388
|
-
}
|
|
389
|
-
return obj;
|
|
390
|
-
}
|
|
391
|
-
var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
392
|
-
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
393
|
-
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
394
|
-
[ParamKeyAnnotationId]: value
|
|
395
|
-
});
|
|
396
|
-
var UrlParser = class {
|
|
397
|
-
/**
|
|
398
|
-
* Parse URL params.
|
|
399
|
-
*/
|
|
400
|
-
parse(_url) {
|
|
401
|
-
const url = new URL(_url);
|
|
402
|
-
return Object.entries(this._schema.fields).reduce((params, [key, type]) => {
|
|
403
|
-
let value = url.searchParams.get(decamelize(key));
|
|
404
|
-
if (value == null) {
|
|
405
|
-
value = url.searchParams.get(key);
|
|
406
|
-
}
|
|
407
|
-
if (value != null) {
|
|
408
|
-
if (SchemaAST2.isNumberKeyword(type.ast)) {
|
|
409
|
-
params[key] = parseInt(value);
|
|
410
|
-
} else if (SchemaAST2.isBooleanKeyword(type.ast)) {
|
|
411
|
-
params[key] = value === "true" || value === "1";
|
|
412
|
-
} else {
|
|
413
|
-
params[key] = value;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
return params;
|
|
417
|
-
}, {});
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Return URL with encoded params.
|
|
421
|
-
*/
|
|
422
|
-
create(_url, params) {
|
|
423
|
-
const url = new URL(_url);
|
|
424
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
425
|
-
if (value !== void 0) {
|
|
426
|
-
const field = this._schema.fields[key];
|
|
427
|
-
if (field) {
|
|
428
|
-
const { key: serializedKey } = pipe2(getParamKeyAnnotation(field.ast), Option3.getOrElse(() => ({
|
|
429
|
-
key: decamelize(key)
|
|
430
|
-
})));
|
|
431
|
-
url.searchParams.set(serializedKey, String(value));
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
return url;
|
|
436
|
-
}
|
|
437
|
-
constructor(_schema) {
|
|
438
|
-
_define_property(this, "_schema", void 0);
|
|
439
|
-
this._schema = _schema;
|
|
440
|
-
}
|
|
299
|
+
// src/atom-kvs.ts
|
|
300
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
301
|
+
import * as BrowserKeyValueStore from "@effect/platform-browser/BrowserKeyValueStore";
|
|
302
|
+
var defaultRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);
|
|
303
|
+
var createKvsStore = (options) => {
|
|
304
|
+
const runtime2 = options.runtime ?? defaultRuntime;
|
|
305
|
+
return Atom.kvs({
|
|
306
|
+
runtime: runtime2,
|
|
307
|
+
key: options.key,
|
|
308
|
+
schema: options.schema,
|
|
309
|
+
defaultValue: options.defaultValue
|
|
310
|
+
}).pipe(Atom.keepAlive);
|
|
441
311
|
};
|
|
442
312
|
|
|
443
313
|
// src/context.ts
|
|
444
|
-
import
|
|
314
|
+
import * as Effect from "effect/Effect";
|
|
445
315
|
import { Context } from "@dxos/context";
|
|
446
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/effect/src/context.ts";
|
|
447
316
|
var contextFromScope = () => Effect.gen(function* () {
|
|
448
|
-
const ctx = new Context(
|
|
449
|
-
F: __dxlog_file3,
|
|
450
|
-
L: 12
|
|
451
|
-
});
|
|
317
|
+
const ctx = new Context();
|
|
452
318
|
yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));
|
|
453
319
|
return ctx;
|
|
454
320
|
});
|
|
455
321
|
|
|
322
|
+
// src/dynamic-runtime.ts
|
|
323
|
+
var dynamic_runtime_exports = {};
|
|
324
|
+
__export(dynamic_runtime_exports, {
|
|
325
|
+
make: () => make
|
|
326
|
+
});
|
|
327
|
+
import * as Context2 from "effect/Context";
|
|
328
|
+
import * as Effect3 from "effect/Effect";
|
|
329
|
+
import * as Exit2 from "effect/Exit";
|
|
330
|
+
import * as Option3 from "effect/Option";
|
|
331
|
+
import * as Runtime2 from "effect/Runtime";
|
|
332
|
+
|
|
456
333
|
// src/errors.ts
|
|
457
|
-
import
|
|
458
|
-
|
|
459
|
-
|
|
334
|
+
import * as Cause from "effect/Cause";
|
|
335
|
+
import * as Chunk from "effect/Chunk";
|
|
336
|
+
import * as Effect2 from "effect/Effect";
|
|
337
|
+
import * as Exit from "effect/Exit";
|
|
338
|
+
import * as GlobalValue from "effect/GlobalValue";
|
|
339
|
+
import * as Option2 from "effect/Option";
|
|
340
|
+
import * as Runtime from "effect/Runtime";
|
|
341
|
+
var spanSymbol = /* @__PURE__ */ Symbol.for("effect/SpanAnnotation");
|
|
460
342
|
var spanToTrace = GlobalValue.globalValue("effect/Tracer/spanToTrace", () => /* @__PURE__ */ new WeakMap());
|
|
461
343
|
var locationRegex = /\((.*)\)/g;
|
|
462
344
|
var prettyErrorStack = (error, appendStacks = []) => {
|
|
345
|
+
if (typeof error !== "object" || error === null) {
|
|
346
|
+
return error;
|
|
347
|
+
}
|
|
463
348
|
const span = error[spanSymbol];
|
|
464
349
|
const lines = typeof error.stack === "string" ? error.stack.split("\n") : [];
|
|
465
350
|
const out = [];
|
|
466
|
-
let atStack = false;
|
|
351
|
+
let atStack = false, inCore = false, passedScheduler = false;
|
|
467
352
|
for (let i = 0; i < lines.length; i++) {
|
|
468
353
|
if (!atStack && !lines[i].startsWith(" at ")) {
|
|
469
354
|
out.push(lines[i]);
|
|
@@ -480,6 +365,26 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
480
365
|
if (lines[i].includes("effect_internal_function")) {
|
|
481
366
|
break;
|
|
482
367
|
}
|
|
368
|
+
const filename = lines[i].match(/\/([a-zA-Z0-9_\-.]+):\d+:\d+\)$/)?.[1];
|
|
369
|
+
if (!inCore && [
|
|
370
|
+
"core-effect.ts"
|
|
371
|
+
].includes(filename)) {
|
|
372
|
+
inCore = true;
|
|
373
|
+
}
|
|
374
|
+
if (inCore && !passedScheduler && [
|
|
375
|
+
"Scheduler.ts"
|
|
376
|
+
].includes(filename)) {
|
|
377
|
+
passedScheduler = true;
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (passedScheduler && ![
|
|
381
|
+
"Scheduler.ts"
|
|
382
|
+
].includes(filename)) {
|
|
383
|
+
inCore = false;
|
|
384
|
+
}
|
|
385
|
+
if (inCore) {
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
483
388
|
out.push(lines[i].replace(/at .*effect_instruction_i.*\((.*)\)/, "at $1").replace(/EffectPrimitive\.\w+/, "<anonymous>").replace(/at Arguments\./, "at "));
|
|
484
389
|
}
|
|
485
390
|
if (span) {
|
|
@@ -505,14 +410,12 @@ var prettyErrorStack = (error, appendStacks = []) => {
|
|
|
505
410
|
} else {
|
|
506
411
|
out.push(` at ${current.name}`);
|
|
507
412
|
}
|
|
508
|
-
current =
|
|
413
|
+
current = Option2.getOrUndefined(current.parent);
|
|
509
414
|
i++;
|
|
510
415
|
}
|
|
511
416
|
}
|
|
512
417
|
out.push(...appendStacks);
|
|
513
|
-
|
|
514
|
-
error = error[originalSymbol];
|
|
515
|
-
}
|
|
418
|
+
error = Cause.originalError(error);
|
|
516
419
|
if (error.cause) {
|
|
517
420
|
error.cause = prettyErrorStack(error.cause);
|
|
518
421
|
}
|
|
@@ -535,8 +438,8 @@ var causeToError = (cause) => {
|
|
|
535
438
|
...Chunk.toArray(Cause.defects(cause))
|
|
536
439
|
];
|
|
537
440
|
const getStackFrames = () => {
|
|
538
|
-
const o =
|
|
539
|
-
Error.captureStackTrace(o,
|
|
441
|
+
const o = new Error();
|
|
442
|
+
Error.captureStackTrace(o, causeToError);
|
|
540
443
|
return o.stack.split("\n").slice(1);
|
|
541
444
|
};
|
|
542
445
|
const stackFrames = getStackFrames();
|
|
@@ -551,15 +454,30 @@ var causeToError = (cause) => {
|
|
|
551
454
|
var throwCause = (cause) => {
|
|
552
455
|
throw causeToError(cause);
|
|
553
456
|
};
|
|
554
|
-
var unwrapExit = (
|
|
555
|
-
if (Exit.isSuccess(
|
|
556
|
-
return
|
|
457
|
+
var unwrapExit = (exit2) => {
|
|
458
|
+
if (Exit.isSuccess(exit2)) {
|
|
459
|
+
return exit2.value;
|
|
557
460
|
}
|
|
558
|
-
return throwCause(
|
|
461
|
+
return throwCause(exit2.cause);
|
|
559
462
|
};
|
|
560
463
|
var runAndForwardErrors = async (effect, options) => {
|
|
561
|
-
const
|
|
562
|
-
return unwrapExit(
|
|
464
|
+
const exit2 = await Effect2.runPromiseExit(effect, options);
|
|
465
|
+
return unwrapExit(exit2);
|
|
466
|
+
};
|
|
467
|
+
var runInRuntime = (...args) => {
|
|
468
|
+
if (args.length === 1) {
|
|
469
|
+
const [runtime2] = args;
|
|
470
|
+
return async (effect, options) => {
|
|
471
|
+
const exit2 = await Runtime.runPromiseExit(runtime2, effect, options);
|
|
472
|
+
return unwrapExit(exit2);
|
|
473
|
+
};
|
|
474
|
+
} else {
|
|
475
|
+
const [runtime2, effect, options] = args;
|
|
476
|
+
return (async () => {
|
|
477
|
+
const exit2 = await Runtime.runPromiseExit(runtime2, effect, options);
|
|
478
|
+
return unwrapExit(exit2);
|
|
479
|
+
})();
|
|
480
|
+
}
|
|
563
481
|
};
|
|
564
482
|
var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
565
483
|
try {
|
|
@@ -570,81 +488,338 @@ var promiseWithCauseCapture = (evaluate) => Effect2.promise(async (signal) => {
|
|
|
570
488
|
}
|
|
571
489
|
}).pipe(Effect2.flatten);
|
|
572
490
|
|
|
573
|
-
// src/
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
return yield* effect;
|
|
491
|
+
// src/dynamic-runtime.ts
|
|
492
|
+
var validateTags = (context, tags) => Effect3.gen(function* () {
|
|
493
|
+
const missingTags = [];
|
|
494
|
+
for (const tag of tags) {
|
|
495
|
+
const option = Context2.getOption(context, tag);
|
|
496
|
+
if (Option3.isNone(option)) {
|
|
497
|
+
missingTags.push(tag.key);
|
|
581
498
|
}
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
499
|
+
}
|
|
500
|
+
if (missingTags.length > 0) {
|
|
501
|
+
return yield* Effect3.die(new Error(`Missing required tags in runtime: ${missingTags.join(", ")}`));
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
function make(managedRuntime, tags) {
|
|
505
|
+
const managedRuntimeAny = managedRuntime;
|
|
506
|
+
let cachedRuntime;
|
|
507
|
+
let validatedRuntimePromise;
|
|
508
|
+
const getValidatedRuntimeAsync = async () => {
|
|
509
|
+
if (!validatedRuntimePromise) {
|
|
510
|
+
validatedRuntimePromise = managedRuntimeAny.runPromise(Effect3.gen(function* () {
|
|
511
|
+
const rt = yield* managedRuntimeAny.runtimeEffect;
|
|
512
|
+
yield* validateTags(rt.context, tags);
|
|
513
|
+
return rt;
|
|
514
|
+
}));
|
|
588
515
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
516
|
+
return validatedRuntimePromise;
|
|
517
|
+
};
|
|
518
|
+
const getValidatedRuntime = () => {
|
|
519
|
+
const validationExit = managedRuntimeAny.runSyncExit(Effect3.gen(function* () {
|
|
520
|
+
const rt = yield* managedRuntimeAny.runtimeEffect;
|
|
521
|
+
yield* validateTags(rt.context, tags);
|
|
522
|
+
return rt;
|
|
523
|
+
}));
|
|
524
|
+
return unwrapExit(validationExit);
|
|
525
|
+
};
|
|
526
|
+
return {
|
|
527
|
+
managedRuntime: managedRuntimeAny,
|
|
528
|
+
runPromise: async (effect) => {
|
|
529
|
+
const runtime2 = await getValidatedRuntimeAsync();
|
|
530
|
+
return Runtime2.runPromise(runtime2)(effect);
|
|
531
|
+
},
|
|
532
|
+
runSync: (effect) => {
|
|
533
|
+
const runtime2 = getValidatedRuntime();
|
|
534
|
+
return Runtime2.runSync(runtime2)(effect);
|
|
535
|
+
},
|
|
536
|
+
runSyncExit: (effect) => {
|
|
537
|
+
const validationExit = managedRuntimeAny.runSyncExit(Effect3.gen(function* () {
|
|
538
|
+
const rt = yield* managedRuntimeAny.runtimeEffect;
|
|
539
|
+
yield* validateTags(rt.context, tags);
|
|
540
|
+
return rt;
|
|
541
|
+
}));
|
|
542
|
+
if (Exit2.isSuccess(validationExit)) {
|
|
543
|
+
const runtime2 = validationExit.value;
|
|
544
|
+
return Runtime2.runSyncExit(runtime2)(effect);
|
|
545
|
+
}
|
|
546
|
+
return validationExit;
|
|
547
|
+
},
|
|
548
|
+
runPromiseExit: async (effect) => {
|
|
549
|
+
try {
|
|
550
|
+
const runtime2 = await getValidatedRuntimeAsync();
|
|
551
|
+
return Runtime2.runPromiseExit(runtime2)(effect);
|
|
552
|
+
} catch (error) {
|
|
553
|
+
return Exit2.die(error);
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
runFork: (effect) => {
|
|
557
|
+
const runtime2 = getValidatedRuntime();
|
|
558
|
+
return Runtime2.runFork(runtime2)(effect);
|
|
559
|
+
},
|
|
560
|
+
runtimeEffect: Effect3.gen(function* () {
|
|
561
|
+
if (cachedRuntime) {
|
|
562
|
+
return cachedRuntime;
|
|
563
|
+
}
|
|
564
|
+
const rt = yield* managedRuntimeAny.runtimeEffect;
|
|
565
|
+
yield* validateTags(rt.context, tags);
|
|
566
|
+
const runtime2 = rt;
|
|
567
|
+
cachedRuntime = runtime2;
|
|
568
|
+
return runtime2;
|
|
569
|
+
}).pipe(Effect3.catchAll(() => (
|
|
570
|
+
// This should never happen since validateTags uses Effect.die
|
|
571
|
+
Effect3.die(new Error("Unexpected error in runtimeEffect validation"))
|
|
572
|
+
))),
|
|
573
|
+
dispose: async () => {
|
|
574
|
+
await managedRuntimeAny.dispose();
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/json-path.ts
|
|
580
|
+
import * as Option4 from "effect/Option";
|
|
581
|
+
import * as Schema2 from "effect/Schema";
|
|
582
|
+
import { JSONPath } from "jsonpath-plus";
|
|
583
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
584
|
+
import { getDeep, setDeep } from "@dxos/util";
|
|
585
|
+
var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
|
|
586
|
+
var PROP_REGEX = /^\w+$/;
|
|
587
|
+
var JsonPath = Schema2.String.pipe(Schema2.pattern(PATH_REGEX)).annotations({
|
|
588
|
+
title: "JSON path",
|
|
589
|
+
description: "JSON path to a property"
|
|
590
|
+
});
|
|
591
|
+
var JsonProp = Schema2.NonEmptyString.pipe(Schema2.pattern(PROP_REGEX, {
|
|
592
|
+
message: () => "Property name must contain only letters, numbers, and underscores"
|
|
593
|
+
}));
|
|
594
|
+
var isJsonPath = (value) => {
|
|
595
|
+
return Option4.isSome(Schema2.validateOption(JsonPath)(value));
|
|
596
|
+
};
|
|
597
|
+
var createJsonPath = (path) => {
|
|
598
|
+
const candidatePath = path.map((p, i) => {
|
|
599
|
+
if (typeof p === "number") {
|
|
600
|
+
return `[${p}]`;
|
|
593
601
|
} else {
|
|
594
|
-
return
|
|
602
|
+
return i === 0 ? p : `.${p}`;
|
|
595
603
|
}
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
604
|
+
}).join("");
|
|
605
|
+
invariant2(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);
|
|
606
|
+
return candidatePath;
|
|
607
|
+
};
|
|
608
|
+
var fromEffectValidationPath = (effectPath) => {
|
|
609
|
+
const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
|
|
610
|
+
invariant2(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);
|
|
611
|
+
return jsonPath;
|
|
612
|
+
};
|
|
613
|
+
var splitJsonPath = (path) => {
|
|
614
|
+
if (!isJsonPath(path)) {
|
|
615
|
+
return [];
|
|
616
|
+
}
|
|
617
|
+
return path.match(/[a-zA-Z_$][\w$]*|\[\d+\]/g)?.map((part) => part.replace(/[[\]]/g, "")).map((part) => {
|
|
618
|
+
const parsed = Number.parseInt(part, 10);
|
|
619
|
+
return Number.isNaN(parsed) ? part : parsed;
|
|
620
|
+
}) ?? [];
|
|
621
|
+
};
|
|
622
|
+
var getField = (object, path) => {
|
|
623
|
+
return JSONPath({
|
|
624
|
+
path,
|
|
625
|
+
json: object
|
|
626
|
+
})[0];
|
|
627
|
+
};
|
|
628
|
+
var getValue = (obj, path) => {
|
|
629
|
+
return getDeep(obj, splitJsonPath(path));
|
|
630
|
+
};
|
|
631
|
+
var setValue = (obj, path, value) => {
|
|
632
|
+
return setDeep(obj, splitJsonPath(path), value);
|
|
600
633
|
};
|
|
601
|
-
var TestHelpers;
|
|
602
634
|
|
|
603
635
|
// src/resource.ts
|
|
604
|
-
import
|
|
605
|
-
var
|
|
636
|
+
import * as Effect4 from "effect/Effect";
|
|
637
|
+
var acquireReleaseResource = (getResource) => Effect4.acquireRelease(Effect4.gen(function* () {
|
|
606
638
|
const resource = getResource();
|
|
607
639
|
yield* Effect4.promise(async () => {
|
|
608
|
-
resource.open?.();
|
|
640
|
+
await resource.open?.();
|
|
609
641
|
return void 0;
|
|
610
642
|
});
|
|
611
643
|
return resource;
|
|
612
644
|
}), (resource) => Effect4.promise(async () => {
|
|
613
|
-
resource.close?.();
|
|
645
|
+
await resource.close?.();
|
|
614
646
|
return void 0;
|
|
615
647
|
}));
|
|
648
|
+
|
|
649
|
+
// src/url.ts
|
|
650
|
+
import * as Function2 from "effect/Function";
|
|
651
|
+
import * as Option5 from "effect/Option";
|
|
652
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
653
|
+
import { decamelize } from "@dxos/util";
|
|
654
|
+
var ParamKeyAnnotationId = /* @__PURE__ */ Symbol.for("@dxos/schema/annotation/ParamKey");
|
|
655
|
+
var getParamKeyAnnotation = SchemaAST2.getAnnotation(ParamKeyAnnotationId);
|
|
656
|
+
var ParamKeyAnnotation = (value) => (self) => self.annotations({
|
|
657
|
+
[ParamKeyAnnotationId]: value
|
|
658
|
+
});
|
|
659
|
+
var UrlParser = class {
|
|
660
|
+
_schema;
|
|
661
|
+
constructor(_schema) {
|
|
662
|
+
this._schema = _schema;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Parse URL params.
|
|
666
|
+
*/
|
|
667
|
+
parse(_url) {
|
|
668
|
+
const url = new URL(_url);
|
|
669
|
+
return Object.entries(this._schema.fields).reduce((params, [key, type]) => {
|
|
670
|
+
let value = url.searchParams.get(decamelize(key));
|
|
671
|
+
if (value == null) {
|
|
672
|
+
value = url.searchParams.get(key);
|
|
673
|
+
}
|
|
674
|
+
if (value != null) {
|
|
675
|
+
if (SchemaAST2.isNumberKeyword(type.ast)) {
|
|
676
|
+
params[key] = parseInt(value);
|
|
677
|
+
} else if (SchemaAST2.isBooleanKeyword(type.ast)) {
|
|
678
|
+
params[key] = value === "true" || value === "1";
|
|
679
|
+
} else {
|
|
680
|
+
params[key] = value;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return params;
|
|
684
|
+
}, {});
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Return URL with encoded params.
|
|
688
|
+
*/
|
|
689
|
+
create(_url, params) {
|
|
690
|
+
const url = new URL(_url);
|
|
691
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
692
|
+
if (value !== void 0) {
|
|
693
|
+
const field = this._schema.fields[key];
|
|
694
|
+
if (field) {
|
|
695
|
+
const { key: serializedKey } = Function2.pipe(getParamKeyAnnotation(field.ast), Option5.getOrElse(() => ({
|
|
696
|
+
key: decamelize(key)
|
|
697
|
+
})));
|
|
698
|
+
url.searchParams.set(serializedKey, String(value));
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
return url;
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
// src/RuntimeProvider.ts
|
|
707
|
+
var RuntimeProvider_exports = {};
|
|
708
|
+
__export(RuntimeProvider_exports, {
|
|
709
|
+
currentRuntime: () => currentRuntime,
|
|
710
|
+
provide: () => provide2,
|
|
711
|
+
runPromise: () => runPromise2
|
|
712
|
+
});
|
|
713
|
+
import * as Effect5 from "effect/Effect";
|
|
714
|
+
import * as Runtime3 from "effect/Runtime";
|
|
715
|
+
var currentRuntime = () => Effect5.runtime().pipe(Effect5.map(Effect5.succeed));
|
|
716
|
+
var runPromise2 = (provider) => async (effect) => {
|
|
717
|
+
const runtime2 = await runAndForwardErrors(provider);
|
|
718
|
+
return unwrapExit(await effect.pipe(Runtime3.runPromiseExit(runtime2)));
|
|
719
|
+
};
|
|
720
|
+
var provide2 = (runtimeProvider) => (effect) => Effect5.flatMap(runtimeProvider, (runtime2) => Effect5.provide(effect, runtime2));
|
|
721
|
+
|
|
722
|
+
// src/Performance.ts
|
|
723
|
+
var Performance_exports = {};
|
|
724
|
+
__export(Performance_exports, {
|
|
725
|
+
addTrackEntry: () => addTrackEntry
|
|
726
|
+
});
|
|
727
|
+
import * as Effect6 from "effect/Effect";
|
|
728
|
+
var addTrackEntry = (options) => (effect) => Effect6.gen(function* () {
|
|
729
|
+
const start = performance.now();
|
|
730
|
+
const exit2 = yield* Effect6.exit(effect);
|
|
731
|
+
const resolvedOptions = typeof options === "function" ? options(exit2) : options;
|
|
732
|
+
performance.measure(resolvedOptions.name, {
|
|
733
|
+
start,
|
|
734
|
+
detail: {
|
|
735
|
+
...resolvedOptions.detail,
|
|
736
|
+
devtools: resolvedOptions.devtools
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
return yield* exit2;
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
// src/async-task-tagging.ts
|
|
743
|
+
import * as Context3 from "effect/Context";
|
|
744
|
+
import * as Effect7 from "effect/Effect";
|
|
745
|
+
import { pipe as pipe3 } from "effect/Function";
|
|
746
|
+
import * as Layer from "effect/Layer";
|
|
747
|
+
import * as Predicate from "effect/Predicate";
|
|
748
|
+
import * as Tracer from "effect/Tracer";
|
|
749
|
+
var runInTask = /* @__PURE__ */ Symbol("runInTask");
|
|
750
|
+
var asyncTaskTaggingLayer = () => {
|
|
751
|
+
if (Predicate.hasProperty(console, "createTask") === false) {
|
|
752
|
+
return Layer.empty;
|
|
753
|
+
}
|
|
754
|
+
const makeTracer = Effect7.gen(function* () {
|
|
755
|
+
const oldTracer = yield* Effect7.tracer;
|
|
756
|
+
return Tracer.make({
|
|
757
|
+
span: (name, ...args) => {
|
|
758
|
+
const span = oldTracer.span(name, ...args);
|
|
759
|
+
const trace = console.createTask(name);
|
|
760
|
+
span[runInTask] = (f) => trace.run(f);
|
|
761
|
+
return span;
|
|
762
|
+
},
|
|
763
|
+
context: (f, fiber) => {
|
|
764
|
+
const maybeParentSpan = Context3.getOption(Tracer.ParentSpan)(fiber.currentContext);
|
|
765
|
+
if (maybeParentSpan._tag === "None") {
|
|
766
|
+
return oldTracer.context(f, fiber);
|
|
767
|
+
}
|
|
768
|
+
const parentSpan = maybeParentSpan.value;
|
|
769
|
+
if (parentSpan._tag === "ExternalSpan") {
|
|
770
|
+
return oldTracer.context(f, fiber);
|
|
771
|
+
}
|
|
772
|
+
const span = parentSpan;
|
|
773
|
+
if (runInTask in span && typeof span[runInTask] === "function") {
|
|
774
|
+
return span[runInTask](() => oldTracer.context(f, fiber));
|
|
775
|
+
}
|
|
776
|
+
return oldTracer.context(f, fiber);
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
return pipe3(makeTracer, Effect7.map(Layer.setTracer), Layer.unwrapEffect);
|
|
781
|
+
};
|
|
616
782
|
export {
|
|
783
|
+
dynamic_runtime_exports as DynamicRuntime,
|
|
617
784
|
JsonPath,
|
|
618
785
|
JsonProp,
|
|
619
786
|
ParamKeyAnnotation,
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
TestHelpers,
|
|
787
|
+
Performance_exports as Performance,
|
|
788
|
+
RuntimeProvider_exports as RuntimeProvider,
|
|
623
789
|
UrlParser,
|
|
624
790
|
VisitResult,
|
|
625
|
-
|
|
791
|
+
acquireReleaseResource,
|
|
792
|
+
asyncTaskTaggingLayer,
|
|
626
793
|
causeToError,
|
|
627
794
|
contextFromScope,
|
|
628
795
|
createJsonPath,
|
|
796
|
+
createKvsStore,
|
|
629
797
|
findAnnotation,
|
|
630
798
|
findNode,
|
|
631
799
|
findProperty,
|
|
632
800
|
fromEffectValidationPath,
|
|
633
|
-
getAnnotation,
|
|
801
|
+
getAnnotation2 as getAnnotation,
|
|
802
|
+
getArrayElementType,
|
|
803
|
+
getBaseType,
|
|
634
804
|
getDiscriminatedType,
|
|
635
805
|
getDiscriminatingProps,
|
|
636
806
|
getField,
|
|
807
|
+
getLiteralValues,
|
|
637
808
|
getParamKeyAnnotation,
|
|
638
|
-
|
|
809
|
+
getProperties,
|
|
810
|
+
getValue,
|
|
639
811
|
isArrayType,
|
|
640
812
|
isDiscriminatedUnion,
|
|
641
813
|
isJsonPath,
|
|
642
814
|
isLiteralUnion,
|
|
815
|
+
isNestedType,
|
|
643
816
|
isOption,
|
|
644
|
-
|
|
817
|
+
isTupleType2 as isTupleType,
|
|
645
818
|
mapAst,
|
|
646
819
|
promiseWithCauseCapture,
|
|
647
820
|
runAndForwardErrors,
|
|
821
|
+
runInRuntime,
|
|
822
|
+
setValue,
|
|
648
823
|
splitJsonPath,
|
|
649
824
|
throwCause,
|
|
650
825
|
unwrapExit,
|