@dxos/effect 0.8.3-staging.0fa589b → 0.8.4-main.84f28bd

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.
@@ -1,487 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var node_exports = {};
20
- __export(node_exports, {
21
- JsonPath: () => JsonPath,
22
- JsonProp: () => JsonProp,
23
- ParamKeyAnnotation: () => ParamKeyAnnotation,
24
- SimpleType: () => SimpleType,
25
- UrlParser: () => UrlParser,
26
- VisitResult: () => VisitResult,
27
- createJsonPath: () => createJsonPath,
28
- findAnnotation: () => findAnnotation,
29
- findNode: () => findNode,
30
- findProperty: () => findProperty,
31
- fromEffectValidationPath: () => fromEffectValidationPath,
32
- getAnnotation: () => getAnnotation,
33
- getDiscriminatedType: () => getDiscriminatedType,
34
- getDiscriminatingProps: () => getDiscriminatingProps,
35
- getField: () => getField,
36
- getParamKeyAnnotation: () => getParamKeyAnnotation,
37
- getSimpleType: () => getSimpleType,
38
- isDiscriminatedUnion: () => isDiscriminatedUnion,
39
- isJsonPath: () => isJsonPath,
40
- isLiteralUnion: () => isLiteralUnion,
41
- isOption: () => isOption,
42
- isSimpleType: () => isSimpleType,
43
- mapAst: () => mapAst,
44
- splitJsonPath: () => splitJsonPath,
45
- visit: () => visit
46
- });
47
- module.exports = __toCommonJS(node_exports);
48
- var import_effect = require("effect");
49
- var import_invariant = require("@dxos/invariant");
50
- var import_util = require("@dxos/util");
51
- var import_effect2 = require("effect");
52
- var import_jsonpath_plus = require("jsonpath-plus");
53
- var import_invariant2 = require("@dxos/invariant");
54
- var import_effect3 = require("effect");
55
- var import_util2 = require("@dxos/util");
56
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/effect/src/ast.ts";
57
- var getSimpleType = (node) => {
58
- if (import_effect.SchemaAST.isDeclaration(node) || import_effect.SchemaAST.isObjectKeyword(node) || import_effect.SchemaAST.isTypeLiteral(node) || isDiscriminatedUnion(node)) {
59
- return "object";
60
- }
61
- if (import_effect.SchemaAST.isStringKeyword(node)) {
62
- return "string";
63
- }
64
- if (import_effect.SchemaAST.isNumberKeyword(node)) {
65
- return "number";
66
- }
67
- if (import_effect.SchemaAST.isBooleanKeyword(node)) {
68
- return "boolean";
69
- }
70
- if (import_effect.SchemaAST.isEnums(node)) {
71
- return "enum";
72
- }
73
- if (import_effect.SchemaAST.isLiteral(node)) {
74
- return "literal";
75
- }
76
- };
77
- var isSimpleType = (node) => !!getSimpleType(node);
78
- (function(SimpleType2) {
79
- SimpleType2.getDefaultValue = (type) => {
80
- switch (type) {
81
- case "string": {
82
- return "";
83
- }
84
- case "number": {
85
- return 0;
86
- }
87
- case "boolean": {
88
- return false;
89
- }
90
- case "object": {
91
- return {};
92
- }
93
- default: {
94
- throw new Error(`Unsupported type for default value: ${type}`);
95
- }
96
- }
97
- };
98
- })(SimpleType || (SimpleType = {}));
99
- var VisitResult = /* @__PURE__ */ function(VisitResult2) {
100
- VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
101
- VisitResult2[VisitResult2["SKIP"] = 1] = "SKIP";
102
- VisitResult2[VisitResult2["EXIT"] = 2] = "EXIT";
103
- return VisitResult2;
104
- }({});
105
- var defaultTest = isSimpleType;
106
- var visit = (node, testOrVisitor, visitor) => {
107
- if (!visitor) {
108
- visitNode(node, defaultTest, testOrVisitor);
109
- } else {
110
- visitNode(node, testOrVisitor, visitor);
111
- }
112
- };
113
- var visitNode = (node, test, visitor, path = [], depth = 0) => {
114
- const _result = test?.(node, path, depth);
115
- const result = _result === void 0 ? 0 : typeof _result === "boolean" ? _result ? 0 : 1 : _result;
116
- if (result === 2) {
117
- return result;
118
- }
119
- if (result !== 1) {
120
- visitor(node, path, depth);
121
- }
122
- if (import_effect.SchemaAST.isTypeLiteral(node)) {
123
- for (const prop of import_effect.SchemaAST.getPropertySignatures(node)) {
124
- const currentPath = [
125
- ...path,
126
- prop.name.toString()
127
- ];
128
- const result2 = visitNode(prop.type, test, visitor, currentPath, depth + 1);
129
- if (result2 === 2) {
130
- return result2;
131
- }
132
- }
133
- } else if (import_effect.SchemaAST.isTupleType(node)) {
134
- for (const [i, element] of node.elements.entries()) {
135
- const currentPath = [
136
- ...path,
137
- i
138
- ];
139
- const result2 = visitNode(element.type, test, visitor, currentPath, depth);
140
- if (result2 === 2) {
141
- return result2;
142
- }
143
- }
144
- } else if (import_effect.SchemaAST.isUnion(node)) {
145
- for (const type of node.types) {
146
- const result2 = visitNode(type, test, visitor, path, depth);
147
- if (result2 === 2) {
148
- return result2;
149
- }
150
- }
151
- } else if (import_effect.SchemaAST.isRefinement(node)) {
152
- const result2 = visitNode(node.from, test, visitor, path, depth);
153
- if (result2 === 2) {
154
- return result2;
155
- }
156
- }
157
- };
158
- var findNode = (node, test) => {
159
- if (test(node)) {
160
- return node;
161
- } else if (import_effect.SchemaAST.isTypeLiteral(node)) {
162
- for (const prop of import_effect.SchemaAST.getPropertySignatures(node)) {
163
- const child = findNode(prop.type, test);
164
- if (child) {
165
- return child;
166
- }
167
- }
168
- } else if (import_effect.SchemaAST.isTupleType(node)) {
169
- for (const [_, element] of node.elements.entries()) {
170
- const child = findNode(element.type, test);
171
- if (child) {
172
- return child;
173
- }
174
- }
175
- } else if (import_effect.SchemaAST.isUnion(node)) {
176
- if (isOption(node)) {
177
- for (const type of node.types) {
178
- const child = findNode(type, test);
179
- if (child) {
180
- return child;
181
- }
182
- }
183
- }
184
- } else if (import_effect.SchemaAST.isRefinement(node)) {
185
- return findNode(node.from, test);
186
- }
187
- };
188
- var findProperty = (schema, path) => {
189
- const getProp = (node, path2) => {
190
- const [name, ...rest] = path2;
191
- const typeNode = findNode(node, import_effect.SchemaAST.isTypeLiteral);
192
- (0, import_invariant.invariant)(typeNode, void 0, {
193
- F: __dxlog_file,
194
- L: 246,
195
- S: void 0,
196
- A: [
197
- "typeNode",
198
- ""
199
- ]
200
- });
201
- for (const prop of import_effect.SchemaAST.getPropertySignatures(typeNode)) {
202
- if (prop.name === name) {
203
- if (rest.length) {
204
- return getProp(prop.type, rest);
205
- } else {
206
- return prop.type;
207
- }
208
- }
209
- }
210
- };
211
- return getProp(schema.ast, path.split("."));
212
- };
213
- var defaultAnnotations = {
214
- ["ObjectKeyword"]: import_effect.SchemaAST.objectKeyword,
215
- ["StringKeyword"]: import_effect.SchemaAST.stringKeyword,
216
- ["NumberKeyword"]: import_effect.SchemaAST.numberKeyword,
217
- ["BooleanKeyword"]: import_effect.SchemaAST.booleanKeyword
218
- };
219
- var getAnnotation = (annotationId, noDefault = true) => (node) => {
220
- const id = (0, import_effect.pipe)(import_effect.SchemaAST.getIdentifierAnnotation(node), import_effect.Option.getOrUndefined);
221
- const value = (0, import_effect.pipe)(import_effect.SchemaAST.getAnnotation(annotationId)(node), import_effect.Option.getOrUndefined);
222
- if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {
223
- return void 0;
224
- }
225
- return value;
226
- };
227
- var findAnnotation = (node, annotationId, noDefault = true) => {
228
- const getAnnotationById = getAnnotation(annotationId, noDefault);
229
- const getBaseAnnotation = (node2) => {
230
- const value = getAnnotationById(node2);
231
- if (value !== void 0) {
232
- return value;
233
- }
234
- if (import_effect.SchemaAST.isUnion(node2)) {
235
- if (isOption(node2)) {
236
- return getAnnotationById(node2.types[0]);
237
- }
238
- }
239
- };
240
- return getBaseAnnotation(node);
241
- };
242
- var isOption = (node) => {
243
- return import_effect.SchemaAST.isUnion(node) && node.types.length === 2 && import_effect.SchemaAST.isUndefinedKeyword(node.types[1]);
244
- };
245
- var isLiteralUnion = (node) => {
246
- return import_effect.SchemaAST.isUnion(node) && node.types.every(import_effect.SchemaAST.isLiteral);
247
- };
248
- var isDiscriminatedUnion = (node) => {
249
- return import_effect.SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
250
- };
251
- var getDiscriminatingProps = (node) => {
252
- (0, import_invariant.invariant)(import_effect.SchemaAST.isUnion(node), void 0, {
253
- F: __dxlog_file,
254
- L: 343,
255
- S: void 0,
256
- A: [
257
- "SchemaAST.isUnion(node)",
258
- ""
259
- ]
260
- });
261
- if (isOption(node)) {
262
- return;
263
- }
264
- return node.types.reduce((shared, type) => {
265
- const props = import_effect.SchemaAST.getPropertySignatures(type).filter((p) => import_effect.SchemaAST.isLiteral(p.type)).map((p) => p.name.toString());
266
- return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));
267
- }, []);
268
- };
269
- var getDiscriminatedType = (node, value = {}) => {
270
- (0, import_invariant.invariant)(import_effect.SchemaAST.isUnion(node), void 0, {
271
- F: __dxlog_file,
272
- L: 367,
273
- S: void 0,
274
- A: [
275
- "SchemaAST.isUnion(node)",
276
- ""
277
- ]
278
- });
279
- (0, import_invariant.invariant)(value, void 0, {
280
- F: __dxlog_file,
281
- L: 368,
282
- S: void 0,
283
- A: [
284
- "value",
285
- ""
286
- ]
287
- });
288
- const props = getDiscriminatingProps(node);
289
- if (!props?.length) {
290
- return;
291
- }
292
- for (const type of node.types) {
293
- const match = import_effect.SchemaAST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
294
- (0, import_invariant.invariant)(import_effect.SchemaAST.isLiteral(prop.type), void 0, {
295
- F: __dxlog_file,
296
- L: 379,
297
- S: void 0,
298
- A: [
299
- "SchemaAST.isLiteral(prop.type)",
300
- ""
301
- ]
302
- });
303
- return prop.type.literal === value[prop.name.toString()];
304
- });
305
- if (match) {
306
- return type;
307
- }
308
- }
309
- const fields = Object.fromEntries(props.map((prop) => {
310
- const literals = node.types.map((type) => {
311
- const literal = import_effect.SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
312
- (0, import_invariant.invariant)(import_effect.SchemaAST.isLiteral(literal.type), void 0, {
313
- F: __dxlog_file,
314
- L: 397,
315
- S: void 0,
316
- A: [
317
- "SchemaAST.isLiteral(literal.type)",
318
- ""
319
- ]
320
- });
321
- return literal.type.literal;
322
- }).filter(import_util.isNonNullable);
323
- return literals.length ? [
324
- prop,
325
- import_effect.Schema.Literal(...literals)
326
- ] : void 0;
327
- }).filter(import_util.isNonNullable));
328
- const schema = import_effect.Schema.Struct(fields);
329
- return schema.ast;
330
- };
331
- var mapAst = (ast, f) => {
332
- switch (ast._tag) {
333
- case "TypeLiteral": {
334
- return new import_effect.SchemaAST.TypeLiteral(ast.propertySignatures.map((prop) => new import_effect.SchemaAST.PropertySignature(prop.name, f(prop.type, prop.name), prop.isOptional, prop.isReadonly, prop.annotations)), ast.indexSignatures);
335
- }
336
- case "Union": {
337
- return import_effect.SchemaAST.Union.make(ast.types.map(f), ast.annotations);
338
- }
339
- case "TupleType": {
340
- return new import_effect.SchemaAST.TupleType(ast.elements.map((t, index) => new import_effect.SchemaAST.OptionalType(f(t.type, index), t.isOptional, t.annotations)), ast.rest.map((t) => new import_effect.SchemaAST.Type(f(t.type, void 0), t.annotations)), ast.isReadonly, ast.annotations);
341
- }
342
- case "Suspend": {
343
- const newAst = f(ast.f(), void 0);
344
- return new import_effect.SchemaAST.Suspend(() => newAst, ast.annotations);
345
- }
346
- default: {
347
- return ast;
348
- }
349
- }
350
- };
351
- var SimpleType;
352
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/effect/src/jsonPath.ts";
353
- var PATH_REGEX = /^($|[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*|\[\d+\](?:\.)?)*$)/;
354
- var PROP_REGEX = /^\w+$/;
355
- var JsonPath = import_effect2.Schema.String.pipe(import_effect2.Schema.pattern(PATH_REGEX)).annotations({
356
- title: "JSON path",
357
- description: "JSON path to a property"
358
- });
359
- var JsonProp = import_effect2.Schema.NonEmptyString.pipe(import_effect2.Schema.pattern(PROP_REGEX, {
360
- message: () => "Property name must contain only letters, numbers, and underscores"
361
- }));
362
- var isJsonPath = (value) => {
363
- return import_effect2.Option.isSome(import_effect2.Schema.validateOption(JsonPath)(value));
364
- };
365
- var createJsonPath = (path) => {
366
- const candidatePath = path.map((p, i) => {
367
- if (typeof p === "number") {
368
- return `[${p}]`;
369
- } else {
370
- return i === 0 ? p : `.${p}`;
371
- }
372
- }).join("");
373
- (0, import_invariant2.invariant)(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`, {
374
- F: __dxlog_file2,
375
- L: 63,
376
- S: void 0,
377
- A: [
378
- "isJsonPath(candidatePath)",
379
- "`Invalid JsonPath: ${candidatePath}`"
380
- ]
381
- });
382
- return candidatePath;
383
- };
384
- var fromEffectValidationPath = (effectPath) => {
385
- const jsonPath = effectPath.replace(/\.\[(\d+)\]/g, "[$1]");
386
- (0, import_invariant2.invariant)(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`, {
387
- F: __dxlog_file2,
388
- L: 74,
389
- S: void 0,
390
- A: [
391
- "isJsonPath(jsonPath)",
392
- "`Invalid JsonPath: ${jsonPath}`"
393
- ]
394
- });
395
- return jsonPath;
396
- };
397
- var splitJsonPath = (path) => {
398
- if (!isJsonPath(path)) {
399
- return [];
400
- }
401
- return path.match(/[a-zA-Z_$][\w$]*|\[\d+\]/g)?.map((part) => part.startsWith("[") ? part.replace(/[[\]]/g, "") : part) ?? [];
402
- };
403
- var getField = (object, path) => {
404
- return (0, import_jsonpath_plus.JSONPath)({
405
- path,
406
- json: object
407
- })[0];
408
- };
409
- var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
410
- var getParamKeyAnnotation = import_effect3.SchemaAST.getAnnotation(ParamKeyAnnotationId);
411
- var ParamKeyAnnotation = (value) => (self) => self.annotations({
412
- [ParamKeyAnnotationId]: value
413
- });
414
- var UrlParser = class {
415
- constructor(_schema) {
416
- this._schema = _schema;
417
- }
418
- /**
419
- * Parse URL params.
420
- */
421
- parse(_url) {
422
- const url = new URL(_url);
423
- return Object.entries(this._schema.fields).reduce((params, [key, type]) => {
424
- let value = url.searchParams.get((0, import_util2.decamelize)(key));
425
- if (value == null) {
426
- value = url.searchParams.get(key);
427
- }
428
- if (value != null) {
429
- if (import_effect3.SchemaAST.isNumberKeyword(type.ast)) {
430
- params[key] = parseInt(value);
431
- } else if (import_effect3.SchemaAST.isBooleanKeyword(type.ast)) {
432
- params[key] = value === "true" || value === "1";
433
- } else {
434
- params[key] = value;
435
- }
436
- }
437
- return params;
438
- }, {});
439
- }
440
- /**
441
- * Return URL with encoded params.
442
- */
443
- create(_url, params) {
444
- const url = new URL(_url);
445
- Object.entries(params).forEach(([key, value]) => {
446
- if (value !== void 0) {
447
- const field = this._schema.fields[key];
448
- if (field) {
449
- const { key: serializedKey } = (0, import_effect3.pipe)(getParamKeyAnnotation(field.ast), import_effect3.Option.getOrElse(() => ({
450
- key: (0, import_util2.decamelize)(key)
451
- })));
452
- url.searchParams.set(serializedKey, String(value));
453
- }
454
- }
455
- });
456
- return url;
457
- }
458
- };
459
- // Annotate the CommonJS export names for ESM import in node:
460
- 0 && (module.exports = {
461
- JsonPath,
462
- JsonProp,
463
- ParamKeyAnnotation,
464
- SimpleType,
465
- UrlParser,
466
- VisitResult,
467
- createJsonPath,
468
- findAnnotation,
469
- findNode,
470
- findProperty,
471
- fromEffectValidationPath,
472
- getAnnotation,
473
- getDiscriminatedType,
474
- getDiscriminatingProps,
475
- getField,
476
- getParamKeyAnnotation,
477
- getSimpleType,
478
- isDiscriminatedUnion,
479
- isJsonPath,
480
- isLiteralUnion,
481
- isOption,
482
- isSimpleType,
483
- mapAst,
484
- splitJsonPath,
485
- visit
486
- });
487
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/ast.ts", "../../../src/jsonPath.ts", "../../../src/url.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Option, pipe, SchemaAST, Schema } from 'effect';\n\nimport { invariant } from '@dxos/invariant';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type JsonPath, type JsonProp } from './jsonPath';\n\n//\n// Refs\n// https://effect.website/docs/schema/introduction\n// https://www.npmjs.com/package/@effect/schema\n// https://effect-ts.github.io/effect/schema/SchemaAST.ts.html\n//\n\nexport type SimpleType = 'object' | 'string' | 'number' | 'boolean' | 'enum' | 'literal';\n\n/**\n * Get the base type; e.g., traverse through refinements.\n */\nexport const getSimpleType = (node: SchemaAST.AST): SimpleType | undefined => {\n if (\n SchemaAST.isDeclaration(node) ||\n SchemaAST.isObjectKeyword(node) ||\n SchemaAST.isTypeLiteral(node) ||\n isDiscriminatedUnion(node)\n ) {\n return 'object';\n }\n\n if (SchemaAST.isStringKeyword(node)) {\n return 'string';\n }\n if (SchemaAST.isNumberKeyword(node)) {\n return 'number';\n }\n if (SchemaAST.isBooleanKeyword(node)) {\n return 'boolean';\n }\n\n if (SchemaAST.isEnums(node)) {\n return 'enum';\n }\n\n if (SchemaAST.isLiteral(node)) {\n return 'literal';\n }\n};\n\nexport const isSimpleType = (node: SchemaAST.AST): boolean => !!getSimpleType(node);\n\nexport namespace SimpleType {\n /**\n * Returns the default empty value for a given SimpleType.\n * Used for initializing new array values etc.\n */\n export const getDefaultValue = (type: SimpleType): any => {\n switch (type) {\n case 'string': {\n return '';\n }\n case 'number': {\n return 0;\n }\n case 'boolean': {\n return false;\n }\n case 'object': {\n return {};\n }\n default: {\n throw new Error(`Unsupported type for default value: ${type}`);\n }\n }\n };\n}\n\n//\n// Branded types\n//\n\nexport enum VisitResult {\n CONTINUE = 0,\n /**\n * Skip visiting children.\n */\n SKIP = 1,\n /**\n * Stop traversing immediately.\n */\n EXIT = 2,\n}\n\nexport type Path = (string | number)[];\n\nexport type TestFn = (node: SchemaAST.AST, path: Path, depth: number) => VisitResult | boolean | undefined;\n\nexport type VisitorFn = (node: SchemaAST.AST, path: Path, depth: number) => void;\n\nconst defaultTest: TestFn = isSimpleType;\n\n/**\n * Visit leaf nodes.\n * Refs:\n * - https://github.com/syntax-tree/unist-util-visit?tab=readme-ov-file#visitor\n * - https://github.com/syntax-tree/unist-util-is?tab=readme-ov-file#test\n */\nexport const visit: {\n (node: SchemaAST.AST, visitor: VisitorFn): void;\n (node: SchemaAST.AST, test: TestFn, visitor: VisitorFn): void;\n} = (node: SchemaAST.AST, testOrVisitor: TestFn | VisitorFn, visitor?: VisitorFn): void => {\n if (!visitor) {\n visitNode(node, defaultTest, testOrVisitor);\n } else {\n visitNode(node, testOrVisitor as TestFn, visitor);\n }\n};\n\nconst visitNode = (\n node: SchemaAST.AST,\n test: TestFn | undefined,\n visitor: VisitorFn,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n const _result = test?.(node, path, depth);\n const result: VisitResult =\n _result === undefined\n ? VisitResult.CONTINUE\n : typeof _result === 'boolean'\n ? _result\n ? VisitResult.CONTINUE\n : VisitResult.SKIP\n : _result;\n\n if (result === VisitResult.EXIT) {\n return result;\n }\n if (result !== VisitResult.SKIP) {\n visitor(node, path, depth);\n }\n\n // Object.\n if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const currentPath = [...path, prop.name.toString()];\n const result = visitNode(prop.type, test, visitor, currentPath, depth + 1);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Array.\n else if (SchemaAST.isTupleType(node)) {\n for (const [i, element] of node.elements.entries()) {\n const currentPath = [...path, i];\n const result = visitNode(element.type, test, visitor, currentPath, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n for (const type of node.types) {\n const result = visitNode(type, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n const result = visitNode(node.from, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n\n // TODO(burdon): Transforms?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Rewrite using visitNode?\nexport const findNode = (node: SchemaAST.AST, test: (node: SchemaAST.AST) => boolean): SchemaAST.AST | undefined => {\n if (test(node)) {\n return node;\n }\n\n // Object.\n else if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Tuple.\n else if (SchemaAST.isTupleType(node)) {\n for (const [_, element] of node.elements.entries()) {\n const child = findNode(element.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n for (const type of node.types) {\n const child = findNode(type, test);\n if (child) {\n return child;\n }\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n};\n\n/**\n * Get the AST node for the given property (dot-path).\n */\nexport const findProperty = (\n schema: Schema.Schema.AnyNoContext,\n path: JsonPath | JsonProp,\n): SchemaAST.AST | undefined => {\n const getProp = (node: SchemaAST.AST, path: JsonProp[]): SchemaAST.AST | undefined => {\n const [name, ...rest] = path;\n const typeNode = findNode(node, SchemaAST.isTypeLiteral);\n invariant(typeNode);\n for (const prop of SchemaAST.getPropertySignatures(typeNode)) {\n if (prop.name === name) {\n if (rest.length) {\n return getProp(prop.type, rest);\n } else {\n return prop.type;\n }\n }\n }\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n//\n// Annotations\n//\n\nconst defaultAnnotations: Record<string, SchemaAST.Annotated> = {\n ['ObjectKeyword' as const]: SchemaAST.objectKeyword,\n ['StringKeyword' as const]: SchemaAST.stringKeyword,\n ['NumberKeyword' as const]: SchemaAST.numberKeyword,\n ['BooleanKeyword' as const]: SchemaAST.booleanKeyword,\n};\n\n/**\n * Get annotation or return undefined.\n * @param annotationId\n * @param noDefault If true, then return undefined for effect library defined values.\n */\nexport const getAnnotation =\n <T>(annotationId: symbol, noDefault = true) =>\n (node: SchemaAST.AST): T | undefined => {\n // Title fallback seems to be the identifier.\n const id = pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);\n const value = pipe(SchemaAST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\n if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {\n return undefined;\n }\n\n return value;\n };\n\n/**\n * Recursively descend into AST to find first matching annotations.\n * Optionally skips default annotations for basic types (e.g., 'a string').\n */\n// TODO(burdon): Convert to effect pattern (i.e., return operator like getAnnotation).\nexport const findAnnotation = <T>(node: SchemaAST.AST, annotationId: symbol, noDefault = true): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId, noDefault);\n\n const getBaseAnnotation = (node: SchemaAST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n return getAnnotationById(node.types[0]) as T;\n }\n }\n };\n\n return getBaseAnnotation(node);\n};\n\n//\n// Unions\n//\n\n/**\n * Effect Schema.optional creates a union type with undefined as the second type.\n */\nexport const isOption = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.length === 2 && SchemaAST.isUndefinedKeyword(node.types[1]);\n};\n\n/**\n * Determines if the node is a union of literal types.\n */\nexport const isLiteralUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);\n};\n\n/**\n * Determines if the node is a discriminated union.\n */\nexport const isDiscriminatedUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;\n};\n\n/**\n * Get the discriminating properties for the given union type.\n */\nexport const getDiscriminatingProps = (node: SchemaAST.AST): string[] | undefined => {\n invariant(SchemaAST.isUnion(node));\n if (isOption(node)) {\n return;\n }\n\n // Get common literals across all types.\n return node.types.reduce<string[]>((shared, type) => {\n const props = SchemaAST.getPropertySignatures(type)\n // TODO(burdon): Should check each literal is unique.\n .filter((p) => SchemaAST.isLiteral(p.type))\n .map((p) => p.name.toString());\n\n // Return common literals.\n return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));\n }, []);\n};\n\n/**\n * Get the discriminated type for the given value.\n */\nexport const getDiscriminatedType = (\n node: SchemaAST.AST,\n value: Record<string, any> = {},\n): SchemaAST.AST | undefined => {\n invariant(SchemaAST.isUnion(node));\n invariant(value);\n const props = getDiscriminatingProps(node);\n if (!props?.length) {\n return;\n }\n\n // Match provided values.\n for (const type of node.types) {\n const match = SchemaAST.getPropertySignatures(type)\n .filter((prop) => props?.includes(prop.name.toString()))\n .every((prop) => {\n invariant(SchemaAST.isLiteral(prop.type));\n return prop.type.literal === value[prop.name.toString()];\n });\n\n if (match) {\n return type;\n }\n }\n\n // Create union of discriminating properties.\n // NOTE: This may not work with non-overlapping variants.\n // TODO(burdon): Iterate through props and knock-out variants that don't match.\n const fields = Object.fromEntries(\n props\n .map((prop) => {\n const literals = node.types\n .map((type) => {\n const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop)!;\n invariant(SchemaAST.isLiteral(literal.type));\n return literal.type.literal;\n })\n .filter(isNonNullable);\n\n return literals.length ? [prop, Schema.Literal(...literals)] : undefined;\n })\n .filter(isNonNullable),\n );\n\n const schema = Schema.Struct(fields);\n return schema.ast;\n};\n\n/**\n * Maps AST nodes.\n * The user is responsible for recursively calling {@link mapAst} on the SchemaAST.\n * NOTE: Will evaluate suspended ASTs.\n */\nexport const mapAst = (\n ast: SchemaAST.AST,\n f: (ast: SchemaAST.AST, key: keyof any | undefined) => SchemaAST.AST,\n): SchemaAST.AST => {\n switch (ast._tag) {\n case 'TypeLiteral': {\n return new SchemaAST.TypeLiteral(\n ast.propertySignatures.map(\n (prop) =>\n new SchemaAST.PropertySignature(\n prop.name,\n f(prop.type, prop.name),\n prop.isOptional,\n prop.isReadonly,\n prop.annotations,\n ),\n ),\n ast.indexSignatures,\n );\n }\n case 'Union': {\n return SchemaAST.Union.make(ast.types.map(f), ast.annotations);\n }\n case 'TupleType': {\n return new SchemaAST.TupleType(\n ast.elements.map((t, index) => new SchemaAST.OptionalType(f(t.type, index), t.isOptional, t.annotations)),\n ast.rest.map((t) => new SchemaAST.Type(f(t.type, undefined), t.annotations)),\n ast.isReadonly,\n ast.annotations,\n );\n }\n case 'Suspend': {\n const newAst = f(ast.f(), undefined);\n return new SchemaAST.Suspend(() => newAst, ast.annotations);\n }\n default: {\n // TODO(dmaretskyi): Support more nodes.\n return ast;\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema, Option } from 'effect';\nimport { JSONPath } from 'jsonpath-plus';\n\nimport { invariant } from '@dxos/invariant';\n\nexport type JsonProp = string & { __JsonPath: true; __JsonProp: true };\nexport type JsonPath = string & { __JsonPath: true };\n\nconst PATH_REGEX = /^($|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*|\\[\\d+\\](?:\\.)?)*$)/;\nconst PROP_REGEX = /^\\w+$/;\n\n/**\n * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html\n */\nexport const JsonPath = Schema.String.pipe(Schema.pattern(PATH_REGEX)).annotations({\n title: 'JSON path',\n description: 'JSON path to a property',\n}) as any as Schema.Schema<JsonPath>;\nexport const JsonProp = Schema.NonEmptyString.pipe(\n Schema.pattern(PROP_REGEX, {\n message: () => 'Property name must contain only letters, numbers, and underscores',\n }),\n) as any as Schema.Schema<JsonProp>;\n\nexport const isJsonPath = (value: unknown): value is JsonPath => {\n return Option.isSome(Schema.validateOption(JsonPath)(value));\n};\n\n/**\n * Creates a JsonPath from an array of path segments.\n *\n * Currently supports:\n * - Simple property access (e.g., 'foo.bar')\n * - Array indexing with non-negative integers (e.g., 'foo[0]')\n * - Identifiers starting with letters, underscore, or $ (e.g., '$foo', '_bar')\n * - Dot notation for nested properties (e.g., 'foo.bar.baz')\n *\n * Does not support (yet?).\n * - Recursive descent (..)\n * - Wildcards (*)\n * - Array slicing\n * - Filters\n * - Negative indices\n *\n * @param path Array of string or number segments\n * @returns Valid JsonPath or undefined if invalid\n */\nexport const createJsonPath = (path: (string | number)[]): JsonPath => {\n const candidatePath = path\n .map((p, i) => {\n if (typeof p === 'number') {\n return `[${p}]`;\n } else {\n return i === 0 ? p : `.${p}`;\n }\n })\n .join('');\n\n invariant(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);\n return candidatePath;\n};\n\n/**\n * Converts Effect validation path format (e.g. \"addresses.[0].zip\")\n * to JsonPath format (e.g., \"addresses[0].zip\")\n */\nexport const fromEffectValidationPath = (effectPath: string): JsonPath => {\n // Handle array notation: convert \"prop.[0]\" to \"prop[0]\"\n const jsonPath = effectPath.replace(/\\.\\[(\\d+)\\]/g, '[$1]');\n invariant(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);\n return jsonPath;\n};\n\n/**\n * Splits a JsonPath into its constituent parts.\n * Handles property access and array indexing.\n */\nexport const splitJsonPath = (path: JsonPath): string[] => {\n if (!isJsonPath(path)) {\n return [];\n }\n\n return (\n path\n .match(/[a-zA-Z_$][\\w$]*|\\[\\d+\\]/g)\n ?.map((part) => (part.startsWith('[') ? part.replace(/[[\\]]/g, '') : part)) ?? []\n );\n};\n\n/**\n * Applies a JsonPath to an object.\n */\nexport const getField = (object: any, path: JsonPath): any => {\n // By default, JSONPath returns an array of results.\n return JSONPath({ path, json: object })[0];\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { SchemaAST, type Schema, Option, pipe } from 'effect';\n\nimport { decamelize } from '@dxos/util';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: SchemaAST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n SchemaAST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends Schema.Annotable.All>(self: S): Schema.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: Schema.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (SchemaAST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (SchemaAST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAgD;AAEhD,uBAA0B;AAC1B,kBAA8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AAQmF,IAAII,aAAaC,QAAIC,yBAAWH,GAAAA,CAAAA;AAC5C,UAAItF,SAAS,MAAM;AACjBA,gBAAQmF,IAAII,aAAaC,IAAIF,GAAAA;MAC/B;AAEA,UAAItF,SAAS,MAAM;AACjB,YAAInE,eAAAA,UAAUM,gBAAgBO,KAAKuC,GAAG,GAAG;AACvCoG,iBAAOC,GAAAA,IAAOI,SAAS1F,KAAAA;QACzB,WAAWnE,eAAAA,UAAUO,iBAAiBM,KAAKuC,GAAG,GAAG;AAC/CoG,iBAAOC,GAAAA,IAAOtF,UAAU,UAAUA,UAAU;QAC9C,OAAO;AACLqF,iBAAOC,GAAAA,IAAOtF;QAChB;MACF;AAEA,aAAOqF;IACT,GAAG,CAAC,CAAA;EACN;;;;EAKAM,OAAOT,MAAcG,QAAgB;AACnC,UAAMF,MAAM,IAAIC,IAAIF,IAAAA;AACpB7D,WAAOpD,QAAQoH,MAAAA,EAAQO,QAAQ,CAAC,CAACN,KAAKtF,KAAAA,MAAM;AAC1C,UAAIA,UAAUzC,QAAW;AACvB,cAAMsI,QAAQ,KAAKb,QAAQ5D,OAAOkE,GAAAA;AAClC,YAAIO,OAAO;AACT,gBAAM,EAAEP,KAAKQ,cAAa,QAAKlG,eAAAA,MAC7BgF,sBAAsBiB,MAAM5G,GAAG,GAC/Ba,eAAAA,OAAOiG,UAAU,OAAO;YACtBT,SAAKG,yBAAWH,GAAAA;UAClB,EAAA,CAAA;AAGFH,cAAII,aAAaS,IAAIF,eAAe7C,OAAOjD,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOmF;EACT;AACF;",
6
- "names": ["import_effect", "import_invariant", "import_util", "getSimpleType", "node", "SchemaAST", "isDeclaration", "isObjectKeyword", "isTypeLiteral", "isDiscriminatedUnion", "isStringKeyword", "isNumberKeyword", "isBooleanKeyword", "isEnums", "isLiteral", "isSimpleType", "SimpleType", "getDefaultValue", "type", "Error", "VisitResult", "defaultTest", "visit", "testOrVisitor", "visitor", "visitNode", "test", "path", "depth", "_result", "result", "undefined", "prop", "getPropertySignatures", "currentPath", "name", "toString", "isTupleType", "i", "element", "elements", "entries", "isUnion", "types", "isRefinement", "from", "findNode", "child", "_", "isOption", "findProperty", "schema", "getProp", "rest", "typeNode", "invariant", "length", "ast", "split", "defaultAnnotations", "objectKeyword", "stringKeyword", "numberKeyword", "booleanKeyword", "getAnnotation", "annotationId", "noDefault", "id", "pipe", "getIdentifierAnnotation", "Option", "getOrUndefined", "value", "_tag", "annotations", "findAnnotation", "getAnnotationById", "getBaseAnnotation", "isUndefinedKeyword", "isLiteralUnion", "every", "getDiscriminatingProps", "reduce", "shared", "props", "filter", "p", "map", "includes", "getDiscriminatedType", "match", "literal", "fields", "Object", "fromEntries", "literals", "find", "isNonNullable", "Schema", "Literal", "Struct", "mapAst", "f", "TypeLiteral", "propertySignatures", "PropertySignature", "isOptional", "isReadonly", "indexSignatures", "Union", "make", "TupleType", "t", "index", "OptionalType", "Type", "newAst", "Suspend", "PATH_REGEX", "PROP_REGEX", "JsonPath", "String", "pattern", "title", "description", "JsonProp", "NonEmptyString", "message", "isJsonPath", "isSome", "validateOption", "createJsonPath", "candidatePath", "join", "fromEffectValidationPath", "effectPath", "jsonPath", "replace", "splitJsonPath", "part", "startsWith", "getField", "object", "JSONPath", "json", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "ParamKeyAnnotation", "self", "UrlParser", "_schema", "parse", "_url", "url", "URL", "params", "key", "searchParams", "get", "decamelize", "parseInt", "create", "forEach", "field", "serializedKey", "getOrElse", "set"]
7
- }
@@ -1 +0,0 @@
1
- {"inputs":{"packages/common/effect/src/ast.ts":{"bytes":41244,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/jsonPath.ts":{"bytes":9732,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"jsonpath-plus","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/url.ts":{"bytes":7566,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":616,"imports":[{"path":"packages/common/effect/src/ast.ts","kind":"import-statement","original":"./ast"},{"path":"packages/common/effect/src/jsonPath.ts","kind":"import-statement","original":"./jsonPath"},{"path":"packages/common/effect/src/url.ts","kind":"import-statement","original":"./url"}],"format":"esm"}},"outputs":{"packages/common/effect/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":29975},"packages/common/effect/dist/lib/node/index.cjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"jsonpath-plus","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["JsonPath","JsonProp","ParamKeyAnnotation","SimpleType","UrlParser","VisitResult","createJsonPath","findAnnotation","findNode","findProperty","fromEffectValidationPath","getAnnotation","getDiscriminatedType","getDiscriminatingProps","getField","getParamKeyAnnotation","getSimpleType","isDiscriminatedUnion","isJsonPath","isLiteralUnion","isOption","isSimpleType","mapAst","splitJsonPath","visit"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"packages/common/effect/src/ast.ts":{"bytesInOutput":8838},"packages/common/effect/src/index.ts":{"bytesInOutput":0},"packages/common/effect/src/jsonPath.ts":{"bytesInOutput":1875},"packages/common/effect/src/url.ts":{"bytesInOutput":1621}},"bytes":12919}}}