@oino-ts/db-postgresql 0.0.17 → 0.1.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 CHANGED
@@ -75,7 +75,7 @@
75
75
  OINO handles serialization of data to JSON/CSV/etc. and back based on the data model. It knows what columns exist, what is their data type and how to convert each to JSON/CSV and back. This allows also partial data to be sent, i.e. you can send only columns that need updating or even send extra columns and have them ignored.
76
76
 
77
77
  ### Features
78
- - Files can be sent to BLOB fields using BASE64 or MIME multipart encoding.
78
+ - Files can be sent to BLOB fields using BASE64 or MIME multipart encoding. Also supports standard HTML form file submission to blob fields and returning them data url images.
79
79
  - Datetimes are (optionally) normalized to ISO 8601 format.
80
80
  - Extended JSON-encoding
81
81
  - Unquoted literal `undefined` can be used to represent non-existent values (leaving property out works too but preserving structure might be easier e.g. when translating data).
@@ -100,11 +100,11 @@
100
100
  - Mariadb / Mysql-support through [mariadb](https://www.npmjs.com/package/mariadb)-package
101
101
  - Sql Server through [mssql](https://www.npmjs.com/package/mssql)-package
102
102
 
103
- ## Complex Keys
103
+ ## Composite Keys
104
104
  To support tables with multipart primary keys OINO generates a composite key `_OINOID_` that is included in the result and can be used as the REST ID. For example in the example above table `OrderDetails` has two primary keys `OrderID` and `ProductID` making the `_OINOID_` of form `11077:99`.
105
105
 
106
106
  ## Power Of SQL
107
- Since OINO is just generating SQL, WHERE-conditions can be defined with [`OINOSqlFilter`](https://pragmatta.github.io/oino-ts/classes/db_src.OINODbSqlFilter.html), order with [`OINOSqlOrder`](https://pragmatta.github.io/oino-ts/classes/db_src.OINODbSqlOrder.html) and limits/paging with [`OINOSqlOrder`](https://pragmatta.github.io/oino-ts/classes/db_src.OINODbSqlLimit.html) that are passed as HTTP request parameters. No more API development where you make unique API endpoints for each filter that fetch all data with original API and filter in backend code. Every API can be filtered when and as needed without unnessecary data tranfer and utilizing SQL indexing when available.
107
+ Since OINO is just generating SQL, WHERE-conditions can be defined with [`OINOSqlFilter`](https://pragmatta.github.io/oino-ts/classes/db_src.OINODbSqlFilter.html), order with [`OINOSqlOrder`](https://pragmatta.github.io/oino-ts/classes/db_src.OINODbSqlOrder.html) and limits/paging with [`OINOSqlLimit`](https://pragmatta.github.io/oino-ts/classes/db_src.OINODbSqlLimit.html) that are passed as HTTP request parameters. No more API development where you make unique API endpoints for each filter that fetch all data with original API and filter in backend code. Every API can be filtered when and as needed without unnessecary data tranfer and utilizing SQL indexing when available.
108
108
 
109
109
  ## Swagger Support
110
110
  Swagger is great as long as the definitions are updated and with OINO you can automatically get a Swagger definition including a data model schema.
@@ -121,7 +121,7 @@
121
121
  ## HTMX support
122
122
  OINO is [htmx.org](https://htmx.org) friendly, allowing easy translation of [`OINODataRow`](https://pragmatta.github.io/oino-ts/types/db_src.OINODataRow.html) to HTML output using templates (cf. the [htmx sample app](https://github.com/pragmatta/oino-ts/tree/main/samples/htmxApp)).
123
123
 
124
- ### Hashids
124
+ ## Hashids
125
125
  Autoinc numeric id's are very pragmatic and fit well with OINO (e.g. using a form without primary key fields to insert new rows with database assigned ids). However it's not always sensible to share information about the sequence. Hashids solve this by masking the original values by encrypting the ids using AES-128 and some randomness. Length of the hashid can be chosen from 12-32 characters where longer ids provide more security. However this should not be considereded a cryptographic solution for keeping ids secret but rather making it infeasible to iterate all ids.
126
126
 
127
127
 
@@ -133,9 +133,6 @@
133
133
 
134
134
  ### Realistic app
135
135
  There needs to be a realistic app built on top of OINO to get a better grasp of the edge cases.
136
-
137
- ### Security review
138
- Handling of SQL-injection attacks needs a thorough review, what are the relevant attack vectors are for OINO and what protections are still needed.
139
136
 
140
137
  ## Roadmap
141
138
  Things that need to happen in some order before beta-status are at least following:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/db-postgresql",
3
- "version": "0.0.17",
3
+ "version": "0.1.0",
4
4
  "description": "OINO TS package for using Postgresql databases.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",
@@ -20,7 +20,7 @@
20
20
  "module": "./dist/esm/index.js",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "dependencies": {
23
- "@oino-ts/db": "^0.0.17",
23
+ "@oino-ts/db": "^0.1.0",
24
24
  "pg": "^8.11.3"
25
25
  },
26
26
  "devDependencies": {
@@ -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";