@technicity/data-service-generator 0.8.2 → 0.8.5

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.
@@ -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
  }
@@ -9,4 +9,5 @@ export declare class MSSQL {
9
9
  commit: () => Promise<void>;
10
10
  dbCall: (q: string) => Promise<any>;
11
11
  }>;
12
+ closePool(): Promise<void>;
12
13
  }
@@ -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();
@@ -4,4 +4,5 @@ export declare class MySQL {
4
4
  query(...args: any[]): any;
5
5
  beginTransaction(): Promise<any>;
6
6
  getConnection(): Promise<any>;
7
+ endPool(): Promise<void>;
7
8
  }
@@ -32,5 +32,8 @@ class MySQL {
32
32
  .getConnectionAsync()
33
33
  .disposer((connection) => connection.release());
34
34
  }
35
+ async endPool() {
36
+ await this.pool.endAsync();
37
+ }
35
38
  }
36
39
  exports.MySQL = MySQL;
@@ -19,7 +19,10 @@ function stringifyWhere(input) {
19
19
  rowWithMatchingCursor,
20
20
  });
21
21
  if (paginationWhere) {
22
- result = result + " AND " + paginationWhere;
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, } = input;
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.2",
3
+ "version": "0.8.5",
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 && env-cmd mocha ./test/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",
@@ -38,6 +40,6 @@
38
40
  "env-cmd": "^10.1.0",
39
41
  "mocha": "9.1.3",
40
42
  "sinon": "12.0.1",
41
- "typescript": "^4.0.5"
43
+ "typescript": "4.6.4"
42
44
  }
43
45
  }