@lionweb/json 0.7.0-beta.8 → 0.7.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.
package/dist/version.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The <em>current</em> version of the serialization format.
2
+ * The *current* version of the serialization format.
3
3
  */
4
4
  export declare const currentSerializationFormatVersion = "2023.1";
5
5
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The <em>current</em> version of the serialization format.
2
+ * The *current* version of the serialization format.
3
3
  */
4
4
  export const currentSerializationFormatVersion = "2023.1";
5
5
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
- "name": "@lionweb/json",
3
- "version": "0.7.0-beta.8",
4
- "description": "TypeScript types for LionWeb JSON",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "typings": "dist/index.d.ts",
8
- "type": "module",
9
- "license": "Apache-2.0",
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/LionWeb-io/lionweb-typescript.git"
13
- },
14
- "bugs": {
15
- "url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
16
- },
17
- "scripts": {
18
- "clean": "npx rimraf dist node_modules -g lionweb-json-*.tgz",
19
- "build": "tsc",
20
- "lint": "eslint src",
21
- "prep:pre-release": "npm run clean && npm install && npm run build",
22
- "prerelease-alpha": "npm run prep:pre-release",
23
- "release-alpha": "npm publish --tag alpha",
24
- "prerelease-beta": "npm run prep:pre-release",
25
- "release-beta": "npm publish --tag beta",
26
- "prerelease": "npm run prep:pre-release",
27
- "release": "npm publish"
28
- }
2
+ "name": "@lionweb/json",
3
+ "version": "0.7.0",
4
+ "description": "TypeScript types for LionWeb JSON",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "typings": "dist/index.d.ts",
8
+ "type": "module",
9
+ "license": "Apache-2.0",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/LionWeb-io/lionweb-typescript.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/LionWeb-io/lionweb-typescript/issues"
16
+ },
17
+ "scripts": {
18
+ "clean": "npx rimraf dist node_modules -g lionweb-json-*.tgz",
19
+ "build": "tsc",
20
+ "lint": "eslint src",
21
+ "prep:pre-release": "npm run clean && npm install && npm run build",
22
+ "prerelease-alpha": "npm run prep:pre-release",
23
+ "release-alpha": "npm publish --tag alpha",
24
+ "prerelease-beta": "npm run prep:pre-release",
25
+ "release-beta": "npm publish --tag beta",
26
+ "prerelease": "npm run prep:pre-release",
27
+ "release": "npm publish"
28
+ }
29
29
  }
@@ -0,0 +1,20 @@
1
+ import { LionWebJsonMetaPointer, LionWebJsonReferenceTarget } from "./types.js"
2
+
3
+ /**
4
+ * Tests whether all the properties of the two meta pointers are identical.
5
+ * @param p1
6
+ * @param p2
7
+ */
8
+ export function isEqualMetaPointer(p1: LionWebJsonMetaPointer, p2: LionWebJsonMetaPointer): boolean {
9
+ return p1.key === p2.key && p1.version === p2.version && p1.language === p2.language
10
+ }
11
+
12
+ /**
13
+ * Tests whether all the properties of the two JSON objects are identical.
14
+ * @param first
15
+ * @param second
16
+ */
17
+ export function isEqualReferenceTarget(first: LionWebJsonReferenceTarget, second: LionWebJsonReferenceTarget): boolean {
18
+ return first.reference === second.reference && first.resolveInfo === second.resolveInfo
19
+ }
20
+
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./version.js"
2
+ export * from "./types.js"
3
+ export * from "./functions.js"
package/src/types.ts ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The types defining the structure of the LionWeb JSON format.
3
+ * @see https://lionweb-io.github.io/specification/serialization/serialization.html
4
+ * We use types instead of classes, because the purpose is to define the Lionweb JSON to be sent over the line.
5
+ */
6
+
7
+ /**
8
+ * LionWebId of LionWeb node.
9
+ */
10
+ export type LionWebId = string
11
+
12
+ /**
13
+ * Key of classifier or feature.
14
+ */
15
+ export type LionWebKey = string
16
+
17
+
18
+ /**
19
+ * Pointer to a classifier or feature in a version of a language.
20
+ */
21
+ export type LionWebJsonMetaPointer = {
22
+ language: LionWebKey
23
+ version: string
24
+ /**
25
+ * The key of the classifier or feature pointed to.
26
+ */
27
+ key: LionWebKey
28
+ }
29
+
30
+ export type LionWebJsonChunk = {
31
+ serializationFormatVersion: string
32
+ languages: LionWebJsonUsedLanguage[]
33
+ nodes: LionWebJsonNode[]
34
+ }
35
+
36
+ export type LionWebJsonUsedLanguage = {
37
+ key: LionWebKey
38
+ version: string
39
+ }
40
+
41
+ export type LionWebJsonNode = {
42
+ id: LionWebId
43
+ classifier: LionWebJsonMetaPointer
44
+ properties: LionWebJsonProperty[]
45
+ containments: LionWebJsonContainment[]
46
+ references: LionWebJsonReference[]
47
+ annotations: LionWebId[]
48
+ parent: LionWebId | null
49
+ }
50
+
51
+ export type LionWebJsonProperty = {
52
+ property: LionWebJsonMetaPointer
53
+ value: string | null
54
+ }
55
+
56
+ export type LionWebJsonContainment = {
57
+ containment: LionWebJsonMetaPointer
58
+ children: LionWebId[]
59
+ }
60
+
61
+ export type LionWebJsonReference = {
62
+ reference: LionWebJsonMetaPointer
63
+ targets: LionWebJsonReferenceTarget[]
64
+ }
65
+
66
+ export type LionWebJsonReferenceTarget = {
67
+ reference: LionWebId
68
+ resolveInfo: string | null
69
+ }
70
+
package/src/version.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The *current* version of the serialization format.
3
+ */
4
+ export const currentSerializationFormatVersion = "2023.1"