@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.
Files changed (62) hide show
  1. package/blob/src/OINOBlob.d.ts +78 -0
  2. package/blob/src/OINOBlobApi.d.ts +49 -0
  3. package/blob/src/OINOBlobConstants.d.ts +37 -0
  4. package/blob/src/OINOBlobDataModel.d.ts +33 -0
  5. package/blob/src/OINOBlobFactory.d.ts +40 -0
  6. package/blob/src/index.d.ts +5 -0
  7. package/blob-aws/src/OINOBlobAwsS3.d.ts +90 -0
  8. package/blob-aws/src/index.d.ts +1 -0
  9. package/blob-azure/src/OINOBlobAzureTable.d.ts +86 -0
  10. package/blob-azure/src/index.d.ts +1 -0
  11. package/common/src/OINOApi.d.ts +191 -0
  12. package/common/src/OINOConfig.d.ts +63 -0
  13. package/common/src/OINOConstants.d.ts +51 -0
  14. package/common/src/OINODataField.d.ts +209 -0
  15. package/common/src/OINODataModel.d.ts +78 -0
  16. package/common/src/OINODataSource.d.ts +184 -0
  17. package/common/src/OINOHtmlTemplate.d.ts +1 -1
  18. package/common/src/OINOModelSet.d.ts +64 -0
  19. package/common/src/OINOParser.d.ts +42 -0
  20. package/common/src/OINOQueryParams.d.ts +270 -0
  21. package/common/src/OINORequest.d.ts +4 -1
  22. package/common/src/OINOResult.d.ts +1 -1
  23. package/common/src/OINOStr.d.ts +1 -1
  24. package/common/src/OINOSwagger.d.ts +25 -0
  25. package/common/src/index.d.ts +14 -31
  26. package/db/src/OINODb.d.ts +55 -0
  27. package/db/src/OINODbApi.d.ts +78 -0
  28. package/db/src/OINODbConfig.d.ts +56 -0
  29. package/db/src/OINODbConstants.d.ts +23 -0
  30. package/db/src/OINODbDataField.d.ts +210 -0
  31. package/db/src/OINODbDataModel.d.ts +55 -0
  32. package/db/src/OINODbDataSet.d.ts +95 -0
  33. package/db/src/OINODbFactory.d.ts +34 -0
  34. package/db/src/OINODbModelSet.d.ts +62 -0
  35. package/db/src/OINODbParser.d.ts +42 -0
  36. package/db/src/OINODbQueryParams.d.ts +72 -0
  37. package/db/src/OINODbRequestParams.d.ts +146 -0
  38. package/db/src/OINODbSqlParams.d.ts +296 -0
  39. package/db/src/OINODbSwagger.d.ts +25 -0
  40. package/db/src/index.d.ts +6 -0
  41. package/db-bunsqlite/src/OINODbBunSqlite.d.ts +99 -0
  42. package/db-bunsqlite/src/index.d.ts +1 -0
  43. package/db-mariadb/src/OINODbMariadb.d.ts +99 -0
  44. package/db-mariadb/src/index.d.ts +1 -0
  45. package/db-mssql/src/OINODbMsSql.d.ts +116 -0
  46. package/db-mssql/src/index.d.ts +1 -0
  47. package/db-postgresql/src/OINODbPostgresql.d.ts +95 -0
  48. package/db-postgresql/src/index.d.ts +1 -0
  49. package/hashid/src/OINOHashid.d.ts +42 -0
  50. package/hashid/src/index.d.ts +1 -0
  51. package/index.d.ts +7 -7
  52. package/nosql/src/OINONoSql.d.ts +81 -0
  53. package/nosql/src/OINONoSqlApi.d.ts +67 -0
  54. package/nosql/src/OINONoSqlConstants.d.ts +34 -0
  55. package/nosql/src/OINONoSqlDataModel.d.ts +29 -0
  56. package/nosql/src/OINONoSqlFactory.d.ts +40 -0
  57. package/nosql/src/index.d.ts +5 -0
  58. package/nosql-aws/src/OINONoSqlAwsDynamo.d.ts +223 -0
  59. package/nosql-aws/src/index.d.ts +1 -0
  60. package/nosql-azure/src/OINONoSqlAzureTable.d.ts +130 -0
  61. package/nosql-azure/src/index.d.ts +1 -0
  62. package/package.json +28 -28
