Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .factory/automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ build:
bazel run @vaticle_dependencies//distribution/artifact:create-netrc
.factory/test-core.sh //test/behaviour/typeql/language/match/... --test_output=errors --jobs=1
.factory/test-core.sh //test/behaviour/typeql/language/get/... --test_output=errors --jobs=1
.factory/test-core.sh //test/behaviour/typeql/language/expression/... --test_output=errors --jobs=1
test-behaviour-match-cluster:
image: vaticle-ubuntu-22.04
command: |
Expand All @@ -120,6 +121,7 @@ build:
bazel run @vaticle_dependencies//distribution/artifact:create-netrc
.factory/test-cluster.sh //test/behaviour/typeql/language/match/... --test_output=errors --jobs=1
.factory/test-cluster.sh //test/behaviour/typeql/language/get/... --test_output=errors --jobs=1
.factory/test-cluster.sh //test/behaviour/typeql/language/expression/... --test_output=errors --jobs=1
test-behaviour-writable-core:
image: vaticle-ubuntu-22.04
command: |
Expand Down
1 change: 0 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ checkstyle_test(
filegroup(
name = "ci",
data = [
"@vaticle_dependencies//tool/bazelrun:rbe",
"@vaticle_dependencies//distribution/artifact:create-netrc",
"@vaticle_dependencies//tool/release/notes:create",
],
Expand Down
47 changes: 47 additions & 0 deletions api/concept/Concept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { RelationType } from "./type/RelationType";
import { RoleType } from "./type/RoleType";
import { ThingType } from "./type/ThingType";
import { Type } from "./type/Type";
import {ValueType as ValueTypeProto} from "typedb-protocol/common/concept_pb";
import {Value} from "./value/Value";

export interface Concept {

Expand Down Expand Up @@ -58,6 +60,8 @@ export interface Concept {

isRelation(): boolean;

isValue(): boolean;

asType(): Type;

asThingType(): ThingType;
Expand All @@ -78,6 +82,8 @@ export interface Concept {

asRelation(): Relation;

asValue(): Value;

equals(concept: Concept): boolean;

toJSONRecord(): Record<string, boolean | string | number>;
Expand Down Expand Up @@ -111,4 +117,45 @@ export namespace Concept {

asRelation(): Relation.Remote;
}


export interface ValueType {

proto(): ValueTypeProto;

name(): string;
}

export namespace ValueType {

class Impl implements ValueType {

private readonly _proto: ValueTypeProto;
private readonly _name: string;

constructor(type: ValueTypeProto, name: string) {
this._proto = type;
this._name = name;
}

proto(): ValueTypeProto {
return this._proto;
}

name(): string {
return this._name.toLowerCase();
}

toString() {
return "ValueType[" + this._name + "]";
}
}

export const OBJECT = new Impl(ValueTypeProto.OBJECT, "OBJECT");
export const BOOLEAN = new Impl(ValueTypeProto.BOOLEAN, "BOOLEAN");
export const LONG = new Impl(ValueTypeProto.LONG, "LONG");
export const DOUBLE = new Impl(ValueTypeProto.DOUBLE, "DOUBLE");
export const STRING = new Impl(ValueTypeProto.STRING, "STRING");
export const DATETIME = new Impl(ValueTypeProto.DATETIME, "DATETIME");
}
}
13 changes: 7 additions & 6 deletions api/concept/ConceptManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
* under the License.
*/

import { Thing } from "./thing/Thing";
import { AttributeType } from "./type/AttributeType";
import { EntityType } from "./type/EntityType";
import { RelationType } from "./type/RelationType";
import { ThingType } from "./type/ThingType";
import {Thing} from "./thing/Thing";
import {AttributeType} from "./type/AttributeType";
import {EntityType} from "./type/EntityType";
import {RelationType} from "./type/RelationType";
import {ThingType} from "./type/ThingType";
import {Concept} from "./Concept";

export interface ConceptManager {

Expand All @@ -49,5 +50,5 @@ export interface ConceptManager {

getAttributeType(label: string): Promise<AttributeType>;

putAttributeType(label: string, valueType: AttributeType.ValueType): Promise<AttributeType>;
putAttributeType(label: string, valueType: Concept.ValueType): Promise<AttributeType>;
}
81 changes: 14 additions & 67 deletions api/concept/type/AttributeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
* under the License.
*/

import { AttributeType as AttributeTypeProto } from "typedb-protocol/common/concept_pb";
import { Stream } from "../../../common/util/Stream";
import { TypeDBTransaction } from "../../connection/TypeDBTransaction";
import { Attribute } from "../thing/Attribute";
import { Entity } from "../thing/Entity";
import { Relation } from "../thing/Relation";
import { Thing } from "../thing/Thing";
import { EntityType } from "./EntityType";
import { RelationType } from "./RelationType";
import { RoleType } from "./RoleType";
import { ThingType } from "./ThingType";
import { Type } from "./Type";
import {Stream} from "../../../common/util/Stream";
import {TypeDBTransaction} from "../../connection/TypeDBTransaction";
import {Attribute} from "../thing/Attribute";
import {Entity} from "../thing/Entity";
import {Relation} from "../thing/Relation";
import {Thing} from "../thing/Thing";
import {EntityType} from "./EntityType";
import {RelationType} from "./RelationType";
import {RoleType} from "./RoleType";
import {ThingType} from "./ThingType";
import {Type} from "./Type";
import {Concept} from "../Concept";
import Annotation = ThingType.Annotation;

export interface AttributeType extends ThingType {

readonly valueType: AttributeType.ValueType;
readonly valueType: Concept.ValueType;

isBoolean(): boolean;

Expand Down Expand Up @@ -62,8 +63,6 @@ export interface AttributeType extends ThingType {
/* eslint @typescript-eslint/ban-types: "off" */
export namespace AttributeType {

import Annotation = ThingType.Annotation;

export interface Remote extends AttributeType, ThingType.Remote {

setSupertype(type: AttributeType): Promise<void>;
Expand Down Expand Up @@ -381,56 +380,4 @@ export namespace AttributeType {
get(value: Date): Promise<Attribute.DateTime>;
}
}

export interface ValueType {

isKeyable(): boolean;

isWritable(): boolean;

proto(): AttributeTypeProto.ValueType;

name(): string;
}

export namespace ValueType {

class Impl implements ValueType {

private readonly _attrTypeProto: AttributeTypeProto.ValueType;
private readonly _name: string;

constructor(type: AttributeTypeProto.ValueType, name: string) {
this._attrTypeProto = type;
this._name = name;
}

proto(): AttributeTypeProto.ValueType {
return this._attrTypeProto;
}

name(): string {
return this._name.toLowerCase();
}

isKeyable(): boolean {
return [AttributeTypeProto.ValueType.LONG, AttributeTypeProto.ValueType.STRING, AttributeTypeProto.ValueType.DATETIME].includes(this._attrTypeProto);
}

isWritable(): boolean {
return this._attrTypeProto !== AttributeTypeProto.ValueType.OBJECT;
}

toString() {
return "ValueType[" + this._name + "]";
}
}

export const OBJECT = new Impl(AttributeTypeProto.ValueType.OBJECT, "OBJECT");
export const BOOLEAN = new Impl(AttributeTypeProto.ValueType.BOOLEAN, "BOOLEAN");
export const LONG = new Impl(AttributeTypeProto.ValueType.LONG, "LONG");
export const DOUBLE = new Impl(AttributeTypeProto.ValueType.DOUBLE, "DOUBLE");
export const STRING = new Impl(AttributeTypeProto.ValueType.STRING, "STRING");
export const DATETIME = new Impl(AttributeTypeProto.ValueType.DATETIME, "DATETIME");
}
}
9 changes: 5 additions & 4 deletions api/concept/type/ThingType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import {RequestBuilder} from "../../../common/rpc/RequestBuilder";
import {Stream} from "../../../common/util/Stream";
import {TypeDBTransaction} from "../../connection/TypeDBTransaction";
import {Concept} from "../Concept";
import {Attribute} from "../thing/Attribute";
import {Entity} from "../thing/Entity";
import {Relation} from "../thing/Relation";
Expand Down Expand Up @@ -136,19 +137,19 @@ export namespace ThingType {

getOwns(): Stream<AttributeType>;

getOwns(valueType: AttributeType.ValueType): Stream<AttributeType>;
getOwns(valueType: Concept.ValueType): Stream<AttributeType>;

getOwns(annotations: Annotation[]): Stream<AttributeType>;

getOwns(valueType: AttributeType.ValueType, annotations: Annotation[]): Stream<AttributeType>;
getOwns(valueType: Concept.ValueType, annotations: Annotation[]): Stream<AttributeType>;

getOwnsExplicit(): Stream<AttributeType>;

getOwnsExplicit(valueType: AttributeType.ValueType): Stream<AttributeType>;
getOwnsExplicit(valueType: Concept.ValueType): Stream<AttributeType>;

getOwnsExplicit(annotations: Annotation[]): Stream<AttributeType>;

getOwnsExplicit(valueType: AttributeType.ValueType, annotations: Annotation[]): Stream<AttributeType>;
getOwnsExplicit(valueType: Concept.ValueType, annotations: Annotation[]): Stream<AttributeType>;

getOwnsOverridden(attributeType: AttributeType): Promise<AttributeType>;

Expand Down
32 changes: 16 additions & 16 deletions api/concept/type/Type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
*/


import { Type as TypeProto } from "typedb-protocol/common/concept_pb";
import { ErrorMessage } from "../../../common/errors/ErrorMessage";
import { TypeDBClientError } from "../../../common/errors/TypeDBClientError";
import { Label } from "../../../common/Label";
import { Stream } from "../../../common/util/Stream";
import { TypeDBTransaction } from "../../connection/TypeDBTransaction";
import { Concept } from "../Concept";
import { Attribute } from "../thing/Attribute";
import { Entity } from "../thing/Entity";
import { Relation } from "../thing/Relation";
import { Thing } from "../thing/Thing";
import { AttributeType } from "./AttributeType";
import { EntityType } from "./EntityType";
import { RelationType } from "./RelationType";
import { RoleType } from "./RoleType";
import { ThingType } from "./ThingType";
import {Type as TypeProto} from "typedb-protocol/common/concept_pb";
import {ErrorMessage} from "../../../common/errors/ErrorMessage";
import {TypeDBClientError} from "../../../common/errors/TypeDBClientError";
import {Label} from "../../../common/Label";
import {Stream} from "../../../common/util/Stream";
import {TypeDBTransaction} from "../../connection/TypeDBTransaction";
import {Concept} from "../Concept";
import {Attribute} from "../thing/Attribute";
import {Entity} from "../thing/Entity";
import {Relation} from "../thing/Relation";
import {Thing} from "../thing/Thing";
import {AttributeType} from "./AttributeType";
import {EntityType} from "./EntityType";
import {RelationType} from "./RelationType";
import {RoleType} from "./RoleType";
import {ThingType} from "./ThingType";
import BAD_ENCODING = ErrorMessage.Concept.BAD_ENCODING;

export interface Type extends Concept {
Expand Down
83 changes: 83 additions & 0 deletions api/concept/value/Value.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2022 Vaticle
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


import {Concept} from "../Concept";

export interface Value extends Concept {

readonly valueType: Concept.ValueType;

readonly value: boolean | string | number | Date;

isBoolean(): boolean;

isLong(): boolean;

isDouble(): boolean;

isString(): boolean;

isDateTime(): boolean;

asBoolean(): Value.Boolean;

asLong(): Value.Long;

asDouble(): Value.Double;

asString(): Value.String;

asDateTime(): Value.DateTime;
}

export namespace Value {

export interface Boolean extends Value {

readonly value: boolean;

}

export interface Long extends Value {

readonly value: number;

}

export interface Double extends Value {

readonly value: number;

}

export interface String extends Value {

readonly value: string;

}

export interface DateTime extends Value {

readonly value: Date;

}
}
1 change: 1 addition & 0 deletions common/errors/ErrorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export namespace ErrorMessage {
export const BAD_VALUE_TYPE = new Concept(6, (args: Stringable[]) => `The value type '${args[0]}' was not recognised.`);
export const BAD_ANNOTATION = new Concept(7, (args: Stringable[]) => `The annotation '${args[0]}' was not recognised.`);
export const BAD_ATTRIBUTE_VALUE = new Concept(8, (args: Stringable[]) => `The attribute value '${args[0]}' was not recognised.`);
export const VALUE_HAS_NO_REMOTE = new Concept(9, (args: Stringable[]) => `A 'value' has no remote concept.`);
}

export class Query extends ErrorMessage {
Expand Down
Loading