@technicity/data-service-generator 0.9.0 → 0.10.0-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.
Files changed (45) hide show
  1. package/dist/index.d.ts +1 -2
  2. package/dist/index.js +3 -4
  3. package/dist/runtime/Cache.d.ts +18 -0
  4. package/dist/runtime/Cache.js +90 -0
  5. package/dist/runtime/Runtime.d.ts +23 -0
  6. package/dist/runtime/Runtime.js +29 -0
  7. package/dist/runtime/RuntimeKSQL.d.ts +1 -1
  8. package/dist/runtime/RuntimeKSQL.js +13 -11
  9. package/dist/runtime/RuntimeMSSQL.d.ts +18 -14
  10. package/dist/runtime/RuntimeMSSQL.js +48 -43
  11. package/dist/runtime/RuntimeMySQL.d.ts +11 -12
  12. package/dist/runtime/RuntimeMySQL.js +46 -79
  13. package/dist/runtime/lib/create.d.ts +12 -0
  14. package/dist/runtime/lib/create.js +175 -0
  15. package/dist/runtime/lib/delete.d.ts +5 -0
  16. package/dist/runtime/lib/delete.js +43 -0
  17. package/dist/runtime/lib/error.d.ts +9 -0
  18. package/dist/runtime/lib/error.js +22 -0
  19. package/dist/runtime/lib/getData.d.ts +4 -0
  20. package/dist/runtime/lib/getData.js +227 -0
  21. package/dist/runtime/lib/getSqlAst.js +2 -2
  22. package/dist/runtime/lib/getWhere.d.ts +17 -0
  23. package/dist/runtime/lib/getWhere.js +228 -4
  24. package/dist/runtime/lib/prepareWhere.d.ts +2 -0
  25. package/dist/runtime/lib/prepareWhere.js +158 -0
  26. package/dist/runtime/lib/resolve.d.ts +10 -0
  27. package/dist/runtime/lib/resolve.js +66 -0
  28. package/dist/runtime/lib/shared.d.ts +22 -12
  29. package/dist/runtime/lib/shared.js +16 -746
  30. package/dist/runtime/lib/typeCastMSSQL.js +1 -1
  31. package/dist/runtime/lib/update.d.ts +4 -0
  32. package/dist/runtime/lib/update.js +143 -0
  33. package/dist/runtime/lib/utility.d.ts +5 -0
  34. package/dist/runtime/lib/utility.js +15 -0
  35. package/package.json +7 -6
  36. package/dist/runtime/lib/MSSQL.d.ts +0 -13
  37. package/dist/runtime/lib/MSSQL.js +0 -73
  38. package/dist/runtime/lib/SDKBadWhereError.d.ts +0 -4
  39. package/dist/runtime/lib/SDKBadWhereError.js +0 -10
  40. package/dist/runtime/lib/SDKNotFoundError.d.ts +0 -4
  41. package/dist/runtime/lib/SDKNotFoundError.js +0 -10
  42. package/dist/runtime/lib/getDateTimeStringMySQL.d.ts +0 -1
  43. package/dist/runtime/lib/getDateTimeStringMySQL.js +0 -8
  44. package/dist/runtime/lib/stringifyWhere.d.ts +0 -18
  45. package/dist/runtime/lib/stringifyWhere.js +0 -228
