@lionweb/delta-protocol-test-cli 0.8.0-beta.1 → 0.8.0-beta.2
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/cli-client.js +4 -12
- package/dist/cli-client.js.map +1 -1
- package/dist/tasks.d.ts +1 -2
- package/dist/tasks.d.ts.map +1 -1
- package/dist/tasks.js +21 -9
- package/dist/tasks.js.map +1 -1
- package/package.json +10 -10
- package/src/cli-client.ts +4 -16
- package/src/tasks.ts +30 -10
package/dist/cli-client.js
CHANGED
|
@@ -28,9 +28,7 @@ const { clientInfo, genericError } = ansi;
|
|
|
28
28
|
const testLanguageBase = TestLanguageBase.INSTANCE;
|
|
29
29
|
const languageBases = [testLanguageBase];
|
|
30
30
|
const boldRedIf = (apply, text) => apply ? genericError(text) : text;
|
|
31
|
-
|
|
32
|
-
.map((concept) => [concept.name, concept]));
|
|
33
|
-
// $ node dist/cli-client.js <port> <clientID> <partitionConcept> [tasks] [--${protocolLogOptionPrefix}=<path>]
|
|
31
|
+
// $ node dist/cli-client.js <port> <clientID> [tasks] [--${protocolLogOptionPrefix}=<path>]
|
|
34
32
|
const protocolLogOptionPrefix = "--protocol-log=";
|
|
35
33
|
const protocolLogPathIndex = argv.findIndex((argument) => argument.startsWith(protocolLogOptionPrefix));
|
|
36
34
|
// arguments without "node" (index=0), "dist/cli-client.js" (index=1), and `${protocolLogOptionPrefix}=<path>` (optional)
|
|
@@ -41,8 +39,7 @@ if (trueArguments.length < 3) {
|
|
|
41
39
|
Parameters (${genericError("bold red")} are missing):
|
|
42
40
|
- ${boldRedIf(trueArguments.length < 1, `<port>: the port of the WebSocket where the LionWeb delta protocol repository is running on localhost`)}
|
|
43
41
|
- ${boldRedIf(trueArguments.length < 2, `<clientID>: the ID that the client identifies itself with at the repository`)}
|
|
44
|
-
- ${boldRedIf(trueArguments.length < 3,
|
|
45
|
-
- ${boldRedIf(trueArguments.length < 4, `[tasks]: a comma-separated list of tasks — one of ${Object.keys(recognizedTasks).sort().join(", ")}`)}
|
|
42
|
+
- ${boldRedIf(trueArguments.length < 3, `[tasks]: a comma-separated list of tasks — one of ${Object.keys(recognizedTasks).sort().join(", ")}`)}
|
|
46
43
|
- ${boldRedIf(protocolLogPathIndex === -1, `${protocolLogOptionPrefix}=<path>: option to configure that the client logs all messages exchanged with the repository to a file with the given path`)}
|
|
47
44
|
|
|
48
45
|
ASSUMPTION: the initial (states of the models) on client(s) and repository are identical!
|
|
@@ -51,12 +48,7 @@ Parameters (${genericError("bold red")} are missing):
|
|
|
51
48
|
}
|
|
52
49
|
const port = tryParseInteger(argv[2]);
|
|
53
50
|
const clientId = argv[3];
|
|
54
|
-
const
|
|
55
|
-
if (!(partitionConcept in partitionConcepts)) {
|
|
56
|
-
console.error(genericError(`unknown partition concept specified: ${partitionConcept} — must be one of: ${Object.keys(partitionConcepts).join(", ")}`));
|
|
57
|
-
exit(2);
|
|
58
|
-
}
|
|
59
|
-
const tasks = argv[5]?.split(",") ?? [];
|
|
51
|
+
const tasks = argv[4]?.split(",") ?? [];
|
|
60
52
|
console.log(clientInfo(`tasks provided: ${tasks.length === 0 ? "none" : tasks.join(", ")}`));
|
|
61
53
|
const infoUnrecognizedTasks = tasks
|
|
62
54
|
.map((task, index) => task in recognizedTasks ? undefined : [task, index])
|
|
@@ -82,7 +74,7 @@ await runAsApp(async () => {
|
|
|
82
74
|
})
|
|
83
75
|
});
|
|
84
76
|
console.log(clientInfo(`LionWeb delta protocol client (with ID=${clientId}) connecting to repository on ${url} - press Ctrl+C to terminate`));
|
|
85
|
-
const executeTask = taskExecutor(lionWebClient,
|
|
77
|
+
const executeTask = taskExecutor(lionWebClient, semanticLogItems);
|
|
86
78
|
let querySequenceNumber = 0;
|
|
87
79
|
const queryId = () => `query-${++querySequenceNumber}`;
|
|
88
80
|
for (const task of tasks) {
|
package/dist/cli-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-client.js","sourceRoot":"","sources":["../src/cli-client.ts"],"names":[],"mappings":";AAEA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"cli-client.js","sourceRoot":"","sources":["../src/cli-client.ts"],"names":[],"mappings":";AAEA,wDAAwD;AACxD,EAAE;AACF,iEAAiE;AACjE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,sCAAsC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,aAAa,EAAyB,MAAM,gCAAgC,CAAA;AACrF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAA;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE1D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;AAGzC,MAAM,gBAAgB,GAA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aAAa,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC;QAC7C,QAAQ;QACR,GAAG;QACH,aAAa;QACb,cAAc,EAAE,OAAO,CAAC,qBAAqB,EAAE,aAAa,CAAC;QAC7D,0BAA0B,EAAE,KAAK,EAAE,wBAAwB,EAAE,EAAE,CAC3D,MAAM,sBAAsB,CACxB,wBAAwB,EACxB,CAAC,OAAO,EAAE,EAAE;YACR,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC1B,CAAC,CACJ;KACR,CAAC,CAAA;IAEF,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,0CAA0C,QAAQ,iCAAiC,GAAG,8BAA8B,CAAC,CAAC,CAAA;IAE7I,MAAM,WAAW,GAAG,YAAY,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAA;IAEjE,IAAI,mBAAmB,GAAG,CAAC,CAAA;IAC3B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,EAAE,mBAAmB,EAAE,CAAA;IAEtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;IACtC,CAAC;IAED,IAAI,oBAAoB,GAAG,CAAC,CAAC,EAAE,CAAC;QAC5B,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,SAAS,CAAC,uBAAuB,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAA;IACnG,CAAC;IAED,OAAO,GAAG,EAAE;QACR,OAAO,aAAa,CAAC,UAAU,EAAE,CAAA;IACrC,CAAC,CAAA;AACL,CAAC,CAAC,CAAA"}
|
package/dist/tasks.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Concept } from "@lionweb/core";
|
|
2
1
|
import { LionWebClient } from "@lionweb/delta-protocol-client";
|
|
3
2
|
import { ISemanticLogItem } from "@lionweb/delta-protocol-common";
|
|
4
3
|
/**
|
|
@@ -9,5 +8,5 @@ import { ISemanticLogItem } from "@lionweb/delta-protocol-common";
|
|
|
9
8
|
* inside the build package to generate the contents of the following object.
|
|
10
9
|
*/
|
|
11
10
|
export declare const recognizedTasks: Record<string, boolean>;
|
|
12
|
-
export declare const taskExecutor: (lionWebClient: LionWebClient,
|
|
11
|
+
export declare const taskExecutor: (lionWebClient: LionWebClient, semanticLogItems: ISemanticLogItem[]) => (task: keyof typeof recognizedTasks, queryId: string) => Promise<void>;
|
|
13
12
|
//# sourceMappingURL=tasks.d.ts.map
|
package/dist/tasks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAC9D,OAAO,EAA+B,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAe9F;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAoCnD,CAAA;AAMD,eAAO,MAAM,YAAY,GAAI,eAAe,aAAa,EAAE,kBAAkB,gBAAgB,EAAE,MAkC7E,MAAM,MAAM,OAAO,eAAe,EAAE,SAAS,MAAM,kBAsIpE,CAAA"}
|
package/dist/tasks.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
import { ansi, ClientReceivedMessage } from "@lionweb/delta-protocol-common";
|
|
18
18
|
import { lastOfArray } from "@lionweb/ts-utils";
|
|
19
|
-
import { TestLanguageBase } from "@lionweb/class-core-test-language";
|
|
19
|
+
import { TestLanguageBase, TestPartition } from "@lionweb/class-core-test-language";
|
|
20
20
|
import { waitUntil } from "./async.js";
|
|
21
21
|
const { clientInfo, genericWarning } = ansi;
|
|
22
22
|
/**
|
|
@@ -64,7 +64,7 @@ export const recognizedTasks = {
|
|
|
64
64
|
"SubscribeToChangingPartitions": true
|
|
65
65
|
};
|
|
66
66
|
const testLanguageBase = TestLanguageBase.INSTANCE;
|
|
67
|
-
export const taskExecutor = (lionWebClient,
|
|
67
|
+
export const taskExecutor = (lionWebClient, semanticLogItems) => {
|
|
68
68
|
const numberOfReceivedMessages = () => semanticLogItems.filter((item) => item instanceof ClientReceivedMessage).length;
|
|
69
69
|
const waitForReceivedMessages = async (numberOfMessagesToReceive) => {
|
|
70
70
|
const expectedNumber = numberOfReceivedMessages() + numberOfMessagesToReceive; // (precompute here)
|
|
@@ -74,10 +74,18 @@ export const taskExecutor = (lionWebClient, partitionConcept, semanticLogItems)
|
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
const annotation = (id) => lionWebClient.forest.createNode(testLanguageBase.TestAnnotation, id);
|
|
77
|
-
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
const as = (obj, classConstructor, customErrorMessage) => {
|
|
79
|
+
if (obj instanceof classConstructor) {
|
|
80
|
+
return obj;
|
|
81
|
+
}
|
|
82
|
+
throw new Error(customErrorMessage ?? `object is not of class ${classConstructor.name}`);
|
|
83
|
+
};
|
|
84
|
+
const thePartition = () => as(lionWebClient.forest.partitions[0], TestPartition, `partition at index 0 in forest is not a ${testLanguageBase.TestPartition.name}`);
|
|
78
85
|
const linkTestConcept = (id) => id === undefined
|
|
79
|
-
? thePartition()
|
|
86
|
+
? thePartition().links[0]
|
|
80
87
|
: lionWebClient.forest.createNode(testLanguageBase.LinkTestConcept, id);
|
|
88
|
+
const dataTypeTestConcept = () => thePartition().data;
|
|
81
89
|
return async (task, queryId) => {
|
|
82
90
|
console.log(clientInfo(`client "${lionWebClient.clientId}" is executing task "${task}"`));
|
|
83
91
|
switch (task) {
|
|
@@ -95,13 +103,13 @@ export const taskExecutor = (lionWebClient, partitionConcept, semanticLogItems)
|
|
|
95
103
|
return waitForReceivedMessages(1);
|
|
96
104
|
}
|
|
97
105
|
case "AddStringValue_0_1":
|
|
98
|
-
|
|
106
|
+
dataTypeTestConcept().stringValue_0_1 = "new property";
|
|
99
107
|
return waitForReceivedMessages(1);
|
|
100
108
|
case "SetStringValue_0_1":
|
|
101
|
-
|
|
109
|
+
dataTypeTestConcept().stringValue_0_1 = "changed property";
|
|
102
110
|
return waitForReceivedMessages(1);
|
|
103
111
|
case "DeleteStringValue_0_1":
|
|
104
|
-
|
|
112
|
+
dataTypeTestConcept().stringValue_0_1 = undefined;
|
|
105
113
|
return waitForReceivedMessages(1);
|
|
106
114
|
case "AddName_Containment_0_1":
|
|
107
115
|
linkTestConcept().containment_0_1.name = "my name";
|
|
@@ -194,9 +202,13 @@ export const taskExecutor = (lionWebClient, partitionConcept, semanticLogItems)
|
|
|
194
202
|
case "MoveChildFromOtherContainmentInSameParent_Multiple":
|
|
195
203
|
linkTestConcept().addContainment_1_nAtIndex(lastOfArray(linkTestConcept().containment_0_n), 1);
|
|
196
204
|
return waitForReceivedMessages(1);
|
|
197
|
-
case "AddPartition":
|
|
198
|
-
lionWebClient.
|
|
205
|
+
case "AddPartition": {
|
|
206
|
+
const partition = lionWebClient.forest.createNode(testLanguageBase.TestPartition, "partition");
|
|
207
|
+
partition.data = lionWebClient.forest.createNode(testLanguageBase.DataTypeTestConcept, "data");
|
|
208
|
+
partition.addLinks(lionWebClient.forest.createNode(testLanguageBase.LinkTestConcept, "link"));
|
|
209
|
+
lionWebClient.addPartition(partition);
|
|
199
210
|
return waitForReceivedMessages(1);
|
|
211
|
+
}
|
|
200
212
|
default: {
|
|
201
213
|
// (shouldn't happen because of upfront validation of tasks)
|
|
202
214
|
console.log(genericWarning(`task "${task}" is unknown => ignored`));
|
package/dist/tasks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAAA,wDA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
|
3
|
-
"version": "0.8.0-beta.
|
|
3
|
+
"version": "0.8.0-beta.2",
|
|
4
4
|
"description": "CLI programs for testing the delta protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"release": "npm publish"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lionweb/class-core": "0.8.0-beta.
|
|
34
|
-
"@lionweb/class-core-test-language": "0.8.0-beta.
|
|
35
|
-
"@lionweb/core": "0.8.0-beta.
|
|
36
|
-
"@lionweb/delta-protocol-client": "0.8.0-beta.
|
|
37
|
-
"@lionweb/delta-protocol-common": "0.8.0-beta.
|
|
38
|
-
"@lionweb/delta-protocol-low-level-client-ws": "0.8.0-beta.
|
|
39
|
-
"@lionweb/delta-protocol-repository-ws": "0.8.0-beta.
|
|
40
|
-
"@lionweb/json": "0.8.0-beta.
|
|
41
|
-
"@lionweb/utilities": "0.8.0-beta.
|
|
33
|
+
"@lionweb/class-core": "0.8.0-beta.2",
|
|
34
|
+
"@lionweb/class-core-test-language": "0.8.0-beta.2",
|
|
35
|
+
"@lionweb/core": "0.8.0-beta.2",
|
|
36
|
+
"@lionweb/delta-protocol-client": "0.8.0-beta.2",
|
|
37
|
+
"@lionweb/delta-protocol-common": "0.8.0-beta.2",
|
|
38
|
+
"@lionweb/delta-protocol-low-level-client-ws": "0.8.0-beta.2",
|
|
39
|
+
"@lionweb/delta-protocol-repository-ws": "0.8.0-beta.2",
|
|
40
|
+
"@lionweb/json": "0.8.0-beta.2",
|
|
41
|
+
"@lionweb/utilities": "0.8.0-beta.2"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/cli-client.ts
CHANGED
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
// SPDX-License-Identifier: Apache-2.0
|
|
19
19
|
|
|
20
20
|
import { TestLanguageBase } from "@lionweb/class-core-test-language"
|
|
21
|
-
import { Concept } from "@lionweb/core"
|
|
22
21
|
import { LionWebClient, LowLevelClientLogItem } from "@lionweb/delta-protocol-client"
|
|
23
22
|
import { ansi, combine, semanticConsoleLogger, semanticLogItemStorer } from "@lionweb/delta-protocol-common"
|
|
24
23
|
import { createWSLowLevelClient } from "@lionweb/delta-protocol-low-level-client-ws"
|
|
@@ -38,12 +37,7 @@ const languageBases = [testLanguageBase]
|
|
|
38
37
|
const boldRedIf = (apply: boolean, text: string) =>
|
|
39
38
|
apply ? genericError(text) : text
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
[testLanguageBase.DataTypeTestConcept, testLanguageBase.LinkTestConcept]
|
|
43
|
-
.map((concept) => [concept.name, concept])
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
// $ node dist/cli-client.js <port> <clientID> <partitionConcept> [tasks] [--${protocolLogOptionPrefix}=<path>]
|
|
40
|
+
// $ node dist/cli-client.js <port> <clientID> [tasks] [--${protocolLogOptionPrefix}=<path>]
|
|
47
41
|
|
|
48
42
|
const protocolLogOptionPrefix = "--protocol-log="
|
|
49
43
|
const protocolLogPathIndex = argv.findIndex((argument) => argument.startsWith(protocolLogOptionPrefix))
|
|
@@ -57,8 +51,7 @@ if (trueArguments.length < 3) {
|
|
|
57
51
|
Parameters (${genericError("bold red")} are missing):
|
|
58
52
|
- ${boldRedIf(trueArguments.length < 1, `<port>: the port of the WebSocket where the LionWeb delta protocol repository is running on localhost`)}
|
|
59
53
|
- ${boldRedIf(trueArguments.length < 2, `<clientID>: the ID that the client identifies itself with at the repository`)}
|
|
60
|
-
- ${boldRedIf(trueArguments.length < 3,
|
|
61
|
-
- ${boldRedIf(trueArguments.length < 4, `[tasks]: a comma-separated list of tasks — one of ${Object.keys(recognizedTasks).sort().join(", ")}`)}
|
|
54
|
+
- ${boldRedIf(trueArguments.length < 3, `[tasks]: a comma-separated list of tasks — one of ${Object.keys(recognizedTasks).sort().join(", ")}`)}
|
|
62
55
|
- ${boldRedIf(protocolLogPathIndex === -1, `${protocolLogOptionPrefix}=<path>: option to configure that the client logs all messages exchanged with the repository to a file with the given path`)}
|
|
63
56
|
|
|
64
57
|
ASSUMPTION: the initial (states of the models) on client(s) and repository are identical!
|
|
@@ -68,12 +61,7 @@ Parameters (${genericError("bold red")} are missing):
|
|
|
68
61
|
|
|
69
62
|
const port = tryParseInteger(argv[2])
|
|
70
63
|
const clientId = argv[3]
|
|
71
|
-
const
|
|
72
|
-
if (!(partitionConcept in partitionConcepts)) {
|
|
73
|
-
console.error(genericError(`unknown partition concept specified: ${partitionConcept} — must be one of: ${Object.keys(partitionConcepts).join(", ")}`))
|
|
74
|
-
exit(2)
|
|
75
|
-
}
|
|
76
|
-
const tasks = argv[5]?.split(",") ?? []
|
|
64
|
+
const tasks = argv[4]?.split(",") ?? []
|
|
77
65
|
console.log(clientInfo(`tasks provided: ${tasks.length === 0 ? "none" : tasks.join(", ")}`))
|
|
78
66
|
const infoUnrecognizedTasks = tasks
|
|
79
67
|
.map((task, index) => task in recognizedTasks ? undefined : [task, index] as [string, number])
|
|
@@ -108,7 +96,7 @@ await runAsApp(async () => {
|
|
|
108
96
|
|
|
109
97
|
console.log(clientInfo(`LionWeb delta protocol client (with ID=${clientId}) connecting to repository on ${url} - press Ctrl+C to terminate`))
|
|
110
98
|
|
|
111
|
-
const executeTask = taskExecutor(lionWebClient,
|
|
99
|
+
const executeTask = taskExecutor(lionWebClient, semanticLogItems)
|
|
112
100
|
|
|
113
101
|
let querySequenceNumber = 0
|
|
114
102
|
const queryId = () => `query-${++querySequenceNumber}`
|
package/src/tasks.ts
CHANGED
|
@@ -15,12 +15,17 @@
|
|
|
15
15
|
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
import { Concept } from "@lionweb/core"
|
|
19
18
|
import { LionWebClient } from "@lionweb/delta-protocol-client"
|
|
20
19
|
import { ansi, ClientReceivedMessage, ISemanticLogItem } from "@lionweb/delta-protocol-common"
|
|
21
20
|
import { LionWebId } from "@lionweb/json"
|
|
22
21
|
import { lastOfArray } from "@lionweb/ts-utils"
|
|
23
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
DataTypeTestConcept,
|
|
24
|
+
LinkTestConcept,
|
|
25
|
+
TestAnnotation,
|
|
26
|
+
TestLanguageBase,
|
|
27
|
+
TestPartition
|
|
28
|
+
} from "@lionweb/class-core-test-language"
|
|
24
29
|
|
|
25
30
|
import { waitUntil } from "./async.js"
|
|
26
31
|
const { clientInfo, genericWarning } = ansi
|
|
@@ -75,7 +80,7 @@ export const recognizedTasks: Record<string, boolean> = {
|
|
|
75
80
|
const testLanguageBase = TestLanguageBase.INSTANCE
|
|
76
81
|
|
|
77
82
|
|
|
78
|
-
export const taskExecutor = (lionWebClient: LionWebClient,
|
|
83
|
+
export const taskExecutor = (lionWebClient: LionWebClient, semanticLogItems: ISemanticLogItem[]) => {
|
|
79
84
|
|
|
80
85
|
const numberOfReceivedMessages = () =>
|
|
81
86
|
semanticLogItems.filter((item) => item instanceof ClientReceivedMessage).length
|
|
@@ -91,13 +96,24 @@ export const taskExecutor = (lionWebClient: LionWebClient, partitionConcept: Con
|
|
|
91
96
|
const annotation = (id: LionWebId) =>
|
|
92
97
|
lionWebClient.forest.createNode(testLanguageBase.TestAnnotation, id) as TestAnnotation
|
|
93
98
|
|
|
94
|
-
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
+
const as = <T>(obj: object, classConstructor: new (...args: any[]) => T, customErrorMessage?: string) => {
|
|
101
|
+
if (obj instanceof classConstructor) {
|
|
102
|
+
return obj as T
|
|
103
|
+
}
|
|
104
|
+
throw new Error(customErrorMessage ?? `object is not of class ${classConstructor.name}`)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const thePartition = () =>
|
|
108
|
+
as(lionWebClient.forest.partitions[0], TestPartition, `partition at index 0 in forest is not a ${testLanguageBase.TestPartition.name}`)
|
|
95
109
|
|
|
96
110
|
const linkTestConcept = (id?: LionWebId) =>
|
|
97
111
|
id === undefined
|
|
98
|
-
? thePartition()
|
|
112
|
+
? thePartition().links[0]
|
|
99
113
|
: lionWebClient.forest.createNode(testLanguageBase.LinkTestConcept, id) as LinkTestConcept
|
|
100
114
|
|
|
115
|
+
const dataTypeTestConcept = () => thePartition().data!
|
|
116
|
+
|
|
101
117
|
return async (task: keyof typeof recognizedTasks, queryId: string) => {
|
|
102
118
|
console.log(clientInfo(`client "${lionWebClient.clientId}" is executing task "${task}"`))
|
|
103
119
|
switch (task) {
|
|
@@ -115,13 +131,13 @@ export const taskExecutor = (lionWebClient: LionWebClient, partitionConcept: Con
|
|
|
115
131
|
return waitForReceivedMessages(1)
|
|
116
132
|
}
|
|
117
133
|
case "AddStringValue_0_1":
|
|
118
|
-
(
|
|
134
|
+
dataTypeTestConcept().stringValue_0_1 = "new property"
|
|
119
135
|
return waitForReceivedMessages(1)
|
|
120
136
|
case "SetStringValue_0_1":
|
|
121
|
-
(
|
|
137
|
+
dataTypeTestConcept().stringValue_0_1 = "changed property"
|
|
122
138
|
return waitForReceivedMessages(1)
|
|
123
139
|
case "DeleteStringValue_0_1":
|
|
124
|
-
(
|
|
140
|
+
dataTypeTestConcept().stringValue_0_1 = undefined
|
|
125
141
|
return waitForReceivedMessages(1)
|
|
126
142
|
case "AddName_Containment_0_1":
|
|
127
143
|
linkTestConcept().containment_0_1!.name = "my name"
|
|
@@ -217,9 +233,13 @@ export const taskExecutor = (lionWebClient: LionWebClient, partitionConcept: Con
|
|
|
217
233
|
case "MoveChildFromOtherContainmentInSameParent_Multiple":
|
|
218
234
|
linkTestConcept().addContainment_1_nAtIndex(lastOfArray(linkTestConcept().containment_0_n), 1)
|
|
219
235
|
return waitForReceivedMessages(1)
|
|
220
|
-
case "AddPartition":
|
|
221
|
-
lionWebClient.
|
|
236
|
+
case "AddPartition": {
|
|
237
|
+
const partition = lionWebClient.forest.createNode(testLanguageBase.TestPartition, "partition") as TestPartition
|
|
238
|
+
partition.data = lionWebClient.forest.createNode(testLanguageBase.DataTypeTestConcept, "data") as DataTypeTestConcept
|
|
239
|
+
partition.addLinks(lionWebClient.forest.createNode(testLanguageBase.LinkTestConcept, "link") as LinkTestConcept)
|
|
240
|
+
lionWebClient.addPartition(partition)
|
|
222
241
|
return waitForReceivedMessages(1)
|
|
242
|
+
}
|
|
223
243
|
|
|
224
244
|
default: {
|
|
225
245
|
// (shouldn't happen because of upfront validation of tasks)
|