@dxos/echo 0.9.0 → 0.9.1-staging.ee54ba693a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/neutral/Annotation.mjs +30 -8
- package/dist/lib/neutral/Database.mjs +7 -3
- package/dist/lib/neutral/Entity.mjs +15 -11
- package/dist/lib/neutral/Err.mjs +7 -3
- package/dist/lib/neutral/Feed.mjs +15 -19
- package/dist/lib/neutral/Filter.mjs +13 -11
- package/dist/lib/neutral/Format.mjs +3 -7
- package/dist/lib/neutral/JsonSchema.mjs +7 -7
- package/dist/lib/neutral/Migration.mjs +11 -11
- package/dist/lib/neutral/Obj.mjs +19 -13
- package/dist/lib/neutral/Order.mjs +1 -1
- package/dist/lib/neutral/Query.mjs +17 -17
- package/dist/lib/neutral/QueryResult.mjs +1 -1
- package/dist/lib/neutral/Ref.mjs +6 -6
- package/dist/lib/neutral/Registry.mjs +1 -1
- package/dist/lib/neutral/Relation.mjs +12 -12
- package/dist/lib/neutral/Tag.mjs +15 -15
- package/dist/lib/neutral/Text.mjs +25 -0
- package/dist/lib/neutral/Text.mjs.map +7 -0
- package/dist/lib/neutral/Type.mjs +10 -10
- package/dist/lib/neutral/chunk-2HKGAQM4.mjs +1394 -0
- package/dist/lib/neutral/chunk-2HKGAQM4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-O6BH7EPN.mjs → chunk-2ZHECXUR.mjs} +5 -4
- package/dist/lib/neutral/chunk-2ZHECXUR.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-QQIYS74I.mjs → chunk-3KTE2Y7Q.mjs} +20 -20
- package/dist/lib/neutral/chunk-3KTE2Y7Q.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-R5W6DXR4.mjs → chunk-3TN2VMI4.mjs} +72 -36
- package/dist/lib/neutral/chunk-3TN2VMI4.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-5SMDBFVB.mjs → chunk-42L4HJ3Z.mjs} +11 -15
- package/dist/lib/neutral/chunk-42L4HJ3Z.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-7PI7C4EF.mjs → chunk-4A2NWKRJ.mjs} +5 -5
- package/dist/lib/neutral/chunk-ACFAOTKJ.mjs +1531 -0
- package/dist/lib/neutral/chunk-ACFAOTKJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-SBVFRTST.mjs → chunk-BEFR7LEA.mjs} +20 -10
- package/dist/lib/neutral/chunk-BEFR7LEA.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6M2Z6WBH.mjs → chunk-BXIKXT7Q.mjs} +2 -6
- package/dist/lib/neutral/{chunk-6M2Z6WBH.mjs.map → chunk-BXIKXT7Q.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-UUP46KUQ.mjs → chunk-C57XMMBY.mjs} +21 -20
- package/dist/lib/neutral/chunk-C57XMMBY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-C62JYFAD.mjs +183 -0
- package/dist/lib/neutral/chunk-C62JYFAD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-MZ7K3MLL.mjs → chunk-FSGX2R62.mjs} +3 -3
- package/dist/lib/neutral/chunk-FSGX2R62.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TYGKCRMK.mjs → chunk-HBXT3GSB.mjs} +37 -15
- package/dist/lib/neutral/chunk-HBXT3GSB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WU3GIANS.mjs → chunk-IQR45HAD.mjs} +1 -1
- package/dist/lib/neutral/chunk-IQR45HAD.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-TFEWTY5A.mjs → chunk-KCBW4BR6.mjs} +4 -8
- package/dist/lib/neutral/chunk-KCBW4BR6.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-WTQJHC75.mjs → chunk-L3E5IXAE.mjs} +225 -45
- package/dist/lib/neutral/chunk-L3E5IXAE.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-EVK6XBXO.mjs → chunk-PRC4FEKJ.mjs} +2 -2
- package/dist/lib/neutral/chunk-PRC4FEKJ.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-6YDI3J37.mjs → chunk-SCT6FFCR.mjs} +9 -4
- package/dist/lib/neutral/chunk-SCT6FFCR.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-BBFJWWAV.mjs → chunk-TOCVVFK2.mjs} +26 -2
- package/dist/lib/neutral/chunk-TOCVVFK2.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-RIVWNMSF.mjs → chunk-U53LSQQA.mjs} +3 -3
- package/dist/lib/neutral/{chunk-RIVWNMSF.mjs.map → chunk-U53LSQQA.mjs.map} +1 -1
- package/dist/lib/neutral/{chunk-IGK6FN65.mjs → chunk-UGFFV2FR.mjs} +2 -2
- package/dist/lib/neutral/{chunk-35INCYOE.mjs → chunk-UWLP4RFM.mjs} +1 -1
- package/dist/lib/neutral/chunk-UWLP4RFM.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-LWXVKPPW.mjs → chunk-UZHCQ6NI.mjs} +13 -11
- package/dist/lib/neutral/{chunk-LWXVKPPW.mjs.map → chunk-UZHCQ6NI.mjs.map} +3 -3
- package/dist/lib/neutral/{chunk-5SUJPHAE.mjs → chunk-WKIT2YY5.mjs} +2 -2
- package/dist/lib/neutral/{chunk-T6E37YIP.mjs → chunk-XB6ISRAO.mjs} +38 -18
- package/dist/lib/neutral/chunk-XB6ISRAO.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XXL42WCB.mjs +84 -0
- package/dist/lib/neutral/chunk-XXL42WCB.mjs.map +7 -0
- package/dist/lib/neutral/{chunk-ZGNNFYHS.mjs → chunk-XXWK4J53.mjs} +27 -42
- package/dist/lib/neutral/chunk-XXWK4J53.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +30 -26
- package/dist/lib/neutral/internal/index.mjs +111 -69
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/testing/index.mjs +79 -60
- package/dist/lib/neutral/testing/index.mjs.map +3 -3
- package/dist/types/src/Annotation.d.ts +35 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Collection.d.ts +9 -8
- package/dist/types/src/Collection.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +38 -0
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Dataset.d.ts +1 -16
- package/dist/types/src/Dataset.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +2 -0
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +67 -0
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +59 -80
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +9 -1
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +2 -9
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Migration.d.ts +1 -1
- package/dist/types/src/Migration.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +33 -6
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts +1 -1
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +1 -1
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/QueryResult.d.ts +2 -2
- package/dist/types/src/QueryResult.d.ts.map +1 -1
- package/dist/types/src/Ref.d.ts +10 -6
- package/dist/types/src/Ref.d.ts.map +1 -1
- package/dist/types/src/Registry.d.ts +1 -1
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts +11 -13
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Text.d.ts +41 -0
- package/dist/types/src/Text.d.ts.map +1 -0
- package/dist/types/src/Text.test.d.ts +2 -0
- package/dist/types/src/Text.test.d.ts.map +1 -0
- package/dist/types/src/Type.d.ts +38 -21
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +8 -9
- package/dist/types/src/View.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +50 -0
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/atoms.d.ts +14 -0
- package/dist/types/src/internal/Annotation/atoms.d.ts.map +1 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts +13 -0
- package/dist/types/src/internal/Annotation/entity-dictionary.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/guard.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/model.d.ts +1 -1
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/object.d.ts +5 -1
- package/dist/types/src/internal/Entity/object.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/relation.d.ts +7 -0
- package/dist/types/src/internal/Entity/relation.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/type-uri.d.ts.map +1 -1
- package/dist/types/src/internal/Filter/index.d.ts +2 -0
- package/dist/types/src/internal/Filter/index.d.ts.map +1 -0
- package/dist/types/src/internal/Filter/match.d.ts +22 -0
- package/dist/types/src/internal/Filter/match.d.ts.map +1 -0
- package/dist/types/src/internal/Format/format.d.ts +0 -2
- package/dist/types/src/internal/Format/format.d.ts.map +1 -1
- package/dist/types/src/internal/Format/index.d.ts +2 -2
- package/dist/types/src/internal/Format/index.d.ts.map +1 -1
- package/dist/types/src/internal/Format/string.d.ts +0 -8
- package/dist/types/src/internal/Format/string.d.ts.map +1 -1
- package/dist/types/src/internal/Format/types.d.ts +2 -1
- package/dist/types/src/internal/Format/types.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/atoms.d.ts +12 -3
- package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/clone.d.ts +2 -1
- package/dist/types/src/internal/Obj/clone.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/create-object.d.ts +3 -4
- package/dist/types/src/internal/Obj/create-object.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Query/index.d.ts +1 -0
- package/dist/types/src/internal/Query/index.d.ts.map +1 -1
- package/dist/types/src/internal/Query/query-result-effect.d.ts +9 -0
- package/dist/types/src/internal/Query/query-result-effect.d.ts.map +1 -0
- package/dist/types/src/internal/Ref/atoms.d.ts +1 -2
- package/dist/types/src/internal/Ref/atoms.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/index.d.ts +1 -0
- package/dist/types/src/internal/Ref/index.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/ref.d.ts +79 -8
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/strong-deps.d.ts +35 -0
- package/dist/types/src/internal/Ref/strong-deps.d.ts.map +1 -0
- package/dist/types/src/internal/common/atom-snapshot.d.ts +8 -0
- package/dist/types/src/internal/common/atom-snapshot.d.ts.map +1 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts +12 -0
- package/dist/types/src/internal/common/proxy/proxy-types.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts +25 -0
- package/dist/types/src/internal/common/proxy/proxy-utils.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts +5 -0
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +17 -0
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/entity.d.ts +4 -4
- package/dist/types/src/internal/common/types/entity.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/meta.d.ts +2 -4
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts +1 -0
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +42 -171
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -13
- package/src/Annotation.test.ts +257 -10
- package/src/Annotation.ts +58 -4
- package/src/Collection.ts +10 -12
- package/src/Database.ts +55 -21
- package/src/Entity.ts +3 -1
- package/src/Err.ts +22 -0
- package/src/Feed.ts +117 -141
- package/src/Filter.test.ts +38 -0
- package/src/Filter.ts +17 -3
- package/src/Hypergraph.ts +2 -11
- package/src/Migration.ts +1 -1
- package/src/Obj.test.ts +92 -12
- package/src/Obj.ts +38 -5
- package/src/Order.ts +3 -3
- package/src/Query.test.ts +2 -2
- package/src/Query.ts +16 -16
- package/src/QueryResult.ts +2 -2
- package/src/Ref.ts +14 -6
- package/src/Registry.ts +1 -1
- package/src/Relation.ts +1 -1
- package/src/Tag.ts +13 -16
- package/src/Text.test.ts +186 -0
- package/src/Text.ts +116 -0
- package/src/Type.test.ts +52 -24
- package/src/Type.ts +85 -33
- package/src/View.ts +22 -30
- package/src/index.ts +1 -1
- package/src/internal/Annotation/annotations.ts +71 -2
- package/src/internal/Annotation/atoms.ts +107 -0
- package/src/internal/Annotation/entity-dictionary.ts +40 -37
- package/src/internal/Entity/api.ts +1 -1
- package/src/internal/Entity/guard.ts +2 -1
- package/src/internal/Entity/model.ts +2 -2
- package/src/internal/Entity/object.ts +14 -1
- package/src/internal/Entity/relation.ts +19 -0
- package/src/internal/Entity/type-uri.ts +3 -1
- package/src/internal/Filter/index.ts +5 -0
- package/src/internal/Filter/match.ts +284 -0
- package/src/internal/Format/format.ts +0 -2
- package/src/internal/Format/index.ts +2 -2
- package/src/internal/Format/string.ts +0 -12
- package/src/internal/Format/types.ts +4 -2
- package/src/internal/JsonSchema/json-schema.test.ts +82 -54
- package/src/internal/Obj/atoms.ts +62 -18
- package/src/internal/Obj/clone.ts +61 -20
- package/src/internal/Obj/create-object.test.ts +3 -3
- package/src/internal/Obj/create-object.ts +3 -4
- package/src/internal/Obj/inspect.ts +1 -1
- package/src/internal/Obj/json-serializer.test.ts +7 -5
- package/src/internal/Obj/json-serializer.ts +4 -4
- package/src/internal/Obj/schema-validator.test.ts +53 -0
- package/src/internal/Obj/set-value.test.ts +29 -19
- package/src/internal/Query/index.ts +1 -0
- package/src/internal/Query/query-result-effect.ts +35 -0
- package/src/internal/Ref/atoms.ts +23 -3
- package/src/internal/Ref/index.ts +1 -0
- package/src/internal/Ref/ref.test.ts +8 -8
- package/src/internal/Ref/ref.ts +122 -39
- package/src/internal/Ref/strong-deps.ts +107 -0
- package/src/internal/common/atom-snapshot.ts +19 -0
- package/src/internal/common/proxy/make-object.ts +1 -1
- package/src/internal/common/proxy/proxy-types.ts +20 -0
- package/src/internal/common/proxy/proxy-utils.ts +37 -1
- package/src/internal/common/proxy/reactive-array.ts +3 -3
- package/src/internal/common/proxy/reactive.test.ts +1 -1
- package/src/internal/common/proxy/schema-validator.ts +181 -8
- package/src/internal/common/proxy/typed-handler.ts +254 -76
- package/src/internal/common/types/entity.ts +15 -7
- package/src/internal/index.ts +1 -0
- package/src/testing/test-schema.ts +75 -90
- package/dist/lib/neutral/chunk-35INCYOE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs +0 -101
- package/dist/lib/neutral/chunk-3PBP4V4O.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs +0 -184
- package/dist/lib/neutral/chunk-4ZUHOTCG.mjs.map +0 -7
- package/dist/lib/neutral/chunk-5SMDBFVB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-6YDI3J37.mjs.map +0 -7
- package/dist/lib/neutral/chunk-7FPIAJIV.mjs +0 -2279
- package/dist/lib/neutral/chunk-7FPIAJIV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BBFJWWAV.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EVK6XBXO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-MZ7K3MLL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-O6BH7EPN.mjs.map +0 -7
- package/dist/lib/neutral/chunk-QQIYS74I.mjs.map +0 -7
- package/dist/lib/neutral/chunk-R5W6DXR4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SBVFRTST.mjs.map +0 -7
- package/dist/lib/neutral/chunk-T6E37YIP.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TFEWTY5A.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TYGKCRMK.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UUP46KUQ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WTQJHC75.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WU3GIANS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ZGNNFYHS.mjs.map +0 -7
- package/dist/types/src/exemplars.test.d.ts +0 -2
- package/dist/types/src/exemplars.test.d.ts.map +0 -1
- package/dist/types/src/hierarchy.test.d.ts +0 -2
- package/dist/types/src/hierarchy.test.d.ts.map +0 -1
- package/src/exemplars.test.ts +0 -21
- package/src/hierarchy.test.ts +0 -33
- /package/dist/lib/neutral/{chunk-7PI7C4EF.mjs.map → chunk-4A2NWKRJ.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-IGK6FN65.mjs.map → chunk-UGFFV2FR.mjs.map} +0 -0
- /package/dist/lib/neutral/{chunk-5SUJPHAE.mjs.map → chunk-WKIT2YY5.mjs.map} +0 -0
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
select
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3KTE2Y7Q.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Feed
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XXWK4J53.mjs";
|
|
7
7
|
import {
|
|
8
8
|
nothing
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SCT6FFCR.mjs";
|
|
10
10
|
import {
|
|
11
11
|
Unknown,
|
|
12
12
|
instanceOf,
|
|
13
13
|
make
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HBXT3GSB.mjs";
|
|
15
15
|
import {
|
|
16
16
|
Ref
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-FSGX2R62.mjs";
|
|
18
18
|
import {
|
|
19
19
|
getSchema,
|
|
20
20
|
makeObject
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XB6ISRAO.mjs";
|
|
22
22
|
import {
|
|
23
23
|
JsonSchemaType
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-4A2NWKRJ.mjs";
|
|
25
25
|
import {
|
|
26
26
|
FormInputAnnotation,
|
|
27
27
|
HiddenAnnotation,
|
|
28
28
|
IconAnnotation
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-3TN2VMI4.mjs";
|
|
30
30
|
import {
|
|
31
31
|
__export
|
|
32
32
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -94,13 +94,14 @@ __export(Collection_exports, {
|
|
|
94
94
|
});
|
|
95
95
|
import * as Schema from "effect/Schema";
|
|
96
96
|
import { DXN } from "@dxos/keys";
|
|
97
|
-
var Collection = Schema.Struct({
|
|
97
|
+
var Collection = class extends makeObject(DXN.make("org.dxos.type.collection", "0.1.0"))(Schema.Struct({
|
|
98
98
|
name: Schema.String.pipe(Schema.optional),
|
|
99
99
|
objects: Schema.Array(Ref(Unknown)).pipe(FormInputAnnotation.set(false))
|
|
100
100
|
}).pipe(IconAnnotation.set({
|
|
101
101
|
icon: "ph--folder--regular",
|
|
102
|
-
hue: "
|
|
103
|
-
})
|
|
102
|
+
hue: "indigo"
|
|
103
|
+
}))) {
|
|
104
|
+
};
|
|
104
105
|
var make2 = (props = {}) => make(Collection, {
|
|
105
106
|
objects: [],
|
|
106
107
|
...props
|
|
@@ -149,24 +150,24 @@ var Projection = Schema2.Struct({
|
|
|
149
150
|
*/
|
|
150
151
|
pivotFieldId: Schema2.String.pipe(Schema2.optional)
|
|
151
152
|
});
|
|
152
|
-
var
|
|
153
|
+
var View = class extends makeObject(DXN2.make("org.dxos.type.view", "0.1.0"))(Schema2.Struct({
|
|
153
154
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
* Query used to retrieve data.
|
|
156
|
+
* Can be a user-provided query grammar string or a query AST.
|
|
157
|
+
*/
|
|
157
158
|
query: Schema2.Struct({
|
|
158
159
|
raw: Schema2.optional(Schema2.String),
|
|
159
160
|
ast: QueryAST.Query
|
|
160
161
|
}),
|
|
161
162
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
* Projection of the data returned from the query.
|
|
164
|
+
*/
|
|
164
165
|
projection: Projection
|
|
165
166
|
}).pipe(HiddenAnnotation.set(true), IconAnnotation.set({
|
|
166
167
|
icon: "ph--funnel--regular",
|
|
167
168
|
hue: "green"
|
|
168
|
-
})
|
|
169
|
-
|
|
169
|
+
}))) {
|
|
170
|
+
};
|
|
170
171
|
var make3 = (props) => {
|
|
171
172
|
return make(View, {
|
|
172
173
|
query: {
|
|
@@ -202,4 +203,4 @@ export {
|
|
|
202
203
|
EID2 as EID,
|
|
203
204
|
URI
|
|
204
205
|
};
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
206
|
+
//# sourceMappingURL=chunk-C57XMMBY.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/Hypergraph.ts", "../../../src/Json.ts", "../../../src/Collection.ts", "../../../src/View.ts", "../../../src/Dataset.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { QueryAST } from '@dxos/echo-protocol';\nexport { DXN, EID, URI } from '@dxos/keys';\n\nexport * as Annotation from './Annotation';\nexport * as Database from './Database';\nexport * as Entity from './Entity';\nexport * as Err from './Err';\nexport * as Feed from './Feed';\nexport * as Filter from './Filter';\nexport * as Format from './Format';\nexport * as Hypergraph from './Hypergraph';\nexport * as Json from './Json';\nexport * as JsonSchema from './JsonSchema';\nexport * as Key from './Key';\nexport * as Migration from './Migration';\nexport * as Obj from './Obj';\nexport * as Order from './Order';\nexport * as Query from './Query';\nexport * as QueryResult from './QueryResult';\nexport * as Ref from './Ref';\nexport * as Registry from './Registry';\nexport * as Relation from './Relation';\nexport * as Scope from './Scope';\nexport * as Tag from './Tag';\nexport * as Text from './Text';\nexport * as Type from './Type';\nexport * as Collection from './Collection';\nexport * as View from './View';\nexport * as Dataset from './Dataset';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type URI } from '@dxos/keys';\n\nimport type * as Database from './Database';\nimport type * as Entity from './Entity';\nimport type * as Key from './Key';\nimport type * as Ref from './Ref';\nimport type * as Registry from './Registry';\n\n/**\n * Resolution context.\n * Affects how non-absolute DXNs are resolved.\n */\nexport interface RefResolutionContext {\n /**\n * Space that the resolution is happening from.\n */\n space?: Key.SpaceId;\n\n /**\n * Feed that the resolution is happening from.\n * This feed will be searched first, and then the space it belongs to.\n */\n feed?: URI.URI;\n}\n\nexport interface RefResolverOptions {\n /**\n * Resolution context.\n * Affects how non-absolute DXNs are resolved.\n */\n context?: RefResolutionContext;\n}\n\n/**\n * Manages cross-space database interactions.\n */\nexport interface Hypergraph extends Database.Queryable {\n /**\n * In-process registry of keyed objects and static schema types.\n * Populated at startup via `registry.add(objects)` / `registry.add(schemas)`.\n * Queries that include no explicit from() clause will fan out to this registry automatically.\n */\n get registry(): Registry.Registry;\n\n /**\n * Query objects.\n */\n query: Database.QueryFn;\n\n /**\n * Creates a reference to an existing object in the database.\n *\n * NOTE: The reference may be dangling if the object is not present in the database.\n * NOTE: Difference from `Ref.fromURI`\n * `Ref.fromURI(dxn)` returns an unhydrated reference. The `.load` and `.target` APIs will not work.\n * `db.makeRef(dxn)` is preferable in cases with access to the database.\n */\n makeRef<T extends Entity.Unknown = Entity.Unknown>(uri: URI.URI): Ref.Ref<T>;\n\n /**\n * Create a resolver that dereferences `Ref`s against this graph. Persisted schema objects are\n * surfaced as their registered `Type.Type` entity.\n */\n createRefResolver(options: RefResolverOptions): Ref.Resolver;\n\n /**\n * Get a database by space ID.\n * @returns The database for the given space ID, or undefined if not found.\n */\n getDatabase(spaceId: Key.SpaceId): Database.Database | undefined;\n}\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport { EID } from '@dxos/keys';\n\nimport * as Database from './Database';\nimport * as Obj from './Obj';\n\n/**\n * `JSON.stringify` replacer signature.\n *\n * Defined here (rather than re-imported from a UI package) so other ECHO-aware utilities can\n * share a stable signature without creating a dependency edge into the UI tree.\n */\nexport type JsonReplacer = (key: string, value: any) => any;\n\nexport type CreateRefReplacerOptions = {\n db: Database.Database;\n /** How many ref hops to follow. `0` leaves all refs as-is. Default: `1`. */\n depth?: number;\n};\n\nconst isEncodedRef = (value: unknown): value is { '/': string } =>\n typeof value === 'object' &&\n value !== null &&\n Object.keys(value as object).length === 1 &&\n typeof (value as { '/': unknown })['/'] === 'string';\n\nconst toJson = (obj: Obj.Any): unknown => (typeof (obj as any).toJSON === 'function' ? (obj as any).toJSON() : obj);\n\n/**\n * Returns a {@link JsonReplacer} that inlines ECHO ref objects (`{ \"/\": \"echo:...\" }`) up to\n * `depth` ref hops. Beyond that depth refs are left in their encoded form.\n *\n * Implemented as a per-call `JSON.stringify` replacer (not a one-shot tree walk at root) so it\n * composes with wrappers like `safeStringify` that intercept the root call. JSON.stringify\n * already drives the recursion; we only need to (a) detect a ref at the current callback,\n * (b) resolve and return the target if hop budget remains, and (c) tag the returned object\n * with its hop count so children know how far in they are.\n *\n * The hop count is tracked per-object via a `WeakMap`: a ref-resolved target's children inherit\n * `parentHops + 1`; a regular intermediate object's children inherit `parentHops`. This makes the\n * budget count *ref hops*, not tree depth — a ref deep in a tree still resolves once when\n * `depth >= 1`.\n *\n * Note: ECHO objects' `toJSON` runs before the replacer is invoked, so by the time we see a\n * value refs are already encoded as `{ \"/\": \"dxn:...\" }`.\n */\nexport const createRefReplacer = ({ db, depth = 1 }: CreateRefReplacerOptions): JsonReplacer => {\n // Per-object hop count. Set when we return an object (via ref resolution or pass-through) so\n // the child callbacks (which carry that object as `this`) can read it.\n const hops = new WeakMap<object, number>();\n\n return function (this: any, key: string, value: any) {\n // Hop count for this call: hops at the parent, or 0 for the root.\n const parentHops = this && typeof this === 'object' ? (hops.get(this) ?? 0) : 0;\n if (isEncodedRef(value)) {\n if (parentHops >= depth) {\n return value;\n }\n\n // The `{ '/': string }` shape is shared with non-DXN IPLD-style refs (e.g. CIDs);\n // an unparseable string would otherwise crash the whole `JSON.stringify`.\n // Treat any parse miss as \"leave as-is\" rather than propagating.\n const dxnString = value['/'];\n if (!dxnString.startsWith('dxn:') && !dxnString.startsWith('echo:')) {\n return value;\n }\n\n let echoUri: string | undefined;\n try {\n const parsed = EID.tryParse(dxnString);\n echoUri = parsed ? EID.getEntityId(parsed) : undefined;\n } catch {\n return value;\n }\n\n if (!echoUri) {\n return value;\n }\n const target = db.getObjectById(echoUri);\n if (!target) {\n return value;\n }\n\n const encoded = toJson(target);\n if (encoded != null && typeof encoded === 'object') {\n // Children of the resolved target are one hop deeper.\n hops.set(encoded as object, parentHops + 1);\n }\n return encoded;\n }\n\n // Pass-through object: children inherit the parent's hop count (this branch doesn't burn\n // budget).\n if (value != null && typeof value === 'object') {\n hops.set(value, parentHops);\n }\n\n return value;\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN } from '@dxos/keys';\n\nimport * as Annotation from './Annotation';\nimport * as internal from './internal';\nimport * as Obj from './Obj';\nimport * as Ref from './Ref';\nimport * as Type from './Type';\n\n/**\n * A an ordered set of objects.\n */\nexport class Collection extends Type.makeObject<Collection>(DXN.make('org.dxos.type.collection', '0.1.0'))(\n Schema.Struct({\n name: Schema.String.pipe(Schema.optional),\n objects: Schema.Array(Ref.Ref(Obj.Unknown)).pipe(internal.FormInputAnnotation.set(false)),\n }).pipe(Annotation.IconAnnotation.set({ icon: 'ph--folder--regular', hue: 'indigo' })),\n) {}\n\nexport const make = (props: Partial<Obj.MakeProps<typeof Collection>> = {}): Type.InstanceType<typeof Collection> =>\n Obj.make(Collection, { objects: [], ...props });\n\nexport const isCollection: (value: unknown) => value is Type.InstanceType<typeof Collection> =\n Obj.instanceOf(Collection);\n", "//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { QueryAST } from '@dxos/echo-protocol';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN, PublicKey } from '@dxos/keys';\n\nimport * as Annotation from './Annotation';\nimport * as Filter from './Filter';\nimport * as internal from './internal';\nimport * as Obj from './Obj';\nimport * as Query from './Query';\nimport * as Type from './Type';\n\n/**\n * Stored field metadata (e.g., for UX).\n */\nexport const FieldSchema = Schema.Struct({\n id: Schema.String,\n path: SchemaEx.JsonPath,\n visible: Schema.optional(Schema.Boolean),\n\n // TODO(wittjosiah): Presentation-specific?\n referencePath: Schema.optional(SchemaEx.JsonPath),\n});\n\nexport type FieldType = Schema.Schema.Type<typeof FieldSchema>;\n\nexport const KeyValueProps = Schema.Record({ key: Schema.String, value: Schema.Any });\n\nexport const createFieldId = () => PublicKey.random().truncate();\n\nexport const Projection = Schema.Struct({\n /**\n * Optional schema override used to customize the underlying schema.\n */\n schema: internal.JsonSchemaType.pipe(Schema.optional),\n\n /**\n * UX metadata associated with displayed fields (in table, form, etc.)\n */\n // TODO(wittjosiah): Should this just be an array of SchemaEx.JsonPath?\n fields: Schema.Array(FieldSchema),\n\n /**\n * The id for the field used to pivot the view.\n * E.g., the field to use for kanban columns or the field to use for map coordinates.\n */\n pivotFieldId: Schema.String.pipe(Schema.optional),\n});\n\nexport type Projection = Schema.Schema.Type<typeof Projection>;\n\n/**\n * Views are generated or user-defined projections of a schema's properties.\n * They are used to configure the visual representation of the data.\n */\nexport class View extends Type.makeObject<View>(DXN.make('org.dxos.type.view', '0.1.0'))(\n Schema.Struct({\n /**\n * Query used to retrieve data.\n * Can be a user-provided query grammar string or a query AST.\n */\n query: Schema.Struct({\n raw: Schema.optional(Schema.String),\n ast: QueryAST.Query,\n }),\n\n /**\n * Projection of the data returned from the query.\n */\n projection: Projection,\n }).pipe(\n internal.HiddenAnnotation.set(true),\n Annotation.IconAnnotation.set({ icon: 'ph--funnel--regular', hue: 'green' }),\n ),\n) {}\n\nexport const make = (props: Partial<Obj.MakeProps<typeof View>>): Type.InstanceType<typeof View> => {\n return Obj.make(View, {\n query: { ast: Query.select(Filter.nothing()).ast },\n projection: { fields: [] },\n ...props,\n });\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { pipe } from 'effect/Function';\nimport * as Predicate from 'effect/Predicate';\nimport * as Schema from 'effect/Schema';\n\nimport * as Collection from './Collection';\nimport * as Feed from './Feed';\nimport * as Obj from './Obj';\nimport * as Type from './Type';\nimport * as View from './View';\n\n/**\n * Abstract set of objects, represented by a view, feed, or collection.\n * Schema-level union of the underlying type entities (rebuilt via\n * `Type.getSchema`) so this can still be consumed by Schema-side APIs such\n * as `Filter.type(...)` on a union.\n */\nexport type Dataset = Feed.Feed | Collection.Collection | View.View;\nexport const Dataset = Schema.Union(\n Type.getSchema(Feed.Feed),\n Type.getSchema(Collection.Collection),\n Type.getSchema(View.View),\n);\n\nexport const isDataset: (value: unknown) => value is Dataset = pipe(\n Obj.instanceOf(Feed.Feed),\n Predicate.or(Obj.instanceOf(Collection.Collection)),\n Predicate.or(Obj.instanceOf(View.View)),\n);\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["QueryAST", "DXN", "EID", "URI", "EID", "isEncodedRef", "value", "Object", "keys", "length", "toJson", "obj", "toJSON", "createRefReplacer", "db", "depth", "hops", "WeakMap", "key", "parentHops", "get", "dxnString", "startsWith", "echoUri", "parsed", "tryParse", "getEntityId", "undefined", "target", "getObjectById", "encoded", "set", "make", "Schema", "DXN", "Collection", "makeObject", "DXN", "make", "Struct", "name", "String", "pipe", "optional", "objects", "Array", "Ref", "Unknown", "FormInputAnnotation", "set", "IconAnnotation", "icon", "hue", "props", "isCollection", "instanceOf", "make", "Schema", "QueryAST", "SchemaEx", "DXN", "PublicKey", "FieldSchema", "Struct", "id", "String", "path", "SchemaEx", "JsonPath", "visible", "optional", "Boolean", "referencePath", "KeyValueProps", "Record", "key", "value", "Any", "createFieldId", "PublicKey", "random", "truncate", "Projection", "schema", "JsonSchemaType", "pipe", "fields", "Array", "pivotFieldId", "View", "makeObject", "DXN", "make", "query", "raw", "ast", "QueryAST", "Query", "projection", "HiddenAnnotation", "set", "IconAnnotation", "icon", "hue", "props", "select", "nothing", "pipe", "Predicate", "Schema", "Dataset", "Union", "getSchema", "Feed", "Collection", "View", "isDataset", "pipe", "instanceOf", "or"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import {
|
|
2
|
+
get,
|
|
3
|
+
isEntity,
|
|
4
|
+
set,
|
|
5
|
+
snapshotForComparison,
|
|
6
|
+
update
|
|
7
|
+
} from "./chunk-2HKGAQM4.mjs";
|
|
8
|
+
import {
|
|
9
|
+
subscribe
|
|
10
|
+
} from "./chunk-L3E5IXAE.mjs";
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_LAYOUT_NAME,
|
|
13
|
+
DescriptionAnnotation,
|
|
14
|
+
Dictionary,
|
|
15
|
+
FieldLookupAnnotationId,
|
|
16
|
+
FormCreateAnnotation,
|
|
17
|
+
FormCreateAnnotationId,
|
|
18
|
+
FormInlineAnnotation,
|
|
19
|
+
FormInputAnnotation,
|
|
20
|
+
FormLayoutAnnotation,
|
|
21
|
+
FormLayoutAnnotationId,
|
|
22
|
+
FormOrderedAnnotation,
|
|
23
|
+
GeneratorAnnotation,
|
|
24
|
+
GeneratorAnnotationId,
|
|
25
|
+
HiddenAnnotation,
|
|
26
|
+
IconAnnotation,
|
|
27
|
+
IconFromRefAnnotation,
|
|
28
|
+
Key,
|
|
29
|
+
LabelAnnotation,
|
|
30
|
+
ReferenceAnnotation,
|
|
31
|
+
ReferenceAnnotationId,
|
|
32
|
+
TypeAnnotation,
|
|
33
|
+
getDescriptionWithSchema,
|
|
34
|
+
getDictionary,
|
|
35
|
+
getFromAst,
|
|
36
|
+
getLabelWithSchema,
|
|
37
|
+
getTypeAnnotation,
|
|
38
|
+
getTypeIdentifierAnnotation,
|
|
39
|
+
makeUserAnnotation,
|
|
40
|
+
setDescriptionWithSchema,
|
|
41
|
+
setDictionary,
|
|
42
|
+
setLabelWithSchema
|
|
43
|
+
} from "./chunk-3TN2VMI4.mjs";
|
|
44
|
+
import {
|
|
45
|
+
__export
|
|
46
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
47
|
+
|
|
48
|
+
// src/Annotation.ts
|
|
49
|
+
var Annotation_exports = {};
|
|
50
|
+
__export(Annotation_exports, {
|
|
51
|
+
DEFAULT_LAYOUT_NAME: () => DEFAULT_LAYOUT_NAME,
|
|
52
|
+
DescriptionAnnotation: () => DescriptionAnnotation,
|
|
53
|
+
Dictionary: () => Dictionary2,
|
|
54
|
+
FieldLookupAnnotationId: () => FieldLookupAnnotationId,
|
|
55
|
+
FormCreateAnnotation: () => FormCreateAnnotation,
|
|
56
|
+
FormCreateAnnotationId: () => FormCreateAnnotationId,
|
|
57
|
+
FormInlineAnnotation: () => FormInlineAnnotation,
|
|
58
|
+
FormInputAnnotation: () => FormInputAnnotation,
|
|
59
|
+
FormLayoutAnnotation: () => FormLayoutAnnotation,
|
|
60
|
+
FormLayoutAnnotationId: () => FormLayoutAnnotationId,
|
|
61
|
+
FormOrderedAnnotation: () => FormOrderedAnnotation,
|
|
62
|
+
GeneratorAnnotation: () => GeneratorAnnotation,
|
|
63
|
+
GeneratorAnnotationId: () => GeneratorAnnotationId,
|
|
64
|
+
HiddenAnnotation: () => HiddenAnnotation,
|
|
65
|
+
IconAnnotation: () => IconAnnotation,
|
|
66
|
+
IconFromRefAnnotation: () => IconFromRefAnnotation,
|
|
67
|
+
Key: () => Key2,
|
|
68
|
+
LabelAnnotation: () => LabelAnnotation,
|
|
69
|
+
ReferenceAnnotation: () => ReferenceAnnotation,
|
|
70
|
+
ReferenceAnnotationId: () => ReferenceAnnotationId,
|
|
71
|
+
TypeAnnotation: () => TypeAnnotation,
|
|
72
|
+
TypeId: () => TypeId,
|
|
73
|
+
atom: () => atom,
|
|
74
|
+
atomProperty: () => atomProperty,
|
|
75
|
+
buildDictionary: () => buildDictionary,
|
|
76
|
+
get: () => get2,
|
|
77
|
+
getDescriptionWithSchema: () => getDescriptionWithSchema,
|
|
78
|
+
getDictionary: () => getDictionary2,
|
|
79
|
+
getFromAst: () => getFromAst2,
|
|
80
|
+
getLabelWithSchema: () => getLabelWithSchema,
|
|
81
|
+
getTypeAnnotation: () => getTypeAnnotation,
|
|
82
|
+
getTypeIdentifierAnnotation: () => getTypeIdentifierAnnotation,
|
|
83
|
+
make: () => make2,
|
|
84
|
+
set: () => set2,
|
|
85
|
+
setDescriptionWithSchema: () => setDescriptionWithSchema,
|
|
86
|
+
setDictionary: () => setDictionary2,
|
|
87
|
+
setLabelWithSchema: () => setLabelWithSchema,
|
|
88
|
+
update: () => update2
|
|
89
|
+
});
|
|
90
|
+
import * as Function from "effect/Function";
|
|
91
|
+
import * as Schema from "effect/Schema";
|
|
92
|
+
|
|
93
|
+
// src/internal/Annotation/atoms.ts
|
|
94
|
+
import * as Atom from "@effect-atom/atom/Atom";
|
|
95
|
+
import * as Data from "effect/Data";
|
|
96
|
+
import * as Option from "effect/Option";
|
|
97
|
+
import { assertArgument } from "@dxos/invariant";
|
|
98
|
+
var annotationFamily = Atom.family((target) => Atom.family((annotation) => {
|
|
99
|
+
const read = () => Option.map(get(target, annotation), snapshotForComparison);
|
|
100
|
+
return Atom.make((get3) => {
|
|
101
|
+
let previous = read();
|
|
102
|
+
const unsubscribe = subscribe(target, () => {
|
|
103
|
+
const next = read();
|
|
104
|
+
if (!sameOption(previous, next)) {
|
|
105
|
+
previous = next;
|
|
106
|
+
get3.setSelf(next);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
get3.addFinalizer(() => unsubscribe());
|
|
110
|
+
return previous;
|
|
111
|
+
}).pipe(Atom.keepAlive);
|
|
112
|
+
}));
|
|
113
|
+
var annotationPropertyFamily = Atom.family(([target, annotation, key]) => {
|
|
114
|
+
const read = () => get(target, annotation).pipe(Option.map((value) => snapshotForComparison(value[key])), Option.getOrUndefined);
|
|
115
|
+
return Atom.make((get3) => {
|
|
116
|
+
let previous = read();
|
|
117
|
+
const unsubscribe = subscribe(target, () => {
|
|
118
|
+
const next = read();
|
|
119
|
+
if (next !== previous) {
|
|
120
|
+
previous = next;
|
|
121
|
+
get3.setSelf(next);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
get3.addFinalizer(() => unsubscribe());
|
|
125
|
+
return previous;
|
|
126
|
+
}).pipe(Atom.keepAlive);
|
|
127
|
+
});
|
|
128
|
+
var sameOption = (a, b) => Option.isNone(a) || Option.isNone(b) ? Option.isNone(a) && Option.isNone(b) : a.value === b.value;
|
|
129
|
+
var makeAtom = (target, annotation) => {
|
|
130
|
+
assertArgument(isEntity(target), "target", "Must be a reactive ECHO entity");
|
|
131
|
+
return annotationFamily(target)(annotation);
|
|
132
|
+
};
|
|
133
|
+
var makeProperty = (target, annotation, key) => {
|
|
134
|
+
assertArgument(isEntity(target), "target", "Must be a reactive ECHO entity");
|
|
135
|
+
return annotationPropertyFamily(Data.tuple(target, annotation, key));
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// src/Annotation.ts
|
|
139
|
+
var TypeId = "~@dxos/echo/Annotation";
|
|
140
|
+
var Key2 = Key;
|
|
141
|
+
var make2 = makeUserAnnotation;
|
|
142
|
+
var get2 = Function.dual(2, (target, annotation) => {
|
|
143
|
+
return get(target, annotation);
|
|
144
|
+
});
|
|
145
|
+
var set2 = Function.dual(3, (target, annotation, value) => {
|
|
146
|
+
return set(target, annotation, value);
|
|
147
|
+
});
|
|
148
|
+
var update2 = (target, annotation, mutator) => update(target, annotation, mutator);
|
|
149
|
+
var getFromAst2 = Function.dual(2, (ast, annotation) => {
|
|
150
|
+
return getFromAst(ast, annotation);
|
|
151
|
+
});
|
|
152
|
+
var atom = makeAtom;
|
|
153
|
+
var atomProperty = makeProperty;
|
|
154
|
+
var Dictionary2 = Dictionary;
|
|
155
|
+
var getDictionary2 = Function.dual(2, (values, annotation) => {
|
|
156
|
+
return getDictionary(values, annotation);
|
|
157
|
+
});
|
|
158
|
+
var setDictionary2 = Function.dual(3, (values, annotation, value) => {
|
|
159
|
+
return setDictionary(values, annotation, value);
|
|
160
|
+
});
|
|
161
|
+
var buildDictionary = (build) => {
|
|
162
|
+
const dictionary = Schema.encodeSync(Dictionary2)({});
|
|
163
|
+
build(dictionary);
|
|
164
|
+
return dictionary;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
TypeId,
|
|
169
|
+
Key2 as Key,
|
|
170
|
+
make2 as make,
|
|
171
|
+
get2 as get,
|
|
172
|
+
set2 as set,
|
|
173
|
+
update2 as update,
|
|
174
|
+
getFromAst2 as getFromAst,
|
|
175
|
+
atom,
|
|
176
|
+
atomProperty,
|
|
177
|
+
Dictionary2 as Dictionary,
|
|
178
|
+
getDictionary2 as getDictionary,
|
|
179
|
+
setDictionary2 as setDictionary,
|
|
180
|
+
buildDictionary,
|
|
181
|
+
Annotation_exports
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=chunk-C62JYFAD.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Annotation.ts", "../../../src/internal/Annotation/atoms.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nexport {\n DEFAULT_LAYOUT_NAME,\n DescriptionAnnotation,\n FieldLookupAnnotationId,\n FormCreateAnnotation,\n FormCreateAnnotationId,\n FormInlineAnnotation,\n FormInputAnnotation,\n FormLayoutAnnotation,\n FormLayoutAnnotationId,\n type FormLayoutMap,\n FormOrderedAnnotation,\n GeneratorAnnotation,\n GeneratorAnnotationId,\n type GeneratorAnnotationValue,\n HiddenAnnotation,\n IconAnnotation,\n IconFromRefAnnotation,\n LabelAnnotation,\n ReferenceAnnotation,\n ReferenceAnnotationId,\n type ReferenceAnnotationValue,\n TypeAnnotation,\n getDescriptionWithSchema,\n getLabelWithSchema,\n getTypeAnnotation,\n getTypeIdentifierAnnotation,\n setDescriptionWithSchema,\n setLabelWithSchema,\n} from './internal/Annotation';\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport * as Types from 'effect/Types';\n\nimport * as Entity from './Entity';\nimport * as internalAnnotations from './internal/Annotation';\nimport * as annotationAtoms from './internal/Annotation/atoms';\n\nexport const TypeId = '~@dxos/echo/Annotation' as const;\nexport type TypeId = typeof TypeId;\n\n// TODO(dmaretskyi): Reconcile different get/set styles: mutate in-place, return.\n// TODO(dmaretskyi): Reconcile Annotation methods vs static functions.\n// TODO(dmaretskyi): Reconcile Annotation.Key vs DXN -- work-out approach to versioning.\n\n/**\n * Annotation is a typed property that can be assigned to a schema or an entity instance.\n */\nexport interface Annotation<T> {\n [TypeId]: {\n _Type: T;\n };\n\n // TODO(dmaretskyi): Make this a DXN?\n /**\n * Unique fully-qualified identifier for the annotation.\n * @example \"org.dxos.annotation.color\"\n */\n readonly key: Key;\n\n /**\n * Schema of the annotation value.\n */\n readonly schema: Schema.Schema<T, unknown, never>;\n\n /**\n * Get the annotation value from an Effect schema.\n *\n * Only accepts `Schema.Schema.Any` — to read an annotation off a `Type.Type`\n * entity, unwrap it first with `Type.getSchema(entity)`. This keeps the\n * annotation pipeline single-shaped and forces annotations to live on the\n * source schema, not on the post-construction Type entity.\n */\n get: (schema: Schema.Schema.Any) => Option.Option<T>;\n /**\n * Get the annotation value from the AST.\n */\n getFromAst: (ast: SchemaAST.AST) => Option.Option<T>;\n /**\n * Set the annotation on an Effect schema.\n *\n * Only accepts `Schema.Schema.Any` — annotations must be applied to the\n * source schema BEFORE wrapping it with `Type.makeObject` / `Type.makeRelation`.\n * In a pipe, place every `Annotation.X.set(...)` before the `Type.make...` step.\n */\n set: (value: T) => <S extends Schema.Schema.Any>(schema: S) => S;\n}\n\nexport const Key = internalAnnotations.Key;\nexport type Key = Schema.Schema.Type<typeof Key>;\n\ninterface MakeProps<T> {\n id: string;\n schema: Schema.Schema<T, any, never>;\n}\n\n/**\n * Create a new schema annotation.\n * Annotation can be assigned both to fields and to the schema itself.\n * Annotation is serialized with the schema.\n *\n * @example\n * ```ts\n * const ColorAnnotation = Annotation.make({\n * id: 'org.dxos.annotation.color',\n * schema: Schema.String,\n * });\n *\n * const schema = Schema.String.annotations(ColorAnnotation.set('red'));\n * ```\n */\nexport const make: <T>(props: MakeProps<T>) => Annotation<T> = internalAnnotations.makeUserAnnotation;\n\n/**\n * Get the value of an annotation from an entity instance or snapshot.\n * For schema-level reads use the annotation instance method (e.g. `ColorAnnotation.get(schema)`).\n * For getting an annotation value from a dictionary, use `getDictionary`.\n *\n * The value is read-only (schema types are readonly by default): to mutate an annotation (including\n * in-place array splices) use `Annotation.update` or `Annotation.set`, which open a change transaction.\n * A read-only return is sound regardless of context — the reactive proxy rejects mutation outside an\n * `Obj.update`.\n */\nexport const get: {\n <T>(annotation: Annotation<T>): (target: Entity.Unknown | Entity.Snapshot) => Option.Option<T>;\n <T>(target: Entity.Unknown | Entity.Snapshot, annotation: Annotation<T>): Option.Option<T>;\n} = Function.dual<\n <T>(annotation: Annotation<T>) => (target: Entity.Unknown | Entity.Snapshot) => Option.Option<T>,\n <T>(target: Entity.Unknown | Entity.Snapshot, annotation: Annotation<T>) => Option.Option<T>\n>(2, (target, annotation) => {\n return internalAnnotations.get(target, annotation);\n});\n\n/**\n * Set the value of an annotation on an entity instance.\n * For schema-level writes use the annotation instance method (e.g. `ColorAnnotation.set('red')`).\n * For setting an annotation value on a dictionary, use `setDictionary`.\n */\nexport const set: {\n <T>(annotation: Annotation<T>, value: T): (target: Entity.Mutable<Entity.Unknown>) => void;\n <T>(target: Entity.Mutable<Entity.Unknown>, annotation: Annotation<T>, value: T): void;\n} = Function.dual<\n <T>(annotation: Annotation<T>, value: T) => (target: Entity.Mutable<Entity.Unknown>) => void,\n <T>(target: Entity.Mutable<Entity.Unknown>, annotation: Annotation<T>, value: T) => void\n>(3, (target, annotation, value) => {\n return internalAnnotations.set(target, annotation, value);\n});\n\n/**\n * Mutate an existing annotation value in place via a callback, wrapping the mutation in a change\n * transaction (like `Obj.update`). The result is validated against the annotation's schema. Use when\n * only an annotation needs to change; to mutate it alongside other changes (unvalidated), call\n * `Annotation.get` inside an existing `Obj.update` instead. No-op when absent.\n */\nexport const update = <T>(\n target: Entity.Unknown,\n annotation: Annotation<T>,\n mutator: (value: Entity.Mutable<T>) => void,\n): void => internalAnnotations.update(target, annotation, mutator);\n\nexport const getFromAst: {\n <T>(annotation: Annotation<T>): (ast: SchemaAST.AST) => Option.Option<T>;\n <T>(ast: SchemaAST.AST, annotation: Annotation<T>): Option.Option<T>;\n} = Function.dual<\n <T>(annotation: Annotation<T>) => (ast: SchemaAST.AST) => Option.Option<T>,\n <T>(ast: SchemaAST.AST, annotation: Annotation<T>) => Option.Option<T>\n>(2, (ast, annotation) => {\n return internalAnnotations.getFromAst(ast, annotation);\n});\n\n/**\n * Reactive atom for an annotation value on an entity instance.\n * Fires only when the annotation value changes (mirrors `Obj.atom`, scoped to one annotation).\n */\nexport const atom = annotationAtoms.makeAtom;\n\n/**\n * Reactive atom for a single key of a record-valued annotation on an entity instance.\n * Reactivity is scoped to that key, and the value type is preserved (mirrors `Obj.atomProperty`).\n */\nexport const atomProperty = annotationAtoms.makeProperty;\n\n/**\n * Set of annotation 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: Annotation.Dictionary,\n * });\n * ```\n */\nexport const Dictionary = internalAnnotations.Dictionary;\nexport interface Dictionary extends Schema.Schema.Type<typeof Dictionary> {}\n\n/**\n * Get the value of an annotation from a Dictionary.\n */\nexport const getDictionary: {\n <T>(annotation: Annotation<T>): (values: Dictionary) => Option.Option<T>;\n <T>(values: Dictionary, annotation: Annotation<T>): Option.Option<T>;\n} = Function.dual<\n <T>(annotation: Annotation<T>) => (values: Dictionary) => Option.Option<T>,\n <T>(values: Dictionary, annotation: Annotation<T>) => Option.Option<T>\n>(2, (values, annotation) => {\n return internalAnnotations.getDictionary(values, annotation);\n});\n\n/**\n * Set the value of an annotation in a Dictionary.\n *\n * Can also be used within Obj.update callback:\n *\n * ```ts\n * Obj.update(obj, (obj) => {\n * Annotation.setDictionary(obj.annotations, ColorAnnotation, 'red');\n * });\n * ```\n */\nexport const setDictionary: {\n <T>(annotation: Annotation<T>, value: T): (values: Dictionary) => void;\n <T>(values: Types.Mutable<Dictionary>, annotation: Annotation<T>, value: T): void;\n} = Function.dual<\n <T>(annotation: Annotation<T>, value: T) => (values: Dictionary) => void,\n <T>(values: Types.Mutable<Dictionary>, annotation: Annotation<T>, value: T) => void\n>(3, (values, annotation, value) => {\n return internalAnnotations.setDictionary(values, annotation, value);\n});\n\n/**\n * Build a dictionary by mutating it in a callback.\n *\n * @example\n * ```ts\n * const dictionary = Annotation.buildDictionary((dictionary) => {\n * Annotation.setDictionary(dictionary, ColorAnnotation, 'red');\n * Annotation.setDictionary(dictionary, SizeAnnotation, '10px');\n * });\n * ```\n */\nexport const buildDictionary = (build: (dictionary: Types.Mutable<Dictionary>) => void): Dictionary => {\n const dictionary = Schema.encodeSync(Dictionary)({});\n build(dictionary);\n return dictionary;\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Atom from '@effect-atom/atom/Atom';\nimport * as Data from 'effect/Data';\nimport * as Option from 'effect/Option';\n\nimport { assertArgument } from '@dxos/invariant';\n\nimport type * as Annotation from '../../Annotation';\nimport type * as Entity from '../../Entity';\nimport { snapshotForComparison } from '../common/atom-snapshot';\nimport { subscribe } from '../common/proxy/reactive';\nimport { isEntity } from '../Entity';\nimport { get as getAnnotation } from './entity-dictionary';\n\n/**\n * Atom family for an annotation value on an entity instance.\n * Mirrors the object-property atom family: re-emits a fresh reference whenever the entity changes\n * (so an in-place array mutation is observed) and dedupes primitive values via `!==`.\n */\nconst annotationFamily = Atom.family((target: Entity.Unknown) =>\n Atom.family(<T>(annotation: Annotation.Annotation<T>): Atom.Atom<Option.Option<T>> => {\n const read = (): Option.Option<T> => Option.map(getAnnotation(target, annotation), snapshotForComparison);\n\n return Atom.make<Option.Option<T>>((get) => {\n let previous = read();\n\n const unsubscribe = subscribe(target, () => {\n const next = read();\n if (!sameOption(previous, next)) {\n previous = next;\n get.setSelf(next);\n }\n });\n get.addFinalizer(() => unsubscribe());\n\n return previous;\n }).pipe(Atom.keepAlive);\n }),\n);\n\n/**\n * Atom family for a single key of a record-valued annotation on an entity instance.\n * Keyed by a value-equal `Data.tuple([target, annotation, key])` so nested families are avoided.\n */\nconst annotationPropertyFamily = Atom.family(\n ([target, annotation, key]: readonly [\n Entity.Unknown,\n Annotation.Annotation<Record<string, any>>,\n string,\n ]): Atom.Atom<any> => {\n const read = (): unknown =>\n getAnnotation(target, annotation).pipe(\n Option.map((value) => snapshotForComparison(value[key])),\n Option.getOrUndefined,\n );\n\n return Atom.make<unknown>((get) => {\n let previous = read();\n\n const unsubscribe = subscribe(target, () => {\n const next = read();\n if (next !== previous) {\n previous = next;\n get.setSelf(next);\n }\n });\n get.addFinalizer(() => unsubscribe());\n\n return previous;\n }).pipe(Atom.keepAlive);\n },\n);\n\n/** Equal when both empty, or both present with the same (snapshotted) value. */\nconst sameOption = <T>(a: Option.Option<T>, b: Option.Option<T>): boolean =>\n Option.isNone(a) || Option.isNone(b) ? Option.isNone(a) && Option.isNone(b) : a.value === b.value;\n\n/**\n * Reactive atom for an annotation value on an entity instance. Emits a shallow snapshot (a fresh\n * reference for objects/arrays) so dependent atoms recompute on change. Mirrors {@link makeProperty}.\n */\nexport const makeAtom = <T>(\n target: Entity.Unknown,\n annotation: Annotation.Annotation<T>,\n): Atom.Atom<Option.Option<T>> => {\n assertArgument(isEntity(target), 'target', 'Must be a reactive ECHO entity');\n return annotationFamily(target)(annotation);\n};\n\n/**\n * Reactive atom for a single key of a record-valued annotation on an entity instance.\n */\nexport const makeProperty = <V>(\n target: Entity.Unknown,\n annotation: Annotation.Annotation<Record<string, V>>,\n key: string,\n): Atom.Atom<V | undefined> => {\n assertArgument(isEntity(target), 'target', 'Must be a reactive ECHO entity');\n // The flattened family key is a single concrete tuple type, so the generic `V` is erased at the\n // family boundary and recovered here; no typed alternative exists for a per-call-generic family.\n return annotationPropertyFamily(\n Data.tuple(target, annotation as Annotation.Annotation<Record<string, any>>, key),\n ) as Atom.Atom<V | undefined>;\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Dictionary", "Key", "get", "getDictionary", "getFromAst", "make", "set", "setDictionary", "update", "Function", "Schema", "Atom", "Data", "Option", "assertArgument", "annotationFamily", "family", "target", "annotation", "read", "map", "getAnnotation", "snapshotForComparison", "make", "get", "previous", "unsubscribe", "subscribe", "next", "sameOption", "setSelf", "addFinalizer", "pipe", "keepAlive", "annotationPropertyFamily", "key", "value", "getOrUndefined", "a", "b", "isNone", "makeAtom", "assertArgument", "isEntity", "makeProperty", "tuple", "TypeId", "Key", "make", "makeUserAnnotation", "get", "dual", "target", "annotation", "set", "value", "update", "mutator", "getFromAst", "ast", "atom", "makeAtom", "atomProperty", "makeProperty", "Dictionary", "getDictionary", "values", "setDictionary", "buildDictionary", "build", "dictionary", "encodeSync"]
|
|
7
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RefArray
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WKIT2YY5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Ref,
|
|
6
6
|
getSchemaReference
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-L3E5IXAE.mjs";
|
|
8
8
|
import {
|
|
9
9
|
__export
|
|
10
10
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -45,4 +45,4 @@ export {
|
|
|
45
45
|
isRefType,
|
|
46
46
|
Ref_exports
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-FSGX2R62.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/Ref.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Option from 'effect/Option';\nimport type * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { type URI } from '@dxos/keys';\n\nimport type * as Entity from './Entity';\nimport type * as internal from './internal';\nimport * as refInternal from './internal/Ref';\nimport type * as JsonSchema from './JsonSchema';\nimport type * as Obj from './Obj';\nimport type * as Relation from './Relation';\n// eslint-disable-next-line @dxos/rules/import-as-namespace\nimport type * as Type$ from './Type';\n\n/**\n * Instance type for a reference.\n *\n * Reference can point to any object or relation.\n * References are lazy loaded.\n *\n * `ref.dxn` is the DXN of the referenced object.\n *\n * @example\n * ```ts\n * const taskRef: Ref<Task> = Ref.make(task);\n *\n * await taskRef.load(); // Returns Promise<Task>\n * yield* Database.load(taskRef); // Effectful version.\n *\n * database.makeRef(dxn); // Create a ref from a DXN.\n * ```\n */\nexport type Ref<T> = refInternal.Ref<T>;\nexport type Unknown = refInternal.Ref<Obj.Unknown>;\n\n/**\n * Factory function to create a Ref schema for the given target schema.\n * Use this in schema definitions to declare reference fields.\n *\n * @example\n * ```ts\n * class Task extends Type.makeObject<Task>(DXN.make('com.example.type.task', '0.1.0'))(\n * Schema.Struct({\n * assignee: Ref.Ref(Person), // Creates a Ref schema\n * }),\n * ) {}\n * ```\n */\nexport const Ref: {\n <S extends Type$.AnyObj>(type: S): RefSchema<Type$.InstanceType<S> & Obj.Unknown>;\n\n // Relations are entities too and can be referenced. The instance type already\n // carries the relation kind brand, so intersect with `Relation.Unknown` (not\n // `Obj.Unknown`, whose object kind brand conflicts and collapses to `never`).\n <S extends Type$.AnyRelation>(type: S): RefSchema<Type$.InstanceType<S> & Relation.Unknown>;\n\n // `Type.Type` entities (the meta-schema kind) can be referenced too — e.g. a\n // trigger that points to a stored function/workflow definition.\n <T extends Type$.Type<any>>(type: T): RefSchema<Type$.InstanceType<T>>;\n\n // Schema-side overload for the well-known \"any object\" / \"any relation\" schemas.\n // Other raw `Schema.Schema` values are intentionally rejected — callers should\n // pass a `Type.Type` entity instead.\n <S extends internal.UnknownTypeSchema<any, any>>(schema: S): RefSchema<Schema.Schema.Type<S> & Obj.Unknown>;\n} = refInternal.Ref as any;\n\nexport const Array = refInternal.RefArray;\n\n/**\n * TypeScript type for a Ref schema.\n * This is the type of the SCHEMA itself, not the runtime ref instance.\n * For the instance type, use `Ref.Ref<T>` from the Ref module.\n *\n * @example\n * ```ts\n * // Schema type annotation (rarely needed, usually inferred):\n * const refSchema: Ref.RefSchema<typeof Task> = Ref.Ref(Task);\n *\n * // Instance type annotation (use Ref.Ref instead):\n * const refInstance: Ref.Ref<Task> = Ref.make(task);\n * ```\n */\n// TODO(dmaretskyi): Investigate if we can remove this type.\n// Post DX-836 it will become just `Schema.Schema<Ref.Ref<T>>`.\n// NOTE: This could be Type.Ref<T> instead, but since it going to be removed, it's better to keep it here, self-contained.\nexport interface RefSchema<T extends Entity.Unknown> extends refInternal.RefSchema<T> {}\n\n/**\n * Extract reference target.\n */\nexport type Target<R extends Unknown> = R extends refInternal.Ref<infer T> ? T : never;\n\n/**\n * Reference resolver.\n */\nexport type Resolver = refInternal.RefResolver;\n\nexport const isRef: (value: unknown) => value is Unknown = refInternal.Ref.isRef;\n\nexport const make = refInternal.Ref.make;\n\n// TODO(dmaretskyi): Consider just allowing `make` to accept URI.\nexport const fromURI = (uri: URI.URI): refInternal.Ref<any> => refInternal.Ref.fromURI(uri);\n\nexport const hasEntityId = refInternal.Ref.hasEntityId;\n\n// TODO(wittjosiah): Factor out?\nexport const isRefType = (ast: SchemaAST.AST): boolean => {\n return SchemaAST.getAnnotation<JsonSchema.JsonSchema>(ast, SchemaAST.JSONSchemaAnnotationId).pipe(\n Option.flatMap((jsonSchema) => ('$id' in jsonSchema ? Option.some(jsonSchema) : Option.none())),\n Option.flatMap((jsonSchema) => {\n const { typename } = refInternal.getSchemaReference(jsonSchema) ?? {};\n return typename ? Option.some(true) : Option.some(false);\n }),\n Option.getOrElse(() => false),\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAAA;;;aAAAA;EAAA;;;;;;AAMA,YAAYC,YAAY;AAExB,YAAYC,eAAe;AA+CpB,IAAMC,OAgBGA;AAET,IAAMC,QAAoBC;AA+B1B,IAAMC,QAA0DH,IAAIG;AAEpE,IAAMC,OAAmBJ,IAAII;AAG7B,IAAMC,UAAU,CAACC,QAAmDN,IAAIK,QAAQC,GAAAA;AAEhF,IAAMC,cAA0BP,IAAIO;AAGpC,IAAMC,YAAY,CAACC,QAAAA;AACxB,SAAiBC,wBAAqCD,KAAeE,gCAAsB,EAAEC,KACpFC,eAAQ,CAACC,eAAgB,SAASA,aAAoBC,YAAKD,UAAAA,IAAqBE,YAAI,CAAA,GACpFH,eAAQ,CAACC,eAAAA;AACd,UAAM,EAAEG,SAAQ,IAAiBC,mBAAmBJ,UAAAA,KAAe,CAAC;AACpE,WAAOG,WAAkBF,YAAK,IAAA,IAAeA,YAAK,KAAA;EACpD,CAAA,GACOI,iBAAU,MAAM,KAAA,CAAA;AAE3B;",
|
|
6
|
+
"names": ["Ref", "Option", "SchemaAST", "Ref", "Array", "RefArray", "isRef", "make", "fromURI", "uri", "hasEntityId", "isRefType", "ast", "getAnnotation", "JSONSchemaAnnotationId", "pipe", "flatMap", "jsonSchema", "some", "none", "typename", "getSchemaReference", "getOrElse"]
|
|
7
|
+
}
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isRef
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FSGX2R62.mjs";
|
|
4
4
|
import {
|
|
5
5
|
Kind,
|
|
6
6
|
KindId,
|
|
7
7
|
SnapshotKindId
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-BEFR7LEA.mjs";
|
|
9
9
|
import {
|
|
10
10
|
getSchema
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XB6ISRAO.mjs";
|
|
12
12
|
import {
|
|
13
13
|
VersionTypeId,
|
|
14
|
-
change,
|
|
15
14
|
clone,
|
|
16
15
|
compareVersions,
|
|
17
16
|
decodeVersion,
|
|
18
17
|
encodeVersion,
|
|
19
|
-
getProxyTarget,
|
|
20
18
|
getSnapshot,
|
|
21
19
|
isDeleted,
|
|
22
|
-
isProxy,
|
|
23
20
|
isVersion,
|
|
24
21
|
makeAtom,
|
|
25
|
-
|
|
22
|
+
makeLabelAtom,
|
|
26
23
|
makeProperty,
|
|
27
24
|
makeWithReactive,
|
|
28
25
|
objectFromJSON,
|
|
@@ -31,17 +28,23 @@ import {
|
|
|
31
28
|
sort,
|
|
32
29
|
sortByLabel,
|
|
33
30
|
sortByTypename,
|
|
34
|
-
subscribe,
|
|
35
31
|
version,
|
|
36
32
|
versionValid
|
|
37
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-ACFAOTKJ.mjs";
|
|
38
34
|
import {
|
|
39
35
|
addTag,
|
|
40
36
|
deleteKeys,
|
|
41
37
|
getKeys,
|
|
42
38
|
getMetaChecked,
|
|
39
|
+
makeObject,
|
|
43
40
|
removeTag
|
|
44
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-2HKGAQM4.mjs";
|
|
42
|
+
import {
|
|
43
|
+
change,
|
|
44
|
+
getProxyTarget,
|
|
45
|
+
isProxy,
|
|
46
|
+
subscribe
|
|
47
|
+
} from "./chunk-L3E5IXAE.mjs";
|
|
45
48
|
import {
|
|
46
49
|
MetaId,
|
|
47
50
|
ParentId,
|
|
@@ -50,6 +53,7 @@ import {
|
|
|
50
53
|
getDescription,
|
|
51
54
|
getIcon,
|
|
52
55
|
getLabel,
|
|
56
|
+
getLabelProperty,
|
|
53
57
|
getType,
|
|
54
58
|
getTypeAnnotation,
|
|
55
59
|
getTypeURI,
|
|
@@ -58,14 +62,14 @@ import {
|
|
|
58
62
|
isInstanceOf,
|
|
59
63
|
setDescription,
|
|
60
64
|
setLabel
|
|
61
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-3TN2VMI4.mjs";
|
|
62
66
|
import {
|
|
63
67
|
ANY_OBJECT_TYPENAME,
|
|
64
68
|
ANY_OBJECT_VERSION
|
|
65
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-2ZHECXUR.mjs";
|
|
66
70
|
import {
|
|
67
71
|
GetReactiveError
|
|
68
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-TOCVVFK2.mjs";
|
|
69
73
|
import {
|
|
70
74
|
__export
|
|
71
75
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -98,6 +102,7 @@ __export(Obj_exports, {
|
|
|
98
102
|
getReactive: () => getReactive,
|
|
99
103
|
getReactiveOption: () => getReactiveOption,
|
|
100
104
|
getReactiveOrThrow: () => getReactiveOrThrow,
|
|
105
|
+
getReactiveOrUndefined: () => getReactiveOrUndefined,
|
|
101
106
|
getSnapshot: () => getSnapshot2,
|
|
102
107
|
getType: () => getType2,
|
|
103
108
|
getTypeURI: () => getTypeURI2,
|
|
@@ -109,6 +114,8 @@ __export(Obj_exports, {
|
|
|
109
114
|
isObject: () => isObject,
|
|
110
115
|
isSnapshot: () => isSnapshot,
|
|
111
116
|
isVersion: () => isVersion2,
|
|
117
|
+
labelAtom: () => labelAtom,
|
|
118
|
+
labelProperty: () => labelProperty,
|
|
112
119
|
make: () => make,
|
|
113
120
|
removeTag: () => removeTag2,
|
|
114
121
|
setDescription: () => setDescription2,
|
|
@@ -128,6 +135,7 @@ __export(Obj_exports, {
|
|
|
128
135
|
});
|
|
129
136
|
import * as Effect from "effect/Effect";
|
|
130
137
|
import * as Equal from "effect/Equal";
|
|
138
|
+
import * as Exit from "effect/Exit";
|
|
131
139
|
import * as Function from "effect/Function";
|
|
132
140
|
import * as Option from "effect/Option";
|
|
133
141
|
import * as Schema from "effect/Schema";
|
|
@@ -208,6 +216,15 @@ var getReactive = (snapshot) => Effect.gen(function* () {
|
|
|
208
216
|
});
|
|
209
217
|
var getReactiveOption = (snapshot) => getReactive(snapshot).pipe(Effect.map(Option.some), Effect.catchAll(() => Effect.succeed(Option.none())));
|
|
210
218
|
var getReactiveOrThrow = (snapshot) => Effect.runSync(getReactive(snapshot));
|
|
219
|
+
var getReactiveOrUndefined = (snapshot) => {
|
|
220
|
+
if (snapshot === void 0) {
|
|
221
|
+
return void 0;
|
|
222
|
+
}
|
|
223
|
+
return Effect.runSyncExit(getReactive(snapshot)).pipe(Exit.match({
|
|
224
|
+
onSuccess: (value) => value,
|
|
225
|
+
onFailure: () => void 0
|
|
226
|
+
}));
|
|
227
|
+
};
|
|
211
228
|
var clone2 = clone;
|
|
212
229
|
var update = (obj, callback) => {
|
|
213
230
|
change(obj, callback);
|
|
@@ -236,7 +253,7 @@ var getURI = (entity, options) => {
|
|
|
236
253
|
};
|
|
237
254
|
var getTypeURI2 = (obj) => {
|
|
238
255
|
const type = getTypeURI(obj);
|
|
239
|
-
invariant(type != null, "Corrupted object: missing type.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L:
|
|
256
|
+
invariant(type != null, "Corrupted object: missing type.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 329, S: void 0, A: ["type != null", "'Corrupted object: missing type.'"] });
|
|
240
257
|
return type;
|
|
241
258
|
};
|
|
242
259
|
var getType2 = (obj) => getType(obj);
|
|
@@ -378,6 +395,8 @@ var version2 = (entity) => version(entity);
|
|
|
378
395
|
var atom = makeAtom;
|
|
379
396
|
var atomReactive = makeWithReactive;
|
|
380
397
|
var atomProperty = makeProperty;
|
|
398
|
+
var labelAtom = makeLabelAtom;
|
|
399
|
+
var labelProperty = getLabelProperty;
|
|
381
400
|
|
|
382
401
|
export {
|
|
383
402
|
Unknown2 as Unknown,
|
|
@@ -389,6 +408,7 @@ export {
|
|
|
389
408
|
getReactive,
|
|
390
409
|
getReactiveOption,
|
|
391
410
|
getReactiveOrThrow,
|
|
411
|
+
getReactiveOrUndefined,
|
|
392
412
|
clone2 as clone,
|
|
393
413
|
update,
|
|
394
414
|
getValue,
|
|
@@ -432,6 +452,8 @@ export {
|
|
|
432
452
|
atom,
|
|
433
453
|
atomReactive,
|
|
434
454
|
atomProperty,
|
|
455
|
+
labelAtom,
|
|
456
|
+
labelProperty,
|
|
435
457
|
Obj_exports
|
|
436
458
|
};
|
|
437
|
-
//# sourceMappingURL=chunk-
|
|
459
|
+
//# sourceMappingURL=chunk-HBXT3GSB.mjs.map
|