@lionweb/core 0.5.0-beta.0

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.
Files changed (119) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +201 -0
  3. package/dist/api.d.ts +72 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +47 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/deserializer.d.ts +14 -0
  8. package/dist/deserializer.d.ts.map +1 -0
  9. package/dist/deserializer.js +134 -0
  10. package/dist/deserializer.js.map +1 -0
  11. package/dist/dynamic-api.d.ts +19 -0
  12. package/dist/dynamic-api.d.ts.map +1 -0
  13. package/dist/dynamic-api.js +28 -0
  14. package/dist/dynamic-api.js.map +1 -0
  15. package/dist/functions.d.ts +10 -0
  16. package/dist/functions.d.ts.map +1 -0
  17. package/dist/functions.js +13 -0
  18. package/dist/functions.js.map +1 -0
  19. package/dist/id-generation.d.ts +54 -0
  20. package/dist/id-generation.d.ts.map +1 -0
  21. package/dist/id-generation.js +76 -0
  22. package/dist/id-generation.js.map +1 -0
  23. package/dist/index.d.ts +12 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +12 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/m3/api.d.ts +16 -0
  28. package/dist/m3/api.d.ts.map +1 -0
  29. package/dist/m3/api.js +55 -0
  30. package/dist/m3/api.js.map +1 -0
  31. package/dist/m3/builtins.d.ts +24 -0
  32. package/dist/m3/builtins.d.ts.map +1 -0
  33. package/dist/m3/builtins.js +67 -0
  34. package/dist/m3/builtins.js.map +1 -0
  35. package/dist/m3/constraints.d.ts +16 -0
  36. package/dist/m3/constraints.d.ts.map +1 -0
  37. package/dist/m3/constraints.js +40 -0
  38. package/dist/m3/constraints.js.map +1 -0
  39. package/dist/m3/deserializer.d.ts +8 -0
  40. package/dist/m3/deserializer.d.ts.map +1 -0
  41. package/dist/m3/deserializer.js +16 -0
  42. package/dist/m3/deserializer.js.map +1 -0
  43. package/dist/m3/factory.d.ts +26 -0
  44. package/dist/m3/factory.d.ts.map +1 -0
  45. package/dist/m3/factory.js +48 -0
  46. package/dist/m3/factory.js.map +1 -0
  47. package/dist/m3/functions.d.ts +110 -0
  48. package/dist/m3/functions.d.ts.map +1 -0
  49. package/dist/m3/functions.js +145 -0
  50. package/dist/m3/functions.js.map +1 -0
  51. package/dist/m3/index.d.ts +12 -0
  52. package/dist/m3/index.d.ts.map +1 -0
  53. package/dist/m3/index.js +12 -0
  54. package/dist/m3/index.js.map +1 -0
  55. package/dist/m3/key-generation.d.ts +15 -0
  56. package/dist/m3/key-generation.d.ts.map +1 -0
  57. package/dist/m3/key-generation.js +11 -0
  58. package/dist/m3/key-generation.js.map +1 -0
  59. package/dist/m3/lioncore.d.ts +39 -0
  60. package/dist/m3/lioncore.d.ts.map +1 -0
  61. package/dist/m3/lioncore.js +150 -0
  62. package/dist/m3/lioncore.js.map +1 -0
  63. package/dist/m3/reference-checker.d.ts +6 -0
  64. package/dist/m3/reference-checker.d.ts.map +1 -0
  65. package/dist/m3/reference-checker.js +29 -0
  66. package/dist/m3/reference-checker.js.map +1 -0
  67. package/dist/m3/serializer.d.ts +9 -0
  68. package/dist/m3/serializer.d.ts.map +1 -0
  69. package/dist/m3/serializer.js +9 -0
  70. package/dist/m3/serializer.js.map +1 -0
  71. package/dist/m3/textual-syntax.d.ts +4 -0
  72. package/dist/m3/textual-syntax.d.ts.map +1 -0
  73. package/dist/m3/textual-syntax.js +57 -0
  74. package/dist/m3/textual-syntax.js.map +1 -0
  75. package/dist/m3/types.d.ts +117 -0
  76. package/dist/m3/types.d.ts.map +1 -0
  77. package/dist/m3/types.js +196 -0
  78. package/dist/m3/types.js.map +1 -0
  79. package/dist/references.d.ts +18 -0
  80. package/dist/references.d.ts.map +1 -0
  81. package/dist/references.js +10 -0
  82. package/dist/references.js.map +1 -0
  83. package/dist/serialization.d.ts +51 -0
  84. package/dist/serialization.d.ts.map +1 -0
  85. package/dist/serialization.js +5 -0
  86. package/dist/serialization.js.map +1 -0
  87. package/dist/serializer.d.ts +8 -0
  88. package/dist/serializer.d.ts.map +1 -0
  89. package/dist/serializer.js +101 -0
  90. package/dist/serializer.js.map +1 -0
  91. package/dist/types.d.ts +12 -0
  92. package/dist/types.d.ts.map +1 -0
  93. package/dist/types.js +2 -0
  94. package/dist/types.js.map +1 -0
  95. package/dist/utils/array-helpers.d.ts +14 -0
  96. package/dist/utils/array-helpers.d.ts.map +1 -0
  97. package/dist/utils/array-helpers.js +15 -0
  98. package/dist/utils/array-helpers.js.map +1 -0
  99. package/dist/utils/cycles.d.ts +8 -0
  100. package/dist/utils/cycles.d.ts.map +1 -0
  101. package/dist/utils/cycles.js +26 -0
  102. package/dist/utils/cycles.js.map +1 -0
  103. package/dist/utils/grouping.d.ts +13 -0
  104. package/dist/utils/grouping.d.ts.map +1 -0
  105. package/dist/utils/grouping.js +26 -0
  106. package/dist/utils/grouping.js.map +1 -0
  107. package/dist/utils/index.d.ts +5 -0
  108. package/dist/utils/index.d.ts.map +1 -0
  109. package/dist/utils/index.js +5 -0
  110. package/dist/utils/index.js.map +1 -0
  111. package/dist/utils/recursion.d.ts +13 -0
  112. package/dist/utils/recursion.d.ts.map +1 -0
  113. package/dist/utils/recursion.js +21 -0
  114. package/dist/utils/recursion.js.map +1 -0
  115. package/dist/utils/sorting.d.ts +7 -0
  116. package/dist/utils/sorting.d.ts.map +1 -0
  117. package/dist/utils/sorting.js +7 -0
  118. package/dist/utils/sorting.js.map +1 -0
  119. package/package.json +23 -0
