@oino-ts/types 0.21.2 → 1.0.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/blob/src/OINOBlob.d.ts +78 -0
- package/blob/src/OINOBlobApi.d.ts +49 -0
- package/blob/src/OINOBlobConstants.d.ts +37 -0
- package/blob/src/OINOBlobDataModel.d.ts +33 -0
- package/blob/src/OINOBlobFactory.d.ts +40 -0
- package/blob/src/index.d.ts +5 -0
- package/blob-aws/src/OINOBlobAwsS3.d.ts +90 -0
- package/blob-aws/src/index.d.ts +1 -0
- package/blob-azure/src/OINOBlobAzureTable.d.ts +86 -0
- package/blob-azure/src/index.d.ts +1 -0
- package/common/src/OINOApi.d.ts +191 -0
- package/common/src/OINOConfig.d.ts +63 -0
- package/common/src/OINOConstants.d.ts +51 -0
- package/common/src/OINODataField.d.ts +209 -0
- package/common/src/OINODataModel.d.ts +78 -0
- package/common/src/OINODataSource.d.ts +184 -0
- package/common/src/OINOHtmlTemplate.d.ts +1 -1
- package/common/src/OINOModelSet.d.ts +64 -0
- package/common/src/OINOParser.d.ts +42 -0
- package/common/src/OINOQueryParams.d.ts +270 -0
- package/common/src/OINORequest.d.ts +4 -1
- package/common/src/OINOResult.d.ts +1 -1
- package/common/src/OINOStr.d.ts +1 -1
- package/common/src/OINOSwagger.d.ts +25 -0
- package/common/src/index.d.ts +14 -31
- package/db/src/OINODb.d.ts +55 -0
- package/db/src/OINODbApi.d.ts +78 -0
- package/db/src/OINODbConfig.d.ts +56 -0
- package/db/src/OINODbConstants.d.ts +23 -0
- package/db/src/OINODbDataField.d.ts +210 -0
- package/db/src/OINODbDataModel.d.ts +55 -0
- package/db/src/OINODbDataSet.d.ts +95 -0
- package/db/src/OINODbFactory.d.ts +34 -0
- package/db/src/OINODbModelSet.d.ts +62 -0
- package/db/src/OINODbParser.d.ts +42 -0
- package/db/src/OINODbQueryParams.d.ts +72 -0
- package/db/src/OINODbRequestParams.d.ts +146 -0
- package/db/src/OINODbSqlParams.d.ts +296 -0
- package/db/src/OINODbSwagger.d.ts +25 -0
- package/db/src/index.d.ts +6 -0
- package/db-bunsqlite/src/OINODbBunSqlite.d.ts +99 -0
- package/db-bunsqlite/src/index.d.ts +1 -0
- package/db-mariadb/src/OINODbMariadb.d.ts +99 -0
- package/db-mariadb/src/index.d.ts +1 -0
- package/db-mssql/src/OINODbMsSql.d.ts +116 -0
- package/db-mssql/src/index.d.ts +1 -0
- package/db-postgresql/src/OINODbPostgresql.d.ts +95 -0
- package/db-postgresql/src/index.d.ts +1 -0
- package/hashid/src/OINOHashid.d.ts +42 -0
- package/hashid/src/index.d.ts +1 -0
- package/index.d.ts +7 -7
- package/nosql/src/OINONoSql.d.ts +81 -0
- package/nosql/src/OINONoSqlApi.d.ts +67 -0
- package/nosql/src/OINONoSqlConstants.d.ts +34 -0
- package/nosql/src/OINONoSqlDataModel.d.ts +29 -0
- package/nosql/src/OINONoSqlFactory.d.ts +40 -0
- package/nosql/src/index.d.ts +5 -0
- package/nosql-aws/src/OINONoSqlAwsDynamo.d.ts +223 -0
- package/nosql-aws/src/index.d.ts +1 -0
- package/nosql-azure/src/OINONoSqlAzureTable.d.ts +130 -0
- package/nosql-azure/src/index.d.ts +1 -0
- package/package.json +28 -28
|
@@ -0,0 +1,210 @@
|
|
|
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
|
+
* Serialize cell value in the given content format.
|
|
197
|
+
*
|
|
198
|
+
* @param cellVal cell value
|
|
199
|
+
* @param locale locale-object to format datetimes with
|
|
200
|
+
*
|
|
201
|
+
*/
|
|
202
|
+
serializeCellWithLocale(cellVal: OINODataCell, locale: Intl.DateTimeFormat): string | null | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Parce cell value from string using field type specific formatting rules.
|
|
205
|
+
*
|
|
206
|
+
* @param value string value
|
|
207
|
+
*
|
|
208
|
+
*/
|
|
209
|
+
deserializeCell(value: string | null | undefined): OINODataCell;
|
|
210
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { OINODataModel, OINODataField, OINODataRow, OINOQueryParams } from "@oino-ts/common";
|
|
2
|
+
import { OINODbApi } from "./OINODbApi.js";
|
|
3
|
+
/**
|
|
4
|
+
* OINO Datamodel object for representing one database table and it's columns.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export declare class OINODbDataModel extends OINODataModel {
|
|
8
|
+
/** Database refererence of the table */
|
|
9
|
+
readonly dbApi: OINODbApi;
|
|
10
|
+
/** Field refererences of the API */
|
|
11
|
+
readonly fields: OINODataField[];
|
|
12
|
+
/**
|
|
13
|
+
* Constructor of the data model.
|
|
14
|
+
* NOTE! OINODbDataModel.initialize must be called after constructor to populate fields.
|
|
15
|
+
*
|
|
16
|
+
* @param api api of the data model
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
constructor(api: OINODbApi);
|
|
20
|
+
private _printColumnNames;
|
|
21
|
+
private _printSqlInsertColumnsAndValues;
|
|
22
|
+
private _printSqlUpdateValues;
|
|
23
|
+
private _printSqlPrimaryKeyCondition;
|
|
24
|
+
private _printSqlPrimaryKeyColumns;
|
|
25
|
+
/**
|
|
26
|
+
* Print SQL select statement using optional id and filter.
|
|
27
|
+
*
|
|
28
|
+
* @param id OINO ID (i.e. combined primary key values)
|
|
29
|
+
* @param params OINO reqest params
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
printSqlSelect(id: string, params: OINOQueryParams): string;
|
|
33
|
+
/**
|
|
34
|
+
* Print SQL insert statement from one data row.
|
|
35
|
+
*
|
|
36
|
+
* @param row one row of data in the data model
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
printSqlInsert(row: OINODataRow): string;
|
|
40
|
+
/**
|
|
41
|
+
* Print SQL insert statement from one data row.
|
|
42
|
+
*
|
|
43
|
+
* @param id OINO ID (i.e. combined primary key values)
|
|
44
|
+
* @param row one row of data in the data model
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
printSqlUpdate(id: string, row: OINODataRow): string;
|
|
48
|
+
/**
|
|
49
|
+
* Print SQL delete statement for id.
|
|
50
|
+
*
|
|
51
|
+
* @param id OINO ID (i.e. combined primary key values)
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
printSqlDelete(id: string): string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { OINODataRow } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for SQL results that can be asynchronously iterated (but
|
|
4
|
+
* not necessarity rewinded). Idea is to handle database specific mechanisms
|
|
5
|
+
* for returning and formatting conventions in the database specific
|
|
6
|
+
* implementation. Data might be in memory or streamed in chunks and
|
|
7
|
+
* `OINODbDataSet` will serve it out consistently.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class OINODbDataSet {
|
|
11
|
+
private _data;
|
|
12
|
+
/** Error messages */
|
|
13
|
+
readonly messages: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Constructor for `OINODbDataSet`.
|
|
16
|
+
*
|
|
17
|
+
* @param data internal database specific data type (constructor will throw if invalid)
|
|
18
|
+
* @param messages error messages from SQL-query
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
constructor(data: unknown, messages?: string[]);
|
|
22
|
+
/**
|
|
23
|
+
* Is data set empty.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
abstract isEmpty(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Is there no more content, i.e. either dataset is empty or we have moved beyond last line
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
abstract isEof(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Attempts to moves dataset to the next row, possibly waiting for more data to become available. Returns !isEof().
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
abstract next(): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets current row of data.
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
abstract getRow(): OINODataRow;
|
|
42
|
+
/**
|
|
43
|
+
* Checks if the messages contain errors.
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
hasErrors(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the messages contain errors.
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
getFirstError(): string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Generic in memory implementation of a data set where data is an array of rows. Used
|
|
55
|
+
* by BunSqlite and automated testing. Can be rewinded.
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
export declare class OINODbMemoryDataSet extends OINODbDataSet {
|
|
59
|
+
private _rows;
|
|
60
|
+
private _currentRow;
|
|
61
|
+
private _eof;
|
|
62
|
+
/**
|
|
63
|
+
* Constructor of `OINODbMemoryDataSet`.
|
|
64
|
+
*
|
|
65
|
+
* @param data data as OINODataRow[] (constructor will throw if invalid)
|
|
66
|
+
* @param errors error messages from SQL-query
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
constructor(data: unknown, errors?: string[]);
|
|
70
|
+
/**
|
|
71
|
+
* Is data set empty.
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
isEmpty(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Is there no more content, i.e. either dataset is empty or we have moved beyond last line
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
isEof(): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Attempts to moves dataset to the next row, possibly waiting for more data to become available. Returns !isEof().
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
next(): Promise<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
* Gets current row of data.
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
getRow(): OINODataRow;
|
|
90
|
+
/**
|
|
91
|
+
* Rewinds data set to the first row, returns !isEof().
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
first(): boolean;
|
|
95
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { OINOApiParams } from "@oino-ts/common";
|
|
2
|
+
import { OINODbParams, OINODbConstructor } from "./OINODbConstants.js";
|
|
3
|
+
import { OINODbApi } from "./OINODbApi.js";
|
|
4
|
+
import { OINODb } from "./OINODb.js";
|
|
5
|
+
/**
|
|
6
|
+
* Static factory class for easily creating things based on data
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare class OINODbFactory {
|
|
10
|
+
private static _dbRegistry;
|
|
11
|
+
/**
|
|
12
|
+
* Register a supported database class. Used to enable those that are installed in the factory
|
|
13
|
+
* instead of forcing everyone to install all database libraries.
|
|
14
|
+
*
|
|
15
|
+
* @param dbName name of the database implementation class
|
|
16
|
+
* @param dbTypeClass constructor for creating a database of that type
|
|
17
|
+
*/
|
|
18
|
+
static registerDb(dbName: string, dbTypeClass: OINODbConstructor): void;
|
|
19
|
+
/**
|
|
20
|
+
* Create database from parameters from the registered classes.
|
|
21
|
+
*
|
|
22
|
+
* @param params database connection parameters
|
|
23
|
+
* @param connect if true, connects to the database
|
|
24
|
+
* @param validate if true, validates the database connection
|
|
25
|
+
*/
|
|
26
|
+
static createDb(params: OINODbParams, connect?: boolean, validate?: boolean): Promise<OINODb>;
|
|
27
|
+
/**
|
|
28
|
+
* Create API from parameters and calls initDatamodel on the datamodel.
|
|
29
|
+
*
|
|
30
|
+
* @param db databased used in API
|
|
31
|
+
* @param params parameters of the API
|
|
32
|
+
*/
|
|
33
|
+
static createApi(db: OINODb, params: OINOApiParams): Promise<OINODbApi>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { OINOContentType } from "@oino-ts/common";
|
|
2
|
+
import { OINODbDataSet, OINODbDataModel, OINODataCell, OINODbSqlParams } from "./index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Class for dataset based on a data model that can be serialized to
|
|
5
|
+
* a supported format:
|
|
6
|
+
* - JSON (application/json)
|
|
7
|
+
* - CSV (text/csv)
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare class OINODbModelSet {
|
|
11
|
+
/** Reference to datamodel */
|
|
12
|
+
readonly datamodel: OINODbDataModel;
|
|
13
|
+
/** Reference to data set */
|
|
14
|
+
readonly dataset: OINODbDataSet;
|
|
15
|
+
/** SQL parameters */
|
|
16
|
+
readonly sqlParams?: OINODbSqlParams;
|
|
17
|
+
/** Collection of errors */
|
|
18
|
+
errors: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Constructor for `OINODbModelSet`.
|
|
21
|
+
*
|
|
22
|
+
* @param datamodel data model
|
|
23
|
+
* @param dataset data set
|
|
24
|
+
* @param sqlParams SQL parameters
|
|
25
|
+
*/
|
|
26
|
+
constructor(datamodel: OINODbDataModel, dataset: OINODbDataSet, sqlParams?: OINODbSqlParams);
|
|
27
|
+
private _encodeAndHashFieldValue;
|
|
28
|
+
private _writeRowJson;
|
|
29
|
+
private _writeStringJson;
|
|
30
|
+
private _writeHeaderCsv;
|
|
31
|
+
private _writeRowCsv;
|
|
32
|
+
private _writeStringCsv;
|
|
33
|
+
private _writeRowFormdataParameterBlock;
|
|
34
|
+
private _writeRowFormdataFileBlock;
|
|
35
|
+
private _writeRowFormdata;
|
|
36
|
+
private _writeStringFormdata;
|
|
37
|
+
private _writeRowUrlencode;
|
|
38
|
+
private _writeStringUrlencode;
|
|
39
|
+
private _exportRow;
|
|
40
|
+
/**
|
|
41
|
+
* Serialize model set in the given format.
|
|
42
|
+
*
|
|
43
|
+
* @param [contentType=OINOContentType.json] serialization content type
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
writeString(contentType?: OINOContentType): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Get value of given field in the current row. Undefined if no rows,
|
|
49
|
+
* field not found or value does not exist.
|
|
50
|
+
*
|
|
51
|
+
* @param fieldName name of the field
|
|
52
|
+
* @param serialize serialize the value
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
getValueByFieldName(fieldName: string, serialize?: boolean): OINODataCell;
|
|
56
|
+
/**
|
|
57
|
+
* Export all rows as a record with OINOId as key and object with row cells as values.
|
|
58
|
+
*
|
|
59
|
+
* @param idFieldName optional field name to use as key instead of OINOId
|
|
60
|
+
*/
|
|
61
|
+
exportAsRecord(idFieldName?: string): Promise<Record<string, any>>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Buffer } from "node:buffer";
|
|
4
|
+
import { OINOContentType } from "@oino-ts/common";
|
|
5
|
+
import { OINODbDataModel, OINODataRow } from "./index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Static factory class for easily creating things based on data
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare class OINODbParser {
|
|
11
|
+
/**
|
|
12
|
+
* Create data rows from request body based on the datamodel.
|
|
13
|
+
*
|
|
14
|
+
* @param datamodel datamodel of the api
|
|
15
|
+
* @param data data as either serialized string or unserialized JS object or OINODataRow-array or Buffer/Uint8Array binary data
|
|
16
|
+
* @param contentType content type of the data
|
|
17
|
+
* @param multipartBoundary multipart boundary for formdata parsing, if applicable
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
static createRows(datamodel: OINODbDataModel, data: string | object | Buffer | Uint8Array, contentType: OINOContentType, multipartBoundary?: string): OINODataRow[];
|
|
21
|
+
private static _createRowsFromText;
|
|
22
|
+
private static _createRowsFromBlob;
|
|
23
|
+
/**
|
|
24
|
+
* Create one data row from javascript object based on the datamodel.
|
|
25
|
+
* NOTE! Data assumed to be unserialized i.e. of the native type (string, number, boolean, Buffer)
|
|
26
|
+
*
|
|
27
|
+
* @param datamodel datamodel of the api
|
|
28
|
+
* @param data data as javascript object
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
private static _createRowFromObject;
|
|
32
|
+
private static _findCsvLineEnd;
|
|
33
|
+
private static _parseCsvLine;
|
|
34
|
+
private static _createRowFromCsv;
|
|
35
|
+
private static _createRowFromJsonObj;
|
|
36
|
+
private static _createRowFromJson;
|
|
37
|
+
private static _findMultipartBoundary;
|
|
38
|
+
private static _parseMultipartLine;
|
|
39
|
+
private static _multipartHeaderRegex;
|
|
40
|
+
private static _createRowFromFormdata;
|
|
41
|
+
private static _createRowFromUrlencoded;
|
|
42
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { OINOQueryFilter, OINOQueryOrder, OINOQueryLimit, OINOQueryAggregate, OINOQuerySelect, OINODataModel } from "@oino-ts/common";
|
|
2
|
+
import { OINODbDataModel } from "./OINODbDataModel.js";
|
|
3
|
+
/**
|
|
4
|
+
* Class for recursively parsing of filters and printing them as SQL conditions.
|
|
5
|
+
* Supports three types of statements
|
|
6
|
+
* - comparison: (field)-lt|le|eq|ge|gt|like(value)
|
|
7
|
+
* - negation: -not(filter)
|
|
8
|
+
* - conjunction/disjunction: (filter)-and|or(filter)
|
|
9
|
+
* Supported conditions are comparisons (<, <=, =, >=, >) and substring match (LIKE).
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare class OINODbQueryFilter extends OINOQueryFilter {
|
|
13
|
+
private static operatorToSql;
|
|
14
|
+
/**
|
|
15
|
+
* Print filter as SQL condition based on the datamodel of the API.
|
|
16
|
+
*
|
|
17
|
+
* @param dataModel data model (and database) to use for formatting of values
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
static printSql(filter: OINOQueryFilter, dataModel: OINODbDataModel): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Class for ordering select results on a number of columns.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export declare class OINODbQueryOrder extends OINOQueryOrder {
|
|
27
|
+
/**
|
|
28
|
+
* Print order as SQL condition based on the datamodel of the API.
|
|
29
|
+
*
|
|
30
|
+
* @param order order instance
|
|
31
|
+
* @param dataModel data model (and database) to use for formatting of values
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
static printSql(order: OINOQueryOrder, dataModel: OINODbDataModel): string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Class for limiting the number of results.
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
export declare class OINODbQueryLimit extends OINOQueryLimit {
|
|
41
|
+
/**
|
|
42
|
+
* Print order as SQL condition based on the datamodel of the API.
|
|
43
|
+
*
|
|
44
|
+
* @param limit limit instance
|
|
45
|
+
* @param dataModel data model (and database) to use for formatting of values
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
static printSql(limit: OINOQueryLimit, dataModel: OINODbDataModel): string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Class for limiting the number of results.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
export declare class OINODbQueryAggregate extends OINOQueryAggregate {
|
|
55
|
+
/**
|
|
56
|
+
* Print non-aggregated fields as SQL GROUP BY-condition based on the datamodel of the API.
|
|
57
|
+
*
|
|
58
|
+
* @param aggregate aggregate instance
|
|
59
|
+
* @param dataModel data model (and database) to use for formatting of values
|
|
60
|
+
* @param select what fields to select
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
static printSql(aggregate: OINOQueryAggregate, dataModel: OINODataModel, select?: OINOQuerySelect): string;
|
|
64
|
+
/**
|
|
65
|
+
* Print non-aggregated fields as SQL GROUP BY-condition based on the datamodel of the API.
|
|
66
|
+
*
|
|
67
|
+
* @param dataModel data model (and database) to use for formatting of values
|
|
68
|
+
* @param select what fields to select
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
static printColumnNames(aggregate: OINOQueryAggregate, dataModel: OINODataModel, select?: OINOQuerySelect): string;
|
|
72
|
+
}
|