@timeback/qti 0.1.1 → 0.1.2

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.
@@ -6,12 +6,17 @@
6
6
  import type { ClientUrlMaps, Platform } from '@timeback/internal-client-infra';
7
7
  /**
8
8
  * Environment variable names for fallback config.
9
+ *
10
+ * Supports fallback chains - tries each env var in order until one is defined:
11
+ * - `TIMEBACK_API_*` (canonical/preferred)
12
+ * - `TIMEBACK_*` (unified Timeback shorthand)
13
+ * - `QTI_*` (service-specific legacy)
9
14
  */
10
15
  export declare const QTI_ENV_VARS: {
11
- readonly baseUrl: "QTI_BASE_URL";
12
- readonly clientId: "QTI_CLIENT_ID";
13
- readonly clientSecret: "QTI_CLIENT_SECRET";
14
- readonly authUrl: "QTI_TOKEN_URL";
16
+ readonly baseUrl: readonly ["TIMEBACK_API_BASE_URL", "TIMEBACK_BASE_URL", "QTI_BASE_URL"];
17
+ readonly clientId: readonly ["TIMEBACK_API_CLIENT_ID", "TIMEBACK_CLIENT_ID", "QTI_CLIENT_ID"];
18
+ readonly clientSecret: readonly ["TIMEBACK_API_CLIENT_SECRET", "TIMEBACK_CLIENT_SECRET", "QTI_CLIENT_SECRET"];
19
+ readonly authUrl: readonly ["TIMEBACK_API_AUTH_URL", "TIMEBACK_AUTH_URL", "QTI_TOKEN_URL"];
15
20
  };