@@ -1,15 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWhere = void 0;
4
- const stringifyWhere_1 = require("./stringifyWhere");
3
+ exports.getEscape = exports.getEscapeId = exports.stringifyWhere = exports.getWhere = void 0;
4
+ const _ = require("lodash/fp");
5
+ const MySqlString = require("sqlstring");
6
+ // @ts-ignore
7
+ const TSqlString = require("tsqlstring");
5
8
  function getWhere(
6
9
  // Note: `table` is not escaped in getWhere, so it should be escaped beforehand.
7
10
  table, args, dialect, orderBy, rowWithMatchingCursor) {
8
11
  if (args?.$where == null && args?.$paginate == null) {
9
12
  return null;
10
13
  }
11
- let where = args?.$where ?? {};
12
- return ((0, stringifyWhere_1.stringifyWhere)({
14
+ const where = args?.$where ?? {};
15
+ return (stringifyWhere({
13
16
  where,
14
17
  table,
15
18
  dialect,
@@ -19,3 +22,224 @@ table, args, dialect, orderBy, rowWithMatchingCursor) {
19
22
  }) || null);
20
23
  }
21
24
  exports.getWhere = getWhere;
25
+ function stringifyWhere(input) {
26
+ const { where, table, dialect, args, orderBy, rowWithMatchingCursor } = input;
27
+ const escapeId = getEscapeId(dialect);
28
+ const escape = getEscape(dialect);
29
+ let result = _stringifyWhere(where, table, escapeId, escape, "");
30
+ const paginationWhere = stringifyPaginationWhere({
31
+ table,
32
+ args,
33
+ orderBy,
34
+ escapeId,
35
+ escape,
36
+ rowWithMatchingCursor,
37
+ });
38
+ if (paginationWhere) {
39
+ result =
40
+ result.length === 0
41
+ ? paginationWhere
42
+ : result + " AND " + paginationWhere;
43
+ }
44
+ return result;
45
+ }
46
+ exports.stringifyWhere = stringifyWhere;
47
+ function _stringifyWhere(where, table, escapeId, escape, result) {
48
+ if (Object.prototype.hasOwnProperty.call(where, "$and")) {
49
+ if (Object.keys(where).length !== 1) {
50
+ throw new Error("Must have 1 key: " + JSON.stringify(where, null, 2));
51
+ }
52
+ const _xs = where.$and.filter((x) => x != null);
53
+ if (_xs.length === 0) {
54
+ return result;
55
+ }
56
+ const xs = _xs
57
+ .map((x) => _stringifyWhere(x, table, escapeId, escape, result))
58
+ .filter(Boolean);
59
+ if (xs.length === 0) {
60
+ return result;
61
+ }
62
+ return `(${xs.join(" AND ")})`;
63
+ }
64
+ if (Object.prototype.hasOwnProperty.call(where, "$or")) {
65
+ if (Object.keys(where).length !== 1) {
66
+ throw new Error("Must have 1 key: " + JSON.stringify(where, null, 2));
67
+ }
68
+ const _xs = where.$or.filter((x) => x != null);
69
+ if (_xs.length === 0) {
70
+ return result;
71
+ }
72
+ const xs = _xs
73
+ .map((x) => _stringifyWhere(x, table, escapeId, escape, result))
74
+ .filter(Boolean);
75
+ if (xs.length === 0) {
76
+ return result;
77
+ }
78
+ return `(${xs.join(" OR ")})`;
79
+ }
80
+ function printValue(v) {
81
+ if (v === true) {
82
+ v = 1;
83
+ }
84
+ if (v === false) {
85
+ v = 0;
86
+ }
87
+ return escape(v);
88
+ }
89
+ return Object.keys(where)
90
+ .map((k) => {
91
+ const v = where[k];
92
+ if (v === void 0) {
93
+ return null;
94
+ }
95
+ // Can't do this, since we need this function to be sync
96
+ // if (relationMap[k] !== null) {
97
+ // const relationData = await getRelationData(k, v, relationMap);
98
+ // k = relationData.k;
99
+ // v = relationData.v;
100
+ // }
101
+ if (v === null) {
102
+ return `${table}.${escapeId(k)} IS NULL`;
103
+ }
104
+ if (typeof v === "string" ||
105
+ typeof v === "number" ||
106
+ typeof v === "boolean") {
107
+ return `${table}.${escapeId(k)} = ${printValue(v)}`;
108
+ }
109
+ if (_.isPlainObject(v)) {
110
+ const keys = Object.keys(v);
111
+ if (keys.length !== 1) {
112
+ throw new Error("Must have 1 key: " + JSON.stringify(v, null, 2));
113
+ }
114
+ const operator = keys[0];
115
+ const operand = v[operator];
116
+ if (operator === "$ne") {
117
+ return `${table}.${escapeId(k)} ${getOperatorNeq(v)} ${printValue(operand)}`;
118
+ }
119
+ if (operator === "$gt") {
120
+ return `${table}.${escapeId(k)} > ${printValue(operand)}`;
121
+ }
122
+ if (operator === "$gte") {
123
+ return `${table}.${escapeId(k)} >= ${printValue(operand)}`;
124
+ }
125
+ if (operator === "$lt") {
126
+ return `${table}.${escapeId(k)} < ${printValue(operand)}`;
127
+ }
128
+ if (operator === "$lte") {
129
+ return `${table}.${escapeId(k)} <= ${printValue(operand)}`;
130
+ }
131
+ if (operator === "$like") {
132
+ return `${table}.${escapeId(k)} LIKE ${printValue(operand)}`;
133
+ }
134
+ if (operator === "$nlike") {
135
+ return `${table}.${escapeId(k)} NOT LIKE ${printValue(operand)}`;
136
+ }
137
+ if (operator === "$in") {
138
+ if (operand.length === 0) {
139
+ // Would do "FALSE" instead, as it's more readable, but it
140
+ // causes a RequestError in MSSQL.
141
+ return "(1=0)";
142
+ }
143
+ return `${table}.${escapeId(k)} IN (${operand
144
+ .map((x) => printValue(x))
145
+ .join(",")})`;
146
+ }
147
+ if (operator === "$nin") {
148
+ if (operand.length === 0) {
149
+ // Would do "TRUE" instead, as it's more readable, but it
150
+ // causes a RequestError in MSSQL.
151
+ return "(1=1)";
152
+ }
153
+ return `${table}.${escapeId(k)} NOT IN (${operand
154
+ .map((x) => printValue(x))
155
+ .join(",")})`;
156
+ }
157
+ if (operator === "$btwn") {
158
+ if (operand.length !== 2) {
159
+ throw new Error("Expected length of 2, got: " + operand.length);
160
+ }
161
+ return `${table}.${escapeId(k)} BETWEEN ${printValue(operand[0])} AND ${printValue(operand[1])}`;
162
+ }
163
+ if (operator === "$nbtwn") {
164
+ if (operand.length !== 2) {
165
+ throw new Error("Expected length of 2, got: " + operand.length);
166
+ }
167
+ return `${table}.${escapeId(k)} NOT BETWEEN ${printValue(operand[0])} AND ${printValue(operand[1])}`;
168
+ }
169
+ throw new Error("Invalid operator: " + operator);
170
+ }
171
+ throw new Error("Invalid value: " + v);
172
+ })
173
+ .filter((x) => x != null)
174
+ .join(" AND ");
175
+ }
176
+ const valuesThatUseIsOrIsNot = new Set([null]);
177
+ function getOperatorNeq(value) {
178
+ return valuesThatUseIsOrIsNot.has(value) ? "IS NOT" : "!=";
179
+ }
180
+ // async function getRelationData(k: string, v: any, relationMap: IRelationMap) {
181
+ // // TODO
182
+ // return { k, v };
183
+ // }
184
+ function stringifyPaginationWhere(input) {
185
+ const { table, args, orderBy, escapeId, escape, rowWithMatchingCursor } = input;
186
+ if (args?.$paginate?.after == null && args?.$paginate?.before == null) {
187
+ return "";
188
+ }
189
+ if (rowWithMatchingCursor == null) {
190
+ return "";
191
+ }
192
+ // orderBy should never be null because of getOrderBy, but add a check.
193
+ if (orderBy == null) {
194
+ throw new Error("orderBy cannot be null when paginating");
195
+ }
196
+ function getCompOp(dir) {
197
+ return dir === "asc" ? ">" : "<";
198
+ }
199
+ function printValue(v) {
200
+ if (v === true) {
201
+ v = 1;
202
+ }
203
+ if (v === false) {
204
+ v = 0;
205
+ }
206
+ return escape(v);
207
+ }
208
+ // https://gist.github.com/pcattori/2bb645d587e45c9fdbcabf5cef7a7106
209
+ const cond = orderBy
210
+ .map(({ column, direction }, i) => {
211
+ const a = orderBy.slice(0, i).map(({ column: col2 }) => {
212
+ const field = `${table}.${escapeId(col2)}`;
213
+ const op = "=";
214
+ const v = printValue(rowWithMatchingCursor[col2]);
215
+ return `${field} ${op} ${v}`;
216
+ });
217
+ const field = `${table}.${escapeId(column)}`;
218
+ const op = getCompOp(direction);
219
+ const v = printValue(rowWithMatchingCursor[column]);
220
+ a.push(`${field} ${op} ${v}`);
221
+ return "(" + a.join(" AND ") + ")";
222
+ })
223
+ .join(" OR ");
224
+ return "(" + cond + ")";
225
+ }
226
+ function getEscapeId(dialect) {
227
+ if (dialect === "mysql") {
228
+ return MySqlString.escapeId.bind(MySqlString);
229
+ }
230
+ if (dialect === "mssql") {
231
+ return TSqlString.escapeId.bind(TSqlString);
232
+ }
233
+ throw new Error("Unsupported dialect: " + dialect);
234
+ }
235
+ exports.getEscapeId = getEscapeId;
236
+ function getEscape(dialect) {
237
+ if (dialect === "mysql") {
238
+ return MySqlString.escape.bind(MySqlString);
239
+ }
240
+ if (dialect === "mssql") {
241
+ return TSqlString.escape.bind(TSqlString);
242
+ }
243
+ throw new Error("Unsupported dialect: " + dialect);
244
+ }
245
+ exports.getEscape = getEscape;
@@ -0,0 +1,2 @@
1
+ import { IArtifacts, TDbCall, TFormatQuery } from '../IRuntime';
2
+ export declare function prepareWhere(artifacts: IArtifacts, table: string, data: any, dbCall: TDbCall, formatQuery: TFormatQuery): Promise<{}>;
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareWhere = void 0;
4
+ const _ = require("lodash/fp");
5
+ const error_1 = require("./error");
6
+ const OPERATIONS = [
7
+ "$eq",
8
+ "$neq",
9
+ "$gt",
10
+ "$gte",
11
+ "$lt",
12
+ "$lte",
13
+ "$in",
14
+ "$nin",
15
+ "$like",
16
+ "$nlike",
17
+ "$btwn",
18
+ "$nbtwn",
19
+ ];
20
+ async function prepareWhere(artifacts, table, data, dbCall, formatQuery) {
21
+ const { mappedFields } = artifacts[table];
22
+ let out = {};
23
+ await traverseWhere(data, async (where, ptr, parentPtr, root) => {
24
+ const path = ptr.split("/").slice(1);
25
+ const opIndex = path.length - 1;
26
+ if (OPERATIONS.includes(path[opIndex])) {
27
+ const newPath = path.slice();
28
+ const index = newPath.length - 2;
29
+ const key = newPath[index];
30
+ const mappedField = mappedFields?.[key];
31
+ if (mappedField != null) {
32
+ newPath[index] = mappedField.foreignKey;
33
+ if (Array.isArray(where)) {
34
+ const newVal = await Promise.all(where.map((v) => dbCall(formatQuery("SELECT ?? FROM ?? WHERE ?? = ?", [
35
+ mappedField.referencedKey,
36
+ mappedField.referencedTable,
37
+ mappedField.name,
38
+ v,
39
+ ])).then((xs) => xs[0]?.[mappedField.referencedKey])));
40
+ if (newVal.some((x) => x == null)) {
41
+ const index = newVal.findIndex((x) => x == null);
42
+ if (index === -1) {
43
+ throw new error_1.SDKBadWhereError();
44
+ }
45
+ else {
46
+ const v = where[index];
47
+ throw new error_1.SDKBadWhereError(getPrepareWhereNotFoundMessage(mappedField, v));
48
+ }
49
+ }
50
+ out = _.set(newPath, newVal, out);
51
+ }
52
+ else {
53
+ const newVal = await dbCall(formatQuery("SELECT ?? FROM ?? WHERE ?? = ?", [
54
+ mappedField.referencedKey,
55
+ mappedField.referencedTable,
56
+ mappedField.name,
57
+ where,
58
+ ])).then((xs) => xs[0]?.[mappedField.referencedKey]);
59
+ if (newVal == null) {
60
+ throw new error_1.SDKBadWhereError(getPrepareWhereNotFoundMessage(mappedField, where));
61
+ }
62
+ out = _.set(newPath, newVal, out);
63
+ }
64
+ out = _.unset(path.slice(0, path.length - 1), out);
65
+ return;
66
+ }
67
+ }
68
+ else {
69
+ const key = path[path.length - 1];
70
+ const mappedField = mappedFields?.[key];
71
+ if (mappedField != null) {
72
+ const newPath = path
73
+ .slice(0, path.length - 1)
74
+ .concat(mappedField.foreignKey);
75
+ if (Array.isArray(where)) {
76
+ const newVal = await Promise.all(where.map((v) => dbCall(formatQuery("SELECT ?? FROM ?? WHERE ?? = ?", [
77
+ mappedField.referencedKey,
78
+ mappedField.referencedTable,
79
+ mappedField.name,
80
+ v,
81
+ ])).then((xs) => xs[0]?.[mappedField.referencedKey])));
82
+ if (newVal.some((x) => x == null)) {
83
+ const index = newVal.findIndex((x) => x == null);
84
+ if (index === -1) {
85
+ throw new error_1.SDKBadWhereError();
86
+ }
87
+ else {
88
+ const v = where[index];
89
+ throw new error_1.SDKBadWhereError(getPrepareWhereNotFoundMessage(mappedField, v));
90
+ }
91
+ }
92
+ out = _.set(newPath, newVal, out);
93
+ }
94
+ else {
95
+ const newVal = await dbCall(formatQuery("SELECT ?? FROM ?? WHERE ?? = ?", [
96
+ mappedField.referencedKey,
97
+ mappedField.referencedTable,
98
+ mappedField.name,
99
+ where,
100
+ ])).then((xs) => xs[0]?.[mappedField.referencedKey]);
101
+ if (newVal == null) {
102
+ throw new error_1.SDKBadWhereError(getPrepareWhereNotFoundMessage(mappedField, where));
103
+ }
104
+ out = _.set(newPath, newVal, out);
105
+ }
106
+ out = _.unset(path, out);
107
+ }
108
+ else {
109
+ out = path.length > 0 ? _.set(path, where, out) : where;
110
+ }
111
+ }
112
+ });
113
+ return out;
114
+ }
115
+ exports.prepareWhere = prepareWhere;
116
+ function getPrepareWhereNotFoundMessage(mappedField, value) {
117
+ return `Not found: unable to map \`${mappedField.referencedTable}\`.\`${mappedField.name}\` to \`${mappedField.referencedTable}\`.\`${mappedField.referencedKey}\` for the value \`${value}\`.`;
118
+ }
119
+ async function traverseWhere(where, cb) {
120
+ return await _traverseWhere(cb, where, "", where);
121
+ }
122
+ async function _traverseWhere(cb, where, ptr, root, parentPtr) {
123
+ await cb(where, ptr, parentPtr, root);
124
+ if (where && typeof where == "object" && !Array.isArray(where)) {
125
+ for (let key in where) {
126
+ const sch = where[key];
127
+ if (key === "$and" || key == "$or") {
128
+ await Promise.all(sch.map(async (s, i) => {
129
+ await _traverseWhere(cb, s, ptr + "/" + key + "/" + i, root, ptr
130
+ // key,
131
+ // where,
132
+ // parentPtr,
133
+ // i
134
+ );
135
+ }));
136
+ }
137
+ else if (typeof sch === "object") {
138
+ for (let prop in sch) {
139
+ await _traverseWhere(cb, sch[prop], ptr + "/" + key + "/" + escapePtr(prop), root, ptr
140
+ // key,
141
+ // where,
142
+ // prop
143
+ );
144
+ }
145
+ }
146
+ else {
147
+ await _traverseWhere(cb, sch, ptr + "/" + key, root, ptr
148
+ // key,
149
+ // where
150
+ );
151
+ }
152
+ }
153
+ }
154
+ }
155
+ ;
156
+ function escapePtr(str) {
157
+ return str.replace(/~/g, "~0").replace(/\//g, "~1");
158
+ }
@@ -0,0 +1,10 @@
1
+ import Cache from '../Cache';
2
+ import { IDialect, TBeginTransaction, TContext, TDbCall, TFormatQuery, TMiddleware, TResolveParams } from '../IRuntime';
3
+ export declare function resolve(input: TResolveParams, dbCall: TDbCall, formatQuery: TFormatQuery, beginTransaction: TBeginTransaction, dialect: IDialect, middlewareHandler: MiddlewareHandler<TMiddleware>, context: TContext, cache?: Cache): Promise<any>;
4
+ export declare class MiddlewareHandler<M extends Function> {
5
+ private _middlewares;
6
+ register(middleware: M): void;
7
+ get(id: number): M | undefined;
8
+ has(id: number): boolean;
9
+ length(): number;
10
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MiddlewareHandler = exports.resolve = void 0;
4
+ const async_hooks_1 = require("async_hooks");
5
+ const create_1 = require("./create");
6
+ const delete_1 = require("./delete");
7
+ const getData_1 = require("./getData");
8
+ const update_1 = require("./update");
9
+ async function resolve(input, dbCall, formatQuery, beginTransaction, dialect, middlewareHandler, context, cache) {
10
+ // https://github.com/prisma/prisma/blob/822198e5ba21535364d20c86901b8c3778ebf6a3/packages/client/src/runtime/getPrismaClient.ts#L1087
11
+ let index = -1;
12
+ const resolve = (extra) => {
13
+ const inputs = { ...input, ...extra };
14
+ switch (inputs.action) {
15
+ case "findUnique":
16
+ case "findMany":
17
+ case "findManyPaginated":
18
+ return cache ?
19
+ (0, getData_1.getCacheableData)(inputs, dbCall, formatQuery, dialect, cache) :
20
+ (0, getData_1.getData)(inputs, dbCall, formatQuery, dialect);
21
+ case "create":
22
+ return (0, create_1.create)(inputs, dbCall, formatQuery, beginTransaction, dialect, context);
23
+ case "update":
24
+ return (0, update_1.update)(inputs, dbCall, formatQuery, dialect, cache);
25
+ case "updateMany":
26
+ return (0, update_1.updateMany)(inputs, dbCall, formatQuery, dialect, cache);
27
+ case "delete":
28
+ return (0, delete_1.deleteOne)(inputs, dbCall, formatQuery, dialect, cache);
29
+ case "deleteMany":
30
+ return (0, delete_1.deleteMany)(inputs, dbCall, formatQuery, dialect, cache);
31
+ default:
32
+ throw new Error("Invalid action: " + inputs.action);
33
+ }
34
+ };
35
+ if (middlewareHandler.length() > 0) {
36
+ const resource = new async_hooks_1.AsyncResource("sdk-request");
37
+ const params = input;
38
+ const consumer = (paramsMaybeMutated) => {
39
+ const nextMiddleware = middlewareHandler.get(++index);
40
+ if (nextMiddleware != null)
41
+ return nextMiddleware(paramsMaybeMutated, consumer);
42
+ return resolve(params);
43
+ };
44
+ return resource.runInAsyncScope(() => consumer(params));
45
+ }
46
+ return resolve();
47
+ }
48
+ exports.resolve = resolve;
49
+ class MiddlewareHandler {
50
+ constructor() {
51
+ this._middlewares = [];
52
+ }
53
+ register(middleware) {
54
+ this._middlewares.push(middleware);
55
+ }
56
+ get(id) {
57
+ return this._middlewares[id];
58
+ }
59
+ has(id) {
60
+ return !!this._middlewares[id];
61
+ }
62
+ length() {
63
+ return this._middlewares.length;
64
+ }
65
+ }
66
+ exports.MiddlewareHandler = MiddlewareHandler;
@@ -1,13 +1,23 @@
1
- import type { IGetSQLASTInput, IArtifacts, IDialect, TDbCall, TFormatQuery, TBeginTransaction, TContext } from "../IRuntime";
2
- import type { TMiddleware, TResolveParams } from "../IRuntime";
3
- export declare function resolve(input: TResolveParams, dbCall: TDbCall, formatQuery: TFormatQuery, beginTransaction: TBeginTransaction, dialect: IDialect, middlewareHandler: MiddlewareHandler<TMiddleware>, context: TContext): Promise<any>;
4
- export declare class MiddlewareHandler<M extends Function> {
5
- private _middlewares;
6
- register(middleware: M): void;
7
- get(id: number): M | undefined;
8
- has(id: number): boolean;
9
- length(): number;
10
- }
1
+ import { IArtifacts, IGetSQLASTInput, TDbCall, TFormatQuery } from '../IRuntime';
2
+ export declare function wrapListPaginationLimitOffset(data: any[], totalCount: number): {
3
+ paginationInfo: {
4
+ totalCount: number;
5
+ };
6
+ results: any[];
7
+ };
8
+ export declare function getDateTimeStringMySQL(dateTimeString: string): string;
9
+ export declare function wrapListPaginationCursor(data: any[], args: any, flip: boolean, cb: (data: any[]) => void, primaryKey: string, totalCount: number): {
10
+ paginationInfo: {
11
+ hasPreviousPage: boolean;
12
+ hasNextPage: boolean;
13
+ startCursor: string | null;
14
+ endCursor: string | null;
15
+ totalCount: number;
16
+ };
17
+ results: any[];
18
+ };
19
+ export declare function getTotalCount(sqlASTTotalCount: any, dbCall: TDbCall, context: any, options: any): Promise<any>;
20
+ export declare function getScalarFields(table: string, artifacts: IArtifacts): string[];
21
+ export declare function hasMappedFields(artifacts: IArtifacts, table: string, data: any): boolean;
22
+ export declare function mapMappedFields(artifactsForTable: IArtifacts[string], data: any, dbCall: TDbCall, formatQuery: TFormatQuery): Promise<void>;
11
23
  export declare function postProcess(data: any, fields: IGetSQLASTInput["fields"], shouldRemoveExtraKeys: boolean): void;
12
- export declare function whereNeedsProcessing(where: any): boolean;
13
- export declare function _prepareWhere(artifacts: IArtifacts, table: string, data: any, dbCall: TDbCall, formatQuery: TFormatQuery): Promise<{}>;