@magmamath/frontend-config 0.0.1-rc.3 → 0.0.1-rc.30

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.mts 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,25 +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
- DISTRICT_DASHBOARD = "DISTRICT"
37
+ DISTRICT_DASHBOARD = "DISTRICT",
38
+ AUTH_WEB = "AUTH_WEB"
39
+ }
40
+ declare enum Environment {
41
+ MARS = "MARS",
42
+ PROD = "PROD"
35
43
  }
36
44
  declare enum Locale {
37
45
  US = "en-SE",
@@ -41,33 +49,165 @@ declare enum Locale {
41
49
  SCT = "en-SCT",
42
50
  DE = "de-DE"
43
51
  }
44
- declare enum Environment {
45
- MARS = "MARS",
46
- 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"
91
+ }
92
+
93
+ declare enum MatrixMode {
94
+ SKILL = "SKILL",
95
+ STANDARD = "STANDARD"
47
96
  }
48
97
 
49
- type RegionEnv = Readonly<{
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
+ };
108
+ type SSO_US = {
109
+ GOOGLE_AUTH: string;
110
+ MICROSOFT_AUTH: string;
111
+ CLASS_LINK_AUTH: string;
112
+ SCHOOLOGY_AUTH: string;
113
+ CLEVER_AUTH: string;
114
+ };
115
+ type SSO_SE = {
116
+ GOOGLE_AUTH: string;
117
+ MICROSOFT_AUTH: string;
118
+ SKOLFEDERATION_AUTH: string;
119
+ SKOLON_AUTH: string;
120
+ };
121
+ type SSO_DE = {
122
+ GOOGLE_AUTH: string;
123
+ MICROSOFT_AUTH: string;
124
+ };
125
+
126
+ type RegionSpecificVars = {
50
127
  API_URL: string;
51
128
  AUTH_WEB_URL: string;
52
- MYSCRIPT_HOST: string;
129
+ CDN_HOST: string;
130
+ DISTRICT_WEB_URL: string;
53
131
  LOGGLY_TAG: string;
54
- SKOLFED_AUTH: string;
132
+ MAGMAMATH_URL: string;
55
133
  SOCKET_URL: string;
56
134
  STUDENTS_WEB_URL: string;
57
135
  TEACHERS_WEB_URL: string;
58
- CDN_HOST: string;
59
- }>;
60
- type CommonEnv = Readonly<{
136
+ };
137
+ type StudentsWebCommon = {
61
138
  GOOGLE_API_KEY: string;
62
139
  DESMOS_API_KEY: string;
140
+ LOGGLY_CUSTOMER_TOKEN: string;
63
141
  MYSCRIPT_APPLICATION_KEY: string;
64
142
  MYSCRIPT_HMAC_KEY: string;
143
+ MYSCRIPT_HOST: string;
65
144
  MYSCRIPT_SOCKET_KEY: string;
66
145
  MYSCRIPT_REST_APP_KEY: string;
67
146
  MYSCRIPT_REST_HMAC_KEY: string;
68
- LOGGLY_CUSTOMER_TOKEN: string;
147
+ };
148
+ type StudentsWebVars = RegionSpecificVars & StudentsWebCommon;
149
+ type TeachersWebVars = RegionSpecificVars & {};
150
+ type DistrictDashboardVars = RegionSpecificVars & {};
151
+ type AuthWebBaseVars = Omit<RegionSpecificVars, 'CDN_HOST' | 'LOGGLY_TAG' | 'SOCKET_URL'> & {
152
+ TOS_URL: string;
153
+ CLARITY_PROJECT_ID: string;
154
+ INTERCOM_APP_ID: string;
155
+ };
156
+ type AuthWebCAVars = AuthWebBaseVars & SSO_US;
157
+ type AuthWebDEVars = AuthWebBaseVars & SSO_DE;
158
+ type AuthWebUKVars = AuthWebBaseVars & SSO_UK;
159
+ type AuthWebSEVars = AuthWebBaseVars & SSO_SE;
160
+ type AuthWebUSVars = AuthWebBaseVars & SSO_US;
161
+ type EnvPreset = Readonly<{
162
+ [Platform.STUDENTS_WEB]: {
163
+ [key in Locale]: {
164
+ [key in Environment]: StudentsWebVars;
165
+ };
166
+ };
167
+ [Platform.TEACHERS_WEB]: {
168
+ [key in Locale]: {
169
+ [key in Environment]: TeachersWebVars;
170
+ };
171
+ };
172
+ [Platform.DISTRICT_DASHBOARD]: {
173
+ [key in Locale]: {
174
+ [key in Environment]: DistrictDashboardVars;
175
+ };
176
+ };
177
+ [Platform.AUTH_WEB]: {
178
+ [Locale.CA]: {
179
+ [key in Environment]: AuthWebCAVars;
180
+ };
181
+ [Locale.DE]: {
182
+ [key in Environment]: AuthWebDEVars;
183
+ };
184
+ [Locale.GB]: {
185
+ [key in Environment]: AuthWebUKVars;
186
+ };
187
+ [Locale.SCT]: {
188
+ [key in Environment]: AuthWebUKVars;
189
+ };
190
+ [Locale.SE]: {
191
+ [key in Environment]: AuthWebSEVars;
192
+ };
193
+ [Locale.US]: {
194
+ [key in Environment]: AuthWebUSVars;
195
+ };
196
+ };
197
+ }>;
198
+ type EnvironmentVars<P extends Platform> = EnvPreset[P][Locale][Environment];
199
+
200
+ type SSOConfig = Readonly<{
201
+ name: string;
202
+ icon: ComponentType<IconProps>;
203
+ type: SSO;
204
+ loginSource: LoginSource;
205
+ getUrl: (envs: EnvironmentVars<Platform.AUTH_WEB>) => string;
206
+ ownUrl?: boolean;
69
207
  }>;
70
- type EnvironmentVariables = RegionEnv & CommonEnv;
208
+
209
+ declare const SSO_CONFIG_MAP: Record<SSO, SSOConfig>;
210
+ declare const SSO_CONFIG_LIST: SSOConfig[];
71
211
 
72
212
  type StudentsLocaleConfig = CommonLocaleConfig & {
73
213
  textFormatting: {
@@ -110,28 +250,13 @@ type StudentsLocaleConfig = CommonLocaleConfig & {
110
250
  statsTab: {
111
251
  buttonWithMinWidth: boolean;
112
252
  };
113
- };
114
-
115
- type DistrictLocaleConfig = CommonLocaleConfig & {
116
- date: {
117
- use24HourFormat: boolean;
118
- locale: DateLocale;
119
- formats: {
120
- full: DateFormat;
121
- dayMonthYear: DateFormat;
122
- dayMonth: DateFormat;
123
- hoursMinutes: DateFormat;
124
- fullWithSeconds: DateFormat;
125
- };
253
+ smartEval: {
254
+ language: string;
126
255
  };
127
256
  };
128
257
 
129
- declare enum MatrixMode {
130
- SKILL = "SKILL",
131
- STANDARD = "STANDARD"
132
- }
133
-
134
258
  type TeachersLocaleConfig = CommonLocaleConfig & {
259
+ country: string;
135
260
  emails: {
136
261
  studentsList: string;
137
262
  };
@@ -175,12 +300,47 @@ type TeachersLocaleConfig = CommonLocaleConfig & {
175
300
  getStarted: {
176
301
  showSentEmailInfo: boolean;
177
302
  };
303
+ firstLoginBooks: {
304
+ isLargeGrade: ((grade: number) => boolean) | null;
305
+ };
178
306
  grades: {
179
307
  showPrefix: boolean;
180
308
  showOtherGrade: boolean;
181
309
  };
182
310
  };
183
311
 
312
+ type DistrictLocaleConfig = CommonLocaleConfig & {
313
+ date: {
314
+ use24HourFormat: boolean;
315
+ locale: DateLocale;
316
+ formats: {
317
+ full: DateFormat;
318
+ dayMonthYear: DateFormat;
319
+ dayMonth: DateFormat;
320
+ hoursMinutes: DateFormat;
321
+ fullWithSeconds: DateFormat;
322
+ };
323
+ };
324
+ };
325
+
326
+ type AuthWebLocaleConfig = {
327
+ path: string;
328
+ shortCode: string;
329
+ icon: ComponentType<IconProps>;
330
+ sources: {
331
+ signUp: {
332
+ list: SSOConfig[];
333
+ };
334
+ signIn: {
335
+ withOnboarding: boolean;
336
+ largeQRCode: boolean;
337
+ list: SSOConfig[];
338
+ };
339
+ };
340
+ isPrimaryRegion: boolean;
341
+ regionGroup: string;
342
+ };
343
+
184
344
  type CommonLocaleConfig = Readonly<{
185
345
  name: string;
186
346
  languageName: string;
@@ -198,35 +358,74 @@ type LocalePreset = {
198
358
  [Platform.DISTRICT_DASHBOARD]: {
199
359
  [key in Locale]: DistrictLocaleConfig;
200
360
  };
361
+ [Platform.AUTH_WEB]: {
362
+ [key in Locale]: AuthWebLocaleConfig;
363
+ };
201
364
  };
202
- type PlatformLocaleConfig<P extends Platform> = LocalePreset[P][Locale];
365
+ type LocaleConfig<P extends Platform> = LocalePreset[P][Locale];
203
366
 
367
+ type DevOverrides<P extends Platform> = {
368
+ [K in Locale]?: Partial<EnvironmentVars<P>>;
369
+ };
204
370
  type ConfigOptions<P extends Platform> = {
205
371
  platform: P;
206
372
  environment: Environment;
373
+ _DEV_OVERRIDES_?: DevOverrides<P>;
207
374
  };
208
375
  type SetProps = {
209
376
  locale?: Locale;
210
377
  environment?: Environment;
211
378
  };
212
379
  declare class AppConfigManager<P extends Platform> {
380
+ private readonly _DEV_OVERRIDES_?;
213
381
  private readonly platform;
214
- private environment;
215
- private locale;
382
+ environment: Environment;
383
+ locale: Locale;
216
384
  private readonly setEnvs;
217
385
  private readonly setLocaleConfig;
218
- readonly $envs: effector.StoreWritable<EnvironmentVariables>;
219
- readonly $localeConfig: effector.StoreWritable<PlatformLocaleConfig<P>>;
386
+ readonly $envs: effector.StoreWritable<EnvironmentVars<P>>;
387
+ readonly $localeConfig: effector.StoreWritable<LocaleConfig<P>>;
220
388
  constructor(opts: ConfigOptions<P>);
389
+ private readonly syncConfigsStores;
221
390
  readonly set: (props: SetProps) => void;
222
- readonly onEnvsChange: (cb: () => void) => effector.Subscription;
223
- readonly onLocaleChange: (cb: () => void) => effector.Subscription;
391
+ readonly onEnvsChange: (cb: (cfg: EnvironmentVars<P>) => void) => effector.Subscription;
392
+ readonly onLocaleChange: (cb: (cfg: LocaleConfig<P>) => void) => effector.Subscription;
224
393
  readonly getConfig: () => {
225
- platform: P;
226
- currentLocale: Locale;
227
- envs: EnvironmentVariables;
228
- locales: PlatformLocaleConfig<P>;
394
+ envs: EnvironmentVars<P>;
395
+ localeConfig: LocaleConfig<P>;
396
+ };
397
+ readonly getSSOList: () => Readonly<{
398
+ name: string;
399
+ icon: react.ComponentType<IconProps>;
400
+ type: SSO;
401
+ loginSource: LoginSource;
402
+ getUrl: (envs: EnvironmentVars<Platform.AUTH_WEB>) => string;
403
+ ownUrl?: boolean;
404
+ }>[];
405
+ readonly getSSO: (key: SSO) => Readonly<{
406
+ name: string;
407
+ icon: react.ComponentType<IconProps>;
408
+ type: SSO;
409
+ loginSource: LoginSource;
410
+ getUrl: (envs: EnvironmentVars<Platform.AUTH_WEB>) => string;
411
+ ownUrl?: boolean;
412
+ }>;
413
+ readonly getPresets: () => {
414
+ envPreset: Readonly<{
415
+ STUDENTS: { [key in Locale]: { [key_1 in Environment]: StudentsWebVars; }; };
416
+ TEACHERS: { [key in Locale]: { [key_1 in Environment]: TeachersWebVars; }; };
417
+ DISTRICT: { [key in Locale]: { [key_1 in Environment]: DistrictDashboardVars; }; };
418
+ AUTH_WEB: {
419
+ [Locale.CA]: { [key in Environment]: AuthWebCAVars; };
420
+ [Locale.DE]: { [key in Environment]: AuthWebDEVars; };
421
+ [Locale.GB]: { [key in Environment]: AuthWebUKVars; };
422
+ [Locale.SCT]: { [key in Environment]: AuthWebUKVars; };
423
+ [Locale.SE]: { [key in Environment]: AuthWebSEVars; };
424
+ [Locale.US]: { [key in Environment]: AuthWebUSVars; };
425
+ };
426
+ }>;
427
+ localePreset: LocalePreset;
229
428
  };
230
429
  }
231
430
 
232
- export { AppConfigManager, DateFormat, DateLocale, Environment, Locale, Platform };
431
+ 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 };