timeback 0.2.1 → 0.2.2-beta.20260320221119
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/cli.js +342 -327
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -11676,158 +11676,8 @@ var {
|
|
|
11676
11676
|
Help
|
|
11677
11677
|
} = import__.default;
|
|
11678
11678
|
|
|
11679
|
-
// ../clients/core/dist/chunk-
|
|
11679
|
+
// ../clients/core/dist/chunk-bjb7ngh9.js
|
|
11680
11680
|
init_chunk_3j7jywnx();
|
|
11681
|
-
|
|
11682
|
-
class ApiError extends Error {
|
|
11683
|
-
statusCode;
|
|
11684
|
-
response;
|
|
11685
|
-
name = "ApiError";
|
|
11686
|
-
constructor(message, statusCode, response) {
|
|
11687
|
-
super(message);
|
|
11688
|
-
this.statusCode = statusCode;
|
|
11689
|
-
this.response = response;
|
|
11690
|
-
}
|
|
11691
|
-
get minorCodes() {
|
|
11692
|
-
const ims = this.response;
|
|
11693
|
-
if (!ims?.imsx_CodeMinor?.imsx_codeMinorField) {
|
|
11694
|
-
return [];
|
|
11695
|
-
}
|
|
11696
|
-
return ims.imsx_CodeMinor.imsx_codeMinorField.map((field) => ({
|
|
11697
|
-
field: field.imsx_codeMinorFieldName,
|
|
11698
|
-
value: field.imsx_codeMinorFieldValue
|
|
11699
|
-
}));
|
|
11700
|
-
}
|
|
11701
|
-
get details() {
|
|
11702
|
-
const ims = this.response;
|
|
11703
|
-
return ims?.imsx_error_details ?? [];
|
|
11704
|
-
}
|
|
11705
|
-
}
|
|
11706
|
-
|
|
11707
|
-
class UnauthorizedError extends ApiError {
|
|
11708
|
-
name = "UnauthorizedError";
|
|
11709
|
-
constructor(message = "Unauthorized", response) {
|
|
11710
|
-
super(message, 401, response);
|
|
11711
|
-
}
|
|
11712
|
-
}
|
|
11713
|
-
|
|
11714
|
-
class ForbiddenError extends ApiError {
|
|
11715
|
-
name = "ForbiddenError";
|
|
11716
|
-
constructor(message = "Forbidden", response) {
|
|
11717
|
-
super(message, 403, response);
|
|
11718
|
-
}
|
|
11719
|
-
}
|
|
11720
|
-
|
|
11721
|
-
class NotFoundError extends ApiError {
|
|
11722
|
-
name = "NotFoundError";
|
|
11723
|
-
constructor(message = "Not Found", response) {
|
|
11724
|
-
super(message, 404, response);
|
|
11725
|
-
}
|
|
11726
|
-
}
|
|
11727
|
-
|
|
11728
|
-
class ValidationError extends ApiError {
|
|
11729
|
-
name = "ValidationError";
|
|
11730
|
-
constructor(message = "Validation Error", response) {
|
|
11731
|
-
super(message, 422, response);
|
|
11732
|
-
}
|
|
11733
|
-
}
|
|
11734
|
-
|
|
11735
|
-
class InputValidationError extends ApiError {
|
|
11736
|
-
name = "InputValidationError";
|
|
11737
|
-
issues;
|
|
11738
|
-
constructor(message, issues) {
|
|
11739
|
-
const response = {
|
|
11740
|
-
imsx_codeMajor: "failure",
|
|
11741
|
-
imsx_severity: "error",
|
|
11742
|
-
imsx_description: message,
|
|
11743
|
-
imsx_error_details: issues.map((issue) => ({
|
|
11744
|
-
path: issue.path,
|
|
11745
|
-
message: issue.message
|
|
11746
|
-
}))
|
|
11747
|
-
};
|
|
11748
|
-
super(message, 400, response);
|
|
11749
|
-
this.issues = issues;
|
|
11750
|
-
}
|
|
11751
|
-
}
|
|
11752
|
-
function createInputValidationError(message, issues) {
|
|
11753
|
-
return new InputValidationError(message, issues);
|
|
11754
|
-
}
|
|
11755
|
-
function isApiError(error) {
|
|
11756
|
-
if (!(error instanceof Error))
|
|
11757
|
-
return false;
|
|
11758
|
-
return "statusCode" in error && "response" in error;
|
|
11759
|
-
}
|
|
11760
|
-
function escapeValue(value) {
|
|
11761
|
-
if (value instanceof Date) {
|
|
11762
|
-
return value.toISOString();
|
|
11763
|
-
}
|
|
11764
|
-
if (typeof value === "boolean") {
|
|
11765
|
-
return value ? "true" : "false";
|
|
11766
|
-
}
|
|
11767
|
-
if (typeof value === "number") {
|
|
11768
|
-
return String(value);
|
|
11769
|
-
}
|
|
11770
|
-
return value.replaceAll("'", "''");
|
|
11771
|
-
}
|
|
11772
|
-
function formatValue2(value) {
|
|
11773
|
-
const escaped = escapeValue(value);
|
|
11774
|
-
const needsQuotes = typeof value === "string" || value instanceof Date;
|
|
11775
|
-
return needsQuotes ? `'${escaped}'` : escaped;
|
|
11776
|
-
}
|
|
11777
|
-
function fieldToConditions(field, condition) {
|
|
11778
|
-
if (typeof condition === "string" || typeof condition === "number" || typeof condition === "boolean" || condition instanceof Date) {
|
|
11779
|
-
return [`${field}=${formatValue2(condition)}`];
|
|
11780
|
-
}
|
|
11781
|
-
if (typeof condition === "object" && condition !== null) {
|
|
11782
|
-
const ops = condition;
|
|
11783
|
-
const conditions = [];
|
|
11784
|
-
if (ops.ne !== undefined) {
|
|
11785
|
-
conditions.push(`${field}!=${formatValue2(ops.ne)}`);
|
|
11786
|
-
}
|
|
11787
|
-
if (ops.gt !== undefined) {
|
|
11788
|
-
conditions.push(`${field}>${formatValue2(ops.gt)}`);
|
|
11789
|
-
}
|
|
11790
|
-
if (ops.gte !== undefined) {
|
|
11791
|
-
conditions.push(`${field}>=${formatValue2(ops.gte)}`);
|
|
11792
|
-
}
|
|
11793
|
-
if (ops.lt !== undefined) {
|
|
11794
|
-
conditions.push(`${field}<${formatValue2(ops.lt)}`);
|
|
11795
|
-
}
|
|
11796
|
-
if (ops.lte !== undefined) {
|
|
11797
|
-
conditions.push(`${field}<=${formatValue2(ops.lte)}`);
|
|
11798
|
-
}
|
|
11799
|
-
if (ops.contains !== undefined) {
|
|
11800
|
-
conditions.push(`${field}~${formatValue2(ops.contains)}`);
|
|
11801
|
-
}
|
|
11802
|
-
if (ops.in !== undefined && ops.in.length > 0) {
|
|
11803
|
-
const inConditions = ops.in.map((v) => `${field}=${formatValue2(v)}`);
|
|
11804
|
-
const joined = inConditions.join(" OR ");
|
|
11805
|
-
conditions.push(inConditions.length > 1 ? `(${joined})` : joined);
|
|
11806
|
-
}
|
|
11807
|
-
if (ops.notIn !== undefined && ops.notIn.length > 0) {
|
|
11808
|
-
const notInConditions = ops.notIn.map((v) => `${field}!=${formatValue2(v)}`);
|
|
11809
|
-
conditions.push(notInConditions.join(" AND "));
|
|
11810
|
-
}
|
|
11811
|
-
return conditions;
|
|
11812
|
-
}
|
|
11813
|
-
return [];
|
|
11814
|
-
}
|
|
11815
|
-
function isOrCondition(clause) {
|
|
11816
|
-
return "OR" in clause && Array.isArray(clause.OR);
|
|
11817
|
-
}
|
|
11818
|
-
function whereToFilter(where) {
|
|
11819
|
-
if (isOrCondition(where)) {
|
|
11820
|
-
const orParts = where.OR.map((clause) => whereToFilter(clause)).filter((s) => s !== undefined);
|
|
11821
|
-
return orParts.length > 0 ? orParts.join(" OR ") : undefined;
|
|
11822
|
-
}
|
|
11823
|
-
const conditions = [];
|
|
11824
|
-
for (const [field, condition] of Object.entries(where)) {
|
|
11825
|
-
if (condition !== undefined) {
|
|
11826
|
-
conditions.push(...fieldToConditions(field, condition));
|
|
11827
|
-
}
|
|
11828
|
-
}
|
|
11829
|
-
return conditions.length > 0 ? conditions.join(" AND ") : undefined;
|
|
11830
|
-
}
|
|
11831
11681
|
var PLATFORM_BEYOND_AI = "BEYOND_AI";
|
|
11832
11682
|
var PLATFORM_LEARNWITH_AI = "LEARNWITH_AI";
|
|
11833
11683
|
var DEFAULT_PLATFORM = PLATFORM_BEYOND_AI;
|
|
@@ -12049,9 +11899,9 @@ var LEVEL_PREFIX = {
|
|
|
12049
11899
|
error: "[ERROR]"
|
|
12050
11900
|
};
|
|
12051
11901
|
function formatContext2(context) {
|
|
12052
|
-
return Object.entries(context).map(([key, value]) => `${key}=${
|
|
11902
|
+
return Object.entries(context).map(([key, value]) => `${key}=${formatValue2(value)}`).join(" ");
|
|
12053
11903
|
}
|
|
12054
|
-
function
|
|
11904
|
+
function formatValue2(value) {
|
|
12055
11905
|
if (typeof value === "string")
|
|
12056
11906
|
return value;
|
|
12057
11907
|
if (typeof value === "number")
|
|
@@ -12368,11 +12218,11 @@ class TimebackProvider {
|
|
|
12368
12218
|
env;
|
|
12369
12219
|
auth;
|
|
12370
12220
|
timeout;
|
|
12371
|
-
|
|
12372
|
-
|
|
12373
|
-
|
|
12374
|
-
|
|
12375
|
-
|
|
12221
|
+
_endpoints;
|
|
12222
|
+
_authUrl;
|
|
12223
|
+
_tokenScope;
|
|
12224
|
+
_pathProfiles;
|
|
12225
|
+
_tokenManagers = new Map;
|
|
12376
12226
|
constructor(config) {
|
|
12377
12227
|
this.timeout = config.timeout ?? 30000;
|
|
12378
12228
|
if (isEnvConfig(config)) {
|
|
@@ -12385,89 +12235,89 @@ class TimebackProvider {
|
|
|
12385
12235
|
if (!platformEndpoints) {
|
|
12386
12236
|
throw new Error(`Unknown platform: ${platform}`);
|
|
12387
12237
|
}
|
|
12388
|
-
this.
|
|
12389
|
-
this.
|
|
12390
|
-
this.
|
|
12391
|
-
this.
|
|
12238
|
+
this._authUrl = platformEndpoints.token[env];
|
|
12239
|
+
this._tokenScope = platformEndpoints.tokenScope ?? undefined;
|
|
12240
|
+
this._pathProfiles = PLATFORM_PATHS[platform] ?? BEYONDAI_PATHS;
|
|
12241
|
+
this._endpoints = {
|
|
12392
12242
|
oneroster: {
|
|
12393
12243
|
baseUrl: platformEndpoints.api[env],
|
|
12394
|
-
authUrl: this.
|
|
12244
|
+
authUrl: this._authUrl
|
|
12395
12245
|
},
|
|
12396
12246
|
edubridge: {
|
|
12397
12247
|
baseUrl: platformEndpoints.api[env],
|
|
12398
|
-
authUrl: this.
|
|
12248
|
+
authUrl: this._authUrl
|
|
12399
12249
|
},
|
|
12400
12250
|
powerpath: {
|
|
12401
12251
|
baseUrl: platformEndpoints.api[env],
|
|
12402
|
-
authUrl: this.
|
|
12252
|
+
authUrl: this._authUrl
|
|
12403
12253
|
},
|
|
12404
12254
|
clr: {
|
|
12405
12255
|
baseUrl: platformEndpoints.api[env],
|
|
12406
|
-
authUrl: this.
|
|
12256
|
+
authUrl: this._authUrl
|
|
12407
12257
|
},
|
|
12408
12258
|
case: {
|
|
12409
12259
|
baseUrl: platformEndpoints.api[env],
|
|
12410
|
-
authUrl: this.
|
|
12260
|
+
authUrl: this._authUrl
|
|
12411
12261
|
},
|
|
12412
12262
|
caliper: {
|
|
12413
12263
|
baseUrl: platformEndpoints.caliper[env],
|
|
12414
|
-
authUrl: this.
|
|
12264
|
+
authUrl: this._authUrl
|
|
12415
12265
|
},
|
|
12416
12266
|
webhooks: {
|
|
12417
12267
|
baseUrl: platformEndpoints.caliper[env],
|
|
12418
|
-
authUrl: this.
|
|
12268
|
+
authUrl: this._authUrl
|
|
12419
12269
|
},
|
|
12420
12270
|
reporting: {
|
|
12421
12271
|
baseUrl: platformEndpoints.api[env],
|
|
12422
|
-
authUrl: this.
|
|
12272
|
+
authUrl: this._authUrl
|
|
12423
12273
|
},
|
|
12424
12274
|
qti: {
|
|
12425
12275
|
baseUrl: platformEndpoints.qti[env],
|
|
12426
|
-
authUrl: this.
|
|
12276
|
+
authUrl: this._authUrl
|
|
12427
12277
|
}
|
|
12428
12278
|
};
|
|
12429
12279
|
} else if (isExplicitConfig(config)) {
|
|
12430
12280
|
this.auth = config.auth;
|
|
12431
|
-
this.
|
|
12432
|
-
this.
|
|
12433
|
-
this.
|
|
12434
|
-
oneroster: { baseUrl: config.baseUrl, authUrl: this.
|
|
12435
|
-
edubridge: { baseUrl: config.baseUrl, authUrl: this.
|
|
12436
|
-
powerpath: { baseUrl: config.baseUrl, authUrl: this.
|
|
12437
|
-
clr: { baseUrl: config.baseUrl, authUrl: this.
|
|
12438
|
-
case: { baseUrl: config.baseUrl, authUrl: this.
|
|
12439
|
-
caliper: { baseUrl: config.baseUrl, authUrl: this.
|
|
12440
|
-
webhooks: { baseUrl: config.baseUrl, authUrl: this.
|
|
12441
|
-
reporting: { baseUrl: config.baseUrl, authUrl: this.
|
|
12442
|
-
qti: { baseUrl: config.baseUrl, authUrl: this.
|
|
12281
|
+
this._authUrl = config.authUrl;
|
|
12282
|
+
this._pathProfiles = resolvePathProfiles(config.pathProfile, config.paths);
|
|
12283
|
+
this._endpoints = {
|
|
12284
|
+
oneroster: { baseUrl: config.baseUrl, authUrl: this._authUrl },
|
|
12285
|
+
edubridge: { baseUrl: config.baseUrl, authUrl: this._authUrl },
|
|
12286
|
+
powerpath: { baseUrl: config.baseUrl, authUrl: this._authUrl },
|
|
12287
|
+
clr: { baseUrl: config.baseUrl, authUrl: this._authUrl },
|
|
12288
|
+
case: { baseUrl: config.baseUrl, authUrl: this._authUrl },
|
|
12289
|
+
caliper: { baseUrl: config.baseUrl, authUrl: this._authUrl },
|
|
12290
|
+
webhooks: { baseUrl: config.baseUrl, authUrl: this._authUrl },
|
|
12291
|
+
reporting: { baseUrl: config.baseUrl, authUrl: this._authUrl },
|
|
12292
|
+
qti: { baseUrl: config.baseUrl, authUrl: this._authUrl }
|
|
12443
12293
|
};
|
|
12444
12294
|
} else if (isServicesConfig(config)) {
|
|
12445
12295
|
this.auth = config.auth;
|
|
12446
|
-
this.
|
|
12447
|
-
this.
|
|
12448
|
-
this.
|
|
12296
|
+
this._authUrl = config.authUrl;
|
|
12297
|
+
this._pathProfiles = resolvePathProfiles(config.pathProfile, config.paths);
|
|
12298
|
+
this._endpoints = {};
|
|
12449
12299
|
for (const [service, baseUrl] of Object.entries(config.services)) {
|
|
12450
12300
|
if (baseUrl) {
|
|
12451
|
-
this.
|
|
12301
|
+
this._endpoints[service] = {
|
|
12452
12302
|
baseUrl,
|
|
12453
|
-
authUrl: this.
|
|
12303
|
+
authUrl: this._authUrl
|
|
12454
12304
|
};
|
|
12455
12305
|
}
|
|
12456
12306
|
}
|
|
12457
12307
|
} else {
|
|
12458
12308
|
throw new Error("Invalid provider configuration");
|
|
12459
12309
|
}
|
|
12460
|
-
for (const service of Object.keys(this.
|
|
12461
|
-
if (this.
|
|
12462
|
-
delete this.
|
|
12310
|
+
for (const service of Object.keys(this._pathProfiles)) {
|
|
12311
|
+
if (this._pathProfiles[service] === null) {
|
|
12312
|
+
delete this._endpoints[service];
|
|
12463
12313
|
}
|
|
12464
12314
|
}
|
|
12465
12315
|
}
|
|
12466
12316
|
getEndpoint(service) {
|
|
12467
|
-
const endpoint = this.
|
|
12317
|
+
const endpoint = this._endpoints[service];
|
|
12468
12318
|
if (!endpoint) {
|
|
12469
12319
|
const pathKey = service;
|
|
12470
|
-
if (pathKey in this.
|
|
12320
|
+
if (pathKey in this._pathProfiles && this._pathProfiles[pathKey] === null) {
|
|
12471
12321
|
throw new Error(`Service "${service}" is not supported on ${this.platform ?? "this"} platform.`);
|
|
12472
12322
|
}
|
|
12473
12323
|
throw new Error(`Service "${service}" is not configured in this provider`);
|
|
@@ -12475,13 +12325,13 @@ class TimebackProvider {
|
|
|
12475
12325
|
return endpoint;
|
|
12476
12326
|
}
|
|
12477
12327
|
hasService(service) {
|
|
12478
|
-
return service in this.
|
|
12328
|
+
return service in this._endpoints;
|
|
12479
12329
|
}
|
|
12480
12330
|
getAvailableServices() {
|
|
12481
|
-
return Object.keys(this.
|
|
12331
|
+
return Object.keys(this._endpoints);
|
|
12482
12332
|
}
|
|
12483
12333
|
getTokenUrl() {
|
|
12484
|
-
return this.
|
|
12334
|
+
return this._authUrl;
|
|
12485
12335
|
}
|
|
12486
12336
|
getEndpointWithPaths(service) {
|
|
12487
12337
|
const endpoint = this.getEndpoint(service);
|
|
@@ -12489,17 +12339,17 @@ class TimebackProvider {
|
|
|
12489
12339
|
return { ...endpoint, paths };
|
|
12490
12340
|
}
|
|
12491
12341
|
getPaths() {
|
|
12492
|
-
return this.
|
|
12342
|
+
return this._pathProfiles;
|
|
12493
12343
|
}
|
|
12494
12344
|
getServicePaths(service) {
|
|
12495
|
-
const paths = this.
|
|
12345
|
+
const paths = this._pathProfiles[service];
|
|
12496
12346
|
if (!paths) {
|
|
12497
12347
|
throw new Error(`Service "${service}" is not supported on ${this.platform ?? "this"} platform.`);
|
|
12498
12348
|
}
|
|
12499
12349
|
return paths;
|
|
12500
12350
|
}
|
|
12501
12351
|
hasServiceSupport(service) {
|
|
12502
|
-
return this.
|
|
12352
|
+
return this._pathProfiles[service] !== null;
|
|
12503
12353
|
}
|
|
12504
12354
|
getTokenProvider(service) {
|
|
12505
12355
|
const endpoint = this.getEndpoint(service);
|
|
@@ -12510,7 +12360,7 @@ class TimebackProvider {
|
|
|
12510
12360
|
if (!this.auth) {
|
|
12511
12361
|
throw new Error(`Service "${service}" requires authentication but no credentials were provided`);
|
|
12512
12362
|
}
|
|
12513
|
-
let manager = this.
|
|
12363
|
+
let manager = this._tokenManagers.get(authUrl);
|
|
12514
12364
|
if (!manager) {
|
|
12515
12365
|
manager = new TokenManager({
|
|
12516
12366
|
tokenUrl: authUrl,
|
|
@@ -12518,28 +12368,28 @@ class TimebackProvider {
|
|
|
12518
12368
|
clientId: this.auth.clientId,
|
|
12519
12369
|
clientSecret: this.auth.clientSecret
|
|
12520
12370
|
},
|
|
12521
|
-
scope: this.
|
|
12371
|
+
scope: this._tokenScope
|
|
12522
12372
|
});
|
|
12523
|
-
this.
|
|
12373
|
+
this._tokenManagers.set(authUrl, manager);
|
|
12524
12374
|
}
|
|
12525
12375
|
return manager;
|
|
12526
12376
|
}
|
|
12527
12377
|
async checkAuth() {
|
|
12528
|
-
if (!this.
|
|
12378
|
+
if (!this._authUrl || !this.auth) {
|
|
12529
12379
|
throw new Error("No auth configured on this provider");
|
|
12530
12380
|
}
|
|
12531
12381
|
const startTime = Date.now();
|
|
12532
|
-
let manager = this.
|
|
12382
|
+
let manager = this._tokenManagers.get(this._authUrl);
|
|
12533
12383
|
if (!manager) {
|
|
12534
12384
|
manager = new TokenManager({
|
|
12535
|
-
tokenUrl: this.
|
|
12385
|
+
tokenUrl: this._authUrl,
|
|
12536
12386
|
credentials: {
|
|
12537
12387
|
clientId: this.auth.clientId,
|
|
12538
12388
|
clientSecret: this.auth.clientSecret
|
|
12539
12389
|
},
|
|
12540
|
-
scope: this.
|
|
12390
|
+
scope: this._tokenScope
|
|
12541
12391
|
});
|
|
12542
|
-
this.
|
|
12392
|
+
this._tokenManagers.set(this._authUrl, manager);
|
|
12543
12393
|
}
|
|
12544
12394
|
try {
|
|
12545
12395
|
await manager.getToken();
|
|
@@ -12558,10 +12408,10 @@ class TimebackProvider {
|
|
|
12558
12408
|
}
|
|
12559
12409
|
}
|
|
12560
12410
|
invalidateTokens() {
|
|
12561
|
-
for (const manager of this.
|
|
12411
|
+
for (const manager of this._tokenManagers.values()) {
|
|
12562
12412
|
manager.invalidate?.();
|
|
12563
12413
|
}
|
|
12564
|
-
this.
|
|
12414
|
+
this._tokenManagers.clear();
|
|
12565
12415
|
}
|
|
12566
12416
|
}
|
|
12567
12417
|
function getEnv(key) {
|
|
@@ -12821,6 +12671,156 @@ function resolveToProvider(config, envVars, registry = DEFAULT_PROVIDER_REGISTRY
|
|
|
12821
12671
|
}
|
|
12822
12672
|
throw new Error(buildMissingEnvError(envVars));
|
|
12823
12673
|
}
|
|
12674
|
+
|
|
12675
|
+
class ApiError extends Error {
|
|
12676
|
+
statusCode;
|
|
12677
|
+
response;
|
|
12678
|
+
name = "ApiError";
|
|
12679
|
+
constructor(message, statusCode, response) {
|
|
12680
|
+
super(message);
|
|
12681
|
+
this.statusCode = statusCode;
|
|
12682
|
+
this.response = response;
|
|
12683
|
+
}
|
|
12684
|
+
get minorCodes() {
|
|
12685
|
+
const ims = this.response;
|
|
12686
|
+
if (!ims?.imsx_CodeMinor?.imsx_codeMinorField) {
|
|
12687
|
+
return [];
|
|
12688
|
+
}
|
|
12689
|
+
return ims.imsx_CodeMinor.imsx_codeMinorField.map((field) => ({
|
|
12690
|
+
field: field.imsx_codeMinorFieldName,
|
|
12691
|
+
value: field.imsx_codeMinorFieldValue
|
|
12692
|
+
}));
|
|
12693
|
+
}
|
|
12694
|
+
get details() {
|
|
12695
|
+
const ims = this.response;
|
|
12696
|
+
return ims?.imsx_error_details ?? [];
|
|
12697
|
+
}
|
|
12698
|
+
}
|
|
12699
|
+
|
|
12700
|
+
class UnauthorizedError extends ApiError {
|
|
12701
|
+
name = "UnauthorizedError";
|
|
12702
|
+
constructor(message = "Unauthorized", response) {
|
|
12703
|
+
super(message, 401, response);
|
|
12704
|
+
}
|
|
12705
|
+
}
|
|
12706
|
+
|
|
12707
|
+
class ForbiddenError extends ApiError {
|
|
12708
|
+
name = "ForbiddenError";
|
|
12709
|
+
constructor(message = "Forbidden", response) {
|
|
12710
|
+
super(message, 403, response);
|
|
12711
|
+
}
|
|
12712
|
+
}
|
|
12713
|
+
|
|
12714
|
+
class NotFoundError extends ApiError {
|
|
12715
|
+
name = "NotFoundError";
|
|
12716
|
+
constructor(message = "Not Found", response) {
|
|
12717
|
+
super(message, 404, response);
|
|
12718
|
+
}
|
|
12719
|
+
}
|
|
12720
|
+
|
|
12721
|
+
class ValidationError extends ApiError {
|
|
12722
|
+
name = "ValidationError";
|
|
12723
|
+
constructor(message = "Validation Error", response) {
|
|
12724
|
+
super(message, 422, response);
|
|
12725
|
+
}
|
|
12726
|
+
}
|
|
12727
|
+
|
|
12728
|
+
class InputValidationError extends ApiError {
|
|
12729
|
+
name = "InputValidationError";
|
|
12730
|
+
issues;
|
|
12731
|
+
constructor(message, issues) {
|
|
12732
|
+
const response = {
|
|
12733
|
+
imsx_codeMajor: "failure",
|
|
12734
|
+
imsx_severity: "error",
|
|
12735
|
+
imsx_description: message,
|
|
12736
|
+
imsx_error_details: issues.map((issue) => ({
|
|
12737
|
+
path: issue.path,
|
|
12738
|
+
message: issue.message
|
|
12739
|
+
}))
|
|
12740
|
+
};
|
|
12741
|
+
super(message, 400, response);
|
|
12742
|
+
this.issues = issues;
|
|
12743
|
+
}
|
|
12744
|
+
}
|
|
12745
|
+
function createInputValidationError(message, issues) {
|
|
12746
|
+
return new InputValidationError(message, issues);
|
|
12747
|
+
}
|
|
12748
|
+
function isApiError(error) {
|
|
12749
|
+
if (!(error instanceof Error))
|
|
12750
|
+
return false;
|
|
12751
|
+
return "statusCode" in error && "response" in error;
|
|
12752
|
+
}
|
|
12753
|
+
function escapeValue(value) {
|
|
12754
|
+
if (value instanceof Date) {
|
|
12755
|
+
return value.toISOString();
|
|
12756
|
+
}
|
|
12757
|
+
if (typeof value === "boolean") {
|
|
12758
|
+
return value ? "true" : "false";
|
|
12759
|
+
}
|
|
12760
|
+
if (typeof value === "number") {
|
|
12761
|
+
return String(value);
|
|
12762
|
+
}
|
|
12763
|
+
return value.replaceAll("'", "''");
|
|
12764
|
+
}
|
|
12765
|
+
function formatValue22(value) {
|
|
12766
|
+
const escaped = escapeValue(value);
|
|
12767
|
+
const needsQuotes = typeof value === "string" || value instanceof Date;
|
|
12768
|
+
return needsQuotes ? `'${escaped}'` : escaped;
|
|
12769
|
+
}
|
|
12770
|
+
function fieldToConditions(field, condition) {
|
|
12771
|
+
if (typeof condition === "string" || typeof condition === "number" || typeof condition === "boolean" || condition instanceof Date) {
|
|
12772
|
+
return [`${field}=${formatValue22(condition)}`];
|
|
12773
|
+
}
|
|
12774
|
+
if (typeof condition === "object" && condition !== null) {
|
|
12775
|
+
const ops = condition;
|
|
12776
|
+
const conditions = [];
|
|
12777
|
+
if (ops.ne !== undefined) {
|
|
12778
|
+
conditions.push(`${field}!=${formatValue22(ops.ne)}`);
|
|
12779
|
+
}
|
|
12780
|
+
if (ops.gt !== undefined) {
|
|
12781
|
+
conditions.push(`${field}>${formatValue22(ops.gt)}`);
|
|
12782
|
+
}
|
|
12783
|
+
if (ops.gte !== undefined) {
|
|
12784
|
+
conditions.push(`${field}>=${formatValue22(ops.gte)}`);
|
|
12785
|
+
}
|
|
12786
|
+
if (ops.lt !== undefined) {
|
|
12787
|
+
conditions.push(`${field}<${formatValue22(ops.lt)}`);
|
|
12788
|
+
}
|
|
12789
|
+
if (ops.lte !== undefined) {
|
|
12790
|
+
conditions.push(`${field}<=${formatValue22(ops.lte)}`);
|
|
12791
|
+
}
|
|
12792
|
+
if (ops.contains !== undefined) {
|
|
12793
|
+
conditions.push(`${field}~${formatValue22(ops.contains)}`);
|
|
12794
|
+
}
|
|
12795
|
+
if (ops.in !== undefined && ops.in.length > 0) {
|
|
12796
|
+
const inConditions = ops.in.map((v) => `${field}=${formatValue22(v)}`);
|
|
12797
|
+
const joined = inConditions.join(" OR ");
|
|
12798
|
+
conditions.push(inConditions.length > 1 ? `(${joined})` : joined);
|
|
12799
|
+
}
|
|
12800
|
+
if (ops.notIn !== undefined && ops.notIn.length > 0) {
|
|
12801
|
+
const notInConditions = ops.notIn.map((v) => `${field}!=${formatValue22(v)}`);
|
|
12802
|
+
conditions.push(notInConditions.join(" AND "));
|
|
12803
|
+
}
|
|
12804
|
+
return conditions;
|
|
12805
|
+
}
|
|
12806
|
+
return [];
|
|
12807
|
+
}
|
|
12808
|
+
function isOrCondition(clause) {
|
|
12809
|
+
return "OR" in clause && Array.isArray(clause.OR);
|
|
12810
|
+
}
|
|
12811
|
+
function whereToFilter(where) {
|
|
12812
|
+
if (isOrCondition(where)) {
|
|
12813
|
+
const orParts = where.OR.map((clause) => whereToFilter(clause)).filter((s) => s !== undefined);
|
|
12814
|
+
return orParts.length > 0 ? orParts.join(" OR ") : undefined;
|
|
12815
|
+
}
|
|
12816
|
+
const conditions = [];
|
|
12817
|
+
for (const [field, condition] of Object.entries(where)) {
|
|
12818
|
+
if (condition !== undefined) {
|
|
12819
|
+
conditions.push(...fieldToConditions(field, condition));
|
|
12820
|
+
}
|
|
12821
|
+
}
|
|
12822
|
+
return conditions.length > 0 ? conditions.join(" AND ") : undefined;
|
|
12823
|
+
}
|
|
12824
12824
|
var MAX_RETRIES = 3;
|
|
12825
12825
|
var RETRY_STATUS_CODES = [429, 503];
|
|
12826
12826
|
var INITIAL_RETRY_DELAY_MS = 1000;
|
|
@@ -26823,7 +26823,7 @@ function date4(params) {
|
|
|
26823
26823
|
|
|
26824
26824
|
// ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/external.js
|
|
26825
26825
|
config(en_default());
|
|
26826
|
-
// ../clients/core/dist/chunk-
|
|
26826
|
+
// ../clients/core/dist/chunk-2mkbbgd8.js
|
|
26827
26827
|
var log3 = createScopedLogger("edubridge");
|
|
26828
26828
|
function normalizeBoolean(value) {
|
|
26829
26829
|
if (typeof value === "boolean")
|
|
@@ -30282,6 +30282,18 @@ class ScoreScalesResource extends BaseResource {
|
|
|
30282
30282
|
}
|
|
30283
30283
|
}
|
|
30284
30284
|
}
|
|
30285
|
+
function normalizeResourceFromApi(resource) {
|
|
30286
|
+
if (!resource.metadata) {
|
|
30287
|
+
return resource;
|
|
30288
|
+
}
|
|
30289
|
+
return {
|
|
30290
|
+
...resource,
|
|
30291
|
+
metadata: {
|
|
30292
|
+
...resource.metadata,
|
|
30293
|
+
grades: parseGrades(resource.metadata.grades)
|
|
30294
|
+
}
|
|
30295
|
+
};
|
|
30296
|
+
}
|
|
30285
30297
|
|
|
30286
30298
|
class ScopedResourceResource {
|
|
30287
30299
|
transport;
|
|
@@ -30295,7 +30307,7 @@ class ScopedResourceResource {
|
|
|
30295
30307
|
}
|
|
30296
30308
|
async get() {
|
|
30297
30309
|
const response = await this.transport.request(this.basePath);
|
|
30298
|
-
return response.resource;
|
|
30310
|
+
return normalizeResourceFromApi(response.resource);
|
|
30299
30311
|
}
|
|
30300
30312
|
exists() {
|
|
30301
30313
|
return this.transport.exists(this.basePath);
|
|
@@ -30333,6 +30345,9 @@ class ResourcesResourceImpl extends BaseResource {
|
|
|
30333
30345
|
get updateSchema() {
|
|
30334
30346
|
return OneRosterResourceCreateInput.partial();
|
|
30335
30347
|
}
|
|
30348
|
+
transform(resource) {
|
|
30349
|
+
return normalizeResourceFromApi(resource);
|
|
30350
|
+
}
|
|
30336
30351
|
}
|
|
30337
30352
|
function createResourcesResource(transport) {
|
|
30338
30353
|
const impl = new ResourcesResourceImpl(transport);
|
|
@@ -30384,7 +30399,7 @@ class ScopedUserResource {
|
|
|
30384
30399
|
return this.streamResources(params).toArray();
|
|
30385
30400
|
}
|
|
30386
30401
|
streamResources(params) {
|
|
30387
|
-
return new Paginator3(this.transport, `${this.transport.paths.resources}/resources/users/${this.userId}/resources`, params, "resources");
|
|
30402
|
+
return new Paginator3(this.transport, `${this.transport.paths.resources}/resources/users/${this.userId}/resources`, params, "resources", normalizeResourceFromApi);
|
|
30388
30403
|
}
|
|
30389
30404
|
classes(params) {
|
|
30390
30405
|
return this.streamClasses(params).toArray();
|
|
@@ -30869,7 +30884,7 @@ class ScopedClassResource {
|
|
|
30869
30884
|
return this.streamResources(params).toArray();
|
|
30870
30885
|
}
|
|
30871
30886
|
streamResources(params) {
|
|
30872
|
-
return new Paginator3(this.transport, `${this.transport.paths.resources}/resources/classes/${this.classId}/resources`, params, "resources");
|
|
30887
|
+
return new Paginator3(this.transport, `${this.transport.paths.resources}/resources/classes/${this.classId}/resources`, params, "resources", normalizeResourceFromApi);
|
|
30873
30888
|
}
|
|
30874
30889
|
student(studentId) {
|
|
30875
30890
|
return new ScopedClassStudentResource(this.transport, this.classId, studentId);
|
|
@@ -30973,7 +30988,7 @@ class ScopedCourseResource {
|
|
|
30973
30988
|
return this.streamResources(params).toArray();
|
|
30974
30989
|
}
|
|
30975
30990
|
streamResources(params) {
|
|
30976
|
-
return new Paginator3(this.transport, `${this.transport.paths.resources}/resources/courses/${this.courseId}/resources`, params, "resources");
|
|
30991
|
+
return new Paginator3(this.transport, `${this.transport.paths.resources}/resources/courses/${this.courseId}/resources`, params, "resources", normalizeResourceFromApi);
|
|
30977
30992
|
}
|
|
30978
30993
|
}
|
|
30979
30994
|
|
|
@@ -38016,11 +38031,11 @@ class TimebackProvider2 {
|
|
|
38016
38031
|
env;
|
|
38017
38032
|
auth;
|
|
38018
38033
|
timeout;
|
|
38019
|
-
|
|
38020
|
-
|
|
38021
|
-
|
|
38022
|
-
|
|
38023
|
-
|
|
38034
|
+
_endpoints;
|
|
38035
|
+
_authUrl;
|
|
38036
|
+
_tokenScope;
|
|
38037
|
+
_pathProfiles;
|
|
38038
|
+
_tokenManagers = new Map;
|
|
38024
38039
|
constructor(config3) {
|
|
38025
38040
|
this.timeout = config3.timeout ?? 30000;
|
|
38026
38041
|
if (isEnvConfig2(config3)) {
|
|
@@ -38033,89 +38048,89 @@ class TimebackProvider2 {
|
|
|
38033
38048
|
if (!platformEndpoints) {
|
|
38034
38049
|
throw new Error(`Unknown platform: ${platform3}`);
|
|
38035
38050
|
}
|
|
38036
|
-
this.
|
|
38037
|
-
this.
|
|
38038
|
-
this.
|
|
38039
|
-
this.
|
|
38051
|
+
this._authUrl = platformEndpoints.token[env2];
|
|
38052
|
+
this._tokenScope = platformEndpoints.tokenScope ?? undefined;
|
|
38053
|
+
this._pathProfiles = PLATFORM_PATHS2[platform3] ?? BEYONDAI_PATHS2;
|
|
38054
|
+
this._endpoints = {
|
|
38040
38055
|
oneroster: {
|
|
38041
38056
|
baseUrl: platformEndpoints.api[env2],
|
|
38042
|
-
authUrl: this.
|
|
38057
|
+
authUrl: this._authUrl
|
|
38043
38058
|
},
|
|
38044
38059
|
edubridge: {
|
|
38045
38060
|
baseUrl: platformEndpoints.api[env2],
|
|
38046
|
-
authUrl: this.
|
|
38061
|
+
authUrl: this._authUrl
|
|
38047
38062
|
},
|
|
38048
38063
|
powerpath: {
|
|
38049
38064
|
baseUrl: platformEndpoints.api[env2],
|
|
38050
|
-
authUrl: this.
|
|
38065
|
+
authUrl: this._authUrl
|
|
38051
38066
|
},
|
|
38052
38067
|
clr: {
|
|
38053
38068
|
baseUrl: platformEndpoints.api[env2],
|
|
38054
|
-
authUrl: this.
|
|
38069
|
+
authUrl: this._authUrl
|
|
38055
38070
|
},
|
|
38056
38071
|
case: {
|
|
38057
38072
|
baseUrl: platformEndpoints.api[env2],
|
|
38058
|
-
authUrl: this.
|
|
38073
|
+
authUrl: this._authUrl
|
|
38059
38074
|
},
|
|
38060
38075
|
caliper: {
|
|
38061
38076
|
baseUrl: platformEndpoints.caliper[env2],
|
|
38062
|
-
authUrl: this.
|
|
38077
|
+
authUrl: this._authUrl
|
|
38063
38078
|
},
|
|
38064
38079
|
webhooks: {
|
|
38065
38080
|
baseUrl: platformEndpoints.caliper[env2],
|
|
38066
|
-
authUrl: this.
|
|
38081
|
+
authUrl: this._authUrl
|
|
38067
38082
|
},
|
|
38068
38083
|
reporting: {
|
|
38069
38084
|
baseUrl: platformEndpoints.api[env2],
|
|
38070
|
-
authUrl: this.
|
|
38085
|
+
authUrl: this._authUrl
|
|
38071
38086
|
},
|
|
38072
38087
|
qti: {
|
|
38073
38088
|
baseUrl: platformEndpoints.qti[env2],
|
|
38074
|
-
authUrl: this.
|
|
38089
|
+
authUrl: this._authUrl
|
|
38075
38090
|
}
|
|
38076
38091
|
};
|
|
38077
38092
|
} else if (isExplicitConfig2(config3)) {
|
|
38078
38093
|
this.auth = config3.auth;
|
|
38079
|
-
this.
|
|
38080
|
-
this.
|
|
38081
|
-
this.
|
|
38082
|
-
oneroster: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38083
|
-
edubridge: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38084
|
-
powerpath: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38085
|
-
clr: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38086
|
-
case: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38087
|
-
caliper: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38088
|
-
webhooks: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38089
|
-
reporting: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38090
|
-
qti: { baseUrl: config3.baseUrl, authUrl: this.
|
|
38094
|
+
this._authUrl = config3.authUrl;
|
|
38095
|
+
this._pathProfiles = resolvePathProfiles2(config3.pathProfile, config3.paths);
|
|
38096
|
+
this._endpoints = {
|
|
38097
|
+
oneroster: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
38098
|
+
edubridge: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
38099
|
+
powerpath: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
38100
|
+
clr: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
38101
|
+
case: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
38102
|
+
caliper: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
38103
|
+
webhooks: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
38104
|
+
reporting: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
38105
|
+
qti: { baseUrl: config3.baseUrl, authUrl: this._authUrl }
|
|
38091
38106
|
};
|
|
38092
38107
|
} else if (isServicesConfig2(config3)) {
|
|
38093
38108
|
this.auth = config3.auth;
|
|
38094
|
-
this.
|
|
38095
|
-
this.
|
|
38096
|
-
this.
|
|
38109
|
+
this._authUrl = config3.authUrl;
|
|
38110
|
+
this._pathProfiles = resolvePathProfiles2(config3.pathProfile, config3.paths);
|
|
38111
|
+
this._endpoints = {};
|
|
38097
38112
|
for (const [service, baseUrl] of Object.entries(config3.services)) {
|
|
38098
38113
|
if (baseUrl) {
|
|
38099
|
-
this.
|
|
38114
|
+
this._endpoints[service] = {
|
|
38100
38115
|
baseUrl,
|
|
38101
|
-
authUrl: this.
|
|
38116
|
+
authUrl: this._authUrl
|
|
38102
38117
|
};
|
|
38103
38118
|
}
|
|
38104
38119
|
}
|
|
38105
38120
|
} else {
|
|
38106
38121
|
throw new Error("Invalid provider configuration");
|
|
38107
38122
|
}
|
|
38108
|
-
for (const service of Object.keys(this.
|
|
38109
|
-
if (this.
|
|
38110
|
-
delete this.
|
|
38123
|
+
for (const service of Object.keys(this._pathProfiles)) {
|
|
38124
|
+
if (this._pathProfiles[service] === null) {
|
|
38125
|
+
delete this._endpoints[service];
|
|
38111
38126
|
}
|
|
38112
38127
|
}
|
|
38113
38128
|
}
|
|
38114
38129
|
getEndpoint(service) {
|
|
38115
|
-
const endpoint = this.
|
|
38130
|
+
const endpoint = this._endpoints[service];
|
|
38116
38131
|
if (!endpoint) {
|
|
38117
38132
|
const pathKey = service;
|
|
38118
|
-
if (pathKey in this.
|
|
38133
|
+
if (pathKey in this._pathProfiles && this._pathProfiles[pathKey] === null) {
|
|
38119
38134
|
throw new Error(`Service "${service}" is not supported on ${this.platform ?? "this"} platform.`);
|
|
38120
38135
|
}
|
|
38121
38136
|
throw new Error(`Service "${service}" is not configured in this provider`);
|
|
@@ -38123,13 +38138,13 @@ class TimebackProvider2 {
|
|
|
38123
38138
|
return endpoint;
|
|
38124
38139
|
}
|
|
38125
38140
|
hasService(service) {
|
|
38126
|
-
return service in this.
|
|
38141
|
+
return service in this._endpoints;
|
|
38127
38142
|
}
|
|
38128
38143
|
getAvailableServices() {
|
|
38129
|
-
return Object.keys(this.
|
|
38144
|
+
return Object.keys(this._endpoints);
|
|
38130
38145
|
}
|
|
38131
38146
|
getTokenUrl() {
|
|
38132
|
-
return this.
|
|
38147
|
+
return this._authUrl;
|
|
38133
38148
|
}
|
|
38134
38149
|
getEndpointWithPaths(service) {
|
|
38135
38150
|
const endpoint = this.getEndpoint(service);
|
|
@@ -38137,17 +38152,17 @@ class TimebackProvider2 {
|
|
|
38137
38152
|
return { ...endpoint, paths };
|
|
38138
38153
|
}
|
|
38139
38154
|
getPaths() {
|
|
38140
|
-
return this.
|
|
38155
|
+
return this._pathProfiles;
|
|
38141
38156
|
}
|
|
38142
38157
|
getServicePaths(service) {
|
|
38143
|
-
const paths = this.
|
|
38158
|
+
const paths = this._pathProfiles[service];
|
|
38144
38159
|
if (!paths) {
|
|
38145
38160
|
throw new Error(`Service "${service}" is not supported on ${this.platform ?? "this"} platform.`);
|
|
38146
38161
|
}
|
|
38147
38162
|
return paths;
|
|
38148
38163
|
}
|
|
38149
38164
|
hasServiceSupport(service) {
|
|
38150
|
-
return this.
|
|
38165
|
+
return this._pathProfiles[service] !== null;
|
|
38151
38166
|
}
|
|
38152
38167
|
getTokenProvider(service) {
|
|
38153
38168
|
const endpoint = this.getEndpoint(service);
|
|
@@ -38158,7 +38173,7 @@ class TimebackProvider2 {
|
|
|
38158
38173
|
if (!this.auth) {
|
|
38159
38174
|
throw new Error(`Service "${service}" requires authentication but no credentials were provided`);
|
|
38160
38175
|
}
|
|
38161
|
-
let manager = this.
|
|
38176
|
+
let manager = this._tokenManagers.get(authUrl);
|
|
38162
38177
|
if (!manager) {
|
|
38163
38178
|
manager = new TokenManager2({
|
|
38164
38179
|
tokenUrl: authUrl,
|
|
@@ -38166,28 +38181,28 @@ class TimebackProvider2 {
|
|
|
38166
38181
|
clientId: this.auth.clientId,
|
|
38167
38182
|
clientSecret: this.auth.clientSecret
|
|
38168
38183
|
},
|
|
38169
|
-
scope: this.
|
|
38184
|
+
scope: this._tokenScope
|
|
38170
38185
|
});
|
|
38171
|
-
this.
|
|
38186
|
+
this._tokenManagers.set(authUrl, manager);
|
|
38172
38187
|
}
|
|
38173
38188
|
return manager;
|
|
38174
38189
|
}
|
|
38175
38190
|
async checkAuth() {
|
|
38176
|
-
if (!this.
|
|
38191
|
+
if (!this._authUrl || !this.auth) {
|
|
38177
38192
|
throw new Error("No auth configured on this provider");
|
|
38178
38193
|
}
|
|
38179
38194
|
const startTime = Date.now();
|
|
38180
|
-
let manager = this.
|
|
38195
|
+
let manager = this._tokenManagers.get(this._authUrl);
|
|
38181
38196
|
if (!manager) {
|
|
38182
38197
|
manager = new TokenManager2({
|
|
38183
|
-
tokenUrl: this.
|
|
38198
|
+
tokenUrl: this._authUrl,
|
|
38184
38199
|
credentials: {
|
|
38185
38200
|
clientId: this.auth.clientId,
|
|
38186
38201
|
clientSecret: this.auth.clientSecret
|
|
38187
38202
|
},
|
|
38188
|
-
scope: this.
|
|
38203
|
+
scope: this._tokenScope
|
|
38189
38204
|
});
|
|
38190
|
-
this.
|
|
38205
|
+
this._tokenManagers.set(this._authUrl, manager);
|
|
38191
38206
|
}
|
|
38192
38207
|
try {
|
|
38193
38208
|
await manager.getToken();
|
|
@@ -38206,10 +38221,10 @@ class TimebackProvider2 {
|
|
|
38206
38221
|
}
|
|
38207
38222
|
}
|
|
38208
38223
|
invalidateTokens() {
|
|
38209
|
-
for (const manager of this.
|
|
38224
|
+
for (const manager of this._tokenManagers.values()) {
|
|
38210
38225
|
manager.invalidate?.();
|
|
38211
38226
|
}
|
|
38212
|
-
this.
|
|
38227
|
+
this._tokenManagers.clear();
|
|
38213
38228
|
}
|
|
38214
38229
|
}
|
|
38215
38230
|
// ../internal/client-infra/src/errors/errors.ts
|
|
@@ -38993,7 +39008,7 @@ async function runImportFlow(opts = {}) {
|
|
|
38993
39008
|
configPath
|
|
38994
39009
|
};
|
|
38995
39010
|
}
|
|
38996
|
-
// ../clients/masterytrack/dist/chunk-
|
|
39011
|
+
// ../clients/masterytrack/dist/chunk-740nbf3x.js
|
|
38997
39012
|
init_chunk_6jf1natv();
|
|
38998
39013
|
|
|
38999
39014
|
class ApiError3 extends Error {
|
|
@@ -39613,11 +39628,11 @@ class TimebackProvider3 {
|
|
|
39613
39628
|
env;
|
|
39614
39629
|
auth;
|
|
39615
39630
|
timeout;
|
|
39616
|
-
|
|
39617
|
-
|
|
39618
|
-
|
|
39619
|
-
|
|
39620
|
-
|
|
39631
|
+
_endpoints;
|
|
39632
|
+
_authUrl;
|
|
39633
|
+
_tokenScope;
|
|
39634
|
+
_pathProfiles;
|
|
39635
|
+
_tokenManagers = new Map;
|
|
39621
39636
|
constructor(config3) {
|
|
39622
39637
|
this.timeout = config3.timeout ?? 30000;
|
|
39623
39638
|
if (isEnvConfig3(config3)) {
|
|
@@ -39630,89 +39645,89 @@ class TimebackProvider3 {
|
|
|
39630
39645
|
if (!platformEndpoints) {
|
|
39631
39646
|
throw new Error(`Unknown platform: ${platform3}`);
|
|
39632
39647
|
}
|
|
39633
|
-
this.
|
|
39634
|
-
this.
|
|
39635
|
-
this.
|
|
39636
|
-
this.
|
|
39648
|
+
this._authUrl = platformEndpoints.token[env2];
|
|
39649
|
+
this._tokenScope = platformEndpoints.tokenScope ?? undefined;
|
|
39650
|
+
this._pathProfiles = PLATFORM_PATHS3[platform3] ?? BEYONDAI_PATHS3;
|
|
39651
|
+
this._endpoints = {
|
|
39637
39652
|
oneroster: {
|
|
39638
39653
|
baseUrl: platformEndpoints.api[env2],
|
|
39639
|
-
authUrl: this.
|
|
39654
|
+
authUrl: this._authUrl
|
|
39640
39655
|
},
|
|
39641
39656
|
edubridge: {
|
|
39642
39657
|
baseUrl: platformEndpoints.api[env2],
|
|
39643
|
-
authUrl: this.
|
|
39658
|
+
authUrl: this._authUrl
|
|
39644
39659
|
},
|
|
39645
39660
|
powerpath: {
|
|
39646
39661
|
baseUrl: platformEndpoints.api[env2],
|
|
39647
|
-
authUrl: this.
|
|
39662
|
+
authUrl: this._authUrl
|
|
39648
39663
|
},
|
|
39649
39664
|
clr: {
|
|
39650
39665
|
baseUrl: platformEndpoints.api[env2],
|
|
39651
|
-
authUrl: this.
|
|
39666
|
+
authUrl: this._authUrl
|
|
39652
39667
|
},
|
|
39653
39668
|
case: {
|
|
39654
39669
|
baseUrl: platformEndpoints.api[env2],
|
|
39655
|
-
authUrl: this.
|
|
39670
|
+
authUrl: this._authUrl
|
|
39656
39671
|
},
|
|
39657
39672
|
caliper: {
|
|
39658
39673
|
baseUrl: platformEndpoints.caliper[env2],
|
|
39659
|
-
authUrl: this.
|
|
39674
|
+
authUrl: this._authUrl
|
|
39660
39675
|
},
|
|
39661
39676
|
webhooks: {
|
|
39662
39677
|
baseUrl: platformEndpoints.caliper[env2],
|
|
39663
|
-
authUrl: this.
|
|
39678
|
+
authUrl: this._authUrl
|
|
39664
39679
|
},
|
|
39665
39680
|
reporting: {
|
|
39666
39681
|
baseUrl: platformEndpoints.api[env2],
|
|
39667
|
-
authUrl: this.
|
|
39682
|
+
authUrl: this._authUrl
|
|
39668
39683
|
},
|
|
39669
39684
|
qti: {
|
|
39670
39685
|
baseUrl: platformEndpoints.qti[env2],
|
|
39671
|
-
authUrl: this.
|
|
39686
|
+
authUrl: this._authUrl
|
|
39672
39687
|
}
|
|
39673
39688
|
};
|
|
39674
39689
|
} else if (isExplicitConfig3(config3)) {
|
|
39675
39690
|
this.auth = config3.auth;
|
|
39676
|
-
this.
|
|
39677
|
-
this.
|
|
39678
|
-
this.
|
|
39679
|
-
oneroster: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39680
|
-
edubridge: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39681
|
-
powerpath: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39682
|
-
clr: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39683
|
-
case: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39684
|
-
caliper: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39685
|
-
webhooks: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39686
|
-
reporting: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39687
|
-
qti: { baseUrl: config3.baseUrl, authUrl: this.
|
|
39691
|
+
this._authUrl = config3.authUrl;
|
|
39692
|
+
this._pathProfiles = resolvePathProfiles3(config3.pathProfile, config3.paths);
|
|
39693
|
+
this._endpoints = {
|
|
39694
|
+
oneroster: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
39695
|
+
edubridge: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
39696
|
+
powerpath: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
39697
|
+
clr: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
39698
|
+
case: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
39699
|
+
caliper: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
39700
|
+
webhooks: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
39701
|
+
reporting: { baseUrl: config3.baseUrl, authUrl: this._authUrl },
|
|
39702
|
+
qti: { baseUrl: config3.baseUrl, authUrl: this._authUrl }
|
|
39688
39703
|
};
|
|
39689
39704
|
} else if (isServicesConfig3(config3)) {
|
|
39690
39705
|
this.auth = config3.auth;
|
|
39691
|
-
this.
|
|
39692
|
-
this.
|
|
39693
|
-
this.
|
|
39706
|
+
this._authUrl = config3.authUrl;
|
|
39707
|
+
this._pathProfiles = resolvePathProfiles3(config3.pathProfile, config3.paths);
|
|
39708
|
+
this._endpoints = {};
|
|
39694
39709
|
for (const [service, baseUrl] of Object.entries(config3.services)) {
|
|
39695
39710
|
if (baseUrl) {
|
|
39696
|
-
this.
|
|
39711
|
+
this._endpoints[service] = {
|
|
39697
39712
|
baseUrl,
|
|
39698
|
-
authUrl: this.
|
|
39713
|
+
authUrl: this._authUrl
|
|
39699
39714
|
};
|
|
39700
39715
|
}
|
|
39701
39716
|
}
|
|
39702
39717
|
} else {
|
|
39703
39718
|
throw new Error("Invalid provider configuration");
|
|
39704
39719
|
}
|
|
39705
|
-
for (const service of Object.keys(this.
|
|
39706
|
-
if (this.
|
|
39707
|
-
delete this.
|
|
39720
|
+
for (const service of Object.keys(this._pathProfiles)) {
|
|
39721
|
+
if (this._pathProfiles[service] === null) {
|
|
39722
|
+
delete this._endpoints[service];
|
|
39708
39723
|
}
|
|
39709
39724
|
}
|
|
39710
39725
|
}
|
|
39711
39726
|
getEndpoint(service) {
|
|
39712
|
-
const endpoint = this.
|
|
39727
|
+
const endpoint = this._endpoints[service];
|
|
39713
39728
|
if (!endpoint) {
|
|
39714
39729
|
const pathKey = service;
|
|
39715
|
-
if (pathKey in this.
|
|
39730
|
+
if (pathKey in this._pathProfiles && this._pathProfiles[pathKey] === null) {
|
|
39716
39731
|
throw new Error(`Service "${service}" is not supported on ${this.platform ?? "this"} platform.`);
|
|
39717
39732
|
}
|
|
39718
39733
|
throw new Error(`Service "${service}" is not configured in this provider`);
|
|
@@ -39720,13 +39735,13 @@ class TimebackProvider3 {
|
|
|
39720
39735
|
return endpoint;
|
|
39721
39736
|
}
|
|
39722
39737
|
hasService(service) {
|
|
39723
|
-
return service in this.
|
|
39738
|
+
return service in this._endpoints;
|
|
39724
39739
|
}
|
|
39725
39740
|
getAvailableServices() {
|
|
39726
|
-
return Object.keys(this.
|
|
39741
|
+
return Object.keys(this._endpoints);
|
|
39727
39742
|
}
|
|
39728
39743
|
getTokenUrl() {
|
|
39729
|
-
return this.
|
|
39744
|
+
return this._authUrl;
|
|
39730
39745
|
}
|
|
39731
39746
|
getEndpointWithPaths(service) {
|
|
39732
39747
|
const endpoint = this.getEndpoint(service);
|
|
@@ -39734,17 +39749,17 @@ class TimebackProvider3 {
|
|
|
39734
39749
|
return { ...endpoint, paths };
|
|
39735
39750
|
}
|
|
39736
39751
|
getPaths() {
|
|
39737
|
-
return this.
|
|
39752
|
+
return this._pathProfiles;
|
|
39738
39753
|
}
|
|
39739
39754
|
getServicePaths(service) {
|
|
39740
|
-
const paths = this.
|
|
39755
|
+
const paths = this._pathProfiles[service];
|
|
39741
39756
|
if (!paths) {
|
|
39742
39757
|
throw new Error(`Service "${service}" is not supported on ${this.platform ?? "this"} platform.`);
|
|
39743
39758
|
}
|
|
39744
39759
|
return paths;
|
|
39745
39760
|
}
|
|
39746
39761
|
hasServiceSupport(service) {
|
|
39747
|
-
return this.
|
|
39762
|
+
return this._pathProfiles[service] !== null;
|
|
39748
39763
|
}
|
|
39749
39764
|
getTokenProvider(service) {
|
|
39750
39765
|
const endpoint = this.getEndpoint(service);
|
|
@@ -39755,7 +39770,7 @@ class TimebackProvider3 {
|
|
|
39755
39770
|
if (!this.auth) {
|
|
39756
39771
|
throw new Error(`Service "${service}" requires authentication but no credentials were provided`);
|
|
39757
39772
|
}
|
|
39758
|
-
let manager = this.
|
|
39773
|
+
let manager = this._tokenManagers.get(authUrl);
|
|
39759
39774
|
if (!manager) {
|
|
39760
39775
|
manager = new TokenManager3({
|
|
39761
39776
|
tokenUrl: authUrl,
|
|
@@ -39763,28 +39778,28 @@ class TimebackProvider3 {
|
|
|
39763
39778
|
clientId: this.auth.clientId,
|
|
39764
39779
|
clientSecret: this.auth.clientSecret
|
|
39765
39780
|
},
|
|
39766
|
-
scope: this.
|
|
39781
|
+
scope: this._tokenScope
|
|
39767
39782
|
});
|
|
39768
|
-
this.
|
|
39783
|
+
this._tokenManagers.set(authUrl, manager);
|
|
39769
39784
|
}
|
|
39770
39785
|
return manager;
|
|
39771
39786
|
}
|
|
39772
39787
|
async checkAuth() {
|
|
39773
|
-
if (!this.
|
|
39788
|
+
if (!this._authUrl || !this.auth) {
|
|
39774
39789
|
throw new Error("No auth configured on this provider");
|
|
39775
39790
|
}
|
|
39776
39791
|
const startTime = Date.now();
|
|
39777
|
-
let manager = this.
|
|
39792
|
+
let manager = this._tokenManagers.get(this._authUrl);
|
|
39778
39793
|
if (!manager) {
|
|
39779
39794
|
manager = new TokenManager3({
|
|
39780
|
-
tokenUrl: this.
|
|
39795
|
+
tokenUrl: this._authUrl,
|
|
39781
39796
|
credentials: {
|
|
39782
39797
|
clientId: this.auth.clientId,
|
|
39783
39798
|
clientSecret: this.auth.clientSecret
|
|
39784
39799
|
},
|
|
39785
|
-
scope: this.
|
|
39800
|
+
scope: this._tokenScope
|
|
39786
39801
|
});
|
|
39787
|
-
this.
|
|
39802
|
+
this._tokenManagers.set(this._authUrl, manager);
|
|
39788
39803
|
}
|
|
39789
39804
|
try {
|
|
39790
39805
|
await manager.getToken();
|
|
@@ -39803,10 +39818,10 @@ class TimebackProvider3 {
|
|
|
39803
39818
|
}
|
|
39804
39819
|
}
|
|
39805
39820
|
invalidateTokens() {
|
|
39806
|
-
for (const manager of this.
|
|
39821
|
+
for (const manager of this._tokenManagers.values()) {
|
|
39807
39822
|
manager.invalidate?.();
|
|
39808
39823
|
}
|
|
39809
|
-
this.
|
|
39824
|
+
this._tokenManagers.clear();
|
|
39810
39825
|
}
|
|
39811
39826
|
}
|
|
39812
39827
|
function getEnv3(key) {
|