@dxos/effect 0.8.4-main.67995b8 → 0.8.4-main.69d29f4

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.
Files changed (75) hide show
  1. package/dist/lib/browser/chunk-CGS2ULMK.mjs +11 -0
  2. package/dist/lib/browser/chunk-CGS2ULMK.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +418 -230
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing.mjs +38 -0
  7. package/dist/lib/browser/testing.mjs.map +7 -0
  8. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  9. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +418 -230
  11. package/dist/lib/node-esm/index.mjs.map +4 -4
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing.mjs +38 -0
  14. package/dist/lib/node-esm/testing.mjs.map +7 -0
  15. package/dist/types/src/RuntimeProvider.d.ts +21 -0
  16. package/dist/types/src/RuntimeProvider.d.ts.map +1 -0
  17. package/dist/types/src/ast.d.ts +36 -22
  18. package/dist/types/src/ast.d.ts.map +1 -1
  19. package/dist/types/src/atom-kvs.d.ts +19 -0
  20. package/dist/types/src/atom-kvs.d.ts.map +1 -0
  21. package/dist/types/src/context.d.ts +2 -1
  22. package/dist/types/src/context.d.ts.map +1 -1
  23. package/dist/types/src/dynamic-runtime.d.ts +56 -0
  24. package/dist/types/src/dynamic-runtime.d.ts.map +1 -0
  25. package/dist/types/src/dynamic-runtime.test.d.ts +2 -0
  26. package/dist/types/src/dynamic-runtime.test.d.ts.map +1 -0
  27. package/dist/types/src/errors.d.ts +35 -1
  28. package/dist/types/src/errors.d.ts.map +1 -1
  29. package/dist/types/src/index.d.ts +5 -3
  30. package/dist/types/src/index.d.ts.map +1 -1
  31. package/dist/types/src/interrupt.test.d.ts +2 -0
  32. package/dist/types/src/interrupt.test.d.ts.map +1 -0
  33. package/dist/types/src/{jsonPath.d.ts → json-path.d.ts} +12 -4
  34. package/dist/types/src/json-path.d.ts.map +1 -0
  35. package/dist/types/src/json-path.test.d.ts +2 -0
  36. package/dist/types/src/json-path.test.d.ts.map +1 -0
  37. package/dist/types/src/layers.test.d.ts +2 -0
  38. package/dist/types/src/layers.test.d.ts.map +1 -0
  39. package/dist/types/src/otel.d.ts +17 -0
  40. package/dist/types/src/otel.d.ts.map +1 -0
  41. package/dist/types/src/otel.test.d.ts +2 -0
  42. package/dist/types/src/otel.test.d.ts.map +1 -0
  43. package/dist/types/src/resource.d.ts +6 -2
  44. package/dist/types/src/resource.d.ts.map +1 -1
  45. package/dist/types/src/testing.d.ts +33 -1
  46. package/dist/types/src/testing.d.ts.map +1 -1
  47. package/dist/types/src/url.d.ts +3 -1
  48. package/dist/types/src/url.d.ts.map +1 -1
  49. package/dist/types/tsconfig.tsbuildinfo +1 -1
  50. package/package.json +35 -11
  51. package/src/RuntimeProvider.ts +35 -0
  52. package/src/ast.test.ts +14 -11
  53. package/src/ast.ts +119 -92
  54. package/src/atom-kvs.ts +35 -0
  55. package/src/context.ts +2 -1
  56. package/src/dynamic-runtime.test.ts +465 -0
  57. package/src/dynamic-runtime.ts +195 -0
  58. package/src/errors.test.ts +1 -1
  59. package/src/errors.ts +90 -22
  60. package/src/index.ts +5 -3
  61. package/src/interrupt.test.ts +35 -0
  62. package/src/{jsonPath.test.ts → json-path.test.ts} +47 -8
  63. package/src/{jsonPath.ts → json-path.ts} +29 -4
  64. package/src/layers.test.ts +112 -0
  65. package/src/otel.test.ts +126 -0
  66. package/src/otel.ts +45 -0
  67. package/src/resource.test.ts +5 -4
  68. package/src/resource.ts +10 -5
  69. package/src/sanity.test.ts +30 -15
  70. package/src/testing.ts +53 -1
  71. package/src/url.test.ts +1 -1
  72. package/src/url.ts +5 -2
  73. package/dist/types/src/jsonPath.d.ts.map +0 -1
  74. package/dist/types/src/jsonPath.test.d.ts +0 -2
  75. package/dist/types/src/jsonPath.test.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/ast.ts", "../../../src/jsonPath.ts", "../../../src/url.ts", "../../../src/context.ts", "../../../src/errors.ts", "../../../src/testing.ts", "../../../src/resource.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Option, pipe, SchemaAST, Schema } from 'effect';\nimport { isUndefinedKeyword } from 'effect/SchemaAST';\n\nimport { invariant } from '@dxos/invariant';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type JsonPath, type JsonProp } from './jsonPath';\n\n//\n// Refs\n// https://effect.website/docs/schema/introduction\n// https://www.npmjs.com/package/@effect/schema\n// https://effect-ts.github.io/effect/schema/SchemaAST.ts.html\n//\n\nexport type SimpleType = 'object' | 'string' | 'number' | 'boolean' | 'enum' | 'literal';\n\n/**\n * Get the base type; e.g., traverse through refinements.\n */\nexport const getSimpleType = (node: SchemaAST.AST): SimpleType | undefined => {\n if (\n SchemaAST.isDeclaration(node) ||\n SchemaAST.isObjectKeyword(node) ||\n SchemaAST.isTypeLiteral(node) ||\n isDiscriminatedUnion(node)\n ) {\n return 'object';\n }\n\n if (SchemaAST.isStringKeyword(node)) {\n return 'string';\n }\n if (SchemaAST.isNumberKeyword(node)) {\n return 'number';\n }\n if (SchemaAST.isBooleanKeyword(node)) {\n return 'boolean';\n }\n\n if (SchemaAST.isEnums(node)) {\n return 'enum';\n }\n\n if (SchemaAST.isLiteral(node)) {\n return 'literal';\n }\n};\n\nexport const isSimpleType = (node: SchemaAST.AST): boolean => !!getSimpleType(node);\n\nexport namespace SimpleType {\n /**\n * Returns the default empty value for a given SimpleType.\n * Used for initializing new array values etc.\n */\n export const getDefaultValue = (type: SimpleType): any => {\n switch (type) {\n case 'string': {\n return '';\n }\n case 'number': {\n return 0;\n }\n case 'boolean': {\n return false;\n }\n case 'object': {\n return {};\n }\n default: {\n throw new Error(`Unsupported type for default value: ${type}`);\n }\n }\n };\n}\n\n//\n// Branded types\n//\n\nexport enum VisitResult {\n CONTINUE = 0,\n /**\n * Skip visiting children.\n */\n SKIP = 1,\n /**\n * Stop traversing immediately.\n */\n EXIT = 2,\n}\n\nexport type Path = (string | number)[];\n\nexport type TestFn = (node: SchemaAST.AST, path: Path, depth: number) => VisitResult | boolean | undefined;\n\nexport type VisitorFn = (node: SchemaAST.AST, path: Path, depth: number) => void;\n\nconst defaultTest: TestFn = isSimpleType;\n\n/**\n * Visit leaf nodes.\n * Refs:\n * - https://github.com/syntax-tree/unist-util-visit?tab=readme-ov-file#visitor\n * - https://github.com/syntax-tree/unist-util-is?tab=readme-ov-file#test\n */\nexport const visit: {\n (node: SchemaAST.AST, visitor: VisitorFn): void;\n (node: SchemaAST.AST, test: TestFn, visitor: VisitorFn): void;\n} = (node: SchemaAST.AST, testOrVisitor: TestFn | VisitorFn, visitor?: VisitorFn): void => {\n if (!visitor) {\n visitNode(node, defaultTest, testOrVisitor);\n } else {\n visitNode(node, testOrVisitor as TestFn, visitor);\n }\n};\n\nconst visitNode = (\n node: SchemaAST.AST,\n test: TestFn | undefined,\n visitor: VisitorFn,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n const _result = test?.(node, path, depth);\n const result: VisitResult =\n _result === undefined\n ? VisitResult.CONTINUE\n : typeof _result === 'boolean'\n ? _result\n ? VisitResult.CONTINUE\n : VisitResult.SKIP\n : _result;\n\n if (result === VisitResult.EXIT) {\n return result;\n }\n if (result !== VisitResult.SKIP) {\n visitor(node, path, depth);\n }\n\n // Object.\n if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const currentPath = [...path, prop.name.toString()];\n const result = visitNode(prop.type, test, visitor, currentPath, depth + 1);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Array.\n else if (SchemaAST.isTupleType(node)) {\n for (const [i, element] of node.elements.entries()) {\n const currentPath = [...path, i];\n const result = visitNode(element.type, test, visitor, currentPath, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n for (const type of node.types) {\n const result = visitNode(type, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n const result = visitNode(node.from, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n\n // TODO(burdon): Transforms?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Rewrite using visitNode?\nexport const findNode = (node: SchemaAST.AST, test: (node: SchemaAST.AST) => boolean): SchemaAST.AST | undefined => {\n if (test(node)) {\n return node;\n }\n\n // Object.\n else if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Tuple.\n else if (SchemaAST.isTupleType(node)) {\n for (const [_, element] of node.elements.entries()) {\n const child = findNode(element.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n for (const type of node.types) {\n const child = findNode(type, test);\n if (child) {\n return child;\n }\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n};\n\n/**\n * Get the AST node for the given property (dot-path).\n */\nexport const findProperty = (\n schema: Schema.Schema.AnyNoContext,\n path: JsonPath | JsonProp,\n): SchemaAST.AST | undefined => {\n const getProp = (node: SchemaAST.AST, path: JsonProp[]): SchemaAST.AST | undefined => {\n const [name, ...rest] = path;\n const typeNode = findNode(node, SchemaAST.isTypeLiteral);\n invariant(typeNode);\n for (const prop of SchemaAST.getPropertySignatures(typeNode)) {\n if (prop.name === name) {\n if (rest.length) {\n return getProp(prop.type, rest);\n } else {\n return prop.type;\n }\n }\n }\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n//\n// Annotations\n//\n\nconst defaultAnnotations: Record<string, SchemaAST.Annotated> = {\n ['ObjectKeyword' as const]: SchemaAST.objectKeyword,\n ['StringKeyword' as const]: SchemaAST.stringKeyword,\n ['NumberKeyword' as const]: SchemaAST.numberKeyword,\n ['BooleanKeyword' as const]: SchemaAST.booleanKeyword,\n};\n\n/**\n * Get annotation or return undefined.\n * @param annotationId\n * @param noDefault If true, then return undefined for effect library defined values.\n */\nexport const getAnnotation =\n <T>(annotationId: symbol, noDefault = true) =>\n (node: SchemaAST.AST): T | undefined => {\n // Title fallback seems to be the identifier.\n const id = pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);\n const value = pipe(SchemaAST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\n if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {\n return undefined;\n }\n\n return value;\n };\n\n/**\n * Recursively descend into AST to find first matching annotations.\n * Optionally skips default annotations for basic types (e.g., 'a string').\n */\n// TODO(burdon): Convert to effect pattern (i.e., return operator like getAnnotation).\nexport const findAnnotation = <T>(node: SchemaAST.AST, annotationId: symbol, noDefault = true): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId, noDefault);\n\n const getBaseAnnotation = (node: SchemaAST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n return getAnnotationById(node.types[0]) as T;\n }\n }\n };\n\n return getBaseAnnotation(node);\n};\n\n//\n// Unions\n//\n\n/**\n * Effect Schema.optional creates a union type with undefined as the second type.\n */\nexport const isOption = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.length === 2 && SchemaAST.isUndefinedKeyword(node.types[1]);\n};\n\n/**\n * Determines if the node is a union of literal types.\n */\nexport const isLiteralUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);\n};\n\n/**\n * Determines if the node is a discriminated union.\n */\nexport const isDiscriminatedUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;\n};\n\n/**\n * Get the discriminating properties for the given union type.\n */\nexport const getDiscriminatingProps = (node: SchemaAST.AST): string[] | undefined => {\n invariant(SchemaAST.isUnion(node));\n if (isOption(node)) {\n return;\n }\n\n // Get common literals across all types.\n return node.types.reduce<string[]>((shared, type) => {\n const props = SchemaAST.getPropertySignatures(type)\n // TODO(burdon): Should check each literal is unique.\n .filter((p) => SchemaAST.isLiteral(p.type))\n .map((p) => p.name.toString());\n\n // Return common literals.\n return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));\n }, []);\n};\n\n/**\n * Get the discriminated type for the given value.\n */\nexport const getDiscriminatedType = (\n node: SchemaAST.AST,\n value: Record<string, any> = {},\n): SchemaAST.AST | undefined => {\n invariant(SchemaAST.isUnion(node));\n invariant(value);\n const props = getDiscriminatingProps(node);\n if (!props?.length) {\n return;\n }\n\n // Match provided values.\n for (const type of node.types) {\n const match = SchemaAST.getPropertySignatures(type)\n .filter((prop) => props?.includes(prop.name.toString()))\n .every((prop) => {\n invariant(SchemaAST.isLiteral(prop.type));\n return prop.type.literal === value[prop.name.toString()];\n });\n\n if (match) {\n return type;\n }\n }\n\n // Create union of discriminating properties.\n // NOTE: This may not work with non-overlapping variants.\n // TODO(burdon): Iterate through props and knock-out variants that don't match.\n const fields = Object.fromEntries(\n props\n .map((prop) => {\n const literals = node.types\n .map((type) => {\n const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop)!;\n invariant(SchemaAST.isLiteral(literal.type));\n return literal.type.literal;\n })\n .filter(isNonNullable);\n\n return literals.length ? [prop, Schema.Literal(...literals)] : undefined;\n })\n .filter(isNonNullable),\n );\n\n const schema = Schema.Struct(fields);\n return schema.ast;\n};\n\n/**\n * Maps AST nodes.\n * The user is responsible for recursively calling {@link mapAst} on the SchemaAST.\n * NOTE: Will evaluate suspended ASTs.\n */\nexport const mapAst = (\n ast: SchemaAST.AST,\n f: (ast: SchemaAST.AST, key: keyof any | undefined) => SchemaAST.AST,\n): SchemaAST.AST => {\n switch (ast._tag) {\n case 'TypeLiteral': {\n return new SchemaAST.TypeLiteral(\n ast.propertySignatures.map(\n (prop) =>\n new SchemaAST.PropertySignature(\n prop.name,\n f(prop.type, prop.name),\n prop.isOptional,\n prop.isReadonly,\n prop.annotations,\n ),\n ),\n ast.indexSignatures,\n );\n }\n case 'Union': {\n return SchemaAST.Union.make(ast.types.map(f), ast.annotations);\n }\n case 'TupleType': {\n return new SchemaAST.TupleType(\n ast.elements.map((t, index) => new SchemaAST.OptionalType(f(t.type, index), t.isOptional, t.annotations)),\n ast.rest.map((t) => new SchemaAST.Type(f(t.type, undefined), t.annotations)),\n ast.isReadonly,\n ast.annotations,\n );\n }\n case 'Suspend': {\n const newAst = f(ast.f(), undefined);\n return new SchemaAST.Suspend(() => newAst, ast.annotations);\n }\n default: {\n // TODO(dmaretskyi): Support more nodes.\n return ast;\n }\n }\n};\n\n/**\n * @returns true if AST is for Array(T) or optional(Array(T)).\n */\nexport const isArrayType = (node: SchemaAST.AST): boolean => {\n return (\n SchemaAST.isTupleType(node) ||\n (SchemaAST.isUnion(node) &&\n node.types.some(isArrayType) &&\n node.types.some(isUndefinedKeyword) &&\n node.types.length === 2)\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema, Option } from 'effect';\nimport { JSONPath } from 'jsonpath-plus';\n\nimport { invariant } from '@dxos/invariant';\n\nexport type JsonProp = string & { __JsonPath: true; __JsonProp: true };\nexport type JsonPath = string & { __JsonPath: true };\n\nconst PATH_REGEX = /^($|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*|\\[\\d+\\](?:\\.)?)*$)/;\nconst PROP_REGEX = /^\\w+$/;\n\n/**\n * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html\n */\nexport const JsonPath = Schema.String.pipe(Schema.pattern(PATH_REGEX)).annotations({\n title: 'JSON path',\n description: 'JSON path to a property',\n}) as any as Schema.Schema<JsonPath>;\nexport const JsonProp = Schema.NonEmptyString.pipe(\n Schema.pattern(PROP_REGEX, {\n message: () => 'Property name must contain only letters, numbers, and underscores',\n }),\n) as any as Schema.Schema<JsonProp>;\n\nexport const isJsonPath = (value: unknown): value is JsonPath => {\n return Option.isSome(Schema.validateOption(JsonPath)(value));\n};\n\n/**\n * Creates a JsonPath from an array of path segments.\n *\n * Currently supports:\n * - Simple property access (e.g., 'foo.bar')\n * - Array indexing with non-negative integers (e.g., 'foo[0]')\n * - Identifiers starting with letters, underscore, or $ (e.g., '$foo', '_bar')\n * - Dot notation for nested properties (e.g., 'foo.bar.baz')\n *\n * Does not support (yet?).\n * - Recursive descent (..)\n * - Wildcards (*)\n * - Array slicing\n * - Filters\n * - Negative indices\n *\n * @param path Array of string or number segments\n * @returns Valid JsonPath or undefined if invalid\n */\nexport const createJsonPath = (path: (string | number)[]): JsonPath => {\n const candidatePath = path\n .map((p, i) => {\n if (typeof p === 'number') {\n return `[${p}]`;\n } else {\n return i === 0 ? p : `.${p}`;\n }\n })\n .join('');\n\n invariant(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);\n return candidatePath;\n};\n\n/**\n * Converts Effect validation path format (e.g. \"addresses.[0].zip\")\n * to JsonPath format (e.g., \"addresses[0].zip\")\n */\nexport const fromEffectValidationPath = (effectPath: string): JsonPath => {\n // Handle array notation: convert \"prop.[0]\" to \"prop[0]\"\n const jsonPath = effectPath.replace(/\\.\\[(\\d+)\\]/g, '[$1]');\n invariant(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);\n return jsonPath;\n};\n\n/**\n * Splits a JsonPath into its constituent parts.\n * Handles property access and array indexing.\n */\nexport const splitJsonPath = (path: JsonPath): string[] => {\n if (!isJsonPath(path)) {\n return [];\n }\n\n return (\n path\n .match(/[a-zA-Z_$][\\w$]*|\\[\\d+\\]/g)\n ?.map((part) => (part.startsWith('[') ? part.replace(/[[\\]]/g, '') : part)) ?? []\n );\n};\n\n/**\n * Applies a JsonPath to an object.\n */\nexport const getField = (object: any, path: JsonPath): any => {\n // By default, JSONPath returns an array of results.\n return JSONPath({ path, json: object })[0];\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { SchemaAST, type Schema, Option, pipe } from 'effect';\n\nimport { decamelize } from '@dxos/util';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: SchemaAST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n SchemaAST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends Schema.Annotable.All>(self: S): Schema.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: Schema.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (SchemaAST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (SchemaAST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = pipe(\n getParamKeyAnnotation(field.ast),\n Option.getOrElse(() => ({\n key: decamelize(key),\n })),\n );\n\n url.searchParams.set(serializedKey, String(value));\n }\n }\n });\n\n return url;\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect, type Scope } from 'effect';\n\nimport { Context } from '@dxos/context';\n\n// TODO(dmaretskyi): Error handling.\nexport const contextFromScope = (): Effect.Effect<Context, never, Scope.Scope> =>\n Effect.gen(function* () {\n const ctx = new Context();\n yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));\n return ctx;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Cause, Chunk, Effect, Exit, GlobalValue, Option } from 'effect';\nimport type { AnySpan, Span } from 'effect/Tracer';\n\nconst spanSymbol = Symbol.for('effect/SpanAnnotation');\nconst originalSymbol = Symbol.for('effect/OriginalAnnotation');\nconst spanToTrace = GlobalValue.globalValue('effect/Tracer/spanToTrace', () => new WeakMap());\nconst locationRegex = /\\((.*)\\)/g;\n\n/**\n * Adds effect spans.\n * Removes effect internal functions.\n * Unwraps error proxy.\n */\nconst prettyErrorStack = (error: any, appendStacks: string[] = []): any => {\n const span = error[spanSymbol];\n\n const lines = typeof error.stack === 'string' ? error.stack.split('\\n') : [];\n const out = [];\n\n let atStack = false;\n for (let i = 0; i < lines.length; i++) {\n if (!atStack && !lines[i].startsWith(' at ')) {\n out.push(lines[i]);\n continue;\n }\n atStack = true;\n\n if (lines[i].includes(' at new BaseEffectError') || lines[i].includes(' at new YieldableError')) {\n i++;\n continue;\n }\n if (lines[i].includes('Generator.next')) {\n break;\n }\n if (lines[i].includes('effect_internal_function')) {\n break;\n }\n out.push(\n lines[i]\n .replace(/at .*effect_instruction_i.*\\((.*)\\)/, 'at $1')\n .replace(/EffectPrimitive\\.\\w+/, '<anonymous>')\n .replace(/at Arguments\\./, 'at '),\n );\n }\n\n if (span) {\n let current: Span | AnySpan | undefined = span;\n let i = 0;\n while (current && current._tag === 'Span' && i < 10) {\n const stackFn = spanToTrace.get(current);\n if (typeof stackFn === 'function') {\n const stack = stackFn();\n if (typeof stack === 'string') {\n const locationMatchAll = stack.matchAll(locationRegex);\n let match = false;\n for (const [, location] of locationMatchAll) {\n match = true;\n out.push(` at ${current.name} (${location})`);\n }\n if (!match) {\n out.push(` at ${current.name} (${stack.replace(/^at /, '')})`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n current = Option.getOrUndefined(current.parent);\n i++;\n }\n }\n\n out.push(...appendStacks);\n\n if (error[originalSymbol]) {\n error = error[originalSymbol];\n }\n if (error.cause) {\n error.cause = prettyErrorStack(error.cause);\n }\n\n Object.defineProperty(error, 'stack', {\n value: out.join('\\n'),\n writable: true,\n enumerable: false,\n configurable: true,\n });\n\n return error;\n};\n\n/**\n * Runs the embedded effect asynchronously and throws any failures and defects as errors.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const runAndForwardErrors = async <A, E>(\n effect: Effect.Effect<A, E, never>,\n options?: { signal?: AbortSignal },\n): Promise<A> => {\n const exit = await Effect.runPromiseExit(effect, options);\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n if (Cause.isEmpty(exit.cause)) {\n throw new Error('Fiber failed without a cause');\n } else if (Cause.isInterrupted(exit.cause)) {\n throw new Error('Fiber was interrupted');\n } else {\n const errors = [...Chunk.toArray(Cause.failures(exit.cause)), ...Chunk.toArray(Cause.defects(exit.cause))];\n\n const getStackFrames = (): string[] => {\n const o: { stack: string } = {} as any;\n Error.captureStackTrace(o, getStackFrames);\n return o.stack.split('\\n').slice(1);\n };\n\n const stackFrames = getStackFrames();\n const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));\n\n if (newErrors.length === 1) {\n throw newErrors[0];\n } else {\n throw new AggregateError(newErrors);\n }\n }\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect } from 'effect';\nimport type { TestContext } from 'vitest';\n\nexport namespace TestHelpers {\n /**\n * Skip the test if the condition is false.\n *\n * Exmaple:\n * ```ts\n * it.effect(\n * 'should process an agentic loop using Claude',\n * Effect.fn(function* ({ expect }) {\n * // ...\n * }),\n * TestHelpers.runIf(process.env.ANTHROPIC_API_KEY),\n * );\n * ```\n */\n export const runIf =\n (condition: unknown) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (!condition) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n\n /**\n * Skip the test if the condition is true.\n *\n * Exmaple:\n * ```ts\n * it.effect(\n * 'should process an agentic loop using Claude',\n * Effect.fn(function* ({ expect }) {\n * // ...\n * }),\n * TestHelpers.skipIf(!process.env.ANTHROPIC_API_KEY),\n * );\n * ```\n */\n export const skipIf =\n (condition: unknown) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (condition) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect } from 'effect';\n\nimport type { Lifecycle } from '@dxos/context';\n\n// TODO(dmaretskyi): Extract to effect-utils.\nexport const accuireReleaseResource = <T extends Lifecycle>(getResource: () => T) =>\n Effect.acquireRelease(\n Effect.gen(function* () {\n const resource = getResource();\n yield* Effect.promise(async () => {\n resource.open?.();\n return undefined;\n });\n return resource;\n }),\n (resource) =>\n Effect.promise(async () => {\n resource.close?.();\n return undefined;\n }),\n );\n"],