@@ -0,0 +1,63 @@
1
+ /** Set the name of the OINO ID field (default \_OINOID\_) */
2
+ export declare class OINOConfig {
3
+ /** Name of the synthetic OINO ID field */
4
+ static OINO_ID_FIELD: string;
5
+ /** Private key separator of the synthetic OINO ID field */
6
+ static OINO_ID_SEPARATOR: string;
7
+ private static OINO_ID_SEPARATOR_ESCAPED;
8
+ /** Name of the OINODbQueryFilter-parameter in request */
9
+ static OINO_QUERY_FILTER_PARAM: string;
10
+ /** Name of the OINODbQueryOrder-parameter in request */
11
+ static OINO_QUERY_ORDER_PARAM: string;
12
+ /** Name of the OINODbQueryLimit-parameter in request */
13
+ static OINO_QUERY_LIMIT_PARAM: string;
14
+ /** Name of the OINODbQueryAggregate-parameter in request */
15
+ static OINO_QUERY_AGGREGATE_PARAM: string;
16
+ /** Name of the OINODbSqlSelect-parameter in request */
17
+ static OINO_QUERY_SELECT_PARAM: string;
18
+ /**
19
+ * Set the name of the OINO ID field
20
+ * @param idField name of the OINO ID field
21
+ */
22
+ static setOinoIdField(idField: string): void;
23
+ /**
24
+ * Set the separator character of the OINO ID field
25
+ * @param idSeparator character to use as separator of id parts
26
+ */
27
+ static setOinoIdSeparator(idSeparator: string): void;
28
+ /**
29
+ * Print OINO ID for primary key values.
30
+ *
31
+ * @param primaryKeys an array of primary key values.
32
+ *
33
+ */
34
+ static printOINOId(primaryKeys: string[]): string;
35
+ /**
36
+ * Print OINO ID for primary key values.
37
+ *
38
+ * @param oinoid the OINO ID string to parse as primary key values.
39
+ *
40
+ */
41
+ static parseOINOId(oinoid: string): string[];
42
+ /**
43
+ * Set the name of the OINODbQueryFilter-param field
44
+ *
45
+ * @param sqlFilterParam name of the http parameter with `OINODbQueryFilter` definition
46
+ *
47
+ */
48
+ static setOinoQueryFilterParam(sqlFilterParam: string): void;
49
+ /**
50
+ * Set the name of the OINODbQueryOrder-param field
51
+ *
52
+ * @param sqlOrderParam name of the http parameter with `OINODbQueryOrder` definition
53
+ *
54
+ */
55
+ static setOinoQueryOrderParam(sqlOrderParam: string): void;
56
+ /**
57
+ * Set the name of the OINODbQueryLimit-param field
58
+ *
59
+ * @param sqlLimitParam name of the http parameter with `OINODbQueryLimit` definition
60
+ *
61
+ */
62
+ static setOinoQueryLimitParam(sqlLimitParam: string): void;
63
+ }
@@ -0,0 +1,51 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Buffer } from "node:buffer";
4
+ /** OINO error message prefix */
5
+ export declare const OINO_ERROR_PREFIX = "OINO ERROR";
6
+ /** OINO warning message prefix */
7
+ export declare const OINO_WARNING_PREFIX = "OINO WARNING";
8
+ /** OINO info message prefix */
9
+ export declare const OINO_INFO_PREFIX = "OINO INFO";
10
+ /** OINO debug message prefix */
11
+ export declare const OINO_DEBUG_PREFIX = "OINO DEBUG";
12
+ /** Name of the OINOContentType-parameter request */
13
+ export declare const OINO_REQUEST_TYPE_PARAM = "oinorequesttype";
14
+ /** Name of the OINOContentType-parameter request */
15
+ export declare const OINO_RESPONSE_TYPE_PARAM = "oinoresponsetype";
16
+ /** Name of the query parameter that triggers a file download response */
17
+ export declare const OINO_RESPONSE_DOWNLOAD_PARAM = "oinoresponsedownload";
18
+ /**
19
+ * Supported content format mime-types
20
+ */
21
+ export declare enum OINOContentType {
22
+ /** JSON encoded data */
23
+ json = "application/json",
24
+ /** CSV encoded data */
25
+ csv = "text/csv",
26
+ /** Multipart encoded form data */
27
+ formdata = "multipart/form-data",
28
+ /** URL encoded form data */
29
+ urlencode = "application/x-www-form-urlencoded",
30
+ /** HTML encoded data (output only) */
31
+ html = "text/html"
32
+ }
33
+ /** Field parameters in database */
34
+ export type OINODataFieldParams = {
35
+ /** Is the field a primary key */
36
+ isPrimaryKey: boolean;
37
+ /** Is the field a primary key */
38
+ isForeignKey: boolean;
39
+ /** Is the field an auto inc type */
40
+ isAutoInc: boolean;
41
+ /** Is the field allowed to have null values */
42
+ isNotNull: boolean;
43
+ };
44
+ /** A single column value of a data row */
45
+ export type OINODataCell = string | bigint | number | boolean | Date | Uint8Array | Buffer | null | undefined;
46
+ /** A single data row */
47
+ export type OINODataRow = Array<OINODataCell>;
48
+ /** Empty row instance */
49
+ export declare const OINO_EMPTY_ROW: OINODataRow;
50
+ /** Empty row array instance */
51
+ export declare const OINO_EMPTY_ROWS: OINODataRow[];
@@ -0,0 +1,209 @@
1
+ import { OINODataFieldParams, OINODataCell } from "./OINOConstants.js";
2
+ import { OINODataSource } from "./OINODataSource.js";
3
+ /**
4
+ * Base class for a column of data responsible for appropriatelly serializing/deserializing the data.
5
+ *
6
+ */
7
+ export declare class OINODataField {
8
+ /** OINO data source reference*/
9
+ readonly datasource: OINODataSource;
10
+ /** Name of the field */
11
+ readonly name: string;
12
+ /** Internal type of field*/
13
+ readonly type: string;
14
+ /** SQL type of the field */
15
+ readonly nativeType: string;
16
+ /** Maximum length of the field (or 0) */
17
+ readonly maxLength: number;
18
+ /** Parameters for the field */
19
+ readonly fieldParams: OINODataFieldParams;
20
+ /**
21
+ * Constructor for a data field
22
+ *
23
+ * @param datasource OINO data source reference
24
+ * @param name name of the field
25
+ * @param type internal type of the field
26
+ * @param nativeType column type in database
27
+ * @param fieldParams parameters of the field
28
+ * @param maxLength maximum length of the field (or 0)
29
+ *
30
+ */
31
+ constructor(datasource: OINODataSource, name: string, type: string, nativeType: string, fieldParams: OINODataFieldParams, maxLength?: number);
32
+ /**
33
+ * Serialize cell value in the given content format.
34
+ *
35
+ * @param cellVal cell value
36
+ *
37
+ */
38
+ serializeCell(cellVal: OINODataCell): string | null | undefined;
39
+ /**
40
+ * Parce cell value from string using field type specific formatting rules.
41
+ *
42
+ * @param value string value
43
+ *
44
+ */
45
+ deserializeCell(value: string | null | undefined): OINODataCell;
46
+ /**
47
+ * Print data cell (from deserialization) as SQL-string.
48
+ *
49
+ * @param cellVal cell value
50
+ *
51
+ */
52
+ printCellAsValue(cellVal: OINODataCell): string;
53
+ /**
54
+ * Print name of column as SQL.
55
+ *
56
+ */
57
+ printColumnName(): string;
58
+ }
59
+ /**
60
+ * Specialised class for a string column.
61
+ *
62
+ */
63
+ export declare class OINOStringDataField extends OINODataField {
64
+ /**
65
+ * Constructor for a string data field
66
+ *
67
+ * @param datasource OINO data source reference
68
+ * @param name name of the field
69
+ * @param nativeType column type in database
70
+ * @param fieldParams parameters of the field
71
+ * @param maxLength maximum length of the field (or 0)
72
+ *
73
+ */
74
+ constructor(datasource: OINODataSource, name: string, nativeType: string, fieldParams: OINODataFieldParams, maxLength: number);
75
+ }
76
+ /**
77
+ * Specialised class for a boolean column.
78
+ *
79
+ */
80
+ export declare class OINOBooleanDataField extends OINODataField {
81
+ /**
82
+ * Constructor for a boolean data field
83
+ *
84
+ * @param datasource OINO data source reference
85
+ * @param name name of the field
86
+ * @param nativeType column type in database
87
+ * @param fieldParams parameters of the field
88
+ *
89
+ */
90
+ constructor(datasource: OINODataSource, name: string, nativeType: string, fieldParams: OINODataFieldParams);
91
+ /**
92
+ * Serialize cell value in the given content format.
93
+ *
94
+ * @param cellVal cell value
95
+ *
96
+ */
97
+ serializeCell(cellVal: OINODataCell): string | null | undefined;
98
+ /**
99
+ * Parce cell value from string using field type specific formatting rules.
100
+ *
101
+ * @param value string value
102
+ *
103
+ */
104
+ deserializeCell(value: string | null | undefined): OINODataCell;
105
+ }
106
+ /**
107
+ * Specialised class for a number column.
108
+ *
109
+ */
110
+ export declare class OINONumberDataField extends OINODataField {
111
+ /**
112
+ * Constructor for a string data field
113
+ *
114
+ * @param datasource OINO data source reference
115
+ * @param name name of the field
116
+ * @param nativeType column type in database
117
+ * @param fieldParams parameters of the field
118
+ *
119
+ */
120
+ constructor(datasource: OINODataSource, name: string, nativeType: string, fieldParams: OINODataFieldParams);
121
+ /**
122
+ * Serialize cell value in the given content format.
123
+ *
124
+ * @param cellVal cell value
125
+ *
126
+ */
127
+ serializeCell(cellVal: OINODataCell): string | null | undefined;
128
+ /**
129
+ * Parce cell value from string using field type specific formatting rules.
130
+ *
131
+ * @param value string value
132
+ *
133
+ */
134
+ deserializeCell(value: string | null | undefined): OINODataCell;
135
+ }
136
+ /**
137
+ * Specialised class for a blob column.
138
+ *
139
+ */
140
+ export declare class OINOBlobDataField extends OINODataField {
141
+ /**
142
+ * Constructor for a blob data field
143
+ *
144
+ * @param datasource OINO data source reference
145
+ * @param name name of the field
146
+ * @param nativeType column type in database
147
+ * @param fieldParams parameters of the field
148
+ * @param maxLength maximum length of the field (or 0)
149
+ *
150
+ */
151
+ constructor(datasource: OINODataSource, name: string, nativeType: string, fieldParams: OINODataFieldParams, maxLength: number);
152
+ /**
153
+ * Serialize cell value in the given content format.
154
+ *
155
+ * @param cellVal cell value
156
+ *
157
+ */
158
+ serializeCell(cellVal: OINODataCell): string | null | undefined;
159
+ /**
160
+ * Parce cell value from string using field type specific formatting rules.
161
+ *
162
+ * @param value string value
163
+ *
164
+ */
165
+ deserializeCell(value: string | null | undefined): OINODataCell;
166
+ }
167
+ /**
168
+ * Specialised class for a datetime column.
169
+ *
170
+ */
171
+ export declare class OINODatetimeDataField extends OINODataField {
172
+ /**
173
+ * Constructor for a string data field
174
+ *
175
+ * @param datasource OINO data source reference
176
+ * @param name name of the field
177
+ * @param nativeType column type in database
178
+ * @param fieldParams parameters of the field
179
+ *
180
+ */
181
+ constructor(datasource: OINODataSource, name: string, nativeType: string, fieldParams: OINODataFieldParams);
182
+ /**
183
+ * Serialize cell value in the given content format.
184
+ *
185
+ * @param cellVal cell value
186
+ *
187
+ */
188
+ serializeCell(cellVal: OINODataCell): string | null | undefined;
189
+ /**
190
+ * Serialize cell value in the given content format.
191
+ *
192
+ * @param cellVal cell value
193
+ * @param locale locale-object to format datetimes with
194
+ *
195
+ */
196
+ serializeCellWithLocale(cellVal: OINODataCell, locale: Intl.DateTimeFormat): string | null | undefined;
197
+ /**
198
+ * Parce cell value from string using field type specific formatting rules.
199
+ *
200
+ * @param value string value
201
+ *
202
+ */
203
+ deserializeCell(value: string | null | undefined): OINODataCell;
204
+ }
205
+ /**
206
+ * Callback to filter data fields
207
+ * @param field fields to filter
208
+ */
209
+ export type OINODataFieldFilter = (field: OINODataField) => Boolean;
@@ -0,0 +1,78 @@
1
+ import { OINODataRow } from "./OINOConstants.js";
2
+ import { OINOApi } from "./OINOApi.js";
3
+ import { OINODataField, OINODataFieldFilter } from "./OINODataField.js";
4
+ /**
5
+ * OINO Datamodel object for representing one database table and it's columns.
6
+ *
7
+ */
8
+ export declare class OINODataModel {
9
+ private _fieldIndexLookup;
10
+ /** Database refererence of the table */
11
+ readonly api: OINOApi;
12
+ /** Field refererences of the API */
13
+ readonly fields: OINODataField[];
14
+ /**
15
+ * Constructor of the data model.
16
+ * NOTE! OINODbDataModel.initialize must be called after constructor to populate fields.
17
+ *
18
+ * @param api api of the data model
19
+ *
20
+ */
21
+ constructor(api: OINOApi);
22
+ /**
23
+ * Add a field to the datamodel.
24
+ *
25
+ * @param field dataset field
26
+ *
27
+ */
28
+ addField(field: OINODataField): void;
29
+ /**
30
+ * Find a field of a given name if any.
31
+ *
32
+ * @param name name of the field to find
33
+ *
34
+ */
35
+ findFieldByName(name: string): OINODataField | null;
36
+ /**
37
+ * Find index of a field of a given name if any.
38
+ *
39
+ * @param name name of the field to find
40
+ *
41
+ */
42
+ findFieldIndexByName(name: string): number;
43
+ /**
44
+ * Find all fields based of given filter callback criteria (e.g. fields of certain data type, primary keys etc.)
45
+ *
46
+ * @param filter callback called for each field to include or not
47
+ *
48
+ */
49
+ filterFields(filter: OINODataFieldFilter): OINODataField[];
50
+ /**
51
+ * Return the primary key values of one row in order of the data model
52
+ *
53
+ * @param row data row
54
+ * @param hashidValues apply hashid when applicable
55
+ *
56
+ */
57
+ getRowPrimarykeyValues(row: OINODataRow, hashidValues?: boolean): string[];
58
+ /**
59
+ * Pring debug information for the field
60
+ *
61
+ * @param length length of the debug output (or 0 for as long as needed)
62
+ *
63
+ */
64
+ printColumnDebug(field: OINODataField, length?: number): string;
65
+ /**
66
+ * Print debug information about the fields.
67
+ *
68
+ * @param separator string to separate field prints
69
+ *
70
+ */
71
+ printDebug(separator?: string): string;
72
+ /**
73
+ * Print all public properties (db, table name, fields) of the datamodel. Used
74
+ * in automated testing validate schema has stayed the same.
75
+ *
76
+ */
77
+ printFieldPublicPropertiesJson(): string;
78
+ }
@@ -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
+ }
@@ -1,4 +1,4 @@
1
- import { OINOResult, OINOHttpResult } from ".";
1
+ import { OINOResult, OINOHttpResult } from "./OINOResult.js";
2
2
  /**
3
3
  * Class for rendering HTML from data.
4
4
  */
@@ -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
+ }