@magmamath/frontend-config 0.0.1-rc.2 → 0.0.1-rc.21

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/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as react from 'react';
2
+ import { ComponentType } from 'react';
1
3
  import * as effector from 'effector';
2
4
 
3
5
  declare enum DateFormat {
@@ -13,28 +15,31 @@ declare enum DateFormat {
13
15
  FULL_WITH_SECONDS = "DD MMM YYYY HH:mm:ss",
14
16
  FULL_WITH_SECONDS_US = "DD MMM YYYY hh:mm:ss A"
15
17
  }
16
- declare enum DateLocale {
17
- US = "en",
18
- SV = "sv",
19
- 'en-SE' = "en",
20
- 'sv-SE' = "sv",
21
- GB = "en",
22
- 'en-GB' = "en",
23
- CA = "en",
24
- 'en-CA' = "en",
25
- SCT = "en",
26
- 'en-SCT' = "en",
27
- DE = "de",
28
- 'de-DE' = "de"
29
- }
18
+ declare const DateLocale: {
19
+ readonly US: "en";
20
+ readonly SV: "sv";
21
+ readonly 'en-SE': "en";
22
+ readonly 'sv-SE': "sv";
23
+ readonly GB: "en";
24
+ readonly 'en-GB': "en";
25
+ readonly CA: "en";
26
+ readonly 'en-CA': "en";
27
+ readonly SCT: "en";
28
+ readonly 'en-SCT': "en";
29
+ readonly DE: "de";
30
+ readonly 'de-DE': "de";
31
+ };
32
+ type DateLocale = (typeof DateLocale)[keyof typeof DateLocale];
30
33
 
31
34
  declare enum Platform {
32
35
  STUDENTS_WEB = "STUDENTS",
33
36
  TEACHERS_WEB = "TEACHERS",
34
37
  DISTRICT_DASHBOARD = "DISTRICT",
35
- AUTH_WEB = "AUTH_WEB",
36
- STUDENTS_APP = "STUDENTS_RN_APP",
37
- TEACHERS_APP = "TEACHERS_RN_APP"
38
+ AUTH_WEB = "AUTH_WEB"
39
+ }
40
+ declare enum Environment {
41
+ MARS = "MARS",
42
+ PROD = "PROD"
38
43
  }
39
44
  declare enum Locale {
40
45
  US = "en-SE",
@@ -44,33 +49,168 @@ declare enum Locale {
44
49
  SCT = "en-SCT",
45
50
  DE = "de-DE"
46
51
  }
47
- declare enum Environment {
48
- MARS = "MARS",
49
- PROD = "PROD"
52
+ declare enum Source {
53
+ MATTEAPPEN = 0,
54
+ SKOLON = 1,
55
+ SKOLFEDERATION = 2,
56
+ GOOGLE = 3,
57
+ MICROSOFT = 4,
58
+ CLEVER = 5,
59
+ APPLE = 6,
60
+ MATHSYNC = 7,
61
+ CLASSLINK = 8,
62
+ EDUCLOUD = 9,
63
+ EGIL = 10,
64
+ WONDE = 12,
65
+ SCHOOLOGY = 13,
66
+ SEEMIS = 14,
67
+ IMPORT = 15,
68
+ CANVAS = 16
69
+ }
70
+ declare enum LoginSource {
71
+ MAGMA = 0,
72
+ CLEVER = 1,
73
+ CLASS_LINK = 2,
74
+ SKOLON = 3,
75
+ SKOLFEDERATION = 4,
76
+ GOOGLE = 5,
77
+ MICROSOFT = 6,
78
+ APPLE = 7,
79
+ SCHOOLOGY = 8,
80
+ MY_LOGIN = 9
81
+ }
82
+ declare enum SSO {
83
+ GOOGLE = "GOOGLE",
84
+ MICROSOFT = "MICROSOFT",
85
+ CLEVER = "CLEVER",
86
+ SCHOOLOGY = "SCHOOLOGY",
87
+ CLASS_LINK = "CLASS_LINK",
88
+ SKOLFEDERATION = "SKOLFEDERATION",
89
+ SKOLON = "SKOLON",
90
+ WONDE = "WONDE"
50
91
  }
51
92
 
52
- type RegionEnv = Readonly<{
93
+ declare enum MatrixMode {
94
+ SKILL = "SKILL",
95
+ STANDARD = "STANDARD"
96
+ }
97
+
98
+ type IconProps = {
99
+ size?: number;
100
+ };
101
+
102
+ type SSO_UK = {
103
+ GOOGLE_AUTH: string;
104
+ MICROSOFT_AUTH: string;
105
+ WONDE_AUTH: string;
106
+ SKOLON_AUTH: string;
107
+ CLEVER_AUTH: never;
108
+ CLASS_LINK_AUTH: never;
109
+ SKOLFEDERATION_AUTH: never;
110
+ SCHOOLOGY_AUTH: never;
111
+ };
112
+ type SSO_US = {
113
+ GOOGLE_AUTH: string;
114
+ MICROSOFT_AUTH: string;
115
+ CLASS_LINK_AUTH: string;
116
+ SCHOOLOGY_AUTH: string;
117
+ CLEVER_AUTH: string;
118
+ };
119
+ type SSO_SE = {
120
+ GOOGLE_AUTH: string;
121
+ MICROSOFT_AUTH: string;
122
+ SKOLFEDERATION_AUTH: string;
123
+ SKOLON_AUTH: string;
124
+ };
125
+ type SSO_DE = {
126
+ GOOGLE_AUTH: string;
127
+ MICROSOFT_AUTH: string;
128
+ };
129
+
130
+ type RegionSpecificVars = {
53
131
  API_URL: string;
54
132
  AUTH_WEB_URL: string;
55
- MYSCRIPT_HOST: string;
133
+ CDN_HOST: string;
134
+ DISTRICT_WEB_URL: string;
56
135
  LOGGLY_TAG: string;
57
- SKOLFED_AUTH: string;
136
+ MAGMAMATH_URL: string;
58
137
  SOCKET_URL: string;
59
138
  STUDENTS_WEB_URL: string;
60
139
  TEACHERS_WEB_URL: string;
61
- CDN_HOST: string;
62
- }>;
63
- type CommonEnv = Readonly<{
140
+ };
141
+ type StudentsWebCommon = {
64
142
  GOOGLE_API_KEY: string;
65
143
  DESMOS_API_KEY: string;
66
144
  MYSCRIPT_APPLICATION_KEY: string;
67
145
  MYSCRIPT_HMAC_KEY: string;
146
+ MYSCRIPT_HOST: string;
68
147
  MYSCRIPT_SOCKET_KEY: string;
69
148
  MYSCRIPT_REST_APP_KEY: string;
70
149
  MYSCRIPT_REST_HMAC_KEY: string;
71
- LOGGLY_CUSTOMER_TOKEN: string;
150
+ };
151
+ type StudentsWebVars = RegionSpecificVars & StudentsWebCommon;
152
+ type TeachersWebVars = RegionSpecificVars & {};
153
+ type DistrictDashboardVars = RegionSpecificVars & {};
154
+ type AuthWebBaseVars = Omit<RegionSpecificVars, 'CDN_HOST' | 'LOGGLY_TAG' | 'SOCKET_URL'> & {
155
+ TOS_URL: string;
156
+ CLARITY_PROJECT_ID: string;
157
+ INTERCOM_APP_ID: string;
158
+ };
159
+ type AuthWebCAVars = AuthWebBaseVars & SSO_US;
160
+ type AuthWebDEVars = AuthWebBaseVars & SSO_DE;
161
+ type AuthWebUKVars = AuthWebBaseVars & SSO_UK;
162
+ type AuthWebSEVars = AuthWebBaseVars & SSO_SE;
163
+ type AuthWebUSVars = AuthWebBaseVars & SSO_US;
164
+ type EnvPreset = Readonly<{
165
+ [Platform.STUDENTS_WEB]: {
166
+ [key in Locale]: {
167
+ [key in Environment]: StudentsWebVars;
168
+ };
169
+ };
170
+ [Platform.TEACHERS_WEB]: {
171
+ [key in Locale]: {
172
+ [key in Environment]: TeachersWebVars;
173
+ };
174
+ };
175
+ [Platform.DISTRICT_DASHBOARD]: {
176
+ [key in Locale]: {
177
+ [key in Environment]: DistrictDashboardVars;
178
+ };
179
+ };
180
+ [Platform.AUTH_WEB]: {
181
+ [Locale.CA]: {
182
+ [key in Environment]: AuthWebCAVars;
183
+ };
184
+ [Locale.DE]: {
185
+ [key in Environment]: AuthWebDEVars;
186
+ };
187
+ [Locale.GB]: {
188
+ [key in Environment]: AuthWebUKVars;
189
+ };
190
+ [Locale.SCT]: {
191
+ [key in Environment]: AuthWebUKVars;
192
+ };
193
+ [Locale.SE]: {
194
+ [key in Environment]: AuthWebSEVars;
195
+ };
196
+ [Locale.US]: {
197
+ [key in Environment]: AuthWebUSVars;
198
+ };
199
+ };
200
+ }>;
201
+ type EnvironmentVars<P extends Platform> = EnvPreset[P][Locale][Environment];
202
+
203
+ type SSOConfig = Readonly<{
204
+ name: string;
205
+ icon: ComponentType<IconProps>;
206
+ type: SSO;
207
+ loginSource: LoginSource;
208
+ getUrl: (envs: EnvironmentVars<Platform.AUTH_WEB>) => string;
209
+ ownUrl?: boolean;
72
210
  }>;
73
- type EnvironmentVariables = RegionEnv & CommonEnv;
211
+
212
+ declare const SSO_CONFIG_MAP: Record<SSO, SSOConfig>;
213
+ declare const SSO_CONFIG_LIST: SSOConfig[];
74
214
 
75
215
  type StudentsLocaleConfig = CommonLocaleConfig & {
76
216
  textFormatting: {
@@ -113,28 +253,13 @@ type StudentsLocaleConfig = CommonLocaleConfig & {
113
253
  statsTab: {
114
254
  buttonWithMinWidth: boolean;
115
255
  };
116
- };
117
-
118
- type DistrictLocaleConfig = CommonLocaleConfig & {
119
- date: {
120
- use24HourFormat: boolean;
121
- locale: DateLocale;
122
- formats: {
123
- full: DateFormat;
124
- dayMonthYear: DateFormat;
125
- dayMonth: DateFormat;
126
- hoursMinutes: DateFormat;
127
- fullWithSeconds: DateFormat;
128
- };
256
+ smartEval: {
257
+ language: string;
129
258
  };
130
259
  };
131
260
 
132
- declare enum MatrixMode {
133
- SKILL = "SKILL",
134
- STANDARD = "STANDARD"
135
- }
136
-
137
261
  type TeachersLocaleConfig = CommonLocaleConfig & {
262
+ country: string;
138
263
  emails: {
139
264
  studentsList: string;
140
265
  };
@@ -178,12 +303,47 @@ type TeachersLocaleConfig = CommonLocaleConfig & {
178
303
  getStarted: {
179
304
  showSentEmailInfo: boolean;
180
305
  };
306
+ firstLoginBooks: {
307
+ isLargeGrade: ((grade: number) => boolean) | null;
308
+ };
181
309
  grades: {
182
310
  showPrefix: boolean;
183
311
  showOtherGrade: boolean;
184
312
  };
185
313
  };
186
314
 
315
+ type DistrictLocaleConfig = CommonLocaleConfig & {
316
+ date: {
317
+ use24HourFormat: boolean;
318
+ locale: DateLocale;
319
+ formats: {
320
+ full: DateFormat;
321
+ dayMonthYear: DateFormat;
322
+ dayMonth: DateFormat;
323
+ hoursMinutes: DateFormat;
324
+ fullWithSeconds: DateFormat;
325
+ };
326
+ };
327
+ };
328
+
329
+ type AuthWebLocaleConfig = {
330
+ path: string;
331
+ shortCode: string;
332
+ icon: ComponentType<IconProps>;
333
+ sources: {
334
+ signUp: {
335
+ list: SSOConfig[];
336
+ };
337
+ signIn: {
338
+ withOnboarding: boolean;
339
+ largeQRCode: boolean;
340
+ list: SSOConfig[];
341
+ };
342
+ };
343
+ isPrimaryRegion: boolean;
344
+ regionGroup: string;
345
+ };
346
+
187
347
  type CommonLocaleConfig = Readonly<{
188
348
  name: string;
189
349
  languageName: string;
@@ -202,44 +362,68 @@ type LocalePreset = {
202
362
  [key in Locale]: DistrictLocaleConfig;
203
363
  };
204
364
  [Platform.AUTH_WEB]: {
205
- [key in Locale]: DistrictLocaleConfig;
206
- };
207
- [Platform.STUDENTS_APP]: {
208
- [key in Locale]: StudentsLocaleConfig;
209
- };
210
- [Platform.TEACHERS_APP]: {
211
- [key in Locale]: TeachersLocaleConfig;
365
+ [key in Locale]: AuthWebLocaleConfig;
212
366
  };
213
367
  };
368
+ type LocaleConfig<P extends Platform> = LocalePreset[P][Locale];
214
369
 
215
- type Locales<P extends Platform, L extends Locale> = LocalePreset[P][L];
216
- type ConfigOptions<P extends Platform, L extends Locale> = {
370
+ type ConfigOptions<P extends Platform> = {
217
371
  platform: P;
218
- locale: L;
219
372
  environment: Environment;
220
373
  };
221
374
  type SetProps = {
222
375
  locale?: Locale;
223
376
  environment?: Environment;
224
377
  };
225
- declare class AppConfigManager<P extends Platform, L extends Locale> {
378
+ declare class AppConfigManager<P extends Platform> {
226
379
  private readonly platform;
227
- private readonly locale;
228
- private readonly environment;
380
+ environment: Environment;
381
+ locale: Locale;
229
382
  private readonly setEnvs;
230
383
  private readonly setLocaleConfig;
231
- readonly $envs: effector.StoreWritable<EnvironmentVariables>;
232
- readonly $localeConfig: effector.StoreWritable<Locales<P, L>>;
233
- constructor(opts: ConfigOptions<P, L>);
234
- readonly set: (props?: SetProps) => void;
235
- readonly onEnvsChange: (cb: () => void) => effector.Subscription;
236
- readonly onLocaleChange: (cb: () => void) => effector.Subscription;
384
+ readonly $envs: effector.StoreWritable<EnvironmentVars<P>>;
385
+ readonly $localeConfig: effector.StoreWritable<LocaleConfig<P>>;
386
+ constructor(opts: ConfigOptions<P>);
387
+ private readonly syncConfigsStores;
388
+ readonly set: (props: SetProps) => void;
389
+ readonly onEnvsChange: (cb: (cfg: EnvironmentVars<P>) => void) => this;
390
+ readonly onLocaleChange: (cb: (cfg: LocaleConfig<P>) => void) => this;
237
391
  readonly getConfig: () => {
238
- platform: P;
239
- currentLocale: L;
240
- envs: EnvironmentVariables;
241
- locales: Locales<P, L>;
392
+ envs: EnvironmentVars<P>;
393
+ localeConfig: LocaleConfig<P>;
394
+ };
395
+ readonly getSSOList: () => Readonly<{
396
+ name: string;
397
+ icon: react.ComponentType<IconProps>;
398
+ type: SSO;
399
+ loginSource: LoginSource;
400
+ getUrl: (envs: EnvironmentVars<Platform.AUTH_WEB>) => string;
401
+ ownUrl?: boolean;
402
+ }>[];
403
+ readonly getSSO: (key: SSO) => Readonly<{
404
+ name: string;
405
+ icon: react.ComponentType<IconProps>;
406
+ type: SSO;
407
+ loginSource: LoginSource;
408
+ getUrl: (envs: EnvironmentVars<Platform.AUTH_WEB>) => string;
409
+ ownUrl?: boolean;
410
+ }>;
411
+ readonly getPresets: () => {
412
+ envPreset: Readonly<{
413
+ STUDENTS: { [key in Locale]: { [key_1 in Environment]: StudentsWebVars; }; };
414
+ TEACHERS: { [key in Locale]: { [key_1 in Environment]: TeachersWebVars; }; };
415
+ DISTRICT: { [key in Locale]: { [key_1 in Environment]: DistrictDashboardVars; }; };
416
+ AUTH_WEB: {
417
+ [Locale.CA]: { [key in Environment]: AuthWebCAVars; };
418
+ [Locale.DE]: { [key in Environment]: AuthWebDEVars; };
419
+ [Locale.GB]: { [key in Environment]: AuthWebUKVars; };
420
+ [Locale.SCT]: { [key in Environment]: AuthWebUKVars; };
421
+ [Locale.SE]: { [key in Environment]: AuthWebSEVars; };
422
+ [Locale.US]: { [key in Environment]: AuthWebUSVars; };
423
+ };
424
+ }>;
425
+ localePreset: LocalePreset;
242
426
  };
243
427
  }
244
428
 
245
- export { AppConfigManager, DateFormat, DateLocale, Environment, Locale, Platform };
429
+ export { AppConfigManager, type AuthWebCAVars, type AuthWebDEVars, type AuthWebSEVars, type AuthWebUKVars, type AuthWebUSVars, DateFormat, DateLocale, type DistrictDashboardVars, type EnvPreset, Environment, type EnvironmentVars, Locale, LoginSource, MatrixMode, Platform, type RegionSpecificVars, SSO, type SSOConfig, SSO_CONFIG_LIST, SSO_CONFIG_MAP, Source, type StudentsWebCommon, type StudentsWebVars, type TeachersWebVars };