@iamkirbki/database-handler-core 4.4.3 → 4.4.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.
Files changed (28) hide show
  1. package/dist/abstract/Controller.js +18 -39
  2. package/dist/abstract/Model.d.ts.map +1 -1
  3. package/dist/abstract/Model.js +100 -98
  4. package/dist/abstract/SchemaTableBuilder.js +4 -1
  5. package/dist/abstract/model/ModelRelation.d.ts +4 -4
  6. package/dist/abstract/model/ModelRelation.d.ts.map +1 -1
  7. package/dist/abstract/model/ModelRelation.js +47 -49
  8. package/dist/base/Query.js +56 -79
  9. package/dist/base/Record.js +75 -90
  10. package/dist/base/Table.d.ts.map +1 -1
  11. package/dist/base/Table.js +130 -153
  12. package/dist/helpers/QueryBuilders/BaseQueryBuilders/BaseSelectQueryBuilder.js +7 -18
  13. package/dist/helpers/QueryBuilders/ExpressionBuilders/JsonAggregateExpression.js +5 -1
  14. package/dist/helpers/QueryBuilders/QueryDecorators/ExpressionDecorator.js +7 -18
  15. package/dist/helpers/QueryBuilders/QueryDecorators/GroupByDecorator.js +8 -19
  16. package/dist/helpers/QueryBuilders/QueryDecorators/JoinDecorator.js +26 -39
  17. package/dist/helpers/QueryBuilders/QueryDecorators/LimitDecorator.js +9 -20
  18. package/dist/helpers/QueryBuilders/QueryDecorators/OrderByDecorator.js +8 -19
  19. package/dist/helpers/QueryBuilders/QueryDecorators/WhereDecorator.js +9 -20
  20. package/dist/helpers/QueryBuilders/QueryStatementBuilder.js +87 -101
  21. package/dist/runtime/Repository.d.ts +1 -1
  22. package/dist/runtime/Repository.d.ts.map +1 -1
  23. package/dist/runtime/Repository.js +98 -102
  24. package/dist/types/model.d.ts +3 -0
  25. package/dist/types/model.d.ts.map +1 -1
  26. package/dist/types/table.d.ts +1 -0
  27. package/dist/types/table.d.ts.map +1 -1
  28. package/package.json +1 -1
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import QueryStatementBuilder from "../helpers/QueryBuilders/QueryStatementBuilder.js";
11
2
  import { Record, Query } from "../index.js";
12
3
  /** Table class for interacting with a database table */
@@ -27,176 +18,162 @@ export default class Table {
27
18
  return this._query;
28
19
  }
29
20
  /** Get raw column information */
30
- TableColumnInformation(tableName) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- return this._query.TableColumnInformation(tableName || this._name);
33
- });
21
+ async TableColumnInformation(tableName) {
22
+ return this._query.TableColumnInformation(tableName || this._name);
34
23
  }
35
24
  /** Get readable, formatted column information */
36
- ReadableTableColumnInformation() {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- const columns = yield this.TableColumnInformation(this._name);
39
- return columns.map((col) => ({
40
- name: col.name,
41
- type: col.type,
42
- nullable: col.notnull === 0,
43
- isPrimaryKey: col.pk === 1,
44
- defaultValue: col.dflt_value,
45
- }));
46
- });
25
+ async ReadableTableColumnInformation() {
26
+ const columns = await this.TableColumnInformation(this._name);
27
+ return columns.map((col) => ({
28
+ name: col.name,
29
+ type: col.type,
30
+ nullable: col.notnull === 0,
31
+ isPrimaryKey: col.pk === 1,
32
+ defaultValue: col.dflt_value,
33
+ }));
47
34
  }
