@timeback/oneroster 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.js +95 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14781 -74
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/pagination.d.ts +3 -0
- package/dist/lib/pagination.d.ts.map +1 -1
- package/dist/lib/validation.d.ts +21 -0
- package/dist/lib/validation.d.ts.map +1 -0
- package/dist/resources/assessment/line-items.d.ts.map +1 -1
- package/dist/resources/assessment/results.d.ts +1 -0
- package/dist/resources/assessment/results.d.ts.map +1 -1
- package/dist/resources/base.d.ts +83 -7
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/gradebook/categories.d.ts +4 -1
- package/dist/resources/gradebook/categories.d.ts.map +1 -1
- package/dist/resources/gradebook/line-items.d.ts.map +1 -1
- package/dist/resources/gradebook/results.d.ts +7 -3
- package/dist/resources/gradebook/results.d.ts.map +1 -1
- package/dist/resources/gradebook/score-scales.d.ts +3 -0
- package/dist/resources/gradebook/score-scales.d.ts.map +1 -1
- package/dist/resources/resources/resources.d.ts.map +1 -1
- package/dist/resources/rostering/academic-sessions.d.ts +8 -1
- package/dist/resources/rostering/academic-sessions.d.ts.map +1 -1
- package/dist/resources/rostering/classes.d.ts +3 -1
- package/dist/resources/rostering/classes.d.ts.map +1 -1
- package/dist/resources/rostering/courses.d.ts +1 -1
- package/dist/resources/rostering/courses.d.ts.map +1 -1
- package/dist/resources/rostering/demographics.d.ts +5 -1
- package/dist/resources/rostering/demographics.d.ts.map +1 -1
- package/dist/resources/rostering/enrollments.d.ts +5 -1
- package/dist/resources/rostering/enrollments.d.ts.map +1 -1
- package/dist/resources/rostering/orgs.d.ts +5 -1
- package/dist/resources/rostering/orgs.d.ts.map +1 -1
- package/dist/resources/rostering/schools.d.ts +2 -1
- package/dist/resources/rostering/schools.d.ts.map +1 -1
- package/dist/resources/rostering/users.d.ts +6 -1
- package/dist/resources/rostering/users.d.ts.map +1 -1
- package/dist/types/callable.d.ts +14 -6
- package/dist/types/callable.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -10
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/streamable.d.ts +36 -0
- package/dist/types/streamable.d.ts.map +1 -0
- package/package.json +3 -2
- package/dist/types/base.d.ts +0 -127
- package/dist/types/base.d.ts.map +0 -1
- package/dist/types/filters.d.ts +0 -165
- package/dist/types/filters.d.ts.map +0 -1
- package/dist/types/gradebook.d.ts +0 -262
- package/dist/types/gradebook.d.ts.map +0 -1
- package/dist/types/resources.d.ts +0 -191
- package/dist/types/resources.d.ts.map +0 -1
- package/dist/types/rostering.d.ts +0 -732
- package/dist/types/rostering.d.ts.map +0 -1
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
|
|
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;
|
|
@@ -971,6 +983,27 @@ class ValidationError extends ApiError {
|
|
|
971
983
|
super(message, 422, response);
|
|
972
984
|
}
|
|
973
985
|
}
|
|
986
|
+
|
|
987
|
+
class InputValidationError extends ApiError {
|
|
988
|
+
name = "InputValidationError";
|
|
989
|
+
issues;
|
|
990
|
+
constructor(message, issues) {
|
|
991
|
+
const response = {
|
|
992
|
+
imsx_codeMajor: "failure",
|
|
993
|
+
imsx_severity: "error",
|
|
994
|
+
imsx_description: message,
|
|
995
|
+
imsx_error_details: issues.map((issue) => ({
|
|
996
|
+
path: issue.path,
|
|
997
|
+
message: issue.message
|
|
998
|
+
}))
|
|
999
|
+
};
|
|
1000
|
+
super(message, 400, response);
|
|
1001
|
+
this.issues = issues;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
function createInputValidationError(message, issues) {
|
|
1005
|
+
return new InputValidationError(message, issues);
|
|
1006
|
+
}
|
|
974
1007
|
// ../../internal/client-infra/src/transport/constants.ts
|
|
975
1008
|
var MAX_RETRIES = 3;
|
|
976
1009
|
var RETRY_STATUS_CODES = [429, 503];
|
|
@@ -996,8 +1029,9 @@ class BaseTransport {
|
|
|
996
1029
|
fetch: fetchFn
|
|
997
1030
|
});
|
|
998
1031
|
}
|
|
1032
|
+
const normalizedBaseUrl = config.baseUrl.endsWith("/") ? config.baseUrl : `${config.baseUrl}/`;
|
|
999
1033
|
this.config = {
|
|
1000
|
-
baseUrl:
|
|
1034
|
+
baseUrl: normalizedBaseUrl,
|
|
1001
1035
|
timeout: config.timeout ?? 30000,
|
|
1002
1036
|
fetch: fetchFn,
|
|
1003
1037
|
tokenProvider
|
|
@@ -1083,7 +1117,8 @@ class BaseTransport {
|
|
|
1083
1117
|
if (/^[a-z][a-z0-9+.-]*:/i.test(path)) {
|
|
1084
1118
|
throw new Error(`Absolute URLs are not allowed in path: ${path}. Use relative paths only.`);
|
|
1085
1119
|
}
|
|
1086
|
-
const
|
|
1120
|
+
const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
1121
|
+
const url = new URL(normalizedPath, this.config.baseUrl);
|
|
1087
1122
|
if (params) {
|
|
1088
1123
|
for (const [key, value] of Object.entries(params)) {
|
|
1089
1124
|
if (value !== undefined) {
|
|
@@ -1283,6 +1318,7 @@ class Paginator {
|
|
|
1283
1318
|
unwrapKey;
|
|
1284
1319
|
log;
|
|
1285
1320
|
transform;
|
|
1321
|
+
paginationStyle;
|
|
1286
1322
|
constructor(options) {
|
|
1287
1323
|
this.fetcher = options.fetcher;
|
|
1288
1324
|
this.path = options.path;
|
|
@@ -1291,16 +1327,21 @@ class Paginator {
|
|
|
1291
1327
|
this.unwrapKey = options.unwrapKey;
|
|
1292
1328
|
this.log = options.logger?.child("pagination") ?? createScopedLogger("pagination");
|
|
1293
1329
|
this.transform = options.transform;
|
|
1330
|
+
this.paginationStyle = options.paginationStyle ?? "offset";
|
|
1294
1331
|
}
|
|
1295
1332
|
buildRequestParams(limit, offset) {
|
|
1296
|
-
const { where, fields, ...rest } = this.params;
|
|
1297
|
-
|
|
1333
|
+
const { where, fields, offset: _, limit: __, ...rest } = this.params;
|
|
1334
|
+
const baseParams = {
|
|
1298
1335
|
...rest,
|
|
1299
1336
|
filter: where ? whereToFilter(where) : undefined,
|
|
1300
1337
|
fields: fields?.join(","),
|
|
1301
|
-
limit
|
|
1302
|
-
offset
|
|
1338
|
+
limit
|
|
1303
1339
|
};
|
|
1340
|
+
if (this.paginationStyle === "page") {
|
|
1341
|
+
const page = Math.floor(offset / limit) + 1;
|
|
1342
|
+
return { ...baseParams, page };
|
|
1343
|
+
}
|
|
1344
|
+
return { ...baseParams, offset };
|
|
1304
1345
|
}
|
|
1305
1346
|
extractItems(data, pageNumber) {
|
|
1306
1347
|
let items;
|
|
@@ -1405,6 +1446,52 @@ function parseHeaderPagination(response, data) {
|
|
|
1405
1446
|
total
|
|
1406
1447
|
};
|
|
1407
1448
|
}
|
|
1449
|
+
// ../../internal/client-infra/src/validation/index.ts
|
|
1450
|
+
function issue(path, message) {
|
|
1451
|
+
return { path, message };
|
|
1452
|
+
}
|
|
1453
|
+
function validateWithSchema(schema, data, context) {
|
|
1454
|
+
const result = schema.safeParse(data);
|
|
1455
|
+
if (result.success) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const issues = result.error.issues.map((errorIssue) => ({
|
|
1459
|
+
path: errorIssue.path.join(".") || "(root)",
|
|
1460
|
+
message: errorIssue.message
|
|
1461
|
+
}));
|
|
1462
|
+
throw createInputValidationError(`Invalid ${context} data`, issues);
|
|
1463
|
+
}
|
|
1464
|
+
function validateOffsetListParams(params) {
|
|
1465
|
+
if (!params) {
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
const issues = [];
|
|
1469
|
+
if (params.limit !== undefined) {
|
|
1470
|
+
if (!Number.isInteger(params.limit) || params.limit <= 0) {
|
|
1471
|
+
issues.push(issue("limit", "Must be a positive integer"));
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
if (params.offset !== undefined) {
|
|
1475
|
+
if (!Number.isInteger(params.offset) || params.offset < 0) {
|
|
1476
|
+
issues.push(issue("offset", "Must be a non-negative integer"));
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
if (params.max !== undefined) {
|
|
1480
|
+
if (!Number.isInteger(params.max) || params.max <= 0) {
|
|
1481
|
+
issues.push(issue("max", "Must be a positive integer"));
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
if (issues.length > 0) {
|
|
1485
|
+
throw createInputValidationError("Invalid list parameters", issues);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
function validateSourcedId(sourcedId, context) {
|
|
1489
|
+
if (typeof sourcedId !== "string" || sourcedId.trim() === "") {
|
|
1490
|
+
throw createInputValidationError(`Invalid ${context} request`, [
|
|
1491
|
+
issue("sourcedId", "Must be a non-empty string")
|
|
1492
|
+
]);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1408
1495
|
export {
|
|
1409
1496
|
ValidationError,
|
|
1410
1497
|
UnauthorizedError,
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* },
|
|
14
14
|
* })
|
|
15
15
|
*
|
|
16
|
-
* for await (const school of client.schools.
|
|
16
|
+
* for await (const school of client.schools.stream()) {
|
|
17
17
|
* console.log(school.name)
|
|
18
18
|
* }
|
|
19
19
|
* ```
|
|
@@ -34,7 +34,7 @@ export { OneRosterClient, type OneRosterClientInstance } from './client';
|
|
|
34
34
|
export { createOneRosterClient } from './factory';
|
|
35
35
|
export type { OneRosterClientConfig } from './types/client';
|
|
36
36
|
export type { Environment, EnvAuth, ExplicitAuth } from './types/client';
|
|
37
|
-
export type { StreamableResource } from './types
|
|
37
|
+
export type { StreamableResource } from './types';
|
|
38
38
|
export type { AuthCheckResult, ListParams, PageResult } from '@timeback/internal-client-infra';
|
|
39
39
|
export { whereToFilter } from '@timeback/internal-client-infra';
|
|
40
40
|
export type { FieldCondition, FieldOperators, FilterFields, FilterValue, OrCondition, WhereClause, } from '@timeback/internal-client-infra';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,OAAO,EAAE,eAAe,EAAE,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAExE,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,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,OAAO,EAAE,eAAe,EAAE,KAAK,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAExE,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,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AAM9F,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAE/D,YAAY,EACX,cAAc,EACd,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,EACX,WAAW,GACX,MAAM,iCAAiC,CAAA;AAMxC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA"}
|