@technicity/data-service-generator 0.11.5 → 0.11.7-next.0

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.
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.typeCastMSSQL = void 0;
4
- const mssql = require("mssql");
5
- // TODO: see https://github.com/tediousjs/node-mssql/pull/1171
6
- function typeCastMSSQL(customTypeCast) {
7
- return function (result, meta) {
8
- let typeCasts = {};
9
- for (let k in meta) {
10
- const v = meta[k];
11
- if (typeof customTypeCast === "function") {
12
- const tc = customTypeCast(v, mssql);
13
- if (tc) {
14
- typeCasts[v.name] = tc;
15
- }
16
- }
17
- // ids
18
- if (v.identity === true || v.type === mssql.BigInt) {
19
- typeCasts[v.name] = (x) => (typeof x === "string" ? parseInt(x) : x);
20
- }
21
- // uuids
22
- if (v.type === mssql.UniqueIdentifier) {
23
- typeCasts[v.name] = (x) => typeof x === "string" ? x.toLocaleLowerCase() : x;
24
- }
25
- }
26
- const data = result.recordset;
27
- if (Object.keys(typeCasts).length === 0) {
28
- return data;
29
- }
30
- return data.map((x) => {
31
- for (let k of Object.keys(x)) {
32
- if (typeCasts[k]) {
33
- x[k] = typeCasts[k](x[k]);
34
- }
35
- }
36
- return x;
37
- });
38
- };
39
- }
40
- exports.typeCastMSSQL = typeCastMSSQL;