@dxos/echo 0.8.2-main.2f9c567 → 0.8.2-main.30e4dbb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +19 -4
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +16 -1
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +19 -4
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/experimental/database.d.ts.map +1 -0
- package/dist/types/src/experimental/index.d.ts +1 -0
- package/dist/types/src/experimental/index.d.ts.map +1 -0
- package/dist/types/src/experimental/queue.d.ts.map +1 -0
- package/dist/types/src/experimental/space.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/query/api.d.ts +183 -0
- package/dist/types/src/query/api.d.ts.map +1 -0
- package/dist/types/src/query/ast.d.ts +146 -0
- package/dist/types/src/query/ast.d.ts.map +1 -0
- package/dist/types/src/query/query.test.d.ts +2 -0
- package/dist/types/src/query/query.test.d.ts.map +1 -0
- package/dist/types/src/type/Relation.d.ts +16 -0
- package/dist/types/src/type/Relation.d.ts.map +1 -0
- package/dist/types/src/{api/type.d.ts → type/Type.d.ts} +1 -1
- package/dist/types/src/type/Type.d.ts.map +1 -0
- package/dist/types/src/type/Type.test.d.ts +2 -0
- package/dist/types/src/type/Type.test.d.ts.map +1 -0
- package/dist/types/src/type/index.d.ts +3 -0
- package/dist/types/src/type/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/{api → experimental}/index.ts +0 -5
- package/src/index.ts +4 -1
- package/src/query/api.ts +498 -0
- package/src/query/ast.ts +179 -0
- package/src/query/query.test.ts +146 -0
- package/src/type/Relation.ts +17 -0
- package/src/{api.test.ts → type/Type.test.ts} +38 -19
- package/src/{api/type.ts → type/Type.ts} +1 -1
- package/src/type/index.ts +6 -0
- package/dist/types/src/api/database.d.ts.map +0 -1
- package/dist/types/src/api/index.d.ts +0 -4
- package/dist/types/src/api/index.d.ts.map +0 -1
- package/dist/types/src/api/queue.d.ts.map +0 -1
- package/dist/types/src/api/space.d.ts.map +0 -1
- package/dist/types/src/api/type.d.ts.map +0 -1
- package/dist/types/src/api.test.d.ts +0 -2
- package/dist/types/src/api.test.d.ts.map +0 -1
- /package/dist/types/src/{api → experimental}/database.d.ts +0 -0
- /package/dist/types/src/{api → experimental}/queue.d.ts +0 -0
- /package/dist/types/src/{api → experimental}/space.d.ts +0 -0
- /package/src/{api → experimental}/database.ts +0 -0
- /package/src/{api → experimental}/queue.ts +0 -0
- /package/src/{api → experimental}/space.ts +0 -0
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
2
7
|
|
|
3
|
-
// packages/core/echo/echo/src/
|
|
4
|
-
import { Format } from "@dxos/echo-schema";
|
|
8
|
+
// packages/core/echo/echo/src/index.ts
|
|
9
|
+
import { Format, FormatEnum } from "@dxos/echo-schema";
|
|
5
10
|
import { DXN } from "@dxos/keys";
|
|
6
11
|
|
|
7
|
-
// packages/core/echo/echo/src/
|
|
12
|
+
// packages/core/echo/echo/src/type/Type.ts
|
|
8
13
|
import { EchoObject, EntityKind, Expando as Expando$, ObjectId as ObjectId$, Ref as Ref$, SpaceIdSchema as SpaceIdSchema$, getTypeAnnotation, getSchema as getSchema$, getSchemaDXN, getSchemaTypename, getSchemaVersion, isInstanceOf, toJsonSchema as toJsonSchema$ } from "@dxos/echo-schema";
|
|
9
14
|
import { invariant } from "@dxos/invariant";
|
|
10
15
|
import { SpaceId as SpaceId$ } from "@dxos/keys";
|
|
11
16
|
import { live as live$ } from "@dxos/live-object";
|
|
12
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/
|
|
17
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/type/Type.ts";
|
|
13
18
|
var Type;
|
|
14
19
|
(function(Type2) {
|
|
15
20
|
Type2.SpaceIdSchema = SpaceIdSchema$;
|
|
@@ -41,9 +46,19 @@ var Type;
|
|
|
41
46
|
Type2.getVersion = getSchemaVersion;
|
|
42
47
|
Type2.toJsonSchema = toJsonSchema$;
|
|
43
48
|
})(Type || (Type = {}));
|
|
49
|
+
|
|
50
|
+
// packages/core/echo/echo/src/type/Relation.ts
|
|
51
|
+
var Relation_exports = {};
|
|
52
|
+
__export(Relation_exports, {
|
|
53
|
+
def: () => def
|
|
54
|
+
});
|
|
55
|
+
import { EchoRelation } from "@dxos/echo-schema";
|
|
56
|
+
var def = EchoRelation;
|
|
44
57
|
export {
|
|
45
58
|
DXN,
|
|
46
59
|
Format,
|
|
60
|
+
FormatEnum,
|
|
61
|
+
Relation_exports as Relation,
|
|
47
62
|
Type
|
|
48
63
|
};
|
|
49
64
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Format", "DXN", "EchoObject", "EntityKind", "Expando", "Expando$", "ObjectId", "ObjectId$", "Ref", "Ref$", "SpaceIdSchema", "SpaceIdSchema$", "getTypeAnnotation", "getSchema", "getSchema$", "getSchemaDXN", "getSchemaTypename", "getSchemaVersion", "isInstanceOf", "toJsonSchema", "toJsonSchema$", "invariant", "SpaceId", "SpaceId$", "live", "live$", "Type", "Kind", "create", "def", "meta", "self", "ref", "make", "getMeta", "instanceOf", "getDXN", "getTypename", "schema", "typename", "getVersion"]
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/type/Type.ts", "../../../src/type/Relation.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format, FormatEnum } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\nexport * from './type';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';\nimport {\n type BaseEchoObject,\n type BaseObject,\n type BaseSchema,\n type EchoSchema,\n EchoObject,\n EntityKind,\n Expando as Expando$,\n type ImmutableSchema,\n type JsonSchemaType,\n ObjectId as ObjectId$,\n Ref as Ref$,\n SpaceIdSchema as SpaceIdSchema$,\n type StoredSchema,\n type TypeMeta,\n getTypeAnnotation,\n getSchema as getSchema$,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n isInstanceOf,\n toJsonSchema as toJsonSchema$,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId as SpaceId$ } from '@dxos/keys';\nimport { live as live$ } from '@dxos/live-object';\n\n// TODO(burdon): Type vs. Ref vs. Relation vs. Object.\n\n/**\n * Type System API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport namespace Type {\n //\n // Keys\n //\n\n export const SpaceIdSchema = SpaceIdSchema$; // TODO(burdon): Reconcile with SpaceId as with ObjectId.\n export const SpaceId = SpaceId$;\n export type SpaceId = SpaceId$;\n\n export const ObjectId = ObjectId$;\n export type ObjectId = ObjectId$;\n\n //\n // Objects\n //\n\n export const Kind = EntityKind;\n export type AnyObject = BaseEchoObject;\n export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;\n\n //\n // Schema\n //\n\n export type JsonSchema = JsonSchemaType;\n\n /**\n * A schema that can be extended with arbitrary properties.\n */\n export const Expando = Expando$;\n export type Expando = Expando$;\n\n // TODO(burdon): Review/remove.\n export type Abstract<T = any> = BaseSchema<T>;\n export type ImmutableType<T> = ImmutableSchema<T>;\n export type MutableType<T> = EchoSchema<T>;\n export type StoredType = StoredSchema;\n\n export const create = live$;\n\n /**\n * Defines an ECHO type.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Organization = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.def({\n * typename: 'example.com/type/Organization',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const def = (meta: TypeMeta) => EchoObject(meta);\n\n //\n // Refs\n //\n\n /**\n * Defines a reference to an ECHO object.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Person = Schema.Struct({\n * name: Schema.String,\n * organization: Type.Ref(Organization),\n * }).pipe(Type.def({\n * typename: 'example.com/type/Person',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);\n\n export const ref = Ref$.make;\n\n //\n // Object utils\n //\n\n export const getMeta = getTypeAnnotation;\n export const getSchema = getSchema$;\n export const instanceOf = isInstanceOf;\n\n //\n // Type utils\n //\n\n // TODO(burdon): Reconcile getDXN and getTypename.\n export const getDXN = getSchemaDXN;\n export const getTypename = (schema: Schema.Schema.AnyNoContext): string => {\n const typename = getSchemaTypename(schema);\n invariant(typename, 'Invalid object');\n return typename;\n };\n export const getVersion = getSchemaVersion;\n export const toJsonSchema = toJsonSchema$;\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { EchoRelation, type RelationSourceTargetRefs } from '@dxos/echo-schema';\n\nexport const def = EchoRelation;\n\n/**\n * Get relation target type.\n */\nexport type Target<A> = A extends RelationSourceTargetRefs<infer T, infer _S> ? T : never;\n\n/**\n * Get relation source type.\n */\nexport type Source<A> = A extends RelationSourceTargetRefs<infer _T, infer S> ? S : never;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,SAASA,QAAQC,kBAAkB;AACnC,SAASC,WAAW;;;ACEpB,SAKEC,YACAC,YACAC,WAAWC,UAGXC,YAAYC,WACZC,OAAOC,MACPC,iBAAiBC,gBAGjBC,mBACAC,aAAaC,YACbC,cACAC,mBACAC,kBACAC,cACAC,gBAAgBC,qBACX;AACP,SAASC,iBAAiB;AAC1B,SAASC,WAAWC,gBAAgB;AACpC,SAASC,QAAQC,aAAa;;;UAUbC,OAAAA;QAKFhB,gBAAgBC;QAChBW,UAAUC;QAGVjB,WAAWC;QAOXoB,OAAOxB;AAYnB,EAAAuB,MACYtB,UAAUC;QASVuB,SAASH;AAerB,EAAAC,MACYG,MAAM,CAACC,SAAmB5B,WAAW4B,IAAAA;AAoBjD,EAAAJ,MACYlB,MAAM,CAAuCuB,SAAYtB,KAA4BsB,IAAAA;QAErFC,MAAMvB,KAAKwB;QAMXC,UAAUtB;QACVC,YAAYC;QACZqB,aAAajB;QAObkB,SAASrB;QACTsB,cAAc,CAACC,WAAAA;AAC1B,UAAMC,WAAWvB,kBAAkBsB,MAAAA;AACnCjB,cAAUkB,UAAU,kBAAA;;;;;;;;;AACpB,WAAOA;EACT;QACaC,aAAavB;QACbE,eAAeC;AAC9B,GApGiBM,SAAAA,OAAAA,CAAAA,EAAAA;;;AC1CjB;;;;AAIA,SAASe,oBAAmD;AAErD,IAAMC,MAAMC;",
|
|
6
|
+
"names": ["Format", "FormatEnum", "DXN", "EchoObject", "EntityKind", "Expando", "Expando$", "ObjectId", "ObjectId$", "Ref", "Ref$", "SpaceIdSchema", "SpaceIdSchema$", "getTypeAnnotation", "getSchema", "getSchema$", "getSchemaDXN", "getSchemaTypename", "getSchemaVersion", "isInstanceOf", "toJsonSchema", "toJsonSchema$", "invariant", "SpaceId", "SpaceId$", "live", "live$", "Type", "Kind", "create", "def", "meta", "self", "ref", "make", "getMeta", "instanceOf", "getDXN", "getTypename", "schema", "typename", "getVersion", "EchoRelation", "def", "EchoRelation"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo/src/
|
|
1
|
+
{"inputs":{"packages/core/echo/echo/src/type/Type.ts":{"bytes":9137,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/type/Relation.ts":{"bytes":1122,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/type/index.ts":{"bytes":683,"imports":[{"path":"packages/core/echo/echo/src/type/Type.ts","kind":"import-statement","original":"./Type"},{"path":"packages/core/echo/echo/src/type/Relation.ts","kind":"import-statement","original":"./Relation"}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":829,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/echo/echo/src/type/index.ts","kind":"import-statement","original":"./type"}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5484},"packages/core/echo/echo/dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["DXN","Format","FormatEnum","Relation","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/index.ts":{"bytesInOutput":90},"packages/core/echo/echo/src/type/Type.ts":{"bytesInOutput":1353},"packages/core/echo/echo/src/type/index.ts":{"bytesInOutput":0},"packages/core/echo/echo/src/type/Relation.ts":{"bytesInOutput":151}},"bytes":2046}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -20,6 +20,8 @@ var node_exports = {};
|
|
|
20
20
|
__export(node_exports, {
|
|
21
21
|
DXN: () => import_keys.DXN,
|
|
22
22
|
Format: () => import_echo_schema.Format,
|
|
23
|
+
FormatEnum: () => import_echo_schema.FormatEnum,
|
|
24
|
+
Relation: () => Relation_exports,
|
|
23
25
|
Type: () => Type
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(node_exports);
|
|
@@ -29,7 +31,13 @@ var import_echo_schema2 = require("@dxos/echo-schema");
|
|
|
29
31
|
var import_invariant = require("@dxos/invariant");
|
|
30
32
|
var import_keys2 = require("@dxos/keys");
|
|
31
33
|
var import_live_object = require("@dxos/live-object");
|
|
32
|
-
var
|
|
34
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
35
|
+
var __defProp2 = Object.defineProperty;
|
|
36
|
+
var __export2 = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/type/Type.ts";
|
|
33
41
|
var Type;
|
|
34
42
|
(function(Type2) {
|
|
35
43
|
Type2.SpaceIdSchema = import_echo_schema2.SpaceIdSchema;
|
|
@@ -61,10 +69,17 @@ var Type;
|
|
|
61
69
|
Type2.getVersion = import_echo_schema2.getSchemaVersion;
|
|
62
70
|
Type2.toJsonSchema = import_echo_schema2.toJsonSchema;
|
|
63
71
|
})(Type || (Type = {}));
|
|
72
|
+
var Relation_exports = {};
|
|
73
|
+
__export2(Relation_exports, {
|
|
74
|
+
def: () => def
|
|
75
|
+
});
|
|
76
|
+
var def = import_echo_schema3.EchoRelation;
|
|
64
77
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
78
|
0 && (module.exports = {
|
|
66
79
|
DXN,
|
|
67
80
|
Format,
|
|
81
|
+
FormatEnum,
|
|
82
|
+
Relation,
|
|
68
83
|
Type
|
|
69
84
|
});
|
|
70
85
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["import_echo_schema", "import_keys", "Type", "SpaceIdSchema", "SpaceIdSchema$", "SpaceId", "SpaceId$", "ObjectId", "ObjectId$", "Kind", "EntityKind", "Expando", "Expando$", "create", "live$", "def", "meta", "EchoObject", "Ref", "self", "Ref$", "ref", "make", "getMeta", "getTypeAnnotation", "getSchema", "getSchema$", "instanceOf", "isInstanceOf", "getDXN", "getSchemaDXN", "getTypename", "schema", "typename", "getSchemaTypename", "invariant", "getVersion", "getSchemaVersion", "toJsonSchema", "toJsonSchema$"]
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/type/Type.ts", "../../../src/type/Relation.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format, FormatEnum } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\nexport * from './type';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';\nimport {\n type BaseEchoObject,\n type BaseObject,\n type BaseSchema,\n type EchoSchema,\n EchoObject,\n EntityKind,\n Expando as Expando$,\n type ImmutableSchema,\n type JsonSchemaType,\n ObjectId as ObjectId$,\n Ref as Ref$,\n SpaceIdSchema as SpaceIdSchema$,\n type StoredSchema,\n type TypeMeta,\n getTypeAnnotation,\n getSchema as getSchema$,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n isInstanceOf,\n toJsonSchema as toJsonSchema$,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId as SpaceId$ } from '@dxos/keys';\nimport { live as live$ } from '@dxos/live-object';\n\n// TODO(burdon): Type vs. Ref vs. Relation vs. Object.\n\n/**\n * Type System API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport namespace Type {\n //\n // Keys\n //\n\n export const SpaceIdSchema = SpaceIdSchema$; // TODO(burdon): Reconcile with SpaceId as with ObjectId.\n export const SpaceId = SpaceId$;\n export type SpaceId = SpaceId$;\n\n export const ObjectId = ObjectId$;\n export type ObjectId = ObjectId$;\n\n //\n // Objects\n //\n\n export const Kind = EntityKind;\n export type AnyObject = BaseEchoObject;\n export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;\n\n //\n // Schema\n //\n\n export type JsonSchema = JsonSchemaType;\n\n /**\n * A schema that can be extended with arbitrary properties.\n */\n export const Expando = Expando$;\n export type Expando = Expando$;\n\n // TODO(burdon): Review/remove.\n export type Abstract<T = any> = BaseSchema<T>;\n export type ImmutableType<T> = ImmutableSchema<T>;\n export type MutableType<T> = EchoSchema<T>;\n export type StoredType = StoredSchema;\n\n export const create = live$;\n\n /**\n * Defines an ECHO type.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Organization = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.def({\n * typename: 'example.com/type/Organization',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const def = (meta: TypeMeta) => EchoObject(meta);\n\n //\n // Refs\n //\n\n /**\n * Defines a reference to an ECHO object.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Person = Schema.Struct({\n * name: Schema.String,\n * organization: Type.Ref(Organization),\n * }).pipe(Type.def({\n * typename: 'example.com/type/Person',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);\n\n export const ref = Ref$.make;\n\n //\n // Object utils\n //\n\n export const getMeta = getTypeAnnotation;\n export const getSchema = getSchema$;\n export const instanceOf = isInstanceOf;\n\n //\n // Type utils\n //\n\n // TODO(burdon): Reconcile getDXN and getTypename.\n export const getDXN = getSchemaDXN;\n export const getTypename = (schema: Schema.Schema.AnyNoContext): string => {\n const typename = getSchemaTypename(schema);\n invariant(typename, 'Invalid object');\n return typename;\n };\n export const getVersion = getSchemaVersion;\n export const toJsonSchema = toJsonSchema$;\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { EchoRelation, type RelationSourceTargetRefs } from '@dxos/echo-schema';\n\nexport const def = EchoRelation;\n\n/**\n * Get relation target type.\n */\nexport type Target<A> = A extends RelationSourceTargetRefs<infer T, infer _S> ? T : never;\n\n/**\n * Get relation source type.\n */\nexport type Source<A> = A extends RelationSourceTargetRefs<infer _T, infer S> ? S : never;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAmC;AACnC,kBAAoB;ACEpB,IAAAA,sBAsBO;AACP,uBAA0B;AAC1B,IAAAC,eAAoC;AACpC,yBAA8B;AC5B9B,IAAAD,sBAA4D;;;;;;;;UDsC3CE,OAAAA;QAKFC,gBAAgBC,oBAAAA;QAChBC,UAAUC,aAAAA;QAGVC,WAAWC,oBAAAA;QAOXC,OAAOC;AAYnBR,QACYS,UAAUC,oBAAAA;QASVC,SAASC,mBAAAA;AAerBZ,QACYa,MAAM,CAACC,aAAmBC,gCAAWD,IAAAA;AAoBjDd,QACYgB,MAAM,CAAuCC,aAAYC,oBAAAA,KAA4BD,IAAAA;QAErFE,MAAMD,oBAAAA,IAAKE;QAMXC,UAAUC;QACVC,YAAYC,oBAAAA;QACZC,aAAaC;QAObC,SAASC;QACTC,cAAc,CAACC,WAAAA;AAC1B,UAAMC,eAAWC,uCAAkBF,MAAAA;AACnCG,oCAAUF,UAAU,kBAAA;;;;;;;;;AACpB,WAAOA;EACT;QACaG,aAAaC;QACbC,eAAeC,oBAAAA;AAC9B,GApGiBrC,SAAAA,OAAAA,CAAAA,EAAAA;AC1CjB,IAAA,mBAAA,CAAA;;;;AAMO,IAAMa,MAAMyB;",
|
|
6
|
+
"names": ["import_echo_schema", "import_keys", "Type", "SpaceIdSchema", "SpaceIdSchema$", "SpaceId", "SpaceId$", "ObjectId", "ObjectId$", "Kind", "EntityKind", "Expando", "Expando$", "create", "live$", "def", "meta", "EchoObject", "Ref", "self", "Ref$", "ref", "make", "getMeta", "getTypeAnnotation", "getSchema", "getSchema$", "instanceOf", "isInstanceOf", "getDXN", "getSchemaDXN", "getTypename", "schema", "typename", "getSchemaTypename", "invariant", "getVersion", "getSchemaVersion", "toJsonSchema", "toJsonSchema$", "EchoRelation"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo/src/
|
|
1
|
+
{"inputs":{"packages/core/echo/echo/src/type/Type.ts":{"bytes":9137,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/type/Relation.ts":{"bytes":1122,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/type/index.ts":{"bytes":683,"imports":[{"path":"packages/core/echo/echo/src/type/Type.ts","kind":"import-statement","original":"./Type"},{"path":"packages/core/echo/echo/src/type/Relation.ts","kind":"import-statement","original":"./Relation"}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":829,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/echo/echo/src/type/index.ts","kind":"import-statement","original":"./type"}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5483},"packages/core/echo/echo/dist/lib/node/index.cjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["DXN","Format","FormatEnum","Relation","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/index.ts":{"bytesInOutput":90},"packages/core/echo/echo/src/type/Type.ts":{"bytesInOutput":1353},"packages/core/echo/echo/src/type/index.ts":{"bytesInOutput":0},"packages/core/echo/echo/src/type/Relation.ts":{"bytesInOutput":151}},"bytes":2013}}}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
2
7
|
|
|
3
|
-
// packages/core/echo/echo/src/
|
|
4
|
-
import { Format } from "@dxos/echo-schema";
|
|
8
|
+
// packages/core/echo/echo/src/index.ts
|
|
9
|
+
import { Format, FormatEnum } from "@dxos/echo-schema";
|
|
5
10
|
import { DXN } from "@dxos/keys";
|
|
6
11
|
|
|
7
|
-
// packages/core/echo/echo/src/
|
|
12
|
+
// packages/core/echo/echo/src/type/Type.ts
|
|
8
13
|
import { EchoObject, EntityKind, Expando as Expando$, ObjectId as ObjectId$, Ref as Ref$, SpaceIdSchema as SpaceIdSchema$, getTypeAnnotation, getSchema as getSchema$, getSchemaDXN, getSchemaTypename, getSchemaVersion, isInstanceOf, toJsonSchema as toJsonSchema$ } from "@dxos/echo-schema";
|
|
9
14
|
import { invariant } from "@dxos/invariant";
|
|
10
15
|
import { SpaceId as SpaceId$ } from "@dxos/keys";
|
|
11
16
|
import { live as live$ } from "@dxos/live-object";
|
|
12
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/
|
|
17
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo/src/type/Type.ts";
|
|
13
18
|
var Type;
|
|
14
19
|
(function(Type2) {
|
|
15
20
|
Type2.SpaceIdSchema = SpaceIdSchema$;
|
|
@@ -41,9 +46,19 @@ var Type;
|
|
|
41
46
|
Type2.getVersion = getSchemaVersion;
|
|
42
47
|
Type2.toJsonSchema = toJsonSchema$;
|
|
43
48
|
})(Type || (Type = {}));
|
|
49
|
+
|
|
50
|
+
// packages/core/echo/echo/src/type/Relation.ts
|
|
51
|
+
var Relation_exports = {};
|
|
52
|
+
__export(Relation_exports, {
|
|
53
|
+
def: () => def
|
|
54
|
+
});
|
|
55
|
+
import { EchoRelation } from "@dxos/echo-schema";
|
|
56
|
+
var def = EchoRelation;
|
|
44
57
|
export {
|
|
45
58
|
DXN,
|
|
46
59
|
Format,
|
|
60
|
+
FormatEnum,
|
|
61
|
+
Relation_exports as Relation,
|
|
47
62
|
Type
|
|
48
63
|
};
|
|
49
64
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Format", "DXN", "EchoObject", "EntityKind", "Expando", "Expando$", "ObjectId", "ObjectId$", "Ref", "Ref$", "SpaceIdSchema", "SpaceIdSchema$", "getTypeAnnotation", "getSchema", "getSchema$", "getSchemaDXN", "getSchemaTypename", "getSchemaVersion", "isInstanceOf", "toJsonSchema", "toJsonSchema$", "invariant", "SpaceId", "SpaceId$", "live", "live$", "Type", "Kind", "create", "def", "meta", "self", "ref", "make", "getMeta", "instanceOf", "getDXN", "getTypename", "schema", "typename", "getVersion"]
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/type/Type.ts", "../../../src/type/Relation.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nexport { Format, FormatEnum } from '@dxos/echo-schema';\nexport { DXN } from '@dxos/keys';\n\nexport * from './type';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Schema } from 'effect';\n\nimport { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';\nimport {\n type BaseEchoObject,\n type BaseObject,\n type BaseSchema,\n type EchoSchema,\n EchoObject,\n EntityKind,\n Expando as Expando$,\n type ImmutableSchema,\n type JsonSchemaType,\n ObjectId as ObjectId$,\n Ref as Ref$,\n SpaceIdSchema as SpaceIdSchema$,\n type StoredSchema,\n type TypeMeta,\n getTypeAnnotation,\n getSchema as getSchema$,\n getSchemaDXN,\n getSchemaTypename,\n getSchemaVersion,\n isInstanceOf,\n toJsonSchema as toJsonSchema$,\n} from '@dxos/echo-schema';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceId as SpaceId$ } from '@dxos/keys';\nimport { live as live$ } from '@dxos/live-object';\n\n// TODO(burdon): Type vs. Ref vs. Relation vs. Object.\n\n/**\n * Type System API.\n *\n * @category api namespace\n * @since 0.9.0\n */\nexport namespace Type {\n //\n // Keys\n //\n\n export const SpaceIdSchema = SpaceIdSchema$; // TODO(burdon): Reconcile with SpaceId as with ObjectId.\n export const SpaceId = SpaceId$;\n export type SpaceId = SpaceId$;\n\n export const ObjectId = ObjectId$;\n export type ObjectId = ObjectId$;\n\n //\n // Objects\n //\n\n export const Kind = EntityKind;\n export type AnyObject = BaseEchoObject;\n export type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;\n\n //\n // Schema\n //\n\n export type JsonSchema = JsonSchemaType;\n\n /**\n * A schema that can be extended with arbitrary properties.\n */\n export const Expando = Expando$;\n export type Expando = Expando$;\n\n // TODO(burdon): Review/remove.\n export type Abstract<T = any> = BaseSchema<T>;\n export type ImmutableType<T> = ImmutableSchema<T>;\n export type MutableType<T> = EchoSchema<T>;\n export type StoredType = StoredSchema;\n\n export const create = live$;\n\n /**\n * Defines an ECHO type.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Organization = Schema.Struct({\n * name: Schema.String,\n * }).pipe(Type.def({\n * typename: 'example.com/type/Organization',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const def = (meta: TypeMeta) => EchoObject(meta);\n\n //\n // Refs\n //\n\n /**\n * Defines a reference to an ECHO object.\n *\n * @example\n * ```ts\n * import { Type } from '@dxos/echo';\n * const Person = Schema.Struct({\n * name: Schema.String,\n * organization: Type.Ref(Organization),\n * }).pipe(Type.def({\n * typename: 'example.com/type/Person',\n * version: '0.1.0',\n * }));\n * ```\n */\n export const Ref = <S extends Schema.Schema.AnyNoContext>(self: S) => Ref$<Schema.Schema.Type<S>>(self);\n\n export const ref = Ref$.make;\n\n //\n // Object utils\n //\n\n export const getMeta = getTypeAnnotation;\n export const getSchema = getSchema$;\n export const instanceOf = isInstanceOf;\n\n //\n // Type utils\n //\n\n // TODO(burdon): Reconcile getDXN and getTypename.\n export const getDXN = getSchemaDXN;\n export const getTypename = (schema: Schema.Schema.AnyNoContext): string => {\n const typename = getSchemaTypename(schema);\n invariant(typename, 'Invalid object');\n return typename;\n };\n export const getVersion = getSchemaVersion;\n export const toJsonSchema = toJsonSchema$;\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { EchoRelation, type RelationSourceTargetRefs } from '@dxos/echo-schema';\n\nexport const def = EchoRelation;\n\n/**\n * Get relation target type.\n */\nexport type Target<A> = A extends RelationSourceTargetRefs<infer T, infer _S> ? T : never;\n\n/**\n * Get relation source type.\n */\nexport type Source<A> = A extends RelationSourceTargetRefs<infer _T, infer S> ? S : never;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,SAASA,QAAQC,kBAAkB;AACnC,SAASC,WAAW;;;ACEpB,SAKEC,YACAC,YACAC,WAAWC,UAGXC,YAAYC,WACZC,OAAOC,MACPC,iBAAiBC,gBAGjBC,mBACAC,aAAaC,YACbC,cACAC,mBACAC,kBACAC,cACAC,gBAAgBC,qBACX;AACP,SAASC,iBAAiB;AAC1B,SAASC,WAAWC,gBAAgB;AACpC,SAASC,QAAQC,aAAa;;;UAUbC,OAAAA;QAKFhB,gBAAgBC;QAChBW,UAAUC;QAGVjB,WAAWC;QAOXoB,OAAOxB;AAYnB,EAAAuB,MACYtB,UAAUC;QASVuB,SAASH;AAerB,EAAAC,MACYG,MAAM,CAACC,SAAmB5B,WAAW4B,IAAAA;AAoBjD,EAAAJ,MACYlB,MAAM,CAAuCuB,SAAYtB,KAA4BsB,IAAAA;QAErFC,MAAMvB,KAAKwB;QAMXC,UAAUtB;QACVC,YAAYC;QACZqB,aAAajB;QAObkB,SAASrB;QACTsB,cAAc,CAACC,WAAAA;AAC1B,UAAMC,WAAWvB,kBAAkBsB,MAAAA;AACnCjB,cAAUkB,UAAU,kBAAA;;;;;;;;;AACpB,WAAOA;EACT;QACaC,aAAavB;QACbE,eAAeC;AAC9B,GApGiBM,SAAAA,OAAAA,CAAAA,EAAAA;;;AC1CjB;;;;AAIA,SAASe,oBAAmD;AAErD,IAAMC,MAAMC;",
|
|
6
|
+
"names": ["Format", "FormatEnum", "DXN", "EchoObject", "EntityKind", "Expando", "Expando$", "ObjectId", "ObjectId$", "Ref", "Ref$", "SpaceIdSchema", "SpaceIdSchema$", "getTypeAnnotation", "getSchema", "getSchema$", "getSchemaDXN", "getSchemaTypename", "getSchemaVersion", "isInstanceOf", "toJsonSchema", "toJsonSchema$", "invariant", "SpaceId", "SpaceId$", "live", "live$", "Type", "Kind", "create", "def", "meta", "self", "ref", "make", "getMeta", "instanceOf", "getDXN", "getTypename", "schema", "typename", "getVersion", "EchoRelation", "def", "EchoRelation"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/echo/echo/src/
|
|
1
|
+
{"inputs":{"packages/core/echo/echo/src/type/Type.ts":{"bytes":9137,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/type/Relation.ts":{"bytes":1122,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/echo/echo/src/type/index.ts":{"bytes":683,"imports":[{"path":"packages/core/echo/echo/src/type/Type.ts","kind":"import-statement","original":"./Type"},{"path":"packages/core/echo/echo/src/type/Relation.ts","kind":"import-statement","original":"./Relation"}],"format":"esm"},"packages/core/echo/echo/src/index.ts":{"bytes":829,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"packages/core/echo/echo/src/type/index.ts","kind":"import-statement","original":"./type"}],"format":"esm"}},"outputs":{"packages/core/echo/echo/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5484},"packages/core/echo/echo/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/live-object","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["DXN","Format","FormatEnum","Relation","Type"],"entryPoint":"packages/core/echo/echo/src/index.ts","inputs":{"packages/core/echo/echo/src/index.ts":{"bytesInOutput":90},"packages/core/echo/echo/src/type/Type.ts":{"bytesInOutput":1353},"packages/core/echo/echo/src/type/index.ts":{"bytesInOutput":0},"packages/core/echo/echo/src/type/Relation.ts":{"bytesInOutput":151}},"bytes":2105}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../../src/experimental/database.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,QAAQ,CAAC,GAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/experimental/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../src/experimental/queue.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,yBAAiB,KAAK,CAAC,GAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../../src/experimental/space.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { type Schema } from 'effect';
|
|
2
|
+
import type { Simplify } from 'effect/Schema';
|
|
3
|
+
import { type Ref } from '@dxos/echo-schema';
|
|
4
|
+
import type * as QueryAST from './ast';
|
|
5
|
+
import type { Relation } from '..';
|
|
6
|
+
export interface Query<T> {
|
|
7
|
+
'~Query': {
|
|
8
|
+
value: T;
|
|
9
|
+
};
|
|
10
|
+
ast: QueryAST.Query;
|
|
11
|
+
/**
|
|
12
|
+
* Filter the current selection based on a filter.
|
|
13
|
+
* @param filter - Filter to select the objects.
|
|
14
|
+
* @returns Query for the selected objects.
|
|
15
|
+
*/
|
|
16
|
+
select(filter: Filter<T>): Query<T>;
|
|
17
|
+
select(props: Filter.Props<T>): Query<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Traverse an outgoing reference.
|
|
20
|
+
* @param key - Property path inside T that is a reference.
|
|
21
|
+
* @returns Query for the target of the reference.
|
|
22
|
+
*/
|
|
23
|
+
reference<K extends RefPropKey<T>>(key: K): Query<Ref.Target<T[K]>>;
|
|
24
|
+
/**
|
|
25
|
+
* Find objects referencing this object.
|
|
26
|
+
* @param target - Schema of the referencing object.
|
|
27
|
+
* @param key - Property path inside the referencing object that is a reference.
|
|
28
|
+
* @returns Query for the referencing objects.
|
|
29
|
+
*/
|
|
30
|
+
referencedBy<S extends Schema.Schema.All>(target: S, key: RefPropKey<Schema.Schema.Type<S>>): Query<Schema.Schema.Type<S>>;
|
|
31
|
+
/**
|
|
32
|
+
* Find relations where this object is the source.
|
|
33
|
+
* @returns Query for the relation objects.
|
|
34
|
+
* @param relation - Schema of the relation.
|
|
35
|
+
* @param predicates - Predicates to filter the relation objects.
|
|
36
|
+
*/
|
|
37
|
+
sourceOf<S extends Schema.Schema.All>(relation: S, predicates?: Filter.Props<Schema.Schema.Type<S>>): Query<Schema.Schema.Type<S>>;
|
|
38
|
+
/**
|
|
39
|
+
* Find relations where this object is the target.
|
|
40
|
+
* @returns Query for the relation objects.
|
|
41
|
+
* @param relation - Schema of the relation.
|
|
42
|
+
* @param predicates - Predicates to filter the relation objects.
|
|
43
|
+
*/
|
|
44
|
+
targetOf<S extends Schema.Schema.All>(relation: S, predicates?: Filter.Props<Schema.Schema.Type<S>>): Query<Schema.Schema.Type<S>>;
|
|
45
|
+
/**
|
|
46
|
+
* For a query for relations, get the source objects.
|
|
47
|
+
* @returns Query for the source objects.
|
|
48
|
+
*/
|
|
49
|
+
source(): Query<Relation.Source<T>>;
|
|
50
|
+
/**
|
|
51
|
+
* For a query for relations, get the target objects.
|
|
52
|
+
* @returns Query for the target objects.
|
|
53
|
+
*/
|
|
54
|
+
target(): Query<Relation.Target<T>>;
|
|
55
|
+
}
|
|
56
|
+
interface QueryAPI {
|
|
57
|
+
/**
|
|
58
|
+
* Select objects based on a filter.
|
|
59
|
+
* @param filter - Filter to select the objects.
|
|
60
|
+
* @returns Query for the selected objects.
|
|
61
|
+
*/
|
|
62
|
+
select<F extends Filter.Any>(filter: F): Query<Filter.Type<F>>;
|
|
63
|
+
/**
|
|
64
|
+
* Query for objects of a given schema.
|
|
65
|
+
* @param schema - Schema of the objects.
|
|
66
|
+
* @param predicates - Predicates to filter the objects.
|
|
67
|
+
* @returns Query for the objects.
|
|
68
|
+
*
|
|
69
|
+
* Shorthand for: `Query.select(Filter.type(schema, predicates))`.
|
|
70
|
+
*/
|
|
71
|
+
type<S extends Schema.Schema.All>(schema: S, predicates?: Filter.Props<Schema.Schema.Type<S>>): Query<Schema.Schema.Type<S>>;
|
|
72
|
+
/**
|
|
73
|
+
* Full-text or vector search.
|
|
74
|
+
*
|
|
75
|
+
* @deprecated Use `Filter`.
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
* Combine results of multiple queries.
|
|
79
|
+
* @param queries - Queries to combine.
|
|
80
|
+
* @returns Query for the combined results.
|
|
81
|
+
*/
|
|
82
|
+
all<T>(...queries: Query<T>[]): Query<T>;
|
|
83
|
+
}
|
|
84
|
+
export declare namespace Query {
|
|
85
|
+
type TextSearchOptions = {
|
|
86
|
+
type?: 'full-text' | 'vector';
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export interface Filter<T> {
|
|
90
|
+
'~Filter': {
|
|
91
|
+
value: T;
|
|
92
|
+
};
|
|
93
|
+
ast: QueryAST.Filter;
|
|
94
|
+
}
|
|
95
|
+
type Intersection<Types extends readonly unknown[]> = Types extends [infer First, ...infer Rest] ? First & Intersection<Rest> : unknown;
|
|
96
|
+
interface FilterAPI {
|
|
97
|
+
is(value: unknown): value is Filter<any>;
|
|
98
|
+
/**
|
|
99
|
+
* Filter by type.
|
|
100
|
+
*/
|
|
101
|
+
type<S extends Schema.Schema.All>(schema: S, props?: Filter.Props<Schema.Schema.Type<S>>): Filter<Schema.Schema.Type<S>>;
|
|
102
|
+
/**
|
|
103
|
+
* Filter by properties.
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* Full-text or vector search.
|
|
107
|
+
*/
|
|
108
|
+
text<S extends Schema.Schema.All>(schema: S, text: string, options?: Query.TextSearchOptions): Filter<Schema.Schema.Type<S>>;
|
|
109
|
+
/**
|
|
110
|
+
* Predicate for property to be equal to the provided value.
|
|
111
|
+
*/
|
|
112
|
+
eq<T>(value: T): Filter<T>;
|
|
113
|
+
/**
|
|
114
|
+
* Predicate for property to be not equal to the provided value.
|
|
115
|
+
*/
|
|
116
|
+
neq<T>(value: T): Filter<T>;
|
|
117
|
+
/**
|
|
118
|
+
* Predicate for property to be greater than the provided value.
|
|
119
|
+
*/
|
|
120
|
+
gt<T>(value: T): Filter<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Predicate for property to be greater than the provided value.
|
|
123
|
+
*/
|
|
124
|
+
gt<T>(value: T): Filter<T>;
|
|
125
|
+
/**
|
|
126
|
+
* Predicate for property to be greater than or equal to the provided value.
|
|
127
|
+
*/
|
|
128
|
+
gte<T>(value: T): Filter<T>;
|
|
129
|
+
/**
|
|
130
|
+
* Predicate for property to be less than the provided value.
|
|
131
|
+
*/
|
|
132
|
+
lt<T>(value: T): Filter<T>;
|
|
133
|
+
/**
|
|
134
|
+
* Predicate for property to be less than or equal to the provided value.
|
|
135
|
+
*/
|
|
136
|
+
lte<T>(value: T): Filter<T>;
|
|
137
|
+
/**
|
|
138
|
+
* Predicate for property to be in the provided array.
|
|
139
|
+
* @param values - Values to check against.
|
|
140
|
+
*/
|
|
141
|
+
in<T>(...values: T[]): Filter<T>;
|
|
142
|
+
/**
|
|
143
|
+
* Predicate for property to be in the provided range.
|
|
144
|
+
* @param from - Start of the range (inclusive).
|
|
145
|
+
* @param to - End of the range (exclusive).
|
|
146
|
+
*/
|
|
147
|
+
between<T>(from: T, to: T): Filter<T>;
|
|
148
|
+
/**
|
|
149
|
+
* Negate the filter.
|
|
150
|
+
*/
|
|
151
|
+
not<F extends Filter.Any>(filter: F): Filter<F>;
|
|
152
|
+
/**
|
|
153
|
+
* Combine filters with a logical AND.
|
|
154
|
+
*/
|
|
155
|
+
and<FS extends Filter.Any[]>(...filters: FS): Filter<Filter.And<FS>>;
|
|
156
|
+
/**
|
|
157
|
+
* Combine filters with a logical OR.
|
|
158
|
+
*/
|
|
159
|
+
or<FS extends Filter.Any[]>(...filters: FS): Filter<Filter.Or<FS>>;
|
|
160
|
+
}
|
|
161
|
+
export declare namespace Filter {
|
|
162
|
+
type Props<T> = {
|
|
163
|
+
[K in keyof T & string]?: Filter<T[K]> | T[K];
|
|
164
|
+
};
|
|
165
|
+
type Any = Filter<any>;
|
|
166
|
+
type Type<F extends Any> = F extends Filter<infer T> ? T : never;
|
|
167
|
+
type And<FS extends readonly Any[]> = Simplify<Intersection<{
|
|
168
|
+
[K in keyof FS]: Type<FS[K]>;
|
|
169
|
+
}>>;
|
|
170
|
+
type Or<FS extends readonly Any[]> = Simplify<{
|
|
171
|
+
[K in keyof FS]: Type<FS[K]>;
|
|
172
|
+
}[number]>;
|
|
173
|
+
}
|
|
174
|
+
export declare const Filter: FilterAPI;
|
|
175
|
+
/**
|
|
176
|
+
* All property paths inside T that are references.
|
|
177
|
+
*/
|
|
178
|
+
type RefPropKey<T> = {
|
|
179
|
+
[K in keyof T]: T[K] extends Ref<infer _U> ? K : never;
|
|
180
|
+
}[keyof T] & string;
|
|
181
|
+
export declare const Query: QueryAPI;
|
|
182
|
+
export {};
|
|
183
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/query/api.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAgB,KAAK,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,KAAK,QAAQ,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAKnC,MAAM,WAAW,KAAK,CAAC,CAAC;IAEtB,QAAQ,EAAE;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE,CAAC;IAEvB,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC;IAEpB;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEzC;;;;OAIG;IACH,SAAS,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpE;;;;;OAKG;IAEH,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,EACtC,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GACrC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IA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