@oino-ts/db 0.0.11
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/README.md +222 -0
- package/dist/cjs/OINODb.js +27 -0
- package/dist/cjs/OINODbApi.js +270 -0
- package/dist/cjs/OINODbConfig.js +86 -0
- package/dist/cjs/OINODbDataField.js +354 -0
- package/dist/cjs/OINODbDataModel.js +279 -0
- package/dist/cjs/OINODbDataSet.js +139 -0
- package/dist/cjs/OINODbFactory.js +563 -0
- package/dist/cjs/OINODbModelSet.js +267 -0
- package/dist/cjs/OINODbParams.js +280 -0
- package/dist/cjs/OINODbRequestParams.js +280 -0
- package/dist/cjs/OINODbSwagger.js +201 -0
- package/dist/cjs/index.js +51 -0
- package/dist/esm/OINODb.js +23 -0
- package/dist/esm/OINODbApi.js +265 -0
- package/dist/esm/OINODbConfig.js +82 -0
- package/dist/esm/OINODbDataField.js +345 -0
- package/dist/esm/OINODbDataModel.js +275 -0
- package/dist/esm/OINODbDataSet.js +134 -0
- package/dist/esm/OINODbFactory.js +559 -0
- package/dist/esm/OINODbModelSet.js +263 -0
- package/dist/esm/OINODbRequestParams.js +274 -0
- package/dist/esm/OINODbSwagger.js +197 -0
- package/dist/esm/index.js +17 -0
- package/dist/types/OINODb.d.ts +75 -0
- package/dist/types/OINODbApi.d.ts +57 -0
- package/dist/types/OINODbConfig.d.ts +52 -0
- package/dist/types/OINODbDataField.d.ts +202 -0
- package/dist/types/OINODbDataModel.d.ts +108 -0
- package/dist/types/OINODbDataSet.d.ts +95 -0
- package/dist/types/OINODbFactory.d.ts +99 -0
- package/dist/types/OINODbModelSet.d.ts +50 -0
- package/dist/types/OINODbRequestParams.d.ts +130 -0
- package/dist/types/OINODbSwagger.d.ts +25 -0
- package/dist/types/index.d.ts +103 -0
- package/package.json +35 -0
- package/src/OINODb.ts +98 -0
- package/src/OINODbApi.test.ts +243 -0
- package/src/OINODbApi.ts +270 -0
- package/src/OINODbConfig.ts +92 -0
- package/src/OINODbDataField.ts +372 -0
- package/src/OINODbDataModel.ts +290 -0
- package/src/OINODbDataSet.ts +170 -0
- package/src/OINODbFactory.ts +570 -0
- package/src/OINODbModelSet.ts +286 -0
- package/src/OINODbRequestParams.ts +281 -0
- package/src/OINODbSwagger.ts +209 -0
- package/src/index.ts +116 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Static class for Swagger utilities
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export class OINODbSwagger {
|
|
11
|
+
static _getSchemaApiMethodParamsQueryId() {
|
|
12
|
+
return {
|
|
13
|
+
"schema": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"in": "path",
|
|
17
|
+
"name": "id",
|
|
18
|
+
"required": true
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static _getSchemaApiMethodParamsBody(tableName) {
|
|
22
|
+
return {
|
|
23
|
+
"schema": {
|
|
24
|
+
"$ref": "#/components/schemas/" + tableName
|
|
25
|
+
},
|
|
26
|
+
"in": "body",
|
|
27
|
+
"required": true
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
static _getSchemaApiMethodDescription(method, tableName, hasQueryIdParam) {
|
|
31
|
+
if (hasQueryIdParam) {
|
|
32
|
+
return method.toUpperCase() + " " + tableName + " object";
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return method.toUpperCase() + " " + tableName + " object array";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
static _getSchemaApiMethodOperationId(method, tableName, hasQueryIdParam) {
|
|
39
|
+
if (hasQueryIdParam) {
|
|
40
|
+
return method + tableName;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return method + tableName + "All";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
static _getSchemaOinoResponse() {
|
|
47
|
+
return {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"properties": {
|
|
50
|
+
"success": {
|
|
51
|
+
"type": "boolean"
|
|
52
|
+
},
|
|
53
|
+
"statusCode": {
|
|
54
|
+
"type": "number"
|
|
55
|
+
},
|
|
56
|
+
"statusMessage": {
|
|
57
|
+
"type": "string"
|
|
58
|
+
},
|
|
59
|
+
"messages": {
|
|
60
|
+
"type": "array",
|
|
61
|
+
"items": {
|
|
62
|
+
"type": "string"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"required": [
|
|
67
|
+
"success",
|
|
68
|
+
"statusCode",
|
|
69
|
+
"statusMessage",
|
|
70
|
+
"messages"
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
static _getSchemaFieldType(field) {
|
|
75
|
+
let type_string;
|
|
76
|
+
if (field.type == "boolean") {
|
|
77
|
+
type_string = "boolean";
|
|
78
|
+
}
|
|
79
|
+
else if (field.type == "integer" || field.type == "number") {
|
|
80
|
+
type_string = "number";
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
type_string = "string";
|
|
84
|
+
}
|
|
85
|
+
if (!field.fieldParams.isNotNull) {
|
|
86
|
+
return {
|
|
87
|
+
"anyOf": [
|
|
88
|
+
{
|
|
89
|
+
"type": type_string
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "null"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return { type: type_string };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
static _getSwaggerApiType(api) {
|
|
102
|
+
let result = {
|
|
103
|
+
type: "object",
|
|
104
|
+
properties: {},
|
|
105
|
+
required: []
|
|
106
|
+
};
|
|
107
|
+
let field;
|
|
108
|
+
for (field of api.datamodel.fields) {
|
|
109
|
+
result.properties[field.name] = this._getSchemaFieldType(field);
|
|
110
|
+
if (field.fieldParams.isPrimaryKey) {
|
|
111
|
+
result.required.push(field.name);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
static _getSchemaType(tableName, hasQueryIdParam, hasResultData) {
|
|
117
|
+
if (hasResultData && hasQueryIdParam) {
|
|
118
|
+
return { "$ref": "#/components/schemas/" + tableName };
|
|
119
|
+
}
|
|
120
|
+
else if (hasResultData) {
|
|
121
|
+
return { type: "array", items: { "$ref": "#/components/schemas/" + tableName } };
|
|
122
|
+
}
|
|
123
|
+
else if (hasQueryIdParam) {
|
|
124
|
+
return { "$ref": "#/components/schemas/OINOResponse" };
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
return { "$ref": "#/components/schemas/OINOResponse" };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
static _getSchemaApiMethodParams(tableName, hasQueryIdParam, hasResultData) {
|
|
131
|
+
if (hasResultData && hasQueryIdParam) {
|
|
132
|
+
return [this._getSchemaApiMethodParamsQueryId()];
|
|
133
|
+
}
|
|
134
|
+
else if (hasResultData) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
else if (hasQueryIdParam) {
|
|
138
|
+
return [this._getSchemaApiMethodParamsQueryId(), this._getSchemaApiMethodParamsBody(tableName)];
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return [this._getSchemaApiMethodParamsBody(tableName)];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
static _getSchemaApiMethod(method, tableName, hasQueryIdParam, hasBody, hasResultData) {
|
|
145
|
+
return {
|
|
146
|
+
responses: {
|
|
147
|
+
200: { description: this._getSchemaApiMethodDescription(method, tableName, hasQueryIdParam), content: { "application/json": { schema: this._getSchemaType(tableName, hasQueryIdParam, hasResultData) } } }
|
|
148
|
+
},
|
|
149
|
+
"operationId": this._getSchemaApiMethodOperationId(method, tableName, hasQueryIdParam),
|
|
150
|
+
"parameters": this._getSchemaApiMethodParams(tableName, hasQueryIdParam, hasResultData)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
static _getSwaggerApiPath(tableName, hasQueryIdParam) {
|
|
154
|
+
if (hasQueryIdParam) {
|
|
155
|
+
return {
|
|
156
|
+
get: this._getSchemaApiMethod("get", tableName, hasQueryIdParam, false, true),
|
|
157
|
+
put: this._getSchemaApiMethod("put", tableName, hasQueryIdParam, true, false),
|
|
158
|
+
delete: this._getSchemaApiMethod("delete", tableName, hasQueryIdParam, false, false)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
return {
|
|
163
|
+
get: this._getSchemaApiMethod("get", tableName, hasQueryIdParam, false, true),
|
|
164
|
+
post: this._getSchemaApiMethod("post", tableName, hasQueryIdParam, true, false)
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Returns swagger.json as object of the given API's.
|
|
170
|
+
*
|
|
171
|
+
* @param apis array of API's use for Swagger definition
|
|
172
|
+
*
|
|
173
|
+
*/
|
|
174
|
+
static getApiDefinition(apis) {
|
|
175
|
+
let result = {
|
|
176
|
+
"openapi": "3.1.0",
|
|
177
|
+
"info": {
|
|
178
|
+
"title": "",
|
|
179
|
+
"description": "",
|
|
180
|
+
"version": ""
|
|
181
|
+
},
|
|
182
|
+
"paths": {},
|
|
183
|
+
"components": {
|
|
184
|
+
"schemas": {
|
|
185
|
+
OINOResponse: this._getSchemaOinoResponse()
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
for (let i = 0; i < apis.length; i++) {
|
|
190
|
+
const table_name = apis[i].params.tableName;
|
|
191
|
+
result.paths["/" + table_name] = this._getSwaggerApiPath(table_name, false);
|
|
192
|
+
result.paths["/" + table_name + "/{id}"] = this._getSwaggerApiPath(table_name, true);
|
|
193
|
+
result.components.schemas[table_name] = this._getSwaggerApiType(apis[i]);
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OINOContentType } from "@oino-ts/types";
|
|
2
|
+
export { OINOContentType };
|
|
3
|
+
export { OINO_ERROR_PREFIX, OINO_WARNING_PREFIX, OINO_INFO_PREFIX, OINO_DEBUG_PREFIX, OINOStr, OINOBenchmark, OINOLog, OINOLogLevel, OINOConsoleLog, OINOResult } from "@oino-ts/types";
|
|
4
|
+
export { OINODbApiResult, OINODbApi } from "./OINODbApi.js";
|
|
5
|
+
export { OINODbDataModel } from "./OINODbDataModel.js";
|
|
6
|
+
export { OINODbModelSet } from "./OINODbModelSet.js";
|
|
7
|
+
export { OINODbDataField, OINOBooleanDataField, OINONumberDataField, OINOStringDataField, OINOBlobDataField, OINODatetimeDataField } from "./OINODbDataField.js";
|
|
8
|
+
export { OINODb } from "./OINODb.js";
|
|
9
|
+
export { OINODbDataSet, OINODbMemoryDataSet } from "./OINODbDataSet.js";
|
|
10
|
+
export { OINODbSqlFilter, OINODbSqlOrder, OINODbSqlComparison, OINODbSqlLimit, OINODbSqlBooleanOperation } from "./OINODbRequestParams.js";
|
|
11
|
+
export { OINODbConfig } from "./OINODbConfig.js";
|
|
12
|
+
export { OINODbFactory } from "./OINODbFactory.js";
|
|
13
|
+
export { OINODbSwagger } from "./OINODbSwagger.js";
|
|
14
|
+
/** Empty row instance */
|
|
15
|
+
export const OINODB_EMPTY_ROW = [];
|
|
16
|
+
/** Empty row array instance */
|
|
17
|
+
export const OINODB_EMPTY_ROWS = [OINODB_EMPTY_ROW];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { OINODbParams, OINODbApi, OINODataCell, OINODbDataSet } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for database abstraction, implementing methods for connecting, making queries and parsing/formatting data
|
|
4
|
+
* between SQL and serialization formats.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class OINODb {
|
|
8
|
+
protected _params: OINODbParams;
|
|
9
|
+
/** Name of the database */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Constructor for `OINODb`.
|
|
13
|
+
* @param params database parameters
|
|
14
|
+
*/
|
|
15
|
+
constructor(params: OINODbParams);
|
|
16
|
+
/**
|
|
17
|
+
* Connect to database.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
abstract connect(): Promise<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Print a table name using database specific SQL escaping.
|
|
23
|
+
*
|
|
24
|
+
* @param sqlTable name of the table
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
abstract printSqlTablename(sqlTable: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Print a column name with correct SQL escaping.
|
|
30
|
+
*
|
|
31
|
+
* @param sqlColumn name of the column
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
abstract printSqlColumnname(sqlColumn: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Print a single data value from serialization using the context of the native data
|
|
37
|
+
* type with the correct SQL escaping.
|
|
38
|
+
*
|
|
39
|
+
* @param cellValue data from sql results
|
|
40
|
+
* @param sqlType native type name for table column
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
abstract printCellAsSqlValue(cellValue: OINODataCell, sqlType: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Parse a single SQL result value for serialization using the context of the native data
|
|
46
|
+
* type.
|
|
47
|
+
*
|
|
48
|
+
* @param sqlValue data from serialization
|
|
49
|
+
* @param sqlType native type name for table column
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
abstract parseSqlValueAsCell(sqlValue: OINODataCell, sqlType: string): OINODataCell;
|
|
53
|
+
/**
|
|
54
|
+
* Execute a select operation.
|
|
55
|
+
*
|
|
56
|
+
* @param sql SQL statement.
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
abstract sqlSelect(sql: string): Promise<OINODbDataSet>;
|
|
60
|
+
/**
|
|
61
|
+
* Execute other sql operations.
|
|
62
|
+
*
|
|
63
|
+
* @param sql SQL statement.
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
abstract sqlExec(sql: string): Promise<OINODbDataSet>;
|
|
67
|
+
/**
|
|
68
|
+
* Initialize a data model by getting the SQL schema and populating OINODbDataFields of
|
|
69
|
+
* the model.
|
|
70
|
+
*
|
|
71
|
+
* @param api api which data model to initialize.
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
abstract initializeApiDatamodel(api: OINODbApi): Promise<void>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { OINODbApiParams, OINODb, OINODbDataModel, OINODbModelSet, OINORequestParams, OINOResult } from "./index.js";
|
|
2
|
+
import { OINOHashid } from "@oino-ts/hashid";
|
|
3
|
+
/**
|
|
4
|
+
* OINO API request result object with returned data and/or http status code/message and
|
|
5
|
+
* error / warning messages.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export declare class OINODbApiResult extends OINOResult {
|
|
9
|
+
/** Returned data if any */
|
|
10
|
+
data?: OINODbModelSet;
|
|
11
|
+
/**
|
|
12
|
+
* Constructor of OINODbApiResult.
|
|
13
|
+
*
|
|
14
|
+
* @param data result data
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
constructor(data?: OINODbModelSet);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* API class with method to process HTTP REST requests.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare class OINODbApi {
|
|
24
|
+
/** API database reference */
|
|
25
|
+
readonly db: OINODb;
|
|
26
|
+
/** API datamodel */
|
|
27
|
+
readonly datamodel: OINODbDataModel;
|
|
28
|
+
/** API parameters */
|
|
29
|
+
readonly params: OINODbApiParams;
|
|
30
|
+
/** API hashid */
|
|
31
|
+
readonly hashid: OINOHashid | null;
|
|
32
|
+
/**
|
|
33
|
+
* Constructor of API object.
|
|
34
|
+
* NOTE! OINODb.initDatamodel must be called if created manually instead of the factory.
|
|
35
|
+
*
|
|
36
|
+
* @param db database for the API
|
|
37
|
+
* @param params parameters for the API
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
constructor(db: OINODb, params: OINODbApiParams);
|
|
41
|
+
private _validateRowValues;
|
|
42
|
+
private _doGet;
|
|
43
|
+
private _doPost;
|
|
44
|
+
private _doPut;
|
|
45
|
+
private _doDelete;
|
|
46
|
+
/**
|
|
47
|
+
* Method for handlind a HTTP REST request with GET, POST, PUT, DELETE corresponding to
|
|
48
|
+
* SQL select, insert, update and delete.
|
|
49
|
+
*
|
|
50
|
+
* @param method HTTP verb (uppercase)
|
|
51
|
+
* @param id URL id of the REST request
|
|
52
|
+
* @param body HTTP body data as string
|
|
53
|
+
* @param params HTTP URL parameters as key-value-pairs
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
doRequest(method: string, id: string, body: string, params: OINORequestParams): Promise<OINODbApiResult>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Set the name of the OINO ID field (default \_OINOID\_) */
|
|
2
|
+
export declare class OINODbConfig {
|
|
3
|
+
/** Name of the synthetic OINO ID field */
|
|
4
|
+
static OINODB_ID_FIELD: string;
|
|
5
|
+
/** Private key separator of the synthetic OINO ID field */
|
|
6
|
+
static OINODB_ID_SEPARATOR: string;
|
|
7
|
+
private static OINODB_ID_SEPARATOR_ESCAPED;
|
|
8
|
+
/** Name of the OINODbSqlFilter-parameter in request */
|
|
9
|
+
static OINODB_SQL_FILTER_PARAM: string;
|
|
10
|
+
/** Name of the OINODbSqlOrder-parameter in request */
|
|
11
|
+
static OINODB_SQL_ORDER_PARAM: string;
|
|
12
|
+
/** Name of the OINODbSqlLimit-parameter in request */
|
|
13
|
+
static OINODB_SQL_LIMIT_PARAM: string;
|
|
14
|
+
/**
|
|
15
|
+
* Set the name of the OINO ID field
|
|
16
|
+
* @param idField name of the OINO ID field
|
|
17
|
+
*/
|
|
18
|
+
static setOinoIdField(idField: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Set the separator character of the OINO ID field
|
|
21
|
+
* @param idSeparator character to use as separator of id parts
|
|
22
|
+
*/
|
|
23
|
+
static setOinoIdSeparator(idSeparator: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Print OINO ID for primary key values.
|
|
26
|
+
*
|
|
27
|
+
* @param primaryKeys an array of primary key values.
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
static printOINOId(primaryKeys: string[]): string;
|
|
31
|
+
/**
|
|
32
|
+
* Set the name of the OINODbSqlFilter-param field
|
|
33
|
+
*
|
|
34
|
+
* @param sqlFilterParam name of the http parameter with `OINODbSqlFilter` definition
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
static setOinoSqlFilterParam(sqlFilterParam: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Set the name of the OINODbSqlOrder-param field
|
|
40
|
+
*
|
|
41
|
+
* @param sqlOrderParam name of the http parameter with `OINODbSqlOrder` definition
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
static setOinoSqlOrderParam(sqlOrderParam: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Set the name of the OINODbSqlLimit-param field
|
|
47
|
+
*
|
|
48
|
+
* @param sqlLimitParam name of the http parameter with `OINODbSqlLimit` definition
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
static setOinoSqlLimitParam(sqlLimitParam: string): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { OINODbDataFieldParams, OINODataCell, OINODb } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for a column of data responsible for appropriatelly serializing/deserializing the data.
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class OINODbDataField {
|
|
7
|
+
/** OINODB reference*/
|
|
8
|
+
readonly db: OINODb;
|
|
9
|
+
/** Name of the field */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/** Internal type of field*/
|
|
12
|
+
readonly type: string;
|
|
13
|
+
/** SQL type of the field */
|
|
14
|
+
readonly sqlType: string;
|
|
15
|
+
/** Maximum length of the field (or 0) */
|
|
16
|
+
readonly maxLength: number;
|
|
17
|
+
/** Parameters for the field */
|
|
18
|
+
readonly fieldParams: OINODbDataFieldParams;
|
|
19
|
+
/**
|
|
20
|
+
* Constructor for a data field
|
|
21
|
+
*
|
|
22
|
+
* @param db OINODb reference
|
|
23
|
+
* @param name name of the field
|
|
24
|
+
* @param type internal type of the field
|
|
25
|
+
* @param sqlType column type in database
|
|
26
|
+
* @param fieldParams parameters of the field
|
|
27
|
+
* @param maxLength maximum length of the field (or 0)
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
constructor(db: OINODb, name: string, type: string, sqlType: string, fieldParams: OINODbDataFieldParams, maxLength?: number);
|
|
31
|
+
/**
|
|
32
|
+
* Pring debug information for the field
|
|
33
|
+
*
|
|
34
|
+
* @param length length of the debug output (or 0 for as long as needed)
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
printColumnDebug(length?: number): string;
|
|
38
|
+
/**
|
|
39
|
+
* Serialize cell value in the given content format.
|
|
40
|
+
*
|
|
41
|
+
* @param cellVal cell value
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
serializeCell(cellVal: OINODataCell): string | null | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Parce cell value from string using field type specific formatting rules.
|
|
47
|
+
*
|
|
48
|
+
* @param value string value
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
deserializeCell(value: string | null | undefined): OINODataCell;
|
|
52
|
+
/**
|
|
53
|
+
* Print data cell (from deserialization) as SQL-string.
|
|
54
|
+
*
|
|
55
|
+
* @param cellVal cell value
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
printCellAsSqlValue(cellVal: OINODataCell): string;
|
|
59
|
+
/**
|
|
60
|
+
* Print name of column as SQL.
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
printSqlColumnName(): string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Specialised class for a string column.
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
export declare class OINOStringDataField extends OINODbDataField {
|
|
70
|
+
/**
|
|
71
|
+
* Constructor for a string data field
|
|
72
|
+
*
|
|
73
|
+
* @param db OINODb reference
|
|
74
|
+
* @param name name of the field
|
|
75
|
+
* @param sqlType column type in database
|
|
76
|
+
* @param fieldParams parameters of the field
|
|
77
|
+
* @param maxLength maximum length of the field (or 0)
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
constructor(db: OINODb, name: string, sqlType: string, fieldParams: OINODbDataFieldParams, maxLength: number);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Specialised class for a boolean column.
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
export declare class OINOBooleanDataField extends OINODbDataField {
|
|
87
|
+
/**
|
|
88
|
+
* Constructor for a boolean data field
|
|
89
|
+
*
|
|
90
|
+
* @param db OINODb reference
|
|
91
|
+
* @param name name of the field
|
|
92
|
+
* @param sqlType column type in database
|
|
93
|
+
* @param fieldParams parameters of the field
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
constructor(db: OINODb, name: string, sqlType: string, fieldParams: OINODbDataFieldParams);
|
|
97
|
+
/**
|
|
98
|
+
* Serialize cell value in the given content format.
|
|
99
|
+
*
|
|
100
|
+
* @param cellVal cell value
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
serializeCell(cellVal: OINODataCell): string | null | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Parce cell value from string using field type specific formatting rules.
|
|
106
|
+
*
|
|
107
|
+
* @param value string value
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
deserializeCell(value: string | null | undefined): OINODataCell;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Specialised class for a number column.
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
export declare class OINONumberDataField extends OINODbDataField {
|
|
117
|
+
/**
|
|
118
|
+
* Constructor for a string data field
|
|
119
|
+
*
|
|
120
|
+
* @param db OINODb reference
|
|
121
|
+
* @param name name of the field
|
|
122
|
+
* @param sqlType column type in database
|
|
123
|
+
* @param fieldParams parameters of the field
|
|
124
|
+
*
|
|
125
|
+
*/
|
|
126
|
+
constructor(db: OINODb, name: string, sqlType: string, fieldParams: OINODbDataFieldParams);
|
|
127
|
+
/**
|
|
128
|
+
* Serialize cell value in the given content format.
|
|
129
|
+
*
|
|
130
|
+
* @param cellVal cell value
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
|
+
serializeCell(cellVal: OINODataCell): string | null | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Parce cell value from string using field type specific formatting rules.
|
|
136
|
+
*
|
|
137
|
+
* @param value string value
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
deserializeCell(value: string | null | undefined): OINODataCell;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Specialised class for a blob column.
|
|
144
|
+
*
|
|
145
|
+
*/
|
|
146
|
+
export declare class OINOBlobDataField extends OINODbDataField {
|
|
147
|
+
/**
|
|
148
|
+
* Constructor for a blob data field
|
|
149
|
+
*
|
|
150
|
+
* @param db OINODb reference
|
|
151
|
+
* @param name name of the field
|
|
152
|
+
* @param sqlType column type in database
|
|
153
|
+
* @param fieldParams parameters of the field
|
|
154
|
+
* @param maxLength maximum length of the field (or 0)
|
|
155
|
+
*
|
|
156
|
+
*/
|
|
157
|
+
constructor(db: OINODb, name: string, sqlType: string, fieldParams: OINODbDataFieldParams, maxLength: number);
|
|
158
|
+
/**
|
|
159
|
+
* Serialize cell value in the given content format.
|
|
160
|
+
*
|
|
161
|
+
* @param cellVal cell value
|
|
162
|
+
*
|
|
163
|
+
*/
|
|
164
|
+
serializeCell(cellVal: OINODataCell): string | null | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* Parce cell value from string using field type specific formatting rules.
|
|
167
|
+
*
|
|
168
|
+
* @param value string value
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
deserializeCell(value: string | null | undefined): OINODataCell;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Specialised class for a datetime column.
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
177
|
+
export declare class OINODatetimeDataField extends OINODbDataField {
|
|
178
|
+
/**
|
|
179
|
+
* Constructor for a string data field
|
|
180
|
+
*
|
|
181
|
+
* @param db OINODb reference
|
|
182
|
+
* @param name name of the field
|
|
183
|
+
* @param sqlType column type in database
|
|
184
|
+
* @param fieldParams parameters of the field
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
187
|
+
constructor(db: OINODb, name: string, sqlType: string, fieldParams: OINODbDataFieldParams);
|
|
188
|
+
/**
|
|
189
|
+
* Serialize cell value in the given content format.
|
|
190
|
+
*
|
|
191
|
+
* @param cellVal cell value
|
|
192
|
+
*
|
|
193
|
+
*/
|
|
194
|
+
serializeCell(cellVal: OINODataCell): string | null | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Parce cell value from string using field type specific formatting rules.
|
|
197
|
+
*
|
|
198
|
+
* @param value string value
|
|
199
|
+
*
|
|
200
|
+
*/
|
|
201
|
+
deserializeCell(value: string | null | undefined): OINODataCell;
|
|
202
|
+
}
|