Skip to content
Open
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
5 changes: 4 additions & 1 deletion clients/client-relational/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"project": "tsconfig.json"
},
"rules": {
"@typescript-eslint/no-explicity-any": "off"
"@typescript-eslint/no-explicity-any": "off",
"@typescript-eslint/no-unsafe-assignment":"off",
"@typescript-eslint/no-unsafe-member-access":"off",
"@typescript-eslint/no-unsafe-argument":"off"
}
}
1 change: 1 addition & 0 deletions clients/client-relational/bin/gen-stubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const protoConfig = [
`--ts_proto_opt=Mgoogle/protobuf/struct.proto=@topcoder-framework/lib-common`,
`--ts_proto_opt=Mgoogle/protobuf/timestamp.proto=@topcoder-framework/lib-common`,
`--proto_path ${PROTO_DIR} ${PROTO_DIR}/data-access-layer/relational/*.proto`,
`--experimental_allow_proto3_optional`,
];

// https://github.com/stephenh/ts-proto#usage
Expand Down
9 changes: 9 additions & 0 deletions clients/client-relational/src/common/Op.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WhereGroupCondition, ConditionGroup } from "src/interfaces";

export function and(...conditions: WhereGroupCondition[]): ConditionGroup {
return ["and", conditions];
}

export function or(...conditions: WhereGroupCondition[]): ConditionGroup {
return ["or", conditions];
}
1 change: 1 addition & 0 deletions clients/client-relational/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Op";
1 change: 1 addition & 0 deletions clients/client-relational/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./client/RelationalClient";
export * from "./common";
export * from "./interfaces/";
export * from "./models/data-access-layer/relational/relational";
export * from "./query/";
18 changes: 18 additions & 0 deletions clients/client-relational/src/interfaces/Conditions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {
Operator,
TypedColumn,
} from "src/models/data-access-layer/relational/relational";
import { ValueTypes } from "./ValueTypes";

export type ConditionGroup = [
group: "and" | "or",
conditions: WhereGroupCondition[]
];

export type WhereCondition = [
column: TypedColumn,
operator: Operator,
...value: ValueTypes[]
];

export type WhereGroupCondition = WhereCondition | ConditionGroup;
8 changes: 8 additions & 0 deletions clients/client-relational/src/interfaces/Joiner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {
Join,
JoinCondition,
} from "src/models/data-access-layer/relational/relational";

export type Joiner = Omit<Required<Join>, "type"> & {
conditions: Required<JoinCondition>[];
};
5 changes: 5 additions & 0 deletions clients/client-relational/src/interfaces/ModelAttributes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { TypedColumn } from "src/models/data-access-layer/relational/relational";

export type ModelAttributes<T extends object> = {
[Property in keyof T]-?: TypedColumn;
};
18 changes: 18 additions & 0 deletions clients/client-relational/src/interfaces/ModelOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
type BaseModelOptions = {
schema: string;
table: string;
};

type ModelOptionsWithoutTimestamps = BaseModelOptions & {
timestamps?: false;
};

type ModelOptionsWithTimestamps<T extends object> = BaseModelOptions & {
timestamps: true;
createdAt: keyof T;
updatedAt: keyof T;
};

export type ModelOptions<T extends object> =
| ModelOptionsWithoutTimestamps
| ModelOptionsWithTimestamps<T>;
11 changes: 0 additions & 11 deletions clients/client-relational/src/interfaces/Schema.ts

This file was deleted.

8 changes: 4 additions & 4 deletions clients/client-relational/src/interfaces/TableColumns.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ColumnType } from "../models/data-access-layer/relational/relational";
import { ColumnType } from "src/models/data-access-layer/relational/relational";

export type TableColumn = {
type TableColumn = {
name: string;
type: ColumnType;
};

export type TableColumns<T extends Record<string, unknown>> = {
[Property in keyof T]: TableColumn;
export type TableColumns<T extends object> = {
[Property in keyof T]-?: TableColumn;
};
1 change: 1 addition & 0 deletions clients/client-relational/src/interfaces/ValueTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type ValueTypes = string | number | boolean | null;
6 changes: 5 additions & 1 deletion clients/client-relational/src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export * from "./Schema";
export * from "./Conditions";
export * from "./Joiner";
export * from "./ModelAttributes";
export * from "./ModelOptions";
export * from "./TableColumns";
export * from "./ValueTypes";
Loading