@timeback/oneroster 0.1.4 → 0.1.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.
@@ -6,12 +6,17 @@
6
6
  import type { ClientUrlMaps, Platform } from '@timeback/internal-client-infra';
7
7
  /**
8
8
  * Environment variable names for OneRoster configuration fallback.
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
+ * - `ONEROSTER_*` (service-specific legacy)
9
14
  */
10
15
  export declare const ONEROSTER_ENV_VARS: {
11
- readonly baseUrl: "ONEROSTER_BASE_URL";
12
- readonly clientId: "ONEROSTER_CLIENT_ID";
13
- readonly clientSecret: "ONEROSTER_CLIENT_SECRET";
14
- readonly authUrl: "ONEROSTER_TOKEN_URL";
16
+ readonly baseUrl: readonly ["TIMEBACK_API_BASE_URL", "TIMEBACK_BASE_URL", "ONEROSTER_BASE_URL"];
17
+ readonly clientId: readonly ["TIMEBACK_API_CLIENT_ID", "TIMEBACK_CLIENT_ID", "ONEROSTER_CLIENT_ID"];
18
+ readonly clientSecret: readonly ["TIMEBACK_API_CLIENT_SECRET", "TIMEBACK_CLIENT_SECRET", "ONEROSTER_CLIENT_SECRET"];
19
+ readonly authUrl: readonly ["TIMEBACK_API_AUTH_URL", "TIMEBACK_AUTH_URL", "ONEROSTER_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,kBAAkB;;;;;CAKrB,CAAA;AAMV;;;;;GAKG;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,kBAAkB;;;;;CAKrB,CAAA;AAMV;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,QAA2B,GAAG,aAAa,CAM1F"}
package/dist/errors.js CHANGED
@@ -704,7 +704,17 @@ class TimebackProvider {
704
704
  // ../../internal/client-infra/src/utils/utils.ts
705
705
  function getEnv(key) {
706
706
  try {
707
- 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;
708
718
  } catch {
709
719
  return;
710
720
  }
@@ -738,6 +748,18 @@ var DEFAULT_PROVIDER_REGISTRY = {
738
748
  };
739
749
 
740
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
+ }
741
763
  function validateEnv(env) {
742
764
  if (env !== "staging" && env !== "production") {
743
765
  throw new Error(`Invalid env "${env}": must be "staging" or "production"`);
@@ -748,10 +770,10 @@ function validateAuth(auth, envVars) {
748
770
  const clientId = auth?.clientId ?? getEnv(envVars.clientId);
749
771
  const clientSecret = auth?.clientSecret ?? getEnv(envVars.clientSecret);
750
772
  if (!clientId) {
751
- 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)}`);
752
774
  }
753
775
  if (!clientSecret) {
754
- 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)}`);
755
777
  }
756
778
  return { clientId, clientSecret };
757
779
  }
@@ -767,21 +789,21 @@ function buildMissingEnvError(envVars) {
767
789
  const clientId = getEnv(envVars.clientId);
768
790
  const clientSecret = getEnv(envVars.clientSecret);
769
791
  if (baseUrl === undefined && clientId === undefined) {
770
- const hint = envVars.env ?? envVars.baseUrl;
792
+ const hint = formatEnvVarKey(envVars.env ?? envVars.baseUrl);
771
793
  return `Missing env: provide in config or set ${hint}`;
772
794
  }
773
795
  const missing = [];
774
796
  if (baseUrl === undefined) {
775
- missing.push(envVars.env ?? envVars.baseUrl);
797
+ missing.push(formatEnvVarKey(envVars.env ?? envVars.baseUrl));
776
798
  }
777
799
  if (baseUrl !== undefined && authUrl === undefined) {
778
- missing.push(envVars.authUrl);
800
+ missing.push(formatEnvVarKey(envVars.authUrl));
779
801
  }
780
802
  if (clientId === undefined) {
781
- missing.push(envVars.clientId);
803
+ missing.push(formatEnvVarKey(envVars.clientId));
782
804
  }
783
805
  if (clientSecret === undefined) {
784
- missing.push(envVars.clientSecret);
806
+ missing.push(formatEnvVarKey(envVars.clientSecret));
785
807
  }
786
808
  return `Missing environment variables: ${missing.join(", ")}`;
787
809
  }
package/dist/index.js CHANGED
@@ -704,7 +704,17 @@ class TimebackProvider {
704
704
  // ../../internal/client-infra/src/utils/utils.ts
705
705
  function getEnv(key) {
706
706
  try {
707
- 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;
708
718
  } catch {
709
719
  return;
710
720
  }
@@ -738,6 +748,18 @@ var DEFAULT_PROVIDER_REGISTRY = {
738
748
  };
739
749
 
740
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
+ }
741
763
  function validateEnv(env) {
742
764
  if (env !== "staging" && env !== "production") {
743
765
  throw new Error(`Invalid env "${env}": must be "staging" or "production"`);
@@ -748,10 +770,10 @@ function validateAuth(auth, envVars) {
748
770
  const clientId = auth?.clientId ?? getEnv(envVars.clientId);
749
771
  const clientSecret = auth?.clientSecret ?? getEnv(envVars.clientSecret);
750
772
  if (!clientId) {
751
- 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)}`);
752
774
  }
753
775
  if (!clientSecret) {
754
- 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)}`);
755
777
  }
756
778
  return { clientId, clientSecret };
757
779
  }
@@ -767,21 +789,21 @@ function buildMissingEnvError(envVars) {
767
789
  const clientId = getEnv(envVars.clientId);
768
790
  const clientSecret = getEnv(envVars.clientSecret);
769
791
  if (baseUrl === undefined && clientId === undefined) {
770
- const hint = envVars.env ?? envVars.baseUrl;
792
+ const hint = formatEnvVarKey(envVars.env ?? envVars.baseUrl);
771
793
  return `Missing env: provide in config or set ${hint}`;
772
794
  }
773
795
  const missing = [];
774
796
  if (baseUrl === undefined) {
775
- missing.push(envVars.env ?? envVars.baseUrl);
797
+ missing.push(formatEnvVarKey(envVars.env ?? envVars.baseUrl));
776
798
  }
777
799
  if (baseUrl !== undefined && authUrl === undefined) {
778
- missing.push(envVars.authUrl);
800
+ missing.push(formatEnvVarKey(envVars.authUrl));
779
801
  }
780
802
  if (clientId === undefined) {
781
- missing.push(envVars.clientId);
803
+ missing.push(formatEnvVarKey(envVars.clientId));
782
804
  }
783
805
  if (clientSecret === undefined) {
784
- missing.push(envVars.clientSecret);
806
+ missing.push(formatEnvVarKey(envVars.clientSecret));
785
807
  }
786
808
  return `Missing environment variables: ${missing.join(", ")}`;
787
809
  }
@@ -1504,10 +1526,10 @@ function validateSourcedId(sourcedId, context) {
1504
1526
  }
1505
1527
  // src/constants.ts
1506
1528
  var ONEROSTER_ENV_VARS = {
1507
- baseUrl: "ONEROSTER_BASE_URL",
1508
- clientId: "ONEROSTER_CLIENT_ID",
1509
- clientSecret: "ONEROSTER_CLIENT_SECRET",
1510
- authUrl: "ONEROSTER_TOKEN_URL"
1529
+ baseUrl: ["TIMEBACK_API_BASE_URL", "TIMEBACK_BASE_URL", "ONEROSTER_BASE_URL"],
1530
+ clientId: ["TIMEBACK_API_CLIENT_ID", "TIMEBACK_CLIENT_ID", "ONEROSTER_CLIENT_ID"],
1531
+ clientSecret: ["TIMEBACK_API_CLIENT_SECRET", "TIMEBACK_CLIENT_SECRET", "ONEROSTER_CLIENT_SECRET"],
1532
+ authUrl: ["TIMEBACK_API_AUTH_URL", "TIMEBACK_AUTH_URL", "ONEROSTER_TOKEN_URL"]
1511
1533
  };
1512
1534
 
1513
1535
  // src/lib/resolve.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timeback/oneroster",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {