@timeback/core 0.2.3-beta.20260326015342 → 0.2.3-beta.20260330020222
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/{chunk-z964w2xh.js → chunk-jqy7m30q.js} +217 -54
- package/dist/index.js +9 -7
- package/dist/utils.js +1 -1
- package/package.json +1 -1
|
@@ -39,7 +39,17 @@ function getTimezoneOffsetMs(at, timezone) {
|
|
|
39
39
|
const localMs = Date.UTC(n("year"), n("month") - 1, n("day"), n("hour"), n("minute"), n("second"));
|
|
40
40
|
return at.getTime() - at.getTime() % 1000 - localMs;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function validateBareDate(bareDate, fieldName) {
|
|
43
|
+
const [year, month, day] = bareDate.split("-").map(Number);
|
|
44
|
+
const d = new Date(Date.UTC(year, month - 1, day));
|
|
45
|
+
if (d.getUTCFullYear() !== year || d.getUTCMonth() !== month - 1 || d.getUTCDate() !== day) {
|
|
46
|
+
throw createInputValidationError("Invalid date", [
|
|
47
|
+
{ path: fieldName, message: `Not a valid calendar date: "${bareDate}"` }
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function bareDateToUTC(bareDate, time, timezone, fieldName) {
|
|
52
|
+
validateBareDate(bareDate, fieldName);
|
|
43
53
|
try {
|
|
44
54
|
const [year, month, day] = bareDate.split("-").map(Number);
|
|
45
55
|
const [h, m, secMs] = time.split(":");
|
|
@@ -59,19 +69,23 @@ function bareDateToUTC(bareDate, time, timezone) {
|
|
|
59
69
|
throw err;
|
|
60
70
|
}
|
|
61
71
|
}
|
|
62
|
-
function normalizeStartDate(date, timezone) {
|
|
72
|
+
function normalizeStartDate(date, timezone, fieldName = "startDate") {
|
|
63
73
|
if (date.includes("T"))
|
|
64
74
|
return date;
|
|
75
|
+
validateBareDate(date, fieldName);
|
|
65
76
|
if (!timezone)
|
|
66
77
|
return `${date}T00:00:00.000Z`;
|
|
67
|
-
return bareDateToUTC(date, "00:00:00.000", timezone);
|
|
78
|
+
return bareDateToUTC(date, "00:00:00.000", timezone, fieldName);
|
|
68
79
|
}
|
|
69
|
-
function normalizeEndDate(date, timezone) {
|
|
70
|
-
if (date.includes("T"))
|
|
80
|
+
function normalizeEndDate(date, timezone, fieldName = "endDate") {
|
|
81
|
+
if (date.includes("T")) {
|
|
71
82
|
return date;
|
|
72
|
-
|
|
83
|
+
}
|
|
84
|
+
validateBareDate(date, fieldName);
|
|
85
|
+
if (!timezone) {
|
|
73
86
|
return `${date}T23:59:59.999Z`;
|
|
74
|
-
|
|
87
|
+
}
|
|
88
|
+
return bareDateToUTC(date, "23:59:59.999", timezone, fieldName);
|
|
75
89
|
}
|
|
76
90
|
function aggregateActivityMetrics(data) {
|
|
77
91
|
const result = {
|
|
@@ -183,7 +197,7 @@ var TimebackSubject = z.enum([
|
|
|
183
197
|
"None",
|
|
184
198
|
"Other"
|
|
185
199
|
]).meta({ id: "TimebackSubject", description: "Subject area" });
|
|
186
|
-
var
|
|
200
|
+
var NumericTimebackGrade = z.union([
|
|
187
201
|
z.literal(-1),
|
|
188
202
|
z.literal(0),
|
|
189
203
|
z.literal(1),
|
|
@@ -199,7 +213,39 @@ var TimebackGrade = z.union([
|
|
|
199
213
|
z.literal(11),
|
|
200
214
|
z.literal(12),
|
|
201
215
|
z.literal(13)
|
|
202
|
-
])
|
|
216
|
+
]);
|
|
217
|
+
var StringTimebackGrade = z.string().transform((value, ctx) => {
|
|
218
|
+
const raw = value.toLowerCase().trim().replaceAll("_", " ");
|
|
219
|
+
if (raw === "") {
|
|
220
|
+
ctx.addIssue({
|
|
221
|
+
code: "custom",
|
|
222
|
+
message: "must be a valid Timeback grade"
|
|
223
|
+
});
|
|
224
|
+
return z.NEVER;
|
|
225
|
+
}
|
|
226
|
+
const stripped = raw.replace(/\bgrade\b/g, "").replace(/(\d+)(st|nd|rd|th)\b/g, "$1").trim();
|
|
227
|
+
if (stripped === "pre-k" || stripped === "pk") {
|
|
228
|
+
return -1;
|
|
229
|
+
}
|
|
230
|
+
if (stripped === "k") {
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
if (stripped === "middle school") {
|
|
234
|
+
return 7;
|
|
235
|
+
}
|
|
236
|
+
const normalized = stripped.replace(/\s+/g, "");
|
|
237
|
+
const withoutLeadingZeros = normalized.replace(/^0+/, "") || "0";
|
|
238
|
+
const parsed = Number(withoutLeadingZeros);
|
|
239
|
+
if (!Number.isInteger(parsed)) {
|
|
240
|
+
ctx.addIssue({
|
|
241
|
+
code: "custom",
|
|
242
|
+
message: "must be a valid Timeback grade"
|
|
243
|
+
});
|
|
244
|
+
return z.NEVER;
|
|
245
|
+
}
|
|
246
|
+
return parsed;
|
|
247
|
+
});
|
|
248
|
+
var TimebackGrade = z.union([z.number(), StringTimebackGrade]).pipe(NumericTimebackGrade).meta({
|
|
203
249
|
id: "TimebackGrade",
|
|
204
250
|
description: "Grade level (-1 = Pre-K, 0 = K, 1-12 = grades, 13 = AP)"
|
|
205
251
|
});
|
|
@@ -1015,7 +1061,42 @@ var Ref = z9.object({
|
|
|
1015
1061
|
type: z9.string().optional(),
|
|
1016
1062
|
href: z9.string().optional()
|
|
1017
1063
|
}).strict();
|
|
1064
|
+
var GuidRefType = z9.enum([
|
|
1065
|
+
"academicSession",
|
|
1066
|
+
"assessmentLineItem",
|
|
1067
|
+
"category",
|
|
1068
|
+
"class",
|
|
1069
|
+
"course",
|
|
1070
|
+
"demographics",
|
|
1071
|
+
"enrollment",
|
|
1072
|
+
"gradingPeriod",
|
|
1073
|
+
"lineItem",
|
|
1074
|
+
"org",
|
|
1075
|
+
"resource",
|
|
1076
|
+
"result",
|
|
1077
|
+
"scoreScale",
|
|
1078
|
+
"student",
|
|
1079
|
+
"teacher",
|
|
1080
|
+
"term",
|
|
1081
|
+
"user",
|
|
1082
|
+
"componentResource",
|
|
1083
|
+
"courseComponent"
|
|
1084
|
+
]);
|
|
1085
|
+
var GuidRef = z9.object({
|
|
1086
|
+
sourcedId: NonEmptyString,
|
|
1087
|
+
type: GuidRefType,
|
|
1088
|
+
href: z9.url()
|
|
1089
|
+
}).strict();
|
|
1018
1090
|
var OneRosterDateString = z9.union([IsoDateString, IsoDateTimeString]).transform((date) => date.includes("T") ? date : `${date}T00:00:00Z`);
|
|
1091
|
+
var LearningObjectiveResult = z9.object({
|
|
1092
|
+
learningObjectiveId: z9.string(),
|
|
1093
|
+
score: z9.number().optional(),
|
|
1094
|
+
textScore: z9.string().optional()
|
|
1095
|
+
});
|
|
1096
|
+
var LearningObjectiveScoreSetSchema = z9.array(z9.object({
|
|
1097
|
+
source: z9.string(),
|
|
1098
|
+
learningObjectiveResults: z9.array(LearningObjectiveResult)
|
|
1099
|
+
}));
|
|
1019
1100
|
var OneRosterUserRoleInput = z9.object({
|
|
1020
1101
|
roleType: z9.enum(["primary", "secondary"]),
|
|
1021
1102
|
role: OneRosterUserRole,
|
|
@@ -1028,35 +1109,46 @@ var OneRosterUserRoleInput = z9.object({
|
|
|
1028
1109
|
var OneRosterUserCreateInput = z9.object({
|
|
1029
1110
|
sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string"),
|
|
1030
1111
|
status: Status.optional(),
|
|
1031
|
-
enabledUser: z9.
|
|
1112
|
+
enabledUser: z9.union([
|
|
1113
|
+
z9.boolean(),
|
|
1114
|
+
z9.enum(["true", "false"]).transform((value) => value === "true")
|
|
1115
|
+
]),
|
|
1032
1116
|
givenName: NonEmptyString.describe("givenName must be a non-empty string"),
|
|
1033
1117
|
familyName: NonEmptyString.describe("familyName must be a non-empty string"),
|
|
1034
|
-
middleName: NonEmptyString.optional(),
|
|
1035
|
-
|
|
1118
|
+
middleName: NonEmptyString.nullable().optional(),
|
|
1119
|
+
preferredFirstName: NonEmptyString.nullable().optional(),
|
|
1120
|
+
preferredMiddleName: NonEmptyString.nullable().optional(),
|
|
1121
|
+
preferredLastName: NonEmptyString.nullable().optional(),
|
|
1122
|
+
username: NonEmptyString.nullable().optional(),
|
|
1036
1123
|
email: z9.email(),
|
|
1124
|
+
userMasterIdentifier: z9.string().nullable().optional(),
|
|
1037
1125
|
roles: z9.array(OneRosterUserRoleInput).min(1, "roles must include at least one role"),
|
|
1038
1126
|
userIds: z9.array(z9.object({
|
|
1039
1127
|
type: NonEmptyString,
|
|
1040
1128
|
identifier: NonEmptyString
|
|
1041
1129
|
}).strict()).optional(),
|
|
1042
1130
|
agents: z9.array(Ref).optional(),
|
|
1131
|
+
primaryOrg: Ref.optional(),
|
|
1043
1132
|
grades: z9.array(TimebackGrade).optional(),
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
password: NonEmptyString.optional(),
|
|
1133
|
+
sms: NonEmptyString.nullable().optional(),
|
|
1134
|
+
phone: NonEmptyString.nullable().optional(),
|
|
1135
|
+
pronouns: NonEmptyString.nullable().optional(),
|
|
1136
|
+
password: NonEmptyString.nullable().optional(),
|
|
1049
1137
|
metadata: Metadata
|
|
1050
1138
|
}).strict();
|
|
1051
1139
|
var OneRosterCourseCreateInput = z9.object({
|
|
1052
1140
|
sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string").optional(),
|
|
1053
|
-
status: Status
|
|
1141
|
+
status: Status,
|
|
1054
1142
|
title: NonEmptyString.describe("title must be a non-empty string"),
|
|
1055
1143
|
org: Ref,
|
|
1056
|
-
courseCode: NonEmptyString.optional(),
|
|
1057
|
-
subjects: z9.array(TimebackSubject).optional(),
|
|
1058
|
-
|
|
1059
|
-
|
|
1144
|
+
courseCode: NonEmptyString.nullable().optional(),
|
|
1145
|
+
subjects: z9.array(TimebackSubject).nullable().optional(),
|
|
1146
|
+
subjectCodes: z9.array(z9.string()).nullable().optional(),
|
|
1147
|
+
grades: z9.array(TimebackGrade).nullable().optional(),
|
|
1148
|
+
level: NonEmptyString.nullable().optional(),
|
|
1149
|
+
academicSession: Ref.nullable().optional(),
|
|
1150
|
+
schoolYear: GuidRef.nullable().optional(),
|
|
1151
|
+
gradingScheme: NonEmptyString.nullable().optional(),
|
|
1060
1152
|
metadata: Metadata
|
|
1061
1153
|
}).strict();
|
|
1062
1154
|
var OneRosterClassCreateInput = z9.object({
|
|
@@ -1066,9 +1158,9 @@ var OneRosterClassCreateInput = z9.object({
|
|
|
1066
1158
|
terms: z9.array(Ref).min(1, "terms must have at least one item"),
|
|
1067
1159
|
course: Ref,
|
|
1068
1160
|
org: Ref,
|
|
1069
|
-
classCode: NonEmptyString.optional(),
|
|
1161
|
+
classCode: NonEmptyString.nullable().optional(),
|
|
1070
1162
|
classType: z9.enum(["homeroom", "scheduled"]).optional(),
|
|
1071
|
-
location: NonEmptyString.optional(),
|
|
1163
|
+
location: NonEmptyString.nullable().optional(),
|
|
1072
1164
|
grades: z9.array(TimebackGrade).optional(),
|
|
1073
1165
|
subjects: z9.array(TimebackSubject).optional(),
|
|
1074
1166
|
subjectCodes: z9.array(NonEmptyString).optional(),
|
|
@@ -1103,18 +1195,21 @@ var OneRosterLineItemCreateInput = z9.object({
|
|
|
1103
1195
|
category: Ref,
|
|
1104
1196
|
assignDate: OneRosterDateString,
|
|
1105
1197
|
dueDate: OneRosterDateString,
|
|
1106
|
-
status: Status,
|
|
1107
|
-
description: z9.string().optional(),
|
|
1198
|
+
status: Status.optional(),
|
|
1199
|
+
description: z9.string().nullable().optional(),
|
|
1108
1200
|
resultValueMin: z9.number().nullable().optional(),
|
|
1109
1201
|
resultValueMax: z9.number().nullable().optional(),
|
|
1110
|
-
|
|
1202
|
+
gradingPeriod: Ref.nullable().optional(),
|
|
1203
|
+
academicSession: Ref.nullable().optional(),
|
|
1204
|
+
scoreScale: Ref.nullable().optional(),
|
|
1205
|
+
learningObjectiveSet: LearningObjectiveSetSchema.nullable().optional(),
|
|
1111
1206
|
metadata: Metadata
|
|
1112
1207
|
}).strict();
|
|
1113
1208
|
var OneRosterResultCreateInput = z9.object({
|
|
1114
1209
|
sourcedId: NonEmptyString.optional(),
|
|
1115
1210
|
lineItem: Ref,
|
|
1116
1211
|
student: Ref,
|
|
1117
|
-
class: Ref.optional(),
|
|
1212
|
+
class: Ref.nullable().optional(),
|
|
1118
1213
|
scoreDate: OneRosterDateString,
|
|
1119
1214
|
scoreStatus: z9.enum([
|
|
1120
1215
|
"exempt",
|
|
@@ -1126,14 +1221,20 @@ var OneRosterResultCreateInput = z9.object({
|
|
|
1126
1221
|
score: z9.number().nullable().optional(),
|
|
1127
1222
|
textScore: z9.string().nullable().optional(),
|
|
1128
1223
|
status: Status,
|
|
1224
|
+
scoreScale: Ref.nullable().optional(),
|
|
1129
1225
|
comment: z9.string().nullable().optional(),
|
|
1226
|
+
learningObjectiveSet: LearningObjectiveScoreSetSchema.nullable().optional(),
|
|
1227
|
+
inProgress: z9.string().optional(),
|
|
1228
|
+
incomplete: z9.string().optional(),
|
|
1229
|
+
late: z9.string().optional(),
|
|
1230
|
+
missing: z9.string().optional(),
|
|
1130
1231
|
metadata: Metadata
|
|
1131
1232
|
}).strict();
|
|
1132
1233
|
var OneRosterScoreScaleCreateInput = z9.object({
|
|
1133
1234
|
sourcedId: NonEmptyString.optional(),
|
|
1134
1235
|
title: NonEmptyString.describe("title must be a non-empty string"),
|
|
1135
|
-
status: Status
|
|
1136
|
-
type:
|
|
1236
|
+
status: Status,
|
|
1237
|
+
type: NonEmptyString,
|
|
1137
1238
|
class: Ref,
|
|
1138
1239
|
course: Ref.nullable().optional(),
|
|
1139
1240
|
scoreScaleValue: z9.array(z9.object({
|
|
@@ -1142,13 +1243,11 @@ var OneRosterScoreScaleCreateInput = z9.object({
|
|
|
1142
1243
|
value: z9.string().optional(),
|
|
1143
1244
|
description: z9.string().optional()
|
|
1144
1245
|
}).strict()),
|
|
1145
|
-
minScore: z9.number().optional(),
|
|
1146
|
-
maxScore: z9.number().optional(),
|
|
1147
1246
|
metadata: Metadata
|
|
1148
1247
|
}).strict();
|
|
1149
1248
|
var OneRosterAssessmentLineItemCreateInput = z9.object({
|
|
1150
1249
|
sourcedId: NonEmptyString.optional(),
|
|
1151
|
-
status: Status
|
|
1250
|
+
status: Status,
|
|
1152
1251
|
dateLastModified: IsoDateTimeString.optional(),
|
|
1153
1252
|
title: NonEmptyString.describe("title must be a non-empty string"),
|
|
1154
1253
|
description: z9.string().nullable().optional(),
|
|
@@ -1166,18 +1265,9 @@ var OneRosterAssessmentLineItemCreateInput = z9.object({
|
|
|
1166
1265
|
course: Ref.nullable().optional(),
|
|
1167
1266
|
metadata: Metadata
|
|
1168
1267
|
}).strict();
|
|
1169
|
-
var LearningObjectiveResult = z9.object({
|
|
1170
|
-
learningObjectiveId: z9.string(),
|
|
1171
|
-
score: z9.number().optional(),
|
|
1172
|
-
textScore: z9.string().optional()
|
|
1173
|
-
});
|
|
1174
|
-
var LearningObjectiveScoreSetSchema = z9.array(z9.object({
|
|
1175
|
-
source: z9.string(),
|
|
1176
|
-
learningObjectiveResults: z9.array(LearningObjectiveResult)
|
|
1177
|
-
}));
|
|
1178
1268
|
var OneRosterAssessmentResultCreateInput = z9.object({
|
|
1179
1269
|
sourcedId: NonEmptyString.optional(),
|
|
1180
|
-
status: Status
|
|
1270
|
+
status: Status,
|
|
1181
1271
|
dateLastModified: IsoDateTimeString.optional(),
|
|
1182
1272
|
metadata: Metadata,
|
|
1183
1273
|
assessmentLineItem: Ref,
|
|
@@ -1206,7 +1296,7 @@ var OneRosterOrgCreateInput = z9.object({
|
|
|
1206
1296
|
status: Status.optional(),
|
|
1207
1297
|
name: NonEmptyString.describe("name must be a non-empty string"),
|
|
1208
1298
|
type: OrganizationType,
|
|
1209
|
-
identifier:
|
|
1299
|
+
identifier: z9.string().nullish(),
|
|
1210
1300
|
parent: Ref.optional(),
|
|
1211
1301
|
metadata: Metadata
|
|
1212
1302
|
}).strict();
|
|
@@ -1214,8 +1304,8 @@ var OneRosterSchoolCreateInput = z9.object({
|
|
|
1214
1304
|
sourcedId: NonEmptyString.optional(),
|
|
1215
1305
|
status: Status.optional(),
|
|
1216
1306
|
name: NonEmptyString.describe("name must be a non-empty string"),
|
|
1217
|
-
type: z9.literal("school").
|
|
1218
|
-
identifier:
|
|
1307
|
+
type: z9.literal("school").default("school"),
|
|
1308
|
+
identifier: z9.string().nullish(),
|
|
1219
1309
|
parent: Ref.optional(),
|
|
1220
1310
|
metadata: Metadata
|
|
1221
1311
|
}).strict();
|
|
@@ -1233,11 +1323,13 @@ var OneRosterAcademicSessionCreateInput = z9.object({
|
|
|
1233
1323
|
metadata: Metadata
|
|
1234
1324
|
}).strict();
|
|
1235
1325
|
var OneRosterComponentResourceCreateInput = z9.object({
|
|
1236
|
-
sourcedId: NonEmptyString
|
|
1326
|
+
sourcedId: NonEmptyString,
|
|
1237
1327
|
title: NonEmptyString.describe("title must be a non-empty string"),
|
|
1238
1328
|
courseComponent: Ref,
|
|
1239
1329
|
resource: Ref,
|
|
1240
1330
|
status: Status,
|
|
1331
|
+
sortOrder: z9.number().optional(),
|
|
1332
|
+
lessonType: LessonType.optional(),
|
|
1241
1333
|
metadata: Metadata
|
|
1242
1334
|
}).strict();
|
|
1243
1335
|
var OneRosterCourseComponentCreateInput = z9.object({
|
|
@@ -1245,8 +1337,17 @@ var OneRosterCourseComponentCreateInput = z9.object({
|
|
|
1245
1337
|
title: NonEmptyString.describe("title must be a non-empty string"),
|
|
1246
1338
|
course: Ref,
|
|
1247
1339
|
status: Status,
|
|
1340
|
+
sortOrder: z9.number().optional(),
|
|
1341
|
+
parent: Ref.nullable().optional(),
|
|
1342
|
+
courseComponent: Ref.nullable().optional(),
|
|
1343
|
+
prerequisites: z9.array(z9.string()).nullable().optional(),
|
|
1344
|
+
prerequisiteCriteria: z9.string().nullable().optional(),
|
|
1345
|
+
unlockDate: OneRosterDateString.nullable().optional(),
|
|
1248
1346
|
metadata: Metadata
|
|
1249
|
-
}).strict()
|
|
1347
|
+
}).strict().transform(({ courseComponent, parent, ...rest }) => ({
|
|
1348
|
+
...rest,
|
|
1349
|
+
parent: parent === undefined ? courseComponent ?? undefined : parent
|
|
1350
|
+
}));
|
|
1250
1351
|
var OneRosterEnrollInput = z9.object({
|
|
1251
1352
|
sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string"),
|
|
1252
1353
|
role: z9.enum(["student", "teacher"]),
|
|
@@ -1266,8 +1367,23 @@ var OneRosterCredentialInput = z9.object({
|
|
|
1266
1367
|
})
|
|
1267
1368
|
}).strict();
|
|
1268
1369
|
var OneRosterDemographicsCreateInput = z9.object({
|
|
1269
|
-
sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string")
|
|
1270
|
-
|
|
1370
|
+
sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string"),
|
|
1371
|
+
status: Status.optional(),
|
|
1372
|
+
metadata: Metadata,
|
|
1373
|
+
birthDate: z9.string().regex(/^\d{4}-\d{2}-\d{2}$/).nullable().optional(),
|
|
1374
|
+
sex: z9.enum(["male", "female"]).nullable().optional(),
|
|
1375
|
+
americanIndianOrAlaskaNative: StringBoolean.nullable().optional(),
|
|
1376
|
+
asian: StringBoolean.nullable().optional(),
|
|
1377
|
+
blackOrAfricanAmerican: StringBoolean.nullable().optional(),
|
|
1378
|
+
nativeHawaiianOrOtherPacificIslander: StringBoolean.nullable().optional(),
|
|
1379
|
+
white: StringBoolean.nullable().optional(),
|
|
1380
|
+
demographicRaceTwoOrMoreRaces: StringBoolean.nullable().optional(),
|
|
1381
|
+
hispanicOrLatinoEthnicity: StringBoolean.nullable().optional(),
|
|
1382
|
+
countryOfBirthCode: z9.string().nullable().optional(),
|
|
1383
|
+
stateOfBirthAbbreviation: z9.string().nullable().optional(),
|
|
1384
|
+
cityOfBirth: z9.string().nullable().optional(),
|
|
1385
|
+
publicSchoolResidenceStatus: z9.string().nullable().optional()
|
|
1386
|
+
}).strict();
|
|
1271
1387
|
var CommonResourceMetadataSchema = z9.object({
|
|
1272
1388
|
type: ResourceType,
|
|
1273
1389
|
subject: TimebackSubject.nullish(),
|
|
@@ -1337,16 +1453,63 @@ var ResourceMetadataSchema = z9.discriminatedUnion("type", [
|
|
|
1337
1453
|
CourseMaterialMetadataSchema,
|
|
1338
1454
|
AssessmentBankMetadataSchema
|
|
1339
1455
|
]);
|
|
1456
|
+
var ReservedResourceMetadataKeys = new Set([
|
|
1457
|
+
"type",
|
|
1458
|
+
"subject",
|
|
1459
|
+
"grades",
|
|
1460
|
+
"language",
|
|
1461
|
+
"xp",
|
|
1462
|
+
"url",
|
|
1463
|
+
"keywords",
|
|
1464
|
+
"learningObjectiveSet",
|
|
1465
|
+
"lessonType",
|
|
1466
|
+
"subType",
|
|
1467
|
+
"questionType",
|
|
1468
|
+
"difficulty",
|
|
1469
|
+
"format",
|
|
1470
|
+
"author",
|
|
1471
|
+
"pageCount",
|
|
1472
|
+
"duration",
|
|
1473
|
+
"speaker",
|
|
1474
|
+
"captionsAvailable",
|
|
1475
|
+
"launchUrl",
|
|
1476
|
+
"toolProvider",
|
|
1477
|
+
"instructionalMethod",
|
|
1478
|
+
"courseIdOnFail",
|
|
1479
|
+
"resolution",
|
|
1480
|
+
"resources"
|
|
1481
|
+
]);
|
|
1482
|
+
var UntypedResourceMetadataSchema = z9.record(z9.string(), z9.unknown()).superRefine((metadata, ctx) => {
|
|
1483
|
+
if ("fail_fast" in metadata) {
|
|
1484
|
+
const result = FastFailConfigSchema.safeParse(metadata.fail_fast);
|
|
1485
|
+
if (!result.success) {
|
|
1486
|
+
for (const issue of result.error.issues) {
|
|
1487
|
+
ctx.addIssue({
|
|
1488
|
+
...issue,
|
|
1489
|
+
path: ["fail_fast", ...issue.path]
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
const reservedKeys = Object.keys(metadata).filter((key) => ReservedResourceMetadataKeys.has(key));
|
|
1495
|
+
if (reservedKeys.length === 0) {
|
|
1496
|
+
return;
|
|
1497
|
+
}
|
|
1498
|
+
ctx.addIssue({
|
|
1499
|
+
code: "custom",
|
|
1500
|
+
message: `metadata keys ${reservedKeys.map((key) => `\`${key}\``).join(", ")} require a valid \`type\` discriminator`
|
|
1501
|
+
});
|
|
1502
|
+
});
|
|
1340
1503
|
var OneRosterResourceCreateInput = z9.object({
|
|
1341
1504
|
sourcedId: NonEmptyString.optional(),
|
|
1342
1505
|
title: NonEmptyString.describe("title must be a non-empty string"),
|
|
1343
1506
|
vendorResourceId: NonEmptyString.describe("vendorResourceId must be a non-empty string"),
|
|
1344
1507
|
roles: z9.array(z9.enum(["primary", "secondary"])).optional(),
|
|
1345
1508
|
importance: z9.enum(["primary", "secondary"]).optional(),
|
|
1346
|
-
vendorId:
|
|
1347
|
-
applicationId:
|
|
1509
|
+
vendorId: NonEmptyString.nullable().optional(),
|
|
1510
|
+
applicationId: NonEmptyString.nullable().optional(),
|
|
1348
1511
|
status: Status.optional(),
|
|
1349
|
-
metadata: ResourceMetadataSchema.nullable().optional()
|
|
1512
|
+
metadata: z9.union([ResourceMetadataSchema, UntypedResourceMetadataSchema]).nullable().optional()
|
|
1350
1513
|
}).strict();
|
|
1351
1514
|
var CourseStructureItem = z9.object({
|
|
1352
1515
|
url: NonEmptyString.describe("courseStructure.url must be a non-empty string"),
|
|
@@ -1961,7 +2124,7 @@ class AnalyticsResource {
|
|
|
1961
2124
|
params: {
|
|
1962
2125
|
email: validated.email,
|
|
1963
2126
|
studentId: validated.studentId,
|
|
1964
|
-
weekDate: normalizeStartDate(validated.weekDate, validated.timezone),
|
|
2127
|
+
weekDate: normalizeStartDate(validated.weekDate, validated.timezone, "weekDate"),
|
|
1965
2128
|
timezone: validated.timezone
|
|
1966
2129
|
}
|
|
1967
2130
|
});
|
package/dist/index.js
CHANGED
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
WebhookFilterCreateInput,
|
|
86
86
|
WebhookFilterUpdateInput,
|
|
87
87
|
WebhookUpdateInput
|
|
88
|
-
} from "./chunk-
|
|
88
|
+
} from "./chunk-jqy7m30q.js";
|
|
89
89
|
import {
|
|
90
90
|
ApiError,
|
|
91
91
|
BaseTransport,
|
|
@@ -2264,17 +2264,18 @@ class CoursesResourceImpl extends BaseResource {
|
|
|
2264
2264
|
return response.courseComponent;
|
|
2265
2265
|
}
|
|
2266
2266
|
createComponent(data) {
|
|
2267
|
-
validateWithSchema(OneRosterCourseComponentCreateInput, data, "course component");
|
|
2267
|
+
const validated = validateWithSchema(OneRosterCourseComponentCreateInput, data, "course component");
|
|
2268
2268
|
return this.transport.request(`${this.basePath}/components`, {
|
|
2269
2269
|
method: "POST",
|
|
2270
|
-
body: { courseComponent:
|
|
2270
|
+
body: { courseComponent: validated }
|
|
2271
2271
|
});
|
|
2272
2272
|
}
|
|
2273
2273
|
updateComponent(sourcedId, data) {
|
|
2274
2274
|
validateSourcedId(sourcedId, "update course component");
|
|
2275
|
+
const validated = validateWithSchema(OneRosterCourseComponentCreateInput, data, "course component");
|
|
2275
2276
|
return this.transport.request(`${this.basePath}/components/${sourcedId}`, {
|
|
2276
2277
|
method: "PUT",
|
|
2277
|
-
body: { courseComponent:
|
|
2278
|
+
body: { courseComponent: validated }
|
|
2278
2279
|
});
|
|
2279
2280
|
}
|
|
2280
2281
|
deleteComponent(sourcedId) {
|
|
@@ -2295,17 +2296,18 @@ class CoursesResourceImpl extends BaseResource {
|
|
|
2295
2296
|
return response.componentResource;
|
|
2296
2297
|
}
|
|
2297
2298
|
createComponentResource(data) {
|
|
2298
|
-
validateWithSchema(OneRosterComponentResourceCreateInput, data, "component resource");
|
|
2299
|
+
const validated = validateWithSchema(OneRosterComponentResourceCreateInput, data, "component resource");
|
|
2299
2300
|
return this.transport.request(`${this.basePath}/component-resources`, {
|
|
2300
2301
|
method: "POST",
|
|
2301
|
-
body: { componentResource:
|
|
2302
|
+
body: { componentResource: validated }
|
|
2302
2303
|
});
|
|
2303
2304
|
}
|
|
2304
2305
|
updateComponentResource(sourcedId, data) {
|
|
2305
2306
|
validateSourcedId(sourcedId, "update component resource");
|
|
2307
|
+
const validated = validateWithSchema(OneRosterComponentResourceCreateInput, data, "component resource");
|
|
2306
2308
|
return this.transport.request(`${this.basePath}/component-resources/${sourcedId}`, {
|
|
2307
2309
|
method: "PUT",
|
|
2308
|
-
body: { componentResource:
|
|
2310
|
+
body: { componentResource: validated }
|
|
2309
2311
|
});
|
|
2310
2312
|
}
|
|
2311
2313
|
deleteComponentResource(sourcedId) {
|
package/dist/utils.js
CHANGED