@dxos/echo 0.9.0 → 0.9.1-main.c7dcc2e112

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 (103) hide show
  1. package/dist/lib/neutral/Annotation.mjs +12 -4
  2. package/dist/lib/neutral/Database.mjs +5 -1
  3. package/dist/lib/neutral/Entity.mjs +12 -8
  4. package/dist/lib/neutral/Feed.mjs +12 -12
  5. package/dist/lib/neutral/Filter.mjs +8 -8
  6. package/dist/lib/neutral/JsonSchema.mjs +4 -4
  7. package/dist/lib/neutral/Migration.mjs +8 -8
  8. package/dist/lib/neutral/Obj.mjs +14 -10
  9. package/dist/lib/neutral/Query.mjs +14 -14
  10. package/dist/lib/neutral/Ref.mjs +4 -4
  11. package/dist/lib/neutral/Relation.mjs +9 -9
  12. package/dist/lib/neutral/Tag.mjs +12 -12
  13. package/dist/lib/neutral/Type.mjs +7 -7
  14. package/dist/lib/neutral/{chunk-UUP46KUQ.mjs → chunk-3JXQUMUI.mjs} +9 -9
  15. package/dist/lib/neutral/{chunk-WTQJHC75.mjs → chunk-4TPQZPLY.mjs} +37 -25
  16. package/dist/lib/neutral/chunk-4TPQZPLY.mjs.map +7 -0
  17. package/dist/lib/neutral/{chunk-ZGNNFYHS.mjs → chunk-5GAIWRQB.mjs} +4 -4
  18. package/dist/lib/neutral/{chunk-ZGNNFYHS.mjs.map → chunk-5GAIWRQB.mjs.map} +2 -2
  19. package/dist/lib/neutral/{chunk-TYGKCRMK.mjs → chunk-6CEISA3V.mjs} +15 -7
  20. package/dist/lib/neutral/{chunk-TYGKCRMK.mjs.map → chunk-6CEISA3V.mjs.map} +3 -3
  21. package/dist/lib/neutral/{chunk-RIVWNMSF.mjs → chunk-A53NTBHE.mjs} +3 -3
  22. package/dist/lib/neutral/{chunk-QQIYS74I.mjs → chunk-AFANXSGV.mjs} +6 -6
  23. package/dist/lib/neutral/{chunk-5SMDBFVB.mjs → chunk-E7IOTOZD.mjs} +6 -6
  24. package/dist/lib/neutral/{chunk-5SMDBFVB.mjs.map → chunk-E7IOTOZD.mjs.map} +2 -2
  25. package/dist/lib/neutral/{chunk-T6E37YIP.mjs → chunk-HGWQR5KH.mjs} +18 -10
  26. package/dist/lib/neutral/chunk-HGWQR5KH.mjs.map +7 -0
  27. package/dist/lib/neutral/{chunk-3PBP4V4O.mjs → chunk-JZ6LFQU5.mjs} +11 -3
  28. package/dist/lib/neutral/chunk-JZ6LFQU5.mjs.map +7 -0
  29. package/dist/lib/neutral/{chunk-7PI7C4EF.mjs → chunk-K3S7D5PR.mjs} +3 -3
  30. package/dist/lib/neutral/{chunk-5SUJPHAE.mjs → chunk-L3OBWBV2.mjs} +2 -2
  31. package/dist/lib/neutral/{chunk-6YDI3J37.mjs → chunk-NOL7O3BL.mjs} +4 -4
  32. package/dist/lib/neutral/{chunk-IGK6FN65.mjs → chunk-PLDMJJJC.mjs} +2 -2
  33. package/dist/lib/neutral/{chunk-LWXVKPPW.mjs → chunk-SZ5WB6HF.mjs} +6 -6
  34. package/dist/lib/neutral/{chunk-MZ7K3MLL.mjs → chunk-TF5BSLF6.mjs} +3 -3
  35. package/dist/lib/neutral/chunk-TF5BSLF6.mjs.map +7 -0
  36. package/dist/lib/neutral/{chunk-7FPIAJIV.mjs → chunk-VQYL2OQF.mjs} +89 -15
  37. package/dist/lib/neutral/chunk-VQYL2OQF.mjs.map +7 -0
  38. package/dist/lib/neutral/{chunk-R5W6DXR4.mjs → chunk-WZ32BF53.mjs} +26 -2
  39. package/dist/lib/neutral/chunk-WZ32BF53.mjs.map +7 -0
  40. package/dist/lib/neutral/{chunk-4ZUHOTCG.mjs → chunk-X3NUUON4.mjs} +3 -3
  41. package/dist/lib/neutral/{chunk-SBVFRTST.mjs → chunk-Z3WMRRAZ.mjs} +14 -6
  42. package/dist/lib/neutral/chunk-Z3WMRRAZ.mjs.map +7 -0
  43. package/dist/lib/neutral/index.mjs +19 -19
  44. package/dist/lib/neutral/internal/index.mjs +26 -6
  45. package/dist/lib/neutral/meta.json +1 -1
  46. package/dist/lib/neutral/testing/index.mjs +19 -19
  47. package/dist/types/src/Annotation.d.ts +1 -1
  48. package/dist/types/src/Annotation.d.ts.map +1 -1
  49. package/dist/types/src/Database.d.ts +22 -0
  50. package/dist/types/src/Database.d.ts.map +1 -1
  51. package/dist/types/src/Entity.d.ts +2 -0
  52. package/dist/types/src/Entity.d.ts.map +1 -1
  53. package/dist/types/src/Feed.d.ts +3 -0
  54. package/dist/types/src/Feed.d.ts.map +1 -1
  55. package/dist/types/src/Obj.d.ts +2 -0
  56. package/dist/types/src/Obj.d.ts.map +1 -1
  57. package/dist/types/src/Ref.d.ts +3 -3
  58. package/dist/types/src/Ref.d.ts.map +1 -1
  59. package/dist/types/src/Tag.d.ts.map +1 -1
  60. package/dist/types/src/Type.d.ts +5 -1
  61. package/dist/types/src/Type.d.ts.map +1 -1
  62. package/dist/types/src/internal/Annotation/annotations.d.ts +41 -0
  63. package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
  64. package/dist/types/src/internal/Obj/atoms.d.ts +5 -0
  65. package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -1
  66. package/dist/types/src/internal/Ref/index.d.ts +1 -0
  67. package/dist/types/src/internal/Ref/index.d.ts.map +1 -1
  68. package/dist/types/src/internal/Ref/ref.d.ts +66 -2
  69. package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
  70. package/dist/types/src/internal/Ref/strong-deps.d.ts +35 -0
  71. package/dist/types/src/internal/Ref/strong-deps.d.ts.map +1 -0
  72. package/dist/types/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +11 -11
  74. package/src/Annotation.ts +5 -0
  75. package/src/Database.ts +33 -1
  76. package/src/Entity.ts +3 -1
  77. package/src/Feed.ts +3 -0
  78. package/src/Obj.ts +2 -0
  79. package/src/Ref.ts +3 -3
  80. package/src/Tag.ts +1 -0
  81. package/src/Type.ts +16 -2
  82. package/src/internal/Annotation/annotations.ts +56 -0
  83. package/src/internal/Obj/atoms.ts +31 -0
  84. package/src/internal/Obj/json-serializer.ts +3 -3
  85. package/src/internal/Ref/index.ts +1 -0
  86. package/src/internal/Ref/ref.ts +96 -19
  87. package/src/internal/Ref/strong-deps.ts +107 -0
  88. package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +0 -7
  89. package/dist/lib/neutral/chunk-7FPIAJIV.mjs.map +0 -7
  90. package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +0 -7
  91. package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +0 -7
  92. package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +0 -7
  93. package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +0 -7
  94. package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +0 -7
  95. /package/dist/lib/neutral/{chunk-UUP46KUQ.mjs.map → chunk-3JXQUMUI.mjs.map} +0 -0
  96. /package/dist/lib/neutral/{chunk-RIVWNMSF.mjs.map → chunk-A53NTBHE.mjs.map} +0 -0
  97. /package/dist/lib/neutral/{chunk-QQIYS74I.mjs.map → chunk-AFANXSGV.mjs.map} +0 -0
  98. /package/dist/lib/neutral/{chunk-7PI7C4EF.mjs.map → chunk-K3S7D5PR.mjs.map} +0 -0
  99. /package/dist/lib/neutral/{chunk-5SUJPHAE.mjs.map → chunk-L3OBWBV2.mjs.map} +0 -0
  100. /package/dist/lib/neutral/{chunk-6YDI3J37.mjs.map → chunk-NOL7O3BL.mjs.map} +0 -0
  101. /package/dist/lib/neutral/{chunk-IGK6FN65.mjs.map → chunk-PLDMJJJC.mjs.map} +0 -0
  102. /package/dist/lib/neutral/{chunk-LWXVKPPW.mjs.map → chunk-SZ5WB6HF.mjs.map} +0 -0
  103. /package/dist/lib/neutral/{chunk-4ZUHOTCG.mjs.map → chunk-X3NUUON4.mjs.map} +0 -0
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/Ref.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Option from 'effect/Option';\nimport type * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { type URI } from '@dxos/keys';\n\nimport type * as Entity from './Entity';\nimport type * as internal from './internal';\nimport * as refInternal from './internal/Ref';\nimport type * as JsonSchema from './JsonSchema';\nimport type * as Obj from './Obj';\n// eslint-disable-next-line @dxos/rules/import-as-namespace\nimport type * as TypeNs from './Type';\n\n/**\n * Instance type for a reference.\n *\n * Reference can point to any object or relation.\n * References are lazy loaded.\n *\n * `ref.dxn` is the DXN of the referenced object.\n *\n * @example\n * ```ts\n * const taskRef: Ref<Task> = Ref.make(task);\n *\n * await taskRef.load(); // Returns Promise<Task>\n * yield* Database.load(taskRef); // Effectful version.\n *\n * database.makeRef(dxn); // Create a ref from a DXN.\n * ```\n */\nexport type Ref<T> = refInternal.Ref<T>;\nexport type Unknown = refInternal.Ref<Obj.Unknown>;\n\n/**\n * Factory function to create a Ref schema for the given target schema.\n * Use this in schema definitions to declare reference fields.\n *\n * @example\n * ```ts\n * const Task = Schema.Struct({\n * assignee: Ref.Ref(Person), // Creates a Ref schema\n * }).pipe(Type.makeObject(DXN.make('com.example.type.task', '0.1.0')));\n * ```\n */\nexport const Ref: {\n <S extends TypeNs.AnyObj | TypeNs.AnyRelation>(type: S): RefSchema<TypeNs.InstanceType<S> & Obj.Unknown>;\n\n // `Type.Type` entities (the meta-schema kind) can be referenced too — e.g. a\n // trigger that points to a stored function/workflow definition.\n <T extends TypeNs.Type<any>>(type: T): RefSchema<TypeNs.InstanceType<T>>;\n\n // Schema-side overload for the well-known \"any object\" / \"any relation\" schemas.\n // Other raw `Schema.Schema` values are intentionally rejected — callers should\n // pass a `Type.Type` entity instead.\n <S extends internal.UnknownTypeSchema<any, any>>(schema: S): RefSchema<Schema.Schema.Type<S> & Obj.Unknown>;\n} = refInternal.Ref as any;\n\nexport const Array = refInternal.RefArray;\n\n/**\n * TypeScript type for a Ref schema.\n * This is the type of the SCHEMA itself, not the runtime ref instance.\n * For the instance type, use `Ref.Ref<T>` from the Ref module.\n *\n * @example\n * ```ts\n * // Schema type annotation (rarely needed, usually inferred):\n * const refSchema: Ref.RefSchema<typeof Task> = Ref.Ref(Task);\n *\n * // Instance type annotation (use Ref.Ref instead):\n * const refInstance: Ref.Ref<Task> = Ref.make(task);\n * ```\n */\n// TODO(dmaretskyi): Investigate if we can remove this type.\n// Post DX-836 it will become just `Schema.Schema<Ref.Ref<T>>`.\n// NOTE: This could be Type.Ref<T> instead, but since it going to be removed, it's better to keep it here, self-contained.\nexport interface RefSchema<T extends Entity.Unknown> extends refInternal.RefSchema<T> {}\n\n/**\n * Extract reference target.\n */\nexport type Target<R extends Unknown> = R extends refInternal.Ref<infer T> ? T : never;\n\n/**\n * Reference resolver.\n */\nexport type Resolver = refInternal.RefResolver;\n\nexport const isRef: (value: unknown) => value is Unknown = refInternal.Ref.isRef;\n\nexport const make = refInternal.Ref.make;\n\n// TODO(dmaretskyi): Consider just allowing `make` to accept URI.\nexport const fromURI = (uri: URI.URI): refInternal.Ref<any> => refInternal.Ref.fromURI(uri);\n\nexport const hasEntityId = refInternal.Ref.hasEntityId;\n\n// TODO(wittjosiah): Factor out?\nexport const isRefType = (ast: SchemaAST.AST): boolean => {\n return SchemaAST.getAnnotation<JsonSchema.JsonSchema>(ast, SchemaAST.JSONSchemaAnnotationId).pipe(\n Option.flatMap((jsonSchema) => ('$id' in jsonSchema ? Option.some(jsonSchema) : Option.none())),\n Option.flatMap((jsonSchema) => {\n const { typename } = refInternal.getSchemaReference(jsonSchema) ?? {};\n return typename ? Option.some(true) : Option.some(false);\n }),\n Option.getOrElse(() => false),\n );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;AAAA;;;aAAAA;EAAA;;;;;;AAMA,YAAYC,YAAY;AAExB,YAAYC,eAAe;AA4CpB,IAAMC,OAWGA;AAET,IAAMC,QAAoBC;AA+B1B,IAAMC,QAA0DH,IAAIG;AAEpE,IAAMC,OAAmBJ,IAAII;AAG7B,IAAMC,UAAU,CAACC,QAAmDN,IAAIK,QAAQC,GAAAA;AAEhF,IAAMC,cAA0BP,IAAIO;AAGpC,IAAMC,YAAY,CAACC,QAAAA;AACxB,SAAiBC,wBAAqCD,KAAeE,gCAAsB,EAAEC,KACpFC,eAAQ,CAACC,eAAgB,SAASA,aAAoBC,YAAKD,UAAAA,IAAqBE,YAAI,CAAA,GACpFH,eAAQ,CAACC,eAAAA;AACd,UAAM,EAAEG,SAAQ,IAAiBC,mBAAmBJ,UAAAA,KAAe,CAAC;AACpE,WAAOG,WAAkBF,YAAK,IAAA,IAAeA,YAAK,KAAA;EACpD,CAAA,GACOI,iBAAU,MAAM,KAAA,CAAA;AAE3B;",
6
- "names": ["Ref", "Option", "SchemaAST", "Ref", "Array", "RefArray", "isRef", "make", "fromURI", "uri", "hasEntityId", "isRefType", "ast", "getAnnotation", "JSONSchemaAnnotationId", "pipe", "flatMap", "jsonSchema", "some", "none", "typename", "getSchemaReference", "getOrElse"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/Database.ts", "../../../src/internal/Entity/type-uri.ts", "../../../src/internal/Annotation/annotations.ts", "../../../src/internal/common/types/model-symbols.ts", "../../../src/internal/common/types/typename.ts", "../../../src/internal/Annotation/dictionary.ts", "../../../src/internal/Entity/api.ts", "../../../src/internal/Entity/model.ts", "../../../src/internal/Entity/util.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Effectable from 'effect/Effectable';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport { EffectEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { type SpaceId, type URI } from '@dxos/keys';\n\nimport type * as Entity from './Entity';\nimport * as Err from './Err';\nimport type * as Filter from './Filter';\nimport type * as Hypergraph from './Hypergraph';\nimport { type AnyProperties, EntityKind, KindId } from './internal/common/types';\n// Deep import (not the `./internal/Entity` barrel) to avoid a cycle:\n// Database → internal/Entity → entity → JsonSchema → Ref → Database.\nimport { isInstanceOf } from './internal/Entity/type-uri';\nimport type { Ref } from './internal/Ref/ref';\nimport type * as Obj from './Obj';\nimport type * as Query from './Query';\nimport type * as QueryResult from './QueryResult';\nimport type * as Registry from './Registry';\nimport type * as Type from './Type';\n\n/**\n * `query` API function declaration.\n */\n// TODO(burdon): Reconcile Query and Filter (should only have one root type).\nexport interface QueryFn {\n <Q extends Query.Any>(query: Q): QueryResult.QueryResult<Query.Type<Q>>;\n <F extends Filter.Any>(filter: F): QueryResult.QueryResult<Filter.Type<F>>;\n}\n\n/**\n * Common interface for Database, Feed, and Hypergraph.\n */\nexport interface Queryable {\n query: QueryFn;\n}\n\nexport type GetObjectByIdOptions = {\n deleted?: boolean;\n};\n\nexport type ObjectPlacement = 'root-doc' | 'linked-doc';\n\nexport type AddOptions = {\n /**\n * Where to place the object in the Automerge document tree.\n * Root document is always loaded with the space.\n * Linked documents are loaded lazily.\n * Placing large number of objects in the root document may slow down the initial load.\n *\n * @default 'linked-doc'\n */\n placeIn?: ObjectPlacement;\n};\n\n/**\n * Rejects Type entities from {@link Database.add} at compile time via their `[KindId]` brand. Used\n * as `T & RejectTypeEntity<T>` to preserve inference of `T`. Bounding `add` on\n * `Obj.Unknown | Relation.Unknown` instead would reject broadly-typed instance adds (e.g.\n * `Entity.Any`, `Obj.OfShape<T>`), forcing casts repo-wide.\n */\nexport type RejectTypeEntity<T> = T extends { readonly [KindId]: EntityKind.Type }\n ? { __error: 'Type entities must be persisted via db.addType(), not db.add().' }\n : T;\n\nexport type FlushOptions = {\n /**\n * Write any pending changes to disk.\n * @default true\n */\n disk?: boolean;\n\n /**\n * Wait for pending index updates.\n * @default true\n */\n indexes?: boolean;\n\n /**\n * Flush pending updates to objects and queries.\n * @default false\n */\n updates?: boolean;\n};\n\n/**\n * Identifier denoting an ECHO Database.\n */\nexport const TypeId = Symbol.for('@dxos/echo/Database');\nexport type TypeId = typeof TypeId;\n\n/**\n * ECHO Database interface.\n */\nexport interface Database extends Queryable {\n readonly [TypeId]: TypeId;\n\n get spaceId(): SpaceId;\n\n get graph(): Hypergraph.Hypergraph;\n\n /**\n * Registry for this database. Delegates type lookups to the shared hypergraph registry.\n * To persist a schema so it replicates to other clients, add the type entity with\n * {@link addType} (e.g. `await db.addType(Type.makeObjectFromJsonSchema(...))`).\n */\n readonly registry: Registry.Registry;\n\n toJSON(): object;\n\n /**\n * Return object by local ID.\n * @deprecated Use `db.query(Filter.id(id)).runSync()[0]` for a working-set lookup, or resolve via a {@link Ref}.\n */\n getObjectById<T extends Obj.Unknown = Obj.OfShape<AnyProperties>>(\n id: string,\n opts?: GetObjectByIdOptions,\n ): T | undefined;\n\n /**\n * Query objects.\n */\n query: QueryFn;\n\n /**\n * Creates a reference to an existing object in the database.\n *\n * NOTE: The reference may be dangling if the object is not present in the database.\n * NOTE: Difference from `Ref.fromURI`\n * `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.\n * `db.makeRef(dxn)` is preferable in cases with access to the database.\n */\n makeRef<T extends Entity.Unknown = Entity.Unknown>(uri: URI.URI): Ref<T>;\n\n /**\n * Adds an object or relation to the database.\n *\n * Only Object and Relation entities are accepted. To persist a Type definition use\n * {@link addType} — passing a Type entity is rejected at compile time (and at runtime).\n */\n add<T extends Entity.Unknown = Entity.Unknown>(obj: T & RejectTypeEntity<T>, opts?: AddOptions): T;\n\n /**\n * Persists a Type definition (clones/forks the entity) so it replicates to other peers.\n *\n * Runs a conflict query first: if a type with the same typename + version already exists in\n * this space, the existing persisted entity is returned and no duplicate is created. This is\n * the only supported way to add Type entities — {@link add} rejects them.\n */\n addType<T extends Type.AnyEntity>(type: T): Promise<T>;\n\n /**\n * Removes object from the database.\n */\n // TODO(burdon): Return true if removed (currently throws if not present).\n remove(obj: Entity.Unknown): void;\n\n /**\n * Wait for all pending changes to be saved to disk.\n * Optionaly waits for changes to be propagated to indexes and event handlers.\n */\n flush(opts?: FlushOptions): Promise<void>;\n}\n\nexport const isDatabase = (obj: unknown): obj is Database => {\n return obj ? typeof obj === 'object' && TypeId in obj && obj[TypeId] === TypeId : false;\n};\n\nexport const Database: Schema.Schema<Database> = Schema.Any.pipe(Schema.filter((space) => isDatabase(space)));\n\n/**\n * Effect service tag for Database dependency injection.\n */\nexport class Service extends Context.Tag('@dxos/echo/Database/Service')<\n Service,\n {\n readonly db: Database;\n }\n>() {}\n\n/**\n * Layer that provides a Database service that throws when accessed.\n * Useful as a default layer when no database is available.\n */\nexport const notAvailable = Layer.succeed(Service, {\n get db(): Database {\n throw new Error('Database not available');\n },\n});\n\n/**\n * Creates a Database service instance from a Database.\n */\nexport const makeService = (db: Database): Context.Tag.Service<Service> => {\n return {\n get db() {\n return db;\n },\n };\n};\n\n/**\n * Creates a Layer that provides the Database service.\n */\nexport const layer = (db: Database): Layer.Layer<Service> => {\n return Layer.succeed(Service, makeService(db));\n};\n\n/**\n * Returns the space ID of the database.\n */\nexport const spaceId = Effect.gen(function* () {\n const { db } = yield* Service;\n return db.spaceId;\n});\n\n/**\n * Resolves an object by its DXN.\n */\nexport const resolve: {\n // No type check.\n (ref: URI.URI | Ref<any>): Effect.Effect<Entity.Unknown, never, Service>;\n // Check matches schema.\n <S extends Type.AnyEntity>(\n ref: URI.URI | Ref<any>,\n schema: S,\n ): Effect.Effect<Type.InstanceType<S>, Err.EntityNotFoundError, Service>;\n} = (<S extends Type.AnyEntity>(\n ref: URI.URI | Ref<any>,\n schema?: S,\n): Effect.Effect<Type.InstanceType<S>, Err.EntityNotFoundError, Service> =>\n Effect.gen(function* () {\n const { db } = yield* Service;\n const dxn = typeof ref === 'string' ? ref : ref.uri;\n const object = yield* EffectEx.promiseWithCauseCapture(() =>\n db.graph\n .createRefResolver({\n context: {\n space: db.spaceId,\n },\n })\n .resolve(dxn),\n );\n\n if (!object) {\n return yield* Effect.fail(new Err.EntityNotFoundError(dxn));\n }\n // `isInstanceOf` uses a conditional generic that TS can't resolve through\n // the local `S extends Type.AnyEntity` parameter — runtime accepts it fine.\n invariant(!schema || isInstanceOf(schema as any, object), 'Object type mismatch.');\n return object as any;\n }).pipe(Effect.withSpan('Database.resolve'))) as any;\n\n/**\n * Loads an object reference.\n *\n * Catching not found error:\n *\n * ```ts\n * yield* load(ref).pipe(Effect.catchTag('EntityNotFoundError', () => Effect.succeed(undefined)));\n * ```\n *\n */\nexport const load: <T>(ref: Ref<T>) => Effect.Effect<T, Err.EntityNotFoundError, never> = Effect.fn('Database.load')(\n function* (ref) {\n const object = yield* EffectEx.promiseWithCauseCapture(() => ref.tryLoad());\n if (!object) {\n return yield* Effect.fail(new Err.EntityNotFoundError(ref.uri));\n }\n return object;\n },\n);\n\n/**\n * Adds an object or relation to the database.\n * @see {@link Database.add}\n */\nexport const add = <T extends Entity.Unknown>(obj: T & RejectTypeEntity<T>): Effect.Effect<T, never, Service> =>\n Service.pipe(Effect.map(({ db }) => db.add<T>(obj))).pipe(Effect.withSpan('Database.add'));\n\n/**\n * Persists a Type definition to the database.\n * @see {@link Database.addType}\n */\nexport const addType = <T extends Type.AnyEntity>(type: T): Effect.Effect<T, never, Service> =>\n Service.pipe(Effect.flatMap(({ db }) => EffectEx.promiseWithCauseCapture(() => db.addType(type)))).pipe(\n Effect.withSpan('Database.addType'),\n );\n\n/**\n * Removes an object from the database.\n * @see {@link Database.remove}\n */\nexport const remove = <T extends Entity.Unknown>(obj: T): Effect.Effect<void, never, Service> =>\n Service.pipe(Effect.map(({ db }) => db.remove(obj))).pipe(Effect.withSpan('Database.remove'));\n\n/**\n * Flushes pending changes to disk.\n * @see {@link Database.flush}\n */\nexport const flush = (opts?: FlushOptions) =>\n Service.pipe(Effect.flatMap(({ db }) => EffectEx.promiseWithCauseCapture(() => db.flush(opts)))).pipe(\n Effect.withSpan('Database.flush'),\n );\n\n/**\n * Creates a `QueryResult` object that can be subscribed to.\n */\nexport const query: {\n <Q extends Query.Any>(query: Q): QueryResult.QueryResultEffect<Query.Type<Q>, never, Service>;\n <F extends Filter.Any>(filter: F): QueryResult.QueryResultEffect<Filter.Type<F>, never, Service>;\n} = (queryOrFilter: Query.Any | Filter.Any) =>\n Service.pipe(\n Effect.map(({ db }) => db.query(queryOrFilter as any) as QueryResult.QueryResult<any>),\n Effect.withSpan('Database.query'),\n makeQueryResultEffect,\n );\n\nconst makeQueryResultEffect = <T>(\n eff: Effect.Effect<QueryResult.QueryResult<T>, never, Service>,\n): QueryResult.QueryResultEffect<T, never, Service> => {\n return {\n run: Effect.flatMap(eff, (result) => EffectEx.promiseWithCauseCapture(() => result.run())),\n first: Effect.flatMap(eff, (result) =>\n EffectEx.promiseWithCauseCapture(async () => Option.fromNullable(await result.firstOrUndefined())),\n ),\n\n // Effect internals\n ...Effectable.CommitPrototype,\n commit() {\n return eff;\n },\n } as any;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { raise } from '@dxos/debug';\nimport { assertArgument } from '@dxos/invariant';\nimport { DXN, EID, URI } from '@dxos/keys';\n\nimport { getSchemaURI, getTypename } from '../Annotation/annotations';\nimport { type AnyEntity, InstancePhantomId, KindId, TypeId, getStaticTypeSchema } from '../common/types';\nimport { getUri as getUriFromEntity } from './api';\n\n/**\n * @param input schema, `Type.Type` entity, or a type URI (an `echo:` EID or a `dxn:` DXN).\n * @return type identifier URI — see {@link getSchemaURI}. A URI is returned verbatim. For a\n * `Type.Type` entity, the URI of the schema it declares, symmetric with what\n * `Obj.make(typeEntity, ...)` stamps on `system.type`: a static declaration resolves to its\n * typename DXN, a persisted entity to its local `echo:/<objectId>`.\n */\nexport const getTypeURIFromSpecifier = (input: Schema.Schema.All | AnyEntity | URI.URI): URI.URI => {\n if (Schema.isSchema(input)) {\n return getSchemaURI(input) ?? raise(new TypeError('Schema has no URI'));\n }\n if (typeof input === 'object' && input !== null && KindId in input) {\n // `Type.Type` entity. Both in-memory and persisted forms expose the schema\n // they declare via `StaticTypeSchemaSlot`, whose URI is exactly what\n // `Obj.make` stamps on `system.type` — a static declaration carries\n // `TypeAnnotation` (→ typename DXN), a persisted entity's rebuilt schema\n // carries `TypeIdentifierAnnotation` (→ local `echo:/<objectId>`).\n const schema = getStaticTypeSchema(input);\n if (schema != null) {\n // Static types carry TypeAnnotation → DXN; persisted db types carry\n // TypeIdentifierAnnotation → echo EID. In-memory makeObjectFromJsonSchema\n // entities have neither (plain JSON Schema), so fall through to the EID path.\n const uri = getSchemaURI(schema);\n if (uri != null) {\n return uri;\n }\n }\n return getUriFromEntity(input as AnyEntity);\n }\n // A string specifier is already a branded URI — an `echo:` EID or a `dxn:` DXN.\n assertArgument(EID.isEID(input) || DXN.isDXN(input), 'input', 'expected a type URI (EID or DXN)');\n return input;\n};\n\n/**\n * Checks if the object is an instance of the schema.\n * Only typename is compared, the schema version is ignored.\n *\n * The following cases are considered to mean that the object is an instance of the schema:\n * - Object was created with this exact schema.\n * - Object was created with a different version of this schema.\n * - Object was created with a different schema (maybe dynamic) that has the same typename.\n */\n// TODO(burdon): Can we use `Schema.is`?\nexport const isInstanceOf = <S>(\n schemaOrType: S extends Schema.Schema.AnyNoContext ? S : Schema.Schema.AnyNoContext | AnyEntity,\n object: any,\n): object is S extends Schema.Schema.AnyNoContext\n ? Schema.Schema.Type<S>\n : S extends { readonly [InstancePhantomId]?: infer A }\n ? A\n : unknown => {\n if (object == null) {\n return false;\n }\n\n const schemaURI = getTypeURIFromSpecifier(schemaOrType);\n\n // `object` is arbitrary input — read TypeId directly (it may be missing on\n // non-entities) rather than via `getTypeURI` which asserts the URI is set.\n const type = (object as any)[TypeId];\n if (URI.isURI(type) && type === schemaURI) {\n return true;\n }\n\n const typename = getTypename(object);\n if (!typename) {\n return false;\n }\n\n if (!DXN.isDXN(schemaURI)) {\n // EID-based schema URI — no typename match possible.\n return false;\n }\n\n const parsed = DXN.tryMake(schemaURI);\n return parsed != null && DXN.getName(parsed) === typename;\n};\n", "//\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 { SchemaEx } from '@dxos/effect';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN, URI } from '@dxos/keys';\nimport { type Primitive } from '@dxos/util';\n\nimport type * as Annotation from '../../Annotation';\nimport { type Mutable } from '../common/proxy';\nimport { type AnyProperties, EntityKind, TypeId, getSchema } from '../common/types';\nimport { createAnnotationHelper } from './util';\n\nconst ANNOTATION_TYPE_ID: Annotation.TypeId = '~@dxos/echo/Annotation' as const;\n\n/**\n * @internal\n */\nexport const FIELD_PATH_ANNOTATION = 'path';\n\n/**\n * Sets the path for the field.\n * @param path Data source path in the json path format. This is the field path in the source object.\n */\n// TODO(burdon): Field, vs. path vs. property.\nexport const FieldPath = (path: string) => PropertyMeta(FIELD_PATH_ANNOTATION, path);\n\n//\n// Type\n//\n\n/**\n * ECHO identifier (for a stored schema).\n * Must be an `echo:` URI.\n */\nexport const TypeIdentifierAnnotationId = Symbol.for('@dxos/schema/annotation/TypeIdentifier');\n\nexport const getTypeIdentifierAnnotation = (schema: Schema.Schema.All) =>\n Function.flow(\n SchemaAST.getAnnotation<string>(TypeIdentifierAnnotationId),\n Option.getOrElse(() => undefined),\n )(schema.ast);\n\n/**\n * @returns The schema's type identifier URI — whichever URI fits.\n *\n * - Stored (dynamic) schemas: the schema-as-object's EID, so loaded objects ride\n * along with their schema as a strong dependency.\n * - Non-stored (static) schemas: the typename DXN built from `TypeAnnotation`.\n *\n * This URI is what gets written to an object's `system.type`; queries that filter by\n * type also use it (see `Filter.type` / `getTypeURIFromSpecifier`), so both sides\n * stay symmetric without per-schema branching.\n */\nexport const getSchemaURI = (schema: Schema.Schema.All): URI.URI | undefined => {\n assertArgument(Schema.isSchema(schema), 'schema', 'invalid schema');\n const id = getTypeIdentifierAnnotation(schema);\n if (id) {\n return URI.make(id);\n }\n const objectAnnotation = getTypeAnnotation(schema);\n if (objectAnnotation) {\n return DXN.make(objectAnnotation.typename, objectAnnotation.version);\n }\n return undefined;\n};\n\n//\n// TypeAnnotation\n//\n\n/**\n * Fully qualified globally unique typename.\n * Example: `org.dxos.type.message`\n */\n// TODO(wittjosiah): Factor out to DXN spec.\nexport const TypenameSchema = Schema.String.pipe(\n Schema.pattern(\n /^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)$/,\n ),\n).annotations({\n description: 'Fully qualified globally unique typename in reverse-DNS form.',\n example: 'org.dxos.type.message',\n});\n\n/**\n * Semantic version format: `major.minor.patch`\n * Example: `1.0.0`\n */\nexport const VersionSchema = Schema.String.pipe(Schema.pattern(/^\\d+.\\d+.\\d+$/)).annotations({\n description: 'Semantic version format: `major.minor.patch`',\n example: '1.0.0',\n});\n\nexport const TypeMeta = Schema.Struct({\n typename: TypenameSchema,\n version: VersionSchema,\n});\n\nexport interface TypeMeta extends Schema.Schema.Type<typeof TypeMeta> {}\n\n/**\n * Entity type.\n */\nexport const TypeAnnotationId = Symbol.for('@dxos/schema/annotation/Type');\n\n/**\n * Payload stored under {@link TypeAnnotationId}.\n */\nexport const TypeAnnotation = Schema.extend(\n TypeMeta,\n Schema.Struct({\n kind: Schema.Enums(EntityKind),\n\n /**\n * If this is a relation, the schema of the source object.\n * Must be present if entity kind is {@link EntityKind.Relation}.\n */\n sourceSchema: Schema.optional(DXN.Schema),\n\n /**\n * If this is a relation, the schema of the target object.\n * Must be present if entity kind is {@link EntityKind.Relation}.\n */\n targetSchema: Schema.optional(DXN.Schema),\n }),\n);\n\nexport interface TypeAnnotation extends Schema.Schema.Type<typeof TypeAnnotation> {}\n\n/**\n * @returns {@link TypeAnnotation} from a schema.\n * Schema must have been created with {@link TypedObject} or {@link TypedLink} or manually assigned an appropriate annotation.\n */\nexport const getTypeAnnotation = (schema: Schema.Schema.All): TypeAnnotation | undefined => {\n assertArgument(schema != null && schema.ast != null, 'schema', 'invalid schema');\n return Function.flow(\n SchemaAST.getAnnotation<TypeAnnotation>(TypeAnnotationId),\n Option.getOrElse(() => undefined),\n )(schema.ast);\n};\n\n/**\n * @returns {@link EntityKind} from a schema.\n */\nexport const getEntityKind = (schema: Schema.Schema.All): EntityKind | undefined => getTypeAnnotation(schema)?.kind;\n\n/**\n * @internal\n * @returns Schema typename (without dxn: prefix or version number).\n */\nexport const getSchemaTypename = (schema: Schema.Schema.All): string | undefined => getTypeAnnotation(schema)?.typename;\n\n/**\n * @internal\n * @returns Schema version in semver format.\n */\nexport const getSchemaVersion = (schema: Schema.Schema.All): string | undefined => getTypeAnnotation(schema)?.version;\n\n/**\n * Gets the typename of the object without the version.\n * Returns only the name portion, not the DXN.\n * @example \"org.example.type.contact\"\n *\n * @internal (use Obj.getTypename)\n */\nexport const getTypename = (obj: AnyProperties): string | undefined => {\n const schema = getSchema(obj);\n if (schema != null) {\n // Try to extract typename from DXN.\n return getSchemaTypename(schema);\n } else {\n // `obj` may be an arbitrary value (e.g. from `isInstanceOf`); read TypeId\n // directly so we return undefined for non-entities instead of throwing.\n const type = (obj as any)?.[TypeId];\n // Parse the URI string to extract typename.\n if (DXN.isDXN(type)) {\n const parsed = DXN.tryMake(type);\n return parsed && DXN.getName(parsed);\n }\n return undefined;\n }\n};\n\n/**\n * @internal (use Type.setTypename)\n */\n// TODO(dmaretskyi): Rename setTypeDXN.\nexport const setTypename = (obj: any, typename: URI.URI): void => {\n assertArgument(typeof typename === 'string', 'typename', 'Invalid type.');\n Object.defineProperty(obj, TypeId, {\n value: typename,\n writable: false,\n enumerable: false,\n configurable: false,\n });\n};\n\n/**\n * @returns Object type URI — either a typename {@link DXN} or an `echo:` reference to a stored Schema object.\n * @returns undefined if the object has no registered type URI (e.g. unresolved query result).\n * @example `dxn:com.example.type.person:1.0.0`\n * @example `echo:/01KKKG2FHWCMTR0BY00GJSVT1X` (stored schema)\n *\n * @internal (use Obj.getTypeURI)\n */\nexport const getTypeURI = (obj: AnyProperties): URI.URI | undefined => {\n if (obj == null) {\n return undefined;\n }\n const type = (obj as any)[TypeId];\n if (type == null) {\n return undefined;\n }\n invariant(URI.isURI(type), 'Invalid object.');\n return type;\n};\n\n//\n// PropertyMeta\n//\n\n/**\n * PropertyMeta (metadata for dynamic schema properties).\n * For user-defined annotations.\n */\nexport const PropertyMetaAnnotationId = Symbol.for('@dxos/schema/annotation/PropertyMeta');\n\nexport type PropertyMetaValue = Primitive | Record<string, Primitive> | Primitive[];\n\nexport type PropertyMetaAnnotation = {\n [name: string]: PropertyMetaValue;\n};\n\n// TODO(wittjosiah): Align with other annotations.\n// TODO(wittjosiah): Why is this separate from FormatAnnotation?\n/**\n * Apply property-level metadata to an Effect schema. Only accepts\n * `Schema.Schema.Any` — apply BEFORE wrapping the schema with\n * `Type.makeObject` / `Type.makeRelation`. To read property meta off a\n * `Type.Type` entity, unwrap it first with `Type.getSchema(entity)`.\n */\nexport const PropertyMeta = (name: string, value: PropertyMetaValue) => {\n return <A, I, R>(self: Schema.Schema<A, I, R>): Schema.Schema<A, I, R> => {\n const existingMeta = self.ast.annotations[PropertyMetaAnnotationId] as PropertyMetaAnnotation;\n return self.annotations({\n [PropertyMetaAnnotationId]: {\n ...existingMeta,\n [name]: value,\n },\n });\n };\n};\n\nexport const getPropertyMetaAnnotation = <T>(prop: SchemaAST.PropertySignature, name: string) =>\n Function.pipe(\n SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(prop.type),\n Option.map((meta) => meta[name] as T),\n Option.getOrElse(() => undefined),\n );\n\n//\n// Reference\n//\n\n/**\n * Schema reference.\n */\nexport const ReferenceAnnotationId = Symbol.for('@dxos/schema/annotation/Reference');\nexport type ReferenceAnnotationValue = TypeAnnotation;\nexport const ReferenceAnnotation = createAnnotationHelper<ReferenceAnnotationValue>(ReferenceAnnotationId);\n\n/**\n * SchemaMeta.\n */\nexport const SchemaMetaSymbol = Symbol.for('@dxos/schema/SchemaMeta');\nexport type SchemaMeta = TypeMeta & { id: string };\n\n/**\n * Identifies a schema as hidden from user-facing surfaces (like dotfiles — visible only via an advanced setting).\n */\nexport const HiddenAnnotationId = Symbol.for('@dxos/schema/annotation/Hidden');\nexport const HiddenAnnotation = createAnnotationHelper<boolean>(HiddenAnnotationId);\n\n/**\n * Identifies label property or JSON path expression.\n * Either a string or an array of strings representing field accessors each matched in priority order.\n */\nexport const LabelAnnotationId = Symbol.for('@dxos/schema/annotation/Label');\nexport const LabelAnnotation = createAnnotationHelper<string[]>(LabelAnnotationId);\n\n/**\n * Returns the label for a given object based on {@link LabelAnnotationId}.\n * Lower-level version that requires explicit schema parameter.\n * Skips empty strings and whitespace-only strings, continuing to the next field.\n */\n// TODO(burdon): Convert to SchemaEx.JsonPath?\nexport const getLabelWithSchema = <S extends Schema.Schema.Any>(\n schema: S,\n object: Schema.Schema.Type<S>,\n): string | undefined => {\n const annotation = LabelAnnotation.get(schema).pipe(Option.getOrElse(() => ['name']));\n for (const accessor of annotation) {\n assertArgument(\n typeof accessor === 'string',\n 'accessor',\n 'Label annotation must be a string or an array of strings',\n );\n const value = SchemaEx.getField(object, accessor as SchemaEx.JsonPath);\n switch (typeof value) {\n case 'string': {\n const trimmed = value.trim();\n if (trimmed.length > 0) {\n return value;\n }\n continue;\n }\n case 'number':\n case 'boolean':\n case 'bigint':\n case 'symbol':\n return value.toString();\n case 'undefined':\n case 'object':\n case 'function':\n continue;\n }\n }\n\n return undefined;\n};\n\n/**\n * Sets the label for a given object based on {@link LabelAnnotationId}.\n * Lower-level version that requires explicit schema parameter.\n */\nexport const setLabelWithSchema = <S extends Schema.Schema.Any>(\n schema: S,\n object: Schema.Schema.Type<S>,\n label: string,\n) => {\n const annotation = LabelAnnotation.get(schema).pipe(\n Option.map((field) => field[0]),\n Option.getOrElse(() => 'name'),\n );\n object[annotation] = label;\n};\n\n/**\n * Identifies description property or JSON path expression.\n * A string representing field accessor.\n */\nexport const DescriptionAnnotationId = Symbol.for('@dxos/schema/annotation/Description');\nexport const DescriptionAnnotation = createAnnotationHelper<string>(DescriptionAnnotationId);\n\n/**\n * Returns the description for a given object based on {@link DescriptionAnnotationId}.\n * Lower-level version that requires explicit schema parameter.\n */\n// TODO(burdon): Convert to SchemaEx.JsonPath?\nexport const getDescriptionWithSchema = <S extends Schema.Schema.Any>(\n schema: S,\n object: Schema.Schema.Type<S>,\n): string | undefined => {\n const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));\n assertArgument(typeof accessor === 'string', 'accessor', 'Description annotation must be a string');\n const value = SchemaEx.getField(object, accessor as SchemaEx.JsonPath);\n switch (typeof value) {\n case 'string':\n case 'number':\n case 'boolean':\n case 'bigint':\n case 'symbol':\n return value.toString();\n case 'undefined':\n case 'object':\n case 'function':\n default:\n return undefined;\n }\n};\n\n/**\n * Sets the description for a given object based on {@link DescriptionAnnotationId}.\n * Lower-level version that requires explicit schema parameter.\n */\nexport const setDescriptionWithSchema = <S extends Schema.Schema.Any>(\n schema: S,\n object: Schema.Schema.Type<S>,\n description: string,\n) => {\n const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));\n object[accessor] = description;\n};\n\n/**\n * Identifies if a property should be included in a form or not.\n * By default, all properties are included in forms, so this is opt-out.\n */\nexport const FormInputAnnotationId = Symbol.for('@dxos/schema/annotation/FormInput');\nexport const FormInputAnnotation = createAnnotationHelper<boolean>(FormInputAnnotationId);\n\n/**\n * When set on a `Ref` property, the form renders the referenced object's own\n * fields inline (a nested form bound to the target) instead of a picker.\n */\nexport const FormInlineAnnotationId = Symbol.for('@dxos/schema/annotation/FormInline');\nexport const FormInlineAnnotation = createAnnotationHelper<boolean>(FormInlineAnnotationId);\n\n/**\n * Default field to be used on referenced schema to lookup the value.\n */\nexport const FieldLookupAnnotationId = Symbol.for('@dxos/schema/annotation/FieldLookup');\n\n/**\n * Generate test data.\n */\nexport const GeneratorAnnotationId = Symbol.for('@dxos/schema/annotation/Generator');\n\nexport type GeneratorAnnotationValue =\n | string\n | {\n generator: string;\n args?: any[];\n probability?: number;\n };\n\nexport const GeneratorAnnotation = createAnnotationHelper<GeneratorAnnotationValue>(GeneratorAnnotationId);\n\ninterface MakeAnnoationsProps<T> {\n id: string;\n schema: Schema.Schema<T, any, never>;\n}\n\n// Annotation ids use the same NSID / reverse-DNS format as TypenameSchema —\n// dot-separated segments, middle segments may be hyphenated, final segment may be camelCase.\n// At least 3 segments are required (e.g. org.dxos.annotation.example).\nexport const makeUserAnnotation = <T>(props: MakeAnnoationsProps<T>): Annotation.Annotation<T> => {\n assertArgument(\n /^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?){2,}(\\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)?$/.test(\n props.id,\n ),\n 'id',\n 'Annotation id must be in the FQN format (org.dxos.annotation.example or org.dxos.space.rootCollection).',\n );\n\n const annotation: Annotation.Annotation<T> = {\n [ANNOTATION_TYPE_ID]: { _Type: {} as T },\n key: props.id as Annotation.Key,\n schema: props.schema,\n get: (schema) => getFromAst(schema.ast, annotation),\n getFromAst: (ast) => getFromAst(ast, annotation),\n set: (value) =>\n PropertyMeta(props.id, Schema.encodeSync(props.schema)(value)) as <S extends Schema.Schema.Any>(schema: S) => S,\n };\n\n return annotation;\n};\n\nconst IconAnnotationSchema = Schema.Struct({\n /**\n * Phosphor icon name (e.g., 'ph--user--regular', 'ph--cube--regular', 'ph--link--regular ', etc.)\n */\n icon: Schema.String.pipe(Schema.pattern(/^ph--[a-z-]+--[a-z]+$/)),\n\n /**\n * Color name.\n *\n * List of colors:\n * - 'red'\n * - 'orange'\n * - 'amber'\n * - 'yellow'\n * - 'lime'\n * - 'green'\n * - 'emerald'\n * - 'teal'\n * - 'cyan'\n * - 'violet'\n * - 'purple'\n * - 'fuchsia'\n * - 'pink'\n * - 'rose'\n */\n hue: Schema.optional(Schema.String),\n});\n\nexport interface IconAnnotation extends Schema.Schema.Type<typeof IconAnnotationSchema> {}\n\n/**\n * Icon to render in the UI.\n */\nexport const IconAnnotation = makeUserAnnotation<IconAnnotation>({\n id: 'org.dxos.annotation.icon',\n schema: IconAnnotationSchema,\n});\n\n/**\n * Indicates that this entity's icon should be resolved from a property whose value is a `Ref`\n * to another entity. Consumers (e.g. graph node builders) resolve the ref target and use that\n * target's schema `IconAnnotation` in place of the static one declared on this schema.\n *\n * Useful for wrapper schemas that delegate their visual identity to a referenced sub-entity\n * (e.g. a generic `Game` whose icon should come from its `variant` ref's typed state).\n */\nexport const IconFromRefAnnotation = makeUserAnnotation<string>({\n id: 'org.dxos.annotation.icon.from-ref',\n schema: Schema.String,\n});\n\n/**\n * Options for {@link getLabel}.\n */\nexport type GetLabelOptions = {\n /**\n * Strategy for deriving a label when the entity has no `LabelAnnotation` value.\n * - `'typename'`: use the entity's typename (e.g. `org.dxos.type.table`).\n * Useful for Card.Title chrome that must always display something, even\n * for unlabeled objects.\n */\n fallback?: 'typename';\n};\n\n/**\n * Get the label of an entity.\n * Accepts both reactive entities and snapshots.\n *\n * If `options.fallback === 'typename'` and no label is set, returns the\n * entity's typename instead.\n */\nexport const getLabel = (entity: AnyProperties, options?: GetLabelOptions): string | undefined => {\n const schema = getSchema(entity);\n const label = schema != null ? getLabelWithSchema(schema, entity) : undefined;\n if (label != null) {\n return label;\n }\n if (options?.fallback === 'typename') {\n return getTypename(entity);\n }\n return undefined;\n};\n\n/**\n * Set the label of an entity.\n * Must be called within an Obj.update or Relation.update callback.\n */\nexport const setLabel = (entity: Mutable<AnyProperties>, label: string) => {\n const schema = getSchema(entity);\n if (schema != null) {\n setLabelWithSchema(schema, entity, label);\n }\n};\n\n/**\n * Get the description of an entity.\n * Accepts both reactive entities and snapshots.\n */\nexport const getDescription = (entity: AnyProperties): string | undefined => {\n const schema = getSchema(entity);\n if (schema != null) {\n return getDescriptionWithSchema(schema, entity);\n }\n};\n\n/**\n * Get the icon annotation for an entity, resolved via its type-level `IconAnnotation`.\n * Accepts both reactive entities and snapshots.\n *\n * Returns the full `{ icon, hue }` annotation so callers can use both the phosphor icon\n * name and the suggested colour. Callers wanting just the icon name typically write\n * `Obj.getIcon(obj)?.icon ?? 'ph--cube--regular'`.\n *\n * Note: this is the \"static\" icon from the object's own schema. It does not follow\n * `IconFromRefAnnotation` delegation — call sites needing that (e.g. app-graph node\n * builders) should resolve the ref themselves.\n */\nexport const getIcon = (entity: AnyProperties): IconAnnotation | undefined => {\n const schema = getSchema(entity);\n if (schema == null) {\n return undefined;\n }\n return Option.getOrUndefined(IconAnnotation.get(schema));\n};\n\n/**\n * Set the description of an entity.\n * Must be called within an Obj.update or Relation.update callback.\n */\nexport const setDescription = (entity: Mutable<AnyProperties>, description: string) => {\n const schema = getSchema(entity);\n if (schema != null) {\n setDescriptionWithSchema(schema, entity, description);\n }\n};\n\nexport { Dictionary, Key, getDictionary, setDictionary } from './dictionary';\n\nexport const getFromAst = <T>(ast: SchemaAST.AST, annotation: Annotation.Annotation<T>): Option.Option<T> => {\n return SchemaAST.getAnnotation<PropertyMetaAnnotation>(PropertyMetaAnnotationId)(ast).pipe(\n Option.flatMap((meta) => Option.fromNullable(meta[annotation.key])),\n Option.map(Schema.decodeUnknownSync(annotation.schema)),\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// TODO(rename): These internal entity-wide symbols/types still use the `Object*` prefix but apply\n// to all entities (objects AND relations). Rename to `Entity*` in a follow-up pass (deferred from the\n// EchoURI→EID / ObjectId→EntityId / ObjectMeta→EntityMeta rename, which covered only public SDK API):\n// ObjectCore, ObjectInternals, ObjectVersion, ObjectVersionId, ObjectDeletedId, ObjectDatabaseId,\n// ObjectLoader, ObjectDocumentLoaded, ObjectUnavailable.\n// (ObjectMigration / ObjectMigrationContext intentionally excluded — object-only, not entity-wide.)\n\n/**\n * Internal symbol/string constants for the echo object model.\n * Defined in common/ so proxy/ can use them without importing from Entity/.\n * Entity/ re-exports these for external consumers.\n */\n\n/**\n * Property name for the object's own URI when serialized to JSON.\n */\nexport const ATTR_SELF_URI = '@uri';\n\n/**\n * @deprecated Legacy JSON property name accepted on read for backward compat.\n */\nexport const ATTR_SELF_URI_LEGACY = '@dxn';\n\n/**\n * Symbol carrying the object's own URI on live entities.\n */\nexport const SelfURIId = Symbol.for('@dxos/echo/URI');\n\n/**\n * Property name for deleted when object is serialized to JSON.\n */\nexport const ATTR_DELETED = '@deleted';\n\n/**\n * Deletion marker.\n */\nexport const ObjectDeletedId = Symbol.for('@dxos/echo/Deleted');\n\n/**\n * Object version accessor symbol.\n */\nexport const ObjectVersionId: unique symbol = Symbol.for('@dxos/echo/Version');\n\n/**\n * Object database accessor symbol.\n */\nexport const ObjectDatabaseId = Symbol.for('@dxos/echo/Database');\n\n/**\n * Property name for relation source when object is serialized to JSON.\n */\nexport const ATTR_RELATION_SOURCE = '@relationSource';\n\n/**\n * Used to access relation source ref on live ECHO objects.\n */\nexport const RelationSourceId: unique symbol = Symbol.for('@dxos/echo/RelationSource');\n\n/**\n * Used to access relation source DXN on live ECHO objects.\n */\nexport const RelationSourceDXNId: unique symbol = Symbol.for('@dxos/echo/RelationSourceDXN');\n\n/**\n * Property name for relation target when object is serialized to JSON.\n */\nexport const ATTR_RELATION_TARGET = '@relationTarget';\n\n/**\n * Used to access relation target ref on live ECHO objects.\n */\nexport const RelationTargetId: unique symbol = Symbol.for('@dxos/echo/RelationTarget');\n\n/**\n * Used to access relation target DXN on live ECHO objects.\n */\nexport const RelationTargetDXNId: unique symbol = Symbol.for('@dxos/echo/RelationTargetDXN');\n\n/**\n * Symbol carrying the entity metadata (EntityMeta) on live ECHO entities.\n * Must be importable by both meta.ts (which depends on the Ref schema) and\n * Entity/api.ts (which is transitively imported by the Ref schema), so it\n * cannot live in either of those files without creating an import cycle.\n */\nexport const MetaId = Symbol.for('@dxos/echo/Meta');\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\n\n/**\n * Property name for typename when object is serialized to JSON.\n */\nexport const ATTR_TYPE = '@type';\n\n/**\n * DXN to the object type.\n */\nexport const TypeId = Symbol.for('@dxos/echo/Type');\n\n/**\n * Reference to the object schema.\n */\nexport const SchemaId = Symbol.for('@dxos/echo/Schema');\n\n/**\n * Property name for parent when object is serialized to JSON.\n */\nexport const ATTR_PARENT = '@parent';\n\n/**\n * Reference to the object parent.\n */\nexport const ParentId = Symbol.for('@dxos/echo/Parent');\n\n/**\n * Reference to the object's type entity (`Type.Obj`, `Type.Relation`, or\n * `Type.Type`). Set at instance creation by `createObject` / `makeObject`\n * when the entity is known. Public read-back via `Obj.getType` / `Relation.getType`\n * / `Entity.getType`.\n */\nexport const TypeEntityId = Symbol.for('@dxos/echo/TypeEntity');\n\n/**\n * Returns the Effect Schema for the given object if one is defined.\n *\n * @internal\n * Internal callers needing schema-side validation read from `SchemaId`.\n * Public callers should use `Type.getSchema(Obj.getType(obj))` instead.\n */\n// TODO(dmaretskyi): For echo objects, this always returns the root schema.\nexport const getSchema = (obj: unknown | undefined): Schema.Schema.AnyNoContext | undefined => {\n if (obj) {\n return (obj as any)[SchemaId];\n }\n};\n\n/**\n * @internal\n */\nexport const setSchema = (obj: any, schema: Schema.Schema.AnyNoContext): void => {\n Object.defineProperty(obj, SchemaId, {\n value: schema,\n writable: false,\n enumerable: false,\n configurable: false,\n });\n};\n\n/**\n * Returns the type entity (`Type.AnyEntity`) for the given instance.\n * Set at instance creation; every entity has a type. Defensive: returns\n * undefined for null/undefined input so callers can safely probe arbitrary\n * values via this helper.\n *\n * @internal Re-exported via `Obj.getType` / `Relation.getType` / `Entity.getType`.\n */\nexport const getType = (obj: unknown): unknown => {\n if (obj == null) {\n return undefined;\n }\n return (obj as any)[TypeEntityId];\n};\n\n/**\n * @internal\n */\nexport const setType = (obj: any, type: unknown): void => {\n Object.defineProperty(obj, TypeEntityId, {\n value: type,\n writable: false,\n enumerable: false,\n configurable: true,\n });\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as Types from 'effect/Types';\n\nimport type * as Annotation from '../../Annotation';\n\n/**\n * Unique identifier for an annotation.\n */\nexport const Key = Schema.String.pipe(Schema.brand('~@dxos/echo/AnnotationKey'));\nexport type Key = Schema.Schema.Type<typeof Key>;\n\n/**\n * Set of annotation values stored on entity meta or nested in schemas.\n */\nexport const Dictionary = Schema.Record({ key: Key, value: Schema.Unknown });\nexport interface Dictionary extends Schema.Schema.Type<typeof Dictionary> {}\n\n/**\n * Get the value of an annotation from a dictionary.\n */\nexport const getDictionary = <T>(\n values: Annotation.Dictionary,\n annotation: Annotation.Annotation<T>,\n): Option.Option<T> => {\n if (!(annotation.key in values)) {\n return Option.none();\n }\n\n return Function.pipe(values[annotation.key], Schema.decodeUnknownSync(annotation.schema), Option.some);\n};\n\n/**\n * Set the value of an annotation in a dictionary.\n */\nexport const setDictionary = <T>(\n values: Types.Mutable<Annotation.Dictionary>,\n annotation: Annotation.Annotation<T>,\n value: T,\n): void => {\n values[annotation.key] = Schema.encodeSync(annotation.schema)(value);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\nimport { DXN, EID, URI, type SpaceId } from '@dxos/keys';\nimport { assumeType } from '@dxos/util';\n\nimport type { AnyEntity } from '../common/types';\nimport { MetaId } from '../common/types/model-symbols';\nimport { type InternalObjectProps, ObjectDatabaseId } from './model';\nimport { getObjectEchoUri } from './util';\n\n/**\n * Controls the URI form returned by `getUri` and the public `*.getURI` helpers.\n *\n * - `'named'` — Registry key URI (`dxn:<meta.key>`) when the entity has a key in its meta;\n * falls back to the default EID.\n * - `'absolute'` — Fully-qualified EID with space id (`echo://<spaceId>/<entityId>`);\n * falls back when no space is available.\n * - `'relative'` — Local EID without space id (`echo:/<entityId>`).\n *\n * Omitting `prefer` preserves the existing behaviour.\n */\nexport type GetURIOptions = {\n prefer?: 'named' | 'absolute' | 'relative';\n};\n\n/**\n * Get the URI of an entity.\n * Accepts both reactive entities and snapshots.\n */\nexport const getUri = (entity: AnyEntity, options?: GetURIOptions): URI.URI => {\n const prefer = options?.prefer;\n\n if (prefer === 'named') {\n const key = (entity as any)[MetaId]?.key;\n if (key) {\n return (DXN.tryMake(`dxn:${key}`) ?? URI.make(key)) as URI.URI;\n }\n const uri = getObjectEchoUri(entity);\n invariant(uri != null, 'Invalid entity.');\n return uri;\n }\n\n if (prefer === 'relative') {\n const eid = getObjectEchoUri(entity);\n invariant(eid != null, 'Invalid entity.');\n const entityId = EID.getEntityId(eid);\n return entityId ? EID.make({ entityId }) : eid;\n }\n\n if (prefer === 'absolute') {\n const eid = getObjectEchoUri(entity);\n invariant(eid != null, 'Invalid entity.');\n const entityId = EID.getEntityId(eid);\n if (!entityId) {\n return eid;\n }\n assumeType<InternalObjectProps>(entity);\n const spaceId: SpaceId | undefined = entity[ObjectDatabaseId]?.spaceId ?? EID.getSpaceId(eid);\n return spaceId ? EID.make({ spaceId, entityId }) : eid;\n }\n\n const uri = getObjectEchoUri(entity);\n invariant(uri != null, 'Invalid entity.');\n return uri;\n};\n\n/**\n * Get the database the entity belongs to.\n * Accepts both reactive entities and snapshots.\n */\nexport const getDatabase = (entity: AnyEntity): any | undefined => {\n assumeType<InternalObjectProps>(entity);\n return entity[ObjectDatabaseId];\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\n\nimport { type ForeignKey } from '@dxos/echo-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { EID, EntityId, type URI } from '@dxos/keys';\nimport { assumeType } from '@dxos/util';\n\nimport type * as Database from '../../Database';\nimport {\n type ATTR_PARENT,\n type ATTR_TYPE,\n ATTR_DELETED,\n ATTR_RELATION_SOURCE,\n ATTR_RELATION_TARGET,\n ATTR_SELF_URI,\n ATTR_SELF_URI_LEGACY,\n EntityKind,\n KindId,\n ObjectDatabaseId,\n ObjectDeletedId,\n ObjectVersionId,\n type ParentId,\n RelationSourceDXNId,\n RelationSourceId,\n RelationTargetDXNId,\n RelationTargetId,\n type SchemaId,\n SelfURIId,\n TypeId,\n type Version,\n} from '../common/types';\nimport { type ATTR_META, type EntityMeta } from '../common/types/meta';\nimport { type MetaId } from '../common/types/model-symbols';\n\nexport {\n ATTR_DELETED,\n ATTR_SELF_URI,\n ATTR_SELF_URI_LEGACY,\n ObjectDatabaseId,\n ObjectDeletedId,\n ObjectVersionId,\n SelfURIId,\n};\n\n/**\n * Internal runtime representation of an object.\n * The fields are accessed through getter functions.\n */\n// NOTE: Each symbol has a jsdoc describing its purpose.\nexport interface InternalObjectProps {\n readonly id: EntityId;\n readonly [SelfURIId]: EID.EID;\n readonly [KindId]: EntityKind;\n readonly [SchemaId]: Schema.Schema.AnyNoContext;\n readonly [TypeId]: URI.URI;\n readonly [MetaId]?: EntityMeta;\n [ParentId]?: InternalObjectProps;\n readonly [ObjectDatabaseId]?: Database.Database;\n readonly [ObjectDeletedId]?: boolean;\n readonly [ObjectVersionId]?: Version;\n readonly [RelationSourceDXNId]?: EID.EID;\n readonly [RelationTargetDXNId]?: EID.EID;\n readonly [RelationSourceId]?: InternalObjectProps;\n readonly [RelationTargetId]?: InternalObjectProps;\n}\n\n/**\n * Entity metadata.\n */\nexport interface EntityMetaJSON {\n keys: ForeignKey[];\n tags?: string[];\n key?: string;\n version?: string;\n}\n\n/**\n * JSON representation of an object or relation metadata.\n */\nexport interface ObjectJSON {\n id: EntityId;\n [ATTR_TYPE]?: URI.URI;\n [ATTR_SELF_URI]?: EID.EID;\n [ATTR_PARENT]?: EID.EID; // Encoded reference\n [ATTR_DELETED]?: boolean;\n [ATTR_META]?: EntityMetaJSON;\n [ATTR_RELATION_SOURCE]?: EID.EID;\n [ATTR_RELATION_TARGET]?: EID.EID;\n\n /**\n * Application-specific properties.\n */\n [key: string]: unknown;\n}\n\n/**\n * NOTE: Keep as `function` to avoid type inference issues.\n */\nexport function assertObjectModel(obj: unknown): asserts obj is InternalObjectProps {\n invariant(typeof obj === 'object' && obj !== null, 'Invalid object model: not an object');\n assumeType<InternalObjectProps>(obj);\n invariant(EntityId.isValid(obj.id), 'Invalid object model: invalid id');\n invariant(obj[TypeId] === undefined || typeof obj[TypeId] === 'string', 'Invalid object model: invalid type');\n invariant(\n obj[KindId] === EntityKind.Object || obj[KindId] === EntityKind.Relation || obj[KindId] === EntityKind.Type,\n 'Invalid object model: invalid entity kind',\n );\n\n if (obj[KindId] === EntityKind.Relation) {\n invariant(EID.isEID(obj[RelationSourceDXNId]), 'Invalid object model: invalid relation source');\n invariant(EID.isEID(obj[RelationTargetDXNId]), 'Invalid object model: invalid relation target');\n invariant(!EID.isEID(obj[RelationSourceId]), 'Invalid object model: source pointer is a DXN');\n invariant(!EID.isEID(obj[RelationTargetId]), 'Invalid object model: target pointer is a DXN');\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { EID, EntityId } from '@dxos/keys';\nimport { assumeType } from '@dxos/util';\n\nimport { type InternalObjectProps, SelfURIId } from './model';\n\n/**\n * Returns the EID of an object.\n *\n * @internal\n */\nexport const getObjectEchoUri = (object: any): EID.EID | undefined => {\n invariant(!Schema.isSchema(object), 'schema not allowed in this function');\n assertArgument(typeof object === 'object' && object != null, 'object', 'expected object');\n assumeType<InternalObjectProps>(object);\n\n if (object[SelfURIId]) {\n invariant(EID.isEID(object[SelfURIId]), 'Invalid object model: invalid self dxn');\n return EID.parse(object[SelfURIId]);\n }\n\n if (!EntityId.isValid(object.id)) {\n throw new TypeError('Object id is not valid.');\n }\n\n return EID.make({ entityId: object.id });\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;AAAA;;;;gBA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B,OAAcC,eAAAA,KAAAA,CAAAA,WAAe,SAAA,wBAAA,YAAA,qBAAA,MAAA,OAAA,iBAAA,CAAA,CAAA,CAAA;;OAEpBH;IACT,SAAA;AACF,aAAA;IACF;;;",
6
- "names": ["TypeId", "Context", "Effect", "Effectable", "Layer", "Option", "Schema", "EffectEx", "invariant", "Schema", "raise", "assertArgument", "DXN", "EID", "URI", "Function", "Option", "Schema", "SchemaAST", "SchemaEx", "assertArgument", "invariant", "DXN", "URI", "ATTR_SELF_URI", "ATTR_SELF_URI_LEGACY", "SelfURIId", "Symbol", "for", "ATTR_DELETED", "ObjectDeletedId", "ObjectVersionId", "ObjectDatabaseId", "ATTR_RELATION_SOURCE", "RelationSourceId", "RelationSourceDXNId", "ATTR_RELATION_TARGET", "RelationTargetId", "RelationTargetDXNId", "MetaId", "ATTR_TYPE", "TypeId", "Symbol", "for", "SchemaId", "ATTR_PARENT", "ParentId", "TypeEntityId", "getSchema", "obj", "setSchema", "schema", "Object", "defineProperty", "value", "writable", "enumerable", "configurable", "getType", "undefined", "setType", "type", "Function", "Option", "Schema", "Key", "String", "pipe", "brand", "Dictionary", "Record", "key", "value", "Unknown", "getDictionary", "values", "annotation", "none", "decodeUnknownSync", "schema", "some", "setDictionary", "encodeSync", "ANNOTATION_TYPE_ID", "id", "getTypeIdentifierAnnotation", "URI", "objectAnnotation", "typename", "undefined", "example", "TypeMeta", "version", "VersionSchema", "Function", "getAnnotation", "schema", "getSchemaTypename", "DXN", "type", "parsed", "Object", "defineProperty", "obj", "TypeId", "writable", "enumerable", "configurable", "invariant", "existingMeta", "self", "annotations", "PropertyMetaAnnotationId", "value", "assertArgument", "SchemaEx", "getField", "annotation", "label", "object", "accessor", "description", "key", "get", "getFromAst", "ast", "set", "PropertyMeta", "Schema", "encodeSync", "IconAnnotationSchema", "getLabelWithSchema", "options", "setLabelWithSchema", "entity", "getDescriptionWithSchema", "Option", "setDescriptionWithSchema", "invariant", "DXN", "EID", "URI", "assumeType", "invariant", "EID", "EntityId", "assumeType", "__dxlog_file", "ATTR_DELETED", "assumeType", "obj", "invariant", "EntityId", "isValid", "__dxlog_file", "TypeId", "KindId", "EntityKind", "Type", "EID", "isEID", "RelationSourceDXNId", "RelationTargetDXNId", "Schema", "assertArgument", "invariant", "EID", "EntityId", "assumeType", "__dxlog_file", "assertArgument", "object", "assumeType", "SelfURIId", "invariant", "EID", "EntityId", "isValid", "make", "__dxlog_file", "prefer", "key", "MetaId", "DXN", "tryMake", "uri", "getObjectEchoUri", "entity", "invariant", "eid", "entityId", "getEntityId", "make", "assumeType", "spaceId", "EID", "ObjectDatabaseId", "getTypeURIFromSpecifier", "input", "isSchema", "getSchemaURI", "raise", "TypeError", "KindId", "schema", "getStaticTypeSchema", "uri", "getUriFromEntity", "assertArgument", "EID", "isEID", "DXN", "isDXN", "isInstanceOf", "schemaOrType", "object", "schemaURI", "type", "TypeId", "URI", "isURI", "typename", "getTypename", "parsed", "tryMake", "getName", "__dxlog_file", "obj", "TypeId", "Database", "Schema", "Any", "space", "isDatabase", "db", "spaceId", "dxn", "ref", "object", "EffectEx", "context", "resolve", "Effect", "pipe", "withSpan", "EntityNotFoundError", "uri", "eff", "result", "first", "CommitPrototype"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/Entity.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport type { ForeignKey } from '@dxos/echo-protocol';\nimport type { EntityId, URI } from '@dxos/keys';\n\nimport * as internal from './internal';\nimport * as objInternal from './internal/Obj';\nimport type * as Ref from './Ref';\nimport type * as Relation from './Relation';\nimport type * as Tag from './Tag';\nimport * as Type from './Type';\n\n// Re-export KindId and SnapshotKindId from internal.\nexport const KindId = internal.KindId;\nexport type KindId = typeof internal.KindId;\nexport const SnapshotKindId = internal.SnapshotKindId;\nexport type SnapshotKindId = typeof internal.SnapshotKindId;\n\n// NOTE: Relation does not extend Obj so that, for example, we can prevent Relations from being used as source and target objects.\n// However, we generally refer to Obj and Relation instances as \"objects\",\n// and many API methods accept both Obj.Unknown and Relation.Unknown (i.e., Entity.Unknown) instances.\n\nexport const Kind = internal.EntityKind;\nexport type Kind = internal.EntityKind;\nexport const KindSchema = internal.EntityKindSchema;\n\n/**\n * Assigns a kind to an Object or Relation instance.\n * NOTE: Needed to make `isRelation` and `isObject` checks work.\n */\nexport interface OfKind<K extends Kind> {\n readonly [KindId]: K;\n readonly id: EntityId;\n}\n\n/**\n * Assigns a snapshot kind to an Object or Relation snapshot.\n */\nexport interface SnapshotOfKind<K extends Kind> {\n readonly [SnapshotKindId]: K;\n readonly id: EntityId;\n}\n\n/**\n * Obj or Relation with a specific set of properties.\n */\nexport type Entity<Props> = OfKind<Kind> & Props;\n\n/**\n * Unknown Obj or Relation (reactive).\n */\nexport interface Unknown extends OfKind<Kind> {}\n\n/**\n * Effect Schema for any ECHO entity (object or relation).\n *\n * Kind-agnostic counterpart to `Obj.Unknown` / `Relation.Unknown` — validates\n * the structural shape (id + properties) without constraining `[KindId]`. Used\n * in operation input schemas that accept any entity flavour (e.g.\n * `Schema.Array(Entity.Unknown)`).\n *\n * The cast bridges the runtime structural schema to the branded `Unknown` type:\n * `[KindId]` is a symbol brand that can't be expressed in a runtime `Struct`,\n * so the entity guarantee is carried at the type level only (same approach as\n * `Obj.Unknown` / `Relation.Unknown`). Unlike those, this is kind-agnostic so it\n * isn't an `UnknownTypeSchema<_, K>` (there's no single `K`) and carries no\n * `TypeAnnotation`.\n */\nexport const Unknown: Schema.Schema<Unknown> = Schema.Struct({\n id: Schema.String,\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n) as unknown as Schema.Schema<Unknown>;\n\n/**\n * Snapshot of an Obj or Relation.\n * Branded with SnapshotKindId instead of KindId.\n */\nexport interface Snapshot extends SnapshotOfKind<Kind> {}\n\n/**\n * Object with arbitrary properties.\n *\n * NOTE: Due to how typescript works, this type is not assignable to a specific schema type.\n * In that case, use `Obj.instanceOf` to check if an object is of a specific type.\n *\n * This type is very permissive and allows accessing any property on the object.\n * We should move to Obj.Unknown that is not permissive and requires explicit instanceof checks..\n */\nexport interface Any extends OfKind<Kind> {\n [key: string]: unknown;\n}\n\n/**\n * Returns all properties of an object or relation except for the id and kind.\n */\nexport type Properties<T> = Omit<T, 'id' | KindId | Relation.Source | Relation.Target>;\n\n/**\n * Check if a value is an ECHO entity (object or relation).\n * Returns `false` for snapshots.\n */\nexport const isEntity: (value: unknown) => value is Unknown = internal.isEntity;\n\n/**\n * Test if a value is an instance of a given object or relation type.\n *\n * Kind-agnostic counterpart to `Obj.instanceOf` / `Relation.instanceOf` —\n * use this when the caller's input type is `Type.AnyObj | Type.AnyRelation`.\n *\n * @example\n * ```ts\n * // Caller doesn't know whether `type` is object- or relation-kind.\n * const matches = <T extends Type.AnyObj | Type.AnyRelation>(type: T, value: unknown) =>\n * Entity.instanceOf(type, value);\n * ```\n */\nexport const instanceOf: {\n <S extends Type.AnyEntity>(schema: S): (value: unknown) => value is Type.InstanceType<S>;\n <S extends Type.AnyEntity>(schema: S, value: unknown): value is Type.InstanceType<S>;\n} = ((...args: [schema: Type.AnyEntity, value?: unknown]) => {\n if (args.length === 1) {\n return (entity: unknown) => internal.isInstanceOf(args[0], entity);\n }\n return internal.isInstanceOf(args[0], args[1]);\n}) as any;\n\n/**\n * Check if a value is an ECHO entity snapshot.\n * Returns `false` for entities.\n */\nexport const isSnapshot = (value: unknown): value is Snapshot => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n return (value as any)[SnapshotKindId] !== undefined;\n};\n\n// TODO(dmaretskyi): Type introspection -- move to kind.\nexport const getKind = internal.getEntityKind;\n\n/**\n * Property that accesses metadata for an entity.\n */\nexport const Meta: unique symbol = internal.MetaId as any;\n\n/**\n * Property that accesses metadata for an entity.\n */\nexport type Meta = typeof Meta;\n\n//\n// Entity-level functions that work on any entity (object or relation).\n// Use these when you don't know or care about the specific entity kind.\n// For kind-specific functions, use Obj.* or Relation.*.\n//\n\n/**\n * JSON representation of an entity.\n */\nexport type JSON = internal.ObjectJSON;\n\n/**\n * Whether the entity is a type-kind entity (a `Type.Type` produced by\n * `Type.makeObject` / `Type.makeRelation`, or a persisted schema). Type entities\n * carry their identity (typename/version) on themselves rather than referencing a\n * separate type, so the accessors below route them through the `Type.*` module.\n */\nconst isTypeEntity = (entity: unknown): boolean => internal.getEntityKindBrand(entity) === internal.EntityKind.Type;\n\n/**\n * Any value the read accessors operate on: a reactive entity or a snapshot.\n * Type entities (`Type.AnyEntity`) are also accepted — they're first-class\n * entities, and `Unknown`'s kind-agnostic brand already subsumes them.\n */\nexport type AnyInput = Unknown | Snapshot;\n\n/**\n * Get the canonical URI of an entity (object, relation, or type). Returns `URI.URI` —\n * an `EID` for object/relation instances and persisted types, or a typename\n * `DXN` for static type entities; narrow with `EID.parse(uri)` or\n * `DXN.tryMake(uri)` at the point of use.\n *\n * @param options.prefer - Controls the URI form (see {@link internal.GetURIOptions}).\n */\nexport const getURI = (entity: AnyInput, options?: internal.GetURIOptions): URI.URI =>\n isTypeEntity(entity) ? Type.getURI(entity as Type.AnyEntity) : internal.getUri(entity as Unknown, options);\n\n/**\n * Get the DXN of an entity's type. For object/relation instances this is the URI\n * of the type they were created from; for a type entity it is the URI of the\n * meta-type ({@link Type.Type}, `dxn:org.dxos.type.schema:0.1.0`).\n */\nexport const getTypeURI = (entity: AnyInput): URI.URI | undefined =>\n isTypeEntity(entity) ? Type.getURI(Type.Type) : internal.getTypeURI(entity as Unknown);\n\n/**\n * Get the type entity (`Type.AnyEntity`) the instance was created from.\n *\n * Returns `undefined` when the entity's type isn't registered in this runtime\n * (e.g. a freshly deserialized snapshot whose type entity hasn't been wired\n * up yet, or an entity loaded from storage before its schema is known). To\n * get the Effect Schema from the returned entity, use `Type.getSchema(...)`.\n *\n * For a type entity, returns the meta-type {@link Type.Type} (a type entity's\n * type is \"Type\").\n */\nexport const getType = (entity: AnyInput): Type.AnyEntity | undefined =>\n isTypeEntity(entity) ? Type.Type : (internal.getType(entity) as Type.AnyEntity | undefined);\n\n/**\n * Get the typename of an entity's type. For object/relation instances this is the\n * typename of the type they were created from; for a type entity it is the type's\n * own typename (e.g. `com.example.type.person`).\n */\nexport const getTypename = (entity: AnyInput): string | undefined =>\n isTypeEntity(entity) ? Type.getTypename(entity as Type.AnyEntity) : internal.getTypename(entity as Unknown);\n\n/**\n * Get the database an entity belongs to.\n */\nexport const getDatabase = (entity: Unknown | Snapshot): any | undefined => internal.getDatabase(entity);\n\n/**\n * Get the metadata for an entity.\n * Returns mutable meta when passed a mutable entity (inside change callback).\n * Returns read-only meta when passed a regular entity or snapshot.\n */\n// TODO(wittjosiah): When passed a Snapshot, should return a snapshot of meta, not the live meta proxy.\nexport function getMeta(entity: Mutable<Unknown>): internal.EntityMeta;\nexport function getMeta(entity: Unknown | Snapshot): internal.ReadonlyMeta;\nexport function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): internal.EntityMeta | internal.ReadonlyMeta {\n return internal.getMetaChecked(entity);\n}\n\n/**\n * Get foreign keys for an entity from the specified source.\n */\nexport const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => internal.getKeys(entity, source);\n\n/**\n * Check if an entity is deleted.\n */\nexport const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDeleted(entity);\n\n/**\n * Get the label of an entity.\n *\n * @param options.fallback `'typename'` returns the entity's typename when no\n * label is set (e.g. `org.dxos.type.table`).\n */\nexport const getLabel = (entity: Unknown | Snapshot, options?: internal.GetLabelOptions): string | undefined =>\n internal.getLabel(entity, options);\n\n/**\n * Set the label of an entity.\n * Must be called within an `Entity.update` / `Obj.update` / `Relation.update` callback.\n */\nexport const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);\n\n/**\n * Get the description of an entity.\n */\nexport const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);\n\n/**\n * Get the icon annotation for an entity (object or relation), resolved via its type-level\n * `IconAnnotation`. Returns the full `{ icon, hue }` annotation so callers can use both\n * the phosphor icon name and the suggested colour.\n */\nexport const getIcon = (entity: Unknown | Snapshot): internal.IconAnnotation | undefined => internal.getIcon(entity);\n\n/**\n * Convert an entity to its JSON representation.\n */\nexport const toJSON = (entity: Unknown | Snapshot): JSON => internal.objectToJSON(entity);\n\n/**\n * Subscribe to changes on an entity (object or relation).\n * @returns Unsubscribe function.\n */\nexport const subscribe = (entity: Unknown, callback: () => void): (() => void) => {\n return internal.subscribe(entity, callback);\n};\n\n//\n// Change\n//\n\n/**\n * Used to provide a mutable view of an entity within `Entity.update`.\n */\nexport type Mutable<T> = internal.Mutable<T>;\n\n/**\n * Perform mutations on an entity (object or relation) within a change context.\n *\n * Entities are read-only by default. Mutations are batched and notifications fire\n * when the callback completes. Direct mutations outside of `Entity.update` will throw\n * at runtime.\n *\n * @param entity - The echo entity (object or relation) to mutate.\n * @param callback - Receives a mutable view of the entity. All mutations must occur here.\n *\n * @example\n * ```typescript\n * // Mutate within Entity.update\n * Entity.update(entity, (obj) => {\n * obj.name = 'Updated';\n * obj.count = 42;\n * });\n *\n * // Direct mutation throws\n * entity.name = 'Bob'; // Error: Cannot modify outside Entity.update()\n * ```\n *\n * Note: For type-specific operations, prefer `Obj.update` or `Relation.update`.\n */\nexport const update = <T extends Unknown>(entity: T, callback: internal.ChangeCallback<T>): void => {\n internal.change(entity, callback);\n};\n\n/**\n * Add a tag to an entity.\n * Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.\n */\nexport const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);\n\n/**\n * Remove a tag from an entity.\n * Must be called within an `Entity.update`, `Obj.update`, or `Relation.update` callback.\n */\nexport const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);\n\n//\n// Atoms\n//\n\nexport const atom = objInternal.makeEntity;\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,IAAI,IAAaI,WAAWd,MAAAA;AAa/D,IAAMe,WAAU,CAACf,WACtBQ,aAAaR,MAAAA,IAAeU,OAAiBK,QAAQf,MAAAA;AAOhD,IAAMgB,eAAc,CAAChB,WAC1BQ,aAAaR,MAAAA,IAAegB,aAAYhB,MAAAA,IAAqCgB,YAAYhB,MAAAA;AAKpF,IAAMiB,eAAc,CAACjB,WAAyDiB,YAAYjB,MAAAA;AAU1F,SAASkB,QAAQlB,QAA6C;AACnE,SAAgBmB,eAAenB,MAAAA;AACjC;AAKO,IAAMoB,WAAU,CAACpB,QAA4BqB,WAA0CD,QAAQpB,QAAQqB,MAAAA;AAKvG,IAAMC,aAAY,CAACtB,WAAiDsB,UAAUtB,MAAAA;AAQ9E,IAAMuB,YAAW,CAACvB,QAA4BY,YAC1CW,SAASvB,QAAQY,OAAAA;AAMrB,IAAMY,YAAW,CAACxB,QAA0ByB,UAAiCD,SAASxB,QAAQyB,KAAAA;AAK9F,IAAMC,kBAAiB,CAAC1B,WAA4D0B,eAAe1B,MAAAA;AAOnG,IAAM2B,WAAU,CAAC3B,WAA6E2B,QAAQ3B,MAAAA;AAKtG,IAAM4B,SAAS,CAAC5B,WAA8C6B,aAAa7B,MAAAA;AAM3E,IAAM8B,aAAY,CAAC9B,QAAiB+B,aAAAA;AACzC,SAAgBD,UAAU9B,QAAQ+B,QAAAA;AACpC;AAmCO,IAAMC,SAAS,CAAoBhC,QAAW+B,aAAAA;AACnDE,EAASC,OAAOlC,QAAQ+B,QAAAA;AAC1B;AAMO,IAAMI,UAAS,CAACnC,QAA0BoC,QAAyCD,OAAOnC,QAAQoC,GAAAA;AAMlG,IAAMC,aAAY,CAACrC,QAA0BoC,QAAyCC,UAAUrC,QAAQoC,GAAAA;AAMxG,IAAME,OAAmBC;",
6
- "names": ["KindId", "SnapshotKindId", "Unknown", "addTag", "getDatabase", "getDescription", "getIcon", "getKeys", "getLabel", "getType", "getTypeURI", "getTypename", "getURI", "isDeleted", "isEntity", "removeTag", "setLabel", "subscribe", "Schema", "KindId", "SnapshotKindId", "Kind", "EntityKind", "KindSchema", "EntityKindSchema", "Unknown", "Struct", "id", "String", "pipe", "extend", "Record", "key", "value", "isEntity", "instanceOf", "args", "length", "entity", "isInstanceOf", "isSnapshot", "undefined", "getKind", "getEntityKind", "Meta", "MetaId", "isTypeEntity", "getEntityKindBrand", "Type", "getURI", "options", "getUri", "getTypeURI", "getType", "getTypename", "getDatabase", "getMeta", "getMetaChecked", "getKeys", "source", "isDeleted", "getLabel", "setLabel", "label", "getDescription", "getIcon", "toJSON", "objectToJSON", "subscribe", "callback", "update", "internal", "change", "addTag", "tag", "removeTag", "atom", "makeEntity"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/Type.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\nimport type * as Types from 'effect/Types';\n\nimport { raise } from '@dxos/debug';\nimport { type EncodedReference } from '@dxos/echo-protocol';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN, EID, type EntityId, type URI } from '@dxos/keys';\n\nimport type * as Database from './Database';\nimport type * as EntityModule from './Entity';\nimport * as internal from './internal';\nimport * as typeInternal from './internal/Type';\nimport type * as RelationModule from './Relation';\n\n//\n// Internal types (not exported)\n//\n\n/**\n * Structural base shared by the three sibling type-entity interfaces\n * ({@link Obj}, {@link Relation}, {@link Type}). NOT exported — callers\n * should constrain on {@link AnyEntity} when they want \"any of the three\"\n * and on the specific kind interface otherwise.\n */\ninterface BaseTypeEntity<A> {\n /**\n * Entity-kind brand of the type-entity value itself — always `EntityKind.Type`.\n * The kind of instance the type *describes* lives on `[SchemaKindId]`\n * (Object / Relation / Type). Lets `Obj.isObject` / `Relation.isRelation`\n * reject type entities by a single `[KindId]` check.\n */\n readonly [internal.KindId]: internal.EntityKind.Type;\n\n /**\n * Object id. Like all ECHO entities, type entities always carry an id —\n * stamped at construction for in-memory (static) declarations and assigned by\n * the database once persisted. The id does NOT determine the entity's URI:\n * static types resolve to their typename DXN, persisted types to `echo:/<id>`\n * (see `getTypeURIFromSpecifier`).\n */\n readonly id: EntityId;\n\n readonly name?: string;\n // NOTE: `typename` / `version` are intentionally NOT fields on any type-entity\n // interface. Both static and persisted entities carry them in `EntityMeta`\n // (`key` / `version`); read them via `Type.getTypename(self)` /\n // `Type.getVersion(self)` — never as a direct property.\n readonly jsonSchema: internal.JsonSchemaType;\n readonly [InstancePhantomId]?: A;\n}\n\n//\n// Obj — `Type.Type` value for an ECHO object schema.\n//\n\n/**\n * TypeScript type for an ECHO object type — a `Type.Type<A>` entity.\n *\n * `T` is the instance type produced by `Obj.make(Foo, props)`. `Fields` is\n * retained as a structural hint (the runtime value still carries `.fields`),\n * but consumers should derive instance/encoded types via `Type.InstanceType`.\n *\n * **Not a `Schema.Schema`.** `Foo.ast` / `Schema.Schema.Type<typeof Foo>` /\n * `Schema.extend(Foo)` no longer typecheck — extract the Effect Schema via\n * `Type.getSchema(Foo)` first, or derive instance types via\n * `Type.InstanceType<typeof Foo>`.\n *\n * @example\n * ```ts\n * const Person = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));\n *\n * type Person = Type.InstanceType<typeof Person>;\n * ```\n */\nexport interface Obj<T, Fields extends Schema.Struct.Fields = Schema.Struct.Fields> extends BaseTypeEntity<\n T & EntityModule.OfKind<typeof EntityModule.Kind.Object>\n> {\n /** Schema-kind brand (object). */\n readonly [internal.SchemaKindId]: internal.EntityKind.Object;\n\n /** Source Effect Schema — used internally by `Type.getSchema(self)`. */\n readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;\n\n /**\n * The fields defined in the original struct schema.\n * Allows accessing field definitions for introspection.\n */\n readonly fields: Fields;\n}\n\n/**\n * Type that represents any ECHO object type — a `Type.Type` entity branded\n * with the object entity kind, i.e. what `Type.makeObject(dxn)` produces.\n */\nexport type AnyObj = Obj<unknown>;\n\n/**\n * Factory function to create an ECHO object type.\n *\n * Returns a `Type.Type` entity — a live, in-memory `TypeSchema` instance,\n * NOT a `Schema.Schema`. Use `Type.InstanceType<typeof Foo>` for the instance\n * type and `Type.getSchema(Foo)` to obtain the underlying Effect Schema.\n *\n * The entity's id defaults to `EntityId.deterministic(typename, version)` so\n * constructing a type never reaches `crypto.getRandomValues()` — required for\n * Cloudflare workerd, which forbids RNG calls in global (module-evaluation)\n * scope. Pass `{ id }` to override (e.g. with `EntityId.random()` from a\n * request handler).\n *\n * @example\n * ```ts\n * const Person = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.makeObject(DXN.make('com.example.type.person', '0.1.0')));\n * ```\n */\nexport const makeObject: {\n (\n dxn: DXN.DXN,\n options?: { id?: EntityId },\n ): <Self extends Schema.Schema.Any>(self: Self) => Obj<Schema.Schema.Type<Self>>;\n} = internal.EchoObjectSchema as any;\n\n//\n// Type — the ECHO entity that holds a schema and metadata.\n// Persisted via `db.addType()`; subscribed to via `Filter.type(Type.Type)`.\n//\n\n/**\n * ECHO meta-schema entity — stores `{ name?, typename, version, jsonSchema }`.\n * Type-kind sibling of `Type.makeObject(...)` / `Type.makeRelation(...)` outputs.\n * Stored types live under this entity; filter via `Filter.type(Type.Type)`.\n */\nexport const Type: Type<typeInternal.TypeSchema> = typeInternal.TypeSchema as any;\n\n/**\n * Default version stamped on draft (unnamed) types created via\n * {@link makeObjectFromJsonSchema} / {@link makeRelationFromJsonSchema} when\n * the caller does not supply one. Pure dynamic drafts surface as `'0.0.0'`\n * until they are persisted, at which point automerge-heads suffix the version.\n */\nconst DRAFT_VERSION = '0.0.0';\n\n/**\n * Common props shared by the type-kind factories. Typename and version are\n * optional — drafts omit typename and default version to {@link DRAFT_VERSION}.\n */\ntype MakeTypeProps = {\n jsonSchema: internal.JsonSchemaType;\n typename?: string;\n version?: string;\n name?: string;\n id?: EntityId;\n};\n\n/**\n * Construct a new object-kind type entity from raw metadata — for cases where\n * an Effect Schema isn't available (e.g. JSON-Schema arriving over the network\n * or from a UI editor). Parallel to {@link makeObject} but takes pre-built\n * `jsonSchema` instead of piping through an Effect schema.\n *\n * The returned entity is in-memory; persist it with `db.addType(entity)`.\n */\nexport const makeObjectFromJsonSchema = (props: MakeTypeProps): Type<typeInternal.TypeSchema> => {\n const { typename, version, ...data } = props;\n // `typename` / `version` are routed through `EntityMeta` (`key` / `version`)\n // — the canonical registry-provenance pair — not data fields. Drafts default\n // to `'0.0.0'`; the version is omitted from meta entirely when the caller\n // doesn't supply one so the proxy projection can apply its own default.\n return internal.makeObject(\n internal.getStaticTypeSchema(typeInternal.TypeSchema) as any,\n data as any,\n {\n keys: [],\n key: typename,\n version: version ?? DRAFT_VERSION,\n },\n typeInternal.TypeSchema,\n ) as unknown as Type<typeInternal.TypeSchema>;\n};\n\n/**\n * Construct a new relation-kind type entity from raw metadata. Parallel to\n * {@link makeRelation} but takes pre-built `jsonSchema` instead of piping\n * through an Effect schema. `source` / `target` accept either a static\n * `Type.Obj` entity or the well-known `Obj.Unknown` schema.\n *\n * The returned entity is in-memory; persist it with `db.addType(entity)`.\n */\nexport const makeRelationFromJsonSchema = (\n props: MakeTypeProps & {\n source: AnyObj | internal.UnknownTypeSchema<any, typeof EntityModule.Kind.Object>;\n target: AnyObj | internal.UnknownTypeSchema<any, typeof EntityModule.Kind.Object>;\n },\n): Type<typeInternal.TypeSchema> => {\n const { source, target, jsonSchema, typename, version, ...rest } = props;\n // Embed source/target DXNs + relation entity-kind into the jsonSchema so the\n // entity round-trips correctly through `toEffectSchema` / queries / refs.\n const sourceURI = internal.getTypeURIFromSpecifier(source);\n const targetURI = internal.getTypeURIFromSpecifier(target);\n const enrichedJsonSchema: internal.JsonSchemaType = {\n ...jsonSchema,\n entityKind: internal.EntityKind.Relation,\n relationSource: { $ref: sourceURI },\n relationTarget: { $ref: targetURI },\n };\n // `typename` / `version` route through `EntityMeta` (see\n // {@link makeObjectFromJsonSchema}); drafts default version to `'0.0.0'`.\n return internal.makeObject(\n internal.getStaticTypeSchema(typeInternal.TypeSchema) as any,\n { ...rest, jsonSchema: enrichedJsonSchema } as any,\n {\n keys: [],\n key: typename,\n version: version ?? DRAFT_VERSION,\n },\n typeInternal.TypeSchema,\n ) as unknown as Type<typeInternal.TypeSchema>;\n};\n\n/**\n * TypeScript type for an ECHO relation type — a `Type.Type<A>` entity.\n *\n * `T` is the instance-property type produced by `Relation.make(...)` (excluding\n * source/target endpoints). `Source` and `Target` are the endpoint types.\n *\n * **Not a `Schema.Schema`.** See {@link Obj}'s note.\n */\nexport interface Relation<\n T,\n Source,\n Target,\n Fields extends Schema.Struct.Fields = Schema.Struct.Fields,\n> extends BaseTypeEntity<\n RelationModule.Endpoints<Source, Target> & T & EntityModule.OfKind<typeof EntityModule.Kind.Relation>\n> {\n /** Schema-kind brand (relation). */\n readonly [internal.SchemaKindId]: internal.EntityKind.Relation;\n\n /** Source Effect Schema — used internally by `Type.getSchema(self)`. */\n readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;\n\n /**\n * The fields defined in the original struct schema.\n * Allows accessing field definitions for introspection.\n */\n readonly fields: Fields;\n}\n\n/**\n * Type that represents any ECHO relation type — a `Type.Type` entity branded\n * with the relation entity kind, i.e. what `Type.makeRelation(...)` produces.\n */\nexport type AnyRelation = Relation<unknown, unknown, unknown>;\n\n/**\n * Factory function to create an ECHO relation schema.\n * Adds relation metadata annotations to an Effect schema.\n *\n * @example\n * ```ts\n * const WorksFor = Schema.Struct({\n * role: Schema.String,\n * }).pipe(Type.makeRelation({\n * dxn: DXN.make('com.example.type.worksFor', '0.1.0'),\n * source: Person,\n * target: Company,\n * }));\n * ```\n */\nexport const makeRelation: {\n <SourceInstance, TargetInstance>(opts: {\n dxn: DXN.DXN;\n source: Obj<SourceInstance, any> | internal.UnknownTypeSchema<SourceInstance, typeof EntityModule.Kind.Object>;\n target: Obj<TargetInstance, any> | internal.UnknownTypeSchema<TargetInstance, typeof EntityModule.Kind.Object>;\n /**\n * Override the entity id. Defaults to `EntityId.deterministic(typename, version)`;\n * see `Type.makeObject` for the workerd motivation.\n */\n id?: EntityId;\n }): <Self extends Schema.Schema.Any>(\n self: Self,\n ) => Relation<\n Schema.Schema.Type<Self>,\n SourceInstance & EntityModule.OfKind<typeof EntityModule.Kind.Object>,\n TargetInstance & EntityModule.OfKind<typeof EntityModule.Kind.Object>\n >;\n} = internal.EchoRelationSchema as any;\n\n/**\n * Type that represents any ECHO type-kind entity — a `Type.Type` meta-schema\n * value (static `Type.Type` or a persisted draft from `db.addType(...)`).\n * Mirrors {@link AnyObj} / {@link AnyRelation} for the third sibling kind.\n */\nexport type AnyType = Type<unknown>;\n\n/**\n * Any ECHO type-entity — one of the three sibling kinds: object-kind, relation-kind,\n * or type-kind (the meta-schema). APIs that want \"any ECHO type\" use this union;\n * the underlying Effect Schema is retrieved via `Type.getSchema`.\n */\nexport type AnyEntity = AnyObj | AnyRelation | AnyType;\n\n/**\n * Type guard: narrows a `Type.AnyEntity` to an object-kind entity. Checks\n * ENTITIES, not instances — use `Obj.isObject` for instances. Raw\n * `Schema.Schema` values (including the branded `Obj.Unknown` companion)\n * are intentionally not accepted; inspect their `TypeAnnotation` directly.\n */\nexport const isObject = (entity: AnyEntity): entity is AnyObj => {\n return internal.getSchemaKind(entity) === internal.EntityKind.Object;\n};\n\n/**\n * Type guard: narrows a `Type.AnyEntity` to a relation-kind entity. Checks\n * ENTITIES, not instances — use `Relation.isRelation` for instances.\n */\nexport const isRelation = (entity: AnyEntity): entity is AnyRelation => {\n return internal.getSchemaKind(entity) === internal.EntityKind.Relation;\n};\n\n/**\n * Type guard: narrows a `Type.AnyEntity` to the type-kind meta-schema\n * (e.g. `Type.Type`). Mirrors {@link isObject} / {@link isRelation}.\n */\nexport const isTypeKind = (entity: AnyEntity): entity is Type => {\n return internal.getSchemaKind(entity) === internal.EntityKind.Type;\n};\n\n/**\n * Narrow a `Type.AnyEntity` (e.g. one returned from `schemaRegistry.query(...)`)\n * to `AnyObj`, throwing if it describes a relation or the type-kind\n * meta-schema. Use at call sites that need to pass the value to `Obj.make`,\n * `Filter.type`, or other object-only APIs.\n */\nexport const assertObject = (entity: AnyEntity): AnyObj => {\n assertArgument(isObject(entity), 'entity', 'Expected an object-kind Type entity.');\n return entity;\n};\n\n/** Narrow a `Type.AnyEntity` to `AnyRelation`, throwing otherwise. */\nexport const expectRelation = (entity: AnyEntity): AnyRelation => {\n assertArgument(isRelation(entity), 'entity', 'Expected a relation-kind Type entity.');\n return entity;\n};\n\n/** Narrow a `Type.AnyEntity` to the `Type.Type` meta-schema, throwing otherwise. */\nexport const expectTypeKind = (entity: AnyEntity): Type => {\n assertArgument(isTypeKind(entity), 'entity', 'Expected a type-kind Type entity.');\n return entity;\n};\n\n/**\n * Type that represents any Ref schema (with unknown target type).\n * This is a schema type, not an instance type.\n */\nexport type AnyRef = Schema.Schema<internal.Ref<any>, EncodedReference>;\n\n//\n// Schema utility functions\n//\n\n/**\n * Returns the URI identifying a type entity. Always defined.\n *\n * - Static `Type.Obj` / `Type.Relation` → typename DXN (e.g. `dxn:com.example.type.person:0.1.0`).\n * - Persisted `Type.Type` instance (has `id`) → local `EID` (`echo:/<objectId>`).\n * - In-memory `Type.Type` draft (has `id`, no typename) → local `EID`.\n *\n * Only accepts `Type.AnyEntity` entities. Raw `Schema.Schema` values and the\n * branded `Obj.Unknown` / `Relation.Unknown` schemas are intentionally not\n * supported — use `internal.getSchemaURI` or the schema's typename annotation\n * directly when working at the schema level.\n */\nexport const getURI = (input: AnyEntity): URI.URI => {\n // For Type entities, route through `getTypeURIFromSpecifier` (id → EID,\n // typename/version → DXN). For Obj/Relation entities, unwrap to the source\n // Effect Schema first and read its annotations.\n if (isType(input)) {\n return internal.getTypeURIFromSpecifier(input);\n }\n return internal.getSchemaURI(getSchema(input)) ?? raise(new TypeError('Type entity has no URI'));\n};\n\n/**\n * @returns The typename. Example: `com.example.type.person`.\n *\n * Persisted `Type.Type` entities carry typename in `EntityMeta.key` (the\n * canonical registry-provenance field); unnamed drafts fall back to the\n * entity's object id so the helper always returns a string. Any `dxn:` or\n * `echo:/` prefix is stripped — typename is a bare identifier, not a URI.\n */\n// TODO(wittjosiah): For in-database types this should return the object id once the registry\n// has more robust options for shadowing types (so callers can disambiguate db-stored copies).\nexport const getTypename = (input: AnyEntity): string => {\n // Both in-memory and in-database entities carry typename in `EntityMeta.key`\n // — the canonical registry-provenance field. In-memory entities attach meta\n // eagerly (see `makeEchoTypeSchema`), so a single meta-backed read covers\n // both forms.\n const meta = internal.getMetaChecked(input);\n let typename: string | undefined = meta.key as string | undefined;\n // `meta.key` is a denormalized copy of the typename. The authoritative source\n // for a type entity is its `jsonSchema.typename` (`getSchema` rebuilds the\n // Effect Schema from `jsonSchema`). A type loaded from a snapshot can arrive\n // with `meta.key` absent (the meta round-trip dropped the denormalized copy)\n // while `jsonSchema.typename` is always present — consult it before the\n // last-resort id fallback so callers never receive a bare object id where a\n // typename is expected (e.g. `Filter.typename`, which rejects non-typenames).\n if (typename == null) {\n typename = input.jsonSchema?.typename;\n }\n // Unnamed drafts (no meta.key, no jsonSchema typename) fall back to the id.\n typename ??= input.id as string;\n // Typename is a bare identifier — strip URI prefixes if a caller seeded\n // meta.key with one accidentally (or if a static entity carries a DXN-\n // style typename).\n typename = stripTypenamePrefix(typename);\n invariant(typeof typename === 'string' && typename.length > 0, 'Invalid typename');\n return typename;\n};\n\n/**\n * Gets the version.\n * @example 0.1.0\n * @example 0.1.0-<heads> (in-database, versioned by automerge heads)\n *\n * The registry-provenance semver lives in `EntityMeta.version`; unversioned\n * drafts default to {@link DRAFT_VERSION} (`'0.0.0'`). In-database entities are\n * additionally versioned by their automerge heads, which are exposed as the\n * semver pre-release tag (`<semver>-<heads>`). In-memory declarations have no\n * heads and surface the bare semver. Read the registry semver alone via\n * `Type.getMeta(input).version`.\n */\nexport const getVersion = (input: AnyEntity): string => {\n const meta = internal.getMetaChecked(input);\n // As with `getTypename`: `meta.version` is a denormalized copy; the\n // authoritative semver lives in `jsonSchema.version`. Prefer meta, fall back\n // to jsonSchema (always present on persisted types, survives serialization),\n // then to `DRAFT_VERSION` for unversioned drafts.\n const semver = (meta.version as string | undefined) ?? input.jsonSchema?.version ?? DRAFT_VERSION;\n invariant(typeof semver === 'string' && semver.match(/^\\d+\\.\\d+\\.\\d+$/), 'Invalid version');\n // In-database entities are versioned by their automerge heads; expose them as\n // the semver pre-release tag. In-memory drafts carry no heads → bare semver.\n const heads = internal.version(input).automergeHeads;\n if (heads != null && heads.length > 0) {\n return `${semver}-${[...heads].sort().join('.')}`;\n }\n return semver;\n};\n\n/**\n * Strip URI prefixes (`dxn:`, `echo:/`, `echo://`) from a typename string.\n * Typename is a bare identifier — callers reading from meta or from a\n * caller-supplied seed value shouldn't propagate URI prefixes downstream.\n */\nconst stripTypenamePrefix = (value: string): string => {\n if (value.startsWith('dxn:')) {\n return value.slice('dxn:'.length);\n }\n if (value.startsWith('echo://')) {\n return value.slice('echo://'.length);\n }\n if (value.startsWith('echo:/')) {\n return value.slice('echo:/'.length);\n }\n return value;\n};\n\n/**\n * Type predicate: true iff the value is any type-kind ECHO entity — a static\n * `Type.Obj` / `Type.Relation` produced by `Type.makeObject` / `Type.makeRelation`, a\n * static meta `Type.Type`, or a persisted `Type.Type` returned by the database.\n *\n * All three branches stamp `[KindId] = Type`, so this is a single brand check.\n * Use {@link isObject} / {@link isRelation} / {@link isTypeKind}\n * when you need to discriminate further; use {@link getDatabase} when you mean\n * \"is this a db-attached type\" (vs. an in-memory declaration).\n */\nexport const isType = (value: unknown): value is AnyEntity =>\n internal.getEntityKindBrand(value) === internal.EntityKind.Type;\n\n/**\n * Get the database the type entity belongs to, or `undefined` if it is an\n * in-memory declaration (`Type.makeObject` / `Type.makeRelation` result) not\n * yet attached to a database. Mirrors `Obj.getDatabase` / `Relation.getDatabase`.\n *\n * Database attachment is the canonical discriminator between in-memory and\n * in-database type entities — both are live reactive `TypeSchema` instances and\n * are otherwise indistinguishable.\n */\nexport const getDatabase = (input: AnyEntity): Database.Database | undefined => internal.getDatabase(input);\n\n/**\n * Mutable meta type returned by `Type.getMeta` inside a `Type.update` callback.\n * Mirrors `Obj.Meta` / `Relation.Meta` — `Type.Type` is an Entity like its\n * siblings, so its meta is the same `EntityMeta` record:\n * `{ keys, tags?, key?, version? }`.\n *\n * `key` / `version` here are the canonical registry-provenance pair\n * (typename + semver) on persisted Type.Type entities; they are absent on\n * unnamed drafts. Use {@link getTypename} / {@link getVersion} when you want\n * a non-`undefined` value with id / {@link DRAFT_VERSION} fallbacks.\n */\nexport type Meta = internal.Meta;\n\n/**\n * Deeply read-only version of {@link Meta}.\n * Prevents mutation at all nesting levels (e.g., `meta.keys.push()` is a TS error).\n */\nexport type ReadonlyMeta = internal.ReadonlyMeta;\n\n/**\n * Returns the entity's `EntityMeta`. Same semantics as `Obj.getMeta` /\n * `Relation.getMeta` — `Type.Type` is an Entity and carries the canonical\n * `EntityMeta` directly. Returns mutable meta when passed a mutable type\n * (inside a `Type.update` callback), read-only meta otherwise.\n *\n * For persisted Type entities, `meta.key` holds the typename and\n * `meta.version` holds the semver. Use {@link getTypename} / {@link getVersion}\n * if you want the helpers' id / {@link DRAFT_VERSION} fallbacks for drafts.\n *\n * Both persisted and in-memory type entities (`Type.makeObject` /\n * `Type.makeRelation` results) carry their `EntityMeta` via `[MetaId]`, so the\n * lookup is uniform.\n */\nexport function getMeta(entity: internal.Mutable<AnyEntity>): Meta;\nexport function getMeta(entity: Mutable): Meta;\nexport function getMeta(entity: AnyEntity): ReadonlyMeta;\nexport function getMeta(entity: AnyEntity | internal.Mutable<AnyEntity> | Mutable): ReadonlyMeta | Meta {\n // The `Mutable` overload accepts the narrowed view passed to `Type.update`\n // callbacks; at runtime that draft IS the underlying persisted Type entity,\n // so the same `MetaId` lookup works.\n assertArgument(isType(entity), 'entity', 'Expected a Type entity.');\n // Both persisted and in-memory type entities carry runtime `EntityMeta` via\n // `[MetaId]`, so the lookup is uniform.\n return internal.getMetaChecked(entity);\n}\n\n/**\n * Get the display label of a type entity.\n * Reads the field(s) nominated by the type's {@link LabelAnnotation} (e.g. `name` on persisted schemas).\n * Returns `undefined` if no label field is populated.\n */\nexport const getLabel = (entity: AnyEntity, options?: internal.GetLabelOptions): string | undefined =>\n internal.getLabel(entity, options);\n\n/**\n * String key used to phantom-carry the instance type produced by a `Type.Type`.\n * Used by `Type.InstanceType<typeof Foo>` to recover the schema instance type\n * since `Type.makeObject(dxn)` does not return a `Schema.Schema`.\n *\n * Re-exported from the internal types layer so both `Type.ts` and internal\n * helpers (`makeObject`, `createObject`) reference the same phantom key.\n */\nexport const InstancePhantomId = internal.InstancePhantomId;\nexport type InstancePhantomId = internal.InstancePhantomId;\n\n/**\n * Sibling of {@link Obj} / {@link Relation} for the third ECHO entity kind:\n * **type-kind** entities (meta-schemas). The singleton {@link Type} const is\n * the canonical example — it describes stored type definitions themselves.\n *\n * Not a `Schema.Schema`. Use `Type.getSchema(value)` to obtain the underlying\n * Effect Schema and `Type.update(value, draft => ...)` to mutate.\n *\n * `A` is the instance-type phantom — what `Obj.make(value, ...)` would produce.\n * Merged with the `Type` const value via TypeScript declaration merging.\n */\nexport interface Type<A = unknown> extends BaseTypeEntity<A & EntityModule.OfKind<typeof EntityModule.Kind.Type>> {\n /** Schema-kind brand (type — the meta-schema kind). */\n readonly [internal.SchemaKindId]: internal.EntityKind.Type;\n\n /** Source Effect Schema — used internally by `Type.getSchema(self)`. */\n readonly [internal.StaticTypeSchemaSlot]: Schema.Schema.AnyNoContext;\n}\n\n/**\n * Instance type produced by a Type entity.\n *\n * Accepts ONLY {@link AnyEntity} inputs — `Type.Obj`, `Type.Relation`, or\n * `Type.Type`. Raw Effect `Schema.Schema` values are rejected: for those, use\n * `Schema.Schema.Type<typeof Foo>` directly. This separation keeps the type\n * system honest about which values represent ECHO entities versus plain\n * Effect schemas.\n *\n * Dispatches on the entity kind:\n * - `Relation<Props, S, T>` → `Endpoints<S,T> & Props & OfKind<Relation>`\n * - `Obj<A>` → `A & OfKind<Object>`\n * - `Type<A>` → `A & OfKind<Type>`\n */\nexport type InstanceType<T extends AnyEntity> =\n T extends Relation<infer Props, infer Source, infer Target, any>\n ? RelationModule.Endpoints<Source, Target> & Props & EntityModule.OfKind<typeof EntityModule.Kind.Relation>\n : T extends Obj<infer A, any>\n ? A & EntityModule.OfKind<typeof EntityModule.Kind.Object>\n : T extends Type<infer A>\n ? A & EntityModule.OfKind<typeof EntityModule.Kind.Type>\n : never;\n\n/**\n * Returns the Effect Schema for a type entity.\n *\n * - For static `Type.Obj` / `Type.Relation` entities the source Effect Schema is\n * read from a hidden slot — these overloads preserve the instance type.\n * - For `Type.Type` entities (the meta-schema kind) the schema is rebuilt from\n * `type.jsonSchema`; the instance type isn't statically knowable so the wide\n * `AnyEntity` overload widens to `Schema.Schema.AnyNoContext`.\n *\n * Always call this when you need to interact with the Effect Schema API\n * (e.g. before passing to Effect.Schema functions). For ECHO-side APIs\n * (`Obj.make`, `Filter.type`, `Ref`) pass the type entity directly.\n *\n * Only accepts `Type.AnyEntity` — raw `Schema.Schema` values can be used\n * directly without unwrapping.\n */\nexport function getSchema<T extends AnyObj>(type: T): Schema.Schema<InstanceType<T>>;\nexport function getSchema<T extends AnyRelation>(type: T): Schema.Schema<InstanceType<T>>;\nexport function getSchema(type: AnyEntity): Schema.Schema.AnyNoContext;\nexport function getSchema(type: AnyEntity): Schema.Schema.AnyNoContext {\n // Static `Type.Type` entities carry the source Effect Schema on a hidden\n // slot so we can return it without round-tripping through JsonSchema.\n const staticSchema = internal.getStaticTypeSchema(type);\n if (staticSchema != null) {\n return staticSchema;\n }\n assertArgument(isType(type), 'type', 'Expected a Type entity.');\n // Persisted `Type.Type` entity — build the Effect Schema from its stored\n // jsonSchema and re-attach the TypeIdentifierAnnotation so the rebuilt\n // schema's URI (via getSchemaURI) matches the entity's local EID.\n const rebuilt = internal.toEffectSchema(type.jsonSchema);\n if (typeof type.id === 'string') {\n return rebuilt.annotations({\n [internal.TypeIdentifierAnnotationId]: EID.make({ entityId: type.id }),\n });\n }\n return rebuilt;\n}\n\n/**\n * Mutable view of a `Type.Type` — the shape passed to the `Type.update` callback.\n * Outside `Type.update`, `Type.Type` fields are read-only (both at the type level\n * and at runtime — direct assignment throws). Use this to constrain mutation to\n * the change context, analogous to `Obj.update(obj, (draft) => ...)`.\n *\n * NOTE: `typename` and `version` are intentionally absent — they live in\n * `EntityMeta` (`key` / `version` — the canonical registry-provenance pair).\n * Read them via {@link getTypename} / {@link getVersion} / {@link getMeta};\n * `typename` is treated as immutable on persisted entities.\n *\n * Unlike `Obj.update` — whose mutable view is inferred as `Mutable<A>` over the\n * whole instance type because every data field is editable — a `Type.Type`\n * exposes only `name` and `jsonSchema` for mutation. The rest of its shape\n * (`id`, the `[KindId]` / `[SchemaKindId]` brands, and `typename` / `version`\n * in meta) is immutable, so this view is declared explicitly rather than\n * derived from `InstanceType<Type.Type>`.\n */\nexport interface Mutable {\n name?: string;\n // Deep-mutable within the change context — `Type.update`'s purpose is to allow\n // mutation, so the draft exposes `jsonSchema` as writable (the readonly\n // `JsonSchemaType` would force callers to cast).\n jsonSchema: Types.DeepMutable<internal.JsonSchemaType>;\n}\n\n/**\n * Perform mutations on a `Type.Type` within a change context.\n *\n * The callback receives a {@link Mutable} view of the type — direct mutation of\n * a `Type.Type` outside `Type.update` throws at runtime, mirroring `Obj.update`.\n * Delegates to the same automerge-transaction primitive `Obj.update(obj, cb)` uses.\n */\nexport const update = (type: AnyEntity, callback: (mutable: Mutable) => void): void => {\n // `Type.Type` is an ECHO object; the change machinery is the same as `Obj.update`.\n internal.change(type, callback as internal.ChangeCallback<AnyEntity>);\n};\n\n//\n// Field-level helpers for mutating persisted types.\n// These are thin wrappers over `Type.update` plus the JsonSchema manipulation\n// utilities. Callers pass a persisted `Type.Type` (e.g. one returned by\n// `db.addType(schemaEntity)`) and the helper drives the change context.\n//\n\n/**\n * Add fields to a persisted type's schema.\n * @throws if the type is not persisted.\n */\nexport const addFields = (type: AnyEntity, fields: Schema.Struct.Fields): void => {\n const extended = typeInternal.addFieldsToSchema(getSchema(type), fields);\n update(type, (draft) => {\n draft.jsonSchema = internal.toJsonSchema(extended);\n });\n};\n\n/**\n * Replace existing fields on a persisted type's schema.\n * @throws if the type is not persisted.\n */\nexport const updateFields = (type: AnyEntity, fields: Schema.Struct.Fields): void => {\n const updated = typeInternal.updateFieldsInSchema(getSchema(type), fields);\n update(type, (draft) => {\n draft.jsonSchema = internal.toJsonSchema(updated);\n });\n};\n\n/**\n * Rename a field on a persisted type's schema.\n * @throws if the type is not persisted.\n */\nexport const updateFieldPropertyName = (\n type: Type,\n { before, after }: { before: PropertyKey; after: PropertyKey },\n): void => {\n const renamed = typeInternal.updateFieldNameInSchema(getSchema(type), { before, after });\n update(type, (draft) => {\n draft.jsonSchema = internal.toJsonSchema(renamed);\n });\n};\n\n/**\n * Remove fields from a persisted type's schema.\n * @throws if the type is not persisted.\n */\nexport const removeFields = (type: AnyEntity, fieldNames: string[]): void => {\n const removed = typeInternal.removeFieldsFromSchema(getSchema(type), fieldNames);\n update(type, (draft) => {\n draft.jsonSchema = internal.toJsonSchema(removed);\n });\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;2BAAAA;EAAA;;;;;qBAAAC;EAAA,gBAAAC;EAAA;;;;;;;;;oBAAAC;EAAA;;;;;;;;AASA,SAASC,aAAa;AAEtB,SAASC,gBAAgBC,iBAAiB;AAC1C,SAAcC,WAAoC;AA4FlD,IAAA,eAAA;AA4BA,IAAAC,cAAA;;;AAyCE,IAAA,2BAAA,CAAA,UAAA;AACA,QAAA,EAAA,UAAA,SAAAC,UAAA,GAAA,KAAA,IAAA;SAQSC,WAAAA,oBAAAA,UAAAA,GAAAA,MAAAA;IACLD,MAAAA,CAAAA;IAEFE,KAAAA;IAEF,SAAAF,YAAA;EAEF,GAAA,UAAA;;AAeE,IAAA,6BAAA,CAAA,U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,YAAiB;MAAC,CAAA,0BAAA,GAAA,IAAA,KAAA;QACtE,UAAA,KAAA;MACF,CAAA;IACA,CAAA;EACF;AA4BA,SAAA;;AASEF,IAASG,SAAaC,CAAAA,MAAAA,aAAAA;AAGtB,EAAA,OAAA,MAAA,QAAA;AACF;AAYSC,IAAM,YAACC,CAAAA,MAAAA,WAAAA;QACZA,WAAmBN,kBAAsBO,UAAAA,IAAAA,GAAAA,MAAAA;AAC3C,SAAA,MAAA,CAAA,UAAA;AACA,UAAA,aAAA,aAAA,QAAA;EAEF,CAAA;;AAMSF,IAAM,eAACC,CAAAA,MAAAA,WAAAA;QACZA,UAAmBN,qBAAsBQ,UAAAA,IAAAA,GAAAA,MAAAA;AAC3C,SAAA,MAAA,CAAA,UAAA;AACA,UAAA,aAAA,aAAA,OAAA;EAEF,CAAA;;AAQ0EC,IAAAA,0BAAAA,CAAAA,MAAAA,EAAAA,QAAAA,MAAAA,MAAAA;QAAQC,UAAAA,wBAAAA,UAAAA,IAAAA,GAAAA;IAAM;IACtFC;;AAEA,SAAA,MAAA,CAAA,UAAA;AACA,UAAA,aAAA,aAAA,OAAA;EAEF,CAAA;;AAMSN,IAAM,eAACC,CAAAA,MAAAA,eAAAA;QACZA,UAAmBN,uBAAsBY,UAAAA,IAAAA,GAAAA,UAAAA;AAC3C,SAAA,MAAA,CAAA,UAAA;AACA,UAAA,aAAA,aAAA,OAAA;;;",
6
- "names": ["InstancePhantomId", "getDatabase", "getLabel", "makeObject", "raise", "assertArgument", "invariant", "EID", "makeObject", "version", "typename", "typeInternal", "enrichedJsonSchema", "entityKind", "EntityKind", "relationSource", "sourceURI", "relationTarget", "keys", "entity", "getSchemaURI", "input", "heads", "join", "semver", "value", "startsWith", "getDatabase", "InstancePhantomId", "staticSchema", "assertArgument", "annotations", "internal", "TypeIdentifierAnnotationId", "entityId", "change", "callback", "type", "draft", "extended", "updated", "before", "after", "update", "removed"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/internal/Ref/ref.ts", "../../../src/internal/Ref/atoms.ts", "../../../src/internal/Ref/utils.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Atom from '@effect-atom/atom/Atom';\nimport * as Effect from 'effect/Effect';\nimport * as Equal from 'effect/Equal';\nimport * as Hash from 'effect/Hash';\nimport * as Option from 'effect/Option';\nimport * as ParseResult from 'effect/ParseResult';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport type * as Types from 'effect/Types';\n\nimport { Event } from '@dxos/async';\nimport { type CustomInspectFunction, inspectCustom } from '@dxos/debug';\nimport { EncodedReference } from '@dxos/echo-protocol';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN, EID, EntityId, type URI } from '@dxos/keys';\n\nimport * as Database from '../../Database';\nimport type * as Type from '../../Type';\nimport {\n ReferenceAnnotationId,\n getSchemaURI,\n getTypeAnnotation,\n getTypeIdentifierAnnotation,\n} from '../Annotation/annotations';\nimport { type AnyEntity, type AnyProperties, type UnknownTypeSchema, getStaticTypeSchema } from '../common/types';\nimport { type JsonSchemaType } from '../JsonSchema';\nimport * as RefAtoms from './atoms';\n\n/**\n * The `$id` and `$ref` fields for an ECHO reference schema.\n */\nexport const JSON_SCHEMA_ECHO_REF_ID = '/schemas/echo/ref';\n\nexport const getSchemaReference = (property: JsonSchemaType): { typename: string } | undefined => {\n const { $id, reference: { schema: { $ref } = {} } = {} } = property;\n if ($id === JSON_SCHEMA_ECHO_REF_ID && $ref) {\n const parsed = DXN.tryMake($ref);\n const typename = parsed ? DXN.getName(parsed) : undefined;\n return typename ? { typename } : undefined;\n }\n};\n\nexport const createSchemaReference = (typename: string): Types.DeepMutable<JsonSchemaType> => {\n return {\n $id: JSON_SCHEMA_ECHO_REF_ID,\n reference: {\n schema: {\n $ref: DXN.make(typename),\n },\n },\n };\n};\n\n/**\n * Runtime type-info for a reference extracted from effect AST.\n */\nexport type RefereneAST = {\n /**\n * Typename of linked schema.\n */\n typename: string;\n\n /**\n * Version of linked schema.\n */\n version: string;\n};\n\nexport const getReferenceAst = (ast: SchemaAST.AST): RefereneAST | undefined => {\n if (ast._tag !== 'Declaration' || !ast.annotations[ReferenceAnnotationId]) {\n return undefined;\n }\n return {\n typename: (ast.annotations[ReferenceAnnotationId] as any).typename,\n version: (ast.annotations[ReferenceAnnotationId] as any).version,\n };\n};\n\nexport const RefTypeId: unique symbol = Symbol('@dxos/echo/internal/Ref');\n\n/**\n * Reference Schema.\n */\nexport interface RefSchema<T extends AnyEntity> extends Schema.SchemaClass<Ref<T>, EncodedReference> {}\n\n/**\n * Type of the `Ref` function and extra methods attached to it.\n */\nexport interface RefFn {\n // A reference target is a `Type.AnyEntity` entity (the canonical Option B\n // input) or one of the well-known \"any object\" / \"any relation\" branded\n // schemas (`Obj.Unknown` / `Relation.Unknown`). Arbitrary raw schemas are\n // rejected.\n //\n // Referencing a type-kind entity (a meta-schema, e.g. `Type.Type`) yields a\n // reference to a stored schema record; its loaded target is any registered\n // entity (`Type.AnyEntity`), since a stored object/relation schema is itself a\n // `Type.Type` record. Referencing an object/relation type yields a reference\n // to an instance of that type.\n <S extends Type.AnyEntity | UnknownTypeSchema<any, any> = Type.AnyEntity>(\n schema: S,\n ): RefSchema<\n S extends Type.AnyType\n ? Type.AnyEntity\n : S extends Type.AnyObj | Type.AnyRelation\n ? Type.InstanceType<S>\n : S extends UnknownTypeSchema<infer A, any>\n ? A\n : never\n >;\n\n /**\n * @returns True if the object is a reference.\n */\n isRef: (obj: unknown) => obj is Ref<any>;\n\n /**\n * @returns True if the reference points to the given object id.\n */\n hasEntityId: (id: EntityId) => (ref: Ref<any>) => boolean;\n\n /**\n * @returns True if the schema is a reference schema.\n */\n isRefSchema: (schema: Schema.Schema<any, any>) => schema is RefSchema<any>;\n\n /**\n * @returns True if the schema AST is a reference schema.\n */\n isRefSchemaAST: (ast: SchemaAST.AST) => boolean;\n\n /**\n * Constructs a reference that points to the given object.\n */\n // TODO(burdon): Narrow to Obj.Unknown?\n make: <T extends AnyEntity>(object: T) => Ref<T>;\n\n /**\n * Constructs a reference that points to the object specified by the provided URI\n * (either an `echo:` EID for an object reference or a `dxn:` DXN for a type reference).\n */\n fromURI: (uri: URI.URI) => Ref<any>;\n}\n\n/**\n * Schema builder for references.\n */\nexport const Ref: RefFn = (input: any): RefSchema<any> => {\n // `Type.Type` entities carry their source schema on the hidden slot; the\n // branded `Obj.Unknown` / `Relation.Unknown` schemas are used directly.\n const schema = getStaticTypeSchema(input) ?? input;\n assertArgument(Schema.isSchema(schema), 'schema', 'Must call with an instance of effect-schema');\n const annotation = getTypeAnnotation(schema);\n if (annotation == null) {\n throw new Error('Reference target must be an ECHO schema.');\n }\n\n return createEchoReferenceSchema(getTypeIdentifierAnnotation(schema), annotation.typename, annotation.version);\n};\n\n/**\n * Represents materialized reference to a target.\n * This is the data type for the fields marked as ref.\n */\nexport interface Ref<T> extends Pipeable.Pipeable {\n /**\n * Target URI (either an `echo:` EID for an object reference or a `dxn:` DXN for a type reference).\n */\n get uri(): URI.URI;\n\n /**\n * Returns true if the reference has a target available (inlined or resolver set).\n */\n get isAvailable(): boolean;\n\n /**\n * @returns The reference target.\n * May return `undefined` if the object is not loaded in the working set.\n * Accessing this property, even if it returns `undefined` will trigger the object to be loaded to the working set.\n */\n get target(): T | undefined;\n\n /**\n * @returns Promise that will resolves with the target object.\n * Will load the object from disk if it is not present in the working set.\n * @throws If the object is not available locally.\n */\n load(): Promise<T>;\n\n /**\n * @returns Promise that will resolves with the target object or undefined if the object is not loaded locally.\n */\n\n tryLoad(): Promise<T | undefined>;\n\n /**\n * Subscribe to the ref's resolution event.\n * The callback fires when the target object becomes available in the working set\n * (e.g. when its document is loaded after sibling-client mutation).\n * Note: the resolver only schedules a notification when the target is requested\n * via {@link target} while it is not yet loaded.\n * @returns Function that unsubscribes the callback.\n */\n onResolved(callback: () => void): () => void;\n\n /**\n * Do not inline the target object in the reference.\n * Makes .target unavailable unless the reference is connected to a database context.\n *\n * When serialized with toJSON, the difference is between:\n * `{ \"/\": \"dxn:...\" }`\n * and\n * `{ \"/\": \"dxn:...\", \"target\": { ... } }`\n *\n * Clones the reference object.\n */\n noInline(): Ref<T>;\n\n /**\n * Read-only atom for the ref target.\n * Resolves once when the target loads; does NOT subscribe to target object mutations.\n * Use `Obj.atom(ref)` if you need reactive snapshots that update on every object mutation.\n */\n get atom(): Atom.Atom<T | undefined>;\n\n /**\n * Serializes the reference to a JSON object.\n * The serialization format is compatible with the IPLD-style encoded references.\n * When a reference has a saved target (i.e. the target or object holding the reference is not in the database),\n * the target is included in the serialized object.\n *\n * Examples:\n * `{ \"/\": \"dxn:...\" }`\n * `{ \"/\": \"dxn:...\", \"target\": { ... } }`\n */\n encode(): EncodedReference;\n\n [RefTypeId]: {\n _T: T;\n };\n}\n\nexport declare namespace Ref {\n /**\n * Target of the reference.\n */\n export type Target<R> = R extends Ref<infer U> ? U : never;\n}\n\nRef.isRef = (obj: any): obj is Ref<any> => {\n return obj && typeof obj === 'object' && RefTypeId in obj;\n};\n\nRef.hasEntityId = (id: EntityId) => (ref: Ref<any>) => {\n const uri = EID.tryParse(ref.uri);\n return uri !== undefined && EID.isLocal(uri) && EID.getEntityId(uri) === id;\n};\n\nRef.isRefSchema = (schema: Schema.Schema<any, any>): schema is RefSchema<any> => {\n return Ref.isRefSchemaAST(schema.ast);\n};\n\nRef.isRefSchemaAST = (ast: SchemaAST.AST): boolean => {\n return SchemaAST.getAnnotation(ast, ReferenceAnnotationId).pipe(Option.isSome);\n};\n\nRef.make = <T extends AnyProperties>(obj: T): Ref<T> => {\n if (typeof obj !== 'object' || obj === null) {\n throw new TypeError('Expected: ECHO object.');\n }\n\n // TODO(dmaretskyi): Extract to `getObjectEchoUri` function.\n const id = obj.id;\n invariant(EntityId.isValid(id), 'Invalid object ID');\n const uri = EID.make({ entityId: id });\n return new RefImpl(uri, obj);\n};\n\nRef.fromURI = (uri: URI.URI): Ref<any> => {\n assertArgument(typeof uri === 'string', 'uri', 'Expected URI string');\n return new RefImpl(uri);\n};\n\n/**\n * `reference` field on the schema object.\n */\nexport type JsonSchemaReferenceInfo = {\n schema: { $ref: string };\n schemaVersion?: string;\n};\n\n/**\n * @internal\n */\n// TODO(burdon): Move to json schema and make private?\nexport const createEchoReferenceSchema = (\n echoUri: string | undefined,\n typename: string | undefined,\n version: string | undefined,\n): Schema.SchemaClass<Ref<any>, EncodedReference> => {\n if (!echoUri && !typename) {\n throw new TypeError('Either echoUri or typename must be provided.');\n }\n\n const referenceInfo: JsonSchemaReferenceInfo = {\n schema: {\n // TODO(dmaretskyi): Include version?\n $ref: echoUri ?? DXN.make(typename!),\n },\n schemaVersion: version,\n };\n\n // TODO(dmaretskyi): Add name and description.\n const refSchema = Schema.declare<Ref<any>, EncodedReference, []>(\n [],\n {\n encode: () => {\n return (value) =>\n Effect.gen(function* () {\n if (Ref.isRef(value)) {\n return EncodedReference.fromURI((value as Ref<any>).uri);\n } else if (EncodedReference.isEncodedReference(value)) {\n return value;\n }\n throw new Error('Invalid reference');\n });\n },\n decode: () => {\n return (value) =>\n Effect.gen(function* () {\n const dbService = yield* Effect.serviceOption(Database.Service);\n\n // TODO(dmaretskyi): This branch seems to be taken by Schema.is\n if (Ref.isRef(value)) {\n if (Option.isSome(dbService)) {\n return dbService.value.db.makeRef(value.uri);\n } else {\n return value;\n }\n }\n\n if (!EncodedReference.isEncodedReference(value)) {\n return yield* Effect.fail(new ParseResult.Unexpected(value, 'reference'));\n }\n if (Option.isSome(dbService)) {\n return dbService.value.db.makeRef(EncodedReference.toURI(value));\n } else {\n return Ref.fromURI(EncodedReference.toURI(value));\n }\n });\n },\n },\n {\n jsonSchema: {\n // TODO(dmaretskyi): We should remove `$id` and keep `$ref` with a fully qualified name.\n $id: JSON_SCHEMA_ECHO_REF_ID,\n $ref: JSON_SCHEMA_ECHO_REF_ID,\n reference: referenceInfo,\n },\n [ReferenceAnnotationId]: {\n typename: typename ?? '',\n version,\n },\n },\n );\n\n return refSchema;\n};\n\nconst getSchemaExpectedName = (ast: SchemaAST.Annotated): string | undefined => {\n return SchemaAST.getIdentifierAnnotation(ast).pipe(\n Option.orElse(() => SchemaAST.getTitleAnnotation(ast)),\n Option.orElse(() => SchemaAST.getDescriptionAnnotation(ast)),\n Option.getOrElse(() => undefined),\n );\n};\n\nexport interface RefResolver {\n /**\n * Resolve ref synchronously from the objects in the working set.\n *\n * @param uri\n * @param load If true the resolver should attempt to load the object from disk.\n * @param onLoad Callback to call when the object is loaded.\n */\n resolveSync(uri: URI.URI, load: boolean, onLoad?: () => void): AnyProperties | undefined;\n\n /**\n * Resolver ref asynchronously.\n */\n resolve(uri: URI.URI): Promise<AnyProperties | undefined>;\n\n // TODO(dmaretskyi): Combine with `resolve`.\n resolveSchema(uri: URI.URI): Promise<Schema.Schema.AnyNoContext | undefined>;\n\n /**\n * Resolve the source `Type.AnyEntity` entity for a type URI. Used by\n * deserialization paths (`Obj.fromJSON`) to set the back-reference accessed\n * via `Obj.getType` / `Entity.getType`. Optional — resolvers that only\n * carry raw schemas may leave this unimplemented; the deserializer falls\n * back to leaving the type entity unset.\n */\n resolveType?(uri: URI.URI): Promise<unknown | undefined>;\n}\n\nexport class RefImpl<T> implements Ref<T> {\n #uri: URI.URI;\n #resolver?: RefResolver = undefined;\n #resolved = new Event<void>();\n\n /**\n * Target is set when the reference is created from a specific object.\n * In this case, the target might not be in the database.\n */\n #target: T | undefined = undefined;\n\n /**\n * Callback to issue a reactive notification when object is resolved.\n */\n #resolverCallback = () => {\n this.#resolved.emit();\n };\n\n constructor(uri: URI.URI, target?: T) {\n this.#uri = uri;\n this.#target = target;\n }\n\n /**\n * @inheritdoc\n */\n get uri(): URI.URI {\n return this.#uri;\n }\n\n /**\n * @inheritdoc\n */\n get isAvailable(): boolean {\n return this.#target !== undefined || this.#resolver !== undefined;\n }\n\n /**\n * @inheritdoc\n */\n get target(): T | undefined {\n if (this.#target) {\n return this.#target;\n }\n\n invariant(this.#resolver, 'Resolver is not set');\n return this.#resolver.resolveSync(this.#uri, true, this.#resolverCallback) as T | undefined;\n }\n\n /**\n * @inheritdoc\n */\n async load(): Promise<T> {\n if (this.#target) {\n return this.#target;\n }\n invariant(this.#resolver, 'Resolver is not set');\n const obj = await this.#resolver.resolve(this.#uri);\n if (obj == null) {\n throw new Error('Object not found');\n }\n return obj as T;\n }\n\n /**\n * @inheritdoc\n */\n async tryLoad(): Promise<T | undefined> {\n if (this.#target) {\n return this.#target;\n }\n invariant(this.#resolver, 'Resolver is not set');\n return (await this.#resolver.resolve(this.#uri)) as T | undefined;\n }\n\n /**\n * @inheritdoc\n */\n onResolved(callback: () => void): () => void {\n return this.#resolved.on(callback);\n }\n\n /**\n * Do not inline the target object in the reference.\n * Makes .target unavailable unless the reference is connected to a database context.\n * Clones the reference object.\n */\n noInline(): RefImpl<T> {\n const ref = new RefImpl<T>(this.#uri, undefined);\n ref.#resolver = this.#resolver;\n return ref;\n }\n\n encode(): EncodedReference {\n return {\n '/': this.#uri,\n ...(this.#target ? { target: this.#target } : {}),\n };\n }\n\n /**\n * Serializes the reference to a JSON object.\n * The serialization format is compatible with the IPLD-style encoded references.\n * When a reference has a saved target (i.e. the target or object holding the reference is not in the database),\n * the target is included in the serialized object.\n */\n toJSON(): EncodedReference {\n return this.encode();\n }\n\n toString(): string {\n if (this.#target) {\n return `Ref(${this.#target.toString()})`;\n }\n\n return `Ref(${this.#uri.toString()})`;\n }\n\n [inspectCustom]: CustomInspectFunction = (depth, options, inspect) => {\n return this.toString();\n };\n\n [RefTypeId] = refVariance;\n\n /**\n * Effect Hash trait. Required for MutableHashMap-based caches (e.g., Atom.family)\n * to deduplicate Ref instances that point to the same object.\n * ECHO proxies return new RefImpl instances on every property access,\n * so without this, each access would create a separate cache entry.\n */\n [Hash.symbol](): number {\n return Hash.hash(this.#uri.toString());\n }\n\n /** Effect Equal trait. See {@link Hash.symbol} for rationale. */\n [Equal.symbol](that: Equal.Equal): boolean {\n return that instanceof RefImpl && this.#uri === that.uri;\n }\n\n get atom(): Atom.Atom<T | undefined> {\n return RefAtoms.refSimpleFamily(this);\n }\n\n /**\n * Internal method to set the resolver.\n *\n * @internal\n */\n _setResolver(resolver: RefResolver): void {\n this.#resolver = resolver;\n }\n\n /**\n * @internal\n */\n _getSavedTarget(): T | undefined {\n return this.#target;\n }\n\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n }\n}\n\n/**\n * Internal API for setting the reference resolver.\n */\nexport const setRefResolver = (ref: Ref<any>, resolver: RefResolver) => {\n invariant(ref instanceof RefImpl, 'Ref is not an instance of RefImpl');\n ref._setResolver(resolver);\n};\n\n/**\n * Internal API for getting the saved target on a reference.\n */\nexport const getRefSavedTarget = (ref: Ref<any>): AnyProperties | undefined => {\n invariant(ref instanceof RefImpl, 'Ref is not an instance of RefImpl');\n return ref._getSavedTarget();\n};\n\n// Used to validate reference target type.\nconst refVariance: Ref<any>[typeof RefTypeId] = {\n _T: null as any,\n};\n\nexport const refFromEncodedReference = (encodedReference: EncodedReference, resolver?: RefResolver): Ref<any> => {\n const uri = EncodedReference.toURI(encodedReference);\n const ref = new RefImpl(uri);\n\n // TODO(dmaretskyi): Handle inline target in the encoded reference.\n\n if (resolver) {\n setRefResolver(ref, resolver);\n }\n return ref;\n};\n\nexport class StaticRefResolver implements RefResolver {\n public objects = new Map<EntityId, AnyProperties>();\n public schemas = new Map<URI.URI, Schema.Schema.AnyNoContext>();\n\n addObject(obj: AnyProperties): this {\n this.objects.set(obj.id, obj);\n return this;\n }\n\n addSchema(input: Type.AnyEntity): this {\n const schema = getStaticTypeSchema(input);\n invariant(schema, 'Type entity is missing its source schema');\n const uri = getSchemaURI(schema);\n invariant(uri, 'Schema has no URI');\n this.schemas.set(uri, schema);\n return this;\n }\n\n resolveSync(uri: URI.URI, _load: boolean, _onLoad?: () => void): AnyProperties | undefined {\n const echoUri = EID.tryParse(uri);\n const id = echoUri ? EID.getEntityId(echoUri) : undefined;\n if (id == null) {\n return undefined;\n }\n\n return this.objects.get(id);\n }\n\n async resolve(uri: URI.URI): Promise<AnyProperties | undefined> {\n const echoUri = EID.tryParse(uri);\n const id = echoUri ? EID.getEntityId(echoUri) : undefined;\n if (id == null) {\n return undefined;\n }\n\n return this.objects.get(id);\n }\n\n async resolveSchema(uri: URI.URI): Promise<Schema.Schema.AnyNoContext | undefined> {\n return this.schemas.get(uri);\n }\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Atom from '@effect-atom/atom/Atom';\n\nimport type { Ref } from './ref';\nimport { loadRefTarget } from './utils';\n\n/**\n * Atom family for ECHO refs.\n * Uses ref reference as key — same ref returns same atom.\n * This atom only updates once when the ref loads — it does not subscribe to target object changes.\n * Use `Obj.atom(ref)` if you need reactive snapshots of ECHO objects via a ref.\n */\nexport const refSimpleFamily = Atom.family(<T>(ref: Ref<T>): Atom.Atom<T | undefined> => {\n return Atom.make<T | undefined>((get) => {\n return loadRefTarget(ref, get, (target) => target);\n });\n});\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Atom from '@effect-atom/atom/Atom';\n\nimport type { Ref } from './ref';\n\n/**\n * Internal helper for loading ref targets in atoms.\n * Handles the common pattern of checking for loaded target and triggering async load.\n */\nexport const loadRefTarget = <T, R>(\n ref: Ref<T>,\n get: Atom.Context,\n onTargetAvailable: (target: T) => R,\n): R | undefined => {\n // Accessing `ref.target` registers a resolution callback when the target is\n // not yet loaded, so resolution can be observed via `ref.onResolved` below.\n const currentTarget = ref.target;\n if (currentTarget) {\n return onTargetAvailable(currentTarget);\n }\n\n // Subscribe to the ref's resolution event in case the target loads later.\n const unsubscribe = ref.onResolved(() => {\n const target = ref.target;\n if (target) {\n get.setSelf(onTargetAvailable(target));\n }\n });\n get.addFinalizer(unsubscribe);\n\n // Also try async load (e.g. for objects that need disk loading).\n void ref\n .load()\n .then((loadedTarget) => {\n get.setSelf(onTargetAvailable(loadedTarget));\n })\n .catch(() => {\n // Loading failed; the resolution subscription above will pick up cross-client updates.\n });\n\n return undefined;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;AAKA,YAAYA,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,UAAU;AACtB,YAAYC,YAAY;AACxB,YAAYC,iBAAiB;AAC7B,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,eAAe;AAG3B,SAASC,aAAa;AACtB,SAAqCC,qBAAqB;AAC1D,SAASC,wBAAwB;AACjC,SAASC,gBAAgBC,iBAAiB;AAC1C,SAASC,KAAKC,KAAKC,gBAA0B;;;ACf7C,YAAYC,UAAU;;;ACQf,IAAMC,gBAAgB,CAC3BC,KACAC,KACAC,sBAAAA;AAIA,QAAMC,gBAAgBH,IAAII;AAC1B,MAAID,eAAe;AACjB,WAAOD,kBAAkBC,aAAAA;EAC3B;AAGA,QAAME,cAAcL,IAAIM,WAAW,MAAA;AACjC,UAAMF,SAASJ,IAAII;AACnB,QAAIA,QAAQ;AACVH,UAAIM,QAAQL,kBAAkBE,MAAAA,CAAAA;IAChC;EACF,CAAA;AACAH,MAAIO,aAAaH,WAAAA;AAGjB,OAAKL,IACFS,KAAI,EACJC,KAAK,CAACC,iBAAAA;AACLV,QAAIM,QAAQL,kBAAkBS,YAAAA,CAAAA;EAChC,CAAA,EACCC,MAAM,MAAA;EAEP,CAAA;AAEF,SAAOC;AACT;;;AD7BO,IAAMC,kBAAuBC,YAAO,CAAIC,QAAAA;AAC7C,SAAYC,UAAoB,CAACC,QAAAA;AAC/B,WAAOC,cAAcH,KAAKE,KAAK,CAACE,WAAWA,MAAAA;EAC7C,CAAA;AACF,CAAA;;;ADcA,IAAA,eAAA;AAMQ,IAAOC,0BAAuBC;AACpC,IAAIC,qBAAQC,CAAAA,aAA2BF;QACrC,EAAA,KAAMG,WAAaC,EAAAA,QAAQJ,EAAAA,KAAAA,IAAAA,CAAAA,EAAAA,IAAAA,CAAAA,EA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;EAEnF,MAAA,cAAA,KAAA;AACF,WAAA,KAAA,QAAA,IAAA,GAAA;;;",
6
- "names": ["Effect", "Equal", "Hash", "Option", "ParseResult", "Pipeable", "Schema", "SchemaAST", "Event", "inspectCustom", "EncodedReference", "assertArgument", "invariant", "DXN", "EID", "EntityId", "Atom", "loadRefTarget", "ref", "get", "onTargetAvailable", "currentTarget", "target", "unsubscribe", "onResolved", "setSelf", "addFinalizer", "load", "then", "loadedTarget", "catch", "undefined", "refSimpleFamily", "family", "ref", "make", "get", "loadRefTarget", "target", "reference", "$ref", "$id", "JSON_SCHEMA_ECHO_REF_ID", "parsed", "tryMake", "typename", "getName", "undefined", "schema", "version", "annotation", "getTypeAnnotation", "Error", "createEchoReferenceSchema", "isRef", "obj", "hasEntityId", "ref", "uri", "isRefSchema", "isRefSchemaAST", "ast", "make", "TypeError", "EID", "entityId", "id", "RefImpl", "fromURI", "referenceInfo", "schemaVersion", "Effect", "gen", "EncodedReference", "value", "Ref", "dbService", "Option", "isSome", "jsonSchema", "ReferenceAnnotationId", "getSchemaExpectedName", "undefined", "target", "invariant", "obj", "Error", "ref", "encode", "toString", "inspectCustom", "depth", "options", "inspect", "RefTypeId", "refVariance", "atom", "pipe", "_setResolver", "resolver", "_getSavedTarget", "uri", "schemas", "addObject", "objects", "set", "addSchema", "input", "schema", "getSchemaURI", "resolveSync", "id", "echoUri", "getEntityId", "resolve", "resolveSchema"]
7
- }