@timeback/core 0.2.3-beta.20260326022000 → 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.
@@ -197,7 +197,7 @@ var TimebackSubject = z.enum([
197
197
  "None",
198
198
  "Other"
199
199
  ]).meta({ id: "TimebackSubject", description: "Subject area" });
200
- var TimebackGrade = z.union([
200
+ var NumericTimebackGrade = z.union([
201
201
  z.literal(-1),
202
202
  z.literal(0),
203
203
  z.literal(1),
@@ -213,7 +213,39 @@ var TimebackGrade = z.union([
213
213
  z.literal(11),
214
214
  z.literal(12),
215
215
  z.literal(13)
216
- ]).meta({
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({
217
249
  id: "TimebackGrade",
218
250
  description: "Grade level (-1 = Pre-K, 0 = K, 1-12 = grades, 13 = AP)"
219
251
  });
@@ -1029,7 +1061,42 @@ var Ref = z9.object({
1029
1061
  type: z9.string().optional(),
1030
1062
  href: z9.string().optional()
1031
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();
1032
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
+ }));
1033
1100
  var OneRosterUserRoleInput = z9.object({
1034
1101
  roleType: z9.enum(["primary", "secondary"]),
1035
1102
  role: OneRosterUserRole,
@@ -1042,35 +1109,46 @@ var OneRosterUserRoleInput = z9.object({
1042
1109
  var OneRosterUserCreateInput = z9.object({
1043
1110
  sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string"),
1044
1111
  status: Status.optional(),
1045
- enabledUser: z9.boolean(),
1112
+ enabledUser: z9.union([
1113
+ z9.boolean(),
1114
+ z9.enum(["true", "false"]).transform((value) => value === "true")
1115
+ ]),
1046
1116
  givenName: NonEmptyString.describe("givenName must be a non-empty string"),
1047
1117
  familyName: NonEmptyString.describe("familyName must be a non-empty string"),
1048
- middleName: NonEmptyString.optional(),
1049
- username: NonEmptyString.optional(),
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(),
1050
1123
  email: z9.email(),
1124
+ userMasterIdentifier: z9.string().nullable().optional(),
1051
1125
  roles: z9.array(OneRosterUserRoleInput).min(1, "roles must include at least one role"),
1052
1126
  userIds: z9.array(z9.object({
1053
1127
  type: NonEmptyString,
1054
1128
  identifier: NonEmptyString
1055
1129
  }).strict()).optional(),
1056
1130
  agents: z9.array(Ref).optional(),
1131
+ primaryOrg: Ref.optional(),
1057
1132
  grades: z9.array(TimebackGrade).optional(),
1058
- identifier: NonEmptyString.optional(),
1059
- sms: NonEmptyString.optional(),
1060
- phone: NonEmptyString.optional(),
1061
- pronouns: NonEmptyString.optional(),
1062
- password: NonEmptyString.optional(),
1133
+ sms: NonEmptyString.nullable().optional(),
1134
+ phone: NonEmptyString.nullable().optional(),
1135
+ pronouns: NonEmptyString.nullable().optional(),
1136
+ password: NonEmptyString.nullable().optional(),
1063
1137
  metadata: Metadata
1064
1138
  }).strict();
1065
1139
  var OneRosterCourseCreateInput = z9.object({
1066
1140
  sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string").optional(),
1067
- status: Status.optional(),
1141
+ status: Status,
1068
1142
  title: NonEmptyString.describe("title must be a non-empty string"),
1069
1143
  org: Ref,
1070
- courseCode: NonEmptyString.optional(),
1071
- subjects: z9.array(TimebackSubject).optional(),
1072
- grades: z9.array(TimebackGrade).optional(),
1073
- level: NonEmptyString.optional(),
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(),
1074
1152
  metadata: Metadata
1075
1153
  }).strict();
1076
1154
  var OneRosterClassCreateInput = z9.object({
@@ -1080,9 +1158,9 @@ var OneRosterClassCreateInput = z9.object({
1080
1158
  terms: z9.array(Ref).min(1, "terms must have at least one item"),
1081
1159
  course: Ref,
1082
1160
  org: Ref,
1083
- classCode: NonEmptyString.optional(),
1161
+ classCode: NonEmptyString.nullable().optional(),
1084
1162
  classType: z9.enum(["homeroom", "scheduled"]).optional(),
1085
- location: NonEmptyString.optional(),
1163
+ location: NonEmptyString.nullable().optional(),
1086
1164
  grades: z9.array(TimebackGrade).optional(),
1087
1165
  subjects: z9.array(TimebackSubject).optional(),
1088
1166
  subjectCodes: z9.array(NonEmptyString).optional(),
@@ -1117,18 +1195,21 @@ var OneRosterLineItemCreateInput = z9.object({
1117
1195
  category: Ref,
1118
1196
  assignDate: OneRosterDateString,
1119
1197
  dueDate: OneRosterDateString,
1120
- status: Status,
1121
- description: z9.string().optional(),
1198
+ status: Status.optional(),
1199
+ description: z9.string().nullable().optional(),
1122
1200
  resultValueMin: z9.number().nullable().optional(),
1123
1201
  resultValueMax: z9.number().nullable().optional(),
1124
- scoreScale: Ref.optional(),
1202
+ gradingPeriod: Ref.nullable().optional(),
1203
+ academicSession: Ref.nullable().optional(),
1204
+ scoreScale: Ref.nullable().optional(),
1205
+ learningObjectiveSet: LearningObjectiveSetSchema.nullable().optional(),
1125
1206
  metadata: Metadata
1126
1207
  }).strict();
1127
1208
  var OneRosterResultCreateInput = z9.object({
1128
1209
  sourcedId: NonEmptyString.optional(),
1129
1210
  lineItem: Ref,
1130
1211
  student: Ref,
1131
- class: Ref.optional(),
1212
+ class: Ref.nullable().optional(),
1132
1213
  scoreDate: OneRosterDateString,
1133
1214
  scoreStatus: z9.enum([
1134
1215
  "exempt",
@@ -1140,14 +1221,20 @@ var OneRosterResultCreateInput = z9.object({
1140
1221
  score: z9.number().nullable().optional(),
1141
1222
  textScore: z9.string().nullable().optional(),
1142
1223
  status: Status,
1224
+ scoreScale: Ref.nullable().optional(),
1143
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(),
1144
1231
  metadata: Metadata
1145
1232
  }).strict();
1146
1233
  var OneRosterScoreScaleCreateInput = z9.object({
1147
1234
  sourcedId: NonEmptyString.optional(),
1148
1235
  title: NonEmptyString.describe("title must be a non-empty string"),
1149
- status: Status.optional(),
1150
- type: z9.string(),
1236
+ status: Status,
1237
+ type: NonEmptyString,
1151
1238
  class: Ref,
1152
1239
  course: Ref.nullable().optional(),
1153
1240
  scoreScaleValue: z9.array(z9.object({
@@ -1156,13 +1243,11 @@ var OneRosterScoreScaleCreateInput = z9.object({
1156
1243
  value: z9.string().optional(),
1157
1244
  description: z9.string().optional()
1158
1245
  }).strict()),
1159
- minScore: z9.number().optional(),
1160
- maxScore: z9.number().optional(),
1161
1246
  metadata: Metadata
1162
1247
  }).strict();
1163
1248
  var OneRosterAssessmentLineItemCreateInput = z9.object({
1164
1249
  sourcedId: NonEmptyString.optional(),
1165
- status: Status.optional(),
1250
+ status: Status,
1166
1251
  dateLastModified: IsoDateTimeString.optional(),
1167
1252
  title: NonEmptyString.describe("title must be a non-empty string"),
1168
1253
  description: z9.string().nullable().optional(),
@@ -1180,18 +1265,9 @@ var OneRosterAssessmentLineItemCreateInput = z9.object({
1180
1265
  course: Ref.nullable().optional(),
1181
1266
  metadata: Metadata
1182
1267
  }).strict();
1183
- var LearningObjectiveResult = z9.object({
1184
- learningObjectiveId: z9.string(),
1185
- score: z9.number().optional(),
1186
- textScore: z9.string().optional()
1187
- });
1188
- var LearningObjectiveScoreSetSchema = z9.array(z9.object({
1189
- source: z9.string(),
1190
- learningObjectiveResults: z9.array(LearningObjectiveResult)
1191
- }));
1192
1268
  var OneRosterAssessmentResultCreateInput = z9.object({
1193
1269
  sourcedId: NonEmptyString.optional(),
1194
- status: Status.optional(),
1270
+ status: Status,
1195
1271
  dateLastModified: IsoDateTimeString.optional(),
1196
1272
  metadata: Metadata,
1197
1273
  assessmentLineItem: Ref,
@@ -1220,7 +1296,7 @@ var OneRosterOrgCreateInput = z9.object({
1220
1296
  status: Status.optional(),
1221
1297
  name: NonEmptyString.describe("name must be a non-empty string"),
1222
1298
  type: OrganizationType,
1223
- identifier: NonEmptyString.optional(),
1299
+ identifier: z9.string().nullish(),
1224
1300
  parent: Ref.optional(),
1225
1301
  metadata: Metadata
1226
1302
  }).strict();
@@ -1228,8 +1304,8 @@ var OneRosterSchoolCreateInput = z9.object({
1228
1304
  sourcedId: NonEmptyString.optional(),
1229
1305
  status: Status.optional(),
1230
1306
  name: NonEmptyString.describe("name must be a non-empty string"),
1231
- type: z9.literal("school").optional(),
1232
- identifier: NonEmptyString.optional(),
1307
+ type: z9.literal("school").default("school"),
1308
+ identifier: z9.string().nullish(),
1233
1309
  parent: Ref.optional(),
1234
1310
  metadata: Metadata
1235
1311
  }).strict();
@@ -1247,11 +1323,13 @@ var OneRosterAcademicSessionCreateInput = z9.object({
1247
1323
  metadata: Metadata
1248
1324
  }).strict();
1249
1325
  var OneRosterComponentResourceCreateInput = z9.object({
1250
- sourcedId: NonEmptyString.optional(),
1326
+ sourcedId: NonEmptyString,
1251
1327
  title: NonEmptyString.describe("title must be a non-empty string"),
1252
1328
  courseComponent: Ref,
1253
1329
  resource: Ref,
1254
1330
  status: Status,
1331
+ sortOrder: z9.number().optional(),
1332
+ lessonType: LessonType.optional(),
1255
1333
  metadata: Metadata
1256
1334
  }).strict();
1257
1335
  var OneRosterCourseComponentCreateInput = z9.object({
@@ -1259,8 +1337,17 @@ var OneRosterCourseComponentCreateInput = z9.object({
1259
1337
  title: NonEmptyString.describe("title must be a non-empty string"),
1260
1338
  course: Ref,
1261
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(),
1262
1346
  metadata: Metadata
1263
- }).strict();
1347
+ }).strict().transform(({ courseComponent, parent, ...rest }) => ({
1348
+ ...rest,
1349
+ parent: parent === undefined ? courseComponent ?? undefined : parent
1350
+ }));
1264
1351
  var OneRosterEnrollInput = z9.object({
1265
1352
  sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string"),
1266
1353
  role: z9.enum(["student", "teacher"]),
@@ -1280,8 +1367,23 @@ var OneRosterCredentialInput = z9.object({
1280
1367
  })
1281
1368
  }).strict();
1282
1369
  var OneRosterDemographicsCreateInput = z9.object({
1283
- sourcedId: NonEmptyString.describe("sourcedId must be a non-empty string")
1284
- }).loose();
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();
1285
1387
  var CommonResourceMetadataSchema = z9.object({
1286
1388
  type: ResourceType,
1287
1389
  subject: TimebackSubject.nullish(),
@@ -1351,16 +1453,63 @@ var ResourceMetadataSchema = z9.discriminatedUnion("type", [
1351
1453
  CourseMaterialMetadataSchema,
1352
1454
  AssessmentBankMetadataSchema
1353
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
+ });
1354
1503
  var OneRosterResourceCreateInput = z9.object({
1355
1504
  sourcedId: NonEmptyString.optional(),
1356
1505
  title: NonEmptyString.describe("title must be a non-empty string"),
1357
1506
  vendorResourceId: NonEmptyString.describe("vendorResourceId must be a non-empty string"),
1358
1507
  roles: z9.array(z9.enum(["primary", "secondary"])).optional(),
1359
1508
  importance: z9.enum(["primary", "secondary"]).optional(),
1360
- vendorId: z9.string().optional(),
1361
- applicationId: z9.string().optional(),
1509
+ vendorId: NonEmptyString.nullable().optional(),
1510
+ applicationId: NonEmptyString.nullable().optional(),
1362
1511
  status: Status.optional(),
1363
- metadata: ResourceMetadataSchema.nullable().optional()
1512
+ metadata: z9.union([ResourceMetadataSchema, UntypedResourceMetadataSchema]).nullable().optional()
1364
1513
  }).strict();
1365
1514
  var CourseStructureItem = z9.object({
1366
1515
  url: NonEmptyString.describe("courseStructure.url must be a non-empty string"),
package/dist/index.js CHANGED
@@ -85,7 +85,7 @@ import {
85
85
  WebhookFilterCreateInput,
86
86
  WebhookFilterUpdateInput,
87
87
  WebhookUpdateInput
88
- } from "./chunk-sdbhq9cc.js";
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: data }
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: data }
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: data }
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: data }
2310
+ body: { componentResource: validated }
2309
2311
  });
2310
2312
  }
2311
2313
  deleteComponentResource(sourcedId) {
package/dist/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  aggregateActivityMetrics
3
- } from "./chunk-sdbhq9cc.js";
3
+ } from "./chunk-jqy7m30q.js";
4
4
  import"./chunk-bjb7ngh9.js";
5
5
  import"./chunk-3j7jywnx.js";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timeback/core",
3
- "version": "0.2.3-beta.20260326022000",
3
+ "version": "0.2.3-beta.20260330020222",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {