@dxos/echo-query 0.8.4-main.422d1c7879 → 0.8.4-main.4f23b4e393
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/neutral/index.mjs +22 -17
- package/dist/lib/neutral/index.mjs.map +3 -3
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/query-lite/index.d.ts +55 -45
- package/dist/query-lite/index.d.ts.map +1 -1
- package/dist/query-lite/index.js +24 -8
- package/dist/query-lite/index.js.map +1 -1
- package/dist/types/src/parser/gen/index.d.ts.map +1 -1
- package/dist/types/src/parser/query-builder.d.ts.map +1 -1
- package/dist/types/src/query-lite/query-lite.d.ts.map +1 -1
- package/dist/types/src/sandbox/query-sandbox.d.ts.map +1 -1
- package/dist/types/src/sandbox/quickjs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/parser/query-builder.ts +21 -8
- package/src/query-lite/query-lite.ts +27 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/echo-query",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.4f23b4e393",
|
|
4
4
|
"description": "ECHO queries.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -32,22 +32,22 @@
|
|
|
32
32
|
"@lezer/common": "^1.2.2",
|
|
33
33
|
"@lezer/lezer": "^1.1.2",
|
|
34
34
|
"@lezer/lr": "^1.4.2",
|
|
35
|
-
"@dxos/context": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/echo": "0.8.4-main.
|
|
38
|
-
"@dxos/errors": "0.8.4-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/invariant": "0.8.4-main.
|
|
41
|
-
"@dxos/node-std": "0.8.4-main.
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
35
|
+
"@dxos/context": "0.8.4-main.4f23b4e393",
|
|
36
|
+
"@dxos/echo-protocol": "0.8.4-main.4f23b4e393",
|
|
37
|
+
"@dxos/echo": "0.8.4-main.4f23b4e393",
|
|
38
|
+
"@dxos/errors": "0.8.4-main.4f23b4e393",
|
|
39
|
+
"@dxos/debug": "0.8.4-main.4f23b4e393",
|
|
40
|
+
"@dxos/invariant": "0.8.4-main.4f23b4e393",
|
|
41
|
+
"@dxos/node-std": "0.8.4-main.4f23b4e393",
|
|
42
|
+
"@dxos/util": "0.8.4-main.4f23b4e393",
|
|
43
|
+
"@dxos/vendor-quickjs": "0.8.4-main.4f23b4e393"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@lezer/generator": "^1.7.1",
|
|
47
47
|
"tsdown": "^0.16.7",
|
|
48
48
|
"typescript": "^6.0.3",
|
|
49
|
-
"@dxos/echo-generator": "0.8.4-main.
|
|
50
|
-
"@dxos/random": "0.8.4-main.
|
|
49
|
+
"@dxos/echo-generator": "0.8.4-main.4f23b4e393",
|
|
50
|
+
"@dxos/random": "0.8.4-main.4f23b4e393"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
@@ -246,8 +246,9 @@ export class QueryBuilder {
|
|
|
246
246
|
let exprEnd = cursor.to;
|
|
247
247
|
|
|
248
248
|
while (cursor.nextSibling() && depth > 0) {
|
|
249
|
-
if (cursor.node.name === '(')
|
|
250
|
-
|
|
249
|
+
if (cursor.node.name === '(') {
|
|
250
|
+
depth++;
|
|
251
|
+
} else if (cursor.node.name === ')') {
|
|
251
252
|
depth--;
|
|
252
253
|
if (depth === 0) {
|
|
253
254
|
exprEnd = cursor.from;
|
|
@@ -681,12 +682,24 @@ export const normalizeInput = (input: string): string => {
|
|
|
681
682
|
let scanIndex = pos;
|
|
682
683
|
while (scanIndex < input.length) {
|
|
683
684
|
const innerChar = input[scanIndex];
|
|
684
|
-
if (innerChar === '"')
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (innerChar
|
|
688
|
-
|
|
689
|
-
|
|
685
|
+
if (innerChar === '"') {
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
if (innerChar === "'" && scanIndex > pos && !/[a-zA-Z0-9_]/.test(input[scanIndex - 1])) {
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
if (innerChar === "'" && scanIndex === pos) {
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
if (innerChar !== "'" && SPECIAL_CHARS.test(innerChar)) {
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
if (innerChar === '-' && input[scanIndex + 1] === '>') {
|
|
698
|
+
break;
|
|
699
|
+
}
|
|
700
|
+
if (innerChar === '<' && input[scanIndex + 1] === '-') {
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
690
703
|
scanIndex++;
|
|
691
704
|
}
|
|
692
705
|
// Defensive: if no characters were consumed, advance one to avoid infinite loops.
|
|
@@ -111,7 +111,7 @@ class FilterClass implements Filter$.Any {
|
|
|
111
111
|
}
|
|
112
112
|
return new FilterClass({
|
|
113
113
|
type: 'object',
|
|
114
|
-
typename:
|
|
114
|
+
typename: makeTypeDXN(schema),
|
|
115
115
|
...propsFilterToAst(props ?? {}),
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -119,7 +119,7 @@ class FilterClass implements Filter$.Any {
|
|
|
119
119
|
static typename(typename: string): Filter$.Any {
|
|
120
120
|
return new FilterClass({
|
|
121
121
|
type: 'object',
|
|
122
|
-
typename:
|
|
122
|
+
typename: makeTypeDXN(typename),
|
|
123
123
|
props: {},
|
|
124
124
|
});
|
|
125
125
|
}
|
|
@@ -451,7 +451,7 @@ class QueryClass implements Query$.Any {
|
|
|
451
451
|
from: {
|
|
452
452
|
_tag: 'scope',
|
|
453
453
|
scope: {
|
|
454
|
-
...(options?.includeFeeds ? {
|
|
454
|
+
...(options?.includeFeeds ? { allFeedsFromSpaces: true } : {}),
|
|
455
455
|
},
|
|
456
456
|
},
|
|
457
457
|
});
|
|
@@ -573,6 +573,21 @@ class QueryClass implements Query$.Any {
|
|
|
573
573
|
options,
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
|
+
|
|
577
|
+
debugLabel(label: string): Query$.Any {
|
|
578
|
+
if (this.ast.type === 'options') {
|
|
579
|
+
return new QueryClass({
|
|
580
|
+
type: 'options',
|
|
581
|
+
query: this.ast.query,
|
|
582
|
+
options: { ...this.ast.options, debugLabel: label },
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
return new QueryClass({
|
|
586
|
+
type: 'options',
|
|
587
|
+
query: this.ast,
|
|
588
|
+
options: { debugLabel: label },
|
|
589
|
+
});
|
|
590
|
+
}
|
|
576
591
|
}
|
|
577
592
|
|
|
578
593
|
export const Query1: typeof Query$ = QueryClass;
|
|
@@ -583,7 +598,7 @@ const isRef = (obj: any): obj is Ref.Ref<any> => {
|
|
|
583
598
|
return obj && typeof obj === 'object' && RefTypeId in obj;
|
|
584
599
|
};
|
|
585
600
|
|
|
586
|
-
const
|
|
601
|
+
const makeTypeDXN = (typename: string) => {
|
|
587
602
|
assertArgument(typeof typename === 'string', 'typename');
|
|
588
603
|
assertArgument(!typename.startsWith('dxn:'), 'typename');
|
|
589
604
|
return `dxn:type:${typename}`;
|
|
@@ -599,7 +614,7 @@ const isDxnLike = (value: unknown): value is DXN => {
|
|
|
599
614
|
);
|
|
600
615
|
};
|
|
601
616
|
|
|
602
|
-
const SCOPE_KEYS = new Set(['spaceIds', '
|
|
617
|
+
const SCOPE_KEYS = new Set(['spaceIds', 'feeds', 'allFeedsFromSpaces']);
|
|
603
618
|
|
|
604
619
|
const _isScopeLike = (value: unknown): value is QueryAST.Scope => {
|
|
605
620
|
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
@@ -701,6 +716,9 @@ const prettyQuery = (query: QueryAST.Query): string => {
|
|
|
701
716
|
if (query.options.deleted !== undefined) {
|
|
702
717
|
parts.push(`deleted: ${JSON.stringify(query.options.deleted)}`);
|
|
703
718
|
}
|
|
719
|
+
if (query.options.debugLabel !== undefined) {
|
|
720
|
+
parts.push(`debugLabel: ${JSON.stringify(query.options.debugLabel)}`);
|
|
721
|
+
}
|
|
704
722
|
return `${prettyQuery(query.query)}.options({ ${parts.join(', ')} })`;
|
|
705
723
|
}
|
|
706
724
|
case 'from': {
|
|
@@ -710,11 +728,11 @@ const prettyQuery = (query: QueryAST.Query): string => {
|
|
|
710
728
|
if (scope.spaceIds !== undefined) {
|
|
711
729
|
parts.push(`spaceIds: [${scope.spaceIds.join(', ')}]`);
|
|
712
730
|
}
|
|
713
|
-
if (scope.
|
|
714
|
-
parts.push(`
|
|
731
|
+
if (scope.feeds !== undefined) {
|
|
732
|
+
parts.push(`feeds: [${scope.feeds.join(', ')}]`);
|
|
715
733
|
}
|
|
716
|
-
if (scope.
|
|
717
|
-
parts.push(`
|
|
734
|
+
if (scope.allFeedsFromSpaces !== undefined) {
|
|
735
|
+
parts.push(`allFeedsFromSpaces: ${scope.allFeedsFromSpaces}`);
|
|
718
736
|
}
|
|
719
737
|
return `${prettyQuery(query.query)}.from({ ${parts.join(', ')} })`;
|
|
720
738
|
}
|