@magmamath/frontend-config 1.0.16-rc.2 → 1.0.16-rc.20

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
@@ -35,7 +35,8 @@ declare enum Platform {
35
35
  TEACHERS_WEB = "TEACHERS",
36
36
  DISTRICT_DASHBOARD = "DISTRICT",
37
37
  AUTH_WEB = "AUTH_WEB",
38
- WEB_ADMIN = "WEB_ADMIN"
38
+ WEB_ADMIN = "WEB_ADMIN",
39
+ MOBILE = "MOBILE"
39
40
  }
40
41
  declare enum Environment {
41
42
  MARS = "MARS",
@@ -48,7 +49,7 @@ declare enum PlatformBuildTarget {
48
49
  VENUS = "pre-release",
49
50
  PROD = "production"
50
51
  }
51
- declare enum AppLocale {
52
+ declare enum Locale {
52
53
  US = "en-SE",
53
54
  SE = "sv-SE",
54
55
  GB = "en-GB",
@@ -56,13 +57,6 @@ declare enum AppLocale {
56
57
  SCT = "en-SCT",
57
58
  DE = "de-DE"
58
59
  }
59
- declare enum ContentLocale {
60
- US = "en-SE",
61
- SE = "sv-SE",
62
- GB = "en-GB",
63
- CA = "en-CA",
64
- DE = "de-DE"
65
- }
66
60
  declare enum Source {
67
61
  MATTEAPPEN = 0,
68
62
  SKOLON = 1,
@@ -105,6 +99,10 @@ declare enum SSO {
105
99
  CANVAS = "CANVAS",
106
100
  QR_CODE = "QR_CODE"
107
101
  }
102
+ declare enum ApiRegion {
103
+ MAIN = "MAIN",
104
+ CANADA = "MAIN"
105
+ }
108
106
 
109
107
  declare enum MatrixMode {
110
108
  SKILL = "SKILL",
@@ -139,6 +137,14 @@ type SSO_DE = {
139
137
  MICROSOFT_AUTH: string;
140
138
  };
141
139
  type SSOVariant = SSO_US | SSO_DE | SSO_UK | SSO_SE;
140
+ type SSOByLocale = {
141
+ [Locale.US]: SSO_US;
142
+ [Locale.CA]: SSO_US;
143
+ [Locale.GB]: SSO_UK;
144
+ [Locale.SCT]: SSO_UK;
145
+ [Locale.SE]: SSO_SE;
146
+ [Locale.DE]: SSO_DE;
147
+ };
142
148
 
143
149
  type Prettify<T> = T extends Function ? T : {
144
150
  [K in keyof T]: T[K];
@@ -155,6 +161,43 @@ type RegionSpecificVars = {
155
161
  STUDENTS_WEB_URL: string;
156
162
  TEACHERS_WEB_URL: string;
157
163
  };
164
+
165
+ type AuthWebVars<T extends SSOVariant> = Prettify<AuthWebBaseVars & T>;
166
+ type AuthWebBaseVars = Omit<RegionSpecificVars, 'CDN_HOST' | 'LOGGLY_TAG' | 'SOCKET_URL'> & {
167
+ TOS_URL: string;
168
+ CLARITY_PROJECT_ID: string;
169
+ INTERCOM_APP_ID: string;
170
+ };
171
+ type AuthWebVarsPreset = {
172
+ [Locale.CA]: {
173
+ [key in Environment]: AuthWebVars<SSO_US>;
174
+ };
175
+ [Locale.DE]: {
176
+ [key in Environment]: AuthWebVars<SSO_DE>;
177
+ };
178
+ [Locale.GB]: {
179
+ [key in Environment]: AuthWebVars<SSO_UK>;
180
+ };
181
+ [Locale.SCT]: {
182
+ [key in Environment]: AuthWebVars<SSO_UK>;
183
+ };
184
+ [Locale.SE]: {
185
+ [key in Environment]: AuthWebVars<SSO_SE>;
186
+ };
187
+ [Locale.US]: {
188
+ [key in Environment]: AuthWebVars<SSO_US>;
189
+ };
190
+ };
191
+
192
+ type SSOConfig<T extends SSOVariant> = Readonly<{
193
+ name: string;
194
+ icon: ComponentType<IconProps>;
195
+ type: SSO;
196
+ loginSource: LoginSource;
197
+ getUrl: (envs: AuthWebVars<T>) => string;
198
+ ownUrl?: boolean;
199
+ }>;
200
+
158
201
  type StudentsWebCommon = {
159
202
  GOOGLE_API_KEY: string;
160
203
  DESMOS_API_KEY: string;
@@ -166,6 +209,13 @@ type StudentsWebCommon = {
166
209
  MYSCRIPT_REST_APP_KEY: string;
167
210
  MYSCRIPT_REST_HMAC_KEY: string;
168
211
  };
212
+ type StudentsWebVars = RegionSpecificVars & StudentsWebCommon;
213
+ type StudentsWebVarsPreset = {
214
+ [key in Locale]: {
215
+ [key in Environment]: StudentsWebVars;
216
+ };
217
+ };
218
+
169
219
  type TeachersWebCommon = {
170
220
  MYSCRIPT_HOST: string;
171
221
  MYSCRIPT_REST_APP_KEY: string;
@@ -175,11 +225,65 @@ type TeachersWebCommon = {
175
225
  CLARITY_PROJECT_ID: string;
176
226
  LOGGLY_CUSTOMER_TOKEN: string;
177
227
  };
228
+ type TeachersWebVars = RegionSpecificVars & TeachersWebCommon;
229
+ type TeachersWebVarsPreset = {
230
+ [key in Locale]: {
231
+ [key in Environment]: TeachersWebVars;
232
+ };
233
+ };
234
+
178
235
  type DistrictCommon = {
179
236
  INTERCOM_APP_ID: string;
180
237
  CLARITY_PROJECT_ID: string;
181
238
  PROBLEM_IMAGE_SIZE_LIMIT: number;
182
239
  };
240
+ type DistrictDashboardVars = Omit<RegionSpecificVars, 'SOCKET_URL'> & DistrictCommon;
241
+ type DistrictWebVarsPreset = {
242
+ [key in Locale]: {
243
+ [key in Environment]: DistrictDashboardVars;
244
+ };
245
+ };
246
+
247
+ type MobileCommon = {
248
+ DESMOS_API_KEY: string;
249
+ USER_AGENT: string;
250
+ LOGGLY_CUSTOMER_TOKEN: string;
251
+ MYSCRIPT_HOST: string;
252
+ MYSCRIPT_APPLICATION_KEY: string;
253
+ MYSCRIPT_HMAC_KEY: string;
254
+ MYSCRIPT_SOCKET_KEY: string;
255
+ MYSCRIPT_REST_APP_KEY: string;
256
+ MYSCRIPT_REST_HMAC_KEY: string;
257
+ };
258
+ type MobileBaseVars = {
259
+ TEACHERS_WEB_URL: string;
260
+ API_URL: string;
261
+ CDN_HOST: string;
262
+ SOCKET_URL: string;
263
+ LOGGLY_TAG: string;
264
+ } & MobileCommon;
265
+ type MobileVars<T extends SSOVariant> = Prettify<MobileBaseVars & T>;
266
+ type MobileVarsPreset = {
267
+ [Locale.CA]: {
268
+ [key in Environment]: MobileVars<SSO_US>;
269
+ };
270
+ [Locale.DE]: {
271
+ [key in Environment]: MobileVars<SSO_DE>;
272
+ };
273
+ [Locale.GB]: {
274
+ [key in Environment]: MobileVars<SSO_UK>;
275
+ };
276
+ [Locale.SCT]: {
277
+ [key in Environment]: MobileVars<SSO_UK>;
278
+ };
279
+ [Locale.SE]: {
280
+ [key in Environment]: MobileVars<SSO_SE>;
281
+ };
282
+ [Locale.US]: {
283
+ [key in Environment]: MobileVars<SSO_US>;
284
+ };
285
+ };
286
+
183
287
  type RegionSpecificWebAdminVars = {
184
288
  API_URL: string;
185
289
  CDN_HOST: string;
@@ -191,68 +295,22 @@ type WebAdminCommon = {
191
295
  MARS_URL: string;
192
296
  PROD_URL: string;
193
297
  };
194
- type StudentsWebVars = RegionSpecificVars & StudentsWebCommon;
195
- type TeachersWebVars = RegionSpecificVars & TeachersWebCommon;
196
- type DistrictDashboardVars = Omit<RegionSpecificVars, 'SOCKET_URL'> & DistrictCommon;
197
298
  type WebAdminVars = RegionSpecificWebAdminVars & WebAdminCommon;
198
- type AuthWebBaseVars = Omit<RegionSpecificVars, 'CDN_HOST' | 'LOGGLY_TAG' | 'SOCKET_URL'> & {
199
- TOS_URL: string;
200
- CLARITY_PROJECT_ID: string;
201
- INTERCOM_APP_ID: string;
202
- };
203
- type AuthWebVars<T extends SSOVariant> = Prettify<AuthWebBaseVars & T>;
204
- type EnvPreset = Readonly<{
205
- [Platform.STUDENTS_WEB]: {
206
- [key in AppLocale]: {
207
- [key in Environment]: StudentsWebVars;
208
- };
209
- };
210
- [Platform.TEACHERS_WEB]: {
211
- [key in AppLocale]: {
212
- [key in Environment]: TeachersWebVars;
213
- };
299
+ type WebAdminVarsPreset = {
300
+ [key in Locale]: {
301
+ [key in Environment]: WebAdminVars;
214
302
  };
215
- [Platform.DISTRICT_DASHBOARD]: {
216
- [key in AppLocale]: {
217
- [key in Environment]: DistrictDashboardVars;
218
- };
219
- };
220
- [Platform.AUTH_WEB]: {
221
- [AppLocale.CA]: {
222
- [key in Environment]: AuthWebVars<SSO_US>;
223
- };
224
- [AppLocale.DE]: {
225
- [key in Environment]: AuthWebVars<SSO_DE>;
226
- };
227
- [AppLocale.GB]: {
228
- [key in Environment]: AuthWebVars<SSO_UK>;
229
- };
230
- [AppLocale.SCT]: {
231
- [key in Environment]: AuthWebVars<SSO_UK>;
232
- };
233
- [AppLocale.SE]: {
234
- [key in Environment]: AuthWebVars<SSO_SE>;
235
- };
236
- [AppLocale.US]: {
237
- [key in Environment]: AuthWebVars<SSO_US>;
238
- };
239
- };
240
- [Platform.WEB_ADMIN]: {
241
- [key in AppLocale]: {
242
- [key in Environment]: WebAdminVars;
243
- };
244
- };
245
- }>;
246
- type EnvironmentVars<P extends Platform> = EnvPreset[P][AppLocale][Environment];
303
+ };
247
304
 
248
- type SSOConfig<T extends SSOVariant> = Readonly<{
249
- name: string;
250
- icon: ComponentType<IconProps>;
251
- type: SSO;
252
- loginSource: LoginSource;
253
- getUrl: (envs: AuthWebVars<T>) => string;
254
- ownUrl?: boolean;
305
+ type EnvPreset = Readonly<{
306
+ [Platform.STUDENTS_WEB]: StudentsWebVarsPreset;
307
+ [Platform.TEACHERS_WEB]: TeachersWebVarsPreset;
308
+ [Platform.DISTRICT_DASHBOARD]: DistrictWebVarsPreset;
309
+ [Platform.AUTH_WEB]: AuthWebVarsPreset;
310
+ [Platform.WEB_ADMIN]: WebAdminVarsPreset;
311
+ [Platform.MOBILE]: MobileVarsPreset;
255
312
  }>;
313
+ type EnvironmentVars<P extends Platform> = EnvPreset[P][Locale][Environment];
256
314
 
257
315
  declare function buildTargetToEnvironment(buildTarget: PlatformBuildTarget): Environment;
258
316
 
@@ -264,7 +322,7 @@ type StudentsLocaleConfig = CommonLocaleConfig & {
264
322
  numberDecimalSeparator: string;
265
323
  };
266
324
  practiceMode: {
267
- languageCode: AppLocale;
325
+ languageCode: Locale;
268
326
  defaultPracticeTreeId: string;
269
327
  };
270
328
  chatbot: {
@@ -387,89 +445,90 @@ type AuthWebLocaleConfig<T extends SSOVariant> = {
387
445
  isPrimaryRegion: boolean;
388
446
  regionGroup: string;
389
447
  navigatorLanguages: string[];
390
- locale: AppLocale;
448
+ locale: Locale;
449
+ };
450
+
451
+ type WebAdminLocaleConfig = {
452
+ name: string;
453
+ icon: ComponentType<IconProps>;
454
+ locale: Locale;
455
+ isPrimaryRegion: boolean;
456
+ regionGroup: string;
457
+ apiRegion: ApiRegion;
391
458
  };
392
459
 
393
460
  type CommonLocaleConfig = Readonly<{
394
461
  name: string;
395
462
  languageName: string;
396
463
  languageHeader: string;
397
- contentLocale: ContentLocale;
464
+ contentLocale: Locale;
398
465
  shortCode: string;
399
466
  }>;
400
467
  type LocalePreset = {
401
468
  [Platform.STUDENTS_WEB]: {
402
- [key in AppLocale]: StudentsLocaleConfig;
469
+ [key in Locale]: StudentsLocaleConfig;
403
470
  };
404
471
  [Platform.TEACHERS_WEB]: {
405
- [key in AppLocale]: TeachersLocaleConfig;
472
+ [key in Locale]: TeachersLocaleConfig;
406
473
  };
407
474
  [Platform.DISTRICT_DASHBOARD]: {
408
- [key in AppLocale]: DistrictLocaleConfig;
475
+ [key in Locale]: DistrictLocaleConfig;
476
+ };
477
+ [Platform.AUTH_WEB]: {
478
+ [key in Locale]: AuthWebLocaleConfig<SSOByLocale[key]>;
409
479
  };
410
480
  [Platform.WEB_ADMIN]: {
411
- [key in AppLocale]: {};
481
+ [key in Locale]: WebAdminLocaleConfig;
412
482
  };
413
- [Platform.AUTH_WEB]: {
414
- [AppLocale.CA]: AuthWebLocaleConfig<SSO_US>;
415
- [AppLocale.DE]: AuthWebLocaleConfig<SSO_DE>;
416
- [AppLocale.GB]: AuthWebLocaleConfig<SSO_UK>;
417
- [AppLocale.SCT]: AuthWebLocaleConfig<SSO_UK>;
418
- [AppLocale.SE]: AuthWebLocaleConfig<SSO_SE>;
419
- [AppLocale.US]: AuthWebLocaleConfig<SSO_US>;
483
+ [Platform.MOBILE]: {
484
+ [key in Locale]: AuthWebLocaleConfig<SSOByLocale[key]>;
420
485
  };
421
486
  };
422
- type LocaleConfig<P extends Platform> = LocalePreset[P][AppLocale];
487
+ type LocaleConfig<P extends Platform, L extends Locale> = LocalePreset[P][L];
423
488
 
424
489
  type DevOverrides<P extends Platform> = {
425
- [K in AppLocale]?: Partial<EnvironmentVars<P>>;
490
+ [K in Locale]?: Partial<EnvironmentVars<P>>;
426
491
  };
427
492
  type ConfigOptions<P extends Platform> = {
428
493
  platform: P;
429
494
  environment: Environment;
430
495
  _DEV_OVERRIDES_?: DevOverrides<P>;
431
496
  };
432
- type SetProps = {
433
- locale?: AppLocale;
434
- envsRegion?: AppLocale;
497
+ type SetProps<L extends Locale> = {
498
+ locale?: L;
499
+ envsRegion?: L;
435
500
  environment?: Environment;
436
501
  };
437
- declare class AppConfigManager<P extends Platform> {
502
+ declare class AppConfigManager<P extends Platform, L extends Locale> {
438
503
  private readonly _DEV_OVERRIDES_?;
439
504
  private readonly platform;
440
505
  environment: Environment;
441
- locale: AppLocale;
442
- envsRegion: AppLocale;
506
+ locale: L;
507
+ envsRegion: L;
443
508
  private readonly setEnvs;
444
509
  private readonly setLocaleConfig;
445
510
  readonly $envs: effector.StoreWritable<EnvironmentVars<P>>;
446
- readonly $localeConfig: effector.StoreWritable<LocaleConfig<P>>;
511
+ readonly $localeConfig: effector.StoreWritable<LocaleConfig<P, L>>;
447
512
  constructor(opts: ConfigOptions<P>);
448
513
  private readonly syncConfigsStores;
449
- readonly set: (props: SetProps) => void;
514
+ readonly set: (props: SetProps<L>) => void;
450
515
  getEnvs: () => EnvironmentVars<P>;
451
- getLocaleConfig: () => LocaleConfig<P> & {
452
- locale: AppLocale;
516
+ getLocaleConfig: () => LocaleConfig<P, L> & {
517
+ locale: L;
453
518
  };
454
519
  readonly onEnvsChange: (cb: (cfg: EnvironmentVars<P>) => void) => effector.Subscription;
455
- readonly onLocaleChange: (cb: (cfg: LocaleConfig<P>) => void) => effector.Subscription;
520
+ readonly onLocaleChange: (cb: (cfg: LocaleConfig<P, L>) => void) => effector.Subscription;
456
521
  readonly getPresets: () => {
457
522
  envPreset: Readonly<{
458
- STUDENTS: { [key in AppLocale]: { [key_1 in Environment]: StudentsWebVars; }; };
459
- TEACHERS: { [key in AppLocale]: { [key_1 in Environment]: TeachersWebVars; }; };
460
- DISTRICT: { [key in AppLocale]: { [key_1 in Environment]: DistrictDashboardVars; }; };
461
- AUTH_WEB: {
462
- [AppLocale.CA]: { [key in Environment]: AuthWebVars<SSO_US>; };
463
- [AppLocale.DE]: { [key in Environment]: AuthWebVars<SSO_DE>; };
464
- [AppLocale.GB]: { [key in Environment]: AuthWebVars<SSO_UK>; };
465
- [AppLocale.SCT]: { [key in Environment]: AuthWebVars<SSO_UK>; };
466
- [AppLocale.SE]: { [key in Environment]: AuthWebVars<SSO_SE>; };
467
- [AppLocale.US]: { [key in Environment]: AuthWebVars<SSO_US>; };
468
- };
469
- WEB_ADMIN: { [key in AppLocale]: { [key_1 in Environment]: WebAdminVars; }; };
523
+ STUDENTS: StudentsWebVarsPreset;
524
+ TEACHERS: TeachersWebVarsPreset;
525
+ DISTRICT: DistrictWebVarsPreset;
526
+ AUTH_WEB: AuthWebVarsPreset;
527
+ WEB_ADMIN: WebAdminVarsPreset;
528
+ MOBILE: MobileVarsPreset;
470
529
  }>;
471
530
  localePreset: LocalePreset;
472
531
  };
473
532
  }
474
533
 
475
- export { AppConfigManager, AppLocale, type AuthWebVars, ContentLocale, DateFormat, DateLocale, type DistrictCommon, type DistrictDashboardVars, type EnvPreset, Environment, type EnvironmentVars, LoginSource, MatrixMode, Platform, PlatformBuildTarget, type RegionSpecificVars, type RegionSpecificWebAdminVars, SSO, type SSOConfig, Source, type StudentsWebCommon, type StudentsWebVars, type TeachersWebCommon, type TeachersWebVars, type WebAdminCommon, type WebAdminVars, buildTargetToEnvironment };
534
+ export { ApiRegion, AppConfigManager, DateFormat, DateLocale, type EnvPreset, Environment, type EnvironmentVars, Locale, LoginSource, MatrixMode, Platform, PlatformBuildTarget, SSO, type SSOConfig, Source, buildTargetToEnvironment };