@oino-ts/common 1.0.1 → 1.0.2
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/dist/cjs/OINOApi.js +1 -1
- package/dist/cjs/OINODataField.js +2 -2
- package/dist/esm/OINOApi.js +1 -1
- package/dist/esm/OINODataField.js +2 -2
- package/dist/types/OINOApi.d.ts +2 -0
- package/dist/types/OINODataField.d.ts +2 -2
- package/dist/types/OINODataSource.d.ts +7 -14
- package/package.json +2 -2
- package/src/OINOApi.ts +3 -1
- package/src/OINODataField.ts +2 -2
- package/src/OINODataSource.ts +7 -15
package/dist/cjs/OINOApi.js
CHANGED
|
@@ -293,7 +293,7 @@ class OINOApi {
|
|
|
293
293
|
this.datasource = datasource;
|
|
294
294
|
this.params = params;
|
|
295
295
|
if (this.params.hashidKey) {
|
|
296
|
-
this.hashid = new hashid_1.OINOHashid(this.params.hashidKey, this.params.apiName, this.params.hashidLength, this.params.hashidStaticIds);
|
|
296
|
+
this.hashid = new hashid_1.OINOHashid(this.params.hashidKey, this.params.hashidDomain || this.params.apiName, this.params.hashidLength, this.params.hashidStaticIds);
|
|
297
297
|
}
|
|
298
298
|
else {
|
|
299
299
|
this.hashid = null;
|
|
@@ -79,10 +79,10 @@ class OINODataField {
|
|
|
79
79
|
return this.datasource.printCellAsValue(cellVal, this.nativeType);
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* Print name of
|
|
82
|
+
* Print name of the field in datasource specific format.
|
|
83
83
|
*
|
|
84
84
|
*/
|
|
85
|
-
|
|
85
|
+
printFieldName() {
|
|
86
86
|
return this.datasource.printColumnName(this.name);
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/esm/OINOApi.js
CHANGED
|
@@ -287,7 +287,7 @@ export class OINOApi {
|
|
|
287
287
|
this.datasource = datasource;
|
|
288
288
|
this.params = params;
|
|
289
289
|
if (this.params.hashidKey) {
|
|
290
|
-
this.hashid = new OINOHashid(this.params.hashidKey, this.params.apiName, this.params.hashidLength, this.params.hashidStaticIds);
|
|
290
|
+
this.hashid = new OINOHashid(this.params.hashidKey, this.params.hashidDomain || this.params.apiName, this.params.hashidLength, this.params.hashidStaticIds);
|
|
291
291
|
}
|
|
292
292
|
else {
|
|
293
293
|
this.hashid = null;
|
|
@@ -76,10 +76,10 @@ export class OINODataField {
|
|
|
76
76
|
return this.datasource.printCellAsValue(cellVal, this.nativeType);
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
|
-
* Print name of
|
|
79
|
+
* Print name of the field in datasource specific format.
|
|
80
80
|
*
|
|
81
81
|
*/
|
|
82
|
-
|
|
82
|
+
printFieldName() {
|
|
83
83
|
return this.datasource.printColumnName(this.name);
|
|
84
84
|
}
|
|
85
85
|
}
|
package/dist/types/OINOApi.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export type OINOApiParams = {
|
|
|
38
38
|
hashidLength?: number;
|
|
39
39
|
/** Make hashids static per row/table */
|
|
40
40
|
hashidStaticIds?: boolean;
|
|
41
|
+
/** Defaults to api name but should be set to a domain unique value among those apis that need hashids to be compatible (e.g. hashid of a foreign key works in the main api) */
|
|
42
|
+
hashidDomain?: string;
|
|
41
43
|
/** Name of field that has the modified field */
|
|
42
44
|
cacheModifiedField?: string;
|
|
43
45
|
/** Return inserted id values */
|
|
@@ -51,10 +51,10 @@ export declare class OINODataField {
|
|
|
51
51
|
*/
|
|
52
52
|
printCellAsValue(cellVal: OINODataCell): string;
|
|
53
53
|
/**
|
|
54
|
-
* Print name of
|
|
54
|
+
* Print name of the field in datasource specific format.
|
|
55
55
|
*
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
printFieldName(): string;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Specialised class for a string column.
|
|
@@ -25,28 +25,21 @@ export declare abstract class OINODataSource {
|
|
|
25
25
|
*/
|
|
26
26
|
abstract disconnect(): Promise<void>;
|
|
27
27
|
/**
|
|
28
|
-
* Print a
|
|
28
|
+
* Print a column name with correct datasource specific formatting.
|
|
29
29
|
*
|
|
30
|
-
* @param
|
|
30
|
+
* @param column name of the column
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
|
-
abstract
|
|
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;
|
|
33
|
+
abstract printColumnName(column: string): string;
|
|
41
34
|
/**
|
|
42
35
|
* Print a single data value from serialization using the context of the native data
|
|
43
36
|
* type with the correct SQL escaping.
|
|
44
37
|
*
|
|
45
38
|
* @param cellValue data from sql results
|
|
46
|
-
* @param
|
|
39
|
+
* @param nativeType native type name for table column
|
|
47
40
|
*
|
|
48
41
|
*/
|
|
49
|
-
abstract printCellAsValue(cellValue: OINODataCell,
|
|
42
|
+
abstract printCellAsValue(cellValue: OINODataCell, nativeType: string): string;
|
|
50
43
|
/**
|
|
51
44
|
* Print a single string value as valid sql literal
|
|
52
45
|
*
|
|
@@ -59,10 +52,10 @@ export declare abstract class OINODataSource {
|
|
|
59
52
|
* type.
|
|
60
53
|
*
|
|
61
54
|
* @param sqlValue data from serialization
|
|
62
|
-
* @param
|
|
55
|
+
* @param nativeType native type name for table column
|
|
63
56
|
*
|
|
64
57
|
*/
|
|
65
|
-
abstract parseValueAsCell(sqlValue: OINODataCell,
|
|
58
|
+
abstract parseValueAsCell(sqlValue: OINODataCell, nativeType: string): OINODataCell;
|
|
66
59
|
/**
|
|
67
60
|
* Initialize a data model by getting the SQL schema and populating OINODataFields of
|
|
68
61
|
* the model.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "OINO TS package for common classes.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@oino-ts/types": "1.0.
|
|
22
|
+
"@oino-ts/types": "1.0.2",
|
|
23
23
|
"@types/node": "^22.0.0",
|
|
24
24
|
"typescript": "~5.9.0"
|
|
25
25
|
},
|
package/src/OINOApi.ts
CHANGED
|
@@ -41,6 +41,8 @@ export type OINOApiParams = {
|
|
|
41
41
|
hashidLength?:number,
|
|
42
42
|
/** Make hashids static per row/table */
|
|
43
43
|
hashidStaticIds?: boolean,
|
|
44
|
+
/** Defaults to api name but should be set to a domain unique value among those apis that need hashids to be compatible (e.g. hashid of a foreign key works in the main api) */
|
|
45
|
+
hashidDomain?: string,
|
|
44
46
|
/** Name of field that has the modified field */
|
|
45
47
|
cacheModifiedField?:string,
|
|
46
48
|
/** Return inserted id values */
|
|
@@ -350,7 +352,7 @@ export abstract class OINOApi {
|
|
|
350
352
|
this.params = params
|
|
351
353
|
|
|
352
354
|
if (this.params.hashidKey) {
|
|
353
|
-
this.hashid = new OINOHashid(this.params.hashidKey, this.params.apiName, this.params.hashidLength, this.params.hashidStaticIds)
|
|
355
|
+
this.hashid = new OINOHashid(this.params.hashidKey, this.params.hashidDomain || this.params.apiName, this.params.hashidLength, this.params.hashidStaticIds)
|
|
354
356
|
} else {
|
|
355
357
|
this.hashid = null
|
|
356
358
|
}
|
package/src/OINODataField.ts
CHANGED
|
@@ -89,10 +89,10 @@ export class OINODataField {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Print name of
|
|
92
|
+
* Print name of the field in datasource specific format.
|
|
93
93
|
*
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
printFieldName():string {
|
|
96
96
|
return this.datasource.printColumnName(this.name)
|
|
97
97
|
}
|
|
98
98
|
}
|
package/src/OINODataSource.ts
CHANGED
|
@@ -31,30 +31,22 @@ export abstract class OINODataSource {
|
|
|
31
31
|
abstract disconnect(): Promise<void>
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Print a
|
|
34
|
+
* Print a column name with correct datasource specific formatting.
|
|
35
35
|
*
|
|
36
|
-
* @param
|
|
36
|
+
* @param column name of the column
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
|
-
abstract
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Print a column name with correct SQL escaping.
|
|
43
|
-
*
|
|
44
|
-
* @param sqlColumn name of the column
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
abstract printColumnName(sqlColumn:string): string
|
|
39
|
+
abstract printColumnName(column:string): string
|
|
48
40
|
|
|
49
41
|
/**
|
|
50
42
|
* Print a single data value from serialization using the context of the native data
|
|
51
43
|
* type with the correct SQL escaping.
|
|
52
44
|
*
|
|
53
45
|
* @param cellValue data from sql results
|
|
54
|
-
* @param
|
|
46
|
+
* @param nativeType native type name for table column
|
|
55
47
|
*
|
|
56
48
|
*/
|
|
57
|
-
abstract printCellAsValue(cellValue:OINODataCell,
|
|
49
|
+
abstract printCellAsValue(cellValue:OINODataCell, nativeType: string): string
|
|
58
50
|
|
|
59
51
|
/**
|
|
60
52
|
* Print a single string value as valid sql literal
|
|
@@ -69,10 +61,10 @@ export abstract class OINODataSource {
|
|
|
69
61
|
* type.
|
|
70
62
|
*
|
|
71
63
|
* @param sqlValue data from serialization
|
|
72
|
-
* @param
|
|
64
|
+
* @param nativeType native type name for table column
|
|
73
65
|
*
|
|
74
66
|
*/
|
|
75
|
-
abstract parseValueAsCell(sqlValue:OINODataCell,
|
|
67
|
+
abstract parseValueAsCell(sqlValue:OINODataCell, nativeType: string): OINODataCell
|
|
76
68
|
|
|
77
69
|
/**
|
|
78
70
|
* Initialize a data model by getting the SQL schema and populating OINODataFields of
|