@dxos/echo 0.10.0 → 0.11.1
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 +3 -0
- package/dist/lib/Blob.mjs +160 -0
- package/dist/lib/Blob.mjs.map +1 -0
- package/dist/lib/Database.mjs +2 -0
- package/dist/lib/Entity.mjs +231 -0
- package/dist/lib/Entity.mjs.map +1 -0
- package/dist/lib/Err.mjs +105 -0
- package/dist/lib/Err.mjs.map +1 -0
- package/dist/lib/Feed.mjs +338 -0
- package/dist/lib/Feed.mjs.map +1 -0
- package/dist/lib/Filter.mjs +380 -0
- package/dist/lib/Filter.mjs.map +1 -0
- package/dist/lib/Format.mjs +47 -0
- package/dist/lib/Format.mjs.map +1 -0
- package/dist/lib/JsonSchema.mjs +21 -0
- package/dist/lib/JsonSchema.mjs.map +1 -0
- package/dist/lib/Key.mjs +15 -0
- package/dist/lib/Key.mjs.map +1 -0
- package/dist/lib/Migration.mjs +38 -0
- package/dist/lib/Migration.mjs.map +1 -0
- package/dist/lib/Obj.mjs +660 -0
- package/dist/lib/Obj.mjs.map +1 -0
- package/dist/lib/Order.mjs +65 -0
- package/dist/lib/Order.mjs.map +1 -0
- package/dist/lib/Query.mjs +336 -0
- package/dist/lib/Query.mjs.map +1 -0
- package/dist/lib/QueryResult.mjs +7 -0
- package/dist/lib/QueryResult.mjs.map +1 -0
- package/dist/lib/Ref.mjs +44 -0
- package/dist/lib/Ref.mjs.map +1 -0
- package/dist/lib/Registry.mjs +35 -0
- package/dist/lib/Registry.mjs.map +1 -0
- package/dist/lib/Relation.mjs +397 -0
- package/dist/lib/Relation.mjs.map +1 -0
- package/dist/lib/Scope.mjs +51 -0
- package/dist/lib/Scope.mjs.map +1 -0
- package/dist/lib/Tag.mjs +70 -0
- package/dist/lib/Tag.mjs.map +1 -0
- package/dist/lib/Text.mjs +82 -0
- package/dist/lib/Text.mjs.map +1 -0
- package/dist/lib/Type.mjs +371 -0
- package/dist/lib/Type.mjs.map +1 -0
- package/dist/lib/chunk-Annotation.mjs +221 -0
- package/dist/lib/chunk-Annotation.mjs.map +1 -0
- package/dist/lib/chunk-Database.mjs +918 -0
- package/dist/lib/chunk-Database.mjs.map +1 -0
- package/dist/lib/chunk-atom-snapshot.mjs +249 -0
- package/dist/lib/chunk-atom-snapshot.mjs.map +1 -0
- package/dist/lib/chunk-internal.mjs +2775 -0
- package/dist/lib/chunk-internal.mjs.map +1 -0
- package/dist/lib/chunk-json-schema.mjs +660 -0
- package/dist/lib/chunk-json-schema.mjs.map +1 -0
- package/dist/lib/chunk-number.mjs +164 -0
- package/dist/lib/chunk-number.mjs.map +1 -0
- package/dist/lib/chunk-ref-array.mjs +31 -0
- package/dist/lib/chunk-ref-array.mjs.map +1 -0
- package/dist/lib/chunk-ref.mjs +590 -0
- package/dist/lib/chunk-ref.mjs.map +1 -0
- package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
- package/dist/lib/chunk-select.mjs +186 -0
- package/dist/lib/chunk-select.mjs.map +1 -0
- package/dist/lib/chunk-src.mjs +234 -0
- package/dist/lib/chunk-src.mjs.map +1 -0
- package/dist/lib/chunk-util.mjs +140 -0
- package/dist/lib/chunk-util.mjs.map +1 -0
- package/dist/lib/index.mjs +24 -0
- package/dist/lib/internal.mjs +10 -0
- package/dist/lib/testing.mjs +346 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/types/src/Aggregate.d.ts +86 -0
- package/dist/types/src/Aggregate.d.ts.map +1 -0
- package/dist/types/src/Blob.d.ts +153 -0
- package/dist/types/src/Blob.d.ts.map +1 -0
- package/dist/types/src/Blob.test.d.ts +2 -0
- package/dist/types/src/Blob.test.d.ts.map +1 -0
- package/dist/types/src/Database.d.ts +153 -4
- package/dist/types/src/Database.d.ts.map +1 -1
- package/dist/types/src/Err.d.ts +116 -0
- package/dist/types/src/Err.d.ts.map +1 -1
- package/dist/types/src/Feed.d.ts +116 -28
- package/dist/types/src/Feed.d.ts.map +1 -1
- package/dist/types/src/Feed.test.d.ts +2 -0
- package/dist/types/src/Feed.test.d.ts.map +1 -0
- package/dist/types/src/Filter.d.ts +14 -6
- package/dist/types/src/Filter.d.ts.map +1 -1
- package/dist/types/src/Hypergraph.d.ts +18 -0
- package/dist/types/src/Hypergraph.d.ts.map +1 -1
- package/dist/types/src/Json.d.ts.map +1 -1
- package/dist/types/src/Obj.d.ts +14 -1
- package/dist/types/src/Obj.d.ts.map +1 -1
- package/dist/types/src/Order.d.ts +9 -3
- package/dist/types/src/Order.d.ts.map +1 -1
- package/dist/types/src/Query.d.ts +107 -26
- package/dist/types/src/Query.d.ts.map +1 -1
- package/dist/types/src/Relation.d.ts +6 -0
- package/dist/types/src/Relation.d.ts.map +1 -1
- package/dist/types/src/Type.d.ts.map +1 -1
- package/dist/types/src/View.d.ts +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/Entity/api.d.ts +6 -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/Filter/match.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts +34 -8
- package/dist/types/src/internal/JsonSchema/json-schema-type.d.ts.map +1 -1
- package/dist/types/src/internal/JsonSchema/json-schema.d.ts.map +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/Query/query-result-effect.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/make-object.d.ts +13 -0
- package/dist/types/src/internal/common/proxy/make-object.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/reactive.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/symbols.d.ts.map +1 -1
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts +12 -0
- package/dist/types/src/internal/common/proxy/typed-handler.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/index.d.ts +1 -0
- package/dist/types/src/internal/common/types/index.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/model-symbols.d.ts +5 -0
- package/dist/types/src/internal/common/types/model-symbols.d.ts.map +1 -1
- package/dist/types/src/internal/common/types/projection.d.ts +32 -0
- package/dist/types/src/internal/common/types/projection.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -35
- package/src/Aggregate.ts +105 -0
- package/src/Blob.test.ts +45 -0
- package/src/Blob.ts +205 -0
- package/src/Database.ts +207 -17
- package/src/Err.ts +36 -0
- package/src/Feed.test.ts +188 -0
- package/src/Feed.ts +238 -62
- package/src/Filter.ts +28 -10
- package/src/Hypergraph.ts +18 -0
- package/src/Json.ts +1 -0
- package/src/Obj.test.ts +2 -2
- package/src/Obj.ts +21 -1
- package/src/Order.ts +16 -9
- package/src/Query.test.ts +319 -2
- package/src/Query.ts +165 -51
- package/src/Relation.ts +14 -0
- package/src/Type.ts +5 -6
- package/src/index.ts +2 -0
- package/src/internal/Entity/api.ts +11 -1
- package/src/internal/Entity/model.ts +3 -0
- package/src/internal/Filter/match.ts +30 -1
- package/src/internal/JsonSchema/json-schema-type.ts +14 -2
- package/src/internal/JsonSchema/json-schema.test.ts +28 -1
- package/src/internal/JsonSchema/json-schema.ts +33 -6
- package/src/internal/Obj/atoms.ts +4 -2
- package/src/internal/Obj/json-serializer.test.ts +162 -2
- package/src/internal/Obj/json-serializer.ts +6 -0
- package/src/internal/Query/pretty.ts +19 -1
- package/src/internal/Query/query-result-effect.ts +2 -4
- package/src/internal/Ref/atoms.ts +1 -1
- package/src/internal/common/proxy/change-context.ts +1 -1
- package/src/internal/common/proxy/make-object.ts +42 -3
- package/src/internal/common/proxy/reactive.ts +5 -0
- package/src/internal/common/proxy/symbols.ts +1 -0
- package/src/internal/common/proxy/typed-handler.ts +71 -29
- package/src/internal/common/types/index.ts +1 -0
- package/src/internal/common/types/model-symbols.ts +6 -0
- package/src/internal/common/types/projection.ts +45 -0
- package/src/testing/test-data.ts +14 -14
- package/dist/lib/neutral/Annotation.mjs +0 -90
- package/dist/lib/neutral/Annotation.mjs.map +0 -7
- package/dist/lib/neutral/Database.mjs +0 -42
- package/dist/lib/neutral/Database.mjs.map +0 -7
- package/dist/lib/neutral/Entity.mjs +0 -76
- package/dist/lib/neutral/Entity.mjs.map +0 -7
- package/dist/lib/neutral/Err.mjs +0 -16
- package/dist/lib/neutral/Err.mjs.map +0 -7
- package/dist/lib/neutral/Feed.mjs +0 -50
- package/dist/lib/neutral/Feed.mjs.map +0 -7
- package/dist/lib/neutral/Filter.mjs +0 -72
- package/dist/lib/neutral/Filter.mjs.map +0 -7
- package/dist/lib/neutral/Format.mjs +0 -82
- package/dist/lib/neutral/Format.mjs.map +0 -7
- package/dist/lib/neutral/JsonSchema.mjs +0 -18
- package/dist/lib/neutral/JsonSchema.mjs.map +0 -7
- package/dist/lib/neutral/Key.mjs +0 -16
- package/dist/lib/neutral/Key.mjs.map +0 -7
- package/dist/lib/neutral/Migration.mjs +0 -18
- package/dist/lib/neutral/Migration.mjs.map +0 -7
- package/dist/lib/neutral/Obj.mjs +0 -128
- package/dist/lib/neutral/Obj.mjs.map +0 -7
- package/dist/lib/neutral/Order.mjs +0 -16
- package/dist/lib/neutral/Order.mjs.map +0 -7
- package/dist/lib/neutral/Query.mjs +0 -38
- package/dist/lib/neutral/Query.mjs.map +0 -7
- package/dist/lib/neutral/QueryResult.mjs +0 -2
- package/dist/lib/neutral/QueryResult.mjs.map +0 -7
- package/dist/lib/neutral/Ref.mjs +0 -25
- package/dist/lib/neutral/Ref.mjs.map +0 -7
- package/dist/lib/neutral/Registry.mjs +0 -14
- package/dist/lib/neutral/Registry.mjs.map +0 -7
- package/dist/lib/neutral/Relation.mjs +0 -97
- package/dist/lib/neutral/Relation.mjs.map +0 -7
- package/dist/lib/neutral/Scope.mjs +0 -12
- package/dist/lib/neutral/Scope.mjs.map +0 -7
- package/dist/lib/neutral/Tag.mjs +0 -32
- package/dist/lib/neutral/Tag.mjs.map +0 -7
- package/dist/lib/neutral/Text.mjs +0 -25
- package/dist/lib/neutral/Text.mjs.map +0 -7
- package/dist/lib/neutral/Type.mjs +0 -65
- package/dist/lib/neutral/Type.mjs.map +0 -7
- package/dist/lib/neutral/chunk-2HKGAQM4.mjs +0 -1394
- package/dist/lib/neutral/chunk-2HKGAQM4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-2ZHECXUR.mjs +0 -95
- package/dist/lib/neutral/chunk-2ZHECXUR.mjs.map +0 -7
- package/dist/lib/neutral/chunk-3KTE2Y7Q.mjs +0 -336
- package/dist/lib/neutral/chunk-3KTE2Y7Q.mjs.map +0 -7
- package/dist/lib/neutral/chunk-3TN2VMI4.mjs +0 -714
- package/dist/lib/neutral/chunk-3TN2VMI4.mjs.map +0 -7
- package/dist/lib/neutral/chunk-42L4HJ3Z.mjs +0 -104
- package/dist/lib/neutral/chunk-42L4HJ3Z.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4A2NWKRJ.mjs +0 -747
- package/dist/lib/neutral/chunk-4A2NWKRJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs +0 -25
- package/dist/lib/neutral/chunk-7LOUAPYZ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-ACFAOTKJ.mjs +0 -1531
- package/dist/lib/neutral/chunk-ACFAOTKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BEFR7LEA.mjs +0 -170
- package/dist/lib/neutral/chunk-BEFR7LEA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BXIKXT7Q.mjs +0 -89
- package/dist/lib/neutral/chunk-BXIKXT7Q.mjs.map +0 -7
- package/dist/lib/neutral/chunk-C57XMMBY.mjs +0 -206
- package/dist/lib/neutral/chunk-C57XMMBY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-C62JYFAD.mjs +0 -183
- package/dist/lib/neutral/chunk-C62JYFAD.mjs.map +0 -7
- package/dist/lib/neutral/chunk-FSGX2R62.mjs +0 -48
- package/dist/lib/neutral/chunk-FSGX2R62.mjs.map +0 -7
- package/dist/lib/neutral/chunk-HBXT3GSB.mjs +0 -459
- package/dist/lib/neutral/chunk-HBXT3GSB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-IQR45HAD.mjs +0 -31
- package/dist/lib/neutral/chunk-IQR45HAD.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-KCBW4BR6.mjs +0 -424
- package/dist/lib/neutral/chunk-KCBW4BR6.mjs.map +0 -7
- package/dist/lib/neutral/chunk-L3E5IXAE.mjs +0 -575
- package/dist/lib/neutral/chunk-L3E5IXAE.mjs.map +0 -7
- package/dist/lib/neutral/chunk-PRC4FEKJ.mjs +0 -56
- package/dist/lib/neutral/chunk-PRC4FEKJ.mjs.map +0 -7
- package/dist/lib/neutral/chunk-SCT6FFCR.mjs +0 -351
- package/dist/lib/neutral/chunk-SCT6FFCR.mjs.map +0 -7
- package/dist/lib/neutral/chunk-TOCVVFK2.mjs +0 -75
- package/dist/lib/neutral/chunk-TOCVVFK2.mjs.map +0 -7
- package/dist/lib/neutral/chunk-U53LSQQA.mjs +0 -41
- package/dist/lib/neutral/chunk-U53LSQQA.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UGFFV2FR.mjs +0 -27
- package/dist/lib/neutral/chunk-UGFFV2FR.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UWLP4RFM.mjs +0 -7
- package/dist/lib/neutral/chunk-UWLP4RFM.mjs.map +0 -7
- package/dist/lib/neutral/chunk-UZHCQ6NI.mjs +0 -283
- package/dist/lib/neutral/chunk-UZHCQ6NI.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WISOH2XH.mjs +0 -36
- package/dist/lib/neutral/chunk-WISOH2XH.mjs.map +0 -7
- package/dist/lib/neutral/chunk-WKIT2YY5.mjs +0 -34
- package/dist/lib/neutral/chunk-WKIT2YY5.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XB6ISRAO.mjs +0 -271
- package/dist/lib/neutral/chunk-XB6ISRAO.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XXL42WCB.mjs +0 -84
- package/dist/lib/neutral/chunk-XXL42WCB.mjs.map +0 -7
- package/dist/lib/neutral/chunk-XXWK4J53.mjs +0 -117
- package/dist/lib/neutral/chunk-XXWK4J53.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -115
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/internal/index.mjs +0 -581
- package/dist/lib/neutral/internal/index.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/testing/index.mjs +0 -477
- package/dist/lib/neutral/testing/index.mjs.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-ref.mjs","names":[],"sources":["../../src/internal/common/proxy/proxy-utils.ts","../../src/internal/common/proxy/symbols.ts","../../src/internal/common/proxy/reactive.ts","../../src/internal/Ref/utils.ts","../../src/internal/Ref/atoms.ts","../../src/internal/Ref/ref.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport { invariant } from '@dxos/invariant';\n\nimport { type ReactiveHandler } from './proxy-types';\n\nexport const symbolIsProxy = Symbol.for('@dxos/schema/Proxy');\n\n/**\n * Marker placed on a reactive-object behaviour prototype (e.g. the typed handler's\n * `TypedObject` prototype). A record target whose prototype chain carries this marker\n * is a reactive data record — equivalent, for the purposes of the \"plain object\" gates\n * below, to one rooted directly at `Object.prototype`. This lets a handler move its\n * per-object metadata onto an intermediate prototype without those gates mistaking the\n * record for a foreign class instance.\n */\nexport const symbolReactivePrototype = Symbol.for('@dxos/echo/ReactivePrototype');\n\n/**\n * Internal api.\n */\nexport const isProxy = (value: unknown) => !!(value as any)?.[symbolIsProxy];\n\n/**\n * True if `value` is a plain data record — either rooted at `Object.prototype` or carrying\n * a reactive behaviour prototype (see {@link symbolReactivePrototype}).\n */\nexport const isReactiveRecord = (value: any): boolean => {\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || (proto != null && !!proto[symbolReactivePrototype]);\n};\n\nexport const isValidProxyTarget = (value: any): value is object => {\n if (value == null || value[symbolIsProxy]) {\n return false;\n }\n if (Array.isArray(value)) {\n return true;\n }\n\n return typeof value === 'object' && isReactiveRecord(value);\n};\n\n/**\n * @deprecated\n */\nexport const getProxySlot = <T extends object>(proxy: any): ProxyHandlerSlot<T> => {\n const value = (proxy as any)[symbolIsProxy];\n invariant(value instanceof ProxyHandlerSlot);\n return value;\n};\n\nexport const getProxyTarget = <T extends object>(proxy: any): T => {\n return getProxySlot<T>(proxy).target;\n};\n\nexport const getProxyHandler = <T extends object>(proxy: any): ReactiveHandler<T> => {\n return getProxySlot<T>(proxy).handler;\n};\n\n/**\n * Clamp a splice range to `Array.prototype.splice` semantics for a string of the given `length`:\n * a negative `start` counts from the end, a `start` past the end appends, and `deleteCount` is bounded\n * to the remaining characters. Shared by both reactive handlers so the string CRDT API behaves\n * identically across the in-memory and Automerge backends (Automerge's `splice` otherwise throws on\n * out-of-range indices).\n */\nexport const normalizeSpliceRange = (\n length: number,\n start: number,\n deleteCount: number,\n): { start: number; deleteCount: number } => {\n const safeStart = start < 0 ? Math.max(length + start, 0) : Math.min(start, length);\n const safeDeleteCount = Math.max(0, Math.min(deleteCount, length - safeStart));\n return { start: safeStart, deleteCount: safeDeleteCount };\n};\n\n/**\n * Unsafe method to override id for debugging/testing and migration purposes.\n * @deprecated\n */\nexport const dangerouslySetProxyId = <T>(obj: T, id: string) => {\n (getProxySlot(obj).target as any).id = id;\n};\n\n/**\n * Create a reactive proxy object.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy\n *\n * @param target Object or array. Passing in array will enable array methods.\n * @param handler ReactiveHandler instance.\n */\n// TODO(burdon): Document.\n// TODO(burdon): Tests for low-level functions.\nexport const createProxy = <T extends object>(target: T, handler: ReactiveHandler<T>): T => {\n const existingProxy = handler._proxyMap.get(target);\n if (existingProxy) {\n return existingProxy;\n }\n\n // TODO(dmaretskyi): In the future this should be mutable to allow replacing the handler on-the-fly while maintaining the proxy identity.\n const proxy = new Proxy(target, new ProxyHandlerSlot<T>(target, handler));\n handler.init(target);\n\n // TODO(dmaretskyi): Check if this will actually work; maybe a global WeakMap is better?\n handler._proxyMap.set(target, proxy);\n return proxy;\n};\n\n/**\n * Passed as the handler to the Proxy constructor.\n * Maintains a mutable slot for the actual handler.\n */\nclass ProxyHandlerSlot<T extends object> implements ProxyHandler<T> {\n /**\n * @param target Original object.\n * @param _handler Handles intercepted operations.\n */\n constructor(\n readonly target: T,\n private _handler: ReactiveHandler<T>,\n ) {}\n\n get handler() {\n invariant(this._handler);\n return this._handler;\n }\n\n // TODO(burdon): Requires comment.\n setHandler(handler: ReactiveHandler<T>): void {\n this._handler = handler;\n }\n\n /**\n * Get value.\n */\n get(target: T, prop: string | symbol, receiver: any): any {\n if (prop === symbolIsProxy) {\n return this;\n }\n\n if (!this._handler || !this._handler.get) {\n return Reflect.get(target, prop, receiver);\n }\n\n return this._handler.get(target, prop, receiver);\n }\n\n static {\n const TRAPS: (keyof ProxyHandler<any>)[] = [\n 'apply',\n 'construct',\n 'defineProperty',\n 'deleteProperty',\n 'get',\n 'getOwnPropertyDescriptor',\n 'getPrototypeOf',\n 'has',\n 'isExtensible',\n 'ownKeys',\n 'preventExtensions',\n 'set',\n 'setPrototypeOf',\n ];\n\n for (const trap of TRAPS) {\n if (trap === 'get') {\n continue;\n }\n\n Object.defineProperty(this.prototype, trap, {\n enumerable: false,\n value: function (this: ProxyHandlerSlot<any>, ...args: any[]) {\n // log.info('trap', { trap, args });\n if (!this._handler || !this._handler[trap]) {\n return (Reflect[trap] as Function)(...args);\n }\n\n return (this._handler[trap] as Function).apply(this._handler, args);\n },\n });\n }\n }\n}\n","//\n// Copyright 2024 DXOS.org\n//\n\n// TODO(dmaretskyi): Rename all symbols that are props to end with *Key.\nexport const EventId = Symbol.for('@dxos/live-object/EventId');\n\nexport const ChangeId = Symbol.for('@dxos/live-object/ChangeId');\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { type RefTypeId } from '../../Ref/ref';\nimport { getProxyTarget, isProxy } from './proxy-utils';\nimport { ChangeId, EventId } from './symbols';\n\n/**\n * Subscribe to changes on a reactive object.\n * @param obj - The reactive object to subscribe to.\n * @param callback - Called when the object changes.\n * @returns Unsubscribe function.\n */\n// TODO(wittjosiah): Consider throwing if obj doesn't have EventId instead of returning no-op.\nexport const subscribe = (obj: unknown, callback: () => void): (() => void) => {\n // Guard against non-reactive inputs (queue-stored typed objects, snapshots, plain shapes\n // with branded symbols) before `getProxyTarget`'s `ProxyHandlerSlot` invariant kicks in.\n // `Obj.isObject` (KindId-based) is satisfied by these inputs, so callers like\n // `Atom.family((obj) => Atom.make((get) => Obj.subscribe(obj, ...)))` legitimately reach\n // here with a non-proxy. Falling back to a no-op preserves the documented contract that\n // values without subscription support get a no-op unsubscribe.\n if (!isProxy(obj)) {\n return () => {};\n }\n const target = getProxyTarget(obj as any);\n if (target && EventId in target) {\n return (target as any)[EventId].on(callback);\n }\n return () => {};\n};\n\n/**\n * Deeply removes readonly modifiers from all properties of T.\n * Inside Obj.update, all properties are fully mutable regardless of schema definition.\n * Ref types are preserved as-is since they are value-like objects that are replaced, not mutated.\n * Primitive types (including branded primitives) are preserved as-is.\n */\nexport type Mutable<T> = T extends string | number | boolean | bigint | symbol | null | undefined\n ? T // Primitives (including branded primitives like JsonPath) stay as-is.\n : T extends { [RefTypeId]: any }\n ? T // Keep Ref types as-is (they're value-like, not mutated in place).\n : T extends object\n ? T extends readonly (infer U)[]\n ? Mutable<U>[]\n : { -readonly [K in keyof T]: Mutable<T[K]> }\n : T;\n\n/**\n * Callback type for the change function.\n */\nexport type ChangeCallback<T> = (mutableObj: Mutable<T>) => void;\n\n/**\n * Perform mutations on a reactive object within a change context.\n *\n * If the object has a change handler (via ChangeId), it will be called with the callback.\n * This allows handlers to implement features like:\n * - Readonly enforcement (mutations only allowed within change context)\n * - Batched notifications (single notification for all mutations in the callback)\n * - Transaction semantics\n *\n * If the object doesn't have a change handler, the callback is called directly.\n *\n * @param obj - The reactive object to mutate.\n * @param callback - Callback that receives a mutable view of the object.\n */\nexport const change = <T>(obj: T, callback: ChangeCallback<T>): void => {\n // Check proxy first (allows handler to intercept), then fall back to target.\n // This order is important for EchoReactiveHandler which handles ChangeId in the proxy trap.\n //\n // The direct-callback fallback (no `[ChangeId]`) now only applies to true snapshots and\n // schemaless feed items (unresolvable type at decode time, see `makeDecodedEntityLive`) — live\n // feed-backed objects carry a `[ChangeId]` (via `TypedReactiveHandler`) same as any other typed\n // reactive object, so they take the `changeFn` branch above like automerge-backed objects do.\n const changeFn = (obj as any)[ChangeId];\n if (changeFn) {\n changeFn(callback);\n } else {\n callback(obj as Mutable<T>);\n }\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Atom from '@effect-atom/atom/Atom';\n\nimport type { Ref } from './ref';\n\n/**\n * Internal helper for loading ref targets in atoms.\n * Handles the common pattern of checking for loaded target and triggering async load.\n */\nexport const loadRefTarget = <T, R>(\n ref: Ref<T>,\n get: Atom.Context,\n onTargetAvailable: (target: T) => R,\n): R | undefined => {\n // Accessing `ref.target` registers a resolution callback when the target is\n // not yet loaded, so resolution can be observed via `ref.onResolved` below.\n const currentTarget = ref.target;\n if (currentTarget) {\n return onTargetAvailable(currentTarget);\n }\n\n // Subscribe to the ref's resolution event in case the target loads later.\n const unsubscribe = ref.onResolved(() => {\n const target = ref.target;\n if (target) {\n get.setSelf(onTargetAvailable(target));\n }\n });\n get.addFinalizer(unsubscribe);\n\n // Also try async load (e.g. for objects that need disk loading).\n void ref\n .load()\n .then((loadedTarget) => {\n get.setSelf(onTargetAvailable(loadedTarget));\n })\n .catch(() => {\n // Loading failed; the resolution subscription above will pick up cross-client updates.\n });\n\n return undefined;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Atom from '@effect-atom/atom/Atom';\n\nimport { subscribe } from '../common/proxy/reactive';\nimport { ObjectDeletedId } from '../common/types/model-symbols';\nimport type { Ref } from './ref';\nimport { loadRefTarget } from './utils';\n\n/**\n * Atom family for ECHO refs.\n * Uses ref reference as key — same ref returns same atom.\n * Subscribes to target object changes and resolves to undefined when the target is deleted.\n */\nexport const refSimpleFamily = Atom.family(<T>(ref: Ref<T>): Atom.Atom<T | undefined> => {\n return Atom.make<T | undefined>((get) => {\n let unsubscribeTarget: (() => void) | undefined;\n\n const setupSubscription = (target: T): T | undefined => {\n // Release any previous subscription before re-subscribing (loadRefTarget may call this more than once).\n // T has no ECHO-proxy constraint at this generic level; `subscribe` and ObjectDeletedId\n // both require the internal proxy shape that cannot be expressed statically here.\n unsubscribeTarget?.();\n unsubscribeTarget = subscribe(target as any, () => {\n const deleted = !!(target as any)[ObjectDeletedId];\n get.setSelf(deleted ? undefined : target);\n });\n const deleted = !!(target as any)[ObjectDeletedId];\n return deleted ? undefined : target;\n };\n\n get.addFinalizer(() => {\n unsubscribeTarget?.();\n });\n\n return loadRefTarget(ref, get, setupSubscription);\n }).pipe(Atom.keepAlive);\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport type * as Atom from '@effect-atom/atom/Atom';\nimport * as Effect from 'effect/Effect';\nimport * as Equal from 'effect/Equal';\nimport * as Hash from 'effect/Hash';\nimport * as Option from 'effect/Option';\nimport * as ParseResult from 'effect/ParseResult';\nimport * as Pipeable from 'effect/Pipeable';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport type * as Types from 'effect/Types';\n\nimport { Event } from '@dxos/async';\nimport { type CustomInspectFunction, inspectCustom } from '@dxos/debug';\nimport { EncodedReference } from '@dxos/echo-protocol';\nimport { assertArgument, invariant } from '@dxos/invariant';\nimport { DXN, EID, EntityId, type URI } from '@dxos/keys';\n\nimport * as Database from '../../Database';\nimport type * as Type from '../../Type';\nimport {\n ReferenceAnnotationId,\n getSchemaURI,\n getTypeAnnotation,\n getTypeIdentifierAnnotation,\n} from '../Annotation/annotations';\nimport { type AnyEntity, type AnyProperties, type UnknownTypeSchema, getStaticTypeSchema } from '../common/types';\nimport { type JsonSchemaType } from '../JsonSchema';\nimport * as RefAtoms from './atoms';\n\n/**\n * The `$id` and `$ref` fields for an ECHO reference schema.\n */\nexport const JSON_SCHEMA_ECHO_REF_ID = '/schemas/echo/ref';\n\nexport const getSchemaReference = (property: JsonSchemaType): { typename: string } | undefined => {\n const { $id, reference: { schema: { $ref } = {} } = {} } = property;\n if ($id === JSON_SCHEMA_ECHO_REF_ID && $ref) {\n const parsed = DXN.tryMake($ref);\n const typename = parsed ? DXN.getName(parsed) : undefined;\n return typename ? { typename } : undefined;\n }\n};\n\nexport const createSchemaReference = (typename: string): Types.DeepMutable<JsonSchemaType> => {\n return {\n $id: JSON_SCHEMA_ECHO_REF_ID,\n reference: {\n schema: {\n $ref: DXN.make(typename),\n },\n },\n };\n};\n\n/**\n * Runtime type-info for a reference extracted from effect AST.\n */\nexport type RefereneAST = {\n /**\n * Typename of linked schema.\n */\n typename: string;\n\n /**\n * Version of linked schema.\n */\n version: string;\n};\n\nexport const getReferenceAst = (ast: SchemaAST.AST): RefereneAST | undefined => {\n if (ast._tag !== 'Declaration' || !ast.annotations[ReferenceAnnotationId]) {\n return undefined;\n }\n return {\n typename: (ast.annotations[ReferenceAnnotationId] as any).typename,\n version: (ast.annotations[ReferenceAnnotationId] as any).version,\n };\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const RefTypeId: unique symbol = Symbol.for('@dxos/echo/internal/Ref') as any;\n\n/**\n * Reference Schema.\n */\nexport interface RefSchema<T extends AnyEntity> extends Schema.SchemaClass<Ref<T>, EncodedReference> {}\n\n/**\n * Type of the `Ref` function and extra methods attached to it.\n */\nexport interface RefFn {\n // A reference target is a `Type.AnyEntity` entity (the canonical Option B\n // input) or one of the well-known \"any object\" / \"any relation\" branded\n // schemas (`Obj.Unknown` / `Relation.Unknown`). Arbitrary raw schemas are\n // rejected.\n //\n // Referencing a type-kind entity (a meta-schema, e.g. `Type.Type`) yields a\n // reference to a stored schema record; its loaded target is any registered\n // entity (`Type.AnyEntity`), since a stored object/relation schema is itself a\n // `Type.Type` record. Referencing an object/relation type yields a reference\n // to an instance of that type.\n <S extends Type.AnyEntity | UnknownTypeSchema<any, any> = Type.AnyEntity>(\n schema: S,\n ): RefSchema<\n S extends Type.AnyType\n ? Type.AnyEntity\n : S extends Type.AnyObj | Type.AnyRelation\n ? Type.InstanceType<S>\n : S extends UnknownTypeSchema<infer A, any>\n ? A\n : never\n >;\n\n /**\n * @returns True if the object is a reference.\n */\n isRef: (obj: unknown) => obj is Ref<any>;\n\n /**\n * @returns True if the reference points to the given object id.\n */\n hasEntityId: (id: EntityId) => (ref: Ref<any>) => boolean;\n\n /**\n * @returns True if the schema is a reference schema.\n */\n isRefSchema: (schema: Schema.Schema<any, any>) => schema is RefSchema<any>;\n\n /**\n * @returns True if the schema AST is a reference schema.\n */\n isRefSchemaAST: (ast: SchemaAST.AST) => boolean;\n\n /**\n * Constructs a reference that points to the given object.\n */\n // TODO(burdon): Narrow to Obj.Unknown?\n make: <T extends AnyEntity>(object: T) => Ref<T>;\n\n /**\n * Constructs a reference that points to the object specified by the provided URI\n * (either an `echo:` EID for an object reference or a `dxn:` DXN for a type reference).\n */\n fromURI: (uri: URI.URI) => Ref<any>;\n}\n\n/**\n * Schema builder for references.\n */\nexport const Ref: RefFn = (input: any): RefSchema<any> => {\n // `Type.Type` entities carry their source schema on the hidden slot; the\n // branded `Obj.Unknown` / `Relation.Unknown` schemas are used directly.\n const schema = getStaticTypeSchema(input) ?? input;\n assertArgument(Schema.isSchema(schema), 'schema', 'Must call with an instance of effect-schema');\n const annotation = getTypeAnnotation(schema);\n if (annotation == null) {\n throw new Error('Reference target must be an ECHO schema.');\n }\n\n return createEchoReferenceSchema(getTypeIdentifierAnnotation(schema), annotation.typename, annotation.version);\n};\n\n/**\n * Represents materialized reference to a target.\n * This is the data type for the fields marked as ref.\n */\nexport interface Ref<T> extends Pipeable.Pipeable {\n /**\n * Target URI (either an `echo:` EID for an object reference or a `dxn:` DXN for a type reference).\n */\n get uri(): URI.URI;\n\n /**\n * Returns true if the reference has a target available (inlined or resolver set).\n */\n get isAvailable(): boolean;\n\n /**\n * @returns The reference target.\n * May return `undefined` if the object is not loaded in the working set.\n * Accessing this property, even if it returns `undefined` will trigger the object to be loaded to the working set.\n */\n get target(): T | undefined;\n\n /**\n * @returns Promise that will resolves with the target object.\n * Will load the object from disk if it is not present in the working set.\n * Short-circuits immediately when the target is already loaded.\n * @throws If the object is not available locally.\n *\n * @idiom org.dxos.echo.refLoad\n * applies: Resolving a ref inside an async function or Effect handler — guarantees the object is available before proceeding\n * instead-of: `ref.target` — not guaranteed to be defined in async contexts; use `await ref.load()` (or `yield* Database.load(ref)` in Effect) to ensure the target is present\n * uses: {@link load}\n * related: org.dxos.echo-react.useObjectReactive\n */\n load(): Promise<T>;\n\n /**\n * @returns Promise that will resolves with the target object or undefined if the object is not loaded locally.\n */\n\n tryLoad(): Promise<T | undefined>;\n\n /**\n * Subscribe to the ref's resolution event.\n * The callback fires when the target object becomes available in the working set\n * (e.g. when its document is loaded after sibling-client mutation).\n * Note: the resolver only schedules a notification when the target is requested\n * via {@link target} while it is not yet loaded.\n * @returns Function that unsubscribes the callback.\n */\n onResolved(callback: () => void): () => void;\n\n /**\n * Do not inline the target object in the reference.\n * Makes .target unavailable unless the reference is connected to a database context.\n *\n * When serialized with toJSON, the difference is between:\n * `{ \"/\": \"dxn:...\" }`\n * and\n * `{ \"/\": \"dxn:...\", \"target\": { ... } }`\n *\n * Clones the reference object.\n */\n noInline(): Ref<T>;\n\n /**\n * Read-only atom for the ref target.\n * Resolves once when the target loads; does NOT subscribe to target object mutations.\n * Use `Obj.atom(ref)` if you need reactive snapshots that update on every object mutation.\n */\n get atom(): Atom.Atom<T | undefined>;\n\n /**\n * Serializes the reference to a JSON object.\n * The serialization format is compatible with the IPLD-style encoded references.\n * When a reference has a saved target (i.e. the target or object holding the reference is not in the database),\n * the target is included in the serialized object.\n *\n * Examples:\n * `{ \"/\": \"dxn:...\" }`\n * `{ \"/\": \"dxn:...\", \"target\": { ... } }`\n */\n encode(): EncodedReference;\n\n [RefTypeId]: {\n _T: T;\n };\n}\n\nexport declare namespace Ref {\n /**\n * Target of the reference.\n */\n export type Target<R> = R extends Ref<infer U> ? U : never;\n}\n\nRef.isRef = (obj: any): obj is Ref<any> => {\n return obj != null && typeof obj === 'object' && RefTypeId in obj;\n};\n\nRef.hasEntityId = (id: EntityId) => (ref: Ref<any>) => {\n const uri = EID.tryParse(ref.uri);\n return uri !== undefined && EID.isLocal(uri) && EID.getEntityId(uri) === id;\n};\n\nRef.isRefSchema = (schema: Schema.Schema<any, any>): schema is RefSchema<any> => {\n return Ref.isRefSchemaAST(schema.ast);\n};\n\nRef.isRefSchemaAST = (ast: SchemaAST.AST): boolean => {\n return SchemaAST.getAnnotation(ast, ReferenceAnnotationId).pipe(Option.isSome);\n};\n\nRef.make = <T extends AnyProperties>(obj: T): Ref<T> => {\n if (typeof obj !== 'object' || obj === null) {\n throw new TypeError('Expected: ECHO object.');\n }\n\n // TODO(dmaretskyi): Extract to `getObjectEchoUri` function.\n const id = obj.id;\n invariant(EntityId.isValid(id), 'Invalid object ID');\n const uri = EID.make({ entityId: id });\n const ref = new RefImpl(uri, obj);\n return ref;\n};\n\nRef.fromURI = (uri: URI.URI): Ref<any> => {\n assertArgument(typeof uri === 'string', 'uri', 'Expected URI string');\n return new RefImpl(uri);\n};\n\n/**\n * `reference` field on the schema object.\n */\nexport type JsonSchemaReferenceInfo = {\n schema: { $ref: string };\n schemaVersion?: string;\n};\n\n/**\n * @internal\n */\n// TODO(burdon): Move to json schema and make private?\nexport const createEchoReferenceSchema = (\n echoUri: string | undefined,\n typename: string | undefined,\n version: string | undefined,\n): Schema.SchemaClass<Ref<any>, EncodedReference> => {\n if (!echoUri && !typename) {\n throw new TypeError('Either echoUri or typename must be provided.');\n }\n\n const referenceInfo: JsonSchemaReferenceInfo = {\n schema: {\n // TODO(dmaretskyi): Include version?\n $ref: echoUri ?? DXN.make(typename!),\n },\n schemaVersion: version,\n };\n\n // TODO(dmaretskyi): Add name and description.\n const refSchema = Schema.declare<Ref<any>, EncodedReference, []>(\n [],\n {\n encode: () => {\n return (value) =>\n Effect.gen(function* () {\n if (Ref.isRef(value)) {\n return EncodedReference.fromURI((value as Ref<any>).uri);\n } else if (EncodedReference.isEncodedReference(value)) {\n return value;\n }\n throw new Error('Invalid reference');\n });\n },\n decode: () => {\n return (value) =>\n Effect.gen(function* () {\n const dbService = yield* Effect.serviceOption(Database.Service);\n\n // TODO(dmaretskyi): This branch seems to be taken by Schema.is\n if (Ref.isRef(value)) {\n if (Option.isSome(dbService)) {\n return dbService.value.db.makeRef(value.uri);\n } else {\n return value;\n }\n }\n\n if (!EncodedReference.isEncodedReference(value)) {\n return yield* Effect.fail(new ParseResult.Unexpected(value, 'reference'));\n }\n if (Option.isSome(dbService)) {\n return dbService.value.db.makeRef(EncodedReference.toURI(value));\n } else {\n return Ref.fromURI(EncodedReference.toURI(value));\n }\n });\n },\n },\n {\n jsonSchema: {\n // TODO(dmaretskyi): We should remove `$id` and keep `$ref` with a fully qualified name.\n $id: JSON_SCHEMA_ECHO_REF_ID,\n $ref: JSON_SCHEMA_ECHO_REF_ID,\n reference: referenceInfo,\n },\n [ReferenceAnnotationId]: {\n typename: typename ?? '',\n version,\n },\n },\n );\n\n return refSchema;\n};\n\nconst getSchemaExpectedName = (ast: SchemaAST.Annotated): string | undefined => {\n return SchemaAST.getIdentifierAnnotation(ast).pipe(\n Option.orElse(() => SchemaAST.getTitleAnnotation(ast)),\n Option.orElse(() => SchemaAST.getDescriptionAnnotation(ast)),\n Option.getOrElse(() => undefined),\n );\n};\n\n/**\n * Load-source ceiling for a resolution request. Cheaper tiers are always probed first; the\n * ceiling caps how far a request is allowed to reach:\n * - `working-set`: synchronous, in-memory only. A miss settles `unavailable` immediately.\n * - `disk`: probe the working set, then local storage; never the network.\n * - `network`: probe the working set, disk, then fetch from peers.\n *\n * `unavailable` is always relative to the requested ceiling (disk-unavailable ≠ network-unavailable).\n */\nexport type RefSource = 'working-set' | 'disk' | 'network';\n\n/**\n * A stateful, closure-aware handle to an in-flight (or settled) reference resolution.\n *\n * `ready` means the entity is FULLY USABLE: its own body and its strong-dependency closure are all\n * materialized. The body-vs-closure split is internal; `requesting` transparently covers \"a\n * dependency is still loading\".\n */\nexport interface RefResolverRequest {\n /**\n * `pending` is a one-way entry state (never re-entered). `requesting` means the body and/or\n * closure is still loading. `ready` means fully usable. `unavailable` means unreachable at the\n * requested ceiling.\n */\n readonly state: 'pending' | 'requesting' | 'ready' | 'unavailable';\n\n /**\n * Fires (deferred to a microtask) whenever {@link state} changes.\n */\n readonly stateChanged: Event<void>;\n\n /**\n * Synchronous snapshot of the resolved entity; defined iff `state === 'ready'`.\n */\n getResult(): AnyProperties | undefined;\n\n /**\n * Settles when `state ∈ {ready, unavailable}`.\n */\n wait(): Promise<AnyProperties | undefined>;\n\n /**\n * Decrements the refcount on the shared load op(s); cancels the underlying IO at zero.\n */\n abort(): void;\n}\n\nexport interface RefResolver {\n /**\n * Resolve a reference, returning a stateful handle. `source` is a required ceiling; cheaper\n * tiers are always probed first.\n */\n resolve(uri: URI.URI, options: { source: RefSource }): RefResolverRequest;\n\n /**\n * Resolve ref synchronously from the objects in the working set.\n *\n * @param uri\n * @param load If true the resolver should attempt to load the object from disk.\n * @param onLoad Callback to call when the object is loaded.\n * @deprecated Use {@link resolve} with `{ source: 'working-set' }`. Removed in Task 11.\n */\n resolveSync(uri: URI.URI, load: boolean, onLoad?: () => void): AnyProperties | undefined;\n\n /**\n * Resolver ref asynchronously.\n * @deprecated Use {@link resolve} with `{ source: 'network' }`. Removed in Task 11.\n */\n resolveLegacy(uri: URI.URI): Promise<AnyProperties | undefined>;\n\n /**\n * @deprecated Use {@link resolve} + `Type.getSchema`. Removed in Task 11.\n */\n resolveSchema(uri: URI.URI): Promise<Schema.Schema.AnyNoContext | undefined>;\n\n /**\n * Resolve the source `Type.AnyEntity` entity for a type URI. Used by\n * deserialization paths (`Obj.fromJSON`) to set the back-reference accessed\n * via `Obj.getType` / `Entity.getType`. Optional — resolvers that only\n * carry raw schemas may leave this unimplemented; the deserializer falls\n * back to leaving the type entity unset.\n * @deprecated Use {@link resolve}. Removed in Task 11.\n */\n resolveType?(uri: URI.URI): Promise<unknown | undefined>;\n}\n\n/**\n * A settled {@link RefResolverRequest} with a fixed `state` and `result`, used by resolvers\n * whose backends are fully synchronous (e.g. {@link StaticRefResolver}).\n */\nexport const makeSettledRequest = (\n state: RefResolverRequest['state'],\n result: AnyProperties | undefined,\n): RefResolverRequest => ({\n state,\n stateChanged: new Event<void>(),\n getResult: () => (state === 'ready' ? result : undefined),\n wait: async () => (state === 'ready' ? result : undefined),\n abort: () => {},\n});\n\nexport class RefImpl<T> implements Ref<T> {\n [RefTypeId] = refVariance;\n\n #uri: URI.URI;\n\n /**\n * Target is set when the reference is created from a specific object.\n * In this case, the target might not be in the database.\n */\n #target: T | undefined = undefined;\n\n #resolver?: RefResolver = undefined;\n #resolved = new Event<void>();\n\n /**\n * Callback to issue a reactive notification when object is resolved.\n */\n #resolverCallback = () => {\n this.#resolved.emit();\n };\n\n constructor(uri: URI.URI, target?: T) {\n this.#uri = uri;\n this.#target = target;\n }\n\n /**\n * @inheritdoc\n */\n get uri(): URI.URI {\n return this.#uri;\n }\n\n /**\n * @inheritdoc\n */\n get target(): T | undefined {\n if (this.#target) {\n return this.#target;\n }\n\n invariant(this.#resolver, 'Resolver is not set');\n return this.#resolver.resolveSync(this.#uri, true, this.#resolverCallback) as T | undefined;\n }\n\n /**\n * @inheritdoc\n */\n get isAvailable(): boolean {\n return this.#target !== undefined || this.#resolver !== undefined;\n }\n\n get atom(): Atom.Atom<T | undefined> {\n return RefAtoms.refSimpleFamily(this);\n }\n\n /**\n * @inheritdoc\n */\n async load(): Promise<T> {\n if (this.#target) {\n return this.#target;\n }\n invariant(this.#resolver, 'Resolver is not set');\n const obj = await this.#resolver.resolveLegacy(this.#uri);\n if (obj == null) {\n throw new Error('Object not found');\n }\n return obj as T;\n }\n\n /**\n * @inheritdoc\n */\n async tryLoad(): Promise<T | undefined> {\n if (this.#target) {\n return this.#target;\n }\n invariant(this.#resolver, 'Resolver is not set');\n return (await this.#resolver.resolveLegacy(this.#uri)) as T | undefined;\n }\n\n /**\n * @inheritdoc\n */\n onResolved(callback: () => void): () => void {\n return this.#resolved.on(callback);\n }\n\n /**\n * Do not inline the target object in the reference.\n * Makes .target unavailable unless the reference is connected to a database context.\n * Clones the reference object.\n */\n noInline(): RefImpl<T> {\n const ref = new RefImpl<T>(this.#uri, undefined);\n ref.#resolver = this.#resolver;\n return ref;\n }\n\n encode(): EncodedReference {\n return {\n '/': this.#uri,\n ...(this.#target ? { target: this.#target } : {}),\n };\n }\n\n /**\n * Serializes the reference to a JSON object.\n * The serialization format is compatible with the IPLD-style encoded references.\n * When a reference has a saved target (i.e. the target or object holding the reference is not in the database),\n * the target is included in the serialized object.\n */\n toJSON(): EncodedReference {\n return this.encode();\n }\n\n toString(): string {\n if (this.#target) {\n return `Ref(${this.#target.toString()})`;\n }\n\n return `Ref(${this.#uri.toString()})`;\n }\n\n [inspectCustom]: CustomInspectFunction = (depth, options, inspect) => {\n return this.toString();\n };\n\n /**\n * Effect Hash trait. Required for MutableHashMap-based caches (e.g., Atom.family)\n * to deduplicate Ref instances that point to the same object.\n * ECHO proxies return new RefImpl instances on every property access,\n * so without this, each access would create a separate cache entry.\n */\n [Hash.symbol](): number {\n return Hash.hash(this.#uri.toString());\n }\n\n /** Effect Equal trait. See {@link Hash.symbol} for rationale. */\n [Equal.symbol](that: Equal.Equal): boolean {\n return that instanceof RefImpl && this.#uri === that.uri;\n }\n\n pipe() {\n // eslint-disable-next-line prefer-rest-params\n return Pipeable.pipeArguments(this, arguments);\n }\n\n /**\n * @internal\n */\n _setResolver(resolver: RefResolver): void {\n this.#resolver = resolver;\n }\n\n /**\n * @internal\n */\n _getSavedTarget(): T | undefined {\n return this.#target;\n }\n}\n\n/**\n * Internal API for setting the reference resolver.\n */\nexport const setRefResolver = (ref: Ref<any>, resolver: RefResolver) => {\n invariant(ref instanceof RefImpl, 'Ref is not an instance of RefImpl');\n ref._setResolver(resolver);\n};\n\n/**\n * Internal API for getting the saved target on a reference.\n */\nexport const getRefSavedTarget = (ref: Ref<any>): AnyProperties | undefined => {\n invariant(ref instanceof RefImpl, 'Ref is not an instance of RefImpl');\n return ref._getSavedTarget();\n};\n\n// Used to validate reference target type.\nconst refVariance: Ref<any>[typeof RefTypeId] = {\n _T: null as any,\n};\n\nexport const refFromEncodedReference = (encodedReference: EncodedReference, resolver?: RefResolver): Ref<any> => {\n const uri = EncodedReference.toURI(encodedReference);\n const ref = new RefImpl(uri);\n\n // TODO(dmaretskyi): Handle inline target in the encoded reference.\n\n if (resolver) {\n setRefResolver(ref, resolver);\n }\n return ref;\n};\n\nexport class StaticRefResolver implements RefResolver {\n public objects = new Map<EntityId, AnyProperties>();\n public schemas = new Map<URI.URI, Schema.Schema.AnyNoContext>();\n\n addObject(obj: AnyProperties): this {\n this.objects.set(obj.id, obj);\n return this;\n }\n\n addSchema(input: Type.AnyEntity): this {\n const schema = getStaticTypeSchema(input);\n invariant(schema, 'Type entity is missing its source schema');\n const uri = getSchemaURI(schema);\n invariant(uri, 'Schema has no URI');\n this.schemas.set(uri, schema);\n return this;\n }\n\n resolve(uri: URI.URI, _options: { source: RefSource }): RefResolverRequest {\n const obj = this.#lookup(uri);\n return makeSettledRequest(obj ? 'ready' : 'unavailable', obj);\n }\n\n resolveSync(uri: URI.URI, _load: boolean, _onLoad?: () => void): AnyProperties | undefined {\n return this.#lookup(uri);\n }\n\n async resolveLegacy(uri: URI.URI): Promise<AnyProperties | undefined> {\n return this.#lookup(uri);\n }\n\n async resolveSchema(uri: URI.URI): Promise<Schema.Schema.AnyNoContext | undefined> {\n return this.schemas.get(uri);\n }\n\n #lookup(uri: URI.URI): AnyProperties | undefined {\n const echoUri = EID.tryParse(uri);\n const id = echoUri ? EID.getEntityId(echoUri) : undefined;\n if (id == null) {\n return undefined;\n }\n return this.objects.get(id);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAQA,IAAa,gBAAgB,OAAO,IAAI,oBAAoB;;;;;;;;;AAU5D,IAAa,0BAA0B,OAAO,IAAI,8BAA8B;;;;AAKhF,IAAa,WAAW,UAAmB,CAAC,CAAE,QAAgB;;;;;AAM9D,IAAa,oBAAoB,UAAwB;CACvD,MAAM,QAAQ,OAAO,eAAe,KAAK;CACzC,OAAO,UAAU,OAAO,aAAc,SAAS,QAAQ,CAAC,CAAC,MAAM;AACjE;AAEA,IAAa,sBAAsB,UAAgC;CACjE,IAAI,SAAS,QAAQ,MAAM,gBACzB,OAAO;CAET,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAGT,OAAO,OAAO,UAAU,YAAY,iBAAiB,KAAK;AAC5D;;;;AAKA,IAAa,gBAAkC,UAAoC;CACjF,MAAM,QAAS,MAAc;CAC7B,UAAU,iBAAiB,kBAAe,KAAA,GAAA;EAAA,YAAA;EAAA,GAAA;EAAA,GAAA;EAAA,GAAA,KAAA;EAAA,GAAA,CAAA,qCAAA,EAAA;CAAA,CAAC;CAC3C,OAAO;AACT;AAEA,IAAa,kBAAoC,UAAkB;CACjE,OAAO,aAAgB,KAAK,CAAC,CAAC;AAChC;AAEA,IAAa,mBAAqC,UAAmC;CACnF,OAAO,aAAgB,KAAK,CAAC,CAAC;AAChC;;;;;;;;AASA,IAAa,wBACX,QACA,OACA,gBAC2C;CAC3C,MAAM,YAAY,QA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;EACrC,MAAM,SAAS,oBAAoB,KAAK;EACxC,UAAU,QAAQ,4CAAyC;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,CAAA,UAAA,4CAAA;EAAA,CAAC;EAC5D,MAAM,MAAM,aAAa,MAAM;EAC/B,UAAU,KAAK,qBAAkB;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA,CAAA,OAAA,qBAAA;EAAA,CAAC;EAClC,KAAK,QAAQ,IAAI,KAAK,MAAM;EAC5B,OAAO;CACT;CAEA,QAAQ,KAAc,UAAqD;EACzE,MAAM,MAAM,KAAK,QAAQ,GAAG;EAC5B,OAAO,mBAAmB,MAAM,UAAU,eAAe,GAAG;CAC9D;CAEA,YAAY,KAAc,OAAgB,SAAiD;EACzF,OAAO,KAAK,QAAQ,GAAG;CACzB;CAEA,MAAM,cAAc,KAAkD;EACpE,OAAO,KAAK,QAAQ,GAAG;CACzB;CAEA,MAAM,cAAc,KAA+D;EACjF,OAAO,KAAK,QAAQ,IAAI,GAAG;CAC7B;CAEA,QAAQ,KAAyC;EAC/C,MAAM,UAAU,IAAI,SAAS,GAAG;EAChC,MAAM,KAAK,UAAU,IAAI,YAAY,OAAO,IAAI,KAAA;EAChD,IAAI,MAAM,MACR;EAEF,OAAO,KAAK,QAAQ,IAAI,EAAE;CAC5B;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { a as Percent, i as Integer, m as TypeFormat, o as Timestamp, s as FormatAnnotation, t as Currency } from "./chunk-number.mjs";
|
|
2
|
+
import * as Keys from "@dxos/keys";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
5
|
+
import { clamp } from "@dxos/util";
|
|
6
|
+
//#region src/internal/Format/date.ts
|
|
7
|
+
/**
|
|
8
|
+
* Datetime values should be stored as ISO strings or unix numbers (ms) in UTC.
|
|
9
|
+
*
|
|
10
|
+
* NOTE: HyperFormula uses Excel's time format (null date 1900/01/01)
|
|
11
|
+
* It can be configured to use a different parser via `parseDateTime`.
|
|
12
|
+
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#date-and-time-handling
|
|
13
|
+
* https://github.com/handsontable/hyperformula/blob/master/src/DateTimeHelper.ts
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Simple date compatible with HF.
|
|
17
|
+
*/
|
|
18
|
+
var SimpleDate = Schema.Struct({
|
|
19
|
+
year: Schema.Number.pipe(Schema.between(1900, 9999)),
|
|
20
|
+
month: Schema.Number.pipe(Schema.between(1, 12)),
|
|
21
|
+
day: Schema.Number.pipe(Schema.between(1, 31))
|
|
22
|
+
});
|
|
23
|
+
var toSimpleDate = (date) => ({
|
|
24
|
+
year: date.getUTCFullYear(),
|
|
25
|
+
month: date.getUTCMonth() + 1,
|
|
26
|
+
day: date.getUTCDate()
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Simple time compatible with HF.
|
|
30
|
+
*/
|
|
31
|
+
var SimpleTime = Schema.Struct({
|
|
32
|
+
hours: Schema.Number.pipe(Schema.between(0, 23)),
|
|
33
|
+
minutes: Schema.Number.pipe(Schema.between(0, 59)),
|
|
34
|
+
seconds: Schema.Number.pipe(Schema.between(0, 59))
|
|
35
|
+
});
|
|
36
|
+
var toSimpleTime = (date) => ({
|
|
37
|
+
hours: date.getUTCHours(),
|
|
38
|
+
minutes: date.getUTCSeconds(),
|
|
39
|
+
seconds: date.getUTCSeconds()
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Simple date-time compatible with HF.
|
|
43
|
+
*/
|
|
44
|
+
var SimpleDateTime = Schema.extend(SimpleDate, SimpleTime);
|
|
45
|
+
var toSimpleDateTime = (date) => ({
|
|
46
|
+
...toSimpleDate(date),
|
|
47
|
+
...toSimpleTime(date)
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* https://effect.website/docs/guides/schema/transformations#date-transformations
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* Format: 2018-11-13
|
|
54
|
+
*/
|
|
55
|
+
var DateOnly = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Date), Schema.annotations({ description: "Valid date in ISO format" }));
|
|
56
|
+
/**
|
|
57
|
+
* Format: 20:20:39+00:00
|
|
58
|
+
*/
|
|
59
|
+
var TimeOnly = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Time), Schema.annotations({ description: "Valid time in ISO format" }));
|
|
60
|
+
/**
|
|
61
|
+
* Format: 2018-11-13T20:20:39+00:00
|
|
62
|
+
*/
|
|
63
|
+
var DateTime = Schema.String.pipe(FormatAnnotation.set(TypeFormat.DateTime), Schema.annotations({ description: "Valid date and time in ISO format" }));
|
|
64
|
+
/**
|
|
65
|
+
* https://datatracker.ietf.org/doc/html/rfc3339#appendix-A
|
|
66
|
+
*/
|
|
67
|
+
var Duration = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Duration), Schema.annotations({
|
|
68
|
+
description: "Duration in ISO 8601 format",
|
|
69
|
+
[SchemaAST.ExamplesAnnotationId]: ["1h", "3D"]
|
|
70
|
+
}));
|
|
71
|
+
var roundCoordinate = (value) => {
|
|
72
|
+
const factor = 10 ** 7;
|
|
73
|
+
return Math.round(value * factor) / factor;
|
|
74
|
+
};
|
|
75
|
+
/** Longitude/latitude clamped to range and rounded to {@link GEO_PRECISION} decimal places. */
|
|
76
|
+
var Coordinate = (min, max, title) => Schema.transform(Schema.Number.pipe(Schema.clamp(min, max)), Schema.Number, {
|
|
77
|
+
strict: true,
|
|
78
|
+
decode: roundCoordinate,
|
|
79
|
+
encode: roundCoordinate
|
|
80
|
+
}).annotations({ title });
|
|
81
|
+
var GeoPoint = Schema.Tuple(Coordinate(-180, 180, "Longitude"), Coordinate(-90, 90, "Latitude"), Schema.optionalElement(Schema.Number).annotations({ title: "Height ASL (m)" })).pipe(FormatAnnotation.set(TypeFormat.GeoPoint), Schema.annotations({
|
|
82
|
+
title: "GeoPoint",
|
|
83
|
+
description: "GeoJSON Position"
|
|
84
|
+
}));
|
|
85
|
+
var GeoLocation;
|
|
86
|
+
(function(_GeoLocation) {
|
|
87
|
+
_GeoLocation.toGeoPoint = ({ longitude, latitude, height }) => {
|
|
88
|
+
const clampedLongitude = roundCoordinate(clamp(longitude, -180, 180));
|
|
89
|
+
const clampedLatitude = roundCoordinate(clamp(latitude, -90, 90));
|
|
90
|
+
return height !== void 0 ? [
|
|
91
|
+
clampedLongitude,
|
|
92
|
+
clampedLatitude,
|
|
93
|
+
height
|
|
94
|
+
] : [clampedLongitude, clampedLatitude];
|
|
95
|
+
};
|
|
96
|
+
_GeoLocation.fromGeoPoint = (geoPoint) => {
|
|
97
|
+
if (!geoPoint) return {
|
|
98
|
+
longitude: 0,
|
|
99
|
+
latitude: 0
|
|
100
|
+
};
|
|
101
|
+
const result = {
|
|
102
|
+
longitude: geoPoint[0],
|
|
103
|
+
latitude: geoPoint[1]
|
|
104
|
+
};
|
|
105
|
+
if (geoPoint[2] !== void 0) result.height = geoPoint[2];
|
|
106
|
+
return result;
|
|
107
|
+
};
|
|
108
|
+
})(GeoLocation || (GeoLocation = {}));
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/internal/Format/string.ts
|
|
111
|
+
/**
|
|
112
|
+
* Email address (RFC 5321)
|
|
113
|
+
* https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2
|
|
114
|
+
*/
|
|
115
|
+
var Email = Schema.String.pipe(Schema.pattern(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/), FormatAnnotation.set(TypeFormat.Email), Schema.annotations({
|
|
116
|
+
title: "Email",
|
|
117
|
+
description: "Email address"
|
|
118
|
+
}));
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
var Formula = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Formula));
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
*/
|
|
126
|
+
var Hostname = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Hostname));
|
|
127
|
+
/**
|
|
128
|
+
* Regex
|
|
129
|
+
* https://json-schema.org/understanding-json-schema/reference/regular_expressions
|
|
130
|
+
* https://ecma-international.org/publications-and-standards/standards/ecma-262
|
|
131
|
+
*/
|
|
132
|
+
var Regex = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Regex));
|
|
133
|
+
/**
|
|
134
|
+
* Multi-line text.
|
|
135
|
+
*/
|
|
136
|
+
var Text = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Text));
|
|
137
|
+
/**
|
|
138
|
+
* https://datatracker.ietf.org/doc/html/rfc3986#section-1.1.3
|
|
139
|
+
*/
|
|
140
|
+
var URL = Schema.String.pipe(Schema.pattern(/^(\w+?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/i), FormatAnnotation.set(TypeFormat.URL), Schema.annotations({
|
|
141
|
+
title: "URL",
|
|
142
|
+
description: "URL"
|
|
143
|
+
}));
|
|
144
|
+
/**
|
|
145
|
+
* UUID (RFC 4122)
|
|
146
|
+
* https://datatracker.ietf.org/doc/html/rfc4122
|
|
147
|
+
*/
|
|
148
|
+
var UUID = Schema.UUID.pipe(FormatAnnotation.set(TypeFormat.UUID), Schema.annotations({ [SchemaAST.ExamplesAnnotationId]: ["3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a"] }));
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/internal/Format/format.ts
|
|
151
|
+
var Format;
|
|
152
|
+
(function(_Format) {
|
|
153
|
+
_Format.TypeFormat = TypeFormat;
|
|
154
|
+
_Format.DXN = Keys.DXN.Schema;
|
|
155
|
+
_Format.Email = Email;
|
|
156
|
+
_Format.Formula = Formula;
|
|
157
|
+
_Format.Hostname = Hostname;
|
|
158
|
+
_Format.Regex = Regex;
|
|
159
|
+
_Format.URL = URL;
|
|
160
|
+
_Format.UUID = Schema.UUID;
|
|
161
|
+
_Format.Currency = Currency;
|
|
162
|
+
_Format.Integer = Integer;
|
|
163
|
+
_Format.Percent = Percent;
|
|
164
|
+
_Format.Timestamp = Timestamp;
|
|
165
|
+
_Format.Date = DateOnly;
|
|
166
|
+
_Format.DateTime = DateTime;
|
|
167
|
+
_Format.Duration = Duration;
|
|
168
|
+
_Format.Time = TimeOnly;
|
|
169
|
+
_Format.GeoPoint = GeoPoint;
|
|
170
|
+
})(Format || (Format = {}));
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/internal/Format/select.ts
|
|
173
|
+
/**
|
|
174
|
+
* Schema for a single select option. Used to define choices in a {single|multi}-select field.
|
|
175
|
+
*/
|
|
176
|
+
var SelectOption = Schema.Struct({
|
|
177
|
+
/** Stable identifier for the option. */
|
|
178
|
+
id: Schema.NonEmptyString,
|
|
179
|
+
title: Schema.String,
|
|
180
|
+
/** Color palette used for visual styling. */
|
|
181
|
+
color: Schema.String
|
|
182
|
+
});
|
|
183
|
+
//#endregion
|
|
184
|
+
export { SimpleTime as _, Hostname as a, toSimpleDateTime as b, URL as c, GeoPoint as d, DateOnly as f, SimpleDateTime as g, SimpleDate as h, Formula as i, UUID as l, Duration as m, Format as n, Regex as o, DateTime as p, Email as r, Text as s, SelectOption as t, GeoLocation as u, TimeOnly as v, toSimpleTime as x, toSimpleDate as y };
|
|
185
|
+
|
|
186
|
+
//# sourceMappingURL=chunk-select.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-select.mjs","names":[],"sources":["../../src/internal/Format/date.ts","../../src/internal/Format/object.ts","../../src/internal/Format/string.ts","../../src/internal/Format/format.ts","../../src/internal/Format/select.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { FormatAnnotation, TypeFormat } from './types';\n\n/**\n * Datetime values should be stored as ISO strings or unix numbers (ms) in UTC.\n *\n * NOTE: HyperFormula uses Excel's time format (null date 1900/01/01)\n * It can be configured to use a different parser via `parseDateTime`.\n * https://hyperformula.handsontable.com/guide/date-and-time-handling.html#date-and-time-handling\n * https://github.com/handsontable/hyperformula/blob/master/src/DateTimeHelper.ts\n */\n\n// TODO(burdon): Annotations not present in JSON.\n// TODO(burdon): Timezone.\n// TODO(burdon): Format for timestamp (Unix UTC or ISO 8601)?\n// TODO(burdon): Refs\n// - https://www.npmjs.com/package/numfmt\n// - https://date-fns.org/docs/Getting-Started\n// - https://github.com/date-fns/tz\n\n/**\n * Simple date compatible with HF.\n */\nexport const SimpleDate = Schema.Struct({\n year: Schema.Number.pipe(Schema.between(1900, 9999)),\n month: Schema.Number.pipe(Schema.between(1, 12)),\n day: Schema.Number.pipe(Schema.between(1, 31)),\n});\n\nexport type SimpleDate = Schema.Schema.Type<typeof SimpleDate>;\n\nexport const toSimpleDate = (date: Date): SimpleDate => ({\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n});\n\n/**\n * Simple time compatible with HF.\n */\nexport const SimpleTime = Schema.Struct({\n hours: Schema.Number.pipe(Schema.between(0, 23)),\n minutes: Schema.Number.pipe(Schema.between(0, 59)),\n seconds: Schema.Number.pipe(Schema.between(0, 59)),\n});\n\nexport type SimpleTime = Schema.Schema.Type<typeof SimpleTime>;\n\nexport const toSimpleTime = (date: Date): SimpleTime => ({\n hours: date.getUTCHours(),\n minutes: date.getUTCSeconds(),\n seconds: date.getUTCSeconds(),\n});\n\n/**\n * Simple date-time compatible with HF.\n */\nexport const SimpleDateTime = Schema.extend(SimpleDate, SimpleTime);\n\nexport type SimpleDateTime = Schema.Schema.Type<typeof SimpleDateTime>;\n\nexport const toSimpleDateTime = (date: Date): SimpleDateTime => ({\n ...toSimpleDate(date),\n ...toSimpleTime(date),\n});\n\n/**\n * https://effect.website/docs/guides/schema/transformations#date-transformations\n */\n\n// TODO(burdon): Consider if transformations should be supported with Automerge.\n\n/**\n * Format: 2018-11-13\n */\nexport const DateOnly = /* Schema.transformOrFail(Schema.String, SimpleDate, {\n strict: true,\n decode: (str, _, ast) => {\n if (!isValidDateFormat(str)) {\n return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected YYYY-MM-DD format'));\n }\n if (!isValidDate(str)) {\n return ParseResult.fail(new ParseResult.Type(ast, str, 'Invalid date'));\n }\n\n const [year, month, day] = str.split('-').map(Number);\n return ParseResult.succeed({ year, month, day });\n },\n encode: (date) => {\n return ParseResult.succeed(\n [\n date.year.toString().padStart(4, '0'),\n date.month.toString().padStart(2, '0'),\n date.day.toString().padStart(2, '0'),\n ].join('-'),\n );\n },\n}) */ Schema.String.pipe(\n FormatAnnotation.set(TypeFormat.Date),\n Schema.annotations({\n description: 'Valid date in ISO format',\n }),\n);\n\n/**\n * Format: 20:20:39+00:00\n */\nexport const TimeOnly = /* Schema.transformOrFail(Schema.String, SimpleTime, {\n strict: true,\n decode: (str, _, ast) => {\n if (!isValidTimeFormat(str)) {\n return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected HH:mm:ss format'));\n }\n\n const [hours, minutes, seconds] = str.split(':').map(Number);\n return ParseResult.succeed({ hours, minutes, seconds });\n },\n encode: (time) => {\n return ParseResult.succeed(\n [\n time.hours.toString().padStart(2, '0'),\n time.minutes.toString().padStart(2, '0'),\n time.seconds.toString().padStart(2, '0'),\n ].join(':'),\n );\n },\n}) */ Schema.String.pipe(\n FormatAnnotation.set(TypeFormat.Time),\n Schema.annotations({\n description: 'Valid time in ISO format',\n }),\n);\n\n/**\n * Format: 2018-11-13T20:20:39+00:00\n */\nexport const DateTime = /* Schema.transformOrFail(Schema.String, SimpleDateTime, {\n strict: false,\n decode: (str, _, ast) => {\n const [date, time] = str.split('T');\n if (!isValidDateFormat(date)) {\n return ParseResult.fail(new ParseResult.Type(ast, date, 'Expected YYYY-MM-DD format'));\n }\n if (!isValidDate(date)) {\n return ParseResult.fail(new ParseResult.Type(ast, date, 'Invalid date'));\n }\n if (!isValidTimeFormat(time)) {\n return ParseResult.fail(new ParseResult.Type(ast, str, 'Expected HH:mm:ss format'));\n }\n\n const [year, month, day] = date.split('-').map(Number);\n const [hours, minutes, seconds] = time.split(':').map(Number);\n return ParseResult.succeed({ year, month, day, hours, minutes, seconds });\n },\n encode: (datetime) => {\n return ParseResult.succeed(\n [\n [\n datetime.year.toString().padStart(4, '0'),\n datetime.month.toString().padStart(2, '0'),\n datetime.day.toString().padStart(2, '0'),\n ].join('-'),\n [\n datetime.hours.toString().padStart(2, '0'),\n datetime.minutes.toString().padStart(2, '0'),\n datetime.seconds.toString().padStart(2, '0'),\n ].join(':'),\n ].join('T'),\n );\n },\n}) */ Schema.String.pipe(\n FormatAnnotation.set(TypeFormat.DateTime),\n Schema.annotations({\n description: 'Valid date and time in ISO format',\n }),\n);\n\n/**\n * https://datatracker.ietf.org/doc/html/rfc3339#appendix-A\n */\n// TODO(burdon): Define duration type.\nexport const Duration = Schema.String.pipe(\n FormatAnnotation.set(TypeFormat.Duration),\n Schema.annotations({\n description: 'Duration in ISO 8601 format',\n [SchemaAST.ExamplesAnnotationId]: ['1h', '3D'],\n }),\n);\n\n//\n// Utils\n//\n\n// YYYY-MM-DD\nconst DATE_REGEX = /^\\d{4}-\\d{2}-\\d{2}$/;\n\nconst _isValidDateFormat = (str: string) => DATE_REGEX.test(str);\n\nconst _isValidDate = (str: string) => {\n const date = new Date(str);\n return !isNaN(date.getTime()) && date.toISOString().startsWith(str);\n};\n\n// HH:mm:ss\nconst TIME_REGEX = /^([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d)$/;\n\nconst _isValidTimeFormat = (str: string) => TIME_REGEX.test(str);\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { clamp } from '@dxos/util';\n\nimport { FormatAnnotation, TypeFormat } from './types';\n\n/**\n * GeoJSON Format\n * https://datatracker.ietf.org/doc/html/rfc7946\n * https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.1\n * https://en.wikipedia.org/wiki/Geographic_coordinate_system\n * https://geojson.org\n * {\n * \"type\": \"Point\",\n * \"coordinates\": [0, 51.47] // [longitude, latitude]\n * }\n * Note: optional third element for altitude.\n */\n/** Decimal places retained for stored coordinates (~1.1cm at the equator). */\nexport const GEO_PRECISION = 7;\n\nconst roundCoordinate = (value: number): number => {\n const factor = 10 ** GEO_PRECISION;\n return Math.round(value * factor) / factor;\n};\n\n/** Longitude/latitude clamped to range and rounded to {@link GEO_PRECISION} decimal places. */\nconst Coordinate = (min: number, max: number, title: string) =>\n Schema.transform(Schema.Number.pipe(Schema.clamp(min, max)), Schema.Number, {\n strict: true,\n decode: roundCoordinate,\n encode: roundCoordinate,\n }).annotations({ title });\n\nexport const GeoPoint = Schema.Tuple(\n Coordinate(-180, 180, 'Longitude'),\n Coordinate(-90, 90, 'Latitude'),\n Schema.optionalElement(Schema.Number).annotations({\n title: 'Height ASL (m)',\n }),\n).pipe(\n FormatAnnotation.set(TypeFormat.GeoPoint),\n Schema.annotations({\n title: 'GeoPoint',\n description: 'GeoJSON Position',\n }),\n);\n\nexport type GeoPoint = Schema.Schema.Type<typeof GeoPoint>;\n\nexport type GeoLocation = {\n longitude: number;\n latitude: number;\n height?: number;\n};\n\n/**\n * Geolocation utilities for working with GeoPoint format.\n */\nexport namespace GeoLocation {\n /**\n * Convert latitude and longitude to GeoPoint (GeoJSON format [longitude, latitude, height?]).\n * Clamps values to valid ranges: latitude [-90, 90], longitude [-180, 180].\n */\n export const toGeoPoint = ({ longitude, latitude, height }: GeoLocation): GeoPoint => {\n // TODO(ZaymonFC): Use schema validation instead of doing this manually.\n // Clamp + round to match the `Format.GeoPoint` decode/encode path so both produce identical tuples.\n const clampedLongitude = roundCoordinate(clamp(longitude, -180, 180));\n const clampedLatitude = roundCoordinate(clamp(latitude, -90, 90));\n return height !== undefined ? [clampedLongitude, clampedLatitude, height] : [clampedLongitude, clampedLatitude];\n };\n\n /**\n * Extract latitude and longitude from GeoPoint (GeoJSON format [longitude, latitude, height?]).\n */\n export const fromGeoPoint = (geoPoint: GeoPoint | undefined): GeoLocation => {\n if (!geoPoint) {\n return { longitude: 0, latitude: 0 };\n }\n\n const result: GeoLocation = {\n longitude: geoPoint[0],\n latitude: geoPoint[1],\n };\n\n // Add height if defined.\n if (geoPoint[2] !== undefined) {\n result.height = geoPoint[2];\n }\n\n return result;\n };\n}\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { FormatAnnotation, TypeFormat } from './types';\n\n/**\n * Email address (RFC 5321)\n * https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.2\n */\nexport const Email = Schema.String.pipe(\n Schema.pattern(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/),\n FormatAnnotation.set(TypeFormat.Email),\n Schema.annotations({\n title: 'Email',\n description: 'Email address',\n }),\n);\n\n/**\n *\n */\n// TODO(burdon): Implement.\nexport const Formula = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Formula));\n\n/**\n *\n */\n// TODO(burdon): Implement.\nexport const Hostname = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Hostname));\n\n/**\n * Regex\n * https://json-schema.org/understanding-json-schema/reference/regular_expressions\n * https://ecma-international.org/publications-and-standards/standards/ecma-262\n */\n// TODO(burdon): Implement.\nexport const Regex = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Regex));\n\n/**\n * Multi-line text.\n */\nexport const Text = Schema.String.pipe(FormatAnnotation.set(TypeFormat.Text));\n\n/**\n * https://datatracker.ietf.org/doc/html/rfc3986#section-1.1.3\n */\nexport const URL = Schema.String.pipe(\n Schema.pattern(/^(\\w+?:\\/\\/)?([\\da-z.-]+)\\.([a-z.]{2,6})([/\\w .-]*)*\\/?$/i),\n FormatAnnotation.set(TypeFormat.URL),\n Schema.annotations({\n title: 'URL',\n description: 'URL',\n }),\n);\n\n/**\n * UUID (RFC 4122)\n * https://datatracker.ietf.org/doc/html/rfc4122\n */\nexport const UUID = Schema.UUID.pipe(\n FormatAnnotation.set(TypeFormat.UUID),\n Schema.annotations({\n [SchemaAST.ExamplesAnnotationId]: ['3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a'],\n }),\n);\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Keys from '@dxos/keys';\n\nimport * as DateUtil from './date';\nimport * as NumberUtil from './number';\nimport * as ObjectUtil from './object';\nimport * as StringUtil from './string';\nimport { TypeFormat as TypeFormat$ } from './types';\n\n// TODO(burdon): Media encoding.\n// - https://json-schema.org/understanding-json-schema/reference/non_json_data\n\n/**\n * Formats.\n * https://json-schema.org/understanding-json-schema/reference/string#built-in-formats\n * NOTE: A JSON Schema validator will ignore any format type that it does not understand.\n */\n// TODO(burdon): Add fields for `examples`, `message`, etc.\nexport namespace Format {\n export import TypeFormat = TypeFormat$;\n\n // String\n export const DXN = Keys.DXN.Schema;\n export const Email = StringUtil.Email;\n export const Formula = StringUtil.Formula;\n export const Hostname = StringUtil.Hostname;\n export const Regex = StringUtil.Regex;\n export const URL = StringUtil.URL;\n export const UUID = Schema.UUID;\n\n // Numbers\n // TODO(burdon): BigInt.\n export const Currency = NumberUtil.Currency;\n export const Integer = NumberUtil.Integer;\n export const Percent = NumberUtil.Percent;\n export const Timestamp = NumberUtil.Timestamp;\n\n // Dates and times\n export const Date = DateUtil.DateOnly;\n export const DateTime = DateUtil.DateTime;\n export const Duration = DateUtil.Duration;\n export const Time = DateUtil.TimeOnly;\n\n // Objects\n export const GeoPoint = ObjectUtil.GeoPoint;\n export type GeoPoint = ObjectUtil.GeoPoint; // TODO(burdon): Export types.\n}\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\n/**\n * Schema for a single select option. Used to define choices in a {single|multi}-select field.\n */\nexport const SelectOption = Schema.Struct({\n /** Stable identifier for the option. */\n id: Schema.NonEmptyString,\n title: Schema.String,\n /** Color palette used for visual styling. */\n color: Schema.String,\n});\n\nexport type SelectOption = Schema.Schema.Type<typeof SelectOption>;\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,IAAa,aAAa,OAAO,OAAO;CACtC,MAAM,OAAO,OAAO,KAAK,OAAO,QAAQ,MAAM,IAAI,CAAC;CACnD,OAAO,OAAO,OAAO,KAAK,OAAO,QAAQ,GAAG,EAAE,CAAC;CAC/C,KAAK,OAAO,OAAO,KAAK,OAAO,QAAQ,GAAG,EAAE,CAAC;AAC/C,CAAC;AAID,IAAa,gBAAgB,UAA4B;CACvD,MAAM,KAAK,eAAe;CAC1B,OAAO,KAAK,YAAY,IAAI;CAC5B,KAAK,KAAK,WAAW;AACvB;;;;AAKA,IAAa,aAAa,OAAO,OAAO;CACtC,OAAO,OAAO,OAAO,KAAK,OAAO,QAAQ,GAAG,EAAE,CAAC;CAC/C,SAAS,OAAO,OAAO,KAAK,OAAO,QAAQ,GAAG,EAAE,CAAC;CACjD,SAAS,OAAO,OAAO,KAAK,OAAO,QAAQ,GAAG,EAAE,CAAC;AACnD,CAAC;AAID,IAAa,gBAAgB,UAA4B;CACvD,OAAO,KAAK,YAAY;CACxB,SAAS,KAAK,cAAc;CAC5B,SAAS,KAAK,cAAc;AAC9B;;;;AAKA,IAAa,iBAAiB,OAAO,OAAO,YAAY,UAAU;AAIlE,IAAa,oBAAoB,UA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AQ;CACR,QAAA,UAAU;CACV,QAAA,WAAW;CACX,QAAA,QAAQ;CACR,QAAA,MAAM;CACN,QAAA,OAAO,OAAO;CAId,QAAA,WAAW;CACX,QAAA,UAAU;CACV,QAAA,UAAU;CACV,QAAA,YAAY;CAGZ,QAAA,OAAO;CACP,QAAA,WAAW;CACX,QAAA,WAAW;CACX,QAAA,OAAO;CAGP,QAAA,WAAW;GAE1B,WAAA,SAAA,CAAA,EAAA;;;;;;AC1CA,IAAa,eAAe,OAAO,OAAO;;CAExC,IAAI,OAAO;CACX,OAAO,OAAO;;CAEd,OAAO,OAAO;AAChB,CAAC"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
|
+
import { G as HiddenAnnotation, L as FormInputAnnotation, q as IconAnnotation } from "./chunk-Database.mjs";
|
|
3
|
+
import { l as JsonSchemaType } from "./chunk-json-schema.mjs";
|
|
4
|
+
import { getSchema, makeObject } from "./Type.mjs";
|
|
5
|
+
import { Ref } from "./Ref.mjs";
|
|
6
|
+
import { Unknown, instanceOf, make as make$2 } from "./Obj.mjs";
|
|
7
|
+
import { nothing } from "./Filter.mjs";
|
|
8
|
+
import { select } from "./Query.mjs";
|
|
9
|
+
import { Feed } from "./Feed.mjs";
|
|
10
|
+
import { QueryAST, QueryAST as QueryAST$1 } from "@dxos/echo-protocol";
|
|
11
|
+
import { DXN, DXN as DXN$1, EID, EID as EID$1, PublicKey, URI as URI$1 } from "@dxos/keys";
|
|
12
|
+
import { pipe } from "effect/Function";
|
|
13
|
+
import * as Schema from "effect/Schema";
|
|
14
|
+
import { SchemaEx } from "@dxos/effect";
|
|
15
|
+
import * as Predicate from "effect/Predicate";
|
|
16
|
+
//#region src/Aggregate.ts
|
|
17
|
+
var Aggregate_exports = /* @__PURE__ */ __exportAll({
|
|
18
|
+
AggregateTypeId: () => AggregateTypeId,
|
|
19
|
+
count: () => count,
|
|
20
|
+
group: () => group,
|
|
21
|
+
items: () => items,
|
|
22
|
+
max: () => max,
|
|
23
|
+
min: () => min
|
|
24
|
+
});
|
|
25
|
+
var AggregateTypeId = "~@dxos/echo/Aggregate";
|
|
26
|
+
var AggregateClass = class AggregateClass {
|
|
27
|
+
spec;
|
|
28
|
+
static "variance" = {};
|
|
29
|
+
static is(value) {
|
|
30
|
+
return typeof value === "object" && value !== null && "~@dxos/echo/Aggregate" in value;
|
|
31
|
+
}
|
|
32
|
+
constructor(spec) {
|
|
33
|
+
this.spec = spec;
|
|
34
|
+
}
|
|
35
|
+
[AggregateTypeId] = AggregateClass.variance;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Group members by a scalar property. The record key names the result field carrying the coerced
|
|
39
|
+
* group-key value; multiple `group` entries form a composite key. Members whose property is missing,
|
|
40
|
+
* `null`, `undefined`, or non-scalar group under the `null` key, so the field value is `T[K] | null`.
|
|
41
|
+
*/
|
|
42
|
+
var group = (property) => new AggregateClass({
|
|
43
|
+
kind: "group",
|
|
44
|
+
property
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Aggregate the maximum of a scalar property across the group's members.
|
|
48
|
+
* `T` is inferred from the `Query.aggregate` context, so `property` is checked against the query's
|
|
49
|
+
* element type (like {@link Order.property}).
|
|
50
|
+
*/
|
|
51
|
+
var max = (property) => new AggregateClass({
|
|
52
|
+
kind: "max",
|
|
53
|
+
property
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Aggregate the minimum of a scalar property across the group's members.
|
|
57
|
+
*/
|
|
58
|
+
var min = (property) => new AggregateClass({
|
|
59
|
+
kind: "min",
|
|
60
|
+
property
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Collect the group's members, optionally ordered by `order` and capped to `limit` per group.
|
|
64
|
+
* Opt-in — groups carry no members unless this aggregate is declared.
|
|
65
|
+
*
|
|
66
|
+
* `order` is this aggregate's own per-group ordering — independent of any `orderBy` elsewhere in
|
|
67
|
+
* the query, which orders the whole input stream (and, following `aggregate`, the resulting
|
|
68
|
+
* groups), not this aggregate's member selection. Without `order`, members keep whatever order
|
|
69
|
+
* they arrived in from a preceding `orderBy` (unspecified if there is none), so a per-group
|
|
70
|
+
* top-`limit` moved position in the chain would silently change; declaring `order` here makes the
|
|
71
|
+
* ordering explicit and local to this aggregate regardless of where it sits.
|
|
72
|
+
*/
|
|
73
|
+
var items = (options) => new AggregateClass({
|
|
74
|
+
kind: "items",
|
|
75
|
+
limit: options?.limit,
|
|
76
|
+
order: options?.order?.map((order) => order.ast)
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Count the group's members. Opt-in — groups carry no count unless this aggregate is declared.
|
|
80
|
+
*/
|
|
81
|
+
var count = () => new AggregateClass({ kind: "count" });
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/Hypergraph.ts
|
|
84
|
+
var Hypergraph_exports = /* @__PURE__ */ __exportAll({});
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/Json.ts
|
|
87
|
+
var Json_exports = /* @__PURE__ */ __exportAll({ createRefReplacer: () => createRefReplacer });
|
|
88
|
+
var isEncodedRef = (value) => typeof value === "object" && value !== null && Object.keys(value).length === 1 && typeof value["/"] === "string";
|
|
89
|
+
var toJson = (obj) => typeof obj.toJSON === "function" ? obj.toJSON() : obj;
|
|
90
|
+
/**
|
|
91
|
+
* Returns a {@link JsonReplacer} that inlines ECHO ref objects (`{ "/": "echo:..." }`) up to
|
|
92
|
+
* `depth` ref hops. Beyond that depth refs are left in their encoded form.
|
|
93
|
+
*
|
|
94
|
+
* Implemented as a per-call `JSON.stringify` replacer (not a one-shot tree walk at root) so it
|
|
95
|
+
* composes with wrappers like `safeStringify` that intercept the root call. JSON.stringify
|
|
96
|
+
* already drives the recursion; we only need to (a) detect a ref at the current callback,
|
|
97
|
+
* (b) resolve and return the target if hop budget remains, and (c) tag the returned object
|
|
98
|
+
* with its hop count so children know how far in they are.
|
|
99
|
+
*
|
|
100
|
+
* The hop count is tracked per-object via a `WeakMap`: a ref-resolved target's children inherit
|
|
101
|
+
* `parentHops + 1`; a regular intermediate object's children inherit `parentHops`. This makes the
|
|
102
|
+
* budget count *ref hops*, not tree depth — a ref deep in a tree still resolves once when
|
|
103
|
+
* `depth >= 1`.
|
|
104
|
+
*
|
|
105
|
+
* Note: ECHO objects' `toJSON` runs before the replacer is invoked, so by the time we see a
|
|
106
|
+
* value refs are already encoded as `{ "/": "dxn:..." }`.
|
|
107
|
+
*/
|
|
108
|
+
var createRefReplacer = ({ db, depth = 1 }) => {
|
|
109
|
+
const hops = /* @__PURE__ */ new WeakMap();
|
|
110
|
+
return function(key, value) {
|
|
111
|
+
const parentHops = this && typeof this === "object" ? hops.get(this) ?? 0 : 0;
|
|
112
|
+
if (isEncodedRef(value)) {
|
|
113
|
+
if (parentHops >= depth) return value;
|
|
114
|
+
const dxnString = value["/"];
|
|
115
|
+
if (!dxnString.startsWith("dxn:") && !dxnString.startsWith("echo:")) return value;
|
|
116
|
+
let echoUri;
|
|
117
|
+
try {
|
|
118
|
+
const parsed = EID.tryParse(dxnString);
|
|
119
|
+
echoUri = parsed ? EID.getEntityId(parsed) : void 0;
|
|
120
|
+
} catch {
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
if (!echoUri) return value;
|
|
124
|
+
const target = db.getObjectById(echoUri);
|
|
125
|
+
if (!target) return value;
|
|
126
|
+
const encoded = toJson(target);
|
|
127
|
+
if (encoded != null && typeof encoded === "object") hops.set(encoded, parentHops + 1);
|
|
128
|
+
return encoded;
|
|
129
|
+
}
|
|
130
|
+
if (value != null && typeof value === "object") hops.set(value, parentHops);
|
|
131
|
+
return value;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/Collection.ts
|
|
136
|
+
var Collection_exports = /* @__PURE__ */ __exportAll({
|
|
137
|
+
Collection: () => Collection,
|
|
138
|
+
isCollection: () => isCollection,
|
|
139
|
+
make: () => make$1
|
|
140
|
+
});
|
|
141
|
+
/**
|
|
142
|
+
* A an ordered set of objects.
|
|
143
|
+
*/
|
|
144
|
+
var Collection = class extends makeObject(DXN.make("org.dxos.type.collection", "0.1.0"))(Schema.Struct({
|
|
145
|
+
name: Schema.String.pipe(Schema.optional),
|
|
146
|
+
objects: Schema.Array(Ref(Unknown)).pipe(FormInputAnnotation.set(false))
|
|
147
|
+
}).pipe(IconAnnotation.set({
|
|
148
|
+
icon: "ph--folder--regular",
|
|
149
|
+
hue: "indigo"
|
|
150
|
+
}))) {};
|
|
151
|
+
var make$1 = (props = {}) => make$2(Collection, {
|
|
152
|
+
objects: [],
|
|
153
|
+
...props
|
|
154
|
+
});
|
|
155
|
+
var isCollection = instanceOf(Collection);
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/View.ts
|
|
158
|
+
var View_exports = /* @__PURE__ */ __exportAll({
|
|
159
|
+
FieldSchema: () => FieldSchema,
|
|
160
|
+
KeyValueProps: () => KeyValueProps,
|
|
161
|
+
Projection: () => Projection,
|
|
162
|
+
View: () => View,
|
|
163
|
+
createFieldId: () => createFieldId,
|
|
164
|
+
make: () => make
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
167
|
+
* Stored field metadata (e.g., for UX).
|
|
168
|
+
*/
|
|
169
|
+
var FieldSchema = Schema.Struct({
|
|
170
|
+
id: Schema.String,
|
|
171
|
+
path: SchemaEx.JsonPath,
|
|
172
|
+
visible: Schema.optional(Schema.Boolean),
|
|
173
|
+
referencePath: Schema.optional(SchemaEx.JsonPath)
|
|
174
|
+
});
|
|
175
|
+
var KeyValueProps = Schema.Record({
|
|
176
|
+
key: Schema.String,
|
|
177
|
+
value: Schema.Any
|
|
178
|
+
});
|
|
179
|
+
var createFieldId = () => PublicKey.random().truncate();
|
|
180
|
+
var Projection = Schema.Struct({
|
|
181
|
+
/**
|
|
182
|
+
* Optional schema override used to customize the underlying schema.
|
|
183
|
+
*/
|
|
184
|
+
schema: JsonSchemaType.pipe(Schema.optional),
|
|
185
|
+
/**
|
|
186
|
+
* UX metadata associated with displayed fields (in table, form, etc.)
|
|
187
|
+
*/
|
|
188
|
+
fields: Schema.Array(FieldSchema),
|
|
189
|
+
/**
|
|
190
|
+
* The id for the field used to pivot the view.
|
|
191
|
+
* E.g., the field to use for kanban columns or the field to use for map coordinates.
|
|
192
|
+
*/
|
|
193
|
+
pivotFieldId: Schema.String.pipe(Schema.optional)
|
|
194
|
+
});
|
|
195
|
+
/**
|
|
196
|
+
* Views are generated or user-defined projections of a schema's properties.
|
|
197
|
+
* They are used to configure the visual representation of the data.
|
|
198
|
+
*/
|
|
199
|
+
var View = class extends makeObject(DXN.make("org.dxos.type.view", "0.1.0"))(Schema.Struct({
|
|
200
|
+
/**
|
|
201
|
+
* Query used to retrieve data.
|
|
202
|
+
* Can be a user-provided query grammar string or a query AST.
|
|
203
|
+
*/
|
|
204
|
+
query: Schema.Struct({
|
|
205
|
+
raw: Schema.optional(Schema.String),
|
|
206
|
+
ast: QueryAST.Query
|
|
207
|
+
}),
|
|
208
|
+
/**
|
|
209
|
+
* Projection of the data returned from the query.
|
|
210
|
+
*/
|
|
211
|
+
projection: Projection
|
|
212
|
+
}).pipe(HiddenAnnotation.set(true), IconAnnotation.set({
|
|
213
|
+
icon: "ph--funnel--regular",
|
|
214
|
+
hue: "green"
|
|
215
|
+
}))) {};
|
|
216
|
+
var make = (props) => {
|
|
217
|
+
return make$2(View, {
|
|
218
|
+
query: { ast: select(nothing()).ast },
|
|
219
|
+
projection: { fields: [] },
|
|
220
|
+
...props
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/Dataset.ts
|
|
225
|
+
var Dataset_exports = /* @__PURE__ */ __exportAll({
|
|
226
|
+
Dataset: () => Dataset,
|
|
227
|
+
isDataset: () => isDataset
|
|
228
|
+
});
|
|
229
|
+
var Dataset = Schema.Union(getSchema(Feed), getSchema(Collection), getSchema(View));
|
|
230
|
+
var isDataset = pipe(instanceOf(Feed), Predicate.or(instanceOf(Collection)), Predicate.or(instanceOf(View)));
|
|
231
|
+
//#endregion
|
|
232
|
+
export { Dataset_exports as a, Json_exports as c, URI$1 as i, Hypergraph_exports as l, EID$1 as n, View_exports as o, QueryAST$1 as r, Collection_exports as s, DXN$1 as t, Aggregate_exports as u };
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=chunk-src.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-src.mjs","names":[],"sources":["../../src/Aggregate.ts","../../src/Hypergraph.ts","../../src/Json.ts","../../src/Collection.ts","../../src/View.ts","../../src/Dataset.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as EffectTypes from 'effect/Types';\n\nimport type { QueryAST } from '@dxos/echo-protocol';\n\nimport type * as Order from './Order';\nimport type * as Query from './Query';\n\n/**\n * The aggregate spec sans name; the name is supplied by the `Query.aggregate` record key. A tagged\n * union per kind so `property`/`limit`/`order` are present exactly when the kind uses them (no\n * unused optional fields to guard against at read sites).\n */\nexport type Spec =\n | { kind: 'group'; property: string }\n | { kind: 'max'; property: string }\n | { kind: 'min'; property: string }\n | { kind: 'items'; limit?: number; order?: readonly QueryAST.Order[] }\n | { kind: 'count' };\n\nexport const AggregateTypeId = '~@dxos/echo/Aggregate' as const;\nexport type AggregateTypeId = typeof AggregateTypeId;\n\n/**\n * A per-group aggregate declaration, materialised as a top-level field on the flat result record\n * `Query.aggregate` produces and orderable via a following `orderBy(Order.property(name))`. Name it\n * via the record passed to `Query.aggregate({ name: Aggregate.max('created') })`.\n *\n * `T` is the query's element type (so a reduced/grouped property is checked against it); `V` is the\n * value the aggregate produces. {@link group} entries define the grouping keys; a record with no\n * `group` entries aggregates the entire input into a single row.\n */\nexport interface Aggregate<T, V> {\n readonly [AggregateTypeId]: { element: T; value: V };\n\n spec: Spec;\n}\n\nexport type Any = Aggregate<any, any>;\n\n/** Extracts the value type a {@link Aggregate} produces. */\nexport type ValueOf<A> = A extends Aggregate<any, infer V> ? V : never;\n\n/** Computes the flat result type of `Query.aggregate(aggregates)` for a given aggregate record `A`. */\nexport type AggregationResult<A extends Record<string, Any>> = EffectTypes.Simplify<\n Query.AggregateResult & { readonly [N in keyof A]: ValueOf<A[N]> }\n>;\n\nclass AggregateClass<T, V> implements Aggregate<T, V> {\n private static 'variance': Aggregate<any, any>[AggregateTypeId] = {} as Aggregate<any, any>[AggregateTypeId];\n\n static is(value: unknown): value is Any {\n return typeof value === 'object' && value !== null && AggregateTypeId in value;\n }\n\n constructor(public readonly spec: Spec) {}\n\n [AggregateTypeId] = AggregateClass.variance as Aggregate<T, V>[AggregateTypeId];\n}\n\n/**\n * Group members by a scalar property. The record key names the result field carrying the coerced\n * group-key value; multiple `group` entries form a composite key. Members whose property is missing,\n * `null`, `undefined`, or non-scalar group under the `null` key, so the field value is `T[K] | null`.\n */\nexport const group = <T, K extends keyof T & string>(property: K): Aggregate<T, T[K] | null> =>\n new AggregateClass({ kind: 'group', property });\n\n/**\n * Aggregate the maximum of a scalar property across the group's members.\n * `T` is inferred from the `Query.aggregate` context, so `property` is checked against the query's\n * element type (like {@link Order.property}).\n */\nexport const max = <T, K extends keyof T & string>(property: K): Aggregate<T, T[K] | null> =>\n new AggregateClass({ kind: 'max', property });\n\n/**\n * Aggregate the minimum of a scalar property across the group's members.\n */\nexport const min = <T, K extends keyof T & string>(property: K): Aggregate<T, T[K] | null> =>\n new AggregateClass({ kind: 'min', property });\n\n/**\n * Collect the group's members, optionally ordered by `order` and capped to `limit` per group.\n * Opt-in — groups carry no members unless this aggregate is declared.\n *\n * `order` is this aggregate's own per-group ordering — independent of any `orderBy` elsewhere in\n * the query, which orders the whole input stream (and, following `aggregate`, the resulting\n * groups), not this aggregate's member selection. Without `order`, members keep whatever order\n * they arrived in from a preceding `orderBy` (unspecified if there is none), so a per-group\n * top-`limit` moved position in the chain would silently change; declaring `order` here makes the\n * ordering explicit and local to this aggregate regardless of where it sits.\n */\nexport const items = <T>(options?: { limit?: number; order?: Order.Any[] }): Aggregate<T, T[]> =>\n new AggregateClass({ kind: 'items', limit: options?.limit, order: options?.order?.map((order) => order.ast) });\n\n/**\n * Count the group's members. Opt-in — groups carry no count unless this aggregate is declared.\n */\nexport const count = <T>(): Aggregate<T, number> => new AggregateClass({ kind: 'count' });\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { type CleanupFn } from '@dxos/async';\nimport { type BlobBackend } from '@dxos/echo-protocol';\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 * Registers a pluggable blob storage backend under `name`, claiming its declared URI schemes.\n * Registering a scheme already claimed by another backend is an error.\n *\n * @param options.default - When true, `name` becomes the storage used when\n * `Blob.fromBytes`'s `storage` option is omitted.\n * @returns A cleanup function that unregisters the backend.\n */\n registerBlobBackend(name: string, backend: BlobBackend, options?: { default?: boolean }): CleanupFn;\n\n /**\n * Storage name `Blob.fromBytes` uses when its `storage` option is omitted. Starts as `'inline'`;\n * reflects the most recent `registerBlobBackend(name, backend, { default: true })` call.\n */\n get defaultBlobStorage(): string;\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 */\n// TODO(dmaretskyi): is this used anywhere?\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(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