5
- "mappings": ";;;AAIA,SAASA,QAAQC,MAAMC,WAAWC,cAAc;AAChD,SAASC,0BAA0B;AAEnC,SAASC,iBAAiB;AAC1B,SAASC,qBAAqB;;AAgBvB,IAAMC,gBAAgB,CAACC,SAAAA;AAC5B,MACEN,UAAUO,c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6
- "names": ["Option", "pipe", "SchemaAST", "Schema", "isUndefinedKeyword", "invariant", "isNonNullable", "getSimpleType", "node", "isDeclaration", "isObjectKeyword", "isTypeLiteral", "isDiscriminatedUnion", "isStringKeyword", "isNumberKeyword", "isBooleanKeyword", "isEnums", "isLiteral", "isSimpleType", "SimpleType", "getDefaultValue", "type", "Error", "VisitResult", "defaultTest", "visit", "testOrVisitor", "visitor", "visitNode", "test", "path", "depth", "_result", "result", "undefined", "prop", "getPropertySignatures", "currentPath", "name", "toString", "isTupleType", "i", "element", "elements", "entries", "isUnion", "types", "isRefinement", "from", "findNode", "child", "_", "isOption", "findProperty", "schema", "getProp", "rest", "typeNode", "length", "ast", "split", "defaultAnnotations", "objectKeyword", "stringKeyword", "numberKeyword", "booleanKeyword", "getAnnotation", "annotationId", "noDefault", "id", "getIdentifierAnnotation", "getOrUndefined", "value", "_tag", "annotations", "findAnnotation", "getAnnotationById", "getBaseAnnotation", "isLiteralUnion", "every", "getDiscriminatingProps", "reduce", "shared", "props", "filter", "p", "map", "includes", "getDiscriminatedType", "match", "literal", "fields", "Object", "fromEntries", "literals", "find", "Literal", "Struct", "mapAst", "f", "TypeLiteral", "propertySignatures", "PropertySignature", "isOptional", "isReadonly", "indexSignatures", "Union", "make", "TupleType", "t", "index", "OptionalType", "Type", "newAst", "Suspend", "isArrayType", "some", "Schema", "Option", "JSONPath", "invariant", "PATH_REGEX", "PROP_REGEX", "JsonPath", "String", "pipe", "pattern", "annotations", "title", "description", "JsonProp", "NonEmptyString", "message", "isJsonPath", "value", "isSome", "validateOption", "createJsonPath", "path", "candidatePath", "map", "p", "i", "join", "fromEffectValidationPath", "effectPath", "jsonPath", "replace", "splitJsonPath", "match", "part", "startsWith", "getField", "object", "json", "SchemaAST", "Option", "pipe", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "SchemaAST", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "_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", "Effect", "Context", "contextFromScope", "gen", "ctx", "addFinalizer", "promise", "dispose", "Cause", "Chunk", "Effect", "Exit", "GlobalValue", "Option", "spanSymbol", "Symbol", "for", "originalSymbol", "spanToTrace", "GlobalValue", "globalValue", "WeakMap", "locationRegex", "prettyErrorStack", "error", "appendStacks", "span", "lines", "stack", "split", "out", "atStack", "i", "length", "startsWith", "push", "includes", "replace", "current", "_tag", "stackFn", "get", "locationMatchAll", "matchAll", "match", "location", "name", "Option", "getOrUndefined", "parent", "cause", "Object", "defineProperty", "value", "join", "writable", "enumerable", "configurable", "runAndForwardErrors", "effect", "options", "exit", "Effect", "runPromiseExit", "Exit", "isSuccess", "Cause", "isEmpty", "Error", "isInterrupted", "errors", "Chunk", "toArray", "failures", "defects", "getStackFrames", "o", "captureStackTrace", "slice", "stackFrames", "newErrors", "map", "AggregateError", "Effect", "TestHelpers", "runIf", "condition", "effect", "ctx", "Effect", "gen", "skip", "skipIf", "Effect", "accuireReleaseResource", "getResource", "Effect", "acquireRelease", "gen", "resource", "promise", "open", "undefined", "close"]
3
+ "sources": ["../../../src/ast.ts", "../../../src/atom-kvs.ts", "../../../src/context.ts", "../../../src/dynamic-runtime.ts", "../../../src/errors.ts", "../../../src/json-path.ts", "../../../src/resource.ts", "../../../src/url.ts", "../../../src/RuntimeProvider.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { invariant } from '@dxos/invariant';\nimport { isNonNullable } from '@dxos/util';\n\nimport { type JsonPath, type JsonProp } from './json-path';\n\n//\n// Refs\n// https://effect.website/docs/schema/introduction\n// https://www.npmjs.com/package/@effect/schema\n// https://effect-ts.github.io/effect/schema/SchemaAST.ts.html\n//\n\n/**\n * Unwraps and collects refinement filters.\n */\nconst reduceRefinements = (\n type: SchemaAST.AST,\n refinements: SchemaAST.Refinement['filter'][] = [],\n): { type: SchemaAST.AST; refinements: SchemaAST.Refinement['filter'][] } => {\n if (SchemaAST.isRefinement(type)) {\n const annotations = type.annotations;\n const filter = type.filter;\n const nextType = { ...type.from, annotations: { ...type.annotations, ...annotations } } as SchemaAST.AST;\n return reduceRefinements(nextType, [...refinements, filter]);\n }\n\n return { type, refinements };\n};\n\n/**\n * Get the base type of a property.\n *\n * Unwraps refinements and optional unions.\n */\nexport const getBaseType = (\n prop: SchemaAST.PropertySignature | SchemaProperty,\n): { type: SchemaAST.AST; refinements: SchemaAST.Refinement['filter'][] } => {\n const encoded = SchemaAST.encodedBoundAST(prop.type);\n // Extract property ast from optional union.\n const unwrapped = prop.isOptional && encoded._tag === 'Union' ? encoded.types[0] : encoded;\n return reduceRefinements(unwrapped);\n};\n\nexport type SchemaProperty = Pick<SchemaAST.PropertySignature, 'name' | 'type' | 'isOptional' | 'isReadonly'> & {\n /** Can be used to validate the property to the spec of the initial AST. */\n refinements: SchemaAST.Refinement['filter'][];\n};\n\n/**\n * Get the property types of an AST.\n */\nexport const getProperties = (ast: SchemaAST.AST): SchemaProperty[] => {\n const properties = SchemaAST.getPropertySignatures(ast);\n return properties.map((prop) => ({\n ...getBaseType(prop),\n name: prop.name,\n isOptional: prop.isOptional,\n isReadonly: prop.isReadonly,\n }));\n};\n\n//\n// Branded types\n//\n\nexport enum VisitResult {\n CONTINUE = 0,\n /**\n * Skip visiting children.\n */\n SKIP = 1,\n /**\n * Stop traversing immediately.\n */\n EXIT = 2,\n}\n\nexport type Path = (string | number)[];\n\nexport type TestFn = (node: SchemaAST.AST, path: Path, depth: number) => VisitResult | boolean | undefined;\n\nexport type VisitorFn = (node: SchemaAST.AST, path: Path, depth: number) => void;\n\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 = (node: SchemaAST.AST, testOrVisitor: TestFn | VisitorFn, visitor: VisitorFn): void => {\n visitNode(node, testOrVisitor as TestFn, visitor);\n};\n\nconst visitNode = (\n node: SchemaAST.AST,\n test: TestFn | undefined,\n visitor: VisitorFn,\n path: Path = [],\n depth = 0,\n): VisitResult | undefined => {\n const $result = test?.(node, path, depth);\n const result: VisitResult =\n $result === undefined\n ? VisitResult.CONTINUE\n : typeof $result === 'boolean'\n ? $result\n ? VisitResult.CONTINUE\n : VisitResult.SKIP\n : $result;\n\n if (result === VisitResult.EXIT) {\n return result;\n }\n if (result !== VisitResult.SKIP) {\n visitor(node, path, depth);\n }\n\n // Object.\n if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const currentPath = [...path, prop.name.toString()];\n const result = visitNode(prop.type, test, visitor, currentPath, depth + 1);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Array.\n else if (SchemaAST.isTupleType(node)) {\n for (const [i, element] of node.elements.entries()) {\n const currentPath = [...path, i];\n const result = visitNode(element.type, test, visitor, currentPath, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n for (const type of node.types) {\n const result = visitNode(type, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n }\n\n // Refinement.\n else if (SchemaAST.isRefinement(node)) {\n const result = visitNode(node.from, test, visitor, path, depth);\n if (result === VisitResult.EXIT) {\n return result;\n }\n }\n\n // TODO(burdon): Transforms?\n};\n\n/**\n * Recursively descend into AST to find first node that passes the test.\n */\n// TODO(burdon): Rewrite using visitNode?\nexport const findNode = (node: SchemaAST.AST, test: (node: SchemaAST.AST) => boolean): SchemaAST.AST | undefined => {\n if (test(node)) {\n return node;\n }\n\n // Object.\n else if (SchemaAST.isTypeLiteral(node)) {\n for (const prop of SchemaAST.getPropertySignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n for (const prop of getIndexSignatures(node)) {\n const child = findNode(prop.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Tuple.\n else if (SchemaAST.isTupleType(node)) {\n for (const [_, element] of node.elements.entries()) {\n const child = findNode(element.type, test);\n if (child) {\n return child;\n }\n }\n }\n\n // Branching union (e.g., optional, discriminated unions).\n else if (SchemaAST.isUnion(node)) {\n if (isLiteralUnion(node)) {\n return undefined;\n }\n\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 (SchemaAST.isRefinement(node)) {\n return findNode(node.from, test);\n }\n};\n\n/**\n * Get the AST node for the given property (dot-path).\n */\nexport const findProperty = (\n schema: Schema.Schema.AnyNoContext,\n path: JsonPath | JsonProp,\n): SchemaAST.AST | undefined => {\n const getProp = (node: SchemaAST.AST, path: JsonProp[]): SchemaAST.AST | undefined => {\n const [name, ...rest] = path;\n const typeNode = findNode(node, SchemaAST.isTypeLiteral);\n invariant(typeNode);\n for (const prop of SchemaAST.getPropertySignatures(typeNode)) {\n if (prop.name === name) {\n if (rest.length) {\n return getProp(prop.type, rest);\n } else {\n return prop.type;\n }\n }\n }\n };\n\n return getProp(schema.ast, path.split('.') as JsonProp[]);\n};\n\n//\n// Annotations\n//\n\nconst defaultAnnotations: Record<string, SchemaAST.Annotated> = {\n ['ObjectKeyword' as const]: SchemaAST.objectKeyword,\n ['StringKeyword' as const]: SchemaAST.stringKeyword,\n ['NumberKeyword' as const]: SchemaAST.numberKeyword,\n ['BooleanKeyword' as const]: SchemaAST.booleanKeyword,\n};\n\n/**\n * Get annotation or return undefined.\n * @param annotationId\n * @param noDefault If true, then return undefined for effect library defined values.\n */\nexport const getAnnotation =\n <T>(annotationId: symbol, noDefault = true) =>\n (node: SchemaAST.AST): T | undefined => {\n // Title fallback seems to be the identifier.\n const id = Function.pipe(SchemaAST.getIdentifierAnnotation(node), Option.getOrUndefined);\n const value = Function.pipe(SchemaAST.getAnnotation<T>(annotationId)(node), Option.getOrUndefined);\n if (noDefault && (value === defaultAnnotations[node._tag]?.annotations[annotationId] || value === id)) {\n return undefined;\n }\n\n return value;\n };\n\n/**\n * Recursively descend into AST to find first matching annotations.\n * Optionally skips default annotations for basic types (e.g., 'a string').\n */\n// TODO(burdon): Convert to effect pattern (i.e., return operator like getAnnotation).\nexport const findAnnotation = <T>(node: SchemaAST.AST, annotationId: symbol, noDefault = true): T | undefined => {\n const getAnnotationById = getAnnotation(annotationId, noDefault);\n\n const getBaseAnnotation = (node: SchemaAST.AST): T | undefined => {\n const value = getAnnotationById(node);\n if (value !== undefined) {\n return value as T;\n }\n\n if (SchemaAST.isUnion(node)) {\n if (isOption(node)) {\n return getAnnotationById(node.types[0]) as T;\n }\n }\n };\n\n return getBaseAnnotation(node);\n};\n\n//\n// Unions\n//\n\n/**\n * Effect Schema.optional creates a union type with undefined as the second type.\n */\nexport const isOption = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && node.types.length === 2 && SchemaAST.isUndefinedKeyword(node.types[1]);\n};\n\n/**\n * Determines if the node is a union of literal types.\n */\nexport const isLiteralUnion = (node: SchemaAST.AST): node is SchemaAST.Union<SchemaAST.Literal> => {\n return SchemaAST.isUnion(node) && node.types.every(SchemaAST.isLiteral);\n};\n\n/**\n * Determines if the node is an array type.\n */\nexport const isArrayType = (node: SchemaAST.AST): node is SchemaAST.TupleType => {\n return SchemaAST.isTupleType(node) && node.elements.length === 0 && node.rest.length === 1;\n};\n\n/**\n * Get the type of the array elements.\n */\nexport const getArrayElementType = (node: SchemaAST.AST): SchemaAST.AST | undefined => {\n return isArrayType(node) ? node.rest.at(0)?.type : undefined;\n};\n\n/**\n * Determines if the node is a tuple type.\n */\nexport const isTupleType = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isTupleType(node) && node.elements.length > 0;\n};\n\n/**\n * Determines if the node is a discriminated union.\n */\nexport const isDiscriminatedUnion = (node: SchemaAST.AST): boolean => {\n return SchemaAST.isUnion(node) && !!getDiscriminatingProps(node)?.length;\n};\n\n/**\n * Get the discriminating properties for the given union type.\n */\nexport const getDiscriminatingProps = (node: SchemaAST.AST): string[] | undefined => {\n invariant(SchemaAST.isUnion(node));\n if (isOption(node)) {\n return;\n }\n\n // Get common literals across all types.\n return node.types.reduce<string[]>((shared, type) => {\n const props = SchemaAST.getPropertySignatures(type)\n // TODO(burdon): Should check each literal is unique.\n .filter((p) => SchemaAST.isLiteral(p.type))\n .map((p) => p.name.toString());\n\n // Return common literals.\n return shared.length === 0 ? props : shared.filter((prop) => props.includes(prop));\n }, []);\n};\n\n/**\n * Get the discriminated type for the given value.\n */\nexport const getDiscriminatedType = (\n node: SchemaAST.AST,\n value: Record<string, any> = {},\n): SchemaAST.AST | undefined => {\n invariant(SchemaAST.isUnion(node));\n invariant(value);\n const props = getDiscriminatingProps(node);\n if (!props?.length) {\n return;\n }\n\n // Match provided values.\n for (const type of node.types) {\n const match = SchemaAST.getPropertySignatures(type)\n .filter((prop) => props?.includes(prop.name.toString()))\n .every((prop) => {\n invariant(SchemaAST.isLiteral(prop.type));\n return prop.type.literal === value[prop.name.toString()];\n });\n\n if (match) {\n return type;\n }\n }\n\n // Create union of discriminating properties.\n // NOTE: This may not work with non-overlapping variants.\n // TODO(burdon): Iterate through props and knock-out variants that don't match.\n const fields = Object.fromEntries(\n props\n .map((prop) => {\n const literals = node.types\n .map((type) => {\n const literal = SchemaAST.getPropertySignatures(type).find((p) => p.name.toString() === prop)!;\n invariant(SchemaAST.isLiteral(literal.type));\n return literal.type.literal;\n })\n .filter(isNonNullable);\n\n return literals.length ? [prop, Schema.Literal(...literals)] : undefined;\n })\n .filter(isNonNullable),\n );\n\n const schema = Schema.Struct(fields);\n return schema.ast;\n};\n\n/**\n * Determines if the node is a nested object type.\n */\nexport const isNestedType = (node: SchemaAST.AST): boolean => {\n return (\n SchemaAST.isDeclaration(node) ||\n SchemaAST.isObjectKeyword(node) ||\n SchemaAST.isTypeLiteral(node) ||\n // TODO(wittjosiah): Tuples are actually arrays.\n isTupleType(node) ||\n isDiscriminatedUnion(node)\n );\n};\n\n/**\n * Maps AST nodes.\n * The user is responsible for recursively calling {@link mapAst} on the SchemaAST.\n * NOTE: Will evaluate suspended ASTs.\n */\nexport const mapAst = (\n ast: SchemaAST.AST,\n f: (ast: SchemaAST.AST, key: keyof any | undefined) => SchemaAST.AST,\n): SchemaAST.AST => {\n switch (ast._tag) {\n case 'TypeLiteral': {\n return new SchemaAST.TypeLiteral(\n ast.propertySignatures.map(\n (prop) =>\n new SchemaAST.PropertySignature(\n prop.name,\n f(prop.type, prop.name),\n prop.isOptional,\n prop.isReadonly,\n prop.annotations,\n ),\n ),\n ast.indexSignatures,\n ast.annotations,\n );\n }\n case 'Union': {\n return SchemaAST.Union.make(ast.types.map(f), ast.annotations);\n }\n case 'TupleType': {\n return new SchemaAST.TupleType(\n ast.elements.map((t, index) => new SchemaAST.OptionalType(f(t.type, index), t.isOptional, t.annotations)),\n ast.rest.map((t) => new SchemaAST.Type(f(t.type, undefined), t.annotations)),\n ast.isReadonly,\n ast.annotations,\n );\n }\n case 'Suspend': {\n const newAst = f(ast.f(), undefined);\n return new SchemaAST.Suspend(() => newAst, ast.annotations);\n }\n default: {\n // TODO(dmaretskyi): Support more nodes.\n return ast;\n }\n }\n};\n\nconst getIndexSignatures = (ast: SchemaAST.AST): Array<SchemaAST.IndexSignature> => {\n const annotation = SchemaAST.getSurrogateAnnotation(ast);\n if (Option.isSome(annotation)) {\n return getIndexSignatures(annotation.value);\n }\n switch (ast._tag) {\n case 'TypeLiteral':\n return ast.indexSignatures.slice();\n case 'Suspend':\n return getIndexSignatures(ast.f());\n case 'Refinement':\n return getIndexSignatures(ast.from);\n }\n return [];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as BrowserKeyValueStore from '@effect/platform-browser/BrowserKeyValueStore';\nimport { Atom } from '@effect-atom/atom-react';\nimport type * as Schema from 'effect/Schema';\n\n// TODO(wittjosiah): This is currently provided for convenience but maybe should be removed.\nconst defaultRuntime = Atom.runtime(BrowserKeyValueStore.layerLocalStorage);\n\n/**\n * Creates a KVS-backed atom for structured settings using Atom.kvs.\n * The entire object is stored as a single localStorage key with JSON serialization.\n *\n * @param options.key - The localStorage key to store the value under.\n * @param options.schema - Effect Schema for the value type.\n * @param options.defaultValue - Function returning the default value.\n * @param options.runtime - Optional custom Atom runtime (defaults to localStorage).\n * @returns A writable atom that persists to localStorage.\n */\nexport const createKvsStore = <T extends Record<string, any>>(options: {\n key: string;\n schema: Schema.Schema<T>;\n defaultValue: () => T;\n runtime?: ReturnType<typeof Atom.runtime>;\n}): Atom.Writable<T> => {\n const runtime = options.runtime ?? defaultRuntime;\n return Atom.kvs({\n runtime,\n key: options.key,\n schema: options.schema,\n defaultValue: options.defaultValue,\n }).pipe(Atom.keepAlive);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Scope from 'effect/Scope';\n\nimport { Context } from '@dxos/context';\n\n// TODO(dmaretskyi): Error handling.\nexport const contextFromScope = (): Effect.Effect<Context, never, Scope.Scope> =>\n Effect.gen(function* () {\n const ctx = new Context();\n yield* Effect.addFinalizer(() => Effect.promise(() => ctx.dispose()));\n return ctx;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport type * as Fiber from 'effect/Fiber';\nimport type * as ManagedRuntime from 'effect/ManagedRuntime';\nimport * as Option from 'effect/Option';\nimport * as Runtime from 'effect/Runtime';\n\nimport { unwrapExit } from './errors';\n\n/**\n * Helper type to construct a union of tag identifiers from an array of tags.\n */\nexport type TagsToContext<Tags extends ReadonlyArray<Context.Tag<any, any>>> = Tags extends readonly [\n infer Head,\n ...infer Tail,\n]\n ? Head extends Context.Tag<infer Id, any>\n ? Tail extends ReadonlyArray<Context.Tag<any, any>>\n ? Id | TagsToContext<Tail>\n : Id\n : never\n : never;\n\n/**\n * A runtime wrapper that validates required tags are available at runtime\n * while providing type-level guarantees that effects require those tags.\n */\nexport interface DynamicRuntime<Tags extends ReadonlyArray<Context.Tag<any, any>>> {\n /**\n * Run an effect as a promise that requires the specified tags.\n */\n readonly runPromise: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Promise<A>;\n\n /**\n * Run an effect synchronously that requires the specified tags.\n */\n readonly runSync: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => A;\n\n /**\n * Run an effect synchronously returning exit that requires the specified tags.\n */\n readonly runSyncExit: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Exit.Exit<A, E>;\n\n /**\n * Run an effect as a promise returning exit that requires the specified tags.\n */\n readonly runPromiseExit: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Promise<Exit.Exit<A, E>>;\n\n /**\n * Fork an effect that requires the specified tags.\n */\n readonly runFork: <A, E>(effect: Effect.Effect<A, E, TagsToContext<Tags>>) => Fiber.RuntimeFiber<A, E>;\n\n /**\n * Get the runtime as an effect that requires the specified tags.\n */\n readonly runtimeEffect: Effect.Effect<Runtime.Runtime<TagsToContext<Tags>>, never, never>;\n\n /**\n * Dispose the underlying managed runtime.\n */\n readonly dispose: () => Promise<void>;\n\n /**\n * Get the underlying managed runtime.\n */\n readonly managedRuntime: ManagedRuntime.ManagedRuntime<any, any>;\n}\n\n/**\n * Validate that all required tags are present in the runtime context.\n */\nconst validateTags = <Tags extends ReadonlyArray<Context.Tag<any, any>>>(\n context: Context.Context<any>,\n tags: Tags,\n): Effect.Effect<void> =>\n Effect.gen(function* () {\n const missingTags: string[] = [];\n for (const tag of tags) {\n const option = Context.getOption(context, tag);\n if (Option.isNone(option)) {\n missingTags.push(tag.key);\n }\n }\n\n if (missingTags.length > 0) {\n return yield* Effect.die(new Error(`Missing required tags in runtime: ${missingTags.join(', ')}`));\n }\n });\n\n/**\n * Create a dynamic runtime from a managed runtime and validate required tags.\n */\nexport function make<const Tags extends ReadonlyArray<Context.Tag<any, any>>>(\n managedRuntime: ManagedRuntime.ManagedRuntime<any, any> | ManagedRuntime.ManagedRuntime<never, never>,\n tags: Tags,\n): DynamicRuntime<Tags> {\n type RequiredContext = TagsToContext<Tags>;\n const managedRuntimeAny = managedRuntime as ManagedRuntime.ManagedRuntime<any, any>;\n\n // Cache for the validated runtime - once resolved, can be used synchronously.\n let cachedRuntime: Runtime.Runtime<RequiredContext> | undefined;\n\n // Cache validated runtime for async operations.\n let validatedRuntimePromise: Promise<Runtime.Runtime<RequiredContext>> | undefined;\n\n const getValidatedRuntimeAsync = async (): Promise<Runtime.Runtime<RequiredContext>> => {\n if (!validatedRuntimePromise) {\n validatedRuntimePromise = managedRuntimeAny.runPromise(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n }\n return validatedRuntimePromise;\n };\n\n // Get validated runtime for sync operations.\n const getValidatedRuntime = (): Runtime.Runtime<RequiredContext> => {\n const validationExit = managedRuntimeAny.runSyncExit(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n return unwrapExit(validationExit);\n };\n\n return {\n managedRuntime: managedRuntimeAny,\n runPromise: async <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Promise<A> => {\n const runtime = await getValidatedRuntimeAsync();\n return Runtime.runPromise(runtime)(effect);\n },\n runSync: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): A => {\n const runtime = getValidatedRuntime();\n return Runtime.runSync(runtime)(effect);\n },\n runSyncExit: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Exit.Exit<A, E> => {\n const validationExit = managedRuntimeAny.runSyncExit(\n Effect.gen(function* () {\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n return rt as Runtime.Runtime<RequiredContext>;\n }),\n );\n if (Exit.isSuccess(validationExit)) {\n const runtime = validationExit.value;\n return Runtime.runSyncExit(runtime)(effect);\n }\n return validationExit as Exit.Exit<A, E>;\n },\n runPromiseExit: async <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Promise<Exit.Exit<A, E>> => {\n try {\n const runtime = await getValidatedRuntimeAsync();\n return Runtime.runPromiseExit(runtime)(effect);\n } catch (error) {\n // If validation failed, return a failure exit\n return Exit.die(error);\n }\n },\n runFork: <A, E>(effect: Effect.Effect<A, E, RequiredContext>): Fiber.RuntimeFiber<A, E> => {\n const runtime = getValidatedRuntime();\n return Runtime.runFork(runtime)(effect);\n },\n runtimeEffect: Effect.gen(function* () {\n // Return cached runtime if available.\n if (cachedRuntime) {\n return cachedRuntime;\n }\n const rt = yield* managedRuntimeAny.runtimeEffect;\n yield* validateTags(rt.context, tags);\n const runtime = rt as Runtime.Runtime<RequiredContext>;\n // Cache for future sync calls.\n cachedRuntime = runtime;\n return runtime;\n }).pipe(\n Effect.catchAll(() =>\n // This should never happen since validateTags uses Effect.die\n Effect.die(new Error('Unexpected error in runtimeEffect validation')),\n ),\n ),\n dispose: async (): Promise<void> => {\n await managedRuntimeAny.dispose();\n },\n };\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Chunk from 'effect/Chunk';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport * as GlobalValue from 'effect/GlobalValue';\nimport * as Option from 'effect/Option';\nimport * as Runtime from 'effect/Runtime';\nimport type * as Tracer from 'effect/Tracer';\n\nconst spanSymbol = Symbol.for('effect/SpanAnnotation');\nconst originalSymbol = Symbol.for('effect/OriginalAnnotation');\nconst spanToTrace = GlobalValue.globalValue('effect/Tracer/spanToTrace', () => new WeakMap());\nconst locationRegex = /\\((.*)\\)/g;\n\n/**\n * Adds effect spans.\n * Removes effect internal functions.\n * Unwraps error proxy.\n */\nconst prettyErrorStack = (error: any, appendStacks: string[] = []): any => {\n if (typeof error !== 'object' || error === null) {\n return error;\n }\n\n const span = error[spanSymbol];\n\n const lines = typeof error.stack === 'string' ? error.stack.split('\\n') : [];\n const out = [];\n\n let atStack = false;\n for (let i = 0; i < lines.length; i++) {\n if (!atStack && !lines[i].startsWith(' at ')) {\n out.push(lines[i]);\n continue;\n }\n atStack = true;\n\n if (lines[i].includes(' at new BaseEffectError') || lines[i].includes(' at new YieldableError')) {\n i++;\n continue;\n }\n if (lines[i].includes('Generator.next')) {\n break;\n }\n if (lines[i].includes('effect_internal_function')) {\n break;\n }\n out.push(\n lines[i]\n .replace(/at .*effect_instruction_i.*\\((.*)\\)/, 'at $1')\n .replace(/EffectPrimitive\\.\\w+/, '<anonymous>')\n .replace(/at Arguments\\./, 'at '),\n );\n }\n\n if (span) {\n let current: Tracer.Span | Tracer.AnySpan | undefined = span;\n let i = 0;\n while (current && current._tag === 'Span' && i < 10) {\n const stackFn = spanToTrace.get(current);\n if (typeof stackFn === 'function') {\n const stack = stackFn();\n if (typeof stack === 'string') {\n const locationMatchAll = stack.matchAll(locationRegex);\n let match = false;\n for (const [, location] of locationMatchAll) {\n match = true;\n out.push(` at ${current.name} (${location})`);\n }\n if (!match) {\n out.push(` at ${current.name} (${stack.replace(/^at /, '')})`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n } else {\n out.push(` at ${current.name}`);\n }\n current = Option.getOrUndefined(current.parent);\n i++;\n }\n }\n\n out.push(...appendStacks);\n\n if (error[originalSymbol]) {\n error = error[originalSymbol];\n }\n if (error.cause) {\n error.cause = prettyErrorStack(error.cause);\n }\n\n Object.defineProperty(error, 'stack', {\n value: out.join('\\n'),\n writable: true,\n enumerable: false,\n configurable: true,\n });\n\n return error;\n};\n\n/**\n * Converts a cause to an error.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const causeToError = (cause: Cause.Cause<any>): Error => {\n if (Cause.isEmpty(cause)) {\n return new Error('Fiber failed without a cause');\n } else if (Cause.isInterruptedOnly(cause)) {\n return new Error('Fiber was interrupted');\n } else {\n const errors = [...Chunk.toArray(Cause.failures(cause)), ...Chunk.toArray(Cause.defects(cause))];\n\n const getStackFrames = (): string[] => {\n // Bun requies the target object for `captureStackTrace` to be an Error.\n const o = new Error();\n Error.captureStackTrace(o, getStackFrames);\n return o.stack!.split('\\n').slice(1);\n };\n\n const stackFrames = getStackFrames();\n const newErrors = errors.map((error) => prettyErrorStack(error, stackFrames));\n\n if (newErrors.length === 1) {\n return newErrors[0];\n } else {\n return new AggregateError(newErrors);\n }\n }\n};\n\n/**\n * Throws an error based on the cause.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const throwCause = (cause: Cause.Cause<any>): never => {\n throw causeToError(cause);\n};\n\nexport const unwrapExit = <A>(exit: Exit.Exit<A, any>): A => {\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n return throwCause(exit.cause);\n};\n\n/**\n * Runs the embedded effect asynchronously and throws any failures and defects as errors.\n * Inserts effect spans as stack frames.\n * The error will have stack frames of where the effect was run (if stack trace limit allows).\n * Removes effect runtime internal stack frames.\n *\n * To be used in place of `Effect.runPromise`.\n *\n * @throws AggregateError if there are multiple errors.\n */\nexport const runAndForwardErrors = async <A, E>(\n effect: Effect.Effect<A, E, never>,\n options?: { signal?: AbortSignal },\n): Promise<A> => {\n const exit = await Effect.runPromiseExit(effect, options);\n return unwrapExit(exit);\n};\n\nexport const runInRuntime = async <A, E, R>(\n runtime: Runtime.Runtime<R>,\n effect: Effect.Effect<A, E, R>,\n options?: { signal?: AbortSignal },\n): Promise<A> => {\n const exit = await Runtime.runPromiseExit(runtime, effect, options);\n return unwrapExit(exit);\n};\n\n/**\n * Like `Effect.promise` but also caputes spans for defects.\n * Workaround for: https://github.com/Effect-TS/effect/issues/5436\n */\nexport const promiseWithCauseCapture: <A>(evaluate: (signal: AbortSignal) => PromiseLike<A>) => Effect.Effect<A> = (\n evaluate,\n) =>\n Effect.promise(async (signal) => {\n try {\n const result = await evaluate(signal);\n return Effect.succeed(result);\n } catch (err) {\n return Effect.die(err);\n }\n }).pipe(Effect.flatten);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport { JSONPath } from 'jsonpath-plus';\n\nimport { invariant } from '@dxos/invariant';\nimport { getDeep, setDeep } from '@dxos/util';\n\nexport type JsonProp = string & { __JsonPath: true; __JsonProp: true };\nexport type JsonPath = string & { __JsonPath: true };\n\n// TODO(burdon): Start with \"$.\"?\n\nconst PATH_REGEX = /^($|[a-zA-Z_$][\\w$]*(?:\\.[a-zA-Z_$][\\w$]*|\\[\\d+\\](?:\\.)?)*$)/;\n\nconst PROP_REGEX = /^\\w+$/;\n\n/**\n * https://www.ietf.org/archive/id/draft-goessner-dispatch-jsonpath-00.html\n */\n// TODO(burdon): Keys could be arbitrary strings.\nexport const JsonPath = Schema.String.pipe(Schema.pattern(PATH_REGEX)).annotations({\n title: 'JSON path',\n description: 'JSON path to a property',\n}) as any as Schema.Schema<JsonPath>;\nexport const JsonProp = Schema.NonEmptyString.pipe(\n Schema.pattern(PROP_REGEX, {\n message: () => 'Property name must contain only letters, numbers, and underscores',\n }),\n) as any as Schema.Schema<JsonProp>;\n\nexport const isJsonPath = (value: unknown): value is JsonPath => {\n return Option.isSome(Schema.validateOption(JsonPath)(value));\n};\n\n/**\n * Creates a JsonPath from an array of path segments.\n *\n * Currently supports:\n * - Simple property access (e.g., 'foo.bar')\n * - Array indexing with non-negative integers (e.g., 'foo[0]')\n * - Identifiers starting with letters, underscore, or $ (e.g., '$foo', '_bar')\n * - Dot notation for nested properties (e.g., 'foo.bar.baz')\n *\n * Does not support (yet?).\n * - Recursive descent (..)\n * - Wildcards (*)\n * - Array slicing\n * - Filters\n * - Negative indices\n *\n * @param path Array of string or number segments\n * @returns Valid JsonPath or undefined if invalid\n */\nexport const createJsonPath = (path: readonly (string | number)[]): JsonPath => {\n const candidatePath = path\n .map((p, i) => {\n if (typeof p === 'number') {\n return `[${p}]`;\n } else {\n return i === 0 ? p : `.${p}`;\n }\n })\n .join('');\n\n invariant(isJsonPath(candidatePath), `Invalid JsonPath: ${candidatePath}`);\n return candidatePath;\n};\n\n/**\n * Converts Effect validation path format (e.g. \"addresses.[0].zip\")\n * to JsonPath format (e.g., \"addresses[0].zip\")\n */\nexport const fromEffectValidationPath = (effectPath: string): JsonPath => {\n // Handle array notation: convert \"prop.[0]\" to \"prop[0]\"\n const jsonPath = effectPath.replace(/\\.\\[(\\d+)\\]/g, '[$1]');\n invariant(isJsonPath(jsonPath), `Invalid JsonPath: ${jsonPath}`);\n return jsonPath;\n};\n\n/**\n * Splits a JsonPath into its constituent parts.\n * Handles property access and array indexing.\n */\nexport const splitJsonPath = (path: JsonPath): (string | number)[] => {\n if (!isJsonPath(path)) {\n return [];\n }\n\n return (\n path\n .match(/[a-zA-Z_$][\\w$]*|\\[\\d+\\]/g)\n ?.map((part) => part.replace(/[[\\]]/g, ''))\n .map((part) => {\n const parsed = Number.parseInt(part, 10);\n return Number.isNaN(parsed) ? part : parsed;\n }) ?? []\n );\n};\n\n/**\n * Applies a JsonPath to an object.\n */\n// TODO(burdon): Reconcile with getValue.\nexport const getField = (object: any, path: JsonPath): any => {\n // By default, JSONPath returns an array of results.\n return JSONPath({ path, json: object })[0];\n};\n\n/**\n * Get value from object using JsonPath.\n */\nexport const getValue = <T extends object>(obj: T, path: JsonPath): any => {\n return getDeep(obj, splitJsonPath(path));\n};\n\n/**\n * Set value on object using JsonPath.\n */\nexport const setValue = <T extends object>(obj: T, path: JsonPath, value: any): T => {\n return setDeep(obj, splitJsonPath(path), value);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport type * as Scope from 'effect/Scope';\n\nimport type { Lifecycle } from '@dxos/context';\n\n/**\n * Acquires a resource and releases it when the scope is closed.\n */\nexport const acquireReleaseResource = <T extends Lifecycle>(\n getResource: () => T,\n): Effect.Effect<T, never, Scope.Scope> =>\n Effect.acquireRelease(\n Effect.gen(function* () {\n const resource = getResource();\n yield* Effect.promise(async () => {\n await resource.open?.();\n return undefined;\n });\n return resource;\n }),\n (resource) =>\n Effect.promise(async () => {\n await resource.close?.();\n return undefined;\n }),\n );\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport type * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { decamelize } from '@dxos/util';\n\nconst ParamKeyAnnotationId = Symbol.for('@dxos/schema/annotation/ParamKey');\n\ntype ParamKeyAnnotationValue = { key: string };\n\nexport const getParamKeyAnnotation: (annotated: SchemaAST.Annotated) => Option.Option<ParamKeyAnnotationValue> =\n SchemaAST.getAnnotation<ParamKeyAnnotationValue>(ParamKeyAnnotationId);\n\nexport const ParamKeyAnnotation =\n (value: ParamKeyAnnotationValue) =>\n <S extends Schema.Annotable.All>(self: S): Schema.Annotable.Self<S> =>\n self.annotations({ [ParamKeyAnnotationId]: value });\n\n/**\n * HTTP params parser.\n * Supports custom key serialization.\n */\nexport class UrlParser<T extends Record<string, any>> {\n constructor(private readonly _schema: Schema.Struct<T>) {}\n\n /**\n * Parse URL params.\n */\n parse(_url: string): T {\n const url = new URL(_url);\n return Object.entries(this._schema.fields).reduce<Record<string, any>>((params, [key, type]) => {\n let value = url.searchParams.get(decamelize(key));\n if (value == null) {\n value = url.searchParams.get(key);\n }\n\n if (value != null) {\n if (SchemaAST.isNumberKeyword(type.ast)) {\n params[key] = parseInt(value);\n } else if (SchemaAST.isBooleanKeyword(type.ast)) {\n params[key] = value === 'true' || value === '1';\n } else {\n params[key] = value;\n }\n }\n\n return params;\n }, {}) as T;\n }\n\n /**\n * Return URL with encoded params.\n */\n create(_url: string, params: T): URL {\n const url = new URL(_url);\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined) {\n const field = this._schema.fields[key];\n if (field) {\n const { key: serializedKey } = Function.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", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Runtime from 'effect/Runtime';\n\nimport { runAndForwardErrors, unwrapExit } from './errors';\n\n/**\n * Provides effect runtime with services to run effects.\n */\nexport type RuntimeProvider<R> = Effect.Effect<Runtime.Runtime<R>>;\n\n/**\n * @returns Runtime provider from the current context.\n */\nexport const currentRuntime = <R = never>() => Effect.runtime<R>().pipe(Effect.map(Effect.succeed));\n\n/**\n * Run effect, within runitme, clean errors and fix stack-traces.\n */\nexport const runPromise =\n <R>(provider: RuntimeProvider<R>) =>\n async <A>(effect: Effect.Effect<A, any, R>): Promise<A> => {\n const runtime = await runAndForwardErrors(provider);\n return unwrapExit(await effect.pipe(Runtime.runPromiseExit(runtime)));\n };\n\n/**\n * Provide services from runtime provider to effect.\n */\nexport const provide: {\n <R2>(runtime: RuntimeProvider<R2>): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, R2>>;\n} = (runtimeProvider) => (effect) => Effect.flatMap(runtimeProvider, (runtime) => Effect.provide(effect, runtime));\n"],
5
+ "mappings": ";;;;;;AAIA,YAAYA,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,YAAY;AACxB,YAAYC,eAAe;AAE3B,SAASC,iB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F,OAAOL,KAAaQ,wBAAeT,QAAAA,CAAAA,CAAAA;AAC7D;AAKK,IAAMU,WAET,CAACC,oBAAoB,CAACL,WAAkBM,gBAAQD,iBAAiB,CAACX,aAAmBU,gBAAQJ,QAAQN,QAAAA,CAAAA;",
6
+ "names": ["Function", "Option", "Schema", "SchemaAST", "invariant", "isNonNullable", "reduceRefinements", "type", "refinements", "isRefinement", "annotations", "filter", "nextType", "from", "getBaseType", "prop", "encoded", "encodedBoundAST", "unwrapped", "isOptional", "_tag", "types", "getProperties", "ast", "properties", "getPropertySignatures", "map", "name", "isReadonly", "VisitResult", "visit", "node", "testOrVisitor", "visitor", "visitNode", "test", "path", "depth", "$result", "result", "undefined", "isTypeLiteral", "currentPath", "toString", "isTupleType", "i", "element", "elements", "entries", "isUnion", "findNode", "child", "getIndexSignatures", "_", "isLiteralUnion", "findProperty", "schema", "getProp", "rest", "typeNode", "length", "split", "defaultAnnotations", "objectKeyword", "stringKeyword", "numberKeyword", "booleanKeyword", "getAnnotation", "annotationId", "noDefault", "id", "pipe", "getIdentifierAnnotation", "getOrUndefined", "value", "findAnnotation", "getAnnotationById", "getBaseAnnotation", "isOption", "isUndefinedKeyword", "every", "isLiteral", "isArrayType", "getArrayElementType", "at", "isDiscriminatedUnion", "getDiscriminatingProps", "reduce", "shared", "props", "p", "includes", "getDiscriminatedType", "match", "literal", "fields", "Object", "fromEntries", "literals", "find", "Literal", "Struct", "isNestedType", "isDeclaration", "isObjectKeyword", "mapAst", "f", "TypeLiteral", "propertySignatures", "PropertySignature", "indexSignatures", "Union", "make", "TupleType", "t", "index", "OptionalType", "Type", "newAst", "Suspend", "annotation", "getSurrogateAnnotation", "isSome", "slice", "BrowserKeyValueStore", "Atom", "defaultRuntime", "Atom", "runtime", "layerLocalStorage", "createKvsStore", "options", "kvs", "key", "schema", "defaultValue", "pipe", "keepAlive", "Effect", "Context", "contextFromScope", "gen", "ctx", "addFinalizer", "promise", "dispose", "Context", "Effect", "Exit", "Option", "Runtime", "Cause", "Chunk", "Effect", "Exit", "GlobalValue", "Option", "Runtime", "spanSymbol", "Symbol", "for", "originalSymbol", "spanToTrace", "globalValue", "WeakMap", "locationRegex", "prettyErrorStack", "error", "appendStacks", "span", "lines", "stack", "split", "out", "atStack", "i", "length", "startsWith", "push", "includes", "replace", "current", "_tag", "stackFn", "get", "locationMatchAll", "matchAll", "match", "location", "name", "getOrUndefined", "parent", "cause", "Object", "defineProperty", "value", "join", "writable", "enumerable", "configurable", "causeToError", "isEmpty", "Error", "isInterruptedOnly", "errors", "toArray", "failures", "defects", "getStackFrames", "o", "captureStackTrace", "slice", "stackFrames", "newErrors", "map", "AggregateError", "throwCause", "unwrapExit", "exit", "isSuccess", "runAndForwardErrors", "effect", "options", "runPromiseExit", "runInRuntime", "runtime", "promiseWithCauseCapture", "evaluate", "promise", "signal", "result", "succeed", "err", "die", "pipe", "flatten", "validateTags", "context", "tags", "gen", "missingTags", "tag", "option", "getOption", "isNone", "push", "key", "length", "die", "Error", "join", "make", "managedRuntime", "managedRuntimeAny", "cachedRuntime", "validatedRuntimePromise", "getValidatedRuntimeAsync", "runPromise", "rt", "runtimeEffect", "getValidatedRuntime", "validationExit", "runSyncExit", "unwrapExit", "effect", "runtime", "runSync", "isSuccess", "value", "runPromiseExit", "error", "runFork", "pipe", "catchAll", "dispose", "Option", "Schema", "JSONPath", "invariant", "getDeep", "setDeep", "PATH_REGEX", "PROP_REGEX", "JsonPath", "String", "pipe", "pattern", "annotations", "title", "description", "JsonProp", "NonEmptyString", "message", "isJsonPath", "value", "isSome", "validateOption", "createJsonPath", "path", "candidatePath", "map", "p", "i", "join", "fromEffectValidationPath", "effectPath", "jsonPath", "replace", "splitJsonPath", "match", "part", "parsed", "Number", "parseInt", "isNaN", "getField", "object", "json", "getValue", "obj", "setValue", "Effect", "acquireReleaseResource", "getResource", "acquireRelease", "gen", "resource", "promise", "open", "undefined", "close", "Function", "Option", "SchemaAST", "decamelize", "ParamKeyAnnotationId", "Symbol", "for", "getParamKeyAnnotation", "getAnnotation", "ParamKeyAnnotation", "value", "self", "annotations", "UrlParser", "_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", "getOrElse", "set", "String", "provide", "runPromise", "Effect", "Runtime", "currentRuntime", "runtime", "pipe", "map", "succeed", "runPromise", "provider", "effect", "runAndForwardErrors", "unwrapExit", "runPromiseExit", "provide", "runtimeProvider", "flatMap"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/ast.ts":{"bytes":42462,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/jsonPath.ts":{"bytes":9719,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"jsonpath-plus","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"src/url.ts":{"bytes":7553,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/context.ts":{"bytes":1663,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true}],"format":"esm"},"src/errors.ts":{"bytes":14736,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/testing.ts":{"bytes":3316,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/resource.ts":{"bytes":2161,"imports":[{"path":"effect","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":947,"imports":[{"path":"src/ast.ts","kind":"import-statement","original":"./ast"},{"path":"src/jsonPath.ts","kind":"import-statement","original":"./jsonPath"},{"path":"src/url.ts","kind":"import-statement","original":"./url"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/testing.ts","kind":"import-statement","original":"./testing"},{"path":"src/resource.ts","kind":"import-statement","original":"./resource"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":41920},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"jsonpath-plus","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true}],"exports":["JsonPath","JsonProp","ParamKeyAnnotation","SimpleType","TestHelpers","UrlParser","VisitResult","accuireReleaseResource","contextFromScope","createJsonPath","findAnnotation","findNode","findProperty","fromEffectValidationPath","getAnnotation","getDiscriminatedType","getDiscriminatingProps","getField","getParamKeyAnnotation","getSimpleType","isArrayType","isDiscriminatedUnion","isJsonPath","isLiteralUnion","isOption","isSimpleType","mapAst","runAndForwardErrors","splitJsonPath","visit"],"entryPoint":"src/index.ts","inputs":{"src/ast.ts":{"bytesInOutput":9076},"src/index.ts":{"bytesInOutput":0},"src/jsonPath.ts":{"bytesInOutput":1862},"src/url.ts":{"bytesInOutput":1621},"src/context.ts":{"bytesInOutput":370},"src/errors.ts":{"bytesInOutput":3272},"src/testing.ts":{"bytesInOutput":476},"src/resource.ts":{"bytesInOutput":372}},"bytes":17833}}}
1
+ {"inputs":{"src/ast.ts":{"bytes":46984,"imports":[{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/atom-kvs.ts":{"bytes":3891,"imports":[{"path":"@effect/platform-browser/BrowserKeyValueStore","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true}],"format":"esm"},"src/context.ts":{"bytes":1719,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true}],"format":"esm"},"src/errors.ts":{"bytes":20626,"imports":[{"path":"effect/Cause","kind":"import-statement","external":true},{"path":"effect/Chunk","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/GlobalValue","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true}],"format":"esm"},"src/dynamic-runtime.ts":{"bytes":17249,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"src/json-path.ts":{"bytes":11858,"imports":[{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"jsonpath-plus","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/resource.ts":{"bytes":2400,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"},"src/url.ts":{"bytes":7881,"imports":[{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/RuntimeProvider.ts":{"bytes":3526,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"}],"format":"esm"},"src/index.ts":{"bytes":1340,"imports":[{"path":"src/ast.ts","kind":"import-statement","original":"./ast"},{"path":"src/atom-kvs.ts","kind":"import-statement","original":"./atom-kvs"},{"path":"src/context.ts","kind":"import-statement","original":"./context"},{"path":"src/dynamic-runtime.ts","kind":"import-statement","original":"./dynamic-runtime"},{"path":"src/errors.ts","kind":"import-statement","original":"./errors"},{"path":"src/json-path.ts","kind":"import-statement","original":"./json-path"},{"path":"src/resource.ts","kind":"import-statement","original":"./resource"},{"path":"src/url.ts","kind":"import-statement","original":"./url"},{"path":"src/RuntimeProvider.ts","kind":"import-statement","original":"./RuntimeProvider"}],"format":"esm"},"src/testing.ts":{"bytes":6498,"imports":[{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":59245},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-HSLMI22Q.mjs","kind":"import-statement"},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@effect/platform-browser/BrowserKeyValueStore","kind":"import-statement","external":true},{"path":"@effect-atom/atom-react","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"effect/Cause","kind":"import-statement","external":true},{"path":"effect/Chunk","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Exit","kind":"import-statement","external":true},{"path":"effect/GlobalValue","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"jsonpath-plus","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Function","kind":"import-statement","external":true},{"path":"effect/Option","kind":"import-statement","external":true},{"path":"effect/SchemaAST","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"effect/Runtime","kind":"import-statement","external":true}],"exports":["DynamicRuntime","JsonPath","JsonProp","ParamKeyAnnotation","RuntimeProvider","UrlParser","VisitResult","acquireReleaseResource","causeToError","contextFromScope","createJsonPath","createKvsStore","findAnnotation","findNode","findProperty","fromEffectValidationPath","getAnnotation","getArrayElementType","getBaseType","getDiscriminatedType","getDiscriminatingProps","getField","getParamKeyAnnotation","getProperties","getValue","isArrayType","isDiscriminatedUnion","isJsonPath","isLiteralUnion","isNestedType","isOption","isTupleType","mapAst","promiseWithCauseCapture","runAndForwardErrors","runInRuntime","setValue","splitJsonPath","throwCause","unwrapExit","visit"],"entryPoint":"src/index.ts","inputs":{"src/ast.ts":{"bytesInOutput":9908},"src/index.ts":{"bytesInOutput":0},"src/atom-kvs.ts":{"bytesInOutput":462},"src/context.ts":{"bytesInOutput":378},"src/dynamic-runtime.ts":{"bytesInOutput":3194},"src/errors.ts":{"bytesInOutput":4134},"src/json-path.ts":{"bytesInOutput":2189},"src/resource.ts":{"bytesInOutput":382},"src/url.ts":{"bytesInOutput":1693},"src/RuntimeProvider.ts":{"bytesInOutput":657}},"bytes":24193},"dist/lib/node-esm/testing.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3852},"dist/lib/node-esm/testing.mjs":{"imports":[{"path":"dist/lib/node-esm/chunk-HSLMI22Q.mjs","kind":"import-statement"},{"path":"effect/Context","kind":"import-statement","external":true},{"path":"effect/Effect","kind":"import-statement","external":true}],"exports":["TestContextService","TestHelpers"],"entryPoint":"src/testing.ts","inputs":{"src/testing.ts":{"bytesInOutput":919}},"bytes":1146},"dist/lib/node-esm/chunk-HSLMI22Q.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/node-esm/chunk-HSLMI22Q.mjs":{"imports":[],"exports":["__export"],"inputs":{},"bytes":327}}}
@@ -0,0 +1,38 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import "./chunk-HSLMI22Q.mjs";
3
+
4
+ // src/testing.ts
5
+ import * as Context from "effect/Context";
6
+ import * as Effect from "effect/Effect";
7
+ (function(TestHelpers2) {
8
+ TestHelpers2.runIf = (condition) => (effect, ctx) => Effect.gen(function* () {
9
+ if (!condition) {
10
+ ctx.skip();
11
+ } else {
12
+ return yield* effect;
13
+ }
14
+ });
15
+ TestHelpers2.skipIf = (condition) => (effect, ctx) => Effect.gen(function* () {
16
+ if (condition) {
17
+ ctx.skip();
18
+ } else {
19
+ return yield* effect;
20
+ }
21
+ });
22
+ TestHelpers2.taggedTest = (tag) => (effect, ctx) => Effect.gen(function* () {
23
+ if (!process.env.DX_TEST_TAGS?.includes(tag)) {
24
+ ctx.skip();
25
+ } else {
26
+ return yield* effect;
27
+ }
28
+ });
29
+ TestHelpers2.provideTestContext = (effect, ctx) => Effect.provideService(effect, TestContextService, ctx);
30
+ })(TestHelpers || (TestHelpers = {}));
31
+ var TestContextService = class extends Context.Tag("@dxos/effect/TestContextService")() {
32
+ };
33
+ var TestHelpers;
34
+ export {
35
+ TestContextService,
36
+ TestHelpers
37
+ };
38
+ //# sourceMappingURL=testing.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/testing.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport type { TestContext } from 'vitest';\n\n// TODO(dmaretskyi): Add all different test tags here.\nexport type TestTag =\n | 'flaky' // Flaky tests.\n | 'llm' // Tests with AI.\n | 'sync'; // Sync with external services.\n\nexport namespace TestHelpers {\n /**\n * Skip the test if the condition is false.\n *\n * Exmaple:\n * ```ts\n * it.effect(\n * 'should process an agentic loop using Claude',\n * Effect.fn(function* ({ expect }) {\n * // ...\n * }),\n * TestHelpers.runIf(process.env.ANTHROPIC_API_KEY),\n * );\n * ```\n */\n export const runIf =\n (condition: unknown) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (!condition) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n\n /**\n * Skip the test if the condition is true.\n *\n * Exmaple:\n * ```ts\n * it.effect(\n * 'should process an agentic loop using Claude',\n * Effect.fn(function* ({ expect }) {\n * // ...\n * }),\n * TestHelpers.skipIf(!process.env.ANTHROPIC_API_KEY),\n * );\n * ```\n */\n export const skipIf =\n (condition: unknown) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (condition) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n\n /**\n * Skips this test if the tag is not in the list of tags to run.\n * Tags are specified in the `DX_TEST_TAGS` environment variable.\n *\n * @param tag\n * @returns\n */\n export const taggedTest =\n (tag: TestTag) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>, ctx: TestContext): Effect.Effect<A, E, R> =>\n Effect.gen(function* () {\n if (!process.env.DX_TEST_TAGS?.includes(tag)) {\n ctx.skip();\n } else {\n return yield* effect;\n }\n });\n\n /**\n * Provide TestContext from test parameters.\n *\n * Exmaple:\n * ```ts\n * it.effect(\n * 'with context',\n * Effect.fn(function* ({ expect }) {\n * const ctx = yield* TestContextService;\n * }),\n * TestHelpers.provideTestContext,\n * );\n * ```\n */\n export const provideTestContext = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n ctx: TestContext,\n ): Effect.Effect<A, E, Exclude<R, TestContextService>> => Effect.provideService(effect, TestContextService, ctx);\n}\n\n/**\n * Exposes vitest test context as an effect service.\n */\nexport class TestContextService extends Context.Tag('@dxos/effect/TestContextService')<\n TestContextService,\n TestContext\n>() {}\n"],
5
+ "mappings": ";;;;AAIA,YAAYA,aAAa;AACzB,YAAYC,YAAY;UASPC,cAAAA;eAeFC,QACX,CAACC,cACD,CAAUC,QAAgCC,QACjCC,WAAI,aAAA;AACT,QAAI,CAACH,WAAW;AACdE,UAAIE,KAAI;IACV,OAAO;AACL,aAAO,OAAOH;IAChB;EACF,CAAA;eAgBSI,SACX,CAACL,cACD,CAAUC,QAAgCC,QACjCC,WAAI,aAAA;AACT,QAAIH,WAAW;AACbE,UAAIE,KAAI;IACV,OAAO;AACL,aAAO,OAAOH;IAChB;EACF,CAAA;eASSK,aACX,CAACC,QACD,CAAUN,QAAgCC,QACjCC,WAAI,aAAA;AACT,QAAI,CAACK,QAAQC,IAAIC,cAAcC,SAASJ,GAAAA,GAAM;AAC5CL,UAAIE,KAAI;IACV,OAAO;AACL,aAAO,OAAOH;IAChB;EACF,CAAA;eAgBSW,qBAAqB,CAChCX,QACAC,QAC+DW,sBAAeZ,QAAQa,oBAAoBZ,GAAAA;AAC9G,GAvFiBJ,gBAAAA,cAAAA,CAAAA,EAAAA;AA4FV,IAAMgB,qBAAN,cAAyCC,YAAI,iCAAA,EAAA,EAAA;AAG/C;;",
6
+ "names": ["Context", "Effect", "TestHelpers", "runIf", "condition", "effect", "ctx", "gen", "skip", "skipIf", "taggedTest", "tag", "process", "env", "DX_TEST_TAGS", "includes", "provideTestContext", "provideService", "TestContextService", "Tag"]
7
+ }
@@ -0,0 +1,21 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import * as Runtime from 'effect/Runtime';
3
+ /**
4
+ * Provides effect runtime with services to run effects.
5
+ */
6
+ export type RuntimeProvider<R> = Effect.Effect<Runtime.Runtime<R>>;
7
+ /**
8
+ * @returns Runtime provider from the current context.
9
+ */
10
+ export declare const currentRuntime: <R = never>() => Effect.Effect<Effect.Effect<Runtime.Runtime<R>, never, never>, never, R>;
11
+ /**
12
+ * Run effect, within runitme, clean errors and fix stack-traces.
13
+ */
14
+ export declare const runPromise: <R>(provider: RuntimeProvider<R>) => <A>(effect: Effect.Effect<A, any, R>) => Promise<A>;
15
+ /**
16
+ * Provide services from runtime provider to effect.
17
+ */
18
+ export declare const provide: {
19
+ <R2>(runtime: RuntimeProvider<R2>): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, R2>>;
20
+ };
21
+ //# sourceMappingURL=RuntimeProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimeProvider.d.ts","sourceRoot":"","sources":["../../../src/RuntimeProvider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAI1C;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,GAAG,KAAK,+EAA2D,CAAC;AAEpG;;GAEG;AACH,eAAO,MAAM,UAAU,GACpB,CAAC,EAAE,UAAU,eAAe,CAAC,CAAC,CAAC,MACzB,CAAC,EAAE,QAAQ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAGrD,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE;IACpB,CAAC,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;CACH,CAAC"}
@@ -1,18 +1,23 @@
1
- import { SchemaAST, Schema } from 'effect';
2
- import { type JsonPath, type JsonProp } from './jsonPath';
3
- export type SimpleType = 'object' | 'string' | 'number' | 'boolean' | 'enum' | 'literal';
1
+ import * as Schema from 'effect/Schema';
2
+ import * as SchemaAST from 'effect/SchemaAST';
3
+ import { type JsonPath, type JsonProp } from './json-path';
4
4
  /**
5
- * Get the base type; e.g., traverse through refinements.
5
+ * Get the base type of a property.
6
+ *
7
+ * Unwraps refinements and optional unions.
6
8
  */
7
- export declare const getSimpleType: (node: SchemaAST.AST) => SimpleType | undefined;
8
- export declare const isSimpleType: (node: SchemaAST.AST) => boolean;
9
- export declare namespace SimpleType {
10
- /**
11
- * Returns the default empty value for a given SimpleType.
12
- * Used for initializing new array values etc.
13
- */
14
- const getDefaultValue: (type: SimpleType) => any;
15
- }
9
+ export declare const getBaseType: (prop: SchemaAST.PropertySignature | SchemaProperty) => {
10
+ type: SchemaAST.AST;
11
+ refinements: SchemaAST.Refinement["filter"][];
12
+ };
13
+ export type SchemaProperty = Pick<SchemaAST.PropertySignature, 'name' | 'type' | 'isOptional' | 'isReadonly'> & {
14
+ /** Can be used to validate the property to the spec of the initial AST. */
15
+ refinements: SchemaAST.Refinement['filter'][];
16
+ };
17
+ /**
18
+ * Get the property types of an AST.
19
+ */
20
+ export declare const getProperties: (ast: SchemaAST.AST) => SchemaProperty[];
16
21
  export declare enum VisitResult {
17
22
  CONTINUE = 0,
18
23
  /**
@@ -33,10 +38,7 @@ export type VisitorFn = (node: SchemaAST.AST, path: Path, depth: number) => void
33
38
  * - https://github.com/syntax-tree/unist-util-visit?tab=readme-ov-file#visitor
34
39
  * - https://github.com/syntax-tree/unist-util-is?tab=readme-ov-file#test
35
40
  */
36
- export declare const visit: {
37
- (node: SchemaAST.AST, visitor: VisitorFn): void;
38
- (node: SchemaAST.AST, test: TestFn, visitor: VisitorFn): void;
39
- };
41
+ export declare const visit: (node: SchemaAST.AST, testOrVisitor: TestFn | VisitorFn, visitor: VisitorFn) => void;
40
42
  /**
41
43
  * Recursively descend into AST to find first node that passes the test.
42
44
  */
@@ -63,7 +65,19 @@ export declare const isOption: (node: SchemaAST.AST) => boolean;
63
65
  /**
64
66
  * Determines if the node is a union of literal types.
65
67
  */
66
- export declare const isLiteralUnion: (node: SchemaAST.AST) => boolean;
68
+ export declare const isLiteralUnion: (node: SchemaAST.AST) => node is SchemaAST.Union<SchemaAST.Literal>;
69
+ /**
70
+ * Determines if the node is an array type.
71
+ */
72
+ export declare const isArrayType: (node: SchemaAST.AST) => node is SchemaAST.TupleType;
73
+ /**
74
+ * Get the type of the array elements.
75
+ */
76
+ export declare const getArrayElementType: (node: SchemaAST.AST) => SchemaAST.AST | undefined;
77
+ /**
78
+ * Determines if the node is a tuple type.
79
+ */
80
+ export declare const isTupleType: (node: SchemaAST.AST) => boolean;
67
81
  /**
68
82
  * Determines if the node is a discriminated union.
69
83
  */
@@ -76,14 +90,14 @@ export declare const getDiscriminatingProps: (node: SchemaAST.AST) => string[] |
76
90
  * Get the discriminated type for the given value.
77
91
  */
78
92
  export declare const getDiscriminatedType: (node: SchemaAST.AST, value?: Record<string, any>) => SchemaAST.AST | undefined;
93
+ /**
94
+ * Determines if the node is a nested object type.
95
+ */
96
+ export declare const isNestedType: (node: SchemaAST.AST) => boolean;
79
97
  /**
80
98
  * Maps AST nodes.
81
99
  * The user is responsible for recursively calling {@link mapAst} on the SchemaAST.
82
100
  * NOTE: Will evaluate suspended ASTs.
83
101
  */
84
102
  export declare const mapAst: (ast: SchemaAST.AST, f: (ast: SchemaAST.AST, key: keyof any | undefined) => SchemaAST.AST) => SchemaAST.AST;
85
- /**
86
- * @returns true if AST is for Array(T) or optional(Array(T)).
87
- */
88
- export declare const isArrayType: (node: SchemaAST.AST) => boolean;
89
103
  //# sourceMappingURL=ast.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../src/ast.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMzD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS1D,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,CAAC,GAAG,KAAG,UAAU,GAAG,SA2BhE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,CAAC,GAAG,KAAG,OAAgC,CAAC;AAEpF,yBAAiB,UAAU,CAAC;IAC1B;;;OAGG;IACI,MAAM,eAAe,GAAI,MAAM,UAAU,KAAG,GAkBlD,CAAC;CACH;AAMD,oBAAY,WAAW;IACrB,QAAQ,IAAI;IACZ;;OAEG;IACH,IAAI,IAAI;IACR;;OAEG;IACH,IAAI,IAAI;CACT;AAED,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAEvC,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,GAAG,SAAS,CAAC;AAE3G,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AAM,GAAG,GAAG,SAAS,KAAK,SAAS,CAAC,GAAG,KACnE,SAAS,CAAC,GAsCZ,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { Atom } from '@effect-atom/atom-react';
2
+ import type * as Schema from 'effect/Schema';
3
+ /**
4
+ * Creates a KVS-backed atom for structured settings using Atom.kvs.
5
+ * The entire object is stored as a single localStorage key with JSON serialization.
6
+ *
7
+ * @param options.key - The localStorage key to store the value under.
8
+ * @param options.schema - Effect Schema for the value type.
9
+ * @param options.defaultValue - Function returning the default value.
10
+ * @param options.runtime - Optional custom Atom runtime (defaults to localStorage).
11
+ * @returns A writable atom that persists to localStorage.
12
+ */
13
+ export declare const createKvsStore: <T extends Record<string, any>>(options: {
14
+ key: string;
15
+ schema: Schema.Schema<T>;
16
+ defaultValue: () => T;
17
+ runtime?: ReturnType<typeof Atom.runtime>;
18
+ }) => Atom.Writable<T>;
19
+ //# sourceMappingURL=atom-kvs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atom-kvs.d.ts","sourceRoot":"","sources":["../../../src/atom-kvs.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAK7C;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,SAAS;IACrE,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC,CAAC;IACtB,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;CAC3C,KAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAQlB,CAAC"}
@@ -1,4 +1,5 @@
1
- import { Effect, type Scope } from 'effect';
1
+ import * as Effect from 'effect/Effect';
2
+ import type * as Scope from 'effect/Scope';
2
3
  import { Context } from '@dxos/context';
3
4
  export declare const contextFromScope: () => Effect.Effect<Context, never, Scope.Scope>;
4
5
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/context.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,eAAO,MAAM,gBAAgB,QAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAKzE,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/context.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,eAAO,MAAM,gBAAgB,QAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAKzE,CAAC"}