Skip to content
This repository was archived by the owner on Mar 18, 2022. It is now read-only.

Commit c321562

Browse files
ArsenyYankovskypleerock
authored andcommitted
feat: Aurora Data API (typeorm#4375)
* Initial POC Implementation * Initial POC Implementation * Implemented an interface transformation between typeorm and data api so most of the queries should work, added some tests * Fixed lint errors * Fixed a regex and added some tests on query transformation * Move out to a separate repo * Bumped aurora driver version to latest * Bumped aurora driver version to latest * Delegate transactions to the driver * Delegate transactions to the driver * WIP * WIP * Bump the aurora driver version * Bump the aurora driver version * Fixed aurora driver version * removed unused entity
1 parent b4e9cf0 commit c321562

10 files changed

Lines changed: 2555 additions & 1 deletion

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989
"sqlite3": "^4.0.9",
9090
"ts-node": "^8.0.2",
9191
"tslint": "^5.13.1",
92-
"typescript": "^3.3.3333"
92+
"typescript": "^3.3.3333",
93+
"typeorm-aurora-data-api-driver": "^1.1.1"
9394
},
9495
"dependencies": {
9596
"app-root-path": "^2.0.1",

src/connection/ConnectionOptions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {SqljsConnectionOptions} from "../driver/sqljs/SqljsConnectionOptions";
1010
import {ReactNativeConnectionOptions} from "../driver/react-native/ReactNativeConnectionOptions";
1111
import {NativescriptConnectionOptions} from "../driver/nativescript/NativescriptConnectionOptions";
1212
import {ExpoConnectionOptions} from "../driver/expo/ExpoConnectionOptions";
13+
import {AuroraDataApiConnectionOptions} from "../driver/aurora-data-api/AuroraDataApiConnectionOptions";
14+
1315

1416
/**
1517
* ConnectionOptions is an interface with settings and options for specific connection.
@@ -28,4 +30,5 @@ export type ConnectionOptions =
2830
ReactNativeConnectionOptions|
2931
SqljsConnectionOptions|
3032
MongoConnectionOptions|
33+
AuroraDataApiConnectionOptions|
3134
ExpoConnectionOptions;

src/driver/DriverFactory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {SqljsDriver} from "./sqljs/SqljsDriver";
1111
import {MysqlDriver} from "./mysql/MysqlDriver";
1212
import {PostgresDriver} from "./postgres/PostgresDriver";
1313
import {ExpoDriver} from "./expo/ExpoDriver";
14+
import {AuroraDataApiDriver} from "./aurora-data-api/AuroraDataApiDriver";
1415
import {Driver} from "./Driver";
1516
import {Connection} from "../connection/Connection";
1617

@@ -51,6 +52,8 @@ export class DriverFactory {
5152
return new MongoDriver(connection);
5253
case "expo":
5354
return new ExpoDriver(connection);
55+
case "aurora-data-api":
56+
return new AuroraDataApiDriver(connection);
5457
default:
5558
throw new MissingDriverError(type);
5659
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {AuroraDataApiQueryRunner} from "./AuroraDataApiQueryRunner";
2+
import {Connection} from "../../connection/Connection";
3+
import {ConnectionOptions, QueryRunner} from "../..";
4+
5+
/**
6+
* Organizes communication with MySQL DBMS.
7+
*/
8+
export class AuroraDataApiConnection extends Connection {
9+
queryRunnter: AuroraDataApiQueryRunner;
10+
11+
constructor(options: ConnectionOptions, queryRunner: AuroraDataApiQueryRunner) {
12+
super(options);
13+
this.queryRunnter = queryRunner;
14+
}
15+
16+
public createQueryRunner(mode: "master" | "slave" = "master"): QueryRunner {
17+
return this.queryRunnter;
18+
}
19+
20+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* MySQL specific connection credential options.
3+
*
4+
* @see https://github.com/mysqljs/mysql#connection-options
5+
*/
6+
export interface AuroraDataApiConnectionCredentialsOptions {
7+
8+
/**
9+
* Connection url where perform connection to.
10+
*/
11+
readonly url?: string;
12+
13+
/**
14+
* Database host.
15+
*/
16+
readonly host?: string;
17+
18+
/**
19+
* Database host port.
20+
*/
21+
readonly port?: number;
22+
23+
/**
24+
* Database username.
25+
*/
26+
readonly username?: string;
27+
28+
/**
29+
* Database password.
30+
*/
31+
readonly password?: string;
32+
33+
/**
34+
* Database name to connect to.
35+
*/
36+
readonly database?: string;
37+
38+
/**
39+
* Object with ssl parameters or a string containing name of ssl profile.
40+
*/
41+
readonly ssl?: any;
42+
43+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {BaseConnectionOptions} from "../../connection/BaseConnectionOptions";
2+
import {AuroraDataApiConnectionCredentialsOptions} from "./AuroraDataApiConnectionCredentialsOptions";
3+
4+
/**
5+
* MySQL specific connection options.
6+
*
7+
* @see https://github.com/mysqljs/mysql#connection-options
8+
*/
9+
export interface AuroraDataApiConnectionOptions extends BaseConnectionOptions, AuroraDataApiConnectionCredentialsOptions {
10+
11+
/**
12+
* Database type.
13+
*/
14+
readonly type: "aurora-data-api";
15+
16+
readonly region: string;
17+
18+
readonly secretArn: string;
19+
20+
readonly resourceArn: string;
21+
22+
readonly database: string;
23+
}

0 commit comments

Comments
 (0)