@oino-ts/db 0.0.13 → 0.0.14
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/OINODbApi.js +5 -11
- package/dist/cjs/OINODbDataField.js +1 -1
- package/dist/cjs/OINODbFactory.js +2 -3
- package/dist/esm/OINODbApi.js +5 -11
- package/dist/esm/OINODbDataField.js +1 -1
- package/dist/esm/OINODbFactory.js +1 -2
- package/dist/types/OINODbApi.d.ts +1 -1
- package/dist/types/OINODbFactory.d.ts +1 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/OINODbApi.test.ts +1 -1
- package/src/OINODbApi.ts +6 -12
- package/src/OINODbDataField.ts +1 -1
- package/src/OINODbFactory.ts +1 -2
- package/src/index.ts +1 -1
package/dist/cjs/OINODbApi.js
CHANGED
|
@@ -65,6 +65,7 @@ class OINODbHtmlTemplate extends index_js_1.OINOHtmlTemplate {
|
|
|
65
65
|
*
|
|
66
66
|
*/
|
|
67
67
|
renderFromDbData(modelset) {
|
|
68
|
+
index_js_1.OINOBenchmark.start("OINOHtmlTemplate", "renderFromDbData");
|
|
68
69
|
let html = "";
|
|
69
70
|
const dataset = modelset.dataset;
|
|
70
71
|
const datamodel = modelset.datamodel;
|
|
@@ -97,6 +98,7 @@ class OINODbHtmlTemplate extends index_js_1.OINOHtmlTemplate {
|
|
|
97
98
|
}
|
|
98
99
|
const result = new index_js_1.OINOHttpResult(html);
|
|
99
100
|
result.lastModified = last_modified;
|
|
101
|
+
index_js_1.OINOBenchmark.end("OINOHtmlTemplate", "renderFromDbData");
|
|
100
102
|
return result;
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -131,7 +133,7 @@ class OINODbApi {
|
|
|
131
133
|
this.params = params;
|
|
132
134
|
this.datamodel = new index_js_1.OINODbDataModel(this);
|
|
133
135
|
if (this.params.hashidKey) {
|
|
134
|
-
this.hashid = new hashid_1.OINOHashid(this.params.hashidKey, this.db.name, this.params.hashidLength, this.params.
|
|
136
|
+
this.hashid = new hashid_1.OINOHashid(this.params.hashidKey, this.db.name, this.params.hashidLength, this.params.hashidStaticIds);
|
|
135
137
|
}
|
|
136
138
|
else {
|
|
137
139
|
this.hashid = null;
|
|
@@ -171,7 +173,6 @@ class OINODbApi {
|
|
|
171
173
|
//logDebug("OINODbApi.validateHttpValues", {result:result})
|
|
172
174
|
}
|
|
173
175
|
async _doGet(result, id, params) {
|
|
174
|
-
index_js_1.OINOBenchmark.start("doGet");
|
|
175
176
|
const sql = this.datamodel.printSqlSelect(id, params.sqlParams || {});
|
|
176
177
|
// OINOLog.debug("OINODbApi.doGet sql", {sql:sql})
|
|
177
178
|
try {
|
|
@@ -189,10 +190,8 @@ class OINODbApi {
|
|
|
189
190
|
result.setError(500, "Unhandled exception in doGet: " + e.message, "DoGet");
|
|
190
191
|
result.addDebug("OINO GET SQL [" + sql + "]", "DoGet");
|
|
191
192
|
}
|
|
192
|
-
index_js_1.OINOBenchmark.end("doGet");
|
|
193
193
|
}
|
|
194
194
|
async _doPost(result, rows) {
|
|
195
|
-
index_js_1.OINOBenchmark.start("doPost");
|
|
196
195
|
let sql = "";
|
|
197
196
|
try {
|
|
198
197
|
let i = 0;
|
|
@@ -223,10 +222,8 @@ class OINODbApi {
|
|
|
223
222
|
result.setError(500, "Unhandled exception in doPost: " + e.message, "DoPost");
|
|
224
223
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPost");
|
|
225
224
|
}
|
|
226
|
-
index_js_1.OINOBenchmark.end("doPost");
|
|
227
225
|
}
|
|
228
226
|
async _doPut(result, id, row) {
|
|
229
|
-
index_js_1.OINOBenchmark.start("doPut");
|
|
230
227
|
let sql = "";
|
|
231
228
|
try {
|
|
232
229
|
this._validateRowValues(result, row, false);
|
|
@@ -246,10 +243,8 @@ class OINODbApi {
|
|
|
246
243
|
result.setError(500, "Unhandled exception: " + e.message, "DoPut");
|
|
247
244
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPut");
|
|
248
245
|
}
|
|
249
|
-
index_js_1.OINOBenchmark.end("doPut");
|
|
250
246
|
}
|
|
251
247
|
async _doDelete(result, id) {
|
|
252
|
-
index_js_1.OINOBenchmark.start("doDelete");
|
|
253
248
|
let sql = "";
|
|
254
249
|
try {
|
|
255
250
|
sql = this.datamodel.printSqlDelete(id);
|
|
@@ -266,7 +261,6 @@ class OINODbApi {
|
|
|
266
261
|
result.setError(500, "Unhandled exception: " + e.message, "DoDelete");
|
|
267
262
|
result.addDebug("OINO DELETE SQL [" + sql + "]", "DoDelete");
|
|
268
263
|
}
|
|
269
|
-
index_js_1.OINOBenchmark.end("doDelete");
|
|
270
264
|
}
|
|
271
265
|
/**
|
|
272
266
|
* Method for handlind a HTTP REST request with GET, POST, PUT, DELETE corresponding to
|
|
@@ -279,7 +273,7 @@ class OINODbApi {
|
|
|
279
273
|
*
|
|
280
274
|
*/
|
|
281
275
|
async doRequest(method, id, body, params = API_EMPTY_PARAMS) {
|
|
282
|
-
index_js_1.OINOBenchmark.start("doRequest");
|
|
276
|
+
index_js_1.OINOBenchmark.start("OINODbApi", "doRequest");
|
|
283
277
|
// OINOLog.debug("OINODbApi.doRequest enter", {method:method, id:id, body:body, params:params})
|
|
284
278
|
let result = new OINODbApiResult(params);
|
|
285
279
|
let rows = [];
|
|
@@ -347,7 +341,7 @@ class OINODbApi {
|
|
|
347
341
|
else {
|
|
348
342
|
result.setError(405, "Unsupported HTTP method '" + method + "'", "DoRequest");
|
|
349
343
|
}
|
|
350
|
-
index_js_1.OINOBenchmark.end("doRequest");
|
|
344
|
+
index_js_1.OINOBenchmark.end("OINODbApi", "doRequest", method);
|
|
351
345
|
return result;
|
|
352
346
|
}
|
|
353
347
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.OINODbFactory = void 0;
|
|
9
|
-
const OINOResult_js_1 = require("../../types/src/OINOResult.js");
|
|
10
9
|
const index_js_1 = require("./index.js");
|
|
11
10
|
/**
|
|
12
11
|
* Static factory class for easily creating things based on data
|
|
@@ -143,7 +142,7 @@ class OINODbFactory {
|
|
|
143
142
|
html += html_row + "\r\n";
|
|
144
143
|
dataset.next();
|
|
145
144
|
}
|
|
146
|
-
const result = new
|
|
145
|
+
const result = new index_js_1.OINOHttpResult(html);
|
|
147
146
|
return result;
|
|
148
147
|
}
|
|
149
148
|
/**
|
|
@@ -180,7 +179,7 @@ class OINODbFactory {
|
|
|
180
179
|
html = html.replaceAll('###messages###', "<ul>" + messages + "</ul>");
|
|
181
180
|
}
|
|
182
181
|
html = html.replace(/###[^#]*###/g, "");
|
|
183
|
-
const http_result = new
|
|
182
|
+
const http_result = new index_js_1.OINOHttpResult(html);
|
|
184
183
|
return http_result;
|
|
185
184
|
}
|
|
186
185
|
static _findCsvLineEnd(csvData, start) {
|
package/dist/esm/OINODbApi.js
CHANGED
|
@@ -61,6 +61,7 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
61
61
|
*
|
|
62
62
|
*/
|
|
63
63
|
renderFromDbData(modelset) {
|
|
64
|
+
OINOBenchmark.start("OINOHtmlTemplate", "renderFromDbData");
|
|
64
65
|
let html = "";
|
|
65
66
|
const dataset = modelset.dataset;
|
|
66
67
|
const datamodel = modelset.datamodel;
|
|
@@ -93,6 +94,7 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
93
94
|
}
|
|
94
95
|
const result = new OINOHttpResult(html);
|
|
95
96
|
result.lastModified = last_modified;
|
|
97
|
+
OINOBenchmark.end("OINOHtmlTemplate", "renderFromDbData");
|
|
96
98
|
return result;
|
|
97
99
|
}
|
|
98
100
|
}
|
|
@@ -126,7 +128,7 @@ export class OINODbApi {
|
|
|
126
128
|
this.params = params;
|
|
127
129
|
this.datamodel = new OINODbDataModel(this);
|
|
128
130
|
if (this.params.hashidKey) {
|
|
129
|
-
this.hashid = new OINOHashid(this.params.hashidKey, this.db.name, this.params.hashidLength, this.params.
|
|
131
|
+
this.hashid = new OINOHashid(this.params.hashidKey, this.db.name, this.params.hashidLength, this.params.hashidStaticIds);
|
|
130
132
|
}
|
|
131
133
|
else {
|
|
132
134
|
this.hashid = null;
|
|
@@ -166,7 +168,6 @@ export class OINODbApi {
|
|
|
166
168
|
//logDebug("OINODbApi.validateHttpValues", {result:result})
|
|
167
169
|
}
|
|
168
170
|
async _doGet(result, id, params) {
|
|
169
|
-
OINOBenchmark.start("doGet");
|
|
170
171
|
const sql = this.datamodel.printSqlSelect(id, params.sqlParams || {});
|
|
171
172
|
// OINOLog.debug("OINODbApi.doGet sql", {sql:sql})
|
|
172
173
|
try {
|
|
@@ -184,10 +185,8 @@ export class OINODbApi {
|
|
|
184
185
|
result.setError(500, "Unhandled exception in doGet: " + e.message, "DoGet");
|
|
185
186
|
result.addDebug("OINO GET SQL [" + sql + "]", "DoGet");
|
|
186
187
|
}
|
|
187
|
-
OINOBenchmark.end("doGet");
|
|
188
188
|
}
|
|
189
189
|
async _doPost(result, rows) {
|
|
190
|
-
OINOBenchmark.start("doPost");
|
|
191
190
|
let sql = "";
|
|
192
191
|
try {
|
|
193
192
|
let i = 0;
|
|
@@ -218,10 +217,8 @@ export class OINODbApi {
|
|
|
218
217
|
result.setError(500, "Unhandled exception in doPost: " + e.message, "DoPost");
|
|
219
218
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPost");
|
|
220
219
|
}
|
|
221
|
-
OINOBenchmark.end("doPost");
|
|
222
220
|
}
|
|
223
221
|
async _doPut(result, id, row) {
|
|
224
|
-
OINOBenchmark.start("doPut");
|
|
225
222
|
let sql = "";
|
|
226
223
|
try {
|
|
227
224
|
this._validateRowValues(result, row, false);
|
|
@@ -241,10 +238,8 @@ export class OINODbApi {
|
|
|
241
238
|
result.setError(500, "Unhandled exception: " + e.message, "DoPut");
|
|
242
239
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPut");
|
|
243
240
|
}
|
|
244
|
-
OINOBenchmark.end("doPut");
|
|
245
241
|
}
|
|
246
242
|
async _doDelete(result, id) {
|
|
247
|
-
OINOBenchmark.start("doDelete");
|
|
248
243
|
let sql = "";
|
|
249
244
|
try {
|
|
250
245
|
sql = this.datamodel.printSqlDelete(id);
|
|
@@ -261,7 +256,6 @@ export class OINODbApi {
|
|
|
261
256
|
result.setError(500, "Unhandled exception: " + e.message, "DoDelete");
|
|
262
257
|
result.addDebug("OINO DELETE SQL [" + sql + "]", "DoDelete");
|
|
263
258
|
}
|
|
264
|
-
OINOBenchmark.end("doDelete");
|
|
265
259
|
}
|
|
266
260
|
/**
|
|
267
261
|
* Method for handlind a HTTP REST request with GET, POST, PUT, DELETE corresponding to
|
|
@@ -274,7 +268,7 @@ export class OINODbApi {
|
|
|
274
268
|
*
|
|
275
269
|
*/
|
|
276
270
|
async doRequest(method, id, body, params = API_EMPTY_PARAMS) {
|
|
277
|
-
OINOBenchmark.start("doRequest");
|
|
271
|
+
OINOBenchmark.start("OINODbApi", "doRequest");
|
|
278
272
|
// OINOLog.debug("OINODbApi.doRequest enter", {method:method, id:id, body:body, params:params})
|
|
279
273
|
let result = new OINODbApiResult(params);
|
|
280
274
|
let rows = [];
|
|
@@ -342,7 +336,7 @@ export class OINODbApi {
|
|
|
342
336
|
else {
|
|
343
337
|
result.setError(405, "Unsupported HTTP method '" + method + "'", "DoRequest");
|
|
344
338
|
}
|
|
345
|
-
OINOBenchmark.end("doRequest");
|
|
339
|
+
OINOBenchmark.end("OINODbApi", "doRequest", method);
|
|
346
340
|
return result;
|
|
347
341
|
}
|
|
348
342
|
}
|
|
@@ -3,8 +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 { OINOHttpResult } from "
|
|
7
|
-
import { OINODbApi, OINOContentType, OINODbSqlFilter, OINOStr, OINODbConfig, OINONumberDataField, OINODbSqlOrder, OINODbSqlLimit, OINO_ERROR_PREFIX, OINO_WARNING_PREFIX, OINO_INFO_PREFIX, OINO_DEBUG_PREFIX, OINOLog } from "./index.js";
|
|
6
|
+
import { OINOHttpResult, OINODbApi, OINOContentType, OINODbSqlFilter, OINOStr, OINODbConfig, OINONumberDataField, OINODbSqlOrder, OINODbSqlLimit, OINO_ERROR_PREFIX, OINO_WARNING_PREFIX, OINO_INFO_PREFIX, OINO_DEBUG_PREFIX, OINOLog } from "./index.js";
|
|
8
7
|
/**
|
|
9
8
|
* Static factory class for easily creating things based on data
|
|
10
9
|
*
|
|
@@ -25,7 +25,7 @@ export declare class OINODbApiResult extends OINOResult {
|
|
|
25
25
|
* @param headers Headers to include in the response
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
|
-
getResponse(headers?:
|
|
28
|
+
getResponse(headers?: Record<string, string>): Response;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Specialized HTML template that can render ´OINODbApiResult´.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { OINOHttpResult } from "
|
|
2
|
-
import { OINODbApi, OINODbApiParams, OINODbParams, OINODbDataModel, OINODb, OINODataRow, OINODbConstructor, OINODbApiRequestParams, OINODbModelSet, OINOResult } from "./index.js";
|
|
1
|
+
import { OINOHttpResult, OINODbApi, OINODbApiParams, OINODbParams, OINODbDataModel, OINODb, OINODataRow, OINODbConstructor, OINODbApiRequestParams, OINODbModelSet, OINOResult } from "./index.js";
|
|
3
2
|
/**
|
|
4
3
|
* Static factory class for easily creating things based on data
|
|
5
4
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export type OINODbApiParams = {
|
|
|
35
35
|
/** Set (minimum) length (12-32 chars) of the hashids */
|
|
36
36
|
hashidLength?: number;
|
|
37
37
|
/** Make hashids static per row/table */
|
|
38
|
-
|
|
38
|
+
hashidStaticIds?: boolean;
|
|
39
39
|
/** Name of field that has the modified field */
|
|
40
40
|
cacheModifiedField?: string;
|
|
41
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/db",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
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",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@types/node": "^20.14.10",
|
|
23
|
-
"@oino-ts/types": "0.0.
|
|
23
|
+
"@oino-ts/types": "0.0.14"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/bun": "latest",
|
package/src/OINODbApi.test.ts
CHANGED
|
@@ -192,7 +192,7 @@ const apis:OINOTestApiParams[] = [
|
|
|
192
192
|
putRow: [99, "Umeshu", 1, 1, undefined, 24.99, 3, 0, 20, 0]
|
|
193
193
|
},
|
|
194
194
|
{
|
|
195
|
-
apiParams: { tableName: "Employees", hashidKey: "12345678901234567890123456789012" },
|
|
195
|
+
apiParams: { tableName: "Employees", hashidKey: "12345678901234567890123456789012", hashidStaticIds:true },
|
|
196
196
|
requestParams: {
|
|
197
197
|
sqlParams: { filter: OINODbSqlFilter.parse("(TitleOfCourtesy)-eq(Ms.)"), order: OINODbSqlOrder.parse("LastName asc") }
|
|
198
198
|
},
|
package/src/OINODbApi.ts
CHANGED
|
@@ -41,7 +41,7 @@ export class OINODbApiResult extends OINOResult {
|
|
|
41
41
|
* @param headers Headers to include in the response
|
|
42
42
|
*
|
|
43
43
|
*/
|
|
44
|
-
getResponse(headers:
|
|
44
|
+
getResponse(headers:Record<string, string> = {}):Response {
|
|
45
45
|
let response:Response|null = null
|
|
46
46
|
if (this.success && this.data) {
|
|
47
47
|
response = new Response(this.data.writeString(this.params.responseType), {status:this.statusCode, statusText: this.statusMessage, headers: headers })
|
|
@@ -68,6 +68,7 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
68
68
|
*
|
|
69
69
|
*/
|
|
70
70
|
renderFromDbData(modelset:OINODbModelSet):OINOHttpResult {
|
|
71
|
+
OINOBenchmark.start("OINOHtmlTemplate", "renderFromDbData")
|
|
71
72
|
let html:string = ""
|
|
72
73
|
const dataset:OINODbDataSet|undefined = modelset.dataset
|
|
73
74
|
const datamodel:OINODbDataModel = modelset.datamodel
|
|
@@ -101,6 +102,7 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
101
102
|
}
|
|
102
103
|
const result:OINOHttpResult = new OINOHttpResult(html)
|
|
103
104
|
result.lastModified = last_modified
|
|
105
|
+
OINOBenchmark.end("OINOHtmlTemplate", "renderFromDbData")
|
|
104
106
|
return result
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -141,7 +143,7 @@ export class OINODbApi {
|
|
|
141
143
|
this.params = params
|
|
142
144
|
this.datamodel = new OINODbDataModel(this)
|
|
143
145
|
if (this.params.hashidKey) {
|
|
144
|
-
this.hashid = new OINOHashid(this.params.hashidKey, this.db.name, this.params.hashidLength, this.params.
|
|
146
|
+
this.hashid = new OINOHashid(this.params.hashidKey, this.db.name, this.params.hashidLength, this.params.hashidStaticIds)
|
|
145
147
|
} else {
|
|
146
148
|
this.hashid = null
|
|
147
149
|
}
|
|
@@ -182,7 +184,6 @@ export class OINODbApi {
|
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
private async _doGet(result:OINODbApiResult, id:string, params:OINODbApiRequestParams):Promise<void> {
|
|
185
|
-
OINOBenchmark.start("doGet")
|
|
186
187
|
const sql:string = this.datamodel.printSqlSelect(id, params.sqlParams || {})
|
|
187
188
|
// OINOLog.debug("OINODbApi.doGet sql", {sql:sql})
|
|
188
189
|
try {
|
|
@@ -198,11 +199,9 @@ export class OINODbApi {
|
|
|
198
199
|
result.setError(500, "Unhandled exception in doGet: " + e.message, "DoGet")
|
|
199
200
|
result.addDebug("OINO GET SQL [" + sql + "]", "DoGet")
|
|
200
201
|
}
|
|
201
|
-
OINOBenchmark.end("doGet")
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
private async _doPost(result:OINODbApiResult, rows:OINODataRow[]):Promise<void> {
|
|
205
|
-
OINOBenchmark.start("doPost")
|
|
206
205
|
let sql:string = ""
|
|
207
206
|
try {
|
|
208
207
|
let i:number = 0
|
|
@@ -232,11 +231,9 @@ export class OINODbApi {
|
|
|
232
231
|
result.setError(500, "Unhandled exception in doPost: " + e.message, "DoPost")
|
|
233
232
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPost")
|
|
234
233
|
}
|
|
235
|
-
OINOBenchmark.end("doPost")
|
|
236
234
|
}
|
|
237
235
|
|
|
238
236
|
private async _doPut(result:OINODbApiResult, id:string, row:OINODataRow):Promise<void> {
|
|
239
|
-
OINOBenchmark.start("doPut")
|
|
240
237
|
let sql:string = ""
|
|
241
238
|
try {
|
|
242
239
|
this._validateRowValues(result, row, false)
|
|
@@ -255,11 +252,9 @@ export class OINODbApi {
|
|
|
255
252
|
result.setError(500, "Unhandled exception: " + e.message, "DoPut")
|
|
256
253
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPut")
|
|
257
254
|
}
|
|
258
|
-
OINOBenchmark.end("doPut")
|
|
259
255
|
}
|
|
260
256
|
|
|
261
257
|
private async _doDelete(result:OINODbApiResult, id:string):Promise<void> {
|
|
262
|
-
OINOBenchmark.start("doDelete")
|
|
263
258
|
let sql:string = ""
|
|
264
259
|
try {
|
|
265
260
|
sql = this.datamodel.printSqlDelete(id)
|
|
@@ -275,7 +270,6 @@ export class OINODbApi {
|
|
|
275
270
|
result.setError(500, "Unhandled exception: " + e.message, "DoDelete")
|
|
276
271
|
result.addDebug("OINO DELETE SQL [" + sql + "]", "DoDelete")
|
|
277
272
|
}
|
|
278
|
-
OINOBenchmark.end("doDelete")
|
|
279
273
|
}
|
|
280
274
|
|
|
281
275
|
/**
|
|
@@ -289,7 +283,7 @@ export class OINODbApi {
|
|
|
289
283
|
*
|
|
290
284
|
*/
|
|
291
285
|
async doRequest(method:string, id: string, body:string|OINODataRow[]|any, params:OINODbApiRequestParams = API_EMPTY_PARAMS):Promise<OINODbApiResult> {
|
|
292
|
-
OINOBenchmark.start("doRequest")
|
|
286
|
+
OINOBenchmark.start("OINODbApi", "doRequest")
|
|
293
287
|
// OINOLog.debug("OINODbApi.doRequest enter", {method:method, id:id, body:body, params:params})
|
|
294
288
|
let result:OINODbApiResult = new OINODbApiResult(params)
|
|
295
289
|
let rows:OINODataRow[] = []
|
|
@@ -354,7 +348,7 @@ export class OINODbApi {
|
|
|
354
348
|
} else {
|
|
355
349
|
result.setError(405, "Unsupported HTTP method '" + method + "'", "DoRequest")
|
|
356
350
|
}
|
|
357
|
-
OINOBenchmark.end("doRequest")
|
|
351
|
+
OINOBenchmark.end("OINODbApi", "doRequest", method)
|
|
358
352
|
return result
|
|
359
353
|
}
|
|
360
354
|
}
|
package/src/OINODbDataField.ts
CHANGED
|
@@ -250,7 +250,7 @@ export class OINONumberDataField extends OINODbDataField {
|
|
|
250
250
|
deserializeCell(value: string|null|undefined): OINODataCell {
|
|
251
251
|
if (value === undefined) {
|
|
252
252
|
return undefined
|
|
253
|
-
} else if ((value
|
|
253
|
+
} else if ((value === "") || (value === null)) {
|
|
254
254
|
return null
|
|
255
255
|
} else {
|
|
256
256
|
return Number.parseFloat(value)
|
package/src/OINODbFactory.ts
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { OINOHttpResult } from "
|
|
8
|
-
import { OINODbApi, OINODbApiParams, OINODbParams, OINOContentType, OINODbDataModel, OINODbDataField, OINODb, OINODataRow, OINODbConstructor, OINODbApiRequestParams, OINODbSqlFilter, OINOStr, OINOBlobDataField, OINODbApiResult, OINODbDataSet, OINODbModelSet, OINODbConfig, OINONumberDataField, OINODataCell, OINODbSqlOrder, OINODbSqlLimit, OINO_ERROR_PREFIX, OINO_WARNING_PREFIX, OINO_INFO_PREFIX, OINO_DEBUG_PREFIX, OINOLog, OINODbSqlParams, OINOResult } from "./index.js"
|
|
7
|
+
import { OINOHttpResult, OINODbApi, OINODbApiParams, OINODbParams, OINOContentType, OINODbDataModel, OINODbDataField, OINODb, OINODataRow, OINODbConstructor, OINODbApiRequestParams, OINODbSqlFilter, OINOStr, OINOBlobDataField, OINODbApiResult, OINODbDataSet, OINODbModelSet, OINODbConfig, OINONumberDataField, OINODataCell, OINODbSqlOrder, OINODbSqlLimit, OINO_ERROR_PREFIX, OINO_WARNING_PREFIX, OINO_INFO_PREFIX, OINO_DEBUG_PREFIX, OINOLog, OINODbSqlParams, OINOResult } from "./index.js"
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Static factory class for easily creating things based on data
|
package/src/index.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type OINODbApiParams = {
|
|
|
39
39
|
/** Set (minimum) length (12-32 chars) of the hashids */
|
|
40
40
|
hashidLength?:number,
|
|
41
41
|
/** Make hashids static per row/table */
|
|
42
|
-
|
|
42
|
+
hashidStaticIds?: boolean,
|
|
43
43
|
/** Name of field that has the modified field */
|
|
44
44
|
cacheModifiedField?:string
|
|
45
45
|
}
|