@dxos/echo 0.8.2-main.12df754 → 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 +48 -33
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +48 -29
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +48 -33
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/{Database.d.ts → experimental/database.d.ts} +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/{Queue.d.ts → experimental/queue.d.ts} +1 -1
- package/dist/types/src/experimental/queue.d.ts.map +1 -0
- package/dist/types/src/{Space.d.ts → experimental/space.d.ts} +1 -1
- package/dist/types/src/experimental/space.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -6
- 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/type/Type.d.ts +80 -0
- 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 +14 -14
- package/src/{Database.ts → experimental/database.ts} +1 -1
- package/src/experimental/index.ts +7 -0
- package/src/{Queue.ts → experimental/queue.ts} +1 -1
- package/src/index.ts +3 -7
- 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/type/Type.test.ts +125 -0
- package/src/type/Type.ts +143 -0
- package/src/type/index.ts +6 -0
- package/dist/types/src/Database.d.ts.map +0 -1
- package/dist/types/src/Queue.d.ts.map +0 -1
- package/dist/types/src/Space.d.ts.map +0 -1
- package/dist/types/src/Type.d.ts +0 -49
- package/dist/types/src/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/src/Type.ts +0 -99
- package/src/api.test.ts +0 -94
- /package/src/{Space.ts → experimental/space.ts} +0 -0
|
@@ -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,EA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C,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAEjE,KAAK,GAAG,CAAC,EAAE,SAAS,SAAS,GAAG,EAAE,IAAI,QAAQ,CAAC,YAAY,CAAC;SAAG,CAAC,IAAI,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAAE,CAAC,CAAC,CAAC;IAE/F,KAAK,EAAE,CAAC,EAAE,SAAS,SAAS,GAAG,EAAE,IAAI,QAAQ,CAAC;SAAG,CAAC,IAAI,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAAE,CAAC,MAAM,CAAC,CAAC,CAAC;CACzF;AAuID,eAAO,MAAM,MAAM,EAAE,SAAuB,CAAC;AAE7C;;GAEG;AACH,KAAK,UAAU,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC;AA4GlG,eAAO,MAAM,KAAK,EAAE,QAAqB,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
declare const FilterObject_: Schema.Struct<{
|
|
3
|
+
type: Schema.Literal<["object"]>;
|
|
4
|
+
typename: Schema.Union<[Schema.refine<string, typeof Schema.NonEmptyString>, typeof Schema.Null]>;
|
|
5
|
+
props: Schema.Record$<Schema.SchemaClass<string, string, never>, Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>>;
|
|
6
|
+
}>;
|
|
7
|
+
interface FilterObject extends Schema.Schema.Type<typeof FilterObject_> {
|
|
8
|
+
}
|
|
9
|
+
declare const FilterObject: Schema.Schema<FilterObject>;
|
|
10
|
+
declare const FilterCompare_: Schema.Struct<{
|
|
11
|
+
type: Schema.Literal<["compare"]>;
|
|
12
|
+
operator: Schema.Literal<["eq", "neq", "gt", "gte", "lt", "lte"]>;
|
|
13
|
+
value: typeof Schema.Unknown;
|
|
14
|
+
}>;
|
|
15
|
+
interface FilterCompare extends Schema.Schema.Type<typeof FilterCompare_> {
|
|
16
|
+
}
|
|
17
|
+
declare const FilterCompare: Schema.Schema<FilterCompare>;
|
|
18
|
+
declare const FilterIn_: Schema.Struct<{
|
|
19
|
+
type: Schema.Literal<["in"]>;
|
|
20
|
+
values: Schema.Array$<typeof Schema.Any>;
|
|
21
|
+
}>;
|
|
22
|
+
interface FilterIn extends Schema.Schema.Type<typeof FilterIn_> {
|
|
23
|
+
}
|
|
24
|
+
declare const FilterIn: Schema.Schema<FilterIn>;
|
|
25
|
+
declare const FilterRange_: Schema.Struct<{
|
|
26
|
+
type: Schema.Literal<["range"]>;
|
|
27
|
+
from: typeof Schema.Any;
|
|
28
|
+
to: typeof Schema.Any;
|
|
29
|
+
}>;
|
|
30
|
+
interface FilterRange extends Schema.Schema.Type<typeof FilterRange_> {
|
|
31
|
+
}
|
|
32
|
+
declare const FilterRange: Schema.Schema<FilterRange>;
|
|
33
|
+
declare const FilterTextSearch_: Schema.Struct<{
|
|
34
|
+
type: Schema.Literal<["text-search"]>;
|
|
35
|
+
typename: Schema.Union<[Schema.refine<string, typeof Schema.NonEmptyString>, typeof Schema.Null]>;
|
|
36
|
+
text: typeof Schema.String;
|
|
37
|
+
searchKind: Schema.optional<Schema.Literal<["full-text", "vector"]>>;
|
|
38
|
+
}>;
|
|
39
|
+
interface FilterTextSearch extends Schema.Schema.Type<typeof FilterTextSearch_> {
|
|
40
|
+
}
|
|
41
|
+
declare const FilterTextSearch: Schema.Schema<FilterTextSearch>;
|
|
42
|
+
declare const FilterNot_: Schema.Struct<{
|
|
43
|
+
type: Schema.Literal<["not"]>;
|
|
44
|
+
filter: Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>;
|
|
45
|
+
}>;
|
|
46
|
+
interface FilterNot extends Schema.Schema.Type<typeof FilterNot_> {
|
|
47
|
+
}
|
|
48
|
+
declare const FilterNot: Schema.Schema<FilterNot>;
|
|
49
|
+
declare const FilterAnd_: Schema.Struct<{
|
|
50
|
+
type: Schema.Literal<["and"]>;
|
|
51
|
+
filters: Schema.Array$<Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>>;
|
|
52
|
+
}>;
|
|
53
|
+
interface FilterAnd extends Schema.Schema.Type<typeof FilterAnd_> {
|
|
54
|
+
}
|
|
55
|
+
declare const FilterAnd: Schema.Schema<FilterAnd>;
|
|
56
|
+
declare const FilterOr_: Schema.Struct<{
|
|
57
|
+
type: Schema.Literal<["or"]>;
|
|
58
|
+
filters: Schema.Array$<Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>>;
|
|
59
|
+
}>;
|
|
60
|
+
interface FilterOr extends Schema.Schema.Type<typeof FilterOr_> {
|
|
61
|
+
}
|
|
62
|
+
declare const FilterOr: Schema.Schema<FilterOr>;
|
|
63
|
+
export declare const Filter: Schema.Union<[Schema.Schema<FilterObject, FilterObject, never>, Schema.Schema<FilterTextSearch, FilterTextSearch, never>, Schema.Schema<FilterCompare, FilterCompare, never>, Schema.Schema<FilterIn, FilterIn, never>, Schema.Schema<FilterRange, FilterRange, never>, Schema.Schema<FilterNot, FilterNot, never>, Schema.Schema<FilterAnd, FilterAnd, never>, Schema.Schema<FilterOr, FilterOr, never>]>;
|
|
64
|
+
export type Filter = Schema.Schema.Type<typeof Filter>;
|
|
65
|
+
/**
|
|
66
|
+
* Query objects by type, id, and/or predicates.
|
|
67
|
+
*/
|
|
68
|
+
declare const QuerySelectClause_: Schema.Struct<{
|
|
69
|
+
type: Schema.Literal<["select"]>;
|
|
70
|
+
filter: Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>;
|
|
71
|
+
}>;
|
|
72
|
+
interface QuerySelectClause extends Schema.Schema.Type<typeof QuerySelectClause_> {
|
|
73
|
+
}
|
|
74
|
+
declare const QuerySelectClause: Schema.Schema<QuerySelectClause>;
|
|
75
|
+
/**
|
|
76
|
+
* Filter objects from selection.
|
|
77
|
+
*/
|
|
78
|
+
declare const QueryFilterClause_: Schema.Struct<{
|
|
79
|
+
type: Schema.Literal<["filter"]>;
|
|
80
|
+
selection: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, never>;
|
|
81
|
+
filter: Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>;
|
|
82
|
+
}>;
|
|
83
|
+
interface QueryFilterClause extends Schema.Schema.Type<typeof QueryFilterClause_> {
|
|
84
|
+
}
|
|
85
|
+
declare const QueryFilterClause: Schema.Schema<QueryFilterClause>;
|
|
86
|
+
/**
|
|
87
|
+
* Traverse references from an anchor object.
|
|
88
|
+
*/
|
|
89
|
+
declare const QueryReferenceTraversalClause_: Schema.Struct<{
|
|
90
|
+
type: Schema.Literal<["reference-traversal"]>;
|
|
91
|
+
anchor: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, never>;
|
|
92
|
+
property: typeof Schema.String;
|
|
93
|
+
}>;
|
|
94
|
+
interface QueryReferenceTraversalClause extends Schema.Schema.Type<typeof QueryReferenceTraversalClause_> {
|
|
95
|
+
}
|
|
96
|
+
declare const QueryReferenceTraversalClause: Schema.Schema<QueryReferenceTraversalClause>;
|
|
97
|
+
/**
|
|
98
|
+
* Traverse incoming references to an anchor object.
|
|
99
|
+
*/
|
|
100
|
+
declare const QueryIncomingReferencesClause_: Schema.Struct<{
|
|
101
|
+
type: Schema.Literal<["incoming-references"]>;
|
|
102
|
+
anchor: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, never>;
|
|
103
|
+
property: typeof Schema.String;
|
|
104
|
+
typename: Schema.Union<[Schema.refine<string, typeof Schema.NonEmptyString>, typeof Schema.Null]>;
|
|
105
|
+
}>;
|
|
106
|
+
interface QueryIncomingReferencesClause extends Schema.Schema.Type<typeof QueryIncomingReferencesClause_> {
|
|
107
|
+
}
|
|
108
|
+
declare const QueryIncomingReferencesClause: Schema.Schema<QueryIncomingReferencesClause>;
|
|
109
|
+
/**
|
|
110
|
+
* Traverse relations connecting to an anchor object.
|
|
111
|
+
*/
|
|
112
|
+
declare const QueryRelationClause_: Schema.Struct<{
|
|
113
|
+
type: Schema.Literal<["relation"]>;
|
|
114
|
+
anchor: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, never>;
|
|
115
|
+
direction: Schema.Literal<["outgoing", "incoming", "both"]>;
|
|
116
|
+
filter: Schema.optional<Schema.suspend<FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, FilterObject | FilterTextSearch | FilterCompare | FilterIn | FilterRange | FilterNot | FilterAnd | FilterOr, never>>;
|
|
117
|
+
}>;
|
|
118
|
+
interface QueryRelationClause extends Schema.Schema.Type<typeof QueryRelationClause_> {
|
|
119
|
+
}
|
|
120
|
+
declare const QueryRelationClause: Schema.Schema<QueryRelationClause>;
|
|
121
|
+
/**
|
|
122
|
+
* Traverse into the source or target of a relation.
|
|
123
|
+
*/
|
|
124
|
+
declare const QueryRelationTraversalClause_: Schema.Struct<{
|
|
125
|
+
type: Schema.Literal<["relation-traversal"]>;
|
|
126
|
+
anchor: Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, never>;
|
|
127
|
+
direction: Schema.Literal<["source", "target", "both"]>;
|
|
128
|
+
}>;
|
|
129
|
+
interface QueryRelationTraversalClause extends Schema.Schema.Type<typeof QueryRelationTraversalClause_> {
|
|
130
|
+
}
|
|
131
|
+
declare const QueryRelationTraversalClause: Schema.Schema<QueryRelationTraversalClause>;
|
|
132
|
+
/**
|
|
133
|
+
* Union of multiple queries.
|
|
134
|
+
*/
|
|
135
|
+
declare const QueryUnionClause_: Schema.Struct<{
|
|
136
|
+
type: Schema.Literal<["union"]>;
|
|
137
|
+
queries: Schema.Array$<Schema.suspend<QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, QuerySelectClause | QueryFilterClause | QueryReferenceTraversalClause | QueryIncomingReferencesClause | QueryRelationClause | QueryRelationTraversalClause | QueryUnionClause, never>>;
|
|
138
|
+
}>;
|
|
139
|
+
interface QueryUnionClause extends Schema.Schema.Type<typeof QueryUnionClause_> {
|
|
140
|
+
}
|
|
141
|
+
declare const QueryUnionClause: Schema.Schema<QueryUnionClause>;
|
|
142
|
+
declare const Query_: Schema.Union<[Schema.Schema<QuerySelectClause, QuerySelectClause, never>, Schema.Schema<QueryFilterClause, QueryFilterClause, never>, Schema.Schema<QueryReferenceTraversalClause, QueryReferenceTraversalClause, never>, Schema.Schema<QueryIncomingReferencesClause, QueryIncomingReferencesClause, never>, Schema.Schema<QueryRelationClause, QueryRelationClause, never>, Schema.Schema<QueryRelationTraversalClause, QueryRelationTraversalClause, never>, Schema.Schema<QueryUnionClause, QueryUnionClause, never>]>;
|
|
143
|
+
export type Query = Schema.Schema.Type<typeof Query_>;
|
|
144
|
+
export declare const Query: Schema.Schema<Query>;
|
|
145
|
+
export {};
|
|
146
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../../../src/query/ast.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUhC,QAAA,MAAM,aAAa;;;;EAOjB,CAAC;AACH,UAAU,YAAa,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,aAAa,CAAC;CAAG;AAC1E,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAiB,CAAC;AAEhE,QAAA,MAAM,cAAc;;;;EAIlB,CAAC;AACH,UAAU,aAAc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,MAAM,CAAC,IAAI,CAAC,OAAO,oBAAoB,CAAC;CAAG;AACxF,QAAA,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAwB,CAAC;AAErF;;GAEG;AACH,QAAA,MAAM,6BAA6B;;;;EAIjC,CAAC;AACH,UAAU,4BAA6B,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,6BAA6B,CAAC;CAAG;AAC1G,QAAA,MAAM,4BAA4B,EAAE,MAAM,CAAC,MAAM,CAAC,4BAA4B,CAAiC,CAAC;AAEhH;;GAEG;AACH,QAAA,MAAM,iBAAiB;;;EAGrB,CAAC;AACH,UAAU,gBAAiB,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC;CAAG;AAClF,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAqB,CAAC;AAE5E,QAAA,MAAM,MAAM,4fAQX,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,MAAM,CAAC,CAAC;AACtD,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.test.d.ts","sourceRoot":"","sources":["../../../../src/query/query.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RelationSourceTargetRefs } from '@dxos/echo-schema';
|
|
2
|
+
export declare const def: <TSource extends import("effect/Schema").Schema.AnyNoContext, TTarget extends import("effect/Schema").Schema.AnyNoContext>(options: {
|
|
3
|
+
typename: string;
|
|
4
|
+
version: string;
|
|
5
|
+
source: TSource;
|
|
6
|
+
target: TTarget;
|
|
7
|
+
}) => <Self extends import("effect/Schema").Schema.Any>(self: Self) => import("@dxos/echo-schema").EchoTypeSchema<Self, RelationSourceTargetRefs<import("effect/Schema").Schema.Type<TSource>, import("effect/Schema").Schema.Type<TTarget>>>;
|
|
8
|
+
/**
|
|
9
|
+
* Get relation target type.
|
|
10
|
+
*/
|
|
11
|
+
export type Target<A> = A extends RelationSourceTargetRefs<infer T, infer _S> ? T : never;
|
|
12
|
+
/**
|
|
13
|
+
* Get relation source type.
|
|
14
|
+
*/
|
|
15
|
+
export type Source<A> = A extends RelationSourceTargetRefs<infer _T, infer S> ? S : never;
|
|
16
|
+
//# sourceMappingURL=Relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Relation.d.ts","sourceRoot":"","sources":["../../../../src/type/Relation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,eAAO,MAAM,GAAG;;;;;6OAAe,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,wBAAwB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,wBAAwB,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type Schema } from 'effect';
|
|
2
|
+
import { type AnyLiveObject as AnyLiveObject$ } from '@dxos/echo-db';
|
|
3
|
+
import { type BaseEchoObject, type BaseObject, type BaseSchema, type EchoSchema, EntityKind, Expando as Expando$, type ImmutableSchema, type JsonSchemaType, ObjectId as ObjectId$, Ref as Ref$, type StoredSchema, type TypeMeta } from '@dxos/echo-schema';
|
|
4
|
+
import { SpaceId as SpaceId$ } from '@dxos/keys';
|
|
5
|
+
/**
|
|
6
|
+
* Type System API.
|
|
7
|
+
*
|
|
8
|
+
* @category api namespace
|
|
9
|
+
* @since 0.9.0
|
|
10
|
+
*/
|
|
11
|
+
export declare namespace Type {
|
|
12
|
+
const SpaceIdSchema: Schema.Schema<SpaceId$, string, never>;
|
|
13
|
+
const SpaceId: Readonly<{
|
|
14
|
+
byteLength: 20;
|
|
15
|
+
encode: (value: Uint8Array) => SpaceId$;
|
|
16
|
+
decode: (value: SpaceId$) => Uint8Array;
|
|
17
|
+
isValid: (value: string) => value is SpaceId$;
|
|
18
|
+
random: () => SpaceId$;
|
|
19
|
+
}>;
|
|
20
|
+
type SpaceId = SpaceId$;
|
|
21
|
+
const ObjectId: import("@dxos/echo-schema").ObjectIdClass;
|
|
22
|
+
type ObjectId = ObjectId$;
|
|
23
|
+
const Kind: typeof EntityKind;
|
|
24
|
+
type AnyObject = BaseEchoObject;
|
|
25
|
+
type AnyLiveObject<T extends BaseObject> = AnyLiveObject$<T>;
|
|
26
|
+
type JsonSchema = JsonSchemaType;
|
|
27
|
+
/**
|
|
28
|
+
* A schema that can be extended with arbitrary properties.
|
|
29
|
+
*/
|
|
30
|
+
const Expando: Schema.Schema<Expando$, Expando$, never>;
|
|
31
|
+
type Expando = Expando$;
|
|
32
|
+
type Abstract<T = any> = BaseSchema<T>;
|
|
33
|
+
type ImmutableType<T> = ImmutableSchema<T>;
|
|
34
|
+
type MutableType<T> = EchoSchema<T>;
|
|
35
|
+
type StoredType = StoredSchema;
|
|
36
|
+
const create: {
|
|
37
|
+
<T extends BaseObject>(obj: T): import("@dxos/live-object").Live<T>;
|
|
38
|
+
<T extends BaseObject>(schema: Schema.Schema<T, any, never>, obj: NoInfer<import("@dxos/echo-schema").ExcludeId<T>>, meta?: import("@dxos/echo-schema").ObjectMeta): import("@dxos/live-object").Live<T>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Defines an ECHO type.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { Type } from '@dxos/echo';
|
|
46
|
+
* const Organization = Schema.Struct({
|
|
47
|
+
* name: Schema.String,
|
|
48
|
+
* }).pipe(Type.def({
|
|
49
|
+
* typename: 'example.com/type/Organization',
|
|
50
|
+
* version: '0.1.0',
|
|
51
|
+
* }));
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
const def: (meta: TypeMeta) => <Self extends Schema.Schema.Any>(self: Self) => import("@dxos/echo-schema").EchoTypeSchema<Self>;
|
|
55
|
+
/**
|
|
56
|
+
* Defines a reference to an ECHO object.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { Type } from '@dxos/echo';
|
|
61
|
+
* const Person = Schema.Struct({
|
|
62
|
+
* name: Schema.String,
|
|
63
|
+
* organization: Type.Ref(Organization),
|
|
64
|
+
* }).pipe(Type.def({
|
|
65
|
+
* typename: 'example.com/type/Person',
|
|
66
|
+
* version: '0.1.0',
|
|
67
|
+
* }));
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
const Ref: <S extends Schema.Schema.AnyNoContext>(self: S) => import("@dxos/echo-schema").Ref$<Schema.Schema.Type<S>>;
|
|
71
|
+
const ref: <T extends import("@dxos/echo-schema").WithId>(object: T) => Ref$<T>;
|
|
72
|
+
const getMeta: (schema: Schema.Schema.All) => import("@dxos/echo-schema").TypeAnnotation | undefined;
|
|
73
|
+
const getSchema: (obj: unknown | undefined) => Schema.Schema.AnyNoContext | undefined;
|
|
74
|
+
const instanceOf: <Schema extends Schema.Schema.AnyNoContext>(schema: Schema, object: any) => object is Schema.Schema.Type<Schema>;
|
|
75
|
+
const getDXN: (schema: Schema.Schema.All) => import("@dxos/keys").DXN | undefined;
|
|
76
|
+
const getTypename: (schema: Schema.Schema.AnyNoContext) => string;
|
|
77
|
+
const getVersion: (schema: Schema.Schema.All) => string | undefined;
|
|
78
|
+
const toJsonSchema: (schema: Schema.Schema.All) => JsonSchemaType;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=Type.d.ts.map
|
|
@@ -0,0 +1 @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C;IAC3C,KAAY,UAAU,GAAG,YAAY,CAAC;IAE/B,MAAM,MAAM;;;KAAQ,CAAC;IAE5B;;;;;;;;;;;;;OAaG;IACI,MAAM,GAAG,GAAI,MAAM,QAAQ,qGAAqB,CAAC;IAMxD;;;;;;;;;;;;;;OAcG;IACI,MAAM,GAAG,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,4DAAsC,CAAC;IAEjG,MAAM,GAAG,sEAAY,CAAC;IAMtB,MAAM,OAAO,uFAAoB,CAAC;IAClC,MAAM,SAAS,sEAAa,CAAC;IAC7B,MAAM,UAAU,kHAAe,CAAC;IAOhC,MAAM,MAAM,qEAAe,CAAC;IAC5B,MAAM,WAAW,GAAI,QAAQ,MAAM,CAAC,MAAM,CAAC,YAAY,KAAG,MAIhE,CAAC;IACK,MAAM,UAAU,mDAAmB,CAAC;IACpC,MAAM,YAAY,+CAAgB,CAAC;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Type.test.d.ts","sourceRoot":"","sources":["../../../../src/type/Type.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/type/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo",
|
|
3
|
-
"version": "0.8.2-main.
|
|
3
|
+
"version": "0.8.2-main.30e4dbb",
|
|
4
4
|
"description": "ECHO API",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@preact/signals-core": "^1.6.0",
|
|
25
|
-
"effect": "3.
|
|
26
|
-
"@dxos/debug": "0.8.2-main.
|
|
27
|
-
"@dxos/echo-protocol": "0.8.2-main.
|
|
28
|
-
"@dxos/echo-
|
|
29
|
-
"@dxos/echo-
|
|
30
|
-
"@dxos/effect": "0.8.2-main.
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/live-object": "0.8.2-main.
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
25
|
+
"effect": "3.14.21",
|
|
26
|
+
"@dxos/debug": "0.8.2-main.30e4dbb",
|
|
27
|
+
"@dxos/echo-protocol": "0.8.2-main.30e4dbb",
|
|
28
|
+
"@dxos/echo-signals": "0.8.2-main.30e4dbb",
|
|
29
|
+
"@dxos/echo-schema": "0.8.2-main.30e4dbb",
|
|
30
|
+
"@dxos/effect": "0.8.2-main.30e4dbb",
|
|
31
|
+
"@dxos/echo-db": "0.8.2-main.30e4dbb",
|
|
32
|
+
"@dxos/invariant": "0.8.2-main.30e4dbb",
|
|
33
|
+
"@dxos/live-object": "0.8.2-main.30e4dbb",
|
|
34
|
+
"@dxos/log": "0.8.2-main.30e4dbb",
|
|
35
|
+
"@dxos/keys": "0.8.2-main.30e4dbb",
|
|
36
|
+
"@dxos/util": "0.8.2-main.30e4dbb",
|
|
37
|
+
"@dxos/node-std": "0.8.2-main.30e4dbb"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
package/src/index.ts
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export { Format, FormatEnum } from '@dxos/echo-schema';
|
|
6
|
+
export { DXN } from '@dxos/keys';
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export * as Database from './Database';
|
|
10
|
-
export * as Queue from './Queue';
|
|
11
|
-
export * as Space from './Space';
|
|
12
|
-
export * as Type from './Type';
|
|
8
|
+
export * from './type';
|