@dxos/echo 0.9.1-main.c7dcc2e112 → 0.9.1-staging.ee54ba693a
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.
- package/dist/lib/neutral/Annotation.mjs +22 -8
- package/dist/lib/neutral/Database.mjs +3 -3
- package/dist/lib/neutral/Entity.mjs +11 -11
- package/dist/lib/neutral/Err.mjs +7 -3
- package/dist/lib/neutral/Feed.mjs +15 -19
- package/dist/lib/neutral/Filter.mjs +13 -11
- package/dist/lib/neutral/Format.mjs +3 -7
- package/dist/lib/neutral/JsonSchema.mjs +7 -7
- package/dist/lib/neutral/Migration.mjs +11 -11
- package/dist/lib/neutral/Obj.mjs +15 -13
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +17 -17
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +6 -6
- package/dist/lib/neutral/Registry.mjs +1 -1
- package/dist/lib/neutral/Relation.mjs +12 -12
- package/dist/lib/neutral/Tag.mjs +15 -15
- package/dist/lib/neutral/Text.mjs +25 -0
- package/dist/lib/neutral/Text.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +10 -10
- package/dist/lib/neutral/chunk-2HKGAQM4.mjs +1394 -0
- package/dist/lib/neutral/chunk-2HKGAQM4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-O6BH7EPN.mjs → chunk-2ZHECXUR.mjs} +5 -4
- package/dist/lib/neutral/chunk-2ZHECXUR.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-AFANXSGV.mjs → chunk-3KTE2Y7Q.mjs} +20 -20
- package/dist/lib/neutral/chunk-3KTE2Y7Q.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WZ32BF53.mjs → chunk-3TN2VMI4.mjs} +49 -37
- package/dist/lib/neutral/chunk-3TN2VMI4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-E7IOTOZD.mjs → chunk-42L4HJ3Z.mjs} +11 -15
- package/dist/lib/neutral/chunk-42L4HJ3Z.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-K3S7D5PR.mjs → chunk-4A2NWKRJ.mjs} +5 -5
- package/dist/lib/neutral/chunk-ACFAOTKJ.mjs +1531 -0
- package/dist/lib/neutral/chunk-ACFAOTKJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-Z3WMRRAZ.mjs → chunk-BEFR7LEA.mjs} +11 -9
- package/dist/lib/neutral/{chunk-Z3WMRRAZ.mjs.map → chunk-BEFR7LEA.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-6M2Z6WBH.mjs → chunk-BXIKXT7Q.mjs} +2 -6
- package/dist/lib/neutral/{chunk-6M2Z6WBH.mjs.map → chunk-BXIKXT7Q.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-3JXQUMUI.mjs → chunk-C57XMMBY.mjs} +21 -20
- package/dist/lib/neutral/chunk-C57XMMBY.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-JZ6LFQU5.mjs → chunk-C62JYFAD.mjs} +82 -8
- package/dist/lib/neutral/chunk-C62JYFAD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TF5BSLF6.mjs → chunk-FSGX2R62.mjs} +3 -3
- package/dist/lib/neutral/chunk-FSGX2R62.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6CEISA3V.mjs → chunk-HBXT3GSB.mjs} +29 -15
- package/dist/lib/neutral/chunk-HBXT3GSB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WU3GIANS.mjs → chunk-IQR45HAD.mjs} +1 -1
- package/dist/lib/neutral/chunk-IQR45HAD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TFEWTY5A.mjs → chunk-KCBW4BR6.mjs} +4 -8
- package/dist/lib/neutral/chunk-KCBW4BR6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4TPQZPLY.mjs → chunk-L3E5IXAE.mjs} +198 -30
- package/dist/lib/neutral/chunk-L3E5IXAE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-EVK6XBXO.mjs → chunk-PRC4FEKJ.mjs} +2 -2
- package/dist/lib/neutral/chunk-PRC4FEKJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NOL7O3BL.mjs → chunk-SCT6FFCR.mjs} +9 -4
- package/dist/lib/neutral/chunk-SCT6FFCR.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BBFJWWAV.mjs → chunk-TOCVVFK2.mjs} +26 -2
- package/dist/lib/neutral/chunk-TOCVVFK2.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-A53NTBHE.mjs → chunk-U53LSQQA.mjs} +3 -3
- package/dist/lib/neutral/{chunk-A53NTBHE.mjs.map → chunk-U53LSQQA.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-PLDMJJJC.mjs → chunk-UGFFV2FR.mjs} +2 -2
- package/dist/lib/neutral/{chunk-35INCYOE.mjs → chunk-UWLP4RFM.mjs} +1 -1
- package/dist/lib/neutral/chunk-UWLP4RFM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SZ5WB6HF.mjs → chunk-UZHCQ6NI.mjs} +13 -11
- package/dist/lib/neutral/{chunk-SZ5WB6HF.mjs.map → chunk-UZHCQ6NI.mjs.map} +3 -3
- package/dist/lib/neutral/{chunk-L3OBWBV2.mjs → chunk-WKIT2YY5.mjs} +2 -2
- package/dist/lib/neutral/{chunk-HGWQR5KH.mjs → chunk-XB6ISRAO.mjs} +27 -15
- package/dist/lib/neutral/chunk-XB6ISRAO.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XXL42WCB.mjs +84 -0
- package/dist/lib/neutral/chunk-XXL42WCB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-5GAIWRQB.mjs → chunk-XXWK4J53.mjs} +27 -42
- package/dist/lib/neutral/chunk-XXWK4J53.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +30 -26
- package/dist/lib/neutral/internal/index.mjs +91 -69
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +79 -60
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +35 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +9 -8
- package/dist/types/src/Collection.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +16 -0
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +1 -16
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +67 -0
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +56 -80
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +9 -1
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +2 -9
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +1 -1
- package/dist/types/src/Migration.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +31 -6
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +1 -1
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/QueryResult.d.ts +2 -2
- package/dist/types/src/QueryResult.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +8 -4
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Registry.d.ts +1 -1
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +11 -13
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Text.d.ts +41 -0
- package/dist/types/src/Text.d.ts.map +1 -0
- package/dist/types/src/Text.test.d.ts +2 -0
- package/dist/types/src/Text.test.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +33 -20
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +8 -9
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +9 -0
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/atoms.d.ts +14 -0
- package/dist/types/src/internal/Annotation/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +13 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/guard.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/model.d.ts +1 -1
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/object.d.ts +5 -1
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/relation.d.ts +7 -0
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -1
- package/dist/types/src/internal/Filter/index.d.ts +2 -0
- package/dist/types/src/internal/Filter/index.d.ts.map +1 -0
- package/dist/types/src/internal/Filter/match.d.ts +22 -0
- package/dist/types/src/internal/Filter/match.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.d.ts +0 -2
- package/dist/types/src/internal/Format/format.d.ts.map +1 -1
- package/dist/types/src/internal/Format/index.d.ts +2 -2
- package/dist/types/src/internal/Format/index.d.ts.map +1 -1
- package/dist/types/src/internal/Format/string.d.ts +0 -8
- package/dist/types/src/internal/Format/string.d.ts.map +1 -1
- package/dist/types/src/internal/Format/types.d.ts +2 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/atoms.d.ts +7 -3
- package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/clone.d.ts +2 -1
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/create-object.d.ts +3 -4
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Query/index.d.ts +1 -0
- package/dist/types/src/internal/Query/index.d.ts.map +1 -1
- package/dist/types/src/internal/Query/query-result-effect.d.ts +9 -0
- package/dist/types/src/internal/Query/query-result-effect.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/atoms.d.ts +1 -2
- package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/ref.d.ts +13 -6
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/common/atom-snapshot.d.ts +8 -0
- package/dist/types/src/internal/common/atom-snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts +12 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts +25 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts +5 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +17 -0
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/entity.d.ts +4 -4
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/meta.d.ts +2 -4
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +1 -0
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +42 -171
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -13
- package/src/Annotation.test.ts +257 -10
- package/src/Annotation.ts +55 -6
- package/src/Collection.ts +10 -12
- package/src/Database.ts +22 -20
- package/src/Err.ts +22 -0
- package/src/Feed.ts +114 -141
- package/src/Filter.test.ts +38 -0
- package/src/Filter.ts +17 -3
- package/src/Hypergraph.ts +2 -11
- package/src/Migration.ts +1 -1
- package/src/Obj.test.ts +92 -12
- package/src/Obj.ts +36 -5
- package/src/Order.ts +3 -3
- package/src/Query.test.ts +2 -2
- package/src/Query.ts +16 -16
- package/src/QueryResult.ts +2 -2
- package/src/Ref.ts +12 -4
- package/src/Registry.ts +1 -1
- package/src/Relation.ts +1 -1
- package/src/Tag.ts +12 -16
- package/src/Text.test.ts +186 -0
- package/src/Text.ts +116 -0
- package/src/Type.test.ts +52 -24
- package/src/Type.ts +69 -31
- package/src/View.ts +22 -30
- package/src/index.ts +1 -1
- package/src/internal/Annotation/annotations.ts +15 -2
- package/src/internal/Annotation/atoms.ts +107 -0
- package/src/internal/Annotation/entity-dictionary.ts +40 -37
- package/src/internal/Entity/api.ts +1 -1
- package/src/internal/Entity/guard.ts +2 -1
- package/src/internal/Entity/model.ts +2 -2
- package/src/internal/Entity/object.ts +14 -1
- package/src/internal/Entity/relation.ts +19 -0
- package/src/internal/Entity/type-uri.ts +3 -1
- package/src/internal/Filter/index.ts +5 -0
- package/src/internal/Filter/match.ts +284 -0
- package/src/internal/Format/format.ts +0 -2
- package/src/internal/Format/index.ts +2 -2
- package/src/internal/Format/string.ts +0 -12
- package/src/internal/Format/types.ts +4 -2
- package/src/internal/JsonSchema/json-schema.test.ts +82 -54
- package/src/internal/Obj/atoms.ts +31 -18
- package/src/internal/Obj/clone.ts +61 -20
- package/src/internal/Obj/create-object.test.ts +3 -3
- package/src/internal/Obj/create-object.ts +3 -4
- package/src/internal/Obj/inspect.ts +1 -1
- package/src/internal/Obj/json-serializer.test.ts +7 -5
- package/src/internal/Obj/json-serializer.ts +1 -1
- package/src/internal/Obj/schema-validator.test.ts +53 -0
- package/src/internal/Obj/set-value.test.ts +29 -19
- package/src/internal/Query/index.ts +1 -0
- package/src/internal/Query/query-result-effect.ts +35 -0
- package/src/internal/Ref/atoms.ts +23 -3
- package/src/internal/Ref/ref.test.ts +8 -8
- package/src/internal/Ref/ref.ts +26 -20
- package/src/internal/common/atom-snapshot.ts +19 -0
- package/src/internal/common/proxy/make-object.ts +1 -1
- package/src/internal/common/proxy/proxy-types.ts +20 -0
- package/src/internal/common/proxy/proxy-utils.ts +37 -1
- package/src/internal/common/proxy/reactive-array.ts +3 -3
- package/src/internal/common/proxy/reactive.test.ts +1 -1
- package/src/internal/common/proxy/schema-validator.ts +181 -8
- package/src/internal/common/proxy/typed-handler.ts +254 -76
- package/src/internal/common/types/entity.ts +15 -7
- package/src/internal/index.ts +1 -0
- package/src/testing/test-schema.ts +75 -90
- package/dist/lib/neutral/chunk-35INCYOE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-3JXQUMUI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4TPQZPLY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-5GAIWRQB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6CEISA3V.mjs.map +0 -7
- package/dist/lib/neutral/chunk-AFANXSGV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-E7IOTOZD.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HGWQR5KH.mjs.map +0 -7
- package/dist/lib/neutral/chunk-JZ6LFQU5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NOL7O3BL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TF5BSLF6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +0 -7
- package/dist/lib/neutral/chunk-VQYL2OQF.mjs +0 -2353
- package/dist/lib/neutral/chunk-VQYL2OQF.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WZ32BF53.mjs.map +0 -7
- package/dist/lib/neutral/chunk-X3NUUON4.mjs +0 -184
- package/dist/lib/neutral/chunk-X3NUUON4.mjs.map +0 -7
- package/dist/types/src/exemplars.test.d.ts +0 -2
- package/dist/types/src/exemplars.test.d.ts.map +0 -1
- package/dist/types/src/hierarchy.test.d.ts +0 -2
- package/dist/types/src/hierarchy.test.d.ts.map +0 -1
- package/src/exemplars.test.ts +0 -21
- package/src/hierarchy.test.ts +0 -33
- /package/dist/lib/neutral/{chunk-K3S7D5PR.mjs.map → chunk-4A2NWKRJ.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-PLDMJJJC.mjs.map → chunk-UGFFV2FR.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-L3OBWBV2.mjs.map → chunk-WKIT2YY5.mjs.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Filter.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Function from 'effect/Function';\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport type * as Types from 'effect/Types';\n\nimport { type ForeignKey, type QueryAST } from '@dxos/echo-protocol';\nimport { assertArgument } from '@dxos/invariant';\nimport { EID, EntityId, type URI } from '@dxos/keys';\n\nimport type * as Entity from './Entity';\nimport * as internal from './internal';\nimport type * as Obj from './Obj';\nimport * as Ref from './Ref';\n// eslint-disable-next-line @dxos/rules/import-as-namespace\nimport type * as Type$ from './Type';\nexport interface Filter<T> {\n // TODO(dmaretskyi): See new effect-schema approach to variance.\n '~Filter': { value: Types.Covariant<T> };\n\n 'ast': QueryAST.Filter;\n}\n\nexport type Props<T> = {\n // Predicate or a value as a shorthand for `eq`.\n [K in keyof T & string]?: Filter<T[K]> | T[K];\n};\n\nexport type Any = Filter<any>;\n\nexport type Type<F extends Any> = F extends Filter<infer T> ? T : never;\n\nclass FilterClass implements Any {\n private static 'variance': Any['~Filter'] = {} as Any['~Filter'];\n\n 'constructor'(public readonly ast: QueryAST.Filter) {}\n\n '~Filter' = FilterClass.variance;\n}\n\nexport const is = (value: unknown): value is Any => {\n return typeof value === 'object' && value !== null && '~Filter' in value;\n};\n\n/** Construct a filter from an ast. */\nexport const fromAst = (ast: QueryAST.Filter): Any => {\n return new FilterClass(ast);\n};\n\n/**\n * Filter that matches all objects.\n */\n// TODO(dmaretskyi): `Entity.Any` would be more type-safe, but causes annoying errors in existing code\nexport const everything = (): FilterClass => {\n return new FilterClass({\n type: 'object',\n typename: null,\n props: {},\n });\n};\n\n/**\n * Filter that matches no objects.\n */\nexport const nothing = (): FilterClass => {\n return new FilterClass({\n type: 'not',\n filter: {\n type: 'object',\n typename: null,\n props: {},\n },\n });\n};\n\n/*\n * Filter by EntityId.\n */\nexport const id = (...ids: EntityId[]): Any => {\n assertArgument(\n ids.every((id) => EntityId.isValid(id)),\n 'ids',\n 'ids must be valid',\n );\n\n if (ids.length === 0) {\n return nothing();\n }\n\n return new FilterClass({\n type: 'object',\n typename: null,\n id: ids,\n props: {},\n });\n};\n\n/**\n * Filter by type.\n *\n * Accepts a `Type.Type` entity (the value produced by `Type.makeObject` /\n * `Type.makeRelation`), a `Schema.Union` of such entities (for filtering across a\n * union of ECHO types), or a fully-qualified type URI — an `echo:` EID (stored schema)\n * or a `dxn:` DXN (static schema). To filter by a bare typename, wrap it: `DXN.make(typename)`.\n */\nexport const type: {\n <T extends Type$.AnyEntity>(type: T, props?: Props<Type$.InstanceType<T>>): Filter<Type$.InstanceType<T>>;\n // Schema-side overload restricted to the well-known unknown schemas and to\n // `Schema.Union(...)` of `Type.Type` entities (for filtering across a union\n // of ECHO types). Other raw schemas are rejected.\n <S extends internal.UnknownTypeSchema<any, any>>(\n schema: S,\n props?: Props<Schema.Schema.Type<S>>,\n ): Filter<Schema.Schema.Type<S>>;\n <S extends Schema.Union<readonly Schema.Schema.AnyNoContext[]>>(\n union: S,\n props?: Props<Schema.Schema.Type<S>>,\n ): Filter<Schema.Schema.Type<S>>;\n (uri: URI.URI, props?: Props<unknown>): Filter<any>;\n // Passthrough overload for callers that hold a `Type.AnyEntity | URI.URI` union\n // (e.g. Query.type / Query.sourceOf / Query.targetOf impls). Listed last so the\n // typed overloads above still win for monomorphic inputs.\n (input: Type$.AnyEntity | URI.URI, props?: Props<unknown>): Filter<unknown>;\n} = (input: Type$.AnyEntity | Schema.Schema.AnyNoContext | URI.URI, props?: Props<unknown>): any => {\n if (Schema.isSchema(input) && SchemaAST.isUnion(input.ast)) {\n const typenames = input.ast.types.map((t) => internal.getTypeURIFromSpecifier(Schema.make(t)));\n return new FilterClass({\n type: 'or',\n filters: typenames.map((typename) => ({\n type: 'object',\n typename,\n props: {},\n })),\n });\n }\n\n const uri = internal.getTypeURIFromSpecifier(input);\n return new FilterClass({\n type: 'object',\n typename: uri,\n ...propsFilterToAst(props ?? {}),\n });\n};\n\n/**\n * Filter by tag.\n */\nexport const tag = (tag: string): Any => {\n return new FilterClass({\n type: 'tag',\n tag,\n });\n};\n\n/**\n * Options for {@link key} filter.\n */\nexport type KeyFilterOptions = {\n /**\n * Optional semver range expression (e.g. `^1.2.3`, `~2.0.0`, `>=1.0.0 <2.0.0`).\n * Matches the object's meta `version` field against the range.\n * If omitted, matches any version (including objects with no version).\n */\n version?: string;\n};\n\n/**\n * Filter by registry key stored in object meta.\n *\n * @example\n * ```ts\n * Filter.key('org.example.type.foo');\n * Filter.key('org.example.type.foo', { version: '^1.2.3' });\n * ```\n */\nexport const key = (key: string, options?: KeyFilterOptions): Any => {\n return new FilterClass({\n type: 'object',\n typename: null,\n props: {},\n metaKey: key,\n metaVersion: options?.version,\n });\n};\n\n/**\n * Filter by properties.\n */\nexport const props = <T>(props: Props<T>): Filter<T> => {\n return new FilterClass({\n type: 'object',\n typename: null,\n ...propsFilterToAst(props),\n });\n};\n\nexport type TextSearchOptions = {\n // TODO(dmaretskyi): Hybrid search.\n type?: 'full-text' | 'vector';\n};\n\n/**\n * Full-text or vector search.\n */\nexport const text = (\n // TODO(dmaretskyi): Consider passing a vector here, but really the embedding should be done on the query-executor side.\n text: string,\n options?: TextSearchOptions,\n): Any => {\n return new FilterClass({\n type: 'text-search',\n text,\n searchKind: options?.type,\n });\n};\n\n/**\n * Filter by foreign keys.\n */\nexport const foreignKeys = <S extends Type$.AnyEntity | URI.URI>(\n schema: S,\n keys: ForeignKey[],\n): Filter<S extends Type$.AnyEntity ? Type$.InstanceType<S> : unknown> => {\n const uri = internal.getTypeURIFromSpecifier(schema);\n return new FilterClass({\n type: 'object',\n typename: uri,\n props: {},\n foreignKeys: keys,\n });\n};\n\n/**\n * Predicate for property to be equal to the provided value.\n */\nexport const eq = <T>(value: T): Filter<T | undefined> => {\n if (!Ref.isRef(value) && typeof value === 'object' && value !== null) {\n throw new TypeError('Cannot use object as a value for eq filter');\n }\n\n return new FilterClass({\n type: 'compare',\n operator: 'eq',\n value: Ref.isRef(value) ? value.noInline().encode() : value,\n });\n};\n\n/**\n * Predicate for property to be not equal to the provided value.\n */\nexport const neq = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'neq',\n value,\n });\n};\n\n/**\n * Predicate for property to be greater than the provided value.\n */\nexport const gt = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'gt',\n value,\n });\n};\n\n/**\n * Predicate for property to be greater than or equal to the provided value.\n */\nexport const gte = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'gte',\n value,\n });\n};\n\n/**\n * Predicate for property to be less than the provided value.\n */\nexport const lt = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'lt',\n value,\n });\n};\n\n/**\n * Predicate for property to be less than or equal to the provided value.\n */\nexport const lte = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'lte',\n value,\n });\n};\n\n/**\n * Predicate for property to be in the provided array.\n * @param values - Values to check against.\n */\nconst in$ = <T>(...values: T[]): Filter<T> => {\n return new FilterClass({\n type: 'in',\n values,\n });\n};\nexport { in$ as in };\n\n/**\n * Predicate for an array property to contain the provided value.\n * @param value - Value to check against.\n */\nexport const contains = <T>(value: T): Filter<readonly T[] | undefined> => {\n return new FilterClass({\n type: 'contains',\n value,\n });\n};\n\n/**\n * Predicate for property to be in the provided range.\n * @param from - Start of the range (inclusive).\n * @param to - End of the range (exclusive).\n */\nexport const between = <T>(from: T, to: T): Filter<T> => {\n return new FilterClass({\n type: 'range',\n from,\n to,\n });\n};\n\ntype TimeRange = { after?: Date | number; before?: Date | number };\n\nconst _toUnixMs = (date: Date | number): number => (typeof date === 'number' ? date : date.getTime());\n\nconst _timeRangeFilter = (field: 'updatedAt' | 'createdAt', range: TimeRange): Any => {\n const filters: Any[] = [];\n if (range.after != null) {\n filters.push(new FilterClass({ type: 'timestamp', field, operator: 'gte', value: _toUnixMs(range.after) }));\n }\n if (range.before != null) {\n filters.push(new FilterClass({ type: 'timestamp', field, operator: 'lte', value: _toUnixMs(range.before) }));\n }\n if (filters.length === 0) {\n return everything();\n }\n return filters.length === 1 ? filters[0] : and(...filters);\n};\n\n/**\n * Filter objects by updatedAt timestamp.\n */\nexport const updated = (range: TimeRange): Any => _timeRangeFilter('updatedAt', range);\n\n/**\n * Filter objects by createdAt timestamp.\n */\nexport const created = (range: TimeRange): Any => _timeRangeFilter('createdAt', range);\n\nexport type ChildOfOptions = {\n /** Whether to match transitively (grandchildren, etc.). Defaults to true. */\n transitive?: boolean;\n};\n\n/**\n * Filter objects that are children of the specified parent(s).\n * Accepts ECHO objects, Refs, or arrays of either.\n * Refs are resolved to DXNs without loading; objects use {@link Obj.getURI}.\n * With transitive=true (default), also matches grandchildren and beyond.\n */\nexport const childOf = (\n parents: Obj.Unknown | Ref.Unknown | readonly (Obj.Unknown | Ref.Unknown)[],\n options?: ChildOfOptions,\n): Any => {\n const items = Array.isArray(parents) ? parents : [parents];\n const dxns = items.map((item) => {\n if (Ref.isRef(item)) {\n return EID.parse(item.uri);\n }\n return EID.parse(internal.getUri(item));\n });\n return new FilterClass({\n type: 'child-of',\n parents: dxns,\n transitive: options?.transitive ?? true,\n });\n};\n\n/**\n * Negate the filter.\n */\nexport const not = <F extends Any>(filter: F): Filter<Type<F>> => {\n return new FilterClass({\n type: 'not',\n filter: filter.ast,\n });\n};\n\n/**\n * Combine filters with a logical AND.\n */\nexport const and = <Filters extends readonly Any[]>(...filters: Filters): Filter<Type<Filters[number]>> => {\n return new FilterClass({\n type: 'and',\n filters: filters.map((f) => f.ast),\n });\n};\n\n/**\n * Combine filters with a logical OR.\n */\nexport const or = <Filters extends readonly Any[]>(...filters: Filters): Filter<Type<Filters[number]>> => {\n return new FilterClass({\n type: 'or',\n filters: filters.map((f) => f.ast),\n });\n};\n\n// TODO(dmaretskyi): Add `Filter.match` to support pattern matching on string props.\n\nconst propsFilterToAst = (predicates: Props<any>): Pick<QueryAST.FilterObject, 'id' | 'props'> => {\n let idFilter: readonly EntityId[] | undefined;\n if ('id' in predicates) {\n assertArgument(\n typeof predicates.id === 'string' || Array.isArray(predicates.id),\n 'predicates.id',\n 'invalid id filter',\n );\n idFilter = typeof predicates.id === 'string' ? [predicates.id] : predicates.id;\n Schema.Array(EntityId).pipe(Schema.validateSync)(idFilter);\n }\n\n return {\n id: idFilter,\n props: Object.fromEntries(\n Object.entries(predicates)\n .filter(([prop, _value]) => prop !== 'id')\n .map(([prop, predicate]) => [prop, processPredicate(predicate)]),\n ) as Record<string, QueryAST.Filter>,\n };\n};\n\nconst processPredicate = (predicate: any): QueryAST.Filter => {\n return Match.value(predicate).pipe(\n Match.withReturnType<QueryAST.Filter>(),\n Match.when(is, (predicate) => predicate.ast),\n // TODO(wittjosiah): Add support for array predicates.\n Match.when(Array.isArray, (_predicate) => {\n throw new Error('Array predicates are not yet supported.');\n }),\n Match.when(\n (predicate: any) => !Ref.isRef(predicate) && typeof predicate === 'object' && predicate !== null,\n (predicate) => {\n const nestedProps = Object.fromEntries(\n Object.entries(predicate).map(([key, value]) => [key, processPredicate(value)]),\n );\n\n return {\n type: 'object',\n typename: null,\n props: nestedProps,\n };\n },\n ),\n Match.orElse((value) => eq(value).ast),\n );\n};\n\n/**\n * Returns a human-readable string representation of a Filter AST.\n */\nexport const pretty = (filter: Any): string => internal.prettyFilter(filter.ast);\n\n/**\n * Create a predicate from a filter.\n */\nexport const toPredicate: {\n <T extends Entity.Unknown>(filter: Filter<T>): (entity: Entity.Unknown) => entity is T;\n <T extends Entity.Unknown>(entity: Entity.Unknown, filter: Filter<T>): entity is T;\n} = Function.dual<\n <T extends Entity.Unknown>(filter: Filter<T>) => (entity: Entity.Unknown) => entity is T,\n <T extends Entity.Unknown>(entity: Entity.Unknown, filter: Filter<T>) => entity is T\n>(2, <T extends Entity.Unknown>(entity: Entity.Unknown, filter: Filter<T>): entity is T =>\n internal.filterMatchEntity(filter.ast, entity),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAYA,cAAc;AAC1B,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,eAAe;AAI3B,SAASC,sBAAsB;AAC/B,SAASC,KAAKC,gBAA0B;AAwBxC,IAAMC,cAAN,MAAMA,aAAAA;;EACJ,OAAe,aAA6B,CAAC;EAE7C,YAA8BC,KAAsB;SAAtBA,MAAAA;EAAuB;EAErD,YAAYD,aAAYE;AAC1B;AAEO,IAAMC,KAAK,CAACC,WAAAA;AACjB,SAAO,OAAOA,WAAU,YAAYA,WAAU,QAAQ,aAAaA;AACrE;AAGO,IAAMC,UAAU,CAACJ,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A,EACpC1B,IAAI,CAAC,CAAC0B,MAAME,SAAAA,MAAe;MAACF;MAAMG,iBAAiBD,SAAAA;KAAW,CAAA;EAErE;AACF;AAEA,IAAMC,mBAAmB,CAACD,cAAAA;AACxB,SAAazD,YAAMyD,SAAAA,EAAWR;IACtBU,qBAAc;IACdC,WAAKC,IAAI,CAACJ,eAAcA,WAAUlB,GAAG;;IAErCqB,WAAKlC,MAAMC,SAAS,CAACmC,eAAAA;AACzB,YAAM,IAAIC,MAAM,yCAAA;IAClB,CAAA;IACMH,WACJ,CAACH,eAAmB,CAAK1B,MAAM0B,UAAAA,KAAc,OAAOA,eAAc,YAAYA,eAAc,MAC5F,CAACA,eAAAA;AACC,YAAMO,cAAcZ,OAAOC,YACzBD,OAAOE,QAAQG,UAAAA,EAAW5B,IAAI,CAAC,CAACoC,MAAKjE,MAAAA,MAAW;QAACiE;QAAKP,iBAAiB1D,MAAAA;OAAO,CAAA;AAGhF,aAAO;QACLE,MAAM;QACNgE,UAAU;QACVf,OAAOa;MACT;IACF,CAAA;IAEIG,aAAO,CAACnE,WAAUoE,GAAGpE,MAAAA,EAAOuC,GAAG;EAAA;AAEzC;AAKO,IAAM8B,SAAS,CAAC/B,WAAiCgC,aAAahC,OAAOC,GAAG;AAKxE,IAAMgC,cAGAC,cAGX,GAAG,CAA2BC,QAAwBnC,WAC7CoC,kBAAkBpC,OAAOC,KAAKkC,MAAAA,CAAAA;",
|
|
6
|
+
"names": ["Function", "Match", "Schema", "SchemaAST", "assertArgument", "EID", "EntityId", "FilterClass", "ast", "variance", "is", "value", "fromAst", "everything", "type", "typename", "props", "nothing", "filter", "id", "ids", "assertArgument", "every", "EntityId", "isValid", "length", "input", "isSchema", "isUnion", "typenames", "types", "map", "t", "getTypeURIFromSpecifier", "make", "filters", "uri", "propsFilterToAst", "tag", "key", "options", "metaKey", "metaVersion", "version", "text", "searchKind", "foreignKeys", "schema", "keys", "eq", "isRef", "TypeError", "operator", "noInline", "encode", "neq", "gt", "gte", "lt", "lte", "in$", "values", "contains", "value", "FilterClass", "type", "between", "from", "to", "_toUnixMs", "date", "getTime", "_timeRangeFilter", "field", "range", "filters", "after", "push", "operator", "before", "length", "everything", "and", "updated", "created", "childOf", "parents", "options", "items", "Array", "isArray", "dxns", "map", "item", "isRef", "EID", "parse", "uri", "getUri", "transitive", "not", "filter", "ast", "f", "or", "propsFilterToAst", "predicates", "idFilter", "assertArgument", "id", "Schema", "EntityId", "pipe", "validateSync", "props", "Object", "fromEntries", "entries", "prop", "_value", "predicate", "processPredicate", "withReturnType", "when", "is", "_predicate", "Error", "nestedProps", "key", "typename", "orElse", "eq", "pretty", "prettyFilter", "toPredicate", "dual", "entity", "filterMatchEntity"]
|
|
7
|
+
}
|
|
@@ -7,7 +7,9 @@ var Err_exports = {};
|
|
|
7
7
|
__export(Err_exports, {
|
|
8
8
|
EntityNotFoundError: () => EntityNotFoundError,
|
|
9
9
|
GetReactiveError: () => GetReactiveError,
|
|
10
|
-
SchemaNotFoundError: () => SchemaNotFoundError
|
|
10
|
+
SchemaNotFoundError: () => SchemaNotFoundError,
|
|
11
|
+
TextEditNotFoundError: () => TextEditNotFoundError,
|
|
12
|
+
TextNotSupportedError: () => TextNotSupportedError
|
|
11
13
|
});
|
|
12
14
|
import { BaseError } from "@dxos/errors";
|
|
13
15
|
var SchemaNotFoundError = class extends BaseError.extend("SchemaNotFoundError", "Schema not found") {
|
|
@@ -30,6 +32,26 @@ var EntityNotFoundError = class extends BaseError.extend("EntityNotFoundError",
|
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
};
|
|
35
|
+
var TextNotSupportedError = class extends BaseError.extend("TextNotSupportedError", "Text operation is not supported for this object") {
|
|
36
|
+
constructor(operation, options) {
|
|
37
|
+
super({
|
|
38
|
+
context: {
|
|
39
|
+
operation
|
|
40
|
+
},
|
|
41
|
+
...options
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var TextEditNotFoundError = class extends BaseError.extend("TextEditNotFoundError", "Edit text not found") {
|
|
46
|
+
constructor(oldString, options) {
|
|
47
|
+
super({
|
|
48
|
+
context: {
|
|
49
|
+
oldString
|
|
50
|
+
},
|
|
51
|
+
...options
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
33
55
|
var GetReactiveError = class extends BaseError.extend("GetReactiveError", "Failed to get reactive object from snapshot") {
|
|
34
56
|
constructor(options) {
|
|
35
57
|
super({
|
|
@@ -45,7 +67,9 @@ var GetReactiveError = class extends BaseError.extend("GetReactiveError", "Faile
|
|
|
45
67
|
export {
|
|
46
68
|
SchemaNotFoundError,
|
|
47
69
|
EntityNotFoundError,
|
|
70
|
+
TextNotSupportedError,
|
|
71
|
+
TextEditNotFoundError,
|
|
48
72
|
GetReactiveError,
|
|
49
73
|
Err_exports
|
|
50
74
|
};
|
|
51
|
-
//# sourceMappingURL=chunk-
|
|
75
|
+
//# sourceMappingURL=chunk-TOCVVFK2.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Err.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { BaseError, type BaseErrorOptions } from '@dxos/errors';\nimport { type URI } from '@dxos/keys';\n\nexport class SchemaNotFoundError extends BaseError.extend('SchemaNotFoundError', 'Schema not found') {\n constructor(schema: string, options?: BaseErrorOptions) {\n super({ context: { schema }, ...options });\n }\n}\n\nexport class EntityNotFoundError extends BaseError.extend('EntityNotFoundError', 'Entity not found') {\n constructor(uri: URI.URI, options?: BaseErrorOptions) {\n super({ context: { uri }, ...options });\n }\n}\n\n/**\n * Thrown when a `Text` mutation is attempted on an object whose reactive handler does not implement\n * string CRDT editing (e.g. a snapshot or a non-reactive value).\n */\nexport class TextNotSupportedError extends BaseError.extend(\n 'TextNotSupportedError',\n 'Text operation is not supported for this object',\n) {\n constructor(operation: string, options?: BaseErrorOptions) {\n super({ context: { operation }, ...options });\n }\n}\n\n/**\n * Thrown by `Text.apply` when a non-`replaceAll` edit's `oldString` is not found in the text.\n */\nexport class TextEditNotFoundError extends BaseError.extend('TextEditNotFoundError', 'Edit text not found') {\n constructor(oldString: string, options?: BaseErrorOptions) {\n super({ context: { oldString }, ...options });\n }\n}\n\n/**\n * Reason why getting a reactive object from a snapshot failed.\n * - `no-database`: The snapshot is not associated with a database.\n * - `object-not-found`: The object was removed or does not exist in the database.\n */\nexport type GetReactiveErrorReason = 'no-database' | 'object-not-found';\n\n/**\n * Error thrown when a reactive object cannot be resolved from a snapshot.\n * Extends `BaseError` with a `reason` and optional `snapshotId` in its context.\n */\nexport class GetReactiveError extends BaseError.extend(\n 'GetReactiveError',\n 'Failed to get reactive object from snapshot',\n) {\n constructor(options: { reason: GetReactiveErrorReason; snapshotId?: string } & BaseErrorOptions) {\n super({ context: { reason: options.reason, snapshotId: options.snapshotId }, ...options });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;;;AAMA,SAASA,iBAAwC;AAG1C,IAAMC,sBAAN,cAAkCD,UAAUE,OAAO,uBAAuB,kBAAA,EAAA;EAC/E,YAAYC,QAAgBC,SAA4B;AACtD,UAAM;MAAEC,SAAS;QAAEF;MAAO;MAAG,GAAGC;IAAQ,CAAA;EAC1C;AACF;AAEO,IAAME,sBAAN,cAAkCN,UAAUE,OAAO,uBAAuB,kBAAA,EAAA;EAC/E,YAAYK,KAAcH,SAA4B;AACpD,UAAM;MAAEC,SAAS;QAAEE;MAAI;MAAG,GAAGH;IAAQ,CAAA;EACvC;AACF;AAMO,IAAMI,wBAAN,cAAoCR,UAAUE,OACnD,yBACA,iDAAA,EAAA;EAEA,YAAYO,WAAmBL,SAA4B;AACzD,UAAM;MAAEC,SAAS;QAAEI;MAAU;MAAG,GAAGL;IAAQ,CAAA;EAC7C;AACF;AAKO,IAAMM,wBAAN,cAAoCV,UAAUE,OAAO,yBAAyB,qBAAA,EAAA;EACnF,YAAYS,WAAmBP,SAA4B;AACzD,UAAM;MAAEC,SAAS;QAAEM;MAAU;MAAG,GAAGP;IAAQ,CAAA;EAC7C;AACF;AAaO,IAAMQ,mBAAN,cAA+BZ,UAAUE,OAC9C,oBACA,6CAAA,EAAA;EAEA,YAAYE,SAAqF;AAC/F,UAAM;MAAEC,SAAS;QAAEQ,QAAQT,QAAQS;QAAQC,YAAYV,QAAQU;MAAW;MAAG,GAAGV;IAAQ,CAAA;EAC1F;AACF;",
|
|
6
|
+
"names": ["BaseError", "SchemaNotFoundError", "extend", "schema", "options", "context", "EntityNotFoundError", "uri", "TextNotSupportedError", "operation", "TextEditNotFoundError", "oldString", "GetReactiveError", "reason", "snapshotId"]
|
|
7
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSchema
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XB6ISRAO.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getSchemaURI
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3TN2VMI4.mjs";
|
|
7
7
|
import {
|
|
8
8
|
__export
|
|
9
9
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -38,4 +38,4 @@ export {
|
|
|
38
38
|
define,
|
|
39
39
|
Migration_exports
|
|
40
40
|
};
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
41
|
+
//# sourceMappingURL=chunk-U53LSQQA.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Migration.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Schema from 'effect/Schema';\n\nimport { type URI } from '@dxos/keys';\n\nimport type * as Database from './Database';\nimport type * as Entity from './Entity';\nimport {
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Schema from 'effect/Schema';\n\nimport { type URI } from '@dxos/keys';\n\nimport type * as Database from './Database';\nimport type * as Entity from './Entity';\nimport { type EntityMeta, MetaId, getSchemaURI } from './internal';\nimport * as Type from './Type';\n\n/**\n * Result returned by a migration's `transform` callback.\n * The data shape matches the target schema; the optional `[Obj.Meta]` symbol key lets the\n * transform update the object's meta (e.g. `key` / `version`) atomically with the data swap.\n */\ntype MigrationSchemaInput = Type.AnyEntity;\n\ntype MigrationInstanceType<S> = S extends Type.AnyEntity\n ? Type.InstanceType<S>\n : S extends Schema.Schema.AnyNoContext\n ? Schema.Schema.Type<S>\n : never;\n\nexport type TransformResult<To> = Omit<MigrationInstanceType<To>, 'id' | Entity.KindId> & {\n [MetaId]?: Partial<EntityMeta>;\n};\n\ntype DefineObjectMigrationOptions<From extends MigrationSchemaInput, To extends MigrationSchemaInput> = {\n from: From;\n to: To;\n /**\n * Pure function that converts the old object data to the new object data.\n *\n * The returned object may include an optional `[Obj.Meta]` entry to update the object's meta\n * (e.g. registry `key` / `version`) atomically with the data swap.\n */\n // TODO(dmaretskyi): `id` should not be a part of the schema.\n transform: (from: MigrationInstanceType<From>, context: ObjectMigrationContext) => Promise<TransformResult<To>>;\n\n /**\n * Callback that is called after the object is migrated. Called for every object that is migrated.\n *\n * NOTE: Database mutations performed in this callback are not guaranteed to be idempotent.\n * If multiple peers run the migration separately, the effects may be applied multiple times.\n */\n onMigration?: (params: OnMigrateProps<From, To>) => Promise<void>;\n};\n\n/**\n * Context passed to object migration callbacks.\n */\nexport type ObjectMigrationContext = {\n db: Database.Database;\n};\n\ntype OnMigrateProps<From, To> = {\n before: MigrationInstanceType<From>;\n object: MigrationInstanceType<To>;\n db: Database.Database;\n};\n\n/**\n * Definition of a migration from one object schema version to another.\n */\nexport type ObjectMigration = {\n fromType: URI.URI;\n toType: URI.URI;\n fromSchema: Schema.Schema.AnyNoContext;\n toSchema: Schema.Schema.AnyNoContext;\n transform: (from: unknown, context: ObjectMigrationContext) => Promise<unknown>;\n onMigration?: (params: OnMigrateProps<any, any>) => Promise<void>;\n};\n\n/**\n * Define a migration between two object schemas.\n *\n * @example\n * ```ts\n * const migration = Migration.define({\n * from: ContactV1,\n * to: ContactV2,\n * transform: async (from) => ({ name: `${from.firstName} ${from.lastName}` }),\n * onMigration: async () => {},\n * });\n * ```\n */\nexport const define = <From extends MigrationSchemaInput, To extends MigrationSchemaInput>(\n options: DefineObjectMigrationOptions<From, To>,\n): ObjectMigration => {\n const fromSchema = Type.getSchema(options.from);\n const toSchema = Type.getSchema(options.to);\n const fromType = getSchemaURI(fromSchema);\n if (!fromType) {\n throw new Error('Invalid from schema');\n }\n const toType = getSchemaURI(toSchema);\n if (!toType) {\n throw new Error('Invalid to schema');\n }\n\n return {\n fromType,\n toType,\n fromSchema,\n toSchema,\n transform: options.transform as any,\n onMigration: options.onMigration as any,\n };\n};\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;AAAA;;;;AA2FO,IAAMA,SAAS,CACpBC,YAAAA;AAEA,QAAMC,aAAkBC,UAAUF,QAAQG,IAAI;AAC9C,QAAMC,WAAgBF,UAAUF,QAAQK,EAAE;AAC1C,QAAMC,WAAWC,aAAaN,UAAAA;AAC9B,MAAI,CAACK,UAAU;AACb,UAAM,IAAIE,MAAM,qBAAA;EAClB;AACA,QAAMC,SAASF,aAAaH,QAAAA;AAC5B,MAAI,CAACK,QAAQ;AACX,UAAM,IAAID,MAAM,mBAAA;EAClB;AAEA,SAAO;IACLF;IACAG;IACAR;IACAG;IACAM,WAAWV,QAAQU;IACnBC,aAAaX,QAAQW;EACvB;AACF;",
|
|
6
6
|
"names": ["define", "options", "fromSchema", "getSchema", "from", "toSchema", "to", "fromType", "getSchemaURI", "Error", "toType", "transform", "onMigration"]
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
JsonSchemaType,
|
|
3
3
|
toEffectSchema,
|
|
4
4
|
toJsonSchema
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-4A2NWKRJ.mjs";
|
|
6
6
|
import {
|
|
7
7
|
__export
|
|
8
8
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -24,4 +24,4 @@ export {
|
|
|
24
24
|
JsonSchema,
|
|
25
25
|
JsonSchema_exports
|
|
26
26
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-UGFFV2FR.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/QueryResult.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Atom from '@effect-atom/atom/Atom';\nimport type * as Effect from 'effect/Effect';\nimport type * as Option from 'effect/Option';\n\nimport { type CleanupFn } from '@dxos/async';\n\nimport type * as Entity from './Entity';\n\n/**\n * Individual query result entry.\n */\nexport type Entry<T> = {\n id: string;\n\n /**\n * May not be present for remote results.\n */\n result?: T;\n\n match?: {\n // TODO(dmaretskyi): text positional info.\n\n /**\n * Higher means better match.\n */\n rank: number;\n };\n\n /**\n * Query resolution metadata.\n */\n // TODO(dmaretskyi): Rename to meta?\n resolution?: {\n // TODO(dmaretskyi): Make this more generic.\n source: 'remote' | 'local' | 'index';\n\n /**\n * Query resolution time in milliseconds.\n */\n time: number;\n };\n};\n\n/**\n * Invidual query result entry for a database Entity.\n */\nexport type EntityEntry<T extends Entity.Unknown = Entity.Unknown> = Entry<T>;\n\nexport type RunOptions = {\n timeout?: number;\n};\n\nexport type SubscriptionOptions = {\n /**\n * Fire the callback immediately.\n */\n fire?: boolean;\n};\n\n// TODO(burdon): Should T be constrained to Entity.Any?\nexport interface QueryResult<T> {\n /**\n * Currently available results along with their match metadata.\n */\n readonly entries: Entry<T>[];\n\n /**\n * Currently available results.\n */\n readonly results: T[];\n\n /**\n * Returns all known results.\n */\n run(opts?: RunOptions): Promise<T[]>;\n\n /**\n * Returns all known results along with their match metadata.\n */\n runEntries(opts?: RunOptions): Promise<Entry<T>[]>;\n\n /**\n * Returns currently available results synchronously.\n */\n runSync(): T[];\n\n /**\n * Returns currently available results synchronously along with their match metadata.\n */\n runSyncEntries(): Entry<T>[];\n\n /**\n * Returns first result.\n */\n first(opts?: RunOptions): Promise<T>;\n\n /**\n * Returns first result if there is one.\n */\n firstOrUndefined(opts?: RunOptions): Promise<T | undefined>;\n\n /**\n * Subscribes to changes in query results.\n */\n subscribe(callback?: (query: QueryResult<T>) => void, opts?: SubscriptionOptions): CleanupFn;\n\n /**\n * Self-updating atom. Updates automatically when query results change.\n *\n * Memoized per QueryResult instance — repeated accesses on the same instance return the same\n * Atom. Safe only when the QueryResult is itself held stable across re-renders (e.g. behind a\n * `useMemo`). It must NOT be used in graph-builder connectors/actions or other atom computes,\n * where `db.query(...)` is called fresh on each re-evaluation: every run constructs a new\n * QueryResult and so a new atom + subscription, leaking the previous ones. Use the memoized\n * {@link atom} family there instead.\n */\n readonly atom: Atom.Atom<T[]>;\n}\n\n/**\n * Effect that returns a QueryResult when evaluated, but also has shorthand methods for running the query or getting the first result.\n */\nexport interface QueryResultEffect<T, E, R> extends Effect.Effect<QueryResult<T>, E, R> {\n run: Effect.Effect<T[], E, R>;\n first: Effect.Effect<Option.Option<T>, E, R>;\n\n // TODO(dmaretskyi): Considering adding `atom`, but since `Database.query` is used in imperative code only, I dont think it will be useful.\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,33 +2,35 @@ import {
|
|
|
2
2
|
Kind,
|
|
3
3
|
KindId,
|
|
4
4
|
SnapshotKindId
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-BEFR7LEA.mjs";
|
|
6
6
|
import {
|
|
7
7
|
getSchema
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XB6ISRAO.mjs";
|
|
9
9
|
import {
|
|
10
10
|
VersionTypeId,
|
|
11
|
-
change,
|
|
12
11
|
getSnapshot,
|
|
13
12
|
isDeleted,
|
|
14
13
|
isVersion,
|
|
15
|
-
makeObject,
|
|
16
14
|
makeRelation,
|
|
17
15
|
objectToJSON,
|
|
18
16
|
setValue,
|
|
19
17
|
sort,
|
|
20
18
|
sortByLabel,
|
|
21
19
|
sortByTypename,
|
|
22
|
-
subscribe,
|
|
23
20
|
version
|
|
24
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ACFAOTKJ.mjs";
|
|
25
22
|
import {
|
|
26
23
|
addTag,
|
|
27
24
|
deleteKeys,
|
|
28
25
|
getKeys,
|
|
29
26
|
getMetaChecked,
|
|
27
|
+
makeObject,
|
|
30
28
|
removeTag
|
|
31
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-2HKGAQM4.mjs";
|
|
30
|
+
import {
|
|
31
|
+
change,
|
|
32
|
+
subscribe
|
|
33
|
+
} from "./chunk-L3E5IXAE.mjs";
|
|
32
34
|
import {
|
|
33
35
|
ATTR_RELATION_SOURCE,
|
|
34
36
|
ATTR_RELATION_TARGET,
|
|
@@ -51,12 +53,12 @@ import {
|
|
|
51
53
|
isInstanceOf,
|
|
52
54
|
setDescription,
|
|
53
55
|
setLabel
|
|
54
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-3TN2VMI4.mjs";
|
|
55
57
|
import {
|
|
56
58
|
ANY_OBJECT_TYPENAME,
|
|
57
59
|
ANY_OBJECT_VERSION,
|
|
58
60
|
EntityKind
|
|
59
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-2ZHECXUR.mjs";
|
|
60
62
|
import {
|
|
61
63
|
__export
|
|
62
64
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -109,7 +111,7 @@ import * as Schema from "effect/Schema";
|
|
|
109
111
|
import { raise } from "@dxos/debug";
|
|
110
112
|
import { SchemaEx } from "@dxos/effect";
|
|
111
113
|
import { assertArgument, invariant } from "@dxos/invariant";
|
|
112
|
-
import {
|
|
114
|
+
import { DXN, EID } from "@dxos/keys";
|
|
113
115
|
import { assumeType } from "@dxos/util";
|
|
114
116
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/Relation.ts";
|
|
115
117
|
var Unknown2 = Schema.Struct({
|
|
@@ -278,4 +280,4 @@ export {
|
|
|
278
280
|
atom,
|
|
279
281
|
Relation_exports
|
|
280
282
|
};
|
|
281
|
-
//# sourceMappingURL=chunk-
|
|
283
|
+
//# sourceMappingURL=chunk-UZHCQ6NI.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Relation.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { raise } from '@dxos/debug';\nimport type { ForeignKey } from '@dxos/echo-protocol';\nimport { SchemaEx } from '@dxos/effect';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { EID, type EntityId, type URI, DXN } from '@dxos/keys';\nimport { assumeType } from '@dxos/util';\n\nimport type * as Database from './Database';\nimport * as Entity from './Entity';\nimport * as internal from './internal';\nimport * as entityInternal from './internal/Entity';\nimport * as objInternal from './internal/Obj';\nimport * as Obj from './Obj';\nimport type * as Ref from './Ref';\nimport type * as Tag from './Tag';\nimport * as Type from './Type';\n\nexport type Endpoints<Source, Target> = {\n [Source]: Source;\n [Target]: Target;\n};\n\n/**\n * Base type for all ECHO relations.\n * @private\n */\ninterface BaseRelation<Source, Target>\n extends internal.AnyEntity, Endpoints<Source, Target>, Entity.OfKind<internal.EntityKind.Relation> {}\n\n/**\n * Relation with no known properties beyond id, kind, source, and target.\n * Use this when the relation's schema/properties are not known.\n *\n * NOTE: This is a TypeScript type only, not a schema.\n * To validate that a value is an ECHO relation, use `Relation.isRelation`.\n */\nexport interface Unknown extends BaseRelation<Obj.Unknown, Obj.Unknown> {}\n\n/**\n * Runtime Effect schema for any ECHO relation.\n * Use for validation, parsing, or as a reference target for collections.\n * A relation has `id`, source, and target fields plus any additional properties.\n *\n * NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).\n * Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.\n *\n * @example\n * ```ts\n * // Structural type guard (accepts any object with id field)\n * if (Schema.is(Type.Relation)(unknownValue)) { ... }\n *\n * // ECHO instance type guard (checks KindId brand)\n * if (Relation.isRelation(unknownValue)) { ... }\n * ```\n */\n// TODO(dmaretskyi): Change ObjModule.Any to ObjModule.Unknown to have stricter types.\nexport const Unknown: internal.UnknownTypeSchema<Unknown, typeof Entity.Kind.Relation> = Schema.Struct({\n id: Schema.String,\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n Schema.annotations({\n [internal.TypeAnnotationId]: {\n kind: Entity.Kind.Relation,\n typename: 'org.dxos.schema.anyRelation',\n version: '0.0.0',\n sourceSchema: DXN.make(internal.ANY_OBJECT_TYPENAME, internal.ANY_OBJECT_VERSION),\n targetSchema: DXN.make(internal.ANY_OBJECT_TYPENAME, internal.ANY_OBJECT_VERSION),\n },\n }),\n) as unknown as internal.UnknownTypeSchema<Unknown, typeof Entity.Kind.Relation>;\n\n/**\n * Relation type with specific source and target types.\n */\nexport type OfShape<Source extends Obj.Unknown, Target extends Obj.Unknown, Props> = BaseRelation<Source, Target> &\n Props;\n\n/**\n * Base type for snapshot relations (has SnapshotKindId instead of KindId).\n */\ninterface BaseRelationSnapshot<Source, Target> extends internal.AnyEntity, Endpoints<Source, Target> {\n readonly [Entity.SnapshotKindId]: internal.EntityKind.Relation;\n readonly id: EntityId;\n}\n\n/**\n * JSON-encoded properties for relations.\n */\nexport interface BaseRelationJson {\n id: string;\n [internal.ATTR_RELATION_SOURCE]: string;\n [internal.ATTR_RELATION_TARGET]: string;\n}\n\n/**\n * Immutable snapshot of an ECHO relation.\n * Branded with SnapshotKindId (not KindId).\n * Property values are frozen at the time the snapshot was created.\n * Returned by getSnapshot() and hooks.\n */\nexport type Snapshot<T extends Unknown = Unknown> = Omit<T, Entity.KindId> &\n BaseRelationSnapshot<Obj.Unknown, Obj.Unknown>;\n\nexport const Source: unique symbol = entityInternal.RelationSourceId as any;\nexport type Source = typeof Source;\n\nexport const Target: unique symbol = entityInternal.RelationTargetId as any;\nexport type Target = typeof Target;\n\n/**\n * Get relation source type.\n */\nexport type SourceOf<A> = A extends Endpoints<infer S, infer _T> ? S : never;\n\n/**\n * Get relation target type.\n */\nexport type TargetOf<A> = A extends Endpoints<infer _S, infer T> ? T : never;\n\n/**\n * Internal props type for relation instance creation.\n */\ntype MakePropsInternal<T extends Endpoints<any, any>> = {\n id?: EntityId;\n [Meta]?: Partial<internal.EntityMeta>;\n [Source]: T[Source];\n [Target]: T[Target];\n} & Entity.Properties<T>;\n\n/**\n * Props type for relation creation with a given schema. Accepts a `Type.AnyRelation`\n * entity (created with `Type.makeRelation`) and derives the props shape via\n * `Type.InstanceType`. Object-kind entities are rejected at the type level —\n * use `Obj.MakeProps` for those.\n */\nexport type MakeProps<S extends Type.AnyRelation> = MakePropsInternal<Type.InstanceType<S>>;\n\n/**\n * Creates new relation.\n * @param schema - Relation schema.\n * @param props - Relation properties. Endpoints are passed as [Relation.Source] and [Relation.Target] keys.\n * @param meta - Relation metadata. (deprecated; use [Obj.Meta] instead)\n * @returns\n */\n// NOTE: Writing the definition this way (with generic over schema) makes typescript perfer to infer the type from the first param (this schema) rather than the second param (the props).\n// TODO(dmaretskyi): Move meta into props.\nexport const make = <T extends Type.AnyRelation>(\n type: T,\n props: NoInfer<MakeProps<T>>,\n): Type.InstanceType<T> & Entity.OfKind<typeof Entity.Kind.Relation> => {\n const schema = Type.getSchema(type);\n assertArgument(\n internal.getTypeAnnotation(schema)?.kind === internal.EntityKind.Relation,\n 'schema',\n 'Expected a relation schema',\n );\n assertArgument(props[internal.ParentId] === undefined, 'props', 'Parent is not allowed for relations');\n\n let meta: internal.EntityMeta | undefined = undefined;\n\n if (props[internal.MetaId] != null) {\n meta = props[internal.MetaId] as any;\n delete props[internal.MetaId];\n }\n\n const sourceDXN = internal.getObjectEchoUri(props[Source]) ?? raise(new Error('Unresolved relation source'));\n const targetDXN = internal.getObjectEchoUri(props[Target]) ?? raise(new Error('Unresolved relation target'));\n\n (props as any)[internal.RelationSourceDXNId] = sourceDXN;\n (props as any)[internal.RelationTargetDXNId] = targetDXN;\n\n // Pass the type entity through as `typeSource` so the resulting instance\n // carries a back-reference resolvable via `Relation.getType` / `Entity.getType`.\n return internal.makeObject(schema as any, props as any, meta, type as any) as any;\n};\n\n/**\n * Test if a value is an instance of a given relation type.\n *\n * Mirrors `Obj.instanceOf` but only accepts `Type.AnyRelation` — use\n * `Obj.instanceOf` for objects and `Type.isType` for `Type.Type` entities.\n *\n * @example\n * ```ts\n * const isEmployedBy = Relation.instanceOf(EmployedBy);\n * if (isEmployedBy(relation)) {\n * // relation is EmployedBy\n * }\n * ```\n */\nexport const instanceOf: {\n <S extends Type.AnyRelation>(schema: S): (value: unknown) => value is Type.InstanceType<S>;\n <S extends Type.AnyRelation>(schema: S, value: unknown): value is Type.InstanceType<S>;\n} = ((...args: [schema: Type.AnyRelation, 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 * Type guard for relations.\n * Returns true for both reactive relations and relation snapshots.\n */\nexport const isRelation = (value: unknown): value is Unknown => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (internal.ATTR_RELATION_SOURCE in value || internal.ATTR_RELATION_TARGET in value) {\n return true;\n }\n\n // Check for reactive relation (KindId) or snapshot (SnapshotKindId).\n const kind = (value as any)[Entity.KindId] ?? (value as any)[Entity.SnapshotKindId];\n return kind === internal.EntityKind.Relation;\n};\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)[Entity.SnapshotKindId] === internal.EntityKind.Relation;\n};\n\n/**\n * @returns Relation source URI.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getSourceURI = (value: Unknown | Snapshot): EID.EID => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(value);\n const uri = (value as internal.InternalObjectProps)[internal.RelationSourceDXNId];\n invariant(EID.isEID(uri));\n return uri;\n};\n\n/**\n * @returns Relation target URI.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getTargetURI = (value: Unknown | Snapshot): EID.EID => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(value);\n const uri = (value as internal.InternalObjectProps)[internal.RelationTargetDXNId];\n invariant(EID.isEID(uri));\n return uri;\n};\n\n/**\n * @returns Relation source.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getSource = <T extends Unknown | Snapshot>(relation: T): SourceOf<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(relation);\n const obj = (relation as internal.InternalObjectProps)[internal.RelationSourceId];\n if (obj === undefined) {\n throw new Error(`Relation source could not be resolved.`);\n }\n return obj as SourceOf<T>;\n};\n\n/**\n * @returns Relation target.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getTarget = <T extends Unknown | Snapshot>(relation: T): TargetOf<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(relation);\n const obj = (relation as internal.InternalObjectProps)[internal.RelationTargetId];\n if (obj === undefined) {\n throw new Error(`Relation target could not be resolved.`);\n }\n return obj as TargetOf<T>;\n};\n\n//\n// Change\n//\n\n/**\n * Makes all properties mutable recursively.\n * Used to provide a mutable view of a relation within `Relation.update`.\n */\nexport type Mutable<T> = internal.Mutable<T>;\n\n/**\n * Perform mutations on an echo relation within a controlled context.\n *\n * All mutations within the callback are batched and trigger a single notification\n * when the callback completes. Direct mutations outside of `Relation.update` will throw\n * an error for echo relations.\n *\n * @param relation - The echo relation to mutate. Use `Obj.update` for objects.\n * @param callback - The callback that performs mutations on the relation.\n *\n * @example\n * ```ts\n * const worksFor = Relation.make(EmployedBy, {\n * [Relation.Source]: person,\n * [Relation.Target]: company,\n * role: 'Engineer',\n * });\n *\n * // Mutate within Relation.update\n * Relation.update(worksFor, (obj) => {\n * obj.role = 'Senior Engineer';\n * });\n * ```\n *\n * Note: Only accepts relations. Use `Obj.update` for objects.\n */\nexport const update = <T extends Unknown>(relation: T, callback: internal.ChangeCallback<T>): void => {\n internal.change(relation, callback);\n};\n\n//\n// Snapshot\n//\n\n/**\n * Returns an immutable snapshot of a relation.\n * The snapshot is branded with SnapshotKindId instead of KindId,\n * making it distinguishable from the reactive relation at the type level.\n */\nexport const getSnapshot: <T extends Unknown>(rel: T) => Snapshot<T> = internal.getSnapshot as any;\n\n//\n// Subscribe\n//\n\n/**\n * Subscribe to relation updates.\n * The callback is called synchronously when the relation is modified.\n * Only accepts reactive relations (not snapshots).\n * @returns Unsubscribe function.\n */\nexport const subscribe = (rel: Unknown, callback: () => void): (() => void) => {\n return internal.subscribe(rel, callback);\n};\n\n//\n// Property Access\n//\n\n/**\n * Get a deeply nested property from a relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const getValue = (rel: Unknown | Snapshot, path: readonly (string | number)[]): any => {\n return SchemaEx.getValue(rel, SchemaEx.createJsonPath(path));\n};\n\n/**\n * Set a deeply nested property on a relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setValue: (rel: Mutable<Unknown>, path: readonly (string | number)[], value: any) => void =\n internal.setValue as any;\n\n//\n// Type\n//\n\n/**\n * Get the canonical URI of the relation. Returns `URI.URI` — today always an EID,\n * but future entity kinds may surface other URI schemes; narrow with `EID.parse(uri)`\n * or `DXN.tryMake(uri)` at the point of use. Accepts both reactive relations and snapshots.\n *\n * @param options.prefer - Controls the URI form (see {@link internal.GetURIOptions}).\n */\nexport const getURI = (entity: Unknown | Snapshot, options?: internal.GetURIOptions): URI.URI =>\n internal.getUri(entity, options);\n\n/**\n * @returns The DXN of the relation's type.\n */\nexport const getTypeURI: (obj: internal.AnyProperties) => URI.URI | undefined = internal.getTypeURI;\n\n/**\n * Get the type entity (`Type.AnyRelation`) the relation was created from.\n *\n * Returns `undefined` when the relation's type isn't registered in this\n * runtime (e.g. a freshly deserialized snapshot whose type entity hasn't been\n * wired up yet, or a relation loaded from storage before its schema is known).\n * To get the Effect Schema from the returned entity, use `Type.getSchema(...)`.\n */\nexport const getType = (relation: Unknown | Snapshot): Type.AnyRelation | undefined =>\n internal.getType(relation) as Type.AnyRelation | undefined;\n\n/**\n * @returns The typename of the relation's type.\n * Accepts both reactive relations and snapshots.\n */\nexport const getTypename = (entity: Unknown | Snapshot): string | undefined => internal.getTypename(entity);\n\n//\n// Database\n//\n\n/**\n * Get the database the relation belongs to.\n * Accepts both reactive relations and snapshots.\n */\nexport const getDatabase = (entity: Unknown | Snapshot): Database.Database | undefined => internal.getDatabase(entity);\n\n//\n// Meta\n//\n\n/**\n * Property that accesses metadata for an entity.\n *\n * Alias for `Entity.Meta`.\n */\nexport const Meta = internal.MetaId;\n\n/**\n * Deeply read-only version of EntityMeta.\n */\nexport type ReadonlyMeta = internal.ReadonlyMeta;\n\n/**\n * Mutable meta type returned by `Relation.getMeta` inside a `Relation.update` callback.\n */\nexport type Meta = internal.Meta;\n\n/**\n * Get the metadata for a relation.\n * Returns mutable meta when passed a mutable relation (inside `Relation.update` callback).\n * Returns read-only meta when passed a regular relation 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>): Meta;\nexport function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;\nexport function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): Meta | ReadonlyMeta {\n return internal.getMetaChecked(entity);\n}\n\n/**\n * @returns Foreign keys for the relation from the specified source.\n * Accepts both reactive relations and snapshots.\n */\nexport const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => internal.getKeys(entity, source);\n\n/**\n * Delete all keys from the relation for the specified source.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const deleteKeys = (entity: Mutable<Unknown>, source: string): void => internal.deleteKeys(entity, source);\n\n/**\n * Add a tag to the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);\n\n/**\n * Remove a tag from the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);\n\n/**\n * Check if the relation is deleted.\n * Accepts both reactive relations and snapshots.\n */\nexport const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDeleted(entity);\n\n//\n// Annotations\n//\n\n/**\n * Get the label of the relation.\n * Accepts both reactive relations and snapshots.\n *\n * @param options.fallback `'typename'` returns the relation'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 the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);\n\n/**\n * Get the description of the relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);\n\n/**\n * Set the description of the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setDescription = (entity: Mutable<Unknown>, description: string): void =>\n internal.setDescription(entity, description);\n\n//\n// JSON\n//\n\n/**\n * JSON representation of a relation.\n */\nexport type JSON = internal.ObjectJSON;\n\n/**\n * Converts relation to its JSON representation.\n * Accepts both reactive relations and snapshots.\n */\nexport const toJSON = (entity: Unknown | Snapshot): JSON => internal.objectToJSON(entity);\n\n//\n// Sorting\n//\n\n/**\n * Comparator function type for sorting relations.\n * Accepts both reactive relations and snapshots.\n */\nexport type Comparator = internal.Comparator<Unknown | Snapshot>;\n\nexport const sortByLabel: Comparator = internal.sortByLabel as Comparator;\nexport const sortByTypename: Comparator = internal.sortByTypename as Comparator;\nexport const sort = (...comparators: Comparator[]): Comparator => internal.sort(...comparators) as Comparator;\n\n//\n// Version\n//\n\nexport const VersionTypeId = internal.VersionTypeId;\nexport const isVersion = internal.isVersion;\n\n/**\n * Represent relation version.\n */\nexport type Version = internal.EntityVersion;\n\n/**\n * Returns the version of the relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const version = (entity: Unknown | Snapshot): Version => internal.version(entity);\n\n//\n// Atoms\n//\n\nexport const atom = objInternal.makeRelation;\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Unknown", "VersionTypeId", "addTag", "deleteKeys", "getDatabase", "getDescription", "getKeys", "getLabel", "getSnapshot", "getType", "getTypeURI", "getTypename", "isDeleted", "isVersion", "removeTag", "setDescription", "setLabel", "setValue", "sort", "sortByLabel", "sortByTypename", "subscribe", "version", "Schema", "raise", "SchemaEx", "assertArgument", "invariant", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { raise } from '@dxos/debug';\nimport type { ForeignKey } from '@dxos/echo-protocol';\nimport { SchemaEx } from '@dxos/effect';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN, EID, type EntityId, type URI } from '@dxos/keys';\nimport { assumeType } from '@dxos/util';\n\nimport type * as Database from './Database';\nimport * as Entity from './Entity';\nimport * as internal from './internal';\nimport * as entityInternal from './internal/Entity';\nimport * as objInternal from './internal/Obj';\nimport * as Obj from './Obj';\nimport type * as Ref from './Ref';\nimport type * as Tag from './Tag';\nimport * as Type from './Type';\n\nexport type Endpoints<Source, Target> = {\n [Source]: Source;\n [Target]: Target;\n};\n\n/**\n * Base type for all ECHO relations.\n * @private\n */\ninterface BaseRelation<Source, Target>\n extends internal.AnyEntity, Endpoints<Source, Target>, Entity.OfKind<internal.EntityKind.Relation> {}\n\n/**\n * Relation with no known properties beyond id, kind, source, and target.\n * Use this when the relation's schema/properties are not known.\n *\n * NOTE: This is a TypeScript type only, not a schema.\n * To validate that a value is an ECHO relation, use `Relation.isRelation`.\n */\nexport interface Unknown extends BaseRelation<Obj.Unknown, Obj.Unknown> {}\n\n/**\n * Runtime Effect schema for any ECHO relation.\n * Use for validation, parsing, or as a reference target for collections.\n * A relation has `id`, source, and target fields plus any additional properties.\n *\n * NOTE: `Schema.is(Type.Relation)` does STRUCTURAL validation only (checks for `id` field).\n * Use `Relation.isRelation()` for proper ECHO instance type guards that check the KindId brand.\n *\n * @example\n * ```ts\n * // Structural type guard (accepts any object with id field)\n * if (Schema.is(Type.Relation)(unknownValue)) { ... }\n *\n * // ECHO instance type guard (checks KindId brand)\n * if (Relation.isRelation(unknownValue)) { ... }\n * ```\n */\n// TODO(dmaretskyi): Change ObjModule.Any to ObjModule.Unknown to have stricter types.\nexport const Unknown: internal.UnknownTypeSchema<Unknown, typeof Entity.Kind.Relation> = Schema.Struct({\n id: Schema.String,\n}).pipe(\n Schema.extend(Schema.Record({ key: Schema.String, value: Schema.Unknown })),\n Schema.annotations({\n [internal.TypeAnnotationId]: {\n kind: Entity.Kind.Relation,\n typename: 'org.dxos.schema.anyRelation',\n version: '0.0.0',\n sourceSchema: DXN.make(internal.ANY_OBJECT_TYPENAME, internal.ANY_OBJECT_VERSION),\n targetSchema: DXN.make(internal.ANY_OBJECT_TYPENAME, internal.ANY_OBJECT_VERSION),\n },\n }),\n) as unknown as internal.UnknownTypeSchema<Unknown, typeof Entity.Kind.Relation>;\n\n/**\n * Relation type with specific source and target types.\n */\nexport type OfShape<Source extends Obj.Unknown, Target extends Obj.Unknown, Props> = BaseRelation<Source, Target> &\n Props;\n\n/**\n * Base type for snapshot relations (has SnapshotKindId instead of KindId).\n */\ninterface BaseRelationSnapshot<Source, Target> extends internal.AnyEntity, Endpoints<Source, Target> {\n readonly [Entity.SnapshotKindId]: internal.EntityKind.Relation;\n readonly id: EntityId;\n}\n\n/**\n * JSON-encoded properties for relations.\n */\nexport interface BaseRelationJson {\n id: string;\n [internal.ATTR_RELATION_SOURCE]: string;\n [internal.ATTR_RELATION_TARGET]: string;\n}\n\n/**\n * Immutable snapshot of an ECHO relation.\n * Branded with SnapshotKindId (not KindId).\n * Property values are frozen at the time the snapshot was created.\n * Returned by getSnapshot() and hooks.\n */\nexport type Snapshot<T extends Unknown = Unknown> = Omit<T, Entity.KindId> &\n BaseRelationSnapshot<Obj.Unknown, Obj.Unknown>;\n\nexport const Source: unique symbol = entityInternal.RelationSourceId as any;\nexport type Source = typeof Source;\n\nexport const Target: unique symbol = entityInternal.RelationTargetId as any;\nexport type Target = typeof Target;\n\n/**\n * Get relation source type.\n */\nexport type SourceOf<A> = A extends Endpoints<infer S, infer _T> ? S : never;\n\n/**\n * Get relation target type.\n */\nexport type TargetOf<A> = A extends Endpoints<infer _S, infer T> ? T : never;\n\n/**\n * Internal props type for relation instance creation.\n */\ntype MakePropsInternal<T extends Endpoints<any, any>> = {\n id?: EntityId;\n [Meta]?: Partial<internal.EntityMeta>;\n [Source]: T[Source];\n [Target]: T[Target];\n} & Entity.Properties<T>;\n\n/**\n * Props type for relation creation with a given schema. Accepts a `Type.AnyRelation`\n * entity (created with `Type.makeRelation`) and derives the props shape via\n * `Type.InstanceType`. Object-kind entities are rejected at the type level —\n * use `Obj.MakeProps` for those.\n */\nexport type MakeProps<S extends Type.AnyRelation> = MakePropsInternal<Type.InstanceType<S>>;\n\n/**\n * Creates new relation.\n * @param schema - Relation schema.\n * @param props - Relation properties. Endpoints are passed as [Relation.Source] and [Relation.Target] keys.\n * @param meta - Relation metadata. (deprecated; use [Obj.Meta] instead)\n * @returns\n */\n// NOTE: Writing the definition this way (with generic over schema) makes typescript perfer to infer the type from the first param (this schema) rather than the second param (the props).\n// TODO(dmaretskyi): Move meta into props.\nexport const make = <T extends Type.AnyRelation>(\n type: T,\n props: NoInfer<MakeProps<T>>,\n): Type.InstanceType<T> & Entity.OfKind<typeof Entity.Kind.Relation> => {\n const schema = Type.getSchema(type);\n assertArgument(\n internal.getTypeAnnotation(schema)?.kind === internal.EntityKind.Relation,\n 'schema',\n 'Expected a relation schema',\n );\n assertArgument(props[internal.ParentId] === undefined, 'props', 'Parent is not allowed for relations');\n\n let meta: internal.EntityMeta | undefined = undefined;\n\n if (props[internal.MetaId] != null) {\n meta = props[internal.MetaId] as any;\n delete props[internal.MetaId];\n }\n\n const sourceDXN = internal.getObjectEchoUri(props[Source]) ?? raise(new Error('Unresolved relation source'));\n const targetDXN = internal.getObjectEchoUri(props[Target]) ?? raise(new Error('Unresolved relation target'));\n\n (props as any)[internal.RelationSourceDXNId] = sourceDXN;\n (props as any)[internal.RelationTargetDXNId] = targetDXN;\n\n // Pass the type entity through as `typeSource` so the resulting instance\n // carries a back-reference resolvable via `Relation.getType` / `Entity.getType`.\n return internal.makeObject(schema as any, props as any, meta, type as any) as any;\n};\n\n/**\n * Test if a value is an instance of a given relation type.\n *\n * Mirrors `Obj.instanceOf` but only accepts `Type.AnyRelation` — use\n * `Obj.instanceOf` for objects and `Type.isType` for `Type.Type` entities.\n *\n * @example\n * ```ts\n * const isEmployedBy = Relation.instanceOf(EmployedBy);\n * if (isEmployedBy(relation)) {\n * // relation is EmployedBy\n * }\n * ```\n */\nexport const instanceOf: {\n <S extends Type.AnyRelation>(schema: S): (value: unknown) => value is Type.InstanceType<S>;\n <S extends Type.AnyRelation>(schema: S, value: unknown): value is Type.InstanceType<S>;\n} = ((...args: [schema: Type.AnyRelation, 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 * Type guard for relations.\n * Returns true for both reactive relations and relation snapshots.\n */\nexport const isRelation = (value: unknown): value is Unknown => {\n if (typeof value !== 'object' || value === null) {\n return false;\n }\n if (internal.ATTR_RELATION_SOURCE in value || internal.ATTR_RELATION_TARGET in value) {\n return true;\n }\n\n // Check for reactive relation (KindId) or snapshot (SnapshotKindId).\n const kind = (value as any)[Entity.KindId] ?? (value as any)[Entity.SnapshotKindId];\n return kind === internal.EntityKind.Relation;\n};\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)[Entity.SnapshotKindId] === internal.EntityKind.Relation;\n};\n\n/**\n * @returns Relation source URI.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getSourceURI = (value: Unknown | Snapshot): EID.EID => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(value);\n const uri = (value as internal.InternalObjectProps)[internal.RelationSourceDXNId];\n invariant(EID.isEID(uri));\n return uri;\n};\n\n/**\n * @returns Relation target URI.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getTargetURI = (value: Unknown | Snapshot): EID.EID => {\n assertArgument(isRelation(value), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(value);\n const uri = (value as internal.InternalObjectProps)[internal.RelationTargetDXNId];\n invariant(EID.isEID(uri));\n return uri;\n};\n\n/**\n * @returns Relation source.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getSource = <T extends Unknown | Snapshot>(relation: T): SourceOf<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(relation);\n const obj = (relation as internal.InternalObjectProps)[internal.RelationSourceId];\n if (obj === undefined) {\n throw new Error(`Relation source could not be resolved.`);\n }\n return obj as SourceOf<T>;\n};\n\n/**\n * @returns Relation target.\n * Accepts both reactive relations and snapshots.\n * @throws If the object is not a relation.\n */\nexport const getTarget = <T extends Unknown | Snapshot>(relation: T): TargetOf<T> => {\n assertArgument(isRelation(relation), 'Expected a relation');\n assumeType<internal.InternalObjectProps>(relation);\n const obj = (relation as internal.InternalObjectProps)[internal.RelationTargetId];\n if (obj === undefined) {\n throw new Error(`Relation target could not be resolved.`);\n }\n return obj as TargetOf<T>;\n};\n\n//\n// Change\n//\n\n/**\n * Makes all properties mutable recursively.\n * Used to provide a mutable view of a relation within `Relation.update`.\n */\nexport type Mutable<T> = internal.Mutable<T>;\n\n/**\n * Perform mutations on an echo relation within a controlled context.\n *\n * All mutations within the callback are batched and trigger a single notification\n * when the callback completes. Direct mutations outside of `Relation.update` will throw\n * an error for echo relations.\n *\n * @param relation - The echo relation to mutate. Use `Obj.update` for objects.\n * @param callback - The callback that performs mutations on the relation.\n *\n * @example\n * ```ts\n * const worksFor = Relation.make(EmployedBy, {\n * [Relation.Source]: person,\n * [Relation.Target]: company,\n * role: 'Engineer',\n * });\n *\n * // Mutate within Relation.update\n * Relation.update(worksFor, (obj) => {\n * obj.role = 'Senior Engineer';\n * });\n * ```\n *\n * Note: Only accepts relations. Use `Obj.update` for objects.\n */\nexport const update = <T extends Unknown>(relation: T, callback: internal.ChangeCallback<T>): void => {\n internal.change(relation, callback);\n};\n\n//\n// Snapshot\n//\n\n/**\n * Returns an immutable snapshot of a relation.\n * The snapshot is branded with SnapshotKindId instead of KindId,\n * making it distinguishable from the reactive relation at the type level.\n */\nexport const getSnapshot: <T extends Unknown>(rel: T) => Snapshot<T> = internal.getSnapshot as any;\n\n//\n// Subscribe\n//\n\n/**\n * Subscribe to relation updates.\n * The callback is called synchronously when the relation is modified.\n * Only accepts reactive relations (not snapshots).\n * @returns Unsubscribe function.\n */\nexport const subscribe = (rel: Unknown, callback: () => void): (() => void) => {\n return internal.subscribe(rel, callback);\n};\n\n//\n// Property Access\n//\n\n/**\n * Get a deeply nested property from a relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const getValue = (rel: Unknown | Snapshot, path: readonly (string | number)[]): any => {\n return SchemaEx.getValue(rel, SchemaEx.createJsonPath(path));\n};\n\n/**\n * Set a deeply nested property on a relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setValue: (rel: Mutable<Unknown>, path: readonly (string | number)[], value: any) => void =\n internal.setValue as any;\n\n//\n// Type\n//\n\n/**\n * Get the canonical URI of the relation. Returns `URI.URI` — today always an EID,\n * but future entity kinds may surface other URI schemes; narrow with `EID.parse(uri)`\n * or `DXN.tryMake(uri)` at the point of use. Accepts both reactive relations and snapshots.\n *\n * @param options.prefer - Controls the URI form (see {@link internal.GetURIOptions}).\n */\nexport const getURI = (entity: Unknown | Snapshot, options?: internal.GetURIOptions): URI.URI =>\n internal.getUri(entity, options);\n\n/**\n * @returns The DXN of the relation's type.\n */\nexport const getTypeURI: (obj: internal.AnyProperties) => URI.URI | undefined = internal.getTypeURI;\n\n/**\n * Get the type entity (`Type.AnyRelation`) the relation was created from.\n *\n * Returns `undefined` when the relation's type isn't registered in this\n * runtime (e.g. a freshly deserialized snapshot whose type entity hasn't been\n * wired up yet, or a relation loaded from storage before its schema is known).\n * To get the Effect Schema from the returned entity, use `Type.getSchema(...)`.\n */\nexport const getType = (relation: Unknown | Snapshot): Type.AnyRelation | undefined =>\n internal.getType(relation) as Type.AnyRelation | undefined;\n\n/**\n * @returns The typename of the relation's type.\n * Accepts both reactive relations and snapshots.\n */\nexport const getTypename = (entity: Unknown | Snapshot): string | undefined => internal.getTypename(entity);\n\n//\n// Database\n//\n\n/**\n * Get the database the relation belongs to.\n * Accepts both reactive relations and snapshots.\n */\nexport const getDatabase = (entity: Unknown | Snapshot): Database.Database | undefined => internal.getDatabase(entity);\n\n//\n// Meta\n//\n\n/**\n * Property that accesses metadata for an entity.\n *\n * Alias for `Entity.Meta`.\n */\nexport const Meta = internal.MetaId;\n\n/**\n * Deeply read-only version of EntityMeta.\n */\nexport type ReadonlyMeta = internal.ReadonlyMeta;\n\n/**\n * Mutable meta type returned by `Relation.getMeta` inside a `Relation.update` callback.\n */\nexport type Meta = internal.Meta;\n\n/**\n * Get the metadata for a relation.\n * Returns mutable meta when passed a mutable relation (inside `Relation.update` callback).\n * Returns read-only meta when passed a regular relation 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>): Meta;\nexport function getMeta(entity: Unknown | Snapshot): ReadonlyMeta;\nexport function getMeta(entity: Unknown | Snapshot | Mutable<Unknown>): Meta | ReadonlyMeta {\n return internal.getMetaChecked(entity);\n}\n\n/**\n * @returns Foreign keys for the relation from the specified source.\n * Accepts both reactive relations and snapshots.\n */\nexport const getKeys = (entity: Unknown | Snapshot, source: string): ForeignKey[] => internal.getKeys(entity, source);\n\n/**\n * Delete all keys from the relation for the specified source.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const deleteKeys = (entity: Mutable<Unknown>, source: string): void => internal.deleteKeys(entity, source);\n\n/**\n * Add a tag to the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const addTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.addTag(entity, tag);\n\n/**\n * Remove a tag from the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const removeTag = (entity: Mutable<Unknown>, tag: Ref.Ref<Tag.Tag>): void => internal.removeTag(entity, tag);\n\n/**\n * Check if the relation is deleted.\n * Accepts both reactive relations and snapshots.\n */\nexport const isDeleted = (entity: Unknown | Snapshot): boolean => internal.isDeleted(entity);\n\n//\n// Annotations\n//\n\n/**\n * Get the label of the relation.\n * Accepts both reactive relations and snapshots.\n *\n * @param options.fallback `'typename'` returns the relation'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 the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setLabel = (entity: Mutable<Unknown>, label: string): void => internal.setLabel(entity, label);\n\n/**\n * Get the description of the relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const getDescription = (entity: Unknown | Snapshot): string | undefined => internal.getDescription(entity);\n\n/**\n * Set the description of the relation.\n * Must be called within a `Relation.update` callback.\n *\n * NOTE: TypeScript's structural typing allows readonly objects to be passed to `Mutable<T>`\n * parameters, so there is no compile-time error. Enforcement is runtime-only.\n */\nexport const setDescription = (entity: Mutable<Unknown>, description: string): void =>\n internal.setDescription(entity, description);\n\n//\n// JSON\n//\n\n/**\n * JSON representation of a relation.\n */\nexport type JSON = internal.ObjectJSON;\n\n/**\n * Converts relation to its JSON representation.\n * Accepts both reactive relations and snapshots.\n */\nexport const toJSON = (entity: Unknown | Snapshot): JSON => internal.objectToJSON(entity);\n\n//\n// Sorting\n//\n\n/**\n * Comparator function type for sorting relations.\n * Accepts both reactive relations and snapshots.\n */\nexport type Comparator = internal.Comparator<Unknown | Snapshot>;\n\nexport const sortByLabel: Comparator = internal.sortByLabel as Comparator;\nexport const sortByTypename: Comparator = internal.sortByTypename as Comparator;\nexport const sort = (...comparators: Comparator[]): Comparator => internal.sort(...comparators) as Comparator;\n\n//\n// Version\n//\n\nexport const VersionTypeId = internal.VersionTypeId;\nexport const isVersion = internal.isVersion;\n\n/**\n * Represent relation version.\n */\nexport type Version = internal.EntityVersion;\n\n/**\n * Returns the version of the relation.\n * Accepts both reactive relations and snapshots.\n */\nexport const version = (entity: Unknown | Snapshot): Version => internal.version(entity);\n\n//\n// Atoms\n//\n\nexport const atom = objInternal.makeRelation;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;iBAAAA;EAAA,qBAAAC;EAAA,cAAAC;EAAA;oBAAAC;EAAA,mBAAAC;EAAA,sBAAAC;EAAA,eAAAC;EAAA,gBAAAC;EAAA;qBAAAC;EAAA;;;;iBAAAC;EAAA,kBAAAC;EAAA,mBAAAC;EAAA;;;mBAAAC;EAAA;;mBAAAC;EAAA;mBAAAC;EAAA,sBAAAC;EAAA,gBAAAC;EAAA,gBAAAC;EAAA,YAAAC;EAAA,mBAAAC;EAAA,sBAAAC;EAAA,iBAAAC;EAAA;;iBAAAC;;AAMA,YAAYC,YAAY;AAExB,SAASC,aAAa;AAEtB,SAASC,gBAAgB;AACzB,SAASC,gBAAgBC,iBAAiB;AAC1C,SAASC,KAAKC,WAAoC;AAClD,SAASC,kBAAkB;AAiC3B,IAAA,eAAA;AAoBO,IACLC,WAAqBC,cAAO;EAAEC,IAA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,aAAA,CAAA,KAAA,aAAA;AAEA,SAAA,UAAA,KAAA,QAAA;AACF;AASE,IAAA,WAAA,CAAA,KAAA,SAAA;AAEF,SAAA,SAAA,SAAA,KAAA,SAAA,eAAA,IAAA,CAAA;;AAWO,IAAAC,YAAA;;;;AAoCI,IAAAC,eAAA,CAAA,WAAA,YAAA,MAAA;AAUJ,IAAAC,eAAA,CAAA,WAAA,YAAA,MAAA;AA6BE7B,IAAAA,OAAS8B;AAClB,SAAA,QAAA,QAAA;AAEA,SAAA,eAAA,MAAA;;;;;;AAwCA,IAAcC,aAAA,CAAA,WAAA,UAAA,MAAA;;;;;AAgEP,IAAMC,SAAAA,CAAAA,WAAsCA,aAA6B,MAAA;AACzE,IAAMC,eAAWC;AAEtB,IAAAF,kBAAA;AACF,IAAUC,QAAA,IAAA,gBAAA,KAAA,GAAA,WAAA;AAWV,IAAAE,iBAAA;;AAOQ,IAAAvC,WAAA,CAAA,WAAA,QAAA,MAAA;;",
|
|
6
|
+
"names": ["Unknown", "VersionTypeId", "addTag", "deleteKeys", "getDatabase", "getDescription", "getKeys", "getLabel", "getSnapshot", "getType", "getTypeURI", "getTypename", "isDeleted", "isVersion", "removeTag", "setDescription", "setLabel", "setValue", "sort", "sortByLabel", "sortByTypename", "subscribe", "version", "Schema", "raise", "SchemaEx", "assertArgument", "invariant", "DXN", "EID", "assumeType", "Schema", "Record", "key", "annotations", "TypeAnnotationId", "kind", "Kind", "typename", "version", "sourceSchema", "targetSchema", "assertArgument", "internal", "getTypeAnnotation", "ParentId", "undefined", "meta", "props", "MetaId", "sourceDXN", "getObjectEchoUri", "RelationSourceDXNId", "RelationTargetDXNId", "targetDXN", "entity", "isInstanceOf", "args", "value", "assumeType", "invariant", "EID", "isEID", "uri", "relation", "RelationSourceId", "obj", "RelationTargetId", "getSnapshot", "subscribe", "setValue", "getTypename", "getDatabase", "getMetaChecked", "isDeleted", "sortByTypename", "sort", "comparators", "VersionTypeId"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Ref
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L3E5IXAE.mjs";
|
|
4
4
|
|
|
5
5
|
// src/internal/Ref/ref-array.ts
|
|
6
6
|
import { isNonNullable } from "@dxos/util";
|
|
@@ -31,4 +31,4 @@ var RefArray = Object.freeze({
|
|
|
31
31
|
export {
|
|
32
32
|
RefArray
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-WKIT2YY5.mjs.map
|
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
|
-
EchoObjectSchema,
|
|
3
|
-
EchoRelationSchema,
|
|
4
2
|
TypeSchema,
|
|
5
3
|
addFieldsToSchema,
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
makeObjectType,
|
|
5
|
+
makeRelationType,
|
|
8
6
|
removeFieldsFromSchema,
|
|
9
7
|
updateFieldNameInSchema,
|
|
10
8
|
updateFieldsInSchema,
|
|
11
9
|
version
|
|
12
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ACFAOTKJ.mjs";
|
|
11
|
+
import {
|
|
12
|
+
getMetaChecked,
|
|
13
|
+
makeObject
|
|
14
|
+
} from "./chunk-2HKGAQM4.mjs";
|
|
13
15
|
import {
|
|
14
16
|
toEffectSchema,
|
|
15
17
|
toJsonSchema
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4A2NWKRJ.mjs";
|
|
17
19
|
import {
|
|
18
|
-
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
change
|
|
21
|
+
} from "./chunk-L3E5IXAE.mjs";
|
|
20
22
|
import {
|
|
21
23
|
TypeIdentifierAnnotationId,
|
|
22
24
|
getDatabase,
|
|
23
25
|
getLabel,
|
|
24
26
|
getSchemaURI,
|
|
25
27
|
getTypeURIFromSpecifier
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-3TN2VMI4.mjs";
|
|
27
29
|
import {
|
|
28
30
|
EntityKind,
|
|
29
31
|
InstancePhantomId,
|
|
30
32
|
getEntityKindBrand,
|
|
31
33
|
getSchemaKind,
|
|
32
34
|
getStaticTypeSchema
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-2ZHECXUR.mjs";
|
|
34
36
|
import {
|
|
35
37
|
__export
|
|
36
38
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -68,7 +70,7 @@ import { raise } from "@dxos/debug";
|
|
|
68
70
|
import { assertArgument, invariant } from "@dxos/invariant";
|
|
69
71
|
import { DXN, EID } from "@dxos/keys";
|
|
70
72
|
var __dxlog_file = "/__w/dxos/dxos/packages/core/echo/echo/src/Type.ts";
|
|
71
|
-
var makeObject2 =
|
|
73
|
+
var makeObject2 = (dxn, options) => (schema) => makeObjectType(dxn, schema, options);
|
|
72
74
|
var Type = TypeSchema;
|
|
73
75
|
var DRAFT_VERSION = "0.0.0";
|
|
74
76
|
var makeObjectFromJsonSchema = (props) => {
|
|
@@ -102,7 +104,17 @@ var makeRelationFromJsonSchema = (props) => {
|
|
|
102
104
|
version: version2 ?? DRAFT_VERSION
|
|
103
105
|
}, TypeSchema);
|
|
104
106
|
};
|
|
105
|
-
var makeRelation =
|
|
107
|
+
var makeRelation = (dxn) => (opts) => (schema) => (
|
|
108
|
+
// Boundary cast: makeRelationType erases generic params since the constructor/prototype
|
|
109
|
+
// wiring cannot thread them through the type system.
|
|
110
|
+
makeRelationType({
|
|
111
|
+
dxn,
|
|
112
|
+
source: opts.source,
|
|
113
|
+
target: opts.target,
|
|
114
|
+
schema,
|
|
115
|
+
id: opts.id
|
|
116
|
+
})
|
|
117
|
+
);
|
|
106
118
|
var isObject = (entity) => {
|
|
107
119
|
return getSchemaKind(entity) === EntityKind.Object;
|
|
108
120
|
};
|
|
@@ -146,13 +158,13 @@ var getTypename = (input) => {
|
|
|
146
158
|
}
|
|
147
159
|
typename ??= input.id;
|
|
148
160
|
typename = stripTypenamePrefix(typename);
|
|
149
|
-
invariant(typeof typename === "string" && typename.length > 0, "Invalid typename", { "~LogMeta": "~LogMeta", F: __dxlog_file, L:
|
|
161
|
+
invariant(typeof typename === "string" && typename.length > 0, "Invalid typename", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 228, S: void 0, A: ["typeof typename === 'string' && typename.length > 0", "'Invalid typename'"] });
|
|
150
162
|
return typename;
|
|
151
163
|
};
|
|
152
164
|
var getVersion = (input) => {
|
|
153
165
|
const meta = getMetaChecked(input);
|
|
154
166
|
const semver = meta.version ?? input.jsonSchema?.version ?? DRAFT_VERSION;
|
|
155
|
-
invariant(typeof semver === "string" && semver.match(/^\d+\.\d+\.\d+$/), "Invalid version", { "~LogMeta": "~LogMeta", F: __dxlog_file, L:
|
|
167
|
+
invariant(typeof semver === "string" && semver.match(/^\d+\.\d+\.\d+$/), "Invalid version", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 249, S: void 0, A: ["typeof semver === 'string' && semver.match(/^\\d+\\.\\d+\\.\\d+$/)", "'Invalid version'"] });
|
|
156
168
|
const heads = version(input).automergeHeads;
|
|
157
169
|
if (heads != null && heads.length > 0) {
|
|
158
170
|
return `${semver}-${[
|
|
@@ -256,4 +268,4 @@ export {
|
|
|
256
268
|
removeFields,
|
|
257
269
|
Type_exports
|
|
258
270
|
};
|
|
259
|
-
//# sourceMappingURL=chunk-
|
|
271
|
+
//# sourceMappingURL=chunk-XB6ISRAO.mjs.map
|