@quillsql/node 0.3.1 → 0.3.3
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/clients/QuillServerClient.js +7 -6
- package/dist/index.ispec.js +31 -40
- package/dist/index.js +15 -8
- package/package.json +1 -2
- package/src/clients/QuillServerClient.ts +9 -3
- package/src/index.ispec.ts +31 -31
- package/src/index.ts +25 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/** This client is currently not used but is a good design pratice */
|
|
2
3
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
4
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
5
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,12 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
9
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
10
|
});
|
|
10
11
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const axios_1 = __importDefault(require("axios"));
|
|
16
|
-
/** This client is currently not used but is a good design pratice */
|
|
17
13
|
class QuillServerClient {
|
|
18
14
|
constructor(privateKey) {
|
|
19
15
|
this.baseUrl = "";
|
|
@@ -21,7 +17,12 @@ class QuillServerClient {
|
|
|
21
17
|
}
|
|
22
18
|
postQuill(route, payload) {
|
|
23
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
|
|
20
|
+
const response = yield fetch(`${this.baseUrl}/${route}`, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: Object.assign(Object.assign({}, this.config.headers), { "Content-Type": "application/json" }),
|
|
23
|
+
body: JSON.stringify(payload),
|
|
24
|
+
});
|
|
25
|
+
return response.json();
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
}
|
package/dist/index.ispec.js
CHANGED
|
@@ -1,41 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
const result = yield quill.query({
|
|
35
|
-
orgId: "2",
|
|
36
|
-
metadata,
|
|
37
|
-
});
|
|
38
|
-
// TODO - add assertions
|
|
39
|
-
}));
|
|
40
|
-
});
|
|
41
|
-
});
|
|
2
|
+
// import Quill from ".";
|
|
3
|
+
// import "dotenv/config";
|
|
4
|
+
// const HOST =
|
|
5
|
+
// process.env.ENV === "development"
|
|
6
|
+
// ? "http://localhost:8080"
|
|
7
|
+
// : "https://quill-344421.uc.r.appspot.com";
|
|
8
|
+
// describe("Quill", () => {
|
|
9
|
+
// let quill: Quill;
|
|
10
|
+
// beforeEach(() => {
|
|
11
|
+
// quill = new Quill(
|
|
12
|
+
// process.env.QUILL_PRIVATE_KEY as string,
|
|
13
|
+
// process.env.DB_URL as string
|
|
14
|
+
// );
|
|
15
|
+
// });
|
|
16
|
+
// afterAll(() => {
|
|
17
|
+
// jest.restoreAllMocks();
|
|
18
|
+
// });
|
|
19
|
+
// describe("query", () => {
|
|
20
|
+
// it("org - should return ", async () => {
|
|
21
|
+
// const metadata = {
|
|
22
|
+
// task: "orgs",
|
|
23
|
+
// clientId: "62cda15d7c9fcca7bc0a3689",
|
|
24
|
+
// };
|
|
25
|
+
// const result = await quill.query({
|
|
26
|
+
// orgId: "2",
|
|
27
|
+
// metadata,
|
|
28
|
+
// });
|
|
29
|
+
// // TODO - add assertions
|
|
30
|
+
// });
|
|
31
|
+
// });
|
|
32
|
+
// });
|
package/dist/index.js
CHANGED
|
@@ -8,12 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
const CachedPools_1 = require("./db/CachedPools");
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
13
|
require("dotenv/config");
|
|
18
14
|
const RunQueryProcesses_1 = require("./utils/RunQueryProcesses");
|
|
19
15
|
const HOST = process.env.ENV === "development"
|
|
@@ -22,7 +18,7 @@ const HOST = process.env.ENV === "development"
|
|
|
22
18
|
/**
|
|
23
19
|
* Quill - Fullstack API Platform for Dashboards and Reporting.
|
|
24
20
|
*/
|
|
25
|
-
class
|
|
21
|
+
class QuillClass {
|
|
26
22
|
constructor(privateKey, databaseConnectionString, cache = {}) {
|
|
27
23
|
this.ssl = { rejectUnauthorized: false };
|
|
28
24
|
this.baseUrl = HOST;
|
|
@@ -90,8 +86,13 @@ class Quill {
|
|
|
90
86
|
}
|
|
91
87
|
postQuill(path, payload) {
|
|
92
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const response = yield
|
|
94
|
-
|
|
89
|
+
const response = yield fetch(`${this.baseUrl}/sdk/${path}`, {
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: this.config.headers,
|
|
92
|
+
body: JSON.stringify(payload),
|
|
93
|
+
});
|
|
94
|
+
const data = yield response.json();
|
|
95
|
+
return data;
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
close() {
|
|
@@ -100,4 +101,10 @@ class Quill {
|
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
|
-
exports.default =
|
|
104
|
+
exports.default = QuillClass;
|
|
105
|
+
const Quill = ({ privateKey, databaseConnectionString, cache, }) => {
|
|
106
|
+
return new QuillClass(privateKey, databaseConnectionString, cache);
|
|
107
|
+
};
|
|
108
|
+
module.exports = Quill;
|
|
109
|
+
module.exports.Quill = Quill;
|
|
110
|
+
module.exports.default = Quill;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillsql/node",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Quill's client SDK for node backends.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"typescript": "^5.3.3"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"axios": "^1.6.5",
|
|
30
29
|
"dotenv": "^16.3.1",
|
|
31
30
|
"pg": "^8.11.3",
|
|
32
31
|
"redis": "^4.6.12",
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
|
|
3
1
|
/** This client is currently not used but is a good design pratice */
|
|
4
2
|
|
|
5
3
|
class QuillServerClient {
|
|
@@ -16,7 +14,15 @@ class QuillServerClient {
|
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
public async postQuill(route: string, payload: any): Promise<any> {
|
|
19
|
-
|
|
17
|
+
const response = await fetch(`${this.baseUrl}/${route}`, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: {
|
|
20
|
+
...this.config.headers,
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify(payload),
|
|
24
|
+
});
|
|
25
|
+
return response.json();
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
|
package/src/index.ispec.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import Quill from ".";
|
|
2
|
-
import "dotenv/config";
|
|
1
|
+
// import Quill from ".";
|
|
2
|
+
// import "dotenv/config";
|
|
3
3
|
|
|
4
|
-
const HOST =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
// const HOST =
|
|
5
|
+
// process.env.ENV === "development"
|
|
6
|
+
// ? "http://localhost:8080"
|
|
7
|
+
// : "https://quill-344421.uc.r.appspot.com";
|
|
8
8
|
|
|
9
|
-
describe("Quill", () => {
|
|
10
|
-
|
|
9
|
+
// describe("Quill", () => {
|
|
10
|
+
// let quill: Quill;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
// beforeEach(() => {
|
|
13
|
+
// quill = new Quill(
|
|
14
|
+
// process.env.QUILL_PRIVATE_KEY as string,
|
|
15
|
+
// process.env.DB_URL as string
|
|
16
|
+
// );
|
|
17
|
+
// });
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// afterAll(() => {
|
|
20
|
+
// jest.restoreAllMocks();
|
|
21
|
+
// });
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
23
|
+
// describe("query", () => {
|
|
24
|
+
// it("org - should return ", async () => {
|
|
25
|
+
// const metadata = {
|
|
26
|
+
// task: "orgs",
|
|
27
|
+
// clientId: "62cda15d7c9fcca7bc0a3689",
|
|
28
|
+
// };
|
|
29
|
+
// const result = await quill.query({
|
|
30
|
+
// orgId: "2",
|
|
31
|
+
// metadata,
|
|
32
|
+
// });
|
|
33
|
+
// // TODO - add assertions
|
|
34
|
+
// });
|
|
35
|
+
// });
|
|
36
|
+
// });
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
QuillQueryParams,
|
|
7
7
|
} from "./models/Quill";
|
|
8
8
|
import { CachedPool } from "./db/CachedPools";
|
|
9
|
-
import axios from "axios";
|
|
10
9
|
import "dotenv/config";
|
|
11
10
|
import {
|
|
12
11
|
getTableSchema,
|
|
@@ -22,7 +21,8 @@ const HOST =
|
|
|
22
21
|
/**
|
|
23
22
|
* Quill - Fullstack API Platform for Dashboards and Reporting.
|
|
24
23
|
*/
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
export default class QuillClass {
|
|
26
26
|
// Configure cached connection pools with the given config.
|
|
27
27
|
private connectionString;
|
|
28
28
|
private ssl = { rejectUnauthorized: false };
|
|
@@ -130,15 +130,32 @@ export default class Quill {
|
|
|
130
130
|
path: string,
|
|
131
131
|
payload: any
|
|
132
132
|
): Promise<QuillClientResponse> {
|
|
133
|
-
const response = await
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
);
|
|
138
|
-
|
|
133
|
+
const response = await fetch(`${this.baseUrl}/sdk/${path}`, {
|
|
134
|
+
method: "POST",
|
|
135
|
+
headers: this.config.headers,
|
|
136
|
+
body: JSON.stringify(payload),
|
|
137
|
+
});
|
|
138
|
+
const data = await response.json();
|
|
139
|
+
return data;
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
public async close() {
|
|
142
143
|
await this.targetPool.close();
|
|
143
144
|
}
|
|
144
145
|
}
|
|
146
|
+
|
|
147
|
+
const Quill = ({
|
|
148
|
+
privateKey,
|
|
149
|
+
databaseConnectionString,
|
|
150
|
+
cache,
|
|
151
|
+
}: {
|
|
152
|
+
privateKey: string;
|
|
153
|
+
databaseConnectionString: string;
|
|
154
|
+
cache?: Partial<CacheCredentials>;
|
|
155
|
+
}) => {
|
|
156
|
+
return new QuillClass(privateKey, databaseConnectionString, cache);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
module.exports = Quill;
|
|
160
|
+
module.exports.Quill = Quill;
|
|
161
|
+
module.exports.default = Quill;
|