@oino-ts/types 0.3.2 → 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.
@@ -1,25 +0,0 @@
1
- import { OINODbApi } from "./index.js";
2
- /**
3
- * Static class for Swagger utilities
4
- *
5
- */
6
- export declare class OINODbSwagger {
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: OINODbApi[]): any;
25
- }
package/db/src/index.d.ts DELETED
@@ -1,117 +0,0 @@
1
- import { OINOContentType } from "@oino-ts/common";
2
- export { OINOContentType };
3
- export { OINO_ERROR_PREFIX, OINO_WARNING_PREFIX, OINO_INFO_PREFIX, OINO_DEBUG_PREFIX, OINOStr, OINOBenchmark, OINOLog, OINOLogLevel, OINOConsoleLog, OINOResult, OINOHttpResult, OINOHtmlTemplate } from "@oino-ts/common";
4
- import { OINODb } from "./OINODb.js";
5
- import { OINODbDataField } from "./OINODbDataField.js";
6
- import { OINODbSqlAggregate, OINODbSqlFilter, OINODbSqlLimit, OINODbSqlOrder } from "./OINODbSqlParams.js";
7
- export { OINODbApiResult, OINODbHtmlTemplate, OINODbApi } from "./OINODbApi.js";
8
- export { OINODbDataModel } from "./OINODbDataModel.js";
9
- export { OINODbModelSet } from "./OINODbModelSet.js";
10
- export { OINODbDataField, OINOBooleanDataField, OINONumberDataField, OINOStringDataField, OINOBlobDataField, OINODatetimeDataField } from "./OINODbDataField.js";
11
- export { OINODbDataSet, OINODbMemoryDataSet, OINODb } from "./OINODb.js";
12
- export { OINODbSqlFilter, OINODbSqlOrder, OINODbSqlComparison, OINODbSqlLimit, OINODbSqlBooleanOperation } from "./OINODbSqlParams.js";
13
- export { OINODbConfig } from "./OINODbConfig.js";
14
- export { OINODbFactory } from "./OINODbFactory.js";
15
- export { OINODbSwagger } from "./OINODbSwagger.js";
16
- export { OINODbParser } from "./OINODbParser.js";
17
- /** API parameters */
18
- export type OINODbApiParams = {
19
- /** Name of the api */
20
- apiName: string;
21
- /** Name of the database table */
22
- tableName: string;
23
- /** Reject values that exceed field max length (behaviour on such is platform dependent) */
24
- failOnOversizedValues?: Boolean;
25
- /** Reject PUT-requests that contain values for autoinc-type fields */
26
- failOnUpdateOnAutoinc?: boolean;
27
- /** Reject POST-requests without primary key value (can work if DB-side ) */
28
- failOnInsertWithoutKey?: boolean;
29
- /** Treat date type fields as just strings and use the native formatting instead of the ISO 8601 format */
30
- useDatesAsString?: Boolean;
31
- /** Include given fields from the API and exclude rest (if defined) */
32
- includeFields?: string[];
33
- /** Exclude all fields with this prefix from the API */
34
- excludeFieldPrefix?: string;
35
- /** Exclude given fields from the API and include rest (if defined) */
36
- excludeFields?: string[];
37
- /** Enable hashids for numeric primarykeys by adding a 32 char key */
38
- hashidKey?: string;
39
- /** Set (minimum) length (12-32 chars) of the hashids */
40
- hashidLength?: number;
41
- /** Make hashids static per row/table */
42
- hashidStaticIds?: boolean;
43
- /** Name of field that has the modified field */
44
- cacheModifiedField?: string;
45
- };
46
- /**
47
- * Database class (constructor) type
48
- * @param dbParams database parameters
49
- */
50
- export type OINODbConstructor = new (dbParams: OINODbParams) => OINODb;
51
- /** Database parameters */
52
- export type OINODbParams = {
53
- /** Name of the database class (e.g. OINODbPostgresql) */
54
- type: string;
55
- /** Connection URL, either file://-path or an IP-address or an HTTP-url */
56
- url: string;
57
- /** Name of the database */
58
- database: string;
59
- /** TCP port of the database */
60
- port?: number;
61
- /** Username used to authenticate */
62
- user?: string;
63
- /** Password used to authenticate */
64
- password?: string;
65
- };
66
- /** Field parameters in database */
67
- export type OINODbDataFieldParams = {
68
- /** Is the field a primary key */
69
- isPrimaryKey: Boolean;
70
- /** Is the field a primary key */
71
- isForeignKey: Boolean;
72
- /** Is the field an auto inc type */
73
- isAutoInc: Boolean;
74
- /** Is the field allowed to have null values */
75
- isNotNull: Boolean;
76
- };
77
- /**
78
- * Callback to filter data fields
79
- * @param field fields to filter
80
- */
81
- export type OINODbDataFieldFilter = (field: OINODbDataField) => Boolean;
82
- /** Request options */
83
- export type OINODbSqlParams = {
84
- /** Additional SQL select where-conditions */
85
- filter?: OINODbSqlFilter;
86
- /** SQL result ordering conditions */
87
- order?: OINODbSqlOrder;
88
- /** SQL result limit condition */
89
- limit?: OINODbSqlLimit;
90
- /** SQL aggregation functions */
91
- aggregate?: OINODbSqlAggregate;
92
- };
93
- /** Request options */
94
- export type OINODbApiRequestParams = {
95
- /** Content type of the request body */
96
- requestType?: OINOContentType;
97
- /** Content type of the response body */
98
- responseType?: OINOContentType;
99
- /** Multipart boundary token */
100
- multipartBoundary?: string;
101
- /** Request last-modified value */
102
- lastModified?: number;
103
- /** Request etag values */
104
- etags?: string[];
105
- /** SQL parameters */
106
- sqlParams?: OINODbSqlParams;
107
- };
108
- /** A single column value of a data row */
109
- export type OINODataCell = string | bigint | number | boolean | Date | Uint8Array | Buffer | null | undefined;
110
- /** A single data row */
111
- export type OINODataRow = Array<OINODataCell>;
112
- /** Empty row instance */
113
- export declare const OINODB_EMPTY_ROW: OINODataRow;
114
- /** Empty row array instance */
115
- export declare const OINODB_EMPTY_ROWS: OINODataRow[];
116
- /** Key-value collection */
117
- export type OINOValues = Record<string, string>;
@@ -1,77 +0,0 @@
1
- import { OINODb, OINODbParams, OINODbDataSet, OINODbApi, OINODataCell } from "@oino-ts/db";
2
- /**
3
- * Implementation of BunSqlite-database.
4
- *
5
- */
6
- export declare class OINODbBunSqlite extends OINODb {
7
- private static _tableDescriptionRegex;
8
- private static _tablePrimarykeyRegex;
9
- private static _tableForeignkeyRegex;
10
- private static _tableFieldTypeRegex;
11
- private _db;
12
- /**
13
- * OINODbBunSqlite constructor
14
- * @param params database parameters
15
- */
16
- constructor(params: OINODbParams);
17
- private _parseDbFieldParams;
18
- /**
19
- * Print a table name using database specific SQL escaping.
20
- *
21
- * @param sqlTable name of the table
22
- *
23
- */
24
- printSqlTablename(sqlTable: string): string;
25
- /**
26
- * Print a column name with correct SQL escaping.
27
- *
28
- * @param sqlColumn name of the column
29
- *
30
- */
31
- printSqlColumnname(sqlColumn: string): string;
32
- /**
33
- * Print a single data value from serialization using the context of the native data
34
- * type with the correct SQL escaping.
35
- *
36
- * @param cellValue data from sql results
37
- * @param sqlType native type name for table column
38
- *
39
- */
40
- printCellAsSqlValue(cellValue: OINODataCell, sqlType: string): string;
41
- /**
42
- * Parse a single SQL result value for serialization using the context of the native data
43
- * type.
44
- *
45
- * @param sqlValue data from serialization
46
- * @param sqlType native type name for table column
47
- *
48
- */
49
- parseSqlValueAsCell(sqlValue: OINODataCell, sqlType: string): OINODataCell;
50
- /**
51
- * Connect to database.
52
- *
53
- */
54
- connect(): Promise<boolean>;
55
- /**
56
- * Execute a select operation.
57
- *
58
- * @param sql SQL statement.
59
- *
60
- */
61
- sqlSelect(sql: string): Promise<OINODbDataSet>;
62
- /**
63
- * Execute other sql operations.
64
- *
65
- * @param sql SQL statement.
66
- *
67
- */
68
- sqlExec(sql: string): Promise<OINODbDataSet>;
69
- /**
70
- * Initialize a data model by getting the SQL schema and populating OINODbDataFields of
71
- * the model.
72
- *
73
- * @param api api which data model to initialize.
74
- *
75
- */
76
- initializeApiDatamodel(api: OINODbApi): Promise<void>;
77
- }
@@ -1 +0,0 @@
1
- export { OINODbBunSqlite } from "./OINODbBunSqlite.js";
@@ -1,78 +0,0 @@
1
- import { OINODb, OINODbParams, OINODbDataSet, OINODbApi, OINODataCell } from "@oino-ts/db";
2
- /**
3
- * Implementation of MariaDb/MySql-database.
4
- *
5
- */
6
- export declare class OINODbMariadb extends OINODb {
7
- private static _fieldLengthRegex;
8
- private static _exceptionMessageRegex;
9
- private _pool;
10
- /**
11
- * Constructor of `OINODbMariadb`
12
- * @param params database parameters
13
- */
14
- constructor(params: OINODbParams);
15
- private _parseFieldLength;
16
- private _query;
17
- private _exec;
18
- /**
19
- * Print a table name using database specific SQL escaping.
20
- *
21
- * @param sqlTable name of the table
22
- *
23
- */
24
- printSqlTablename(sqlTable: string): string;
25
- /**
26
- * Print a column name with correct SQL escaping.
27
- *
28
- * @param sqlColumn name of the column
29
- *
30
- */
31
- printSqlColumnname(sqlColumn: string): string;
32
- /**
33
- * Print a single data value from serialization using the context of the native data
34
- * type with the correct SQL escaping.
35
- *
36
- * @param cellValue data from sql results
37
- * @param sqlType native type name for table column
38
- *
39
- */
40
- printCellAsSqlValue(cellValue: OINODataCell, sqlType: string): string;
41
- /**
42
- * Parse a single SQL result value for serialization using the context of the native data
43
- * type.
44
- *
45
- * @param sqlValue data from serialization
46
- * @param sqlType native type name for table column
47
- *
48
- */
49
- parseSqlValueAsCell(sqlValue: OINODataCell, sqlType: string): OINODataCell;
50
- /**
51
- * Connect to database.
52
- *
53
- */
54
- connect(): Promise<boolean>;
55
- /**
56
- * Execute a select operation.
57
- *
58
- * @param sql SQL statement.
59
- *
60
- */
61
- sqlSelect(sql: string): Promise<OINODbDataSet>;
62
- /**
63
- * Execute other sql operations.
64
- *
65
- * @param sql SQL statement.
66
- *
67
- */
68
- sqlExec(sql: string): Promise<OINODbDataSet>;
69
- private _getSchemaSql;
70
- /**
71
- * Initialize a data model by getting the SQL schema and populating OINODbDataFields of
72
- * the model.
73
- *
74
- * @param api api which data model to initialize.
75
- *
76
- */
77
- initializeApiDatamodel(api: OINODbApi): Promise<void>;
78
- }
@@ -1 +0,0 @@
1
- export { OINODbMariadb } from "./OINODbMariadb.js";
@@ -1,87 +0,0 @@
1
- import { OINODb, OINODbParams, OINODbDataSet, OINODbApi, OINODataCell } from "@oino-ts/db";
2
- /**
3
- * Implementation of MariaDb/MySql-database.
4
- *
5
- */
6
- export declare class OINODbMsSql extends OINODb {
7
- private _pool;
8
- /**
9
- * Constructor of `OINODbMsSql`
10
- * @param params database parameters
11
- */
12
- constructor(params: OINODbParams);
13
- private _query;
14
- private _exec;
15
- /**
16
- * Print a table name using database specific SQL escaping.
17
- *
18
- * @param sqlTable name of the table
19
- *
20
- */
21
- printSqlTablename(sqlTable: string): string;
22
- /**
23
- * Print a column name with correct SQL escaping.
24
- *
25
- * @param sqlColumn name of the column
26
- *
27
- */
28
- printSqlColumnname(sqlColumn: string): string;
29
- /**
30
- * Print a single data value from serialization using the context of the native data
31
- * type with the correct SQL escaping.
32
- *
33
- * @param cellValue data from sql results
34
- * @param sqlType native type name for table column
35
- *
36
- */
37
- printCellAsSqlValue(cellValue: OINODataCell, sqlType: string): string;
38
- /**
39
- * Parse a single SQL result value for serialization using the context of the native data
40
- * type.
41
- *
42
- * @param sqlValue data from serialization
43
- * @param sqlType native type name for table column
44
- *
45
- */
46
- parseSqlValueAsCell(sqlValue: OINODataCell, sqlType: string): OINODataCell;
47
- /**
48
- * Print SQL select statement with DB specific formatting.
49
- *
50
- * @param tableName - The name of the table to select from.
51
- * @param columnNames - The columns to be selected.
52
- * @param whereCondition - The WHERE clause to filter the results.
53
- * @param orderCondition - The ORDER BY clause to sort the results.
54
- * @param limitCondition - The LIMIT clause to limit the number of results.
55
- * @param groupByCondition - The GROUP BY clause to group the results.
56
- *
57
- */
58
- printSqlSelect(tableName: string, columnNames: string, whereCondition: string, orderCondition: string, limitCondition: string, groupByCondition: string): string;
59
- /**
60
- * Connect to database.
61
- *
62
- */
63
- connect(): Promise<boolean>;
64
- /**
65
- * Execute a select operation.
66
- *
67
- * @param sql SQL statement.
68
- *
69
- */
70
- sqlSelect(sql: string): Promise<OINODbDataSet>;
71
- /**
72
- * Execute other sql operations.
73
- *
74
- * @param sql SQL statement.
75
- *
76
- */
77
- sqlExec(sql: string): Promise<OINODbDataSet>;
78
- private _getSchemaSql;
79
- /**
80
- * Initialize a data model by getting the SQL schema and populating OINODbDataFields of
81
- * the model.
82
- *
83
- * @param api api which data model to initialize.
84
- *
85
- */
86
- initializeApiDatamodel(api: OINODbApi): Promise<void>;
87
- }
@@ -1 +0,0 @@
1
- export { OINODbMsSql } from "./OINODbMsSql.js";
@@ -1,76 +0,0 @@
1
- import { OINODb, OINODbParams, OINODbDataSet, OINODbApi, OINODataCell } from "@oino-ts/db";
2
- /**
3
- * Implementation of Postgresql-database.
4
- *
5
- */
6
- export declare class OINODbPostgresql extends OINODb {
7
- private _pool;
8
- /**
9
- * Constructor of `OINODbPostgresql`
10
- * @param params database paraneters
11
- */
12
- constructor(params: OINODbParams);
13
- private _parseFieldLength;
14
- private _query;
15
- private _exec;
16
- /**
17
- * Print a table name using database specific SQL escaping.
18
- *
19
- * @param sqlTable name of the table
20
- *
21
- */
22
- printSqlTablename(sqlTable: string): string;
23
- /**
24
- * Print a column name with correct SQL escaping.
25
- *
26
- * @param sqlColumn name of the column
27
- *
28
- */
29
- printSqlColumnname(sqlColumn: string): string;
30
- /**
31
- * Print a single data value from serialization using the context of the native data
32
- * type with the correct SQL escaping.
33
- *
34
- * @param cellValue data from sql results
35
- * @param sqlType native type name for table column
36
- *
37
- */
38
- printCellAsSqlValue(cellValue: OINODataCell, sqlType: string): string;
39
- /**
40
- * Parse a single SQL result value for serialization using the context of the native data
41
- * type.
42
- *
43
- * @param sqlValue data from serialization
44
- * @param sqlType native type name for table column
45
- *
46
- */
47
- parseSqlValueAsCell(sqlValue: OINODataCell, sqlType: string): OINODataCell;
48
- /**
49
- * Connect to database.
50
- *
51
- */
52
- connect(): Promise<boolean>;
53
- /**
54
- * Execute a select operation.
55
- *
56
- * @param sql SQL statement.
57
- *
58
- */
59
- sqlSelect(sql: string): Promise<OINODbDataSet>;
60
- /**
61
- * Execute other sql operations.
62
- *
63
- * @param sql SQL statement.
64
- *
65
- */
66
- sqlExec(sql: string): Promise<OINODbDataSet>;
67
- private _getSchemaSql;
68
- /**
69
- * Initialize a data model by getting the SQL schema and populating OINODbDataFields of
70
- * the model.
71
- *
72
- * @param api api which data model to initialize.
73
- *
74
- */
75
- initializeApiDatamodel(api: OINODbApi): Promise<void>;
76
- }
@@ -1 +0,0 @@
1
- export { OINODbPostgresql } from "./OINODbPostgresql.js";
@@ -1,42 +0,0 @@
1
- export declare const OINOHASHID_MIN_LENGTH: number;
2
- export declare const OINOHASHID_MAX_LENGTH: number;
3
- /**
4
- * Hashid implementation for OINO API:s for the purpose of making it infeasible to scan
5
- * through numeric autoinc keys. It's not a solution to keeping the id secret in insecure
6
- * channels, just making it hard enough to not iterate through the entire key space. Half
7
- * of the the hashid length is nonce and half cryptotext, i.e. 16 char hashid 8 chars of
8
- * base64 encoded nonce ~ 6 bytes or 48 bits of entropy.
9
- *
10
- */
11
- export declare class OINOHashid {
12
- private _key;
13
- private _iv;
14
- private _domainId;
15
- private _minLength;
16
- private _staticIds;
17
- /**
18
- * Hashid constructor
19
- *
20
- * @param key AES128 key (32 char hex-string)
21
- * @param domainId a sufficiently unique domain ID in which row-Id's are unique
22
- * @param minLength minimum length of nonce and crypto
23
- * @param staticIds whether hash values should remain static per row or random values
24
- *
25
- */
26
- constructor(key: string, domainId: string, minLength?: number, staticIds?: boolean);
27
- /**
28
- * Encode given id value as a hashid either using random data or given seed value for nonce.
29
- *
30
- * @param id numeric value
31
- * @param cellSeed a sufficiently unique seed for the current cell to keep hashids unique but persistent (e.g. fieldname + primarykey values)
32
- *
33
- */
34
- encode(id: string, cellSeed?: string): string;
35
- /**
36
- * Decode given hashid.
37
- *
38
- * @param hashid value
39
- *
40
- */
41
- decode(hashid: string): string;
42
- }
@@ -1 +0,0 @@
1
- export { OINOHashid } from "./OINOHashid.js";