@dxos/effect 0.6.14-staging.e15392e → 0.7.1-staging.599df14

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.
@@ -20,15 +20,24 @@ var node_exports = {};
20
20
  __export(node_exports, {
21
21
  AST: () => import_schema.AST,
22
22
  JSONSchema: () => import_schema.JSONSchema,
23
+ JsonPath: () => JsonPath,
24
+ JsonProp: () => JsonProp,
23
25
  ParamKeyAnnotation: () => ParamKeyAnnotation,
24
26
  S: () => import_schema.Schema,
25
27
  UrlParser: () => UrlParser,
26
28
  VisitResult: () => VisitResult,
29
+ findAnnotation: () => findAnnotation,
30
+ findNode: () => findNode,
31
+ findProperty: () => findProperty,
27
32
  getAnnotation: () => getAnnotation,
33
+ getDiscriminatedType: () => getDiscriminatedType,
34
+ getDiscriminatingProps: () => getDiscriminatingProps,
28
35
  getParamKeyAnnotation: () => getParamKeyAnnotation,
29
- getProperty: () => getProperty,
30
- getType: () => getType,
31
- isLeafType: () => isLeafType,
36
+ getSimpleType: () => getSimpleType,
37
+ isDiscriminatedUnion: () => isDiscriminatedUnion,
38
+ isLiteralUnion: () => isLiteralUnion,
39
+ isOption: () => isOption,
40
+ isSimpleType: () => isSimpleType,
32
41
  visit: () => visit
33
42
  });
34
43
  module.exports = __toCommonJS(node_exports);
@@ -36,86 +45,262 @@ var import_schema = require("@effect/schema");
36
45
  var import_schema2 = require("@effect/schema");
37
46
  var import_effect = require("effect");
38
47
  var import_invariant = require("@dxos/invariant");
48
+ var import_util = require("@dxos/util");
39
49
  var import_schema3 = require("@effect/schema");
40
50
  var import_effect2 = require("effect");
