@oino-ts/db 0.4.2 → 0.4.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/dist/cjs/OINODbApi.js +18 -20
- package/dist/esm/OINODbApi.js +18 -20
- package/dist/types/OINODbApi.d.ts +5 -5
- package/package.json +3 -3
- package/src/OINODbApi.ts +16 -18
package/dist/cjs/OINODbApi.js
CHANGED
|
@@ -59,39 +59,37 @@ exports.OINODbApiResult = OINODbApiResult;
|
|
|
59
59
|
*
|
|
60
60
|
*/
|
|
61
61
|
class OINODbHtmlTemplate extends index_js_1.OINOHtmlTemplate {
|
|
62
|
-
/**
|
|
63
|
-
|
|
62
|
+
/** Locale validation regex */
|
|
63
|
+
static LOCALE_REGEX = /^(\w\w)(\-\w\w)?$/;
|
|
64
64
|
/** Locale formatter */
|
|
65
65
|
_locale;
|
|
66
66
|
/**
|
|
67
67
|
* Constructor of OINODbHtmlTemplate.
|
|
68
68
|
*
|
|
69
69
|
* @param template HTML template string
|
|
70
|
-
* @param
|
|
71
|
-
* @param
|
|
70
|
+
* @param dateLocaleStr Datetime format string, either "iso" for ISO8601 or "default" for system default or valid locale string
|
|
71
|
+
* @param dateLocaleStyle Datetime format style, either "short/medium/long/full" or Intl.DateTimeFormat options
|
|
72
72
|
*
|
|
73
73
|
*/
|
|
74
|
-
constructor(template,
|
|
74
|
+
constructor(template, dateLocaleStr, dateLocaleStyle) {
|
|
75
75
|
super(template);
|
|
76
|
-
|
|
76
|
+
console.log("OINODbHtmlTemplate.constructor", { dateLocaleStr: dateLocaleStr, dateLocaleStyle: dateLocaleStyle });
|
|
77
77
|
let locale_opts;
|
|
78
|
-
if (
|
|
79
|
-
locale_opts = { dateStyle:
|
|
78
|
+
if ((dateLocaleStyle == null) || (dateLocaleStyle == "")) {
|
|
79
|
+
locale_opts = { dateStyle: "medium", timeStyle: "medium" };
|
|
80
80
|
}
|
|
81
|
-
else {
|
|
82
|
-
locale_opts =
|
|
83
|
-
}
|
|
84
|
-
if ((localeStr == "iso") || (localeStr == "") || (supported_locales.length == 0)) {
|
|
85
|
-
this._locale = null;
|
|
86
|
-
this.localeStr = "iso";
|
|
87
|
-
}
|
|
88
|
-
else if (localeStr == "default") {
|
|
89
|
-
this._locale = new Intl.DateTimeFormat(undefined, locale_opts);
|
|
90
|
-
this.localeStr = "default";
|
|
81
|
+
else if (typeof dateLocaleStyle == "string") {
|
|
82
|
+
locale_opts = { dateStyle: dateLocaleStyle, timeStyle: dateLocaleStyle };
|
|
91
83
|
}
|
|
92
84
|
else {
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
locale_opts = dateLocaleStyle;
|
|
86
|
+
}
|
|
87
|
+
this._locale = null;
|
|
88
|
+
if ((dateLocaleStr != null) && (dateLocaleStr != "") && OINODbHtmlTemplate.LOCALE_REGEX.test(dateLocaleStr)) {
|
|
89
|
+
try {
|
|
90
|
+
this._locale = new Intl.DateTimeFormat(dateLocaleStr, locale_opts);
|
|
91
|
+
}
|
|
92
|
+
catch (e) { }
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
/**
|
package/dist/esm/OINODbApi.js
CHANGED
|
@@ -55,39 +55,37 @@ export class OINODbApiResult extends OINOResult {
|
|
|
55
55
|
*
|
|
56
56
|
*/
|
|
57
57
|
export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
58
|
-
/**
|
|
59
|
-
|
|
58
|
+
/** Locale validation regex */
|
|
59
|
+
static LOCALE_REGEX = /^(\w\w)(\-\w\w)?$/;
|
|
60
60
|
/** Locale formatter */
|
|
61
61
|
_locale;
|
|
62
62
|
/**
|
|
63
63
|
* Constructor of OINODbHtmlTemplate.
|
|
64
64
|
*
|
|
65
65
|
* @param template HTML template string
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
66
|
+
* @param dateLocaleStr Datetime format string, either "iso" for ISO8601 or "default" for system default or valid locale string
|
|
67
|
+
* @param dateLocaleStyle Datetime format style, either "short/medium/long/full" or Intl.DateTimeFormat options
|
|
68
68
|
*
|
|
69
69
|
*/
|
|
70
|
-
constructor(template,
|
|
70
|
+
constructor(template, dateLocaleStr, dateLocaleStyle) {
|
|
71
71
|
super(template);
|
|
72
|
-
|
|
72
|
+
console.log("OINODbHtmlTemplate.constructor", { dateLocaleStr: dateLocaleStr, dateLocaleStyle: dateLocaleStyle });
|
|
73
73
|
let locale_opts;
|
|
74
|
-
if (
|
|
75
|
-
locale_opts = { dateStyle:
|
|
74
|
+
if ((dateLocaleStyle == null) || (dateLocaleStyle == "")) {
|
|
75
|
+
locale_opts = { dateStyle: "medium", timeStyle: "medium" };
|
|
76
76
|
}
|
|
77
|
-
else {
|
|
78
|
-
locale_opts =
|
|
79
|
-
}
|
|
80
|
-
if ((localeStr == "iso") || (localeStr == "") || (supported_locales.length == 0)) {
|
|
81
|
-
this._locale = null;
|
|
82
|
-
this.localeStr = "iso";
|
|
83
|
-
}
|
|
84
|
-
else if (localeStr == "default") {
|
|
85
|
-
this._locale = new Intl.DateTimeFormat(undefined, locale_opts);
|
|
86
|
-
this.localeStr = "default";
|
|
77
|
+
else if (typeof dateLocaleStyle == "string") {
|
|
78
|
+
locale_opts = { dateStyle: dateLocaleStyle, timeStyle: dateLocaleStyle };
|
|
87
79
|
}
|
|
88
80
|
else {
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
locale_opts = dateLocaleStyle;
|
|
82
|
+
}
|
|
83
|
+
this._locale = null;
|
|
84
|
+
if ((dateLocaleStr != null) && (dateLocaleStr != "") && OINODbHtmlTemplate.LOCALE_REGEX.test(dateLocaleStr)) {
|
|
85
|
+
try {
|
|
86
|
+
this._locale = new Intl.DateTimeFormat(dateLocaleStr, locale_opts);
|
|
87
|
+
}
|
|
88
|
+
catch (e) { }
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
/**
|
|
@@ -32,19 +32,19 @@ export declare class OINODbApiResult extends OINOResult {
|
|
|
32
32
|
*
|
|
33
33
|
*/
|
|
34
34
|
export declare class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
35
|
-
/**
|
|
36
|
-
|
|
35
|
+
/** Locale validation regex */
|
|
36
|
+
static LOCALE_REGEX: RegExp;
|
|
37
37
|
/** Locale formatter */
|
|
38
38
|
protected _locale: Intl.DateTimeFormat | null;
|
|
39
39
|
/**
|
|
40
40
|
* Constructor of OINODbHtmlTemplate.
|
|
41
41
|
*
|
|
42
42
|
* @param template HTML template string
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
43
|
+
* @param dateLocaleStr Datetime format string, either "iso" for ISO8601 or "default" for system default or valid locale string
|
|
44
|
+
* @param dateLocaleStyle Datetime format style, either "short/medium/long/full" or Intl.DateTimeFormat options
|
|
45
45
|
*
|
|
46
46
|
*/
|
|
47
|
-
constructor(template: string,
|
|
47
|
+
constructor(template: string, dateLocaleStr?: string, dateLocaleStyle?: string | any);
|
|
48
48
|
/**
|
|
49
49
|
* Creates HTML Response from API modelset.
|
|
50
50
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/db",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "OINO TS library package for publishing an SQL database tables as a REST API.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"module": "./dist/esm/index.js",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@oino-ts/common": "0.4.
|
|
22
|
+
"@oino-ts/common": "0.4.4"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^20.14.10",
|
|
26
26
|
"@types/bun": "^1.1.14",
|
|
27
|
-
"@oino-ts/types": "0.4.
|
|
27
|
+
"@oino-ts/types": "0.4.4",
|
|
28
28
|
"typedoc": "^0.25.13"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
package/src/OINODbApi.ts
CHANGED
|
@@ -61,8 +61,8 @@ export class OINODbApiResult extends OINOResult {
|
|
|
61
61
|
*
|
|
62
62
|
*/
|
|
63
63
|
export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
64
|
-
/**
|
|
65
|
-
|
|
64
|
+
/** Locale validation regex */
|
|
65
|
+
static LOCALE_REGEX:RegExp = /^(\w\w)(\-\w\w)?$/
|
|
66
66
|
/** Locale formatter */
|
|
67
67
|
protected _locale:Intl.DateTimeFormat|null
|
|
68
68
|
|
|
@@ -70,29 +70,27 @@ export class OINODbHtmlTemplate extends OINOHtmlTemplate {
|
|
|
70
70
|
* Constructor of OINODbHtmlTemplate.
|
|
71
71
|
*
|
|
72
72
|
* @param template HTML template string
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
73
|
+
* @param dateLocaleStr Datetime format string, either "iso" for ISO8601 or "default" for system default or valid locale string
|
|
74
|
+
* @param dateLocaleStyle Datetime format style, either "short/medium/long/full" or Intl.DateTimeFormat options
|
|
75
75
|
*
|
|
76
76
|
*/
|
|
77
|
-
constructor (template:string,
|
|
77
|
+
constructor (template:string, dateLocaleStr?:string, dateLocaleStyle?:string|any) {
|
|
78
78
|
super(template)
|
|
79
|
-
|
|
79
|
+
console.log("OINODbHtmlTemplate.constructor", {dateLocaleStr:dateLocaleStr, dateLocaleStyle:dateLocaleStyle})
|
|
80
80
|
let locale_opts:any
|
|
81
|
-
if (
|
|
82
|
-
locale_opts = { dateStyle:
|
|
81
|
+
if ((dateLocaleStyle == null) || (dateLocaleStyle == "")) {
|
|
82
|
+
locale_opts = { dateStyle: "medium", timeStyle: "medium" }
|
|
83
|
+
} else if (typeof dateLocaleStyle == "string") {
|
|
84
|
+
locale_opts = { dateStyle: dateLocaleStyle, timeStyle: dateLocaleStyle }
|
|
83
85
|
} else {
|
|
84
|
-
locale_opts =
|
|
86
|
+
locale_opts = dateLocaleStyle
|
|
85
87
|
}
|
|
88
|
+
this._locale = null
|
|
86
89
|
|
|
87
|
-
if ((
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this._locale = new Intl.DateTimeFormat(undefined, locale_opts)
|
|
92
|
-
this.localeStr = "default"
|
|
93
|
-
} else {
|
|
94
|
-
this.localeStr = supported_locales[0]
|
|
95
|
-
this._locale = new Intl.DateTimeFormat(supported_locales[0], locale_opts)
|
|
90
|
+
if ((dateLocaleStr != null) && (dateLocaleStr != "") && OINODbHtmlTemplate.LOCALE_REGEX.test(dateLocaleStr)) {
|
|
91
|
+
try {
|
|
92
|
+
this._locale = new Intl.DateTimeFormat(dateLocaleStr, locale_opts)
|
|
93
|
+
} catch (e:any) {}
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
96
|
|