@timeback/edubridge 0.1.0 → 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.
package/dist/errors.d.ts CHANGED
@@ -4,6 +4,6 @@
4
4
  * Re-exports common errors from `@timeback/internal-client-infra`.
5
5
  * Edubridge uses the same error format as other Timeback clients.
6
6
  */
7
- import { ApiError, ForbiddenError, NotFoundError, UnauthorizedError, ValidationError } from '@timeback/internal-client-infra';
8
- export { ApiError as EdubridgeError, ForbiddenError, NotFoundError, UnauthorizedError, ValidationError, };
7
+ import { ApiError, ForbiddenError, InputValidationError, NotFoundError, UnauthorizedError, ValidationError } from '@timeback/internal-client-infra';
8
+ export { ApiError as EdubridgeError, ForbiddenError, InputValidationError, NotFoundError, UnauthorizedError, ValidationError, };
9
9
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACN,QAAQ,EACR,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,MAAM,iCAAiC,CAAA;AAExC,OAAO,EACN,QAAQ,IAAI,cAAc,EAC1B,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,eAAe,GACf,CAAA"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACN,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,MAAM,iCAAiC,CAAA;AAExC,OAAO,EACN,QAAQ,IAAI,cAAc,EAC1B,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,eAAe,GACf,CAAA"}
package/dist/errors.js CHANGED
@@ -15,6 +15,15 @@ var __toESM = (mod, isNodeMode, target) => {
15
15
  });
16
16
  return to;
17
17
  };
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, {
21
+ get: all[name],
22
+ enumerable: true,
23
+ configurable: true,
24
+ set: (newValue) => all[name] = () => newValue
25
+ });
26
+ };
18
27
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
19
28
 
20
29
  // ../../internal/constants/src/endpoints.ts
@@ -68,9 +77,12 @@ var PLATFORM_ENDPOINTS = {
68
77
  // ../../internal/constants/src/typescript.ts
69
78
  var TypeScriptPackages = {
70
79
  tsc: "tsc",
71
- nativePreview: "@typescript/native-preview@7.0.0-dev.20251217.1"
80
+ nativePreview: "@typescript/native-preview"
81
+ };
82
+ var TYPESCRIPT_RUNNER = {
83
+ package: TypeScriptPackages.nativePreview,
84
+ bin: "tsgo"
72
85
  };
73
- var TYPESCRIPT_PACKAGE = TypeScriptPackages.nativePreview;
74
86
  // ../../internal/logger/src/debug.ts
75
87
  var patterns = null;
76
88
  var debugAll = false;
@@ -475,6 +487,9 @@ var BEYONDAI_PATHS = {
475
487
  },
476
488
  edubridge: {
477
489
  base: "/edubridge"
490
+ },
491
+ powerpath: {
492
+ base: "/powerpath"
478
493
  }
479
494
  };
480
495
  var LEARNWITHAI_PATHS = {
@@ -490,7 +505,8 @@ var LEARNWITHAI_PATHS = {
490
505
  gradebook: "/gradebook/1.0",
491
506
  resources: "/resources/1.0"
492
507
  },
493
- edubridge: null
508
+ edubridge: null,
509
+ powerpath: null
494
510
  };
495
511
  var PLATFORM_PATHS = {
496
512
  BEYOND_AI: BEYONDAI_PATHS,
@@ -512,7 +528,8 @@ function resolvePathProfiles(pathProfile, customPaths) {
512
528
  return {
513
529
  caliper: customPaths?.caliper ?? basePaths.caliper,
514
530
  oneroster: customPaths?.oneroster ?? basePaths.oneroster,
515
- edubridge: customPaths?.edubridge ?? basePaths.edubridge
531
+ edubridge: customPaths?.edubridge ?? basePaths.edubridge,
532
+ powerpath: customPaths?.powerpath ?? basePaths.powerpath
516
533
  };
517
534
  }
518
535
 
@@ -548,6 +565,10 @@ class TimebackProvider {
548
565
  baseUrl: platformEndpoints.api[env],
549
566
  authUrl: this.authUrl
550
567
  },
568
+ powerpath: {
569
+ baseUrl: platformEndpoints.api[env],
570
+ authUrl: this.authUrl
571
+ },
551
572
  caliper: {
552
573
  baseUrl: platformEndpoints.caliper[env],
553
574
  authUrl: this.authUrl
@@ -564,6 +585,7 @@ class TimebackProvider {
564
585
  this.endpoints = {
565
586
  oneroster: { baseUrl: config.baseUrl, authUrl: this.authUrl },
566
587
  edubridge: { baseUrl: config.baseUrl, authUrl: this.authUrl },
588
+ powerpath: { baseUrl: config.baseUrl, authUrl: this.authUrl },
567
589
  caliper: { baseUrl: config.baseUrl, authUrl: this.authUrl },
568
590
  qti: { baseUrl: config.baseUrl, authUrl: this.authUrl }
569
591
  };
@@ -971,6 +993,27 @@ class ValidationError extends ApiError {
971
993
  super(message, 422, response);
972
994
  }
973
995
  }
996
+
997
+ class InputValidationError extends ApiError {
998
+ name = "InputValidationError";
999
+ issues;
1000
+ constructor(message, issues) {
1001
+ const response = {
1002
+ imsx_codeMajor: "failure",
1003
+ imsx_severity: "error",
1004
+ imsx_description: message,
1005
+ imsx_error_details: issues.map((issue) => ({
1006
+ path: issue.path,
1007
+ message: issue.message
1008
+ }))
1009
+ };
1010
+ super(message, 400, response);
1011
+ this.issues = issues;
1012
+ }
1013
+ }
1014
+ function createInputValidationError(message, issues) {
1015
+ return new InputValidationError(message, issues);
1016
+ }
974
1017
  // ../../internal/client-infra/src/transport/constants.ts
975
1018
  var MAX_RETRIES = 3;
976
1019
  var RETRY_STATUS_CODES = [429, 503];
@@ -996,8 +1039,9 @@ class BaseTransport {
996
1039
  fetch: fetchFn
997
1040
  });
998
1041
  }
