@dxos/echo 0.16.0 → 0.17.0
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/Annotation.mjs +2 -2
- package/dist/lib/Database.mjs +1 -1
- package/dist/lib/Error.mjs +1 -1
- package/dist/lib/Feed.mjs +1 -1
- package/dist/lib/Format.mjs +2 -2
- package/dist/lib/Migration.mjs +1 -1
- package/dist/lib/chunk-Annotation.mjs +14 -11
- package/dist/lib/chunk-Annotation.mjs.map +1 -1
- package/dist/lib/chunk-Blob.mjs +1 -1
- package/dist/lib/chunk-Collection.mjs +1 -1
- package/dist/lib/chunk-Database.mjs +93 -7
- package/dist/lib/chunk-Database.mjs.map +1 -1
- package/dist/lib/chunk-Dataset.mjs +1 -1
- package/dist/lib/chunk-Entity.mjs +2 -2
- package/dist/lib/chunk-Entity.mjs.map +1 -1
- package/dist/lib/chunk-Error.mjs +13 -1
- package/dist/lib/chunk-Error.mjs.map +1 -1
- package/dist/lib/chunk-Feed.mjs +311 -17
- package/dist/lib/chunk-Feed.mjs.map +1 -1
- package/dist/lib/chunk-Filter.mjs +4 -3
- package/dist/lib/chunk-Filter.mjs.map +1 -1
- package/dist/lib/chunk-Format.mjs +2 -1
- package/dist/lib/chunk-Hypergraph.mjs +1 -1
- package/dist/lib/chunk-Hypergraph.mjs.map +1 -1
- package/dist/lib/chunk-Migration.mjs +155 -5
- package/dist/lib/chunk-Migration.mjs.map +1 -1
- package/dist/lib/chunk-Obj.mjs +12 -5
- package/dist/lib/chunk-Obj.mjs.map +1 -1
- package/dist/lib/chunk-Query.mjs +2 -2
- package/dist/lib/chunk-QueryResult.mjs.map +1 -1
- package/dist/lib/chunk-Ref2.mjs +2 -2
- package/dist/lib/chunk-Registry.mjs +1 -1
- package/dist/lib/chunk-Registry.mjs.map +1 -1
- package/dist/lib/chunk-Relation.mjs +5 -5
- package/dist/lib/chunk-Relation.mjs.map +1 -1
- package/dist/lib/chunk-Scope.mjs +16 -2
- package/dist/lib/chunk-Scope.mjs.map +1 -1
- package/dist/lib/chunk-Tag.mjs +4 -4
- package/dist/lib/chunk-Tag.mjs.map +1 -1
- package/dist/lib/chunk-Text.mjs +2 -2
- package/dist/lib/chunk-Type.mjs +26 -7
- package/dist/lib/chunk-Type.mjs.map +1 -1
- package/dist/lib/chunk-View.mjs +1 -1
- package/dist/lib/chunk-atom-snapshot.mjs +29 -1
- package/dist/lib/chunk-atom-snapshot.mjs.map +1 -1
- package/dist/lib/chunk-entity-dictionary.mjs +28 -19
- package/dist/lib/chunk-entity-dictionary.mjs.map +1 -1
- package/dist/lib/chunk-internal.mjs +231 -79
- package/dist/lib/chunk-internal.mjs.map +1 -1
- package/dist/lib/chunk-json-schema.mjs +1 -1
- package/dist/lib/chunk-ref.mjs +38 -34
- package/dist/lib/chunk-ref.mjs.map +1 -1
- package/dist/lib/chunk-select.mjs +7 -3
- package/dist/lib/chunk-select.mjs.map +1 -1
- package/dist/lib/index.mjs +2 -2
- package/dist/lib/internal.mjs +6 -6
- package/dist/lib/testing.mjs +2 -2
- package/dist/lib/testing.mjs.map +1 -1
- package/dist/types/src/Annotation.d.ts +1 -1
- package/dist/types/src/Annotation.d.ts.map +1 -1
- package/dist/types/src/Database.d.ts +30 -13
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Entity.d.ts +3 -4
- package/dist/types/src/Entity.d.ts.map +1 -1
- package/dist/types/src/Error.d.ts +36 -0
- package/dist/types/src/Error.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +261 -18
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Filter.d.ts +7 -1
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +1 -1
- package/dist/types/src/Migration.d.ts +213 -2
- package/dist/types/src/Migration.d.ts.map +1 -1
- package/dist/types/src/Migration.test.d.ts +2 -0
- package/dist/types/src/Migration.test.d.ts.map +1 -0
- package/dist/types/src/Obj.d.ts +4 -4
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/QueryResult.d.ts +16 -0
- package/dist/types/src/QueryResult.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +3 -4
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Scope.d.ts +32 -1
- package/dist/types/src/Scope.d.ts.map +1 -1
- package/dist/types/src/Tag.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts +27 -2
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts +35 -1
- package/dist/types/src/internal/Annotation/annotations.d.ts.map +1 -1
- package/dist/types/src/internal/Annotation/atoms.d.ts +2 -2
- package/dist/types/src/internal/Annotation/atoms.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts +11 -0
- package/dist/types/src/internal/Entity/api.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/model.d.ts +3 -2
- package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
- package/dist/types/src/internal/Format/string.d.ts +5 -1
- package/dist/types/src/internal/Format/string.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/atoms.d.ts +1 -1
- package/dist/types/src/internal/Obj/atoms.d.ts.map +1 -1
- package/dist/types/src/internal/Obj/json-serializer.d.ts.map +1 -1
- package/dist/types/src/internal/Query/pretty.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/ref.d.ts +5 -1
- package/dist/types/src/internal/Ref/ref.d.ts.map +1 -1
- package/dist/types/src/internal/Ref/strong-deps.d.ts +3 -1
- package/dist/types/src/internal/Ref/strong-deps.d.ts.map +1 -1
- package/dist/types/src/internal/common/api/meta.d.ts +4 -5
- package/dist/types/src/internal/common/api/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/atom-snapshot.d.ts +10 -0
- package/dist/types/src/internal/common/atom-snapshot.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/change-context.d.ts +4 -0
- package/dist/types/src/internal/common/proxy/change-context.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/ownership.d.ts +5 -0
- 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/schema-validator.d.ts +17 -2
- package/dist/types/src/internal/common/proxy/schema-validator.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/symbols.d.ts +10 -0
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +0 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/meta.d.ts +8 -4
- package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/model-symbols.d.ts +6 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
- package/dist/types/src/internal/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -15
- package/src/Annotation.test.ts +34 -0
- package/src/Annotation.ts +3 -0
- package/src/Database.ts +46 -15
- package/src/Entity.ts +3 -4
- package/src/Error.ts +9 -0
- package/src/Feed.test.ts +160 -0
- package/src/Feed.ts +412 -29
- package/src/Filter.ts +8 -1
- package/src/Hypergraph.ts +1 -1
- package/src/Migration.test.ts +137 -0
- package/src/Migration.ts +376 -4
- package/src/Obj.test.ts +44 -4
- package/src/Obj.ts +19 -5
- package/src/QueryResult.ts +14 -0
- package/src/Relation.ts +3 -4
- package/src/Scope.ts +43 -1
- package/src/Tag.md +5 -6
- package/src/Tag.ts +3 -2
- package/src/Type.test.ts +52 -0
- package/src/Type.ts +75 -22
- package/src/Type.tst.ts +155 -0
- package/src/internal/Annotation/annotations.test.ts +19 -0
- package/src/internal/Annotation/annotations.ts +67 -1
- package/src/internal/Annotation/atoms.ts +10 -9
- package/src/internal/Entity/api.ts +20 -1
- package/src/internal/Entity/model.ts +3 -0
- package/src/internal/Filter/match.ts +2 -2
- package/src/internal/Format/string.ts +7 -2
- package/src/internal/JsonSchema/json-schema.test.ts +2 -2
- package/src/internal/Obj/atoms.ts +9 -5
- package/src/internal/Obj/json-serializer.test.ts +34 -7
- package/src/internal/Obj/json-serializer.ts +18 -3
- package/src/internal/Query/pretty.ts +3 -2
- package/src/internal/Ref/ref.test.ts +27 -2
- package/src/internal/Ref/ref.ts +18 -2
- package/src/internal/Ref/strong-deps.ts +21 -2
- package/src/internal/common/api/meta.ts +7 -8
- package/src/internal/common/atom-snapshot.ts +61 -0
- package/src/internal/common/proxy/change-context.ts +5 -0
- package/src/internal/common/proxy/change.test.ts +62 -31
- package/src/internal/common/proxy/json-serializer.ts +3 -2
- package/src/internal/common/proxy/ownership.ts +14 -1
- package/src/internal/common/proxy/proxy-utils.ts +7 -1
- package/src/internal/common/proxy/schema-validator.ts +116 -27
- package/src/internal/common/proxy/symbols.ts +12 -0
- package/src/internal/common/proxy/typed-handler.test.ts +43 -0
- package/src/internal/common/proxy/typed-handler.ts +105 -33
- package/src/internal/common/types/meta.ts +25 -20
- package/src/internal/common/types/model-symbols.ts +7 -0
- package/src/internal/index.ts +1 -2
package/dist/lib/Annotation.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ct as UserTypeAnnotation, Dt as getDescriptionWithSchema, Gt as setDescriptionWithSchema, H as DEFAULT_LAYOUT_NAME, J as FormCreateAnnotation, K as FieldLookupAnnotationId, Nt as getLabelWithSchema, Q as FormInputAnnotation, Rt as getTypeAnnotation, U as DescriptionAnnotation, V as ContentVersionAnnotation, X as FormInlineAnnotation, Y as FormCreateAnnotationId, _t as SetParentAnnotation, at as GeneratorAnnotationId, ct as LabelAnnotation, et as FormLayoutAnnotation, ft as RawStringAnnotation, ht as ReferenceAnnotationId, it as GeneratorAnnotation, mt as ReferenceAnnotation, nt as FormOrderedAnnotation, ot as IconAnnotation, qt as setLabelWithSchema, st as IconFromRefAnnotation, tt as FormLayoutAnnotationId, vt as TypeAnnotation, z as ArrayPresentationAnnotation, zt as getTypeIdentifierAnnotation } from "./chunk-Database.mjs";
|
|
2
2
|
import { a as atom, c as get, d as make, f as set, i as TypeId, l as getDictionary, m as update, n as Dictionary, o as atomProperty, p as setDictionary, r as Key, s as buildDictionary, u as getFromAst } from "./chunk-Annotation.mjs";
|
|
3
|
-
export { ArrayPresentationAnnotation, DEFAULT_LAYOUT_NAME, DescriptionAnnotation, Dictionary, FieldLookupAnnotationId, FormCreateAnnotation, FormCreateAnnotationId, FormInlineAnnotation, FormInputAnnotation, FormLayoutAnnotation, FormLayoutAnnotationId, FormOrderedAnnotation, GeneratorAnnotation, GeneratorAnnotationId, IconAnnotation, IconFromRefAnnotation, Key, LabelAnnotation, ReferenceAnnotation, ReferenceAnnotationId, SetParentAnnotation as SetParent, TypeAnnotation, TypeId, UserTypeAnnotation as UserType, atom, atomProperty, buildDictionary, get, getDescriptionWithSchema, getDictionary, getFromAst, getLabelWithSchema, getTypeAnnotation, getTypeIdentifierAnnotation, make, set, setDescriptionWithSchema, setDictionary, setLabelWithSchema, update };
|
|
3
|
+
export { ArrayPresentationAnnotation, ContentVersionAnnotation, DEFAULT_LAYOUT_NAME, DescriptionAnnotation, Dictionary, FieldLookupAnnotationId, FormCreateAnnotation, FormCreateAnnotationId, FormInlineAnnotation, FormInputAnnotation, FormLayoutAnnotation, FormLayoutAnnotationId, FormOrderedAnnotation, GeneratorAnnotation, GeneratorAnnotationId, IconAnnotation, IconFromRefAnnotation, Key, LabelAnnotation, RawStringAnnotation, ReferenceAnnotation, ReferenceAnnotationId, SetParentAnnotation as SetParent, TypeAnnotation, TypeId, UserTypeAnnotation as UserType, atom, atomProperty, buildDictionary, get, getDescriptionWithSchema, getDictionary, getFromAst, getLabelWithSchema, getTypeAnnotation, getTypeIdentifierAnnotation, make, set, setDescriptionWithSchema, setDictionary, setLabelWithSchema, update };
|
package/dist/lib/Database.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Database, r as Origin, i as Service, a as TraceEvents, o as TypeId, s as add, c as addType, l as appendToFeed, u as
|
|
1
|
+
export { t as Database, r as Origin, i as Service, a as TraceEvents, o as TypeId, s as add, c as addType, l as appendToFeed, u as beginMigration, d as deleteFromFeed, f as flush, p as getSyncState, m as isDatabase, h as layer, g as load, _ as makeRef, v as makeService, y as notAvailable, b as peek, x as query, S as remove, C as resolve, w as retainObjects, T as runGarbageCollection, E as spaceId, D as stats, O as subscribeToSyncState, k as withSpaceId } from "./chunk-Database.mjs";
|
package/dist/lib/Error.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as BlobNotAvailableError, n as BlobTooLargeError, r as BlobWriteError, i as EntityNotFoundError, o as GetReactiveError, s as
|
|
1
|
+
export { t as BlobNotAvailableError, n as BlobTooLargeError, r as BlobWriteError, i as EntityNotFoundError, o as GetReactiveError, s as MigrationError, c as SchemaNotFoundError, l as TextEditNotFoundError, u as TextNotSupportedError } from "./chunk-Error.mjs";
|
package/dist/lib/Feed.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as
|
|
1
|
+
export { t as BLOCK_KEYS, n as BranchId, r as ContextFeedService, i as Cursor, a as CursorAnnotation, o as Feed, s as FeedOptions, l as IndexingOptions, u as LocalCursor, d as Namespace, f as PARENT_KEY, p as POSITION_KEY, m as RetentionOptions, h as START, g as append, _ as branchKey, v as fork, y as getBlockId, b as getBranch, x as getCursor, S as getFeedUri, C as getLocalCursor, w as getParent, T as getPosition, E as getPredecessor, D as getSyncState, O as history, k as isFork, A as layer, j as make, M as query, N as readBranch, P as remove, F as setBranch, I as setIndexing, L as setParent, R as setRetention, z as sync, B as walk } from "./chunk-Feed.mjs";
|
package/dist/lib/Format.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { _ as getOptionsAnnotation, c as FormatAnnotationId, d as OptionsAnnotationId, f as PropertyKind, g as getFormatAnnotation, h as formatToType, l as FormatEnums, m as TypeFormat, n as CurrencyAnnotationId, p as TypeEnum, r as DecimalPrecision, s as FormatAnnotation, t as Currency, u as OptionsAnnotation, v as getTypeEnum, y as typeToFormat } from "./chunk-number.mjs";
|
|
2
|
-
import { _ as
|
|
2
|
+
import { S as toSimpleTime, _ as SimpleDateTime, a as Hostname, b as toSimpleDate, c as Text, d as GeoLocation, f as GeoPoint, g as SimpleDate, h as Duration, i as Formula, l as URL, m as DateTime, n as Format, o as Markdown, p as DateOnly, r as Email, s as Regex, t as SelectOption, u as UUID, v as SimpleTime, x as toSimpleDateTime, y as TimeOnly } from "./chunk-select.mjs";
|
|
3
3
|
import "./chunk-Format.mjs";
|
|
4
|
-
export { Currency, CurrencyAnnotationId, DateOnly, DateTime, DecimalPrecision, Duration, Email, Format, FormatAnnotation, FormatAnnotationId, FormatEnums, Formula, GeoLocation, GeoPoint, Hostname, OptionsAnnotation, OptionsAnnotationId, PropertyKind, Regex, SelectOption, SimpleDate, SimpleDateTime, SimpleTime, Text, TimeOnly, TypeEnum, TypeFormat, URL, UUID, formatToType, getFormatAnnotation, getOptionsAnnotation, getTypeEnum, toSimpleDate, toSimpleDateTime, toSimpleTime, typeToFormat };
|
|
4
|
+
export { Currency, CurrencyAnnotationId, DateOnly, DateTime, DecimalPrecision, Duration, Email, Format, FormatAnnotation, FormatAnnotationId, FormatEnums, Formula, GeoLocation, GeoPoint, Hostname, Markdown, OptionsAnnotation, OptionsAnnotationId, PropertyKind, Regex, SelectOption, SimpleDate, SimpleDateTime, SimpleTime, Text, TimeOnly, TypeEnum, TypeFormat, URL, UUID, formatToType, getFormatAnnotation, getOptionsAnnotation, getTypeEnum, toSimpleDate, toSimpleDateTime, toSimpleTime, typeToFormat };
|
package/dist/lib/Migration.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as TypeId, r as
|
|
1
|
+
export { n as TypeId, r as applyContentSteps, i as define, a as defineContent, o as defineRename, s as defineTransaction, c as getContentSteps, l as isContentMigration, u as isMigration, d as isObjectMigration, f as isRenameMigration, p as isTransactionMigration, m as upgradeContent } from "./chunk-Migration.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
-
import { b as
|
|
3
|
-
import {
|
|
2
|
+
import { S as setDictionary$1, b as Key$1, i as isEntity, n as set$1, r as update$1, t as get$1, x as getDictionary$1, y as Dictionary$1 } from "./chunk-entity-dictionary.mjs";
|
|
3
|
+
import { Ct as UserTypeAnnotation, Dt as getDescriptionWithSchema, Gt as setDescriptionWithSchema, H as DEFAULT_LAYOUT_NAME, J as FormCreateAnnotation, K as FieldLookupAnnotationId, Nt as getLabelWithSchema, Q as FormInputAnnotation, Rt as getTypeAnnotation, U as DescriptionAnnotation, Ut as makeUserAnnotation, V as ContentVersionAnnotation, X as FormInlineAnnotation, Y as FormCreateAnnotationId, _t as SetParentAnnotation, at as GeneratorAnnotationId, ct as LabelAnnotation, et as FormLayoutAnnotation, ft as RawStringAnnotation, ht as ReferenceAnnotationId, it as GeneratorAnnotation, kt as getFromAst$1, mt as ReferenceAnnotation, nt as FormOrderedAnnotation, ot as IconAnnotation, qt as setLabelWithSchema, st as IconFromRefAnnotation, tt as FormLayoutAnnotationId, vt as TypeAnnotation, z as ArrayPresentationAnnotation, zt as getTypeIdentifierAnnotation } from "./chunk-Database.mjs";
|
|
4
4
|
import { y as subscribe } from "./chunk-ref.mjs";
|
|
5
|
-
import { n as
|
|
5
|
+
import { n as snapshotDeepEquals, t as snapshotDeep } from "./chunk-atom-snapshot.mjs";
|
|
6
6
|
import * as Function from "effect/Function";
|
|
7
7
|
import * as Option from "effect/Option";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
@@ -12,10 +12,11 @@ import * as Atom from "effect/reactivity/Atom";
|
|
|
12
12
|
/**
|
|
13
13
|
* Atom family for an annotation value on an entity instance.
|
|
14
14
|
* Mirrors the object-property atom family: re-emits a fresh reference whenever the entity changes
|
|
15
|
-
* (so an in-place array mutation is observed) and dedupes
|
|
15
|
+
* (so an in-place array mutation is observed) and dedupes unchanged content. The snapshot is deep, so a
|
|
16
|
+
* record nested in the value is a new reference too once it changes in place.
|
|
16
17
|
*/
|
|
17
18
|
var annotationFamily = Atom.family(([target, annotation]) => {
|
|
18
|
-
const read = () => Option.map(get$1(target, annotation),
|
|
19
|
+
const read = () => Option.map(get$1(target, annotation), snapshotDeep);
|
|
19
20
|
return Atom.make((get) => {
|
|
20
21
|
let previous = read();
|
|
21
22
|
const unsubscribe = subscribe(target, () => {
|
|
@@ -34,12 +35,12 @@ var annotationFamily = Atom.family(([target, annotation]) => {
|
|
|
34
35
|
* Keyed by a structurally-equal tuple key `[target, annotation, key])` so nested families are avoided.
|
|
35
36
|
*/
|
|
36
37
|
var annotationPropertyFamily = Atom.family(([target, annotation, key]) => {
|
|
37
|
-
const read = () => get$1(target, annotation).pipe(Option.map((value) =>
|
|
38
|
+
const read = () => get$1(target, annotation).pipe(Option.map((value) => snapshotDeep(value[key])), Option.getOrUndefined);
|
|
38
39
|
return Atom.make((get) => {
|
|
39
40
|
let previous = read();
|
|
40
41
|
const unsubscribe = subscribe(target, () => {
|
|
41
42
|
const next = read();
|
|
42
|
-
if (!
|
|
43
|
+
if (!snapshotDeepEquals(next, previous)) {
|
|
43
44
|
previous = next;
|
|
44
45
|
get.setSelf(next);
|
|
45
46
|
}
|
|
@@ -48,11 +49,11 @@ var annotationPropertyFamily = Atom.family(([target, annotation, key]) => {
|
|
|
48
49
|
return previous;
|
|
49
50
|
});
|
|
50
51
|
});
|
|
51
|
-
/** Equal when both empty, or both present with
|
|
52
|
-
var sameOption = (a, b) => Option.isNone(a) || Option.isNone(b) ? Option.isNone(a) && Option.isNone(b) :
|
|
52
|
+
/** Equal when both empty, or both present with equal content at every depth. */
|
|
53
|
+
var sameOption = (a, b) => Option.isNone(a) || Option.isNone(b) ? Option.isNone(a) && Option.isNone(b) : snapshotDeepEquals(a.value, b.value);
|
|
53
54
|
/**
|
|
54
|
-
* Reactive atom for an annotation value on an entity instance. Emits a
|
|
55
|
-
*
|
|
55
|
+
* Reactive atom for an annotation value on an entity instance. Emits a deep snapshot (fresh references
|
|
56
|
+
* for objects and arrays at every depth) so dependent atoms recompute on change. Mirrors {@link makeProperty}.
|
|
56
57
|
*/
|
|
57
58
|
var makeAtom = (target, annotation) => {
|
|
58
59
|
assertArgument(isEntity(target), "target", "Must be a reactive ECHO entity");
|
|
@@ -73,6 +74,7 @@ var makeProperty = (target, annotation, key) => {
|
|
|
73
74
|
//#region src/Annotation.ts
|
|
74
75
|
var Annotation_exports = /* @__PURE__ */ __exportAll({
|
|
75
76
|
ArrayPresentationAnnotation: () => ArrayPresentationAnnotation,
|
|
77
|
+
ContentVersionAnnotation: () => ContentVersionAnnotation,
|
|
76
78
|
DEFAULT_LAYOUT_NAME: () => DEFAULT_LAYOUT_NAME,
|
|
77
79
|
DescriptionAnnotation: () => DescriptionAnnotation,
|
|
78
80
|
Dictionary: () => Dictionary,
|
|
@@ -90,6 +92,7 @@ var Annotation_exports = /* @__PURE__ */ __exportAll({
|
|
|
90
92
|
IconFromRefAnnotation: () => IconFromRefAnnotation,
|
|
91
93
|
Key: () => Key,
|
|
92
94
|
LabelAnnotation: () => LabelAnnotation,
|
|
95
|
+
RawStringAnnotation: () => RawStringAnnotation,
|
|
93
96
|
ReferenceAnnotation: () => ReferenceAnnotation,
|
|
94
97
|
ReferenceAnnotationId: () => ReferenceAnnotationId,
|
|
95
98
|
SetParent: () => SetParentAnnotation,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-Annotation.mjs","names":["getAnnotation","internalAnnotations.Key","internalAnnotations.makeUserAnnotation","internalAnnotations.get","internalAnnotations.set","internalAnnotations.update","internalAnnotations.getFromAst","annotationAtoms.makeAtom","annotationAtoms.makeProperty","internalAnnotations.Dictionary","internalAnnotations.getDictionary","internalAnnotations.setDictionary"],"sources":["../../src/internal/Annotation/atoms.ts","../../src/Annotation.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Atom from 'effect/reactivity/Atom';\n\nimport { assertArgument } from '@dxos/invariant';\n\nimport type * as Annotation from '../../Annotation.ts';\nimport type * as Entity from '../../Entity.ts';\nimport { snapshotEquals, snapshotForComparison } from '../common/atom-snapshot.ts';\nimport { subscribe } from '../common/proxy/reactive.ts';\nimport { isEntity } from '../Entity/index.ts';\nimport { get as getAnnotation } from './entity-dictionary.ts';\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(\n ([target, annotation]: readonly [Entity.Unknown, Annotation.Annotation<any>]): Atom.Atom<Option.Option<any>> => {\n const read = (): Option.Option<any> => Option.map(getAnnotation(target, annotation), snapshotForComparison);\n\n return Atom.make<Option.Option<any>>((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 });\n },\n);\n\n/**\n * Atom family for a single key of a record-valued annotation on an entity instance.\n * Keyed by a structurally-equal tuple key `[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 // Content comparison — `read()` snapshots, so identity never matches for arrays/objects.\n if (!snapshotEquals(next, previous)) {\n previous = next;\n get.setSelf(next);\n }\n });\n get.addFinalizer(() => unsubscribe());\n\n return previous;\n });\n },\n);\n\n/** Equal when both empty, or both present with shallow-equal content (see `snapshotEquals`). */\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) : snapshotEquals(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([target, annotation as Annotation.Annotation<Record<string, any>>, key]) as Atom.Atom<\n V | undefined\n >;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nexport {\n type ArrayPresentation,\n ArrayPresentationAnnotation,\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 IconAnnotation,\n IconFromRefAnnotation,\n LabelAnnotation,\n ReferenceAnnotation,\n ReferenceAnnotationId,\n type ReferenceAnnotationValue,\n SetParentAnnotation as SetParent,\n type SetParentAnnotationValue as SetParentValue,\n TypeAnnotation,\n UserTypeAnnotation as UserType,\n type UserTypeAnnotationValue as UserTypeValue,\n getDescriptionWithSchema,\n getLabelWithSchema,\n getTypeAnnotation,\n getTypeIdentifierAnnotation,\n setDescriptionWithSchema,\n setLabelWithSchema,\n} from './internal/Annotation/index.ts';\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as Types from 'effect/Types';\n\nimport * as SchemaAST from '@dxos/effect/SchemaAST';\n\nimport * as Entity from './Entity.ts';\nimport * as annotationAtoms from './internal/Annotation/atoms.ts';\nimport * as internalAnnotations from './internal/Annotation/index.ts';\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.Codec<T, unknown, never>;\n\n /**\n * Get the annotation value from an Effect schema.\n *\n * Only accepts `Schema.Top` — 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 * @performance O(1) annotation lookup, but decodes the value against `schema` on every call (not cached).\n */\n get: (schema: Schema.Top) => Option.Option<T>;\n /**\n * Get the annotation value from the AST.\n *\n * @performance O(1) annotation lookup, but decodes the value against `schema` on every call (not cached).\n */\n getFromAst: (ast: SchemaAST.AST) => Option.Option<T>;\n /**\n * Set the annotation on an Effect schema.\n *\n * Only accepts `Schema.Top` — 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 * @performance O(value size) encode, once at schema-definition time.\n */\n set: (value: T) => <S extends Schema.Top>(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.Codec<T, any, never>;\n /** Skips the FQN id-format check, for a pre-existing id that may already be embedded in persisted schemas. */\n legacyId?: boolean;\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.annotate(ColorAnnotation.set('red'));\n * ```\n *\n * @performance O(1) at definition time; validates the id format.\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 *\n * @performance O(1) meta-dictionary read; returns the stored value without decoding or copying.\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 *\n * @performance O(value size) schema validation, then an O(1) meta-dictionary write.\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 *\n * @performance O(value size) schema validation after the mutator, inside one change.\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\n/**\n * Get the value of an annotation from a schema AST.\n *\n * @performance O(1) annotation lookup, but decodes the value on every call (not cached).\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 *\n * @performance O(1) memoized atom-family lookup; re-reads the annotation on every entity change.\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 *\n * @performance O(1) memoized atom-family lookup; re-reads the key on every entity change.\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 *\n * @performance O(value size); decodes the stored value on every call.\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 *\n * @performance O(value size); encodes the value on every call.\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 *\n * @performance O(1) setup plus the cost of the builder callback.\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"],"mappings":";;;;;;;;;;;;;;;;AAqBA,IAAM,mBAAmB,KAAK,QAC3B,CAAC,QAAQ,gBAAsG;CAC9G,MAAM,aAAiC,OAAO,IAAIA,MAAc,QAAQ,UAAU,GAAG,qBAAqB;CAE1G,OAAO,KAAK,MAA0B,QAAQ;EAC5C,IAAI,WAAW,KAAK;EAEpB,MAAM,cAAc,UAAU,cAAc;GAC1C,MAAM,OAAO,KAAK;GAClB,IAAI,CAAC,WAAW,UAAU,IAAI,GAAG;IAC/B,WAAW;IACX,IAAI,QAAQ,IAAI;GAClB;EACF,CAAC;EACD,IAAI,mBAAmB,YAAY,CAAC;EAEpC,OAAO;CACT,CAAC;AACH,CACF;;;;;AAMA,IAAM,2BAA2B,KAAK,QACnC,CAAC,QAAQ,YAAY,SAIA;CACpB,MAAM,aACJA,MAAc,QAAQ,UAAU,CAAC,CAAC,KAChC,OAAO,KAAK,UAAU,sBAAsB,MAAM,IAAI,CAAC,GACvD,OAAO,cACT;CAEF,OAAO,KAAK,MAAe,QAAQ;EACjC,IAAI,WAAW,KAAK;EAEpB,MAAM,cAAc,UAAU,cAAc;GAC1C,MAAM,OAAO,KAAK;GAElB,IAAI,CAAC,eAAe,MAAM,QAAQ,GAAG;IACnC,WAAW;IACX,IAAI,QAAQ,IAAI;GAClB;EACF,CAAC;EACD,IAAI,mBAAmB,YAAY,CAAC;EAEpC,OAAO;CACT,CAAC;AACH,CACF;;AAGA,IAAM,cAAiB,GAAqB,MAC1C,OAAO,OAAO,CAAC,KAAK,OAAO,OAAO,CAAC,IAAI,OAAO,OAAO,CAAC,KAAK,OAAO,OAAO,CAAC,IAAI,eAAe,EAAE,OAAO,EAAE,KAAK;;;;;AAM/G,IAAa,YACX,QACA,eACgC;CAChC,eAAe,SAAS,MAAM,GAAG,UAAU,gCAAgC;CAC3E,OAAO,iBAAiB,CAAC,QAAQ,UAAU,CAAC;AAC9C;;;;AAKA,IAAa,gBACX,QACA,YACA,QAC6B;CAC7B,eAAe,SAAS,MAAM,GAAG,UAAU,gCAAgC;CAG3E,OAAO,yBAAyB;EAAC;EAAQ;EAA0D;CAAG,CAAC;AAGzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrDA,IAAa,SAAS;AAwDtB,IAAa,MAAMC;;;;;;;;;;;;;;;;;;AA2BnB,IAAa,OAAkDC;;;;;;;;;;;;;AAc/D,IAAa,MAGT,SAAS,KAGX,IAAI,QAAQ,eAAe;CAC3B,OAAOC,MAAwB,QAAQ,UAAU;AACnD,CAAC;;;;;;;;AASD,IAAa,MAGT,SAAS,KAGX,IAAI,QAAQ,YAAY,UAAU;CAClC,OAAOC,MAAwB,QAAQ,YAAY,KAAK;AAC1D,CAAC;;;;;;;;;AAUD,IAAa,UACX,QACA,YACA,YACSC,SAA2B,QAAQ,YAAY,OAAO;;;;;;AAOjE,IAAa,aAGT,SAAS,KAGX,IAAI,KAAK,eAAe;CACxB,OAAOC,aAA+B,KAAK,UAAU;AACvD,CAAC;;;;;;;AAQD,IAAa,OAAOC;;;;;;;AAQpB,IAAa,eAAeC;;;;;;;;;;;;;AAc5B,IAAa,aAAaC;;;;;;AAQ1B,IAAa,gBAGT,SAAS,KAGX,IAAI,QAAQ,eAAe;CAC3B,OAAOC,gBAAkC,QAAQ,UAAU;AAC7D,CAAC;;;;;;;;;;;;;;AAeD,IAAa,gBAGT,SAAS,KAGX,IAAI,QAAQ,YAAY,UAAU;CAClC,OAAOC,gBAAkC,QAAQ,YAAY,KAAK;AACpE,CAAC;;;;;;;;;;;;;;AAeD,IAAa,mBAAmB,UAAuE;CACrG,MAAM,aAAa,OAAO,WAAW,UAAU,CAAC,CAAC,CAAC,CAAC;CACnD,MAAM,UAAU;CAChB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"chunk-Annotation.mjs","names":["getAnnotation","internalAnnotations.Key","internalAnnotations.makeUserAnnotation","internalAnnotations.get","internalAnnotations.set","internalAnnotations.update","internalAnnotations.getFromAst","annotationAtoms.makeAtom","annotationAtoms.makeProperty","internalAnnotations.Dictionary","internalAnnotations.getDictionary","internalAnnotations.setDictionary"],"sources":["../../src/internal/Annotation/atoms.ts","../../src/Annotation.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Atom from 'effect/reactivity/Atom';\n\nimport { assertArgument } from '@dxos/invariant';\n\nimport type * as Annotation from '../../Annotation.ts';\nimport type * as Entity from '../../Entity.ts';\nimport { snapshotDeep, snapshotDeepEquals } from '../common/atom-snapshot.ts';\nimport { subscribe } from '../common/proxy/reactive.ts';\nimport { isEntity } from '../Entity/index.ts';\nimport { get as getAnnotation } from './entity-dictionary.ts';\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 unchanged content. The snapshot is deep, so a\n * record nested in the value is a new reference too once it changes in place.\n */\nconst annotationFamily = Atom.family(\n ([target, annotation]: readonly [Entity.Unknown, Annotation.Annotation<any>]): Atom.Atom<Option.Option<any>> => {\n const read = (): Option.Option<any> => Option.map(getAnnotation(target, annotation), snapshotDeep);\n\n return Atom.make<Option.Option<any>>((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 });\n },\n);\n\n/**\n * Atom family for a single key of a record-valued annotation on an entity instance.\n * Keyed by a structurally-equal tuple key `[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) => snapshotDeep(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 // Content comparison — `read()` snapshots, so identity never matches for arrays/objects.\n if (!snapshotDeepEquals(next, previous)) {\n previous = next;\n get.setSelf(next);\n }\n });\n get.addFinalizer(() => unsubscribe());\n\n return previous;\n });\n },\n);\n\n/** Equal when both empty, or both present with equal content at every depth. */\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) : snapshotDeepEquals(a.value, b.value);\n\n/**\n * Reactive atom for an annotation value on an entity instance. Emits a deep snapshot (fresh references\n * for objects and arrays at every depth) 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([target, annotation as Annotation.Annotation<Record<string, any>>, key]) as Atom.Atom<\n V | undefined\n >;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nexport {\n type ArrayPresentation,\n ArrayPresentationAnnotation,\n ContentVersionAnnotation,\n type ContentVersionAnnotationValue,\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 IconAnnotation,\n IconFromRefAnnotation,\n LabelAnnotation,\n RawStringAnnotation,\n ReferenceAnnotation,\n ReferenceAnnotationId,\n type ReferenceAnnotationValue,\n SetParentAnnotation as SetParent,\n type SetParentAnnotationValue as SetParentValue,\n TypeAnnotation,\n UserTypeAnnotation as UserType,\n type UserTypeAnnotationValue as UserTypeValue,\n getDescriptionWithSchema,\n getLabelWithSchema,\n getTypeAnnotation,\n getTypeIdentifierAnnotation,\n setDescriptionWithSchema,\n setLabelWithSchema,\n} from './internal/Annotation/index.ts';\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as Types from 'effect/Types';\n\nimport * as SchemaAST from '@dxos/effect/SchemaAST';\n\nimport * as Entity from './Entity.ts';\nimport * as annotationAtoms from './internal/Annotation/atoms.ts';\nimport * as internalAnnotations from './internal/Annotation/index.ts';\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.Codec<T, unknown, never>;\n\n /**\n * Get the annotation value from an Effect schema.\n *\n * Only accepts `Schema.Top` — 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 * @performance O(1) annotation lookup, but decodes the value against `schema` on every call (not cached).\n */\n get: (schema: Schema.Top) => Option.Option<T>;\n /**\n * Get the annotation value from the AST.\n *\n * @performance O(1) annotation lookup, but decodes the value against `schema` on every call (not cached).\n */\n getFromAst: (ast: SchemaAST.AST) => Option.Option<T>;\n /**\n * Set the annotation on an Effect schema.\n *\n * Only accepts `Schema.Top` — 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 * @performance O(value size) encode, once at schema-definition time.\n */\n set: (value: T) => <S extends Schema.Top>(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.Codec<T, any, never>;\n /** Skips the FQN id-format check, for a pre-existing id that may already be embedded in persisted schemas. */\n legacyId?: boolean;\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.annotate(ColorAnnotation.set('red'));\n * ```\n *\n * @performance O(1) at definition time; validates the id format.\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 *\n * @performance O(1) meta-dictionary read; returns the stored value without decoding or copying.\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 *\n * @performance O(value size) schema validation, then an O(1) meta-dictionary write.\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 *\n * @performance O(value size) schema validation after the mutator, inside one change.\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\n/**\n * Get the value of an annotation from a schema AST.\n *\n * @performance O(1) annotation lookup, but decodes the value on every call (not cached).\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 *\n * @performance O(1) memoized atom-family lookup; re-reads the annotation on every entity change.\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 *\n * @performance O(1) memoized atom-family lookup; re-reads the key on every entity change.\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 *\n * @performance O(value size); decodes the stored value on every call.\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 *\n * @performance O(value size); encodes the value on every call.\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 *\n * @performance O(1) setup plus the cost of the builder callback.\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"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAM,mBAAmB,KAAK,QAC3B,CAAC,QAAQ,gBAAsG;CAC9G,MAAM,aAAiC,OAAO,IAAIA,MAAc,QAAQ,UAAU,GAAG,YAAY;CAEjG,OAAO,KAAK,MAA0B,QAAQ;EAC5C,IAAI,WAAW,KAAK;EAEpB,MAAM,cAAc,UAAU,cAAc;GAC1C,MAAM,OAAO,KAAK;GAClB,IAAI,CAAC,WAAW,UAAU,IAAI,GAAG;IAC/B,WAAW;IACX,IAAI,QAAQ,IAAI;GAClB;EACF,CAAC;EACD,IAAI,mBAAmB,YAAY,CAAC;EAEpC,OAAO;CACT,CAAC;AACH,CACF;;;;;AAMA,IAAM,2BAA2B,KAAK,QACnC,CAAC,QAAQ,YAAY,SAIA;CACpB,MAAM,aACJA,MAAc,QAAQ,UAAU,CAAC,CAAC,KAChC,OAAO,KAAK,UAAU,aAAa,MAAM,IAAI,CAAC,GAC9C,OAAO,cACT;CAEF,OAAO,KAAK,MAAe,QAAQ;EACjC,IAAI,WAAW,KAAK;EAEpB,MAAM,cAAc,UAAU,cAAc;GAC1C,MAAM,OAAO,KAAK;GAElB,IAAI,CAAC,mBAAmB,MAAM,QAAQ,GAAG;IACvC,WAAW;IACX,IAAI,QAAQ,IAAI;GAClB;EACF,CAAC;EACD,IAAI,mBAAmB,YAAY,CAAC;EAEpC,OAAO;CACT,CAAC;AACH,CACF;;AAGA,IAAM,cAAiB,GAAqB,MAC1C,OAAO,OAAO,CAAC,KAAK,OAAO,OAAO,CAAC,IAAI,OAAO,OAAO,CAAC,KAAK,OAAO,OAAO,CAAC,IAAI,mBAAmB,EAAE,OAAO,EAAE,KAAK;;;;;AAMnH,IAAa,YACX,QACA,eACgC;CAChC,eAAe,SAAS,MAAM,GAAG,UAAU,gCAAgC;CAC3E,OAAO,iBAAiB,CAAC,QAAQ,UAAU,CAAC;AAC9C;;;;AAKA,IAAa,gBACX,QACA,YACA,QAC6B;CAC7B,eAAe,SAAS,MAAM,GAAG,UAAU,gCAAgC;CAG3E,OAAO,yBAAyB;EAAC;EAAQ;EAA0D;CAAG,CAAC;AAGzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACnDA,IAAa,SAAS;AAwDtB,IAAa,MAAMC;;;;;;;;;;;;;;;;;;AA2BnB,IAAa,OAAkDC;;;;;;;;;;;;;AAc/D,IAAa,MAGT,SAAS,KAGX,IAAI,QAAQ,eAAe;CAC3B,OAAOC,MAAwB,QAAQ,UAAU;AACnD,CAAC;;;;;;;;AASD,IAAa,MAGT,SAAS,KAGX,IAAI,QAAQ,YAAY,UAAU;CAClC,OAAOC,MAAwB,QAAQ,YAAY,KAAK;AAC1D,CAAC;;;;;;;;;AAUD,IAAa,UACX,QACA,YACA,YACSC,SAA2B,QAAQ,YAAY,OAAO;;;;;;AAOjE,IAAa,aAGT,SAAS,KAGX,IAAI,KAAK,eAAe;CACxB,OAAOC,aAA+B,KAAK,UAAU;AACvD,CAAC;;;;;;;AAQD,IAAa,OAAOC;;;;;;;AAQpB,IAAa,eAAeC;;;;;;;;;;;;;AAc5B,IAAa,aAAaC;;;;;;AAQ1B,IAAa,gBAGT,SAAS,KAGX,IAAI,QAAQ,eAAe;CAC3B,OAAOC,gBAAkC,QAAQ,UAAU;AAC7D,CAAC;;;;;;;;;;;;;;AAeD,IAAa,gBAGT,SAAS,KAGX,IAAI,QAAQ,YAAY,UAAU;CAClC,OAAOC,gBAAkC,QAAQ,YAAY,KAAK;AACpE,CAAC;;;;;;;;;;;;;;AAeD,IAAa,mBAAmB,UAAuE;CACrG,MAAM,aAAa,OAAO,WAAW,UAAU,CAAC,CAAC,CAAC,CAAC;CACnD,MAAM,UAAU;CAChB,OAAO;AACT"}
|
package/dist/lib/chunk-Blob.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
-
import { i as Service,
|
|
2
|
+
import { i as Service, ot as IconAnnotation } from "./chunk-Database.mjs";
|
|
3
3
|
import { n as BlobTooLargeError, r as BlobWriteError, t as BlobNotAvailableError } from "./chunk-Error.mjs";
|
|
4
4
|
import { y as makeObject } from "./chunk-Type.mjs";
|
|
5
5
|
import { G as make$1 } from "./chunk-Obj.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Ct as UserTypeAnnotation, Q as FormInputAnnotation, _t as SetParentAnnotation, ot as IconAnnotation } from "./chunk-Database.mjs";
|
|
3
3
|
import { y as makeObject } from "./chunk-Type.mjs";
|
|
4
4
|
import { n as Ref } from "./chunk-Ref2.mjs";
|
|
5
5
|
import { G as make$1, R as instanceOf, a as Unknown } from "./chunk-Obj.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
2
|
import { g as getStaticTypeSchema, o as EntityKind, t as createAnnotationHelper } from "./chunk-util.mjs";
|
|
3
|
-
import { i as EntityNotFoundError } from "./chunk-Error.mjs";
|
|
3
|
+
import { i as EntityNotFoundError, s as MigrationError } from "./chunk-Error.mjs";
|
|
4
4
|
import { DXN, EID, EntityId, URI } from "@dxos/keys";
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
@@ -53,6 +53,12 @@ var ObjectVersionId = Symbol.for("@dxos/echo/Version");
|
|
|
53
53
|
*/
|
|
54
54
|
var ObjectDatabaseId = Symbol.for("@dxos/echo/Database");
|
|
55
55
|
/**
|
|
56
|
+
* Hidden, non-reactive feed block keys of a live feed object this client wrote: what a read of its
|
|
57
|
+
* latest block would stamp in `@meta.keys`, set when the store confirms the write. Read via the `Feed`
|
|
58
|
+
* block getters, which prefer it to `@meta.keys`.
|
|
59
|
+
*/
|
|
60
|
+
var FeedBlockKeysId = Symbol.for("@dxos/echo/FeedBlockKeys");
|
|
61
|
+
/**
|
|
56
62
|
* Branch accessor symbol. Resolves to the branch name this object instance is bound to (`'main'` for
|
|
57
63
|
* the canonical object, or the branch of a `db.branch()` independent instance). Read via `Obj.getBranch`.
|
|
58
64
|
*/
|
|
@@ -500,6 +506,29 @@ var FieldLookupAnnotationId = "@dxos/schema/annotation/FieldLookup";
|
|
|
500
506
|
*/
|
|
501
507
|
var GeneratorAnnotationId = "@dxos/schema/annotation/Generator";
|
|
502
508
|
var GeneratorAnnotation = createAnnotationHelper(GeneratorAnnotationId);
|
|
509
|
+
var RawStringAnnotationId = "org.dxos.annotation.rawString";
|
|
510
|
+
/**
|
|
511
|
+
* Stores every string under the annotated field as an immutable Automerge string: one op per write
|
|
512
|
+
* instead of one per character, at the cost of collaborative (character-level) merging. For
|
|
513
|
+
* machine-written state that is replaced wholesale, never edited as text.
|
|
514
|
+
*/
|
|
515
|
+
var RawStringAnnotation = createAnnotationHelper(RawStringAnnotationId);
|
|
516
|
+
/** True when `ast` (or, for an optional field, one of its union members) carries {@link RawStringAnnotation}. */
|
|
517
|
+
var hasRawStringAnnotation = (ast) => RawStringAnnotation.getFromAst(ast).pipe(Option.getOrElse(() => false)) || SchemaAST.isUnion(ast) && ast.types.some(hasRawStringAnnotation);
|
|
518
|
+
var containsRawStringCache = /* @__PURE__ */ new WeakMap();
|
|
519
|
+
/**
|
|
520
|
+
* True when {@link RawStringAnnotation} appears anywhere within `ast`; cached, so a write to a type that
|
|
521
|
+
* never uses it skips the per-value schema walk.
|
|
522
|
+
*/
|
|
523
|
+
var containsRawStringAnnotation = (ast) => {
|
|
524
|
+
const cached = containsRawStringCache.get(ast);
|
|
525
|
+
if (cached !== void 0) return cached;
|
|
526
|
+
containsRawStringCache.set(ast, false);
|
|
527
|
+
const children = SchemaAST.isObjects(ast) ? [...ast.propertySignatures.map((property) => property.type), ...ast.indexSignatures.map((index) => index.type)] : SchemaAST.isArrays(ast) ? [...ast.elements, ...ast.rest] : SchemaAST.isUnion(ast) ? ast.types : SchemaAST.isSuspend(ast) ? [ast.thunk()] : [];
|
|
528
|
+
const result = hasRawStringAnnotation(ast) || children.some(containsRawStringAnnotation);
|
|
529
|
+
containsRawStringCache.set(ast, result);
|
|
530
|
+
return result;
|
|
531
|
+
};
|
|
503
532
|
var makeUserAnnotation = (props) => {
|
|
504
533
|
if (!props.legacyId) assertArgument(/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?){2,}(\.[a-zA-Z]([a-zA-Z0-9]{0,62})?)?$/.test(props.id), "id", "Annotation id must be in the FQN format (org.dxos.annotation.example or org.dxos.space.rootCollection). Pass `legacyId: true` to keep an existing non-FQN id.");
|
|
505
534
|
const annotation = {
|
|
@@ -604,6 +633,23 @@ var SetParentAnnotation = {
|
|
|
604
633
|
override
|
|
605
634
|
})
|
|
606
635
|
};
|
|
636
|
+
/**
|
|
637
|
+
* Marks a string field of an object schema as the content version of named sibling fields: the
|
|
638
|
+
* format and revision (e.g. `dxos.org/scene/1`) of data ECHO stores opaquely. Content migrations
|
|
639
|
+
* (`Migration.defineContent`) find the version through it.
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```ts
|
|
643
|
+
* Schema.Struct({
|
|
644
|
+
* schema: Schema.String.pipe(Annotation.ContentVersionAnnotation.set({ fields: ['content'] }), Schema.optional),
|
|
645
|
+
* content: Schema.Record(Schema.String, Schema.Any),
|
|
646
|
+
* })
|
|
647
|
+
* ```
|
|
648
|
+
*/
|
|
649
|
+
var ContentVersionAnnotation = makeUserAnnotation({
|
|
650
|
+
id: "org.dxos.annotation.contentVersion",
|
|
651
|
+
schema: Schema.Struct({ fields: Schema.Array(Schema.String) })
|
|
652
|
+
});
|
|
607
653
|
var userTypeAnnotation = makeUserAnnotation({
|
|
608
654
|
id: "org.dxos.annotation.userType",
|
|
609
655
|
schema: Schema.Struct({ tags: Schema.optional(Schema.Array(Schema.String)) })
|
|
@@ -691,6 +737,18 @@ var getFromAst = (ast, annotation) => {
|
|
|
691
737
|
return Option.fromNullishOr(meta?.[annotation.key]).pipe(Option.map(Schema.decodeUnknownSync(annotation.schema)));
|
|
692
738
|
};
|
|
693
739
|
//#endregion
|
|
740
|
+
//#region src/internal/common/proxy/define-hidden-property.ts
|
|
741
|
+
/**
|
|
742
|
+
* Define a non-enumerable property on an object.
|
|
743
|
+
*/
|
|
744
|
+
var defineHiddenProperty = (object, key, value) => {
|
|
745
|
+
Object.defineProperty(object, key, {
|
|
746
|
+
enumerable: false,
|
|
747
|
+
configurable: true,
|
|
748
|
+
value
|
|
749
|
+
});
|
|
750
|
+
};
|
|
751
|
+
//#endregion
|
|
694
752
|
//#region src/internal/Entity/util.ts
|
|
695
753
|
var __dxlog_file$2 = "/__w/dxos/dxos/packages/core/echo/echo/src/internal/Entity/util.ts";
|
|
696
754
|
/**
|
|
@@ -737,7 +795,7 @@ var getUri = (entity, options) => {
|
|
|
737
795
|
invariant(uri != null, "Invalid entity.", {
|
|
738
796
|
"~LogMeta": "~LogMeta",
|
|
739
797
|
F: __dxlog_file$1,
|
|
740
|
-
L:
|
|
798
|
+
L: 44,
|
|
741
799
|
S: void 0,
|
|
742
800
|
A: ["uri != null", "'Invalid entity.'"]
|
|
743
801
|
});
|
|
@@ -748,7 +806,7 @@ var getUri = (entity, options) => {
|
|
|
748
806
|
invariant(eid != null, "Invalid entity.", {
|
|
749
807
|
"~LogMeta": "~LogMeta",
|
|
750
808
|
F: __dxlog_file$1,
|
|
751
|
-
L:
|
|
809
|
+
L: 50,
|
|
752
810
|
S: void 0,
|
|
753
811
|
A: ["eid != null", "'Invalid entity.'"]
|
|
754
812
|
});
|
|
@@ -760,7 +818,7 @@ var getUri = (entity, options) => {
|
|
|
760
818
|
invariant(eid != null, "Invalid entity.", {
|
|
761
819
|
"~LogMeta": "~LogMeta",
|
|
762
820
|
F: __dxlog_file$1,
|
|
763
|
-
L:
|
|
821
|
+
L: 57,
|
|
764
822
|
S: void 0,
|
|
765
823
|
A: ["eid != null", "'Invalid entity.'"]
|
|
766
824
|
});
|
|
@@ -777,13 +835,28 @@ var getUri = (entity, options) => {
|
|
|
777
835
|
invariant(uri != null, "Invalid entity.", {
|
|
778
836
|
"~LogMeta": "~LogMeta",
|
|
779
837
|
F: __dxlog_file$1,
|
|
780
|
-
L:
|
|
838
|
+
L: 68,
|
|
781
839
|
S: void 0,
|
|
782
840
|
A: ["uri != null", "'Invalid entity.'"]
|
|
783
841
|
});
|
|
784
842
|
return uri;
|
|
785
843
|
};
|
|
786
844
|
/**
|
|
845
|
+
* The hidden feed block keys a client stamped on a live feed object it wrote; `undefined` when the
|
|
846
|
+
* object's `@meta.keys` describe its latest block.
|
|
847
|
+
*/
|
|
848
|
+
var getFeedBlockKeys = (entity) => {
|
|
849
|
+
assumeType(entity);
|
|
850
|
+
return entity[FeedBlockKeysId];
|
|
851
|
+
};
|
|
852
|
+
/**
|
|
853
|
+
* Sets, or with `undefined` clears, the hidden feed block keys of a live feed object. Not reactive:
|
|
854
|
+
* the keys describe the block the store wrote, not a change of the object.
|
|
855
|
+
*/
|
|
856
|
+
var setFeedBlockKeys = (entity, keys) => {
|
|
857
|
+
defineHiddenProperty(entity, FeedBlockKeysId, keys);
|
|
858
|
+
};
|
|
859
|
+
/**
|
|
787
860
|
* Get the database the entity belongs to.
|
|
788
861
|
* Accepts both reactive entities and snapshots.
|
|
789
862
|
*/
|
|
@@ -870,6 +943,7 @@ var Database_exports = /* @__PURE__ */ __exportAll({
|
|
|
870
943
|
add: () => add,
|
|
871
944
|
addType: () => addType,
|
|
872
945
|
appendToFeed: () => appendToFeed,
|
|
946
|
+
beginMigration: () => beginMigration,
|
|
873
947
|
deleteFromFeed: () => deleteFromFeed,
|
|
874
948
|
flush: () => flush,
|
|
875
949
|
getSyncState: () => getSyncState,
|
|
@@ -982,13 +1056,25 @@ var resolve = ((ref, schema) => Effect.gen(function* () {
|
|
|
982
1056
|
invariant(!schema || isInstanceOf(schema, object), "Object type mismatch.", {
|
|
983
1057
|
"~LogMeta": "~LogMeta",
|
|
984
1058
|
F: __dxlog_file,
|
|
985
|
-
L:
|
|
1059
|
+
L: 628,
|
|
986
1060
|
S: this,
|
|
987
1061
|
A: ["!schema || isInstanceOf(schema as any, object)", "'Object type mismatch.'"]
|
|
988
1062
|
});
|
|
989
1063
|
return object;
|
|
990
1064
|
}).pipe(Effect.withSpan("Database.resolve"), withSpaceId));
|
|
991
1065
|
/**
|
|
1066
|
+
* Starts staging structural changes in the current database; see {@link Migration.Transaction}.
|
|
1067
|
+
*
|
|
1068
|
+
* @performance Async; loads the transaction code on first use, then O(1).
|
|
1069
|
+
*/
|
|
1070
|
+
var beginMigration = (options) => Effect.gen(function* () {
|
|
1071
|
+
const { db } = yield* Service;
|
|
1072
|
+
return yield* Effect.tryPromise({
|
|
1073
|
+
try: () => db.beginMigration(options),
|
|
1074
|
+
catch: (cause) => new MigrationError({ operation: "begin" }, { cause })
|
|
1075
|
+
});
|
|
1076
|
+
}).pipe(Effect.withSpan("Database.beginMigration"), withSpaceId);
|
|
1077
|
+
/**
|
|
992
1078
|
* Loads an object reference. A deleted target reads as absent unless `{ deleted: 'include' }` asks
|
|
993
1079
|
* for it.
|
|
994
1080
|
*
|
|
@@ -1118,6 +1204,6 @@ var subscribeToSyncState = (options) => Stream.callback((queue) => Effect.gen(fu
|
|
|
1118
1204
|
yield* Effect.addFinalizer(() => Effect.sync(cleanup));
|
|
1119
1205
|
}));
|
|
1120
1206
|
//#endregion
|
|
1121
|
-
export {
|
|
1207
|
+
export { FormInputAnnotationId as $, SchemaId as $t, getTypeURIFromSpecifier as A, getIcon as At, ArrayPresentationAnnotationId as B, getTypeURI as Bt, resolve as C, UserTypeAnnotation as Ct, stats as D, getDescriptionWithSchema as Dt, spaceId as E, getDescription as Et, getUri as F, getSchemaTypename as Ft, FIELD_PATH_ANNOTATION as G, setDescriptionWithSchema as Gt, DEFAULT_LAYOUT_NAME as H, hasRawStringAnnotation as Ht, setFeedBlockKeys as I, getSchemaURI as It, FormCreateAnnotation as J, setTypename as Jt, FieldLookupAnnotationId as K, setLabel as Kt, getObjectEchoUri as L, getSchemaVersion as Lt, getBranch as M, getLabelProperty as Mt, getDatabase as N, getLabelWithSchema as Nt, subscribeToSyncState as O, getEntityKind as Ot, getFeedBlockKeys as P, getPropertyMetaAnnotation as Pt, FormInputAnnotation as Q, SchemaAstId as Qt, defineHiddenProperty as R, getTypeAnnotation as Rt, remove as S, TypenameSchema as St, runGarbageCollection as T, containsRawStringAnnotation as Tt, DescriptionAnnotation as U, makeUserAnnotation as Ut, ContentVersionAnnotation as V, getTypename as Vt, DescriptionAnnotationId as W, setDescription as Wt, FormInlineAnnotation as X, ATTR_TYPE as Xt, FormCreateAnnotationId as Y, ATTR_PARENT as Yt, FormInlineAnnotationId as Z, ParentId as Zt, makeRef as _, RelationSourceDXNId as _n, SetParentAnnotation as _t, TraceEvents as a, setType as an, GeneratorAnnotationId as at, peek as b, RelationTargetId as bn, TypeIdentifierAnnotationId as bt, addType as c, ATTR_RELATION_TARGET as cn, LabelAnnotation as ct, deleteFromFeed as d, FeedBlockKeysId as dn, PropertyMetaAnnotationId as dt, TypeEntityId as en, FormLayoutAnnotation as et, flush as f, MetaId as fn, RawStringAnnotation as ft, load as g, ObjectVersionId as gn, SchemaMetaSymbol as gt, layer as h, ObjectDeletedId as hn, ReferenceAnnotationId as ht, Service as i, setSchema as in, GeneratorAnnotation as it, isInstanceOf as j, getLabel as jt, withSpaceId as k, getFromAst as kt, appendToFeed as l, ATTR_SELF_URI as ln, LabelAnnotationId as lt, isDatabase as m, ObjectDatabaseId as mn, ReferenceAnnotation as mt, Database_exports as n, getSchema as nn, FormOrderedAnnotation as nt, TypeId as o, ATTR_DELETED as on, IconAnnotation as ot, getSyncState as p, ObjectBranchId as pn, RawStringAnnotationId as pt, FieldPath as q, setLabelWithSchema as qt, Origin as r, getType as rn, FormOrderedAnnotationId as rt, add as s, ATTR_RELATION_SOURCE as sn, IconFromRefAnnotation as st, Database as t, TypeId$1 as tn, FormLayoutAnnotationId as tt, beginMigration as u, ATTR_SELF_URI_LEGACY as un, PropertyMeta as ut, makeService as v, RelationSourceId as vn, TypeAnnotation as vt, retainObjects as w, VersionSchema as wt, query as x, SelfURIId as xn, TypeMeta as xt, notAvailable as y, RelationTargetDXNId as yn, TypeAnnotationId as yt, ArrayPresentationAnnotation as z, getTypeIdentifierAnnotation as zt };
|
|
1122
1208
|
|
|
1123
1209
|
//# sourceMappingURL=chunk-Database.mjs.map
|