@dxos/assistant 0.8.2-main.fbd8ed0 → 0.8.2-staging.4d6ad0f
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 +1983 -64
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +1976 -63
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1984 -64
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/{src/bin → bin}/chat.d.ts.map +1 -1
- package/dist/types/src/blueprint/blueprint.d.ts +79 -0
- package/dist/types/src/blueprint/blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprint/blueprint.test.d.ts +2 -0
- package/dist/types/src/blueprint/blueprint.test.d.ts.map +1 -0
- package/dist/types/src/blueprint/index.d.ts +4 -0
- package/dist/types/src/blueprint/index.d.ts.map +1 -0
- package/dist/types/src/blueprint/logger.d.ts +3 -0
- package/dist/types/src/blueprint/logger.d.ts.map +1 -0
- package/dist/types/src/{ai-service/parser.d.ts → blueprint/machine.d.ts} +46 -68
- package/dist/types/src/blueprint/machine.d.ts.map +1 -0
- package/dist/types/src/blueprint/test-data.d.ts +3 -0
- package/dist/types/src/blueprint/test-data.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +4 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts +2 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.test.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/index.d.ts +2 -0
- package/dist/types/src/extraction/extraction-llm-function/index.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +210 -0
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts +2 -0
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.test.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/index.d.ts +3 -0
- package/dist/types/src/extraction/extraction-ner-function/index.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts +14 -0
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.test.d.ts +2 -0
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.test.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction.d.ts +242 -0
- package/dist/types/src/extraction/extraction.d.ts.map +1 -0
- package/dist/types/src/extraction/index.d.ts +5 -0
- package/dist/types/src/extraction/index.d.ts.map +1 -0
- package/dist/types/src/extraction/quotes.d.ts +15 -0
- package/dist/types/src/extraction/quotes.d.ts.map +1 -0
- package/dist/types/src/extraction/quotes.test.d.ts +2 -0
- package/dist/types/src/extraction/quotes.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/research/exa.d.ts +7 -0
- package/dist/types/src/research/exa.d.ts.map +1 -0
- package/dist/types/src/research/graph.d.ts +39 -0
- package/dist/types/src/research/graph.d.ts.map +1 -0
- package/dist/types/src/research/graph.test.d.ts +2 -0
- package/dist/types/src/research/graph.test.d.ts.map +1 -0
- package/dist/types/src/research/index.d.ts +4 -0
- package/dist/types/src/research/index.d.ts.map +1 -0
- package/dist/types/src/research/research.d.ts +10 -0
- package/dist/types/src/research/research.d.ts.map +1 -0
- package/dist/types/src/research/research.test.d.ts.map +1 -0
- package/dist/types/src/session/index.d.ts +0 -1
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +47 -22
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/session/version-pin.d.ts +3 -4
- package/dist/types/src/session/version-pin.d.ts.map +1 -1
- package/dist/types/src/summarization/summarization.test.d.ts +2 -0
- package/dist/types/src/summarization/summarization.test.d.ts.map +1 -0
- package/dist/types/src/testing/exa-search-1748337321991.d.ts +38 -0
- package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +1 -0
- package/dist/types/src/testing/exa-search-1748337331526.d.ts +37 -0
- package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +1 -0
- package/dist/types/src/testing/exa-search-1748337344119.d.ts +58 -0
- package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -7
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +3 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/package.json +22 -38
- package/src/blueprint/blueprint.test.ts +142 -0
- package/src/blueprint/blueprint.ts +95 -0
- package/src/blueprint/index.ts +7 -0
- package/src/blueprint/logger.ts +66 -0
- package/src/blueprint/machine.ts +208 -0
- package/src/blueprint/test-data.ts +55 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +95 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +64 -0
- package/src/extraction/extraction-llm-function/index.ts +5 -0
- package/src/extraction/extraction-llm-function/instructions.tpl +28 -0
- package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +115 -0
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +54 -0
- package/src/extraction/extraction-ner-function/index.ts +6 -0
- package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +94 -0
- package/src/extraction/extraction-ner-function/named-entity-recognition.ts +97 -0
- package/src/extraction/extraction.ts +75 -0
- package/src/extraction/index.ts +8 -0
- package/src/extraction/quotes.test.ts +27 -0
- package/src/extraction/quotes.ts +57 -0
- package/src/index.ts +4 -4
- package/src/research/exa.ts +100 -0
- package/src/research/graph.test.ts +15 -0
- package/src/research/graph.ts +291 -0
- package/src/research/index.ts +7 -0
- package/src/research/instructions-research.tpl +97 -0
- package/src/research/research.test.ts +189 -0
- package/src/research/research.ts +89 -0
- package/src/session/index.ts +0 -1
- package/src/session/session.test.ts +7 -7
- package/src/session/session.ts +46 -19
- package/src/session/version-pin.ts +2 -3
- package/src/summarization/summarization.test.ts +216 -0
- package/src/testing/exa-search-1748337321991.ts +131 -0
- package/src/testing/exa-search-1748337331526.ts +144 -0
- package/src/testing/exa-search-1748337344119.ts +133 -0
- package/src/testing/index.ts +8 -8
- package/src/types.ts +8 -0
- package/src/typings.d.ts +8 -0
- package/dist/lib/browser/chunk-B4HAWUFW.mjs +0 -2786
- package/dist/lib/browser/chunk-B4HAWUFW.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -658
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node/chunk-NOB7CIIC.cjs +0 -2791
- package/dist/lib/node/chunk-NOB7CIIC.cjs.map +0 -7
- package/dist/lib/node/testing/index.cjs +0 -672
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-SAWYU3V5.mjs +0 -2788
- package/dist/lib/node-esm/chunk-SAWYU3V5.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -659
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/ai-service/client.test.d.ts +0 -2
- package/dist/types/src/ai-service/client.test.d.ts.map +0 -1
- package/dist/types/src/ai-service/defs.d.ts +0 -9
- package/dist/types/src/ai-service/defs.d.ts.map +0 -1
- package/dist/types/src/ai-service/edge-client.d.ts +0 -18
- package/dist/types/src/ai-service/edge-client.d.ts.map +0 -1
- package/dist/types/src/ai-service/index.d.ts +0 -10
- package/dist/types/src/ai-service/index.d.ts.map +0 -1
- package/dist/types/src/ai-service/message-collector.d.ts +0 -82
- package/dist/types/src/ai-service/message-collector.d.ts.map +0 -1
- package/dist/types/src/ai-service/ollama-client.d.ts +0 -43
- package/dist/types/src/ai-service/ollama-client.d.ts.map +0 -1
- package/dist/types/src/ai-service/parser.d.ts.map +0 -1
- package/dist/types/src/ai-service/service.d.ts +0 -25
- package/dist/types/src/ai-service/service.d.ts.map +0 -1
- package/dist/types/src/ai-service/stream.d.ts +0 -40
- package/dist/types/src/ai-service/stream.d.ts.map +0 -1
- package/dist/types/src/ai-service/stream.test.d.ts +0 -2
- package/dist/types/src/ai-service/stream.test.d.ts.map +0 -1
- package/dist/types/src/ai-service/testing/index.d.ts +0 -3
- package/dist/types/src/ai-service/testing/index.d.ts.map +0 -1
- package/dist/types/src/ai-service/testing/mock.d.ts +0 -11
- package/dist/types/src/ai-service/testing/mock.d.ts.map +0 -1
- package/dist/types/src/ai-service/testing/test-stream.d.ts +0 -7
- package/dist/types/src/ai-service/testing/test-stream.d.ts.map +0 -1
- package/dist/types/src/ai-service/transform.d.ts +0 -27
- package/dist/types/src/ai-service/transform.d.ts.map +0 -1
- package/dist/types/src/ai-service/types.d.ts +0 -210
- package/dist/types/src/ai-service/types.d.ts.map +0 -1
- package/dist/types/src/ai-service/util/index.d.ts +0 -2
- package/dist/types/src/ai-service/util/index.d.ts.map +0 -1
- package/dist/types/src/ai-service/util/sse.d.ts +0 -39
- package/dist/types/src/ai-service/util/sse.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/conversation.d.ts +0 -61
- package/dist/types/src/experimental/conversation/conversation.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/conversation.test.d.ts +0 -2
- package/dist/types/src/experimental/conversation/conversation.test.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/index.d.ts +0 -2
- package/dist/types/src/experimental/conversation/index.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/types.d.ts +0 -78
- package/dist/types/src/experimental/conversation/types.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/ast.d.ts +0 -56
- package/dist/types/src/experimental/cypher/ast.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/combinators.d.ts +0 -14
- package/dist/types/src/experimental/cypher/combinators.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/combinators.test.d.ts +0 -2
- package/dist/types/src/experimental/cypher/combinators.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/echo-data-source.d.ts +0 -16
- package/dist/types/src/experimental/cypher/echo-data-source.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/execution-plan.d.ts +0 -49
- package/dist/types/src/experimental/cypher/execution-plan.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/execution-plan.test.d.ts +0 -2
- package/dist/types/src/experimental/cypher/execution-plan.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/index.d.ts +0 -5
- package/dist/types/src/experimental/cypher/index.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/parjs.d.ts +0 -4
- package/dist/types/src/experimental/cypher/parjs.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/parser.d.ts +0 -6
- package/dist/types/src/experimental/cypher/parser.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/query-executor.d.ts +0 -26
- package/dist/types/src/experimental/cypher/query-executor.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/query-executor.test.d.ts +0 -2
- package/dist/types/src/experimental/cypher/query-executor.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/schema.d.ts +0 -12
- package/dist/types/src/experimental/cypher/schema.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/schema.test.d.ts +0 -2
- package/dist/types/src/experimental/cypher/schema.test.d.ts.map +0 -1
- package/dist/types/src/experimental/index.d.ts +0 -3
- package/dist/types/src/experimental/index.d.ts.map +0 -1
- package/dist/types/src/experimental/ner/ner.test.d.ts +0 -2
- package/dist/types/src/experimental/ner/ner.test.d.ts.map +0 -1
- package/dist/types/src/experimental/research/exa.d.ts +0 -6
- package/dist/types/src/experimental/research/exa.d.ts.map +0 -1
- package/dist/types/src/experimental/research/research.test.d.ts.map +0 -1
- package/dist/types/src/session/tools.d.ts +0 -18
- package/dist/types/src/session/tools.d.ts.map +0 -1
- package/dist/types/src/testing/artifacts.test.d.ts +0 -1
- package/dist/types/src/testing/artifacts.test.d.ts.map +0 -1
- package/dist/types/src/testing/data.d.ts +0 -2
- package/dist/types/src/testing/data.d.ts.map +0 -1
- package/dist/types/src/testing/defs.d.ts +0 -5
- package/dist/types/src/testing/defs.d.ts.map +0 -1
- package/dist/types/src/testing/logger.d.ts +0 -12
- package/dist/types/src/testing/logger.d.ts.map +0 -1
- package/dist/types/src/testing/object-extraction.test.d.ts +0 -1
- package/dist/types/src/testing/object-extraction.test.d.ts.map +0 -1
- package/dist/types/src/testing/ollama.d.ts +0 -6
- package/dist/types/src/testing/ollama.d.ts.map +0 -1
- package/dist/types/src/testing/printer.d.ts +0 -6
- package/dist/types/src/testing/printer.d.ts.map +0 -1
- package/dist/types/src/testing/query-promts.d.ts +0 -5
- package/dist/types/src/testing/query-promts.d.ts.map +0 -1
- package/dist/types/src/testing/query.test.d.ts +0 -2
- package/dist/types/src/testing/query.test.d.ts.map +0 -1
- package/dist/types/src/testing/test-data.d.ts +0 -29
- package/dist/types/src/testing/test-data.d.ts.map +0 -1
- package/dist/types/src/testing/test-schema.d.ts +0 -52
- package/dist/types/src/testing/test-schema.d.ts.map +0 -1
- package/dist/types/src/util/index.d.ts +0 -2
- package/dist/types/src/util/index.d.ts.map +0 -1
- package/dist/types/src/util/trim.d.ts +0 -5
- package/dist/types/src/util/trim.d.ts.map +0 -1
- package/src/ai-service/client.test.ts +0 -247
- package/src/ai-service/defs.ts +0 -39
- package/src/ai-service/edge-client.ts +0 -60
- package/src/ai-service/index.ts +0 -13
- package/src/ai-service/message-collector.ts +0 -84
- package/src/ai-service/ollama-client.ts +0 -506
- package/src/ai-service/parser.ts +0 -369
- package/src/ai-service/service.ts +0 -31
- package/src/ai-service/stream.test.ts +0 -125
- package/src/ai-service/stream.ts +0 -118
- package/src/ai-service/testing/index.ts +0 -6
- package/src/ai-service/testing/mock.ts +0 -30
- package/src/ai-service/testing/test-stream.ts +0 -93
- package/src/ai-service/transform.ts +0 -121
- package/src/ai-service/types.ts +0 -112
- package/src/ai-service/util/index.ts +0 -5
- package/src/ai-service/util/sse.ts +0 -341
- package/src/bin/chat.ts +0 -79
- package/src/experimental/conversation/conversation.test.ts +0 -73
- package/src/experimental/conversation/conversation.ts +0 -142
- package/src/experimental/conversation/index.ts +0 -5
- package/src/experimental/conversation/types.ts +0 -126
- package/src/experimental/cypher/ast.ts +0 -75
- package/src/experimental/cypher/combinators.test.ts +0 -137
- package/src/experimental/cypher/combinators.ts +0 -148
- package/src/experimental/cypher/echo-data-source.ts +0 -105
- package/src/experimental/cypher/execution-plan.test.ts +0 -44
- package/src/experimental/cypher/execution-plan.ts +0 -208
- package/src/experimental/cypher/index.ts +0 -8
- package/src/experimental/cypher/parjs-shims.d.ts +0 -10
- package/src/experimental/cypher/parjs.ts +0 -10
- package/src/experimental/cypher/parser.ts +0 -19
- package/src/experimental/cypher/query-executor.test.ts +0 -47
- package/src/experimental/cypher/query-executor.ts +0 -145
- package/src/experimental/cypher/schema.test.ts +0 -17
- package/src/experimental/cypher/schema.ts +0 -86
- package/src/experimental/index.ts +0 -6
- package/src/experimental/ner/ner.test.ts +0 -163
- package/src/experimental/research/exa.ts +0 -38
- package/src/experimental/research/instructions.tpl +0 -64
- package/src/experimental/research/research.test.ts +0 -263
- package/src/session/tools.ts +0 -117
- package/src/testing/artifacts.test.ts +0 -182
- package/src/testing/data.ts +0 -13
- package/src/testing/defs.ts +0 -9
- package/src/testing/logger.ts +0 -129
- package/src/testing/object-extraction.test.ts +0 -71
- package/src/testing/ollama.ts +0 -15
- package/src/testing/printer.ts +0 -41
- package/src/testing/query-promts.ts +0 -75
- package/src/testing/query.test.ts +0 -88
- package/src/testing/test-data.ts +0 -379
- package/src/testing/test-schema.ts +0 -79
- package/src/util/index.ts +0 -5
- package/src/util/trim.ts +0 -15
- package/vendor/parjs-browser.mjs +0 -4
- package/vendor/parjs-default.mjs +0 -8
- /package/dist/types/{src/bin → bin}/chat.d.ts +0 -0
- /package/dist/types/src/{experimental/research → research}/research.test.d.ts +0 -0
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
/* eslint-disable unused-imports/no-unused-vars */
|
|
6
|
-
/* eslint-disable @typescript-eslint/consistent-type-imports */
|
|
7
|
-
|
|
8
|
-
import type {
|
|
9
|
-
CypherQuery,
|
|
10
|
-
EqualsPredicate,
|
|
11
|
-
GraphPattern,
|
|
12
|
-
GraphPatternConnector,
|
|
13
|
-
Identifier,
|
|
14
|
-
MatchClause,
|
|
15
|
-
MemberExpression,
|
|
16
|
-
NodePattern,
|
|
17
|
-
Properties,
|
|
18
|
-
Property,
|
|
19
|
-
RelationshipPattern,
|
|
20
|
-
ReturnClause,
|
|
21
|
-
StringLiteral,
|
|
22
|
-
WhereClause,
|
|
23
|
-
} from './ast';
|
|
24
|
-
import { Parjser, parjs, parjsCombinators } from './parjs';
|
|
25
|
-
|
|
26
|
-
// Helper parsers
|
|
27
|
-
const ws = parjs.whitespace(); // Parses whitespace
|
|
28
|
-
|
|
29
|
-
const nothing = parjs.string('').pipe(parjsCombinators.map(() => null)); // Parses nothing
|
|
30
|
-
|
|
31
|
-
const optional = <T>(parser: Parjser<T>) =>
|
|
32
|
-
parser.pipe(
|
|
33
|
-
parjsCombinators.recover(() => ({ kind: 'Soft' })),
|
|
34
|
-
parjsCombinators.or(nothing),
|
|
35
|
-
); // Makes a parser optional
|
|
36
|
-
|
|
37
|
-
const keyword = (word: string) => parjs.string(word).pipe(parjsCombinators.map(() => word)); // Parses specific keywords
|
|
38
|
-
|
|
39
|
-
// Identifiers (node labels, relationship types, variables, etc.)
|
|
40
|
-
export const identifier = parjs.regexp(/[a-zA-Z_][a-zA-Z0-9_]*/).pipe(
|
|
41
|
-
parjsCombinators.map((match): Identifier => ({ astKind: 'Identifier', name: match[0] })), // Extract the matched string
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
// Literals (numbers and strings)
|
|
45
|
-
const numberLiteral = parjs.regexp(/-?\d+(\.\d+)?/).pipe(parjsCombinators.map(Number)); // Numbers
|
|
46
|
-
const stringLiteral = parjs.regexp(/"([^"]*)"|'([^']*)'/).pipe(
|
|
47
|
-
parjsCombinators.map((match): StringLiteral => ({ astKind: 'StringLiteral', value: match[1] || match[2] })), // Extract content without quotes
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// Node pattern (e.g., "(n:Person {name: 'John'})"
|
|
51
|
-
const variableTag = identifier.pipe(parjsCombinators.map((variable) => variable)).expects('variable tag');
|
|
52
|
-
export const label = identifier.pipe(parjsCombinators.map((name) => name));
|
|
53
|
-
export const property = identifier.pipe(
|
|
54
|
-
parjsCombinators.then(parjs.string(':'), ws, stringLiteral),
|
|
55
|
-
parjsCombinators.map(([key, , , value]): Property => ({ key, value })),
|
|
56
|
-
);
|
|
57
|
-
export const properties = property.pipe(
|
|
58
|
-
parjsCombinators.manySepBy(','),
|
|
59
|
-
parjsCombinators.between('{', '}'),
|
|
60
|
-
parjsCombinators.map((properties): Properties => ({ astKind: 'Properties', properties })),
|
|
61
|
-
);
|
|
62
|
-
export const nodePattern = optional(variableTag).pipe(
|
|
63
|
-
parjsCombinators.then(':'),
|
|
64
|
-
parjsCombinators.then(ws, label, ws),
|
|
65
|
-
parjsCombinators.then(optional(properties)),
|
|
66
|
-
parjsCombinators.between('(', ')'),
|
|
67
|
-
parjsCombinators.map(
|
|
68
|
-
([[[variable], _, label], properties]): NodePattern => ({ astKind: 'NodePattern', variable, label, properties }),
|
|
69
|
-
),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
export const relationshipPattern = optional(variableTag).pipe(
|
|
73
|
-
parjsCombinators.then(':'),
|
|
74
|
-
parjsCombinators.then(ws, label, ws),
|
|
75
|
-
parjsCombinators.then(optional(properties)),
|
|
76
|
-
parjsCombinators.between('[', ']'),
|
|
77
|
-
parjsCombinators.map(
|
|
78
|
-
([[[variable], _, label], properties]): RelationshipPattern => ({
|
|
79
|
-
astKind: 'RelationshipPattern',
|
|
80
|
-
variable,
|
|
81
|
-
label,
|
|
82
|
-
properties,
|
|
83
|
-
}),
|
|
84
|
-
),
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
const graphPatternConnector = parjs.string('->').pipe(
|
|
88
|
-
parjsCombinators.or('<-' as const, '-' as const),
|
|
89
|
-
parjsCombinators.map((x): GraphPatternConnector => ({ astKind: 'GraphPatternConnector', direction: x })),
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
export const graphPattern = nodePattern.pipe(
|
|
93
|
-
parjsCombinators.or(relationshipPattern),
|
|
94
|
-
parjsCombinators.manySepBy(graphPatternConnector),
|
|
95
|
-
parjsCombinators.map((segments): GraphPattern => ({ astKind: 'GraphPattern', segments })),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
export const matchClause = keyword('MATCH').pipe(
|
|
99
|
-
parjsCombinators.then(ws),
|
|
100
|
-
parjsCombinators.then(graphPattern),
|
|
101
|
-
parjsCombinators.map(([, pattern]): MatchClause => ({ astKind: 'MatchClause', pattern })),
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const memberExpression = identifier.pipe(
|
|
105
|
-
parjsCombinators.manySepBy('.'),
|
|
106
|
-
parjsCombinators.map((path): MemberExpression => ({ astKind: 'MemberExpression', path })),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const equalsPredicate = memberExpression.pipe(
|
|
110
|
-
parjsCombinators.then(ws, parjs.string('='), ws, stringLiteral),
|
|
111
|
-
parjsCombinators.map(([left, , , , right]): EqualsPredicate => ({ astKind: 'EqualsPredicate', left, right })),
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
export const whereClause = keyword('WHERE').pipe(
|
|
115
|
-
parjsCombinators.then(
|
|
116
|
-
ws,
|
|
117
|
-
equalsPredicate.pipe(parjsCombinators.between(ws, ws), parjsCombinators.manySepBy(parjs.string('AND'))),
|
|
118
|
-
ws,
|
|
119
|
-
),
|
|
120
|
-
parjsCombinators.map(([, , predicates]): WhereClause => ({ astKind: 'WhereClause', predicates })),
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
export const returnClause = keyword('RETURN').pipe(
|
|
124
|
-
parjsCombinators.then(
|
|
125
|
-
ws,
|
|
126
|
-
memberExpression.pipe(
|
|
127
|
-
parjsCombinators.then(
|
|
128
|
-
optional(parjs.string('AS').pipe(parjsCombinators.between(ws), parjsCombinators.then(identifier))),
|
|
129
|
-
ws,
|
|
130
|
-
),
|
|
131
|
-
parjsCombinators.manySepBy(parjs.string(',').pipe(parjsCombinators.then(ws))),
|
|
132
|
-
),
|
|
133
|
-
ws,
|
|
134
|
-
),
|
|
135
|
-
parjsCombinators.map(([, , fields]): ReturnClause => ({ astKind: 'ReturnClause', fields: fields.map(([f]) => f) })),
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
export const cypherQuery = ws.pipe(
|
|
139
|
-
parjsCombinators.then(matchClause, ws, optional(whereClause), ws, returnClause, ws),
|
|
140
|
-
parjsCombinators.map(
|
|
141
|
-
([, matchClause, , whereClause, , returnClause]): CypherQuery => ({
|
|
142
|
-
astKind: 'CypherQuery',
|
|
143
|
-
matchClause,
|
|
144
|
-
whereClause,
|
|
145
|
-
returnClause,
|
|
146
|
-
}),
|
|
147
|
-
),
|
|
148
|
-
);
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import { raise } from '@dxos/debug';
|
|
8
|
-
import { type EchoDatabase, Filter, type AnyLiveObject } from '@dxos/echo-db';
|
|
9
|
-
import { getSchema, getSchemaTypename, StoredSchema, toJsonSchema } from '@dxos/echo-schema';
|
|
10
|
-
import { log } from '@dxos/log';
|
|
11
|
-
|
|
12
|
-
import type { DataSource, Node, Relationship } from './query-executor';
|
|
13
|
-
import { formatInferredRelationshipLabel, formatNodeLabel, isReference } from './schema';
|
|
14
|
-
|
|
15
|
-
export class EchoDataSource implements DataSource {
|
|
16
|
-
constructor(private readonly _db: EchoDatabase) {}
|
|
17
|
-
|
|
18
|
-
@log.method()
|
|
19
|
-
async getNodes({ label }: { label?: string }): Promise<Node[]> {
|
|
20
|
-
if (!label) {
|
|
21
|
-
const { objects } = await this._db.query().run();
|
|
22
|
-
return objects.map(this._objectToNode);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const schema = (await this._getAllSchema()).find((schema) => getSchemaTypename(schema)?.endsWith(label));
|
|
26
|
-
if (!schema) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const { objects } = await this._db.query(Filter.type(schema)).run();
|
|
31
|
-
return objects.map(this._objectToNode);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@log.method()
|
|
35
|
-
async getRelationships({ label }: { label?: string }): Promise<Relationship[]> {
|
|
36
|
-
const syntheticRefRelationships = (await this._getAllSchema())
|
|
37
|
-
.filter((schema) => getSchemaTypename(schema) !== StoredSchema.typename)
|
|
38
|
-
.flatMap((schema) => {
|
|
39
|
-
const jsonSchema = toJsonSchema(schema);
|
|
40
|
-
const relationships = Object.entries(jsonSchema.properties!).filter(([key, prop]) => isReference(prop));
|
|
41
|
-
|
|
42
|
-
return relationships.map(([key, value]) => {
|
|
43
|
-
const relationshipLabel = formatInferredRelationshipLabel(
|
|
44
|
-
jsonSchema.typename ?? raise(new Error('Schema must have typename')),
|
|
45
|
-
key,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
label: relationshipLabel,
|
|
50
|
-
schema,
|
|
51
|
-
property: key,
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
const relationship = syntheticRefRelationships.find((r) => r.label === label);
|
|
56
|
-
if (!relationship) {
|
|
57
|
-
return []; // TODO(dmaretskyi): Handle real relationships.
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const { objects } = await this._db.query(Filter.type(relationship.schema)).run();
|
|
61
|
-
return (
|
|
62
|
-
await Promise.all(objects.map((object) => this._projectRefRelationship(object, relationship.property)))
|
|
63
|
-
).flat();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private async _getAllSchema(): Promise<Schema.Schema.AnyNoContext[]> {
|
|
67
|
-
return [
|
|
68
|
-
...(await this._db.schemaRegistry.query().run()),
|
|
69
|
-
// TODO(dmaretskyi): Remove once we can serialize recursive schema.
|
|
70
|
-
...this._db.graph.schemaRegistry.schemas.filter((schema) => getSchemaTypename(schema)?.startsWith('example.org')),
|
|
71
|
-
].filter((schema) => getSchemaTypename(schema) !== StoredSchema.typename);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private _objectToNode(object: AnyLiveObject<any>): Node {
|
|
75
|
-
const { id, ...properties } = object;
|
|
76
|
-
return {
|
|
77
|
-
id,
|
|
78
|
-
kind: 'node',
|
|
79
|
-
label: formatNodeLabel(getSchemaTypename(getSchema(object)!)!),
|
|
80
|
-
properties,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private async _projectRefRelationship(object: AnyLiveObject<any>, prop: string): Promise<Relationship[]> {
|
|
85
|
-
if (!object[prop]) {
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const value = Array.isArray(object[prop]) ? object[prop] : [object[prop]];
|
|
90
|
-
|
|
91
|
-
return Promise.all(
|
|
92
|
-
value.map(async (ref): Promise<Relationship> => {
|
|
93
|
-
const target = await ref.load();
|
|
94
|
-
return {
|
|
95
|
-
id: `${object.id}-${prop}-${target.id}`,
|
|
96
|
-
kind: 'relationship',
|
|
97
|
-
label: formatInferredRelationshipLabel(getSchemaTypename(getSchema(object)!)!, prop),
|
|
98
|
-
properties: {},
|
|
99
|
-
source: this._objectToNode(object),
|
|
100
|
-
target: this._objectToNode(target),
|
|
101
|
-
};
|
|
102
|
-
}),
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { describe, test } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { log } from '@dxos/log';
|
|
8
|
-
|
|
9
|
-
import { createExecutionPlan } from './execution-plan';
|
|
10
|
-
import { parseCypherQuery } from './parser';
|
|
11
|
-
|
|
12
|
-
// log.config({ filter: 'debug' });
|
|
13
|
-
|
|
14
|
-
describe('Execution Plan', () => {
|
|
15
|
-
test('trivial', ({ expect }) => {
|
|
16
|
-
const plan = createExecutionPlan(parseCypherQuery('MATCH (n:Person) RETURN n'));
|
|
17
|
-
log('', { plan });
|
|
18
|
-
expect(plan.steps.map((step) => step.type)).toEqual(['NodeScan', 'ProduceResults']);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('complex query', ({ expect }) => {
|
|
22
|
-
const plan = createExecutionPlan(
|
|
23
|
-
parseCypherQuery(
|
|
24
|
-
"MATCH (org:Organization {name: 'DXOS'})-[:ORG_EMPLOYEES]->(c:Contact)<-[:TASK_ASSIGNEE]-(:Task)-[:TASK_PROJECT]->(p:Project {name: 'Composer'}) RETURN c.name",
|
|
25
|
-
),
|
|
26
|
-
);
|
|
27
|
-
log('', { plan });
|
|
28
|
-
for (const step of plan.steps) {
|
|
29
|
-
log('step', { step });
|
|
30
|
-
}
|
|
31
|
-
expect(plan.steps.map((step) => step.type)).toEqual([
|
|
32
|
-
'NodeScan',
|
|
33
|
-
'FilterByProperty',
|
|
34
|
-
'RelationshipScan',
|
|
35
|
-
'FilterByLabel',
|
|
36
|
-
'RelationshipScan',
|
|
37
|
-
'FilterByLabel',
|
|
38
|
-
'RelationshipScan',
|
|
39
|
-
'FilterByLabel',
|
|
40
|
-
'FilterByProperty',
|
|
41
|
-
'ProduceResults',
|
|
42
|
-
]);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import type { JsonPath } from '@dxos/echo-schema';
|
|
6
|
-
import { invariant } from '@dxos/invariant';
|
|
7
|
-
import { log } from '@dxos/log';
|
|
8
|
-
|
|
9
|
-
import type { GraphPatternConnector, MatchClause, ReturnClause, WhereClause } from './ast';
|
|
10
|
-
import type { ParsedQuery } from './parser';
|
|
11
|
-
|
|
12
|
-
export type VariableName = string & { __VariableName: never };
|
|
13
|
-
|
|
14
|
-
export type ExecutionPlanStep =
|
|
15
|
-
| {
|
|
16
|
-
type: 'NodeScan';
|
|
17
|
-
label: string;
|
|
18
|
-
into: VariableName;
|
|
19
|
-
}
|
|
20
|
-
| {
|
|
21
|
-
type: 'FilterByLabel';
|
|
22
|
-
variable: VariableName;
|
|
23
|
-
label: string;
|
|
24
|
-
}
|
|
25
|
-
| {
|
|
26
|
-
type: 'FilterByProperty';
|
|
27
|
-
variable: VariableName;
|
|
28
|
-
property: JsonPath;
|
|
29
|
-
value: unknown;
|
|
30
|
-
}
|
|
31
|
-
| {
|
|
32
|
-
/**
|
|
33
|
-
* Scans (anchor)-[relationshipInto:label]->(nodeInto).
|
|
34
|
-
*/
|
|
35
|
-
type: 'RelationshipScan';
|
|
36
|
-
label: string;
|
|
37
|
-
anchor: VariableName;
|
|
38
|
-
relationshipInto: VariableName;
|
|
39
|
-
nodeInto: VariableName;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* `in`: (anchor)<-[relationshipInto:label]-(nodeInto)
|
|
43
|
-
* `out`: (anchor)-[relationshipInto:label]->(nodeInto)
|
|
44
|
-
* `both`: (anchor)-[relationshipInto:label]-(nodeInto)
|
|
45
|
-
*/
|
|
46
|
-
direction: 'in' | 'out' | 'both';
|
|
47
|
-
}
|
|
48
|
-
| {
|
|
49
|
-
type: 'ProduceResults';
|
|
50
|
-
fields: {
|
|
51
|
-
name: string;
|
|
52
|
-
variable: VariableName;
|
|
53
|
-
path: JsonPath;
|
|
54
|
-
}[];
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type ExecutionPlan = {
|
|
58
|
-
steps: ExecutionPlanStep[];
|
|
59
|
-
output: {
|
|
60
|
-
fields: string[];
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const createExecutionPlan = (query: ParsedQuery): ExecutionPlan => {
|
|
65
|
-
return new ExecutionPlanBuilder().build(query);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
class ExecutionPlanBuilder {
|
|
69
|
-
private counter = 0;
|
|
70
|
-
|
|
71
|
-
newVariable(): VariableName {
|
|
72
|
-
return `anon_${this.counter++}` as VariableName;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
build(query: ParsedQuery): ExecutionPlan {
|
|
76
|
-
log('Creating execution plan for query', { query });
|
|
77
|
-
return {
|
|
78
|
-
steps: [
|
|
79
|
-
...this.createStepsForMatchClause(query.ast.matchClause),
|
|
80
|
-
...(query.ast.whereClause ? this.createStepsForWhereClause(query.ast.whereClause) : []),
|
|
81
|
-
...this.createStepsForReturnClause(query.ast.returnClause),
|
|
82
|
-
],
|
|
83
|
-
output: {
|
|
84
|
-
fields: this.getOutputFields(query.ast.returnClause),
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
createStepsForMatchClause(match: MatchClause): ExecutionPlanStep[] {
|
|
90
|
-
invariant(match.pattern.segments.length > 0);
|
|
91
|
-
const firstSegment = match.pattern.segments[0];
|
|
92
|
-
invariant(firstSegment.astKind === 'NodePattern');
|
|
93
|
-
let lastNodeVariable = (firstSegment.variable?.name as VariableName) ?? this.newVariable();
|
|
94
|
-
|
|
95
|
-
const steps: ExecutionPlanStep[] = [];
|
|
96
|
-
steps.push({
|
|
97
|
-
type: 'NodeScan',
|
|
98
|
-
label: firstSegment.label.name,
|
|
99
|
-
into: lastNodeVariable,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
if (firstSegment.properties) {
|
|
103
|
-
for (const property of firstSegment.properties.properties) {
|
|
104
|
-
steps.push({
|
|
105
|
-
type: 'FilterByProperty',
|
|
106
|
-
variable: lastNodeVariable,
|
|
107
|
-
property: property.key.name as JsonPath,
|
|
108
|
-
value: property.value.value,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
for (let i = 1; i < match.pattern.segments.length; i++) {
|
|
114
|
-
const relationshipSegment = match.pattern.segments[i++];
|
|
115
|
-
invariant(relationshipSegment.astKind === 'RelationshipPattern');
|
|
116
|
-
const nodeSegment = match.pattern.segments[i];
|
|
117
|
-
invariant(nodeSegment.astKind === 'NodePattern');
|
|
118
|
-
const leftSeparator = match.pattern.segments.separators[i - 2];
|
|
119
|
-
const rightSeparator = match.pattern.segments.separators[i - 1];
|
|
120
|
-
const direction = getDirection(leftSeparator.direction, rightSeparator.direction);
|
|
121
|
-
|
|
122
|
-
const relationshipVariable = (relationshipSegment.variable?.name as VariableName) ?? this.newVariable();
|
|
123
|
-
const nodeVariable = (nodeSegment.variable?.name as VariableName) ?? this.newVariable();
|
|
124
|
-
|
|
125
|
-
steps.push({
|
|
126
|
-
type: 'RelationshipScan',
|
|
127
|
-
label: relationshipSegment.label.name,
|
|
128
|
-
direction,
|
|
129
|
-
anchor: lastNodeVariable,
|
|
130
|
-
relationshipInto: relationshipVariable,
|
|
131
|
-
nodeInto: nodeVariable,
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
if (relationshipSegment.properties) {
|
|
135
|
-
for (const property of relationshipSegment.properties.properties) {
|
|
136
|
-
steps.push({
|
|
137
|
-
type: 'FilterByProperty',
|
|
138
|
-
variable: relationshipVariable,
|
|
139
|
-
property: property.key.name as JsonPath,
|
|
140
|
-
value: property.value.value,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (nodeSegment.label) {
|
|
145
|
-
steps.push({
|
|
146
|
-
type: 'FilterByLabel',
|
|
147
|
-
variable: nodeVariable,
|
|
148
|
-
label: nodeSegment.label.name,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
if (nodeSegment.properties) {
|
|
152
|
-
for (const property of nodeSegment.properties.properties) {
|
|
153
|
-
steps.push({
|
|
154
|
-
type: 'FilterByProperty',
|
|
155
|
-
variable: nodeVariable,
|
|
156
|
-
property: property.key.name as JsonPath,
|
|
157
|
-
value: property.value.value,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
lastNodeVariable = nodeVariable;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return steps;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
createStepsForWhereClause(where: WhereClause): ExecutionPlanStep[] {
|
|
169
|
-
return [];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
createStepsForReturnClause(returnClause: ReturnClause): ExecutionPlanStep[] {
|
|
173
|
-
return [
|
|
174
|
-
{
|
|
175
|
-
type: 'ProduceResults',
|
|
176
|
-
fields: returnClause.fields.map((field) => ({
|
|
177
|
-
name: field.path.map((p) => p.name).join('_'),
|
|
178
|
-
variable: field.path[0].name as VariableName,
|
|
179
|
-
path:
|
|
180
|
-
field.path.length > 1
|
|
181
|
-
? (field.path
|
|
182
|
-
.slice(1)
|
|
183
|
-
.map((p) => p.name)
|
|
184
|
-
.join('.') as JsonPath)
|
|
185
|
-
: ('$' as JsonPath),
|
|
186
|
-
})),
|
|
187
|
-
},
|
|
188
|
-
];
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
getOutputFields(returnClause: ReturnClause): string[] {
|
|
192
|
-
return returnClause.fields.map((field) => field.path.map((p) => p.name).join('_'));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const getDirection = (
|
|
197
|
-
left: GraphPatternConnector['direction'],
|
|
198
|
-
right: GraphPatternConnector['direction'],
|
|
199
|
-
): 'in' | 'out' | 'both' => {
|
|
200
|
-
if (left === '-' && right === '->') {
|
|
201
|
-
return 'out';
|
|
202
|
-
} else if (left === '<-' && right === '-') {
|
|
203
|
-
return 'in';
|
|
204
|
-
} else if (left === '-' && right === '-') {
|
|
205
|
-
return 'both';
|
|
206
|
-
}
|
|
207
|
-
throw new Error(`Invalid direction: ()${left}[]${right}()`);
|
|
208
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import type { CypherQuery } from './ast';
|
|
6
|
-
import { cypherQuery } from './combinators';
|
|
7
|
-
|
|
8
|
-
export type ParsedQuery = {
|
|
9
|
-
ast: CypherQuery;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const parseCypherQuery = (query: string): ParsedQuery => {
|
|
13
|
-
const parseResult = cypherQuery.parse(query);
|
|
14
|
-
if (parseResult.isOk) {
|
|
15
|
-
return { ast: parseResult.value };
|
|
16
|
-
} else {
|
|
17
|
-
throw new Error(`Failed to parse query: ${parseResult}`);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { test } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { log } from '@dxos/log';
|
|
8
|
-
|
|
9
|
-
import { executeQuery } from './query-executor';
|
|
10
|
-
import { createTestData } from '../../testing';
|
|
11
|
-
|
|
12
|
-
test.skip('run', async ({ expect }) => {
|
|
13
|
-
const dataSource = createTestData();
|
|
14
|
-
// for (const node of dataSource.nodes) {
|
|
15
|
-
// log('node', { id: node.id, label: node.label, name: node.properties.name });
|
|
16
|
-
// }
|
|
17
|
-
// for (const relationship of dataSource.relationships) {
|
|
18
|
-
// log('relationship', {
|
|
19
|
-
// source: relationship.source.id,
|
|
20
|
-
// target: relationship.target.id,
|
|
21
|
-
// label: relationship.label,
|
|
22
|
-
// });
|
|
23
|
-
// }
|
|
24
|
-
|
|
25
|
-
const result = await executeQuery(
|
|
26
|
-
dataSource,
|
|
27
|
-
`
|
|
28
|
-
MATCH (org:Organization {name: 'DXOS'})-[:ORG_EMPLOYEES]->(c:Contact)<-[:TASK_ASSIGNEE]-(t:Task)-[:TASK_PROJECT]->(p:Project {name: 'Composer'})
|
|
29
|
-
RETURN c.name, t.name
|
|
30
|
-
`,
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
expect(result).toEqual([
|
|
34
|
-
{ c_name: 'Rich', t_name: 'Create form builder' },
|
|
35
|
-
{
|
|
36
|
-
c_name: 'Josiah',
|
|
37
|
-
t_name: 'Optimize startup performance',
|
|
38
|
-
},
|
|
39
|
-
{ c_name: 'Rich', t_name: 'Implement dark mode' },
|
|
40
|
-
{
|
|
41
|
-
c_name: 'Josiah',
|
|
42
|
-
t_name: 'Add support for custom themes',
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
|
-
log('result', { result });
|
|
47
|
-
});
|