16
21
  /**
17
22
  * Get URL maps for a specific platform.
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAM9E;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAA;AAMV;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,QAA2B,GAAG,aAAa,CAM1F"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAM9E;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;;;;;CAKf,CAAA;AAMV;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,QAA2B,GAAG,aAAa,CAM1F"}
package/dist/errors.js CHANGED
@@ -487,6 +487,9 @@ var BEYONDAI_PATHS = {
487
487
  },
488
488
  edubridge: {
489
489
  base: "/edubridge"
490
+ },
491
+ powerpath: {
492
+ base: "/powerpath"
490
493
  }
491
494
  };
492
495
  var LEARNWITHAI_PATHS = {
@@ -502,7 +505,8 @@ var LEARNWITHAI_PATHS = {
502
505
  gradebook: "/gradebook/1.0",
503
506
  resources: "/resources/1.0"
504
507
  },
505
- edubridge: null
508
+ edubridge: null,
509
+ powerpath: null
506
510
  };
507
511
  var PLATFORM_PATHS = {
508
512
  BEYOND_AI: BEYONDAI_PATHS,
@@ -524,7 +528,8 @@ function resolvePathProfiles(pathProfile, customPaths) {
524
528
  return {
525
529
  caliper: customPaths?.caliper ?? basePaths.caliper,
526
530
  oneroster: customPaths?.oneroster ?? basePaths.oneroster,
527
- edubridge: customPaths?.edubridge ?? basePaths.edubridge
531
+ edubridge: customPaths?.edubridge ?? basePaths.edubridge,
532
+ powerpath: customPaths?.powerpath ?? basePaths.powerpath
528
533
  };
529
534
  }
530
535
 
@@ -560,6 +565,10 @@ class TimebackProvider {
560
565
  baseUrl: platformEndpoints.api[env],
561
566
  authUrl: this.authUrl
562
567
  },
568
+ powerpath: {
569
+ baseUrl: platformEndpoints.api[env],
570
+ authUrl: this.authUrl
571
+ },
563
572
  caliper: {
564
573
  baseUrl: platformEndpoints.caliper[env],
565
574
  authUrl: this.authUrl
@@ -576,6 +585,7 @@ class TimebackProvider {
576
585
  this.endpoints = {
577
586
  oneroster: { baseUrl: config.baseUrl, authUrl: this.authUrl },
578
587
  edubridge: { baseUrl: config.baseUrl, authUrl: this.authUrl },
588
+ powerpath: { baseUrl: config.baseUrl, authUrl: this.authUrl },
579
589
  caliper: { baseUrl: config.baseUrl, authUrl: this.authUrl },
580
590
  qti: { baseUrl: config.baseUrl, authUrl: this.authUrl }
581
591
  };
@@ -694,7 +704,17 @@ class TimebackProvider {
694
704
  // ../../internal/client-infra/src/utils/utils.ts
695
705
  function getEnv(key) {
696
706
  try {
697
- return typeof process === "undefined" ? undefined : process.env[key];
707
+ if (typeof process === "undefined")
708
+ return;
709
+ if (typeof key === "string") {
710
+ return process.env[key];
711
+ }
712
+ for (const k of key) {
713
+ const value = process.env[k];
714
+ if (value !== undefined)
715
+ return value;
716
+ }
717
+ return;
698
718
  } catch {
699
719
  return;
700
720
  }
@@ -728,6 +748,18 @@ var DEFAULT_PROVIDER_REGISTRY = {
728
748
  };
729
749
 
730
750
  // ../../internal/client-infra/src/config/resolve.ts
751
+ function primaryEnvVar(key) {
752
+ if (typeof key === "string") {
753
+ return key;
754
+ }
755
+ if (key.length === 0) {
756
+ throw new Error(`Missing env var key: ${key}`);
757
+ }
758
+ return key[0];
759
+ }
760
+ function formatEnvVarKey(key) {
761
+ return primaryEnvVar(key);
762
+ }
731
763
  function validateEnv(env) {
732
764
  if (env !== "staging" && env !== "production") {
733
765
  throw new Error(`Invalid env "${env}": must be "staging" or "production"`);
@@ -738,10 +770,10 @@ function validateAuth(auth, envVars) {
738
770
  const clientId = auth?.clientId ?? getEnv(envVars.clientId);
739
771
  const clientSecret = auth?.clientSecret ?? getEnv(envVars.clientSecret);
740
772
  if (!clientId) {
741
- throw new Error(`Missing clientId: provide in config or set ${envVars.clientId}`);
773
+ throw new Error(`Missing clientId: provide in config or set ${formatEnvVarKey(envVars.clientId)}`);
742
774
  }
743
775
  if (!clientSecret) {
744
- throw new Error(`Missing clientSecret: provide in config or set ${envVars.clientSecret}`);
776
+ throw new Error(`Missing clientSecret: provide in config or set ${formatEnvVarKey(envVars.clientSecret)}`);
745
777
  }
746
778
  return { clientId, clientSecret };
747
779
  }
@@ -757,21 +789,21 @@ function buildMissingEnvError(envVars) {
757
789
  const clientId = getEnv(envVars.clientId);
758
790
  const clientSecret = getEnv(envVars.clientSecret);
759
791
  if (baseUrl === undefined && clientId === undefined) {
760
- const hint = envVars.env ?? envVars.baseUrl;
792
+ const hint = formatEnvVarKey(envVars.env ?? envVars.baseUrl);
761
793
  return `Missing env: provide in config or set ${hint}`;
762
794
  }
763
795
  const missing = [];
764
796
  if (baseUrl === undefined) {
765
- missing.push(envVars.env ?? envVars.baseUrl);
797
+ missing.push(formatEnvVarKey(envVars.env ?? envVars.baseUrl));
766
798
  }
767
799
  if (baseUrl !== undefined && authUrl === undefined) {
768
- missing.push(envVars.authUrl);
800
+ missing.push(formatEnvVarKey(envVars.authUrl));
769
801
  }
770
802
  if (clientId === undefined) {
771
- missing.push(envVars.clientId);
803
+ missing.push(formatEnvVarKey(envVars.clientId));
772
804
  }
773
805
  if (clientSecret === undefined) {
774
- missing.push(envVars.clientSecret);
806
+ missing.push(formatEnvVarKey(envVars.clientSecret));
775
807
  }
776
808
  return `Missing environment variables: ${missing.join(", ")}`;
777
809
  }