ismx-nexo-node-app 0.3.37 → 0.3.39
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/dist/js/business/BusinessErrors.js +3 -0
- package/dist/js/repository/RepositoryDatabasePostgres.js +10 -10
- package/dist/types/business/BusinessErrors.d.ts +1 -0
- package/dist/types/repository/RepositoryDatabasePostgres.d.ts +2 -2
- package/package.json +1 -1
- package/src/main/node/business/BusinessErrors.ts +4 -0
- package/src/main/node/repository/RepositoryDatabasePostgres.ts +6 -6
|
@@ -62,13 +62,13 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
62
62
|
return this.any(tableName, { id });
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
any(
|
|
66
|
-
return __awaiter(this,
|
|
65
|
+
any(tableName_1) {
|
|
66
|
+
return __awaiter(this, arguments, void 0, function* (tableName, filters = {}) {
|
|
67
67
|
return yield this.find(tableName, filters).then((rows) => rows[0]);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
find(
|
|
71
|
-
return __awaiter(this,
|
|
70
|
+
find(tableName_1) {
|
|
71
|
+
return __awaiter(this, arguments, void 0, function* (tableName, filters = {}) {
|
|
72
72
|
if (!this.tables[tableName])
|
|
73
73
|
throw new Error(`table ${tableName} does not exist`);
|
|
74
74
|
let schema = this.tables[tableName][0].schema;
|
|
@@ -120,7 +120,7 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
page(tableName_1, sortKey_1) {
|
|
123
|
-
return __awaiter(this, arguments, void 0, function* (tableName, sortKey, maxResults = 50, pageNumber = 0, filters) {
|
|
123
|
+
return __awaiter(this, arguments, void 0, function* (tableName, sortKey, maxResults = 50, pageNumber = 0, filters = {}) {
|
|
124
124
|
if (!this.tables[tableName])
|
|
125
125
|
throw new Error(`table ${tableName} does not exist`);
|
|
126
126
|
let table = this.tables[tableName];
|
|
@@ -134,8 +134,8 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
134
134
|
return Promise.all([total, elements]).then(([total, elements]) => ({ total, elements }));
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
|
-
count(
|
|
138
|
-
return __awaiter(this,
|
|
137
|
+
count(tableName_1) {
|
|
138
|
+
return __awaiter(this, arguments, void 0, function* (tableName, filters = {}) {
|
|
139
139
|
if (!this.tables[tableName])
|
|
140
140
|
throw new Error(`table ${tableName} does not exist`);
|
|
141
141
|
let schema = this.tables[tableName][0].schema;
|
|
@@ -144,8 +144,8 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
144
144
|
return this.query(query, values).then((result) => result[0].count);
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
select(
|
|
148
|
-
return __awaiter(this,
|
|
147
|
+
select(tableName_1, select_1) {
|
|
148
|
+
return __awaiter(this, arguments, void 0, function* (tableName, select, filters = {}) {
|
|
149
149
|
if (!this.tables[tableName])
|
|
150
150
|
throw new Error(`table ${tableName} does not exist`);
|
|
151
151
|
let schema = this.tables[tableName][0].schema;
|
|
@@ -159,7 +159,7 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
159
159
|
throw new Error(`not implemented yet`);
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
toWhere(tableName, filters, alias = "", index = 1) {
|
|
162
|
+
toWhere(tableName, filters = {}, alias = "", index = 1) {
|
|
163
163
|
let table = this.tables[tableName];
|
|
164
164
|
let columns = PostgresUtils_1.default.columns(table);
|
|
165
165
|
let elements = Object.entries(filters !== null && filters !== void 0 ? filters : []);
|
|
@@ -14,6 +14,7 @@ export default class BusinessErrors {
|
|
|
14
14
|
get(code: string, ...params: string[]): FormalError;
|
|
15
15
|
except(code: string, ...params: string[]): void;
|
|
16
16
|
notFound(endpoint: string): void;
|
|
17
|
+
unauthorized(): void;
|
|
17
18
|
getQuery(key: string, query: {
|
|
18
19
|
[key: string]: string;
|
|
19
20
|
} | undefined): string;
|
|
@@ -19,10 +19,10 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase {
|
|
|
19
19
|
native(query: string, values?: any[], options?: QueryOptions): Promise<QueryResult>;
|
|
20
20
|
query<E>(query: string, values?: any[], options?: QueryOptions): Promise<E[]>;
|
|
21
21
|
one<E>(tableName: string, id: string): Promise<E>;
|
|
22
|
-
any<E>(tableName: string, filters
|
|
22
|
+
any<E>(tableName: string, filters?: {
|
|
23
23
|
[key: string]: Primitive | Array<any>;
|
|
24
24
|
}): Promise<E>;
|
|
25
|
-
find<T>(tableName: string, filters
|
|
25
|
+
find<T>(tableName: string, filters?: {
|
|
26
26
|
[key: string]: Primitive | Array<any>;
|
|
27
27
|
}): Promise<T[]>;
|
|
28
28
|
add<E>(tableName: string, object: {
|
package/package.json
CHANGED
|
@@ -33,6 +33,10 @@ export default class BusinessErrors {
|
|
|
33
33
|
this.except("0004", endpoint)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
unauthorized() {
|
|
37
|
+
this.except("0001");
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
getQuery(key: string, query: {[key: string]: string}|undefined): string {
|
|
37
41
|
if (!query || !query[key]) this.except("0011", key)
|
|
38
42
|
return query![key];
|
|
@@ -63,12 +63,12 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
63
63
|
return this.any<E>(tableName, { id });
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
async any<E>(tableName: string, filters: { [key: string]: Primitive | Array<any> }): Promise<E>
|
|
66
|
+
async any<E>(tableName: string, filters: { [key: string]: Primitive | Array<any> }={}): Promise<E>
|
|
67
67
|
{
|
|
68
68
|
return await this.find<E>(tableName, filters).then((rows) => rows[0]);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
async find<T>(tableName: string, filters: { [key: string]: Primitive | Array<any> }): Promise<T[]>
|
|
71
|
+
async find<T>(tableName: string, filters: { [key: string]: Primitive | Array<any> }={}): Promise<T[]>
|
|
72
72
|
{
|
|
73
73
|
if (!this.tables[tableName]) throw new Error(`table ${tableName} does not exist`);
|
|
74
74
|
let schema = this.tables[tableName][0].schema;
|
|
@@ -119,7 +119,7 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
119
119
|
return this.query<T>(query, values).then((result) => result[0]);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
async page<T>(tableName: string, sortKey: string, maxResults: number = 50, pageNumber: number = 0, filters
|
|
122
|
+
async page<T>(tableName: string, sortKey: string, maxResults: number = 50, pageNumber: number = 0, filters: {[key:string]:Primitive|Array<Primitive>}={}): Promise<Pagination<T>>
|
|
123
123
|
{
|
|
124
124
|
if (!this.tables[tableName]) throw new Error(`table ${tableName} does not exist`);
|
|
125
125
|
let table = this.tables[tableName];
|
|
@@ -137,7 +137,7 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
async count(tableName: string, filters
|
|
140
|
+
async count(tableName: string, filters: { [key: string]: Primitive | Array<Primitive> }={}): Promise<number>
|
|
141
141
|
{
|
|
142
142
|
if (!this.tables[tableName]) throw new Error(`table ${tableName} does not exist`);
|
|
143
143
|
let schema = this.tables[tableName][0].schema;
|
|
@@ -146,7 +146,7 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
146
146
|
return this.query<{count:number}>(query, values).then((result) => result[0].count);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
async select(tableName: string, select: string, filters
|
|
149
|
+
async select(tableName: string, select: string, filters: { [key: string]: Primitive | Array<Primitive> }={}): Promise<string[]>
|
|
150
150
|
{
|
|
151
151
|
if (!this.tables[tableName]) throw new Error(`table ${tableName} does not exist`);
|
|
152
152
|
let schema = this.tables[tableName][0].schema;
|
|
@@ -160,7 +160,7 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
160
160
|
throw new Error(`not implemented yet`);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
toWhere(tableName: string, filters
|
|
163
|
+
toWhere(tableName: string, filters: { [key: string]: Primitive | Array<Primitive> }={}, alias:string = "", index=1)
|
|
164
164
|
{
|
|
165
165
|
let table = this.tables[tableName];
|
|
166
166
|
let columns = PostgresUtils.columns(table);
|