@timeback/qti 0.1.0 → 0.1.1
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 +82 -2
- package/dist/index.js +14558 -5
- package/dist/lib/pagination.d.ts.map +1 -1
- package/dist/resources/assessment-items.d.ts +2 -1
- package/dist/resources/assessment-items.d.ts.map +1 -1
- package/dist/resources/assessment-tests.d.ts +3 -2
- package/dist/resources/assessment-tests.d.ts.map +1 -1
- package/dist/resources/general.d.ts.map +1 -1
- package/dist/resources/lesson.d.ts +2 -1
- package/dist/resources/lesson.d.ts.map +1 -1
- package/dist/resources/stimuli.d.ts +3 -2
- package/dist/resources/stimuli.d.ts.map +1 -1
- package/dist/resources/validate.d.ts +2 -1
- package/dist/resources/validate.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -12
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -1
- package/dist/types/api.d.ts +0 -37
- package/dist/types/api.d.ts.map +0 -1
- package/dist/types/assessment-items.d.ts +0 -82
- package/dist/types/assessment-items.d.ts.map +0 -1
- package/dist/types/assessment-tests.d.ts +0 -180
- package/dist/types/assessment-tests.d.ts.map +0 -1
- package/dist/types/base.d.ts +0 -195
- package/dist/types/base.d.ts.map +0 -1
- package/dist/types/lesson.d.ts +0 -38
- package/dist/types/lesson.d.ts.map +0 -1
- package/dist/types/stimuli.d.ts +0 -56
- package/dist/types/stimuli.d.ts.map +0 -1
- package/dist/types/validate.d.ts +0 -39
- package/dist/types/validate.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];
|
|
@@ -1396,10 +1429,57 @@ class Paginator {
|
|
|
1396
1429
|
};
|
|
1397
1430
|
}
|
|
1398
1431
|
}
|
|
1432
|
+
// ../../internal/client-infra/src/validation/index.ts
|
|
1433
|
+
function issue(path, message) {
|
|
1434
|
+
return { path, message };
|
|
1435
|
+
}
|
|
1436
|
+
function validateWithSchema(schema, data, context) {
|
|
1437
|
+
const result = schema.safeParse(data);
|
|
1438
|
+
if (result.success) {
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
const issues = result.error.issues.map((errorIssue) => ({
|
|
1442
|
+
path: errorIssue.path.join(".") || "(root)",
|
|
1443
|
+
message: errorIssue.message
|
|
1444
|
+
}));
|
|
1445
|
+
throw createInputValidationError(`Invalid ${context} data`, issues);
|
|
1446
|
+
}
|
|
1447
|
+
function validateNonEmptyString(value, name) {
|
|
1448
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
1449
|
+
throw createInputValidationError(`Invalid ${name}`, [
|
|
1450
|
+
issue(name, "Must be a non-empty string")
|
|
1451
|
+
]);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
function validatePageListParams(params) {
|
|
1455
|
+
if (!params) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const issues = [];
|
|
1459
|
+
if (params.page !== undefined) {
|
|
1460
|
+
if (!Number.isInteger(params.page) || params.page <= 0) {
|
|
1461
|
+
issues.push(issue("page", "Must be a positive integer"));
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
if (params.limit !== undefined) {
|
|
1465
|
+
if (!Number.isInteger(params.limit) || params.limit <= 0) {
|
|
1466
|
+
issues.push(issue("limit", "Must be a positive integer"));
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
if (params.max !== undefined) {
|
|
1470
|
+
if (!Number.isInteger(params.max) || params.max <= 0) {
|
|
1471
|
+
issues.push(issue("max", "Must be a positive integer"));
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
if (issues.length > 0) {
|
|
1475
|
+
throw createInputValidationError("Invalid list parameters", issues);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1399
1478
|
export {
|
|
1400
1479
|
ValidationError,
|
|
1401
1480
|
UnauthorizedError,
|
|
1402
1481
|
ApiError as QtiError,
|
|
1403
1482
|
NotFoundError,
|
|
1483
|
+
InputValidationError,
|
|
1404
1484
|
ForbiddenError
|
|
1405
1485
|
};
|