1042
+ const normalizedBaseUrl = config.baseUrl.endsWith("/") ? config.baseUrl : `${config.baseUrl}/`;
999
1043
  this.config = {
1000
- baseUrl: config.baseUrl,
1044
+ baseUrl: normalizedBaseUrl,
1001
1045
  timeout: config.timeout ?? 30000,
1002
1046
  fetch: fetchFn,
1003
1047
  tokenProvider
@@ -1083,7 +1127,8 @@ class BaseTransport {
1083
1127
  if (/^[a-z][a-z0-9+.-]*:/i.test(path)) {
1084
1128
  throw new Error(`Absolute URLs are not allowed in path: ${path}. Use relative paths only.`);
1085
1129
  }
1086
- const url = new URL(path, this.config.baseUrl);
1130
+ const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
1131
+ const url = new URL(normalizedPath, this.config.baseUrl);
1087
1132
  if (params) {
1088
1133
  for (const [key, value] of Object.entries(params)) {
1089
1134
  if (value !== undefined) {
@@ -1208,10 +1253,33 @@ function parseBodyPaginationRaw(body) {
1208
1253
  total: body.totalCount
1209
1254
  };
1210
1255
  }
1256
+ // ../../internal/client-infra/src/validation/index.ts
1257
+ function issue(path, message) {
1258
+ return { path, message };
1259
+ }
1260
+ function validateWithSchema(schema, data, context) {
1261
+ const result = schema.safeParse(data);
1262
+ if (result.success) {
1263
+ return;
1264
+ }
1265
+ const issues = result.error.issues.map((errorIssue) => ({
1266
+ path: errorIssue.path.join(".") || "(root)",
1267
+ message: errorIssue.message
1268
+ }));
1269
+ throw createInputValidationError(`Invalid ${context} data`, issues);
1270
+ }
1271
+ function validateNonEmptyString(value, name) {
1272
+ if (typeof value !== "string" || value.trim() === "") {
1273
+ throw createInputValidationError(`Invalid ${name}`, [
1274
+ issue(name, "Must be a non-empty string")
1275
+ ]);
1276
+ }
1277
+ }
1211
1278
  export {
1212
1279
  ValidationError,
1213
1280
  UnauthorizedError,
1214
1281
  NotFoundError,
1282
+ InputValidationError,
1215
1283
  ForbiddenError,
1216
1284
  ApiError as EdubridgeError
1217
1285
  };
package/dist/index.d.ts CHANGED
@@ -37,7 +37,8 @@ export { createEdubridgeClient } from './factory';
37
37
  export type { EdubridgeClientConfig } from './types/client';
38
38
  export type { Environment, EnvAuth, ExplicitAuth } from './types/client';
39
39
  export type { AuthCheckResult, ListParams, PageResult } from '@timeback/internal-client-infra';
40
- export type { ActivityMetricsData, ActivityParams, AggregatedMetrics, DailyActivityMap, EnrollmentFacts, EnrollmentFactsParams, GradeMasteryData, HighestGradeMastered, SubjectMetrics, TimeSpentMetricsData, WeeklyFactRecord, WeeklyFacts, WeeklyFactsParams, } from './types/analytics';
40
+ export type { ActivityMetricsData, AggregatedMetrics, DailyActivityMap, EnrollmentFacts, GradeMasteryData, HighestGradeMastered, SubjectMetrics, TimeSpentMetricsData, WeeklyFactRecord, WeeklyFacts, } from '@timeback/types/protocols/edubridge';
41
+ export type { ActivityParams, EnrollmentFactsParams, WeeklyFactsParams, } from '@timeback/types/zod';
41
42
  export { aggregateActivityMetrics } from './utils';
42
43
  export { Transport } from './lib';
43
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAMH,OAAO,EAAE,eAAe,EAAE,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAA;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAEjD,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAM3D,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAExE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAE9F,YAAY,EACX,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GACjB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAMlD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA"}
1
+ {"version":3,"file":"index.d.ts","s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