-
Notifications
You must be signed in to change notification settings - Fork 0
/
INativeConfigAccess.ts
182 lines (174 loc) · 5.29 KB
/
INativeConfigAccess.ts
1
2
3
4
5
6
7
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import { ILogger } from "@js-soft/logging-abstractions";
import { Result } from "@js-soft/ts-utils";
import { INativeFileAccess } from "./INativeFileAccess";
enum AppType {
Debug = "debug",
Release = "release",
Webapp = "webapp"
}
/**
* Default configuration of the app: This is the set of configurations utilized by the native implementations.
* Additional default configuration entries can be added to the configuration file on demand and will be available to the app at runtime.
*/
export interface IAppConfig {
/**
* Name of the app
*/
name: string;
/**
* Id of the app
*/
applicationId: string;
/**
* Development type of the app
*/
type: AppType;
/**
* Remote push notification token generated by the app during initialization
*/
pushToken: string | null;
cordova?: ICordovaConfig;
electron?: IElectronConfig;
firebase?: IFirebaseConfig;
localforage?: ILocalForageConfig;
launchOptions?: ILaunchOptionsConfig;
}
/**
* Configuration of firebase which can be accessed through the firebase console
*/
export interface IFirebaseConfig {
config: {
apiKey: string;
authDomain: string;
projectId: string;
storageBucket: string;
messagingSenderId: string;
appId: string;
};
vapidKey: string;
}
/**
* [Configuration](https://github.com/localForage/localForage#configuration) of [Local Forage](https://github.com/localForage/localForage)
*/
export interface ILocalForageConfig {
/**
* Storage location (indexeddb, websql)
*/
driver: string;
/**
* Name of app
*/
name: string;
/**
* Version number of app
*/
version: number;
/**
* Size of database
*/
size: number;
/**
* Name of created storage
*/
storeName: string;
/**
* Description of created storage
*/
description: string;
}
/**
* Configuration of the electron platform
*/
export interface IElectronConfig {
/**
* Days after which the stored ids of received remote push notifications should be deleted
*/
persistentIDsremoveDays: number;
/**
* Firebase cloud messaging sender-id which can be accessed through the firebase console
*/
fcmSenderId: string;
/**
* Remote push notification credentials created by app during initialization
*/
pushCredentials?: any;
/**
* Ids of remote push notifications are stored to prevent push notifications to be displayed multiple times
*/
persistentIDs: any;
}
/**
* Configuration of the launch options
*/
export interface ILaunchOptionsConfig {
/**
* Uri which should be registered for the app
*/
uri: string;
}
/**
* Configuration for the cordova platform
*/
export interface ICordovaConfig {
/**
* Configuration of the cordova remote push notifiction plugin (ios/android)
*/
pushChannelConfig: {
id: string;
description: string;
importance: number;
vibration: boolean;
visibility: number;
};
/**
* Configuration of the cordova local push notifiction plugin (ios/android)
*/
localNotificationConfig: {
foreground: boolean;
channel: string;
launch: boolean;
icon: string;
smallIcon: string;
};
}
/**
* Management of default and runtime config. The default config is created during development and delivered as part of the application. The runtime
* config is created by the applocation during execution. Default and runtime config are merged to a single config object which can be accessed
* through the {@link get} method. The default config is read-only. However, values of the runtime config can "overlay" the default config.
*/
export interface INativeConfigAccess {
/**
* Read the value of the config associated to the key.
* @param key
*/
get(key: string): Result<any>;
/**
* Change or add a value of/to the runtime config - in memory. To persist the change onto the filesystem, call {@link save}.
* A {@link ConfigurationSetEvent} is published on the {@link INativeEventBus} after the value was changed.
* @param key
* @param value
*/
set(key: string, value: any): Result<void>;
/**
* Remove a key-value pair from the runtime config.
* A {@link ConfigurationRemoveEvent} is published on the {@link INativeEventBus} after the value was changed.
* @param key
*/
remove(key: string): Result<void>;
/**
* Save the runtime config on the filesystem.
* A {@link ConfigurationSaveEvent} is published on the {@link INativeEventBus} after the value was changed.
*/
save(): Promise<Result<void>>;
/**
* Initialization of the config module without the requirement of a filesystem.
* It loads the default config while keeping the runtime config empty.
* @param path Path where the default config is fetched.
*/
initDefaultConfig(path: string): Promise<Result<void>>;
/**
* Initialization of the runtime config in addition to the default config with the requirement of a filesystem.
* @param path Path where the runtime config is read from the filesystem.
*/
initRuntimeConfig(path: string, logger: ILogger, fileAccess: INativeFileAccess): Promise<Result<void>>;
}