@dxos/echo 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d
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/browser/{chunk-MWLA34S5.mjs → chunk-7GH6RXJ3.mjs} +2513 -2673
- package/dist/lib/browser/chunk-7GH6RXJ3.mjs.map +7 -0
- package/dist/lib/browser/chunk-E4UTVJNF.mjs +1111 -0
- package/dist/lib/browser/chunk-E4UTVJNF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -19
- package/dist/lib/browser/internal/index.mjs +55 -45
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +247 -217
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs +1111 -0
- package/dist/lib/node-esm/chunk-JE5RXM2I.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YTNLFBIK.mjs → chunk-M4B6BMD2.mjs} +2513 -2673
- package/dist/lib/node-esm/chunk-M4B6BMD2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -19
- package/dist/lib/node-esm/internal/index.mjs +55 -45
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +247 -217
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- 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 +137 -0
- package/dist/types/src/Database.d.ts.map +1 -0
- package/dist/types/src/Entity.d.ts +36 -0
- package/dist/types/src/Entity.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/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 +85 -62
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +10 -10
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +14 -11
- package/dist/types/src/Relation.d.ts.map +1 -1
- 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 +39 -49
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/errors.d.ts +14 -18
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +7 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/annotations/annotations.d.ts +174 -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 +26 -0
- package/dist/types/src/internal/annotations/util.d.ts.map +1 -0
- package/dist/types/src/internal/entities/entity.d.ts +10 -0
- package/dist/types/src/internal/entities/entity.d.ts.map +1 -0
- package/dist/types/src/internal/{object → entities}/expando.d.ts +3 -1
- package/dist/types/src/internal/entities/expando.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 +70 -0
- package/dist/types/src/internal/entities/model.d.ts.map +1 -0
- package/dist/types/src/internal/entities/object.d.ts +11 -0
- package/dist/types/src/internal/entities/object.d.ts.map +1 -0
- package/dist/types/src/internal/entities/relation.d.ts +55 -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 +2 -0
- package/dist/types/src/internal/formats/format.d.ts.map +1 -1
- package/dist/types/src/internal/formats/types.d.ts +7 -7
- package/dist/types/src/internal/formats/types.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +6 -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-type.d.ts.map +1 -1
- package/dist/types/src/internal/{json → json-schema}/json-schema.d.ts +2 -5
- 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/common.d.ts.map +1 -1
- package/dist/types/src/internal/object/{create.d.ts → create-object.d.ts} +9 -10
- 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 +3 -12
- package/dist/types/src/internal/object/index.d.ts.map +1 -1
- package/dist/types/src/internal/object/json-serializer.d.ts +1 -2
- package/dist/types/src/internal/object/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/object/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/object/typed-object.d.ts +1 -1
- package/dist/types/src/internal/object/typed-object.d.ts.map +1 -1
- package/dist/types/src/internal/proxy/index.d.ts +3 -0
- package/dist/types/src/internal/proxy/index.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/make-object.d.ts +16 -0
- package/dist/types/src/internal/proxy/make-object.d.ts.map +1 -0
- package/dist/types/src/internal/proxy/typed-handler.d.ts +1 -1
- package/dist/types/src/internal/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/ref/ref.d.ts +15 -12
- package/dist/types/src/internal/ref/ref.d.ts.map +1 -1
- 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 +9 -9
- package/dist/types/src/internal/schema/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/schema/index.d.ts +3 -4
- package/dist/types/src/internal/schema/index.d.ts.map +1 -1
- package/dist/types/src/internal/schema/manipulation.d.ts.map +1 -1
- package/dist/types/src/internal/schema/persistent-schema.d.ts +18 -0
- package/dist/types/src/internal/schema/persistent-schema.d.ts.map +1 -0
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts +1 -1
- package/dist/types/src/internal/schema/runtime-schema-registry.d.ts.map +1 -1
- package/dist/types/src/internal/types/base.d.ts +37 -0
- package/dist/types/src/internal/types/base.d.ts.map +1 -0
- package/dist/types/src/internal/{ast/entity-kind.d.ts → types/entity.d.ts} +3 -1
- 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 +20 -11
- 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/query/filter.d.ts +167 -0
- package/dist/types/src/query/filter.d.ts.map +1 -0
- package/dist/types/src/query/index.d.ts +3 -1
- package/dist/types/src/query/index.d.ts.map +1 -1
- package/dist/types/src/query/order.d.ts +12 -0
- package/dist/types/src/query/order.d.ts.map +1 -0
- package/dist/types/src/query/query.d.ts +9 -144
- package/dist/types/src/query/query.d.ts.map +1 -1
- package/dist/types/src/query/testing.d.ts +51 -0
- package/dist/types/src/query/testing.d.ts.map +1 -0
- package/dist/types/src/{internal/query/query.d.ts → query/types.d.ts} +1 -1
- package/dist/types/src/query/types.d.ts.map +1 -0
- package/dist/types/src/query/util.d.ts +8 -0
- package/dist/types/src/query/util.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 +337 -0
- package/dist/types/src/testing/test-schema.d.ts.map +1 -0
- package/dist/types/src/{internal/testing/utils.d.ts → testing/util.d.ts} +11 -5
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -38
- package/src/Annotation.ts +17 -0
- package/src/Database.ts +189 -0
- package/src/Entity.ts +51 -0
- package/src/Format.ts +11 -0
- package/src/JsonSchema.ts +16 -0
- package/src/Key.ts +3 -0
- package/src/Obj.ts +260 -147
- package/src/Ref.ts +9 -9
- package/src/Relation.ts +58 -44
- package/src/Tag.ts +40 -0
- package/src/Type.ts +96 -83
- package/src/index.ts +10 -4
- package/src/internal/README.md +83 -0
- package/src/internal/{ast → annotations}/annotations.test.ts +13 -15
- package/src/internal/annotations/annotations.ts +463 -0
- package/src/internal/annotations/index.ts +6 -0
- package/src/internal/annotations/util.ts +70 -0
- package/src/internal/entities/entity.ts +109 -0
- package/src/internal/{object → entities}/expando.ts +7 -5
- package/src/internal/entities/index.ts +9 -0
- package/src/internal/entities/model.ts +129 -0
- package/src/internal/entities/object.ts +45 -0
- package/src/internal/entities/relation.ts +155 -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 +5 -5
- package/src/internal/formats/format.ts +3 -0
- package/src/internal/formats/number.ts +5 -5
- package/src/internal/formats/object.ts +2 -2
- package/src/internal/formats/string.ts +9 -9
- package/src/internal/formats/types.ts +44 -39
- package/src/internal/index.ts +29 -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-type.ts +4 -3
- package/src/internal/{json → json-schema}/json-schema.test.ts +230 -97
- package/src/internal/{json → json-schema}/json-schema.ts +67 -87
- 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} +34 -35
- package/src/internal/object/deleted.ts +6 -6
- package/src/internal/object/ids.ts +1 -1
- package/src/internal/object/index.ts +3 -12
- package/src/internal/object/inspect.ts +3 -5
- package/src/internal/object/json-serializer.test.ts +33 -38
- package/src/internal/object/json-serializer.ts +43 -38
- package/src/internal/object/schema-validator.ts +3 -2
- package/src/internal/object/typed-object.test.ts +1 -1
- package/src/internal/object/typed-object.ts +17 -4
- package/src/internal/proxy/handler.test.ts +30 -20
- package/src/internal/proxy/index.ts +6 -0
- package/src/internal/proxy/{reactive-object.ts → make-object.ts} +19 -14
- package/src/internal/proxy/schema.test.ts +5 -4
- package/src/internal/proxy/typed-handler.test.ts +28 -28
- package/src/internal/proxy/typed-handler.ts +11 -6
- package/src/internal/proxy/typed-object.test.ts +17 -12
- package/src/internal/ref/ref.test.ts +9 -8
- package/src/internal/ref/ref.ts +24 -20
- package/src/internal/{projection → schema}/compose.test.ts +5 -6
- package/src/internal/{projection → schema}/compose.ts +2 -1
- package/src/internal/schema/echo-schema.ts +30 -28
- package/src/internal/schema/index.ts +3 -4
- package/src/internal/schema/manipulation.ts +7 -1
- package/src/internal/schema/persistent-schema.ts +28 -0
- package/src/internal/schema/runtime-schema-registry.ts +4 -4
- package/src/internal/types/base.ts +58 -0
- package/src/internal/{ast/entity-kind.ts → types/entity.ts} +8 -0
- package/src/internal/types/index.ts +5 -2
- package/src/internal/{object → types}/meta.ts +32 -18
- package/src/internal/types/typename.ts +45 -0
- package/src/internal/types/version.ts +20 -0
- package/src/query/filter.ts +455 -0
- package/src/query/index.ts +4 -1
- package/src/query/order.ts +34 -0
- package/src/query/query.test.ts +188 -216
- package/src/query/query.ts +24 -505
- package/src/query/testing.ts +64 -0
- package/src/query/util.ts +25 -0
- package/src/testing/api.test.ts +100 -0
- package/src/testing/index.ts +3 -3
- package/src/testing/test-data.ts +130 -0
- package/src/testing/test-schema.ts +213 -0
- package/src/{internal/testing/utils.ts → testing/util.ts} +38 -14
- package/dist/lib/browser/chunk-MWLA34S5.mjs.map +0 -7
- package/dist/lib/browser/chunk-OAZJQHVO.mjs +0 -453
- package/dist/lib/browser/chunk-OAZJQHVO.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORIE2FMS.mjs +0 -514
- package/dist/lib/browser/chunk-ORIE2FMS.mjs.map +0 -7
- package/dist/lib/browser/query/index.mjs +0 -23
- package/dist/lib/browser/query/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AXWVDOP7.mjs +0 -453
- package/dist/lib/node-esm/chunk-AXWVDOP7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L4PBAJDP.mjs +0 -514
- package/dist/lib/node-esm/chunk-L4PBAJDP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YTNLFBIK.mjs.map +0 -7
- package/dist/lib/node-esm/query/index.mjs +0 -23
- package/dist/lib/node-esm/query/index.mjs.map +0 -7
- 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 -119
- 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.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 -29
- 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 -22
- package/dist/types/src/internal/object/entity.d.ts.map +0 -1
- 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/typed-relation.d.ts +0 -32
- package/dist/types/src/internal/object/typed-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.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.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.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/tag.d.ts +0 -18
- 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 -212
- 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 -115
- package/src/internal/object/entity.ts +0 -204
- package/src/internal/object/model.ts +0 -170
- package/src/internal/object/relation.ts +0 -24
- package/src/internal/object/typed-relation.ts +0 -85
- 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/query/index.ts +0 -5
- 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/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/tag.ts +0 -35
- 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/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.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
- /package/src/{internal/query/query.ts → query/types.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { EchoObject, EchoRelation, Expando, TypedObject } from '../object';\nimport { Ref, type Ref$ } from '../ref';\n\n// TODO(burdon): These are non-canonical test types, so we really shouldn't export and use in other classes (compare with @dxos/sdk/testing).\nexport namespace Testing {\n //\n // Primitives\n //\n\n const Circle = Schema.Struct({ type: Schema.Literal('circle'), radius: Schema.Number });\n const Square = Schema.Struct({ type: Schema.Literal('square'), side: Schema.Number });\n const Shape = Schema.Union(Circle, Square);\n\n //\n // Simple types\n //\n\n const TestNestedSchema = Schema.mutable(Schema.Struct({ field: Schema.String }));\n export type TestNestedSchema = Schema.Schema.Type<typeof TestNestedSchema>;\n export const TestNestedType = TestNestedSchema.pipe(\n EchoObject({ typename: 'example.com/type/TestNested', version: '0.1.0' }),\n );\n\n //\n // Complex types\n // TODO(burdon): Change to Type.Obj.\n //\n\n export class EmptySchemaType extends TypedObject({\n typename: 'example.com/type/Empty',\n version: '0.1.0',\n })({}) {}\n\n const fields = {\n string: Schema.String,\n number: Schema.Number,\n nullableShapeArray: Schema.mutable(Schema.Array(Schema.Union(Shape, Schema.Null))),\n boolean: Schema.Boolean,\n null: Schema.Null,\n undefined: Schema.Undefined,\n stringArray: Schema.mutable(Schema.Array(Schema.String)),\n twoDimNumberArray: Schema.mutable(Schema.Array(Schema.mutable(Schema.Array(Schema.Number)))),\n object: TestNestedSchema,\n objectArray: Schema.mutable(Schema.Array(TestNestedSchema)),\n nested: Schema.optional(Ref(TestNestedType)),\n other: Schema.Any,\n };\n\n export const TestSchema = Schema.mutable(Schema.partial(Schema.Struct(fields)));\n export type TestSchema = Schema.Schema.Type<typeof TestSchema>;\n\n export class TestSchemaType extends TypedObject({\n typename: 'example.com/type/Test',\n version: '0.1.0',\n })(fields, { partial: true }) {} // TODO(burdon): Partial?\n\n // TODO(burdon): Why do we use need this rather then TestSchemaType?\n export const TestType = TestSchema.pipe(\n EchoObject({\n typename: 'example.com/type/Test',\n version: '0.1.0',\n }),\n );\n\n export class TestClass {\n field = 'value';\n toJSON() {\n return { field: this.field };\n }\n }\n\n // TODO(dmaretskyi): Another top-level Schema.mutable call as a workaround for the regression in the last minor.\n export const TestSchemaWithClass = Schema.mutable(\n Schema.extend(\n TestSchema,\n Schema.mutable(\n Schema.Struct({\n classInstance: Schema.optional(Schema.instanceOf(TestClass)),\n }),\n ),\n ),\n );\n\n export type TestSchemaWithClass = Schema.Schema.Type<typeof TestSchemaWithClass>;\n\n export class Contact extends TypedObject({\n typename: 'example.com/type/Contact',\n version: '0.1.0',\n })(\n {\n name: Schema.String,\n username: Schema.String,\n email: Schema.String,\n phoneNumbers: Schema.optional(Schema.Array(Schema.Struct({ label: Schema.String, number: Schema.String }))),\n tasks: Schema.suspend((): Schema.mutable<Schema.Array$<Ref$<Task>>> => Schema.mutable(Schema.Array(Ref(Task)))),\n address: Schema.Struct({\n city: Schema.optional(Schema.String),\n state: Schema.optional(Schema.String),\n zip: Schema.optional(Schema.String),\n coordinates: Schema.Struct({\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }),\n }),\n },\n { partial: true },\n ) {}\n\n export class Task extends TypedObject({\n typename: 'example.com/type/Task',\n version: '0.1.0',\n })(\n {\n title: Schema.optional(Schema.String),\n completed: Schema.optional(Schema.Boolean),\n assignee: Schema.optional(Ref(Contact)),\n previous: Schema.optional(Schema.suspend((): Ref$<Task> => Ref(Task))),\n subTasks: Schema.optional(Schema.mutable(Schema.Array(Schema.suspend((): Ref$<Task> => Ref(Task))))),\n description: Schema.optional(Schema.String),\n },\n { partial: true },\n ) {}\n\n // TOOD(burdon): Ref$ breaks if using new syntax (since ID is not declared).\n\n // export const Task = Schema.Struct({\n // title: Schema.String,\n // completed: Schema.Boolean,\n // assignee: Schema.optional(Ref(Schema.suspend((): Ref$<Contact> => Ref(Contact)))),\n // previous: Schema.optional(Ref(Schema.suspend((): Ref$<Task> => Ref(Task)))),\n // subTasks: Schema.optional(Schema.Array(Ref(Schema.suspend((): Ref$<Task> => Ref(Task))))),\n // description: Schema.optional(Schema.String),\n // }).pipe(\n // EchoObject({\n // typename: 'example.com/type/Task',\n // version: '0.1.0',\n // }),\n // );\n\n // export type Task = Schema.Schema.Type<typeof Task>;\n\n // export const Contact = Schema.Struct({\n // name: Schema.String,\n // username: Schema.String,\n // email: Schema.String,\n // // TOOD(burdon): Should model via relations?\n // // tasks: Schema.mutable(Schema.Array(Ref(Task))),\n // address: Schema.Struct({\n // city: Schema.optional(Schema.String),\n // state: Schema.optional(Schema.String),\n // zip: Schema.optional(Schema.String),\n // coordinates: Schema.Struct({\n // lat: Schema.optional(Schema.Number),\n // lng: Schema.optional(Schema.Number),\n // }),\n // }),\n // }).pipe(\n // EchoObject({\n // typename: 'example.com/type/Contact',\n // version: '0.1.0',\n // }),\n // );\n\n // export type Contact = Schema.Schema.Type<typeof Contact>;\n\n export enum RecordType {\n UNDEFINED = 0,\n PERSONAL = 1,\n WORK = 2,\n }\n\n export class Container extends TypedObject({\n typename: 'example.com/type/Container',\n version: '0.1.0',\n })(\n {\n objects: Schema.mutable(Schema.Array(Ref(Expando))),\n records: Schema.mutable(\n Schema.Array(\n Schema.partial(\n Schema.Struct({\n title: Schema.String,\n description: Schema.String,\n contacts: Schema.mutable(Schema.Array(Ref(Contact))),\n type: Schema.Enums(RecordType),\n }),\n ),\n ),\n ),\n },\n { partial: true },\n ) {}\n\n export const HasManager = Schema.Struct({\n since: Schema.optional(Schema.String),\n }).pipe(\n EchoRelation({\n typename: 'example.com/type/HasManager',\n version: '0.1.0',\n source: Contact,\n target: Contact,\n }),\n );\n export interface HasManager extends Schema.Schema.Type<typeof HasManager> {}\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport type * as SchemaAST from 'effect/SchemaAST';\n\nimport { registerSignalsRuntime } from '@dxos/echo-signals';\nimport { deepMapValues } from '@dxos/util';\n\nregisterSignalsRuntime();\n\n// TODO(burdon): Move to util.\nexport const updateCounter = (touch: () => void) => {\n let updateCount = -1;\n const unsubscribe = effect(() => {\n touch();\n updateCount++;\n });\n\n return {\n // https://github.com/tc39/proposal-explicit-resource-management\n [Symbol.dispose]: unsubscribe,\n get count() {\n return updateCount;\n },\n };\n};\n\n/**\n * Converts AST to a format that can be compared with test matchers.\n */\nexport const prepareAstForCompare = (obj: SchemaAST.AST): any =>\n deepMapValues(obj, (value: any, recurse, key) => {\n if (typeof value === 'function') {\n return null;\n }\n\n if (value instanceof RegExp) {\n return value;\n }\n\n // Convert symbols to strings.\n if (typeof value === 'object') {\n const clone = { ...value };\n for (const sym of Object.getOwnPropertySymbols(clone as any)) {\n clone[sym.toString()] = clone[sym];\n delete clone[sym];\n }\n return recurse(clone);\n }\n\n return recurse(value);\n });\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Type } from '..';\n\n// TODO(burdon): These are non-canonical test types, so we really shouldn't export and use in other classes (compare with @dxos/sdk/testing).\nexport namespace Testing {\n const _Contact = Schema.Struct({\n name: Schema.String,\n username: Schema.String,\n email: Schema.String,\n tasks: Schema.mutable(Schema.Array(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task)))),\n address: Schema.Struct({\n city: Schema.optional(Schema.String),\n state: Schema.optional(Schema.String),\n zip: Schema.optional(Schema.String),\n coordinates: Schema.Struct({\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }),\n }),\n }).pipe(\n Schema.partial,\n Type.Obj({\n typename: 'example.com/type/Contact',\n version: '0.1.0',\n }),\n );\n export interface Contact extends Schema.Schema.Type<typeof _Contact> {}\n export const Contact: Schema.Schema<Contact, Schema.Schema.Encoded<typeof _Contact>, never> = _Contact;\n\n const _Task = Schema.Struct({\n title: Schema.optional(Schema.String),\n completed: Schema.optional(Schema.Boolean),\n assignee: Schema.optional(Type.Ref(Contact)),\n previous: Schema.optional(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task))),\n subTasks: Schema.optional(Schema.mutable(Schema.Array(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task))))),\n description: Schema.optional(Schema.String),\n }).pipe(\n Schema.partial,\n Type.Obj({\n typename: 'example.com/type/Task',\n version: '0.1.0',\n }),\n );\n export interface Task extends Schema.Schema.Type<typeof _Task> {}\n export const Task: Schema.Schema<Task, Schema.Schema.Encoded<typeof _Task>, never> = _Task;\n\n export enum RecordType {\n UNDEFINED = 0,\n PERSONAL = 1,\n WORK = 2,\n }\n\n export const Container = Schema.Struct({\n objects: Schema.mutable(Schema.Array(Type.Ref(Type.Expando))),\n records: Schema.mutable(\n Schema.Array(\n Schema.partial(\n Schema.Struct({\n title: Schema.String,\n description: Schema.String,\n contacts: Schema.mutable(Schema.Array(Type.Ref(Contact))),\n type: Schema.Enums(RecordType),\n }),\n ),\n ),\n ),\n }).pipe(\n Schema.partial,\n Type.Obj({\n typename: 'example.com/type/Container',\n version: '0.1.0',\n }),\n );\n\n export const WorksFor = Schema.Struct({\n since: Schema.optional(Schema.String),\n }).pipe(\n Type.Relation({\n typename: 'example.com/type/WorksFor',\n version: '0.1.0',\n source: Contact,\n target: Contact,\n }),\n );\n export interface WorksFor extends Schema.Schema.Type<typeof WorksFor> {}\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport type * as Schema from 'effect/Schema';\n\nimport { registerSignalsRuntime } from '@dxos/echo-signals';\nimport { assertArgument } from '@dxos/invariant';\n\nimport { EchoSchema, StoredSchema, getSchemaTypename, live, toJsonSchema } from '../internal';\n\n// NOTE: Registration is done here is this is the module that calls out to `effect`.\nregisterSignalsRuntime();\n\n/**\n * Create a reactive mutable schema that updates when the JSON schema is updated.\n */\n// TODO(dmaretskyi): Should be replaced by registration of typed object.\nexport const createEchoSchema = (schema: Schema.Schema.AnyNoContext): EchoSchema => {\n const typename = getSchemaTypename(schema);\n assertArgument(typename, 'typename', 'Schema does not have a typename.');\n\n const echoSchema = new EchoSchema(\n live(StoredSchema, {\n typename,\n version: '0.1.0',\n jsonSchema: toJsonSchema(schema),\n }),\n );\n\n // TODO(burdon): Unsubscribe is never called.\n effect(() => {\n const _ = echoSchema.jsonSchema;\n echoSchema._invalidate();\n });\n\n return echoSchema;\n};\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../../src/testing/test-data.ts", "../../../../src/testing/test-schema.ts", "../../../../src/testing/util.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { DatabaseDirectory, ObjectStructure } from '@dxos/echo-protocol';\nimport { DXN, ObjectId, PublicKey } from '@dxos/keys';\n\nimport { Type } from '../index';\n\nimport { TestSchema } from './test-schema';\n\nconst spaceKey = PublicKey.random();\n\n// TODO(burdon): Use Obj.make.\n\nexport const PEOPLE = {\n alice: DatabaseDirectory.make({\n spaceKey: spaceKey.toHex(),\n objects: {\n [ObjectId.random()]: ObjectStructure.makeObject({\n type: Type.getDXN(TestSchema.Person)!.toString(),\n data: {\n name: 'Alice',\n },\n }),\n },\n }),\n bob: DatabaseDirectory.make({\n spaceKey: spaceKey.toHex(),\n objects: {\n [ObjectId.random()]: ObjectStructure.makeObject({\n type: Type.getDXN(TestSchema.Person)!.toString(),\n data: {\n name: 'Bob',\n },\n }),\n },\n }),\n};\n\nexport const ORGS = {\n dxos: DatabaseDirectory.make({\n spaceKey: spaceKey.toHex(),\n objects: {\n [ObjectId.random()]: ObjectStructure.makeObject({\n type: Type.getDXN(TestSchema.Organization)!.toString(),\n data: {\n name: 'DXOS',\n founded: '2023',\n },\n }),\n },\n }),\n cyberdyne: DatabaseDirectory.make({\n spaceKey: spaceKey.toHex(),\n objects: {\n [ObjectId.random()]: ObjectStructure.makeObject({\n type: Type.getDXN(TestSchema.Organization)!.toString(),\n data: {\n name: 'Cyberdyne Systems',\n founded: '1984',\n },\n }),\n },\n }),\n};\n\nexport const WORKS_FOR = {\n fredWorksForCyberdyne: DatabaseDirectory.make({\n spaceKey: spaceKey.toHex(),\n objects: {\n [ObjectId.random()]: ObjectStructure.makeRelation({\n type: Type.getDXN(TestSchema.EmployedBy)!.toString(),\n source: { '/': DXN.fromLocalObjectId(Object.keys(PEOPLE.bob.objects!)[0]).toString() },\n target: { '/': DXN.fromLocalObjectId(Object.keys(ORGS.cyberdyne.objects!)[0]).toString() },\n data: {\n since: '2020',\n position: 'Engineer',\n },\n }),\n },\n }),\n aliceWorksForAperture: DatabaseDirectory.make({\n spaceKey: spaceKey.toHex(),\n objects: {\n [ObjectId.random()]: ObjectStructure.makeRelation({\n type: Type.getDXN(TestSchema.EmployedBy)!.toString(),\n source: { '/': DXN.fromLocalObjectId(Object.keys(PEOPLE.alice.objects!)[0]).toString() },\n target: { '/': DXN.fromLocalObjectId(Object.keys(ORGS.dxos.objects!)[0]).toString() },\n data: {\n since: '2018',\n position: 'Research Scientist',\n },\n }),\n },\n }),\n};\n\nexport const TASKS = {\n task1: DatabaseDirectory.make({\n spaceKey: spaceKey.toHex(),\n objects: {\n [ObjectId.random()]: ObjectStructure.makeObject({\n type: Type.getDXN(TestSchema.Task)!.toString(),\n data: {\n title: 'Complete project documentation',\n description: 'Write comprehensive documentation for the new system',\n status: 'in-progress',\n dueDate: '2023-12-31',\n assignee: { '/': DXN.fromLocalObjectId(Object.keys(PEOPLE.bob.objects!)[0]).toString() },\n },\n }),\n },\n }),\n task2: DatabaseDirectory.make({\n spaceKey: spaceKey.toHex(),\n objects: {\n [ObjectId.random()]: ObjectStructure.makeObject({\n type: Type.getDXN(TestSchema.Task)!.toString(),\n data: {\n title: 'Run experiments',\n description: 'Conduct series of experiments on the portal device',\n status: 'pending',\n dueDate: '2023-11-15',\n assignee: { '/': DXN.fromLocalObjectId(Object.keys(PEOPLE.alice.objects!)[0]).toString() },\n },\n }),\n },\n }),\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Obj from '../Obj';\nimport * as Type from '../Type';\n\nexport namespace TestSchema {\n //\n // Example\n //\n\n const Nested = Schema.Struct({\n field: Schema.String,\n }).pipe(Schema.mutable);\n\n export class TestClass {\n field = 'value';\n toJSON() {\n return { field: this.field };\n }\n }\n\n /** @deprecated Use another test schema or create a specific local test schema. */\n export const ExampleSchema = Schema.Struct({\n string: Schema.String,\n number: Schema.Number,\n boolean: Schema.Boolean,\n null: Schema.Null,\n undefined: Schema.Undefined,\n stringArray: Schema.mutable(Schema.Array(Schema.String)),\n twoDimNumberArray: Schema.mutable(Schema.Array(Schema.mutable(Schema.Array(Schema.Number)))),\n nested: Schema.mutable(Nested),\n nestedArray: Schema.mutable(Schema.Array(Nested)),\n nestedNullableArray: Schema.mutable(Schema.Array(Schema.Union(Nested, Schema.Null))),\n reference: Schema.suspend((): Type.Ref<Example> => Type.Ref(Example)),\n referenceArray: Schema.mutable(Schema.Array(Schema.suspend((): Type.Ref<Example> => Type.Ref(Example)))),\n classInstance: Schema.instanceOf(TestClass),\n other: Schema.Any,\n }).pipe(Schema.partial, Schema.mutable);\n\n /** @deprecated Use another test schema or create a specific local test schema. */\n export interface ExampleSchema extends Schema.Schema.Type<typeof ExampleSchema> {}\n\n /** @deprecated Use another test schema or create a specific local test schema. */\n export const Example = ExampleSchema.pipe(\n Type.Obj({\n typename: 'example.com/type/Example',\n version: '0.1.0',\n }),\n );\n\n /** @deprecated Use another test schema or create a specific local test schema. */\n export interface Example extends Schema.Schema.Type<typeof Example> {}\n\n //\n // Message\n //\n\n // TODO(burdon): Support defaults directly on Type: `make` is erased by `pipe(Type.Obj)`.\n export const MessageStruct = Schema.Struct({\n // TODO(burdon): Support S.Date; Custom Timestamp (with defaults).\n // TODO(burdon): Support defaults (update create and create).\n timestamp: Schema.String.pipe(\n Schema.propertySignature,\n Schema.withConstructorDefault(() => new Date().toISOString()),\n ),\n });\n\n export const Message = MessageStruct.pipe(\n Type.Obj({\n typename: 'example.com/type/Message',\n version: '0.1.0',\n }),\n );\n\n export interface Message extends Schema.Schema.Type<typeof Message> {}\n\n //\n // Organization\n //\n\n export const Organization = Schema.Struct({\n name: Schema.String,\n }).pipe(\n Type.Obj({\n typename: 'example.com/type/Organization',\n version: '0.1.0',\n }),\n );\n\n export interface Organization extends Schema.Schema.Type<typeof Organization> {}\n\n //\n // Person\n //\n\n export const Person = Schema.Struct({\n name: Schema.String,\n username: Schema.String,\n email: Schema.String,\n tasks: Schema.mutable(Schema.Array(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task)))),\n employer: Schema.optional(Type.Ref(Organization)),\n address: Schema.Struct({\n city: Schema.optional(Schema.String),\n state: Schema.optional(Schema.String),\n zip: Schema.optional(Schema.String),\n coordinates: Schema.Struct({\n lat: Schema.optional(Schema.Number),\n lng: Schema.optional(Schema.Number),\n }),\n }),\n }).pipe(\n Schema.partial,\n Type.Obj({\n typename: 'example.com/type/Person',\n version: '0.1.0',\n }),\n );\n\n export interface Person extends Schema.Schema.Type<typeof Person> {}\n\n //\n // Task\n //\n\n export const Task = Schema.Struct({\n title: Schema.optional(Schema.String),\n deadline: Schema.optional(Schema.String),\n completed: Schema.optional(Schema.Boolean),\n assignee: Schema.optional(Type.Ref(Person)),\n previous: Schema.optional(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task))),\n subTasks: Schema.optional(Schema.mutable(Schema.Array(Schema.suspend((): Type.Ref<Task> => Type.Ref(Task))))),\n description: Schema.optional(Schema.String),\n }).pipe(\n Schema.partial,\n Type.Obj({\n typename: 'example.com/type/Task',\n version: '0.1.0',\n }),\n );\n\n export interface Task extends Schema.Schema.Type<typeof Task> {}\n\n //\n // HasManager\n //\n\n export const HasManager = Schema.Struct({}).pipe(\n Type.Relation({\n typename: 'example.com/type/HasManager',\n version: '0.1.0',\n source: Person,\n target: Person,\n }),\n );\n\n export interface HasManager extends Schema.Schema.Type<typeof HasManager> {}\n\n //\n // EmployedBy\n //\n\n export const EmployedBy = Schema.Struct({\n role: Schema.String,\n since: Schema.optional(Schema.String),\n }).pipe(\n Type.Relation({\n typename: 'example.com/type/EmployedBy',\n version: '0.1.0',\n source: Person,\n target: Organization,\n }),\n );\n\n export interface EmployedBy extends Schema.Schema.Type<typeof EmployedBy> {}\n\n //\n // RecordType\n //\n\n export enum RecordType {\n UNDEFINED = 0,\n PERSONAL = 1,\n WORK = 2,\n }\n\n export const Container = Schema.Struct({\n objects: Schema.mutable(Schema.Array(Type.Ref(Obj.Any))),\n records: Schema.mutable(\n Schema.Array(\n Schema.partial(\n Schema.Struct({\n title: Schema.String,\n description: Schema.String,\n contacts: Schema.mutable(Schema.Array(Type.Ref(Person))),\n type: Schema.Enums(RecordType),\n }),\n ),\n ),\n ),\n }).pipe(\n Schema.partial,\n Type.Obj({\n typename: 'example.com/type/Container',\n version: '0.1.0',\n }),\n );\n\n export interface Container extends Schema.Schema.Type<typeof Container> {}\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport type * as Schema from 'effect/Schema';\nimport type * as SchemaAST from 'effect/SchemaAST';\n\nimport { registerSignalsRuntime } from '@dxos/echo-signals';\nimport { assertArgument } from '@dxos/invariant';\nimport { deepMapValues } from '@dxos/util';\n\nimport { EchoSchema, PersistentSchema, getSchemaTypename, makeObject, toJsonSchema } from '../internal';\n\nregisterSignalsRuntime();\n\n/**\n * Create a reactive mutable schema that updates when the JSON schema is updated.\n */\n// TODO(dmaretskyi): Should be replaced by registration of typed object.\nexport const createEchoSchema = (schema: Schema.Schema.AnyNoContext, version = '0.1.0'): EchoSchema => {\n const jsonSchema = toJsonSchema(schema);\n const typename = getSchemaTypename(schema);\n assertArgument(typename, 'typename', 'Schema does not have a typename.');\n const echoSchema = new EchoSchema(makeObject(PersistentSchema, { typename, version, jsonSchema }));\n\n // TODO(burdon): Unsubscribe is never called.\n effect(() => {\n const _ = echoSchema.jsonSchema;\n echoSchema._invalidate();\n });\n\n return echoSchema;\n};\n\n/**\n * Converts AST to a format that can be compared with test matchers.\n */\nexport const prepareAstForCompare = (obj: SchemaAST.AST): any =>\n deepMapValues(obj, (value: any, recurse: any) => {\n if (typeof value === 'function') {\n return null;\n }\n\n if (value instanceof RegExp) {\n return value;\n }\n\n // Convert symbols to strings.\n if (typeof value === 'object') {\n const clone = { ...value };\n for (const sym of Object.getOwnPropertySymbols(clone as any)) {\n clone[sym.toString()] = clone[sym];\n delete clone[sym];\n }\n\n return recurse(clone);\n }\n\n return recurse(value);\n });\n\n// TODO(burdon): Use @dxos/util.\nexport const updateCounter = (touch: () => void) => {\n let updateCount = -1;\n const unsubscribe = effect(() => {\n touch();\n updateCount++;\n });\n\n return {\n // https://github.com/tc39/proposal-explicit-resource-management\n [Symbol.dispose]: unsubscribe,\n get count() {\n return updateCount;\n },\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAIA,SAASA,mBAAmBC,uBAAuB;AACnD,SAASC,KAAKC,UAAUC,iBAAiB;;;ACDzC,YAAYC,YAAY;UAKPC,aAAAA;AAKf,QAAMC,SAAgBC,cAAO;IAC3BC,OAAcC;EAChB,CAAA,EAAGC,KAAYC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,aAAa,IAAIC,WAAWC,WAAWC,kBAAkB;IAAEN;IAAUH;IAASC;EAAW,CAAA,CAAA;AAG/FS,SAAO,MAAA;AACL,UAAMC,IAAIL,WAAWL;AACrBK,eAAWM,YAAW;EACxB,CAAA;AAEA,SAAON;AACT;AAKO,IAAMO,uBAAuB,CAACC,QACnCC,cAAcD,KAAK,CAACE,OAAYC,YAAAA;AAC9B,MAAI,OAAOD,UAAU,YAAY;AAC/B,WAAO;EACT;AAEA,MAAIA,iBAAiBE,QAAQ;AAC3B,WAAOF;EACT;AAGA,MAAI,OAAOA,UAAU,UAAU;AAC7B,UAAMG,QAAQ;MAAE,GAAGH;IAAM;AACzB,eAAWI,OAAOC,OAAOC,sBAAsBH,KAAAA,GAAe;AAC5DA,YAAMC,IAAIG,SAAQ,CAAA,IAAMJ,MAAMC,GAAAA;AAC9B,aAAOD,MAAMC,GAAAA;IACf;AAEA,WAAOH,QAAQE,KAAAA;EACjB;AAEA,SAAOF,QAAQD,KAAAA;AACjB,CAAA;AAGK,IAAMQ,gBAAgB,CAACC,UAAAA;AAC5B,MAAIC,cAAc;AAClB,QAAMC,cAAcjB,OAAO,MAAA;AACzBe,UAAAA;AACAC;EACF,CAAA;AAEA,SAAO;;IAEL,CAACE,OAAOC,OAAO,GAAGF;IAClB,IAAIG,QAAQ;AACV,aAAOJ;IACT;EACF;AACF;",
|
|
6
|
+
"names": ["DatabaseDirectory", "ObjectStructure", "DXN", "ObjectId", "PublicKey", "Schema", "TestSchema", "Nested", "Struct", "field", "String", "pipe", "mutable", "TestClass", "toJSON", "ExampleSchema", "string", "number", "Number", "boolean", "Boolean", "null", "Null", "undefined", "Undefined", "stringArray", "Array", "twoDimNumberArray", "nested", "nestedArray", "nestedNullableArray", "Union", "reference", "suspend", "Ref", "Example", "referenceArray", "classInstance", "instanceOf", "other", "Any", "partial", "Obj", "typename", "version", "MessageStruct", "timestamp", "propertySignature", "withConstructorDefault", "Date", "toISOString", "Message", "Organization", "name", "Person", "username", "email", "tasks", "Task", "employer", "optional", "address", "city", "state", "zip", "coordinates", "lat", "lng", "title", "deadline", "completed", "assignee", "previous", "subTasks", "description", "HasManager", "Relation", "source", "target", "EmployedBy", "role", "since", "RecordType", "Container", "objects", "records", "contacts", "type", "Enums", "spaceKey", "PublicKey", "random", "PEOPLE", "alice", "DatabaseDirectory", "make", "toHex", "objects", "ObjectId", "ObjectStructure", "makeObject", "type", "Type", "getDXN", "TestSchema", "Person", "toString", "data", "name", "bob", "ORGS", "dxos", "Organization", "founded", "cyberdyne", "WORKS_FOR", "fredWorksForCyberdyne", "makeRelation", "EmployedBy", "source", "DXN", "fromLocalObjectId", "Object", "keys", "target", "since", "position", "aliceWorksForAperture", "TASKS", "task1", "Task", "title", "description", "status", "dueDate", "assignee", "task2", "effect", "registerSignalsRuntime", "assertArgument", "deepMapValues", "registerSignalsRuntime", "createEchoSchema", "schema", "version", "jsonSchema", "toJsonSchema", "typename", "getSchemaTypename", "assertArgument", "echoSchema", "EchoSchema", "makeObject", "PersistentSchema", "effect", "_", "_invalidate", "prepareAstForCompare", "obj", "deepMapValues", "value", "recurse", "RegExp", "clone", "sym", "Object", "getOwnPropertySymbols", "toString", "updateCounter", "touch", "updateCount", "unsubscribe", "Symbol", "dispose", "count"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Annotation.d.ts","sourceRoot":"","sources":["../../../src/Annotation.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,QAAQ,GACT,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { type CleanupFn } from '@dxos/async';
|
|
2
|
+
import { type QueryAST } from '@dxos/echo-protocol';
|
|
3
|
+
import { type DXN, type PublicKey, type SpaceId } from '@dxos/keys';
|
|
4
|
+
import { type QueryOptions as QueryOptionsProto } from '@dxos/protocols/proto/dxos/echo/filter';
|
|
5
|
+
import type * as Entity from './Entity';
|
|
6
|
+
import type { Filter, Query } from './query';
|
|
7
|
+
import type * as Ref from './Ref';
|
|
8
|
+
/**
|
|
9
|
+
* Individual query result entry.
|
|
10
|
+
*/
|
|
11
|
+
export type QueryResultEntry<T extends Entity.Unknown = Entity.Unknown> = {
|
|
12
|
+
id: string;
|
|
13
|
+
spaceId: SpaceId;
|
|
14
|
+
/**
|
|
15
|
+
* May not be present for remote results.
|
|
16
|
+
*/
|
|
17
|
+
object?: T;
|
|
18
|
+
match?: {
|
|
19
|
+
/**
|
|
20
|
+
* Higher means better match.
|
|
21
|
+
*/
|
|
22
|
+
rank: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Query resolution metadata.
|
|
26
|
+
*/
|
|
27
|
+
resolution?: {
|
|
28
|
+
source: 'remote' | 'local' | 'index';
|
|
29
|
+
/**
|
|
30
|
+
* Query resolution time in milliseconds.
|
|
31
|
+
*/
|
|
32
|
+
time: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type OneShotQueryResult<T extends Entity.Unknown = Entity.Unknown> = {
|
|
36
|
+
results: QueryResultEntry<T>[];
|
|
37
|
+
objects: T[];
|
|
38
|
+
};
|
|
39
|
+
export type QuerySubscriptionOptions = {
|
|
40
|
+
/**
|
|
41
|
+
* Fire the callback immediately.
|
|
42
|
+
*/
|
|
43
|
+
fire?: boolean;
|
|
44
|
+
};
|
|
45
|
+
export interface QueryResult<T extends Entity.Unknown = Entity.Unknown> {
|
|
46
|
+
readonly query: Query<T>;
|
|
47
|
+
readonly results: QueryResultEntry<T>[];
|
|
48
|
+
readonly objects: T[];
|
|
49
|
+
run(opts?: QueryRunOptions): Promise<OneShotQueryResult<T>>;
|
|
50
|
+
runSync(): QueryResultEntry<T>[];
|
|
51
|
+
first(opts?: QueryRunOptions): Promise<T>;
|
|
52
|
+
subscribe(callback?: (query: QueryResult<T>) => void, opts?: QuerySubscriptionOptions): CleanupFn;
|
|
53
|
+
}
|
|
54
|
+
export type QueryRunOptions = {
|
|
55
|
+
timeout?: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use `QueryAST.QueryOptions` instead.
|
|
59
|
+
*/
|
|
60
|
+
export type QueryOptions = {
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated Use `spaceIds` instead.
|
|
63
|
+
*/
|
|
64
|
+
spaces?: PublicKey[];
|
|
65
|
+
/**
|
|
66
|
+
* Query only in specific spaces.
|
|
67
|
+
*/
|
|
68
|
+
spaceIds?: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Return only the first `limit` results.
|
|
71
|
+
*/
|
|
72
|
+
limit?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Query only local spaces, or remote on agent.
|
|
75
|
+
* @default `QueryOptions.DataLocation.LOCAL`
|
|
76
|
+
*
|
|
77
|
+
* Options:
|
|
78
|
+
* - proto3_optional = true
|
|
79
|
+
*/
|
|
80
|
+
dataLocation?: QueryOptionsProto.DataLocation;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* `query` API function declaration.
|
|
84
|
+
*/
|
|
85
|
+
export interface QueryFn {
|
|
86
|
+
<Q extends Query.Any>(query: Q, options?: (QueryAST.QueryOptions & QueryOptions) | undefined): QueryResult<Query.Type<Q>>;
|
|
87
|
+
<F extends Filter.Any>(filter: F, options?: (QueryAST.QueryOptions & QueryOptions) | undefined): QueryResult<Filter.Type<F>>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Common interface for Database and Queue.
|
|
91
|
+
*/
|
|
92
|
+
export interface Queryable {
|
|
93
|
+
query: QueryFn;
|
|
94
|
+
}
|
|
95
|
+
export type GetObjectByIdOptions = {
|
|
96
|
+
deleted?: boolean;
|
|
97
|
+
};
|
|
98
|
+
export type ObjectPlacement = 'root-doc' | 'linked-doc';
|
|
99
|
+
export type AddOptions = {
|
|
100
|
+
/**
|
|
101
|
+
* Where to place the object in the Automerge document tree.
|
|
102
|
+
* Root document is always loaded with the space.
|
|
103
|
+
* Linked documents are loaded lazily.
|
|
104
|
+
* Placing large number of objects in the root document may slow down the initial load.
|
|
105
|
+
*
|
|
106
|
+
* @default 'linked-doc'
|
|
107
|
+
*/
|
|
108
|
+
placeIn?: ObjectPlacement;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* ECHO Database interface.
|
|
112
|
+
*/
|
|
113
|
+
export interface Database extends Queryable {
|
|
114
|
+
get spaceId(): SpaceId;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a reference to an existing object in the database.
|
|
117
|
+
*
|
|
118
|
+
* NOTE: The reference may be dangling if the object is not present in the database.
|
|
119
|
+
* NOTE: Difference from `Ref.fromDXN`
|
|
120
|
+
* `Ref.fromDXN(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.
|
|
121
|
+
* `db.makeRef(dxn)` is preferable in cases with access to the database.
|
|
122
|
+
*/
|
|
123
|
+
makeRef<T extends Entity.Unknown = Entity.Unknown>(dxn: DXN): Ref.Ref<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Query objects.
|
|
126
|
+
*/
|
|
127
|
+
query: QueryFn;
|
|
128
|
+
/**
|
|
129
|
+
* Adds object to the database.
|
|
130
|
+
*/
|
|
131
|
+
add<T extends Entity.Unknown = Entity.Unknown>(obj: T, opts?: AddOptions): T;
|
|
132
|
+
/**
|
|
133
|
+
* Removes object from the database.
|
|
134
|
+
*/
|
|
135
|
+
remove(obj: Entity.Unknown): void;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=Database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../src/Database.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK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,CAAC,YAAY,GAAG,YAAY,CAAC,GAAG,SAAS,GAC3D,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,YAAY,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,QAAS,SAAQ,SAAS;IACzC,IAAI,OAAO,IAAI,OAAO,CAAC;IAKvB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEzE;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC;IAE7E;;OAEG;IAEH,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;CACnC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ObjectId } from '@dxos/keys';
|
|
2
|
+
import { EntityKind, KindId } from './internal';
|
|
3
|
+
export { KindId };
|
|
4
|
+
export declare const Kind: typeof EntityKind;
|
|
5
|
+
export type Kind = EntityKind;
|
|
6
|
+
export declare const KindSchema: import("effect/Schema").Enums<typeof EntityKind>;
|
|
7
|
+
/**
|
|
8
|
+
* Assigns a kind to an Object or Relation instance.
|
|
9
|
+
*/
|
|
10
|
+
export interface OfKind<K extends Kind> {
|
|
11
|
+
readonly [KindId]: K;
|
|
12
|
+
readonly id: ObjectId;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Obj or Relation with a specific set of properties.
|
|
16
|
+
*/
|
|
17
|
+
export type Entity<Props> = OfKind<Kind> & Props;
|
|
18
|
+
/**
|
|
19
|
+
* Unknown Obj or Relation.
|
|
20
|
+
*/
|
|
21
|
+
export interface Unknown extends OfKind<Kind> {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Object with arbitrary properties.
|
|
25
|
+
*
|
|
26
|
+
* NOTE: Due to how typescript works, this type is not assignable to a specific schema type.
|
|
27
|
+
* In that case, use `Obj.instanceOf` to check if an object is of a specific type.
|
|
28
|
+
*
|
|
29
|
+
* This type is very permissive and allows accessing any property on the object.
|
|
30
|
+
* We should move to Obj.Any that is not permissive and requires explicit instanceof checks..
|
|
31
|
+
*/
|
|
32
|
+
export interface Any extends OfKind<Kind> {
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
export declare const getKind: (schema: import("effect/Schema").Schema.All) => EntityKind | undefined;
|
|
36
|
+
//# sourceMappingURL=Entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/Entity.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAoB,MAAM,EAAiB,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,MAAM,EAAE,CAAC;AAMlB,eAAO,MAAM,IAAI,mBAAa,CAAC;AAC/B,MAAM,MAAM,IAAI,GAAG,UAAU,CAAC;AAC9B,eAAO,MAAM,UAAU,kDAAmB,CAAC;AAE3C;;GAEG;AAEH,MAAM,WAAW,MAAM,CAAC,CAAC,SAAS,IAAI;IACpC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,OAAQ,SAAQ,MAAM,CAAC,IAAI,CAAC;CAAG;AAEhD;;;;;;;;GAQG;AACH,MAAM,WAAW,GAAI,SAAQ,MAAM,CAAC,IAAI,CAAC;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,OAAO,wEAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Format.d.ts","sourceRoot":"","sources":["../../../src/Format.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,IAAI,MAAM,EAAE,MAAM,YAAY,CAAC;AAIvD,cAAc,oBAAoB,CAAC;AAEnC,YAAY,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Schema from 'effect/Schema';
|
|
2
|
+
import { JsonSchemaType } from './internal';
|
|
3
|
+
export { toEffectSchema, toJsonSchema } from './internal';
|
|
4
|
+
/**
|
|
5
|
+
* Serializable JsonSchema type definition.
|
|
6
|
+
*/
|
|
7
|
+
export type JsonSchema = JsonSchemaType;
|
|
8
|
+
export declare const JsonSchema: Schema.Schema<JsonSchemaType>;
|
|
9
|
+
//# sourceMappingURL=JsonSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSchema.d.ts","sourceRoot":"","sources":["../../../src/JsonSchema.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAkB,CAAC"}
|
package/dist/types/src/Key.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Key.d.ts","sourceRoot":"","sources":["../../../src/Key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Key.d.ts","sourceRoot":"","sources":["../../../src/Key.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/types/src/Obj.d.ts
CHANGED
|
@@ -1,34 +1,44 @@
|
|
|
1
1
|
import * as Schema from 'effect/Schema';
|
|
2
|
-
import { type
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
import type
|
|
6
|
-
import
|
|
2
|
+
import { type ForeignKey } from '@dxos/echo-protocol';
|
|
3
|
+
import { type DXN, ObjectId } from '@dxos/keys';
|
|
4
|
+
import * as Entity from './Entity';
|
|
5
|
+
import { type AnyEchoObject, type AnyProperties, type ObjectJSON, type ObjectMeta, VersionTypeId } from './internal';
|
|
6
|
+
import * as Ref from './Ref';
|
|
7
7
|
import * as Type from './Type';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Base type for all ECHO objects.
|
|
10
|
+
* @private
|
|
10
11
|
*/
|
|
11
|
-
interface BaseObj extends
|
|
12
|
+
interface BaseObj extends AnyEchoObject, Entity.OfKind<typeof Entity.Kind.Object> {
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Base type for all Obj objects.
|
|
16
|
+
*/
|
|
17
|
+
export interface Any extends BaseObj {
|
|
18
|
+
}
|
|
19
|
+
export declare const Any: Type.obj<Schema.Struct<{}>>;
|
|
13
20
|
/**
|
|
14
21
|
* Object type with specific properties.
|
|
15
22
|
*/
|
|
16
23
|
export type Obj<Props> = BaseObj & Props;
|
|
17
24
|
/**
|
|
18
|
-
*
|
|
25
|
+
* Object with arbitrary properties.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: Due to how typescript works, this type is not assignable to a specific schema type.
|
|
28
|
+
* In that case, use `Obj.instanceOf` to check if an object is of a specific type.
|
|
19
29
|
*/
|
|
20
|
-
export interface
|
|
30
|
+
export interface AnyProps extends BaseObj, AnyProperties {
|
|
21
31
|
}
|
|
22
|
-
export declare const Any: Type.obj<Schema.Struct<{}>>;
|
|
23
32
|
type Props<T = any> = {
|
|
24
|
-
id?:
|
|
33
|
+
id?: ObjectId;
|
|
34
|
+
[Meta]?: Partial<ObjectMeta>;
|
|
25
35
|
} & Type.Properties<T>;
|
|
26
|
-
export type MakeProps<T extends
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
export type MakeProps<T extends Schema.Schema.AnyNoContext> = {
|
|
37
|
+
id?: ObjectId;
|
|
38
|
+
[Meta]?: Partial<ObjectMeta>;
|
|
39
|
+
} & NoInfer<Props<Schema.Schema.Type<T>>>;
|
|
30
40
|
/**
|
|
31
|
-
* Creates new object.
|
|
41
|
+
* Creates a new object of the given types.
|
|
32
42
|
* @param schema - Object schema.
|
|
33
43
|
* @param props - Object properties.
|
|
34
44
|
* @param meta - Object metadata (deprecated) -- pass with Obj.Meta.
|
|
@@ -40,15 +50,35 @@ export declare const Meta: unique symbol;
|
|
|
40
50
|
* const obj = Obj.make(Person, { [Obj.Meta]: { keys: [...] }, name: 'John' });
|
|
41
51
|
* ```
|
|
42
52
|
*/
|
|
43
|
-
export declare const make: <S extends
|
|
53
|
+
export declare const make: <S extends Schema.Schema.AnyNoContext>(schema: S, props: MakeProps<S>, meta?: Partial<ObjectMeta>) => Obj<Schema.Schema.Type<S>>;
|
|
54
|
+
/**
|
|
55
|
+
* Determine if object is an ECHO object.
|
|
56
|
+
*/
|
|
44
57
|
export declare const isObject: (obj: unknown) => obj is Any;
|
|
58
|
+
/**
|
|
59
|
+
* Returns an immutable snapshot of an object.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getSnapshot: <T extends Any>(obj: Obj<T>) => T;
|
|
62
|
+
export type CloneOptions = {
|
|
63
|
+
/**
|
|
64
|
+
* Retain the original object's ID.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
retainId?: boolean;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Clones an object or relation.
|
|
71
|
+
* This does not clone referenced objects, only the properties in the object.
|
|
72
|
+
* @returns A new object with the same schema and properties.
|
|
73
|
+
*/
|
|
74
|
+
export declare const clone: <T extends Any>(obj: T, opts?: CloneOptions) => T;
|
|
75
|
+
export declare const ID: import("@dxos/keys").ObjectIdClass;
|
|
76
|
+
export type ID = ObjectId;
|
|
45
77
|
/**
|
|
46
78
|
* Test if object or relation is an instance of a schema.
|
|
47
79
|
* @example
|
|
48
80
|
* ```ts
|
|
49
81
|
* const john = Obj.make(Person, { name: 'John' });
|
|
50
|
-
* const johnIsPerson = Obj.instanceOf(Person)(john);
|
|
51
|
-
*
|
|
52
82
|
* const isPerson = Obj.instanceOf(Person);
|
|
53
83
|
* if (isPerson(john)) {
|
|
54
84
|
* // john is Person
|
|
@@ -56,57 +86,61 @@ export declare const isObject: (obj: unknown) => obj is Any;
|
|
|
56
86
|
* ```
|
|
57
87
|
*/
|
|
58
88
|
export declare const instanceOf: {
|
|
59
|
-
<S extends Type.
|
|
60
|
-
<S extends Type.
|
|
89
|
+
<S extends Type.Entity.Any>(schema: S): (value: unknown) => value is Schema.Schema.Type<S>;
|
|
90
|
+
<S extends Type.Entity.Any>(schema: S, value: unknown): value is Schema.Schema.Type<S>;
|
|
61
91
|
};
|
|
62
|
-
export declare const
|
|
63
|
-
export declare const getDXN: (obj: Any | Relation.Any) => DXN;
|
|
92
|
+
export declare const getDXN: (entity: Entity.Unknown) => DXN;
|
|
64
93
|
/**
|
|
65
94
|
* @returns The DXN of the object's type.
|
|
66
|
-
* @example dxn:example.com/type/
|
|
95
|
+
* @example dxn:example.com/type/Person:1.0.0
|
|
67
96
|
*/
|
|
68
|
-
export declare const getTypeDXN: (obj:
|
|
97
|
+
export declare const getTypeDXN: (obj: AnyProperties) => DXN | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Get the schema of the object.
|
|
100
|
+
*/
|
|
101
|
+
export declare const getSchema: (obj: unknown | undefined) => Schema.Schema.AnyNoContext | undefined;
|
|
69
102
|
/**
|
|
70
103
|
* @returns The typename of the object's type.
|
|
71
|
-
* @example `example.com/type/
|
|
104
|
+
* @example `example.com/type/Person`
|
|
72
105
|
*/
|
|
73
|
-
export declare const getTypename: (
|
|
74
|
-
export declare const
|
|
106
|
+
export declare const getTypename: (entity: Entity.Unknown) => string | undefined;
|
|
107
|
+
export declare const Meta: unique symbol;
|
|
108
|
+
export declare const getMeta: (entity: AnyProperties) => ObjectMeta;
|
|
75
109
|
/**
|
|
76
110
|
* @returns Foreign keys for the object from the specified source.
|
|
77
111
|
*/
|
|
78
112
|
export declare const getKeys: {
|
|
79
|
-
(
|
|
80
|
-
(source: string): (
|
|
113
|
+
(entity: Entity.Unknown, source: string): ForeignKey[];
|
|
114
|
+
(source: string): (entity: Entity.Unknown) => ForeignKey[];
|
|
81
115
|
};
|
|
82
116
|
/**
|
|
83
117
|
* Delete all keys from the object for the specified source.
|
|
84
|
-
* @param
|
|
118
|
+
* @param entity
|
|
85
119
|
* @param source
|
|
86
120
|
*/
|
|
87
|
-
export declare const deleteKeys: (
|
|
88
|
-
export declare const
|
|
89
|
-
export declare const
|
|
90
|
-
export declare const
|
|
91
|
-
export
|
|
92
|
-
export declare const
|
|
93
|
-
export declare const
|
|
94
|
-
export declare const
|
|
121
|
+
export declare const deleteKeys: (entity: Entity.Unknown, source: string) => void;
|
|
122
|
+
export declare const addTag: (entity: Entity.Unknown, tag: string) => void;
|
|
123
|
+
export declare const removeTag: (entity: Entity.Unknown, tag: string) => void;
|
|
124
|
+
export declare const isDeleted: (entity: Entity.Unknown) => boolean;
|
|
125
|
+
export declare const getLabel: (entity: Entity.Unknown) => string | undefined;
|
|
126
|
+
export declare const setLabel: (entity: Entity.Unknown, label: string) => void;
|
|
127
|
+
export declare const getDescription: (entity: Entity.Unknown) => string | undefined;
|
|
128
|
+
export declare const setDescription: (entity: Entity.Unknown, description: string) => void;
|
|
95
129
|
/**
|
|
96
130
|
* JSON representation of an object.
|
|
97
131
|
*/
|
|
98
|
-
export type JSON =
|
|
132
|
+
export type JSON = ObjectJSON;
|
|
99
133
|
/**
|
|
100
134
|
* Converts object to its JSON representation.
|
|
101
135
|
*
|
|
102
136
|
* The same algorithm is used when calling the standard `JSON.stringify(obj)` function.
|
|
103
137
|
*/
|
|
104
|
-
export declare const toJSON: (
|
|
138
|
+
export declare const toJSON: (entity: Entity.Unknown) => JSON;
|
|
105
139
|
/**
|
|
106
140
|
* Creates an object from its json representation, performing schema validation.
|
|
107
141
|
* References and schemas will be resolvable if the `refResolver` is provided.
|
|
108
142
|
*
|
|
109
|
-
* The function
|
|
143
|
+
* The function must be async to support resolving the schema as well as the relation endpoints.
|
|
110
144
|
*
|
|
111
145
|
* @param options.refResolver - Resolver for references. Produces hydrated references that can be resolved.
|
|
112
146
|
* @param options.dxn - Override object DXN. Changes the result of `Obj.getDXN`.
|
|
@@ -115,31 +149,21 @@ export declare const fromJSON: (json: unknown, options?: {
|
|
|
115
149
|
refResolver?: Ref.Resolver;
|
|
116
150
|
dxn?: DXN;
|
|
117
151
|
}) => Promise<Any>;
|
|
152
|
+
export type Comparator = (a: Entity.Unknown, b: Entity.Unknown) => number;
|
|
153
|
+
export declare const sortByLabel: Comparator;
|
|
154
|
+
export declare const sortByTypename: Comparator;
|
|
155
|
+
export declare const sort: (...comparators: Comparator[]) => Comparator;
|
|
118
156
|
/**
|
|
119
|
-
*
|
|
120
|
-
*/
|
|
121
|
-
export declare const getSnapshot: <T extends Any>(obj: Obj<T>) => T;
|
|
122
|
-
export type CloneOptions = {
|
|
123
|
-
/**
|
|
124
|
-
* Retain the original object's ID.
|
|
125
|
-
* @default false
|
|
126
|
-
*/
|
|
127
|
-
retainId?: boolean;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Clones an object or relation.
|
|
131
|
-
* This does not clone referenced objects, only the properties in the object.
|
|
132
|
-
* @returns A new object with the same schema and properties.
|
|
157
|
+
* Unique symbol for version type identification.
|
|
133
158
|
*/
|
|
134
|
-
export
|
|
135
|
-
export declare const VersionTypeId: symbol;
|
|
136
|
-
export type VersionType = typeof VersionTypeId;
|
|
159
|
+
export { VersionTypeId };
|
|
137
160
|
/**
|
|
138
161
|
* Represent object version.
|
|
139
162
|
* May be backed by Automerge.
|
|
140
163
|
* Objects with no history are not versioned.
|
|
141
164
|
*/
|
|
142
165
|
export interface Version {
|
|
166
|
+
[VersionTypeId]: {};
|
|
143
167
|
/**
|
|
144
168
|
* Whether the object is versioned.
|
|
145
169
|
*/
|
|
@@ -152,11 +176,11 @@ export interface Version {
|
|
|
152
176
|
/**
|
|
153
177
|
* Checks that `obj` is a version object.
|
|
154
178
|
*/
|
|
155
|
-
export declare const isVersion: (
|
|
179
|
+
export declare const isVersion: (entity: unknown) => entity is Version;
|
|
156
180
|
/**
|
|
157
181
|
* Returns the version of the object.
|
|
158
182
|
*/
|
|
159
|
-
export declare const version: (
|
|
183
|
+
export declare const version: (entity: Entity.Unknown) => Version;
|
|
160
184
|
/**
|
|
161
185
|
* Checks that `version` is a valid version object.
|
|
162
186
|
*/
|
|
@@ -171,5 +195,4 @@ export type VersionCompareResult = 'unversioned' | 'equal' | 'different';
|
|
|
171
195
|
export declare const compareVersions: (version1: Version, version2: Version) => VersionCompareResult;
|
|
172
196
|
export declare const encodeVersion: (version: Version) => string;
|
|
173
197
|
export declare const decodeVersion: (version: string) => Version;
|
|
174
|
-
export {};
|
|
175
198
|
//# sourceMappingURL=Obj.d.ts.map
|