Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit c9e25d7

Browse files
json serialization fixups
1 parent 815201d commit c9e25d7

File tree

12 files changed

+59
-30
lines changed

12 files changed

+59
-30
lines changed

BUILD

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ filegroup(
6767

6868
behaviour_steps_common = [
6969
"//test/behaviour/connection:ConnectionStepsBase.ts",
70-
"//test/behaviour/concept/serialization:SerializationSteps.ts",
70+
"//test/behaviour/concept/serialization/json:JSONSteps.ts",
7171
"//test/behaviour/concept/thing:ThingSteps.ts",
7272
"//test/behaviour/concept/thing/attribute:AttributeSteps.ts",
7373
"//test/behaviour/concept/thing/entity:EntitySteps.ts",

api/answer/ConceptMap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface ConceptMap {
3131

3232
readonly explainables: ConceptMap.Explainables;
3333

34-
JSON(): Record<string, Record<string, boolean | string | number>>;
34+
toJSONRecord(): Record<string, Record<string, boolean | string | number>>;
3535
}
3636

3737
export namespace ConceptMap {

api/concept/Concept.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export interface Concept {
8080

8181
equals(concept: Concept): boolean;
8282

83-
JSON(): Record<string, boolean | string | number>;
83+
toJSONRecord(): Record<string, boolean | string | number>;
8484
}
8585

8686
export namespace Concept {

concept/ConceptImpl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export abstract class ConceptImpl implements Concept {
127127

128128
abstract equals(concept: Concept): boolean;
129129

130-
abstract JSON(): Record<string, boolean | string | number>;
130+
abstract toJSONRecord(): Record<string, boolean | string | number>;
131131
}
132132

133133
export namespace ConceptImpl {

concept/answer/ConceptMapImpl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export class ConceptMapImpl implements ConceptMap {
5353
return this._explainables;
5454
}
5555

56-
JSON(): Record<string, Record<string, boolean | string | number>> {
56+
toJSONRecord(): Record<string, Record<string, boolean | string | number>> {
5757
const object: Record<string, Record<string, boolean | string | number>> = {}
5858
for (const key of this._concepts.keys()) {
59-
object[key] = this._concepts.get(key).JSON();
59+
object[key] = this._concepts.get(key).toJSONRecord();
6060
}
6161
return object;
6262
}

concept/thing/AttributeImpl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export abstract class AttributeImpl extends ThingImpl implements Attribute {
7979
return this;
8080
}
8181

82-
JSON(): Record<string, boolean | string | number> {
82+
toJSONRecord(): Record<string, boolean | string | number> {
8383
let value;
8484
if (this.value instanceof Date) value = this.value.toISOString().slice(0, -1);
8585
else value = this.value;
@@ -191,7 +191,7 @@ export namespace AttributeImpl {
191191
return this;
192192
}
193193

194-
JSON(): Record<string, boolean | string | number> {
194+
toJSONRecord(): Record<string, boolean | string | number> {
195195
let value;
196196
if (this.value instanceof Date) value = this.value.toISOString().slice(0, -1);
197197
else value = this.value;

concept/thing/ThingImpl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export abstract class ThingImpl extends ConceptImpl implements Thing {
7777
return this;
7878
}
7979

80-
JSON(): Record<string, boolean | string | number> {
80+
toJSONRecord(): Record<string, boolean | string | number> {
8181
return {type: this.type.label.name};
8282
}
8383
}
@@ -125,7 +125,7 @@ export namespace ThingImpl {
125125
return this;
126126
}
127127

128-
JSON(): Record<string, boolean | string | number> {
128+
toJSONRecord(): Record<string, boolean | string | number> {
129129
return {type: this.type.label.name};
130130
}
131131

concept/type/TypeImpl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export abstract class TypeImpl extends ConceptImpl implements Type {
6868
return this;
6969
}
7070

71-
JSON(): Record<string, string> {
71+
toJSONRecord(): Record<string, string> {
7272
return {label: this.label.scopedName};
7373
}
7474

@@ -129,7 +129,7 @@ export namespace TypeImpl {
129129
return this;
130130
}
131131

132-
JSON(): Record<string, string> {
132+
toJSONRecord(): Record<string, string> {
133133
return {label: this.label.scopedName};
134134
}
135135

dependencies/vaticle/repositories.bzl

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ def vaticle_typedb_common():
3939
def vaticle_typedb_behaviour():
4040
git_repository(
4141
name = "vaticle_typedb_behaviour",
42-
remote = "https://github.com/vaticle/typedb-behaviour",
43-
commit = "46619244d5f1773505eeacf6d5bd0ae71781f8e8" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_behaviour
42+
remote = "https://github.com/dmitrii-ubskii/typedb-behaviour",
43+
commit = "ab05f18809252674c9b75364a9815c1b264a8b5c" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_behaviour
4444
)

test/behaviour/concept/serialization/BUILD

-14
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,8 @@
2222
load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test")
2323
load("//test/behaviour:rules.bzl", "typedb_behaviour_node_test")
2424

25-
exports_files(["SerializationSteps.ts"])
26-
2725
checkstyle_test(
2826
name = "checkstyle",
2927
include = glob(["*"]),
3028
license_type = "apache-header",
3129
)
32-
33-
typedb_behaviour_node_test(
34-
name = "test",
35-
features = ["@vaticle_typedb_behaviour//concept:serialization.feature"],
36-
node_modules = "//:node_modules",
37-
package_json = "//:package.json",
38-
native_typedb_artifact_core = "//test:native-typedb-artifact",
39-
native_typedb_artifact_cluster = "//test:native-typedb-cluster-artifact",
40-
client = "//:client-nodejs-targz",
41-
steps_core = "//test/behaviour:steps-core-targz",
42-
steps_cluster = "//test/behaviour:steps-cluster-targz",
43-
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# Copyright (C) 2022 Vaticle
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one
5+
# or more contributor license agreements. See the NOTICE file
6+
# distributed with this work for additional information
7+
# regarding copyright ownership. The ASF licenses this file
8+
# to you under the Apache License, Version 2.0 (the
9+
# "License"); you may not use this file except in compliance
10+
# with the License. You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing,
15+
# software distributed under the License is distributed on an
16+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
# KIND, either express or implied. See the License for the
18+
# specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
22+
load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test")
23+
load("//test/behaviour:rules.bzl", "typedb_behaviour_node_test")
24+
25+
exports_files(["JSONSteps.ts"])
26+
27+
checkstyle_test(
28+
name = "checkstyle",
29+
include = glob(["*"]),
30+
license_type = "apache-header",
31+
)
32+
33+
typedb_behaviour_node_test(
34+
name = "test",
35+
features = ["@vaticle_typedb_behaviour//concept/serialization:json.feature"],
36+
node_modules = "//:node_modules",
37+
package_json = "//:package.json",
38+
native_typedb_artifact_core = "//test:native-typedb-artifact",
39+
native_typedb_artifact_cluster = "//test:native-typedb-cluster-artifact",
40+
client = "//:client-nodejs-targz",
41+
steps_core = "//test/behaviour:steps-core-targz",
42+
steps_cluster = "//test/behaviour:steps-cluster-targz",
43+
)

test/behaviour/concept/serialization/SerializationSteps.ts test/behaviour/concept/serialization/json/JSONSteps.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
*/
2121

2222
import {Then} from "@cucumber/cucumber";
23-
import {answers} from "../../typeql/TypeQLSteps"
23+
import {answers} from "../../../typeql/TypeQLSteps"
2424
import assert = require("assert");
2525
import {isDeepStrictEqual} from "util";
2626

2727
Then("JSON of answer concepts matches", async (expectedJSON: string) => {
2828
const expected = JSON.parse(expectedJSON);
29-
const actual = answers.map((conceptMap) => conceptMap.JSON());
29+
const actual = answers.map((conceptMap) => conceptMap.toJSONRecord());
3030
assertUnorderedDeepStrictEqual(actual, expected);
3131
});
3232

0 commit comments

Comments
 (0)