@dxos/index-core 0.8.4-main.fcfe5033a5 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/index.mjs +190 -101
- package/dist/lib/neutral/index.mjs.map +4 -4
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/types/src/index-engine.d.ts +31 -17
- package/dist/types/src/index-engine.d.ts.map +1 -1
- package/dist/types/src/index-tracker.d.ts +3 -3
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/indexes/entity-meta-index.d.ts +113 -0
- package/dist/types/src/indexes/entity-meta-index.d.ts.map +1 -0
- package/dist/types/src/indexes/entity-meta-index.test.d.ts +2 -0
- package/dist/types/src/indexes/entity-meta-index.test.d.ts.map +1 -0
- package/dist/types/src/indexes/fts-index.d.ts +7 -6
- package/dist/types/src/indexes/fts-index.d.ts.map +1 -1
- package/dist/types/src/indexes/index.d.ts +1 -1
- package/dist/types/src/indexes/interface.d.ts +15 -4
- package/dist/types/src/indexes/interface.d.ts.map +1 -1
- package/dist/types/src/indexes/reverse-ref-index.d.ts +3 -2
- package/dist/types/src/indexes/reverse-ref-index.d.ts.map +1 -1
- package/dist/types/src/utils.d.ts +3 -3
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -18
- package/src/index-engine.test.ts +138 -16
- package/src/index-engine.ts +123 -58
- package/src/index.ts +9 -3
- package/src/indexes/{object-meta-index.test.ts → entity-meta-index.test.ts} +114 -53
- package/src/indexes/{object-meta-index.ts → entity-meta-index.ts} +140 -71
- package/src/indexes/fts-index.test.ts +188 -34
- package/src/indexes/fts-index.ts +32 -15
- package/src/indexes/index.ts +1 -1
- package/src/indexes/interface.ts +16 -4
- package/src/indexes/reverse-ref-index.test.ts +57 -43
- package/src/indexes/reverse-ref-index.ts +22 -14
- package/src/utils.ts +5 -5
- package/dist/types/src/indexes/object-meta-index.d.ts +0 -88
- package/dist/types/src/indexes/object-meta-index.d.ts.map +0 -1
- package/dist/types/src/indexes/object-meta-index.test.d.ts +0 -2
- package/dist/types/src/indexes/object-meta-index.test.d.ts.map +0 -1
|
@@ -9,13 +9,13 @@ import * as Effect from 'effect/Effect';
|
|
|
9
9
|
import * as Layer from 'effect/Layer';
|
|
10
10
|
|
|
11
11
|
import { ATTR_TYPE } from '@dxos/echo/internal';
|
|
12
|
-
import { DXN,
|
|
12
|
+
import { DXN, EID, EntityId, SpaceId } from '@dxos/keys';
|
|
13
13
|
|
|
14
14
|
import type { IndexerObject } from './interface';
|
|
15
15
|
import { ReverseRefIndex } from './reverse-ref-index';
|
|
16
16
|
|
|
17
|
-
const TYPE_PERSON = DXN.
|
|
18
|
-
const TYPE_EXAMPLE = DXN.
|
|
17
|
+
const TYPE_PERSON = DXN.make('com.example.type.person', '0.1.0');
|
|
18
|
+
const TYPE_EXAMPLE = DXN.make('com.example.type.example', '0.1.0');
|
|
19
19
|
|
|
20
20
|
const TestLayer = Layer.merge(
|
|
21
21
|
SqliteClient.layer({
|
|
@@ -31,28 +31,30 @@ describe('ReverseRefIndex', () => {
|
|
|
31
31
|
yield* reverseRefIndex.migrate();
|
|
32
32
|
|
|
33
33
|
const spaceId = SpaceId.random();
|
|
34
|
-
const sourceObjectId =
|
|
35
|
-
const targetObjectId =
|
|
36
|
-
const
|
|
34
|
+
const sourceObjectId = EntityId.random();
|
|
35
|
+
const targetObjectId = EntityId.random();
|
|
36
|
+
const targetDXN = EID.make({ entityId: targetObjectId });
|
|
37
37
|
|
|
38
38
|
const sourceObject: IndexerObject = {
|
|
39
39
|
spaceId,
|
|
40
|
-
queueId:
|
|
40
|
+
queueId: EntityId.random(),
|
|
41
|
+
queueNamespace: 'data',
|
|
41
42
|
documentId: null,
|
|
42
43
|
recordId: 1,
|
|
44
|
+
createdAt: null,
|
|
43
45
|
updatedAt: Date.now(),
|
|
44
46
|
data: {
|
|
45
47
|
id: sourceObjectId,
|
|
46
48
|
[ATTR_TYPE]: TYPE_PERSON,
|
|
47
|
-
contact: { '/':
|
|
49
|
+
contact: { '/': targetDXN },
|
|
48
50
|
},
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
yield* reverseRefIndex.update([sourceObject]);
|
|
52
54
|
|
|
53
|
-
const results = yield* reverseRefIndex.query({
|
|
55
|
+
const results = yield* reverseRefIndex.query({ targetDXN: targetDXN });
|
|
54
56
|
expect(results.length).toBe(1);
|
|
55
|
-
expect(results[0].
|
|
57
|
+
expect(results[0].targetDXN).toBe(targetDXN);
|
|
56
58
|
expect(results[0].propPath).toBe('contact');
|
|
57
59
|
}).pipe(Effect.provide(TestLayer)),
|
|
58
60
|
);
|
|
@@ -63,17 +65,19 @@ describe('ReverseRefIndex', () => {
|
|
|
63
65
|
yield* reverseRefIndex.migrate();
|
|
64
66
|
|
|
65
67
|
const spaceId = SpaceId.random();
|
|
66
|
-
const sourceObjectId =
|
|
67
|
-
const targetObjectId1 =
|
|
68
|
-
const targetObjectId2 =
|
|
69
|
-
const targetDxn1 =
|
|
70
|
-
const targetDxn2 =
|
|
68
|
+
const sourceObjectId = EntityId.random();
|
|
69
|
+
const targetObjectId1 = EntityId.random();
|
|
70
|
+
const targetObjectId2 = EntityId.random();
|
|
71
|
+
const targetDxn1 = EID.make({ entityId: targetObjectId1 });
|
|
72
|
+
const targetDxn2 = EID.make({ entityId: targetObjectId2 });
|
|
71
73
|
|
|
72
74
|
const sourceObject: IndexerObject = {
|
|
73
75
|
spaceId,
|
|
74
|
-
queueId:
|
|
76
|
+
queueId: EntityId.random(),
|
|
77
|
+
queueNamespace: 'data',
|
|
75
78
|
documentId: null,
|
|
76
79
|
recordId: 1,
|
|
80
|
+
createdAt: null,
|
|
77
81
|
updatedAt: Date.now(),
|
|
78
82
|
data: {
|
|
79
83
|
id: sourceObjectId,
|
|
@@ -89,11 +93,11 @@ describe('ReverseRefIndex', () => {
|
|
|
89
93
|
|
|
90
94
|
yield* reverseRefIndex.update([sourceObject]);
|
|
91
95
|
|
|
92
|
-
const results1 = yield* reverseRefIndex.query({
|
|
96
|
+
const results1 = yield* reverseRefIndex.query({ targetDXN: targetDxn1 });
|
|
93
97
|
expect(results1.length).toBe(1);
|
|
94
98
|
expect(results1[0].propPath).toBe('nested.deep.ref');
|
|
95
99
|
|
|
96
|
-
const results2 = yield* reverseRefIndex.query({
|
|
100
|
+
const results2 = yield* reverseRefIndex.query({ targetDXN: targetDxn2 });
|
|
97
101
|
expect(results2.length).toBe(1);
|
|
98
102
|
expect(results2[0].propPath).toBe('simple');
|
|
99
103
|
}).pipe(Effect.provide(TestLayer)),
|
|
@@ -105,17 +109,19 @@ describe('ReverseRefIndex', () => {
|
|
|
105
109
|
yield* reverseRefIndex.migrate();
|
|
106
110
|
|
|
107
111
|
const spaceId = SpaceId.random();
|
|
108
|
-
const sourceObjectId =
|
|
109
|
-
const targetObjectId1 =
|
|
110
|
-
const targetObjectId2 =
|
|
111
|
-
const targetDxn1 =
|
|
112
|
-
const targetDxn2 =
|
|
112
|
+
const sourceObjectId = EntityId.random();
|
|
113
|
+
const targetObjectId1 = EntityId.random();
|
|
114
|
+
const targetObjectId2 = EntityId.random();
|
|
115
|
+
const targetDxn1 = EID.make({ entityId: targetObjectId1 });
|
|
116
|
+
const targetDxn2 = EID.make({ entityId: targetObjectId2 });
|
|
113
117
|
|
|
114
118
|
const sourceObject: IndexerObject = {
|
|
115
119
|
spaceId,
|
|
116
|
-
queueId:
|
|
120
|
+
queueId: EntityId.random(),
|
|
121
|
+
queueNamespace: 'data',
|
|
117
122
|
documentId: null,
|
|
118
123
|
recordId: 1,
|
|
124
|
+
createdAt: null,
|
|
119
125
|
updatedAt: Date.now(),
|
|
120
126
|
data: {
|
|
121
127
|
id: sourceObjectId,
|
|
@@ -126,11 +132,11 @@ describe('ReverseRefIndex', () => {
|
|
|
126
132
|
|
|
127
133
|
yield* reverseRefIndex.update([sourceObject]);
|
|
128
134
|
|
|
129
|
-
const results1 = yield* reverseRefIndex.query({
|
|
135
|
+
const results1 = yield* reverseRefIndex.query({ targetDXN: targetDxn1 });
|
|
130
136
|
expect(results1.length).toBe(1);
|
|
131
137
|
expect(results1[0].propPath).toBe('items.0');
|
|
132
138
|
|
|
133
|
-
const results2 = yield* reverseRefIndex.query({
|
|
139
|
+
const results2 = yield* reverseRefIndex.query({ targetDXN: targetDxn2 });
|
|
134
140
|
expect(results2.length).toBe(1);
|
|
135
141
|
expect(results2[0].propPath).toBe('items.1');
|
|
136
142
|
}).pipe(Effect.provide(TestLayer)),
|
|
@@ -142,20 +148,22 @@ describe('ReverseRefIndex', () => {
|
|
|
142
148
|
yield* reverseRefIndex.migrate();
|
|
143
149
|
|
|
144
150
|
const spaceId = SpaceId.random();
|
|
145
|
-
const queueId =
|
|
146
|
-
const sourceObjectId =
|
|
147
|
-
const targetObjectId1 =
|
|
148
|
-
const targetObjectId2 =
|
|
149
|
-
const targetDxn1 =
|
|
150
|
-
const targetDxn2 =
|
|
151
|
+
const queueId = EntityId.random();
|
|
152
|
+
const sourceObjectId = EntityId.random();
|
|
153
|
+
const targetObjectId1 = EntityId.random();
|
|
154
|
+
const targetObjectId2 = EntityId.random();
|
|
155
|
+
const targetDxn1 = EID.make({ entityId: targetObjectId1 });
|
|
156
|
+
const targetDxn2 = EID.make({ entityId: targetObjectId2 });
|
|
151
157
|
const recordId = 1;
|
|
152
158
|
|
|
153
159
|
// Initial object with reference to target1.
|
|
154
160
|
const sourceObject: IndexerObject = {
|
|
155
161
|
spaceId,
|
|
156
162
|
queueId,
|
|
163
|
+
queueNamespace: 'data',
|
|
157
164
|
documentId: null,
|
|
158
165
|
recordId,
|
|
166
|
+
createdAt: null,
|
|
159
167
|
updatedAt: Date.now(),
|
|
160
168
|
data: {
|
|
161
169
|
id: sourceObjectId,
|
|
@@ -166,15 +174,17 @@ describe('ReverseRefIndex', () => {
|
|
|
166
174
|
|
|
167
175
|
yield* reverseRefIndex.update([sourceObject]);
|
|
168
176
|
|
|
169
|
-
let results1 = yield* reverseRefIndex.query({
|
|
177
|
+
let results1 = yield* reverseRefIndex.query({ targetDXN: targetDxn1 });
|
|
170
178
|
expect(results1.length).toBe(1);
|
|
171
179
|
|
|
172
180
|
// Update object to reference target2 instead (same recordId).
|
|
173
181
|
const updatedObject: IndexerObject = {
|
|
174
182
|
spaceId,
|
|
175
183
|
queueId,
|
|
184
|
+
queueNamespace: 'data',
|
|
176
185
|
documentId: null,
|
|
177
186
|
recordId,
|
|
187
|
+
createdAt: null,
|
|
178
188
|
updatedAt: Date.now(),
|
|
179
189
|
data: {
|
|
180
190
|
id: sourceObjectId,
|
|
@@ -186,11 +196,11 @@ describe('ReverseRefIndex', () => {
|
|
|
186
196
|
yield* reverseRefIndex.update([updatedObject]);
|
|
187
197
|
|
|
188
198
|
// Old reference should be gone.
|
|
189
|
-
results1 = yield* reverseRefIndex.query({
|
|
199
|
+
results1 = yield* reverseRefIndex.query({ targetDXN: targetDxn1 });
|
|
190
200
|
expect(results1.length).toBe(0);
|
|
191
201
|
|
|
192
202
|
// New reference should exist.
|
|
193
|
-
const results2 = yield* reverseRefIndex.query({
|
|
203
|
+
const results2 = yield* reverseRefIndex.query({ targetDXN: targetDxn2 });
|
|
194
204
|
expect(results2.length).toBe(1);
|
|
195
205
|
}).pipe(Effect.provide(TestLayer)),
|
|
196
206
|
);
|
|
@@ -201,13 +211,15 @@ describe('ReverseRefIndex', () => {
|
|
|
201
211
|
yield* reverseRefIndex.migrate();
|
|
202
212
|
|
|
203
213
|
const spaceId = SpaceId.random();
|
|
204
|
-
const sourceObjectId =
|
|
214
|
+
const sourceObjectId = EntityId.random();
|
|
205
215
|
|
|
206
216
|
const sourceObject: IndexerObject = {
|
|
207
217
|
spaceId,
|
|
208
|
-
queueId:
|
|
218
|
+
queueId: EntityId.random(),
|
|
219
|
+
queueNamespace: 'data',
|
|
209
220
|
documentId: null,
|
|
210
221
|
recordId: 1,
|
|
222
|
+
createdAt: null,
|
|
211
223
|
updatedAt: Date.now(),
|
|
212
224
|
data: {
|
|
213
225
|
id: sourceObjectId,
|
|
@@ -220,7 +232,7 @@ describe('ReverseRefIndex', () => {
|
|
|
220
232
|
yield* reverseRefIndex.update([sourceObject]);
|
|
221
233
|
|
|
222
234
|
// Should not throw and no results for random DXN.
|
|
223
|
-
const results = yield* reverseRefIndex.query({
|
|
235
|
+
const results = yield* reverseRefIndex.query({ targetDXN: EID.make({ entityId: EntityId.random() }) });
|
|
224
236
|
expect(results.length).toBe(0);
|
|
225
237
|
}).pipe(Effect.provide(TestLayer)),
|
|
226
238
|
);
|
|
@@ -231,26 +243,28 @@ describe('ReverseRefIndex', () => {
|
|
|
231
243
|
yield* reverseRefIndex.migrate();
|
|
232
244
|
|
|
233
245
|
const spaceId = SpaceId.random();
|
|
234
|
-
const sourceObjectId =
|
|
235
|
-
const targetObjectId =
|
|
236
|
-
const
|
|
246
|
+
const sourceObjectId = EntityId.random();
|
|
247
|
+
const targetObjectId = EntityId.random();
|
|
248
|
+
const targetDXN = EID.make({ entityId: targetObjectId });
|
|
237
249
|
|
|
238
250
|
const sourceObject: IndexerObject = {
|
|
239
251
|
spaceId,
|
|
240
252
|
queueId: null,
|
|
253
|
+
queueNamespace: null,
|
|
241
254
|
documentId: 'doc-123',
|
|
242
255
|
recordId: 1,
|
|
256
|
+
createdAt: null,
|
|
243
257
|
updatedAt: Date.now(),
|
|
244
258
|
data: {
|
|
245
259
|
id: sourceObjectId,
|
|
246
260
|
[ATTR_TYPE]: TYPE_EXAMPLE,
|
|
247
|
-
ref: { '/':
|
|
261
|
+
ref: { '/': targetDXN },
|
|
248
262
|
},
|
|
249
263
|
};
|
|
250
264
|
|
|
251
265
|
yield* reverseRefIndex.update([sourceObject]);
|
|
252
266
|
|
|
253
|
-
const results = yield* reverseRefIndex.query({
|
|
267
|
+
const results = yield* reverseRefIndex.query({ targetDXN: targetDXN });
|
|
254
268
|
expect(results.length).toBe(1);
|
|
255
269
|
expect(results[0].propPath).toBe('ref');
|
|
256
270
|
}).pipe(Effect.provide(TestLayer)),
|
|
@@ -8,6 +8,7 @@ import * as Effect from 'effect/Effect';
|
|
|
8
8
|
import * as Schema from 'effect/Schema';
|
|
9
9
|
|
|
10
10
|
import { EncodedReference, isEncodedReference } from '@dxos/echo-protocol';
|
|
11
|
+
import { EID } from '@dxos/keys';
|
|
11
12
|
|
|
12
13
|
import { EscapedPropPath } from '../utils';
|
|
13
14
|
import type { Index, IndexerObject } from './interface';
|
|
@@ -15,16 +16,20 @@ import type { Index, IndexerObject } from './interface';
|
|
|
15
16
|
/**
|
|
16
17
|
* Extracts all outgoing references from an object's data.
|
|
17
18
|
*/
|
|
18
|
-
const extractReferences = (data: Record<string, unknown>): { path: string[];
|
|
19
|
-
const refs: { path: string[];
|
|
19
|
+
const extractReferences = (data: Record<string, unknown>): { path: string[]; targetDXN: EID.EID }[] => {
|
|
20
|
+
const refs: { path: string[]; targetDXN: EID.EID }[] = [];
|
|
20
21
|
const visit = (path: string[], value: unknown) => {
|
|
21
22
|
if (isEncodedReference(value)) {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const uri = EncodedReference.toURI(value);
|
|
24
|
+
const parsedEchoUri = EID.tryParse(uri);
|
|
25
|
+
const echoUri = parsedEchoUri ? EID.getEntityId(parsedEchoUri) : undefined;
|
|
26
|
+
if (!echoUri || !parsedEchoUri) {
|
|
25
27
|
return; // Skip non-echo references.
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
// Key by the local (space-less) form so a space-qualified ref and a bare ref to the same entity index
|
|
30
|
+
// under the same key. The index is scoped to one space (entity ids are unique within it), and lookups
|
|
31
|
+
// normalize the same way (see `query`).
|
|
32
|
+
refs.push({ path, targetDXN: EID.toLocal(parsedEchoUri) });
|
|
28
33
|
} else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
29
34
|
for (const [key, v] of Object.entries(value)) {
|
|
30
35
|
visit([...path, key], v);
|
|
@@ -41,7 +46,7 @@ const extractReferences = (data: Record<string, unknown>): { path: string[]; tar
|
|
|
41
46
|
|
|
42
47
|
export const ReverseRef = Schema.Struct({
|
|
43
48
|
recordId: Schema.Number,
|
|
44
|
-
|
|
49
|
+
targetDXN: EID.Schema,
|
|
45
50
|
/**
|
|
46
51
|
* Escaped property path within an object.
|
|
47
52
|
*
|
|
@@ -56,7 +61,7 @@ export const ReverseRef = Schema.Struct({
|
|
|
56
61
|
export interface ReverseRef extends Schema.Schema.Type<typeof ReverseRef> {}
|
|
57
62
|
|
|
58
63
|
export interface ReverseRefQuery {
|
|
59
|
-
|
|
64
|
+
targetDXN: EID.EID;
|
|
60
65
|
// TODO: Add prop filter
|
|
61
66
|
}
|
|
62
67
|
|
|
@@ -70,23 +75,26 @@ export class ReverseRefIndex implements Index {
|
|
|
70
75
|
|
|
71
76
|
yield* sql`CREATE TABLE IF NOT EXISTS reverseRef (
|
|
72
77
|
recordId INTEGER NOT NULL,
|
|
73
|
-
|
|
78
|
+
targetDXN TEXT NOT NULL,
|
|
74
79
|
propPath TEXT NOT NULL,
|
|
75
|
-
PRIMARY KEY (recordId,
|
|
80
|
+
PRIMARY KEY (recordId, targetDXN, propPath)
|
|
76
81
|
)`;
|
|
77
82
|
|
|
78
|
-
yield* sql`CREATE INDEX IF NOT EXISTS idx_reverse_ref_target ON reverseRef(
|
|
83
|
+
yield* sql`CREATE INDEX IF NOT EXISTS idx_reverse_ref_target ON reverseRef(targetDXN)`;
|
|
79
84
|
});
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
87
|
* Query all references pointing to a target DXN.
|
|
83
88
|
*/
|
|
84
89
|
query = Effect.fn('ReverseRefIndex.query')(
|
|
85
|
-
({
|
|
90
|
+
({ targetDXN }: ReverseRefQuery): Effect.Effect<readonly ReverseRef[], SqlError.SqlError, SqlClient.SqlClient> =>
|
|
86
91
|
Effect.gen(function* () {
|
|
87
92
|
const sql = yield* SqlClient.SqlClient;
|
|
93
|
+
// Normalize to the local form to match how references are keyed on write (space-qualified and bare
|
|
94
|
+
// EIDs for the same entity collapse to one key).
|
|
95
|
+
const normalized = EID.toLocal(targetDXN);
|
|
88
96
|
// TODO(mykola): Join objectMeta table here.
|
|
89
|
-
const rows = yield* sql`SELECT * FROM reverseRef WHERE
|
|
97
|
+
const rows = yield* sql`SELECT * FROM reverseRef WHERE targetDXN = ${normalized}`;
|
|
90
98
|
return rows as ReverseRef[];
|
|
91
99
|
}),
|
|
92
100
|
);
|
|
@@ -115,7 +123,7 @@ export class ReverseRefIndex implements Index {
|
|
|
115
123
|
yield* Effect.forEach(
|
|
116
124
|
refs,
|
|
117
125
|
(ref) =>
|
|
118
|
-
sql`INSERT INTO reverseRef (recordId,
|
|
126
|
+
sql`INSERT INTO reverseRef (recordId, targetDXN, propPath) VALUES (${recordId}, ${ref.targetDXN}, ${EscapedPropPath.escape(ref.path)})`,
|
|
119
127
|
{ discard: true },
|
|
120
128
|
);
|
|
121
129
|
}),
|
package/src/utils.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
|
|
9
|
-
export type
|
|
9
|
+
export type EntityPropPath = string[];
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Escaped property path within an object.
|
|
@@ -18,14 +18,14 @@ export type ObjectPropPath = string[];
|
|
|
18
18
|
* - contact with .
|
|
19
19
|
*/
|
|
20
20
|
export const EscapedPropPath: Schema.SchemaClass<string, string> & {
|
|
21
|
-
escape: (path:
|
|
22
|
-
unescape: (path: EscapedPropPath) =>
|
|
21
|
+
escape: (path: EntityPropPath) => EscapedPropPath;
|
|
22
|
+
unescape: (path: EscapedPropPath) => EntityPropPath;
|
|
23
23
|
} = class extends Schema.String.annotations({ title: 'EscapedPropPath' }) {
|
|
24
|
-
static escape(path:
|
|
24
|
+
static escape(path: EntityPropPath): EscapedPropPath {
|
|
25
25
|
return path.map((p) => p.toString().replaceAll('\\', '\\\\').replaceAll('.', '\\.')).join('.');
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
static unescape(path: EscapedPropPath):
|
|
28
|
+
static unescape(path: EscapedPropPath): EntityPropPath {
|
|
29
29
|
const parts: string[] = [];
|
|
30
30
|
let current = '';
|
|
31
31
|
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import * as SqlClient from '@effect/sql/SqlClient';
|
|
2
|
-
import type * as SqlError from '@effect/sql/SqlError';
|
|
3
|
-
import * as Effect from 'effect/Effect';
|
|
4
|
-
import * as Schema from 'effect/Schema';
|
|
5
|
-
import { type ObjectId, type SpaceId } from '@dxos/keys';
|
|
6
|
-
import type { IndexerObject } from './interface';
|
|
7
|
-
import type { Index } from './interface';
|
|
8
|
-
export declare const ObjectMeta: Schema.Struct<{
|
|
9
|
-
recordId: typeof Schema.Number;
|
|
10
|
-
objectId: typeof Schema.String;
|
|
11
|
-
queueId: typeof Schema.String;
|
|
12
|
-
spaceId: typeof Schema.String;
|
|
13
|
-
documentId: typeof Schema.String;
|
|
14
|
-
entityKind: typeof Schema.String;
|
|
15
|
-
/** The versioned DXN of the type of the object. */
|
|
16
|
-
typeDxn: typeof Schema.String;
|
|
17
|
-
deleted: typeof Schema.Boolean;
|
|
18
|
-
source: Schema.NullOr<typeof Schema.String>;
|
|
19
|
-
target: Schema.NullOr<typeof Schema.String>;
|
|
20
|
-
/** Parent object id (nullable). */
|
|
21
|
-
parent: Schema.NullOr<typeof Schema.String>;
|
|
22
|
-
/** Monotonically increasing sequence number assigned on insert/update for tracking indexing order. */
|
|
23
|
-
version: typeof Schema.Number;
|
|
24
|
-
/** Unix ms timestamp when the object was first indexed. */
|
|
25
|
-
createdAt: Schema.NullOr<typeof Schema.Number>;
|
|
26
|
-
/** Unix ms timestamp when the object was last re-indexed. */
|
|
27
|
-
updatedAt: Schema.NullOr<typeof Schema.Number>;
|
|
28
|
-
}>;
|
|
29
|
-
export interface ObjectMeta extends Schema.Schema.Type<typeof ObjectMeta> {
|
|
30
|
-
}
|
|
31
|
-
export declare class ObjectMetaIndex implements Index {
|
|
32
|
-
migrate: () => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
|
|
33
|
-
query: (query: Pick<ObjectMeta, "spaceId" | "typeDxn">) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
|
|
34
|
-
queryAll: (query: {
|
|
35
|
-
spaceIds: readonly ObjectMeta["spaceId"][];
|
|
36
|
-
includeAllQueues?: boolean;
|
|
37
|
-
queueIds?: readonly string[] | null;
|
|
38
|
-
}) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
|
|
39
|
-
queryTypes: (args_0: {
|
|
40
|
-
spaceIds: readonly ObjectMeta["spaceId"][];
|
|
41
|
-
typeDxns: readonly ObjectMeta["typeDxn"][];
|
|
42
|
-
inverted?: boolean;
|
|
43
|
-
includeAllQueues?: boolean;
|
|
44
|
-
queueIds?: readonly string[] | null;
|
|
45
|
-
}) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
|
|
46
|
-
queryRelations: (args_0: {
|
|
47
|
-
endpoint: "source" | "target";
|
|
48
|
-
anchorDxns: readonly string[];
|
|
49
|
-
}) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
|
|
50
|
-
update: (objects: IndexerObject[]) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
|
|
51
|
-
/**
|
|
52
|
-
* Look up `recordIds` for objects that are already stored in the ObjectMetaIndex.
|
|
53
|
-
* Mutates the objects in place.
|
|
54
|
-
*/
|
|
55
|
-
lookupRecordIds: (objects: IndexerObject[]) => Effect.Effect<void, SqlError.SqlError, SqlClient.SqlClient>;
|
|
56
|
-
/**
|
|
57
|
-
* Look up object metadata by recordIds.
|
|
58
|
-
*/
|
|
59
|
-
lookupByRecordIds: (recordIds: number[]) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
|
|
60
|
-
/**
|
|
61
|
-
* Look up object metadata by objectId, spaceId, and queueId.
|
|
62
|
-
*/
|
|
63
|
-
lookupByObjectId: (query: {
|
|
64
|
-
objectId: string;
|
|
65
|
-
spaceId: string;
|
|
66
|
-
queueId: string;
|
|
67
|
-
}) => Effect.Effect<ObjectMeta | null, SqlError.SqlError, SqlClient.SqlClient>;
|
|
68
|
-
/**
|
|
69
|
-
* Query objects by timestamp range.
|
|
70
|
-
*/
|
|
71
|
-
queryByTimeRange: (query: {
|
|
72
|
-
spaceIds: readonly string[];
|
|
73
|
-
updatedAfter?: number;
|
|
74
|
-
updatedBefore?: number;
|
|
75
|
-
createdAfter?: number;
|
|
76
|
-
createdBefore?: number;
|
|
77
|
-
includeAllQueues?: boolean;
|
|
78
|
-
queueIds?: readonly string[] | null;
|
|
79
|
-
}) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
|
|
80
|
-
/**
|
|
81
|
-
* Query children by parent object ids.
|
|
82
|
-
*/
|
|
83
|
-
queryChildren: (query: {
|
|
84
|
-
spaceId: SpaceId[];
|
|
85
|
-
parentIds: ObjectId[];
|
|
86
|
-
}) => Effect.Effect<readonly ObjectMeta[], SqlError.SqlError, SqlClient.SqlClient>;
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=object-meta-index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-meta-index.d.ts","sourceRoot":"","sources":["../../../../src/indexes/object-meta-index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAO,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAUzC,eAAO,MAAM,UAAU;;;;;;;IAOrB,mDAAmD;;;;;IAKnD,mCAAmC;;IAEnC,sGAAsG;;IAEtG,2DAA2D;;IAE3D,6DAA6D;;EAE7D,CAAC;AACH,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC;CAAG;AAiC5E,qBAAa,eAAgB,YAAW,KAAK;IAC3C,OAAO,oEAgCJ;IAEH,KAAK,mIAoBH;IAEF,QAAQ;kBAEM,SAAS,UAAU,CAAC,SAAS,CAAC,EAAE;2BACvB,OAAO;mBACf,SAAS,MAAM,EAAE,GAAG,IAAI;uFAoBrC;IAEF,UAAU;kBAQI,SAAS,UAAU,CAAC,SAAS,CAAC,EAAE;kBAChC,SAAS,UAAU,CAAC,SAAS,CAAC,EAAE;mBAC/B,OAAO;2BACC,OAAO;mBACf,SAAS,MAAM,EAAE,GAAG,IAAI;uFAsCrC;IAEF,cAAc;kBAKA,QAAQ,GAAG,QAAQ;oBACjB,SAAS,MAAM,EAAE;uFAiB/B;IAGF,MAAM,4FA8EJ;IAEF;;;OAGG;IACH,eAAe,4FA+Bb;IAEF;;OAEG;IACH,iBAAiB,wGAef;IAEF;;OAEG;IACH,gBAAgB;kBAEF,MAAM;iBACP,MAAM;iBACN,MAAM;mFAgBjB;IAEF;;OAEG;IACH,gBAAgB;kBAEF,SAAS,MAAM,EAAE;uBACZ,MAAM;wBACL,MAAM;uBACP,MAAM;wBACL,MAAM;2BACH,OAAO;mBACf,SAAS,MAAM,EAAE,GAAG,IAAI;uFAuCrC;IAEF;;OAEG;IACH,aAAa;iBAEA,OAAO,EAAE;mBACP,QAAQ,EAAE;uFAgBvB;CACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-meta-index.test.d.ts","sourceRoot":"","sources":["../../../../src/indexes/object-meta-index.test.ts"],"names":[],"mappings":""}
|