@dxos/effect 0.6.14-main.8b352a0 → 0.6.14-staging.3e2eaca

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,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,G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C,eAAAA,IAAIgE,gBAAgBpD,KAAKM,GAAG,GAAG;AACjCyC,iBAAOC,GAAAA,IAAOK,SAASnB,KAAAA;QACzB,WAAW9C,eAAAA,IAAIkE,iBAAiBtD,KAAKM,GAAG,GAAG;AACzCyC,iBAAOC,GAAAA,IAAOd,UAAU,UAAUA,UAAU;QAC9C,OAAO;AACLa,iBAAOC,GAAAA,IAAOd;QAChB;MACF;AAEA,aAAOa;IACT,GAAG,CAAC,CAAA;EACN;;;;EAKAQ,OAAOd,MAAcM,QAAgB;AACnC,UAAML,MAAM,IAAIC,IAAIF,IAAAA;AACpBG,WAAOhB,QAAQmB,MAAAA,EAAQS,QAAQ,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';\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 type SimpleType = 'object' | 'string' | 'number' | 'boolean' | 'enum' | 'literal';\n\nexport const getSimpleType = (node: AST.AST): SimpleType | undefined => {\n if (AST.isObjectKeyword(node)) {\n return 'object';\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 if (AST.isEnums(node)) {\n return 'enum';\n }\n if (AST.isLiteral(node)) {\n return 'literal';\n }\n};\n\nexport const isSimpleType = (node: AST.AST) => !!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.\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): Transform?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Reuse visitor.\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 // Array.\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.\n else if (AST.isUnion(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 // Refinement.\n else if (AST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n\n return undefined;\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 return undefined;\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n/**\n * Recursively descend into AST to find first matching annotations\n */\nexport const findAnnotation = <T>(node: AST.AST, annotationId: symbol): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId);\n const getBaseAnnotation = (node: AST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (AST.isUnion(node)) {\n for (const type of node.types) {\n const value = getBaseAnnotation(type);\n if (value !== undefined) {\n return value as T;\n }\n }\n }\n };\n\n return getBaseAnnotation(node);\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.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AAaC,IAAIF,GAAAA;MAC/B;AAEA,UAAInB,SAAS,MAAM;AACjB,YAAI9D,eAAAA,IAAIG,gBAAgBiC,KAAKqB,GAAG,GAAG;AACjCuB,iBAAOC,GAAAA,IAAOI,SAASvB,KAAAA;QACzB,WAAW9D,eAAAA,IAAII,iBAAiBgC,KAAKqB,GAAG,GAAG;AACzCuB,iBAAOC,GAAAA,IAAOnB,UAAU,UAAUA,UAAU;QAC9C,OAAO;AACLkB,iBAAOC,GAAAA,IAAOnB;QAChB;MACF;AAEA,aAAOkB;IACT,GAAG,CAAC,CAAA;EACN;;;;EAKAM,OAAOZ,MAAcM,QAAgB;AACnC,UAAML,MAAM,IAAIC,IAAIF,IAAAA;AACpBG,WAAOpC,QAAQuC,MAAAA,EAAQO,QAAQ,CAAC,CAACN,KAAKnB,KAAAA,MAAM;AAC1C,UAAIA,UAAUb,QAAW;AACvB,cAAMuC,QAAQ,KAAKhB,QAAQM,OAAOG,GAAAA;AAClC,YAAIO,OAAO;AACT,gBAAM,EAAEP,KAAKQ,cAAa,QAAK5E,eAAAA,MAC7BqD,sBAAsBsB,MAAM/B,GAAG,GAC/BvC,eAAAA,OAAOwE,UAAU,OAAO;YACtBT,SAAKG,wBAAWH,GAAAA;UAClB,EAAA,CAAA;AAGFN,cAAIO,aAAaS,IAAIF,eAAeG,OAAO9B,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOa;EACT;AACF;",
6
+ "names": ["import_schema", "import_effect", "getSimpleType", "node", "AST", "isObjectKeyword", "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", "isTypeLiteral", "prop", "getPropertySignatures", "currentPath", "name", "toString", "type", "isTupleType", "i", "element", "elements", "entries", "isUnion", "types", "isRefinement", "from", "findNode", "child", "_", "undefined", "findProperty", "schema", "getProp", "rest", "typeNode", "invariant", "length", "ast", "split", "findAnnotation", "getAnnotationById", "getBaseAnnotation", "value", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "ParamKeyAnnotation", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "fields", "reduce", "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":21205,"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":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":15612},"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","JsonPath","JsonProp","ParamKeyAnnotation","S","UrlParser","VisitResult","findAnnotation","findNode","findProperty","getAnnotation","getParamKeyAnnotation","getSimpleType","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":4515},"packages/common/effect/src/url.ts":{"bytesInOutput":1624}},"bytes":6616}}}
@@ -1,90 +1,170 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
 
3
3
  // packages/common/effect/src/index.ts
4
- import { AST as AST3, JSONSchema, Schema as S } from "@effect/schema";
4
+ import { AST as AST3, JSONSchema, Schema as S2 } from "@effect/schema";
5
5
 
6
6
  // packages/common/effect/src/ast.ts
7
- import { AST } from "@effect/schema";
7
+ import { AST, Schema as S } from "@effect/schema";
8
8
  import { Option, pipe } from "effect";
9
9
  import { invariant } from "@dxos/invariant";
10
10
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/effect/src/ast.ts";
11
- var isLeafType = (node) => !AST.isTupleType(node) && !AST.isTypeLiteral(node);
12
- var getAnnotation = (annotationId, node) => pipe(AST.getAnnotation(annotationId)(node), Option.getOrUndefined);
13
- var getType = (node) => {
14
- if (AST.isUnion(node)) {
15
- return node.types.find((type) => getType(type));
16
- } else if (AST.isRefinement(node)) {
17
- return getType(node.from);
18
- } else {
19
- return node;
11
+ var getSimpleType = (node) => {
12
+ if (AST.isObjectKeyword(node)) {
13
+ return "object";
20
14
  }
21
- };
22
- var getProperty = (schema, path) => {
23
- let node = schema.ast;
24
- for (const part of path.split(".")) {
25
- const props = AST.getPropertySignatures(node);
26
- const prop = props.find((prop2) => prop2.name === part);
27
- if (!prop) {
28
- return void 0;
29
- }
30
- const type = getType(prop.type);
31
- invariant(type, `invalid type: ${path}`, {
32
- F: __dxlog_file,
33
- L: 52,
34
- S: void 0,
35
- A: [
36
- "type",
37
- "`invalid type: ${path}`"
38
- ]
39
- });
40
- node = type;
15
+ if (AST.isStringKeyword(node)) {
16
+ return "string";
17
+ }
18
+ if (AST.isNumberKeyword(node)) {
19
+ return "number";
20
+ }
21
+ if (AST.isBooleanKeyword(node)) {
22
+ return "boolean";
23
+ }
24
+ if (AST.isEnums(node)) {
25
+ return "enum";
26
+ }
27
+ if (AST.isLiteral(node)) {
28
+ return "literal";
41
29
  }
42
- return node;
43
30
  };
31
+ var isSimpleType = (node) => !!getSimpleType(node);
32
+ var PATH_REGEX = /[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/;
33
+ var PROP_REGEX = /\w+/;
34
+ var JsonPath = S.NonEmptyString.pipe(S.pattern(PATH_REGEX));
35
+ var JsonProp = S.NonEmptyString.pipe(S.pattern(PROP_REGEX));
36
+ var getAnnotation = (annotationId) => (node) => pipe(AST.getAnnotation(annotationId)(node), Option.getOrUndefined);
44
37
  var VisitResult;
45
38
  (function(VisitResult2) {
46
39
  VisitResult2[VisitResult2["CONTINUE"] = 0] = "CONTINUE";
47
40
  VisitResult2[VisitResult2["SKIP"] = 1] = "SKIP";
48
41
  VisitResult2[VisitResult2["EXIT"] = 2] = "EXIT";
49
42
  })(VisitResult || (VisitResult = {}));
43
+ var defaultTest = (node) => isSimpleType(node) ? 0 : 1;
50
44
  var visit = (node, testOrVisitor, visitor) => {
51
45
  if (!visitor) {
52
- visitNode(node, void 0, testOrVisitor);
46
+ visitNode(node, defaultTest, testOrVisitor);
53
47
  } else {
54
48
  visitNode(node, testOrVisitor, visitor);
55
49
  }
56
50
  };
57
51
  var visitNode = (node, test, visitor, path = [], depth = 0) => {
58
- for (const prop of AST.getPropertySignatures(node)) {
59
- const currentPath = [
60
- ...path,
61
- prop.name.toString()
62
- ];
63
- const type = getType(prop.type);
64
- if (type) {
65
- const result = test?.(node, path, depth) ?? 0;
66
- if (result === 2) {
67
- return result;
52
+ const result = test?.(node, path, depth) ?? 0;
53
+ if (result === 2) {
54
+ return result;
55
+ }
56
+ if (result !== 1) {
57
+ visitor(node, path, depth);
58
+ }
59
+ if (AST.isTypeLiteral(node)) {
60
+ for (const prop of AST.getPropertySignatures(node)) {
61
+ const currentPath = [
62
+ ...path,
63
+ prop.name.toString()
64
+ ];
65
+ const result2 = visitNode(prop.type, test, visitor, currentPath, depth + 1);
66
+ if (result2 === 2) {
67
+ return result2;
68
68
  }
69
- visitor(type, currentPath, depth);
70
- if (result !== 1) {
71
- if (AST.isTypeLiteral(type)) {
72
- visitNode(type, test, visitor, currentPath, depth + 1);
73
- } else if (AST.isTupleType(type)) {
74
- for (const [i, elementType] of type.elements.entries()) {
75
- const type2 = getType(elementType.type);
76
- if (type2) {
77
- visitNode(type2, test, visitor, [
78
- i,
79
- ...currentPath
80
- ], depth);
81
- }
82
- }
83
- }
69
+ }
70
+ } else if (AST.isTupleType(node)) {
71
+ for (const [i, element] of node.elements.entries()) {
72
+ const currentPath = [
73
+ ...path,
74
+ i
75
+ ];
76
+ const result2 = visitNode(element.type, test, visitor, currentPath, depth);
77
+ if (result2 === 2) {
78
+ return result2;
84
79
  }
85
80
  }
81
+ } else if (AST.isUnion(node)) {
82
+ for (const type of node.types) {
83
+ const result2 = visitNode(type, test, visitor, path, depth);
84
+ if (result2 === 2) {
85
+ return result2;
86
+ }
87
+ }
88
+ } else if (AST.isRefinement(node)) {
89
+ const result2 = visitNode(node.from, test, visitor, path, depth);
90
+ if (result2 === 2) {
91
+ return result2;
92
+ }
86
93
  }
87
94
  };
95
+ var findNode = (node, test) => {
96
+ if (test(node)) {
97
+ return node;
98
+ } else if (AST.isTypeLiteral(node)) {
99
+ for (const prop of AST.getPropertySignatures(node)) {
100
+ const child = findNode(prop.type, test);
101
+ if (child) {
102
+ return child;
103
+ }
104
+ }
105
+ } else if (AST.isTupleType(node)) {
106
+ for (const [_, element] of node.elements.entries()) {
107
+ const child = findNode(element.type, test);
108
+ if (child) {
109
+ return child;
110
+ }
111
+ }
112
+ } else if (AST.isUnion(node)) {
113
+ for (const type of node.types) {
114
+ const child = findNode(type, test);
115
+ if (child) {
116
+ return child;
117
+ }
118
+ }
119
+ } else if (AST.isRefinement(node)) {
120
+ return findNode(node.from, test);
121
+ }
122
+ return void 0;
123
+ };
124
+ var findProperty = (schema, path) => {
125
+ const getProp = (node, path2) => {
126
+ const [name, ...rest] = path2;
127
+ const typeNode = findNode(node, AST.isTypeLiteral);
128
+ invariant(typeNode, void 0, {
129
+ F: __dxlog_file,
130
+ L: 214,
131
+ S: void 0,
132
+ A: [
133
+ "typeNode",
134
+ ""
135
+ ]
136
+ });
137
+ for (const prop of AST.getPropertySignatures(typeNode)) {
138
+ if (prop.name === name) {
139
+ if (rest.length) {
140
+ return getProp(prop.type, rest);
141
+ } else {
142
+ return prop.type;
143
+ }
144
+ }
145
+ }
146
+ return void 0;
147
+ };
148
+ return getProp(schema.ast, path.split("."));
149
+ };
150
+ var findAnnotation = (node, annotationId) => {
151
+ const getAnnotationById = getAnnotation(annotationId);
152
+ const getBaseAnnotation = (node2) => {
153
+ const value = getAnnotationById(node2);
154
+ if (value !== void 0) {
155
+ return value;
156
+ }
157
+ if (AST.isUnion(node2)) {
158
+ for (const type of node2.types) {
159
+ const value2 = getBaseAnnotation(type);
160
+ if (value2 !== void 0) {
161
+ return value2;
162
+ }
163
+ }
164
+ }
165
+ };
166
+ return getBaseAnnotation(node);
167
+ };
88
168
 
89
169
  // packages/common/effect/src/url.ts
90
170
  import { AST as AST2 } from "@effect/schema";
@@ -143,15 +223,19 @@ var UrlParser = class {
143
223
  export {
144
224
  AST3 as AST,
145
225
  JSONSchema,
226
+ JsonPath,
227
+ JsonProp,
146
228
  ParamKeyAnnotation,
147
- S,
229
+ S2 as S,
148
230
  UrlParser,
149
231
  VisitResult,
232
+ findAnnotation,
233
+ findNode,
234
+ findProperty,
150
235
  getAnnotation,
151
236
  getParamKeyAnnotation,
152
- getProperty,
153
- getType,
154
- isLeafType,
237
+ getSimpleType,
238
+ isSimpleType,
155
239
  visit
156
240
  };
157
241
  //# sourceMappingURL=index.mjs.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,SAASA,OAAAA,MAAKC,YAAYC,UAAUC,SAAS;;;ACA7C,SAASC,WAA6B;AACtC,SAASC,QAAQC,YAAY;AAE7B,SAASC,iBAAiB;;AASnB,IAAMC,aAAa,CAACC,SAAkB,CAACL,IAAIM,YAAYD,IAAAA,KAAS,CAACL,IAAIO,cAAcF,IAAAA;AAKnF,IAAMG,gBAAgB,CAAIC,cAAsBJ,SACrDH,KAAKF,IAAIQ,cAAiBC,YAAAA,EAAcJ,IAAAA,GAAOJ,OAAOS,cAAc;AAK/D,IAAMC,UAAU,CAACN,SAAAA;AACtB,MAAIL,IAAIY,QAAQP,IAAAA,GAAO;AACrB,WAAOA,KAAKQ,MAAMC,KAAK,CAACC,SAASJ,QAAQI,IAAAA,CAAAA;EAC3C,WAAWf,IAAIgB,aAAaX,IAAAA,GAAO;AACjC,WAAOM,QAAQN,KAAKY,IAAI;EAC1B,OAAO;AACL,WAAOZ;EACT;AACF;AAKO,IAAMa,cAAc,CAACC,QAAuBC,SAAAA;AACjD,MAAIf,OAAgBc,OAAOE;AAC3B,aAAWC,QAAQF,KAAKG,MAAM,GAAA,GAAM;AAClC,UAAMC,QAAQxB,IAAIyB,sBAAsBpB,IAAAA;AACxC,UAAMqB,OAAOF,MAAMV,KAAK,CAACY,UAASA,MAAKC,SAASL,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AA,MAAM;AAC1C,UAAIA,UAAU0B,QAAW;AACvB,cAAMC,QAAQ,KAAKtB,QAAQO,OAAOG,GAAAA;AAClC,YAAIY,OAAO;AACT,gBAAM,EAAEZ,KAAKa,cAAa,IAAKC,MAC7BjC,sBAAsB+B,MAAMN,GAAG,GAC/BS,QAAOC,UAAU,OAAO;YACtBhB,KAAKI,WAAWJ,GAAAA;UAClB,EAAA,CAAA;AAGFP,cAAIS,aAAae,IAAIJ,eAAeK,OAAOjC,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
- "names": ["AST", "JSONSchema", "Schema", "S", "AST", "Option", "pipe", "invariant", "isLeafType", "node", "isTupleType", "isTypeLiteral", "getAnnotation", "annotationId", "getOrUndefined", "getType", "isUnion", "types", "find", "type", "isRefinement", "from", "getProperty", "schema", "path", "ast", "part", "split", "props", "getPropertySignatures", "prop", "name", "undefined", "VisitResult", "visit", "testOrVisitor", "visitor", "visitNode", "test", "depth", "currentPath", "toString", "result", "i", "elementType", "elements", "entries", "AST", "Option", "pipe", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "AST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "Option", "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';\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 type SimpleType = 'object' | 'string' | 'number' | 'boolean' | 'enum' | 'literal';\n\nexport const getSimpleType = (node: AST.AST): SimpleType | undefined => {\n if (AST.isObjectKeyword(node)) {\n return 'object';\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 if (AST.isEnums(node)) {\n return 'enum';\n }\n if (AST.isLiteral(node)) {\n return 'literal';\n }\n};\n\nexport const isSimpleType = (node: AST.AST) => !!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.\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): Transform?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Reuse visitor.\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 // Array.\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.\n else if (AST.isUnion(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 // Refinement.\n else if (AST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n\n return undefined;\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 return undefined;\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n/**\n * Recursively descend into AST to find first matching annotations\n */\nexport const findAnnotation = <T>(node: AST.AST, annotationId: symbol): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId);\n const getBaseAnnotation = (node: AST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (AST.isUnion(node)) {\n for (const type of node.types) {\n const value = getBaseAnnotation(type);\n if (value !== undefined) {\n return value as T;\n }\n }\n }\n };\n\n return getBaseAnnotation(node);\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,SAASA,OAAAA,MAAKC,YAAYC,UAAUC,UAAS;;;ACA7C,SAASC,KAAKC,UAAUC,SAAS;AACjC,SAASC,QAAQC,YAAY;AAE7B,SAASC,iBAAiB;;AAWnB,IAAMC,gBAAgB,CAACC,SAAAA;AAC5B,MAAIP,IAAIQ,gBAAgBD,IAAAA,GAAO;AAC7B,WAAO;EACT;AACA,MAAIP,IAAIS,gBAAgBF,IAAAA,GAAO;AAC7B,WAAO;EACT;AACA,MAAIP,IAAIU,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AMN,MAAM,IAAIC,IAAIF,IAAAA;AACpBG,WAAOC,QAAQG,MAAAA,EAAQW,QAAQ,CAAC,CAACV,KAAKf,KAAAA,MAAM;AAC1C,UAAIA,UAAU0B,QAAW;AACvB,cAAMC,QAAQ,KAAKtB,QAAQO,OAAOG,GAAAA;AAClC,YAAIY,OAAO;AACT,gBAAM,EAAEZ,KAAKa,cAAa,IAAKC,MAC7BjC,sBAAsB+B,MAAMN,GAAG,GAC/BS,QAAOC,UAAU,OAAO;YACtBhB,KAAKI,WAAWJ,GAAAA;UAClB,EAAA,CAAA;AAGFP,cAAIS,aAAae,IAAIJ,eAAeK,OAAOjC,KAAAA,CAAAA;QAC7C;MACF;IACF,CAAA;AAEA,WAAOQ;EACT;AACF;",
6
+ "names": ["AST", "JSONSchema", "Schema", "S", "AST", "Schema", "S", "Option", "pipe", "invariant", "getSimpleType", "node", "isObjectKeyword", "isStringKeyword", "isNumberKeyword", "isBooleanKeyword", "isEnums", "isLiteral", "isSimpleType", "PATH_REGEX", "PROP_REGEX", "JsonPath", "NonEmptyString", "pattern", "JsonProp", "getAnnotation", "annotationId", "getOrUndefined", "VisitResult", "defaultTest", "visit", "testOrVisitor", "visitor", "visitNode", "test", "path", "depth", "result", "isTypeLiteral", "prop", "getPropertySignatures", "currentPath", "name", "toString", "type", "isTupleType", "i", "element", "elements", "entries", "isUnion", "types", "isRefinement", "from", "findNode", "child", "_", "undefined", "findProperty", "schema", "getProp", "rest", "typeNode", "length", "ast", "split", "findAnnotation", "getAnnotationById", "getBaseAnnotation", "value", "AST", "Option", "pipe", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "AST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "constructor", "_schema", "parse", "_url", "url", "URL", "Object", "entries", "fields", "reduce", "params", "key", "type", "searchParams", "get", "decamelize", "isNumberKeyword", "ast", "parseInt", "isBooleanKeyword", "create", "forEach", "undefined", "field", "serializedKey", "pipe", "Option", "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-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10203},"packages/common/effect/dist/lib/node-esm/index.mjs":{"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":4561}}}
1
+ {"inputs":{"packages/common/effect/src/ast.ts":{"bytes":21205,"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":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-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":15614},"packages/common/effect/dist/lib/node-esm/index.mjs":{"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","JsonPath","JsonProp","ParamKeyAnnotation","S","UrlParser","VisitResult","findAnnotation","findNode","findProperty","getAnnotation","getParamKeyAnnotation","getSimpleType","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":4515},"packages/common/effect/src/url.ts":{"bytesInOutput":1624}},"bytes":6709}}}
@@ -1,17 +1,23 @@
1
- import { AST, type Schema as S } from '@effect/schema';
2
- export declare const isLeafType: (node: AST.AST) => boolean;
3
- /**
4
- * Get annotation or return undefined.
5
- */
6
- export declare const getAnnotation: <T>(annotationId: symbol, node: AST.Annotated) => T | undefined;
1
+ import { AST, Schema as S } from '@effect/schema';
2
+ export type SimpleType = 'object' | 'string' | 'number' | 'boolean' | 'enum' | 'literal';
3
+ export declare const getSimpleType: (node: AST.AST) => SimpleType | undefined;
4
+ export declare const isSimpleType: (node: AST.AST) => boolean;
5
+ export type JsonProp = string & {
6
+ __JsonPath: true;
7
+ __JsonProp: true;
8
+ };
9
+ export type JsonPath = string & {
10
+ __JsonPath: true;
11
+ };
7
12
  /**
8
- * Get type node.
13
+ * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html
9
14
  */
10
- export declare const getType: (node: AST.AST) => AST.AST | undefined;
15
+ export declare const JsonPath: S.Schema<JsonPath>;
16
+ export declare const JsonProp: S.Schema<JsonProp>;
11
17
  /**
12
- * Get the AST node for the given property (dot-path).
18
+ * Get annotation or return undefined.
13
19
  */
14
- export declare const getProperty: (schema: S.Schema<any>, path: string) => AST.AST | undefined;
20
+ export declare const getAnnotation: <T>(annotationId: symbol) => (node: AST.Annotated) => T | undefined;
15
21
  export declare enum VisitResult {
16
22
  CONTINUE = 0,
17
23
  /**
@@ -19,12 +25,12 @@ export declare enum VisitResult {
19
25
  */
20
26
  SKIP = 1,
21
27
  /**
22
- * Stop traversing immeditaely.
28
+ * Stop traversing immediately.
23
29
  */
24
30
  EXIT = 2
25
31
  }
26
32
  export type Path = (string | number)[];
27
- export type Tester = (node: AST.AST, path: Path, depth: number) => VisitResult;
33
+ export type Tester = (node: AST.AST, path: Path, depth: number) => VisitResult | undefined;
28
34
  export type Visitor = (node: AST.AST, path: Path, depth: number) => void;
29
35
  /**
30
36
  * Visit leaf nodes.
@@ -36,4 +42,16 @@ export declare const visit: {
36
42
  (node: AST.AST, visitor: Visitor): void;
37
43
  (node: AST.AST, test: Tester, visitor: Visitor): void;
38
44
  };
45
+ /**
46
+ * Recursively descend into AST to find first node that passes the test.
47
+ */
48
+ export declare const findNode: (node: AST.AST, test: (node: AST.AST) => boolean) => AST.AST | undefined;
49
+ /**
50
+ * Get the AST node for the given property (dot-path).
51
+ */
52
+ export declare const findProperty: (schema: S.Schema<any>, path: JsonPath | JsonProp) => AST.AST | undefined;
53
+ /**
54
+ * Recursively descend into AST to find first matching annotations
55
+ */
56
+ export declare const findAnnotation: <T>(node: AST.AST, annotationId: symbol) => T | undefined;
39
57
  //# sour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"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;AAErC,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/effect",
3
- "version": "0.6.14-main.8b352a0",
3
+ "version": "0.6.14-staging.3e2eaca",
4
4
  "description": "Effect utils.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -22,9 +22,9 @@
22
22
  "src"
23
23
  ],
24
24
  "dependencies": {
25
- "@dxos/invariant": "0.6.14-main.8b352a0",
26
- "@dxos/util": "0.6.14-main.8b352a0",
27
- "@dxos/node-std": "0.6.14-main.8b352a0"
25
+ "@dxos/util": "0.6.14-staging.3e2eaca",
26
+ "@dxos/node-std": "0.6.14-staging.3e2eaca",
27
+ "@dxos/invariant": "0.6.14-staging.3e2eaca"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@effect/schema": "^0.75.1",