@technicity/data-service-generator 0.8.1 → 0.8.4
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/generation/generate.js +5 -1
- package/dist/runtime/IRuntime.d.ts +1 -0
- package/dist/runtime/RuntimeKSQL.d.ts +1 -0
- package/dist/runtime/RuntimeKSQL.js +3 -0
- package/dist/runtime/RuntimeMSSQL.d.ts +1 -0
- package/dist/runtime/RuntimeMSSQL.js +3 -0
- package/dist/runtime/RuntimeMySQL.d.ts +1 -0
- package/dist/runtime/RuntimeMySQL.js +3 -0
- package/dist/runtime/lib/MSSQL.d.ts +1 -0
- package/dist/runtime/lib/MSSQL.js +3 -0
- package/dist/runtime/lib/MySQL.d.ts +1 -0
- package/dist/runtime/lib/MySQL.js +3 -0
- package/dist/runtime/lib/stringifyWhere.js +5 -2
- package/package.json +4 -2
|
@@ -117,7 +117,7 @@ async function generate(input) {
|
|
|
117
117
|
const sdkOutputPath = path.join(outdir, "sdk-ts");
|
|
118
118
|
const nccVersion = "^0.33.0";
|
|
119
119
|
child_process.execSync("npm i", { cwd: tmpDirPath, stdio: "inherit" });
|
|
120
|
-
child_process.execSync(`npx
|
|
120
|
+
child_process.execSync(`npm_config_yes=true npx -p @vercel/ncc@${nccVersion} ncc build ./${sdkFilename} -o ${tmpBuildOutputPath} -e ./artifacts`, { cwd: tmpDirPath, stdio: "inherit" });
|
|
121
121
|
// TODO: workaround for artifacts.js not being output by ncc
|
|
122
122
|
fs.writeFileSync(path.join(tmpBuildOutputPath, "artifacts.js"), artifactsSource
|
|
123
123
|
.replace("export const artifacts: IArtifacts = ", "module.exports.artifacts = ")
|
|
@@ -228,6 +228,10 @@ async function getSDKSource(input, specialCaseUuidColumn, supplementClientOpts)
|
|
|
228
228
|
return this.runtime.$queryRaw(sql, values);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
async $shutdown() {
|
|
232
|
+
return this.runtime.$shutdown();
|
|
233
|
+
}
|
|
234
|
+
|
|
231
235
|
${(await Promise.all(input.flatMap(async (x) => {
|
|
232
236
|
let findOnes = [];
|
|
233
237
|
const primaryColumn = await getPrimaryColumn(x.table);
|
|
@@ -4,6 +4,7 @@ export interface IRuntime {
|
|
|
4
4
|
$use: (middleware: TMiddleware) => void;
|
|
5
5
|
$whereNeedsProcessing(where: any): boolean;
|
|
6
6
|
$prepareWhere(artifacts: IArtifacts, table: string, data: any): Promise<any>;
|
|
7
|
+
$shutdown(): Promise<void>;
|
|
7
8
|
}
|
|
8
9
|
export declare type TResolveParams = {
|
|
9
10
|
resource: string;
|
|
@@ -14,5 +14,6 @@ export declare class RuntimeKSQL implements IRuntime {
|
|
|
14
14
|
$use(middleware: TMiddleware): Promise<void>;
|
|
15
15
|
$whereNeedsProcessing(where: any): boolean;
|
|
16
16
|
$prepareWhere(artifacts: IArtifacts, table: string, data: any): Promise<{}>;
|
|
17
|
+
$shutdown(): Promise<void>;
|
|
17
18
|
}
|
|
18
19
|
export {};
|
|
@@ -57,6 +57,9 @@ class RuntimeKSQL {
|
|
|
57
57
|
async $prepareWhere(artifacts, table, data) {
|
|
58
58
|
return (0, shared_1._prepareWhere)(artifacts, table, data, __classPrivateFieldGet(this, _RuntimeKSQL_dbCall, "f").bind(this), __classPrivateFieldGet(this, _RuntimeKSQL_formatQuery, "f").bind(this));
|
|
59
59
|
}
|
|
60
|
+
async $shutdown() {
|
|
61
|
+
// Nothing to do here, I think
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
exports.RuntimeKSQL = RuntimeKSQL;
|
|
62
65
|
_RuntimeKSQL_ksql = new WeakMap(), _RuntimeKSQL_middlewareHandler = new WeakMap(), _RuntimeKSQL_dbCall = new WeakMap(), _RuntimeKSQL_formatQuery = new WeakMap(), _RuntimeKSQL_getBaseTableName = new WeakMap(), _RuntimeKSQL_getMaterializedViewName = new WeakMap(), _RuntimeKSQL_doNotUseMaterializedViews = new WeakMap();
|
|
@@ -12,6 +12,7 @@ export declare class RuntimeMSSQL implements IRuntime {
|
|
|
12
12
|
$use(middleware: TMiddleware): Promise<void>;
|
|
13
13
|
$whereNeedsProcessing(where: any): boolean;
|
|
14
14
|
$prepareWhere(artifacts: IArtifacts, table: string, data: any): Promise<{}>;
|
|
15
|
+
$shutdown(): Promise<void>;
|
|
15
16
|
private dbCall;
|
|
16
17
|
private formatQuery;
|
|
17
18
|
private beginTransaction;
|
|
@@ -41,6 +41,9 @@ class RuntimeMSSQL {
|
|
|
41
41
|
async $prepareWhere(artifacts, table, data) {
|
|
42
42
|
return (0, shared_1._prepareWhere)(artifacts, table, data, this.dbCall.bind(this), this.formatQuery.bind(this));
|
|
43
43
|
}
|
|
44
|
+
async $shutdown() {
|
|
45
|
+
await __classPrivateFieldGet(this, _RuntimeMSSQL_mssqlClient, "f").closePool();
|
|
46
|
+
}
|
|
44
47
|
async dbCall(q) {
|
|
45
48
|
return __classPrivateFieldGet(this, _RuntimeMSSQL_mssqlClient, "f").dbCall(q);
|
|
46
49
|
}
|
|
@@ -11,6 +11,7 @@ export declare class RuntimeMySQL implements IRuntime {
|
|
|
11
11
|
$use(middleware: TMiddleware): Promise<void>;
|
|
12
12
|
$whereNeedsProcessing(where: any): boolean;
|
|
13
13
|
$prepareWhere(artifacts: IArtifacts, table: string, data: any): Promise<{}>;
|
|
14
|
+
$shutdown(): Promise<void>;
|
|
14
15
|
private dbCall;
|
|
15
16
|
private formatQuery;
|
|
16
17
|
private beginTransaction;
|
|
@@ -78,6 +78,9 @@ class RuntimeMySQL {
|
|
|
78
78
|
async $prepareWhere(artifacts, table, data) {
|
|
79
79
|
return (0, shared_1._prepareWhere)(artifacts, table, data, this.dbCall.bind(this), this.formatQuery.bind(this));
|
|
80
80
|
}
|
|
81
|
+
async $shutdown() {
|
|
82
|
+
await __classPrivateFieldGet(this, _RuntimeMySQL_mysqlClient, "f").endPool();
|
|
83
|
+
}
|
|
81
84
|
dbCall(q) {
|
|
82
85
|
return __classPrivateFieldGet(this, _RuntimeMySQL_mysqlClient, "f").query(q);
|
|
83
86
|
}
|
|
@@ -65,6 +65,9 @@ class MSSQL {
|
|
|
65
65
|
.catch(handleError),
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
+
async closePool() {
|
|
69
|
+
await __classPrivateFieldGet(this, _MSSQL_pool, "f").close();
|
|
70
|
+
}
|
|
68
71
|
}
|
|
69
72
|
exports.MSSQL = MSSQL;
|
|
70
73
|
_MSSQL_pool = new WeakMap(), _MSSQL_poolConnect = new WeakMap(), _MSSQL_typeCast = new WeakMap();
|
|
@@ -19,7 +19,10 @@ function stringifyWhere(input) {
|
|
|
19
19
|
rowWithMatchingCursor,
|
|
20
20
|
});
|
|
21
21
|
if (paginationWhere) {
|
|
22
|
-
result =
|
|
22
|
+
result =
|
|
23
|
+
result.length === 0
|
|
24
|
+
? paginationWhere
|
|
25
|
+
: result + " AND " + paginationWhere;
|
|
23
26
|
}
|
|
24
27
|
return result;
|
|
25
28
|
}
|
|
@@ -162,7 +165,7 @@ function getOperatorNeq(value) {
|
|
|
162
165
|
// return { k, v };
|
|
163
166
|
// }
|
|
164
167
|
function stringifyPaginationWhere(input) {
|
|
165
|
-
const { table, args, orderBy, escapeId, escape, rowWithMatchingCursor
|
|
168
|
+
const { table, args, orderBy, escapeId, escape, rowWithMatchingCursor } = input;
|
|
166
169
|
if (args?.$paginate?.after == null && args?.$paginate?.before == null) {
|
|
167
170
|
return "";
|
|
168
171
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@technicity/data-service-generator",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"compile": "rm -rf dist && tsc",
|
|
10
10
|
"create-database": "env-cmd node ./test/mysql/create-database.js && env-cmd node ./test/mysql8/create-database.js && env-cmd node ./test/mssql/create-database.js",
|
|
11
11
|
"generate": "npm run compile && npm run create-database && env-cmd node ./test/mysql/generate.js && env-cmd node ./test/mysql8/generate.js && env-cmd node ./test/mssql/generate.js",
|
|
12
|
-
"test": "npm run generate && env-cmd mocha ./test/addNullFallbacks.test.js && env-cmd mocha ./test/stringifyWhere.test.js &&
|
|
12
|
+
"test": "npm run generate && env-cmd mocha ./test/addNullFallbacks.test.js && env-cmd mocha ./test/stringifyWhere.test.js && npm run test:sdk",
|
|
13
|
+
"test:sdk": "env-cmd mocha ./test/test.js",
|
|
14
|
+
"test:only": "npm run create-database && npm run test:sdk"
|
|
13
15
|
},
|
|
14
16
|
"dependencies": {
|
|
15
17
|
"bluebird": "^3.7.2",
|