@dxos/echo 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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/README.md +1 -2
- package/dist/lib/neutral/Annotation.mjs +32 -0
- package/dist/lib/neutral/Database.mjs +17 -0
- package/dist/lib/neutral/Entity.mjs +51 -0
- package/dist/lib/neutral/Err.mjs +10 -0
- package/dist/lib/neutral/Filter.mjs +61 -0
- package/dist/lib/neutral/Format.mjs +66 -0
- package/dist/lib/neutral/JsonSchema.mjs +19 -0
- package/dist/lib/neutral/JsonSchema.mjs.map +7 -0
- package/dist/lib/neutral/Key.mjs +12 -0
- package/dist/lib/neutral/Key.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +90 -0
- package/dist/lib/neutral/Obj.mjs.map +7 -0
- package/dist/lib/neutral/Order.mjs +12 -0
- package/dist/lib/neutral/Order.mjs.map +7 -0
- package/dist/lib/neutral/Query.mjs +26 -0
- package/dist/lib/neutral/Query.mjs.map +7 -0
- package/dist/lib/neutral/QueryResult.mjs +2 -0
- package/dist/lib/neutral/QueryResult.mjs.map +7 -0
- package/dist/lib/neutral/Ref.mjs +22 -0
- package/dist/lib/neutral/Ref.mjs.map +7 -0
- package/dist/lib/neutral/Relation.mjs +84 -0
- package/dist/lib/neutral/Relation.mjs.map +7 -0
- package/dist/lib/neutral/SchemaRegistry.mjs +2 -0
- package/dist/lib/neutral/SchemaRegistry.mjs.map +7 -0
- package/dist/lib/neutral/Tag.mjs +25 -0
- package/dist/lib/neutral/Tag.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +47 -0
- package/dist/lib/neutral/Type.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2MTHJ5UW.mjs +203 -0
- package/dist/lib/neutral/chunk-2MTHJ5UW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3ZEAZF7T.mjs +23 -0
- package/dist/lib/neutral/chunk-3ZEAZF7T.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4L6DOFXP.mjs +7 -0
- package/dist/lib/neutral/chunk-4L6DOFXP.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4TT624YA.mjs +73 -0
- package/dist/lib/neutral/chunk-4TT624YA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-62DWJ6CE.mjs +402 -0
- package/dist/lib/neutral/chunk-62DWJ6CE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6QPSGMEF.mjs +97 -0
- package/dist/lib/neutral/chunk-6QPSGMEF.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs +21 -0
- package/dist/lib/neutral/chunk-ANHVGJI4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CUDIBUM4.mjs +282 -0
- package/dist/lib/neutral/chunk-CUDIBUM4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HMOXCO27.mjs +40 -0
- package/dist/lib/neutral/chunk-HMOXCO27.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IP2GHXWA.mjs +56 -0
- package/dist/lib/neutral/chunk-IP2GHXWA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs +132 -0
- package/dist/lib/neutral/chunk-KRHDMXSU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NWUO5FKZ.mjs +39 -0
- package/dist/lib/neutral/chunk-NWUO5FKZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs +7 -0
- package/dist/lib/neutral/chunk-OMUPQMLR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs +42 -0
- package/dist/lib/neutral/chunk-ROKO4RKJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RPB6V4BE.mjs +38 -0
- package/dist/lib/neutral/chunk-RPB6V4BE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-SU2LVM7J.mjs +3846 -0
- package/dist/lib/neutral/chunk-SU2LVM7J.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VB5HVDCA.mjs +287 -0
- package/dist/lib/neutral/chunk-VB5HVDCA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VR4A4WGG.mjs +249 -0
- package/dist/lib/neutral/chunk-VR4A4WGG.mjs.map +7 -0
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs +13 -0
- package/dist/lib/neutral/chunk-X2MPMYYN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs +157 -0
- package/dist/lib/neutral/chunk-XK5OUUBY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XMIDBDE6.mjs +142 -0
- package/dist/lib/neutral/chunk-XMIDBDE6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YQYMWZAD.mjs +67 -0
- package/dist/lib/neutral/chunk-YQYMWZAD.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +84 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{node-esm → neutral}/internal/index.mjs +245 -125
- package/dist/lib/neutral/internal/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/testing/index.mjs +366 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/types/src/Annotation.d.ts +2 -0
- package/dist/types/src/Annotation.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +194 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +142 -0
- package/dist/types/src/Entity.d.ts.map +1 -0
- package/dist/types/src/Entity.test.d.ts +2 -0
- package/dist/types/src/Entity.test.d.ts.map +1 -0
- package/dist/types/src/{errors.d.ts → Err.d.ts} +23 -31
- package/dist/types/src/Err.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +120 -0
- package/dist/types/src/Filter.d.ts.map +1 -0
- package/dist/types/src/Format.d.ts +4 -0
- package/dist/types/src/Format.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +60 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +9 -0
- package/dist/types/src/JsonSchema.d.ts.map +1 -0
- package/dist/types/src/Key.d.ts +1 -0
- package/dist/types/src/Key.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +302 -99
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Obj.test.d.ts +2 -0
- package/dist/types/src/Obj.test.d.ts.map +1 -0
- package/dist/types/src/Order.d.ts +16 -0
- package/dist/types/src/Order.d.ts.map +1 -0
- package/dist/types/src/Query.d.ts +115 -0
- package/dist/types/src/Query.d.ts.map +1 -0
- package/dist/types/src/Query.test.d.ts +2 -0
- package/dist/types/src/Query.test.d.ts.map +1 -0
- package/dist/types/src/QueryResult.d.ts +80 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -0
- package/dist/types/src/Ref.d.ts +13 -11
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +242 -22
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Relation.test.d.ts +2 -0
- package/dist/types/src/Relation.test.d.ts.map +1 -0
- package/dist/types/src/SchemaRegistry.d.ts +84 -0
- package/dist/types/src/SchemaRegistry.d.ts.map +1 -0
- package/dist/types/src/Tag.d.ts +17 -0
- package/dist/types/src/Tag.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +225 -72
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/Type.test.d.ts +2 -0
- package/dist/types/src/Type.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +15 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +170 -0
- package/dist/types/src/internal/annotations/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/annotations.test.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/index.d.ts +3 -0
- package/dist/types/src/internal/annotations/index.d.ts.map +1 -0
- package/dist/types/src/internal/annotations/util.d.ts +27 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
- package/dist/types/src/internal/api/annotations.d.ts +23 -0
- package/dist/types/src/internal/api/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/api/entity.d.ts +13 -0
- package/dist/types/src/internal/api/entity.d.ts.map +1 -0
- package/dist/types/src/internal/api/index.d.ts +15 -0
- package/dist/types/src/internal/api/index.d.ts.map +1 -0
- package/dist/types/src/internal/api/meta.d.ts +42 -0
- package/dist/types/src/internal/api/meta.d.ts.map +1 -0
- package/dist/types/src/internal/api/sorting.d.ts +24 -0
- package/dist/types/src/internal/api/sorting.d.ts.map +1 -0
- package/dist/types/src/internal/api/version.d.ts +42 -0
- package/dist/types/src/internal/api/version.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +20 -0
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
- package/dist/types/src/internal/entities/index.d.ts +6 -0
- package/dist/types/src/internal/entities/index.d.ts.map +1 -0
- package/dist/types/src/internal/entities/model.d.ts +77 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +18 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +62 -0
- package/dist/types/src/internal/entities/relation.d.ts.map +1 -0
- package/dist/types/src/internal/entities/util.d.ts +2 -0
- package/dist/types/src/internal/entities/util.d.ts.map +1 -0
- package/dist/types/src/internal/formats/format.d.ts +4 -2
- package/dist/types/src/internal/formats/format.d.ts.map +1 -1
- package/dist/types/src/internal/formats/select.d.ts +6 -4
- package/dist/types/src/internal/formats/select.d.ts.map +1 -1
- package/dist/types/src/internal/formats/string.d.ts +4 -0
- package/dist/types/src/internal/formats/string.d.ts.map +1 -1
- package/dist/types/src/internal/formats/types.d.ts +13 -9
- package/dist/types/src/internal/formats/types.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +7 -10
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/annotations.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/effect-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/index.d.ts +2 -0
- package/dist/types/src/internal/json-schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts +130 -29
- package/dist/types/src/internal/json-schema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +4 -2
- package/dist/types/src/internal/json-schema/json-schema.d.ts.map +1 -0
- package/dist/types/src/internal/json-schema/json-schema.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/clone.d.ts +8 -0
- package/dist/types/src/internal/object/clone.d.ts.map +1 -0
- package/dist/types/src/internal/object/common.d.ts.map +1 -1
- package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +10 -11
- package/dist/types/src/internal/object/create-object.d.ts.map +1 -0
- package/dist/types/src/internal/object/create-object.test.d.ts +2 -0
- package/dist/types/src/internal/object/create-object.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/deleted.d.ts +2 -2
- package/dist/types/src/internal/object/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/object/ids.d.ts.map +1 -1
- package/dist/types/src/internal/object/index.d.ts +6 -11
- package/dist/types/src/internal/object/index.d.ts.map +1 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +14 -9
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/object/schema-validator.d.ts +1 -14
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/object/set-value.d.ts +7 -0
- package/dist/types/src/internal/object/set-value.d.ts.map +1 -0
- package/dist/types/src/internal/object/set-value.test.d.ts +2 -0
- package/dist/types/src/internal/object/set-value.test.d.ts.map +1 -0
- package/dist/types/src/internal/object/snapshot.d.ts +6 -0
- package/dist/types/src/internal/object/snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/object/typed-object.d.ts +8 -14
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
- package/dist/types/src/internal/proxy/change-context.d.ts +55 -0
- package/dist/types/src/internal/proxy/change-context.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/change.test.d.ts +2 -0
- package/dist/types/src/internal/proxy/change.test.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts +5 -0
- package/dist/types/src/internal/proxy/define-hidden-property.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/errors.d.ts +19 -0
- package/dist/types/src/internal/proxy/errors.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts +10 -0
- package/dist/types/src/internal/proxy/event-batch.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/index.d.ts +14 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts +6 -0
- package/dist/types/src/internal/proxy/json-serializer.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +14 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/ownership.d.ts +57 -0
- package/dist/types/src/internal/proxy/ownership.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts +18 -0
- package/dist/types/src/internal/proxy/proxy-types.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts +47 -0
- package/dist/types/src/internal/proxy/proxy-utils.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts +8 -0
- package/dist/types/src/internal/proxy/reactive-array.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/reactive.d.ts +39 -0
- package/dist/types/src/internal/proxy/reactive.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts +15 -0
- package/dist/types/src/internal/proxy/schema-validator.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/symbols.d.ts +3 -0
- package/dist/types/src/internal/proxy/symbols.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +15 -12
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref-array.d.ts +4 -4
- package/dist/types/src/internal/ref/ref-array.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref.d.ts +29 -17
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/schema/compose.d.ts +7 -0
- package/dist/types/src/internal/schema/compose.d.ts.map +1 -0
- package/dist/types/src/internal/schema/compose.test.d.ts.map +1 -0
- package/dist/types/src/internal/schema/echo-schema.d.ts +24 -12
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/schema/index.d.ts +1 -4
- package/dist/types/src/internal/schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +20 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/types/base.d.ts +26 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/types/entity.d.ts +37 -0
- package/dist/types/src/internal/types/entity.d.ts.map +1 -0
- package/dist/types/src/internal/types/index.d.ts +5 -2
- package/dist/types/src/internal/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/{object → types}/meta.d.ts +17 -16
- package/dist/types/src/internal/types/meta.d.ts.map +1 -0
- package/dist/types/src/internal/types/typename.d.ts +13 -0
- package/dist/types/src/internal/types/typename.d.ts.map +1 -0
- package/dist/types/src/internal/{object → types}/version.d.ts +3 -2
- package/dist/types/src/internal/types/version.d.ts.map +1 -0
- package/dist/types/src/{test → testing}/api.test.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +3 -3
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +18 -0
- package/dist/types/src/testing/test-data.d.ts.map +1 -0
- package/dist/types/src/testing/test-schema.d.ts +303 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +21 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +101 -65
- package/src/Annotation.ts +18 -0
- package/src/Database.ts +336 -0
- package/src/Entity.test.ts +22 -0
- package/src/Entity.ts +217 -0
- package/src/{errors.ts → Err.ts} +2 -2
- package/src/Filter.ts +376 -0
- package/src/Format.ts +9 -0
- package/src/Hypergraph.ts +74 -0
- package/src/JsonSchema.ts +16 -0
- package/src/Key.ts +3 -0
- package/src/Obj.test.ts +386 -0
- package/src/Obj.ts +449 -275
- package/src/Order.ts +44 -0
- package/src/Query.test.ts +465 -0
- package/src/Query.ts +296 -0
- package/src/QueryResult.ts +106 -0
- package/src/Ref.ts +26 -9
- package/src/Relation.test.ts +82 -0
- package/src/Relation.ts +411 -60
- package/src/SchemaRegistry.ts +105 -0
- package/src/{query/tag.ts → Tag.ts} +10 -7
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +361 -114
- package/src/index.ts +16 -6
- package/src/internal/README.md +102 -0
- package/src/internal/{ast → annotations}/annotations.test.ts +18 -20
- package/src/internal/annotations/annotations.ts +460 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +72 -0
- package/src/internal/api/annotations.ts +60 -0
- package/src/internal/api/entity.ts +29 -0
- package/src/internal/api/index.ts +19 -0
- package/src/internal/api/meta.ts +88 -0
- package/src/internal/api/sorting.ts +53 -0
- package/src/internal/api/version.ts +96 -0
- package/src/internal/entities/entity.ts +126 -0
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +134 -0
- package/src/internal/entities/object.ts +58 -0
- package/src/internal/entities/relation.ts +171 -0
- package/src/internal/entities/util.ts +33 -0
- package/src/internal/formats/date.test.ts +1 -1
- package/src/internal/formats/date.ts +5 -5
- package/src/internal/formats/format.test.ts +6 -6
- package/src/internal/formats/format.ts +8 -6
- package/src/internal/formats/number.ts +5 -5
- package/src/internal/formats/object.ts +4 -4
- package/src/internal/formats/select.ts +6 -4
- package/src/internal/formats/string.ts +14 -9
- package/src/internal/formats/types.ts +53 -42
- package/src/internal/index.ts +30 -13
- package/src/internal/{json → json-schema}/annotations.ts +1 -1
- package/src/internal/json-schema/index.ts +2 -0
- package/src/internal/json-schema/json-schema-normalize.ts +4 -2
- package/src/internal/json-schema/json-schema-type.ts +35 -35
- package/src/internal/{json → json-schema}/json-schema.test.ts +73 -69
- package/src/internal/{json → json-schema}/json-schema.ts +27 -14
- package/src/internal/object/clone.ts +48 -0
- package/src/internal/object/common.ts +3 -4
- package/src/internal/object/{create.test.ts → create-object.test.ts} +31 -33
- package/src/internal/object/{create.ts → create-object.ts} +36 -37
- package/src/internal/object/deleted.ts +6 -6
- package/src/internal/object/ids.ts +1 -1
- package/src/internal/object/index.ts +6 -11
- package/src/internal/object/inspect.ts +5 -7
- package/src/internal/object/json-serializer.test.ts +36 -37
- package/src/internal/object/json-serializer.ts +65 -102
- package/src/internal/object/schema-validator.test.ts +3 -7
- package/src/internal/object/schema-validator.ts +2 -237
- package/src/internal/object/set-value.test.ts +281 -0
- package/src/internal/object/set-value.ts +165 -0
- package/src/internal/object/snapshot.ts +70 -0
- package/src/internal/object/typed-object.test.ts +11 -11
- package/src/internal/object/typed-object.ts +8 -66
- package/src/internal/proxy/change-context.ts +138 -0
- package/src/internal/proxy/change.test.ts +519 -0
- package/src/internal/proxy/define-hidden-property.ts +14 -0
- package/src/internal/proxy/errors.ts +42 -0
- package/src/internal/proxy/event-batch.ts +44 -0
- package/src/internal/proxy/handler.test.ts +51 -91
- package/src/internal/proxy/index.ts +17 -0
- package/src/internal/proxy/json-serializer.ts +87 -0
- package/src/internal/proxy/make-object.ts +96 -0
- package/src/internal/proxy/ownership.ts +253 -0
- package/src/internal/proxy/proxy-types.ts +23 -0
- package/src/internal/proxy/proxy-utils.ts +150 -0
- package/src/internal/proxy/reactive-array.ts +71 -0
- package/src/internal/proxy/reactive.ts +69 -0
- package/src/internal/proxy/schema-validator.ts +244 -0
- package/src/internal/proxy/schema.test.ts +27 -18
- package/src/internal/proxy/symbols.ts +7 -0
- package/src/internal/proxy/typed-handler.test.ts +260 -48
- package/src/internal/proxy/typed-handler.ts +275 -61
- package/src/internal/proxy/typed-object.test.ts +54 -38
- package/src/internal/ref/ref-array.ts +4 -4
- package/src/internal/ref/ref.test.ts +10 -9
- package/src/internal/ref/ref.ts +83 -55
- package/src/internal/{projection → schema}/compose.test.ts +8 -9
- package/src/internal/{projection → schema}/compose.ts +13 -8
- package/src/internal/schema/echo-schema.ts +73 -33
- package/src/internal/schema/index.ts +1 -4
- package/src/internal/schema/manipulation.ts +1 -1
- package/src/internal/schema/persistent-schema.ts +27 -0
- package/src/internal/types/base.ts +43 -0
- package/src/internal/types/entity.ts +54 -0
- package/src/internal/types/index.ts +5 -2
- package/src/internal/types/meta.ts +65 -0
- package/src/internal/types/typename.ts +45 -0
- package/src/internal/types/version.ts +20 -0
- package/src/testing/api.test.ts +126 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +238 -0
- package/src/testing/util.ts +85 -0
- package/dist/lib/browser/chunk-JUTFUT73.mjs +0 -175
- package/dist/lib/browser/chunk-JUTFUT73.mjs.map +0 -7
- package/dist/lib/browser/chunk-KEBVBR65.mjs +0 -3727
- package/dist/lib/browser/chunk-KEBVBR65.mjs.map +0 -7
- package/dist/lib/browser/chunk-WO76TDT6.mjs +0 -814
- package/dist/lib/browser/chunk-WO76TDT6.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -35
- package/dist/lib/browser/internal/index.mjs +0 -336
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/query/index.mjs +0 -15
- package/dist/lib/browser/testing/index.mjs +0 -283
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DWZYQ2UR.mjs +0 -3727
- package/dist/lib/node-esm/chunk-DWZYQ2UR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KBD3A2I6.mjs +0 -175
- package/dist/lib/node-esm/chunk-KBD3A2I6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZSSII3JW.mjs +0 -814
- package/dist/lib/node-esm/chunk-ZSSII3JW.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -35
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/query/index.mjs +0 -15
- package/dist/lib/node-esm/testing/index.mjs +0 -283
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/errors.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotation-helper.d.ts +0 -8
- package/dist/types/src/internal/ast/annotation-helper.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.d.ts +0 -131
- package/dist/types/src/internal/ast/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/ast/annotations.test.d.ts.map +0 -1
- package/dist/types/src/internal/ast/entity-kind.d.ts +0 -10
- package/dist/types/src/internal/ast/entity-kind.d.ts.map +0 -1
- package/dist/types/src/internal/ast/index.d.ts +0 -5
- package/dist/types/src/internal/ast/index.d.ts.map +0 -1
- package/dist/types/src/internal/ast/types.d.ts +0 -6
- package/dist/types/src/internal/ast/types.d.ts.map +0 -1
- package/dist/types/src/internal/json/annotations.d.ts.map +0 -1
- package/dist/types/src/internal/json/effect-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/json/index.d.ts +0 -2
- package/dist/types/src/internal/json/index.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.d.ts.map +0 -1
- package/dist/types/src/internal/json/json-schema.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/accessors.d.ts +0 -37
- package/dist/types/src/internal/object/accessors.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.d.ts.map +0 -1
- package/dist/types/src/internal/object/create.test.d.ts +0 -2
- package/dist/types/src/internal/object/create.test.d.ts.map +0 -1
- package/dist/types/src/internal/object/entity.d.ts +0 -33
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- package/dist/types/src/internal/object/expando.d.ts +0 -14
- package/dist/types/src/internal/object/expando.d.ts.map +0 -1
- package/dist/types/src/internal/object/meta.d.ts.map +0 -1
- package/dist/types/src/internal/object/model.d.ts +0 -117
- package/dist/types/src/internal/object/model.d.ts.map +0 -1
- package/dist/types/src/internal/object/relation.d.ts +0 -17
- package/dist/types/src/internal/object/relation.d.ts.map +0 -1
- package/dist/types/src/internal/object/typename.d.ts +0 -15
- package/dist/types/src/internal/object/typename.d.ts.map +0 -1
- package/dist/types/src/internal/object/version.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.d.ts +0 -6
- package/dist/types/src/internal/projection/compose.d.ts.map +0 -1
- package/dist/types/src/internal/projection/compose.test.d.ts.map +0 -1
- package/dist/types/src/internal/projection/index.d.ts +0 -2
- package/dist/types/src/internal/projection/index.d.ts.map +0 -1
- package/dist/types/src/internal/proxy/reactive-object.d.ts +0 -15
- package/dist/types/src/internal/proxy/reactive-object.d.ts.map +0 -1
- package/dist/types/src/internal/query/index.d.ts +0 -2
- package/dist/types/src/internal/query/index.d.ts.map +0 -1
- package/dist/types/src/internal/query/query.d.ts +0 -17
- package/dist/types/src/internal/query/query.d.ts.map +0 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +0 -18
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +0 -1
- package/dist/types/src/internal/schema/snapshot.d.ts +0 -6
- package/dist/types/src/internal/schema/snapshot.d.ts.map +0 -1
- package/dist/types/src/internal/schema/stored-schema.d.ts +0 -13
- package/dist/types/src/internal/schema/stored-schema.d.ts.map +0 -1
- package/dist/types/src/internal/testing/index.d.ts +0 -3
- package/dist/types/src/internal/testing/index.d.ts.map +0 -1
- package/dist/types/src/internal/testing/types.d.ts +0 -455
- package/dist/types/src/internal/testing/types.d.ts.map +0 -1
- package/dist/types/src/internal/testing/utils.d.ts +0 -10
- package/dist/types/src/internal/testing/utils.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.d.ts +0 -79
- package/dist/types/src/internal/types/types.d.ts.map +0 -1
- package/dist/types/src/internal/types/types.test.d.ts +0 -2
- package/dist/types/src/internal/types/types.test.d.ts.map +0 -1
- package/dist/types/src/internal/types/util.d.ts +0 -5
- package/dist/types/src/internal/types/util.d.ts.map +0 -1
- package/dist/types/src/query/index.d.ts +0 -3
- package/dist/types/src/query/index.d.ts.map +0 -1
- package/dist/types/src/query/query.d.ts +0 -248
- package/dist/types/src/query/query.d.ts.map +0 -1
- package/dist/types/src/query/query.test.d.ts +0 -2
- package/dist/types/src/query/query.test.d.ts.map +0 -1
- package/dist/types/src/query/tag.d.ts +0 -17
- package/dist/types/src/query/tag.d.ts.map +0 -1
- package/dist/types/src/testing/echo-schema.d.ts +0 -7
- package/dist/types/src/testing/echo-schema.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -113
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/src/internal/ast/annotation-helper.ts +0 -22
- package/src/internal/ast/annotations.ts +0 -226
- package/src/internal/ast/entity-kind.ts +0 -15
- package/src/internal/ast/index.ts +0 -8
- package/src/internal/ast/types.ts +0 -17
- package/src/internal/json/index.ts +0 -5
- package/src/internal/object/accessors.ts +0 -153
- package/src/internal/object/entity.ts +0 -248
- package/src/internal/object/expando.ts +0 -21
- package/src/internal/object/meta.ts +0 -61
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typename.ts +0 -61
- package/src/internal/object/version.ts +0 -22
- package/src/internal/projection/index.ts +0 -5
- package/src/internal/proxy/reactive-object.ts +0 -108
- package/src/internal/query/index.ts +0 -5
- package/src/internal/query/query.ts +0 -23
- package/src/internal/schema/runtime-schema-registry.ts +0 -78
- package/src/internal/schema/snapshot.ts +0 -25
- package/src/internal/schema/stored-schema.ts +0 -26
- package/src/internal/testing/index.ts +0 -6
- package/src/internal/testing/types.ts +0 -211
- package/src/internal/testing/utils.ts +0 -54
- package/src/internal/types/types.test.ts +0 -48
- package/src/internal/types/types.ts +0 -176
- package/src/internal/types/util.ts +0 -9
- package/src/query/index.ts +0 -6
- package/src/query/query.test.ts +0 -401
- package/src/query/query.ts +0 -789
- package/src/test/api.test.ts +0 -180
- package/src/testing/echo-schema.ts +0 -39
- package/src/testing/types.ts +0 -91
- /package/dist/lib/{browser/index.mjs.map → neutral/Annotation.mjs.map} +0 -0
- /package/dist/lib/{browser/internal/index.mjs.map → neutral/Database.mjs.map} +0 -0
- /package/dist/lib/{browser/query/index.mjs.map → neutral/Entity.mjs.map} +0 -0
- /package/dist/lib/{node-esm/index.mjs.map → neutral/Err.mjs.map} +0 -0
- /package/dist/lib/{node-esm/internal/index.mjs.map → neutral/Filter.mjs.map} +0 -0
- /package/dist/lib/{node-esm/query/index.mjs.map → neutral/Format.mjs.map} +0 -0
- /package/dist/types/src/internal/{ast → annotations}/annotations.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/annotations.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/effect-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{json → json-schema}/json-schema.test.d.ts +0 -0
- /package/dist/types/src/internal/{projection → schema}/compose.test.d.ts +0 -0
- /package/dist/types/src/{test → testing}/api.test.d.ts +0 -0
- /package/src/internal/{json → json-schema}/effect-schema.test.ts +0 -0
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Kinds of entities stored in ECHO: objects and relations.
|
|
9
|
-
*/
|
|
10
|
-
export enum EntityKind {
|
|
11
|
-
Object = 'object',
|
|
12
|
-
Relation = 'relation',
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const EntityKindSchema = Schema.Enums(EntityKind);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { PropertyMeta } from './annotations';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export const FIELD_PATH_ANNOTATION = 'path';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Sets the path for the field.
|
|
14
|
-
* @param path Data source path in the json path format. This is the field path in the source object.
|
|
15
|
-
*/
|
|
16
|
-
// TODO(burdon): Field, vs. path vs. property.
|
|
17
|
-
export const FieldPath = (path: string) => PropertyMeta(FIELD_PATH_ANNOTATION, path);
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Option from 'effect/Option';
|
|
6
|
-
import * as Schema from 'effect/Schema';
|
|
7
|
-
|
|
8
|
-
import { type JsonPath, getField } from '@dxos/effect';
|
|
9
|
-
import { assertArgument, invariant } from '@dxos/invariant';
|
|
10
|
-
import { DXN, ObjectId } from '@dxos/keys';
|
|
11
|
-
import { assumeType } from '@dxos/util';
|
|
12
|
-
|
|
13
|
-
import { DescriptionAnnotation, LabelAnnotation } from '../ast';
|
|
14
|
-
|
|
15
|
-
import { type InternalObjectProps, SchemaId, SelfDXNId } from './model';
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
// Accessors based on model.
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Returns a DXN for an object or schema.
|
|
23
|
-
* @deprecated Use `Obj.getDXN`.
|
|
24
|
-
*/
|
|
25
|
-
export const getObjectDXN = (object: any): DXN | undefined => {
|
|
26
|
-
invariant(!Schema.isSchema(object), 'schema not allowed in this function');
|
|
27
|
-
assertArgument(typeof object === 'object' && object != null, 'object', 'expected object');
|
|
28
|
-
assumeType<InternalObjectProps>(object);
|
|
29
|
-
|
|
30
|
-
if (object[SelfDXNId]) {
|
|
31
|
-
invariant(object[SelfDXNId] instanceof DXN, 'Invalid object model: invalid self dxn');
|
|
32
|
-
return object[SelfDXNId];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!ObjectId.isValid(object.id)) {
|
|
36
|
-
throw new TypeError('Object id is not valid.');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return DXN.fromLocalObjectId(object.id);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Returns the schema for the given object if one is defined.
|
|
44
|
-
*/
|
|
45
|
-
// TODO(burdon): Reconcile with `getTypename`.
|
|
46
|
-
// TODO(dmaretskyi): For echo objects, this always returns the root schema.
|
|
47
|
-
export const getSchema = (obj: unknown | undefined): Schema.Schema.AnyNoContext | undefined => {
|
|
48
|
-
if (obj) {
|
|
49
|
-
return (obj as any)[SchemaId];
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Internal use only.
|
|
55
|
-
*/
|
|
56
|
-
export const setSchema = (obj: any, schema: Schema.Schema.AnyNoContext) => {
|
|
57
|
-
Object.defineProperty(obj, SchemaId, {
|
|
58
|
-
value: schema,
|
|
59
|
-
writable: false,
|
|
60
|
-
enumerable: false,
|
|
61
|
-
configurable: false,
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated Use {@link Obj.getLabel} instead.
|
|
67
|
-
* Returns the label for a given object based on {@link LabelAnnotationId}.
|
|
68
|
-
*/
|
|
69
|
-
export const getLabelForObject = (obj: unknown | undefined): string | undefined => {
|
|
70
|
-
const schema = getSchema(obj);
|
|
71
|
-
if (schema) {
|
|
72
|
-
return getLabel(schema, obj);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Returns the label for a given object based on {@link LabelAnnotationId}.
|
|
78
|
-
*/
|
|
79
|
-
// TODO(burdon): Convert to JsonPath?
|
|
80
|
-
export const getLabel = <S extends Schema.Schema.Any>(schema: S, object: Schema.Schema.Type<S>): string | undefined => {
|
|
81
|
-
const annotation = LabelAnnotation.get(schema).pipe(Option.getOrElse(() => ['name']));
|
|
82
|
-
for (const accessor of annotation) {
|
|
83
|
-
assertArgument(
|
|
84
|
-
typeof accessor === 'string',
|
|
85
|
-
'accessor',
|
|
86
|
-
'Label annotation must be a string or an array of strings',
|
|
87
|
-
);
|
|
88
|
-
const value = getField(object, accessor as JsonPath);
|
|
89
|
-
switch (typeof value) {
|
|
90
|
-
case 'string':
|
|
91
|
-
case 'number':
|
|
92
|
-
case 'boolean':
|
|
93
|
-
case 'bigint':
|
|
94
|
-
case 'symbol':
|
|
95
|
-
return value.toString();
|
|
96
|
-
case 'undefined':
|
|
97
|
-
case 'object':
|
|
98
|
-
case 'function':
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return undefined;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Sets the label for a given object based on {@link LabelAnnotationId}.
|
|
108
|
-
*/
|
|
109
|
-
export const setLabel = <S extends Schema.Schema.Any>(schema: S, object: Schema.Schema.Type<S>, label: string) => {
|
|
110
|
-
const annotation = LabelAnnotation.get(schema).pipe(
|
|
111
|
-
Option.map((field) => field[0]),
|
|
112
|
-
Option.getOrElse(() => 'name'),
|
|
113
|
-
);
|
|
114
|
-
object[annotation] = label;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Returns the label for a given object based on {@link LabelAnnotationId}.
|
|
119
|
-
*/
|
|
120
|
-
// TODO(burdon): Convert to JsonPath?
|
|
121
|
-
export const getDescription = <S extends Schema.Schema.Any>(
|
|
122
|
-
schema: S,
|
|
123
|
-
object: Schema.Schema.Type<S>,
|
|
124
|
-
): string | undefined => {
|
|
125
|
-
const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));
|
|
126
|
-
assertArgument(typeof accessor === 'string', 'accessor', 'Description annotation must be a string');
|
|
127
|
-
const value = getField(object, accessor as JsonPath);
|
|
128
|
-
switch (typeof value) {
|
|
129
|
-
case 'string':
|
|
130
|
-
case 'number':
|
|
131
|
-
case 'boolean':
|
|
132
|
-
case 'bigint':
|
|
133
|
-
case 'symbol':
|
|
134
|
-
return value.toString();
|
|
135
|
-
case 'undefined':
|
|
136
|
-
case 'object':
|
|
137
|
-
case 'function':
|
|
138
|
-
default:
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Sets the description for a given object based on {@link DescriptionAnnotationId}.
|
|
145
|
-
*/
|
|
146
|
-
export const setDescription = <S extends Schema.Schema.Any>(
|
|
147
|
-
schema: S,
|
|
148
|
-
object: Schema.Schema.Type<S>,
|
|
149
|
-
description: string,
|
|
150
|
-
) => {
|
|
151
|
-
const accessor = DescriptionAnnotation.get(schema).pipe(Option.getOrElse(() => 'description'));
|
|
152
|
-
object[accessor] = description;
|
|
153
|
-
};
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
import * as SchemaAST from 'effect/SchemaAST';
|
|
7
|
-
import type * as Types from 'effect/Types';
|
|
8
|
-
|
|
9
|
-
import { raise } from '@dxos/debug';
|
|
10
|
-
import { assertArgument, invariant } from '@dxos/invariant';
|
|
11
|
-
import { DXN } from '@dxos/keys';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
EntityKind,
|
|
15
|
-
type TypeAnnotation,
|
|
16
|
-
TypeAnnotationId,
|
|
17
|
-
type TypeMeta,
|
|
18
|
-
getEntityKind,
|
|
19
|
-
getSchemaTypename,
|
|
20
|
-
getTypeIdentifierAnnotation,
|
|
21
|
-
} from '../ast';
|
|
22
|
-
import { type HasId, type ToMutable } from '../types';
|
|
23
|
-
|
|
24
|
-
import { type RelationSourceTargetRefs } from './relation';
|
|
25
|
-
|
|
26
|
-
// TODO(burdon): Define Schema type for `typename` and use consistently for all DXN-like properties.
|
|
27
|
-
|
|
28
|
-
// type RequiredKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? never : K }[keyof T];
|
|
29
|
-
type EchoTypeSchemaProps<T, ExtraFields = {}> = Types.Simplify<HasId & ToMutable<T> & ExtraFields>;
|
|
30
|
-
|
|
31
|
-
export interface EchoTypeSchema<Self extends Schema.Schema.Any, ExtraFields = {}>
|
|
32
|
-
extends TypeMeta,
|
|
33
|
-
Schema.AnnotableClass<
|
|
34
|
-
EchoTypeSchema<Self, ExtraFields>,
|
|
35
|
-
EchoTypeSchemaProps<Schema.Schema.Type<Self>, ExtraFields>,
|
|
36
|
-
EchoTypeSchemaProps<Schema.Schema.Encoded<Self>, ExtraFields>,
|
|
37
|
-
Schema.Schema.Context<Self>
|
|
38
|
-
> {
|
|
39
|
-
// make(
|
|
40
|
-
// props: RequiredKeys<Schema.TypeLiteral.Constructor<Fields, []>> extends never
|
|
41
|
-
// ? void | Simplify<Schema.TypeLiteral.Constructor<Fields, []>>
|
|
42
|
-
// : Simplify<Schema.TypeLiteral.Constructor<Fields, []>>,
|
|
43
|
-
// options?: MakeOptions,
|
|
44
|
-
// ): Simplify<Schema.TypeLiteral.Type<Fields, []>>;
|
|
45
|
-
|
|
46
|
-
instanceOf(value: unknown): boolean;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Pipeable function to add ECHO object annotations to a schema.
|
|
51
|
-
*/
|
|
52
|
-
// TODO(dmaretskyi): Rename EchoObjectSchema.
|
|
53
|
-
export const EchoObject: {
|
|
54
|
-
// TODO(burdon): Tighten Self type to Schema.TypeLiteral or Schema.Struct to facilitate definition of `make` method.
|
|
55
|
-
// (meta: TypeMeta): <Self extends Schema.Struct<Fields>, Fields extends Schema.Struct.Fields>(self: Self) => EchoObjectSchema<Self, Fields>;
|
|
56
|
-
(meta: TypeMeta): <Self extends Schema.Schema.Any>(self: Self) => EchoTypeSchema<Self>;
|
|
57
|
-
} = ({ typename, version }) => {
|
|
58
|
-
return <Self extends Schema.Schema.Any>(self: Self): EchoTypeSchema<Self> => {
|
|
59
|
-
invariant(typeof TypeAnnotationId === 'symbol', 'Sanity.');
|
|
60
|
-
invariant(SchemaAST.isTypeLiteral(self.ast), 'Schema must be a TypeLiteral.');
|
|
61
|
-
|
|
62
|
-
// TODO(dmaretskyi): Does `Schema.mutable` work for deep mutability here?
|
|
63
|
-
// TODO(dmaretskyi): Do not do mutable here.
|
|
64
|
-
const schemaWithId = Schema.extend(Schema.mutable(self), Schema.Struct({ id: Schema.String }));
|
|
65
|
-
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
66
|
-
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
67
|
-
...self.ast.annotations,
|
|
68
|
-
[TypeAnnotationId]: { kind: EntityKind.Object, typename, version } satisfies TypeAnnotation,
|
|
69
|
-
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
70
|
-
[SchemaAST.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
71
|
-
kind: EntityKind.Object,
|
|
72
|
-
typename,
|
|
73
|
-
version,
|
|
74
|
-
}),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return makeEchoObjectSchema<Self>(/* self.fields, */ ast, typename, version);
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export type EchoRelationOptions<
|
|
82
|
-
TSource extends Schema.Schema.AnyNoContext,
|
|
83
|
-
TTarget extends Schema.Schema.AnyNoContext,
|
|
84
|
-
> = TypeMeta & {
|
|
85
|
-
source: TSource;
|
|
86
|
-
target: TTarget;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// TODO(dmaretskyi): Rename EchoRelationSchema.
|
|
90
|
-
export const EchoRelation = <Source extends Schema.Schema.AnyNoContext, Target extends Schema.Schema.AnyNoContext>(
|
|
91
|
-
options: EchoRelationOptions<Source, Target>,
|
|
92
|
-
) => {
|
|
93
|
-
assertArgument(Schema.isSchema(options.source), 'source');
|
|
94
|
-
assertArgument(Schema.isSchema(options.target), 'target');
|
|
95
|
-
const sourceDXN = getDXNForRelationSchemaRef(options.source);
|
|
96
|
-
const targetDXN = getDXNForRelationSchemaRef(options.target);
|
|
97
|
-
if (getEntityKind(options.source) !== EntityKind.Object) {
|
|
98
|
-
raise(new Error('Source schema must be an echo object schema.'));
|
|
99
|
-
}
|
|
100
|
-
if (getEntityKind(options.target) !== EntityKind.Object) {
|
|
101
|
-
raise(new Error('Target schema must be an echo object schema.'));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return <Self extends Schema.Schema.Any>(
|
|
105
|
-
self: Self,
|
|
106
|
-
): EchoTypeSchema<Self, RelationSourceTargetRefs<Schema.Schema.Type<Source>, Schema.Schema.Type<Target>>> => {
|
|
107
|
-
invariant(SchemaAST.isTypeLiteral(self.ast), 'Schema must be a TypeLiteral.');
|
|
108
|
-
|
|
109
|
-
// TODO(dmaretskyi): Does `Schema.mutable` work for deep mutability here?
|
|
110
|
-
// TODO(dmaretskyi): Do not do mutable here.
|
|
111
|
-
const schemaWithId = Schema.extend(Schema.mutable(self), Schema.Struct({ id: Schema.String }));
|
|
112
|
-
const ast = SchemaAST.annotations(schemaWithId.ast, {
|
|
113
|
-
// TODO(dmaretskyi): `extend` kills the annotations.
|
|
114
|
-
...self.ast.annotations,
|
|
115
|
-
[TypeAnnotationId]: {
|
|
116
|
-
kind: EntityKind.Relation,
|
|
117
|
-
typename: options.typename,
|
|
118
|
-
version: options.version,
|
|
119
|
-
sourceSchema: sourceDXN,
|
|
120
|
-
targetSchema: targetDXN,
|
|
121
|
-
} satisfies TypeAnnotation,
|
|
122
|
-
// TODO(dmaretskyi): TypeIdentifierAnnotationId?
|
|
123
|
-
|
|
124
|
-
[SchemaAST.JSONSchemaAnnotationId]: makeTypeJsonSchemaAnnotation({
|
|
125
|
-
kind: EntityKind.Relation,
|
|
126
|
-
typename: options.typename,
|
|
127
|
-
version: options.version,
|
|
128
|
-
relationSource: sourceDXN,
|
|
129
|
-
relationTarget: targetDXN,
|
|
130
|
-
}),
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
return makeEchoObjectSchema<Self>(/* self.fields, */ ast, options.typename, options.version);
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @returns JSON-schema annotation so that the schema can be serialized with correct parameters.
|
|
139
|
-
*/
|
|
140
|
-
export const makeTypeJsonSchemaAnnotation = (options: {
|
|
141
|
-
identifier?: string;
|
|
142
|
-
kind: EntityKind;
|
|
143
|
-
typename: string;
|
|
144
|
-
version: string;
|
|
145
|
-
relationSource?: string;
|
|
146
|
-
relationTarget?: string;
|
|
147
|
-
}) => {
|
|
148
|
-
assertArgument(!!options.relationSource === (options.kind === EntityKind.Relation), 'relationSource');
|
|
149
|
-
assertArgument(!!options.relationTarget === (options.kind === EntityKind.Relation), 'relationTarget');
|
|
150
|
-
|
|
151
|
-
const obj = {
|
|
152
|
-
// TODO(dmaretskyi): Should this include the version?
|
|
153
|
-
$id: options.identifier ?? DXN.fromTypename(options.typename).toString(),
|
|
154
|
-
entityKind: options.kind,
|
|
155
|
-
version: options.version,
|
|
156
|
-
typename: options.typename,
|
|
157
|
-
} as any;
|
|
158
|
-
if (options.kind === EntityKind.Relation) {
|
|
159
|
-
obj.relationSource = { $ref: options.relationSource };
|
|
160
|
-
obj.relationTarget = { $ref: options.relationTarget };
|
|
161
|
-
}
|
|
162
|
-
return obj;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const getDXNForRelationSchemaRef = (schema: Schema.Schema.Any): string => {
|
|
166
|
-
assertArgument(Schema.isSchema(schema), 'schema');
|
|
167
|
-
const identifier = getTypeIdentifierAnnotation(schema);
|
|
168
|
-
if (identifier) {
|
|
169
|
-
return identifier;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const typename = getSchemaTypename(schema);
|
|
173
|
-
if (!typename) {
|
|
174
|
-
throw new Error('Schema must have a typename');
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return DXN.fromTypename(typename).toString();
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
// type MakeOptions =
|
|
181
|
-
// | boolean
|
|
182
|
-
// | {
|
|
183
|
-
// readonly disableValidation?: boolean;
|
|
184
|
-
// };
|
|
185
|
-
|
|
186
|
-
// NOTE: Utils copied from Effect `Schema.ts`.
|
|
187
|
-
// const _ownKeys = (o: object): Array<PropertyKey> =>
|
|
188
|
-
// (Object.keys(o) as Array<PropertyKey>).concat(Object.getOwnPropertySymbols(o));
|
|
189
|
-
|
|
190
|
-
// const _lazilyMergeDefaults = (
|
|
191
|
-
// fields: Schema.Struct.Fields,
|
|
192
|
-
// out: Record<PropertyKey, unknown>,
|
|
193
|
-
// ): { [x: string | symbol]: unknown } => {
|
|
194
|
-
// const ownKeys = _ownKeys(fields);
|
|
195
|
-
// for (const key of ownKeys) {
|
|
196
|
-
// const field = fields[key];
|
|
197
|
-
// if (out[key] === undefined && Schema.isPropertySignature(field)) {
|
|
198
|
-
// const ast = field.ast;
|
|
199
|
-
// const defaultValue = ast._tag === 'PropertySignatureDeclaration' ? ast.defaultValue : ast.to.defaultValue;
|
|
200
|
-
// if (defaultValue !== undefined) {
|
|
201
|
-
// out[key] = defaultValue();
|
|
202
|
-
// }
|
|
203
|
-
// }
|
|
204
|
-
// }
|
|
205
|
-
// return out;
|
|
206
|
-
// };
|
|
207
|
-
|
|
208
|
-
// const _getDisableValidationMakeOption = (options: MakeOptions | undefined): boolean =>
|
|
209
|
-
// Predicate.isBoolean(options) ? options : options?.disableValidation ?? false;
|
|
210
|
-
|
|
211
|
-
const makeEchoObjectSchema = <Self extends Schema.Schema.Any>(
|
|
212
|
-
// fields: Fields,
|
|
213
|
-
ast: SchemaAST.AST,
|
|
214
|
-
typename: string,
|
|
215
|
-
version: string,
|
|
216
|
-
): EchoTypeSchema<Self> => {
|
|
217
|
-
return class EchoObjectSchemaClass extends Schema.make<
|
|
218
|
-
EchoTypeSchemaProps<Schema.Schema.Type<Self>>,
|
|
219
|
-
EchoTypeSchemaProps<Schema.Schema.Encoded<Self>>,
|
|
220
|
-
Schema.Schema.Context<Self>
|
|
221
|
-
>(ast) {
|
|
222
|
-
static readonly typename = typename;
|
|
223
|
-
static readonly version = version;
|
|
224
|
-
|
|
225
|
-
static override annotations(
|
|
226
|
-
annotations: Schema.Annotations.GenericSchema<EchoTypeSchemaProps<Schema.Schema.Type<Self>>>,
|
|
227
|
-
): EchoTypeSchema<Self> {
|
|
228
|
-
const schema = Schema.make<EchoTypeSchemaProps<Schema.Schema.Type<Self>>>(ast).annotations(annotations);
|
|
229
|
-
return makeEchoObjectSchema<Self>(/* fields, */ schema.ast, typename, version);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// static make(
|
|
233
|
-
// props: RequiredKeys<Schema.TypeLiteral.Constructor<Fields, []>> extends never
|
|
234
|
-
// ? void | Simplify<Schema.TypeLiteral.Constructor<Fields, []>>
|
|
235
|
-
// : Simplify<Schema.TypeLiteral.Constructor<Fields, []>>,
|
|
236
|
-
// options?: MakeOptions,
|
|
237
|
-
// ): Simplify<Schema.TypeLiteral.Type<Fields, []>> {
|
|
238
|
-
// const propsWithDefaults: any = _lazilyMergeDefaults(fields, { ...(props as any) });
|
|
239
|
-
// return _getDisableValidationMakeOption(options)
|
|
240
|
-
// ? propsWithDefaults
|
|
241
|
-
// : ParseResult.validateSync(this)(propsWithDefaults);
|
|
242
|
-
// }
|
|
243
|
-
|
|
244
|
-
static instanceOf(value: unknown): boolean {
|
|
245
|
-
return Schema.is(this)(value);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
|
|
7
|
-
import { EchoObject } from './entity';
|
|
8
|
-
|
|
9
|
-
export const EXPANDO_TYPENAME = 'dxos.org/type/Expando';
|
|
10
|
-
|
|
11
|
-
const ExpandoSchema = Schema.Struct({}, { key: Schema.String, value: Schema.Any }).pipe(
|
|
12
|
-
EchoObject({ typename: EXPANDO_TYPENAME, version: '0.1.0' }),
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Expando object is an object with an arbitrary set of properties.
|
|
17
|
-
*/
|
|
18
|
-
// TODO(dmaretskyi): Can we consider expando a top-type, i.e. have a ref to expando potentially be a valid ref to any object?
|
|
19
|
-
export interface Expando extends Schema.Schema.Type<typeof ExpandoSchema> {}
|
|
20
|
-
|
|
21
|
-
export const Expando: Schema.Schema<Expando> = ExpandoSchema;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import * as Schema from 'effect/Schema';
|
|
6
|
-
|
|
7
|
-
import { ForeignKey } from '@dxos/echo-protocol';
|
|
8
|
-
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { type Comparator, intersection } from '@dxos/util';
|
|
10
|
-
|
|
11
|
-
import { type BaseObject } from '../types';
|
|
12
|
-
|
|
13
|
-
import { MetaId } from './model';
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
// ObjectMeta
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
// TODO(dmaretskyi): Rename to ObjectMeta
|
|
20
|
-
export const ObjectMetaSchema = Schema.mutable(
|
|
21
|
-
Schema.Struct({
|
|
22
|
-
keys: Schema.mutable(Schema.Array(ForeignKey)),
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A set of tags.
|
|
26
|
-
* Tags are arbitrary application-defined strings.
|
|
27
|
-
* ECHO makes no assumptions about the tag structure.
|
|
28
|
-
*/
|
|
29
|
-
// TODO(dmaretskyi): Has to be optional for compatibility with old data.
|
|
30
|
-
// Defaulting to an empty array is possible but requires a bit more work.
|
|
31
|
-
tags: Schema.optional(Schema.mutable(Schema.Array(Schema.String))),
|
|
32
|
-
}),
|
|
33
|
-
);
|
|
34
|
-
export type ObjectMeta = Schema.Schema.Type<typeof ObjectMetaSchema>;
|
|
35
|
-
|
|
36
|
-
export const foreignKey = (source: string, id: string): ForeignKey => ({ source, id });
|
|
37
|
-
export const foreignKeyEquals = (a: ForeignKey, b: ForeignKey) => a.source === b.source && a.id === b.id;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get metadata from object.
|
|
41
|
-
* Only callable on the object root.
|
|
42
|
-
* @deprecated Use {@link getMeta}.
|
|
43
|
-
*/
|
|
44
|
-
// TODO(dmaretskyi): Remove.
|
|
45
|
-
export const getObjectMeta = (obj: any): ObjectMeta => {
|
|
46
|
-
return getMeta(obj);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/*
|
|
50
|
-
* Get metadata from object.
|
|
51
|
-
* Only callable on the object root.
|
|
52
|
-
*/
|
|
53
|
-
export const getMeta = (obj: BaseObject): ObjectMeta => {
|
|
54
|
-
const metadata = (obj as any)[MetaId];
|
|
55
|
-
invariant(metadata, 'ObjectMeta not found.');
|
|
56
|
-
return metadata;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// TODO(dmaretskyi): Move to echo-schema.
|
|
60
|
-
export const compareForeignKeys: Comparator<BaseObject> = (a: BaseObject, b: BaseObject) =>
|
|
61
|
-
intersection(getMeta(a).keys, getMeta(b).keys, foreignKeyEquals).length > 0;
|