asma-helpers 0.2.11 → 0.2.13
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 +39 -39
- package/lib/global.js +4 -4
- 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 -81
- package/lib/helpers/EnvironmentsUrls.d.ts.map +1 -1
- package/lib/helpers/EnvironmentsUrls.js +89 -79
- package/lib/helpers/EnvironmentsUrls.js.map +1 -1
- 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/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 -28
- package/lib/helpers/generateEnvConfigsBindings.d.ts.map +1 -1
- package/lib/helpers/generateEnvConfigsBindings.js +48 -48
- package/lib/helpers/generateGenqlClient.d.ts +18 -18
- package/lib/helpers/generateGenqlClient.js +56 -56
- package/lib/helpers/generateSrvAuthBindings.d.ts +33 -33
- package/lib/helpers/generateSrvAuthBindings.js +163 -163
- package/lib/helpers/getGqlOperationName.d.ts +1 -1
- package/lib/helpers/getGqlOperationName.js +15 -15
- package/lib/helpers/getSubdomain.d.ts +3 -3
- package/lib/helpers/getSubdomain.js +27 -27
- 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 +27 -27
- package/lib/index.js +25 -25
- 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 +30 -30
- package/src/clients/srvAuth.ts +6 -6
- package/src/global.ts +45 -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 -92
- 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/base64ToFile.ts +9 -9
- package/src/helpers/clearCacheData.ts +15 -15
- package/src/helpers/generateEnvConfigsBindings.ts +82 -82
- package/src/helpers/generateGenqlClient.ts +85 -85
- package/src/helpers/generateSrvAuthBindings.ts +215 -215
- package/src/helpers/getGqlOperationName.ts +20 -20
- package/src/helpers/getSubdomain.ts +40 -40
- package/src/helpers/isValidUrl.ts +12 -12
- package/src/helpers/parseJwt.ts +10 -10
- package/src/index.ts +33 -33
- 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/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
|
}
|
|
@@ -1,92 +1,102 @@
|
|
|
1
|
-
import { configWeb, EnvironmentEnums } from '..'
|
|
2
|
-
|
|
3
|
-
export const EnvironmentsUrls = {
|
|
4
|
-
local: {
|
|
5
|
-
SRV_DIRECTORY: `http://${window.location.hostname}:7001`,
|
|
6
|
-
SRV_CALENDAR: `http://${window.location.hostname}:7011`,
|
|
7
|
-
SRV_PROXY_OLD: `http://${window.location.hostname}:4430`,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
import { configWeb, EnvironmentEnums } from '..'
|
|
2
|
+
|
|
3
|
+
export const EnvironmentsUrls = {
|
|
4
|
+
local: {
|
|
5
|
+
SRV_DIRECTORY: `http://${window.location.hostname}:7001`,
|
|
6
|
+
SRV_CALENDAR: `http://${window.location.hostname}:7011`,
|
|
7
|
+
SRV_PROXY_OLD: `http://${window.location.hostname}:4430`,
|
|
8
|
+
SRV_PROXY_OLD_HELSE: `http://${window.location.hostname}:4430/helse`,
|
|
9
|
+
SRV_PROXY_OLD_WEB: `http://${window.location.hostname}:4430/helse`,
|
|
10
|
+
SRV_STORAGE: `http://${window.location.hostname}:4000`,
|
|
11
|
+
SRV_CHAT: `http://${window.location.hostname}:7012`,
|
|
12
|
+
SRV_CONNECTOR: 'https://connector-dev.adopus.no',
|
|
13
|
+
SRV_ARTIFACT: '',
|
|
14
|
+
SRV_ADVOCA: `http://${window.location.hostname}:4433`,
|
|
15
|
+
SRV_PROXY: `http://${window.location.hostname}:7003`,
|
|
16
|
+
SRV_NOTIFICATION: `http://${window.location.hostname}:7002`,
|
|
17
|
+
|
|
18
|
+
SRV_AO_DIRECTORY: `http://${window.location.hostname}:7013`,
|
|
19
|
+
},
|
|
20
|
+
dev: {
|
|
21
|
+
SRV_DIRECTORY: 'https://dev.adopus.no/api/directory',
|
|
22
|
+
SRV_CALENDAR: 'https://dev.adopus.no/api/calendar',
|
|
23
|
+
SRV_PROXY_OLD: 'https://dev.adopus.no/api/proxy',
|
|
24
|
+
SRV_PROXY_OLD_HELSE: 'https://dev.adopus.no/api/proxy/helse',
|
|
25
|
+
SRV_PROXY_OLD_WEB: 'https://dev.adopus.no/api/proxy/web',
|
|
26
|
+
SRV_STORAGE: 'https://dev.adopus.no/api/storage',
|
|
27
|
+
SRV_CHAT: 'https://dev.adopus.no/api/chat',
|
|
28
|
+
SRV_CONNECTOR: 'https://connector-test.adopus.no',
|
|
29
|
+
SRV_ARTIFACT: '',
|
|
30
|
+
SRV_ADVOCA: 'https://dev.advoca.no/api/service',
|
|
31
|
+
SRV_PROXY: 'https://dev.adopus.no/api/srvproxy',
|
|
32
|
+
SRV_NOTIFICATION: 'https://dev.adopus.no/api/notification',
|
|
33
|
+
|
|
34
|
+
SRV_AO_DIRECTORY: 'https://dev.adopus.no/api-ao/directory',
|
|
35
|
+
},
|
|
36
|
+
test: {
|
|
37
|
+
SRV_DIRECTORY: 'https://test.adopus.no/api/directory',
|
|
38
|
+
SRV_CALENDAR: 'https://test.adopus.no/api/calendar',
|
|
39
|
+
SRV_PROXY_OLD: 'https://test.adopus.no/api/proxy',
|
|
40
|
+
SRV_PROXY_OLD_HELSE: 'https://test.adopus.no/api/proxy/helse',
|
|
41
|
+
SRV_PROXY_OLD_WEB: 'https://test.adopus.no/api/proxy/web',
|
|
42
|
+
SRV_STORAGE: 'https://test.adopus.no/api/storage',
|
|
43
|
+
SRV_CHAT: 'https://test.adopus.no/api/chat',
|
|
44
|
+
SRV_CONNECTOR: 'https://connector-test.adopus.no',
|
|
45
|
+
SRV_ARTIFACT: '',
|
|
46
|
+
SRV_ADVOCA: 'https://test.advoca.no/api/service',
|
|
47
|
+
SRV_PROXY: 'https://test.adopus.no/api/srvproxy',
|
|
48
|
+
SRV_NOTIFICATION: 'https://test.adopus.no/api/notification',
|
|
49
|
+
|
|
50
|
+
SRV_AO_DIRECTORY: 'https://test.adopus.no/api-ao/directory',
|
|
51
|
+
},
|
|
52
|
+
stage: {
|
|
53
|
+
SRV_DIRECTORY: 'https://stage.adopus.no/api/directory',
|
|
54
|
+
SRV_CALENDAR: 'https://stage.adopus.no/api/calendar',
|
|
55
|
+
SRV_PROXY_OLD: 'https://stage.adopus.no/api/proxy',
|
|
56
|
+
SRV_PROXY_OLD_HELSE: 'https://stage.adopus.no/api/proxy/helse',
|
|
57
|
+
SRV_PROXY_OLD_WEB: 'https://stage.adopus.no/api/proxy/web',
|
|
58
|
+
SRV_STORAGE: 'https://stage.adopus.no/api/storage',
|
|
59
|
+
SRV_CHAT: 'https://stage.adopus.no/api/chat',
|
|
60
|
+
SRV_CONNECTOR: 'https://connector.adopus.no/stage',
|
|
61
|
+
SRV_ARTIFACT: '',
|
|
62
|
+
SRV_ADVOCA: 'https://stage.advoca.no/api/service',
|
|
63
|
+
SRV_PROXY: 'https://stage.adopus.no/api/srvproxy',
|
|
64
|
+
SRV_NOTIFICATION: 'https://stage.adopus.no/api/notification',
|
|
65
|
+
|
|
66
|
+
SRV_AO_DIRECTORY: 'https://stage.adopus.no/api-ao/directory',
|
|
67
|
+
},
|
|
68
|
+
prod: {
|
|
69
|
+
SRV_DIRECTORY: 'https://www.adopus.no/api/directory',
|
|
70
|
+
SRV_CALENDAR: 'https://www.adopus.no/api/calendar',
|
|
71
|
+
SRV_PROXY_OLD: 'https://www.adopus.no/api/proxy',
|
|
72
|
+
SRV_PROXY_OLD_HELSE: 'https://www.adopus.no/api/proxy/helse',
|
|
73
|
+
SRV_PROXY_OLD_WEB: 'https://www.adopus.no/api/proxy/web',
|
|
74
|
+
SRV_STORAGE: 'https://www.adopus.no/api/storage',
|
|
75
|
+
SRV_CHAT: 'https://www.adopus.no/api/chat',
|
|
76
|
+
SRV_CONNECTOR: 'https://connector.adopus.no',
|
|
77
|
+
SRV_ARTIFACT: '',
|
|
78
|
+
SRV_ADVOCA: 'https://www.advoca.no/api/service',
|
|
79
|
+
SRV_PROXY: 'https://www.adopus.no/api/srvproxy',
|
|
80
|
+
SRV_NOTIFICATION: 'https://www.adopus.no/api/notification',
|
|
81
|
+
|
|
82
|
+
SRV_AO_DIRECTORY: 'https://www.adopus.no/api-ao/directory',
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function environmentUrls(ENVIRONMENT_TO_OPERATE?: string) {
|
|
87
|
+
let env: EnvironmentEnums | undefined
|
|
88
|
+
|
|
89
|
+
const env_to_operate_window = configWeb('ENVIRONMENT_TO_OPERATE', '')
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
(ENVIRONMENT_TO_OPERATE && ENVIRONMENT_TO_OPERATE in EnvironmentEnums) ||
|
|
93
|
+
env_to_operate_window in EnvironmentEnums
|
|
94
|
+
) {
|
|
95
|
+
env = (ENVIRONMENT_TO_OPERATE || env_to_operate_window) as EnvironmentEnums
|
|
96
|
+
|
|
97
|
+
return env && EnvironmentsUrls[env]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return
|
|
101
|
+
}
|
|
102
|
+
export default environmentUrls
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
export const NORVEGIAN_PHONE_NUMBER = {
|
|
2
|
-
placeholder: 'Legg inn tlf nr.',
|
|
3
|
-
format: '+47-###-##-###',
|
|
4
|
-
mask: '_',
|
|
5
|
-
//thousandSeparator: "",
|
|
6
|
-
//prefix: "",
|
|
7
|
-
//suffix: ""
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const PERSONAL_NUMBER = {
|
|
11
|
-
placeholder: 'legg inn ditt person nr',
|
|
12
|
-
format: ' ##/##/##-#####',
|
|
13
|
-
mask: '_',
|
|
14
|
-
//thousandSeparator: "",
|
|
15
|
-
//prefix: "",
|
|
16
|
-
//suffix: ""
|
|
17
|
-
}
|
|
18
|
-
export const ORDINARY = {
|
|
19
|
-
placeholder: 'enkelt nummer',
|
|
20
|
-
//format:"",
|
|
21
|
-
//mask:"_",
|
|
22
|
-
thousandSeparator: ',',
|
|
23
|
-
//prefix: "",
|
|
24
|
-
//suffix: ""
|
|
25
|
-
}
|
|
26
|
-
export const YEARS = {
|
|
27
|
-
placeholder: 'Legg inn år taller',
|
|
28
|
-
//format:"###",
|
|
29
|
-
//mask:"_",
|
|
30
|
-
thousandSeparator: true,
|
|
31
|
-
prefix: 'År: ',
|
|
32
|
-
//suffix: "År"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const CURENCY_NOK = {
|
|
36
|
-
placeholder: 'Legg summen i Kr',
|
|
37
|
-
//format:"###",
|
|
38
|
-
//mask:"_",
|
|
39
|
-
thousandSeparator: true,
|
|
40
|
-
prefix: 'Kr: ',
|
|
41
|
-
//suffix: "År"
|
|
1
|
+
export const NORVEGIAN_PHONE_NUMBER = {
|
|
2
|
+
placeholder: 'Legg inn tlf nr.',
|
|
3
|
+
format: '+47-###-##-###',
|
|
4
|
+
mask: '_',
|
|
5
|
+
//thousandSeparator: "",
|
|
6
|
+
//prefix: "",
|
|
7
|
+
//suffix: ""
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const PERSONAL_NUMBER = {
|
|
11
|
+
placeholder: 'legg inn ditt person nr',
|
|
12
|
+
format: ' ##/##/##-#####',
|
|
13
|
+
mask: '_',
|
|
14
|
+
//thousandSeparator: "",
|
|
15
|
+
//prefix: "",
|
|
16
|
+
//suffix: ""
|
|
17
|
+
}
|
|
18
|
+
export const ORDINARY = {
|
|
19
|
+
placeholder: 'enkelt nummer',
|
|
20
|
+
//format:"",
|
|
21
|
+
//mask:"_",
|
|
22
|
+
thousandSeparator: ',',
|
|
23
|
+
//prefix: "",
|
|
24
|
+
//suffix: ""
|
|
25
|
+
}
|
|
26
|
+
export const YEARS = {
|
|
27
|
+
placeholder: 'Legg inn år taller',
|
|
28
|
+
//format:"###",
|
|
29
|
+
//mask:"_",
|
|
30
|
+
thousandSeparator: true,
|
|
31
|
+
prefix: 'År: ',
|
|
32
|
+
//suffix: "År"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const CURENCY_NOK = {
|
|
36
|
+
placeholder: 'Legg summen i Kr',
|
|
37
|
+
//format:"###",
|
|
38
|
+
//mask:"_",
|
|
39
|
+
thousandSeparator: true,
|
|
40
|
+
prefix: 'Kr: ',
|
|
41
|
+
//suffix: "År"
|
|
42
42
|
}
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { del, get, set } from 'idb-keyval'
|
|
2
|
-
import { applySnapshot, onSnapshot, isStateTreeNode, IStateTreeNode, IType } from 'mobx-state-tree'
|
|
3
|
-
function setIDBListenersOnSnapshots<T extends Object, K extends keyof T>(store: T, omit: K[] = []) {
|
|
4
|
-
const keys = (Object.keys(store) as Array<keyof typeof store>).filter((k) => !omit.includes(k as K))
|
|
5
|
-
|
|
6
|
-
keys.forEach((key) => {
|
|
7
|
-
const mst_node = store[key]
|
|
8
|
-
|
|
9
|
-
if (isStateTreeNode(mst_node)) {
|
|
10
|
-
onSnapshot(mst_node, (snapshot) => {
|
|
11
|
-
set(String(key), snapshot).catch((e) => console.error(e))
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function checkForIDBData<T extends Object>(main_store: T) {
|
|
18
|
-
const keys = Object.keys(main_store) as Array<keyof typeof main_store>
|
|
19
|
-
|
|
20
|
-
const stores_promises: Promise<void>[] = []
|
|
21
|
-
|
|
22
|
-
const promises: Promise<void>[] = keys.reduce((acc, key) => {
|
|
23
|
-
if (typeof main_store[key] === 'object') acc.push(applySnapshotOnResolvedIDBGetPromise(key, main_store))
|
|
24
|
-
|
|
25
|
-
return acc
|
|
26
|
-
}, stores_promises)
|
|
27
|
-
|
|
28
|
-
await myPromiseAllSettled(promises)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function initiatieIDBListenersOnMstSnaphsots<T extends Object, K extends keyof T>(store: T, omit: K[] = []) {
|
|
32
|
-
setIDBListenersOnSnapshots(store, omit)
|
|
33
|
-
|
|
34
|
-
return checkForIDBData(store)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async function applySnapshotOnResolvedIDBGetPromise<T extends Object >(key: keyof T, main_store: T): Promise<void> {
|
|
38
|
-
try {
|
|
39
|
-
const res = await get(String(key))
|
|
40
|
-
|
|
41
|
-
if (res) {
|
|
42
|
-
applySnapshot(main_store[key] as IStateTreeNode<IType<any, any, any>>, res)
|
|
43
|
-
}
|
|
44
|
-
} catch (e) {
|
|
45
|
-
del(String(key))
|
|
46
|
-
|
|
47
|
-
console.error(`resolveIDBGetPromise, ${String(key)}:`, e)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function* map(iterable: any, callback: any) {
|
|
52
|
-
for (const value of iterable) {
|
|
53
|
-
yield callback(value)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const myPromiseAllSettled = (promises: Promise<unknown>[]) => {
|
|
58
|
-
const fulfilled = (value: unknown) => ({ status: 'fulfilled', value })
|
|
59
|
-
const rejected = (reason: unknown) => ({ status: 'rejected', reason })
|
|
60
|
-
|
|
61
|
-
return Promise.all(map(promises, (p: unknown) => Promise.resolve(p).then(fulfilled, rejected)))
|
|
62
|
-
}
|
|
1
|
+
import { del, get, set } from 'idb-keyval'
|
|
2
|
+
import { applySnapshot, onSnapshot, isStateTreeNode, IStateTreeNode, IType } from 'mobx-state-tree'
|
|
3
|
+
function setIDBListenersOnSnapshots<T extends Object, K extends keyof T>(store: T, omit: K[] = []) {
|
|
4
|
+
const keys = (Object.keys(store) as Array<keyof typeof store>).filter((k) => !omit.includes(k as K))
|
|
5
|
+
|
|
6
|
+
keys.forEach((key) => {
|
|
7
|
+
const mst_node = store[key]
|
|
8
|
+
|
|
9
|
+
if (isStateTreeNode(mst_node)) {
|
|
10
|
+
onSnapshot(mst_node, (snapshot) => {
|
|
11
|
+
set(String(key), snapshot).catch((e) => console.error(e))
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function checkForIDBData<T extends Object>(main_store: T) {
|
|
18
|
+
const keys = Object.keys(main_store) as Array<keyof typeof main_store>
|
|
19
|
+
|
|
20
|
+
const stores_promises: Promise<void>[] = []
|
|
21
|
+
|
|
22
|
+
const promises: Promise<void>[] = keys.reduce((acc, key) => {
|
|
23
|
+
if (typeof main_store[key] === 'object') acc.push(applySnapshotOnResolvedIDBGetPromise(key, main_store))
|
|
24
|
+
|
|
25
|
+
return acc
|
|
26
|
+
}, stores_promises)
|
|
27
|
+
|
|
28
|
+
await myPromiseAllSettled(promises)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function initiatieIDBListenersOnMstSnaphsots<T extends Object, K extends keyof T>(store: T, omit: K[] = []) {
|
|
32
|
+
setIDBListenersOnSnapshots(store, omit)
|
|
33
|
+
|
|
34
|
+
return checkForIDBData(store)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function applySnapshotOnResolvedIDBGetPromise<T extends Object >(key: keyof T, main_store: T): Promise<void> {
|
|
38
|
+
try {
|
|
39
|
+
const res = await get(String(key))
|
|
40
|
+
|
|
41
|
+
if (res) {
|
|
42
|
+
applySnapshot(main_store[key] as IStateTreeNode<IType<any, any, any>>, res)
|
|
43
|
+
}
|
|
44
|
+
} catch (e) {
|
|
45
|
+
del(String(key))
|
|
46
|
+
|
|
47
|
+
console.error(`resolveIDBGetPromise, ${String(key)}:`, e)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function* map(iterable: any, callback: any) {
|
|
52
|
+
for (const value of iterable) {
|
|
53
|
+
yield callback(value)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const myPromiseAllSettled = (promises: Promise<unknown>[]) => {
|
|
58
|
+
const fulfilled = (value: unknown) => ({ status: 'fulfilled', value })
|
|
59
|
+
const rejected = (reason: unknown) => ({ status: 'rejected', reason })
|
|
60
|
+
|
|
61
|
+
return Promise.all(map(promises, (p: unknown) => Promise.resolve(p).then(fulfilled, rejected)))
|
|
62
|
+
}
|