@lionweb/delta-protocol-common 0.7.0-beta.21
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/CHANGELOG.md +6 -0
- package/README.md +33 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/ansi.d.ts +44 -0
- package/dist/logging/ansi.d.ts.map +1 -0
- package/dist/logging/ansi.js +53 -0
- package/dist/logging/ansi.js.map +1 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +20 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/semantic-logging.d.ts +55 -0
- package/dist/logging/semantic-logging.d.ts.map +1 -0
- package/dist/logging/semantic-logging.js +88 -0
- package/dist/logging/semantic-logging.js.map +1 -0
- package/dist/logging/textual-logging.d.ts +22 -0
- package/dist/logging/textual-logging.d.ts.map +1 -0
- package/dist/logging/textual-logging.js +54 -0
- package/dist/logging/textual-logging.js.map +1 -0
- package/dist/payload/command-types.d.ts +319 -0
- package/dist/payload/command-types.d.ts.map +1 -0
- package/dist/payload/command-types.js +18 -0
- package/dist/payload/command-types.js.map +1 -0
- package/dist/payload/common.d.ts +13 -0
- package/dist/payload/common.d.ts.map +1 -0
- package/dist/payload/common.js +18 -0
- package/dist/payload/common.js.map +1 -0
- package/dist/payload/event-types.d.ts +378 -0
- package/dist/payload/event-types.d.ts.map +1 -0
- package/dist/payload/event-types.js +68 -0
- package/dist/payload/event-types.js.map +1 -0
- package/dist/payload/index.d.ts +5 -0
- package/dist/payload/index.d.ts.map +1 -0
- package/dist/payload/index.js +20 -0
- package/dist/payload/index.js.map +1 -0
- package/dist/payload/query-types.d.ts +73 -0
- package/dist/payload/query-types.d.ts.map +1 -0
- package/dist/payload/query-types.js +30 -0
- package/dist/payload/query-types.js.map +1 -0
- package/dist/translators/delta-to-command.d.ts +7 -0
- package/dist/translators/delta-to-command.d.ts.map +1 -0
- package/dist/translators/delta-to-command.js +297 -0
- package/dist/translators/delta-to-command.js.map +1 -0
- package/dist/translators/delta-to-event.d.ts +2 -0
- package/dist/translators/delta-to-event.d.ts.map +1 -0
- package/dist/translators/delta-to-event.js +19 -0
- package/dist/translators/delta-to-event.js.map +1 -0
- package/dist/translators/event-to-delta.d.ts +13 -0
- package/dist/translators/event-to-delta.d.ts.map +1 -0
- package/dist/translators/event-to-delta.js +293 -0
- package/dist/translators/event-to-delta.js.map +1 -0
- package/dist/translators/index.d.ts +4 -0
- package/dist/translators/index.d.ts.map +1 -0
- package/dist/translators/index.js +19 -0
- package/dist/translators/index.js.map +1 -0
- package/dist/utils/async.d.ts +13 -0
- package/dist/utils/async.d.ts.map +1 -0
- package/dist/utils/async.js +38 -0
- package/dist/utils/async.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json.d.ts +7 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +30 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/procedure.d.ts +14 -0
- package/dist/utils/procedure.d.ts.map +1 -0
- package/dist/utils/procedure.js +32 -0
- package/dist/utils/procedure.js.map +1 -0
- package/package.json +35 -0
- package/src/index.ts +22 -0
- package/src/logging/ansi.ts +63 -0
- package/src/logging/index.ts +21 -0
- package/src/logging/semantic-logging.ts +96 -0
- package/src/logging/textual-logging.ts +65 -0
- package/src/payload/command-types.ts +378 -0
- package/src/payload/common.ts +33 -0
- package/src/payload/event-types.ts +499 -0
- package/src/payload/index.ts +22 -0
- package/src/payload/query-types.ts +134 -0
- package/src/translators/delta-to-command.ts +378 -0
- package/src/translators/delta-to-event.ts +19 -0
- package/src/translators/event-to-delta.ts +384 -0
- package/src/translators/index.ts +21 -0
- package/src/utils/async.ts +50 -0
- package/src/utils/index.ts +22 -0
- package/src/utils/json.ts +32 -0
- package/src/utils/procedure.ts +43 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
const colors = {
|
|
19
|
+
black: 30,
|
|
20
|
+
red: 31,
|
|
21
|
+
green: 32,
|
|
22
|
+
yellow: 33,
|
|
23
|
+
blue: 34,
|
|
24
|
+
magenta: 35,
|
|
25
|
+
cyan: 36,
|
|
26
|
+
white: 37,
|
|
27
|
+
default: 39
|
|
28
|
+
} as const
|
|
29
|
+
|
|
30
|
+
const styles = {
|
|
31
|
+
default: 0,
|
|
32
|
+
bold: 1,
|
|
33
|
+
italic: 3
|
|
34
|
+
} as const
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
const withColorAndStyleApplied = (color: keyof typeof colors, style: keyof typeof styles) =>
|
|
38
|
+
(text: string) =>
|
|
39
|
+
`\x1b[${style === "default" ? "" : `${styles[style]}`}${color === "default" ? "" : `;${colors[color]}m`}${text}\x1b[0m`
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const clientInfo = withColorAndStyleApplied("magenta", "bold")
|
|
43
|
+
const clientWarning = withColorAndStyleApplied("magenta", "italic")
|
|
44
|
+
const repositoryInfo = withColorAndStyleApplied("cyan", "bold")
|
|
45
|
+
const repositoryWarning = withColorAndStyleApplied("cyan", "italic")
|
|
46
|
+
const genericError = withColorAndStyleApplied("red", "bold")
|
|
47
|
+
const genericWarning = withColorAndStyleApplied("red", "italic")
|
|
48
|
+
|
|
49
|
+
const colorSchemeExplanationString = `${withColorAndStyleApplied("magenta", "default")("magenta=client")}, ${withColorAndStyleApplied("cyan", "default")("cyan=repository")}`
|
|
50
|
+
|
|
51
|
+
export const ansi = {
|
|
52
|
+
colors,
|
|
53
|
+
styles,
|
|
54
|
+
withColorAndStyleApplied,
|
|
55
|
+
clientInfo,
|
|
56
|
+
clientWarning,
|
|
57
|
+
repositoryInfo,
|
|
58
|
+
repositoryWarning,
|
|
59
|
+
genericError,
|
|
60
|
+
genericWarning,
|
|
61
|
+
colorSchemeExplanationString
|
|
62
|
+
}
|
|
63
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
export { ansi } from "./ansi.js"
|
|
19
|
+
export * from "./semantic-logging.js"
|
|
20
|
+
export * from "./textual-logging.js"
|
|
21
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
import { SerializedDelta } from "@lionweb/class-core"
|
|
19
|
+
import { LionWebId } from "@lionweb/json"
|
|
20
|
+
import { asMinimalJsonString } from "@lionweb/ts-utils"
|
|
21
|
+
|
|
22
|
+
import { ansi } from "./ansi.js"
|
|
23
|
+
const { clientInfo, clientWarning, repositoryInfo, withColorAndStyleApplied } = ansi
|
|
24
|
+
|
|
25
|
+
import { Event } from "../payload/event-types.js"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export interface ISemanticLogItem {
|
|
29
|
+
asText(): string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export type SemanticLogger = (semanticLogItem: ISemanticLogItem) => void
|
|
34
|
+
|
|
35
|
+
export const semanticNoOpLogger: SemanticLogger = (_) => {}
|
|
36
|
+
|
|
37
|
+
export const semanticLoggerFunctionFrom = (optionalSemanticLogger?: SemanticLogger) =>
|
|
38
|
+
optionalSemanticLogger ?? semanticNoOpLogger
|
|
39
|
+
|
|
40
|
+
export const semanticConsoleLogger = (semanticLogItem: ISemanticLogItem) => {
|
|
41
|
+
console.log(semanticLogItem.asText())
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export class DeltaOccurredOnClient implements ISemanticLogItem {
|
|
46
|
+
constructor(public readonly clientId: LionWebId, public readonly serializedDelta: SerializedDelta) {}
|
|
47
|
+
asText = () => `${clientInfo(`delta occurred on client "${this.clientId}"`)}: ${asMinimalJsonString(this.serializedDelta)}`
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class ClientSentMessage<TMessageForRepository> implements ISemanticLogItem {
|
|
51
|
+
constructor(public readonly clientId: LionWebId, public readonly message: TMessageForRepository) {}
|
|
52
|
+
asText = () => `${clientInfo(`client "${this.clientId}" sent message`)}: ${asMinimalJsonString(this.message)}`
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class ClientReceivedMessage<TMessageForClient> implements ISemanticLogItem {
|
|
56
|
+
constructor(public readonly clientId: LionWebId, public readonly message: TMessageForClient) {}
|
|
57
|
+
asText = () => `${clientInfo(`client "${this.clientId}" received message`)}: ${asMinimalJsonString(this.message)}`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class ClientAppliedEvent implements ISemanticLogItem {
|
|
61
|
+
constructor(public readonly clientId: LionWebId, public readonly event: Event) {}
|
|
62
|
+
asText = () => `${clientInfo(`client "${this.clientId}" applied (the delta from) the following event`)}: ${asMinimalJsonString(this.event)}`
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class ClientDidNotApplyEventFromOwnCommand implements ISemanticLogItem {
|
|
66
|
+
constructor(public readonly clientId: LionWebId, public readonly originatingCommandId: LionWebId) {}
|
|
67
|
+
asText = () => clientWarning(`client "${this.clientId}" didn't apply (the delta from) an event because it's the result of a command (with ID="${this.originatingCommandId}") it sent itself`)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class ClientHadProblem implements ISemanticLogItem {
|
|
71
|
+
constructor(public readonly clientId: LionWebId, public readonly message: string) {}
|
|
72
|
+
asText = () => clientWarning(`client "${this.clientId}" had a problem: ${this.message}`)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class RepositoryReceivedMessage<TClientMetadata, TIncomingMessage> implements ISemanticLogItem {
|
|
76
|
+
constructor(public readonly knownMetadata: Partial<TClientMetadata>, public readonly message: TIncomingMessage) {}
|
|
77
|
+
asText = () => `${repositoryInfo(`repository received message`)} ${withColorAndStyleApplied("magenta", "default")(`(client's known metadata: ${asMinimalJsonString(this.knownMetadata)})`)}: ${asMinimalJsonString(this.message)}`
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export const semanticLogItemsToConsole = (semanticLogItems: ISemanticLogItem[]) => {
|
|
82
|
+
semanticLogItems.forEach((logItem) => {
|
|
83
|
+
console.log(logItem.asText())
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const semanticLogItemStorer = (): [semanticLogger: SemanticLogger, semanticLogItems: ISemanticLogItem[]] => {
|
|
88
|
+
const items: ISemanticLogItem[] = []
|
|
89
|
+
return [
|
|
90
|
+
(semanticLogItem) => {
|
|
91
|
+
items.push(semanticLogItem)
|
|
92
|
+
},
|
|
93
|
+
items
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
export type TextualLogger = (message: string, error?: boolean) => void
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A {@link TextualLogger textual logger} that simply logs to the console.
|
|
22
|
+
*/
|
|
23
|
+
export const simpleConsoleLogger: TextualLogger = (message, isError) => {
|
|
24
|
+
(isError ? console.error : console.log)(message)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A {@link TextualLogger textual logger} that does nothing.
|
|
29
|
+
*/
|
|
30
|
+
export const noOpTextualLogger: TextualLogger = (_, __) => {}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @return a {@link TextualLogger textual logger} which is either the given one, or the noOpTextualLogger.
|
|
34
|
+
*/
|
|
35
|
+
export const textualLoggerFunctionFrom = (optionalLogger?: TextualLogger): TextualLogger =>
|
|
36
|
+
optionalLogger ?? noOpTextualLogger
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Prefixes all messages passed to the given {@link TextualLogger textual logger} with the given prefix.
|
|
40
|
+
*/
|
|
41
|
+
export const prefixedWith = (logger: TextualLogger, prefix: string): TextualLogger =>
|
|
42
|
+
(message, error) => logger(`${prefix}${message}`, error)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const unit2divider: { [id: string]: bigint } = {
|
|
46
|
+
"ns": 1n,
|
|
47
|
+
"µs": 1000n,
|
|
48
|
+
"ms": 1000_000n,
|
|
49
|
+
"s": 1000_000_000n
|
|
50
|
+
} as const
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A {@link TextualLogger textual logger} that logs to the console, also showing the time elapsed since the creation of it.
|
|
54
|
+
*/
|
|
55
|
+
export const timedConsoleLogger = (unit: "ns" | "µs" | "ms" | "s"): TextualLogger => {
|
|
56
|
+
if (!(unit in unit2divider)) {
|
|
57
|
+
throw new Error(`unknown time unit: "${unit}"`)
|
|
58
|
+
}
|
|
59
|
+
const divider = unit2divider[unit]
|
|
60
|
+
const start = process.hrtime.bigint()
|
|
61
|
+
return (message, isError) => {
|
|
62
|
+
(isError ? console.error : console.log)(`{${((process.hrtime.bigint() - start)/divider).toLocaleString()}${unit}} ${message}`)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
import { LionWebId, LionWebJsonChunk, LionWebJsonMetaPointer } from "@lionweb/json"
|
|
19
|
+
import { DeltaProtocolMessage } from "./common.js"
|
|
20
|
+
|
|
21
|
+
export interface Command extends DeltaProtocolMessage {
|
|
22
|
+
commandId: LionWebId
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// in order of the specification (§ 6.5):
|
|
27
|
+
|
|
28
|
+
/** § 6.5.2.1 */
|
|
29
|
+
export interface AddPartitionCommand extends Command {
|
|
30
|
+
messageKind: "AddPartition"
|
|
31
|
+
newPartition: LionWebJsonChunk
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** § 6.5.2.2 */
|
|
35
|
+
export interface DeletePartitionCommand extends Command {
|
|
36
|
+
messageKind: "DeletePartition"
|
|
37
|
+
deletedPartition: LionWebId
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** § 6.5.3.1 */
|
|
41
|
+
export interface ChangeClassifierCommand extends Command {
|
|
42
|
+
messageKind: "ChangeClassifier"
|
|
43
|
+
node: LionWebId
|
|
44
|
+
newClassifier: LionWebJsonMetaPointer
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** § 6.5.4.1 */
|
|
48
|
+
export interface AddPropertyCommand<T> extends Command {
|
|
49
|
+
messageKind: "AddProperty"
|
|
50
|
+
node: LionWebId
|
|
51
|
+
property: LionWebJsonMetaPointer
|
|
52
|
+
newValue: T
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** § 6.5.4.2 */
|
|
56
|
+
export interface DeletePropertyCommand extends Command {
|
|
57
|
+
messageKind: "DeleteProperty"
|
|
58
|
+
node: LionWebId
|
|
59
|
+
property: LionWebJsonMetaPointer
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** § 6.5.4.3 */
|
|
63
|
+
export interface ChangePropertyCommand<T> extends Command {
|
|
64
|
+
messageKind: "ChangeProperty"
|
|
65
|
+
node: LionWebId
|
|
66
|
+
property: LionWebJsonMetaPointer
|
|
67
|
+
newValue: T
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** § 6.5.5.1 */
|
|
71
|
+
export interface AddChildCommand extends Command {
|
|
72
|
+
messageKind: "AddChild"
|
|
73
|
+
parent: LionWebId
|
|
74
|
+
newChild: LionWebJsonChunk
|
|
75
|
+
containment: LionWebJsonMetaPointer
|
|
76
|
+
index: number
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** § 6.5.5.2 */
|
|
80
|
+
export interface DeleteChildCommand extends Command {
|
|
81
|
+
messageKind: "DeleteChild"
|
|
82
|
+
parent: LionWebId
|
|
83
|
+
containment: LionWebJsonMetaPointer
|
|
84
|
+
index: number
|
|
85
|
+
deletedChild: LionWebId
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** § 6.5.5.3 */
|
|
89
|
+
export interface ReplaceChildCommand extends Command {
|
|
90
|
+
messageKind: "ReplaceChild"
|
|
91
|
+
newChild: LionWebJsonChunk
|
|
92
|
+
parent: LionWebId
|
|
93
|
+
containment: LionWebJsonMetaPointer
|
|
94
|
+
index: number
|
|
95
|
+
replacedChild: LionWebId
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** § 6.5.5.4 */
|
|
99
|
+
export interface MoveChildFromOtherContainmentCommand extends Command {
|
|
100
|
+
messageKind: "MoveChildFromOtherContainment"
|
|
101
|
+
newParent: LionWebId
|
|
102
|
+
newContainment: LionWebJsonMetaPointer
|
|
103
|
+
newIndex: number
|
|
104
|
+
movedChild: LionWebId
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** § 6.5.5.5 */
|
|
108
|
+
export interface MoveChildFromOtherContainmentInSameParentCommand extends Command {
|
|
109
|
+
messageKind: "MoveChildFromOtherContainmentInSameParent"
|
|
110
|
+
newContainment: LionWebJsonMetaPointer
|
|
111
|
+
newIndex: number
|
|
112
|
+
movedChild: LionWebId
|
|
113
|
+
parent: LionWebId
|
|
114
|
+
oldContainment: LionWebJsonMetaPointer
|
|
115
|
+
oldIndex: number
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** § 6.5.5.6 */
|
|
119
|
+
export interface MoveChildInSameContainmentCommand extends Command {
|
|
120
|
+
messageKind: "MoveChildInSameContainment"
|
|
121
|
+
newIndex: number
|
|
122
|
+
movedChild: LionWebId
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** § 6.5.5.7 */
|
|
126
|
+
export interface MoveAndReplaceChildFromOtherContainmentCommand extends Command {
|
|
127
|
+
messageKind: "MoveAndReplaceChildFromOtherContainment"
|
|
128
|
+
newParent: LionWebId
|
|
129
|
+
newContainment: LionWebJsonMetaPointer
|
|
130
|
+
newIndex: number
|
|
131
|
+
replacedChild: LionWebId
|
|
132
|
+
movedChild: LionWebId
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** § 6.5.5.8 */
|
|
136
|
+
export interface MoveAndReplaceChildFromOtherContainmentInSameParentCommand extends Command {
|
|
137
|
+
messageKind: "MoveAndReplaceChildFromOtherContainmentInSameParent"
|
|
138
|
+
newContainment: LionWebJsonMetaPointer
|
|
139
|
+
newIndex: number
|
|
140
|
+
replacedChild: LionWebId
|
|
141
|
+
movedChild: LionWebId
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** § 6.5.5.9 */
|
|
145
|
+
export interface MoveAndReplaceChildInSameContainmentCommand extends Command {
|
|
146
|
+
messageKind: "MoveAndReplaceChildInSameContainment"
|
|
147
|
+
newIndex: number
|
|
148
|
+
replacedChild: LionWebId
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** § 6.5.6.1 */
|
|
152
|
+
export interface AddAnnotationCommand extends Command {
|
|
153
|
+
messageKind: "AddAnnotation"
|
|
154
|
+
parent: LionWebId
|
|
155
|
+
newAnnotation: LionWebJsonChunk
|
|
156
|
+
index: number
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** § 6.5.6.2 */
|
|
160
|
+
export interface DeleteAnnotationCommand extends Command {
|
|
161
|
+
messageKind: "DeleteAnnotation"
|
|
162
|
+
parent: LionWebId
|
|
163
|
+
index: number
|
|
164
|
+
deletedAnnotation: LionWebId
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** § 6.5.6.3 */
|
|
168
|
+
export interface ReplaceAnnotationCommand extends Command {
|
|
169
|
+
messageKind: "ReplaceAnnotation"
|
|
170
|
+
newAnnotation: LionWebJsonChunk
|
|
171
|
+
parent: LionWebId
|
|
172
|
+
index: number
|
|
173
|
+
replacedAnnotation: LionWebId
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** § 6.5.6.4 */
|
|
177
|
+
export interface MoveAnnotationFromOtherParentCommand extends Command {
|
|
178
|
+
messageKind: "MoveAnnotationFromOtherParent"
|
|
179
|
+
newParent: LionWebId
|
|
180
|
+
newIndex: number
|
|
181
|
+
movedAnnotation: LionWebId
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** § 6.5.6.5 */
|
|
185
|
+
export interface MoveAnnotationInSameParentCommand extends Command {
|
|
186
|
+
messageKind: "MoveAnnotationInSameParent"
|
|
187
|
+
newIndex: number
|
|
188
|
+
movedAnnotation: LionWebId
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** § 6.5.6.6 */
|
|
192
|
+
export interface MoveAndReplaceAnnotationFromOtherParentCommand extends Command {
|
|
193
|
+
messageKind: "MoveAndReplaceAnnotationFromOtherParent"
|
|
194
|
+
newParent: LionWebId
|
|
195
|
+
newIndex: number
|
|
196
|
+
replacedAnnotation: LionWebId
|
|
197
|
+
movedAnnotation: LionWebId
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** § 6.5.6.7 */
|
|
201
|
+
export interface MoveAndReplaceAnnotationInSameParentCommand extends Command {
|
|
202
|
+
messageKind: "MoveAndReplaceAnnotationInSameParent"
|
|
203
|
+
newIndex: number
|
|
204
|
+
replacedAnnotation: LionWebId
|
|
205
|
+
movedAnnotation: LionWebId
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** § 6.5.7.1 */
|
|
209
|
+
export interface AddReferenceCommand extends Command {
|
|
210
|
+
messageKind: "AddReference"
|
|
211
|
+
parent: LionWebId
|
|
212
|
+
reference: LionWebJsonMetaPointer
|
|
213
|
+
index: number
|
|
214
|
+
newTarget: LionWebId | null
|
|
215
|
+
newResolveInfo: string | null
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** § 6.5.7.2 */
|
|
219
|
+
export interface DeleteReferenceCommand extends Command {
|
|
220
|
+
messageKind: "DeleteReference"
|
|
221
|
+
parent: LionWebId
|
|
222
|
+
reference: LionWebJsonMetaPointer
|
|
223
|
+
index: number
|
|
224
|
+
deletedTarget: LionWebId | null
|
|
225
|
+
deletedResolveInfo: string | null
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** § 6.5.7.3 */
|
|
229
|
+
export interface ChangeReferenceCommand extends Command {
|
|
230
|
+
messageKind: "ChangeReference"
|
|
231
|
+
parent: LionWebId
|
|
232
|
+
reference: LionWebJsonMetaPointer
|
|
233
|
+
index: number
|
|
234
|
+
oldTarget: LionWebId | null
|
|
235
|
+
oldResolveInfo: string | null
|
|
236
|
+
newTarget: LionWebId | null
|
|
237
|
+
newResolveInfo: string | null
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** § 6.5.7.4 */
|
|
241
|
+
export interface MoveEntryFromOtherReferenceCommand extends Command {
|
|
242
|
+
messageKind: "MoveEntryFromOtherReference"
|
|
243
|
+
newParent: LionWebId
|
|
244
|
+
newReference: LionWebJsonMetaPointer
|
|
245
|
+
newIndex: number
|
|
246
|
+
oldParent: LionWebId
|
|
247
|
+
oldReference: LionWebJsonMetaPointer
|
|
248
|
+
oldIndex: number
|
|
249
|
+
movedTarget: LionWebId | null
|
|
250
|
+
movedResolveInfo: string | null
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** § 6.5.7.5 */
|
|
254
|
+
export interface MoveEntryFromOtherReferenceInSameParentCommand extends Command {
|
|
255
|
+
messageKind: "MoveEntryFromOtherReferenceInSameParent"
|
|
256
|
+
parent: LionWebId
|
|
257
|
+
newReference: LionWebJsonMetaPointer
|
|
258
|
+
newIndex: number
|
|
259
|
+
oldIndex: number
|
|
260
|
+
movedTarget: LionWebId | null
|
|
261
|
+
movedResolveInfo: string | null
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** § 6.5.7.6 */
|
|
265
|
+
export interface MoveEntryInSameReferenceCommand extends Command {
|
|
266
|
+
messageKind: "MoveEntryInSameReference"
|
|
267
|
+
parent: LionWebId
|
|
268
|
+
reference: LionWebJsonMetaPointer
|
|
269
|
+
oldIndex: number
|
|
270
|
+
newIndex: number
|
|
271
|
+
movedTarget: LionWebId | null
|
|
272
|
+
movedResolveInfo: string | null
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** § 6.5.7.7 */
|
|
276
|
+
export interface MoveAndReplaceEntryFromOtherReferenceCommand extends Command {
|
|
277
|
+
messageKind: "MoveAndReplaceEntryFromOtherReference"
|
|
278
|
+
newParent: LionWebId
|
|
279
|
+
newReference: LionWebJsonMetaPointer
|
|
280
|
+
newIndex: number
|
|
281
|
+
replacedTarget: LionWebId | null
|
|
282
|
+
replacedResolveInfo: string | null
|
|
283
|
+
oldParent: LionWebId
|
|
284
|
+
oldReference: LionWebJsonMetaPointer
|
|
285
|
+
oldIndex: number
|
|
286
|
+
movedTarget: LionWebId | null
|
|
287
|
+
movedResolveInfo: string | null
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** § 6.5.7.8 */
|
|
291
|
+
export interface MoveAndReplaceEntryFromOtherReferenceInSameParentCommand extends Command {
|
|
292
|
+
messageKind: "MoveAndReplaceEntryFromOtherReferenceInSameParent"
|
|
293
|
+
parent: LionWebId
|
|
294
|
+
newReference: LionWebJsonMetaPointer
|
|
295
|
+
newIndex: number
|
|
296
|
+
replacedTarget: LionWebId | null
|
|
297
|
+
replacedResolveInfo: string | null
|
|
298
|
+
oldReference: LionWebJsonMetaPointer
|
|
299
|
+
oldIndex: number
|
|
300
|
+
movedTarget: LionWebId | null
|
|
301
|
+
movedResolveInfo: string | null
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** § 6.5.7.9 */
|
|
305
|
+
export interface MoveAndReplaceEntryInSameReferenceCommand extends Command {
|
|
306
|
+
messageKind: "MoveAndReplaceEntryInSameReference"
|
|
307
|
+
parent: LionWebId
|
|
308
|
+
reference: LionWebJsonMetaPointer
|
|
309
|
+
oldIndex: number
|
|
310
|
+
movedTarget: LionWebId | null
|
|
311
|
+
movedResolveInfo: string | null
|
|
312
|
+
newIndex: number
|
|
313
|
+
replacedTarget: LionWebId | null
|
|
314
|
+
replacedResolveInfo: string | null
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** § 6.5.7.10 */
|
|
318
|
+
export interface AddReferenceResolveInfoCommand extends Command {
|
|
319
|
+
messageKind: "AddReferenceResolveInfo"
|
|
320
|
+
parent: LionWebId
|
|
321
|
+
reference: LionWebJsonMetaPointer
|
|
322
|
+
index: number
|
|
323
|
+
newResolveInfo: string
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** § 6.5.7.11 */
|
|
327
|
+
export interface DeleteReferenceResolveInfoCommand extends Command {
|
|
328
|
+
messageKind: "DeleteReferenceResolveInfo"
|
|
329
|
+
parent: LionWebId
|
|
330
|
+
reference: LionWebJsonMetaPointer
|
|
331
|
+
index: number
|
|
332
|
+
deletedResolveInfo: string
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** § 6.5.7.12 */
|
|
336
|
+
export interface ChangeReferenceResolveInfoCommand extends Command {
|
|
337
|
+
messageKind: "ChangeReferenceResolveInfo"
|
|
338
|
+
parent: LionWebId
|
|
339
|
+
reference: LionWebJsonMetaPointer
|
|
340
|
+
index: number
|
|
341
|
+
oldResolveInfo: string
|
|
342
|
+
newResolveInfo: string
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** § 6.5.7.13 */
|
|
346
|
+
export interface AddReferenceTargetCommand extends Command {
|
|
347
|
+
messageKind: "AddReferenceTarget"
|
|
348
|
+
parent: LionWebId
|
|
349
|
+
reference: LionWebJsonMetaPointer
|
|
350
|
+
index: number
|
|
351
|
+
newTarget: LionWebId
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** § 6.5.7.14 */
|
|
355
|
+
export interface DeleteReferenceTargetCommand extends Command {
|
|
356
|
+
messageKind: "DeleteReferenceTarget"
|
|
357
|
+
parent: LionWebId
|
|
358
|
+
reference: LionWebJsonMetaPointer
|
|
359
|
+
index: number
|
|
360
|
+
deletedTarget: LionWebId
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** § 6.5.7.15 */
|
|
364
|
+
export interface ChangeReferenceTargetCommand extends Command {
|
|
365
|
+
messageKind: "ChangeReferenceTarget"
|
|
366
|
+
parent: LionWebId
|
|
367
|
+
reference: LionWebJsonMetaPointer
|
|
368
|
+
index: number
|
|
369
|
+
oldTarget: LionWebId
|
|
370
|
+
newTarget: LionWebId
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** § 6.5.8.1 */
|
|
374
|
+
export interface CompositeCommand extends Command {
|
|
375
|
+
messageKind: "CompositeCommand"
|
|
376
|
+
parts: Command[]
|
|
377
|
+
}
|
|
378
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2025 TRUMPF Laser SE and other contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License")
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-FileCopyrightText: 2025 TRUMPF Laser SE and other contributors
|
|
16
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
|
|
18
|
+
import { LionWebId } from "@lionweb/json"
|
|
19
|
+
|
|
20
|
+
export interface Message {
|
|
21
|
+
messageKind: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ProtocolMessage {
|
|
25
|
+
kind: LionWebId
|
|
26
|
+
message: string
|
|
27
|
+
data: Record<LionWebId, string>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface DeltaProtocolMessage extends Message {
|
|
31
|
+
protocolMessages: ProtocolMessage[]
|
|
32
|
+
}
|
|
33
|
+
|