@oino-ts/common 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/README.md +183 -0
- package/dist/cjs/OINOApi.js +322 -0
- package/dist/cjs/OINOConfig.js +104 -0
- package/dist/cjs/OINOConstants.js +42 -0
- package/dist/cjs/OINODataField.js +346 -0
- package/dist/cjs/OINODataModel.js +182 -0
- package/dist/cjs/OINODataSource.js +165 -0
- package/dist/cjs/OINOFormatter.js +6 -5
- package/dist/cjs/OINOHtmlTemplate.js +21 -18
- package/dist/cjs/OINOModelSet.js +333 -0
- package/dist/cjs/OINOParser.js +448 -0
- package/dist/cjs/OINOQueryParams.js +434 -0
- package/dist/cjs/OINORequest.js +21 -13
- package/dist/cjs/OINOResult.js +13 -12
- package/dist/cjs/OINOStr.js +11 -11
- package/dist/cjs/OINOSwagger.js +205 -0
- package/dist/cjs/index.js +57 -39
- package/dist/esm/OINOApi.js +315 -0
- package/dist/esm/OINOConfig.js +100 -0
- package/dist/esm/OINOConstants.js +39 -0
- package/dist/esm/OINODataField.js +337 -0
- package/dist/esm/OINODataModel.js +178 -0
- package/dist/esm/OINODataSource.js +159 -0
- package/dist/esm/OINOFormatter.js +2 -1
- package/dist/esm/OINOHtmlTemplate.js +4 -1
- package/dist/esm/OINOModelSet.js +329 -0
- package/dist/esm/OINOParser.js +444 -0
- package/dist/esm/OINOQueryParams.js +426 -0
- package/dist/esm/OINORequest.js +9 -1
- package/dist/esm/OINOResult.js +2 -1
- package/dist/esm/OINOStr.js +1 -1
- package/dist/esm/OINOSwagger.js +201 -0
- package/dist/esm/index.js +14 -32
- package/dist/types/OINOApi.d.ts +191 -0
- package/dist/types/OINOConfig.d.ts +63 -0
- package/dist/types/OINOConstants.d.ts +51 -0
- package/dist/types/OINODataField.d.ts +209 -0
- package/dist/types/OINODataModel.d.ts +78 -0
- package/dist/types/OINODataSource.d.ts +184 -0
- package/dist/types/OINOHtmlTemplate.d.ts +1 -1
- package/dist/types/OINOModelSet.d.ts +64 -0
- package/dist/types/OINOParser.d.ts +42 -0
- package/dist/types/OINOQueryParams.d.ts +270 -0
- package/dist/types/OINORequest.d.ts +4 -1
- package/dist/types/OINOResult.d.ts +1 -1
- package/dist/types/OINOStr.d.ts +1 -1
- package/dist/types/OINOSwagger.d.ts +25 -0
- package/dist/types/index.d.ts +14 -31
- package/package.json +32 -32
- package/src/OINOApi.ts +429 -0
- package/src/OINOBenchmark.ts +323 -323
- package/src/OINOConfig.ts +113 -0
- package/src/OINOConstants.ts +59 -0
- package/src/OINODataField.ts +371 -0
- package/src/OINODataModel.ts +187 -0
- package/src/OINODataSource.ts +280 -0
- package/src/OINOFormatter.ts +166 -165
- package/src/OINOHeaders.ts +51 -51
- package/src/OINOHtmlTemplate.test.ts +114 -114
- package/src/OINOHtmlTemplate.ts +225 -222
- package/src/OINOLog.ts +292 -292
- package/src/OINOModelSet.ts +359 -0
- package/src/OINOParser.ts +441 -0
- package/src/OINOQueryParams.ts +449 -0
- package/src/OINORequest.ts +204 -196
- package/src/OINOResult.ts +331 -330
- package/src/OINOStr.ts +254 -254
- package/src/OINOSwagger.ts +213 -0
- package/src/index.ts +18 -38
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { OINODataCell, OINODataRow } from "./OINOConstants.js";
|
|
2
|
+
import { OINOResult } from "./OINOResult.js";
|
|
3
|
+
import { OINOApi } from "./OINOApi.js";
|
|
4
|
+
/**
|
|
5
|
+
* Base class for database abstraction, implementing methods for connecting, making queries and parsing/formatting data
|
|
6
|
+
* between SQL and serialization formats.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class OINODataSource {
|
|
10
|
+
isConnected: boolean;
|
|
11
|
+
isValidated: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Connect to database.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
abstract connect(): Promise<OINOResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Validate connection to database is working.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
abstract validate(): Promise<OINOResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Disconnect from database.
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
abstract disconnect(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Print a table name using database specific SQL escaping.
|
|
29
|
+
*
|
|
30
|
+
* @param sqlTable name of the table
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
abstract printTableName(sqlTable: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Print a column name with correct SQL escaping.
|
|
36
|
+
*
|
|
37
|
+
* @param sqlColumn name of the column
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
abstract printColumnName(sqlColumn: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Print a single data value from serialization using the context of the native data
|
|
43
|
+
* type with the correct SQL escaping.
|
|
44
|
+
*
|
|
45
|
+
* @param cellValue data from sql results
|
|
46
|
+
* @param sqlType native type name for table column
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
abstract printCellAsValue(cellValue: OINODataCell, sqlType: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Print a single string value as valid sql literal
|
|
52
|
+
*
|
|
53
|
+
* @param sqlString string value
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
abstract printStringValue(sqlString: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Parse a single SQL result value for serialization using the context of the native data
|
|
59
|
+
* type.
|
|
60
|
+
*
|
|
61
|
+
* @param sqlValue data from serialization
|
|
62
|
+
* @param sqlType native type name for table column
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
abstract parseValueAsCell(sqlValue: OINODataCell, sqlType: string): OINODataCell;
|
|
66
|
+
/**
|
|
67
|
+
* Initialize a data model by getting the SQL schema and populating OINODataFields of
|
|
68
|
+
* the model.
|
|
69
|
+
*
|
|
70
|
+
* @param api api which data model to initialize.
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
abstract initializeApiDatamodel(api: OINOApi): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Base class for SQL results that can be asynchronously iterated (but
|
|
77
|
+
* not necessarity rewinded). Idea is to handle database specific mechanisms
|
|
78
|
+
* for returning and formatting conventions in the database specific
|
|
79
|
+
* implementation. Data might be in memory or streamed in chunks and
|
|
80
|
+
* `OINODataSet` will serve it out consistently.
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
export declare abstract class OINODataSet extends OINOResult {
|
|
84
|
+
private _data;
|
|
85
|
+
/** Error messages */
|
|
86
|
+
readonly messages: string[];
|
|
87
|
+
/**
|
|
88
|
+
* Constructor for `OINODataSet`.
|
|
89
|
+
*
|
|
90
|
+
* @param data internal database specific data type (constructor will throw if invalid)
|
|
91
|
+
* @param messages error messages from SQL-query
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
constructor(data: unknown, messages?: string[]);
|
|
95
|
+
/**
|
|
96
|
+
* Is data set empty.
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
abstract isEmpty(): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Is there no more content, i.e. either dataset is empty or we have moved beyond last line
|
|
102
|
+
*
|
|
103
|
+
*/
|
|
104
|
+
abstract isEof(): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Attempts to moves dataset to the next row, possibly waiting for more data to become available. Returns !isEof().
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
abstract next(): Promise<boolean>;
|
|
110
|
+
/**
|
|
111
|
+
* Gets current row of data.
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
abstract getRow(): OINODataRow;
|
|
115
|
+
/**
|
|
116
|
+
* Gets all rows of data.
|
|
117
|
+
*
|
|
118
|
+
* NOTE: This is left abstract instead of just using `getRow()` so that DB implementations can hopefully optimize not duplicating data *
|
|
119
|
+
*/
|
|
120
|
+
abstract getAllRows(): Promise<OINODataRow[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Checks if the messages contain errors.
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
hasErrors(): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Finds the first error message that occured
|
|
128
|
+
*
|
|
129
|
+
*/
|
|
130
|
+
getFirstError(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Finds the last error message that occured
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
getLastError(): string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Generic in memory implementation of a data set where data is an array of rows. Used
|
|
139
|
+
* by BunSqlite and automated testing. Can be rewinded.
|
|
140
|
+
*
|
|
141
|
+
*/
|
|
142
|
+
export declare class OINOMemoryDataset extends OINODataSet {
|
|
143
|
+
private _rows;
|
|
144
|
+
private _currentRow;
|
|
145
|
+
private _eof;
|
|
146
|
+
/**
|
|
147
|
+
* Constructor of `OINOMemoryDataset`.
|
|
148
|
+
*
|
|
149
|
+
* @param data data as OINODataRow[] (constructor will throw if invalid)
|
|
150
|
+
* @param errors error messages from SQL-query
|
|
151
|
+
*
|
|
152
|
+
*/
|
|
153
|
+
constructor(data: unknown, errors?: string[]);
|
|
154
|
+
/**
|
|
155
|
+
* Is data set empty.
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
isEmpty(): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Is there no more content, i.e. either dataset is empty or we have moved beyond last line
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
isEof(): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Attempts to moves dataset to the next row, possibly waiting for more data to become available. Returns !isEof().
|
|
166
|
+
*
|
|
167
|
+
*/
|
|
168
|
+
next(): Promise<boolean>;
|
|
169
|
+
/**
|
|
170
|
+
* Gets current row of data.
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
getRow(): OINODataRow;
|
|
174
|
+
/**
|
|
175
|
+
* Gets all rows of data.
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
getAllRows(): Promise<OINODataRow[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Rewinds data set to the first row, returns !isEof().
|
|
181
|
+
*
|
|
182
|
+
*/
|
|
183
|
+
first(): boolean;
|
|
184
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { OINOContentType, OINODataCell } from "./OINOConstants.js";
|
|
2
|
+
import { OINODataSet } from "./OINODataSource.js";
|
|
3
|
+
import { OINODataModel } from "./OINODataModel.js";
|
|
4
|
+
import { OINOQueryParams } from "./OINOQueryParams.js";
|
|
5
|
+
/**
|
|
6
|
+
* Class for dataset based on a data model that can be serialized to
|
|
7
|
+
* a supported format:
|
|
8
|
+
* - JSON (application/json)
|
|
9
|
+
* - CSV (text/csv)
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare class OINOModelSet {
|
|
13
|
+
/** Reference to datamodel */
|
|
14
|
+
readonly datamodel: OINODataModel;
|
|
15
|
+
/** Reference to data set */
|
|
16
|
+
readonly dataset: OINODataSet;
|
|
17
|
+
/** SQL parameters */
|
|
18
|
+
readonly queryParams?: OINOQueryParams;
|
|
19
|
+
/** Collection of errors */
|
|
20
|
+
errors: string[];
|
|
21
|
+
/**
|
|
22
|
+
* Constructor for `OINOModelSet`.
|
|
23
|
+
*
|
|
24
|
+
* @param datamodel data model
|
|
25
|
+
* @param dataset data set
|
|
26
|
+
* @param queryParams SQL parameters
|
|
27
|
+
*/
|
|
28
|
+
constructor(datamodel: OINODataModel, dataset: OINODataSet, queryParams?: OINOQueryParams);
|
|
29
|
+
private _encodeAndHashFieldValue;
|
|
30
|
+
private _writeRowJson;
|
|
31
|
+
private _writeStringJson;
|
|
32
|
+
private _writeHeaderCsv;
|
|
33
|
+
private _writeRowCsv;
|
|
34
|
+
private _writeStringCsv;
|
|
35
|
+
private _writeRowFormdataParameterBlock;
|
|
36
|
+
private _writeRowFormdataFileBlock;
|
|
37
|
+
private _writeRowFormdata;
|
|
38
|
+
private _writeStringFormdata;
|
|
39
|
+
private _writeRowUrlencode;
|
|
40
|
+
private _writeStringUrlencode;
|
|
41
|
+
private _exportRow;
|
|
42
|
+
/**
|
|
43
|
+
* Serialize model set in the given format.
|
|
44
|
+
*
|
|
45
|
+
* @param [contentType=OINOContentType.json] serialization content type
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
writeString(contentType?: OINOContentType): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Get value of given field in the current row. Undefined if no rows,
|
|
51
|
+
* field not found or value does not exist.
|
|
52
|
+
*
|
|
53
|
+
* @param fieldName name of the field
|
|
54
|
+
* @param serialize serialize the value
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
getValueByFieldName(fieldName: string, serialize?: boolean): OINODataCell;
|
|
58
|
+
/**
|
|
59
|
+
* Export all rows as a record with OINOId as key and object with row cells as values.
|
|
60
|
+
*
|
|
61
|
+
* @param idFieldName optional field name to use as key instead of OINOId
|
|
62
|
+
*/
|
|
63
|
+
exportAsRecord(idFieldName?: string): Promise<Record<string, any>>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Buffer } from "node:buffer";
|
|
4
|
+
import { OINOContentType, OINODataRow } from "./OINOConstants.js";
|
|
5
|
+
import { OINODataModel } from "./OINODataModel.js";
|
|
6
|
+
/**
|
|
7
|
+
* Static factory class for easily creating things based on data
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare class OINOParser {
|
|
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: OINODataModel, 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,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported logical conjunctions in filter predicates.
|
|
3
|
+
* @enum
|
|
4
|
+
*/
|
|
5
|
+
export declare enum OINOQueryBooleanOperation {
|
|
6
|
+
and = "and",
|
|
7
|
+
or = "or",
|
|
8
|
+
not = "not"
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Supported logical conjunctions in filter predicates.
|
|
12
|
+
* @enum
|
|
13
|
+
*/
|
|
14
|
+
export declare enum OINOQueryComparison {
|
|
15
|
+
lt = "lt",
|
|
16
|
+
le = "le",
|
|
17
|
+
eq = "eq",
|
|
18
|
+
ne = "ne",
|
|
19
|
+
ge = "ge",
|
|
20
|
+
gt = "gt",
|
|
21
|
+
like = "like"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Supported logical conjunctions in filter predicates.
|
|
25
|
+
* @enum
|
|
26
|
+
*/
|
|
27
|
+
export declare enum OINOQueryNullCheck {
|
|
28
|
+
isnull = "isnull",
|
|
29
|
+
isNotNull = "isNotNull"
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Supported aggregation functions in OINODbQueryAggregate.
|
|
33
|
+
* @enum
|
|
34
|
+
*/
|
|
35
|
+
export declare enum OINOQueryAggregateFunctions {
|
|
36
|
+
count = "count",
|
|
37
|
+
sum = "sum",
|
|
38
|
+
avg = "avg",
|
|
39
|
+
min = "min",
|
|
40
|
+
max = "max"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Class for recursively parsing of filters and printing them as SQL conditions.
|
|
44
|
+
* Supports three types of statements
|
|
45
|
+
* - comparison: (field)-lt|le|eq|ge|gt|like(value)
|
|
46
|
+
* - negation: -not(filter)
|
|
47
|
+
* - conjunction/disjunction: (filter)-and|or(filter)
|
|
48
|
+
* Supported conditions are comparisons (<, <=, =, >=, >) and substring match (LIKE).
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
export declare class OINOQueryFilter {
|
|
52
|
+
protected static _booleanOperationRegex: RegExp;
|
|
53
|
+
protected static _negationRegex: RegExp;
|
|
54
|
+
protected static _filterComparisonRegex: RegExp;
|
|
55
|
+
protected static _filterNullCheckRegex: RegExp;
|
|
56
|
+
readonly leftSide: OINOQueryFilter | string;
|
|
57
|
+
readonly rightSide: OINOQueryFilter | string;
|
|
58
|
+
readonly operator: OINOQueryComparison | OINOQueryBooleanOperation | OINOQueryNullCheck | null;
|
|
59
|
+
/**
|
|
60
|
+
* Constructor of `OINOQueryFilter`
|
|
61
|
+
* @param leftSide left side of the filter, either another filter or a column name
|
|
62
|
+
* @param operation operation of the filter, either `OINOQueryComparison` or `OINOQueryBooleanOperation`
|
|
63
|
+
* @param rightSide right side of the filter, either another filter or a value
|
|
64
|
+
*/
|
|
65
|
+
constructor(leftSide: OINOQueryFilter | string, operation: OINOQueryComparison | OINOQueryBooleanOperation | OINOQueryNullCheck | null, rightSide: OINOQueryFilter | string);
|
|
66
|
+
/**
|
|
67
|
+
* Constructor for `OINOQueryFilter` as parser of http parameter.
|
|
68
|
+
*
|
|
69
|
+
* Supports three types of statements:
|
|
70
|
+
* - comparison: (field)-lt|le|eq|ge|gt|like(value)
|
|
71
|
+
* - negation: -not(filter)
|
|
72
|
+
* - conjunction/disjunction: (filter)-and|or(filter)
|
|
73
|
+
* - null check: -isnull(field) or -isNotNull(field)
|
|
74
|
+
*
|
|
75
|
+
* @param filterString string representation of filter from HTTP-request
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
static parse(filterString: string): OINOQueryFilter;
|
|
79
|
+
/**
|
|
80
|
+
* Construct a new `OINOQueryFilter` as combination of (boolean and/or) of two filters.
|
|
81
|
+
*
|
|
82
|
+
* @param leftSide left side to combine
|
|
83
|
+
* @param operation boolean operation to use in combination
|
|
84
|
+
* @param rightSide right side to combine
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
static combine(leftSide: OINOQueryFilter | undefined, operation: OINOQueryBooleanOperation, rightSide: OINOQueryFilter | undefined): OINOQueryFilter | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Combine two filters with an AND operation.
|
|
90
|
+
*
|
|
91
|
+
* @param leftSide left side filter
|
|
92
|
+
* @param rightSide right side filter
|
|
93
|
+
*
|
|
94
|
+
*/
|
|
95
|
+
static and(leftSide: OINOQueryFilter, rightSide: OINOQueryFilter): OINOQueryFilter | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Combine two filters with an OR operation.
|
|
98
|
+
*
|
|
99
|
+
* @param leftSide left side filter
|
|
100
|
+
* @param rightSide right side filter
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
static or(leftSide: OINOQueryFilter, rightSide: OINOQueryFilter): OINOQueryFilter | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Negate a filter with a NOT operation.
|
|
106
|
+
*
|
|
107
|
+
* @param leftSide left side filter
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
static not(leftSide: OINOQueryFilter): OINOQueryFilter | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Does filter contain any valid conditions.
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
isEmpty(): boolean;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Class for ordering select results on a number of columns.
|
|
119
|
+
*
|
|
120
|
+
*/
|
|
121
|
+
export declare class OINOQueryOrder {
|
|
122
|
+
protected static _orderColumnRegex: RegExp;
|
|
123
|
+
readonly columns: string[];
|
|
124
|
+
readonly descending: boolean[];
|
|
125
|
+
/**
|
|
126
|
+
* Constructor for `OINOQueryOrder`.
|
|
127
|
+
*
|
|
128
|
+
* @param column_or_array single or array of columns to order on
|
|
129
|
+
* @param descending_or_array single or array of booleans if ordes is descending
|
|
130
|
+
*
|
|
131
|
+
*/
|
|
132
|
+
constructor(column_or_array: string[] | string, descending_or_array: boolean[] | boolean);
|
|
133
|
+
/**
|
|
134
|
+
* Constructor for `OINOQueryOrder` as parser of http parameter.
|
|
135
|
+
*
|
|
136
|
+
* Supports comma separated list of column orders formatted as :
|
|
137
|
+
* - `column` - order by column in ascending order
|
|
138
|
+
* - `column ASC|DESC` - order by single either ascending or descending order
|
|
139
|
+
* - `column+|-` - order by single either ascending or descending order
|
|
140
|
+
*
|
|
141
|
+
* @param orderString string representation of order from HTTP-request
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
static parse(orderString: string): OINOQueryOrder;
|
|
145
|
+
/**
|
|
146
|
+
* Does filter contain any valid conditions.
|
|
147
|
+
*
|
|
148
|
+
*/
|
|
149
|
+
isEmpty(): boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Class for limiting the number of results.
|
|
153
|
+
*
|
|
154
|
+
*/
|
|
155
|
+
export declare class OINOQueryLimit {
|
|
156
|
+
protected static _limitRegex: RegExp;
|
|
157
|
+
readonly limit: number;
|
|
158
|
+
readonly page: number;
|
|
159
|
+
/**
|
|
160
|
+
* Constructor for `OINOQueryLimit`.
|
|
161
|
+
*
|
|
162
|
+
* @param limit maximum number of items to return
|
|
163
|
+
* @param page page number to return starting from 1
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
constructor(limit: number, page?: number);
|
|
167
|
+
/**
|
|
168
|
+
* Constructor for `OINOQueryLimit` as parser of http parameter.
|
|
169
|
+
*
|
|
170
|
+
* Supports limit and page formatted as:
|
|
171
|
+
* - `limit` - limit number of items to return
|
|
172
|
+
* - `limit page n` - limit number of items to return and return page n (starting from 1)
|
|
173
|
+
* - `limit.n` - limit number of items to return and return page n (starting from 1)
|
|
174
|
+
*
|
|
175
|
+
* @param limitString string representation of limit from HTTP-request
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
static parse(limitString: string): OINOQueryLimit;
|
|
179
|
+
/**
|
|
180
|
+
* Does filter contain any valid conditions.
|
|
181
|
+
*
|
|
182
|
+
*/
|
|
183
|
+
isEmpty(): boolean;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Class for limiting the number of results.
|
|
187
|
+
*
|
|
188
|
+
*/
|
|
189
|
+
export declare class OINOQueryAggregate {
|
|
190
|
+
protected static _aggregateRegex: RegExp;
|
|
191
|
+
readonly functions: OINOQueryAggregateFunctions[];
|
|
192
|
+
readonly fields: string[];
|
|
193
|
+
/**
|
|
194
|
+
* Constructor for `OINOQueryAggregate`.
|
|
195
|
+
*
|
|
196
|
+
* @param functions aggregate function to use
|
|
197
|
+
* @param fields fields to aggregate
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
constructor(functions: OINOQueryAggregateFunctions[], fields: string[]);
|
|
201
|
+
/**
|
|
202
|
+
* Constructor for `OINOQueryAggregate` as parser of http parameter.
|
|
203
|
+
*
|
|
204
|
+
* Supports comma separated list of aggregates formatted as:
|
|
205
|
+
* - `function(field)`
|
|
206
|
+
*
|
|
207
|
+
* Supported functions are count, sum, avg, min, max.
|
|
208
|
+
*
|
|
209
|
+
* @param aggregatorString string representation of limit from HTTP-request
|
|
210
|
+
*
|
|
211
|
+
*/
|
|
212
|
+
static parse(aggregatorString: string): OINOQueryAggregate;
|
|
213
|
+
/**
|
|
214
|
+
* Does filter contain any valid conditions.
|
|
215
|
+
*
|
|
216
|
+
*/
|
|
217
|
+
isEmpty(): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Does filter contain any valid conditions.
|
|
220
|
+
*
|
|
221
|
+
* @param field field to check if it is aggregated
|
|
222
|
+
*/
|
|
223
|
+
isAggregated(field: string): boolean;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Class for ordering select results on a number of columns.
|
|
227
|
+
*
|
|
228
|
+
*/
|
|
229
|
+
export declare class OINOQuerySelect {
|
|
230
|
+
readonly columns: string[];
|
|
231
|
+
/**
|
|
232
|
+
* Constructor for `OINOQuerySelect`.
|
|
233
|
+
*
|
|
234
|
+
* @param columns array of columns to select
|
|
235
|
+
*
|
|
236
|
+
*/
|
|
237
|
+
constructor(columns: string[]);
|
|
238
|
+
/**
|
|
239
|
+
* Constructor for `OINOQuerySelect` as parser of http parameter.
|
|
240
|
+
*
|
|
241
|
+
* @param columns comma separated string selected columns from HTTP-request
|
|
242
|
+
*
|
|
243
|
+
*/
|
|
244
|
+
static parse(columns: string): OINOQuerySelect;
|
|
245
|
+
/**
|
|
246
|
+
* Does select contain any valid columns.
|
|
247
|
+
*
|
|
248
|
+
*/
|
|
249
|
+
isEmpty(): boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Does select include given column.
|
|
252
|
+
*
|
|
253
|
+
* @param field field to check if it is selected
|
|
254
|
+
*
|
|
255
|
+
*/
|
|
256
|
+
isSelected(field: string): boolean;
|
|
257
|
+
}
|
|
258
|
+
/** Request options */
|
|
259
|
+
export type OINOQueryParams = {
|
|
260
|
+
/** Additional SQL select where-conditions */
|
|
261
|
+
filter?: OINOQueryFilter;
|
|
262
|
+
/** SQL result ordering conditions */
|
|
263
|
+
order?: OINOQueryOrder;
|
|
264
|
+
/** SQL result limit condition */
|
|
265
|
+
limit?: OINOQueryLimit;
|
|
266
|
+
/** SQL aggregation functions */
|
|
267
|
+
aggregate?: OINOQueryAggregate;
|
|
268
|
+
/** SQL select condition */
|
|
269
|
+
select?: OINOQuerySelect;
|
|
270
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
|
-
import { OINOContentType
|
|
4
|
+
import { OINOContentType } from "./OINOConstants.js";
|
|
5
|
+
import { OINOHeaders, type OINOHeadersInit } from "./OINOHeaders.js";
|
|
5
6
|
export interface OINORequestInit {
|
|
6
7
|
params?: Record<string, string>;
|
|
7
8
|
}
|
|
@@ -29,6 +30,7 @@ export interface OINOHttpRequestInit extends OINORequestInit {
|
|
|
29
30
|
body?: OINOHttpData;
|
|
30
31
|
requestType?: OINOContentType;
|
|
31
32
|
responseType?: OINOContentType;
|
|
33
|
+
responseDownload?: string;
|
|
32
34
|
multipartBoundary?: string;
|
|
33
35
|
lastModified?: number;
|
|
34
36
|
}
|
|
@@ -42,6 +44,7 @@ export declare class OINOHttpRequest extends OINORequest {
|
|
|
42
44
|
body: OINOHttpData;
|
|
43
45
|
requestType: OINOContentType;
|
|
44
46
|
responseType: OINOContentType;
|
|
47
|
+
responseDownload?: string;
|
|
45
48
|
multipartBoundary?: string;
|
|
46
49
|
lastModified?: number;
|
|
47
50
|
etags?: string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
|
-
import { OINOHeaders, OINOHeadersInit } from ".";
|
|
4
|
+
import { OINOHeaders, type OINOHeadersInit } from "./OINOHeaders.js";
|
|
5
5
|
export interface OINOResultInit {
|
|
6
6
|
success?: boolean;
|
|
7
7
|
status?: number;
|
package/dist/types/OINOStr.d.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { OINOApi } from "./OINOApi.js";
|
|
2
|
+
/**
|
|
3
|
+
* Static class for Swagger utilities
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export declare class OINOSwagger {
|
|
7
|
+
private static _getSchemaApiMethodParamsQueryId;
|
|
8
|
+
private static _getSchemaApiMethodParamsBody;
|
|
9
|
+
private static _getSchemaApiMethodDescription;
|
|
10
|
+
private static _getSchemaApiMethodOperationId;
|
|
11
|
+
private static _getSchemaOinoResponse;
|
|
12
|
+
private static _getSchemaFieldType;
|
|
13
|
+
private static _getSwaggerApiType;
|
|
14
|
+
private static _getSchemaType;
|
|
15
|
+
private static _getSchemaApiMethodParams;
|
|
16
|
+
private static _getSchemaApiMethod;
|
|
17
|
+
private static _getSwaggerApiPath;
|
|
18
|
+
/**
|
|
19
|
+
* Returns swagger.json as object of the given API's.
|
|
20
|
+
*
|
|
21
|
+
* @param apis array of API's use for Swagger definition
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
static getApiDefinition(apis: OINOApi[]): any;
|
|
25
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
|
+
export { OINOApi, OINOApiRequest, OINOApiResult, OINOApiHtmlTemplate, type OINOApiParams, type OINOApiData, type OINOApiRequestInit } from "./OINOApi.js";
|
|
1
2
|
export { OINOBenchmark, OINOMemoryBenchmark } from "./OINOBenchmark.js";
|
|
3
|
+
export { OINOConfig } from "./OINOConfig.js";
|
|
4
|
+
export { OINO_ERROR_PREFIX, OINO_WARNING_PREFIX, OINO_INFO_PREFIX, OINO_DEBUG_PREFIX, OINO_REQUEST_TYPE_PARAM, OINO_RESPONSE_TYPE_PARAM, OINOContentType, type OINODataFieldParams, type OINODataCell, type OINODataRow, OINO_EMPTY_ROW, OINO_EMPTY_ROWS } from "./OINOConstants.js";
|
|
5
|
+
export { OINODataModel } from "./OINODataModel.js";
|
|
6
|
+
export { OINODataSource, OINODataSet, OINOMemoryDataset } from "./OINODataSource.js";
|
|
7
|
+
export { OINODataField, OINOStringDataField, OINONumberDataField, OINOBooleanDataField, OINODatetimeDataField, OINOBlobDataField, type OINODataFieldFilter } from "./OINODataField.js";
|
|
8
|
+
export { OINOFormatter, OINO_EMPTY_FORMATTER } from "./OINOFormatter.js";
|
|
9
|
+
export { OINOHeaders, type OINOHeadersInit } from "./OINOHeaders.js";
|
|
10
|
+
export { OINOHtmlTemplate } from "./OINOHtmlTemplate.js";
|
|
2
11
|
export { OINOLog, OINOLogLevel, OINOConsoleLog } from "./OINOLog.js";
|
|
3
|
-
export {
|
|
12
|
+
export { OINOModelSet } from "./OINOModelSet.js";
|
|
13
|
+
export { OINOParser } from "./OINOParser.js";
|
|
14
|
+
export { OINOQueryBooleanOperation, OINOQueryComparison, OINOQueryNullCheck, OINOQueryAggregateFunctions, OINOQuerySelect, OINOQueryFilter, OINOQueryOrder, OINOQueryLimit, OINOQueryAggregate, type OINOQueryParams } from "./OINOQueryParams.js";
|
|
4
15
|
export { OINORequest, OINOHttpRequest, type OINOHttpData, type OINORequestInit, type OINOHttpRequestInit } from "./OINORequest.js";
|
|
16
|
+
export { OINOResult, OINOHttpResult, type OINOResultInit, type OINOHttpResultInit } from "./OINOResult.js";
|
|
5
17
|
export { OINOStr } from "./OINOStr.js";
|
|
6
|
-
export {
|
|
7
|
-
export { OINOFormatter, OINO_EMPTY_FORMATTER } from "./OINOFormatter.js";
|
|
8
|
-
export { OINOHeaders, type OINOHeadersInit } from "./OINOHeaders.js";
|
|
9
|
-
/** OINO error message prefix */
|
|
10
|
-
export declare const OINO_ERROR_PREFIX = "OINO ERROR";
|
|
11
|
-
/** OINO warning message prefix */
|
|
12
|
-
export declare const OINO_WARNING_PREFIX = "OINO WARNING";
|
|
13
|
-
/** OINO info message prefix */
|
|
14
|
-
export declare const OINO_INFO_PREFIX = "OINO INFO";
|
|
15
|
-
/** OINO debug message prefix */
|
|
16
|
-
export declare const OINO_DEBUG_PREFIX = "OINO DEBUG";
|
|
17
|
-
/** Name of the OINOContentType-parameter request */
|
|
18
|
-
export declare const OINO_REQUEST_TYPE_PARAM = "oinorequesttype";
|
|
19
|
-
/** Name of the OINOContentType-parameter request */
|
|
20
|
-
export declare const OINO_RESPONSE_TYPE_PARAM = "oinoresponsetype";
|
|
21
|
-
/**
|
|
22
|
-
* Supported content format mime-types
|
|
23
|
-
*/
|
|
24
|
-
export declare enum OINOContentType {
|
|
25
|
-
/** JSON encoded data */
|
|
26
|
-
json = "application/json",
|
|
27
|
-
/** CSV encoded data */
|
|
28
|
-
csv = "text/csv",
|
|
29
|
-
/** Multipart encoded form data */
|
|
30
|
-
formdata = "multipart/form-data",
|
|
31
|
-
/** URL encoded form data */
|
|
32
|
-
urlencode = "application/x-www-form-urlencoded",
|
|
33
|
-
/** HTML encoded data (output only) */
|
|
34
|
-
html = "text/html"
|
|
35
|
-
}
|
|
18
|
+
export { OINOSwagger } from "./OINOSwagger.js";
|