41
- var import_util = require("@dxos/util");
51
+ var import_util2 = require("@dxos/util");
42
52
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/effect/src/ast.ts";
43
- var isLeafType = (node) => !import_schema2.AST.isTupleType(node) && !import_schema2.AST.isTypeLiteral(node);
44
- var getAnnotation = (annotationId, node) => (0, import_effect.pipe)(import_schema2.AST.getAnnotation(annotationId)(node), import_effect.Option.getOrUndefined);
45
- var getType = (node) => {
46
- if (import_schema2.AST.isUnion(node)) {
47
- return node.types.find((type) => getType(type));
48
- } else if (import_schema2.AST.isRefinement(node)) {
49
- return getType(node.from);
50
- } else {
51
- return node;
53
+ var getSimpleType = (node) => {
54
+ if (import_schema2.AST.isObjectKeyword(node) || import_schema2.AST.isTypeLiteral(node) || isDiscriminatedUnion(node)) {
55
+ return "object";
52
56
  }
53
- };
54
- var getProperty = (schema, path) => {
55
- let node = schema.ast;
56
- for (const part of path.split(".")) {
57
- const props = import_schema2.AST.getPropertySignatures(node);
58
- const prop = props.find((prop2) => prop2.name === part);
59
- if (!prop) {
60
- return void 0;
61
- }
62
- const type = getType(prop.type);
63
- (0, import_invariant.invariant)(type, `invalid type: ${path}`, {
64
- F: __dxlog_file,
65
- L: 52,
66
- S: void 0,
67
- A: [
68
- "type",
69
- "`invalid type: ${path}`"
70
- ]
71
- });
72
- node = type;
57
+ if (import_schema2.AST.isStringKeyword(node)) {
58
+ return "string";
59
+ }
60
+ if (import_schema2.AST.isNumberKeyword(node)) {
61
+ return "number";
62
+ }
63
+ if (import_schema2.AST.isBooleanKeyword(node)) {
64
+ return "boolean";
65
+ }
66
+ if (import_schema2.AST.isEnums(node)) {
67
+ return "enum";
68
+ }
69
+ if (import_schema2.AST.isLiteral(node)) {
70
+ return "literal";
73
71
  }
74
- return node;
75
72
  };
73
+ var isSimpleType = (node) => !!getSimpleType(node);
74
+ var PATH_REGEX = /[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/;
75
+ var PROP_REGEX = /\w+/;
76
+ var JsonPath = import_schema2.Schema.NonEmptyString.pipe(import_schema2.Schema.pattern(PATH_REGEX));
77
+ var JsonProp = import_schema2.Schema.NonEmptyString.pipe(import_schema2.Schema.pattern(PROP_REGEX));
78
+ var getAnnotation = (annotationId) => (node) => (0, import_effect.pipe)(import_schema2.AST.getAnnotation(annotationId)(node), import_effect.Option.getOrUndefined);
76
79
  var VisitResult;
77
80
  (function(VisitResult2) {
78
81
  VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
79
82
  VisitResult2[VisitResult2["SKIP"] = 1] = "SKIP";
80
83
  VisitResult2[VisitResult2["EXIT"] = 2] = "EXIT";
81
84
  })(VisitResult || (VisitResult = {}));
85
+ var defaultTest = (node) => isSimpleType(node) ? 0 : 1;
82
86
  var visit = (node, testOrVisitor, visitor) => {
83
87
  if (!visitor) {
84
- visitNode(node, void 0, testOrVisitor);
88
+ visitNode(node, defaultTest, testOrVisitor);
85
89
  } else {
86
90
  visitNode(node, testOrVisitor, visitor);
87
91
  }
88
92
  };
89
93
  var visitNode = (node, test, visitor, path = [], depth = 0) => {
90
- for (const prop of import_schema2.AST.getPropertySignatures(node)) {
91
- const currentPath = [
92
- ...path,
93
- prop.name.toString()
94
- ];
95
- const type = getType(prop.type);
96
- if (type) {
97
- const result = test?.(node, path, depth) ?? 0;
98
- if (result === 2) {
99
- return result;
94
+ const result = test?.(node, path, depth) ?? 0;
95
+ if (result === 2) {
96
+ return result;
97
+ }
98
+ if (result !== 1) {
99
+ visitor(node, path, depth);
100
+ }
101
+ if (import_schema2.AST.isTypeLiteral(node)) {
102
+ for (const prop of import_schema2.AST.getPropertySignatures(node)) {
103
+ const currentPath = [
104
+ ...path,
105
+ prop.name.toString()
106
+ ];
107
+ const result2 = visitNode(prop.type, test, visitor, currentPath, depth + 1);
108
+ if (result2 === 2) {
109
+ return result2;
110
+ }
111
+ }
112
+ } else if (import_schema2.AST.isTupleType(node)) {
113
+ for (const [i, element] of node.elements.entries()) {
114
+ const currentPath = [
115
+ ...path,
116
+ i
117
+ ];
118
+ const result2 = visitNode(element.type, test, visitor, currentPath, depth);
119
+ if (result2 === 2) {
120
+ return result2;
121
+ }
122
+ }
123
+ } else if (import_schema2.AST.isUnion(node)) {
124
+ for (const type of node.types) {
125
+ const result2 = visitNode(type, test, visitor, path, depth);
126
+ if (result2 === 2) {
127
+ return result2;
100
128
  }
101
- visitor(type, currentPath, depth);
102
- if (result !== 1) {
103
- if (import_schema2.AST.isTypeLiteral(type)) {
104
- visitNode(type, test, visitor, currentPath, depth + 1);
105
- } else if (import_schema2.AST.isTupleType(type)) {
106
- for (const [i, elementType] of type.elements.entries()) {
107
- const type2 = getType(elementType.type);
108
- if (type2) {
109
- visitNode(type2, test, visitor, [
110
- i,
111
- ...currentPath
112
- ], depth);
113
- }
114
- }
129
+ }
130
+ } else if (import_schema2.AST.isRefinement(node)) {
131
+ const result2 = visitNode(node.from, test, visitor, path, depth);
132
+ if (result2 === 2) {
133
+ return result2;
134
+ }
135
+ }
136
+ };
137
+ var findNode = (node, test) => {
138
+ if (test(node)) {
139
+ return node;
140
+ } else if (import_schema2.AST.isTypeLiteral(node)) {
141
+ for (const prop of import_schema2.AST.getPropertySignatures(node)) {
142
+ const child = findNode(prop.type, test);
143
+ if (child) {
144
+ return child;
145
+ }
146
+ }
147
+ } else if (import_schema2.AST.isTupleType(node)) {
148
+ for (const [_, element] of node.elements.entries()) {
149
+ const child = findNode(element.type, test);
150
+ if (child) {
151
+ return child;
152
+ }
153
+ }
154
+ } else if (import_schema2.AST.isUnion(node)) {
155
+ if (isOption(node)) {
156
+ for (const type of node.types) {
157
+ const child = findNode(type, test);
158
+ if (child) {
159
+ return child;
115
160
  }
116
161
  }
117
162
  }
163
+ } else if (import_schema2.AST.isRefinement(node)) {
164
+ return findNode(node.from, test);
165
+ }
166
+ };
167
+ var findProperty = (schema, path) => {
168
+ const getProp = (node, path2) => {
169
+ const [name, ...rest] = path2;
170
+ const typeNode = findNode(node, import_schema2.AST.isTypeLiteral);
171
+ (0, import_invariant.invariant)(typeNode, void 0, {
172
+ F: __dxlog_file,
173
+ L: 221,
174
+ S: void 0,
175
+ A: [
176
+ "typeNode",
177
+ ""
178
+ ]
179
+ });
180
+ for (const prop of import_schema2.AST.getPropertySignatures(typeNode)) {
181
+ if (prop.name === name) {
182
+ if (rest.length) {
183
+ return getProp(prop.type, rest);
184
+ } else {
185
+ return prop.type;
186
+ }
187
+ }
188
+ }
189
+ };
190
+ return getProp(schema.ast, path.split("."));
191
+ };
192
+ var defaultAnnotations = {
193
+ ["ObjectKeyword"]: import_schema2.AST.objectKeyword,
194
+ ["StringKeyword"]: import_schema2.AST.stringKeyword,
195
+ ["NumberKeyword"]: import_schema2.AST.numberKeyword,
196
+ ["BooleanKeyword"]: import_schema2.AST.booleanKeyword
197
+ };
198
+ var findAnnotation = (node, annotationId, options) => {
199
+ const getAnnotationById = getAnnotation(annotationId);
200
+ const getBaseAnnotation = (node2) => {
201
+ const value = getAnnotationById(node2);
202
+ if (value !== void 0) {
203
+ if (options?.noDefault && value === defaultAnnotations[node2._tag]?.annotations[annotationId]) {
204
+ return void 0;
205
+ }
206
+ return value;
207
+ }
208
+ if (import_schema2.AST.isUnion(node2)) {
209
+ if (isOption(node2)) {
210
+ return getAnnotationById(node2.types[0]);
211
+ }
212
+ }
213
+ };
214
+ return getBaseAnnotation(node);
215
+ };
216
+ var isOption = (node) => {
217
+ return import_schema2.AST.isUnion(node) && node.types.length === 2 && import_schema2.AST.isUndefinedKeyword(node.types[1]);
218
+ };
219
+ var isLiteralUnion = (node) => {
220
+ return import_schema2.AST.isUnion(node) && node.types.every(import_schema2.AST.isLiteral);
221
+ };
222
+ var isDiscriminatedUnion = (node) => {
223
+ return import_schema2.AST.isUnion(node) && !!getDiscriminatingProps(node)?.length;
224
+ };
225
+ var getDiscriminatingProps = (node) => {
226
+ (0, import_invariant.invariant)(import_schema2.AST.isUnion(node), void 0, {
227
+ F: __dxlog_file,
228
+ L: 307,
229
+ S: void 0,
230
+ A: [
231
+ "AST.isUnion(node)",
232
+ ""
233
+ ]
234
+ });
235
+ if (isOption(node)) {
236
+ return;
237
+ }
238
+ return node.types.reduce((shared, type) => {
239
+ const props = import_schema2.AST.getPropertySignatures(type).filter((p) => import_schema2.AST.isLiteral(p.type)).map((p) => p.name.toString());
240
+ return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));
241
+ }, []);
242
+ };
243
+ var getDiscriminatedType = (node, value = {}) => {
244
+ (0, import_invariant.invariant)(import_schema2.AST.isUnion(node), void 0, {
245
+ F: __dxlog_file,
246
+ L: 328,
247
+ S: void 0,
248
+ A: [
249
+ "AST.isUnion(node)",
250
+ ""
251
+ ]
252
+ });
253
+ (0, import_invariant.invariant)(value, void 0, {
254
+ F: __dxlog_file,
255
+ L: 329,
256
+ S: void 0,
257
+ A: [
258
+ "value",
259
+ ""
260
+ ]
261
+ });
262
+ const props = getDiscriminatingProps(node);
263
+ if (!props?.length) {
264
+ return;
265
+ }
266
+ for (const type of node.types) {
267
+ const match = import_schema2.AST.getPropertySignatures(type).filter((prop) => props?.includes(prop.name.toString())).every((prop) => {
268
+ (0, import_invariant.invariant)(import_schema2.AST.isLiteral(prop.type), void 0, {
269
+ F: __dxlog_file,
270
+ L: 340,
271
+ S: void 0,
272
+ A: [
273
+ "AST.isLiteral(prop.type)",
274
+ ""
275
+ ]
276
+ });
277
+ return prop.type.literal === value[prop.name.toString()];
278
+ });
279
+ if (match) {
280
+ return type;
281
+ }
118
282
  }
283
+ const fields = Object.fromEntries(props.map((prop) => {
284
+ const literals = node.types.map((type) => {
285
+ const literal = import_schema2.AST.getPropertySignatures(type).find((p) => p.name.toString() === prop);
286
+ (0, import_invariant.invariant)(import_schema2.AST.isLiteral(literal.type), void 0, {
287
+ F: __dxlog_file,
288
+ L: 358,
289
+ S: void 0,
290
+ A: [
291
+ "AST.isLiteral(literal.type)",
292
+ ""
293
+ ]
294
+ });
295
+ return literal.type.literal;
296
+ }).filter(import_util.nonNullable);
297
+ return literals.length ? [
298
+ prop,
299
+ import_schema2.Schema.Literal(...literals)
300
+ ] : void 0;
301
+ }).filter(import_util.nonNullable));
302
+ const schema = import_schema2.Schema.Struct(fields);
303
+ return schema.ast;
119
304
  };
120
305
  var ParamKeyAnnotationId = Symbol.for("@dxos/schema/annotation/ParamKey");
121
306
  var getParamKeyAnnotation = import_schema3.AST.getAnnotation(ParamKeyAnnotationId);
@@ -132,7 +317,7 @@ var UrlParser = class {
132
317
  parse(_url) {
133
318
  const url = new URL(_url);
134
319
  return Object.entries(this._schema.fields).reduce((params, [key, type]) => {
135
- let value = url.searchParams.get((0, import_util.decamelize)(key));
320
+ let value = url.searchParams.get((0, import_util2.decamelize)(key));
136
321
  if (value == null) {
137
322
  value = url.searchParams.get(key);
138
323
  }
@@ -158,7 +343,7 @@ var UrlParser = class {
158
343
  const field = this._schema.fields[key];
159
344
  if (field) {
160
345
  const { key: serializedKey } = (0, import_effect2.pipe)(getParamKeyAnnotation(field.ast), import_effect2.Option.getOrElse(() => ({
161
- key: (0, import_util.decamelize)(key)
346
+ key: (0, import_util2.decamelize)(key)
162
347
  })));
163
348
  url.searchParams.set(serializedKey, String(value));
164
349
  }
@@ -171,15 +356,24 @@ var UrlParser = class {
171
356
  0 && (module.exports = {
172
357
  AST,
173
358
  JSONSchema,
359
+ JsonPath,
360
+ JsonProp,
174
361
  ParamKeyAnnotation,
175
362
  S,
176
363
  UrlParser,
177
364
  VisitResult,
365
+ findAnnotation,
366
+ findNode,
367
+ findProperty,
178
368
  getAnnotation,
369
+ getDiscriminatedType,
370
+ getDiscriminatingProps,
179
371
  getParamKeyAnnotation,
180
- getProperty,
181
- getType,
182
- isLeafType,
372
+ getSimpleType,
373
+ isDiscriminatedUnion,
374
+ isLiteralUnion,
375
+ isOption,
376
+ isSimpleType,
183
377
  visit
184
378
  });
185
379
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/index.ts", "../../../src/ast.ts", "../../../src/url.ts"],
4
- "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { AST, JSONSchema, Schema as S } from '@effect/schema';\nimport type * as Types from 'effect/Types';\n\nexport { AST, JSONSchema, S, Types };\n\nexport * from './ast';\nexport * from './url';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { Option, pipe } from 'effect';\n\nimport { invariant } from '@dxos/invariant';\n\n//\n// Refs\n// https://effect.website/docs/guides/schema\n// https://www.npmjs.com/package/@effect/schema\n// https://effect-ts.github.io/effect/schema/AST.ts.html\n//\n\nexport const isLeafType = (node: AST.AST) => !AST.isTupleType(node) && !AST.isTypeLiteral(node);\n\n/**\n * Get annotation or return undefined.\n */\nexport const getAnnotation = <T>(annotationId: symbol, node: AST.Annotated): T | undefined =>\n pipe(AST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\n\n/**\n * Get type node.\n */\nexport const getType = (node: AST.AST): AST.AST | undefined => {\n if (AST.isUnion(node)) {\n return node.types.find((type) => getType(type));\n } else if (AST.isRefinement(node)) {\n return getType(node.from);\n } else {\n return node;\n }\n};\n\n/**\n * Get the AST node for the given property (dot-path).\n */\nexport const getProperty = (schema: S.Schema<any>, path: string): AST.AST | undefined => {\n let node: AST.AST = schema.ast;\n for (const part of path.split('.')) {\n const props = AST.getPropertySignatures(node);\n const prop = props.find((prop) => prop.name === part);\n if (!prop) {\n return undefined;\n }\n\n // TODO(burdon): Check if leaf.\n const type = getType(prop.type);\n invariant(type, `invalid type: ${path}`);\n node = type;\n }\n\n return node;\n};\n\nexport enum VisitResult {\n CONTINUE = 0,\n /**\n * Skip visiting children.\n */\n SKIP = 1,\n /**\n * Stop traversing immeditaely.\n */\n EXIT = 2,\n}\n\nexport type Path = (string | number)[];\n\nexport type Tester = (node: AST.AST, path: Path, depth: number) => VisitResult;\nexport type Visitor = (node: AST.AST, path: Path, depth: number) => void;\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: AST.AST, visitor: Visitor): void;\n (node: AST.AST, test: Tester, visitor: Visitor): void;\n} = (node: AST.AST, testOrVisitor: Tester | Visitor, visitor?: Visitor): void => {\n if (!visitor) {\n visitNode(node, undefined, testOrVisitor);\n } else {\n visitNode(node, testOrVisitor as Tester, visitor);\n }\n};\n\nconst visitNode = (\n node: AST.AST,\n test: Tester | undefined,\n visitor: Visitor,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n for (const prop of AST.getPropertySignatures(node)) {\n const currentPath = [...path, prop.name.toString()];\n const type = getType(prop.type);\n if (type) {\n const result = test?.(node, path, depth) ?? VisitResult.CONTINUE;\n if (result === VisitResult.EXIT) {\n return result;\n }\n\n visitor(type, currentPath, depth);\n\n if (result !== VisitResult.SKIP) {\n if (AST.isTypeLiteral(type)) {\n visitNode(type, test, visitor, currentPath, depth + 1);\n } else if (AST.isTupleType(type)) {\n for (const [i, elementType] of type.elements.entries()) {\n const type = getType(elementType.type);\n if (type) {\n visitNode(type, test, visitor, [i, ...currentPath], depth);\n }\n }\n }\n }\n }\n }\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { 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: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends S.Annotable.All>(self: S): S.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: S.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 (AST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (AST.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,oBAA6C;ACA7C,IAAAA,iBAAsC;AACtC,oBAA6B;AAE7B,uBAA0B;ACH1B,IAAAA,iBAAsC;AACtC,IAAAC,iBAA6B;AAE7B,kBAA2B;;ADSpB,IAAMC,aAAa,CAACC,SAAkB,CAACC,mBAAIC,YAAYF,IAAAA,KAAS,CAACC,mBAAIE,cAAcH,IAAAA;AAKnF,IAAMI,gBAAgB,CAAIC,cAAsBL,aACrDM,oBAAKL,mBAAIG,cAAiBC,YAAAA,EAAcL,IAAAA,GAAOO,qBAAOC,cAAc;AAK/D,IAAMC,UAAU,CAACT,SAAAA;AACtB,MAAIC,mBAAIS,QAAQV,IAAAA,GAAO;AACrB,WAAOA,KAAKW,MAAMC,KAAK,CAACC,SAASJ,QAAQI,IAAAA,CAAAA;EAC3C,WAAWZ,mBAAIa,aAAad,IAAAA,GAAO;AACjC,WAAOS,QAAQT,KAAKe,IAAI;EAC1B,OAAO;AACL,WAAOf;EACT;AACF;AAKO,IAAMgB,cAAc,CAACC,QAAuBC,SAAAA;AACjD,MAAIlB,OAAgBiB,OAAOE;AAC3B,aAAWC,QAAQF,KAAKG,MAAM,GAAA,GAAM;AAClC,UAAMC,QA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AQ,CAAC,CAACR,KAAKd,KAAAA,MAAM;AAC1C,UAAIA,UAAUrB,QAAW;AACvB,cAAM4C,QAAQ,KAAKlB,QAAQM,OAAOG,GAAAA;AAClC,YAAIS,OAAO;AACT,gBAAM,EAAET,KAAKU,cAAa,QAAKjE,eAAAA,MAC7BuC,sBAAsByB,MAAMnD,GAAG,GAC/BZ,eAAAA,OAAOiE,UAAU,OAAO;YACtBX,SAAKG,wBAAWH,GAAAA;UAClB,EAAA,CAAA;AAGFN,cAAIO,aAAaW,IAAIF,eAAeG,OAAO3B,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
- "names": ["import_schema", "import_effect", "isLeafType", "node", "AST", "isTupleType", "isTypeLiteral", "getAnnotation", "annotationId", "pipe", "Option", "getOrUndefined", "getType", "isUnion", "types", "find", "type", "isRefinement", "from", "getProperty", "schema", "path", "ast", "part", "split", "props", "getPropertySignatures", "prop", "name", "undefined", "invariant", "VisitResult", "visit", "testOrVisitor", "visitor", "visitNode", "test", "depth", "currentPath", "toString", "result", "i", "elementType", "elements", "entries", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "fields", "reduce", "params", "key", "searchParams", "get", "decamelize", "isNumberKeyword", "parseInt", "isBooleanKeyword", "create", "forEach", "field", "serializedKey", "getOrElse", "set", "String"]
4
+ "sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport { AST, JSONSchema, Schema as S } from '@effect/schema';\nimport type * as Types from 'effect/Types';\n\n// TODO(dmaretskyi): Remove re-exports.\nexport { AST, JSONSchema, S, Types };\n\nexport * from './ast';\nexport * from './url';\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, Schema as S } from '@effect/schema';\nimport { Option, pipe } from 'effect';\n\nimport { invariant } from '@dxos/invariant';\nimport { nonNullable } from '@dxos/util';\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/AST.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: AST.AST): SimpleType | undefined => {\n if (AST.isObjectKeyword(node) || AST.isTypeLiteral(node) || isDiscriminatedUnion(node)) {\n return 'object';\n }\n\n if (AST.isStringKeyword(node)) {\n return 'string';\n }\n if (AST.isNumberKeyword(node)) {\n return 'number';\n }\n if (AST.isBooleanKeyword(node)) {\n return 'boolean';\n }\n\n if (AST.isEnums(node)) {\n return 'enum';\n }\n\n if (AST.isLiteral(node)) {\n return 'literal';\n }\n};\n\nexport const isSimpleType = (node: AST.AST): boolean => !!getSimpleType(node);\n\n//\n// Branded types\n//\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$]*)*/;\nconst PROP_REGEX = /\\w+/;\n\n/**\n * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html\n */\nexport const JsonPath = S.NonEmptyString.pipe(S.pattern(PATH_REGEX)) as any as S.Schema<JsonPath>;\nexport const JsonProp = S.NonEmptyString.pipe(S.pattern(PROP_REGEX)) as any as S.Schema<JsonProp>;\n\n/**\n * Get annotation or return undefined.\n */\nexport const getAnnotation =\n <T>(annotationId: symbol) =>\n (node: AST.Annotated): T | undefined =>\n pipe(AST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\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 Tester = (node: AST.AST, path: Path, depth: number) => VisitResult | undefined;\nexport type Visitor = (node: AST.AST, path: Path, depth: number) => void;\n\nconst defaultTest: Tester = (node) => (isSimpleType(node) ? VisitResult.CONTINUE : VisitResult.SKIP);\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: AST.AST, visitor: Visitor): void;\n (node: AST.AST, test: Tester, visitor: Visitor): void;\n} = (node: AST.AST, testOrVisitor: Tester | Visitor, visitor?: Visitor): void => {\n if (!visitor) {\n visitNode(node, defaultTest, testOrVisitor);\n } else {\n visitNode(node, testOrVisitor as Tester, visitor);\n }\n};\n\nconst visitNode = (\n node: AST.AST,\n test: Tester | undefined,\n visitor: Visitor,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n const result = test?.(node, path, depth) ?? VisitResult.CONTINUE;\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 (AST.isTypeLiteral(node)) {\n for (const prop of AST.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 (AST.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 (AST.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 (AST.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: AST.AST, test: (node: AST.AST) => boolean): AST.AST | undefined => {\n if (test(node)) {\n return node;\n }\n\n // Object.\n else if (AST.isTypeLiteral(node)) {\n for (const prop of AST.getPropertySignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Tuple.\n else if (AST.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 (AST.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 (AST.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 = (schema: S.Schema<any>, path: JsonPath | JsonProp): AST.AST | undefined => {\n const getProp = (node: AST.AST, path: JsonProp[]): AST.AST | undefined => {\n const [name, ...rest] = path;\n const typeNode = findNode(node, AST.isTypeLiteral);\n invariant(typeNode);\n for (const prop of AST.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, AST.Annotated> = {\n ['ObjectKeyword' as const]: AST.objectKeyword,\n ['StringKeyword' as const]: AST.stringKeyword,\n ['NumberKeyword' as const]: AST.numberKeyword,\n ['BooleanKeyword' as const]: AST.booleanKeyword,\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 */\nexport const findAnnotation = <T>(\n node: AST.AST,\n annotationId: symbol,\n options?: { noDefault: boolean },\n): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId);\n\n const getBaseAnnotation = (node: AST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n if (options?.noDefault && value === defaultAnnotations[node._tag]?.annotations[annotationId]) {\n return undefined;\n }\n\n return value as T;\n }\n\n if (AST.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 S.optional creates a union type with undefined as the second type.\n */\nexport const isOption = (node: AST.AST): boolean => {\n return AST.isUnion(node) && node.types.length === 2 && AST.isUndefinedKeyword(node.types[1]);\n};\n\n/**\n * Determines if the node is a union of literal types.\n */\nexport const isLiteralUnion = (node: AST.AST): boolean => {\n return AST.isUnion(node) && node.types.every(AST.isLiteral);\n};\n\n/**\n * Determines if the node is a discriminated union.\n */\nexport const isDiscriminatedUnion = (node: AST.AST): boolean => {\n return AST.isUnion(node) && !!getDiscriminatingProps(node)?.length;\n};\n\n/**\n * Get the discriminating properties for the given union type.\n */\nexport const getDiscriminatingProps = (node: AST.AST): string[] | undefined => {\n invariant(AST.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 = AST.getPropertySignatures(type)\n // TODO(burdon): Should check each literal is unique.\n .filter((p) => AST.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 = (node: AST.AST, value: Record<string, any> = {}): AST.AST | undefined => {\n invariant(AST.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 = AST.getPropertySignatures(type)\n .filter((prop) => props?.includes(prop.name.toString()))\n .every((prop) => {\n invariant(AST.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 = AST.getPropertySignatures(type).find((p) => p.name.toString() === prop)!;\n invariant(AST.isLiteral(literal.type));\n return literal.type.literal;\n })\n .filter(nonNullable);\n\n return literals.length ? [prop, S.Literal(...literals)] : undefined;\n })\n .filter(nonNullable),\n );\n\n const schema = S.Struct(fields);\n return schema.ast;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AST, type Schema as S } from '@effect/schema';\nimport { 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: AST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n AST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends S.Annotable.All>(self: S): S.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: S.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 (AST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (AST.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,oBAA6C;ACA7C,IAAAA,iBAAiC;AACjC,oBAA6B;AAE7B,uBAA0B;AAC1B,kBAA4B;ACJ5B,IAAAA,iBAAsC;AACtC,IAAAC,iBAA6B;AAE7B,IAAAC,eAA2B;;ADepB,IAAMC,gBAAgB,CAACC,SAAAA;AAC5B,MAAIC,mBAAIC,gBAAgBF,IAAAA,KAASC,mBAAIE,cAAcH,IAAAA,KAASI,qBAAqBJ,IAAAA,GAAO;AACtF,WAAO;EACT;AAEA,MAAIC,mBAAII,gBAAgBL,IAAAA,GAAO;AAC7B,WAAO;EACT;AACA,MAAIC,mBAAIK,gBAAgBN,IAAAA,GAAO;AAC7B,WAAO;EACT;AACA,MAAIC,mBAAIM,iBAAiBP,IAAAA,GAAO;AAC9B,WAAO;EACT;AAEA,MAAIC,mBAAIO,QAAQR,IAAAA,GAAO;AACrB,WAAO;EACT;AAEA,MAAIC,mBAAIQ,UAAUT,IAAAA,GAAO;AACvB,WAAO;EACT;AACF;AAEO,IAAMU,eAAe,CAACV,SAA2B,CAAC,CAACD,cAAcC,IAAAA;AASxE,IAAMW,aAAa;AACnB,IAAMC,aAAa;AAKZ,IAAMC,WAAWC,eAAAA,OAAEC,eAAeC,KAAKF,eAAAA,OAAEG,QAAQN,UAAAA,CAAAA;AACjD,IAAMO,WAAWJ,eAAAA,OAAEC,eAAeC,KAAKF,eAAAA,OAAEG,QAAQL,UAAAA,CAAAA;AAKjD,IAAMO,gBACX,CAAIC,iBACJ,CAACpB,aACCgB,oBAAKf,mBAAIkB,cAAiBC,YAAAA,EAAcpB,IAAAA,GAAOqB,qBA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AM,EAAEV,OAA4B,CAAC+B,QAAQ,CAACC,KAAKzE,IAAAA,MAAK;AACzF,UAAIgC,QAAQsC,IAAII,aAAaC,QAAIC,yBAAWH,GAAAA,CAAAA;AAC5C,UAAIzC,SAAS,MAAM;AACjBA,gBAAQsC,IAAII,aAAaC,IAAIF,GAAAA;MAC/B;AAEA,UAAIzC,SAAS,MAAM;AACjB,YAAIrE,eAAAA,IAAIK,gBAAgBgC,KAAKqB,GAAG,GAAG;AACjCmD,iBAAOC,GAAAA,IAAOI,SAAS7C,KAAAA;QACzB,WAAWrE,eAAAA,IAAIM,iBAAiB+B,KAAKqB,GAAG,GAAG;AACzCmD,iBAAOC,GAAAA,IAAOzC,UAAU,UAAUA,UAAU;QAC9C,OAAO;AACLwC,iBAAOC,GAAAA,IAAOzC;QAChB;MACF;AAEA,aAAOwC;IACT,GAAG,CAAC,CAAA;EACN;;;;EAKAM,OAAOT,MAAcG,QAAgB;AACnC,UAAMF,MAAM,IAAIC,IAAIF,IAAAA;AACpBjB,WAAO/C,QAAQmE,MAAAA,EAAQO,QAAQ,CAAC,CAACN,KAAKzC,KAAAA,MAAM;AAC1C,UAAIA,UAAUC,QAAW;AACvB,cAAM+C,QAAQ,KAAKb,QAAQhB,OAAOsB,GAAAA;AAClC,YAAIO,OAAO;AACT,gBAAM,EAAEP,KAAKQ,cAAa,QAAKvG,eAAAA,MAC7BoF,sBAAsBkB,MAAM3D,GAAG,GAC/BtC,eAAAA,OAAOmG,UAAU,OAAO;YACtBT,SAAKG,yBAAWH,GAAAA;UAClB,EAAA,CAAA;AAGFH,cAAII,aAAaS,IAAIF,eAAeG,OAAOpD,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOsC;EACT;AACF;",
6
+ "names": ["import_schema", "import_effect", "import_util", "getSimpleType", "node", "AST", "isObjectKeyword", "isTypeLiteral", "isDiscriminatedUnion", "isStringKeyword", "isNumberKeyword", "isBooleanKeyword", "isEnums", "isLiteral", "isSimpleType", "PATH_REGEX", "PROP_REGEX", "JsonPath", "S", "NonEmptyString", "pipe", "pattern", "JsonProp", "getAnnotation", "annotationId", "Option", "getOrUndefined", "VisitResult", "defaultTest", "visit", "testOrVisitor", "visitor", "visitNode", "test", "path", "depth", "result", "prop", "getPropertySignatures", "currentPath", "name", "toString", "type", "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", "findAnnotation", "options", "getAnnotationById", "getBaseAnnotation", "value", "undefined", "noDefault", "_tag", "annotations", "isUndefinedKeyword", "isLiteralUnion", "every", "getDiscriminatingProps", "reduce", "shared", "props", "filter", "p", "map", "includes", "getDiscriminatedType", "match", "literal", "fields", "Object", "fromEntries", "literals", "find", "nonNullable", "Literal", "Struct", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "ParamKeyAnnotation", "self", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "params", "key", "searchParams", "get", "decamelize", "parseInt", "create", "forEach", "field", "serializedKey", "getOrElse", "set", "String"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/common/effect/src/ast.ts":{"bytes":11581,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/url.ts":{"bytes":7711,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":1034,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"packages/common/effect/src/ast.ts","kind":"import-statement","original":"./ast"},{"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":10201},"packages/common/effect/dist/lib/node/index.cjs":{"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AST","JSONSchema","ParamKeyAnnotation","S","UrlParser","VisitResult","getAnnotation","getParamKeyAnnotation","getProperty","getType","isLeafType","visit"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"packages/common/effect/src/index.ts":{"bytesInOutput":71},"packages/common/effect/src/ast.ts":{"bytesInOutput":2437},"packages/common/effect/src/url.ts":{"bytesInOutput":1624}},"bytes":4468}}}
1
+ {"inputs":{"packages/common/effect/src/ast.ts":{"bytes":33857,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"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/url.ts":{"bytes":7711,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/common/effect/src/index.ts":{"bytes":1150,"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"packages/common/effect/src/ast.ts","kind":"import-statement","original":"./ast"},{"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":21745},"packages/common/effect/dist/lib/node/index.cjs":{"imports":[{"path":"@effect/schema","kind":"import-statement","external":true},{"path":"@effect/schema","kind":"import-statement","external":true},{"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/schema","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["AST","JSONSchema","JsonPath","JsonProp","ParamKeyAnnotation","S","UrlParser","VisitResult","findAnnotation","findNode","findProperty","getAnnotation","getDiscriminatedType","getDiscriminatingProps","getParamKeyAnnotation","getSimpleType","isDiscriminatedUnion","isLiteralUnion","isOption","isSimpleType","visit"],"entryPoint":"packages/common/effect/src/index.ts","inputs":{"packages/common/effect/src/index.ts":{"bytesInOutput":72},"packages/common/effect/src/ast.ts":{"bytesInOutput":7227},"packages/common/effect/src/url.ts":{"bytesInOutput":1624}},"bytes":9432}}}