@oino-ts/types 0.3.3 → 0.3.4

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/index.d.ts CHANGED
@@ -1,23 +1,23 @@
1
- /// <reference path="db/src/index.d.ts
2
- /// <reference path="db/src/OINODb.d.ts
3
- /// <reference path="db/src/OINODbApi.d.ts
4
- /// <reference path="db/src/OINODbConfig.d.ts
5
- /// <reference path="db/src/OINODbDataField.d.ts
6
- /// <reference path="db/src/OINODbDataModel.d.ts
7
- /// <reference path="db/src/OINODbFactory.d.ts
8
- /// <reference path="db/src/OINODbModelSet.d.ts
9
- /// <reference path="db/src/OINODbRequestParams.d.ts
10
- /// <reference path="db/src/OINODbSqlParams.d.ts
11
- /// <reference path="db/src/OINODbSwagger.d.ts
12
- /// <reference path="db/src/OINODbParser.d.ts
13
- /// <reference path="db-bunsqlite/src/OINODbBunSqlite.d.ts
14
- /// <reference path="db-mariadb/src/OINODbMariadb.d.ts
15
- /// <reference path="db-mssql/src/OINODbMsSql.d.ts
16
- /// <reference path="db-postgresql/src/OINODbPostgresql.d.ts
17
- /// <reference path="hashid/src/OINOHashid.d.ts
18
- /// <reference path="common/src/index.d.ts
19
- /// <reference path="common/src/OINOBenchmark.d.ts
20
- /// <reference path="common/src/OINOHtmlTemplate.d.ts
21
- /// <reference path="common/src/OINOLog.d.ts
22
- /// <reference path="common/src/OINOResult.d.ts
23
- /// <reference path="common/src/OINOStr.d.ts
1
+ /// <reference path="db/src/index.d.ts
2
+ /// <reference path="db/src/OINODb.d.ts
3
+ /// <reference path="db/src/OINODbApi.d.ts
4
+ /// <reference path="db/src/OINODbConfig.d.ts
5
+ /// <reference path="db/src/OINODbDataField.d.ts
6
+ /// <reference path="db/src/OINODbDataModel.d.ts
7
+ /// <reference path="db/src/OINODbFactory.d.ts
8
+ /// <reference path="db/src/OINODbModelSet.d.ts
9
+ /// <reference path="db/src/OINODbRequestParams.d.ts
10
+ /// <reference path="db/src/OINODbSqlParams.d.ts
11
+ /// <reference path="db/src/OINODbSwagger.d.ts
12
+ /// <reference path="db/src/OINODbParser.d.ts
13
+ /// <reference path="db-bunsqlite/src/OINODbBunSqlite.d.ts
14
+ /// <reference path="db-mariadb/src/OINODbMariadb.d.ts
15
+ /// <reference path="db-mssql/src/OINODbMsSql.d.ts
16
+ /// <reference path="db-postgresql/src/OINODbPostgresql.d.ts
17
+ /// <reference path="hashid/src/OINOHashid.d.ts
18
+ /// <reference path="common/src/index.d.ts
19
+ /// <reference path="common/src/OINOBenchmark.d.ts
20
+ /// <reference path="common/src/OINOHtmlTemplate.d.ts
21
+ /// <reference path="common/src/OINOLog.d.ts
22
+ /// <reference path="common/src/OINOResult.d.ts
23
+ /// <reference path="common/src/OINOStr.d.ts
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
- {
2
- "name": "@oino-ts/types",
3
- "version": "0.3.3",
4
- "description": "OINO TS package for types.",
5
- "author": "Matias Kiviniemi (pragmatta)",
6
- "license": "MPL-2.0",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/pragmatta/oino-ts.git"
10
- },
11
- "keywords": [
12
- "types",
13
- "typescript",
14
- "library"
15
- ],
16
- "main": "",
17
- "types": "index.d.ts",
18
- "dependencies": {
19
- },
20
- "devDependencies": {
21
- },
22
- "files": [
23
- "index.d.ts",
24
- "**/src/*.d.ts"
25
- ]
26
- }
1
+ {
2
+ "name": "@oino-ts/types",
3
+ "version": "0.3.4",
4
+ "description": "OINO TS package for types.",
5
+ "author": "Matias Kiviniemi (pragmatta)",
6
+ "license": "MPL-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/pragmatta/oino-ts.git"
10
+ },
11
+ "keywords": [
12
+ "types",
13
+ "typescript",
14
+ "library"
15
+ ],
16
+ "main": "",
17
+ "types": "index.d.ts",
18
+ "dependencies": {
19
+ },
20
+ "devDependencies": {
21
+ },
22
+ "files": [
23
+ "index.d.ts",
24
+ "**/src/*.d.ts"
25
+ ]
26
+ }
@@ -1,181 +0,0 @@
1
- import { OINODbParams, OINODbApi, OINODataCell, OINODataRow } 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
- /**
76
- * Print SQL select statement with DB specific formatting.
77
- *
78
- * @param tableName - The name of the table to select from.
79
- * @param columnNames - The columns to be selected.
80
- * @param whereCondition - The WHERE clause to filter the results.
81
- * @param orderCondition - The ORDER BY clause to sort the results.
82
- * @param limitCondition - The LIMIT clause to limit the number of results.
83
- * @param groupByCondition - The GROUP BY clause to group the results.
84
- *
85
- */
86
- printSqlSelect(tableName: string, columnNames: string, whereCondition: string, orderCondition: string, limitCondition: string, groupByCondition: string): string;
87
- }
88
- /**
89
- * Base class for SQL results that can be asynchronously iterated (but
90
- * not necessarity rewinded). Idea is to handle database specific mechanisms
91
- * for returning and formatting conventions in the database specific
92
- * implementation. Data might be in memory or streamed in chunks and
93
- * `OINODbDataSet` will serve it out consistently.
94
- *
95
- */
96
- export declare abstract class OINODbDataSet {
97
- private _data;
98
- /** Error messages */
99
- readonly messages: string[];
100
- /**
101
- * Constructor for `OINODbDataSet`.
102
- *
103
- * @param data internal database specific data type (constructor will throw if invalid)
104
- * @param messages error messages from SQL-query
105
- *
106
- */
107
- constructor(data: unknown, messages?: string[]);
108
- /**
109
- * Is data set empty.
110
- *
111
- */
112
- abstract isEmpty(): boolean;
113
- /**
114
- * Is there no more content, i.e. either dataset is empty or we have moved beyond last line
115
- *
116
- */
117
- abstract isEof(): boolean;
118
- /**
119
- * Attempts to moves dataset to the next row, possibly waiting for more data to become available. Returns !isEof().
120
- *
121
- */
122
- abstract next(): Promise<boolean>;
123
- /**
124
- * Gets current row of data.
125
- *
126
- */
127
- abstract getRow(): OINODataRow;
128
- /**
129
- * Checks if the messages contain errors.
130
- *
131
- */
132
- hasErrors(): boolean;
133
- /**
134
- * Checks if the messages contain errors.
135
- *
136
- */
137
- getFirstError(): string;
138
- }
139
- /**
140
- * Generic in memory implementation of a data set where data is an array of rows. Used
141
- * by BunSqlite and automated testing. Can be rewinded.
142
- *
143
- */
144
- export declare class OINODbMemoryDataSet extends OINODbDataSet {
145
- private _rows;
146
- private _currentRow;
147
- private _eof;
148
- /**
149
- * Constructor of `OINODbMemoryDataSet`.
150
- *
151
- * @param data data as OINODataRow[] (constructor will throw if invalid)
152
- * @param errors error messages from SQL-query
153
- *
154
- */
155
- constructor(data: unknown, errors?: string[]);
156
- /**
157
- * Is data set empty.
158
- *
159
- */
160
- isEmpty(): boolean;
161
- /**
162
- * Is there no more content, i.e. either dataset is empty or we have moved beyond last line
163
- *
164
- */
165
- isEof(): boolean;
166
- /**
167
- * Attempts to moves dataset to the next row, possibly waiting for more data to become available. Returns !isEof().
168
- *
169
- */
170
- next(): Promise<boolean>;
171
- /**
172
- * Gets current row of data.
173
- *
174
- */
175
- getRow(): OINODataRow;
176
- /**
177
- * Rewinds data set to the first row, returns !isEof().
178
- *
179
- */
180
- first(): boolean;
181
- }
@@ -1,89 +0,0 @@
1
- import { OINODbApiParams, OINODb, OINODbDataModel, OINODataRow, OINODbModelSet, OINODbApiRequestParams, OINOHttpResult, OINOHtmlTemplate } from "./index.js";
2
- import { OINOResult } from "@oino-ts/common";
3
- import { OINOHashid } from "@oino-ts/hashid";
4
- /**
5
- * OINO API request result object with returned data and/or http status code/message and
6
- * error / warning messages.
7
- *
8
- */
9
- export declare class OINODbApiResult extends OINOResult {
10
- /** DbApi request params */
11
- params: OINODbApiRequestParams;
12
- /** Returned data if any */
13
- data?: OINODbModelSet;
14
- /**
15
- * Constructor of OINODbApiResult.
16
- *
17
- * @param params DbApi request parameters
18
- * @param data result data
19
- *
20
- */
21
- constructor(params: OINODbApiRequestParams, data?: OINODbModelSet);
22
- /**
23
- * Creates a HTTP Response from API results.
24
- *
25
- * @param headers Headers to include in the response
26
- *
27
- */
28
- getResponse(headers?: Record<string, string>): Promise<Response>;
29
- }
30
- /**
31
- * Specialized HTML template that can render ´OINODbApiResult´.
32
- *
33
- */
34
- export declare class OINODbHtmlTemplate extends OINOHtmlTemplate {
35
- /**
36
- * Creates HTML Response from API modelset.
37
- *
38
- * @param modelset OINO API dataset
39
- * @param overrideValues values to override in the data
40
- *
41
- */
42
- renderFromDbData(modelset: OINODbModelSet, overrideValues?: any): Promise<OINOHttpResult>;
43
- }
44
- /**
45
- * API class with method to process HTTP REST requests.
46
- *
47
- */
48
- export declare class OINODbApi {
49
- /** API database reference */
50
- readonly db: OINODb;
51
- /** API datamodel */
52
- readonly datamodel: OINODbDataModel;
53
- /** API parameters */
54
- readonly params: OINODbApiParams;
55
- /** API hashid */
56
- readonly hashid: OINOHashid | null;
57
- /**
58
- * Constructor of API object.
59
- * NOTE! OINODb.initDatamodel must be called if created manually instead of the factory.
60
- *
61
- * @param db database for the API
62
- * @param params parameters for the API
63
- *
64
- */
65
- constructor(db: OINODb, params: OINODbApiParams);
66
- private _validateRowValues;
67
- private _doGet;
68
- private _doPost;
69
- private _doPut;
70
- private _doDelete;
71
- /**
72
- * Method for handlind a HTTP REST request with GET, POST, PUT, DELETE corresponding to
73
- * SQL select, insert, update and delete.
74
- *
75
- * @param method HTTP verb (uppercase)
76
- * @param id URL id of the REST request
77
- * @param body HTTP body data as either serialized string or unserialized JS object / OINODataRow-array
78
- * @param params HTTP URL parameters as key-value-pairs
79
- *
80
- */
81
- doRequest(method: string, id: string, body: string | OINODataRow[] | Buffer | any, params?: OINODbApiRequestParams): Promise<OINODbApiResult>;
82
- /**
83
- * Method to check if a field is included in the API params.
84
- *
85
- * @param fieldName name of the field
86
- *
87
- */
88
- isFieldIncluded(fieldName: string): boolean;
89
- }
@@ -1,54 +0,0 @@
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
- /** Name of the OINODbSqlAggregate-parameter in request */
15
- static OINODB_SQL_AGGREGATE_PARAM: string;
16
- /**
17
- * Set the name of the OINO ID field
18
- * @param idField name of the OINO ID field
19
- */
20
- static setOinoIdField(idField: string): void;
21
- /**
22
- * Set the separator character of the OINO ID field
23
- * @param idSeparator character to use as separator of id parts
24
- */
25
- static setOinoIdSeparator(idSeparator: string): void;
26
- /**
27
- * Print OINO ID for primary key values.
28
- *
29
- * @param primaryKeys an array of primary key values.
30
- *
31
- */
32
- static printOINOId(primaryKeys: string[]): string;
33
- /**
34
- * Set the name of the OINODbSqlFilter-param field
35
- *
36
- * @param sqlFilterParam name of the http parameter with `OINODbSqlFilter` definition
37
- *
38
- */
39
- static setOinoSqlFilterParam(sqlFilterParam: string): void;
40
- /**
41
- * Set the name of the OINODbSqlOrder-param field
42
- *
43
- * @param sqlOrderParam name of the http parameter with `OINODbSqlOrder` definition
44
- *
45
- */
46
- static setOinoSqlOrderParam(sqlOrderParam: string): void;
47
- /**
48
- * Set the name of the OINODbSqlLimit-param field
49
- *
50
- * @param sqlLimitParam name of the http parameter with `OINODbSqlLimit` definition
51
- *
52
- */
53
- static setOinoSqlLimitParam(sqlLimitParam: string): void;
54
- }
@@ -1,202 +0,0 @@
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
- }