@oino-ts/db 0.10.4 → 0.12.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.
- package/dist/cjs/OINODb.js +0 -1
- package/dist/cjs/OINODbApi.js +2 -2
- package/dist/cjs/OINODbDataModel.js +0 -4
- package/dist/esm/OINODb.js +1 -2
- package/dist/esm/OINODbApi.js +2 -2
- package/dist/esm/OINODbDataModel.js +1 -5
- package/dist/types/index.d.ts +0 -1
- package/package.json +6 -5
- package/src/OINODb.ts +0 -1
- package/src/OINODbApi.test.ts +1 -1
- package/src/OINODbApi.ts +2 -2
- package/src/OINODbDataModel.ts +0 -4
- package/src/index.ts +0 -1
package/dist/cjs/OINODb.js
CHANGED
package/dist/cjs/OINODbApi.js
CHANGED
|
@@ -125,6 +125,7 @@ class OINODbHtmlTemplate extends index_js_1.OINOHtmlTemplate {
|
|
|
125
125
|
value = f.serializeCellWithLocale(row[i], this._locale);
|
|
126
126
|
}
|
|
127
127
|
else if ((f instanceof index_js_1.OINONumberDataField) && (this._numberDecimals >= 0) && (typeof row[i] === "number")) {
|
|
128
|
+
// console.debug("renderFromDbData number decimals", { field: f.name, value: row[i], type: typeof row[i] });
|
|
128
129
|
value = row[i].toFixed(this._numberDecimals);
|
|
129
130
|
}
|
|
130
131
|
else {
|
|
@@ -146,7 +147,7 @@ class OINODbHtmlTemplate extends index_js_1.OINOHtmlTemplate {
|
|
|
146
147
|
await dataset.next();
|
|
147
148
|
}
|
|
148
149
|
this.modified = last_modified;
|
|
149
|
-
const result = this._createHttpResult(html
|
|
150
|
+
const result = this._createHttpResult(html);
|
|
150
151
|
index_js_1.OINOBenchmark.endMetric("OINOHtmlTemplate", "renderFromDbData");
|
|
151
152
|
return result;
|
|
152
153
|
}
|
|
@@ -276,7 +277,6 @@ class OINODbApi {
|
|
|
276
277
|
else if (result.success) {
|
|
277
278
|
common_1.OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPost", "Print SQL", { sql: sql });
|
|
278
279
|
const sql_res = await this.db.sqlExec(sql);
|
|
279
|
-
// OINOLog.debug("OINODbApi.doPost sql_res", {sql_res:sql_res})
|
|
280
280
|
if (sql_res.hasErrors()) {
|
|
281
281
|
result.setError(500, sql_res.getFirstError(), "DoPost");
|
|
282
282
|
if (this._debugOnError) {
|
|
@@ -245,7 +245,6 @@ class OINODbDataModel {
|
|
|
245
245
|
where_sql = filter_sql;
|
|
246
246
|
}
|
|
247
247
|
const result = this.api.db.printSqlSelect(this.api.params.tableName, column_names, where_sql, order_sql, limit_sql, groupby_sql);
|
|
248
|
-
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlSelect", "Result", { sql: result });
|
|
249
248
|
return result;
|
|
250
249
|
}
|
|
251
250
|
/**
|
|
@@ -256,7 +255,6 @@ class OINODbDataModel {
|
|
|
256
255
|
*/
|
|
257
256
|
printSqlInsert(row) {
|
|
258
257
|
let result = "INSERT INTO " + this.api.db.printSqlTablename(this.api.params.tableName) + " " + this._printSqlInsertColumnsAndValues(row) + ";";
|
|
259
|
-
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlInsert", "Result", { sql: result });
|
|
260
258
|
return result;
|
|
261
259
|
}
|
|
262
260
|
/**
|
|
@@ -268,7 +266,6 @@ class OINODbDataModel {
|
|
|
268
266
|
*/
|
|
269
267
|
printSqlUpdate(id, row) {
|
|
270
268
|
let result = "UPDATE " + this.api.db.printSqlTablename(this.api.params.tableName) + " SET " + this._printSqlUpdateValues(row) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
271
|
-
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlUpdate", "Result", { sql: result });
|
|
272
269
|
return result;
|
|
273
270
|
}
|
|
274
271
|
/**
|
|
@@ -279,7 +276,6 @@ class OINODbDataModel {
|
|
|
279
276
|
*/
|
|
280
277
|
printSqlDelete(id) {
|
|
281
278
|
let result = "DELETE FROM " + this.api.db.printSqlTablename(this.api.params.tableName) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
282
|
-
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlDelete", "Result", { sql: result });
|
|
283
279
|
return result;
|
|
284
280
|
}
|
|
285
281
|
}
|
package/dist/esm/OINODb.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
4
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
import { OINO_ERROR_PREFIX, OINODB_EMPTY_ROW
|
|
6
|
+
import { OINO_ERROR_PREFIX, OINODB_EMPTY_ROW } from "./index.js";
|
|
7
7
|
/**
|
|
8
8
|
* Base class for database abstraction, implementing methods for connecting, making queries and parsing/formatting data
|
|
9
9
|
* between SQL and serialization formats.
|
|
@@ -49,7 +49,6 @@ export class OINODb {
|
|
|
49
49
|
result += " LIMIT " + limitCondition;
|
|
50
50
|
}
|
|
51
51
|
result += ";";
|
|
52
|
-
OINOLog.debug("@oino-ts/db", "OINODb", "printSqlSelect", "Result", { sql: result });
|
|
53
52
|
return result;
|
|
54
53
|
}
|
|
55
54
|
}
|
package/dist/esm/OINODbApi.js
CHANGED
|
@@ -121,6 +121,7 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
121
121
|
value = f.serializeCellWithLocale(row[i], this._locale);
|
|
122
122
|
}
|
|
123
123
|
else if ((f instanceof OINONumberDataField) && (this._numberDecimals >= 0) && (typeof row[i] === "number")) {
|
|
124
|
+
// console.debug("renderFromDbData number decimals", { field: f.name, value: row[i], type: typeof row[i] });
|
|
124
125
|
value = row[i].toFixed(this._numberDecimals);
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
@@ -142,7 +143,7 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
142
143
|
await dataset.next();
|
|
143
144
|
}
|
|
144
145
|
this.modified = last_modified;
|
|
145
|
-
const result = this._createHttpResult(html
|
|
146
|
+
const result = this._createHttpResult(html);
|
|
146
147
|
OINOBenchmark.endMetric("OINOHtmlTemplate", "renderFromDbData");
|
|
147
148
|
return result;
|
|
148
149
|
}
|
|
@@ -271,7 +272,6 @@ export class OINODbApi {
|
|
|
271
272
|
else if (result.success) {
|
|
272
273
|
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPost", "Print SQL", { sql: sql });
|
|
273
274
|
const sql_res = await this.db.sqlExec(sql);
|
|
274
|
-
// OINOLog.debug("OINODbApi.doPost sql_res", {sql_res:sql_res})
|
|
275
275
|
if (sql_res.hasErrors()) {
|
|
276
276
|
result.setError(500, sql_res.getFirstError(), "DoPost");
|
|
277
277
|
if (this._debugOnError) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
4
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
import { OINO_ERROR_PREFIX, OINODbConfig, OINONumberDataField,
|
|
6
|
+
import { OINO_ERROR_PREFIX, OINODbConfig, OINONumberDataField, OINODB_UNDEFINED } from "./index.js";
|
|
7
7
|
/**
|
|
8
8
|
* OINO Datamodel object for representing one database table and it's columns.
|
|
9
9
|
*
|
|
@@ -242,7 +242,6 @@ export class OINODbDataModel {
|
|
|
242
242
|
where_sql = filter_sql;
|
|
243
243
|
}
|
|
244
244
|
const result = this.api.db.printSqlSelect(this.api.params.tableName, column_names, where_sql, order_sql, limit_sql, groupby_sql);
|
|
245
|
-
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlSelect", "Result", { sql: result });
|
|
246
245
|
return result;
|
|
247
246
|
}
|
|
248
247
|
/**
|
|
@@ -253,7 +252,6 @@ export class OINODbDataModel {
|
|
|
253
252
|
*/
|
|
254
253
|
printSqlInsert(row) {
|
|
255
254
|
let result = "INSERT INTO " + this.api.db.printSqlTablename(this.api.params.tableName) + " " + this._printSqlInsertColumnsAndValues(row) + ";";
|
|
256
|
-
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlInsert", "Result", { sql: result });
|
|
257
255
|
return result;
|
|
258
256
|
}
|
|
259
257
|
/**
|
|
@@ -265,7 +263,6 @@ export class OINODbDataModel {
|
|
|
265
263
|
*/
|
|
266
264
|
printSqlUpdate(id, row) {
|
|
267
265
|
let result = "UPDATE " + this.api.db.printSqlTablename(this.api.params.tableName) + " SET " + this._printSqlUpdateValues(row) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
268
|
-
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlUpdate", "Result", { sql: result });
|
|
269
266
|
return result;
|
|
270
267
|
}
|
|
271
268
|
/**
|
|
@@ -276,7 +273,6 @@ export class OINODbDataModel {
|
|
|
276
273
|
*/
|
|
277
274
|
printSqlDelete(id) {
|
|
278
275
|
let result = "DELETE FROM " + this.api.db.printSqlTablename(this.api.params.tableName) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
279
|
-
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlDelete", "Result", { sql: result });
|
|
280
276
|
return result;
|
|
281
277
|
}
|
|
282
278
|
}
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "OINO TS library package for publishing an SQL database tables as a REST API.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
"module": "./dist/esm/index.js",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@oino-ts/common": "0.
|
|
22
|
+
"@oino-ts/common": "0.12.0",
|
|
23
|
+
"oino-ts": "file:.."
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@types
|
|
26
|
+
"@oino-ts/types": "0.12.0",
|
|
26
27
|
"@types/bun": "^1.1.14",
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
28
|
+
"@types/node": "^20.14.10",
|
|
29
|
+
"typescript": "~5.9.0"
|
|
29
30
|
},
|
|
30
31
|
"files": [
|
|
31
32
|
"src/*.ts",
|
package/src/OINODb.ts
CHANGED
package/src/OINODbApi.test.ts
CHANGED
|
@@ -151,7 +151,7 @@ function encodeResult(o:any|undefined):string {
|
|
|
151
151
|
function createApiTemplate(api:OINODbApi):OINODbHtmlTemplate {
|
|
152
152
|
let template_str = ""
|
|
153
153
|
for (let i=0; i<api.datamodel.fields.length; i++) {
|
|
154
|
-
template_str += "<input type='text' name='" + api.datamodel.fields[i].name + "' value='
|
|
154
|
+
template_str += "<input type='text' name='" + api.datamodel.fields[i].name + "' value='{{{" + api.datamodel.fields[i].name + "}}}'></input>"
|
|
155
155
|
}
|
|
156
156
|
return new OINODbHtmlTemplate(template_str, -1, "fi", "medium")
|
|
157
157
|
}
|
package/src/OINODbApi.ts
CHANGED
|
@@ -128,6 +128,7 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
128
128
|
value = f.serializeCellWithLocale(row[i], this._locale)
|
|
129
129
|
|
|
130
130
|
} else if ((f instanceof OINONumberDataField) && (this._numberDecimals >= 0) && (typeof row[i] === "number")) {
|
|
131
|
+
// console.debug("renderFromDbData number decimals", { field: f.name, value: row[i], type: typeof row[i] });
|
|
131
132
|
value = (row[i]! as number).toFixed(this._numberDecimals)
|
|
132
133
|
|
|
133
134
|
} else {
|
|
@@ -149,7 +150,7 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
149
150
|
await dataset.next()
|
|
150
151
|
}
|
|
151
152
|
this.modified = last_modified
|
|
152
|
-
const result:OINOHttpResult = this._createHttpResult(html
|
|
153
|
+
const result:OINOHttpResult = this._createHttpResult(html)
|
|
153
154
|
OINOBenchmark.endMetric("OINOHtmlTemplate", "renderFromDbData")
|
|
154
155
|
return result
|
|
155
156
|
}
|
|
@@ -286,7 +287,6 @@ export class OINODbApi {
|
|
|
286
287
|
} else if (result.success) {
|
|
287
288
|
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPost", "Print SQL", {sql:sql})
|
|
288
289
|
const sql_res:OINODbDataSet = await this.db.sqlExec(sql)
|
|
289
|
-
// OINOLog.debug("OINODbApi.doPost sql_res", {sql_res:sql_res})
|
|
290
290
|
if (sql_res.hasErrors()) {
|
|
291
291
|
result.setError(500, sql_res.getFirstError(), "DoPost")
|
|
292
292
|
if (this._debugOnError) {
|
package/src/OINODbDataModel.ts
CHANGED
|
@@ -252,7 +252,6 @@ export class OINODbDataModel {
|
|
|
252
252
|
where_sql = filter_sql
|
|
253
253
|
}
|
|
254
254
|
const result = this.api.db.printSqlSelect(this.api.params.tableName, column_names, where_sql, order_sql, limit_sql, groupby_sql)
|
|
255
|
-
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlSelect", "Result", {sql:result})
|
|
256
255
|
return result;
|
|
257
256
|
}
|
|
258
257
|
|
|
@@ -264,7 +263,6 @@ export class OINODbDataModel {
|
|
|
264
263
|
*/
|
|
265
264
|
printSqlInsert(row: OINODataRow): string {
|
|
266
265
|
let result: string = "INSERT INTO " + this.api.db.printSqlTablename(this.api.params.tableName) + " " + this._printSqlInsertColumnsAndValues(row) + ";";
|
|
267
|
-
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlInsert", "Result", {sql:result})
|
|
268
266
|
return result;
|
|
269
267
|
}
|
|
270
268
|
|
|
@@ -277,7 +275,6 @@ export class OINODbDataModel {
|
|
|
277
275
|
*/
|
|
278
276
|
printSqlUpdate(id: string, row: OINODataRow): string {
|
|
279
277
|
let result: string = "UPDATE " + this.api.db.printSqlTablename(this.api.params.tableName) + " SET " + this._printSqlUpdateValues(row) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
280
|
-
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlUpdate", "Result", {sql:result})
|
|
281
278
|
return result;
|
|
282
279
|
}
|
|
283
280
|
|
|
@@ -289,7 +286,6 @@ export class OINODbDataModel {
|
|
|
289
286
|
*/
|
|
290
287
|
printSqlDelete(id: string): string {
|
|
291
288
|
let result: string = "DELETE FROM " + this.api.db.printSqlTablename(this.api.params.tableName) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
292
|
-
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlDelete", "Result", {sql:result})
|
|
293
289
|
return result;
|
|
294
290
|
}
|
|
295
291
|
}
|