@lionweb/core 0.8.0-beta.5 → 0.8.0-beta.6
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 +27 -5
- package/dist/deserializer.d.ts +10 -2
- package/dist/deserializer.d.ts.map +1 -1
- package/dist/deserializer.js +8 -7
- package/dist/deserializer.js.map +1 -1
- package/dist/dynamic-facade.d.ts +1 -1
- package/dist/dynamic-facade.d.ts.map +1 -1
- package/dist/dynamic-facade.js +3 -3
- package/dist/dynamic-facade.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/m3/builtins-common.d.ts +70 -0
- package/dist/m3/builtins-common.d.ts.map +1 -0
- package/dist/m3/builtins-common.js +88 -0
- package/dist/m3/builtins-common.js.map +1 -0
- package/dist/m3/builtins-function.d.ts +9 -0
- package/dist/m3/builtins-function.d.ts.map +1 -0
- package/dist/m3/builtins-function.js +19 -0
- package/dist/m3/builtins-function.js.map +1 -0
- package/dist/m3/deserializer.d.ts +25 -0
- package/dist/m3/deserializer.d.ts.map +1 -1
- package/dist/m3/deserializer.js +18 -11
- package/dist/m3/deserializer.js.map +1 -1
- package/dist/m3/index.d.ts +7 -3
- package/dist/m3/index.d.ts.map +1 -1
- package/dist/m3/index.js +6 -3
- package/dist/m3/index.js.map +1 -1
- package/dist/m3/lioncore-common.d.ts +37 -0
- package/dist/m3/lioncore-common.d.ts.map +1 -0
- package/dist/m3/lioncore-common.js +10 -0
- package/dist/m3/lioncore-common.js.map +1 -0
- package/dist/m3/reading-writing.d.ts +41 -0
- package/dist/m3/reading-writing.d.ts.map +1 -0
- package/dist/m3/reading-writing.js +84 -0
- package/dist/m3/reading-writing.js.map +1 -0
- package/dist/m3/serializer.d.ts +17 -0
- package/dist/m3/serializer.d.ts.map +1 -1
- package/dist/m3/serializer.js +11 -2
- package/dist/m3/serializer.js.map +1 -1
- package/dist/m3/types.d.ts +9 -13
- package/dist/m3/types.d.ts.map +1 -1
- package/dist/m3/types.js +1 -5
- package/dist/m3/types.js.map +1 -1
- package/dist/m3/version.d.ts +19 -0
- package/dist/m3/version.d.ts.map +1 -0
- package/dist/m3/version.js +19 -0
- package/dist/m3/version.js.map +1 -0
- package/dist/m3/versions/v2023_1/builtins-legacy.d.ts +44 -0
- package/dist/m3/versions/v2023_1/builtins-legacy.d.ts.map +1 -0
- package/dist/m3/{builtins.js → versions/v2023_1/builtins-legacy.js} +24 -79
- package/dist/m3/versions/v2023_1/builtins-legacy.js.map +1 -0
- package/dist/m3/versions/v2023_1/builtins.d.ts +34 -0
- package/dist/m3/versions/v2023_1/builtins.d.ts.map +1 -0
- package/dist/m3/versions/v2023_1/builtins.js +75 -0
- package/dist/m3/versions/v2023_1/builtins.js.map +1 -0
- package/dist/m3/versions/v2023_1/lioncore.d.ts +34 -0
- package/dist/m3/versions/v2023_1/lioncore.d.ts.map +1 -0
- package/dist/m3/versions/v2023_1/lioncore.js +86 -0
- package/dist/m3/versions/v2023_1/lioncore.js.map +1 -0
- package/dist/m3/versions/v2023_1/version.d.ts +6 -0
- package/dist/m3/versions/v2023_1/version.d.ts.map +1 -0
- package/dist/m3/versions/v2023_1/version.js +8 -0
- package/dist/m3/versions/v2023_1/version.js.map +1 -0
- package/dist/m3/versions.d.ts +27 -0
- package/dist/m3/versions.d.ts.map +1 -0
- package/dist/m3/versions.js +28 -0
- package/dist/m3/versions.js.map +1 -0
- package/dist/reading.d.ts +2 -0
- package/dist/reading.d.ts.map +1 -1
- package/dist/serializer.d.ts +12 -1
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +4 -4
- package/dist/serializer.js.map +1 -1
- package/dist/writing.d.ts +2 -0
- package/dist/writing.d.ts.map +1 -1
- package/dist/writing.js.map +1 -1
- package/package.json +3 -3
- package/src/deserializer.ts +18 -14
- package/src/dynamic-facade.ts +3 -4
- package/src/index.ts +0 -1
- package/src/m3/README.md +1 -1
- package/src/m3/builtins-common.ts +143 -0
- package/src/m3/builtins-function.ts +22 -0
- package/src/m3/deserializer.ts +43 -14
- package/src/m3/index.ts +7 -3
- package/src/m3/lioncore-common.ts +42 -0
- package/src/m3/reading-writing.ts +160 -0
- package/src/m3/serializer.ts +25 -2
- package/src/m3/types.ts +10 -16
- package/src/m3/version.ts +23 -0
- package/src/m3/versions/v2023_1/builtins-legacy.ts +126 -0
- package/src/m3/versions/v2023_1/builtins.ts +102 -0
- package/src/m3/{lioncore.ts → versions/v2023_1/lioncore.ts} +53 -76
- package/src/m3/versions/v2023_1/version.ts +9 -0
- package/src/m3/versions.ts +37 -0
- package/src/reading.ts +2 -0
- package/src/serializer.ts +18 -5
- package/src/writing.ts +2 -0
- package/dist/m3/builtins.d.ts +0 -82
- package/dist/m3/builtins.d.ts.map +0 -1
- package/dist/m3/builtins.js.map +0 -1
- package/dist/m3/facade.d.ts +0 -17
- package/dist/m3/facade.d.ts.map +0 -1
- package/dist/m3/facade.js +0 -58
- package/dist/m3/facade.js.map +0 -1
- package/dist/m3/lioncore.d.ts +0 -41
- package/dist/m3/lioncore.d.ts.map +0 -1
- package/dist/m3/lioncore.js +0 -90
- package/dist/m3/lioncore.js.map +0 -1
- package/dist/version.d.ts +0 -5
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -5
- package/dist/version.js.map +0 -1
- package/src/m3/builtins.ts +0 -198
- package/src/m3/facade.ts +0 -130
- package/src/version.ts +0 -5
package/dist/writing.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface Writer<NT extends Node, PNT extends Node = NT> {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Alias for {@link Writer}, kept for backward compatibility, and to be deprecated and removed later.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Use {@link Writer} instead.
|
|
32
34
|
*/
|
|
33
35
|
export interface InstantiationFacade<NT extends Node, PNT extends Node = NT> extends Writer<NT, PNT> {
|
|
34
36
|
}
|
package/dist/writing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writing.d.ts","sourceRoot":"","sources":["../src/writing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAQ,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGjC;;;;;;GAMG;AACH,MAAM,WAAW,MAAM,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,IAAI,GAAG,EAAE;IAE1D;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE;QAAE,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAA;KAAE,KAAK,EAAE,CAAA;IAGzI;;;OAGG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAGrE;;OAEG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAA;CAEvD;AAED
|
|
1
|
+
{"version":3,"file":"writing.d.ts","sourceRoot":"","sources":["../src/writing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAQ,MAAM,eAAe,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGjC;;;;;;GAMG;AACH,MAAM,WAAW,MAAM,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,IAAI,GAAG,EAAE;IAE1D;;;;OAIG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE;QAAE,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAA;KAAE,KAAK,EAAE,CAAA;IAGzI;;;OAGG;IACH,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAGrE;;OAEG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAA;CAEvD;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB,CAAC,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,IAAI,GAAG,EAAE,CAAE,SAAQ,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;CAAG;AAGvG;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;AAqB3G;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,eAAyC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,iBAAyB,CAAA"}
|
package/dist/writing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writing.js","sourceRoot":"","sources":["../src/writing.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2C,IAAI,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"writing.js","sourceRoot":"","sources":["../src/writing.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2C,IAAI,EAAE,MAAM,eAAe,CAAA;AAgD7E;;;;GAIG;AACH,MAAM,eAAe,GAAG,CAAC,OAAsB,EAAmB,EAAE,CAChE,CAAC,QAAiC,EAAE,OAAgB,EAAE,KAAc,EAAQ,EAAE;IAClF,8DAA8D;IACtD,MAAM,GAAG,GAAI,OAAe,CAAC,OAAO,CAAW,CAAA;IAC/C,IAAI,OAAO,YAAY,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAChC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;QACtB,CAAC;QACA,QAAQ,CAAC,GAAG,CAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;SAAM,CAAC;QACJ,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACzB,CAAC;AACL,CAAC,CAAA;AAEL;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAoB,eAAe,CAAC,MAAM,CAAC,CAAA;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lionweb/core",
|
|
3
|
-
"version": "0.8.0-beta.
|
|
3
|
+
"version": "0.8.0-beta.6",
|
|
4
4
|
"description": "LionWeb core for {Java|Type}Script",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"release": "npm publish"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@lionweb/json": "0.8.0-beta.
|
|
31
|
-
"@lionweb/ts-utils": "0.8.0-beta.
|
|
30
|
+
"@lionweb/json": "0.8.0-beta.6",
|
|
31
|
+
"@lionweb/ts-utils": "0.8.0-beta.6"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/deserializer.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
currentSerializationFormatVersion,
|
|
3
|
-
LionWebId,
|
|
4
|
-
LionWebJsonChunk,
|
|
5
|
-
LionWebJsonNode,
|
|
6
|
-
LionWebKey
|
|
7
|
-
} from "@lionweb/json"
|
|
1
|
+
import { LionWebId, LionWebJsonChunk, LionWebJsonNode, LionWebKey } from "@lionweb/json"
|
|
8
2
|
import { byIdMap, groupBy, keepDefineds } from "@lionweb/ts-utils"
|
|
9
3
|
import { Writer } from "./writing.js"
|
|
10
4
|
import { consoleProblemReporter, ProblemReporter } from "./reporter.js"
|
|
11
|
-
import { builtinPropertyValueDeserializer } from "./m3/builtins.js"
|
|
12
5
|
import { MemoisingSymbolTable } from "./m3/symbol-table.js"
|
|
13
6
|
import { Classifier, Containment, Enumeration, Language, PrimitiveType, Property, Reference } from "./m3/types.js"
|
|
7
|
+
import { LionWebVersion } from "./m3/version.js"
|
|
8
|
+
import { defaultLionWebVersion } from "./m3/versions.js"
|
|
14
9
|
import { unresolved } from "./references.js"
|
|
15
10
|
import { Node } from "./types.js"
|
|
16
11
|
|
|
@@ -23,6 +18,8 @@ export interface PropertyValueDeserializer {
|
|
|
23
18
|
|
|
24
19
|
/**
|
|
25
20
|
* Misspelled alias of {@link PropertyValueDeserializer}, kept for backward compatibility, and to be deprecated and removed later.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Use {@link PropertyValueDeserializer} instead.
|
|
26
23
|
*/
|
|
27
24
|
export interface PrimitiveTypeDeserializer extends PropertyValueDeserializer {}
|
|
28
25
|
|
|
@@ -43,13 +40,18 @@ export type DeserializerConfiguration<NT extends Node> = {
|
|
|
43
40
|
* A {@link Writer} that is used to instantiate nodes (with classifiers coming from the `languages` property) and set values on them.
|
|
44
41
|
*/
|
|
45
42
|
writer: Writer<NT>,
|
|
43
|
+
/**
|
|
44
|
+
* The version of the LionWeb serialization format to deserialize from.
|
|
45
|
+
* Default = {@link defaultLionWebVersion}.
|
|
46
|
+
*/
|
|
47
|
+
lionWebVersion?: LionWebVersion
|
|
46
48
|
/**
|
|
47
49
|
* An array of {@link Language languages} that the serialization chunk is expected to conform to.
|
|
48
50
|
*/
|
|
49
51
|
languages: Language[],
|
|
50
52
|
/**
|
|
51
53
|
* A deserializer for values of properties.
|
|
52
|
-
* Default:
|
|
54
|
+
* Default: `(lionWebVersion ?? defaultLionWebVersion).builtinsFacade.propertyValueDeserializer`.
|
|
53
55
|
*/
|
|
54
56
|
propertyValueDeserializer?: PropertyValueDeserializer,
|
|
55
57
|
/**
|
|
@@ -70,14 +72,16 @@ export const deserializerWith = <NT extends Node>(configuration: DeserializerCon
|
|
|
70
72
|
const symbolTable = new MemoisingSymbolTable(configuration.languages)
|
|
71
73
|
const { writer } = configuration
|
|
72
74
|
|
|
73
|
-
const
|
|
75
|
+
const lionWebVersion = configuration?.lionWebVersion ?? defaultLionWebVersion
|
|
76
|
+
const propertyValueDeserializer = configuration.propertyValueDeserializer ?? lionWebVersion.builtinsFacade.propertyValueDeserializer
|
|
74
77
|
const problemReporter = configuration.problemReporter ?? consoleProblemReporter
|
|
75
78
|
|
|
76
79
|
return (serializationChunk, dependentNodes = []) => {
|
|
77
80
|
|
|
78
|
-
|
|
81
|
+
const serializationFormatVersion = lionWebVersion.serializationFormatVersion
|
|
82
|
+
if (serializationChunk.serializationFormatVersion !== serializationFormatVersion) {
|
|
79
83
|
problemReporter.reportProblem(
|
|
80
|
-
`can't deserialize from serialization format other than version "${
|
|
84
|
+
`can't deserialize from serialization format other than version "${serializationFormatVersion}" - assuming that version`
|
|
81
85
|
)
|
|
82
86
|
}
|
|
83
87
|
|
|
@@ -260,7 +264,7 @@ export const deserializerWith = <NT extends Node>(configuration: DeserializerCon
|
|
|
260
264
|
* @param writer - a {@link Writer} that is used to instantiate nodes and set values on them
|
|
261
265
|
* @param languages - {@link Language languages} that the serialized model is expected to conform to
|
|
262
266
|
* @param dependentNodes - a collection of nodes from dependent models against which all references in the serialized model are supposed to resolve against
|
|
263
|
-
* @param propertyValueDeserializer - a deserializer for values of properties (by default
|
|
267
|
+
* @param propertyValueDeserializer - a deserializer for values of properties (by default `defaultLionWebVersion.builtinsFacade.propertyValueDeserializer`)
|
|
264
268
|
* @param problemReporter - an object for reporting problems (by default a {@link consoleProblemReporter})
|
|
265
269
|
*
|
|
266
270
|
* This is a legacy variant of {@link deserializerWith}, kept for backward compatibility, and to be deprecated and removed later.
|
|
@@ -272,7 +276,7 @@ export const deserializeSerializationChunk = <NT extends Node>(
|
|
|
272
276
|
// TODO facades <--> languages, so it's weird that it looks split up like this
|
|
273
277
|
dependentNodes: Node[],
|
|
274
278
|
// TODO (#13) see if you can turn this into [nodes: Node[], writer: Writer<Node>][] after all
|
|
275
|
-
propertyValueDeserializer: PropertyValueDeserializer =
|
|
279
|
+
propertyValueDeserializer: PropertyValueDeserializer = defaultLionWebVersion.builtinsFacade.propertyValueDeserializer,
|
|
276
280
|
problemReporter: ProblemReporter = consoleProblemReporter
|
|
277
281
|
): NT[] => deserializerWith({ writer, languages, propertyValueDeserializer, problemReporter: problemReporter })(serializationChunk, dependentNodes)
|
|
278
282
|
|
package/src/dynamic-facade.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LionWebKey } from "@lionweb/json"
|
|
2
|
-
import {
|
|
3
|
-
import { Classifier } from "./m3/types.js"
|
|
2
|
+
import { Classifier, defaultLionWebVersion } from "./m3/index.js"
|
|
4
3
|
import { Reader, ResolveInfoDeducer } from "./reading.js"
|
|
5
4
|
import { Node } from "./types.js"
|
|
6
5
|
import { updateSettingsKeyBased, Writer } from "./writing.js"
|
|
@@ -19,7 +18,7 @@ export type DynamicNode = Node & {
|
|
|
19
18
|
const propertyGetterFor = (key: LionWebKey): ResolveInfoDeducer<DynamicNode> =>
|
|
20
19
|
(node) =>
|
|
21
20
|
(key in node.settings && typeof node.settings[key] === "string")
|
|
22
|
-
? node.settings[key] as string
|
|
21
|
+
? node.settings[key] as string
|
|
23
22
|
: undefined
|
|
24
23
|
|
|
25
24
|
/**
|
|
@@ -33,7 +32,7 @@ export const dynamicReader: Reader<DynamicNode> = ({
|
|
|
33
32
|
enumerationLiteralFrom: (value, enumeration) =>
|
|
34
33
|
enumeration.literals.find(({key}) => key === value)
|
|
35
34
|
?? null, // (undefined -> null)
|
|
36
|
-
resolveInfoFor: propertyGetterFor(
|
|
35
|
+
resolveInfoFor: propertyGetterFor(defaultLionWebVersion.builtinsFacade.features.inamed_name.key) // using default LionWeb version is OK, since keys don’t change
|
|
37
36
|
})
|
|
38
37
|
|
|
39
38
|
/**
|
package/src/index.ts
CHANGED
package/src/m3/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* [TypeScript type definitions](./types.ts)
|
|
7
7
|
* [Factory](./factory.ts) for conveniently creating M3 instances
|
|
8
8
|
* [Classifiers built in (`LionCore-builtins`) to LionCore](./builtins.ts)
|
|
9
|
-
* [
|
|
9
|
+
* [A reader and writer specific for M3 instances](reading-writing.ts)
|
|
10
10
|
* Persistence: [serializer](./serializer.ts) and [deserializer](./deserializer.ts)
|
|
11
11
|
* [Constraints checker](./constraints.ts)
|
|
12
12
|
* Convenience/helper [functions](./functions.ts) defined on M3 concepts
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { StringsMapper } from "@lionweb/ts-utils"
|
|
2
|
+
import { PropertyValueDeserializer } from "../deserializer.js"
|
|
3
|
+
import { Concept, DataType, Interface, Language, PrimitiveType, Property } from "./types.js"
|
|
4
|
+
import { isUnresolvedReference } from "../references.js"
|
|
5
|
+
import { PropertyValueSerializer } from "../serializer.js"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Determines whether two data types should be structurally equal based on equality of: meta type, key, and language's key.
|
|
10
|
+
*/
|
|
11
|
+
export const shouldBeIdentical = (left: DataType, right: DataType): boolean =>
|
|
12
|
+
left.key === right.key && left.language.key === right.language.key && left.metaType() === right.metaType()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const lookupFrom = <T>(registry: Map<DataType, T>) =>
|
|
16
|
+
(targetDataType: DataType) => {
|
|
17
|
+
for (const [dataType, t] of registry.entries()) {
|
|
18
|
+
if (shouldBeIdentical(targetDataType, dataType)) {
|
|
19
|
+
return t
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return undefined
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Type def. for functions that deserialize the value of a property of a specific type.
|
|
28
|
+
*/
|
|
29
|
+
export type PropertyValueDeserializerFunction = (value: string) => unknown
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @return an empty registry for populating fluently using
|
|
33
|
+
* `.set(<data type>, <deserializer function>)`,
|
|
34
|
+
* to pass to {@link propertyValueDeserializerFrom}.
|
|
35
|
+
*/
|
|
36
|
+
export const newPropertyValueDeserializerRegistry = () => new Map<DataType, PropertyValueDeserializerFunction>
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @return an instance of a {@link PropertyValueDeserializer} entirely driven by the passed `registry`.
|
|
40
|
+
*/
|
|
41
|
+
export const propertyValueDeserializerFrom = (registry: Map<DataType, PropertyValueDeserializerFunction>): PropertyValueDeserializer => {
|
|
42
|
+
const byType = lookupFrom(registry)
|
|
43
|
+
return {
|
|
44
|
+
deserializeValue: (value: string | undefined, property: Property): unknown | undefined => {
|
|
45
|
+
if (value === undefined) {
|
|
46
|
+
if (property.optional) {
|
|
47
|
+
return undefined
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`can't deserialize undefined as the value of required property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}")`)
|
|
50
|
+
}
|
|
51
|
+
const { type } = property
|
|
52
|
+
if (isUnresolvedReference(type)) {
|
|
53
|
+
throw new Error(`can't deserialize property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}") with unspecified type`)
|
|
54
|
+
}
|
|
55
|
+
const specificDeserializer = byType(type)
|
|
56
|
+
if (specificDeserializer != undefined) {
|
|
57
|
+
return specificDeserializer(value)
|
|
58
|
+
} else {
|
|
59
|
+
throw new Error(`can't deserialize value of property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}") of type "${type!.name}": ${value}`)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Type def. for functions that serialize the value of a property of a specific type.
|
|
68
|
+
*/
|
|
69
|
+
export type PropertyValueSerializerFunction = (value: unknown) => string
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @return an empty registry for populating fluently using
|
|
73
|
+
* `.set(<data type>, <serializer function>)`,
|
|
74
|
+
* to pass to {@link propertyValueSerializerFrom}.
|
|
75
|
+
*/
|
|
76
|
+
export const newPropertyValueSerializerRegistry = () => new Map<DataType, PropertyValueSerializerFunction>
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @return an instance of a {@link PropertyValueSerializer} entirely driven by the passed `registry`.
|
|
80
|
+
*/
|
|
81
|
+
export const propertyValueSerializerFrom = (registry: Map<DataType, PropertyValueSerializerFunction>): PropertyValueSerializer => {
|
|
82
|
+
const byType = lookupFrom(registry)
|
|
83
|
+
return {
|
|
84
|
+
serializeValue: (value: unknown | undefined, property: Property): string | null => {
|
|
85
|
+
if (value === undefined) {
|
|
86
|
+
if (property.optional) {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
throw new Error(`can't serialize undefined as the value of required property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}")`)
|
|
90
|
+
}
|
|
91
|
+
const { type } = property
|
|
92
|
+
if (isUnresolvedReference(type)) {
|
|
93
|
+
throw new Error(`can't serialize property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}") with unspecified type`)
|
|
94
|
+
}
|
|
95
|
+
const specificSerializer = byType(type)
|
|
96
|
+
if (specificSerializer != undefined) {
|
|
97
|
+
return specificSerializer(value)
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error(`can't serialize value of property "${property.name}" (on classifier "${property.classifier.name}" in language "${property.classifier.language.name}") of type "${type!.name}": ${value}`)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The key of the LionCore language containing the built-ins.
|
|
108
|
+
*/
|
|
109
|
+
export const lioncoreBuiltinsKey = "LionCore-builtins"
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A function that generates IDs and keys for entities in the LionCore built-ins language.
|
|
113
|
+
*/
|
|
114
|
+
export const lioncoreBuiltinsIdAndKeyGenerator: StringsMapper = (...names) =>
|
|
115
|
+
[lioncoreBuiltinsKey, ...names.slice(1)].join("-")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Type def. for objects that façade (a version of) the LionCore built-ins.
|
|
120
|
+
*/
|
|
121
|
+
export type LionCoreBuiltinsFacade = {
|
|
122
|
+
language: Language
|
|
123
|
+
/** The default {@link PropertyValueDeserializer}. */
|
|
124
|
+
propertyValueDeserializer: PropertyValueDeserializer
|
|
125
|
+
/** The default {@link PropertyValueSerializer}. */
|
|
126
|
+
propertyValueSerializer: PropertyValueSerializer
|
|
127
|
+
classifiers: {
|
|
128
|
+
node: Concept
|
|
129
|
+
inamed: Interface
|
|
130
|
+
}
|
|
131
|
+
features: {
|
|
132
|
+
inamed_name: Property
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The built-in primitive types: boolean, integer, string + legacy (in the `Record<...>` part).
|
|
136
|
+
*/
|
|
137
|
+
primitiveTypes: {
|
|
138
|
+
booleanDataType: PrimitiveType
|
|
139
|
+
integerDataType: PrimitiveType
|
|
140
|
+
stringDataType: PrimitiveType
|
|
141
|
+
} & Record<string, PrimitiveType>
|
|
142
|
+
}
|
|
143
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Classifier, Concept } from "./types.js"
|
|
2
|
+
import { LionWebVersion } from "./version.js"
|
|
3
|
+
import { defaultLionWebVersion } from "./versions.js"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @return whether the given {@link Classifier} is the built-in `Node` {@link Concept}
|
|
7
|
+
* of *any* version of the LionCore builtins language,
|
|
8
|
+
* or of the version belonging to the designated {@link LionWebVersion}.
|
|
9
|
+
*/
|
|
10
|
+
export const isBuiltinNodeConcept = (classifier: Classifier, lionWebVersion?: LionWebVersion): boolean => {
|
|
11
|
+
const { builtinsFacade } = lionWebVersion ?? defaultLionWebVersion
|
|
12
|
+
return classifier instanceof Concept
|
|
13
|
+
&& (classifier as Concept).abstract
|
|
14
|
+
&& classifier.language.key === builtinsFacade.language.key
|
|
15
|
+
&& (lionWebVersion === undefined || classifier.language.version === builtinsFacade.language.version)
|
|
16
|
+
&& classifier.key === builtinsFacade.classifiers.node.key
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
* NOTE: this function has to be defined in a separate file to avoid circular loading dependencies!
|
|
21
|
+
*/
|
|
22
|
+
|
package/src/m3/deserializer.ts
CHANGED
|
@@ -2,10 +2,43 @@ import { LionWebJsonChunk } from "@lionweb/json"
|
|
|
2
2
|
import { deserializerWith } from "../deserializer.js"
|
|
3
3
|
import { nodesExtractorUsing } from "../extraction.js"
|
|
4
4
|
import { consoleProblemReporter, ProblemReporter } from "../reporter.js"
|
|
5
|
-
import {
|
|
6
|
-
import { lioncoreReader, lioncoreWriter } from "./facade.js"
|
|
7
|
-
import { lioncore } from "./lioncore.js"
|
|
5
|
+
import { lioncoreReaderFor, lioncoreWriterFor } from "./reading-writing.js"
|
|
8
6
|
import { Language } from "./types.js"
|
|
7
|
+
import { LionWebVersion } from "./version.js"
|
|
8
|
+
import { defaultLionWebVersion } from "./versions.js"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Type def. for objects that contain all necessary data to deserialize one or more languages from a {@link LionWebJsonChunk serialization chunk}.
|
|
13
|
+
*/
|
|
14
|
+
export type LanguageDeserializationData = {
|
|
15
|
+
serializationChunk: LionWebJsonChunk
|
|
16
|
+
/**
|
|
17
|
+
* The version of the LionWeb serialization format to deserialize from.
|
|
18
|
+
* Default = {@link defaultLionWebVersion}.
|
|
19
|
+
*/
|
|
20
|
+
lionWebVersion?: LionWebVersion
|
|
21
|
+
dependentLanguages?: Language[]
|
|
22
|
+
/**
|
|
23
|
+
* Default = {@link consoleProblemReporter}.
|
|
24
|
+
*/
|
|
25
|
+
problemReporter?: ProblemReporter
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @return languages serialized to the {@link LionWebJsonChunk serialization chunk} passed in the {@link LanguageDeserializationData data object}.
|
|
30
|
+
*/
|
|
31
|
+
export const deserializeLanguagesFrom = ({serializationChunk, dependentLanguages, problemReporter, lionWebVersion = defaultLionWebVersion}: LanguageDeserializationData): Language[] =>
|
|
32
|
+
deserializerWith({
|
|
33
|
+
writer: lioncoreWriterFor(lionWebVersion),
|
|
34
|
+
languages: [lionWebVersion.lioncoreFacade.language, ...(dependentLanguages ?? [])],
|
|
35
|
+
problemReporter: problemReporter ?? consoleProblemReporter
|
|
36
|
+
})(
|
|
37
|
+
serializationChunk,
|
|
38
|
+
[lionWebVersion.builtinsFacade.language, ...(dependentLanguages ?? [])].flatMap(nodesExtractorUsing(lioncoreReaderFor(lionWebVersion))),
|
|
39
|
+
)
|
|
40
|
+
.filter((rootNode) => rootNode instanceof Language)
|
|
41
|
+
.map((language) => (language as Language).dependingOn(...(dependentLanguages ?? [])))
|
|
9
42
|
|
|
10
43
|
|
|
11
44
|
/**
|
|
@@ -13,31 +46,27 @@ import { Language } from "./types.js"
|
|
|
13
46
|
* as an instance of the LionCore metametamodel, using {@link _M3Concept these type definitions}.
|
|
14
47
|
*/
|
|
15
48
|
export const deserializeLanguages = (serializationChunk: LionWebJsonChunk, ...dependentLanguages: Language[]): Language[] =>
|
|
16
|
-
|
|
49
|
+
deserializeLanguagesFrom({ serializationChunk, dependentLanguages })
|
|
50
|
+
|
|
17
51
|
|
|
18
52
|
/**
|
|
19
53
|
* Deserializes languages that have been serialized into the LionWeb serialization JSON format
|
|
20
54
|
* as an instance of the LionCore metametamodel, using {@link _M3Concept these type definitions}.
|
|
21
55
|
* This function takes a {@link ProblemReporter} to be able to see what problems occurred.
|
|
56
|
+
*
|
|
57
|
+
* @deprecated Use {@link deserializeLanguagesFrom} instead.
|
|
22
58
|
*/
|
|
23
59
|
export const deserializeLanguagesWithReporter = (
|
|
24
60
|
serializationChunk: LionWebJsonChunk,
|
|
25
61
|
problemReporter: ProblemReporter,
|
|
26
62
|
...dependentLanguages: Language[]
|
|
27
63
|
): Language[] =>
|
|
28
|
-
|
|
29
|
-
writer: lioncoreWriter,
|
|
30
|
-
languages: [lioncore, ...dependentLanguages],
|
|
31
|
-
problemReporter: problemReporter
|
|
32
|
-
})(
|
|
33
|
-
serializationChunk,
|
|
34
|
-
[lioncoreBuiltins, ...dependentLanguages].flatMap(nodesExtractorUsing(lioncoreReader)),
|
|
35
|
-
)
|
|
36
|
-
.filter((rootNode) => rootNode instanceof Language)
|
|
37
|
-
.map((language) => (language as Language).dependingOn(...dependentLanguages))
|
|
64
|
+
deserializeLanguagesFrom({ serializationChunk, problemReporter, dependentLanguages })
|
|
38
65
|
|
|
39
66
|
/**
|
|
40
67
|
* Legacy alias for {@link deserializeLanguagesWithReporter}, kept for backward compatibility, and to be deprecated and removed later.
|
|
68
|
+
*
|
|
69
|
+
* @deprecated Use {@link deserializeLanguagesFrom} instead.
|
|
41
70
|
*/
|
|
42
71
|
export const deserializeLanguagesWithHandler = deserializeLanguagesWithReporter
|
|
43
72
|
|
package/src/m3/index.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { newPropertyValueDeserializerRegistry, newPropertyValueSerializerRegistry, propertyValueDeserializerFrom, propertyValueSerializerFrom } from "./builtins-common.js"
|
|
2
|
+
export type * from "./builtins-common.js"
|
|
3
|
+
export { isBuiltinNodeConcept } from "./builtins-function.js"
|
|
2
4
|
export * from "./constraints.js"
|
|
3
5
|
export * from "./deserializer.js"
|
|
4
|
-
export * from "./facade.js"
|
|
5
6
|
export * from "./factory.js"
|
|
6
7
|
export * from "./feature-resolvers.js"
|
|
7
8
|
export * from "./functions.js"
|
|
8
|
-
export
|
|
9
|
+
export { lioncoreKey } from "./lioncore-common.js"
|
|
10
|
+
export * from "./reading-writing.js"
|
|
9
11
|
export * from "./reference-checker.js"
|
|
10
12
|
export * from "./serializer.js"
|
|
11
13
|
export * from "./symbol-table.js"
|
|
12
14
|
export * from "./types.js"
|
|
15
|
+
export { LionWebVersion } from "./version.js"
|
|
16
|
+
export * from "./versions.js"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Concept, Interface, Language, Property } from "./types.js"
|
|
2
|
+
import { StringsMapper } from "@lionweb/ts-utils"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The key for the LionCore language.
|
|
6
|
+
*/
|
|
7
|
+
export const lioncoreKey = "LionCore-M3"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A key generator for the LionCore language.
|
|
11
|
+
* *Note*: don’t export!
|
|
12
|
+
*/
|
|
13
|
+
export const generatedLionCoreKeyFrom: StringsMapper = (...names) =>
|
|
14
|
+
names.length === 1 ? lioncoreKey : names.slice(1).join("-")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Type def. for objects that façade (a version of) the LionCore language.
|
|
19
|
+
*/
|
|
20
|
+
export type LionCoreFacade = {
|
|
21
|
+
language: Language
|
|
22
|
+
metaConcepts: {
|
|
23
|
+
annotation: Concept
|
|
24
|
+
classifier: Concept
|
|
25
|
+
concept: Concept
|
|
26
|
+
interface: Concept
|
|
27
|
+
containment: Concept
|
|
28
|
+
enumeration: Concept
|
|
29
|
+
enumerationLiteral: Concept
|
|
30
|
+
ikeyed: Interface
|
|
31
|
+
language: Concept
|
|
32
|
+
primitiveType: Concept
|
|
33
|
+
property: Concept
|
|
34
|
+
reference: Concept
|
|
35
|
+
}
|
|
36
|
+
metaFeatures: {
|
|
37
|
+
concept_abstract: Property
|
|
38
|
+
ikeyed_key: Property
|
|
39
|
+
language_version: Property
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { metaTypedBasedClassifierDeducerFor, qualifiedNameOf } from "./functions.js"
|
|
2
|
+
import { LionWebVersion } from "./version.js"
|
|
3
|
+
import { defaultLionWebVersion } from "./versions.js"
|
|
4
|
+
import { Reader } from "../reading.js"
|
|
5
|
+
import {
|
|
6
|
+
Annotation,
|
|
7
|
+
Classifier,
|
|
8
|
+
Concept,
|
|
9
|
+
Containment,
|
|
10
|
+
Enumeration,
|
|
11
|
+
EnumerationLiteral,
|
|
12
|
+
Interface,
|
|
13
|
+
Language,
|
|
14
|
+
M3Concept,
|
|
15
|
+
PrimitiveType,
|
|
16
|
+
Property,
|
|
17
|
+
Reference
|
|
18
|
+
} from "./types.js"
|
|
19
|
+
import { updateSettingsNameBased, Writer } from "../writing.js"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @return an instance of {@link Reader} to read instances of the LionCore M3 (so M2s),
|
|
24
|
+
* according to the specified {@link LionWebVersion LionWeb `version`}.
|
|
25
|
+
*/
|
|
26
|
+
export const lioncoreReaderFor = (version: LionWebVersion): Reader<M3Concept> => ({
|
|
27
|
+
classifierOf: metaTypedBasedClassifierDeducerFor(version.lioncoreFacade.language),
|
|
28
|
+
getFeatureValue: (node, feature) =>
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
(node as any)[feature.name], // (mirrors name-based update of settings)
|
|
31
|
+
enumerationLiteralFrom: (value, _) => value as EnumerationLiteral | null
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* An instance of {@link Reader} to read instances of the LionCore M3 (so M2s),
|
|
36
|
+
* according to the 2023.1 version of LionWeb.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Use {@link lioncoreReaderFor} instead.
|
|
39
|
+
*/
|
|
40
|
+
export const lioncoreReader: Reader<M3Concept> = lioncoreReaderFor(defaultLionWebVersion)
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Alias for {@link lioncoreReader}, kept for backward compatibility, and to be removed later.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated Use {@link lioncoreReaderFor} instead (skipping `lioncoreReader`).
|
|
46
|
+
*/
|
|
47
|
+
export const lioncoreExtractionFacade = lioncoreReader
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* An instance of {@link Writer} for instances of the LionCore M3 (so M2s),
|
|
52
|
+
* according to the specified {@link LionWebVersion LionWeb `version`}.
|
|
53
|
+
*/
|
|
54
|
+
export const lioncoreWriterFor = (version: LionWebVersion): Writer<M3Concept> => {
|
|
55
|
+
const { lioncoreFacade, builtinsFacade } = version
|
|
56
|
+
const { ikeyed_key } = lioncoreFacade.metaFeatures
|
|
57
|
+
const { inamed_name } = builtinsFacade.features
|
|
58
|
+
const { metaConcepts, metaFeatures } = lioncoreFacade
|
|
59
|
+
return {
|
|
60
|
+
nodeFor: (parent, classifier, id, propertySettings) => {
|
|
61
|
+
switch (classifier.key) {
|
|
62
|
+
case metaConcepts.annotation.key:
|
|
63
|
+
return new Annotation(
|
|
64
|
+
parent as Language,
|
|
65
|
+
propertySettings[inamed_name.key] as string,
|
|
66
|
+
propertySettings[ikeyed_key.key] as string,
|
|
67
|
+
id
|
|
68
|
+
)
|
|
69
|
+
case metaConcepts.concept.key:
|
|
70
|
+
return new Concept(
|
|
71
|
+
parent as Language,
|
|
72
|
+
propertySettings[inamed_name.key] as string,
|
|
73
|
+
propertySettings[ikeyed_key.key] as string,
|
|
74
|
+
id,
|
|
75
|
+
propertySettings[metaFeatures.concept_abstract.key] as boolean
|
|
76
|
+
)
|
|
77
|
+
case metaConcepts.interface.key:
|
|
78
|
+
return new Interface(
|
|
79
|
+
parent as Language,
|
|
80
|
+
propertySettings[inamed_name.key] as string,
|
|
81
|
+
propertySettings[ikeyed_key.key] as string,
|
|
82
|
+
id
|
|
83
|
+
)
|
|
84
|
+
case metaConcepts.containment.key:
|
|
85
|
+
return new Containment(
|
|
86
|
+
parent as Classifier,
|
|
87
|
+
propertySettings[inamed_name.key] as string,
|
|
88
|
+
propertySettings[ikeyed_key.key] as string,
|
|
89
|
+
id
|
|
90
|
+
)
|
|
91
|
+
case metaConcepts.enumeration.key:
|
|
92
|
+
return new Enumeration(
|
|
93
|
+
parent as Language,
|
|
94
|
+
propertySettings[inamed_name.key] as string,
|
|
95
|
+
propertySettings[ikeyed_key.key] as string,
|
|
96
|
+
id
|
|
97
|
+
)
|
|
98
|
+
case metaConcepts.enumerationLiteral.key:
|
|
99
|
+
return new EnumerationLiteral(
|
|
100
|
+
parent as Enumeration,
|
|
101
|
+
propertySettings[inamed_name.key] as string,
|
|
102
|
+
propertySettings[ikeyed_key.key] as string,
|
|
103
|
+
id
|
|
104
|
+
)
|
|
105
|
+
case metaConcepts.language.key:
|
|
106
|
+
return new Language(
|
|
107
|
+
propertySettings[inamed_name.key] as string,
|
|
108
|
+
propertySettings[metaFeatures.language_version.key] as string,
|
|
109
|
+
id,
|
|
110
|
+
propertySettings[metaFeatures.ikeyed_key.key] as string
|
|
111
|
+
)
|
|
112
|
+
case metaConcepts.primitiveType.key:
|
|
113
|
+
return new PrimitiveType(
|
|
114
|
+
parent as Language,
|
|
115
|
+
propertySettings[inamed_name.key] as string,
|
|
116
|
+
propertySettings[ikeyed_key.key] as string,
|
|
117
|
+
id
|
|
118
|
+
)
|
|
119
|
+
case metaConcepts.property.key:
|
|
120
|
+
return new Property(
|
|
121
|
+
parent as Classifier,
|
|
122
|
+
propertySettings[inamed_name.key] as string,
|
|
123
|
+
propertySettings[ikeyed_key.key] as string,
|
|
124
|
+
id
|
|
125
|
+
)
|
|
126
|
+
case metaConcepts.reference.key:
|
|
127
|
+
return new Reference(
|
|
128
|
+
parent as Classifier,
|
|
129
|
+
propertySettings[inamed_name.key] as string,
|
|
130
|
+
propertySettings[ikeyed_key.key] as string,
|
|
131
|
+
id
|
|
132
|
+
)
|
|
133
|
+
default:
|
|
134
|
+
throw new Error(
|
|
135
|
+
`don't know a node of concept ${qualifiedNameOf(classifier)} with key ${classifier.key} that's not in LionCore M3`
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
setFeatureValue: (node, feature, value) => {
|
|
140
|
+
updateSettingsNameBased(node as unknown as Record<string, unknown>, feature, value)
|
|
141
|
+
},
|
|
142
|
+
encodingOf: literal => literal
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* An instance of {@link Writer} for instances of the LionCore M3 (so M2s),
|
|
148
|
+
* according to the 2023.1 LionWeb version.
|
|
149
|
+
*
|
|
150
|
+
* @deprecated Use {@link lioncoreWriterFor} instead.
|
|
151
|
+
*/
|
|
152
|
+
export const lioncoreWriter: Writer<M3Concept> = lioncoreWriterFor(defaultLionWebVersion)
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Alias for {@link lioncoreWriter}, kept for backward compatibility, and to be deprecated and removed later.
|
|
156
|
+
*
|
|
157
|
+
* @deprecated Use {@link lioncoreWriterFor} instead (skipping `lioncoreWrite` altogether).
|
|
158
|
+
*/
|
|
159
|
+
export const lioncoreInstantationFacade = lioncoreWriter
|
|
160
|
+
|