asma-helpers 0.2.33 → 0.2.35
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/.prettierrc +15 -15
- package/.vscode/settings.json +39 -39
- package/README.md +0 -0
- package/lib/clients/srvAuth.d.ts +1 -1
- package/lib/clients/srvAuth.js +6 -6
- package/lib/global.d.ts +40 -39
- package/lib/global.d.ts.map +1 -1
- package/lib/global.js +4 -4
- package/lib/global.js.map +1 -1
- package/lib/helpers/CapitalizeFistLetter.d.ts +2 -2
- package/lib/helpers/CapitalizeFistLetter.js +6 -6
- package/lib/helpers/Config.d.ts +5 -5
- package/lib/helpers/Config.js +44 -44
- package/lib/helpers/EnvironmentToOperateTypes.d.ts +7 -7
- package/lib/helpers/EnvironmentToOperateTypes.js +8 -8
- package/lib/helpers/EnvironmentsUrls.d.ts +93 -93
- package/lib/helpers/EnvironmentsUrls.js +89 -89
- package/lib/helpers/FormatNumberConstants.d.ts +24 -24
- package/lib/helpers/FormatNumberConstants.js +40 -40
- package/lib/helpers/InitializeIDBListenersOnMstSnapshots.d.ts +1 -1
- package/lib/helpers/InitializeIDBListenersOnMstSnapshots.js +49 -49
- package/lib/helpers/InitializeIDBListenersOnMstSnapshotsThenCatch.d.ts +8 -8
- package/lib/helpers/InitializeIDBListenersOnMstSnapshotsThenCatch.js +68 -68
- package/lib/helpers/IsAdcuris.d.ts +2 -2
- package/lib/helpers/IsAdcuris.js +4 -4
- package/lib/helpers/IsNotEmpty.d.ts +1 -1
- package/lib/helpers/IsNotEmpty.js +3 -3
- package/lib/helpers/NorwegianPostalCodes.d.ts +8 -8
- package/lib/helpers/NorwegianPostalCodes.js +3 -3
- package/lib/helpers/ProcessServerError.d.ts +2 -2
- package/lib/helpers/ProcessServerError.js +100 -100
- package/lib/helpers/attachUserJournalCredentials.d.ts +1 -1
- package/lib/helpers/attachUserJournalCredentials.js +16 -16
- package/lib/helpers/base64ToFile.d.ts +1 -1
- package/lib/helpers/base64ToFile.js +8 -8
- package/lib/helpers/clearCacheData.d.ts +1 -1
- package/lib/helpers/clearCacheData.js +12 -12
- package/lib/helpers/generateEnvConfigsBindings.d.ts +30 -30
- package/lib/helpers/generateEnvConfigsBindings.js +48 -48
- package/lib/helpers/generateGenqlClient.d.ts +16 -16
- package/lib/helpers/generateGenqlClient.d.ts.map +1 -1
- package/lib/helpers/generateGenqlClient.js +77 -75
- package/lib/helpers/generateGenqlClient.js.map +1 -1
- package/lib/helpers/generateSrvAuthBindings.d.ts +36 -36
- package/lib/helpers/generateSrvAuthBindings.d.ts.map +1 -1
- package/lib/helpers/generateSrvAuthBindings.js +163 -153
- package/lib/helpers/generateSrvAuthBindings.js.map +1 -1
- package/lib/helpers/getGqlOperationName.d.ts +1 -1
- package/lib/helpers/getGqlOperationName.js +15 -15
- package/lib/helpers/getSubdomain.d.ts +12 -12
- package/lib/helpers/getSubdomain.js +39 -39
- package/lib/helpers/isValidUrl.d.ts +1 -1
- package/lib/helpers/isValidUrl.js +9 -9
- package/lib/helpers/parseJwt.d.ts +1 -1
- package/lib/helpers/parseJwt.js +7 -7
- package/lib/helpers/userTypingSignal.d.ts +4 -4
- package/lib/helpers/userTypingSignal.js +32 -32
- package/lib/index.d.ts +28 -28
- package/lib/index.js +26 -26
- package/lib/interfaces/api/advoca/ISaveToDataBase.d.ts +16 -16
- package/lib/interfaces/api/advoca/ISaveToDataBase.js +1 -1
- package/lib/interfaces/api/advoca/IUploadedDocument.d.ts +26 -26
- package/lib/interfaces/api/advoca/IUploadedDocument.js +1 -1
- package/lib/interfaces/enums.d.ts +50 -50
- package/lib/interfaces/enums.js +59 -59
- package/lib/utility/fetch.d.ts +1 -1
- package/lib/utility/fetch.js +5 -5
- package/package.json +29 -29
- package/src/clients/srvAuth.ts +6 -6
- package/src/global.ts +46 -45
- package/src/helpers/CapitalizeFistLetter.ts +7 -7
- package/src/helpers/Config.ts +58 -58
- package/src/helpers/EnvironmentToOperateTypes.ts +6 -6
- package/src/helpers/EnvironmentsUrls.ts +102 -102
- package/src/helpers/FormatNumberConstants.ts +41 -41
- package/src/helpers/InitializeIDBListenersOnMstSnapshots.ts +62 -62
- package/src/helpers/InitializeIDBListenersOnMstSnapshotsThenCatch.ts +82 -82
- package/src/helpers/IsAdcuris.ts +4 -4
- package/src/helpers/IsNotEmpty.ts +2 -2
- package/src/helpers/NorwegianPostalCodes.ts +6 -6
- package/src/helpers/ProcessServerError.ts +92 -92
- package/src/helpers/attachUserJournalCredentials.ts +23 -23
- package/src/helpers/base64ToFile.ts +9 -9
- package/src/helpers/clearCacheData.ts +15 -15
- package/src/helpers/generateEnvConfigsBindings.ts +82 -82
- package/src/helpers/generateGenqlClient.ts +110 -108
- package/src/helpers/generateSrvAuthBindings.ts +217 -204
- package/src/helpers/getGqlOperationName.ts +20 -20
- package/src/helpers/getSubdomain.ts +50 -50
- package/src/helpers/isValidUrl.ts +12 -12
- package/src/helpers/parseJwt.ts +10 -10
- package/src/index.ts +34 -34
- package/src/interfaces/api/advoca/ISaveToDataBase.ts +17 -17
- package/src/interfaces/api/advoca/IUploadedDocument.ts +23 -23
- package/src/interfaces/enums.ts +56 -56
- package/src/utility/fetch.ts +9 -9
- package/tsconfig.json +84 -84
package/lib/interfaces/enums.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
export var InitiatorTypes;
|
|
2
|
-
(function (InitiatorTypes) {
|
|
3
|
-
InitiatorTypes["Customer"] = "customer";
|
|
4
|
-
InitiatorTypes["Patient"] = "patient";
|
|
5
|
-
InitiatorTypes["SelfCompletable"] = "self-completable";
|
|
6
|
-
})(InitiatorTypes || (InitiatorTypes = {}));
|
|
7
|
-
export var QnrContextTypes;
|
|
8
|
-
(function (QnrContextTypes) {
|
|
9
|
-
QnrContextTypes["Advoca"] = "advoca";
|
|
10
|
-
QnrContextTypes["Portal"] = "portal";
|
|
11
|
-
QnrContextTypes["Outlook"] = "outlook";
|
|
12
|
-
})(QnrContextTypes || (QnrContextTypes = {}));
|
|
13
|
-
export var DocSignicatSignStatusTypes;
|
|
14
|
-
(function (DocSignicatSignStatusTypes) {
|
|
15
|
-
DocSignicatSignStatusTypes["Complteted"] = "completed";
|
|
16
|
-
DocSignicatSignStatusTypes["Rejected"] = "rejected";
|
|
17
|
-
DocSignicatSignStatusTypes["Waiting"] = "waiting";
|
|
18
|
-
})(DocSignicatSignStatusTypes || (DocSignicatSignStatusTypes = {}));
|
|
19
|
-
export var DocProxyStatusTypes;
|
|
20
|
-
(function (DocProxyStatusTypes) {
|
|
21
|
-
DocProxyStatusTypes["Signed"] = "signed";
|
|
22
|
-
DocProxyStatusTypes["WaitingForSigning"] = "waiting_for_signing";
|
|
23
|
-
DocProxyStatusTypes["OnlyForView"] = "only_for_view";
|
|
24
|
-
/* download = 'download',
|
|
25
|
-
uploaded = 'uploaded' */
|
|
26
|
-
})(DocProxyStatusTypes || (DocProxyStatusTypes = {}));
|
|
27
|
-
export var QuestionTypes;
|
|
28
|
-
(function (QuestionTypes) {
|
|
29
|
-
QuestionTypes["BooleanQuestion"] = "BooleanQuestion";
|
|
30
|
-
QuestionTypes["CheckBoxes"] = "CheckBoxes";
|
|
31
|
-
QuestionTypes["CompositeQuestion"] = "CompositeQuestion";
|
|
32
|
-
QuestionTypes["DateField"] = "DateField";
|
|
33
|
-
QuestionTypes["Dropdown"] = "Dropdown";
|
|
34
|
-
QuestionTypes["FormatNumber"] = "FormatNumber";
|
|
35
|
-
QuestionTypes["LinearScale"] = "LinearScale";
|
|
36
|
-
QuestionTypes["Link"] = "Link";
|
|
37
|
-
QuestionTypes["RadioButtons"] = "RadioButtons";
|
|
38
|
-
QuestionTypes["TextLong"] = "TextLong";
|
|
39
|
-
QuestionTypes["TextShort"] = "TextShort";
|
|
40
|
-
QuestionTypes["Emoticons"] = "Emoticons";
|
|
41
|
-
QuestionTypes["DocumentUpload"] = "DocumentUpload";
|
|
42
|
-
QuestionTypes["Readonly"] = "Readonly";
|
|
43
|
-
QuestionTypes["ExpressionQuestion"] = "ExpressionQuestion";
|
|
44
|
-
QuestionTypes["Chart"] = "Chart";
|
|
45
|
-
})(QuestionTypes || (QuestionTypes = {}));
|
|
46
|
-
export var ActorTypes;
|
|
47
|
-
(function (ActorTypes) {
|
|
48
|
-
ActorTypes["Mappable"] = "mappable";
|
|
49
|
-
ActorTypes["Custom"] = "custom";
|
|
50
|
-
ActorTypes["Complex"] = "complex";
|
|
51
|
-
})(ActorTypes || (ActorTypes = {}));
|
|
52
|
-
export var EnvironmentEnums;
|
|
53
|
-
(function (EnvironmentEnums) {
|
|
54
|
-
EnvironmentEnums["local"] = "local";
|
|
55
|
-
EnvironmentEnums["dev"] = "dev";
|
|
56
|
-
EnvironmentEnums["test"] = "test";
|
|
57
|
-
EnvironmentEnums["stage"] = "stage";
|
|
58
|
-
EnvironmentEnums["prod"] = "prod";
|
|
59
|
-
})(EnvironmentEnums || (EnvironmentEnums = {}));
|
|
1
|
+
export var InitiatorTypes;
|
|
2
|
+
(function (InitiatorTypes) {
|
|
3
|
+
InitiatorTypes["Customer"] = "customer";
|
|
4
|
+
InitiatorTypes["Patient"] = "patient";
|
|
5
|
+
InitiatorTypes["SelfCompletable"] = "self-completable";
|
|
6
|
+
})(InitiatorTypes || (InitiatorTypes = {}));
|
|
7
|
+
export var QnrContextTypes;
|
|
8
|
+
(function (QnrContextTypes) {
|
|
9
|
+
QnrContextTypes["Advoca"] = "advoca";
|
|
10
|
+
QnrContextTypes["Portal"] = "portal";
|
|
11
|
+
QnrContextTypes["Outlook"] = "outlook";
|
|
12
|
+
})(QnrContextTypes || (QnrContextTypes = {}));
|
|
13
|
+
export var DocSignicatSignStatusTypes;
|
|
14
|
+
(function (DocSignicatSignStatusTypes) {
|
|
15
|
+
DocSignicatSignStatusTypes["Complteted"] = "completed";
|
|
16
|
+
DocSignicatSignStatusTypes["Rejected"] = "rejected";
|
|
17
|
+
DocSignicatSignStatusTypes["Waiting"] = "waiting";
|
|
18
|
+
})(DocSignicatSignStatusTypes || (DocSignicatSignStatusTypes = {}));
|
|
19
|
+
export var DocProxyStatusTypes;
|
|
20
|
+
(function (DocProxyStatusTypes) {
|
|
21
|
+
DocProxyStatusTypes["Signed"] = "signed";
|
|
22
|
+
DocProxyStatusTypes["WaitingForSigning"] = "waiting_for_signing";
|
|
23
|
+
DocProxyStatusTypes["OnlyForView"] = "only_for_view";
|
|
24
|
+
/* download = 'download',
|
|
25
|
+
uploaded = 'uploaded' */
|
|
26
|
+
})(DocProxyStatusTypes || (DocProxyStatusTypes = {}));
|
|
27
|
+
export var QuestionTypes;
|
|
28
|
+
(function (QuestionTypes) {
|
|
29
|
+
QuestionTypes["BooleanQuestion"] = "BooleanQuestion";
|
|
30
|
+
QuestionTypes["CheckBoxes"] = "CheckBoxes";
|
|
31
|
+
QuestionTypes["CompositeQuestion"] = "CompositeQuestion";
|
|
32
|
+
QuestionTypes["DateField"] = "DateField";
|
|
33
|
+
QuestionTypes["Dropdown"] = "Dropdown";
|
|
34
|
+
QuestionTypes["FormatNumber"] = "FormatNumber";
|
|
35
|
+
QuestionTypes["LinearScale"] = "LinearScale";
|
|
36
|
+
QuestionTypes["Link"] = "Link";
|
|
37
|
+
QuestionTypes["RadioButtons"] = "RadioButtons";
|
|
38
|
+
QuestionTypes["TextLong"] = "TextLong";
|
|
39
|
+
QuestionTypes["TextShort"] = "TextShort";
|
|
40
|
+
QuestionTypes["Emoticons"] = "Emoticons";
|
|
41
|
+
QuestionTypes["DocumentUpload"] = "DocumentUpload";
|
|
42
|
+
QuestionTypes["Readonly"] = "Readonly";
|
|
43
|
+
QuestionTypes["ExpressionQuestion"] = "ExpressionQuestion";
|
|
44
|
+
QuestionTypes["Chart"] = "Chart";
|
|
45
|
+
})(QuestionTypes || (QuestionTypes = {}));
|
|
46
|
+
export var ActorTypes;
|
|
47
|
+
(function (ActorTypes) {
|
|
48
|
+
ActorTypes["Mappable"] = "mappable";
|
|
49
|
+
ActorTypes["Custom"] = "custom";
|
|
50
|
+
ActorTypes["Complex"] = "complex";
|
|
51
|
+
})(ActorTypes || (ActorTypes = {}));
|
|
52
|
+
export var EnvironmentEnums;
|
|
53
|
+
(function (EnvironmentEnums) {
|
|
54
|
+
EnvironmentEnums["local"] = "local";
|
|
55
|
+
EnvironmentEnums["dev"] = "dev";
|
|
56
|
+
EnvironmentEnums["test"] = "test";
|
|
57
|
+
EnvironmentEnums["stage"] = "stage";
|
|
58
|
+
EnvironmentEnums["prod"] = "prod";
|
|
59
|
+
})(EnvironmentEnums || (EnvironmentEnums = {}));
|
|
60
60
|
//# sourceMappingURL=enums.js.map
|
package/lib/utility/fetch.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function http<R>(request: RequestInfo, init?: RequestInit): Promise<R>;
|
|
1
|
+
export declare function http<R>(request: RequestInfo, init?: RequestInit): Promise<R>;
|
|
2
2
|
//# sourceMappingURL=fetch.d.ts.map
|
package/lib/utility/fetch.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export async function http(request, init) {
|
|
2
|
-
const response = await fetch(request, init);
|
|
3
|
-
const body = await response.json();
|
|
4
|
-
return body;
|
|
5
|
-
}
|
|
1
|
+
export async function http(request, init) {
|
|
2
|
+
const response = await fetch(request, init);
|
|
3
|
+
const body = await response.json();
|
|
4
|
+
return body;
|
|
5
|
+
}
|
|
6
6
|
//# sourceMappingURL=fetch.js.map
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "asma-helpers",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "helpers methods for asma",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"types": "lib",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "npx tsc && npx tsc -p ."
|
|
10
|
-
},
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://avanssoma@dev.azure.com/avanssoma/Arbeidoginkludering/_git/asma-helpers"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [],
|
|
16
|
-
"author": "",
|
|
17
|
-
"license": "MIT",
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"typescript": "^4.9.3"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@genql/runtime": "^2.10.0",
|
|
23
|
-
"axios": "
|
|
24
|
-
"history": "~5.0.0",
|
|
25
|
-
"idb-keyval": "^6.2.0",
|
|
26
|
-
"mobx": "^6.6.1",
|
|
27
|
-
"mobx-state-tree": "^5.1.5"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "asma-helpers",
|
|
3
|
+
"version": "0.2.35",
|
|
4
|
+
"description": "helpers methods for asma",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "npx tsc && npx tsc -p ."
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://avanssoma@dev.azure.com/avanssoma/Arbeidoginkludering/_git/asma-helpers"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^4.9.3"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@genql/runtime": "^2.10.0",
|
|
23
|
+
"axios": "1.0.0",
|
|
24
|
+
"history": "~5.0.0",
|
|
25
|
+
"idb-keyval": "^6.2.0",
|
|
26
|
+
"mobx": "^6.6.1",
|
|
27
|
+
"mobx-state-tree": "^5.1.5"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/clients/srvAuth.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { http } from "../utility/fetch";
|
|
2
|
-
|
|
3
|
-
export async function srvAuthGet<R>(url: string, headers?: Headers) {
|
|
4
|
-
return http<R>(url,{
|
|
5
|
-
headers
|
|
6
|
-
})
|
|
1
|
+
import { http } from "../utility/fetch";
|
|
2
|
+
|
|
3
|
+
export async function srvAuthGet<R>(url: string, headers?: Headers) {
|
|
4
|
+
return http<R>(url,{
|
|
5
|
+
headers
|
|
6
|
+
})
|
|
7
7
|
}
|
package/src/global.ts
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
import { type History, createBrowserHistory } from 'history'
|
|
2
|
-
//import type { IGenerateSRVAuthBindings } from './helpers/generateSrvAuthBindings'
|
|
3
|
-
//import type { IGenerateSRVAuthBindings } from './helpers/generateSrvAuthBindings'
|
|
4
|
-
export {}
|
|
5
|
-
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
__ENV?: Record<string, string>
|
|
9
|
-
__ENV_MICRO: {
|
|
10
|
-
[key: string]: Record<string, string>
|
|
11
|
-
}
|
|
12
|
-
__MICROAPP_REGISTRY?: {
|
|
13
|
-
name: string
|
|
14
|
-
entry: string
|
|
15
|
-
container: string
|
|
16
|
-
loader: (loading: boolean) => void
|
|
17
|
-
activeRule: string
|
|
18
|
-
}[]
|
|
19
|
-
__ASMA__SHELL__?: {
|
|
20
|
-
history?: History
|
|
21
|
-
auth_bindings?: unknown //IGenerateSRVAuthBindings
|
|
22
|
-
isLogged?: () => boolean
|
|
23
|
-
logoutUser?: () => void
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import { type History, createBrowserHistory } from 'history'
|
|
2
|
+
//import type { IGenerateSRVAuthBindings } from './helpers/generateSrvAuthBindings'
|
|
3
|
+
//import type { IGenerateSRVAuthBindings } from './helpers/generateSrvAuthBindings'
|
|
4
|
+
export {}
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
__ENV?: Record<string, string>
|
|
9
|
+
__ENV_MICRO: {
|
|
10
|
+
[key: string]: Record<string, string>
|
|
11
|
+
}
|
|
12
|
+
__MICROAPP_REGISTRY?: {
|
|
13
|
+
name: string
|
|
14
|
+
entry: string
|
|
15
|
+
container: string
|
|
16
|
+
loader: (loading: boolean) => void
|
|
17
|
+
activeRule: string
|
|
18
|
+
}[]
|
|
19
|
+
__ASMA__SHELL__?: {
|
|
20
|
+
history?: History
|
|
21
|
+
auth_bindings?: unknown //IGenerateSRVAuthBindings
|
|
22
|
+
isLogged?: () => boolean
|
|
23
|
+
logoutUser?: () => void
|
|
24
|
+
logoutMfes?: (() => void)[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_env_cloud?: Record<'adopus' | 'adcuris', Record<string, string>>
|
|
28
|
+
_srvUrls?: Record<string, string>
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated
|
|
31
|
+
* DONT'T USE THIS FIELD ANYMORE
|
|
32
|
+
* WILL BE REMOVED AT NEXT MAJOR RELEASE
|
|
33
|
+
*/
|
|
34
|
+
isLogged: boolean
|
|
35
|
+
/**
|
|
36
|
+
* @warning
|
|
37
|
+
* In MicroApps use window.__ASMA__SHELL__.logoutUser
|
|
38
|
+
*/
|
|
39
|
+
logoutUser: () => void
|
|
40
|
+
wsConnection: any
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const history = window.__ASMA__SHELL__?.history || createBrowserHistory()
|
|
45
|
+
|
|
46
|
+
export { History, createBrowserHistory }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function capitalizeFirstLetter(str: string) {
|
|
2
|
-
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function toLowercaseAndCapitalizeFirstLetter(str: string) {
|
|
6
|
-
return str.toLowerCase().charAt(0).toUpperCase() + str.slice(1)
|
|
7
|
-
}
|
|
1
|
+
export function capitalizeFirstLetter(str: string) {
|
|
2
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function toLowercaseAndCapitalizeFirstLetter(str: string) {
|
|
6
|
+
return str.toLowerCase().charAt(0).toUpperCase() + str.slice(1)
|
|
7
|
+
}
|
package/src/helpers/Config.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
type ObjectType<T> = T extends string ? string : T extends boolean ? boolean : never
|
|
2
|
-
|
|
3
|
-
export function config<T>(env_var: string, default_value: T): ObjectType<T> {
|
|
4
|
-
const srv_url = getDynamicSrvUrl(env_var)
|
|
5
|
-
|
|
6
|
-
if (srv_url) {
|
|
7
|
-
return srv_url as ObjectType<T>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const connector =
|
|
11
|
-
(window.location.host.includes('adopus.no') && 'adopus') ||
|
|
12
|
-
(window.location.host.includes('adcuris.no') && 'adcuris') ||
|
|
13
|
-
undefined
|
|
14
|
-
|
|
15
|
-
if (connector) {
|
|
16
|
-
return (window._env_cloud?.[connector]?.[env_var] ?? default_value) as ObjectType<T>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return window.__ENV?.[env_var] as ObjectType<T>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function configWeb<T>(env_var: string, default_value: T): ObjectType<T> {
|
|
23
|
-
const srv_url = getDynamicSrvUrl(env_var)
|
|
24
|
-
|
|
25
|
-
if (srv_url) {
|
|
26
|
-
return srv_url as ObjectType<T>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return (window.__ENV?.[env_var] ?? default_value) as ObjectType<T>
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getDynamicSrvUrl(env_var: string) {
|
|
33
|
-
if (env_var.startsWith('SRV')) {
|
|
34
|
-
const env_name = env_var.replace('SRV_', '').toLowerCase()
|
|
35
|
-
|
|
36
|
-
const srv_url = window._srvUrls?.[env_name]
|
|
37
|
-
if (srv_url) {
|
|
38
|
-
return srv_url
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function httpToWs(url: string) {
|
|
45
|
-
url = absoluteUrl(url)
|
|
46
|
-
|
|
47
|
-
return url.replace('http', 'ws').replace('https', 'wss')
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function absoluteUrl(url: string) {
|
|
51
|
-
if (url.startsWith('http') || url.startsWith('https')) {
|
|
52
|
-
return url
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
url = window.location.origin + url
|
|
56
|
-
|
|
57
|
-
return url
|
|
58
|
-
}
|
|
1
|
+
type ObjectType<T> = T extends string ? string : T extends boolean ? boolean : never
|
|
2
|
+
|
|
3
|
+
export function config<T>(env_var: string, default_value: T): ObjectType<T> {
|
|
4
|
+
const srv_url = getDynamicSrvUrl(env_var)
|
|
5
|
+
|
|
6
|
+
if (srv_url) {
|
|
7
|
+
return srv_url as ObjectType<T>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const connector =
|
|
11
|
+
(window.location.host.includes('adopus.no') && 'adopus') ||
|
|
12
|
+
(window.location.host.includes('adcuris.no') && 'adcuris') ||
|
|
13
|
+
undefined
|
|
14
|
+
|
|
15
|
+
if (connector) {
|
|
16
|
+
return (window._env_cloud?.[connector]?.[env_var] ?? default_value) as ObjectType<T>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return window.__ENV?.[env_var] as ObjectType<T>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function configWeb<T>(env_var: string, default_value: T): ObjectType<T> {
|
|
23
|
+
const srv_url = getDynamicSrvUrl(env_var)
|
|
24
|
+
|
|
25
|
+
if (srv_url) {
|
|
26
|
+
return srv_url as ObjectType<T>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (window.__ENV?.[env_var] ?? default_value) as ObjectType<T>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getDynamicSrvUrl(env_var: string) {
|
|
33
|
+
if (env_var.startsWith('SRV')) {
|
|
34
|
+
const env_name = env_var.replace('SRV_', '').toLowerCase()
|
|
35
|
+
|
|
36
|
+
const srv_url = window._srvUrls?.[env_name]
|
|
37
|
+
if (srv_url) {
|
|
38
|
+
return srv_url
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function httpToWs(url: string) {
|
|
45
|
+
url = absoluteUrl(url)
|
|
46
|
+
|
|
47
|
+
return url.replace('http', 'ws').replace('https', 'wss')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function absoluteUrl(url: string) {
|
|
51
|
+
if (url.startsWith('http') || url.startsWith('https')) {
|
|
52
|
+
return url
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
url = window.location.origin + url
|
|
56
|
+
|
|
57
|
+
return url
|
|
58
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export enum EnvironmentToOperateTypes {
|
|
2
|
-
Local = 'local',
|
|
3
|
-
Dev = 'dev',
|
|
4
|
-
Test = 'test',
|
|
5
|
-
Stage ='stage',
|
|
6
|
-
Prod = 'prod'
|
|
1
|
+
export enum EnvironmentToOperateTypes {
|
|
2
|
+
Local = 'local',
|
|
3
|
+
Dev = 'dev',
|
|
4
|
+
Test = 'test',
|
|
5
|
+
Stage ='stage',
|
|
6
|
+
Prod = 'prod'
|
|
7
7
|
}
|