@@ -0,0 +1,54 @@
1
+ type GenData = string | undefined;
2
+ /**
3
+ * Type definition for a function that generates a unique ID,
4
+ * possibly ingesting some data.
5
+ */
6
+ export type IdGenerator = (data: GenData) => string;
7
+ /**
8
+ * ID generator that produces sequential IDs:
9
+ * `"1"`, `"2"`, `"3"`, …
10
+ */
11
+ export declare const sequentialIdGen: () => IdGenerator;
12
+ /**
13
+ * Augments the given {@link IdGenerator ID generator} by checking
14
+ * whether it's been given unique {@link GenData data},
15
+ * throwing an error when not.
16
+ */
17
+ export declare const checkUniqueData: (idGen: IdGenerator) => IdGenerator;
18
+ /**
19
+ * Augments the given {@link IdGenerator ID generator} by checking
20
+ * whether it's been given defined ({@code !== undefined}) data,
21
+ * throwing an error when not.
22
+ */
23
+ export declare const checkDefinedData: (idGen: IdGenerator) => IdGenerator;
24
+ /**
25
+ * Augments the given {@link IdGenerator ID generator} by checking
26
+ * whether that returns unique IDs, throwing an error when not.
27
+ */
28
+ export declare const checkUniqueId: (idGen: IdGenerator) => IdGenerator;
29
+ /**
30
+ * Augments the given {@link IdGenerator ID generator} by checking
31
+ * whether it returns valid IDs, meaning [Base64URL](https://www.base64url.com/).
32
+ * (See also [Wikipedia](https://en.wikipedia.org/wiki/Base64#Variants_summary_table).)
33
+ * If a generated ID is not valid, an error is thrown.
34
+ */
35
+ export declare const checkValidId: (idGen: IdGenerator) => IdGenerator;
36
+ /**
37
+ * Type definition for transformers of {@link IdGenerator ID generators}.
38
+ */
39
+ export type IdGenTransformer = (idGen: IdGenerator) => IdGenerator;
40
+ /**
41
+ * Wraps the given ("initial") {@link IdGenerator ID generator}
42
+ * with the given {@link IdGenTransformer ID generator transformers}.
43
+ * In other words:
44
+ *
45
+ * wrap(idGen, trafo1, trafo2, ..., trafoN) === trafoN(...trafo2(trafo1(idGen)))
46
+ */
47
+ export declare const wrapIdGen: (idGen: IdGenerator, ...idGenTransformers: IdGenTransformer[]) => IdGenerator;
48
+ /**
49
+ * Wraps the given ("initial") {@link IdGenerator ID generator} with all
50
+ * {@link IdGenTransformer ID generator checkers} defined above.
51
+ */
52
+ export declare const checkAll: (idGen: IdGenerator) => IdGenerator;
53
+ export {};
54
+ //# sourceMappingURL=id-generation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-generation.d.ts","sourceRoot":"","sources":["../src/id-generation.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AAEjC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAA;AAInD;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,WAGlC,CAAA;AAMD;;;;GAIG;AACH,eAAO,MAAM,eAAe,UAAW,WAAW,KAAG,WASpD,CAAA;AAGD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,UAAW,WAAW,KAAG,WAMjD,CAAA;AAGL;;;GAGG;AACH,eAAO,MAAM,aAAa,UAAW,WAAW,KAAG,WAWlD,CAAA;AAGD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,UAAW,WAAW,KAAG,WAO7C,CAAA;AAGL;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,WAAW,CAAA;AAElE;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UAAW,WAAW,wBAAwB,gBAAgB,EAAE,KAAG,WACtB,CAAA;AAGnE;;;GAGG;AACH,eAAO,MAAM,QAAQ,UAAW,WAAW,KAAG,WAOzC,CAAA"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * ID generator that produces sequential IDs:
3
+ * `"1"`, `"2"`, `"3"`, …
4
+ */
5
+ export const sequentialIdGen = () => {
6
+ let num = 0;
7
+ return () => `${++num}`;
8
+ };
9
+ /**
10
+ * Augments the given {@link IdGenerator ID generator} by checking
11
+ * whether it's been given unique {@link GenData data},
12
+ * throwing an error when not.
13
+ */
14
+ export const checkUniqueData = (idGen) => {
15
+ const datas = [];
16
+ return (data) => {
17
+ if (datas.indexOf(data) > -1) {
18
+ throw new Error(`duplicate data encountered: "${data}"`);
19
+ }
20
+ datas.push(data);
21
+ return idGen(data);
22
+ };
23
+ };
24
+ /**
25
+ * Augments the given {@link IdGenerator ID generator} by checking
26
+ * whether it's been given defined ({@code !== undefined}) data,
27
+ * throwing an error when not.
28
+ */
29
+ export const checkDefinedData = (idGen) => (data) => {
30
+ if (data === undefined) {
31
+ throw new Error(`expected data`);
32
+ }
33
+ return idGen(data);
34
+ };
35
+ /**
36
+ * Augments the given {@link IdGenerator ID generator} by checking
37
+ * whether that returns unique IDs, throwing an error when not.
38
+ */
39
+ export const checkUniqueId = (idGen) => {
40
+ const ids = [];
41
+ return (data) => {
42
+ const id = idGen(data);
43
+ if (ids.indexOf(id) > -1) {
44
+ throw new Error(`duplicate ID generated: "${id}"`);
45
+ }
46
+ ids.push(id);
47
+ return id;
48
+ };
49
+ };
50
+ /**
51
+ * Augments the given {@link IdGenerator ID generator} by checking
52
+ * whether it returns valid IDs, meaning [Base64URL](https://www.base64url.com/).
53
+ * (See also [Wikipedia](https://en.wikipedia.org/wiki/Base64#Variants_summary_table).)
54
+ * If a generated ID is not valid, an error is thrown.
55
+ */
56
+ export const checkValidId = (idGen) => (data) => {
57
+ const id = idGen(data);
58
+ if (!id.match(/^[A-Za-z0-9_-]+$/)) {
59
+ throw new Error(`generated ID is not valid: ${id}`);
60
+ }
61
+ return id;
62
+ };
63
+ /**
64
+ * Wraps the given ("initial") {@link IdGenerator ID generator}
65
+ * with the given {@link IdGenTransformer ID generator transformers}.
66
+ * In other words:
67
+ *
68
+ * wrap(idGen, trafo1, trafo2, ..., trafoN) === trafoN(...trafo2(trafo1(idGen)))
69
+ */
70
+ export const wrapIdGen = (idGen, ...idGenTransformers) => idGenTransformers.reduce((acc, current) => current(acc), idGen);
71
+ /**
72
+ * Wraps the given ("initial") {@link IdGenerator ID generator} with all
73
+ * {@link IdGenTransformer ID generator checkers} defined above.
74
+ */
75
+ export const checkAll = (idGen) => wrapIdGen(idGen, checkDefinedData, checkUniqueData, checkValidId, checkUniqueId);
76
+ //# sourceMappingURL=id-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-generation.js","sourceRoot":"","sources":["../src/id-generation.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAgB,EAAE;IAC7C,IAAI,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;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAe,EAAE,CAC5D,CAAC,IAAI,EAAE,EAAE;IACL,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;IACtB,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,8BAA8B,EAAE,EAAE,CAAC,CAAA;KACtD;IACD,OAAO,EAAE,CAAA;AACb,CAAC,CAAA;AAQL;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAkB,EAAE,GAAG,iBAAqC,EAAe,EAAE,CACnG,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;AAGnE;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAkB,EAAe,EAAE,CACxD,SAAS,CACL,KAAK,EACL,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,aAAa,CAChB,CAAA"}
@@ -0,0 +1,12 @@
1
+ export * from "./api.js";
2
+ export * from "./types.js";
3
+ export * from "./deserializer.js";
4
+ export * from "./dynamic-api.js";
5
+ export * from "./functions.js";
6
+ export * from "./id-generation.js";
7
+ export * from "./references.js";
8
+ export * from "./serializer.js";
9
+ export * from "./serialization.js";
10
+ export * from "./m3/index.js";
11
+ export * from "./utils/index.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ export * from "./api.js";
2
+ export * from "./types.js";
3
+ export * from "./deserializer.js";
4
+ export * from "./dynamic-api.js";
5
+ export * from "./functions.js";
6
+ export * from "./id-generation.js";
7
+ export * from "./references.js";
8
+ export * from "./serializer.js";
9
+ export * from "./serialization.js";
10
+ export * from "./m3/index.js";
11
+ export * from "./utils/index.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { ReadModelAPI, WriteModelAPI } from "../api.js";
2
+ import { M3Concept } from "./types.js";
3
+ import { KeyGenerator } from "./key-generation.js";
4
+ export declare const lioncoreReadAPI: ReadModelAPI<M3Concept>;
5
+ /**
6
+ * @return An implementation of {@link WriteModelAPI write-part of the model API} for instances of the LionCore M3 (so M2s).
7
+ * The returned {@link ModelAPI model API} uses the given {@link KeyGenerator key generator} to generate the keys of all objects in the M2.
8
+ */
9
+ export declare const lioncoreWriteAPIWithKeyGen: (keyGen: KeyGenerator) => WriteModelAPI<M3Concept>;
10
+ /**
11
+ * An implementation of {@link WriteModelAPI} for instances of the LionCore M3 (so M2s), where key = name.
12
+ *
13
+ * TODO deprecate this: [de-]serialization of metamodels should be parametrized with key generation throughout
14
+ */
15
+ export declare const lioncoreWriteAPI: WriteModelAPI<M3Concept>;
16
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/m3/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAA2B,aAAa,EAAC,MAAM,WAAW,CAAA;AAC9E,OAAO,EAQH,SAAS,EAIZ,MAAM,YAAY,CAAA;AAInB,OAAO,EAAC,YAAY,EAAqB,MAAM,qBAAqB,CAAA;AAMpE,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,SAAS,CAMlD,CAAA;AAGF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,WAAY,YAAY,KAAG,cAAc,SAAS,CA6BvF,CAAA;AAGF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,0BAAiD,CAAA"}
package/dist/m3/api.js ADDED
@@ -0,0 +1,55 @@
1
+ import { updateSettingsNameBased } from "../api.js";
2
+ import { Concept, ConceptInterface, Containment, Enumeration, EnumerationLiteral, Language, PrimitiveType, Property, Reference } from "./types.js";
3
+ import { builtinFeatures } from "./builtins.js";
4
+ import { lioncore, metaConcepts, metaFeatures } from "./lioncore.js";
5
+ import { classBasedConceptDeducerFor, qualifiedNameOf } from "./functions.js";
6
+ import { nameIsKeyGenerator } from "./key-generation.js";
7
+ const { inamed_name } = builtinFeatures;
8
+ export const lioncoreReadAPI = ({
9
+ conceptOf: classBasedConceptDeducerFor(lioncore),
10
+ getFeatureValue: (node, feature) =>
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ node[feature.name],
13
+ enumerationLiteralFrom: (value, _) => value
14
+ });
15
+ /**
16
+ * @return An implementation of {@link WriteModelAPI write-part of the model API} for instances of the LionCore M3 (so M2s).
17
+ * The returned {@link ModelAPI model API} uses the given {@link KeyGenerator key generator} to generate the keys of all objects in the M2.
18
+ */
19
+ export const lioncoreWriteAPIWithKeyGen = (keyGen) => ({
20
+ nodeFor: (parent, concept, id, propertySettings) => {
21
+ switch (concept.key) {
22
+ case metaConcepts.concept.key:
23
+ return new Concept(parent, propertySettings[inamed_name.key], "", id, propertySettings[metaFeatures.concept_abstract.key]).keyed(keyGen);
24
+ case metaConcepts.conceptInterface.key:
25
+ return new ConceptInterface(parent, propertySettings[inamed_name.key], "", id).keyed(keyGen);
26
+ case metaConcepts.containment.key:
27
+ return new Containment(parent, propertySettings[inamed_name.key], "", id).keyed(keyGen);
28
+ case metaConcepts.enumeration.key:
29
+ return new Enumeration(parent, propertySettings[inamed_name.key], "", id).keyed(keyGen);
30
+ case metaConcepts.enumerationLiteral.key:
31
+ return new EnumerationLiteral(parent, propertySettings[inamed_name.key], "", id).keyed(keyGen);
32
+ case metaConcepts.language.key:
33
+ return new Language(propertySettings[inamed_name.key], propertySettings[metaFeatures.language_version.key], id, propertySettings[metaFeatures.ikeyed_key.key]);
34
+ case metaConcepts.primitiveType.key:
35
+ return new PrimitiveType(parent, propertySettings[inamed_name.key], "", id).keyed(keyGen);
36
+ case metaConcepts.property.key:
37
+ return new Property(parent, propertySettings[inamed_name.key], "", id).keyed(keyGen);
38
+ case metaConcepts.reference.key:
39
+ return new Reference(parent, propertySettings[inamed_name.key], "", id).keyed(keyGen);
40
+ default:
41
+ throw new Error(`can't deserialize a node of concept "${qualifiedNameOf(concept)}" with key "${concept.key}"`);
42
+ }
43
+ },
44
+ setFeatureValue: (node, feature, value) => {
45
+ updateSettingsNameBased(node, feature, value);
46
+ },
47
+ encodingOf: (literal) => literal
48
+ });
49
+ /**
50
+ * An implementation of {@link WriteModelAPI} for instances of the LionCore M3 (so M2s), where key = name.
51
+ *
52
+ * TODO deprecate this: [de-]serialization of metamodels should be parametrized with key generation throughout
53
+ */
54
+ export const lioncoreWriteAPI = lioncoreWriteAPIWithKeyGen(nameIsKeyGenerator);
55
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/m3/api.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AC,MAAM,CAAC,CAAA;YACnH,KAAK,YAAY,CAAC,QAAQ,CAAC,GAAG;gBAC1B,OAAO,IAAI,QAAQ,CAAC,MAAoB,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,CAAW,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YAChH,KAAK,YAAY,CAAC,SAAS,CAAC,GAAG;gBAC3B,OAAO,IAAI,SAAS,CAAC,MAAoB,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,CAAW,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YACjH;gBACI,MAAM,IAAI,KAAK,CAAC,wCAAwC,eAAe,CAAC,OAAO,CAAC,eAAe,OAAO,CAAC,GAAG,GAAG,CAAC,CAAA;SACrH;IACL,CAAC;IACD,eAAe,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACtC,uBAAuB,CAAC,IAA0C,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACvF,CAAC;IACD,UAAU,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO;CACnC,CAAC,CAAA;AAGF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,kBAAkB,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { Property } from "./types.js";
2
+ /**
3
+ * Definition of a LionCore language that serves as a standard library of built-in primitive types.
4
+ */
5
+ declare const lioncoreBuiltins: import("./types.js").Language;
6
+ type BuiltinPrimitive = string | boolean | number | Record<string, unknown> | Array<unknown>;
7
+ declare const builtinPrimitives: {
8
+ stringDatatype: import("./types.js").PrimitiveType;
9
+ booleanDatatype: import("./types.js").PrimitiveType;
10
+ integerDatatype: import("./types.js").PrimitiveType;
11
+ jsonDatatype: import("./types.js").PrimitiveType;
12
+ };
13
+ declare const builtinClassifiers: {
14
+ node: import("./types.js").Concept;
15
+ inamed: import("./types.js").ConceptInterface;
16
+ };
17
+ declare const builtinFeatures: {
18
+ inamed_name: Property;
19
+ };
20
+ declare const serializeBuiltin: (value: BuiltinPrimitive) => string;
21
+ declare const deserializeBuiltin: (value: string | undefined, property: Property) => BuiltinPrimitive | undefined;
22
+ export type { BuiltinPrimitive };
23
+ export { lioncoreBuiltins, builtinPrimitives, builtinClassifiers, builtinFeatures, serializeBuiltin, deserializeBuiltin };
24
+ //# sourceMappingURL=builtins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/m3/builtins.ts"],"names":[],"mappings":"AACA,OAAO,EAAgD,QAAQ,EAAC,MAAM,YAAY,CAAA;AAYlF;;GAEG;AACH,QAAA,MAAM,gBAAgB,+BAAmB,CAAA;AA8BzC,KAAK,gBAAgB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;AAE5F,QAAA,MAAM,iBAAiB;;;;;CAKtB,CAAA;AAED,QAAA,MAAM,kBAAkB;;;CAGvB,CAAA;AAED,QAAA,MAAM,eAAe;;CAEpB,CAAA;AAGD,QAAA,MAAM,gBAAgB,UAAW,gBAAgB,KAAG,MAcnD,CAAA;AAGD,QAAA,MAAM,kBAAkB,UAAW,MAAM,GAAG,SAAS,YAAY,QAAQ,KAAG,gBAAgB,GAAG,SAgB9F,CAAA;AAGD,YAAY,EACR,gBAAgB,EACnB,CAAA;AAED,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EACrB,CAAA"}
@@ -0,0 +1,67 @@
1
+ import { LanguageFactory } from "./factory.js";
2
+ import { lioncoreBuiltinsQName, lioncoreQNameSeparator } from "./types.js";
3
+ import { qualifiedNameBasedKeyGenerator } from "./key-generation.js";
4
+ import { checkAll } from "../id-generation.js";
5
+ const factory = new LanguageFactory(lioncoreBuiltinsQName, "1", checkAll((qualifiedName) => qualifiedName), qualifiedNameBasedKeyGenerator(lioncoreQNameSeparator));
6
+ /**
7
+ * Definition of a LionCore language that serves as a standard library of built-in primitive types.
8
+ */
9
+ const lioncoreBuiltins = factory.language;
10
+ const stringDatatype = factory.primitiveType("String");
11
+ const booleanDatatype = factory.primitiveType("Boolean");
12
+ const integerDatatype = factory.primitiveType("Integer");
13
+ const jsonDatatype = factory.primitiveType("JSON");
14
+ const node = factory.concept("Node", true);
15
+ const inamed = factory.conceptInterface("INamed");
16
+ const inamed_name = factory.property(inamed, "name")
17
+ .ofType(stringDatatype);
18
+ inamed.havingFeatures(inamed_name);
19
+ lioncoreBuiltins.havingEntities(stringDatatype, booleanDatatype, integerDatatype, jsonDatatype, node, inamed);
20
+ const builtinPrimitives = {
21
+ stringDatatype,
22
+ booleanDatatype,
23
+ integerDatatype,
24
+ jsonDatatype
25
+ };
26
+ const builtinClassifiers = {
27
+ node,
28
+ inamed
29
+ };
30
+ const builtinFeatures = {
31
+ inamed_name
32
+ };
33
+ const serializeBuiltin = (value) => {
34
+ switch (typeof value) {
35
+ case "string": return value;
36
+ case "boolean": return `${value}`;
37
+ case "number": return `${value}`; // TODO check whether integer?
38
+ case "object": {
39
+ try {
40
+ return JSON.stringify(value, null);
41
+ }
42
+ catch (_) {
43
+ // pass-through
44
+ }
45
+ }
46
+ }
47
+ throw new Error(`can't serialize value of built-in primitive type: ${value}`);
48
+ };
49
+ const deserializeBuiltin = (value, property) => {
50
+ if (value === undefined) {
51
+ if (property.optional) {
52
+ return undefined;
53
+ }
54
+ throw new Error(`can't deserialize undefined as the value of a required property`);
55
+ }
56
+ const { type } = property;
57
+ switch (type.name) {
58
+ case "String": return value;
59
+ case "Boolean": return JSON.parse(value);
60
+ case "Integer": return Number(value);
61
+ case "JSON": return JSON.parse(value);
62
+ default:
63
+ throw new Error(`can't deserialize value of type "${type.name}": ${value}`);
64
+ }
65
+ };
66
+ export { lioncoreBuiltins, builtinPrimitives, builtinClassifiers, builtinFeatures, serializeBuiltin, deserializeBuiltin };
67
+ //# sourceMappingURL=builtins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtins.js","sourceRoot":"","sources":["../../src/m3/builtins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAC,qBAAqB,EAAE,sBAAsB,EAAW,MAAM,YAAY,CAAA;AAClF,OAAO,EAAC,8BAA8B,EAAC,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAG5C,MAAM,OAAO,GAAG,IAAI,eAAe,CAC/B,qBAAqB,EACrB,GAAG,EACH,QAAQ,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAc,CAAC,EAC3C,8BAA8B,CAAC,sBAAsB,CAAC,CACzD,CAAA;AAED;;GAEG;AACH,MAAM,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAA;AAGzC,MAAM,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;AACtD,MAAM,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;AACxD,MAAM,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;AACxD,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;AAGlD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;AAG1C,MAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAA;AAEjD,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KAC/C,MAAM,CAAC,cAAc,CAAC,CAAA;AAE3B,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;AAGlC,gBAAgB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,CAAA;QACxC,KAAK,SAAS,CAAC,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;QACpC,KAAK,MAAM,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAA;QAC/C;YACI,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAK,CAAC,IAAI,MAAM,KAAK,EAAE,CAAC,CAAA;KACnF;AACL,CAAC,CAAA;AAOD,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EACrB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { Language, M3Concept } from "./types.js";
2
+ /**
3
+ * Type definition for an issue corresponding
4
+ * to a violation of a constraint on a {@link M3Concept language object}.
5
+ */
6
+ export type Issue = {
7
+ location: M3Concept;
8
+ message: string;
9
+ secondaries: M3Concept[];
10
+ };
11
+ /**
12
+ * Computes the {@link Issue issues} (i.e., constraint violations) for the given language.
13
+ * (This computation is resilient against e.g. inheritance cycles.)
14
+ */
15
+ export declare const issuesLanguage: (language: Language) => Issue[];
16
+ //# sourceMappingURL=constraints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constraints.d.ts","sourceRoot":"","sources":["../../src/m3/constraints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,QAAQ,EAAE,SAAS,EAAC,MAAM,YAAY,CAAA;AAKnF;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG;IAChB,QAAQ,EAAE,SAAS,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,SAAS,EAAE,CAAA;CAC3B,CAAA;AAID;;;GAGG;AACH,eAAO,MAAM,cAAc,aAAc,QAAQ,KAAG,KAAK,EA2CpD,CAAA"}
@@ -0,0 +1,40 @@
1
+ import { Concept, ConceptInterface, isINamed } from "./types.js";
2
+ import { flatMap, inheritedCycleWith, keyOf, namedsOf, qualifiedNameOf } from "./functions.js";
3
+ import { duplicatesAmong } from "../utils/grouping.js";
4
+ // TODO back this type with an M2
5
+ /**
6
+ * Computes the {@link Issue issues} (i.e., constraint violations) for the given language.
7
+ * (This computation is resilient against e.g. inheritance cycles.)
8
+ */
9
+ export const issuesLanguage = (language) => [
10
+ ...flatMap(language, (t) => {
11
+ const issues = [];
12
+ const issue = (message, secondaries) => {
13
+ issues.push({
14
+ location: t,
15
+ message,
16
+ secondaries: secondaries ?? []
17
+ });
18
+ };
19
+ if (t instanceof Concept || t instanceof ConceptInterface) {
20
+ const cycle = inheritedCycleWith(t);
21
+ if (cycle.length > 0) {
22
+ issue(`A ${t.constructor.name} can't inherit (directly or indirectly) from itself, but ${qualifiedNameOf(t)} does so through the following cycle: ${cycle.map((t) => qualifiedNameOf(t)).join(" -> ")}`);
23
+ }
24
+ }
25
+ if (isINamed(t)) {
26
+ if (t.name.trim().length === 0) {
27
+ issue(`A ${t.constructor.name} must have a non-whitespace name`);
28
+ }
29
+ }
30
+ return issues;
31
+ }),
32
+ ...Object.entries(duplicatesAmong(namedsOf(language), keyOf))
33
+ .flatMap(([key, ts]) => ts.map((t) => ({ location: t, message: `Multiple (nested) language elements with the same key "${key}" exist in this language`, secondaries: ts.filter((otherT) => t !== otherT) }))),
34
+ ...Object.entries(duplicatesAmong(namedsOf(language), qualifiedNameOf))
35
+ .flatMap(([key, ts]) => ts.map((t) => ({ location: t, message: `Multiple (nested) language elements with the same key "${key}" exist in this language`, secondaries: ts.filter((otherT) => t !== otherT) })))
36
+ ];
37
+ // not here: duplicate IDs and unresolved references are a problem on a lower level
38
+ // TODO (#8) check uniqueness of IDs
39
+ // TODO (#8) check whether references are resolved
40
+ //# sourceMappingURL=constraints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constraints.js","sourceRoot":"","sources":["../../src/m3/constraints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAA;AACnF,OAAO,EAAC,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AC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;SACxD,OAAO,CACJ,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CACjB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,0DAA0D,GAAG,0BAA0B,EAAE,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,CAC/K,CACJ;IACL,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,CAAC;SAClE,OAAO,CACJ,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CACjB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,0DAA0D,GAAG,0BAA0B,EAAE,WAAW,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,CAC/K,CACJ;CACR,CAAA;AAGL,mFAAmF;AACnF,qCAAqC;AACrC,mDAAmD"}
@@ -0,0 +1,8 @@
1
+ import { Language } from "./types.js";
2
+ import { SerializationChunk } from "../serialization.js";
3
+ /**
4
+ * Deserializes a language that's serialized into the LionWeb serialization JSON format
5
+ * as an instance of the LionCore metametamodel, using {@link _M3Concept these type definitions}.
6
+ */
7
+ export declare const deserializeLanguage: (serializationChunk: SerializationChunk, ...dependentMetamodels: Language[]) => Language;
8
+ //# sourceMappingURL=deserializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../../src/m3/deserializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,kBAAkB,EAAC,MAAM,qBAAqB,CAAA;AAQtD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,uBAAwB,kBAAkB,0BAA0B,QAAQ,EAAE,KAAG,QAShH,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { lioncoreReadAPI, lioncoreWriteAPI } from "./api.js";
2
+ import { nodesExtractorUsing } from "../api.js";
3
+ import { deserializeChunk } from "../deserializer.js";
4
+ import { lioncore } from "./lioncore.js";
5
+ import { lioncoreBuiltins } from "./builtins.js";
6
+ /**
7
+ * Deserializes a language that's serialized into the LionWeb serialization JSON format
8
+ * as an instance of the LionCore metametamodel, using {@link _M3Concept these type definitions}.
9
+ */
10
+ export const deserializeLanguage = (serializationChunk, ...dependentMetamodels) => {
11
+ const language = deserializeChunk(serializationChunk, lioncoreWriteAPI, [lioncore], [lioncoreBuiltins, ...dependentMetamodels].flatMap(nodesExtractorUsing(lioncoreReadAPI)))[0];
12
+ language.dependingOn(...dependentMetamodels);
13
+ return language;
14
+ };
15
+ // TODO pass a function that can resolve dependent metamodels, since they'd generally only known in the serialization
16
+ //# sourceMappingURL=deserializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deserializer.js","sourceRoot":"","sources":["../../src/m3/deserializer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAA;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAA;AAG9C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,kBAAsC,EAAE,GAAG,mBAA+B,EAAY,EAAE;IACxH,MAAM,QAAQ,GAAG,gBAAgB,CAC7B,kBAAkB,EAClB,gBAAgB,EAChB,CAAC,QAAQ,CAAC,EACV,CAAC,gBAAgB,EAAE,GAAG,mBAAmB,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,eAAe,CAAC,CAAC,CAC3F,CAAC,CAAC,CAAa,CAAA;IAChB,QAAQ,CAAC,WAAW,CAAC,GAAG,mBAAmB,CAAC,CAAA;IAC5C,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA;AACD,sHAAsH"}
@@ -0,0 +1,26 @@
1
+ import { Annotation, Classifier, Concept, ConceptInterface, Containment, Enumeration, EnumerationLiteral, Language, PrimitiveType, Property, Reference } from "./types.js";
2
+ import { SingleRef } from "../references.js";
3
+ import { IdGenerator } from "../id-generation.js";
4
+ import { KeyGenerator } from "./key-generation.js";
5
+ /**
6
+ * A factory that produces a {@link Language} instance,
7
+ * as well as elements contained by that instance.
8
+ * The {@link https://zelark.github.io/nano-id-cc/ `nanoid`-based} ID generator
9
+ * is used, unless specified otherwise.
10
+ */
11
+ export declare class LanguageFactory {
12
+ readonly id: IdGenerator;
13
+ readonly key: KeyGenerator;
14
+ readonly language: Language;
15
+ constructor(name: string, version: string, id: IdGenerator, key?: KeyGenerator);
16
+ annotation(name: string, extends_?: SingleRef<Annotation>): Annotation;
17
+ concept(name: string, abstract: boolean, extends_?: SingleRef<Concept>): Concept;
18
+ conceptInterface(name: string): ConceptInterface;
19
+ enumeration(name: string): Enumeration;
20
+ primitiveType(name: string): PrimitiveType;
21
+ containment(classifier: Classifier, name: string): Containment;
22
+ property(classifier: Classifier, name: string): Property;
23
+ reference(classifier: Classifier, name: string): Reference;
24
+ enumerationLiteral(enumeration: Enumeration, name: string): EnumerationLiteral;
25
+ }
26
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/m3/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,UAAU,EACV,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EAER,aAAa,EACb,QAAQ,EACR,SAAS,EACZ,MAAM,YAAY,CAAA;AACnB,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAC,YAAY,EAAqB,MAAM,qBAAqB,CAAA;AAUpE;;;;;GAKG;AACH,qBAAa,eAAe;IAExB,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;gBAEf,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,GAAE,YAAiC;IAUlG,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC;IAIzD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC;IAItE,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAI7B,WAAW,CAAC,IAAI,EAAE,MAAM;IAIxB,aAAa,CAAC,IAAI,EAAE,MAAM;IAK1B,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM;IAIhD,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM;IAI7C,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM;IAK9C,kBAAkB,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM;CAI5D"}
@@ -0,0 +1,48 @@
1
+ import { Annotation, Concept, ConceptInterface, Containment, Enumeration, EnumerationLiteral, Language, lioncoreQNameSeparator, PrimitiveType, Property, Reference } from "./types.js";
2
+ import { qualifiedNameOf } from "./functions.js";
3
+ import { nameIsKeyGenerator } from "./key-generation.js";
4
+ const concat = (...names) => names.join(lioncoreQNameSeparator);
5
+ const unkeyed = "!--no key generated--!";
6
+ /**
7
+ * A factory that produces a {@link Language} instance,
8
+ * as well as elements contained by that instance.
9
+ * The {@link https://zelark.github.io/nano-id-cc/ `nanoid`-based} ID generator
10
+ * is used, unless specified otherwise.
11
+ */
12
+ export class LanguageFactory {
13
+ constructor(name, version, id, key = nameIsKeyGenerator) {
14
+ this.id = id;
15
+ this.key = key;
16
+ const idAndKey = this.id(name); // need to call this.id just once
17
+ this.language = new Language(name, version, idAndKey, idAndKey);
18
+ }
19
+ // TODO this pattern (post-re-setting the key) is not nice: improve...
20
+ annotation(name, extends_) {
21
+ return new Annotation(this.language, name, unkeyed, this.id(concat(this.language.name, name)), extends_).keyed(this.key);
22
+ }
23
+ concept(name, abstract, extends_) {
24
+ return new Concept(this.language, name, unkeyed, this.id(concat(this.language.name, name)), abstract, extends_).keyed(this.key);
25
+ }
26
+ conceptInterface(name) {
27
+ return new ConceptInterface(this.language, name, unkeyed, this.id(concat(this.language.name, name))).keyed(this.key);
28
+ }
29
+ enumeration(name) {
30
+ return new Enumeration(this.language, name, unkeyed, this.id(concat(this.language.name, name))).keyed(this.key);
31
+ }
32
+ primitiveType(name) {
33
+ return new PrimitiveType(this.language, name, unkeyed, this.id(concat(this.language.name, name))).keyed(this.key);
34
+ }
35
+ containment(classifier, name) {
36
+ return new Containment(classifier, name, unkeyed, this.id(concat(qualifiedNameOf(classifier, lioncoreQNameSeparator), name))).keyed(this.key);
37
+ }
38
+ property(classifier, name) {
39
+ return new Property(classifier, name, unkeyed, this.id(concat(qualifiedNameOf(classifier, lioncoreQNameSeparator), name))).keyed(this.key);
40
+ }
41
+ reference(classifier, name) {
42
+ return new Reference(classifier, name, unkeyed, this.id(concat(qualifiedNameOf(classifier, lioncoreQNameSeparator), name))).keyed(this.key);
43
+ }
44
+ enumerationLiteral(enumeration, name) {
45
+ return new EnumerationLiteral(enumeration, name, unkeyed, this.id(concat(qualifiedNameOf(enumeration, lioncoreQNameSeparator), name))).keyed(this.key);
46
+ }
47
+ }
48
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/m3/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAEV,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,sBAAsB,EACtB,aAAa,EACb,QAAQ,EACR,SAAS,EACZ,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAe,kBAAkB,EAAC,MAAM,qBAAqB,CAAA;AAGpE,MAAM,MAAM,GAAG,CAAC,GAAG,KAAe,EAAU,EAAE,CAC1C,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;AAGtC,MAAM,OAAO,GAAG,wBAAwB,CAAA;AAGxC;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAMxB,YAAY,IAAY,EAAE,OAAe,EAAE,EAAe,EAAE,MAAoB,kBAAkB;QAC9F,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA,CAAE,iCAAiC;QACjE,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACnE,CAAC;IAGD,uEAAuE;IAEvE,UAAU,CAAC,IAAY,EAAE,QAAgC;QACrD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,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