@technicity/data-service-generator 0.12.3 → 0.13.25
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/README.md +9 -4
- package/dist/generation/generate.d.ts +1 -0
- package/dist/generation/generate.js +403 -68
- package/dist/index.d.ts +0 -2
- package/dist/index.js +1 -5
- package/dist/ksql.js +24 -1
- package/dist/runtime/Cache.js +6 -3
- package/dist/runtime/IRuntime.d.ts +4 -2
- package/dist/runtime/RuntimeKSQL.js +25 -2
- package/dist/runtime/RuntimeMySQL.js +29 -3
- package/dist/runtime/RuntimeSQLite.d.ts +38 -0
- package/dist/runtime/RuntimeSQLite.js +135 -0
- package/dist/runtime/lib/MSSQL.js +25 -2
- package/dist/runtime/lib/addNullFallbacks.test.d.ts +1 -0
- package/dist/runtime/lib/addNullFallbacks.test.js +206 -0
- package/dist/runtime/lib/getSqlAst.js +46 -21
- package/dist/runtime/lib/runTransforms.test.d.ts +1 -0
- package/dist/runtime/lib/runTransforms.test.js +112 -0
- package/dist/runtime/lib/shared.js +127 -47
- package/dist/runtime/lib/stringifyWhere.js +38 -11
- package/dist/runtime/lib/stringifyWhere.test.d.ts +1 -0
- package/dist/runtime/lib/stringifyWhere.test.js +236 -0
- package/dist/runtime/lib/typeCastMSSQL.js +24 -1
- package/dist/traverseFieldArgs.test.d.ts +1 -0
- package/dist/traverseFieldArgs.test.js +72 -0
- package/package.json +13 -12
- package/dist/getFakeData.d.ts +0 -12
- package/dist/getFakeData.js +0 -90
- package/dist/getIsList.d.ts +0 -1
- package/dist/getIsList.js +0 -7
package/dist/ksql.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.KSQL = void 0;
|
|
4
|
-
const http2 = require("http2");
|
|
27
|
+
const http2 = __importStar(require("http2"));
|
|
5
28
|
class KSQL {
|
|
6
29
|
constructor(options) {
|
|
7
30
|
this.hostname = options.hostname;
|
package/dist/runtime/Cache.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const crypto_1 = require("crypto");
|
|
4
|
-
const ioredis_1 = require("ioredis");
|
|
5
|
-
const loglevel_1 = require("loglevel");
|
|
7
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
8
|
+
const loglevel_1 = __importDefault(require("loglevel"));
|
|
6
9
|
const utility_1 = require("./lib/utility");
|
|
7
|
-
const Stats_1 = require("./Stats");
|
|
10
|
+
const Stats_1 = __importDefault(require("./Stats"));
|
|
8
11
|
class Cache {
|
|
9
12
|
constructor(redisConfig, debug) {
|
|
10
13
|
this.waiting = new Set();
|
|
@@ -20,13 +20,12 @@ export declare type TResolveParams = {
|
|
|
20
20
|
context?: TContext | undefined;
|
|
21
21
|
skipCache?: boolean;
|
|
22
22
|
dbCall?: TDbCall;
|
|
23
|
-
nullability?: unknown;
|
|
24
23
|
};
|
|
25
24
|
export declare type TContext = {
|
|
26
25
|
[k: string]: any;
|
|
27
26
|
};
|
|
28
27
|
export declare type TMiddleware = (params: TResolveParams, next: (params: TResolveParams) => Promise<any>) => Promise<any>;
|
|
29
|
-
export declare type IDialect = "mysql" | "mssql" | "ksql";
|
|
28
|
+
export declare type IDialect = "mysql" | "mssql" | "ksql" | "sqlite";
|
|
30
29
|
export declare type TDbCall = (q: string) => Promise<any>;
|
|
31
30
|
export declare type TFormatQuery = (q: string, values: any[]) => string;
|
|
32
31
|
export declare type TBeginTransaction = () => Promise<TBeginTransactionResult>;
|
|
@@ -162,6 +161,9 @@ export declare type IArtifacts = {
|
|
|
162
161
|
};
|
|
163
162
|
dateTimeFieldsCount: number;
|
|
164
163
|
fields: TField[];
|
|
164
|
+
dump: {
|
|
165
|
+
schema: string;
|
|
166
|
+
} | null;
|
|
165
167
|
};
|
|
166
168
|
};
|
|
167
169
|
export declare type TFieldType = "string" | "boolean" | "number" | "integer";
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
26
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
27
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -13,9 +36,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
36
|
var _RuntimeKSQL_ksql, _RuntimeKSQL_middlewareHandler, _RuntimeKSQL_dbCall, _RuntimeKSQL_formatQuery, _RuntimeKSQL_getBaseTableName, _RuntimeKSQL_getMaterializedViewName, _RuntimeKSQL_doNotUseMaterializedViews;
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
exports.RuntimeKSQL = void 0;
|
|
16
|
-
const SqlString = require("sqlstring");
|
|
39
|
+
const SqlString = __importStar(require("sqlstring"));
|
|
17
40
|
const async_hooks_1 = require("async_hooks");
|
|
18
|
-
const _ = require("lodash");
|
|
41
|
+
const _ = __importStar(require("lodash"));
|
|
19
42
|
const graphql_relay_1 = require("graphql-relay");
|
|
20
43
|
const shared_1 = require("./lib/shared");
|
|
21
44
|
const ksql_1 = require("../ksql");
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
26
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
27
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -10,14 +33,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
33
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
35
|
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
13
39
|
var _RuntimeMySQL_dialect, _RuntimeMySQL_mysqlClient, _RuntimeMySQL_clientCache, _RuntimeMySQL_middlewareHandler;
|
|
14
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
41
|
exports.RuntimeMySQL = void 0;
|
|
16
|
-
const SqlString = require("sqlstring");
|
|
17
|
-
const Cache_1 = require("./Cache");
|
|
42
|
+
const SqlString = __importStar(require("sqlstring"));
|
|
43
|
+
const Cache_1 = __importDefault(require("./Cache"));
|
|
18
44
|
const MySQL_1 = require("./lib/MySQL");
|
|
19
45
|
const shared_1 = require("./lib/shared");
|
|
20
|
-
const loglevel_1 = require("loglevel");
|
|
46
|
+
const loglevel_1 = __importDefault(require("loglevel"));
|
|
21
47
|
loglevel_1.default.setDefaultLevel("INFO");
|
|
22
48
|
class RuntimeMySQL {
|
|
23
49
|
constructor(clientOpts, otherOpts, artifacts) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import type { IRuntime, TMiddleware, TResolveParams, IArtifacts, ISupplementClientOpts } from "./IRuntime";
|
|
3
|
+
import { MiddlewareHandler } from "./lib/shared";
|
|
4
|
+
declare type TClientOpts = {
|
|
5
|
+
filename: string;
|
|
6
|
+
} & Parameters<typeof Database>[1];
|
|
7
|
+
export declare class RuntimeSQLite implements IRuntime {
|
|
8
|
+
#private;
|
|
9
|
+
__middlewareHandler: MiddlewareHandler<TMiddleware>;
|
|
10
|
+
constructor(clientOpts: TClientOpts, otherOpts: {
|
|
11
|
+
createTablesString?: string;
|
|
12
|
+
seedString?: string;
|
|
13
|
+
supplementClientOpts?: ISupplementClientOpts;
|
|
14
|
+
}, artifacts: IArtifacts);
|
|
15
|
+
resolve(input: TResolveParams): Promise<any>;
|
|
16
|
+
$queryRaw(sql: string, values?: any[]): Promise<any[] | {
|
|
17
|
+
insertId: number | bigint;
|
|
18
|
+
}>;
|
|
19
|
+
$use(middleware: TMiddleware): Promise<void>;
|
|
20
|
+
$whereNeedsProcessing(where: any): boolean;
|
|
21
|
+
$prepareWhere(artifacts: IArtifacts, table: string, data: any): Promise<{}>;
|
|
22
|
+
$shutdown(): Promise<void>;
|
|
23
|
+
$startTransaction(input?: {
|
|
24
|
+
isolationLevel?: "READ UNCOMMITTED" | "READ COMMITTED" | "REPEATABLE READ" | "SERIALIZABLE";
|
|
25
|
+
}): Promise<{
|
|
26
|
+
commit: () => Promise<void>;
|
|
27
|
+
rollback: () => Promise<void>;
|
|
28
|
+
dbCall: (q: string) => Promise<any[] | {
|
|
29
|
+
insertId: number | bigint;
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
private dbCall;
|
|
33
|
+
private formatQuery;
|
|
34
|
+
private dbCallTransaction;
|
|
35
|
+
private commit;
|
|
36
|
+
private rollback;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
26
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
28
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
29
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
30
|
+
};
|
|
31
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
32
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
33
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
var _RuntimeSQLite_dialect, _RuntimeSQLite_db;
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.RuntimeSQLite = void 0;
|
|
42
|
+
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
43
|
+
// @ts-expect-error
|
|
44
|
+
const SqliteString = __importStar(require("sqlstring-sqlite"));
|
|
45
|
+
const shared_1 = require("./lib/shared");
|
|
46
|
+
class RuntimeSQLite {
|
|
47
|
+
constructor(clientOpts, otherOpts, artifacts) {
|
|
48
|
+
_RuntimeSQLite_dialect.set(this, "sqlite");
|
|
49
|
+
_RuntimeSQLite_db.set(this, void 0);
|
|
50
|
+
const { filename, ...restOpts } = clientOpts;
|
|
51
|
+
this.__middlewareHandler = new shared_1.MiddlewareHandler();
|
|
52
|
+
__classPrivateFieldSet(this, _RuntimeSQLite_db, new better_sqlite3_1.default(filename, restOpts), "f");
|
|
53
|
+
if (clientOpts.filename === ":memory:") {
|
|
54
|
+
if (!otherOpts.createTablesString) {
|
|
55
|
+
throw new Error(`\`createTablesString\` must be supplied when filename is \`:memory:\`.`);
|
|
56
|
+
}
|
|
57
|
+
__classPrivateFieldGet(this, _RuntimeSQLite_db, "f").exec(otherOpts.createTablesString);
|
|
58
|
+
if (otherOpts.seedString) {
|
|
59
|
+
__classPrivateFieldGet(this, _RuntimeSQLite_db, "f").exec(otherOpts.seedString);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async resolve(input) {
|
|
64
|
+
return (0, shared_1.resolve)(input, input.dbCall ?? this.dbCall.bind(this), this.formatQuery.bind(this), this.$startTransaction.bind(this), __classPrivateFieldGet(this, _RuntimeSQLite_dialect, "f"), this.__middlewareHandler, input.context ?? {});
|
|
65
|
+
}
|
|
66
|
+
async $queryRaw(sql, values) {
|
|
67
|
+
return this.dbCall(this.formatQuery(sql, values ?? []));
|
|
68
|
+
}
|
|
69
|
+
async $use(middleware) {
|
|
70
|
+
this.__middlewareHandler.register(middleware);
|
|
71
|
+
}
|
|
72
|
+
$whereNeedsProcessing(where) {
|
|
73
|
+
return (0, shared_1.whereNeedsProcessing)(where);
|
|
74
|
+
}
|
|
75
|
+
async $prepareWhere(artifacts, table, data) {
|
|
76
|
+
return (0, shared_1._prepareWhere)(artifacts, table, data, this.dbCall.bind(this), this.formatQuery.bind(this));
|
|
77
|
+
}
|
|
78
|
+
async $shutdown() {
|
|
79
|
+
__classPrivateFieldGet(this, _RuntimeSQLite_db, "f").close();
|
|
80
|
+
}
|
|
81
|
+
async $startTransaction(input) {
|
|
82
|
+
const isolationLevel = input?.isolationLevel;
|
|
83
|
+
if (isolationLevel != null) {
|
|
84
|
+
if (isolationLevel !== "READ UNCOMMITTED" &&
|
|
85
|
+
isolationLevel !== "READ COMMITTED" &&
|
|
86
|
+
isolationLevel !== "REPEATABLE READ" &&
|
|
87
|
+
isolationLevel !== "SERIALIZABLE") {
|
|
88
|
+
throw new Error(`Invalid isolationLevel: ${isolationLevel}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
__classPrivateFieldGet(this, _RuntimeSQLite_db, "f").prepare("BEGIN TRANSACTION").run();
|
|
92
|
+
return {
|
|
93
|
+
commit: this.commit.bind(this),
|
|
94
|
+
rollback: this.rollback.bind(this),
|
|
95
|
+
dbCall: this.dbCallTransaction.bind(this)
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async dbCall(q) {
|
|
99
|
+
const statement = __classPrivateFieldGet(this, _RuntimeSQLite_db, "f").prepare(q);
|
|
100
|
+
if (q.startsWith("INSERT") || q.startsWith("UPDATE") || q.startsWith("DELETE")) {
|
|
101
|
+
const result = statement.run();
|
|
102
|
+
return { insertId: result.lastInsertRowid };
|
|
103
|
+
}
|
|
104
|
+
// TODO: use statement.raw instead of typeCastSqlite? That would stop
|
|
105
|
+
// working if we start joining instead of batching, though.
|
|
106
|
+
// https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#rawtogglestate---this
|
|
107
|
+
return statement.all();
|
|
108
|
+
}
|
|
109
|
+
formatQuery(q, values) {
|
|
110
|
+
return SqliteString.format(q, values);
|
|
111
|
+
}
|
|
112
|
+
async dbCallTransaction(...args) {
|
|
113
|
+
try {
|
|
114
|
+
return await this.dbCall(...args);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
__classPrivateFieldGet(this, _RuntimeSQLite_db, "f").prepare("ROLLBACK").run();
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async commit() {
|
|
122
|
+
try {
|
|
123
|
+
__classPrivateFieldGet(this, _RuntimeSQLite_db, "f").prepare("COMMIT").run();
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
__classPrivateFieldGet(this, _RuntimeSQLite_db, "f").prepare("ROLLBACK").run();
|
|
127
|
+
throw err;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async rollback() {
|
|
131
|
+
__classPrivateFieldGet(this, _RuntimeSQLite_db, "f").prepare("ROLLBACK").run();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.RuntimeSQLite = RuntimeSQLite;
|
|
135
|
+
_RuntimeSQLite_dialect = new WeakMap(), _RuntimeSQLite_db = new WeakMap();
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
26
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
27
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -13,9 +36,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
36
|
var _MSSQL_pool, _MSSQL_poolConnect, _MSSQL_typeCast;
|
|
14
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
38
|
exports.MSSQL = void 0;
|
|
16
|
-
const mssql = require("mssql");
|
|
39
|
+
const mssql = __importStar(require("mssql"));
|
|
17
40
|
// @ts-ignore
|
|
18
|
-
const TSqlString = require("tsqlstring");
|
|
41
|
+
const TSqlString = __importStar(require("tsqlstring"));
|
|
19
42
|
class MSSQL {
|
|
20
43
|
constructor(clientOpts, typeCast) {
|
|
21
44
|
_MSSQL_pool.set(this, void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const globals_1 = require("@jest/globals");
|
|
7
|
+
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
8
|
+
const addNullFallbacks_1 = require("./addNullFallbacks");
|
|
9
|
+
(0, globals_1.describe)("addNullFallbacks", () => {
|
|
10
|
+
// The actual AST has other fields like `args` that
|
|
11
|
+
// aren't relevant to the function
|
|
12
|
+
const sqlAST = {
|
|
13
|
+
type: "table",
|
|
14
|
+
name: "Session",
|
|
15
|
+
as: "Session",
|
|
16
|
+
fieldName: "session",
|
|
17
|
+
grabMany: false,
|
|
18
|
+
children: [
|
|
19
|
+
{
|
|
20
|
+
type: "column",
|
|
21
|
+
name: "id",
|
|
22
|
+
fieldName: "id",
|
|
23
|
+
as: "a"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "table",
|
|
27
|
+
name: "SessionPlan",
|
|
28
|
+
as: "SessionPlan",
|
|
29
|
+
fieldName: "sessionPlan",
|
|
30
|
+
grabMany: false,
|
|
31
|
+
children: [
|
|
32
|
+
{
|
|
33
|
+
type: "column",
|
|
34
|
+
name: "id",
|
|
35
|
+
fieldName: "id",
|
|
36
|
+
as: "a"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "column",
|
|
40
|
+
name: "uuid",
|
|
41
|
+
fieldName: "uuid",
|
|
42
|
+
as: "c"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: "column",
|
|
46
|
+
name: "id",
|
|
47
|
+
fieldName: "id",
|
|
48
|
+
as: "a"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
(0, globals_1.test)("should work for object", () => {
|
|
55
|
+
const data = {
|
|
56
|
+
id: 1,
|
|
57
|
+
sessionPlanId: null,
|
|
58
|
+
sessionPlan: undefined
|
|
59
|
+
};
|
|
60
|
+
(0, addNullFallbacks_1.addNullFallbacks)(sqlAST, data);
|
|
61
|
+
strict_1.default.deepEqual(data, {
|
|
62
|
+
id: 1,
|
|
63
|
+
sessionPlanId: null,
|
|
64
|
+
sessionPlan: null
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
(0, globals_1.test)("should work for array", () => {
|
|
68
|
+
const data = [
|
|
69
|
+
{
|
|
70
|
+
id: 1,
|
|
71
|
+
sessionPlanId: null,
|
|
72
|
+
sessionPlan: undefined
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 2,
|
|
76
|
+
sessionPlanId: null,
|
|
77
|
+
sessionPlan: undefined
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
(0, addNullFallbacks_1.addNullFallbacks)(sqlAST, data);
|
|
81
|
+
strict_1.default.deepEqual(data, [
|
|
82
|
+
{
|
|
83
|
+
id: 1,
|
|
84
|
+
sessionPlanId: null,
|
|
85
|
+
sessionPlan: null
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 2,
|
|
89
|
+
sessionPlanId: null,
|
|
90
|
+
sessionPlan: null
|
|
91
|
+
}
|
|
92
|
+
]);
|
|
93
|
+
});
|
|
94
|
+
(0, globals_1.test)("should work for nested array", () => {
|
|
95
|
+
const sqlAST = {
|
|
96
|
+
type: "table",
|
|
97
|
+
name: "Session",
|
|
98
|
+
as: "Session",
|
|
99
|
+
fieldName: "session",
|
|
100
|
+
grabMany: false,
|
|
101
|
+
children: [
|
|
102
|
+
{
|
|
103
|
+
type: "column",
|
|
104
|
+
name: "id",
|
|
105
|
+
fieldName: "id",
|
|
106
|
+
as: "a"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: "table",
|
|
110
|
+
name: "SessionPlan",
|
|
111
|
+
as: "SessionPlan",
|
|
112
|
+
fieldName: "sessionPlan",
|
|
113
|
+
grabMany: false,
|
|
114
|
+
children: [
|
|
115
|
+
{
|
|
116
|
+
type: "column",
|
|
117
|
+
name: "id",
|
|
118
|
+
fieldName: "id",
|
|
119
|
+
as: "a"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "column",
|
|
123
|
+
name: "uuid",
|
|
124
|
+
fieldName: "uuid",
|
|
125
|
+
as: "c"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: "column",
|
|
129
|
+
name: "id",
|
|
130
|
+
fieldName: "id",
|
|
131
|
+
as: "a"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: "table",
|
|
135
|
+
name: "SessionPlan",
|
|
136
|
+
as: "SessionPlan",
|
|
137
|
+
fieldName: "sessionPlan",
|
|
138
|
+
grabMany: false,
|
|
139
|
+
children: [
|
|
140
|
+
{
|
|
141
|
+
type: "column",
|
|
142
|
+
name: "id",
|
|
143
|
+
fieldName: "id",
|
|
144
|
+
as: "a"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
type: "column",
|
|
148
|
+
name: "uuid",
|
|
149
|
+
fieldName: "uuid",
|
|
150
|
+
as: "c"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
type: "column",
|
|
154
|
+
name: "id",
|
|
155
|
+
fieldName: "id",
|
|
156
|
+
as: "a"
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
};
|
|
164
|
+
const data = [
|
|
165
|
+
{
|
|
166
|
+
id: 1,
|
|
167
|
+
sessionPlanId: 1,
|
|
168
|
+
sessionPlan: {
|
|
169
|
+
id: 1,
|
|
170
|
+
uuid: "stub",
|
|
171
|
+
sessionPlan: undefined
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
id: 2,
|
|
176
|
+
sessionPlanId: 2,
|
|
177
|
+
sessionPlan: {
|
|
178
|
+
id: 2,
|
|
179
|
+
uuid: "stub",
|
|
180
|
+
sessionPlan: undefined
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
(0, addNullFallbacks_1.addNullFallbacks)(sqlAST, data);
|
|
185
|
+
strict_1.default.deepEqual(data, [
|
|
186
|
+
{
|
|
187
|
+
id: 1,
|
|
188
|
+
sessionPlanId: 1,
|
|
189
|
+
sessionPlan: {
|
|
190
|
+
id: 1,
|
|
191
|
+
uuid: "stub",
|
|
192
|
+
sessionPlan: null
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
id: 2,
|
|
197
|
+
sessionPlanId: 2,
|
|
198
|
+
sessionPlan: {
|
|
199
|
+
id: 2,
|
|
200
|
+
uuid: "stub",
|
|
201
|
+
sessionPlan: null
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
]);
|
|
205
|
+
});
|
|
206
|
+
});
|