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

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,5 +1,3 @@
1
- import * as react from 'react';
2
- import { ComponentType } from 'react';
3
1
  import * as effector from 'effector';
4
2
 
5
3
  declare enum DateFormat {
@@ -15,31 +13,25 @@ declare enum DateFormat {
15
13
  FULL_WITH_SECONDS = "DD MMM YYYY HH:mm:ss",
16
14
  FULL_WITH_SECONDS_US = "DD MMM YYYY hh:mm:ss A"
17
15
  }
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];
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
+ }
33
30
 
34
31
  declare enum Platform {
35
32
  STUDENTS_WEB = "STUDENTS",
36
33
  TEACHERS_WEB = "TEACHERS",
37
- DISTRICT_DASHBOARD = "DISTRICT",
38
- AUTH_WEB = "AUTH_WEB"
39
- }
40
- declare enum Environment {
41
- MARS = "MARS",
42
- PROD = "PROD"
34
+ DISTRICT_DASHBOARD = "DISTRICT"
43
35
  }
44
36
  declare enum Locale {
45
37
  US = "en-SE",
@@ -49,165 +41,33 @@ declare enum Locale {
49
41
  SCT = "en-SCT",
50
42
  DE = "de-DE"
51
43
  }
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"
44
+ declare enum Environment {
45
+ MARS = "MARS",
46
+ PROD = "PROD"
96
47
  }
97
48
 
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 = {
49
+ type RegionEnv = Readonly<{
127
50
  API_URL: string;
128
51
  AUTH_WEB_URL: string;
129
- CDN_HOST: string;
130
- DISTRICT_WEB_URL: string;
52
+ MYSCRIPT_HOST: string;
131
53
  LOGGLY_TAG: string;
132
- MAGMAMATH_URL: string;
54
+ SKOLFED_AUTH: string;
133
55
  SOCKET_URL: string;
134
56
  STUDENTS_WEB_URL: string;
135
57
  TEACHERS_WEB_URL: string;
136
- };
137
- type StudentsWebCommon = {
58
+ CDN_HOST: string;
59
+ }>;
60
+ type CommonEnv = Readonly<{
138
61
  GOOGLE_API_KEY: string;
139
62
  DESMOS_API_KEY: string;
140
- LOGGLY_CUSTOMER_TOKEN: string;
141
63
  MYSCRIPT_APPLICATION_KEY: string;
142
64
  MYSCRIPT_HMAC_KEY: string;
143
- MYSCRIPT_HOST: string;
144
65
  MYSCRIPT_SOCKET_KEY: string;
145
66
  MYSCRIPT_REST_APP_KEY: string;
146
67
  MYSCRIPT_REST_HMAC_KEY: 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;
68
+ LOGGLY_CUSTOMER_TOKEN: string;
207
69
  }>;
208
-
209
- declare const SSO_CONFIG_MAP: Record<SSO, SSOConfig>;
210
- declare const SSO_CONFIG_LIST: SSOConfig[];
70
+ type EnvironmentVariables = RegionEnv & CommonEnv;
211
71
 
212
72
  type StudentsLocaleConfig = CommonLocaleConfig & {
213
73
  textFormatting: {
@@ -250,13 +110,28 @@ type StudentsLocaleConfig = CommonLocaleConfig & {
250
110
  statsTab: {
251
111
  buttonWithMinWidth: boolean;
252
112
  };
253
- smartEval: {
254
- language: string;
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
+ };
255
126
  };
256
127
  };
257
128
 
129
+ declare enum MatrixMode {
130
+ SKILL = "SKILL",
131
+ STANDARD = "STANDARD"
132
+ }
133
+
258
134
  type TeachersLocaleConfig = CommonLocaleConfig & {
259
- country: string;
260
135
  emails: {
261
136
  studentsList: string;
262
137
  };
@@ -300,47 +175,12 @@ type TeachersLocaleConfig = CommonLocaleConfig & {
300
175
  getStarted: {
301
176
  showSentEmailInfo: boolean;
302
177
  };
303
- firstLoginBooks: {
304
- isLargeGrade: ((grade: number) => boolean) | null;
305
- };
306
178
  grades: {
307
179
  showPrefix: boolean;
308
180
  showOtherGrade: boolean;
309
181
  };
310
182
  };
311
183
 
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
-
344
184
  type CommonLocaleConfig = Readonly<{
345
185
  name: string;
346
186
  languageName: string;
@@ -358,74 +198,34 @@ type LocalePreset = {
358
198
  [Platform.DISTRICT_DASHBOARD]: {
359
199
  [key in Locale]: DistrictLocaleConfig;
360
200
  };
361
- [Platform.AUTH_WEB]: {
362
- [key in Locale]: AuthWebLocaleConfig;
363
- };
364
201
  };
365
202
  type LocaleConfig<P extends Platform> = LocalePreset[P][Locale];
366
203
 
367
- type DevOverrides<P extends Platform> = {
368
- [K in Locale]?: Partial<EnvironmentVars<P>>;
369
- };
370
204
  type ConfigOptions<P extends Platform> = {
371
205
  platform: P;
372
206
  environment: Environment;
373
- _DEV_OVERRIDES_?: DevOverrides<P>;
374
207
  };
375
208
  type SetProps = {
376
209
  locale?: Locale;
377
210
  environment?: Environment;
378
211
  };
379
212
  declare class AppConfigManager<P extends Platform> {
380
- private readonly _DEV_OVERRIDES_?;
381
213
  private readonly platform;
382
214
  environment: Environment;
383
215
  locale: Locale;
384
216
  private readonly setEnvs;
385
217
  private readonly setLocaleConfig;
386
- readonly $envs: effector.StoreWritable<EnvironmentVars<P>>;
218
+ readonly $envs: effector.StoreWritable<EnvironmentVariables>;
387
219
  readonly $localeConfig: effector.StoreWritable<LocaleConfig<P>>;
388
220
  constructor(opts: ConfigOptions<P>);
389
221
  private readonly syncConfigsStores;
390
222
  readonly set: (props: SetProps) => void;
391
- readonly onEnvsChange: (cb: (cfg: EnvironmentVars<P>) => void) => effector.Subscription;
223
+ readonly onEnvsChange: (cb: (cfg: EnvironmentVariables) => void) => effector.Subscription;
392
224
  readonly onLocaleChange: (cb: (cfg: LocaleConfig<P>) => void) => effector.Subscription;
393
225
  readonly getConfig: () => {
394
- envs: EnvironmentVars<P>;
226
+ envs: EnvironmentVariables;
395
227
  localeConfig: LocaleConfig<P>;
396
228
  };
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;
428
- };
429
229
  }
430
230
 
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 };
231
+ export { AppConfigManager, DateFormat, DateLocale, Environment, Locale, Platform };