@dxos/echo 0.8.4-main.8360d9e660 → 0.8.4-main.8baae0fced
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/LICENSE +102 -5
- package/README.md +3 -3
- package/dist/lib/neutral/Annotation.mjs +5 -3
- package/dist/lib/neutral/Database.mjs +8 -4
- package/dist/lib/neutral/Entity.mjs +16 -14
- package/dist/lib/neutral/Err.mjs +1 -1
- package/dist/lib/neutral/Extension.mjs +18 -0
- package/dist/lib/neutral/Extension.mjs.map +7 -0
- package/dist/lib/neutral/Feed.mjs +23 -18
- package/dist/lib/neutral/Filter.mjs +23 -13
- package/dist/lib/neutral/Format.mjs +3 -3
- package/dist/lib/neutral/JsonSchema.mjs +8 -8
- package/dist/lib/neutral/Key.mjs +1 -1
- package/dist/lib/neutral/Migration.mjs +17 -0
- package/dist/lib/neutral/Migration.mjs.map +7 -0
- package/dist/lib/neutral/Obj.mjs +16 -13
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +19 -17
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +9 -7
- package/dist/lib/neutral/Relation.mjs +15 -14
- package/dist/lib/neutral/SchemaRegistry.mjs +1 -1
- package/dist/lib/neutral/Tag.mjs +14 -13
- package/dist/lib/neutral/Type.mjs +10 -10
- package/dist/lib/neutral/{chunk-FZO7LQO7.mjs → chunk-44HT3MEC.mjs} +2 -2
- package/dist/lib/neutral/{chunk-ROAGDPV7.mjs → chunk-4A2GS5LQ.mjs} +12 -8
- package/dist/lib/neutral/chunk-4A2GS5LQ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-OENWMTE6.mjs → chunk-5SL5LDLD.mjs} +4 -2
- package/dist/lib/neutral/chunk-5SL5LDLD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ANHVGJI4.mjs → chunk-7RVZT53K.mjs} +1 -1
- package/dist/lib/neutral/{chunk-YWXWXIE5.mjs → chunk-APHSOTIX.mjs} +2 -2
- package/dist/lib/neutral/{chunk-YWXWXIE5.mjs.map → chunk-APHSOTIX.mjs.map} +2 -2
- package/dist/lib/neutral/{chunk-6DNYDXCV.mjs → chunk-B2P7IVG3.mjs} +61 -14
- package/dist/lib/neutral/chunk-B2P7IVG3.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BNCCGLJN.mjs → chunk-BICZKPQG.mjs} +1 -1
- package/dist/lib/neutral/{chunk-43Y5DOS6.mjs → chunk-BMB7IHGB.mjs} +16 -66
- package/dist/lib/neutral/chunk-BMB7IHGB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6K2MVI2O.mjs → chunk-BUBEC474.mjs} +4 -4
- package/dist/lib/neutral/{chunk-YMNSMKKW.mjs → chunk-C4PSESGN.mjs} +6 -22
- package/dist/lib/neutral/{chunk-YMNSMKKW.mjs.map → chunk-C4PSESGN.mjs.map} +3 -3
- package/dist/lib/neutral/chunk-FIWO2FZK.mjs +36 -0
- package/dist/lib/neutral/chunk-FIWO2FZK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs +50 -0
- package/dist/lib/neutral/chunk-GWFFC34K.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NXMFBIT5.mjs → chunk-HKETO4L4.mjs} +72 -6
- package/dist/lib/neutral/chunk-HKETO4L4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-NEGC54NE.mjs → chunk-I2DARWPX.mjs} +17 -19
- package/dist/lib/neutral/chunk-I2DARWPX.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7VNVH63N.mjs → chunk-IVSI7QO6.mjs} +50 -20
- package/dist/lib/neutral/chunk-IVSI7QO6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BOZZPUXE.mjs → chunk-MLS7U7AT.mjs} +12 -65
- package/dist/lib/neutral/chunk-MLS7U7AT.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WYOKA6AE.mjs → chunk-N4B7FHQT.mjs} +2 -2
- package/dist/lib/neutral/{chunk-WYOKA6AE.mjs.map → chunk-N4B7FHQT.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-FXEG7EOK.mjs → chunk-N7VOEPSV.mjs} +6 -3
- package/dist/lib/neutral/{chunk-FXEG7EOK.mjs.map → chunk-N7VOEPSV.mjs.map} +3 -3
- package/dist/lib/neutral/{chunk-UTBRYVQC.mjs → chunk-QRZ2I3ZM.mjs} +2 -2
- package/dist/lib/neutral/{chunk-SEMVAGBM.mjs → chunk-TNBK56IN.mjs} +19 -24
- package/dist/lib/neutral/chunk-TNBK56IN.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-B5OXLWZL.mjs → chunk-TRPZU2HV.mjs} +2 -2
- package/dist/lib/neutral/{chunk-UI6MWK5W.mjs → chunk-TTCSATUD.mjs} +1 -1
- package/dist/lib/neutral/{chunk-OMUPQMLR.mjs → chunk-V72DY6LU.mjs} +1 -1
- package/dist/lib/neutral/{chunk-6GPU7XC3.mjs → chunk-VW42HESL.mjs} +54 -17
- package/dist/lib/neutral/chunk-VW42HESL.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-4JRI2ZJI.mjs → chunk-X3356HPV.mjs} +120 -12
- package/dist/lib/neutral/chunk-X3356HPV.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-W47JKR3X.mjs → chunk-XEXM5HWQ.mjs} +18 -46
- package/dist/lib/neutral/chunk-XEXM5HWQ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-C4JZK4J7.mjs → chunk-Z5GKP74O.mjs} +231 -479
- package/dist/lib/neutral/chunk-Z5GKP74O.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-UBEZSGXY.mjs → chunk-ZISMEVKD.mjs} +1 -1
- package/dist/lib/neutral/{chunk-UBEZSGXY.mjs.map → chunk-ZISMEVKD.mjs.map} +2 -2
- package/dist/lib/neutral/index.mjs +38 -28
- package/dist/lib/neutral/internal/index.mjs +15 -9
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +185 -129
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +1 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +14 -2
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +2 -1
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +17 -11
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +18 -18
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Extension.d.ts +80 -0
- package/dist/types/src/Extension.d.ts.map +1 -0
- package/dist/types/src/Extension.test.d.ts +2 -0
- package/dist/types/src/Extension.test.d.ts.map +1 -0
- package/dist/types/src/Feed.d.ts +62 -21
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +54 -4
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Filter.test.d.ts +2 -0
- package/dist/types/src/Filter.test.d.ts.map +1 -0
- package/dist/types/src/Hypergraph.d.ts +3 -3
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts +33 -0
- package/dist/types/src/Json.d.ts.map +1 -0
- package/dist/types/src/Json.test.d.ts +2 -0
- package/dist/types/src/Json.test.d.ts.map +1 -0
- package/dist/types/src/JsonSchema.d.ts +1 -1
- package/dist/types/src/Migration.d.ts +69 -0
- package/dist/types/src/Migration.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +42 -28
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +13 -2
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +1 -0
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +17 -18
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +2 -2
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +3 -3
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +1 -1
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/exemplars.test.d.ts +2 -0
- package/dist/types/src/exemplars.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +12 -2
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/sorting.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/util.d.ts +1 -1
- package/dist/types/src/internal/Annotation/util.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/model.d.ts +2 -0
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/version.d.ts.map +1 -1
- package/dist/types/src/internal/Format/date.d.ts.map +1 -1
- package/dist/types/src/internal/Format/format.d.ts.map +1 -1
- package/dist/types/src/internal/Format/number.d.ts.map +1 -1
- package/dist/types/src/internal/Format/object.d.ts.map +1 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-normalize.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +28 -28
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/common.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/deleted.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/ids.d.ts +1 -1
- package/dist/types/src/internal/Obj/ids.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/json-serializer.d.ts +4 -3
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts +1 -1
- package/dist/types/src/internal/Obj/set-value.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/snapshot.d.ts.map +1 -1
- package/dist/types/src/internal/Query.d.ts +10 -0
- package/dist/types/src/internal/Query.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/ref-array.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/ref.d.ts +14 -1
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Type/compose.d.ts.map +1 -1
- package/dist/types/src/internal/Type/echo-schema.d.ts +2 -2
- package/dist/types/src/internal/Type/echo-schema.d.ts.map +1 -1
- package/dist/types/src/internal/Type/manipulation.d.ts.map +1 -1
- package/dist/types/src/internal/common/api/meta.d.ts +3 -3
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/define-hidden-property.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/errors.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/event-batch.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/ownership.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive-array.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts +2 -0
- package/dist/types/src/internal/common/proxy/reactive.test.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/base.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/entity.d.ts +4 -4
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/meta.d.ts +10 -0
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/version.d.ts +1 -1
- package/dist/types/src/internal/index.d.ts +1 -0
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +8 -8
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +53 -53
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/testing/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -15
- package/src/Annotation.ts +1 -0
- package/src/Collection.ts +2 -2
- package/src/Database.ts +50 -15
- package/src/Entity.ts +18 -12
- package/src/Extension.test.ts +235 -0
- package/src/Extension.ts +122 -0
- package/src/Feed.ts +107 -34
- package/src/Filter.test.ts +90 -0
- package/src/Filter.ts +97 -3
- package/src/Hypergraph.ts +3 -3
- package/src/Json.test.ts +175 -0
- package/src/Json.ts +102 -0
- package/src/Migration.ts +106 -0
- package/src/Obj.test.ts +105 -13
- package/src/Obj.ts +154 -33
- package/src/Query.test.ts +199 -9
- package/src/Query.ts +58 -8
- package/src/Ref.ts +2 -0
- package/src/Relation.ts +24 -20
- package/src/Type.ts +1 -1
- package/src/View.ts +1 -1
- package/src/exemplars.test.ts +21 -0
- package/src/index.ts +4 -0
- package/src/internal/Annotation/annotations.test.ts +51 -2
- package/src/internal/Annotation/annotations.ts +33 -14
- package/src/internal/Annotation/sorting.ts +0 -1
- package/src/internal/Entity/api.ts +0 -1
- package/src/internal/Entity/model.ts +2 -0
- package/src/internal/Entity/object.ts +0 -1
- package/src/internal/Entity/version.ts +0 -1
- package/src/internal/Format/date.test.ts +0 -1
- package/src/internal/Format/format.test.ts +0 -1
- package/src/internal/JsonSchema/json-schema-type.ts +1 -1
- package/src/internal/JsonSchema/json-schema.test.ts +1 -2
- package/src/internal/JsonSchema/json-schema.ts +1 -2
- package/src/internal/Obj/clone.ts +1 -1
- package/src/internal/Obj/create-object.test.ts +2 -4
- package/src/internal/Obj/create-object.ts +2 -3
- package/src/internal/Obj/deleted.ts +1 -1
- package/src/internal/Obj/ids.ts +1 -1
- package/src/internal/Obj/json-serializer.test.ts +49 -5
- package/src/internal/Obj/json-serializer.ts +47 -25
- package/src/internal/Obj/set-value.test.ts +24 -24
- package/src/internal/Obj/set-value.ts +1 -1
- package/src/internal/Query.ts +156 -0
- package/src/internal/Ref/ref-array.ts +0 -1
- package/src/internal/Ref/ref.test.ts +0 -1
- package/src/internal/Ref/ref.ts +18 -1
- package/src/internal/Type/compose.test.ts +0 -1
- package/src/internal/Type/echo-schema.ts +3 -4
- package/src/internal/common/README.md +1 -1
- package/src/internal/common/api/meta.ts +3 -3
- package/src/internal/common/proxy/change-context.ts +1 -1
- package/src/internal/common/proxy/change.test.ts +94 -94
- package/src/internal/common/proxy/errors.ts +2 -2
- package/src/internal/common/proxy/handler.test.ts +0 -2
- package/src/internal/common/proxy/json-serializer.ts +4 -1
- package/src/internal/common/proxy/make-object.ts +0 -1
- package/src/internal/common/proxy/ownership.ts +0 -1
- package/src/internal/common/proxy/reactive-array.ts +1 -1
- package/src/internal/common/proxy/reactive.test.ts +54 -0
- package/src/internal/common/proxy/reactive.ts +11 -3
- package/src/internal/common/proxy/typed-handler.test.ts +0 -1
- package/src/internal/common/proxy/typed-handler.ts +8 -10
- package/src/internal/common/proxy/typed-object.test.ts +2 -3
- package/src/internal/common/types/entity.ts +1 -1
- package/src/internal/common/types/meta.ts +12 -1
- package/src/internal/index.ts +1 -0
- package/src/testing/api.test.ts +0 -1
- package/src/testing/test-data.ts +157 -98
- package/dist/lib/neutral/chunk-43Y5DOS6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4JRI2ZJI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6DNYDXCV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6GPU7XC3.mjs.map +0 -7
- package/dist/lib/neutral/chunk-7VNVH63N.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BOZZPUXE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-C4JZK4J7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NEGC54NE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-NXMFBIT5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-OENWMTE6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ROAGDPV7.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SEMVAGBM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-W47JKR3X.mjs.map +0 -7
- /package/dist/lib/neutral/{chunk-FZO7LQO7.mjs.map → chunk-44HT3MEC.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-ANHVGJI4.mjs.map → chunk-7RVZT53K.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-BNCCGLJN.mjs.map → chunk-BICZKPQG.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-6K2MVI2O.mjs.map → chunk-BUBEC474.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-UTBRYVQC.mjs.map → chunk-QRZ2I3ZM.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-B5OXLWZL.mjs.map → chunk-TRPZU2HV.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-UI6MWK5W.mjs.map → chunk-TTCSATUD.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-OMUPQMLR.mjs.map → chunk-V72DY6LU.mjs.map} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Service
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-I2DARWPX.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ReferenceAnnotationId,
|
|
6
6
|
getSchemaDXN,
|
|
7
7
|
getTypeAnnotation,
|
|
8
8
|
getTypeIdentifierAnnotation
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TNBK56IN.mjs";
|
|
10
10
|
|
|
11
11
|
// src/internal/Ref/ref.ts
|
|
12
12
|
import * as Effect from "effect/Effect";
|
|
@@ -75,15 +75,7 @@ Ref.make = (obj) => {
|
|
|
75
75
|
throw new TypeError("Expected: ECHO object.");
|
|
76
76
|
}
|
|
77
77
|
const id = obj.id;
|
|
78
|
-
invariant(ObjectId.isValid(id), "Invalid object ID", {
|
|
79
|
-
F: __dxlog_file,
|
|
80
|
-
L: 225,
|
|
81
|
-
S: void 0,
|
|
82
|
-
A: [
|
|
83
|
-
"ObjectId.isValid(id)",
|
|
84
|
-
"'Invalid object ID'"
|
|
85
|
-
]
|
|
86
|
-
});
|
|
78
|
+
invariant(ObjectId.isValid(id), "Invalid object ID", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 76, S: void 0, A: ["ObjectId.isValid(id)", "'Invalid object ID'"] });
|
|
87
79
|
const dxn = DXN.fromLocalObjectId(id);
|
|
88
80
|
return new RefImpl(dxn, obj);
|
|
89
81
|
};
|
|
@@ -185,15 +177,7 @@ var RefImpl = class _RefImpl {
|
|
|
185
177
|
if (this.#target) {
|
|
186
178
|
return this.#target;
|
|
187
179
|
}
|
|
188
|
-
invariant(this.#resolver, "Resolver is not set", {
|
|
189
|
-
F: __dxlog_file,
|
|
190
|
-
L: 393,
|
|
191
|
-
S: this,
|
|
192
|
-
A: [
|
|
193
|
-
"this.#resolver",
|
|
194
|
-
"'Resolver is not set'"
|
|
195
|
-
]
|
|
196
|
-
});
|
|
180
|
+
invariant(this.#resolver, "Resolver is not set", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 181, S: this, A: ["this.#resolver", "'Resolver is not set'"] });
|
|
197
181
|
return this.#resolver.resolveSync(this.#dxn, true, this.#resolverCallback);
|
|
198
182
|
}
|
|
199
183
|
/**
|
|
@@ -203,15 +187,7 @@ var RefImpl = class _RefImpl {
|
|
|
203
187
|
if (this.#target) {
|
|
204
188
|
return this.#target;
|
|
205
189
|
}
|
|
206
|
-
invariant(this.#resolver, "Resolver is not set", {
|
|
207
|
-
F: __dxlog_file,
|
|
208
|
-
L: 404,
|
|
209
|
-
S: this,
|
|
210
|
-
A: [
|
|
211
|
-
"this.#resolver",
|
|
212
|
-
"'Resolver is not set'"
|
|
213
|
-
]
|
|
214
|
-
});
|
|
190
|
+
invariant(this.#resolver, "Resolver is not set", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 190, S: this, A: ["this.#resolver", "'Resolver is not set'"] });
|
|
215
191
|
const obj = await this.#resolver.resolve(this.#dxn);
|
|
216
192
|
if (obj == null) {
|
|
217
193
|
throw new Error("Object not found");
|
|
@@ -225,18 +201,16 @@ var RefImpl = class _RefImpl {
|
|
|
225
201
|
if (this.#target) {
|
|
226
202
|
return this.#target;
|
|
227
203
|
}
|
|
228
|
-
invariant(this.#resolver, "Resolver is not set", {
|
|
229
|
-
F: __dxlog_file,
|
|
230
|
-
L: 419,
|
|
231
|
-
S: this,
|
|
232
|
-
A: [
|
|
233
|
-
"this.#resolver",
|
|
234
|
-
"'Resolver is not set'"
|
|
235
|
-
]
|
|
236
|
-
});
|
|
204
|
+
invariant(this.#resolver, "Resolver is not set", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 203, S: this, A: ["this.#resolver", "'Resolver is not set'"] });
|
|
237
205
|
return await this.#resolver.resolve(this.#dxn);
|
|
238
206
|
}
|
|
239
207
|
/**
|
|
208
|
+
* @inheritdoc
|
|
209
|
+
*/
|
|
210
|
+
onResolved(callback) {
|
|
211
|
+
return this.#resolved.on(callback);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
240
214
|
* Do not inline the target object in the reference.
|
|
241
215
|
* Makes .target unavailable unless the reference is connected to a database context.
|
|
242
216
|
* Clones the reference object.
|
|
@@ -305,27 +279,11 @@ var RefImpl = class _RefImpl {
|
|
|
305
279
|
}
|
|
306
280
|
};
|
|
307
281
|
var setRefResolver = (ref, resolver) => {
|
|
308
|
-
invariant(ref instanceof RefImpl, "Ref is not an instance of RefImpl", {
|
|
309
|
-
F: __dxlog_file,
|
|
310
|
-
L: 506,
|
|
311
|
-
S: void 0,
|
|
312
|
-
A: [
|
|
313
|
-
"ref instanceof RefImpl",
|
|
314
|
-
"'Ref is not an instance of RefImpl'"
|
|
315
|
-
]
|
|
316
|
-
});
|
|
282
|
+
invariant(ref instanceof RefImpl, "Ref is not an instance of RefImpl", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 277, S: void 0, A: ["ref instanceof RefImpl", "'Ref is not an instance of RefImpl'"] });
|
|
317
283
|
ref._setResolver(resolver);
|
|
318
284
|
};
|
|
319
285
|
var getRefSavedTarget = (ref) => {
|
|
320
|
-
invariant(ref instanceof RefImpl, "Ref is not an instance of RefImpl", {
|
|
321
|
-
F: __dxlog_file,
|
|
322
|
-
L: 514,
|
|
323
|
-
S: void 0,
|
|
324
|
-
A: [
|
|
325
|
-
"ref instanceof RefImpl",
|
|
326
|
-
"'Ref is not an instance of RefImpl'"
|
|
327
|
-
]
|
|
328
|
-
});
|
|
286
|
+
invariant(ref instanceof RefImpl, "Ref is not an instance of RefImpl", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 283, S: void 0, A: ["ref instanceof RefImpl", "'Ref is not an instance of RefImpl'"] });
|
|
329
287
|
return ref._getSavedTarget();
|
|
330
288
|
};
|
|
331
289
|
var refVariance = {
|
|
@@ -348,15 +306,7 @@ var StaticRefResolver = class {
|
|
|
348
306
|
}
|
|
349
307
|
addSchema(schema) {
|
|
350
308
|
const dxn = getSchemaDXN(schema);
|
|
351
|
-
invariant(dxn, "Schema has no DXN", {
|
|
352
|
-
F: __dxlog_file,
|
|
353
|
-
L: 546,
|
|
354
|
-
S: this,
|
|
355
|
-
A: [
|
|
356
|
-
"dxn",
|
|
357
|
-
"'Schema has no DXN'"
|
|
358
|
-
]
|
|
359
|
-
});
|
|
309
|
+
invariant(dxn, "Schema has no DXN", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 308, S: this, A: ["dxn", "'Schema has no DXN'"] });
|
|
360
310
|
this.schemas.set(dxn.toString(), schema);
|
|
361
311
|
return this;
|
|
362
312
|
}
|
|
@@ -393,4 +343,4 @@ export {
|
|
|
393
343
|
refFromEncodedReference,
|
|
394
344
|
StaticRefResolver
|
|
395
345
|
};
|
|
396
|
-
//# sourceMappingURL=chunk-
|
|
346
|
+
//# sourceMappingURL=chunk-BMB7IHGB.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/Ref/ref.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Equal from 'effect/Equal';\nimport * as Hash from 'effect/Hash';\nimport * as Option from 'effect/Option';\nimport * as ParseResult from 'effect/ParseResult';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport type * as Types from 'effect/Types';\n\nimport { Event } from '@dxos/async';\nimport { type CustomInspectFunction, inspectCustom } from '@dxos/debug';\nimport { EncodedReference } from '@dxos/echo-protocol';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN, ObjectId } from '@dxos/keys';\n\nimport * as Database from '../../Database';\nimport { ReferenceAnnotationId, getSchemaDXN, getTypeAnnotation, getTypeIdentifierAnnotation } from '../Annotation';\nimport type { AnyEntity, AnyProperties } from '../common/types';\nimport { type JsonSchemaType } from '../JsonSchema';\n\n/**\n * The `$id` and `$ref` fields for an ECHO reference schema.\n */\nexport const JSON_SCHEMA_ECHO_REF_ID = '/schemas/echo/ref';\n\nexport const getSchemaReference = (property: JsonSchemaType): { typename: string } | undefined => {\n const { $id, reference: { schema: { $ref } = {} } = {} } = property;\n if ($id === JSON_SCHEMA_ECHO_REF_ID && $ref) {\n return { typename: DXN.parse($ref).typename };\n }\n};\n\nexport const createSchemaReference = (typename: string): Types.DeepMutable<JsonSchemaType> => {\n return {\n $id: JSON_SCHEMA_ECHO_REF_ID,\n reference: {\n schema: {\n $ref: DXN.fromTypename(typename).toString(),\n },\n },\n };\n};\n\n/**\n * Runtime type-info for a reference extracted from effect AST.\n */\nexport type RefereneAST = {\n /**\n * Typename of linked schema.\n */\n typename: string;\n\n /**\n * Version of linked schema.\n */\n version: string;\n};\n\nexport const getReferenceAst = (ast: SchemaAST.AST): RefereneAST | undefined => {\n if (ast._tag !== 'Declaration' || !ast.annotations[ReferenceAnnotationId]) {\n return undefined;\n }\n return {\n typename: (ast.annotations[ReferenceAnnotationId] as any).typename,\n version: (ast.annotations[ReferenceAnnotationId] as any).version,\n };\n};\n\nexport const RefTypeId: unique symbol = Symbol('@dxos/echo/internal/Ref');\n\n/**\n * Reference Schema.\n */\nexport interface RefSchema<T extends AnyEntity> extends Schema.SchemaClass<Ref<T>, EncodedReference> {}\n\n/**\n * Type of the `Ref` function and extra methods attached to it.\n */\nexport interface RefFn {\n <S extends Schema.Schema.Any>(schema: S): RefSchema<Schema.Schema.Type<S>>;\n\n /**\n * @returns True if the object is a reference.\n */\n isRef: (obj: unknown) => obj is Ref<any>;\n\n /**\n * @returns True if the reference points to the given object id.\n */\n hasObjectId: (id: ObjectId) => (ref: Ref<any>) => boolean;\n\n /**\n * @returns True if the schema is a reference schema.\n */\n isRefSchema: (schema: Schema.Schema<any, any>) => schema is RefSchema<any>;\n\n /**\n * @returns True if the schema AST is a reference schema.\n */\n isRefSchemaAST: (ast: SchemaAST.AST) => boolean;\n\n /**\n * Constructs a reference that points to the given object.\n */\n // TODO(burdon): Narrow to Obj.Unknown?\n make: <T extends AnyEntity>(object: T) => Ref<T>;\n\n /**\n * Constructs a reference that points to the object specified by the provided DXN.\n */\n fromDXN: (dxn: DXN) => Ref<any>;\n}\n\n/**\n * Schema builder for references.\n */\nexport const Ref: RefFn = <S extends Schema.Schema.Any>(schema: S): RefSchema<Schema.Schema.Type<S>> => {\n assertArgument(Schema.isSchema(schema), 'schema', 'Must call with an instance of effect-schema');\n const annotation = getTypeAnnotation(schema);\n if (annotation == null) {\n throw new Error('Reference target must be an ECHO schema.');\n }\n\n return createEchoReferenceSchema(getTypeIdentifierAnnotation(schema), annotation.typename, annotation.version);\n};\n\n/**\n * Represents materialized reference to a target.\n * This is the data type for the fields marked as ref.\n */\nexport interface Ref<T> extends Pipeable.Pipeable {\n /**\n * Target object DXN.\n */\n get dxn(): DXN;\n\n /**\n * Returns true if the reference has a target available (inlined or resolver set).\n */\n get isAvailable(): boolean;\n\n /**\n * @returns The reference target.\n * May return `undefined` if the object is not loaded in the working set.\n * Accessing this property, even if it returns `undefined` will trigger the object to be loaded to the working set.\n */\n get target(): T | undefined;\n\n /**\n * @returns Promise that will resolves with the target object.\n * Will load the object from disk if it is not present in the working set.\n * @throws If the object is not available locally.\n */\n load(): Promise<T>;\n\n /**\n * @returns Promise that will resolves with the target object or undefined if the object is not loaded locally.\n */\n\n tryLoad(): Promise<T | undefined>;\n\n /**\n * Subscribe to the ref's resolution event.\n * The callback fires when the target object becomes available in the working set\n * (e.g. when its document is loaded after sibling-client mutation).\n * Note: the resolver only schedules a notification when the target is requested\n * via {@link target} while it is not yet loaded.\n * @returns Function that unsubscribes the callback.\n */\n onResolved(callback: () => void): () => void;\n\n /**\n * Do not inline the target object in the reference.\n * Makes .target unavailable unless the reference is connected to a database context.\n *\n * When serialized with toJSON, the difference is between:\n * `{ \"/\": \"dxn:...\" }`\n * and\n * `{ \"/\": \"dxn:...\", \"target\": { ... } }`\n *\n * Clones the reference object.\n */\n noInline(): Ref<T>;\n\n /**\n * Serializes the reference to a JSON object.\n * The serialization format is compatible with the IPLD-style encoded references.\n * When a reference has a saved target (i.e. the target or object holding the reference is not in the database),\n * the target is included in the serialized object.\n *\n * Examples:\n * `{ \"/\": \"dxn:...\" }`\n * `{ \"/\": \"dxn:...\", \"target\": { ... } }`\n */\n encode(): EncodedReference;\n\n [RefTypeId]: {\n _T: T;\n };\n}\n\nexport declare namespace Ref {\n /**\n * Target of the reference.\n */\n export type Target<R> = R extends Ref<infer U> ? U : never;\n}\n\nRef.isRef = (obj: any): obj is Ref<any> => {\n return obj && typeof obj === 'object' && RefTypeId in obj;\n};\n\nRef.hasObjectId = (id: ObjectId) => (ref: Ref<any>) => ref.dxn.isLocalObjectId() && ref.dxn.parts[1] === id;\n\nRef.isRefSchema = (schema: Schema.Schema<any, any>): schema is RefSchema<any> => {\n return Ref.isRefSchemaAST(schema.ast);\n};\n\nRef.isRefSchemaAST = (ast: SchemaAST.AST): boolean => {\n return SchemaAST.getAnnotation(ast, ReferenceAnnotationId).pipe(Option.isSome);\n};\n\nRef.make = <T extends AnyProperties>(obj: T): Ref<T> => {\n if (typeof obj !== 'object' || obj === null) {\n throw new TypeError('Expected: ECHO object.');\n }\n\n // TODO(dmaretskyi): Extract to `getObjectDXN` function.\n const id = obj.id;\n invariant(ObjectId.isValid(id), 'Invalid object ID');\n const dxn = DXN.fromLocalObjectId(id);\n return new RefImpl(dxn, obj);\n};\n\nRef.fromDXN = (dxn: DXN): Ref<any> => {\n assertArgument(dxn instanceof DXN, 'dxn', 'Expected DXN');\n return new RefImpl(dxn);\n};\n\n/**\n * `reference` field on the schema object.\n */\nexport type JsonSchemaReferenceInfo = {\n schema: { $ref: string };\n schemaVersion?: string;\n};\n\n/**\n * @internal\n */\n// TODO(burdon): Move to json schema and make private?\nexport const createEchoReferenceSchema = (\n echoId: string | undefined,\n typename: string | undefined,\n version: string | undefined,\n): Schema.SchemaClass<Ref<any>, EncodedReference> => {\n if (!echoId && !typename) {\n throw new TypeError('Either echoId or typename must be provided.');\n }\n\n const referenceInfo: JsonSchemaReferenceInfo = {\n schema: {\n // TODO(dmaretskyi): Include version?\n $ref: echoId ?? DXN.fromTypename(typename!).toString(),\n },\n schemaVersion: version,\n };\n\n // TODO(dmaretskyi): Add name and description.\n const refSchema = Schema.declare<Ref<any>, EncodedReference, []>(\n [],\n {\n encode: () => {\n return (value) =>\n Effect.gen(function* () {\n if (Ref.isRef(value)) {\n return EncodedReference.fromDXN((value as Ref<any>).dxn);\n } else if (EncodedReference.isEncodedReference(value)) {\n return value;\n }\n throw new Error('Invalid reference');\n });\n },\n decode: () => {\n return (value) =>\n Effect.gen(function* () {\n const dbService = yield* Effect.serviceOption(Database.Service);\n\n // TODO(dmaretskyi): This branch seems to be taken by Schema.is\n if (Ref.isRef(value)) {\n if (Option.isSome(dbService)) {\n return dbService.value.db.makeRef(value.dxn);\n } else {\n return value;\n }\n }\n\n if (!EncodedReference.isEncodedReference(value)) {\n return yield* Effect.fail(new ParseResult.Unexpected(value, 'reference'));\n }\n if (Option.isSome(dbService)) {\n return dbService.value.db.makeRef(EncodedReference.toDXN(value));\n } else {\n return Ref.fromDXN(EncodedReference.toDXN(value));\n }\n });\n },\n },\n {\n jsonSchema: {\n // TODO(dmaretskyi): We should remove `$id` and keep `$ref` with a fully qualified name.\n $id: JSON_SCHEMA_ECHO_REF_ID,\n $ref: JSON_SCHEMA_ECHO_REF_ID,\n reference: referenceInfo,\n },\n [ReferenceAnnotationId]: {\n typename: typename ?? '',\n version,\n },\n },\n );\n\n return refSchema;\n};\n\nconst getSchemaExpectedName = (ast: SchemaAST.Annotated): string | undefined => {\n return SchemaAST.getIdentifierAnnotation(ast).pipe(\n Option.orElse(() => SchemaAST.getTitleAnnotation(ast)),\n Option.orElse(() => SchemaAST.getDescriptionAnnotation(ast)),\n Option.getOrElse(() => undefined),\n );\n};\n\nexport interface RefResolver {\n /**\n * Resolve ref synchronously from the objects in the working set.\n *\n * @param dxn\n * @param load If true the resolver should attempt to load the object from disk.\n * @param onLoad Callback to call when the object is loaded.\n */\n resolveSync(dxn: DXN, load: boolean, onLoad?: () => void): AnyProperties | undefined;\n\n /**\n * Resolver ref asynchronously.\n */\n resolve(dxn: DXN): Promise<AnyProperties | undefined>;\n\n // TODO(dmaretskyi): Combine with `resolve`.\n resolveSchema(dxn: DXN): Promise<Schema.Schema.AnyNoContext | undefined>;\n}\n\nexport class RefImpl<T> implements Ref<T> {\n #dxn: DXN;\n #resolver?: RefResolver = undefined;\n #resolved = new Event<void>();\n\n /**\n * Target is set when the reference is created from a specific object.\n * In this case, the target might not be in the database.\n */\n #target: T | undefined = undefined;\n\n /**\n * Callback to issue a reactive notification when object is resolved.\n */\n #resolverCallback = () => {\n this.#resolved.emit();\n };\n\n constructor(dxn: DXN, target?: T) {\n this.#dxn = dxn;\n this.#target = target;\n }\n\n /**\n * @inheritdoc\n */\n get dxn(): DXN {\n return this.#dxn;\n }\n\n /**\n * @inheritdoc\n */\n get isAvailable(): boolean {\n return this.#target !== undefined || this.#resolver !== undefined;\n }\n\n /**\n * @inheritdoc\n */\n get target(): T | undefined {\n if (this.#target) {\n return this.#target;\n }\n\n invariant(this.#resolver, 'Resolver is not set');\n return this.#resolver.resolveSync(this.#dxn, true, this.#resolverCallback) as T | undefined;\n }\n\n /**\n * @inheritdoc\n */\n async load(): Promise<T> {\n if (this.#target) {\n return this.#target;\n }\n invariant(this.#resolver, 'Resolver is not set');\n const obj = await this.#resolver.resolve(this.#dxn);\n if (obj == null) {\n throw new Error('Object not found');\n }\n return obj as T;\n }\n\n /**\n * @inheritdoc\n */\n async tryLoad(): Promise<T | undefined> {\n if (this.#target) {\n return this.#target;\n }\n invariant(this.#resolver, 'Resolver is not set');\n return (await this.#resolver.resolve(this.#dxn)) as T | undefined;\n }\n\n /**\n * @inheritdoc\n */\n onResolved(callback: () => void): () => void {\n return this.#resolved.on(callback);\n }\n\n /**\n * Do not inline the target object in the reference.\n * Makes .target unavailable unless the reference is connected to a database context.\n * Clones the reference object.\n */\n noInline(): RefImpl<T> {\n const ref = new RefImpl<T>(this.#dxn, undefined);\n ref.#resolver = this.#resolver;\n return ref;\n }\n\n encode(): EncodedReference {\n return {\n '/': this.#dxn.toString(),\n ...(this.#target ? { target: this.#target } : {}),\n };\n }\n\n /**\n * Serializes the reference to a JSON object.\n * The serialization format is compatible with the IPLD-style encoded references.\n * When a reference has a saved target (i.e. the target or object holding the reference is not in the database),\n * the target is included in the serialized object.\n */\n toJSON(): EncodedReference {\n return this.encode();\n }\n\n toString(): string {\n if (this.#target) {\n return `Ref(${this.#target.toString()})`;\n }\n\n return `Ref(${this.#dxn.toString()})`;\n }\n\n [inspectCustom]: CustomInspectFunction = (depth, options, inspect) => {\n return this.toString();\n };\n\n [RefTypeId] = refVariance;\n\n /**\n * Effect Hash trait. Required for MutableHashMap-based caches (e.g., Atom.family)\n * to deduplicate Ref instances that point to the same object.\n * ECHO proxies return new RefImpl instances on every property access,\n * so without this, each access would create a separate cache entry.\n */\n [Hash.symbol](): number {\n return Hash.hash(this.#dxn.toString());\n }\n\n /** Effect Equal trait. See {@link Hash.symbol} for rationale. */\n [Equal.symbol](that: Equal.Equal): boolean {\n return that instanceof RefImpl && this.#dxn.toString() === that.dxn.toString();\n }\n\n /**\n * Internal method to set the resolver.\n *\n * @internal\n */\n _setResolver(resolver: RefResolver): void {\n this.#resolver = resolver;\n }\n\n /**\n * @internal\n */\n _getSavedTarget(): T | undefined {\n return this.#target;\n }\n\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n }\n}\n\n/**\n * Internal API for setting the reference resolver.\n */\nexport const setRefResolver = (ref: Ref<any>, resolver: RefResolver) => {\n invariant(ref instanceof RefImpl, 'Ref is not an instance of RefImpl');\n ref._setResolver(resolver);\n};\n\n/**\n * Internal API for getting the saved target on a reference.\n */\nexport const getRefSavedTarget = (ref: Ref<any>): AnyProperties | undefined => {\n invariant(ref instanceof RefImpl, 'Ref is not an instance of RefImpl');\n return ref._getSavedTarget();\n};\n\n// Used to validate reference target type.\nconst refVariance: Ref<any>[typeof RefTypeId] = {\n _T: null as any,\n};\n\nexport const refFromEncodedReference = (encodedReference: EncodedReference, resolver?: RefResolver): Ref<any> => {\n const dxn = DXN.parse(encodedReference['/']);\n const ref = new RefImpl(dxn);\n\n // TODO(dmaretskyi): Handle inline target in the encoded reference.\n\n if (resolver) {\n setRefResolver(ref, resolver);\n }\n return ref;\n};\n\nexport class StaticRefResolver implements RefResolver {\n public objects = new Map<ObjectId, AnyProperties>();\n public schemas = new Map<DXN.String, Schema.Schema.AnyNoContext>();\n\n addObject(obj: AnyProperties): this {\n this.objects.set(obj.id, obj);\n return this;\n }\n\n addSchema(schema: Schema.Schema.AnyNoContext): this {\n const dxn = getSchemaDXN(schema);\n invariant(dxn, 'Schema has no DXN');\n this.schemas.set(dxn.toString(), schema);\n return this;\n }\n\n resolveSync(dxn: DXN, _load: boolean, _onLoad?: () => void): AnyProperties | undefined {\n const id = dxn?.asEchoDXN()?.echoId;\n if (id == null) {\n return undefined;\n }\n\n return this.objects.get(id);\n }\n\n async resolve(dxn: DXN): Promise<AnyProperties | undefined> {\n const id = dxn?.asEchoDXN()?.echoId;\n if (id == null) {\n return undefined;\n }\n\n return this.objects.get(id);\n }\n\n async resolveSchema(dxn: DXN): Promise<Schema.Schema.AnyNoContext | undefined> {\n return this.schemas.get(dxn.toString());\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Effect", "Equal", "Hash", "Option", "ParseResult", "Pipeable", "Schema", "SchemaAST", "Event", "inspectCustom", "EncodedReference", "assertArgument", "invariant", "DXN", "ObjectId", "reference", "$ref", "$id", "JSON_SCHEMA_ECHO_REF_ID", "typename", "schema", "undefined", "version", "annotation", "getTypeAnnotation", "Error", "createEchoReferenceSchema", "isRef", "obj", "hasObjectId", "ref", "isLocalObjectId", "Ref", "isRefSchemaAST", "ast", "make", "TypeError", "dxn", "DXN", "fromDXN", "RefImpl", "referenceInfo", "schemaVersion", "Effect", "gen", "EncodedReference", "value", "dbService", "Option", "isSome", "jsonSchema", "ReferenceAnnotationId", "getSchemaExpectedName", "undefined", "target", "invariant", "obj", "Error", "ref", "encode", "toString", "inspectCustom", "depth", "options", "inspect", "RefTypeId", "refVariance", "pipe", "_setResolver", "resolver", "_getSavedTarget", "dxn", "schemas", "addObject", "objects", "set", "addSchema", "schema", "resolveSync", "id", "resolve", "resolveSchema"]
|
|
7
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
object
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-C4PSESGN.mjs";
|
|
4
4
|
import {
|
|
5
5
|
make
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X3356HPV.mjs";
|
|
7
7
|
import {
|
|
8
8
|
LabelAnnotation,
|
|
9
9
|
SystemTypeAnnotation
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TNBK56IN.mjs";
|
|
11
11
|
import {
|
|
12
12
|
__export
|
|
13
13
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -53,4 +53,4 @@ export {
|
|
|
53
53
|
findTagByLabel,
|
|
54
54
|
Tag_exports
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-BUBEC474.mjs.map
|
|
@@ -4,17 +4,17 @@ import {
|
|
|
4
4
|
EchoSchema,
|
|
5
5
|
PersistentSchema,
|
|
6
6
|
isMutable
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Z5GKP74O.mjs";
|
|
8
8
|
import {
|
|
9
9
|
getSchemaDXN,
|
|
10
10
|
getSchemaTypename,
|
|
11
11
|
getSchemaVersion,
|
|
12
12
|
getTypeAnnotation
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TNBK56IN.mjs";
|
|
14
14
|
import {
|
|
15
15
|
EntityKind,
|
|
16
16
|
SchemaKindId
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-N4B7FHQT.mjs";
|
|
18
18
|
import {
|
|
19
19
|
__export
|
|
20
20
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -51,28 +51,12 @@ var getDXN = (schema) => {
|
|
|
51
51
|
};
|
|
52
52
|
var getTypename = (schema) => {
|
|
53
53
|
const typename = getSchemaTypename(schema);
|
|
54
|
-
invariant(typeof typename === "string" && !typename.startsWith("dxn:"), "Invalid typename", {
|
|
55
|
-
F: __dxlog_file,
|
|
56
|
-
L: 230,
|
|
57
|
-
S: void 0,
|
|
58
|
-
A: [
|
|
59
|
-
"typeof typename === 'string' && !typename.startsWith('dxn:')",
|
|
60
|
-
"'Invalid typename'"
|
|
61
|
-
]
|
|
62
|
-
});
|
|
54
|
+
invariant(typeof typename === "string" && !typename.startsWith("dxn:"), "Invalid typename", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 70, S: void 0, A: ["typeof typename === 'string' && !typename.startsWith('dxn:')", "'Invalid typename'"] });
|
|
63
55
|
return typename;
|
|
64
56
|
};
|
|
65
57
|
var getVersion = (schema) => {
|
|
66
58
|
const version = getSchemaVersion(schema);
|
|
67
|
-
invariant(typeof version === "string" && version.match(/^\d+\.\d+\.\d+$/), "Invalid version", {
|
|
68
|
-
F: __dxlog_file,
|
|
69
|
-
L: 240,
|
|
70
|
-
S: void 0,
|
|
71
|
-
A: [
|
|
72
|
-
"typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/)",
|
|
73
|
-
"'Invalid version'"
|
|
74
|
-
]
|
|
75
|
-
});
|
|
59
|
+
invariant(typeof version === "string" && version.match(/^\d+\.\d+\.\d+$/), "Invalid version", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 78, S: void 0, A: ["typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/)", "'Invalid version'"] });
|
|
76
60
|
return version;
|
|
77
61
|
};
|
|
78
62
|
var isMutable2 = isMutable;
|
|
@@ -94,4 +78,4 @@ export {
|
|
|
94
78
|
getMeta,
|
|
95
79
|
Type_exports
|
|
96
80
|
};
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-C4PSESGN.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Type.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Schema from 'effect/Schema';\n\nimport { type EncodedReference } from '@dxos/echo-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { type DXN } from '@dxos/keys';\nimport { type ToMutable } from '@dxos/util';\n\nimport type * as Entity from './Entity';\nimport * as
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;mBAAAA;EAAA;;;;;AASA,SAASC,iBAAiB;;
|
|
6
|
-
"names": ["isMutable", "invariant", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Schema from 'effect/Schema';\n\nimport { type EncodedReference } from '@dxos/echo-protocol';\nimport { invariant } from '@dxos/invariant';\nimport { type DXN } from '@dxos/keys';\nimport { type ToMutable } from '@dxos/util';\n\nimport type * as Entity from './Entity';\nimport * as internal from './internal';\nimport * as typeInternal from './internal/Type';\nimport type * as ObjModule from './Obj';\nimport type * as RelationModule from './Relation';\n\n/**\n * Dynamic type that can be constructed, mutated, and persisted in the ECHO database.\n */\nexport const RuntimeType = typeInternal.EchoSchema;\n\n/**\n * Dynamic type that can be constructed, mutated, and persisted in the ECHO database.\n */\nexport type RuntimeType = typeInternal.EchoSchema;\n\n//\n// Internal types (not exported)\n//\n\n/**\n * Type that marks a schema as an ECHO schema.\n * The value indicates the entity kind (Object or Relation).\n */\ntype EchoSchemaKind<K extends internal.EntityKind = internal.EntityKind> = {\n readonly [internal.SchemaKindId]: K;\n};\n\n//\n// Obj - Runtime schema for any ECHO object\n//\n\n/**\n * TypeScript type for an ECHO object schema.\n * `T` is the instance type produced by the schema.\n * `Fields` is the optional struct fields type for introspection.\n *\n * @example\n * ```ts\n * const PersonSchema: Type.Obj<Person> = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.object({ typename: 'Person', version: '0.1.0' }));\n *\n * // Access fields for introspection:\n * Object.keys(PersonSchema.fields); // ['name']\n * ```\n */\nexport interface Obj<T, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>\n extends\n internal.TypeMeta,\n EchoSchemaKind<internal.EntityKind.Object>,\n Schema.AnnotableClass<\n Obj<T, Fields>,\n Entity.OfKind<typeof Entity.Kind.Object> & T,\n Schema.Simplify<ObjModule.BaseObjJson & ToMutable<T>>,\n never\n > {\n /**\n * The fields defined in the original struct schema.\n * Allows accessing field definitions for introspection.\n */\n readonly fields: Fields;\n}\n\n/**\n * Structural base type for any ECHO object schema.\n * Accepts both static schemas (created with Type.object()) and EchoSchema.\n * NOTE: Does not include the brand symbol to avoid TS4053 declaration portability issues.\n * Use Type.isObjectSchema() for runtime type guards.\n */\ntype ObjectSchemaBase = Schema.Schema.AnyNoContext & {\n readonly typename: string;\n readonly version: string;\n};\n\n/**\n * Type that represents any ECHO object schema.\n * Accepts both static schemas (Type.object()) and mutable schemas (EchoSchema).\n */\nexport type AnyObj = ObjectSchemaBase;\n\n/**\n * Factory function to create an ECHO object schema.\n * Adds object metadata annotations to an Effect schema.\n *\n * @example\n * ```ts\n * const Person = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.object({ typename: 'com.example.type.person', version: '0.1.0' }));\n * ```\n */\nexport const object: {\n (opts: internal.TypeMeta): <Self extends Schema.Schema.Any>(self: Self) => Obj<Schema.Schema.Type<Self>>;\n} = internal.EchoObjectSchema as any;\n\n//\n// PersistentType (Schema stored in database)\n//\n\nexport const PersistentType: Obj<typeInternal.PersistentSchema> = typeInternal.PersistentSchema as any;\n\nexport interface PersistentType extends Schema.Schema.Type<typeof PersistentType> {}\n\n/**\n * TypeScript type for an ECHO relation schema.\n * `T` is the instance type produced by the schema (excluding source/target).\n * `Source` and `Target` are the endpoint types.\n * `Fields` is the optional struct fields type for introspection.\n */\nexport interface Relation<T, Source, Target, Fields extends Schema.Struct.Fields = Schema.Struct.Fields>\n extends\n internal.TypeMeta,\n EchoSchemaKind<internal.EntityKind.Relation>,\n Schema.AnnotableClass<\n Relation<T, Source, Target, Fields>,\n Entity.OfKind<typeof Entity.Kind.Relation> & RelationModule.Endpoints<Source, Target> & T,\n Schema.Simplify<RelationModule.BaseRelationJson & ToMutable<T>>,\n never\n > {\n /**\n * The fields defined in the original struct schema.\n * Allows accessing field definitions for introspection.\n */\n readonly fields: Fields;\n}\n\n/**\n * Structural base type for any ECHO relation schema.\n * Accepts static schemas (created with Type.relation()).\n * NOTE: Does not include the brand symbol to avoid TS4053 declaration portability issues.\n * Use Type.isRelationSchema() for runtime type guards.\n */\ntype RelationSchemaBase = Schema.Schema.AnyNoContext & {\n readonly typename: string;\n readonly version: string;\n};\n\n/**\n * Type that represents any ECHO relation schema.\n * Accepts static schemas (Type.relation()).\n */\nexport type AnyRelation = RelationSchemaBase;\n\n/**\n * Factory function to create an ECHO relation schema.\n * Adds relation metadata annotations to an Effect schema.\n *\n * @example\n * ```ts\n * const WorksFor = Schema.Struct({\n * role: Schema.String,\n * }).pipe(Type.relation({\n * typename: 'com.example.type.works-for',\n * version: '0.1.0',\n * source: Person,\n * target: Company,\n * }));\n * ```\n */\nexport const relation: {\n <SourceSchema extends Schema.Schema.AnyNoContext, TargetSchema extends Schema.Schema.AnyNoContext>(\n opts: internal.EchoRelationSchemaOptions<SourceSchema, TargetSchema>,\n ): <Self extends Schema.Schema.Any>(\n self: Self,\n ) => Relation<Schema.Schema.Type<Self>, Schema.Schema.Type<SourceSchema>, Schema.Schema.Type<TargetSchema>>;\n} = internal.EchoRelationSchema as any;\n\n/**\n * Type alias for any ECHO entity schema (object or relation).\n * Use this in type annotations for schema parameters.\n */\nexport type AnyEntity = AnyObj | AnyRelation;\n\n/**\n * Type guard to check if a schema is an object schema.\n * NOTE: This checks SCHEMAS, not instances. Use Obj.isObject for instances.\n */\nexport const isObjectSchema = (schema: AnyEntity): schema is AnyObj => {\n return (schema as any)[internal.SchemaKindId] === internal.EntityKind.Object;\n};\n\n/**\n * Type guard to check if a schema is a relation schema.\n * NOTE: This checks SCHEMAS, not instances. Use Relation.isRelation for instances.\n */\nexport const isRelationSchema = (schema: AnyEntity): schema is AnyRelation => {\n return (schema as any)[internal.SchemaKindId] === internal.EntityKind.Relation;\n};\n\n/**\n * Type that represents any Ref schema (with unknown target type).\n * This is a schema type, not an instance type.\n */\nexport type AnyRef = Schema.Schema<internal.Ref<any>, EncodedReference>;\n\n//\n// Schema utility functions\n//\n\n/**\n * Gets the full DXN of the schema.\n * Will include the version if it's a `type` DXN.\n * @example \"dxn:com.example.type.person:0.1.0\"\n * @example \"dxn:echo:SSSSSSSSSS:XXXXXXXXXXXXX\"\n */\nexport const getDXN = (schema: AnyEntity): DXN | undefined => {\n return internal.getSchemaDXN(schema);\n};\n\n/**\n * @param schema - Schema to get the typename from.\n * @returns The typename of the schema. Example: `com.example.type.person`.\n */\nexport const getTypename = (schema: AnyEntity): string => {\n const typename = internal.getSchemaTypename(schema);\n invariant(typeof typename === 'string' && !typename.startsWith('dxn:'), 'Invalid typename');\n return typename;\n};\n\n/**\n * Gets the version of the schema.\n * @example 0.1.0\n */\nexport const getVersion = (schema: AnyEntity): string => {\n const version = internal.getSchemaVersion(schema);\n invariant(typeof version === 'string' && version.match(/^\\d+\\.\\d+\\.\\d+$/), 'Invalid version');\n return version;\n};\n\n/**\n * @returns True if the schema is mutable.\n */\nexport const isMutable = typeInternal.isMutable;\n\n/**\n * ECHO type metadata.\n */\nexport type Meta = internal.TypeAnnotation;\n\n/**\n * Gets the meta data of the schema.\n */\nexport const getMeta = (schema: AnyEntity): Meta | undefined => {\n return internal.getTypeAnnotation(schema);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;mBAAAA;EAAA;;;;;AASA,SAASC,iBAAiB;AAU1B,IAAA,eAAA;;AA2FA,IAAA,SAAA;;;AAmFE,IAAA,iBAAA,CAAA,WAAA;AAEF,SAAA,OAAA,YAAA,MAAA,WAAA;;AAME,IAAA,mBAAA,CAAA,WAAA;AAQA,SAAA,OAAA,YAAA,MAAA,WAAA;AACF;AAWE,IAAA,SAAA,CAAA,WAAA;AAEF,SAAA,aAAA,MAAA;;AAMEC,IAAU,cAAOC,CAAAA,WAAa;AAC9B,QAAA,WAAOA,kBAAAA,MAAAA;AACP,YAAA,OAAA,aAAA,YAAA,CAAA,SAAA,WAAA,MAAA,GAAA,oBAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,QAAA,GAAA,CAAA,gEAAA,oBAAA,EAAA,CAAA;AAEF,SAAA;;AAMED,IAAU,aAAOE,CAAAA,WAAY;AAC7B,QAAA,UAAOA,iBAAAA,MAAAA;AACP,YAAA,OAAA,YAAA,YAAA,QAAA,MAAA,iBAAA,GAAA,mBAAA,EAAA,YAAA,YAAA,GAAA,cAAA,GAAA,IAAA,GAAA,QAAA,GAAA,CAAA,wEAAA,mBAAA,EAAA,CAAA;AAEF,SAAA;;;AAeE,IAAA,UAAA,CAAA,WAAA;;;",
|
|
6
|
+
"names": ["isMutable", "invariant", "invariant", "typename", "version"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSchemaDXN
|
|
3
|
+
} from "./chunk-TNBK56IN.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
7
|
+
|
|
8
|
+
// src/Migration.ts
|
|
9
|
+
var Migration_exports = {};
|
|
10
|
+
__export(Migration_exports, {
|
|
11
|
+
define: () => define
|
|
12
|
+
});
|
|
13
|
+
var define = (options) => {
|
|
14
|
+
const fromType = getSchemaDXN(options.from);
|
|
15
|
+
if (!fromType) {
|
|
16
|
+
throw new Error("Invalid from schema");
|
|
17
|
+
}
|
|
18
|
+
const toType = getSchemaDXN(options.to);
|
|
19
|
+
if (!toType) {
|
|
20
|
+
throw new Error("Invalid to schema");
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
fromType,
|
|
24
|
+
toType,
|
|
25
|
+
fromSchema: options.from,
|
|
26
|
+
toSchema: options.to,
|
|
27
|
+
transform: options.transform,
|
|
28
|
+
onMigration: options.onMigration
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
define,
|
|
34
|
+
Migration_exports
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-FIWO2FZK.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Migration.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Schema from 'effect/Schema';\n\nimport { type DXN } from '@dxos/keys';\n\nimport type * as Database from './Database';\nimport type * as Entity from './Entity';\nimport { MetaId, type ObjectMeta, getSchemaDXN } from './internal';\n\n/**\n * Result returned by a migration's `transform` callback.\n * The data shape matches the target schema; the optional `[Obj.Meta]` symbol key lets the\n * transform update the object's meta (e.g. `key` / `version`) atomically with the data swap.\n */\nexport type TransformResult<To extends Schema.Schema.AnyNoContext> = Omit<\n Schema.Schema.Type<To>,\n 'id' | Entity.KindId\n> & {\n [MetaId]?: Partial<ObjectMeta>;\n};\n\ntype DefineObjectMigrationOptions<From extends Schema.Schema.AnyNoContext, To extends Schema.Schema.AnyNoContext> = {\n from: From;\n to: To;\n /**\n * Pure function that converts the old object data to the new object data.\n *\n * The returned object may include an optional `[Obj.Meta]` entry to update the object's meta\n * (e.g. registry `key` / `version`) atomically with the data swap.\n */\n // TODO(dmaretskyi): `id` should not be a part of the schema.\n transform: (from: Schema.Schema.Type<From>, context: ObjectMigrationContext) => Promise<TransformResult<To>>;\n\n /**\n * Callback that is called after the object is migrated. Called for every object that is migrated.\n *\n * NOTE: Database mutations performed in this callback are not guaranteed to be idempotent.\n * If multiple peers run the migration separately, the effects may be applied multiple times.\n */\n onMigration?: (params: OnMigrateProps<From, To>) => Promise<void>;\n};\n\n/**\n * Context passed to object migration callbacks.\n */\nexport type ObjectMigrationContext = {\n db: Database.Database;\n};\n\ntype OnMigrateProps<From extends Schema.Schema.AnyNoContext, To extends Schema.Schema.AnyNoContext> = {\n before: Schema.Schema.Type<From>;\n object: Schema.Schema.Type<To>;\n db: Database.Database;\n};\n\n/**\n * Definition of a migration from one object schema version to another.\n */\nexport type ObjectMigration = {\n fromType: DXN;\n toType: DXN;\n fromSchema: Schema.Schema.AnyNoContext;\n toSchema: Schema.Schema.AnyNoContext;\n transform: (from: unknown, context: ObjectMigrationContext) => Promise<unknown>;\n onMigration?: (params: OnMigrateProps<any, any>) => Promise<void>;\n};\n\n/**\n * Define a migration between two object schemas.\n *\n * @example\n * ```ts\n * const migration = Migration.define({\n * from: ContactV1,\n * to: ContactV2,\n * transform: async (from) => ({ name: `${from.firstName} ${from.lastName}` }),\n * onMigration: async () => {},\n * });\n * ```\n */\nexport const define = <From extends Schema.Schema.AnyNoContext, To extends Schema.Schema.AnyNoContext>(\n options: DefineObjectMigrationOptions<From, To>,\n): ObjectMigration => {\n const fromType = getSchemaDXN(options.from);\n if (!fromType) {\n throw new Error('Invalid from schema');\n }\n const toType = getSchemaDXN(options.to);\n if (!toType) {\n throw new Error('Invalid to schema');\n }\n\n return {\n fromType,\n toType,\n fromSchema: options.from,\n toSchema: options.to,\n transform: options.transform as any,\n onMigration: options.onMigration as any,\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;;;;AAqFO,IAAMA,SAAS,CACpBC,YAAAA;AAEA,QAAMC,WAAWC,aAAaF,QAAQG,IAAI;AAC1C,MAAI,CAACF,UAAU;AACb,UAAM,IAAIG,MAAM,qBAAA;EAClB;AACA,QAAMC,SAASH,aAAaF,QAAQM,EAAE;AACtC,MAAI,CAACD,QAAQ;AACX,UAAM,IAAID,MAAM,mBAAA;EAClB;AAEA,SAAO;IACLH;IACAI;IACAE,YAAYP,QAAQG;IACpBK,UAAUR,QAAQM;IAClBG,WAAWT,QAAQS;IACnBC,aAAaV,QAAQU;EACvB;AACF;",
|
|
6
|
+
"names": ["define", "options", "fromType", "getSchemaDXN", "from", "Error", "toType", "to", "fromSchema", "toSchema", "transform", "onMigration"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/Extension.ts
|
|
6
|
+
var Extension_exports = {};
|
|
7
|
+
__export(Extension_exports, {
|
|
8
|
+
Key: () => Key,
|
|
9
|
+
TypeId: () => TypeId,
|
|
10
|
+
Values: () => Values,
|
|
11
|
+
get: () => get,
|
|
12
|
+
make: () => make,
|
|
13
|
+
set: () => set
|
|
14
|
+
});
|
|
15
|
+
import * as Function from "effect/Function";
|
|
16
|
+
import * as Option from "effect/Option";
|
|
17
|
+
import * as Schema from "effect/Schema";
|
|
18
|
+
var TypeId = "~@dxos/echo/Extension";
|
|
19
|
+
var make = (key, valueSchema) => {
|
|
20
|
+
return {
|
|
21
|
+
[TypeId]: {},
|
|
22
|
+
key: Key.make(key),
|
|
23
|
+
valueSchema
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
var Key = Schema.String.pipe(Schema.brand("~@dxos/echo/ExtensionKey"));
|
|
27
|
+
var Values = Schema.Record({
|
|
28
|
+
key: Key,
|
|
29
|
+
value: Schema.Unknown
|
|
30
|
+
});
|
|
31
|
+
var get = Function.dual(2, (values, extension) => {
|
|
32
|
+
if (!(extension.key in values)) {
|
|
33
|
+
return Option.none();
|
|
34
|
+
}
|
|
35
|
+
return Function.pipe(values[extension.key], Schema.decodeUnknownSync(extension.valueSchema), Option.some);
|
|
36
|
+
});
|
|
37
|
+
var set = Function.dual(3, (values, extension, value) => {
|
|
38
|
+
values[extension.key] = Schema.encodeSync(extension.valueSchema)(value);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
TypeId,
|
|
43
|
+
make,
|
|
44
|
+
Key,
|
|
45
|
+
Values,
|
|
46
|
+
get,
|
|
47
|
+
set,
|
|
48
|
+
Extension_exports
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=chunk-GWFFC34K.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Extension.ts"],
|
|
4
|
+
"sourcesContent": ["// @import-as-namespace\n//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport type * as Types from 'effect/Types';\n\n// @import-as-namespace\n\n/**\n * Extensions allow objects to contain typed properties that are not part of the schema.\n */\n\nexport const TypeId = '~@dxos/echo/Extension' as const;\nexport type TypeId = typeof TypeId;\n\nexport interface Extension<T> extends Record<\n TypeId,\n {\n _Type: T;\n }\n> {\n readonly [TypeId]: {\n _Type: T;\n };\n\n readonly key: Key;\n readonly valueSchema: Schema.Schema<T>;\n}\n\n/**\n * Create a new typed extension.\n *\n * ```ts\n * const ColorExtension = Extension.make('color', Schema.String);\n *\n * const obj = Obj.make(Person, {\n * [Obj.Meta]: { keys: [{ source: 'external', id: '123' }] },\n * name: 'John',\n * email: 'john@example.com',\n * });\n *\n * Obj.update(obj, (obj) => {\n * Extension.set(obj.extensions, ColorExtension, 'red');\n * });\n *\n * console.log(Extension.get(obj.extensions, ColorExtension)); // 'red'\n * ```\n */\nexport const make = <S extends Schema.Schema.AnyNoContext>(\n key: string,\n valueSchema: S,\n): Extension<Schema.Schema.Type<S>> => {\n return {\n [TypeId]: {} as any,\n key: Key.make(key),\n valueSchema,\n };\n};\n\n/**\n * Unique identifier for an extension.\n */\n// TODO(dmaretskyi): filter to be fully qualified: (e.g., org.dxos.extension.color)\nexport const Key = Schema.String.pipe(Schema.brand('~@dxos/echo/ExtensionKey'));\nexport type Key = Schema.Schema.Type<typeof Key>;\n\n/**\n * Set of extension values.\n *\n * Can be used inside an object/relation schema:\n *\n * ```ts\n * const Person = Schema.Struct({\n * name: Schema.String,\n * extensions: Extension.Values,\n * });\n * ```\n */\nexport const Values = Schema.Record({ key: Key, value: Schema.Unknown });\nexport interface Values extends Schema.Schema.Type<typeof Values> {}\n\n/**\n * Get the value of an extension from a set of values.\n */\nexport const get: {\n <T>(extension: Extension<T>): (values: Values) => Option.Option<T>;\n <T>(values: Values, extension: Extension<T>): Option.Option<T>;\n} = Function.dual<\n <T>(extension: Extension<T>) => (values: Values) => Option.Option<T>,\n <T>(values: Values, extension: Extension<T>) => Option.Option<T>\n>(2, (values, extension) => {\n if (!(extension.key in values)) {\n return Option.none();\n }\n\n return Function.pipe(values[extension.key], Schema.decodeUnknownSync(extension.valueSchema), Option.some);\n});\n\n/**\n * Set the value of an extension in a set of values.\n *\n * Can also be used within Obj.update callback:\n *\n * ```ts\n * Obj.update(obj, (obj) => {\n * Extension.set(obj.extensions, ColorExtension, 'red');\n * });\n * ```\n */\nexport const set: {\n <T>(extension: Extension<T>, value: T): (values: Values) => void;\n <T>(values: Types.Mutable<Values>, extension: Extension<T>, value: T): void;\n} = Function.dual<\n <T>(extension: Extension<T>, value: T) => (values: Values) => void,\n <T>(values: Types.Mutable<Values>, extension: Extension<T>, value: T) => void\n>(3, (values, extension, value) => {\n values[extension.key] = Schema.encodeSync(extension.valueSchema)(value);\n});\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA;;;;;;;;;AAKA,YAAYA,cAAc;AAC1B,YAAYC,YAAY;AACxB,YAAYC,YAAY;AASjB,IAAMC,SAAS;AAoCf,IAAMC,OAAO,CAClBC,KACAC,gBAAAA;AAEA,SAAO;IACL,CAACH,MAAAA,GAAS,CAAC;IACXE,KAAKE,IAAIH,KAAKC,GAAAA;IACdC;EACF;AACF;AAMO,IAAMC,MAAaC,cAAOC,KAAYC,aAAM,0BAAA,CAAA;AAe5C,IAAMC,SAAgBC,cAAO;EAAEP,KAAKE;EAAKM,OAAcC;AAAQ,CAAA;AAM/D,IAAMC,MAGAC,cAGX,GAAG,CAACC,QAAQC,cAAAA;AACZ,MAAI,EAAEA,UAAUb,OAAOY,SAAS;AAC9B,WAAcE,YAAI;EACpB;AAEA,SAAgBV,cAAKQ,OAAOC,UAAUb,GAAG,GAAUe,yBAAkBF,UAAUZ,WAAW,GAAUe,WAAI;AAC1G,CAAA;AAaO,IAAMC,MAGAN,cAGX,GAAG,CAACC,QAAQC,WAAWL,UAAAA;AACvBI,SAAOC,UAAUb,GAAG,IAAWkB,kBAAWL,UAAUZ,WAAW,EAAEO,KAAAA;AACnE,CAAA;",
|
|
6
|
+
"names": ["Function", "Option", "Schema", "TypeId", "make", "key", "valueSchema", "Key", "String", "pipe", "brand", "Values", "Record", "value", "Unknown", "get", "dual", "values", "extension", "none", "decodeUnknownSync", "some", "set", "encodeSync"]
|
|
7
|
+
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isRef
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-N7VOEPSV.mjs";
|
|
4
|
+
import {
|
|
5
|
+
getDXN,
|
|
6
|
+
prettyFilter
|
|
7
|
+
} from "./chunk-Z5GKP74O.mjs";
|
|
4
8
|
import {
|
|
5
9
|
getTypeDXNFromSpecifier
|
|
6
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TNBK56IN.mjs";
|
|
7
11
|
import {
|
|
8
12
|
__export
|
|
9
13
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -13,7 +17,9 @@ var Filter_exports = {};
|
|
|
13
17
|
__export(Filter_exports, {
|
|
14
18
|
and: () => and,
|
|
15
19
|
between: () => between,
|
|
20
|
+
childOf: () => childOf,
|
|
16
21
|
contains: () => contains,
|
|
22
|
+
created: () => created,
|
|
17
23
|
eq: () => eq,
|
|
18
24
|
everything: () => everything,
|
|
19
25
|
foreignKeys: () => foreignKeys,
|
|
@@ -23,18 +29,21 @@ __export(Filter_exports, {
|
|
|
23
29
|
id: () => id,
|
|
24
30
|
in: () => in$,
|
|
25
31
|
is: () => is,
|
|
32
|
+
key: () => key,
|
|
26
33
|
lt: () => lt,
|
|
27
34
|
lte: () => lte,
|
|
28
35
|
neq: () => neq,
|
|
29
36
|
not: () => not,
|
|
30
37
|
nothing: () => nothing,
|
|
31
38
|
or: () => or,
|
|
39
|
+
pretty: () => pretty,
|
|
32
40
|
props: () => props,
|
|
33
41
|
tag: () => tag,
|
|
34
42
|
text: () => text,
|
|
35
43
|
type: () => type,
|
|
36
44
|
typeDXN: () => typeDXN,
|
|
37
|
-
typename: () => typename
|
|
45
|
+
typename: () => typename,
|
|
46
|
+
updated: () => updated
|
|
38
47
|
});
|
|
39
48
|
import * as Match from "effect/Match";
|
|
40
49
|
import * as Schema from "effect/Schema";
|
|
@@ -124,6 +133,15 @@ var tag = (tag2) => {
|
|
|
124
133
|
tag: tag2
|
|
125
134
|
});
|
|
126
135
|
};
|
|
136
|
+
var key = (key2, options) => {
|
|
137
|
+
return new FilterClass({
|
|
138
|
+
type: "object",
|
|
139
|
+
typename: null,
|
|
140
|
+
props: {},
|
|
141
|
+
metaKey: key2,
|
|
142
|
+
metaVersion: options?.version
|
|
143
|
+
});
|
|
144
|
+
};
|
|
127
145
|
var props = (props2) => {
|
|
128
146
|
return new FilterClass({
|
|
129
147
|
type: "object",
|
|
@@ -211,6 +229,48 @@ var between = (from, to) => {
|
|
|
211
229
|
to
|
|
212
230
|
});
|
|
213
231
|
};
|
|
232
|
+
var _toUnixMs = (date) => typeof date === "number" ? date : date.getTime();
|
|
233
|
+
var _timeRangeFilter = (field, range) => {
|
|
234
|
+
const filters = [];
|
|
235
|
+
if (range.after != null) {
|
|
236
|
+
filters.push(new FilterClass({
|
|
237
|
+
type: "timestamp",
|
|
238
|
+
field,
|
|
239
|
+
operator: "gte",
|
|
240
|
+
value: _toUnixMs(range.after)
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
if (range.before != null) {
|
|
244
|
+
filters.push(new FilterClass({
|
|
245
|
+
type: "timestamp",
|
|
246
|
+
field,
|
|
247
|
+
operator: "lte",
|
|
248
|
+
value: _toUnixMs(range.before)
|
|
249
|
+
}));
|
|
250
|
+
}
|
|
251
|
+
if (filters.length === 0) {
|
|
252
|
+
return everything();
|
|
253
|
+
}
|
|
254
|
+
return filters.length === 1 ? filters[0] : and(...filters);
|
|
255
|
+
};
|
|
256
|
+
var updated = (range) => _timeRangeFilter("updatedAt", range);
|
|
257
|
+
var created = (range) => _timeRangeFilter("createdAt", range);
|
|
258
|
+
var childOf = (parents, options) => {
|
|
259
|
+
const items = Array.isArray(parents) ? parents : [
|
|
260
|
+
parents
|
|
261
|
+
];
|
|
262
|
+
const dxns = items.map((item) => {
|
|
263
|
+
if (isRef(item)) {
|
|
264
|
+
return item.dxn.toString();
|
|
265
|
+
}
|
|
266
|
+
return getDXN(item).toString();
|
|
267
|
+
});
|
|
268
|
+
return new FilterClass({
|
|
269
|
+
type: "child-of",
|
|
270
|
+
parents: dxns,
|
|
271
|
+
transitive: options?.transitive ?? true
|
|
272
|
+
});
|
|
273
|
+
};
|
|
214
274
|
var not = (filter) => {
|
|
215
275
|
return new FilterClass({
|
|
216
276
|
type: "not",
|
|
@@ -255,8 +315,8 @@ var processPredicate = (predicate) => {
|
|
|
255
315
|
throw new Error("Array predicates are not yet supported.");
|
|
256
316
|
}),
|
|
257
317
|
Match.when((predicate2) => !isRef(predicate2) && typeof predicate2 === "object" && predicate2 !== null, (predicate2) => {
|
|
258
|
-
const nestedProps = Object.fromEntries(Object.entries(predicate2).map(([
|
|
259
|
-
|
|
318
|
+
const nestedProps = Object.fromEntries(Object.entries(predicate2).map(([key2, value2]) => [
|
|
319
|
+
key2,
|
|
260
320
|
processPredicate(value2)
|
|
261
321
|
]));
|
|
262
322
|
return {
|
|
@@ -268,6 +328,7 @@ var processPredicate = (predicate) => {
|
|
|
268
328
|
Match.orElse((value2) => eq(value2).ast)
|
|
269
329
|
);
|
|
270
330
|
};
|
|
331
|
+
var pretty = (filter) => prettyFilter(filter.ast);
|
|
271
332
|
|
|
272
333
|
export {
|
|
273
334
|
is,
|
|
@@ -279,6 +340,7 @@ export {
|
|
|
279
340
|
typename,
|
|
280
341
|
typeDXN,
|
|
281
342
|
tag,
|
|
343
|
+
key,
|
|
282
344
|
props,
|
|
283
345
|
text,
|
|
284
346
|
foreignKeys,
|
|
@@ -291,9 +353,13 @@ export {
|
|
|
291
353
|
in$,
|
|
292
354
|
contains,
|
|
293
355
|
between,
|
|
356
|
+
updated,
|
|
357
|
+
created,
|
|
358
|
+
childOf,
|
|
294
359
|
not,
|
|
295
360
|
and,
|
|
296
361
|
or,
|
|
362
|
+
pretty,
|
|
297
363
|
Filter_exports
|
|
298
364
|
};
|
|
299
|
-
//# sourceMappingURL=chunk-
|
|
365
|
+
//# sourceMappingURL=chunk-HKETO4L4.mjs.map
|