@playcademy/vite-plugin 1.2.1-beta.8 → 1.2.1-beta.9

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.
Files changed (2) hide show
  1. package/dist/index.js +550 -335
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -24315,7 +24315,7 @@ import path2 from "node:path";
24315
24315
  // package.json
24316
24316
  var package_default = {
24317
24317
  name: "@playcademy/vite-plugin",
24318
- version: "1.2.1-beta.8",
24318
+ version: "1.2.1-beta.9",
24319
24319
  type: "module",
24320
24320
  exports: {
24321
24321
  ".": {
@@ -25073,7 +25073,7 @@ var init_timeback2 = __esm(() => {
25073
25073
  "Math",
25074
25074
  "None"
25075
25075
  ];
25076
- ASSESSMENT_PURPOSES = ["end_of_course", "diagnostic", "review"];
25076
+ ASSESSMENT_PURPOSES = ["end_of_course", "diagnostic", "review", "mastery"];
25077
25077
  TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS = {
25078
25078
  standards: 20,
25079
25079
  itemsPerStandard: 5,
@@ -25921,7 +25921,7 @@ var package_default2;
25921
25921
  var init_package = __esm(() => {
25922
25922
  package_default2 = {
25923
25923
  name: "@playcademy/sandbox",
25924
- version: "0.7.1-beta.8",
25924
+ version: "0.7.1-beta.9",
25925
25925
  description: "Local development server for Playcademy game development",
25926
25926
  type: "module",
25927
25927
  exports: {
@@ -35058,6 +35058,26 @@ function assessmentItemEarnedScore(interactionPoints, maxScore) {
35058
35058
  const earned = interactionPoints.reduce((sum, points) => sum + Math.max(0, points), 0);
35059
35059
  return Math.min(earned, maxScore);
35060
35060
  }
35061
+ function normalizeMasteryStandard(input) {
35062
+ const standard = canonicalReviewStandardRef(input);
35063
+ if (!standard) {
35064
+ throw new Error("Mastery quizzes require a canonical framework and identifier");
35065
+ }
35066
+ return standard;
35067
+ }
35068
+ function masteryRequestFingerprint(input) {
35069
+ return JSON.stringify({
35070
+ kind: "standard-quiz",
35071
+ standardKey: assessmentStandardRefKey(normalizeMasteryStandard(input.standard))
35072
+ });
35073
+ }
35074
+ function masteryStandardMatcher(requested) {
35075
+ const requestedKey = assessmentStandardRefKey(normalizeMasteryStandard(requested));
35076
+ return (authored) => {
35077
+ const canonicalAuthored = authored ? canonicalReviewStandardRef(authored) : null;
35078
+ return canonicalAuthored !== null && assessmentStandardRefKey(canonicalAuthored) === requestedKey;
35079
+ };
35080
+ }
35061
35081
  function isAssessmentScore(value) {
35062
35082
  return isRecord(value) && typeof value.earned === "number" && Number.isFinite(value.earned) && typeof value.possible === "number" && Number.isFinite(value.possible) && value.possible >= 0 && typeof value.normalized === "number" && value.normalized >= 0 && value.normalized <= 1;
35063
35083
  }
@@ -35077,14 +35097,18 @@ function isReviewItemOutcome(value) {
35077
35097
  function isReviewAttemptMetadata(value) {
35078
35098
  return isRecord(value) && typeof value.requestFingerprint === "string" && typeof value.bankRevision === "string" && Array.isArray(value.standards) && value.standards.every(isAssessmentStandardRef) && Number.isInteger(value.itemsPerStandard) && Array.isArray(value.selections) && value.selections.every((selection) => isRecord(selection) && isAssessmentStandardRef(selection.standard) && typeof selection.itemIdentifier === "string") && isReviewFulfillment(value.fulfillment);
35079
35099
  }
35100
+ function isMasteryAttemptMetadata(value) {
35101
+ return isRecord(value) && typeof value.requestFingerprint === "string" && isAssessmentStandardRef(value.standard);
35102
+ }
35080
35103
  function isPlaycademyAssessmentResultMetadataV1(value) {
35081
35104
  if (!isRecord(value)) {
35082
35105
  return false;
35083
35106
  }
35084
35107
  const metadata2 = value;
35085
35108
  const selectedTest = metadata2.selectedTest;
35109
+ const mastery = metadata2.mastery;
35086
35110
  const review = metadata2.review;
35087
- return metadata2.version === 1 && typeof metadata2.activityId === "string" && isAssessmentPurpose(metadata2.purpose) && typeof metadata2.courseId === "string" && typeof metadata2.integrationId === "string" && typeof metadata2.enrollmentId === "string" && Boolean(selectedTest) && typeof selectedTest?.identifier === "string" && typeof selectedTest.contentRevision === "string" && Number.isInteger(metadata2.attemptNumber) && Number.isInteger(metadata2.responseVersion) && Boolean(metadata2.responses) && typeof metadata2.responses === "object" && typeof metadata2.startedAt === "string" && typeof metadata2.updatedAt === "string" && (metadata2.purpose === "review" ? isReviewAttemptMetadata(review) : review === undefined) && (metadata2.submissionId === undefined || typeof metadata2.submissionId === "string") && (metadata2.score === undefined || isAssessmentScore(metadata2.score)) && (metadata2.completion === undefined || isRecord(metadata2.completion) && typeof metadata2.completion.testName === "string" && Number.isInteger(metadata2.completion.correctQuestions) && (metadata2.completion.totalQuestions === undefined || Number.isInteger(metadata2.completion.totalQuestions) && metadata2.completion.totalQuestions >= 0) && (metadata2.completion.itemOutcomes === undefined || metadata2.purpose === "review" && Array.isArray(metadata2.completion.itemOutcomes) && metadata2.completion.itemOutcomes.every(isReviewItemOutcome)));
35111
+ return metadata2.version === 1 && typeof metadata2.activityId === "string" && isAssessmentPurpose(metadata2.purpose) && typeof metadata2.courseId === "string" && typeof metadata2.integrationId === "string" && typeof metadata2.enrollmentId === "string" && Boolean(selectedTest) && typeof selectedTest?.identifier === "string" && typeof selectedTest.contentRevision === "string" && Number.isInteger(metadata2.attemptNumber) && Number.isInteger(metadata2.responseVersion) && Boolean(metadata2.responses) && typeof metadata2.responses === "object" && typeof metadata2.startedAt === "string" && typeof metadata2.updatedAt === "string" && (metadata2.purpose === "mastery" ? isMasteryAttemptMetadata(mastery) : mastery === undefined) && (metadata2.purpose === "review" ? isReviewAttemptMetadata(review) : review === undefined) && (metadata2.submissionId === undefined || typeof metadata2.submissionId === "string") && (metadata2.score === undefined || isAssessmentScore(metadata2.score)) && (metadata2.completion === undefined || isRecord(metadata2.completion) && typeof metadata2.completion.testName === "string" && Number.isInteger(metadata2.completion.correctQuestions) && (metadata2.completion.totalQuestions === undefined || Number.isInteger(metadata2.completion.totalQuestions) && metadata2.completion.totalQuestions >= 0) && (metadata2.completion.itemOutcomes === undefined || metadata2.purpose === "review" && Array.isArray(metadata2.completion.itemOutcomes) && metadata2.completion.itemOutcomes.every(isReviewItemOutcome)));
35088
35112
  }
35089
35113
  function isPlaycademyAssessmentItemResultMetadataV1(value) {
35090
35114
  if (!isRecord(value) || !isRecord(value.responses)) {
@@ -35174,11 +35198,12 @@ var RuntimeGradeSchema;
35174
35198
  var OptionalQueryGradeSchema;
35175
35199
  var AssessmentResponseValueSchema;
35176
35200
  var AssessmentRuntimeIdentitySchema;
35177
- var LatestAssessmentFiltersSchema;
35178
- var LatestRuntimeAssessmentQuerySchema;
35179
35201
  var ResponseKeySchema;
35180
35202
  var StartAssessmentBaseSchema;
35181
35203
  var AssessmentStandardRefSchema;
35204
+ var LatestAssessmentFilterBaseSchema;
35205
+ var LatestAssessmentFiltersSchema;
35206
+ var LatestRuntimeAssessmentQuerySchema;
35182
35207
  var StartAssessmentBodySchema;
35183
35208
  var SaveAssessmentBodySchema;
35184
35209
  var SubmitAssessmentBodySchema;
@@ -35396,12 +35421,6 @@ var init_assessment_runtime = __esm(() => {
35396
35421
  gameId: exports_external.string().uuid(),
35397
35422
  studentId: exports_external.string().trim().min(1)
35398
35423
  });
35399
- LatestAssessmentFiltersSchema = exports_external.object({
35400
- purpose: exports_external.enum(ASSESSMENT_PURPOSES),
35401
- subject: RuntimeSubjectSchema.optional(),
35402
- grade: OptionalQueryGradeSchema
35403
- });
35404
- LatestRuntimeAssessmentQuerySchema = AssessmentRuntimeIdentitySchema.extend(LatestAssessmentFiltersSchema.shape);
35405
35424
  ResponseKeySchema = exports_external.string().refine((key) => key.length > 0 && key.trim() === key, {
35406
35425
  message: "Response keys must be non-empty without surrounding whitespace"
35407
35426
  });
@@ -35416,7 +35435,21 @@ var init_assessment_runtime = __esm(() => {
35416
35435
  }).refine((standard) => {
35417
35436
  const canonical = canonicalAssessmentStandardRef(standard);
35418
35437
  return canonical.framework.length > 0 && canonical.identifier.length > 0;
35419
- }, { message: "Review standards require a canonical framework and identifier" });
35438
+ }, { message: "Assessment standards require a canonical framework and identifier" });
35439
+ LatestAssessmentFilterBaseSchema = exports_external.object({
35440
+ subject: RuntimeSubjectSchema.optional(),
35441
+ grade: OptionalQueryGradeSchema
35442
+ });
35443
+ LatestAssessmentFiltersSchema = exports_external.discriminatedUnion("purpose", [
35444
+ LatestAssessmentFilterBaseSchema.extend({
35445
+ purpose: exports_external.enum(["end_of_course", "diagnostic", "review"])
35446
+ }),
35447
+ LatestAssessmentFilterBaseSchema.extend({
35448
+ purpose: exports_external.literal("mastery"),
35449
+ standard: AssessmentStandardRefSchema
35450
+ })
35451
+ ]);
35452
+ LatestRuntimeAssessmentQuerySchema = exports_external.intersection(AssessmentRuntimeIdentitySchema, LatestAssessmentFiltersSchema);
35420
35453
  StartAssessmentBodySchema = exports_external.discriminatedUnion("purpose", [
35421
35454
  StartAssessmentBaseSchema.extend({
35422
35455
  purpose: exports_external.enum(["end_of_course", "diagnostic"])
@@ -35425,6 +35458,10 @@ var init_assessment_runtime = __esm(() => {
35425
35458
  purpose: exports_external.literal("review"),
35426
35459
  standards: exports_external.array(AssessmentStandardRefSchema).min(1).max(TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standards),
35427
35460
  itemsPerStandard: exports_external.number().int().positive().max(TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.itemsPerStandard).optional()
35461
+ }),
35462
+ StartAssessmentBaseSchema.extend({
35463
+ purpose: exports_external.literal("mastery"),
35464
+ standard: AssessmentStandardRefSchema
35428
35465
  })
35429
35466
  ]);
35430
35467
  SaveAssessmentBodySchema = exports_external.object({
@@ -39213,7 +39250,35 @@ var init_drizzle_orm = __esm(() => {
39213
39250
  init_view_common();
39214
39251
  });
39215
39252
  var init_alias2 = () => {};
39216
- var init_checks = () => {};
39253
+ function check(name2, value) {
39254
+ return new CheckBuilder(name2, value);
39255
+ }
39256
+ var CheckBuilder;
39257
+ var Check;
39258
+ var init_checks = __esm(() => {
39259
+ init_entity();
39260
+ CheckBuilder = class CheckBuilder2 {
39261
+ constructor(name2, value) {
39262
+ this.name = name2;
39263
+ this.value = value;
39264
+ }
39265
+ static [entityKind] = "PgCheckBuilder";
39266
+ brand;
39267
+ build(table2) {
39268
+ return new Check(table2, this);
39269
+ }
39270
+ };
39271
+ Check = class Check2 {
39272
+ constructor(table2, builder) {
39273
+ this.table = table2;
39274
+ this.name = builder.name;
39275
+ this.value = builder.value;
39276
+ }
39277
+ static [entityKind] = "PgCheck";
39278
+ name;
39279
+ value;
39280
+ };
39281
+ });
39217
39282
  var init_columns = __esm(() => {
39218
39283
  init_bigint();
39219
39284
  init_bigserial();
@@ -41657,11 +41722,22 @@ var init_table7 = __esm(() => {
41657
41722
  purpose: gameTimebackAssessmentPurposeEnum("purpose").notNull().default("end_of_course"),
41658
41723
  status: gameTimebackAssessmentStatusEnum("status").notNull().default("draft"),
41659
41724
  sortOrder: integer("sort_order"),
41725
+ standardFramework: text("standard_framework"),
41726
+ standardIdentifier: text("standard_identifier"),
41660
41727
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
41661
41728
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
41662
41729
  }, (table3) => [
41663
41730
  uniqueIndex("game_timeback_assessment_tests_integration_qti_idx").on(table3.integrationId, table3.qtiTestIdentifier),
41664
- uniqueIndex("game_timeback_assessment_tests_one_live_review_idx").on(table3.integrationId).where(sql`${table3.purpose} = 'review' AND ${table3.status} = 'live'`)
41731
+ uniqueIndex("game_timeback_assessment_tests_one_live_review_idx").on(table3.integrationId).where(sql`${table3.purpose} = 'review' AND ${table3.status} = 'live'`),
41732
+ check("game_timeback_assessment_tests_mastery_standard_check", sql`(
41733
+ (${table3.purpose}::text = 'mastery'
41734
+ AND NULLIF(BTRIM(${table3.standardFramework}), '') IS NOT NULL
41735
+ AND NULLIF(BTRIM(${table3.standardIdentifier}), '') IS NOT NULL)
41736
+ OR
41737
+ (${table3.purpose}::text <> 'mastery'
41738
+ AND ${table3.standardFramework} IS NULL
41739
+ AND ${table3.standardIdentifier} IS NULL)
41740
+ )`)
41665
41741
  ]);
41666
41742
  gameTimebackMetricDiscrepancyVerifications = pgTable("game_timeback_metric_discrepancy_verifications", {
41667
41743
  id: uuid("id").primaryKey().defaultRandom(),
@@ -63932,6 +64008,15 @@ function isValidAdminAttributionDate(value) {
63932
64008
  const date3 = new Date(Date.UTC(year, month - 1, day, 12, 0, 0));
63933
64009
  return date3.getUTCFullYear() === year && date3.getUTCMonth() + 1 === month && date3.getUTCDate() === day;
63934
64010
  }
64011
+ function requireMasteryStandard(input, context2) {
64012
+ if (input.purpose === "mastery" && input.standard === undefined) {
64013
+ context2.addIssue({
64014
+ code: "custom",
64015
+ path: ["standard"],
64016
+ message: "Mastery assessments require a standard"
64017
+ });
64018
+ }
64019
+ }
63935
64020
  var TimebackGradeSchema;
63936
64021
  var TimebackSubjectSchema;
63937
64022
  var CourseGoalsSchema;
@@ -63964,6 +64049,7 @@ var ReactivateEnrollmentRequestSchema;
63964
64049
  var VerifyTimebackMetricDiscrepancyRequestSchema;
63965
64050
  var AssessmentPurposeSchema;
63966
64051
  var AssessmentStatusSchema;
64052
+ var AssessmentStandardRefSchema2;
63967
64053
  var CreateAssessmentRequestSchema;
63968
64054
  var UpdateAssessmentRequestSchema;
63969
64055
  var CopyAssessmentRequestSchema;
@@ -64213,21 +64299,28 @@ var init_schemas4 = __esm(() => {
64213
64299
  });
64214
64300
  AssessmentPurposeSchema = exports_external.enum(gameTimebackAssessmentPurposeEnum.enumValues);
64215
64301
  AssessmentStatusSchema = exports_external.enum(gameTimebackAssessmentStatusEnum.enumValues);
64302
+ AssessmentStandardRefSchema2 = exports_external.object({
64303
+ framework: exports_external.string().trim().min(1).max(TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standardFieldLength),
64304
+ identifier: exports_external.string().trim().min(1).max(TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standardFieldLength)
64305
+ });
64216
64306
  CreateAssessmentRequestSchema = exports_external.object({
64217
64307
  title: exports_external.string().min(1, "Assessment title is required"),
64218
- purpose: AssessmentPurposeSchema
64219
- });
64308
+ purpose: AssessmentPurposeSchema,
64309
+ standard: AssessmentStandardRefSchema2.optional()
64310
+ }).superRefine(requireMasteryStandard);
64220
64311
  UpdateAssessmentRequestSchema = exports_external.object({
64221
64312
  title: exports_external.string().trim().min(1, "Assessment title is required").optional(),
64222
64313
  purpose: AssessmentPurposeSchema.optional(),
64314
+ standard: AssessmentStandardRefSchema2.optional(),
64223
64315
  status: AssessmentStatusSchema.optional()
64224
- }).refine((input) => input.title !== undefined || input.purpose !== undefined || input.status !== undefined, {
64225
- message: "Title, purpose, or status is required"
64316
+ }).refine((input) => input.title !== undefined || input.purpose !== undefined || input.standard !== undefined || input.status !== undefined, {
64317
+ message: "Title, purpose, standard, or status is required"
64226
64318
  });
64227
64319
  CopyAssessmentRequestSchema = exports_external.object({
64228
64320
  testIdentifier: exports_external.string().trim().min(1, "Assessment identifier is required"),
64229
- purpose: AssessmentPurposeSchema
64230
- });
64321
+ purpose: AssessmentPurposeSchema,
64322
+ standard: AssessmentStandardRefSchema2.optional()
64323
+ }).superRefine(requireMasteryStandard);
64231
64324
  ReorderAssessmentsRequestSchema = exports_external.object({
64232
64325
  purpose: AssessmentPurposeSchema,
64233
64326
  testIdentifiers: exports_external.array(exports_external.string().trim().min(1, "Assessment identifier is required")).min(1, "At least one assessment is required")
@@ -76519,7 +76612,7 @@ function promise(innerType) {
76519
76612
  innerType
76520
76613
  });
76521
76614
  }
76522
- function check(fn, params) {
76615
+ function check2(fn, params) {
76523
76616
  const ch = new $ZodCheck({
76524
76617
  check: "custom",
76525
76618
  ...exports_util.normalizeParams(params)
@@ -76534,7 +76627,7 @@ function refine(fn, _params = {}) {
76534
76627
  return _refine(ZodCustom, fn, _params);
76535
76628
  }
76536
76629
  function superRefine(fn, params) {
76537
- const ch = check((payload) => {
76630
+ const ch = check2((payload) => {
76538
76631
  payload.addIssue = (issue3) => {
76539
76632
  if (typeof issue3 === "string") {
76540
76633
  payload.issues.push(exports_util.issue(issue3, payload.value, ch._zod.def));
@@ -76673,7 +76766,7 @@ var init_schemas6 = __esm(() => {
76673
76766
  inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
76674
76767
  inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
76675
76768
  inst.spa = inst.safeParseAsync;
76676
- inst.refine = (check2, params) => inst.check(refine(check2, params));
76769
+ inst.refine = (check22, params) => inst.check(refine(check22, params));
76677
76770
  inst.superRefine = (refinement) => inst.check(superRefine(refinement));
76678
76771
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
76679
76772
  inst.optional = () => optional(inst);
@@ -77349,7 +77442,7 @@ __export(exports_external2, {
77349
77442
  clone: () => clone,
77350
77443
  cidrv6: () => cidrv62,
77351
77444
  cidrv4: () => cidrv42,
77352
- check: () => check,
77445
+ check: () => check2,
77353
77446
  catch: () => _catch2,
77354
77447
  boolean: () => boolean4,
77355
77448
  bigint: () => bigint4,
@@ -98767,7 +98860,7 @@ __export(exports_schemas4, {
98767
98860
  codec: () => codec,
98768
98861
  cidrv6: () => cidrv64,
98769
98862
  cidrv4: () => cidrv44,
98770
- check: () => check2,
98863
+ check: () => check3,
98771
98864
  catch: () => _catch4,
98772
98865
  boolean: () => boolean7,
98773
98866
  bigint: () => bigint7,
@@ -99307,7 +99400,7 @@ function _function2(params) {
99307
99400
  output: params?.output ?? unknown2()
99308
99401
  });
99309
99402
  }
99310
- function check2(fn) {
99403
+ function check3(fn) {
99311
99404
  const ch = new $ZodCheck2({
99312
99405
  check: "custom"
99313
99406
  });
@@ -99493,8 +99586,8 @@ var init_schemas8 = __esm(() => {
99493
99586
  reg.add(this, meta22);
99494
99587
  return this;
99495
99588
  },
99496
- refine(check22, params) {
99497
- return this.check(refine2(check22, params));
99589
+ refine(check32, params) {
99590
+ return this.check(refine2(check32, params));
99498
99591
  },
99499
99592
  superRefine(refinement, params) {
99500
99593
  return this.check(superRefine2(refinement, params));
@@ -100891,7 +100984,7 @@ __export(exports_external3, {
100891
100984
  clone: () => clone2,
100892
100985
  cidrv6: () => cidrv64,
100893
100986
  cidrv4: () => cidrv44,
100894
- check: () => check2,
100987
+ check: () => check3,
100895
100988
  catch: () => _catch4,
100896
100989
  boolean: () => boolean7,
100897
100990
  bigint: () => bigint7,
@@ -108827,6 +108920,9 @@ function assessmentPurposeClassificationFields(purpose, input) {
108827
108920
  case "review": {
108828
108921
  return {};
108829
108922
  }
108923
+ case "mastery": {
108924
+ return {};
108925
+ }
108830
108926
  }
108831
108927
  }
108832
108928
  function buildAssessmentCompletionMetadata(input) {
@@ -110983,6 +111079,9 @@ function assessmentPurposeClassificationFields2(purpose, input) {
110983
111079
  case "review": {
110984
111080
  return {};
110985
111081
  }
111082
+ case "mastery": {
111083
+ return {};
111084
+ }
110986
111085
  }
110987
111086
  }
110988
111087
  function deriveSourcedIds2(courseId) {
@@ -116313,6 +116412,103 @@ var init_timeback_admin_service = __esm(async () => {
116313
116412
  init_timeback_mastery_completion_util()
116314
116413
  ]);
116315
116414
  });
116415
+ function validateAssessmentStatusTransition(current, next) {
116416
+ if (current === next) {
116417
+ return;
116418
+ }
116419
+ const allowed = current === "draft" && next === "live" || current === "live" && next === "archived" || current === "archived" && next === "live";
116420
+ if (!allowed) {
116421
+ throw new ValidationError(`Assessment status cannot change from ${current} to ${next}`);
116422
+ }
116423
+ }
116424
+ function isAssessmentPublicationTransition(current, next) {
116425
+ return current !== "live" && next === "live";
116426
+ }
116427
+ function assertDraftAssessment(row) {
116428
+ if (row.status !== "draft") {
116429
+ throw new ValidationError("Only draft assessments can change QTI content or question membership");
116430
+ }
116431
+ }
116432
+ function assertMasteryPurposeChangeDraft(row, nextPurpose) {
116433
+ if (row.purpose !== nextPurpose && (row.purpose === "mastery" || nextPurpose === "mastery") && row.status !== "draft") {
116434
+ throw new ValidationError("Only draft assessments can change to or from mastery");
116435
+ }
116436
+ }
116437
+ function assertAllAssessmentAssociationsDraft(rows) {
116438
+ if (rows.some((row) => row.status !== "draft")) {
116439
+ throw new ValidationError("QTI content cannot change while any associated assessment is live or archived");
116440
+ }
116441
+ }
116442
+ function assertAssessmentHasQuestions(questions) {
116443
+ if (questions.length === 0) {
116444
+ throw new ValidationError("An assessment must contain at least one question to publish");
116445
+ }
116446
+ }
116447
+ function assertReviewAssessmentHasStandards(standardCounts) {
116448
+ if (standardCounts.some((count) => count <= 0)) {
116449
+ throw new ValidationError("Every question in a review assessment must have a standards alignment");
116450
+ }
116451
+ }
116452
+ function planAssessmentRemoval(status) {
116453
+ if (status === "draft") {
116454
+ return { kind: "delete", action: "discarded", operation: "discard_draft" };
116455
+ }
116456
+ if (status === "live") {
116457
+ return { kind: "archive", action: "archived", operation: "archive" };
116458
+ }
116459
+ return { kind: "none", action: "archived" };
116460
+ }
116461
+ function buildAssessmentAssociationUpdates(row, input) {
116462
+ const updates = {};
116463
+ if (input.purpose !== undefined) {
116464
+ updates.purpose = input.purpose;
116465
+ if (input.purpose !== "mastery" && (row.purpose === "mastery" || row.standardFramework || row.standardIdentifier)) {
116466
+ updates.standardFramework = null;
116467
+ updates.standardIdentifier = null;
116468
+ }
116469
+ if (row.status === "live" && input.purpose !== row.purpose) {
116470
+ updates.sortOrder = null;
116471
+ }
116472
+ }
116473
+ if (input.standard !== undefined) {
116474
+ updates.standardFramework = input.standard.framework;
116475
+ updates.standardIdentifier = input.standard.identifier;
116476
+ }
116477
+ if (input.status !== undefined) {
116478
+ updates.status = input.status;
116479
+ if (input.status === "archived") {
116480
+ updates.sortOrder = null;
116481
+ }
116482
+ }
116483
+ return updates;
116484
+ }
116485
+ function assessmentStandardForRow(row) {
116486
+ return row.standardFramework && row.standardIdentifier ? { framework: row.standardFramework, identifier: row.standardIdentifier } : null;
116487
+ }
116488
+ function validateUniqueAssessmentIdentifiers(testIdentifiers) {
116489
+ if (new Set(testIdentifiers).size !== testIdentifiers.length) {
116490
+ throw new ValidationError("Assessment order must contain unique identifiers");
116491
+ }
116492
+ }
116493
+ function assertAssessmentOrderUpdateSucceeded(updatedRow) {
116494
+ if (!updatedRow) {
116495
+ throw new ValidationError("Assessment order changed while it was being saved. Refresh and try again.");
116496
+ }
116497
+ return updatedRow;
116498
+ }
116499
+ function lockOrderAssessmentRows(rows) {
116500
+ return rows.toSorted((left, right) => left.id.localeCompare(right.id));
116501
+ }
116502
+ function orderLiveAssessmentRows(liveRows, purpose, testIdentifiers) {
116503
+ const rowsByIdentifier = new Map(liveRows.map((row) => [row.qtiTestIdentifier, row]));
116504
+ if (liveRows.length !== testIdentifiers.length || testIdentifiers.some((identifier) => !rowsByIdentifier.has(identifier))) {
116505
+ throw new ValidationError(`Assessment order must include every live ${purpose} assessment exactly once`);
116506
+ }
116507
+ return testIdentifiers.map((identifier) => rowsByIdentifier.get(identifier));
116508
+ }
116509
+ var init_timeback_assessment_rules_util = __esm(() => {
116510
+ init_errors2();
116511
+ });
116316
116512
  var PLAYABLE_ASSESSMENT_SHAPES;
116317
116513
  var init_assessment_runtime2 = __esm(() => {
116318
116514
  PLAYABLE_ASSESSMENT_SHAPES = ["circle", "ellipse", "rect", "poly", "default"];
@@ -116856,6 +117052,8 @@ class TimebackAssessmentRuntimeService {
116856
117052
  if (input.purpose === "review") {
116857
117053
  return this.startReview({ gameId, studentId, input, user });
116858
117054
  }
117055
+ const masteryStandard = input.purpose === "mastery" ? normalizeMasteryStandard(input.standard) : undefined;
117056
+ const requestFingerprint = this.startRequestFingerprint(input);
116859
117057
  const candidates = await this.candidateIntegrations(gameId, studentId, input);
116860
117058
  const lockKeys = candidates.rows.map((row) => assessmentRuntimeStartLockKey({
116861
117059
  studentId,
@@ -116874,18 +117072,20 @@ class TimebackAssessmentRuntimeService {
116874
117072
  enrollmentId: context2.enrollment.id
116875
117073
  };
116876
117074
  const [tests, listing] = await Promise.all([
116877
- this.liveTests(context2.integration.id, input.purpose, db2),
117075
+ this.liveTests(context2.integration.id, input.purpose, db2, masteryStandard),
116878
117076
  this.listAttempts(attemptScope)
116879
117077
  ]);
116880
117078
  const attempts = listing.attempts;
116881
- let decision = this.requireDecision(selectRuntimeAssessment(tests, [...attempts.values()].map((entry2) => entry2.selection)), input.purpose);
117079
+ const compatibleAttempts = this.attemptsMatchingRequest(attempts, requestFingerprint);
117080
+ let decision = this.requireDecision(selectRuntimeAssessment(tests, [...compatibleAttempts.values()].map((entry2) => entry2.selection)), input.purpose);
116882
117081
  if (decision.kind === "resume") {
116883
117082
  return this.resumeSnapshot(decision, attempts);
116884
117083
  }
116885
117084
  let assessment = await this.loadAssessment(decision.test.qtiTestIdentifier);
116886
117085
  const refreshedListing = await this.listAttempts(attemptScope);
116887
117086
  const refreshed = refreshedListing.attempts;
116888
- const refreshedDecision = this.requireDecision(selectRuntimeAssessment(tests, [...refreshed.values()].map((entry2) => entry2.selection)), input.purpose);
117087
+ const refreshedCompatible = this.attemptsMatchingRequest(refreshed, requestFingerprint);
117088
+ const refreshedDecision = this.requireDecision(selectRuntimeAssessment(tests, [...refreshedCompatible.values()].map((entry2) => entry2.selection)), input.purpose);
116889
117089
  if (refreshedDecision.kind === "resume") {
116890
117090
  return this.resumeSnapshot(refreshedDecision, refreshed);
116891
117091
  }
@@ -116908,10 +117108,9 @@ class TimebackAssessmentRuntimeService {
116908
117108
  purpose: input.purpose
116909
117109
  }, Math.max(0, ...[...refreshed.values()].map((entry2) => entry2.metadata.attemptNumber)) + 1);
116910
117110
  const timestamp6 = new Date().toISOString();
116911
- const metadata2 = {
117111
+ const metadataBase = {
116912
117112
  version: PLAYCADEMY_ASSESSMENT_RESULT_METADATA_VERSION,
116913
117113
  activityId: input.activityId,
116914
- purpose: input.purpose,
116915
117114
  courseId: context2.integration.courseId,
116916
117115
  integrationId: context2.integration.id,
116917
117116
  enrollmentId: context2.enrollment.id,
@@ -116925,6 +117124,14 @@ class TimebackAssessmentRuntimeService {
116925
117124
  startedAt: timestamp6,
116926
117125
  updatedAt: timestamp6
116927
117126
  };
117127
+ const metadata2 = input.purpose === "mastery" ? {
117128
+ ...metadataBase,
117129
+ purpose: input.purpose,
117130
+ mastery: {
117131
+ requestFingerprint,
117132
+ standard: masteryStandard
117133
+ }
117134
+ } : { ...metadataBase, purpose: input.purpose };
116928
117135
  const result = await this.requireClient().api.oneroster.assessmentResults.upsert(attemptId, {
116929
117136
  status: ONEROSTER_STATUS2.active,
116930
117137
  assessmentLineItem: { sourcedId: lineItemId },
@@ -116971,7 +117178,7 @@ class TimebackAssessmentRuntimeService {
116971
117178
  this.listAttempts(attemptScope)
116972
117179
  ]);
116973
117180
  const attempts = listing.attempts;
116974
- const compatible = this.compatibleReviewAttempts(attempts, requestFingerprint);
117181
+ const compatible = this.attemptsMatchingRequest(attempts, requestFingerprint);
116975
117182
  let decision = selectRuntimeAssessment(tests, [...compatible.values()].map((entry2) => entry2.selection));
116976
117183
  if (decision?.kind === "resume") {
116977
117184
  return this.resumeReviewSnapshot(decision, compatible, listing.reviewChildren, context2);
@@ -116985,7 +117192,7 @@ class TimebackAssessmentRuntimeService {
116985
117192
  let source = await this.loadReviewBank(decision.test.qtiTestIdentifier);
116986
117193
  const refreshedListing = await this.listAttempts(attemptScope);
116987
117194
  const refreshed = refreshedListing.attempts;
116988
- const refreshedCompatible = this.compatibleReviewAttempts(refreshed, requestFingerprint);
117195
+ const refreshedCompatible = this.attemptsMatchingRequest(refreshed, requestFingerprint);
116989
117196
  const refreshedDecision = selectRuntimeAssessment(tests, [...refreshedCompatible.values()].map((entry2) => entry2.selection));
116990
117197
  if (refreshedDecision?.kind === "resume") {
116991
117198
  return this.resumeReviewSnapshot(refreshedDecision, refreshedCompatible, refreshedListing.reviewChildren, context2);
@@ -117086,7 +117293,8 @@ class TimebackAssessmentRuntimeService {
117086
117293
  user,
117087
117294
  purpose,
117088
117295
  subject,
117089
- grade
117296
+ grade,
117297
+ standard
117090
117298
  }) {
117091
117299
  await this.deps.validateDeveloperAccess(user, gameId);
117092
117300
  const integrations = await this.deps.db.query.gameTimebackIntegrations.findMany({
@@ -117114,10 +117322,11 @@ class TimebackAssessmentRuntimeService {
117114
117322
  sort: "scoreDate",
117115
117323
  orderBy: "desc"
117116
117324
  });
117325
+ const matchesMasteryStandard = purpose === "mastery" && standard !== undefined ? masteryStandardMatcher(standard) : undefined;
117117
117326
  const latest = await findLatestAssessmentResult(results, (result) => {
117118
117327
  const metadata2 = playcademyAssessmentResultMetadata(result.metadata);
117119
117328
  const integration2 = metadata2 ? matchingIntegrations.get(metadata2.integrationId) : undefined;
117120
- return metadata2 && metadata2.purpose === purpose && integration2 && metadata2.courseId === integration2.courseId && result.student.sourcedId === studentId && this.isCompleted(result) ? metadata2 : null;
117329
+ return metadata2 && metadata2.purpose === purpose && (metadata2.purpose !== "mastery" || matchesMasteryStandard !== undefined && matchesMasteryStandard(metadata2.mastery.standard)) && integration2 && metadata2.courseId === integration2.courseId && result.student.sourcedId === studentId && this.isCompleted(result) ? metadata2 : null;
117121
117330
  });
117122
117331
  if (!latest) {
117123
117332
  return null;
@@ -117131,6 +117340,7 @@ class TimebackAssessmentRuntimeService {
117131
117340
  subject: integration.subject,
117132
117341
  grade: integration.grade,
117133
117342
  testIdentifier: latest.match.selectedTest.identifier,
117343
+ standard: latest.match.purpose === "mastery" ? latest.match.mastery.standard : null,
117134
117344
  completedAt: latest.result.scoreDate,
117135
117345
  score: { normalized: score.normalized }
117136
117346
  };
@@ -117399,7 +117609,7 @@ class TimebackAssessmentRuntimeService {
117399
117609
  });
117400
117610
  const catalogs = loadedCatalogs.filter((catalog) => catalog !== null);
117401
117611
  return {
117402
- version: 4,
117612
+ version: 5,
117403
117613
  gameId,
117404
117614
  exportedAt: new Date().toISOString(),
117405
117615
  catalogs
@@ -117434,9 +117644,14 @@ class TimebackAssessmentRuntimeService {
117434
117644
  const candidateRows = integrations.filter((integration) => enrollmentByCourse.has(integration.courseId));
117435
117645
  const liveTestRows = candidateRows.length === 0 ? [] : await db2.query.gameTimebackAssessmentTests.findMany({
117436
117646
  where: and(inArray(gameTimebackAssessmentTests.integrationId, candidateRows.map((row) => row.id)), eq(gameTimebackAssessmentTests.purpose, input.purpose), eq(gameTimebackAssessmentTests.status, "live")),
117437
- columns: { integrationId: true }
117647
+ columns: {
117648
+ integrationId: true,
117649
+ standardFramework: true,
117650
+ standardIdentifier: true
117651
+ }
117438
117652
  });
117439
- const integrationIdsWithLiveTests = new Set(liveTestRows.map((row) => row.integrationId));
117653
+ const matchesMasteryStandard = input.purpose === "mastery" ? masteryStandardMatcher(input.standard) : undefined;
117654
+ const integrationIdsWithLiveTests = new Set(liveTestRows.filter((row) => !matchesMasteryStandard || matchesMasteryStandard(assessmentStandardForRow(row))).map((row) => row.integrationId));
117440
117655
  return {
117441
117656
  rows: candidateRows,
117442
117657
  enrollmentByCourse,
@@ -117458,7 +117673,7 @@ class TimebackAssessmentRuntimeService {
117458
117673
  row.courseId,
117459
117674
  enrollmentByCourse.get(row.courseId).id
117460
117675
  ])),
117461
- requestFingerprint: input.purpose === "review" ? reviewRequestFingerprint(input, DEFAULT_REVIEW_SELECTION_POLICY) : undefined
117676
+ requestFingerprint: this.startRequestFingerprint(input)
117462
117677
  }) : new Set;
117463
117678
  const annotated = candidateRows.map((row) => ({
117464
117679
  ...row,
@@ -117484,7 +117699,8 @@ class TimebackAssessmentRuntimeService {
117484
117699
  const acquire = (index2, db2) => index2 === keys.length ? operation(db2) : this.deps.assessmentRuntimeLock(db2, keys[index2], (nested) => acquire(index2 + 1, nested));
117485
117700
  return acquire(0, this.deps.db);
117486
117701
  }
117487
- async liveTests(integrationId, purpose, db2 = this.deps.db) {
117702
+ async liveTests(integrationId, purpose, db2 = this.deps.db, requestedStandard) {
117703
+ const matchesMasteryStandard = requestedStandard ? masteryStandardMatcher(requestedStandard) : undefined;
117488
117704
  const rows = await db2.query.gameTimebackAssessmentTests.findMany({
117489
117705
  where: and(eq(gameTimebackAssessmentTests.integrationId, integrationId), eq(gameTimebackAssessmentTests.purpose, purpose), eq(gameTimebackAssessmentTests.status, "live"))
117490
117706
  });
@@ -117492,8 +117708,9 @@ class TimebackAssessmentRuntimeService {
117492
117708
  id: row.id,
117493
117709
  qtiTestIdentifier: row.qtiTestIdentifier,
117494
117710
  sortOrder: row.sortOrder,
117495
- updatedAt: row.updatedAt.toISOString()
117496
- }));
117711
+ updatedAt: row.updatedAt.toISOString(),
117712
+ standard: assessmentStandardForRow(row)
117713
+ })).filter((test) => !matchesMasteryStandard || matchesMasteryStandard(test.standard));
117497
117714
  }
117498
117715
  async openAttemptCourseIds(scope) {
117499
117716
  const results = this.requireClient().api.oneroster.assessmentResults.stream({
@@ -117505,7 +117722,7 @@ class TimebackAssessmentRuntimeService {
117505
117722
  const courseIds = new Set;
117506
117723
  for await (const result of results) {
117507
117724
  const metadata2 = playcademyAssessmentResultMetadata(result.metadata);
117508
- if (metadata2 && metadata2.activityId === scope.activityId && metadata2.purpose === scope.purpose && (metadata2.purpose !== "review" || metadata2.review.requestFingerprint === scope.requestFingerprint) && result.student.sourcedId === scope.studentId && metadata2.enrollmentId === scope.enrollmentIdByCourse.get(metadata2.courseId) && isAssessmentAttemptOpen({
117725
+ if (metadata2 && metadata2.activityId === scope.activityId && metadata2.purpose === scope.purpose && this.attemptMatchesRequestFingerprint(metadata2, scope.requestFingerprint) && result.student.sourcedId === scope.studentId && metadata2.enrollmentId === scope.enrollmentIdByCourse.get(metadata2.courseId) && isAssessmentAttemptOpen({
117509
117726
  inProgress: result.inProgress ?? "",
117510
117727
  scoreStatus: result.scoreStatus
117511
117728
  })) {
@@ -117547,8 +117764,26 @@ class TimebackAssessmentRuntimeService {
117547
117764
  }
117548
117765
  return { attempts, reviewChildren };
117549
117766
  }
117550
- compatibleReviewAttempts(attempts, requestFingerprint) {
117551
- return new Map([...attempts].filter(([, attempt]) => attempt.metadata.purpose === "review" && attempt.metadata.review.requestFingerprint === requestFingerprint));
117767
+ attemptsMatchingRequest(attempts, requestFingerprint) {
117768
+ if (requestFingerprint === undefined) {
117769
+ return attempts;
117770
+ }
117771
+ return new Map([...attempts].filter(([, attempt]) => this.attemptMatchesRequestFingerprint(attempt.metadata, requestFingerprint)));
117772
+ }
117773
+ startRequestFingerprint(input) {
117774
+ if (input.purpose === "review") {
117775
+ return reviewRequestFingerprint(input, DEFAULT_REVIEW_SELECTION_POLICY);
117776
+ }
117777
+ return input.purpose === "mastery" ? masteryRequestFingerprint(input) : undefined;
117778
+ }
117779
+ attemptMatchesRequestFingerprint(metadata2, requestFingerprint) {
117780
+ if (metadata2.purpose === "review") {
117781
+ return metadata2.review.requestFingerprint === requestFingerprint;
117782
+ }
117783
+ if (metadata2.purpose === "mastery") {
117784
+ return metadata2.mastery.requestFingerprint === requestFingerprint;
117785
+ }
117786
+ return true;
117552
117787
  }
117553
117788
  reviewExposures(results, scope) {
117554
117789
  const exposures = [];
@@ -117985,6 +118220,7 @@ class TimebackAssessmentRuntimeService {
117985
118220
  }
117986
118221
  snapshot(result, metadata2, assessment) {
117987
118222
  const completed = this.isCompleted(result);
118223
+ const selection = this.selectionContext(metadata2);
117988
118224
  return {
117989
118225
  attemptId: result.sourcedId,
117990
118226
  responseVersion: metadata2.responseVersion,
@@ -117992,18 +118228,28 @@ class TimebackAssessmentRuntimeService {
117992
118228
  assessment: assessmentPresentationForAttempt(assessment, result.sourcedId),
117993
118229
  responses: metadata2.responses,
117994
118230
  score: completed ? this.scoreFromResult(result, assessmentPossibleScore(assessment), metadata2) : null,
117995
- selection: metadata2.purpose === "review" ? {
118231
+ selection
118232
+ };
118233
+ }
118234
+ selectionContext(metadata2) {
118235
+ if (metadata2.purpose === "review") {
118236
+ return {
117996
118237
  kind: "standards-review",
117997
118238
  purpose: metadata2.purpose,
117998
118239
  standards: [...metadata2.review.standards],
117999
118240
  itemsPerStandard: metadata2.review.itemsPerStandard,
118000
118241
  selections: [...metadata2.review.selections],
118001
118242
  fulfillment: metadata2.review.fulfillment
118002
- } : {
118003
- kind: "fixed-test",
118004
- purpose: metadata2.purpose
118005
- }
118006
- };
118243
+ };
118244
+ }
118245
+ if (metadata2.purpose === "mastery") {
118246
+ return {
118247
+ kind: "standard-quiz",
118248
+ purpose: metadata2.purpose,
118249
+ standard: metadata2.mastery.standard
118250
+ };
118251
+ }
118252
+ return { kind: "fixed-test", purpose: metadata2.purpose };
118007
118253
  }
118008
118254
  completedResult(result, metadata2) {
118009
118255
  const response = buildCompletedAssessmentSubmitResult({
@@ -118154,6 +118400,7 @@ var init_timeback_assessment_runtime_service = __esm(async () => {
118154
118400
  init_uuid();
118155
118401
  init_errors2();
118156
118402
  init_assessment_runtime_lock_util();
118403
+ init_timeback_assessment_rules_util();
118157
118404
  init_timeback_assessment_runtime_util();
118158
118405
  init_timeback_qti_hydration_util();
118159
118406
  await __promiseAll([
@@ -118161,87 +118408,6 @@ var init_timeback_assessment_runtime_service = __esm(async () => {
118161
118408
  init_errors8()
118162
118409
  ]);
118163
118410
  });
118164
- function validateAssessmentStatusTransition(current, next) {
118165
- if (current === next) {
118166
- return;
118167
- }
118168
- const allowed = current === "draft" && next === "live" || current === "live" && next === "archived" || current === "archived" && next === "live";
118169
- if (!allowed) {
118170
- throw new ValidationError(`Assessment status cannot change from ${current} to ${next}`);
118171
- }
118172
- }
118173
- function isAssessmentPublicationTransition(current, next) {
118174
- return current !== "live" && next === "live";
118175
- }
118176
- function assertDraftAssessment(row) {
118177
- if (row.status !== "draft") {
118178
- throw new ValidationError("Only draft assessments can change QTI content or question membership");
118179
- }
118180
- }
118181
- function assertAllAssessmentAssociationsDraft(rows) {
118182
- if (rows.some((row) => row.status !== "draft")) {
118183
- throw new ValidationError("QTI content cannot change while any associated assessment is live or archived");
118184
- }
118185
- }
118186
- function assertAssessmentHasQuestions(questions) {
118187
- if (questions.length === 0) {
118188
- throw new ValidationError("An assessment must contain at least one question to publish");
118189
- }
118190
- }
118191
- function assertReviewAssessmentHasStandards(standardCounts) {
118192
- if (standardCounts.some((count) => count <= 0)) {
118193
- throw new ValidationError("Every question in a review assessment must have a standards alignment");
118194
- }
118195
- }
118196
- function planAssessmentRemoval(status) {
118197
- if (status === "draft") {
118198
- return { kind: "delete", action: "discarded", operation: "discard_draft" };
118199
- }
118200
- if (status === "live") {
118201
- return { kind: "archive", action: "archived", operation: "archive" };
118202
- }
118203
- return { kind: "none", action: "archived" };
118204
- }
118205
- function buildAssessmentAssociationUpdates(row, input) {
118206
- const updates = {};
118207
- if (input.purpose !== undefined) {
118208
- updates.purpose = input.purpose;
118209
- if (row.status === "live" && input.purpose !== row.purpose) {
118210
- updates.sortOrder = null;
118211
- }
118212
- }
118213
- if (input.status !== undefined) {
118214
- updates.status = input.status;
118215
- if (input.status === "archived") {
118216
- updates.sortOrder = null;
118217
- }
118218
- }
118219
- return updates;
118220
- }
118221
- function validateUniqueAssessmentIdentifiers(testIdentifiers) {
118222
- if (new Set(testIdentifiers).size !== testIdentifiers.length) {
118223
- throw new ValidationError("Assessment order must contain unique identifiers");
118224
- }
118225
- }
118226
- function assertAssessmentOrderUpdateSucceeded(updatedRow) {
118227
- if (!updatedRow) {
118228
- throw new ValidationError("Assessment order changed while it was being saved. Refresh and try again.");
118229
- }
118230
- return updatedRow;
118231
- }
118232
- function lockOrderAssessmentRows(rows) {
118233
- return rows.toSorted((left, right) => left.id.localeCompare(right.id));
118234
- }
118235
- function orderLiveAssessmentRows(liveRows, purpose, testIdentifiers) {
118236
- const rowsByIdentifier = new Map(liveRows.map((row) => [row.qtiTestIdentifier, row]));
118237
- if (liveRows.length !== testIdentifiers.length || testIdentifiers.some((identifier) => !rowsByIdentifier.has(identifier))) {
118238
- throw new ValidationError(`Assessment order must include every live ${purpose} assessment exactly once`);
118239
- }
118240
- return testIdentifiers.map((identifier) => rowsByIdentifier.get(identifier));
118241
- }
118242
- var init_timeback_assessment_rules_util = __esm(() => {
118243
- init_errors2();
118244
- });
118245
118411
  function recordValue(value) {
118246
118412
  return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
118247
118413
  }
@@ -119171,6 +119337,7 @@ class TimebackAssessmentsService {
119171
119337
  const client2 = this.requireClient();
119172
119338
  const ownership = await this.requireQtiTestOwnershipContext(integrationId);
119173
119339
  const { integration } = ownership;
119340
+ const standard = this.requirePurposeStandard(input.purpose, input.standard);
119174
119341
  await client2.course.createAssessmentTest({
119175
119342
  identifier: input.qtiTestIdentifier,
119176
119343
  title: input.title,
@@ -119187,10 +119354,15 @@ class TimebackAssessmentsService {
119187
119354
  integrationId,
119188
119355
  qtiTestIdentifier: input.qtiTestIdentifier,
119189
119356
  purpose: input.purpose,
119190
- status: "draft"
119357
+ status: "draft",
119358
+ standardFramework: standard?.framework,
119359
+ standardIdentifier: standard?.identifier
119191
119360
  }).returning();
119361
+ if (!row) {
119362
+ throw new Error("Assessment association create returned no row");
119363
+ }
119192
119364
  setAttribute("app.assessment.operation", "create");
119193
- return row;
119365
+ return this.associationSummary(row);
119194
119366
  } catch (error88) {
119195
119367
  let committedRow;
119196
119368
  try {
@@ -119207,7 +119379,7 @@ class TimebackAssessmentsService {
119207
119379
  }
119208
119380
  if (committedRow) {
119209
119381
  setAttribute("app.assessment.operation", "create");
119210
- return committedRow;
119382
+ return this.associationSummary(committedRow);
119211
119383
  }
119212
119384
  try {
119213
119385
  await client2.qtiApi.assessmentTests.delete(input.qtiTestIdentifier);
@@ -119226,8 +119398,18 @@ class TimebackAssessmentsService {
119226
119398
  async updateAssessment(integrationId, qtiTestIdentifier, input) {
119227
119399
  try {
119228
119400
  return await this.withLockedAssessmentAssociations(integrationId, qtiTestIdentifier, async (row, tx, associations) => {
119229
- const updates = buildAssessmentAssociationUpdates(row, input);
119230
119401
  const nextPurpose = input.purpose ?? row.purpose;
119402
+ assertMasteryPurposeChangeDraft(row, nextPurpose);
119403
+ const requestedStandard = input.standard ? this.canonicalAssessmentStandard(input.standard) : undefined;
119404
+ const nextStandard = requestedStandard ?? (nextPurpose === "mastery" ? assessmentStandardForRow(row) : null);
119405
+ this.assertPurposeStandard(nextPurpose, nextStandard);
119406
+ if (input.standard !== undefined) {
119407
+ assertDraftAssessment(row);
119408
+ }
119409
+ const updates = buildAssessmentAssociationUpdates(row, {
119410
+ ...input,
119411
+ ...requestedStandard ? { standard: requestedStandard } : {}
119412
+ });
119231
119413
  const nextStatus = input.status ?? row.status;
119232
119414
  const publishing = input.status !== undefined && isAssessmentPublicationTransition(row.status, input.status);
119233
119415
  const activatingReview = nextPurpose === "review" && nextStatus === "live" && (row.purpose !== "review" || row.status !== "live");
@@ -119252,7 +119434,7 @@ class TimebackAssessmentsService {
119252
119434
  updated = updatedRow ?? row;
119253
119435
  }
119254
119436
  setAttribute("app.assessment.operation", input.title !== undefined ? "update_test" : "update_association");
119255
- return updated;
119437
+ return this.associationSummary(updated);
119256
119438
  });
119257
119439
  } catch (error88) {
119258
119440
  if (isUniqueViolation(error88)) {
@@ -119343,10 +119525,11 @@ class TimebackAssessmentsService {
119343
119525
  await this.requireIntegration(integrationId);
119344
119526
  return this.listQtiLibrary(params, async (listParams) => await client2.qtiApi.assessmentTests.list(listParams));
119345
119527
  }
119346
- async copyAssessment(integrationId, sourceTestIdentifier, targetTestIdentifier, purpose) {
119528
+ async copyAssessment(integrationId, sourceTestIdentifier, targetTestIdentifier, purpose, standardInput) {
119347
119529
  const client2 = this.requireClient();
119348
119530
  const ownership = await this.requireQtiTestOwnershipContext(integrationId);
119349
119531
  const { integration } = ownership;
119532
+ const standard = this.requirePurposeStandard(purpose, standardInput);
119350
119533
  const source = await client2.qtiApi.assessmentTests.get(sourceTestIdentifier);
119351
119534
  const itemPlan = buildQtiAssessmentItemCopyPlan(source, targetTestIdentifier, (identifier) => this.qtiItemHref(client2, identifier));
119352
119535
  const itemCopies = await runWithConcurrency(itemPlan, QTI_HYDRATION_CONCURRENCY, async (plan) => {
@@ -119389,10 +119572,15 @@ class TimebackAssessmentsService {
119389
119572
  integrationId,
119390
119573
  qtiTestIdentifier: targetTestIdentifier,
119391
119574
  purpose,
119392
- status: "draft"
119575
+ status: "draft",
119576
+ standardFramework: standard?.framework,
119577
+ standardIdentifier: standard?.identifier
119393
119578
  }).returning();
119579
+ if (!row) {
119580
+ throw new Error("Assessment association copy returned no row");
119581
+ }
119394
119582
  setAttribute("app.assessment.operation", "copy_test");
119395
- return row;
119583
+ return this.associationSummary(row);
119396
119584
  } catch (error88) {
119397
119585
  if (associationCreationAttempted) {
119398
119586
  let committedRow;
@@ -119410,7 +119598,7 @@ class TimebackAssessmentsService {
119410
119598
  }
119411
119599
  if (committedRow) {
119412
119600
  setAttribute("app.assessment.operation", "copy_test");
119413
- return committedRow;
119601
+ return this.associationSummary(committedRow);
119414
119602
  }
119415
119603
  }
119416
119604
  await this.cleanupQtiAssessmentCopy(client2, testCreationAttempted ? targetTestIdentifier : undefined, attemptedItemIdentifiers);
@@ -119715,10 +119903,31 @@ class TimebackAssessmentsService {
119715
119903
  purpose: row.purpose,
119716
119904
  status: row.status,
119717
119905
  sortOrder: row.sortOrder,
119906
+ standard: assessmentStandardForRow(row),
119718
119907
  createdAt: row.createdAt,
119719
119908
  updatedAt: row.updatedAt
119720
119909
  };
119721
119910
  }
119911
+ canonicalAssessmentStandard(input) {
119912
+ const standard = canonicalReviewStandardRef(input);
119913
+ if (!standard) {
119914
+ throw new ValidationError("Assessment standards require a canonical framework and identifier");
119915
+ }
119916
+ return standard;
119917
+ }
119918
+ assertPurposeStandard(purpose, standard) {
119919
+ if (purpose === "mastery" && !standard) {
119920
+ throw new ValidationError("Mastery assessments require a standard");
119921
+ }
119922
+ if (purpose !== "mastery" && standard) {
119923
+ throw new ValidationError("Only mastery assessments may have a quiz-level standard");
119924
+ }
119925
+ }
119926
+ requirePurposeStandard(purpose, input) {
119927
+ const standard = input ? this.canonicalAssessmentStandard(input) : null;
119928
+ this.assertPurposeStandard(purpose, standard);
119929
+ return standard;
119930
+ }
119722
119931
  async listQtiLibrary(params, list) {
119723
119932
  const plan = buildQtiLibraryListPlan(params);
119724
119933
  return list(plan.params);
@@ -135252,8 +135461,8 @@ If you have no idea what this means or what Pirates is, let me explain: Pirates
135252
135461
  return tryPath.type === "index" ? (0, path_1.dirname)(tryPath.path) : tryPath.type === "file" ? tryPath.path : tryPath.type === "extension" ? (0, filesystem_1.removeExtension)(tryPath.path) : tryPath.type === "package" ? tryPath.path : exhaustiveTypeException(tryPath.type);
135253
135462
  }
135254
135463
  exports2.getStrippedPath = getStrippedPath;
135255
- function exhaustiveTypeException(check3) {
135256
- throw new Error("Unknown type ".concat(check3));
135464
+ function exhaustiveTypeException(check4) {
135465
+ throw new Error("Unknown type ".concat(check4));
135257
135466
  }
135258
135467
  exports2.exhaustiveTypeException = exhaustiveTypeException;
135259
135468
  function matchStar(pattern, search) {
@@ -139100,7 +139309,7 @@ function getTableConfig(table62) {
139100
139309
  for (const builder of extraValues) {
139101
139310
  if (is2(builder, IndexBuilder2)) {
139102
139311
  indexes2.push(builder.build(table62));
139103
- } else if (is2(builder, CheckBuilder)) {
139312
+ } else if (is2(builder, CheckBuilder2)) {
139104
139313
  checks6.push(builder.build(table62));
139105
139314
  } else if (is2(builder, UniqueConstraintBuilder)) {
139106
139315
  uniqueConstraints.push(builder.build(table62));
@@ -139327,7 +139536,7 @@ function getTableConfig2(table62) {
139327
139536
  for (const builder of Object.values(extraValues)) {
139328
139537
  if (is2(builder, IndexBuilder22)) {
139329
139538
  indexes2.push(builder.build(table62));
139330
- } else if (is2(builder, CheckBuilder2)) {
139539
+ } else if (is2(builder, CheckBuilder22)) {
139331
139540
  checks6.push(builder.build(table62));
139332
139541
  } else if (is2(builder, UniqueConstraintBuilder2)) {
139333
139542
  uniqueConstraints.push(builder.build(table62));
@@ -141306,9 +141515,9 @@ var dist_exports;
141306
141515
  var init_dist9;
141307
141516
  var init_alias22;
141308
141517
  var _a128;
141309
- var CheckBuilder;
141518
+ var CheckBuilder2;
141310
141519
  var _a129;
141311
- var Check;
141520
+ var Check2;
141312
141521
  var init_checks6;
141313
141522
  var init_columns2;
141314
141523
  var _a130;
@@ -141469,9 +141678,9 @@ var Select;
141469
141678
  var init_selector_ui;
141470
141679
  var init_alias32;
141471
141680
  var _a170;
141472
- var CheckBuilder2;
141681
+ var CheckBuilder22;
141473
141682
  var _a171;
141474
- var Check2;
141683
+ var Check22;
141475
141684
  var init_checks22;
141476
141685
  var _a172;
141477
141686
  var ForeignKeyBuilder22;
@@ -146665,7 +146874,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
146665
146874
  const result = await (isAsync2(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
146666
146875
  return handleResult2(ctx, result);
146667
146876
  }
146668
- refine(check3, message) {
146877
+ refine(check4, message) {
146669
146878
  const getIssueProperties = (val) => {
146670
146879
  if (typeof message === "string" || typeof message === "undefined") {
146671
146880
  return { message };
@@ -146676,7 +146885,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
146676
146885
  }
146677
146886
  };
146678
146887
  return this._refinement((val, ctx) => {
146679
- const result = check3(val);
146888
+ const result = check4(val);
146680
146889
  const setError = () => ctx.addIssue({
146681
146890
  code: ZodIssueCode4.custom,
146682
146891
  ...getIssueProperties(val)
@@ -146699,9 +146908,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
146699
146908
  }
146700
146909
  });
146701
146910
  }
146702
- refinement(check3, refinementData) {
146911
+ refinement(check4, refinementData) {
146703
146912
  return this._refinement((val, ctx) => {
146704
- if (!check3(val)) {
146913
+ if (!check4(val)) {
146705
146914
  ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
146706
146915
  return false;
146707
146916
  } else {
@@ -146860,70 +147069,70 @@ See: https://github.com/isaacs/node-glob/issues/167`);
146860
147069
  }
146861
147070
  const status = new ParseStatus2;
146862
147071
  let ctx = undefined;
146863
- for (const check3 of this._def.checks) {
146864
- if (check3.kind === "min") {
146865
- if (input.data.length < check3.value) {
147072
+ for (const check4 of this._def.checks) {
147073
+ if (check4.kind === "min") {
147074
+ if (input.data.length < check4.value) {
146866
147075
  ctx = this._getOrReturnCtx(input, ctx);
146867
147076
  addIssueToContext2(ctx, {
146868
147077
  code: ZodIssueCode4.too_small,
146869
- minimum: check3.value,
147078
+ minimum: check4.value,
146870
147079
  type: "string",
146871
147080
  inclusive: true,
146872
147081
  exact: false,
146873
- message: check3.message
147082
+ message: check4.message
146874
147083
  });
146875
147084
  status.dirty();
146876
147085
  }
146877
- } else if (check3.kind === "max") {
146878
- if (input.data.length > check3.value) {
147086
+ } else if (check4.kind === "max") {
147087
+ if (input.data.length > check4.value) {
146879
147088
  ctx = this._getOrReturnCtx(input, ctx);
146880
147089
  addIssueToContext2(ctx, {
146881
147090
  code: ZodIssueCode4.too_big,
146882
- maximum: check3.value,
147091
+ maximum: check4.value,
146883
147092
  type: "string",
146884
147093
  inclusive: true,
146885
147094
  exact: false,
146886
- message: check3.message
147095
+ message: check4.message
146887
147096
  });
146888
147097
  status.dirty();
146889
147098
  }
146890
- } else if (check3.kind === "length") {
146891
- const tooBig = input.data.length > check3.value;
146892
- const tooSmall = input.data.length < check3.value;
147099
+ } else if (check4.kind === "length") {
147100
+ const tooBig = input.data.length > check4.value;
147101
+ const tooSmall = input.data.length < check4.value;
146893
147102
  if (tooBig || tooSmall) {
146894
147103
  ctx = this._getOrReturnCtx(input, ctx);
146895
147104
  if (tooBig) {
146896
147105
  addIssueToContext2(ctx, {
146897
147106
  code: ZodIssueCode4.too_big,
146898
- maximum: check3.value,
147107
+ maximum: check4.value,
146899
147108
  type: "string",
146900
147109
  inclusive: true,
146901
147110
  exact: true,
146902
- message: check3.message
147111
+ message: check4.message
146903
147112
  });
146904
147113
  } else if (tooSmall) {
146905
147114
  addIssueToContext2(ctx, {
146906
147115
  code: ZodIssueCode4.too_small,
146907
- minimum: check3.value,
147116
+ minimum: check4.value,
146908
147117
  type: "string",
146909
147118
  inclusive: true,
146910
147119
  exact: true,
146911
- message: check3.message
147120
+ message: check4.message
146912
147121
  });
146913
147122
  }
146914
147123
  status.dirty();
146915
147124
  }
146916
- } else if (check3.kind === "email") {
147125
+ } else if (check4.kind === "email") {
146917
147126
  if (!emailRegex2.test(input.data)) {
146918
147127
  ctx = this._getOrReturnCtx(input, ctx);
146919
147128
  addIssueToContext2(ctx, {
146920
147129
  validation: "email",
146921
147130
  code: ZodIssueCode4.invalid_string,
146922
- message: check3.message
147131
+ message: check4.message
146923
147132
  });
146924
147133
  status.dirty();
146925
147134
  }
146926
- } else if (check3.kind === "emoji") {
147135
+ } else if (check4.kind === "emoji") {
146927
147136
  if (!emojiRegex2) {
146928
147137
  emojiRegex2 = new RegExp(_emojiRegex2, "u");
146929
147138
  }
@@ -146932,61 +147141,61 @@ See: https://github.com/isaacs/node-glob/issues/167`);
146932
147141
  addIssueToContext2(ctx, {
146933
147142
  validation: "emoji",
146934
147143
  code: ZodIssueCode4.invalid_string,
146935
- message: check3.message
147144
+ message: check4.message
146936
147145
  });
146937
147146
  status.dirty();
146938
147147
  }
146939
- } else if (check3.kind === "uuid") {
147148
+ } else if (check4.kind === "uuid") {
146940
147149
  if (!uuidRegex2.test(input.data)) {
146941
147150
  ctx = this._getOrReturnCtx(input, ctx);
146942
147151
  addIssueToContext2(ctx, {
146943
147152
  validation: "uuid",
146944
147153
  code: ZodIssueCode4.invalid_string,
146945
- message: check3.message
147154
+ message: check4.message
146946
147155
  });
146947
147156
  status.dirty();
146948
147157
  }
146949
- } else if (check3.kind === "nanoid") {
147158
+ } else if (check4.kind === "nanoid") {
146950
147159
  if (!nanoidRegex2.test(input.data)) {
146951
147160
  ctx = this._getOrReturnCtx(input, ctx);
146952
147161
  addIssueToContext2(ctx, {
146953
147162
  validation: "nanoid",
146954
147163
  code: ZodIssueCode4.invalid_string,
146955
- message: check3.message
147164
+ message: check4.message
146956
147165
  });
146957
147166
  status.dirty();
146958
147167
  }
146959
- } else if (check3.kind === "cuid") {
147168
+ } else if (check4.kind === "cuid") {
146960
147169
  if (!cuidRegex2.test(input.data)) {
146961
147170
  ctx = this._getOrReturnCtx(input, ctx);
146962
147171
  addIssueToContext2(ctx, {
146963
147172
  validation: "cuid",
146964
147173
  code: ZodIssueCode4.invalid_string,
146965
- message: check3.message
147174
+ message: check4.message
146966
147175
  });
146967
147176
  status.dirty();
146968
147177
  }
146969
- } else if (check3.kind === "cuid2") {
147178
+ } else if (check4.kind === "cuid2") {
146970
147179
  if (!cuid2Regex2.test(input.data)) {
146971
147180
  ctx = this._getOrReturnCtx(input, ctx);
146972
147181
  addIssueToContext2(ctx, {
146973
147182
  validation: "cuid2",
146974
147183
  code: ZodIssueCode4.invalid_string,
146975
- message: check3.message
147184
+ message: check4.message
146976
147185
  });
146977
147186
  status.dirty();
146978
147187
  }
146979
- } else if (check3.kind === "ulid") {
147188
+ } else if (check4.kind === "ulid") {
146980
147189
  if (!ulidRegex2.test(input.data)) {
146981
147190
  ctx = this._getOrReturnCtx(input, ctx);
146982
147191
  addIssueToContext2(ctx, {
146983
147192
  validation: "ulid",
146984
147193
  code: ZodIssueCode4.invalid_string,
146985
- message: check3.message
147194
+ message: check4.message
146986
147195
  });
146987
147196
  status.dirty();
146988
147197
  }
146989
- } else if (check3.kind === "url") {
147198
+ } else if (check4.kind === "url") {
146990
147199
  try {
146991
147200
  new URL(input.data);
146992
147201
  } catch {
@@ -146994,153 +147203,153 @@ See: https://github.com/isaacs/node-glob/issues/167`);
146994
147203
  addIssueToContext2(ctx, {
146995
147204
  validation: "url",
146996
147205
  code: ZodIssueCode4.invalid_string,
146997
- message: check3.message
147206
+ message: check4.message
146998
147207
  });
146999
147208
  status.dirty();
147000
147209
  }
147001
- } else if (check3.kind === "regex") {
147002
- check3.regex.lastIndex = 0;
147003
- const testResult = check3.regex.test(input.data);
147210
+ } else if (check4.kind === "regex") {
147211
+ check4.regex.lastIndex = 0;
147212
+ const testResult = check4.regex.test(input.data);
147004
147213
  if (!testResult) {
147005
147214
  ctx = this._getOrReturnCtx(input, ctx);
147006
147215
  addIssueToContext2(ctx, {
147007
147216
  validation: "regex",
147008
147217
  code: ZodIssueCode4.invalid_string,
147009
- message: check3.message
147218
+ message: check4.message
147010
147219
  });
147011
147220
  status.dirty();
147012
147221
  }
147013
- } else if (check3.kind === "trim") {
147222
+ } else if (check4.kind === "trim") {
147014
147223
  input.data = input.data.trim();
147015
- } else if (check3.kind === "includes") {
147016
- if (!input.data.includes(check3.value, check3.position)) {
147224
+ } else if (check4.kind === "includes") {
147225
+ if (!input.data.includes(check4.value, check4.position)) {
147017
147226
  ctx = this._getOrReturnCtx(input, ctx);
147018
147227
  addIssueToContext2(ctx, {
147019
147228
  code: ZodIssueCode4.invalid_string,
147020
- validation: { includes: check3.value, position: check3.position },
147021
- message: check3.message
147229
+ validation: { includes: check4.value, position: check4.position },
147230
+ message: check4.message
147022
147231
  });
147023
147232
  status.dirty();
147024
147233
  }
147025
- } else if (check3.kind === "toLowerCase") {
147234
+ } else if (check4.kind === "toLowerCase") {
147026
147235
  input.data = input.data.toLowerCase();
147027
- } else if (check3.kind === "toUpperCase") {
147236
+ } else if (check4.kind === "toUpperCase") {
147028
147237
  input.data = input.data.toUpperCase();
147029
- } else if (check3.kind === "startsWith") {
147030
- if (!input.data.startsWith(check3.value)) {
147238
+ } else if (check4.kind === "startsWith") {
147239
+ if (!input.data.startsWith(check4.value)) {
147031
147240
  ctx = this._getOrReturnCtx(input, ctx);
147032
147241
  addIssueToContext2(ctx, {
147033
147242
  code: ZodIssueCode4.invalid_string,
147034
- validation: { startsWith: check3.value },
147035
- message: check3.message
147243
+ validation: { startsWith: check4.value },
147244
+ message: check4.message
147036
147245
  });
147037
147246
  status.dirty();
147038
147247
  }
147039
- } else if (check3.kind === "endsWith") {
147040
- if (!input.data.endsWith(check3.value)) {
147248
+ } else if (check4.kind === "endsWith") {
147249
+ if (!input.data.endsWith(check4.value)) {
147041
147250
  ctx = this._getOrReturnCtx(input, ctx);
147042
147251
  addIssueToContext2(ctx, {
147043
147252
  code: ZodIssueCode4.invalid_string,
147044
- validation: { endsWith: check3.value },
147045
- message: check3.message
147253
+ validation: { endsWith: check4.value },
147254
+ message: check4.message
147046
147255
  });
147047
147256
  status.dirty();
147048
147257
  }
147049
- } else if (check3.kind === "datetime") {
147050
- const regex = datetimeRegex2(check3);
147258
+ } else if (check4.kind === "datetime") {
147259
+ const regex = datetimeRegex2(check4);
147051
147260
  if (!regex.test(input.data)) {
147052
147261
  ctx = this._getOrReturnCtx(input, ctx);
147053
147262
  addIssueToContext2(ctx, {
147054
147263
  code: ZodIssueCode4.invalid_string,
147055
147264
  validation: "datetime",
147056
- message: check3.message
147265
+ message: check4.message
147057
147266
  });
147058
147267
  status.dirty();
147059
147268
  }
147060
- } else if (check3.kind === "date") {
147269
+ } else if (check4.kind === "date") {
147061
147270
  const regex = dateRegex2;
147062
147271
  if (!regex.test(input.data)) {
147063
147272
  ctx = this._getOrReturnCtx(input, ctx);
147064
147273
  addIssueToContext2(ctx, {
147065
147274
  code: ZodIssueCode4.invalid_string,
147066
147275
  validation: "date",
147067
- message: check3.message
147276
+ message: check4.message
147068
147277
  });
147069
147278
  status.dirty();
147070
147279
  }
147071
- } else if (check3.kind === "time") {
147072
- const regex = timeRegex2(check3);
147280
+ } else if (check4.kind === "time") {
147281
+ const regex = timeRegex2(check4);
147073
147282
  if (!regex.test(input.data)) {
147074
147283
  ctx = this._getOrReturnCtx(input, ctx);
147075
147284
  addIssueToContext2(ctx, {
147076
147285
  code: ZodIssueCode4.invalid_string,
147077
147286
  validation: "time",
147078
- message: check3.message
147287
+ message: check4.message
147079
147288
  });
147080
147289
  status.dirty();
147081
147290
  }
147082
- } else if (check3.kind === "duration") {
147291
+ } else if (check4.kind === "duration") {
147083
147292
  if (!durationRegex2.test(input.data)) {
147084
147293
  ctx = this._getOrReturnCtx(input, ctx);
147085
147294
  addIssueToContext2(ctx, {
147086
147295
  validation: "duration",
147087
147296
  code: ZodIssueCode4.invalid_string,
147088
- message: check3.message
147297
+ message: check4.message
147089
147298
  });
147090
147299
  status.dirty();
147091
147300
  }
147092
- } else if (check3.kind === "ip") {
147093
- if (!isValidIP2(input.data, check3.version)) {
147301
+ } else if (check4.kind === "ip") {
147302
+ if (!isValidIP2(input.data, check4.version)) {
147094
147303
  ctx = this._getOrReturnCtx(input, ctx);
147095
147304
  addIssueToContext2(ctx, {
147096
147305
  validation: "ip",
147097
147306
  code: ZodIssueCode4.invalid_string,
147098
- message: check3.message
147307
+ message: check4.message
147099
147308
  });
147100
147309
  status.dirty();
147101
147310
  }
147102
- } else if (check3.kind === "jwt") {
147103
- if (!isValidJWT4(input.data, check3.alg)) {
147311
+ } else if (check4.kind === "jwt") {
147312
+ if (!isValidJWT4(input.data, check4.alg)) {
147104
147313
  ctx = this._getOrReturnCtx(input, ctx);
147105
147314
  addIssueToContext2(ctx, {
147106
147315
  validation: "jwt",
147107
147316
  code: ZodIssueCode4.invalid_string,
147108
- message: check3.message
147317
+ message: check4.message
147109
147318
  });
147110
147319
  status.dirty();
147111
147320
  }
147112
- } else if (check3.kind === "cidr") {
147113
- if (!isValidCidr2(input.data, check3.version)) {
147321
+ } else if (check4.kind === "cidr") {
147322
+ if (!isValidCidr2(input.data, check4.version)) {
147114
147323
  ctx = this._getOrReturnCtx(input, ctx);
147115
147324
  addIssueToContext2(ctx, {
147116
147325
  validation: "cidr",
147117
147326
  code: ZodIssueCode4.invalid_string,
147118
- message: check3.message
147327
+ message: check4.message
147119
147328
  });
147120
147329
  status.dirty();
147121
147330
  }
147122
- } else if (check3.kind === "base64") {
147331
+ } else if (check4.kind === "base64") {
147123
147332
  if (!base64Regex2.test(input.data)) {
147124
147333
  ctx = this._getOrReturnCtx(input, ctx);
147125
147334
  addIssueToContext2(ctx, {
147126
147335
  validation: "base64",
147127
147336
  code: ZodIssueCode4.invalid_string,
147128
- message: check3.message
147337
+ message: check4.message
147129
147338
  });
147130
147339
  status.dirty();
147131
147340
  }
147132
- } else if (check3.kind === "base64url") {
147341
+ } else if (check4.kind === "base64url") {
147133
147342
  if (!base64urlRegex2.test(input.data)) {
147134
147343
  ctx = this._getOrReturnCtx(input, ctx);
147135
147344
  addIssueToContext2(ctx, {
147136
147345
  validation: "base64url",
147137
147346
  code: ZodIssueCode4.invalid_string,
147138
- message: check3.message
147347
+ message: check4.message
147139
147348
  });
147140
147349
  status.dirty();
147141
147350
  }
147142
147351
  } else {
147143
- util3.assertNever(check3);
147352
+ util3.assertNever(check4);
147144
147353
  }
147145
147354
  }
147146
147355
  return { status: status.value, value: input.data };
@@ -147152,10 +147361,10 @@ See: https://github.com/isaacs/node-glob/issues/167`);
147152
147361
  ...errorUtil2.errToObj(message)
147153
147362
  });
147154
147363
  }
147155
- _addCheck(check3) {
147364
+ _addCheck(check4) {
147156
147365
  return new _ZodString3({
147157
147366
  ...this._def,
147158
- checks: [...this._def.checks, check3]
147367
+ checks: [...this._def.checks, check4]
147159
147368
  });
147160
147369
  }
147161
147370
  email(message) {
@@ -147409,67 +147618,67 @@ See: https://github.com/isaacs/node-glob/issues/167`);
147409
147618
  }
147410
147619
  let ctx = undefined;
147411
147620
  const status = new ParseStatus2;
147412
- for (const check3 of this._def.checks) {
147413
- if (check3.kind === "int") {
147621
+ for (const check4 of this._def.checks) {
147622
+ if (check4.kind === "int") {
147414
147623
  if (!util3.isInteger(input.data)) {
147415
147624
  ctx = this._getOrReturnCtx(input, ctx);
147416
147625
  addIssueToContext2(ctx, {
147417
147626
  code: ZodIssueCode4.invalid_type,
147418
147627
  expected: "integer",
147419
147628
  received: "float",
147420
- message: check3.message
147629
+ message: check4.message
147421
147630
  });
147422
147631
  status.dirty();
147423
147632
  }
147424
- } else if (check3.kind === "min") {
147425
- const tooSmall = check3.inclusive ? input.data < check3.value : input.data <= check3.value;
147633
+ } else if (check4.kind === "min") {
147634
+ const tooSmall = check4.inclusive ? input.data < check4.value : input.data <= check4.value;
147426
147635
  if (tooSmall) {
147427
147636
  ctx = this._getOrReturnCtx(input, ctx);
147428
147637
  addIssueToContext2(ctx, {
147429
147638
  code: ZodIssueCode4.too_small,
147430
- minimum: check3.value,
147639
+ minimum: check4.value,
147431
147640
  type: "number",
147432
- inclusive: check3.inclusive,
147641
+ inclusive: check4.inclusive,
147433
147642
  exact: false,
147434
- message: check3.message
147643
+ message: check4.message
147435
147644
  });
147436
147645
  status.dirty();
147437
147646
  }
147438
- } else if (check3.kind === "max") {
147439
- const tooBig = check3.inclusive ? input.data > check3.value : input.data >= check3.value;
147647
+ } else if (check4.kind === "max") {
147648
+ const tooBig = check4.inclusive ? input.data > check4.value : input.data >= check4.value;
147440
147649
  if (tooBig) {
147441
147650
  ctx = this._getOrReturnCtx(input, ctx);
147442
147651
  addIssueToContext2(ctx, {
147443
147652
  code: ZodIssueCode4.too_big,
147444
- maximum: check3.value,
147653
+ maximum: check4.value,
147445
147654
  type: "number",
147446
- inclusive: check3.inclusive,
147655
+ inclusive: check4.inclusive,
147447
147656
  exact: false,
147448
- message: check3.message
147657
+ message: check4.message
147449
147658
  });
147450
147659
  status.dirty();
147451
147660
  }
147452
- } else if (check3.kind === "multipleOf") {
147453
- if (floatSafeRemainder4(input.data, check3.value) !== 0) {
147661
+ } else if (check4.kind === "multipleOf") {
147662
+ if (floatSafeRemainder4(input.data, check4.value) !== 0) {
147454
147663
  ctx = this._getOrReturnCtx(input, ctx);
147455
147664
  addIssueToContext2(ctx, {
147456
147665
  code: ZodIssueCode4.not_multiple_of,
147457
- multipleOf: check3.value,
147458
- message: check3.message
147666
+ multipleOf: check4.value,
147667
+ message: check4.message
147459
147668
  });
147460
147669
  status.dirty();
147461
147670
  }
147462
- } else if (check3.kind === "finite") {
147671
+ } else if (check4.kind === "finite") {
147463
147672
  if (!Number.isFinite(input.data)) {
147464
147673
  ctx = this._getOrReturnCtx(input, ctx);
147465
147674
  addIssueToContext2(ctx, {
147466
147675
  code: ZodIssueCode4.not_finite,
147467
- message: check3.message
147676
+ message: check4.message
147468
147677
  });
147469
147678
  status.dirty();
147470
147679
  }
147471
147680
  } else {
147472
- util3.assertNever(check3);
147681
+ util3.assertNever(check4);
147473
147682
  }
147474
147683
  }
147475
147684
  return { status: status.value, value: input.data };
@@ -147500,10 +147709,10 @@ See: https://github.com/isaacs/node-glob/issues/167`);
147500
147709
  ]
147501
147710
  });
147502
147711
  }
147503
- _addCheck(check3) {
147712
+ _addCheck(check4) {
147504
147713
  return new _ZodNumber({
147505
147714
  ...this._def,
147506
- checks: [...this._def.checks, check3]
147715
+ checks: [...this._def.checks, check4]
147507
147716
  });
147508
147717
  }
147509
147718
  int(message) {
@@ -147638,45 +147847,45 @@ See: https://github.com/isaacs/node-glob/issues/167`);
147638
147847
  }
147639
147848
  let ctx = undefined;
147640
147849
  const status = new ParseStatus2;
147641
- for (const check3 of this._def.checks) {
147642
- if (check3.kind === "min") {
147643
- const tooSmall = check3.inclusive ? input.data < check3.value : input.data <= check3.value;
147850
+ for (const check4 of this._def.checks) {
147851
+ if (check4.kind === "min") {
147852
+ const tooSmall = check4.inclusive ? input.data < check4.value : input.data <= check4.value;
147644
147853
  if (tooSmall) {
147645
147854
  ctx = this._getOrReturnCtx(input, ctx);
147646
147855
  addIssueToContext2(ctx, {
147647
147856
  code: ZodIssueCode4.too_small,
147648
147857
  type: "bigint",
147649
- minimum: check3.value,
147650
- inclusive: check3.inclusive,
147651
- message: check3.message
147858
+ minimum: check4.value,
147859
+ inclusive: check4.inclusive,
147860
+ message: check4.message
147652
147861
  });
147653
147862
  status.dirty();
147654
147863
  }
147655
- } else if (check3.kind === "max") {
147656
- const tooBig = check3.inclusive ? input.data > check3.value : input.data >= check3.value;
147864
+ } else if (check4.kind === "max") {
147865
+ const tooBig = check4.inclusive ? input.data > check4.value : input.data >= check4.value;
147657
147866
  if (tooBig) {
147658
147867
  ctx = this._getOrReturnCtx(input, ctx);
147659
147868
  addIssueToContext2(ctx, {
147660
147869
  code: ZodIssueCode4.too_big,
147661
147870
  type: "bigint",
147662
- maximum: check3.value,
147663
- inclusive: check3.inclusive,
147664
- message: check3.message
147871
+ maximum: check4.value,
147872
+ inclusive: check4.inclusive,
147873
+ message: check4.message
147665
147874
  });
147666
147875
  status.dirty();
147667
147876
  }
147668
- } else if (check3.kind === "multipleOf") {
147669
- if (input.data % check3.value !== BigInt(0)) {
147877
+ } else if (check4.kind === "multipleOf") {
147878
+ if (input.data % check4.value !== BigInt(0)) {
147670
147879
  ctx = this._getOrReturnCtx(input, ctx);
147671
147880
  addIssueToContext2(ctx, {
147672
147881
  code: ZodIssueCode4.not_multiple_of,
147673
- multipleOf: check3.value,
147674
- message: check3.message
147882
+ multipleOf: check4.value,
147883
+ message: check4.message
147675
147884
  });
147676
147885
  status.dirty();
147677
147886
  }
147678
147887
  } else {
147679
- util3.assertNever(check3);
147888
+ util3.assertNever(check4);
147680
147889
  }
147681
147890
  }
147682
147891
  return { status: status.value, value: input.data };
@@ -147716,10 +147925,10 @@ See: https://github.com/isaacs/node-glob/issues/167`);
147716
147925
  ]
147717
147926
  });
147718
147927
  }
147719
- _addCheck(check3) {
147928
+ _addCheck(check4) {
147720
147929
  return new _ZodBigInt({
147721
147930
  ...this._def,
147722
- checks: [...this._def.checks, check3]
147931
+ checks: [...this._def.checks, check4]
147723
147932
  });
147724
147933
  }
147725
147934
  positive(message) {
@@ -147839,35 +148048,35 @@ See: https://github.com/isaacs/node-glob/issues/167`);
147839
148048
  }
147840
148049
  const status = new ParseStatus2;
147841
148050
  let ctx = undefined;
147842
- for (const check3 of this._def.checks) {
147843
- if (check3.kind === "min") {
147844
- if (input.data.getTime() < check3.value) {
148051
+ for (const check4 of this._def.checks) {
148052
+ if (check4.kind === "min") {
148053
+ if (input.data.getTime() < check4.value) {
147845
148054
  ctx = this._getOrReturnCtx(input, ctx);
147846
148055
  addIssueToContext2(ctx, {
147847
148056
  code: ZodIssueCode4.too_small,
147848
- message: check3.message,
148057
+ message: check4.message,
147849
148058
  inclusive: true,
147850
148059
  exact: false,
147851
- minimum: check3.value,
148060
+ minimum: check4.value,
147852
148061
  type: "date"
147853
148062
  });
147854
148063
  status.dirty();
147855
148064
  }
147856
- } else if (check3.kind === "max") {
147857
- if (input.data.getTime() > check3.value) {
148065
+ } else if (check4.kind === "max") {
148066
+ if (input.data.getTime() > check4.value) {
147858
148067
  ctx = this._getOrReturnCtx(input, ctx);
147859
148068
  addIssueToContext2(ctx, {
147860
148069
  code: ZodIssueCode4.too_big,
147861
- message: check3.message,
148070
+ message: check4.message,
147862
148071
  inclusive: true,
147863
148072
  exact: false,
147864
- maximum: check3.value,
148073
+ maximum: check4.value,
147865
148074
  type: "date"
147866
148075
  });
147867
148076
  status.dirty();
147868
148077
  }
147869
148078
  } else {
147870
- util3.assertNever(check3);
148079
+ util3.assertNever(check4);
147871
148080
  }
147872
148081
  }
147873
148082
  return {
@@ -147875,10 +148084,10 @@ See: https://github.com/isaacs/node-glob/issues/167`);
147875
148084
  value: new Date(input.data.getTime())
147876
148085
  };
147877
148086
  }
147878
- _addCheck(check3) {
148087
+ _addCheck(check4) {
147879
148088
  return new _ZodDate({
147880
148089
  ...this._def,
147881
- checks: [...this._def.checks, check3]
148090
+ checks: [...this._def.checks, check4]
147882
148091
  });
147883
148092
  }
147884
148093
  min(minDate, message) {
@@ -150186,8 +150395,8 @@ See: https://github.com/isaacs/node-glob/issues/167`);
150186
150395
  const squashedUniqueConstraints = mapValues(it3[1].uniqueConstraints, (unq) => {
150187
150396
  return MySqlSquasher.squashUnique(unq);
150188
150397
  });
150189
- const squashedCheckConstraints = mapValues(it3[1].checkConstraint, (check3) => {
150190
- return MySqlSquasher.squashCheck(check3);
150398
+ const squashedCheckConstraints = mapValues(it3[1].checkConstraint, (check4) => {
150399
+ return MySqlSquasher.squashCheck(check4);
150191
150400
  });
150192
150401
  return [
150193
150402
  it3[0],
@@ -150854,8 +151063,8 @@ See: https://github.com/isaacs/node-glob/issues/167`);
150854
151063
  cycle: splitted[7] === "true"
150855
151064
  };
150856
151065
  },
150857
- squashCheck: (check3) => {
150858
- return `${check3.name};${check3.value}`;
151066
+ squashCheck: (check4) => {
151067
+ return `${check4.name};${check4.value}`;
150859
151068
  },
150860
151069
  unsquashCheck: (input) => {
150861
151070
  const [
@@ -150892,8 +151101,8 @@ See: https://github.com/isaacs/node-glob/issues/167`);
150892
151101
  const squashedPolicies = mapValues(it3[1].policies, (policy5) => {
150893
151102
  return action === "push" ? PgSquasher.squashPolicyPush(policy5) : PgSquasher.squashPolicy(policy5);
150894
151103
  });
150895
- const squashedChecksContraints = mapValues(it3[1].checkConstraints, (check3) => {
150896
- return PgSquasher.squashCheck(check3);
151104
+ const squashedChecksContraints = mapValues(it3[1].checkConstraints, (check4) => {
151105
+ return PgSquasher.squashCheck(check4);
150897
151106
  });
150898
151107
  return [
150899
151108
  it3[0],
@@ -151325,8 +151534,8 @@ See: https://github.com/isaacs/node-glob/issues/167`);
151325
151534
  unsquashPK: (pk) => {
151326
151535
  return pk.split(",");
151327
151536
  },
151328
- squashCheck: (check3) => {
151329
- return `${check3.name};${check3.value}`;
151537
+ squashCheck: (check4) => {
151538
+ return `${check4.name};${check4.value}`;
151330
151539
  },
151331
151540
  unsquashCheck: (input) => {
151332
151541
  const [
@@ -151353,8 +151562,8 @@ See: https://github.com/isaacs/node-glob/issues/167`);
151353
151562
  const squashedUniqueConstraints = mapValues(it3[1].uniqueConstraints, (unq) => {
151354
151563
  return SQLiteSquasher.squashUnique(unq);
151355
151564
  });
151356
- const squashedCheckConstraints = mapValues(it3[1].checkConstraints, (check3) => {
151357
- return SQLiteSquasher.squashCheck(check3);
151565
+ const squashedCheckConstraints = mapValues(it3[1].checkConstraints, (check4) => {
151566
+ return SQLiteSquasher.squashCheck(check4);
151358
151567
  });
151359
151568
  return [
151360
151569
  it3[0],
@@ -154583,10 +154792,10 @@ Is ${source_default.bold.blue(this.base.name)} schema created or renamed from an
154583
154792
  }
154584
154793
  }
154585
154794
  if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
154586
- for (const check3 of checkConstraints) {
154795
+ for (const check4 of checkConstraints) {
154587
154796
  statement += `,
154588
154797
  `;
154589
- const { value, name: name22 } = SQLiteSquasher.unsquashCheck(check3);
154798
+ const { value, name: name22 } = SQLiteSquasher.unsquashCheck(check4);
154590
154799
  statement += ` CONSTRAINT "${name22}" CHECK(${value})`;
154591
154800
  }
154592
154801
  }
@@ -158262,8 +158471,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
158262
158471
  };
158263
158472
  });
158264
158473
  };
158265
- prepareAddCheckConstraint = (tableName, schema5, check3) => {
158266
- return Object.values(check3).map((it3) => {
158474
+ prepareAddCheckConstraint = (tableName, schema5, check4) => {
158475
+ return Object.values(check4).map((it3) => {
158267
158476
  return {
158268
158477
  type: "create_check_constraint",
158269
158478
  tableName,
@@ -158272,8 +158481,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
158272
158481
  };
158273
158482
  });
158274
158483
  };
158275
- prepareDeleteCheckConstraint = (tableName, schema5, check3) => {
158276
- return Object.values(check3).map((it3) => {
158484
+ prepareDeleteCheckConstraint = (tableName, schema5, check4) => {
158485
+ return Object.values(check4).map((it3) => {
158277
158486
  return {
158278
158487
  type: "delete_check_constraint",
158279
158488
  tableName,
@@ -165016,19 +165225,19 @@ params: ${params}`);
165016
165225
  "../drizzle-orm/dist/pg-core/checks.js"() {
165017
165226
  init_entity2();
165018
165227
  _a128 = entityKind2;
165019
- CheckBuilder = class {
165228
+ CheckBuilder2 = class {
165020
165229
  constructor(name22, value) {
165021
165230
  __publicField(this, "brand");
165022
165231
  this.name = name22;
165023
165232
  this.value = value;
165024
165233
  }
165025
165234
  build(table62) {
165026
- return new Check(table62, this);
165235
+ return new Check2(table62, this);
165027
165236
  }
165028
165237
  };
165029
- __publicField(CheckBuilder, _a128, "PgCheckBuilder");
165238
+ __publicField(CheckBuilder2, _a128, "PgCheckBuilder");
165030
165239
  _a129 = entityKind2;
165031
- Check = class {
165240
+ Check2 = class {
165032
165241
  constructor(table62, builder) {
165033
165242
  __publicField(this, "name");
165034
165243
  __publicField(this, "value");
@@ -165037,7 +165246,7 @@ params: ${params}`);
165037
165246
  this.value = builder.value;
165038
165247
  }
165039
165248
  };
165040
- __publicField(Check, _a129, "PgCheck");
165249
+ __publicField(Check2, _a129, "PgCheck");
165041
165250
  }
165042
165251
  });
165043
165252
  init_columns2 = __esm2({
@@ -167878,21 +168087,21 @@ ${withStyle.errorWarning(`We've found duplicated policy name across ${source_def
167878
168087
  withCheck: is2(policy5.withCheck, SQL2) ? dialect6.sqlToQuery(policy5.withCheck).sql : undefined
167879
168088
  };
167880
168089
  });
167881
- checks6.forEach((check3) => {
167882
- const checkName = check3.name;
168090
+ checks6.forEach((check4) => {
168091
+ const checkName = check4.name;
167883
168092
  if (typeof checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] !== "undefined") {
167884
- if (checksInTable[`"${schema5 ?? "public"}"."${tableName}"`].includes(check3.name)) {
168093
+ if (checksInTable[`"${schema5 ?? "public"}"."${tableName}"`].includes(check4.name)) {
167885
168094
  console.log(`
167886
168095
  ${withStyle.errorWarning(`We've found duplicated check constraint name across ${source_default.underline.blue(schema5 ?? "public")} schema in ${source_default.underline.blue(tableName)}. Please rename your check constraint in either the ${source_default.underline.blue(tableName)} table or the table with the duplicated check contraint name`)}`);
167887
168096
  process.exit(1);
167888
168097
  }
167889
168098
  checksInTable[`"${schema5 ?? "public"}"."${tableName}"`].push(checkName);
167890
168099
  } else {
167891
- checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] = [check3.name];
168100
+ checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] = [check4.name];
167892
168101
  }
167893
168102
  checksObject[checkName] = {
167894
168103
  name: checkName,
167895
- value: dialect6.sqlToQuery(check3.value).sql
168104
+ value: dialect6.sqlToQuery(check4.value).sql
167896
168105
  };
167897
168106
  });
167898
168107
  const tableKey2 = `${schema5 ?? "public"}.${tableName}`;
@@ -169045,19 +169254,19 @@ ORDER BY
169045
169254
  "../drizzle-orm/dist/sqlite-core/checks.js"() {
169046
169255
  init_entity2();
169047
169256
  _a170 = entityKind2;
169048
- CheckBuilder2 = class {
169257
+ CheckBuilder22 = class {
169049
169258
  constructor(name22, value) {
169050
169259
  __publicField(this, "brand");
169051
169260
  this.name = name22;
169052
169261
  this.value = value;
169053
169262
  }
169054
169263
  build(table62) {
169055
- return new Check2(table62, this);
169264
+ return new Check22(table62, this);
169056
169265
  }
169057
169266
  };
169058
- __publicField(CheckBuilder2, _a170, "SQLiteCheckBuilder");
169267
+ __publicField(CheckBuilder22, _a170, "SQLiteCheckBuilder");
169059
169268
  _a171 = entityKind2;
169060
- Check2 = class {
169269
+ Check22 = class {
169061
169270
  constructor(table62, builder) {
169062
169271
  __publicField(this, "name");
169063
169272
  __publicField(this, "value");
@@ -169066,7 +169275,7 @@ ORDER BY
169066
169275
  this.value = builder.value;
169067
169276
  }
169068
169277
  };
169069
- __publicField(Check2, _a171, "SQLiteCheck");
169278
+ __publicField(Check22, _a171, "SQLiteCheck");
169070
169279
  }
169071
169280
  });
169072
169281
  init_foreign_keys22 = __esm2({
@@ -171777,21 +171986,21 @@ The unique constraint ${source_default.underline.blue(name22)} on the ${source_d
171777
171986
  columnsObject[getColumnCasing(it3.columns[0], casing2)].primaryKey = true;
171778
171987
  }
171779
171988
  });
171780
- checks6.forEach((check3) => {
171781
- const checkName = check3.name;
171989
+ checks6.forEach((check4) => {
171990
+ const checkName = check4.name;
171782
171991
  if (typeof checksInTable[tableName] !== "undefined") {
171783
- if (checksInTable[tableName].includes(check3.name)) {
171992
+ if (checksInTable[tableName].includes(check4.name)) {
171784
171993
  console.log(`
171785
171994
  ${withStyle.errorWarning(`We've found duplicated check constraint name in ${source_default.underline.blue(tableName)}. Please rename your check constraint in the ${source_default.underline.blue(tableName)} table`)}`);
171786
171995
  process.exit(1);
171787
171996
  }
171788
171997
  checksInTable[tableName].push(checkName);
171789
171998
  } else {
171790
- checksInTable[tableName] = [check3.name];
171999
+ checksInTable[tableName] = [check4.name];
171791
172000
  }
171792
172001
  checkConstraintObject[checkName] = {
171793
172002
  name: checkName,
171794
- value: dialect6.sqlToQuery(check3.value).sql
172003
+ value: dialect6.sqlToQuery(check4.value).sql
171795
172004
  };
171796
172005
  });
171797
172006
  result[tableName] = {
@@ -172105,10 +172314,10 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
172105
172314
  FROM sqlite_master
172106
172315
  WHERE type = 'table'
172107
172316
  AND ${filterIgnoredTablesByField("tbl_name")};`);
172108
- for (const check3 of checks6) {
172109
- if (!tablesFilter(check3.tableName))
172317
+ for (const check4 of checks6) {
172318
+ if (!tablesFilter(check4.tableName))
172110
172319
  continue;
172111
- const { tableName, sql: sql22 } = check3;
172320
+ const { tableName, sql: sql22 } = check4;
172112
172321
  let namedChecks = [...sql22.matchAll(namedCheckPattern)];
172113
172322
  if (namedChecks.length > 0) {
172114
172323
  namedChecks.forEach(([_222, checkName, checkValue]) => {
@@ -175695,21 +175904,21 @@ We have encountered a collision between the index name on columns ${source_defau
175695
175904
  lock: value.config.lock
175696
175905
  };
175697
175906
  });
175698
- checks6.forEach((check3) => {
175699
- const checkName = check3.name;
175907
+ checks6.forEach((check4) => {
175908
+ const checkName = check4.name;
175700
175909
  if (typeof checksInTable[tableName] !== "undefined") {
175701
- if (checksInTable[tableName].includes(check3.name)) {
175910
+ if (checksInTable[tableName].includes(check4.name)) {
175702
175911
  console.log(`
175703
175912
  ${withStyle.errorWarning(`We've found duplicated check constraint name in ${source_default.underline.blue(tableName)}. Please rename your check constraint in the ${source_default.underline.blue(tableName)} table`)}`);
175704
175913
  process.exit(1);
175705
175914
  }
175706
175915
  checksInTable[tableName].push(checkName);
175707
175916
  } else {
175708
- checksInTable[tableName] = [check3.name];
175917
+ checksInTable[tableName] = [check4.name];
175709
175918
  }
175710
175919
  checkConstraintObject[checkName] = {
175711
175920
  name: checkName,
175712
- value: dialect6.sqlToQuery(check3.value).sql
175921
+ value: dialect6.sqlToQuery(check4.value).sql
175713
175922
  };
175714
175923
  });
175715
175924
  if (!schema5) {
@@ -182641,15 +182850,20 @@ var init_timeback_controller = __esm(() => {
182641
182850
  });
182642
182851
  });
182643
182852
  getLatestRuntimeAssessment = requireDeveloper(async (ctx) => {
182853
+ const purpose = ctx.url.searchParams.get("purpose");
182644
182854
  const query = LatestRuntimeAssessmentQuerySchema.safeParse({
182645
182855
  gameId: ctx.url.searchParams.get("gameId"),
182646
182856
  studentId: ctx.url.searchParams.get("studentId"),
182647
- purpose: ctx.url.searchParams.get("purpose"),
182857
+ purpose,
182648
182858
  subject: ctx.url.searchParams.get("subject") ?? undefined,
182649
- grade: ctx.url.searchParams.get("grade") ?? undefined
182859
+ grade: ctx.url.searchParams.get("grade") ?? undefined,
182860
+ standard: purpose === "mastery" ? {
182861
+ framework: ctx.url.searchParams.get("standardFramework"),
182862
+ identifier: ctx.url.searchParams.get("standardIdentifier")
182863
+ } : undefined
182650
182864
  });
182651
182865
  if (!query.success) {
182652
- throw ApiError.badRequest("Missing or invalid gameId, studentId, purpose, subject, or grade");
182866
+ throw ApiError.badRequest("Missing or invalid gameId, studentId, purpose, subject, grade, or mastery standard");
182653
182867
  }
182654
182868
  return ctx.services.timebackAssessmentRuntime.latest({
182655
182869
  ...query.data,
@@ -182997,6 +183211,7 @@ var init_timeback_controller = __esm(() => {
182997
183211
  return ctx.services.timebackAssessments.createAssessment(integrationId, {
182998
183212
  title: body2.title,
182999
183213
  purpose: body2.purpose,
183214
+ standard: body2.standard,
183000
183215
  qtiTestIdentifier
183001
183216
  });
183002
183217
  });
@@ -183071,7 +183286,7 @@ var init_timeback_controller = __esm(() => {
183071
183286
  const body2 = await parseRequestBody(ctx.request, CopyAssessmentRequestSchema);
183072
183287
  const integrationId = await ctx.services.timebackAssessments.resolveIntegrationId(gameId, courseId, ctx.user);
183073
183288
  const targetTestIdentifier = newPlaycademyTestIdentifier();
183074
- return ctx.services.timebackAssessments.copyAssessment(integrationId, body2.testIdentifier, targetTestIdentifier, body2.purpose);
183289
+ return ctx.services.timebackAssessments.copyAssessment(integrationId, body2.testIdentifier, targetTestIdentifier, body2.purpose, body2.standard);
183075
183290
  });
183076
183291
  createQuestion = requireDeveloper(async (ctx) => {
183077
183292
  const { gameId, courseId, testIdentifier } = ctx.params;
@@ -184996,7 +185211,7 @@ var init_timeback9 = __esm3(() => {
184996
185211
  "Math",
184997
185212
  "None"
184998
185213
  ];
184999
- ASSESSMENT_PURPOSES2 = ["end_of_course", "diagnostic", "review"];
185214
+ ASSESSMENT_PURPOSES2 = ["end_of_course", "diagnostic", "review", "mastery"];
185000
185215
  TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS2 = {
185001
185216
  standards: 20,
185002
185217
  itemsPerStandard: 5,