48
- Drop() {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const queryStr = `DROP TABLE IF EXISTS "${this._name}";`;
51
- const query = this._queryFactory({
52
- tableName: this._name,
53
- query: queryStr,
54
- adapterName: this._customAdapter,
55
- recordFactory: this._recordFactory
56
- });
57
- yield query.Run();
35
+ async Drop() {
36
+ const queryStr = `DROP TABLE IF EXISTS "${this._name}";`;
37
+ const query = this._queryFactory({
38
+ tableName: this._name,
39
+ query: queryStr,
40
+ adapterName: this._customAdapter,
41
+ recordFactory: this._recordFactory
58
42
  });
43
+ await query.Run();
59
44
  }
60
45
  /** Fetch records with optional filtering, ordering, and pagination */
61
- Records(queryLayers) {
62
- return __awaiter(this, void 0, void 0, function* () {
63
- var _a, _b;
64
- const builder = new QueryStatementBuilder(queryLayers);
65
- const queryStr = yield builder.build();
66
- let params = {};
67
- if (((_a = queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.base) === null || _a === void 0 ? void 0 : _a.where) && Object.keys(queryLayers.base.where).length > 0)
68
- params = queryLayers.base.where;
69
- if (((_b = queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.pretty) === null || _b === void 0 ? void 0 : _b.where) && Object.keys(queryLayers.pretty.where).length > 0)
70
- params = Object.assign(Object.assign({}, params), queryLayers.pretty.where);
71
- const query = this._queryFactory({
72
- tableName: this._name,
73
- query: queryStr,
74
- parameters: params,
75
- recordFactory: this._recordFactory
76
- });
77
- const results = yield query.All();
78
- return results;
46
+ async Records(queryLayers) {
47
+ var _a, _b;
48
+ const builder = new QueryStatementBuilder(queryLayers);
49
+ const queryStr = await builder.build();
50
+ let params = {};
51
+ if (((_a = queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.base) === null || _a === void 0 ? void 0 : _a.where) && Object.keys(queryLayers.base.where).length > 0)
52
+ params = queryLayers.base.where;
53
+ if (((_b = queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.pretty) === null || _b === void 0 ? void 0 : _b.where) && Object.keys(queryLayers.pretty.where).length > 0)
54
+ params = { ...params, ...queryLayers.pretty.where };
55
+ const query = this._queryFactory({
56
+ tableName: this._name,
57
+ query: queryStr,
58
+ parameters: params,
59
+ recordFactory: this._recordFactory
79
60
  });
61
+ const results = await query.All();
62
+ return results;
80
63
  }
81
64
  /** Fetch a single record from the table */
82
- Record(queryLayers) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- const results = yield this.Records(Object.assign(Object.assign({}, queryLayers), { final: Object.assign(Object.assign({}, queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.final), { limit: 1 }) }));
85
- return results[0];
65
+ async Record(queryLayers) {
66
+ const results = await this.Records({
67
+ ...queryLayers,
68
+ final: {
69
+ ...queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.final,
70
+ limit: 1,
71
+ },
86
72
  });
73
+ return results[0];
87
74
  }
88
75
  /** Get the total count of records */
89
- RecordsCount() {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const query = this._queryFactory({
92
- tableName: this._name,
93
- query: `SELECT COUNT(*) as count FROM "${this._name}"`,
94
- recordFactory: this._recordFactory
95
- });
96
- const count = yield query.Count();
97
- return count || 0;
76
+ async RecordsCount() {
77
+ const query = this._queryFactory({
78
+ tableName: this._name,
79
+ query: `SELECT COUNT(*) as count FROM "${this._name}"`,
80
+ recordFactory: this._recordFactory
98
81
  });
82
+ const count = await query.Count();
83
+ return count || 0;
99
84
  }
100
- exists() {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- const query = this._queryFactory({
103
- tableName: this._name,
104
- adapterName: this._customAdapter,
105
- recordFactory: this._recordFactory
106
- });
107
- return yield query.DoesTableExist();
85
+ async exists() {
86
+ const query = this._queryFactory({
87
+ tableName: this._name,
88
+ adapterName: this._customAdapter,
89
+ recordFactory: this._recordFactory
108
90
  });
91
+ return await query.DoesTableExist();
109
92
  }
110
93
  /** Insert a record into the table */
111
- Insert(values) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const record = this._recordFactory(this._name, values, this._customAdapter);
114
- yield record.Insert();
115
- return record;
116
- });
94
+ async Insert(values) {
95
+ const record = this._recordFactory(this._name, values, this._customAdapter);
96
+ await record.Insert();
97
+ return record;
117
98
  }
118
99
  /** Perform JOIN operations with other tables */
119
- Join(queryLayers) {
120
- return __awaiter(this, void 0, void 0, function* () {
121
- var _a, _b;
122
- if (queryLayers.base.joins === undefined || (Array.isArray(queryLayers.base.joins) && queryLayers.base.joins.length === 0)) {
123
- throw new Error("No joins defined for the Join operation.");
124
- }
125
- const joinedTables = queryLayers.base.joins.map(j => j.fromTable);
126
- const tableColumnCache = new Map();
127
- const columnInfo = yield this._query.TableColumnInformation(this._name);
128
- tableColumnCache.set(this._name, columnInfo);
129
- for (const tableName of joinedTables) {
130
- const columnInfo = yield this._query.TableColumnInformation(tableName);
131
- tableColumnCache.set(tableName, columnInfo);
132
- }
133
- const builder = new QueryStatementBuilder(queryLayers, tableColumnCache);
134
- const queryString = yield builder.build();
135
- let params = {};
136
- if ((_a = queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.base) === null || _a === void 0 ? void 0 : _a.where)
137
- params = this.QueryHelperObject.ConvertParamsToObject(queryLayers.base.where);
138
- if ((_b = queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.pretty) === null || _b === void 0 ? void 0 : _b.where)
139
- params = Object.assign(Object.assign({}, params), this.QueryHelperObject.ConvertParamsToObject(queryLayers.pretty.where));
140
- const query = this._queryFactory({
141
- tableName: this._name,
142
- query: queryString,
143
- parameters: params,
144
- recordFactory: this._recordFactory
145
- });
146
- const records = yield query.All();
147
- const splitTables = yield this.splitJoinValues(records, joinedTables);
148
- return splitTables;
100
+ async Join(queryLayers) {
101
+ var _a, _b;
102
+ if (queryLayers.base.joins === undefined || (Array.isArray(queryLayers.base.joins) && queryLayers.base.joins.length === 0)) {
103
+ throw new Error("No joins defined for the Join operation.");
104
+ }
105
+ const joinedTables = queryLayers.base.joins.map(j => j.fromTable);
106
+ const tableColumnCache = new Map();
107
+ const columnInfo = await this._query.TableColumnInformation(this._name);
108
+ tableColumnCache.set(this._name, columnInfo);
109
+ for (const tableName of joinedTables) {
110
+ const columnInfo = await this._query.TableColumnInformation(tableName);
111
+ tableColumnCache.set(tableName, columnInfo);
112
+ }
113
+ const builder = new QueryStatementBuilder(queryLayers, tableColumnCache);
114
+ const queryString = await builder.build();
115
+ let params = {};
116
+ if ((_a = queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.base) === null || _a === void 0 ? void 0 : _a.where)
117
+ params = this.QueryHelperObject.ConvertParamsToObject(queryLayers.base.where);
118
+ if ((_b = queryLayers === null || queryLayers === void 0 ? void 0 : queryLayers.pretty) === null || _b === void 0 ? void 0 : _b.where)
119
+ params = { ...params, ...this.QueryHelperObject.ConvertParamsToObject(queryLayers.pretty.where) };
120
+ const query = this._queryFactory({
121
+ tableName: this._name,
122
+ query: queryString,
123
+ parameters: params,
124
+ recordFactory: this._recordFactory
149
125
  });
126
+ const records = await query.All();
127
+ const splitTables = await this.splitJoinValues(records, joinedTables, queryLayers.base.joins);
128
+ return splitTables;
150
129
  }
151
- splitJoinValues(records, joinedTables) {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- return records.map(record => {
154
- var _a;
155
- if (!record.values)
156
- return record;
157
- const mainTableData = {};
158
- const joinedTableData = {};
159
- for (const [aliasedKey, value] of Object.entries(record.values)) {
160
- if (aliasedKey.includes('__')) {
161
- const [tableName, columnName] = aliasedKey.split('__');
162
- if (tableName === this._name) {
163
- mainTableData[columnName] = value;
164
- }
165
- else if (joinedTables.includes(tableName)) {
166
- (_a = joinedTableData[tableName]) !== null && _a !== void 0 ? _a : (joinedTableData[tableName] = {});
167
- joinedTableData[tableName][columnName] = value;
168
- }
130
+ async splitJoinValues(records, joinedTables, joins) {
131
+ return records.map(record => {
132
+ var _a;
133
+ if (!record.values)
134
+ return record;
135
+ const mainTableData = {};
136
+ const joinedTableData = {};
137
+ for (const [aliasedKey, value] of Object.entries(record.values)) {
138
+ if (aliasedKey.includes('__')) {
139
+ const [tableName, columnName] = aliasedKey.split('__');
140
+ if (tableName === this._name) {
141
+ mainTableData[columnName] = value;
169
142
  }
170
- else {
171
- mainTableData[aliasedKey] = value;
143
+ else if (joinedTables.includes(tableName)) {
144
+ const currentJoin = joins.find(j => j.fromTable === tableName);
145
+ const aliasedTableName = (currentJoin === null || currentJoin === void 0 ? void 0 : currentJoin.name) || tableName;
146
+ (_a = joinedTableData[aliasedTableName]) !== null && _a !== void 0 ? _a : (joinedTableData[aliasedTableName] = {});
147
+ joinedTableData[aliasedTableName][columnName] = value;
172
148
  }
173
149
  }
174
- const filteredJoinedData = Object.fromEntries(
175
- // eslint-disable-next-line no-unused-vars
176
- Object.entries(joinedTableData).filter(([_, data]) => Object.keys(data).length > 0));
177
- const combinedData = Object.assign(Object.assign({}, mainTableData), filteredJoinedData);
178
- return this._recordFactory(this._name, combinedData, this._customAdapter);
179
- });
180
- });
181
- }
182
- toSql(queryLayers) {
183
- return __awaiter(this, void 0, void 0, function* () {
184
- if (queryLayers.base.joins && queryLayers.base.joins.length > 0) {
185
- const joinedTables = queryLayers.base.joins.map(j => j.fromTable);
186
- const tableColumnCache = new Map();
187
- const columnInfo = yield this._query.TableColumnInformation(this._name);
188
- tableColumnCache.set(this._name, columnInfo);
189
- for (const tableName of joinedTables) {
190
- const columnInfo = yield this._query.TableColumnInformation(tableName);
191
- tableColumnCache.set(tableName, columnInfo);
150
+ else {
151
+ mainTableData[aliasedKey] = value;
192
152
  }
193
- const builder = new QueryStatementBuilder(queryLayers, tableColumnCache);
194
- return yield builder.build();
195
- }
196
- else {
197
- const builder = new QueryStatementBuilder(queryLayers);
198
- return yield builder.build();
199
153
  }
154
+ const filteredJoinedData = Object.fromEntries(
155
+ // eslint-disable-next-line no-unused-vars
156
+ Object.entries(joinedTableData).filter(([_, data]) => Object.keys(data).length > 0));
157
+ const combinedData = { ...mainTableData, ...filteredJoinedData };
158
+ return this._recordFactory(this._name, combinedData, this._customAdapter);
200
159
  });
201
160
  }
161
+ async toSql(queryLayers) {
162
+ if (queryLayers.base.joins && queryLayers.base.joins.length > 0) {
163
+ const joinedTables = queryLayers.base.joins.map(j => j.fromTable);
164
+ const tableColumnCache = new Map();
165
+ const columnInfo = await this._query.TableColumnInformation(this._name);
166
+ tableColumnCache.set(this._name, columnInfo);
167
+ for (const tableName of joinedTables) {
168
+ const columnInfo = await this._query.TableColumnInformation(tableName);
169
+ tableColumnCache.set(tableName, columnInfo);
170
+ }
171
+ const builder = new QueryStatementBuilder(queryLayers, tableColumnCache);
172
+ return await builder.build();
173
+ }
174
+ else {
175
+ const builder = new QueryStatementBuilder(queryLayers);
176
+ return await builder.build();
177
+ }
178
+ }
202
179
  }
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  export default class BaseSelectQueryBuilder {
11
2
  constructor(tableName, select, joinsSelect, expressionsSelect) {
12
3
  this.tableName = tableName;
@@ -14,14 +5,12 @@ export default class BaseSelectQueryBuilder {
14
5
  this.joinsSelect = joinsSelect;
15
6
  this.expressionsSelect = expressionsSelect;
16
7
  }
17
- build() {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- return {
20
- select: this.select,
21
- joinsSelect: this.joinsSelect,
22
- from: this.tableName,
23
- expressionSelect: this.expressionsSelect,
24
- };
25
- });
8
+ async build() {
9
+ return {
10
+ select: this.select,
11
+ joinsSelect: this.joinsSelect,
12
+ from: this.tableName,
13
+ expressionSelect: this.expressionsSelect,
14
+ };
26
15
  }
27
16
  }
@@ -38,7 +38,11 @@ export default class JsonAggregateExpression {
38
38
  const valueClauseKeywords = [`${comp.parameters.alias}_lat`, `${comp.parameters.alias}_lon`];
39
39
  const expr = {
40
40
  type: comp.type,
41
- parameters: Object.assign(Object.assign({}, comp.parameters), { valueClauseKeywords: comp.type === 'spatialDistance' ? valueClauseKeywords : comp.parameters.valueClauseKeywords, isComputed: true }),
41
+ parameters: {
42
+ ...comp.parameters,
43
+ valueClauseKeywords: comp.type === 'spatialDistance' ? valueClauseKeywords : comp.parameters.valueClauseKeywords,
44
+ isComputed: true
45
+ },
42
46
  requirements: QueryExpressionBuilder.getExpressionDefaultRequirements(comp.type)
43
47
  };
44
48
  const builder = QueryExpressionBuilder.buildExpressionsPart([expr])[0];
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import QueryDecorator from "./QueryDecorator.js";
11
2
  import QueryStatementBuilder from "../QueryStatementBuilder.js";
12
3
  export default class ExpressionDecorator extends QueryDecorator {
@@ -20,15 +11,13 @@ export default class ExpressionDecorator extends QueryDecorator {
20
11
  this.setHavingClauses();
21
12
  this.setValueClauseKeywords();
22
13
  }
23
- build() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- var _a, _b;
26
- const context = yield this.component.build();
27
- (_a = context.expressionSelect) !== null && _a !== void 0 ? _a : (context.expressionSelect = []);
28
- context.expressionSelect.push(...this.parsedExpressions.map(e => e.baseExpressionClause));
29
- (_b = context.conditions) !== null && _b !== void 0 ? _b : (context.conditions = {});
30
- return context;
31
- });
14
+ async build() {
15
+ var _a, _b;
16
+ const context = await this.component.build();
17
+ (_a = context.expressionSelect) !== null && _a !== void 0 ? _a : (context.expressionSelect = []);
18
+ context.expressionSelect.push(...this.parsedExpressions.map(e => e.baseExpressionClause));
19
+ (_b = context.conditions) !== null && _b !== void 0 ? _b : (context.conditions = {});
20
+ return context;
32
21
  }
33
22
  setWhereClauses() {
34
23
  this.whereClauses = this.parsedExpressions
@@ -1,27 +1,16 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import QueryDecorator from "./QueryDecorator.js";
11
2
  export default class GroupByDecorator extends QueryDecorator {
12
3
  constructor(component, groupByColumns) {
13
4
  super(component);
14
5
  this.groupByColumns = groupByColumns;
15
6
  }
16
- build() {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- var _a;
19
- const context = yield this.component.build();
20
- if (this.groupByColumns) {
21
- (_a = context.groupBy) !== null && _a !== void 0 ? _a : (context.groupBy = []);
22
- context.groupBy.push(...this.groupByColumns);
23
- }
24
- return context;
25
- });
7
+ async build() {
8
+ var _a;
9
+ const context = await this.component.build();
10
+ if (this.groupByColumns) {
11
+ (_a = context.groupBy) !== null && _a !== void 0 ? _a : (context.groupBy = []);
12
+ context.groupBy.push(...this.groupByColumns);
13
+ }
14
+ return context;
26
15
  }
27
16
  }
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import QueryDecorator from "./QueryDecorator.js";
11
2
  export default class JoinDecorator extends QueryDecorator {
12
3
  constructor(builder, layer, tableColumnInformation) {
@@ -26,37 +17,33 @@ export default class JoinDecorator extends QueryDecorator {
26
17
  blacklistTables: (_e = layer.final) === null || _e === void 0 ? void 0 : _e.blacklistTables,
27
18
  };
28
19
  }
29
- build() {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- var _a;
32
- const context = yield this.component.build();
33
- const selectExtensions = yield this.buildJoinSelect();
34
- const joinPart = this.buildJoinPart();
35
- context.joinsSelect = selectExtensions;
36
- (_a = context.joins) !== null && _a !== void 0 ? _a : (context.joins = []);
37
- context.joins.push(...joinPart);
38
- return context;
39
- });
20
+ async build() {
21
+ var _a;
22
+ const context = await this.component.build();
23
+ const selectExtensions = await this.buildJoinSelect();
24
+ const joinPart = this.buildJoinPart();
25
+ context.joinsSelect = selectExtensions;
26
+ (_a = context.joins) !== null && _a !== void 0 ? _a : (context.joins = []);
27
+ context.joins.push(...joinPart);
28
+ return context;
40
29
  }
41
- buildJoinSelect() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- var _a;
44
- const blacklist = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.blacklistTables) || [];
45
- const joinArray = Array.isArray(this.joins) ? this.joins : [this.joins];
46
- const mainCols = this.tableColumnsCache.get(this.fromTableName) || [];
47
- const mainSelect = mainCols
48
- .filter(() => !blacklist.includes(this.fromTableName))
49
- .map(col => `"${this.fromTableName}"."${col.name}" AS "${this.fromTableName}__${col.name}"`);
50
- const joinedSelects = yield Promise.all(joinArray.map((join) => __awaiter(this, void 0, void 0, function* () {
51
- if (blacklist.includes(join.fromTable))
52
- return "";
53
- const cols = this.tableColumnsCache.get(join.fromTable) || [];
54
- return cols
55
- .map(col => `"${join.fromTable}"."${col.name}" AS "${join.fromTable}__${col.name}"`)
56
- .filter(col => col.trim() !== "");
57
- })));
58
- return [...mainSelect, ...joinedSelects.flat()].filter(s => s !== "").filter(Boolean);
59
- });
30
+ async buildJoinSelect() {
31
+ var _a;
32
+ const blacklist = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.blacklistTables) || [];
33
+ const joinArray = Array.isArray(this.joins) ? this.joins : [this.joins];
34
+ const mainCols = this.tableColumnsCache.get(this.fromTableName) || [];
35
+ const mainSelect = mainCols
36
+ .filter(() => !blacklist.includes(this.fromTableName))
37
+ .map(col => `"${this.fromTableName}"."${col.name}" AS "${this.fromTableName}__${col.name}"`);
38
+ const joinedSelects = await Promise.all(joinArray.map(async (join) => {
39
+ if (blacklist.includes(join.fromTable))
40
+ return "";
41
+ const cols = this.tableColumnsCache.get(join.fromTable) || [];
42
+ return cols
43
+ .map(col => `"${join.fromTable}"."${col.name}" AS "${join.fromTable}__${col.name}"`)
44
+ .filter(col => col.trim() !== "");
45
+ }));
46
+ return [...mainSelect, ...joinedSelects.flat()].filter(s => s !== "").filter(Boolean);
60
47
  }
61
48
  buildJoinPart() {
62
49
  const joinArray = Array.isArray(this.joins) ? this.joins : [this.joins];
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import QueryDecorator from "./QueryDecorator.js";
11
2
  export default class LimitDecorator extends QueryDecorator {
12
3
  constructor(component, limitCount, offsetCount) {
@@ -14,16 +5,14 @@ export default class LimitDecorator extends QueryDecorator {
14
5
  this.limitCount = limitCount;
15
6
  this.offsetCount = offsetCount;
16
7
  }
17
- build() {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const context = yield this.component.build();
20
- if (this.limitCount) {
21
- context.limit = this.limitCount;
22
- }
23
- if (this.offsetCount) {
24
- context.offset = this.offsetCount;
25
- }
26
- return context;
27
- });
8
+ async build() {
9
+ const context = await this.component.build();
10
+ if (this.limitCount) {
11
+ context.limit = this.limitCount;
12
+ }
13
+ if (this.offsetCount) {
14
+ context.offset = this.offsetCount;
15
+ }
16
+ return context;
28
17
  }
29
18
  }
@@ -1,27 +1,16 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import QueryDecorator from "./QueryDecorator.js";
11
2
  export default class OrderByDecorator extends QueryDecorator {
12
3
  constructor(component, orderByColumns) {
13
4
  super(component);
14
5
  this.orderByColumns = orderByColumns;
15
6
  }
16
- build() {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- var _a;
19
- const context = yield this.component.build();
20
- if (this.orderByColumns) {
21
- (_a = context.orderBy) !== null && _a !== void 0 ? _a : (context.orderBy = []);
22
- context.orderBy.push(...this.orderByColumns);
23
- }
24
- return context;
25
- });
7
+ async build() {
8
+ var _a;
9
+ const context = await this.component.build();
10
+ if (this.orderByColumns) {
11
+ (_a = context.orderBy) !== null && _a !== void 0 ? _a : (context.orderBy = []);
12
+ context.orderBy.push(...this.orderByColumns);
13
+ }
14
+ return context;
26
15
  }
27
16
  }