@playcademy/sandbox 0.7.1-beta.22 → 0.7.1-beta.24

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 (3) hide show
  1. package/dist/cli.js +1069 -655
  2. package/dist/server.js +1069 -655
  3. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -1122,7 +1122,7 @@ var package_default;
1122
1122
  var init_package = __esm(() => {
1123
1123
  package_default = {
1124
1124
  name: "@playcademy/sandbox",
1125
- version: "0.7.1-beta.22",
1125
+ version: "0.7.1-beta.24",
1126
1126
  description: "Local development server for Playcademy game development",
1127
1127
  type: "module",
1128
1128
  exports: {
@@ -9455,6 +9455,9 @@ function isAssessmentAttemptOpen(attempt) {
9455
9455
  function isAssessmentAttemptCompleted(attempt) {
9456
9456
  return attempt.inProgress === ASSESSMENT_ATTEMPT_COMPLETED.inProgress && attempt.scoreStatus === ASSESSMENT_ATTEMPT_COMPLETED.scoreStatus;
9457
9457
  }
9458
+ function isAssessmentAttemptSuperseded(attempt) {
9459
+ return attempt.inProgress === ASSESSMENT_ATTEMPT_SUPERSEDED.inProgress && attempt.scoreStatus === ASSESSMENT_ATTEMPT_SUPERSEDED.scoreStatus;
9460
+ }
9458
9461
  function classifyAssessmentSubmission(attempt, submissionId) {
9459
9462
  if (isAssessmentAttemptCompleted(attempt)) {
9460
9463
  return attempt.submissionId === submissionId ? "replay" : "reject";
@@ -9512,6 +9515,15 @@ function assessmentReviewBankShortage(fulfillment) {
9512
9515
  function assessmentFlowForPurpose(purpose) {
9513
9516
  return purpose === "review" ? "item-submit" : "attempt-submit";
9514
9517
  }
9518
+ function compareCodeUnits(left, right) {
9519
+ if (left < right) {
9520
+ return -1;
9521
+ }
9522
+ if (left > right) {
9523
+ return 1;
9524
+ }
9525
+ return 0;
9526
+ }
9515
9527
  function canonicalJson(value) {
9516
9528
  if (value === null || typeof value !== "object") {
9517
9529
  return JSON.stringify(value) ?? "null";
@@ -9519,18 +9531,9 @@ function canonicalJson(value) {
9519
9531
  if (Array.isArray(value)) {
9520
9532
  return `[${value.map((item) => canonicalJson(item)).join(",")}]`;
9521
9533
  }
9522
- const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== undefined).toSorted(([left], [right]) => compareCanonicalKeys(left, right)).map(([key, entryValue]) => `${JSON.stringify(key)}:${canonicalJson(entryValue)}`);
9534
+ const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== undefined).toSorted(([left], [right]) => compareCodeUnits(left, right)).map(([key, entryValue]) => `${JSON.stringify(key)}:${canonicalJson(entryValue)}`);
9523
9535
  return `{${entries.join(",")}}`;
9524
9536
  }
9525
- function compareCanonicalKeys(left, right) {
9526
- if (left < right) {
9527
- return -1;
9528
- }
9529
- if (left > right) {
9530
- return 1;
9531
- }
9532
- return 0;
9533
- }
9534
9537
  async function diagnosticRoutingRevision(manifest) {
9535
9538
  const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonicalJson(manifest)));
9536
9539
  return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
@@ -10830,15 +10833,6 @@ function assessmentPresentationForAttempt(assessment, attemptId) {
10830
10833
  });
10831
10834
  return { ...assessment, items };
10832
10835
  }
10833
- function compareCodeUnits(left, right) {
10834
- if (left < right) {
10835
- return -1;
10836
- }
10837
- if (left > right) {
10838
- return 1;
10839
- }
10840
- return 0;
10841
- }
10842
10836
  function reviewStandardFieldsWithinLimits(input) {
10843
10837
  return input.framework.trim().length <= TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standardFieldLength && input.identifier.trim().length <= TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standardFieldLength;
10844
10838
  }
@@ -10849,6 +10843,19 @@ function canonicalReviewStandardRef(input) {
10849
10843
  }
10850
10844
  return standard.framework && standard.identifier ? standard : null;
10851
10845
  }
10846
+ function isKnownDescriptiveCurriculumFramework(framework) {
10847
+ return framework === "CCSS" || framework.startsWith("CCSS.");
10848
+ }
10849
+ function reviewRoutingStandardRefsFromMetadata(metadata2, options = {}) {
10850
+ const refs = new Map;
10851
+ for (const authored of qtiAssessmentStandardRefsFromMetadata(metadata2)) {
10852
+ const standard = canonicalReviewStandardRef(authored);
10853
+ if (standard && (!options.customOnly || !isKnownDescriptiveCurriculumFramework(standard.framework))) {
10854
+ refs.set(assessmentStandardRefKey(standard), standard);
10855
+ }
10856
+ }
10857
+ return [...refs.values()];
10858
+ }
10852
10859
  function canonicalRequestStandards(standards) {
10853
10860
  if (standards.length > TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standards) {
10854
10861
  throw new RangeError(`A review request may contain at most ${TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standards} standards`);
@@ -10904,42 +10911,172 @@ function qtiQuestionByIdentifier(questions) {
10904
10911
  }
10905
10912
  return byIdentifier;
10906
10913
  }
10907
- async function buildReviewBankIndex(assessment, questions) {
10914
+ async function reviewBankRevision(input) {
10915
+ const alignmentSignature = input.items.map((item) => ({
10916
+ itemIdentifier: item.itemIdentifier,
10917
+ standardKeys: item.standards.map(assessmentStandardRefKey)
10918
+ }));
10919
+ const bankRevisionUuid = await deterministicUUID(`playcademy:review-bank:v1:${JSON.stringify({
10920
+ bankIdentifier: input.bankIdentifier,
10921
+ contentRevision: input.sourceContentRevision,
10922
+ alignments: alignmentSignature
10923
+ })}`);
10924
+ return `review-bank-v1:${bankRevisionUuid}`;
10925
+ }
10926
+ async function reviewBankIndex(input) {
10927
+ return {
10928
+ ...input,
10929
+ bankRevision: await reviewBankRevision(input)
10930
+ };
10931
+ }
10932
+ async function reviewBankSourceFingerprint(input) {
10933
+ const fingerprintUuid = await deterministicUUID(`playcademy:review-bank-source:v1:${JSON.stringify({
10934
+ bankIdentifier: input.bankIdentifier,
10935
+ items: input.items.map((item) => ({
10936
+ itemIdentifier: item.itemIdentifier,
10937
+ standardKeys: item.standards.map(assessmentStandardRefKey)
10938
+ }))
10939
+ })}`);
10940
+ return `review-bank-source-v1:${fingerprintUuid}`;
10941
+ }
10942
+ async function buildReviewBankIndex(assessment, questions, options = {}) {
10908
10943
  if (assessment.identifier !== questions.assessmentTest) {
10909
10944
  throw new Error(`QTI questions for ${questions.assessmentTest} do not describe assessment ${assessment.identifier}`);
10910
10945
  }
10911
10946
  const questionByIdentifier = qtiQuestionByIdentifier(questions);
10912
10947
  const items = assessment.items.map((item) => {
10913
10948
  const question = questionByIdentifier.get(item.identifier);
10914
- const canonical = new Map;
10915
- for (const authored of qtiAssessmentStandardRefsFromMetadata(question?.metadata)) {
10916
- const standard = canonicalReviewStandardRef(authored);
10917
- if (standard) {
10918
- canonical.set(assessmentStandardRefKey(standard), standard);
10919
- }
10920
- }
10921
- const standards = [...canonical.values()].toSorted((left, right) => compareCodeUnits(assessmentStandardRefKey(left), assessmentStandardRefKey(right)));
10949
+ const standards = reviewRoutingStandardRefsFromMetadata(question?.metadata, options).toSorted((left, right) => compareCodeUnits(assessmentStandardRefKey(left), assessmentStandardRefKey(right)));
10922
10950
  return {
10923
10951
  itemIdentifier: item.identifier,
10924
10952
  standards
10925
10953
  };
10926
10954
  });
10927
- const alignmentSignature = items.map((item) => ({
10928
- itemIdentifier: item.itemIdentifier,
10929
- standardKeys: item.standards.map(assessmentStandardRefKey)
10930
- }));
10931
- const bankRevisionUuid = await deterministicUUID(`playcademy:review-bank:v1:${JSON.stringify({
10932
- bankIdentifier: assessment.identifier,
10933
- contentRevision: assessment.contentRevision,
10934
- alignments: alignmentSignature
10935
- })}`);
10936
- return {
10955
+ return reviewBankIndex({
10937
10956
  bankIdentifier: assessment.identifier,
10938
10957
  sourceContentRevision: assessment.contentRevision,
10939
- bankRevision: `review-bank-v1:${bankRevisionUuid}`,
10940
10958
  items
10959
+ });
10960
+ }
10961
+ function emptyReviewBankManifest(bankIdentifier) {
10962
+ return {
10963
+ version: PLAYCADEMY_REVIEW_BANK_MANIFEST_VERSION,
10964
+ bankIdentifier,
10965
+ sourceFingerprint: null,
10966
+ sourceContentRevision: null,
10967
+ bankRevision: null,
10968
+ itemsByStandard: {}
10969
+ };
10970
+ }
10971
+ function reviewBankMappingIssues(bank) {
10972
+ return {
10973
+ missingOrInvalidItemIdentifiers: bank.items.filter((item) => item.standards.length === 0).map((item) => item.itemIdentifier),
10974
+ multipleStandardItemIdentifiers: bank.items.filter((item) => item.standards.length > 1).map((item) => item.itemIdentifier)
10975
+ };
10976
+ }
10977
+ async function buildReviewBankManifest(bank) {
10978
+ const itemsByStandard = new Map;
10979
+ for (const item of bank.items) {
10980
+ for (const standard of item.standards) {
10981
+ const key = assessmentStandardRefKey(standard);
10982
+ const identifiers = itemsByStandard.get(key) ?? [];
10983
+ identifiers.push(item.itemIdentifier);
10984
+ itemsByStandard.set(key, identifiers);
10985
+ }
10986
+ }
10987
+ return {
10988
+ version: PLAYCADEMY_REVIEW_BANK_MANIFEST_VERSION,
10989
+ bankIdentifier: bank.bankIdentifier,
10990
+ sourceFingerprint: await reviewBankSourceFingerprint(bank),
10991
+ sourceContentRevision: bank.sourceContentRevision,
10992
+ bankRevision: bank.bankRevision,
10993
+ itemsByStandard: Object.fromEntries([...itemsByStandard.entries()].toSorted(([left], [right]) => compareCodeUnits(left, right)))
10941
10994
  };
10942
10995
  }
10996
+ function requiredManifestString(record, field) {
10997
+ const value = record[field];
10998
+ if (typeof value !== "string" || !value.trim()) {
10999
+ throw new Error(`Review-bank manifest requires ${field}`);
11000
+ }
11001
+ return value.trim();
11002
+ }
11003
+ function standardFromManifestKey(key) {
11004
+ try {
11005
+ const parsed = JSON.parse(key);
11006
+ if (!Array.isArray(parsed) || parsed.length !== 2 || typeof parsed[0] !== "string" || typeof parsed[1] !== "string") {
11007
+ return null;
11008
+ }
11009
+ const standard = canonicalReviewStandardRef({
11010
+ framework: parsed[0],
11011
+ identifier: parsed[1]
11012
+ });
11013
+ return standard && assessmentStandardRefKey(standard) === key ? standard : null;
11014
+ } catch {
11015
+ return null;
11016
+ }
11017
+ }
11018
+ async function reviewBankIndexFromManifest(metadata2, input) {
11019
+ const raw = isRecord(metadata2) ? metadata2[PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY] : undefined;
11020
+ if (raw === undefined) {
11021
+ return null;
11022
+ }
11023
+ if (!isRecord(raw) || raw.version !== PLAYCADEMY_REVIEW_BANK_MANIFEST_VERSION) {
11024
+ throw new Error("Review-bank manifest has an unsupported version or shape");
11025
+ }
11026
+ const manifest = raw;
11027
+ const bankIdentifier = requiredManifestString(manifest, "bankIdentifier");
11028
+ if (bankIdentifier !== input.bankIdentifier) {
11029
+ throw new Error(`Review-bank manifest for ${bankIdentifier} does not describe ${input.bankIdentifier}`);
11030
+ }
11031
+ if (manifest.sourceFingerprint === null && manifest.sourceContentRevision === null && manifest.bankRevision === null) {
11032
+ return null;
11033
+ }
11034
+ const sourceFingerprint = requiredManifestString(manifest, "sourceFingerprint");
11035
+ const sourceContentRevision = requiredManifestString(manifest, "sourceContentRevision");
11036
+ const declaredBankRevision = requiredManifestString(manifest, "bankRevision");
11037
+ const itemsByStandard = manifest.itemsByStandard;
11038
+ if (!isRecord(itemsByStandard)) {
11039
+ throw new Error("Review-bank manifest requires an itemsByStandard mapping");
11040
+ }
11041
+ const membership = new Set(input.membershipItemIdentifiers);
11042
+ const standardsByItem = new Map;
11043
+ for (const [standardKey, rawItemIdentifiers] of Object.entries(itemsByStandard)) {
11044
+ const standard = standardFromManifestKey(standardKey);
11045
+ if (!standard || !Array.isArray(rawItemIdentifiers)) {
11046
+ throw new Error("Review-bank manifest contains an invalid standard mapping");
11047
+ }
11048
+ for (const rawItemIdentifier of rawItemIdentifiers) {
11049
+ if (typeof rawItemIdentifier !== "string" || !rawItemIdentifier.trim()) {
11050
+ throw new Error("Review-bank manifest contains an invalid item identifier");
11051
+ }
11052
+ const itemIdentifier = rawItemIdentifier.trim();
11053
+ if (membership.has(itemIdentifier)) {
11054
+ const standards = standardsByItem.get(itemIdentifier) ?? new Map;
11055
+ standards.set(assessmentStandardRefKey(standard), standard);
11056
+ standardsByItem.set(itemIdentifier, standards);
11057
+ }
11058
+ }
11059
+ }
11060
+ const index = await reviewBankIndex({
11061
+ bankIdentifier,
11062
+ sourceContentRevision,
11063
+ items: input.membershipItemIdentifiers.map((itemIdentifier) => ({
11064
+ itemIdentifier,
11065
+ standards: [...standardsByItem.get(itemIdentifier)?.values() ?? []].toSorted((left, right) => compareCodeUnits(assessmentStandardRefKey(left), assessmentStandardRefKey(right)))
11066
+ }))
11067
+ });
11068
+ const issues = reviewBankMappingIssues(index);
11069
+ if (issues.missingOrInvalidItemIdentifiers.length > 0 || issues.multipleStandardItemIdentifiers.length > 0) {
11070
+ throw new Error("Review-bank manifest must map every member to exactly one standard/node key");
11071
+ }
11072
+ if (await reviewBankSourceFingerprint(index) !== sourceFingerprint) {
11073
+ throw new Error("Review-bank manifest source fingerprint is stale");
11074
+ }
11075
+ if (index.bankRevision !== declaredBankRevision) {
11076
+ throw new Error("Review-bank manifest revision does not match its candidate index");
11077
+ }
11078
+ return index;
11079
+ }
10943
11080
  function exposureTimestamp(value) {
10944
11081
  const timestamp = Date.parse(value);
10945
11082
  return Number.isFinite(timestamp) ? timestamp : 0;
@@ -11390,7 +11527,7 @@ function playcademyDiagnosticAssessmentItemResultMetadata(value) {
11390
11527
  const normalized = metadata2.responses === undefined ? { ...metadata2, responses: {} } : metadata2;
11391
11528
  return isPlaycademyDiagnosticAssessmentItemResultMetadataV1(normalized) ? normalized : null;
11392
11529
  }
11393
- var SCRIPT_SCHEMES, DATA_RASTER_IMAGE_PATTERN, QTI_MATHML_ALLOWED_TAGS, metadataSymbol, parser, SUPPORTED_QTI_INTERACTION_TYPES, URL_ATTRIBUTES, IMAGE_URL_ATTRIBUTES, INTERACTION_TYPES, EMPHASIS_TAGS, STRONG_TAGS, CONTENT_SKIPPED_TAGS, BLOCK_CONTENT_KINDS, GAP_MATCH_TOKEN_TAGS, STAGE_GRAPHIC_EXCLUDED_CONTAINERS, BLANK_SENTINEL = "￿", MARKED_BLANK_PATTERN, MARKED_BLANK_GLOBAL_PATTERN, MATCH_CORRECT_TEMPLATE = "http://www.imsglobal.org/question/qti_v3p0/rptemplates/match_correct", MAP_RESPONSE_TEMPLATE = "https://purl.imsglobal.org/spec/qti/v3p0/rptemplates/map_response", MAP_RESPONSE_TEMPLATES, RESPONSE_PROCESSING_TEMPLATES, VOID_BODY_ELEMENTS, URL_ATTRIBUTES2, IMAGE_URL_ATTRIBUTES2, VOID_CHOICE_ELEMENTS, NUMERIC_COMPARISON_ATTRIBUTES, RESPONSE_CARDINALITIES, RESPONSE_BASE_TYPES, POINT_INTERACTION_TYPES, INDEPENDENT_PROCESSING_TAGS, UUID_PATTERN, COMMON_CORE_MATH_FRAMEWORK_ALIASES, COMMON_CORE_ELA_FRAMEWORK_ALIASES, COMMON_CORE_FRAMEWORK_ALIASES, ASSESSMENT_ATTEMPT_OPEN, ASSESSMENT_ATTEMPT_COMPLETED, ASSESSMENT_RUNTIME_ERROR_STATUS, ROUTING_KEY_MAX_LENGTH = 128, ROUTING_RESULT_KEY_MAX_LENGTH = 256, ROUTING_STAGE_LIMIT = 32, ROUTING_TRACK_LIMIT = 128, ROUTING_NODE_LIMIT = 1000, ROUTING_TERMINAL_LIMIT = 1000, ROUTING_GROUP_LIMIT = 128, ROUTING_PREDICATE_DEPTH_LIMIT = 8, ROUTING_EXPLORATION_STATE_LIMIT = 200000, RoutingKeySchema, RoutingResultKeySchema, DiagnosticTrackOutcomeSchema, DiagnosticActivationPredicateSchema, DiagnosticRoutingTransitionSchema, DiagnosticRoutingManifestV1Schema, GRADE_VALUES, POINT_RESPONSE_PATTERN, REVIEW_SELECTION_POLICY_VERSION = "unseen-first-least-recently-delivered-v1", DEFAULT_REVIEW_SELECTION_POLICY, RuntimeSubjectSchema, RuntimeGradeSchema, OptionalQueryGradeSchema, AssessmentResponseValueSchema, AssessmentRuntimeIdentitySchema, ResponseKeySchema, StartAssessmentBaseSchema, AssessmentStandardRefSchema, LatestAssessmentFilterBaseSchema, LatestAssessmentFiltersSchema, LatestRuntimeAssessmentQuerySchema, StartAssessmentBodySchema, SaveAssessmentBodySchema, SubmitAssessmentItemBodySchema, SubmitAssessmentBodySchema, StartRuntimeAssessmentRequestSchema, SaveRuntimeAssessmentRequestSchema, SubmitAssessmentItemRuntimeRequestSchema, SubmitRuntimeAssessmentRequestSchema;
11530
+ var SCRIPT_SCHEMES, DATA_RASTER_IMAGE_PATTERN, QTI_MATHML_ALLOWED_TAGS, metadataSymbol, parser, SUPPORTED_QTI_INTERACTION_TYPES, URL_ATTRIBUTES, IMAGE_URL_ATTRIBUTES, INTERACTION_TYPES, EMPHASIS_TAGS, STRONG_TAGS, CONTENT_SKIPPED_TAGS, BLOCK_CONTENT_KINDS, GAP_MATCH_TOKEN_TAGS, STAGE_GRAPHIC_EXCLUDED_CONTAINERS, BLANK_SENTINEL = "￿", MARKED_BLANK_PATTERN, MARKED_BLANK_GLOBAL_PATTERN, MATCH_CORRECT_TEMPLATE = "http://www.imsglobal.org/question/qti_v3p0/rptemplates/match_correct", MAP_RESPONSE_TEMPLATE = "https://purl.imsglobal.org/spec/qti/v3p0/rptemplates/map_response", MAP_RESPONSE_TEMPLATES, RESPONSE_PROCESSING_TEMPLATES, VOID_BODY_ELEMENTS, URL_ATTRIBUTES2, IMAGE_URL_ATTRIBUTES2, VOID_CHOICE_ELEMENTS, NUMERIC_COMPARISON_ATTRIBUTES, RESPONSE_CARDINALITIES, RESPONSE_BASE_TYPES, POINT_INTERACTION_TYPES, INDEPENDENT_PROCESSING_TAGS, UUID_PATTERN, COMMON_CORE_MATH_FRAMEWORK_ALIASES, COMMON_CORE_ELA_FRAMEWORK_ALIASES, COMMON_CORE_FRAMEWORK_ALIASES, ASSESSMENT_ATTEMPT_OPEN, ASSESSMENT_ATTEMPT_COMPLETED, ASSESSMENT_ATTEMPT_SUPERSEDED, ASSESSMENT_RUNTIME_ERROR_STATUS, ROUTING_KEY_MAX_LENGTH = 128, ROUTING_RESULT_KEY_MAX_LENGTH = 256, ROUTING_STAGE_LIMIT = 32, ROUTING_TRACK_LIMIT = 128, ROUTING_NODE_LIMIT = 1000, ROUTING_TERMINAL_LIMIT = 1000, ROUTING_GROUP_LIMIT = 128, ROUTING_PREDICATE_DEPTH_LIMIT = 8, ROUTING_EXPLORATION_STATE_LIMIT = 200000, RoutingKeySchema, RoutingResultKeySchema, DiagnosticTrackOutcomeSchema, DiagnosticActivationPredicateSchema, DiagnosticRoutingTransitionSchema, DiagnosticRoutingManifestV1Schema, GRADE_VALUES, POINT_RESPONSE_PATTERN, REVIEW_SELECTION_POLICY_VERSION = "unseen-first-least-recently-delivered-v1", PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY = "playcademyReviewBank", PLAYCADEMY_REVIEW_BANK_MANIFEST_VERSION = 1, DEFAULT_REVIEW_SELECTION_POLICY, RuntimeSubjectSchema, RuntimeGradeSchema, OptionalQueryGradeSchema, AssessmentResponseValueSchema, AssessmentRuntimeIdentitySchema, ResponseKeySchema, StartAssessmentBaseSchema, AssessmentStandardRefSchema, LatestAssessmentFilterBaseSchema, LatestAssessmentFiltersSchema, LatestRuntimeAssessmentQuerySchema, StartAssessmentBodySchema, SaveAssessmentBodySchema, SubmitAssessmentItemBodySchema, SubmitAssessmentBodySchema, StartRuntimeAssessmentRequestSchema, SaveRuntimeAssessmentRequestSchema, SubmitAssessmentItemRuntimeRequestSchema, SubmitRuntimeAssessmentRequestSchema;
11394
11531
  var init_assessment_runtime2 = __esm(() => {
11395
11532
  init_timeback3();
11396
11533
  init_timeback3();
@@ -11575,6 +11712,10 @@ var init_assessment_runtime2 = __esm(() => {
11575
11712
  inProgress: "false",
11576
11713
  scoreStatus: "fully graded"
11577
11714
  };
11715
+ ASSESSMENT_ATTEMPT_SUPERSEDED = {
11716
+ inProgress: "false",
11717
+ scoreStatus: "not submitted"
11718
+ };
11578
11719
  ASSESSMENT_RUNTIME_ERROR_STATUS = {
11579
11720
  NO_ELIGIBLE_TESTS: 404,
11580
11721
  REVIEW_BANK_SHORTAGE: 422,
@@ -38330,71 +38471,6 @@ var init_infra2 = __esm(() => {
38330
38471
  init_kv_backup_service();
38331
38472
  });
38332
38473
 
38333
- // ../data/src/locks.ts
38334
- function createInMemoryDatabaseLock() {
38335
- const tails = new Map;
38336
- return async (db2, key, operation) => {
38337
- const previous = tails.get(key) ?? Promise.resolve();
38338
- let release;
38339
- const gate = new Promise((resolve) => {
38340
- release = resolve;
38341
- });
38342
- const tail = previous.then(() => gate);
38343
- tails.set(key, tail);
38344
- await previous;
38345
- try {
38346
- return await operation(db2);
38347
- } finally {
38348
- release();
38349
- if (tails.get(key) === tail) {
38350
- tails.delete(key);
38351
- }
38352
- }
38353
- };
38354
- }
38355
- var LockContentionError;
38356
- var init_locks = __esm(() => {
38357
- init_src6();
38358
- LockContentionError = class LockContentionError extends Error {
38359
- constructor(key) {
38360
- super(`Lock is already held: ${key}`);
38361
- this.name = "LockContentionError";
38362
- }
38363
- };
38364
- });
38365
-
38366
- // ../api-core/src/utils/assessment-runtime-lock.util.ts
38367
- function assessmentRuntimeStartLockKey(input) {
38368
- return JSON.stringify([
38369
- ASSESSMENT_RUNTIME_LOCK_NAMESPACE,
38370
- "start",
38371
- input.studentId,
38372
- input.activityId,
38373
- input.purpose,
38374
- input.courseId
38375
- ]);
38376
- }
38377
- function assessmentRuntimeAttemptLockKey(attemptId) {
38378
- return JSON.stringify([ASSESSMENT_RUNTIME_LOCK_NAMESPACE, "attempt", attemptId]);
38379
- }
38380
- function createAssessmentRuntimeLock(lock) {
38381
- return async (db2, key, operation) => {
38382
- try {
38383
- return await lock(db2, key, operation);
38384
- } catch (error) {
38385
- if (error instanceof LockContentionError) {
38386
- throw new ServiceUnavailableError("Another assessment operation is in progress. Try again shortly.", { retryable: true });
38387
- }
38388
- throw error;
38389
- }
38390
- };
38391
- }
38392
- var ASSESSMENT_RUNTIME_LOCK_NAMESPACE = "playcademy-assessment-runtime-v1";
38393
- var init_assessment_runtime_lock_util = __esm(() => {
38394
- init_locks();
38395
- init_errors2();
38396
- });
38397
-
38398
38474
  // ../api-core/src/services/bucket.service.ts
38399
38475
  function hasPagingOptions(options) {
38400
38476
  return options.cursor !== undefined || options.limit !== undefined || options.delimiter !== undefined;
@@ -89177,73 +89253,6 @@ function stringField2(value) {
89177
89253
  function firstStringField2(...values) {
89178
89254
  return values.map(stringField2).find(Boolean) ?? "";
89179
89255
  }
89180
- function normalizedWhitespace2(value) {
89181
- return value.normalize("NFKC").trim().replace(/\s+/g, " ");
89182
- }
89183
- function normalizedIdentityCase2(value) {
89184
- return value.toLocaleUpperCase("en-US");
89185
- }
89186
- function frameworkAliasKey2(value) {
89187
- return value.normalize("NFKC").toLocaleLowerCase("en-US").replace(/[^a-z0-9]+/g, "");
89188
- }
89189
- function isUuidShaped2(value) {
89190
- return UUID_PATTERN2.test(value.trim());
89191
- }
89192
- function isCommonCoreMathIdentifier2(identifier) {
89193
- const canonical = normalizedIdentityCase2(normalizedWhitespace2(identifier));
89194
- return canonical.startsWith("CCSS.MATH.") || /^(?:K|[1-8])\.(?:CC|OA|NBT|NF|MD|RP|NS|EE|F|G|SP)\./.test(canonical) || /^(?:HS)?(?:N|A|F|G|S)-[A-Z]+\./.test(canonical) || /^MP\.?\d/.test(canonical);
89195
- }
89196
- function isCommonCoreElaIdentifier2(identifier) {
89197
- const canonical = normalizedIdentityCase2(normalizedWhitespace2(identifier));
89198
- return canonical.startsWith("CCSS.ELA-LITERACY.") || /^(?:RL|RI|RF|W|SL|L)\.(?:K|[1-9]|1[0-2])\./.test(canonical) || /^(?:RH|RST|WHST)\.(?:6-8|9-10|11-12)\./.test(canonical) || /^CCRA\.(?:R|W|SL|L)\./.test(canonical);
89199
- }
89200
- function canonicalFramework2(authoredFramework, identifier) {
89201
- const aliasKey = frameworkAliasKey2(authoredFramework);
89202
- if (COMMON_CORE_MATH_FRAMEWORK_ALIASES2.has(aliasKey) || COMMON_CORE_FRAMEWORK_ALIASES2.has(aliasKey) && isCommonCoreMathIdentifier2(identifier)) {
89203
- return "CCSS.Math";
89204
- }
89205
- if (COMMON_CORE_ELA_FRAMEWORK_ALIASES2.has(aliasKey) || COMMON_CORE_FRAMEWORK_ALIASES2.has(aliasKey) && isCommonCoreElaIdentifier2(identifier)) {
89206
- return "CCSS.ELA-Literacy";
89207
- }
89208
- if (COMMON_CORE_FRAMEWORK_ALIASES2.has(aliasKey)) {
89209
- return "CCSS";
89210
- }
89211
- return normalizedIdentityCase2(authoredFramework);
89212
- }
89213
- function canonicalIdentifier2(framework, authoredIdentifier) {
89214
- const identifier = normalizedIdentityCase2(normalizedWhitespace2(authoredIdentifier));
89215
- if (framework === "CCSS.Math") {
89216
- return identifier.replace(/^CCSS\.MATH\.CONTENT\./, "").replace(/^CCSS\.MATH\.PRACTICE\./, "").replace(/^CCSS\.MATH\./, "");
89217
- }
89218
- if (framework === "CCSS.ELA-Literacy") {
89219
- return identifier.replace(/^CCSS\.ELA-LITERACY\./, "");
89220
- }
89221
- return identifier;
89222
- }
89223
- function readableAlignmentIdentifier2(alignment) {
89224
- const identifier = alignment.identifier?.trim() ?? "";
89225
- if (identifier && !isUuidShaped2(identifier)) {
89226
- return identifier;
89227
- }
89228
- const id = alignment.id.trim();
89229
- return id && !isUuidShaped2(id) ? id : "";
89230
- }
89231
- function canonicalAssessmentStandardRef2(standard) {
89232
- const authoredFramework = normalizedWhitespace2(standard.framework);
89233
- const framework = canonicalFramework2(authoredFramework, standard.identifier);
89234
- const identifier = canonicalIdentifier2(framework, standard.identifier);
89235
- return {
89236
- framework,
89237
- identifier
89238
- };
89239
- }
89240
- function assessmentStandardRefKey2(standard) {
89241
- const canonical = canonicalAssessmentStandardRef2(standard);
89242
- return JSON.stringify([
89243
- normalizedIdentityCase2(canonical.framework),
89244
- normalizedIdentityCase2(canonical.identifier)
89245
- ]);
89246
- }
89247
89256
  function dedupeStandards2(standards) {
89248
89257
  const deduped = new Map;
89249
89258
  for (const standard of standards) {
@@ -89334,23 +89343,7 @@ function qtiStandardsFromMetadata(metadata2) {
89334
89343
  standards.push(...qtiAlignmentStandardsFromMetadata2(metadata2));
89335
89344
  return dedupeStandards2(standards);
89336
89345
  }
89337
- function qtiAssessmentStandardRefsFromMetadata2(metadata2) {
89338
- const refs = new Map;
89339
- for (const alignment of qtiAlignmentStandardsFromMetadata2(metadata2)) {
89340
- const identifier = readableAlignmentIdentifier2(alignment);
89341
- if (identifier) {
89342
- const canonical = canonicalAssessmentStandardRef2({
89343
- framework: alignment.source,
89344
- identifier
89345
- });
89346
- if (canonical.framework && canonical.identifier) {
89347
- refs.set(assessmentStandardRefKey2(canonical), canonical);
89348
- }
89349
- }
89350
- }
89351
- return [...refs.values()];
89352
- }
89353
- var EVENT_HANDLER_ATTRIBUTE, SCRIPT_SCHEMES2, DATA_RASTER_IMAGE_PATTERN2, QTI_MATHML_ALLOWED_TAGS2, metadataSymbol2, parser2, SUPPORTED_QTI_INTERACTION_TYPES2, URL_ATTRIBUTES3, IMAGE_URL_ATTRIBUTES3, INTERACTION_TYPES2, XML_NAMED_ENTITIES, EMPHASIS_TAGS2, STRONG_TAGS2, CONTENT_SKIPPED_TAGS2, BLOCK_CONTENT_KINDS2, GAP_MATCH_TOKEN_TAGS2, STAGE_GRAPHIC_EXCLUDED_CONTAINERS2, BLANK_SENTINEL2 = "￿", MARKED_BLANK_PATTERN2, MARKED_BLANK_GLOBAL_PATTERN2, REGION_SHAPE_COORDS, QTI_NAMESPACE = "http://www.imsglobal.org/xsd/imsqtiasi_v3p0", QTI_AUTHORING_BLANK_MARKER = "___", MATCH_CORRECT_TEMPLATE2 = "http://www.imsglobal.org/question/qti_v3p0/rptemplates/match_correct", MAP_RESPONSE_TEMPLATE2 = "https://purl.imsglobal.org/spec/qti/v3p0/rptemplates/map_response", MAP_RESPONSE_TEMPLATES2, RESPONSE_PROCESSING_TEMPLATES2, GLOBAL_BODY_ATTRIBUTES, BODY_ELEMENT_ATTRIBUTES, MATHML_ATTRIBUTES, VOID_BODY_ELEMENTS2, URL_ATTRIBUTES22, IMAGE_URL_ATTRIBUTES22, INTERACTION_ATTRIBUTES, CHOICE_ATTRIBUTES, CHOICE_ELEMENT_ATTRIBUTES, VOID_CHOICE_ELEMENTS2, NUMERIC_COMPARISON_ATTRIBUTES2, RESPONSE_CARDINALITIES2, RESPONSE_BASE_TYPES2, BLANK_SENTINEL22 = "￿", PLAYABLE_POINT_VALUE, POINT_INTERACTION_TYPES2, INDEPENDENT_PROCESSING_TAGS2, UUID_PATTERN2, COMMON_CORE_MATH_FRAMEWORK_ALIASES2, COMMON_CORE_ELA_FRAMEWORK_ALIASES2, COMMON_CORE_FRAMEWORK_ALIASES2;
89346
+ var EVENT_HANDLER_ATTRIBUTE, SCRIPT_SCHEMES2, DATA_RASTER_IMAGE_PATTERN2, QTI_MATHML_ALLOWED_TAGS2, metadataSymbol2, parser2, SUPPORTED_QTI_INTERACTION_TYPES2, URL_ATTRIBUTES3, IMAGE_URL_ATTRIBUTES3, INTERACTION_TYPES2, XML_NAMED_ENTITIES, EMPHASIS_TAGS2, STRONG_TAGS2, CONTENT_SKIPPED_TAGS2, BLOCK_CONTENT_KINDS2, GAP_MATCH_TOKEN_TAGS2, STAGE_GRAPHIC_EXCLUDED_CONTAINERS2, BLANK_SENTINEL2 = "￿", MARKED_BLANK_PATTERN2, MARKED_BLANK_GLOBAL_PATTERN2, REGION_SHAPE_COORDS, QTI_NAMESPACE = "http://www.imsglobal.org/xsd/imsqtiasi_v3p0", QTI_AUTHORING_BLANK_MARKER = "___", MATCH_CORRECT_TEMPLATE2 = "http://www.imsglobal.org/question/qti_v3p0/rptemplates/match_correct", MAP_RESPONSE_TEMPLATE2 = "https://purl.imsglobal.org/spec/qti/v3p0/rptemplates/map_response", MAP_RESPONSE_TEMPLATES2, RESPONSE_PROCESSING_TEMPLATES2, GLOBAL_BODY_ATTRIBUTES, BODY_ELEMENT_ATTRIBUTES, MATHML_ATTRIBUTES, VOID_BODY_ELEMENTS2, URL_ATTRIBUTES22, IMAGE_URL_ATTRIBUTES22, INTERACTION_ATTRIBUTES, CHOICE_ATTRIBUTES, CHOICE_ELEMENT_ATTRIBUTES, VOID_CHOICE_ELEMENTS2, NUMERIC_COMPARISON_ATTRIBUTES2, RESPONSE_CARDINALITIES2, RESPONSE_BASE_TYPES2, BLANK_SENTINEL22 = "￿", PLAYABLE_POINT_VALUE, POINT_INTERACTION_TYPES2, INDEPENDENT_PROCESSING_TAGS2, COMMON_CORE_MATH_FRAMEWORK_ALIASES2, COMMON_CORE_ELA_FRAMEWORK_ALIASES2, COMMON_CORE_FRAMEWORK_ALIASES2;
89354
89347
  var init_qti = __esm(() => {
89355
89348
  init_timeback3();
89356
89349
  init_timeback3();
@@ -89600,7 +89593,6 @@ var init_qti = __esm(() => {
89600
89593
  "qti-sum",
89601
89594
  "qti-base-value"
89602
89595
  ]);
89603
- UUID_PATTERN2 = /^(?:urn:uuid:)?\{?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}?$/i;
89604
89596
  COMMON_CORE_MATH_FRAMEWORK_ALIASES2 = new Set([
89605
89597
  "ccssm",
89606
89598
  "ccssmath",
@@ -91961,6 +91953,110 @@ var init_timeback_admin_service = __esm(async () => {
91961
91953
  ]);
91962
91954
  });
91963
91955
 
91956
+ // ../data/src/locks.ts
91957
+ function createInMemoryDatabaseLock() {
91958
+ const tails = new Map;
91959
+ return async (db2, key, operation) => {
91960
+ const previous = tails.get(key) ?? Promise.resolve();
91961
+ let release;
91962
+ const gate = new Promise((resolve) => {
91963
+ release = resolve;
91964
+ });
91965
+ const tail = previous.then(() => gate);
91966
+ tails.set(key, tail);
91967
+ await previous;
91968
+ try {
91969
+ return await operation(db2);
91970
+ } finally {
91971
+ release();
91972
+ if (tails.get(key) === tail) {
91973
+ tails.delete(key);
91974
+ }
91975
+ }
91976
+ };
91977
+ }
91978
+ var LockContentionError;
91979
+ var init_locks = __esm(() => {
91980
+ LockContentionError = class LockContentionError extends Error {
91981
+ constructor(key) {
91982
+ super(`Lock is already held: ${key}`);
91983
+ this.name = "LockContentionError";
91984
+ }
91985
+ };
91986
+ });
91987
+
91988
+ // ../api-core/src/utils/assessment-runtime-lock.util.ts
91989
+ function normalizeKeys(keys) {
91990
+ return [...new Set(keys)].toSorted();
91991
+ }
91992
+ function errorCode(error88) {
91993
+ if (typeof error88 !== "object" || error88 === null || !("code" in error88)) {
91994
+ return;
91995
+ }
91996
+ return typeof error88.code === "string" ? error88.code : undefined;
91997
+ }
91998
+ function translateAssessmentRuntimeLockError(error88) {
91999
+ if (error88 instanceof LockContentionError) {
92000
+ throw new ServiceUnavailableError("Another assessment operation is in progress. Try again shortly.", { retryable: true });
92001
+ }
92002
+ if (error88 instanceof AssessmentRuntimeLockTimeoutError) {
92003
+ throw new ServiceUnavailableError("The assessment operation took too long. Try again shortly.", { retryable: true, reason: "LOCK_TIMEOUT" });
92004
+ }
92005
+ const code = errorCode(error88);
92006
+ if (code && POSTGRES_TIMEOUT_ERROR_CODES.has(code)) {
92007
+ throw new ServiceUnavailableError("The assessment operation took too long. Try again shortly.", { retryable: true, reason: "LOCK_TIMEOUT" });
92008
+ }
92009
+ if (code && POSTGRES_CONNECTION_ERROR_CODES.has(code)) {
92010
+ throw new ServiceUnavailableError("The assessment lock connection was interrupted. Try again shortly.", { retryable: true, reason: "LOCK_CONNECTION_LOST" });
92011
+ }
92012
+ throw error88;
92013
+ }
92014
+ function createInMemoryAssessmentRuntimeLock() {
92015
+ const lock = createInMemoryDatabaseLock();
92016
+ return async (db2, keys, operation) => {
92017
+ const ordered = normalizeKeys(keys);
92018
+ function acquire(index2, operationDb) {
92019
+ const key = ordered[index2];
92020
+ return key ? lock(operationDb, key, (nested) => acquire(index2 + 1, nested)) : operation(operationDb);
92021
+ }
92022
+ try {
92023
+ return await acquire(0, db2);
92024
+ } catch (error88) {
92025
+ return translateAssessmentRuntimeLockError(error88);
92026
+ }
92027
+ };
92028
+ }
92029
+ function assessmentRuntimeStartLockKey(input) {
92030
+ return JSON.stringify([
92031
+ ASSESSMENT_RUNTIME_LOCK_NAMESPACE,
92032
+ "start",
92033
+ input.studentId,
92034
+ input.activityId,
92035
+ input.purpose,
92036
+ input.courseId
92037
+ ]);
92038
+ }
92039
+ function assessmentRuntimeAttemptLockKey(attemptId) {
92040
+ return JSON.stringify([ASSESSMENT_RUNTIME_LOCK_NAMESPACE, "attempt", attemptId]);
92041
+ }
92042
+ var ASSESSMENT_RUNTIME_LOCK_NAMESPACE = "playcademy-assessment-runtime-v1", POSTGRES_TIMEOUT_ERROR_CODES, POSTGRES_CONNECTION_ERROR_CODES, AssessmentRuntimeLockTimeoutError;
92043
+ var init_assessment_runtime_lock_util = __esm(() => {
92044
+ init_locks();
92045
+ init_errors2();
92046
+ POSTGRES_TIMEOUT_ERROR_CODES = new Set(["25P03", "57014"]);
92047
+ POSTGRES_CONNECTION_ERROR_CODES = new Set([
92048
+ "CONNECTION_CLOSED",
92049
+ "CONNECTION_DESTROYED",
92050
+ "CONNECTION_ENDED"
92051
+ ]);
92052
+ AssessmentRuntimeLockTimeoutError = class AssessmentRuntimeLockTimeoutError extends Error {
92053
+ constructor(timeoutMs) {
92054
+ super(`Assessment operation exceeded its ${timeoutMs}ms lock deadline`);
92055
+ this.name = "AssessmentRuntimeLockTimeoutError";
92056
+ }
92057
+ };
92058
+ });
92059
+
91964
92060
  // ../api-core/src/utils/timeback-assessment-rules.util.ts
91965
92061
  function validateAssessmentStatusTransition(current, next) {
91966
92062
  if (current === next) {
@@ -92006,8 +92102,8 @@ function assertAssessmentHasQuestions(questions) {
92006
92102
  }
92007
92103
  }
92008
92104
  function assertReviewAssessmentHasStandards(standardCounts) {
92009
- if (standardCounts.some((count) => count <= 0)) {
92010
- throw new ValidationError("Every question in a review assessment must have a standards alignment");
92105
+ if (standardCounts.some((count) => count !== 1)) {
92106
+ throw new ValidationError("Every question in a review assessment must have exactly one standards alignment");
92011
92107
  }
92012
92108
  }
92013
92109
  function planAssessmentRemoval(status) {
@@ -92072,6 +92168,41 @@ var init_timeback_assessment_rules_util = __esm(() => {
92072
92168
  });
92073
92169
 
92074
92170
  // ../api-core/src/utils/timeback-assessment-runtime.util.ts
92171
+ function stageAssessmentAttemptSupersession(attempt) {
92172
+ Object.assign(attempt.result, ASSESSMENT_ATTEMPT_SUPERSEDED);
92173
+ Object.assign(attempt.selection, ASSESSMENT_ATTEMPT_SUPERSEDED);
92174
+ }
92175
+ function shouldConfirmAssessmentVersionUnavailable(details) {
92176
+ return typeof details === "object" && details !== null && "expectedRevision" in details && typeof details.expectedRevision === "string" && !("currentRevision" in details);
92177
+ }
92178
+ function buildAssessmentAttemptSupersessionUpdate(result) {
92179
+ if (result.status !== "active" || !isAssessmentAttemptOpen({
92180
+ inProgress: result.inProgress ?? "",
92181
+ scoreStatus: result.scoreStatus
92182
+ })) {
92183
+ return null;
92184
+ }
92185
+ return {
92186
+ status: "active",
92187
+ assessmentLineItem: result.assessmentLineItem,
92188
+ student: result.student,
92189
+ score: result.score ?? 0,
92190
+ scoreDate: result.scoreDate,
92191
+ ...ASSESSMENT_ATTEMPT_SUPERSEDED,
92192
+ metadata: result.metadata ?? {}
92193
+ };
92194
+ }
92195
+ async function resolveAvailableAssessmentAttempt(initialDecision, select3, resume) {
92196
+ let decision = initialDecision;
92197
+ while (decision?.kind === "resume") {
92198
+ const snapshot = await resume(decision);
92199
+ if (snapshot !== null) {
92200
+ return { kind: "resumed", snapshot };
92201
+ }
92202
+ decision = select3();
92203
+ }
92204
+ return { kind: "continue", decision };
92205
+ }
92075
92206
  function buildReviewItemResultMetadata(input) {
92076
92207
  const administration = itemAdministration(input.metadata.itemSubmissions, input.selection.itemIdentifier);
92077
92208
  if (!administration) {
@@ -92516,8 +92647,8 @@ function parsePlayableItem(question) {
92516
92647
  function assessmentContentRevision(test, questions) {
92517
92648
  return sha256Hex(canonicalJson2({
92518
92649
  identifier: test.identifier,
92650
+ title: test.title,
92519
92651
  qtiVersion: test.qtiVersion,
92520
- rawXml: test.rawXml,
92521
92652
  parts: test["qti-test-part"],
92522
92653
  questions: questions.questions.map(({ reference, question }) => ({
92523
92654
  identifier: reference.identifier,
@@ -92675,11 +92806,30 @@ async function hydrateQtiTestQuestions(client2, references) {
92675
92806
  }));
92676
92807
  return { ...references, questions };
92677
92808
  }
92678
- async function loadHydratedQtiTest(client2, identifier) {
92809
+ async function hydrateQtiTestQuestionSelection(client2, references, itemIdentifiers) {
92810
+ const referenceByIdentifier = new Map(references.questions.map((reference) => [reference.reference.identifier, reference]));
92811
+ const selectedReferences = itemIdentifiers.map((itemIdentifier) => {
92812
+ const reference = referenceByIdentifier.get(itemIdentifier);
92813
+ if (!reference) {
92814
+ throw new Error(`QTI assessment ${references.assessmentTest} does not contain item ${itemIdentifier}`);
92815
+ }
92816
+ return reference;
92817
+ });
92818
+ return hydrateQtiTestQuestions(client2, {
92819
+ ...references,
92820
+ totalQuestions: selectedReferences.length,
92821
+ questions: selectedReferences
92822
+ });
92823
+ }
92824
+ async function loadQtiTestReferences(client2, identifier) {
92679
92825
  const [test, references] = await Promise.all([
92680
92826
  client2.qtiApi.assessmentTests.get(identifier),
92681
92827
  client2.qtiApi.assessmentTests.getQuestions(identifier)
92682
92828
  ]);
92829
+ return { test, references };
92830
+ }
92831
+ async function loadHydratedQtiTest(client2, identifier) {
92832
+ const { test, references } = await loadQtiTestReferences(client2, identifier);
92683
92833
  return {
92684
92834
  test,
92685
92835
  questions: await hydrateQtiTestQuestions(client2, references)
@@ -92694,6 +92844,7 @@ class TimebackAssessmentRuntimeService {
92694
92844
  static ASSESSMENT_CACHE_TTL_MS = 60000;
92695
92845
  static EXPORT_CONCURRENCY = 4;
92696
92846
  static ITEM_SUBMISSION_MAX_PREPARATION_ATTEMPTS = 3;
92847
+ static ASSESSMENT_VERSION_CONFIRMATION_DELAY_MS = 25;
92697
92848
  static PROJECTION_BARRIER_MAX_ATTEMPTS = 5;
92698
92849
  static PROJECTION_BARRIER_RETRY_DELAY_MS = 25;
92699
92850
  static SCORING_CONCURRENCY = 4;
@@ -92706,6 +92857,10 @@ class TimebackAssessmentRuntimeService {
92706
92857
  defaultTTL: TimebackAssessmentRuntimeService.ASSESSMENT_CACHE_TTL_MS,
92707
92858
  maxSize: TimebackAssessmentRuntimeService.ASSESSMENT_CACHE_LIMIT
92708
92859
  });
92860
+ reviewSelectionCache = new TimebackCache({
92861
+ defaultTTL: TimebackAssessmentRuntimeService.ASSESSMENT_CACHE_TTL_MS,
92862
+ maxSize: TimebackAssessmentRuntimeService.ASSESSMENT_CACHE_LIMIT
92863
+ });
92709
92864
  constructor(deps) {
92710
92865
  this.deps = deps;
92711
92866
  }
@@ -92724,14 +92879,15 @@ class TimebackAssessmentRuntimeService {
92724
92879
  }
92725
92880
  const masteryStandard = input.purpose === "mastery" ? normalizeMasteryStandard(input.standard) : undefined;
92726
92881
  const requestFingerprint = this.startRequestFingerprint(input);
92882
+ const pendingSupersessions = new Set;
92727
92883
  const candidates = await this.candidateIntegrations(gameId, studentId, input);
92728
92884
  const lockKeys = candidates.rows.map((row) => assessmentRuntimeStartLockKey({
92729
92885
  studentId,
92730
92886
  activityId: input.activityId,
92731
92887
  purpose: input.purpose,
92732
92888
  courseId: row.courseId
92733
- })).toSorted();
92734
- return this.withStartLocks(lockKeys, async (db2) => {
92889
+ }));
92890
+ return this.deps.assessmentRuntimeLock(this.deps.db, lockKeys, async (db2) => {
92735
92891
  const context2 = await this.selectIntegration(candidates, studentId, input);
92736
92892
  const attemptScope = {
92737
92893
  studentId,
@@ -92746,20 +92902,21 @@ class TimebackAssessmentRuntimeService {
92746
92902
  this.listAttempts(attemptScope)
92747
92903
  ]);
92748
92904
  const attempts = listing.attempts;
92749
- const compatibleAttempts = this.attemptsMatchingRequest(attempts, requestFingerprint);
92750
- let decision = this.requireDecision(selectRuntimeAssessment(tests, [...compatibleAttempts.values()].map((entry) => entry.selection)), input.purpose);
92751
- if (decision.kind === "resume") {
92752
- return this.resumeSnapshot(decision, attempts, context2.integration);
92905
+ const initialResolution = await this.resumeAvailableAttempt(tests, attempts, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeSnapshot(resumeDecision, attempts, context2.integration));
92906
+ if (initialResolution.kind === "resumed") {
92907
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
92908
+ return initialResolution.snapshot;
92753
92909
  }
92910
+ let decision = this.requireDecision(initialResolution.decision, input.purpose);
92754
92911
  let assessment = await this.loadAssessment(decision.test.qtiTestIdentifier);
92755
92912
  const refreshedListing = await this.listAttempts(attemptScope);
92756
92913
  const refreshed = refreshedListing.attempts;
92757
- const refreshedCompatible = this.attemptsMatchingRequest(refreshed, requestFingerprint);
92758
- const refreshedDecision = this.requireDecision(selectRuntimeAssessment(tests, [...refreshedCompatible.values()].map((entry) => entry.selection)), input.purpose);
92759
- if (refreshedDecision.kind === "resume") {
92760
- return this.resumeSnapshot(refreshedDecision, refreshed, context2.integration);
92914
+ const refreshedResolution = await this.resumeAvailableAttempt(tests, refreshed, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeSnapshot(resumeDecision, refreshed, context2.integration));
92915
+ if (refreshedResolution.kind === "resumed") {
92916
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
92917
+ return refreshedResolution.snapshot;
92761
92918
  }
92762
- decision = refreshedDecision;
92919
+ decision = this.requireDecision(refreshedResolution.decision, input.purpose);
92763
92920
  if (assessment.identifier !== decision.test.qtiTestIdentifier) {
92764
92921
  assessment = await this.loadAssessment(decision.test.qtiTestIdentifier);
92765
92922
  }
@@ -92817,6 +92974,7 @@ class TimebackAssessmentRuntimeService {
92817
92974
  grade: context2.integration.grade
92818
92975
  })
92819
92976
  });
92977
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
92820
92978
  return this.snapshot(result, metadata2, assessment, context2.integration);
92821
92979
  });
92822
92980
  }
@@ -92826,14 +92984,15 @@ class TimebackAssessmentRuntimeService {
92826
92984
  input
92827
92985
  }) {
92828
92986
  const requestFingerprint = this.startRequestFingerprint(input);
92987
+ const pendingSupersessions = new Set;
92829
92988
  const candidates = await this.candidateIntegrations(gameId, studentId, input);
92830
92989
  const lockKeys = candidates.rows.map((row) => assessmentRuntimeStartLockKey({
92831
92990
  studentId,
92832
92991
  activityId: input.activityId,
92833
92992
  purpose: input.purpose,
92834
92993
  courseId: row.courseId
92835
- })).toSorted();
92836
- return this.withStartLocks(lockKeys, async (db2) => {
92994
+ }));
92995
+ return this.deps.assessmentRuntimeLock(this.deps.db, lockKeys, async (db2) => {
92837
92996
  const context2 = await this.selectIntegration(candidates, studentId, input);
92838
92997
  const attemptScope = {
92839
92998
  studentId,
@@ -92847,22 +93006,23 @@ class TimebackAssessmentRuntimeService {
92847
93006
  this.liveTests(context2.integration.id, input.purpose, db2, undefined, input.diagnosticKey),
92848
93007
  this.listAttempts(attemptScope)
92849
93008
  ]);
92850
- const compatible = this.attemptsMatchingRequest(listing.attempts, requestFingerprint);
92851
- let decision = this.requireDecision(selectRuntimeAssessment(tests, [...compatible.values()].map((entry) => entry.selection)), input.purpose);
92852
- if (decision.kind === "resume") {
92853
- return this.resumeDiagnosticSnapshot(decision, listing.attempts, context2.integration, db2);
93009
+ const initialResolution = await this.resumeAvailableAttempt(tests, listing.attempts, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeDiagnosticSnapshot(resumeDecision, listing.attempts, context2.integration, db2));
93010
+ if (initialResolution.kind === "resumed") {
93011
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93012
+ return initialResolution.snapshot;
92854
93013
  }
93014
+ let decision = this.requireDecision(initialResolution.decision, input.purpose);
92855
93015
  let definition = await this.requireDiagnosticDefinition(decision.test.id, context2.integration.id, db2, true);
92856
93016
  let assessment = await this.loadAssessment(definition.qtiTestIdentifier);
92857
93017
  let routing = await this.initializeHostedDiagnostic(definition, assessment);
92858
93018
  const refreshedListing = await this.listAttempts(attemptScope);
92859
93019
  const refreshed = refreshedListing.attempts;
92860
- const refreshedCompatible = this.attemptsMatchingRequest(refreshed, requestFingerprint);
92861
- const refreshedDecision = this.requireDecision(selectRuntimeAssessment(tests, [...refreshedCompatible.values()].map((entry) => entry.selection)), input.purpose);
92862
- if (refreshedDecision.kind === "resume") {
92863
- return this.resumeDiagnosticSnapshot(refreshedDecision, refreshed, context2.integration, db2);
93020
+ const refreshedResolution = await this.resumeAvailableAttempt(tests, refreshed, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeDiagnosticSnapshot(resumeDecision, refreshed, context2.integration, db2));
93021
+ if (refreshedResolution.kind === "resumed") {
93022
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93023
+ return refreshedResolution.snapshot;
92864
93024
  }
92865
- decision = refreshedDecision;
93025
+ decision = this.requireDecision(refreshedResolution.decision, input.purpose);
92866
93026
  if (definition.id !== decision.test.id) {
92867
93027
  definition = await this.requireDiagnosticDefinition(decision.test.id, context2.integration.id, db2, true);
92868
93028
  assessment = await this.loadAssessment(definition.qtiTestIdentifier);
@@ -92931,6 +93091,7 @@ class TimebackAssessmentRuntimeService {
92931
93091
  grade: context2.integration.grade
92932
93092
  })
92933
93093
  });
93094
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
92934
93095
  return this.diagnosticSnapshot(result, metadata2, assessment, context2.integration, routing.state);
92935
93096
  });
92936
93097
  }
@@ -92939,7 +93100,9 @@ class TimebackAssessmentRuntimeService {
92939
93100
  studentId,
92940
93101
  input
92941
93102
  }) {
93103
+ const preparationStartedAt = Date.now();
92942
93104
  const requestFingerprint = reviewRequestFingerprint(input, DEFAULT_REVIEW_SELECTION_POLICY);
93105
+ const pendingSupersessions = new Set;
92943
93106
  const normalizedRequest = normalizeReviewRequest(input);
92944
93107
  const candidates = await this.candidateIntegrations(gameId, studentId, input);
92945
93108
  const lockKeys = candidates.rows.map((row) => assessmentRuntimeStartLockKey({
@@ -92947,8 +93110,8 @@ class TimebackAssessmentRuntimeService {
92947
93110
  activityId: input.activityId,
92948
93111
  purpose: input.purpose,
92949
93112
  courseId: row.courseId
92950
- })).toSorted();
92951
- return this.withStartLocks(lockKeys, async (db2) => {
93113
+ }));
93114
+ return this.deps.assessmentRuntimeLock(this.deps.db, lockKeys, async (db2) => {
92952
93115
  const context2 = await this.selectIntegration(candidates, studentId, input);
92953
93116
  const attemptScope = {
92954
93117
  studentId,
@@ -92963,38 +93126,44 @@ class TimebackAssessmentRuntimeService {
92963
93126
  this.listAttempts(attemptScope)
92964
93127
  ]);
92965
93128
  const attempts = listing.attempts;
92966
- const compatible = this.attemptsMatchingRequest(attempts, requestFingerprint);
92967
- let decision = selectRuntimeAssessment(tests, [...compatible.values()].map((entry) => entry.selection));
92968
- if (decision?.kind === "resume") {
92969
- return this.resumeReviewSnapshot(decision, compatible, listing.reviewChildren, context2);
93129
+ const initialResolution = await this.resumeAvailableAttempt(tests, attempts, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeReviewSnapshot(resumeDecision, attempts, listing.reviewChildren, context2));
93130
+ if (initialResolution.kind === "resumed") {
93131
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93132
+ return initialResolution.snapshot;
92970
93133
  }
93134
+ let decision = initialResolution.decision;
92971
93135
  if (tests.length === 0 || !decision) {
92972
93136
  throw AssessmentRuntimeError.from(assessmentNoEligibleTests(input.purpose));
92973
93137
  }
92974
93138
  if (tests.length > 1) {
92975
93139
  throw new ValidationError("Standards review requires exactly one live review-bank assessment.");
92976
93140
  }
92977
- let source = await this.loadReviewBank(decision.test.qtiTestIdentifier);
93141
+ const manifestStartedAt = Date.now();
93142
+ let catalog = await this.loadReviewBankCatalog(decision.test.qtiTestIdentifier);
93143
+ this.recordReviewPreparationPhase("manifest_load", manifestStartedAt, {
93144
+ candidateCount: catalog.bank.items.length
93145
+ });
92978
93146
  const refreshedListing = await this.listAttempts(attemptScope);
92979
93147
  const refreshed = refreshedListing.attempts;
92980
- const refreshedCompatible = this.attemptsMatchingRequest(refreshed, requestFingerprint);
92981
- const refreshedDecision = selectRuntimeAssessment(tests, [...refreshedCompatible.values()].map((entry) => entry.selection));
92982
- if (refreshedDecision?.kind === "resume") {
92983
- return this.resumeReviewSnapshot(refreshedDecision, refreshedCompatible, refreshedListing.reviewChildren, context2);
93148
+ const refreshedResolution = await this.resumeAvailableAttempt(tests, refreshed, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeReviewSnapshot(resumeDecision, refreshed, refreshedListing.reviewChildren, context2));
93149
+ if (refreshedResolution.kind === "resumed") {
93150
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93151
+ return refreshedResolution.snapshot;
92984
93152
  }
93153
+ const refreshedDecision = refreshedResolution.decision;
92985
93154
  if (!refreshedDecision || refreshedDecision.kind !== "start") {
92986
93155
  throw AssessmentRuntimeError.from(assessmentNoEligibleTests(input.purpose));
92987
93156
  }
92988
93157
  decision = refreshedDecision;
92989
- if (source.assessment.identifier !== decision.test.qtiTestIdentifier) {
92990
- source = await this.loadReviewBank(decision.test.qtiTestIdentifier);
93158
+ if (catalog.test.identifier !== decision.test.qtiTestIdentifier) {
93159
+ catalog = await this.loadReviewBankCatalog(decision.test.qtiTestIdentifier);
92991
93160
  }
92992
93161
  const exposures = this.reviewExposures(refreshedListing.reviewChildren.values(), {
92993
- bankRevision: source.bank.bankRevision
93162
+ bankRevision: catalog.bank.bankRevision
92994
93163
  });
92995
93164
  const selected = selectReviewItems({
92996
93165
  request: input,
92997
- bank: source.bank,
93166
+ bank: catalog.bank,
92998
93167
  exposures
92999
93168
  });
93000
93169
  if (selected.selections.length === 0) {
@@ -93003,7 +93172,13 @@ class TimebackAssessmentRuntimeService {
93003
93172
  }
93004
93173
  throw AssessmentRuntimeError.from(assessmentReviewBankShortage(selected.fulfillment));
93005
93174
  }
93175
+ const hydrationStartedAt = Date.now();
93176
+ const source = await this.hydrateReviewBankSelection(catalog, selected.selections.map((selection) => selection.itemIdentifier));
93177
+ this.recordReviewPreparationPhase("selected_hydration", hydrationStartedAt, {
93178
+ selectedCount: selected.selections.length
93179
+ });
93006
93180
  const assessment = projectReviewAssessment(source.assessment, source.bank, selected.selections);
93181
+ const provisioningStartedAt = Date.now();
93007
93182
  const parentLineItemId = await this.ensureReviewBankLineItem({
93008
93183
  integration: context2.integration,
93009
93184
  activityId: input.activityId,
@@ -93066,6 +93241,12 @@ class TimebackAssessmentRuntimeService {
93066
93241
  existingChildResults: refreshedListing.reviewChildren,
93067
93242
  lookupMissingResults: false
93068
93243
  });
93244
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93245
+ this.recordReviewPreparationPhase("provisioning", provisioningStartedAt);
93246
+ this.recordReviewPreparationPhase("total", preparationStartedAt, {
93247
+ candidateCount: catalog.bank.items.length,
93248
+ selectedCount: selected.selections.length
93249
+ });
93069
93250
  return this.snapshot(result, metadata2, assessment, context2.integration);
93070
93251
  });
93071
93252
  }
@@ -93148,7 +93329,7 @@ class TimebackAssessmentRuntimeService {
93148
93329
  "app.error.message": errorMessage(error88)
93149
93330
  });
93150
93331
  }
93151
- return this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(params.attemptId), async (db2) => {
93332
+ return this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(params.attemptId)], async (db2) => {
93152
93333
  const attempt = await this.authorizeAttempt(params, {
93153
93334
  db: db2,
93154
93335
  developerAccessValidated: true
@@ -93196,7 +93377,7 @@ class TimebackAssessmentRuntimeService {
93196
93377
  let preview = await this.prepareItemSubmission(params, input);
93197
93378
  let preparationAttempts = 1;
93198
93379
  while (true) {
93199
- const committed = await this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(params.attemptId), async (db2) => {
93380
+ const committed = await this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(params.attemptId)], async (db2) => {
93200
93381
  const attempt = await this.authorizeAttempt(params, {
93201
93382
  db: db2,
93202
93383
  developerAccessValidated: true
@@ -93292,7 +93473,7 @@ class TimebackAssessmentRuntimeService {
93292
93473
  let preview = await this.prepareDiagnosticItemSubmission(params, input);
93293
93474
  let preparationAttempts = 1;
93294
93475
  while (true) {
93295
- const committed = await this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(params.attemptId), async (db2) => {
93476
+ const committed = await this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(params.attemptId)], async (db2) => {
93296
93477
  const attempt = await this.authorizeAttempt(params, {
93297
93478
  db: db2,
93298
93479
  developerAccessValidated: true
@@ -93419,7 +93600,7 @@ class TimebackAssessmentRuntimeService {
93419
93600
  preparationAttempts += 1;
93420
93601
  preview = await this.scoreDiagnosticItemSubmission(params, input);
93421
93602
  } else {
93422
- await this.projectDiagnosticItemResponse(committed.projection);
93603
+ await this.projectDiagnosticItemResponse(committed.projection, preview?.assessment);
93423
93604
  return committed.response;
93424
93605
  }
93425
93606
  }
@@ -93626,7 +93807,7 @@ class TimebackAssessmentRuntimeService {
93626
93807
  }) {
93627
93808
  await this.deps.validateDeveloperAccess(params.user, params.gameId);
93628
93809
  const preview = await this.prepareSubmission(params, input);
93629
- const submission = await this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(params.attemptId), async (db2) => {
93810
+ const submission = await this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(params.attemptId)], async (db2) => {
93630
93811
  const attempt = await this.authorizeAttempt(params, {
93631
93812
  db: db2,
93632
93813
  developerAccessValidated: true
@@ -93833,7 +94014,7 @@ class TimebackAssessmentRuntimeService {
93833
94014
  where: and(eq(gameTimebackAssessmentTests.id, test.id), eq(gameTimebackAssessmentTests.integrationId, integration.id))
93834
94015
  }) : undefined;
93835
94016
  const diagnostic = definition?.diagnosticKey ? await this.initializeHostedDiagnostic(definition, loaded.assessment) : null;
93836
- const reviewBank = purpose === "review" ? await buildReviewBankIndex(loaded.assessment, loaded.questions) : null;
94017
+ const reviewBank = purpose === "review" ? await buildReviewBankIndex(loaded.assessment, loaded.questions, { customOnly: true }) : null;
93837
94018
  return {
93838
94019
  ...test,
93839
94020
  live: true,
@@ -93896,7 +94077,13 @@ class TimebackAssessmentRuntimeService {
93896
94077
  const enrollmentByCourse = new Map(enrollments.map((enrollment) => [enrollment.course.id, enrollment]));
93897
94078
  const candidateRows = integrations.filter((integration) => enrollmentByCourse.has(integration.courseId));
93898
94079
  const liveTestRows = candidateRows.length === 0 ? [] : await db2.query.gameTimebackAssessmentTests.findMany({
93899
- where: and(inArray(gameTimebackAssessmentTests.integrationId, candidateRows.map((row) => row.id)), eq(gameTimebackAssessmentTests.purpose, input.purpose), eq(gameTimebackAssessmentTests.status, "live"))
94080
+ where: and(inArray(gameTimebackAssessmentTests.integrationId, candidateRows.map((row) => row.id)), eq(gameTimebackAssessmentTests.purpose, input.purpose), eq(gameTimebackAssessmentTests.status, "live")),
94081
+ columns: {
94082
+ integrationId: true,
94083
+ standardFramework: true,
94084
+ standardIdentifier: true,
94085
+ diagnosticKey: true
94086
+ }
93900
94087
  });
93901
94088
  const matchesMasteryStandard = input.purpose === "mastery" ? masteryStandardMatcher(input.standard) : undefined;
93902
94089
  const integrationIdsWithLiveTests = new Set(liveTestRows.filter((row) => (!matchesMasteryStandard || matchesMasteryStandard(assessmentStandardForRow(row))) && (input.purpose !== "diagnostic" || row.diagnosticKey === input.diagnosticKey)).map((row) => row.integrationId));
@@ -93943,10 +94130,6 @@ class TimebackAssessmentRuntimeService {
93943
94130
  enrollment: enrollmentByCourse.get(selection.selected.courseId)
93944
94131
  };
93945
94132
  }
93946
- async withStartLocks(keys, operation) {
93947
- const acquire = (index2, db2) => index2 === keys.length ? operation(db2) : this.deps.assessmentRuntimeLock(db2, keys[index2], (nested) => acquire(index2 + 1, nested));
93948
- return acquire(0, this.deps.db);
93949
- }
93950
94133
  async liveTests(integrationId, purpose, db2 = this.deps.db, requestedStandard, requestedDiagnosticKey) {
93951
94134
  const matchesMasteryStandard = requestedStandard ? masteryStandardMatcher(requestedStandard) : undefined;
93952
94135
  const rows = await db2.query.gameTimebackAssessmentTests.findMany({
@@ -94089,6 +94272,75 @@ class TimebackAssessmentRuntimeService {
94089
94272
  });
94090
94273
  return this.diagnosticSnapshot(resumed.result, resumed.metadata, assessment, integration, routing.state);
94091
94274
  }
94275
+ async resumeAvailableAttempt(tests, attempts, requestFingerprint, pendingSupersessions, resume) {
94276
+ const select3 = () => selectRuntimeAssessment(tests, [...this.attemptsMatchingRequest(attempts, requestFingerprint).values()].map((entry) => entry.selection));
94277
+ return resolveAvailableAssessmentAttempt(select3(), select3, (decision) => this.resumeSnapshotOrStageSupersession(decision, attempts, pendingSupersessions, () => resume(decision)));
94278
+ }
94279
+ async resumeSnapshotOrStageSupersession(decision, attempts, pendingSupersessions, resume) {
94280
+ try {
94281
+ return await resume();
94282
+ } catch (error88) {
94283
+ if (!(error88 instanceof AssessmentRuntimeError) || error88.runtimeCode !== "SELECTED_TEST_VERSION_UNAVAILABLE") {
94284
+ throw error88;
94285
+ }
94286
+ if (shouldConfirmAssessmentVersionUnavailable(error88.details)) {
94287
+ await sleep(TimebackAssessmentRuntimeService.ASSESSMENT_VERSION_CONFIRMATION_DELAY_MS);
94288
+ try {
94289
+ return await resume();
94290
+ } catch (confirmationError) {
94291
+ if (!(confirmationError instanceof AssessmentRuntimeError) || confirmationError.runtimeCode !== "SELECTED_TEST_VERSION_UNAVAILABLE") {
94292
+ throw confirmationError;
94293
+ }
94294
+ }
94295
+ }
94296
+ const staged = attempts.get(decision.attempt.attemptId);
94297
+ pendingSupersessions.add(staged.result.sourcedId);
94298
+ stageAssessmentAttemptSupersession(staged);
94299
+ addEvent("assessment.attempt_supersession_staged", {
94300
+ "app.assessment.attempt_id": decision.attempt.attemptId,
94301
+ "app.assessment.reason": "selected_test_version_unavailable"
94302
+ });
94303
+ return null;
94304
+ }
94305
+ }
94306
+ async persistPendingSupersessions(db2, attemptIds) {
94307
+ for (const attemptId of [...attemptIds].toSorted()) {
94308
+ await this.deps.assessmentRuntimeLock(db2, [assessmentRuntimeAttemptLockKey(attemptId)], async () => {
94309
+ let result;
94310
+ try {
94311
+ result = await this.requireClient().api.oneroster.assessmentResults.get(attemptId);
94312
+ } catch (error88) {
94313
+ if (isApiError(error88) && error88.statusCode === 404) {
94314
+ return;
94315
+ }
94316
+ throw error88;
94317
+ }
94318
+ const update2 = buildAssessmentAttemptSupersessionUpdate(result);
94319
+ if (!update2) {
94320
+ return;
94321
+ }
94322
+ await this.requireClient().api.oneroster.assessmentResults.upsert(attemptId, update2);
94323
+ addEvent("assessment.attempt_superseded", {
94324
+ "app.assessment.attempt_id": attemptId,
94325
+ "app.assessment.reason": "selected_test_version_unavailable"
94326
+ });
94327
+ });
94328
+ }
94329
+ }
94330
+ async persistPendingSupersessionsBestEffort(db2, attemptIds) {
94331
+ if (attemptIds.size === 0) {
94332
+ return;
94333
+ }
94334
+ try {
94335
+ await this.persistPendingSupersessions(db2, attemptIds);
94336
+ } catch (error88) {
94337
+ addEvent("assessment.attempt_supersession_persist_failed", {
94338
+ "app.assessment.attempt_ids": [...attemptIds].toSorted().join(","),
94339
+ "exception.type": errorType(error88),
94340
+ "app.error.message": errorMessage(error88)
94341
+ });
94342
+ }
94343
+ }
94092
94344
  async resumeReviewSnapshot(decision, attempts, existingChildResults, context2) {
94093
94345
  if (decision.additionalResumableAttemptIds.length > 0) {
94094
94346
  addEvent("assessment.multiple_resumable_attempts", {
@@ -94100,7 +94352,8 @@ class TimebackAssessmentRuntimeService {
94100
94352
  if (resumed.metadata.purpose !== "review") {
94101
94353
  throw new Error("A standards-review request selected a non-review attempt");
94102
94354
  }
94103
- const currentSource = await this.loadReviewBank(resumed.metadata.selectedTest.identifier, resumed.metadata.selectedTest.contentRevision);
94355
+ const catalog = await this.loadReviewBankCatalog(resumed.metadata.selectedTest.identifier, resumed.metadata.selectedTest.contentRevision);
94356
+ const currentSource = await this.hydrateReviewBankSelection(catalog, resumed.metadata.review.selections.map((selection) => selection.itemIdentifier));
94104
94357
  const source = this.pinnedReviewBankSource(currentSource, resumed.metadata);
94105
94358
  const assessment = projectReviewAssessment(source.assessment, source.bank, resumed.metadata.review.selections);
94106
94359
  await this.ensureReviewChildResults({
@@ -94114,20 +94367,68 @@ class TimebackAssessmentRuntimeService {
94114
94367
  });
94115
94368
  return this.snapshot(resumed.result, resumed.metadata, assessment, context2.integration);
94116
94369
  }
94117
- async loadReviewBank(identifier, expectedSourceRevision) {
94370
+ recordReviewPreparationPhase(phase, startedAt, counts = {}) {
94371
+ addEvent("assessment.review_preparation_phase", {
94372
+ "app.assessment.review_phase": phase,
94373
+ "app.assessment.duration_ms": Date.now() - startedAt,
94374
+ ...counts.candidateCount === undefined ? {} : { "app.assessment.candidate_count": counts.candidateCount },
94375
+ ...counts.selectedCount === undefined ? {} : { "app.assessment.selected_count": counts.selectedCount }
94376
+ });
94377
+ }
94378
+ async loadReviewBankCatalog(identifier, expectedSourceRevision) {
94118
94379
  if (expectedSourceRevision) {
94119
94380
  const cached3 = this.reviewBankCache.get(`${identifier}\x00${expectedSourceRevision}`);
94120
94381
  if (cached3) {
94121
94382
  return cached3;
94122
94383
  }
94123
94384
  }
94124
- const loaded = await this.loadAssessmentSource(identifier, expectedSourceRevision);
94125
- const source = {
94126
- assessment: loaded.assessment,
94127
- bank: await buildReviewBankIndex(loaded.assessment, loaded.questions)
94128
- };
94129
- this.reviewBankCache.set(`${identifier}\x00${source.assessment.contentRevision}`, source);
94130
- return source;
94385
+ let loaded;
94386
+ try {
94387
+ loaded = await loadQtiTestReferences(this.requireClient(), identifier);
94388
+ } catch (error88) {
94389
+ if (expectedSourceRevision && isApiError(error88) && error88.statusCode === 404) {
94390
+ throw new AssessmentRuntimeError("SELECTED_TEST_VERSION_UNAVAILABLE", `The selected assessment version for ${identifier} is no longer available.`, { identifier, expectedRevision: expectedSourceRevision });
94391
+ }
94392
+ throw error88;
94393
+ }
94394
+ let bank;
94395
+ try {
94396
+ bank = await reviewBankIndexFromManifest(loaded.test.metadata, {
94397
+ bankIdentifier: identifier,
94398
+ membershipItemIdentifiers: loaded.references.questions.map((question) => question.reference.identifier)
94399
+ });
94400
+ } catch (error88) {
94401
+ throw new ServiceUnavailableError(`Review bank ${identifier} has stale or invalid routing metadata. Use Update Mapping in assessment authoring.`, { reason: errorMessage(error88) });
94402
+ }
94403
+ if (!bank) {
94404
+ throw new ServiceUnavailableError(`Review bank ${identifier} needs its authoring mapping updated before it can serve review questions.`);
94405
+ }
94406
+ if (expectedSourceRevision && bank.sourceContentRevision !== expectedSourceRevision) {
94407
+ throw new AssessmentRuntimeError("SELECTED_TEST_VERSION_UNAVAILABLE", `The selected assessment version for ${identifier} is no longer available.`, {
94408
+ identifier,
94409
+ expectedRevision: expectedSourceRevision,
94410
+ currentRevision: bank.sourceContentRevision
94411
+ });
94412
+ }
94413
+ const catalog = { ...loaded, bank };
94414
+ this.reviewBankCache.set(`${identifier}\x00${bank.sourceContentRevision}`, catalog);
94415
+ return catalog;
94416
+ }
94417
+ async hydrateReviewBankSelection(catalog, itemIdentifiers) {
94418
+ const cacheKey2 = [
94419
+ catalog.test.identifier,
94420
+ catalog.bank.sourceContentRevision,
94421
+ ...itemIdentifiers
94422
+ ].join("\x00");
94423
+ const cached3 = this.reviewSelectionCache.get(cacheKey2);
94424
+ if (cached3) {
94425
+ return { assessment: cached3, bank: catalog.bank };
94426
+ }
94427
+ const questions = await hydrateQtiTestQuestionSelection(this.requireClient(), catalog.references, itemIdentifiers);
94428
+ const assessment = await buildPlayableAssessment(catalog.test, questions);
94429
+ assessment.contentRevision = catalog.bank.sourceContentRevision;
94430
+ this.reviewSelectionCache.set(cacheKey2, assessment);
94431
+ return { assessment, bank: catalog.bank };
94131
94432
  }
94132
94433
  pinnedReviewBankSource(source, metadata2) {
94133
94434
  return {
@@ -94158,7 +94459,8 @@ class TimebackAssessmentRuntimeService {
94158
94459
  if (metadata2.purpose !== "review") {
94159
94460
  return this.loadAssessment(metadata2.selectedTest.identifier, metadata2.selectedTest.contentRevision);
94160
94461
  }
94161
- const currentSource = await this.loadReviewBank(metadata2.selectedTest.identifier, metadata2.selectedTest.contentRevision);
94462
+ const catalog = await this.loadReviewBankCatalog(metadata2.selectedTest.identifier, metadata2.selectedTest.contentRevision);
94463
+ const currentSource = await this.hydrateReviewBankSelection(catalog, metadata2.review.selections.map((selection) => selection.itemIdentifier));
94162
94464
  const source = this.pinnedReviewBankSource(currentSource, metadata2);
94163
94465
  return projectReviewAssessment(source.assessment, source.bank, metadata2.review.selections);
94164
94466
  }
@@ -94656,7 +94958,7 @@ class TimebackAssessmentRuntimeService {
94656
94958
  async crossAttemptLockBarrier(attemptId) {
94657
94959
  for (let attempt = 1;attempt <= TimebackAssessmentRuntimeService.PROJECTION_BARRIER_MAX_ATTEMPTS; attempt += 1) {
94658
94960
  try {
94659
- await this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(attemptId), async () => {
94961
+ await this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(attemptId)], async () => {
94660
94962
  return;
94661
94963
  });
94662
94964
  return;
@@ -94781,6 +95083,14 @@ class TimebackAssessmentRuntimeService {
94781
95083
  return AssessmentRuntimeError.from(assessmentAttemptUnauthorized(attemptId));
94782
95084
  }
94783
95085
  async snapshotForResult(result, metadata2, integration) {
95086
+ if (isAssessmentAttemptSuperseded({
95087
+ inProgress: result.inProgress ?? "",
95088
+ scoreStatus: result.scoreStatus
95089
+ })) {
95090
+ throw new GoneError("This assessment attempt has been superseded.", {
95091
+ attemptId: result.sourcedId
95092
+ });
95093
+ }
94784
95094
  const assessment = await this.loadAttemptAssessment(metadata2);
94785
95095
  if (this.isPlatformRoutedDiagnosticMetadata(metadata2)) {
94786
95096
  const routing = await this.loadAttemptDiagnosticRouting(metadata2, assessment);
@@ -96129,6 +96439,62 @@ function buildQtiLibraryListPlan(params) {
96129
96439
  }
96130
96440
  var PLAYCADEMY_QTI_SOURCE_PREFIX = "playcademy-test-", PLAYCADEMY_QTI_SOURCE_UPPER_BOUND = "playcademy-test.";
96131
96441
 
96442
+ // ../api-core/src/utils/timeback-review-mapping.util.ts
96443
+ function reviewMappingIssueSummary(label, identifiers) {
96444
+ if (identifiers.length === 0) {
96445
+ return null;
96446
+ }
96447
+ const displayed = identifiers.slice(0, 10).join(", ");
96448
+ const remainder = identifiers.length > 10 ? `, and ${identifiers.length - 10} more` : "";
96449
+ return `${label} (${identifiers.length}): ${displayed}${remainder}`;
96450
+ }
96451
+ async function prepareReviewMappingUpdate(test, questions) {
96452
+ const contentRevision = await assessmentContentRevision(test, questions);
96453
+ const assessment = {
96454
+ identifier: test.identifier,
96455
+ contractVersion: 1,
96456
+ contentRevision,
96457
+ title: test.title,
96458
+ items: questions.questions.map(({ question }) => ({
96459
+ identifier: question.identifier,
96460
+ title: question.title,
96461
+ prompt: "",
96462
+ maxScore: 1,
96463
+ interactions: []
96464
+ }))
96465
+ };
96466
+ const bank = await buildReviewBankIndex(assessment, questions, { customOnly: true });
96467
+ const issues = reviewBankMappingIssues(bank);
96468
+ if (issues.missingOrInvalidItemIdentifiers.length > 0 || issues.multipleStandardItemIdentifiers.length > 0) {
96469
+ const details = [
96470
+ reviewMappingIssueSummary("missing or invalid associations", issues.missingOrInvalidItemIdentifiers),
96471
+ reviewMappingIssueSummary("multiple associations", issues.multipleStandardItemIdentifiers)
96472
+ ].filter((detail) => detail !== null);
96473
+ throw new ValidationError(`Every review question must have exactly one valid standard/node association. ${details.join("; ")}.`);
96474
+ }
96475
+ const manifest = await buildReviewBankManifest(bank);
96476
+ return {
96477
+ update: {
96478
+ ...buildQtiTestUpdateInput(test, test.title),
96479
+ metadata: {
96480
+ ...test.metadata,
96481
+ [PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY]: manifest
96482
+ }
96483
+ },
96484
+ summary: {
96485
+ itemCount: bank.items.length,
96486
+ standardCount: Object.keys(manifest.itemsByStandard).length,
96487
+ sourceFingerprint: manifest.sourceFingerprint
96488
+ }
96489
+ };
96490
+ }
96491
+ var init_timeback_review_mapping_util = __esm(() => {
96492
+ init_assessment_runtime2();
96493
+ init_errors2();
96494
+ init_timeback_assessment_runtime_util();
96495
+ init_timeback_qti_authoring_util();
96496
+ });
96497
+
96132
96498
  // ../api-core/src/services/timeback-assessments.service.ts
96133
96499
  function databaseConstraintName(error88) {
96134
96500
  if (typeof error88 !== "object" || error88 === null) {
@@ -96211,7 +96577,8 @@ class TimebackAssessmentsService {
96211
96577
  ownerGameSlug: ownership.gameSlug,
96212
96578
  integrationId,
96213
96579
  subject: integration.subject,
96214
- grade: String(integration.grade)
96580
+ grade: String(integration.grade),
96581
+ [PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY]: emptyReviewBankManifest(input.qtiTestIdentifier)
96215
96582
  }
96216
96583
  });
96217
96584
  try {
@@ -96280,7 +96647,9 @@ class TimebackAssessmentsService {
96280
96647
  assertAssessmentHasQuestions(loaded.questions.questions);
96281
96648
  assertPlayableAssessmentImportQuestions(manifest.targetStatus, loaded.questions.questions.map(({ question }) => question));
96282
96649
  if (entry.purpose === "review") {
96283
- assertReviewAssessmentHasStandards(loaded.questions.questions.map(({ question }) => qtiAssessmentStandardRefsFromMetadata2(question.metadata).filter((standard) => canonicalReviewStandardRef(standard) !== null).length));
96650
+ assertReviewAssessmentHasStandards(loaded.questions.questions.map(({ question }) => reviewRoutingStandardRefsFromMetadata(question.metadata, {
96651
+ customOnly: true
96652
+ }).length));
96284
96653
  }
96285
96654
  return { entry, test: loaded.test };
96286
96655
  } catch (error88) {
@@ -96432,6 +96801,10 @@ class TimebackAssessmentsService {
96432
96801
  if (input.status !== undefined) {
96433
96802
  validateAssessmentStatusTransition(row.status, input.status);
96434
96803
  }
96804
+ if (!publishing && !activatingReview && nextPurpose === "review" && row.purpose !== "review") {
96805
+ const ownership = await this.requireQtiTestOwnershipContext(integrationId, tx);
96806
+ await this.rebuildReviewMapping(this.requireClient(), qtiTestIdentifier, ownership.gameSlug);
96807
+ }
96435
96808
  if (input.title !== undefined) {
96436
96809
  assertDraftAssessment(row);
96437
96810
  assertAllAssessmentAssociationsDraft(associations);
@@ -96450,7 +96823,8 @@ class TimebackAssessmentsService {
96450
96823
  updates.diagnosticKey = nextDiagnostic.diagnosticKey;
96451
96824
  updates.diagnosticRoutingManifest = nextDiagnostic.routingManifest;
96452
96825
  } else {
96453
- await this.validateAssessmentHasQuestions(qtiTestIdentifier, nextPurpose === "review" && nextStatus === "live");
96826
+ const reviewOwnership = nextPurpose === "review" && nextStatus === "live" ? await this.requireQtiTestOwnershipContext(integrationId, tx) : undefined;
96827
+ await this.validateAssessmentHasQuestions(qtiTestIdentifier, reviewOwnership?.gameSlug);
96454
96828
  }
96455
96829
  }
96456
96830
  let updated = row;
@@ -96545,6 +96919,19 @@ class TimebackAssessmentsService {
96545
96919
  });
96546
96920
  return { ...result, questions };
96547
96921
  }
96922
+ async updateReviewMapping(integrationId, qtiTestIdentifier) {
96923
+ return this.withLockedAssessmentAssociations(integrationId, qtiTestIdentifier, async (row, tx, associations) => {
96924
+ if (!associations.some((association) => association.purpose === "review")) {
96925
+ throw new ValidationError("Review mapping is available only for standards-review assessments.");
96926
+ }
96927
+ const client2 = this.requireClient();
96928
+ const ownership = await this.requireQtiTestOwnershipContext(integrationId, tx);
96929
+ const result = await this.rebuildReviewMapping(client2, qtiTestIdentifier, ownership.gameSlug);
96930
+ setAttribute("app.assessment.operation", "update_review_mapping");
96931
+ setAttribute("app.assessment.review_mapping_item_count", result.itemCount);
96932
+ return result;
96933
+ });
96934
+ }
96548
96935
  async listQuestionLibrary(integrationId, params) {
96549
96936
  const client2 = this.requireClient();
96550
96937
  await this.requireIntegration(integrationId);
@@ -96585,7 +96972,8 @@ class TimebackAssessmentsService {
96585
96972
  integrationId,
96586
96973
  subject: integration.subject,
96587
96974
  grade: String(integration.grade),
96588
- copiedFromTestIdentifier: sourceTestIdentifier
96975
+ copiedFromTestIdentifier: sourceTestIdentifier,
96976
+ [PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY]: emptyReviewBankManifest(targetTestIdentifier)
96589
96977
  }, itemPlan);
96590
96978
  const attemptedItemIdentifiers = [];
96591
96979
  let testCreationAttempted = false;
@@ -96973,16 +97361,20 @@ class TimebackAssessmentsService {
96973
97361
  const plan = buildQtiLibraryListPlan(params);
96974
97362
  return list(plan.params);
96975
97363
  }
96976
- async validateAssessmentHasQuestions(qtiTestIdentifier, requireReviewStandards = false) {
97364
+ async validateAssessmentHasQuestions(qtiTestIdentifier, reviewGameSlug) {
96977
97365
  const client2 = this.requireClient();
96978
- const result = await client2.qtiApi.assessmentTests.getQuestions(qtiTestIdentifier);
97366
+ const [test, result] = await Promise.all([
97367
+ client2.qtiApi.assessmentTests.get(qtiTestIdentifier),
97368
+ client2.qtiApi.assessmentTests.getQuestions(qtiTestIdentifier)
97369
+ ]);
96979
97370
  assertAssessmentHasQuestions(result.questions);
96980
97371
  const hydrated = await hydrateQtiTestQuestions(client2, result);
96981
97372
  for (const { question } of hydrated.questions) {
96982
97373
  assertPlayableQtiQuestion(question);
96983
97374
  }
96984
- if (requireReviewStandards) {
96985
- assertReviewAssessmentHasStandards(hydrated.questions.map(({ question }) => qtiAssessmentStandardRefsFromMetadata2(question.metadata).filter((standard) => canonicalReviewStandardRef(standard) !== null).length));
97375
+ if (reviewGameSlug) {
97376
+ assertQtiTestOwnedByGame(test, reviewGameSlug);
97377
+ await this.writeReviewMapping(client2, test, hydrated);
96986
97378
  }
96987
97379
  }
96988
97380
  async prepareDiagnosticAssociationChanges(row, nextPurpose, requested) {
@@ -97047,6 +97439,19 @@ class TimebackAssessmentsService {
97047
97439
  routingManifest: validation.manifest
97048
97440
  };
97049
97441
  }
97442
+ async rebuildReviewMapping(client2, qtiTestIdentifier, gameSlug) {
97443
+ const [test, references] = await Promise.all([
97444
+ client2.qtiApi.assessmentTests.get(qtiTestIdentifier),
97445
+ client2.qtiApi.assessmentTests.getQuestions(qtiTestIdentifier)
97446
+ ]);
97447
+ assertQtiTestOwnedByGame(test, gameSlug);
97448
+ return this.writeReviewMapping(client2, test, await hydrateQtiTestQuestions(client2, references));
97449
+ }
97450
+ async writeReviewMapping(client2, test, questions) {
97451
+ const prepared = await prepareReviewMappingUpdate(test, questions);
97452
+ await client2.qtiApi.assessmentTests.update(test.identifier, prepared.update);
97453
+ return prepared.summary;
97454
+ }
97050
97455
  }
97051
97456
  var init_timeback_assessments_service = __esm(async () => {
97052
97457
  init_drizzle_orm();
@@ -97054,7 +97459,6 @@ var init_timeback_assessments_service = __esm(async () => {
97054
97459
  init_tables_index();
97055
97460
  init_spans();
97056
97461
  init_assessment_runtime2();
97057
- init_qti();
97058
97462
  init_timeback3();
97059
97463
  init_errors2();
97060
97464
  init_timeback_assessment_import_util();
@@ -97062,6 +97466,7 @@ var init_timeback_assessments_service = __esm(async () => {
97062
97466
  init_timeback_assessment_runtime_util();
97063
97467
  init_timeback_qti_authoring_util();
97064
97468
  init_timeback_qti_hydration_util();
97469
+ init_timeback_review_mapping_util();
97065
97470
  await init_errors8();
97066
97471
  });
97067
97472
 
@@ -99069,7 +99474,7 @@ var init_upload_service = __esm(() => {
99069
99474
  function createPlatformServices(deps) {
99070
99475
  const {
99071
99476
  db: db2,
99072
- databaseLock,
99477
+ assessmentRuntimeLock,
99073
99478
  config: config5,
99074
99479
  cloudflare: cloudflare2,
99075
99480
  corsKvs,
@@ -99138,7 +99543,7 @@ function createPlatformServices(deps) {
99138
99543
  db: db2,
99139
99544
  timeback: timebackClient,
99140
99545
  validateDeveloperAccess,
99141
- assessmentRuntimeLock: createAssessmentRuntimeLock(databaseLock)
99546
+ assessmentRuntimeLock
99142
99547
  });
99143
99548
  return {
99144
99549
  bucket,
@@ -99156,7 +99561,6 @@ function createPlatformServices(deps) {
99156
99561
  };
99157
99562
  }
99158
99563
  var init_platform2 = __esm(async () => {
99159
- init_assessment_runtime_lock_util();
99160
99564
  init_bucket_service();
99161
99565
  init_database_service();
99162
99566
  init_deployment_state_service();
@@ -99851,7 +100255,7 @@ var init_standalone = __esm(() => {
99851
100255
 
99852
100256
  // ../api-core/src/services/factory/index.ts
99853
100257
  function createServices(ctx) {
99854
- const { db: db2, databaseLock, config: config5, providers, cloudflare: cloudflare2, timeback: timeback2, discord, corsKvs } = ctx;
100258
+ const { db: db2, assessmentRuntimeLock, config: config5, providers, cloudflare: cloudflare2, timeback: timeback2, discord, corsKvs } = ctx;
99855
100259
  const { auth: auth2, storage, r2Storage, cache } = providers;
99856
100260
  const infra2 = createInfraServices({
99857
100261
  db: db2,
@@ -99873,7 +100277,7 @@ function createServices(ctx) {
99873
100277
  });
99874
100278
  const platform2 = createPlatformServices({
99875
100279
  db: db2,
99876
- databaseLock,
100280
+ assessmentRuntimeLock,
99877
100281
  config: config5,
99878
100282
  cloudflare: cloudflare2,
99879
100283
  corsKvs,
@@ -99901,6 +100305,342 @@ var init_factory = __esm(async () => {
99901
100305
  await init_platform2();
99902
100306
  });
99903
100307
 
100308
+ // ../api-core/src/types/context.type.ts
100309
+ function isAuthenticated(ctx) {
100310
+ return ctx.user != null;
100311
+ }
100312
+
100313
+ // ../api-core/src/types/index.ts
100314
+ var init_types5 = () => {};
100315
+
100316
+ // ../api-core/src/utils/auth.util.ts
100317
+ function hasGameManagementAccess(user) {
100318
+ return user.role === "admin" || user.role === "teacher" || user.role === "developer" && user.developerStatus === "approved";
100319
+ }
100320
+ function isDashboardWorkerKey(key) {
100321
+ return Boolean(key?.permissions?.[DASHBOARD_PERMISSION_NAMESPACE]);
100322
+ }
100323
+ function workerKeyGrantsGameRead(key, slug2) {
100324
+ if (!isDashboardWorkerKey(key) && !isGameWorkerKey(key)) {
100325
+ return false;
100326
+ }
100327
+ const games2 = key?.permissions?.games;
100328
+ return Boolean(games2?.includes(`read:${slug2}`) || games2?.includes(`write:${slug2}`));
100329
+ }
100330
+ function isGameWorkerKey(key) {
100331
+ return Boolean(key?.name?.startsWith(GAME_WORKER_KEY_PREFIX));
100332
+ }
100333
+ function deniedWorkerKeyRequest(key, method, pathname) {
100334
+ if (isDashboardWorkerKey(key) && !isAllowedDashboardWorkerRequest(method, pathname, key.permissions)) {
100335
+ return DASHBOARD_WORKER_KEY_RESTRICTED;
100336
+ }
100337
+ return null;
100338
+ }
100339
+ function rejectDashboardWorkerKey(ctx) {
100340
+ if (isDashboardWorkerKey(ctx.apiKey)) {
100341
+ throw ApiError.forbidden(DASHBOARD_WORKER_KEY_RESTRICTED);
100342
+ }
100343
+ }
100344
+ function assertAuthenticatedRequest(ctx) {
100345
+ if (!isAuthenticated(ctx)) {
100346
+ throw ApiError.unauthorized("Valid session or bearer token required");
100347
+ }
100348
+ if (ctx.apiKey) {
100349
+ const denied = deniedWorkerKeyRequest(ctx.apiKey, ctx.request.method, ctx.url.pathname);
100350
+ if (denied) {
100351
+ throw ApiError.forbidden(denied);
100352
+ }
100353
+ }
100354
+ }
100355
+ function requireAuth(handler) {
100356
+ return async (ctx) => {
100357
+ assertAuthenticatedRequest(ctx);
100358
+ return handler(ctx);
100359
+ };
100360
+ }
100361
+ function requireNonAnonymous(handler) {
100362
+ return async (ctx) => {
100363
+ assertAuthenticatedRequest(ctx);
100364
+ if (ctx.user.isAnonymous) {
100365
+ throw ApiError.forbidden("This operation is not available for demo/anonymous users");
100366
+ }
100367
+ return handler(ctx);
100368
+ };
100369
+ }
100370
+ function requireAnonymous(handler) {
100371
+ return async (ctx) => {
100372
+ assertAuthenticatedRequest(ctx);
100373
+ if (!ctx.user.isAnonymous) {
100374
+ throw ApiError.forbidden("This operation is only available for demo/anonymous users");
100375
+ }
100376
+ return handler(ctx);
100377
+ };
100378
+ }
100379
+ function requireDeveloper(handler) {
100380
+ return async (ctx) => {
100381
+ assertAuthenticatedRequest(ctx);
100382
+ rejectDashboardWorkerKey(ctx);
100383
+ const isAdmin = ctx.user.role === "admin";
100384
+ const isApprovedDev = ctx.user.role === "developer" && ctx.user.developerStatus === "approved";
100385
+ if (!isAdmin && !isApprovedDev) {
100386
+ throw ApiError.forbidden("Must be an approved developer");
100387
+ }
100388
+ return handler(ctx);
100389
+ };
100390
+ }
100391
+ function requireHumanDeveloper(handler) {
100392
+ return requireDeveloper(async (ctx) => {
100393
+ if (isDashboardWorkerKey(ctx.apiKey) || isGameWorkerKey(ctx.apiKey)) {
100394
+ throw ApiError.forbidden(WORKER_KEY_HUMAN_ONLY);
100395
+ }
100396
+ return handler(ctx);
100397
+ });
100398
+ }
100399
+ function requireGameManagementAccess(handler) {
100400
+ return async (ctx) => {
100401
+ assertAuthenticatedRequest(ctx);
100402
+ rejectDashboardWorkerKey(ctx);
100403
+ if (!hasGameManagementAccess(ctx.user)) {
100404
+ throw ApiError.forbidden("Game management access required");
100405
+ }
100406
+ return handler(ctx);
100407
+ };
100408
+ }
100409
+ var WORKER_KEY_HUMAN_ONLY = "This operation requires your own credential — platform worker keys are refused";
100410
+ var init_auth_util = __esm(() => {
100411
+ init_errors2();
100412
+ init_types5();
100413
+ init_dashboard_util();
100414
+ init_deployment_util();
100415
+ });
100416
+
100417
+ // ../api-core/src/utils/controller.util.ts
100418
+ function defineControllerNames(namespace, handlers) {
100419
+ for (const [key, handler] of Object.entries(handlers)) {
100420
+ Object.defineProperty(handler, "name", {
100421
+ value: `${namespace}.${key}`,
100422
+ configurable: true
100423
+ });
100424
+ }
100425
+ return handlers;
100426
+ }
100427
+
100428
+ // ../api-core/src/utils/lti.util.ts
100429
+ function generateUsername(email5) {
100430
+ const baseUsername = (email5.split("@")[0] || "user").toLowerCase();
100431
+ const cleanUsername = baseUsername.replace(/[^a-z0-9]/g, "");
100432
+ const randomSuffix = Math.random().toString(36).substring(2, 7);
100433
+ return `${cleanUsername}_${randomSuffix}`;
100434
+ }
100435
+ function extractRedirectPath(targetUri, currentHost) {
100436
+ try {
100437
+ const targetUrl = new URL(targetUri);
100438
+ if (targetUrl.hostname === currentHost) {
100439
+ return targetUrl.pathname + targetUrl.search;
100440
+ }
100441
+ } catch {}
100442
+ return "/";
100443
+ }
100444
+ function validateLtiClaims(claims) {
100445
+ const messageType = claims["https://purl.imsglobal.org/spec/lti/claim/message_type"];
100446
+ const version4 = claims["https://purl.imsglobal.org/spec/lti/claim/version"];
100447
+ if (messageType !== "LtiResourceLinkRequest") {
100448
+ return `Invalid LTI message type: ${messageType}`;
100449
+ }
100450
+ if (version4 !== "1.3.0") {
100451
+ return `Unsupported LTI version: ${version4}`;
100452
+ }
100453
+ return null;
100454
+ }
100455
+ var init_lti_util = () => {};
100456
+
100457
+ // ../api-core/src/utils/lti-provisioning.ts
100458
+ import * as crypto4 from "node:crypto";
100459
+ async function provisionLtiUser(db2, claims) {
100460
+ const database = db2;
100461
+ const email5 = claims.email;
100462
+ const ltiTimebackId = claims.sub;
100463
+ const providerId = AUTH_PROVIDER_IDS.TIMEBACK_LTI;
100464
+ if (!email5) {
100465
+ throw new ValidationError("Email is required in LTI claims");
100466
+ }
100467
+ const existingAccount = await database.query.accounts.findFirst({
100468
+ where: and(eq(accounts.accountId, ltiTimebackId), eq(accounts.providerId, providerId))
100469
+ });
100470
+ if (existingAccount) {
100471
+ const user = await database.query.users.findFirst({
100472
+ where: eq(users.id, existingAccount.userId)
100473
+ });
100474
+ if (user) {
100475
+ setAttribute("app.lti.provision", "existing_account");
100476
+ return user;
100477
+ }
100478
+ }
100479
+ const existingUser = await database.query.users.findFirst({
100480
+ where: eq(users.email, email5)
100481
+ });
100482
+ if (existingUser) {
100483
+ await database.transaction(async (tx) => {
100484
+ const existingLtiAccount = await tx.query.accounts.findFirst({
100485
+ where: and(eq(accounts.userId, existingUser.id), eq(accounts.providerId, providerId))
100486
+ });
100487
+ if (!existingLtiAccount) {
100488
+ const [account] = await tx.insert(accounts).values({
100489
+ id: crypto4.randomUUID(),
100490
+ userId: existingUser.id,
100491
+ accountId: ltiTimebackId,
100492
+ providerId,
100493
+ accessToken: null,
100494
+ refreshToken: null,
100495
+ accessTokenExpiresAt: null,
100496
+ refreshTokenExpiresAt: null,
100497
+ createdAt: new Date,
100498
+ updatedAt: new Date
100499
+ }).returning({ id: accounts.id });
100500
+ if (!account) {
100501
+ throw new InternalError("Failed to link LTI account");
100502
+ }
100503
+ }
100504
+ });
100505
+ setAttribute("app.lti.provision", "linked_account");
100506
+ return existingUser;
100507
+ }
100508
+ const newUserId = crypto4.randomUUID();
100509
+ const createdUser = await database.transaction(async (tx) => {
100510
+ const [insertedUser] = await tx.insert(users).values({
100511
+ id: newUserId,
100512
+ email: email5,
100513
+ emailVerified: true,
100514
+ username: generateUsername(email5),
100515
+ name: claims.name || claims.given_name || email5.split("@")[0] || "Timeback User",
100516
+ createdAt: new Date,
100517
+ updatedAt: new Date
100518
+ }).returning();
100519
+ if (!insertedUser) {
100520
+ throw new InternalError("Failed to create user");
100521
+ }
100522
+ await tx.insert(accounts).values({
100523
+ id: crypto4.randomUUID(),
100524
+ userId: newUserId,
100525
+ accountId: ltiTimebackId,
100526
+ providerId,
100527
+ accessToken: null,
100528
+ refreshToken: null,
100529
+ accessTokenExpiresAt: null,
100530
+ refreshTokenExpiresAt: null,
100531
+ createdAt: new Date,
100532
+ updatedAt: new Date
100533
+ });
100534
+ setAttribute("app.lti.provision", "created_user");
100535
+ return insertedUser;
100536
+ });
100537
+ return createdUser;
100538
+ }
100539
+ var init_lti_provisioning = __esm(() => {
100540
+ init_drizzle_orm();
100541
+ init_src();
100542
+ init_tables_index();
100543
+ init_spans();
100544
+ init_errors2();
100545
+ init_lti_util();
100546
+ });
100547
+
100548
+ // ../api-core/src/utils/params.util.ts
100549
+ function requireGameId(gameId) {
100550
+ if (!gameId) {
100551
+ throw ApiError.badRequest("Missing game ID");
100552
+ }
100553
+ if (!isValidUUID(gameId)) {
100554
+ throw ApiError.unprocessableEntity("gameId must be a valid UUID format");
100555
+ }
100556
+ return gameId;
100557
+ }
100558
+ function requireSlug(slug2) {
100559
+ if (!slug2) {
100560
+ throw ApiError.badRequest("Missing game slug");
100561
+ }
100562
+ return slug2;
100563
+ }
100564
+ function requireUserId(userId) {
100565
+ if (!userId) {
100566
+ throw ApiError.badRequest("Missing user ID");
100567
+ }
100568
+ if (!isValidUUID(userId)) {
100569
+ throw ApiError.unprocessableEntity("userId must be a valid UUID format");
100570
+ }
100571
+ return userId;
100572
+ }
100573
+ function parseLimitParam(url4, max) {
100574
+ const raw = url4.searchParams.get("limit");
100575
+ if (raw === null) {
100576
+ return;
100577
+ }
100578
+ const limit = Number(raw);
100579
+ if (!Number.isInteger(limit) || limit < 1 || limit > max) {
100580
+ throw ApiError.badRequest(`limit must be an integer between 1 and ${max}`);
100581
+ }
100582
+ return limit;
100583
+ }
100584
+ var init_params_util = __esm(() => {
100585
+ init_src9();
100586
+ init_errors2();
100587
+ });
100588
+
100589
+ // ../api-core/src/utils/validation.util.ts
100590
+ function formatZodError(error88) {
100591
+ const flat = error88.flatten();
100592
+ const result = {};
100593
+ if (Object.keys(flat.fieldErrors).length > 0) {
100594
+ result.fields = {};
100595
+ for (const [field, messages] of Object.entries(flat.fieldErrors)) {
100596
+ if (messages && messages.length > 0) {
100597
+ result.fields[field] = messages[0];
100598
+ }
100599
+ }
100600
+ }
100601
+ if (flat.formErrors.length > 0) {
100602
+ result.errors = flat.formErrors;
100603
+ }
100604
+ return result;
100605
+ }
100606
+ function recordValidationFailure(details) {
100607
+ setAttribute("app.request.outcome", "validation_failed");
100608
+ addEvent("request.validation_failed", {
100609
+ "app.validation.error": JSON.stringify(details)
100610
+ });
100611
+ }
100612
+ async function parseRequestBody(request, schema2) {
100613
+ try {
100614
+ return schema2.parse(await request.json());
100615
+ } catch (error88) {
100616
+ if (error88 instanceof exports_external.ZodError) {
100617
+ const details = formatZodError(error88);
100618
+ recordValidationFailure(details);
100619
+ throw ApiError.unprocessableEntity("Validation failed", details);
100620
+ }
100621
+ throw ApiError.invalidJsonBody();
100622
+ }
100623
+ }
100624
+ var init_validation_util = __esm(() => {
100625
+ init_esm();
100626
+ init_spans();
100627
+ init_errors2();
100628
+ });
100629
+ // ../api-core/src/utils/index.ts
100630
+ var init_utils7 = __esm(() => {
100631
+ init_auth_util();
100632
+ init_assessment_runtime_lock_util();
100633
+ init_dashboard_util();
100634
+ init_deployment_util();
100635
+ init_leaderboard_util();
100636
+ init_lti_util();
100637
+ init_lti_provisioning();
100638
+ init_params_util();
100639
+ init_secrets_util();
100640
+ init_timeback_util();
100641
+ init_validation_util();
100642
+ });
100643
+
99904
100644
  // src/infrastructure/api/clients/timeback.ts
99905
100645
  function buildTimebackClient() {
99906
100646
  if (!hasTimebackCredentials()) {
@@ -100288,7 +101028,7 @@ function createSandboxContext(options) {
100288
101028
  const services = {};
100289
101029
  const ctx = {
100290
101030
  db: options.db,
100291
- databaseLock: createInMemoryDatabaseLock(),
101031
+ assessmentRuntimeLock: createInMemoryAssessmentRuntimeLock(),
100292
101032
  config: config5,
100293
101033
  providers,
100294
101034
  services,
@@ -100316,7 +101056,7 @@ function resetSandboxContext() {
100316
101056
  var cachedServiceContext = null, cachedDb = null;
100317
101057
  var init_context = __esm(async () => {
100318
101058
  init_config2();
100319
- init_locks();
101059
+ init_utils7();
100320
101060
  init_src6();
100321
101061
  init_providers();
100322
101062
  await __promiseAll([
@@ -114530,7 +115270,7 @@ __export(exports_api, {
114530
115270
  import process22 from "process";
114531
115271
  import os2 from "os";
114532
115272
  import tty from "tty";
114533
- import { randomUUID } from "crypto";
115273
+ import { randomUUID as randomUUID2 } from "crypto";
114534
115274
  function assembleStyles() {
114535
115275
  const codes = /* @__PURE__ */ new Map;
114536
115276
  for (const [groupName, group] of Object.entries(styles2)) {
@@ -117205,7 +117945,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117205
117945
  __defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
117206
117946
  }
117207
117947
  return to;
117208
- }, __toESM5 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, mod)), __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value), ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles2, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default, init_ansi_styles, env, flagForceColor, supportsColor, supports_color_default, init_supports_color, init_utilities, stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles22, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default, init_source, require_old, require_fs, require_path, require_balanced_match, require_brace_expansion, require_minimatch, require_inherits_browser2, require_inherits2, require_common3, require_sync, require_wrappy, require_once, require_inflight, require_glob, require_readline, require_src3, require_utils4, require_lodash, require_hanji, originUUID, snapshotVersion, mapValues, mapKeys, mapEntries, customMapEntries, init_global2, util3, objectUtil2, ZodParsedType2, getParsedType4, init_util5, ZodIssueCode4, ZodError5, init_ZodError2, errorMap2, en_default4, init_en4, overrideErrorMap2, init_errors9, makeIssue2, ParseStatus2, INVALID3, DIRTY2, OK2, isAborted2, isDirty2, isValid2, isAsync2, init_parseUtil2, init_typeAliases2, errorUtil2, init_errorUtil2, ParseInputLazyPath2, handleResult2, ZodType4, cuidRegex2, cuid2Regex2, ulidRegex2, uuidRegex2, nanoidRegex2, jwtRegex2, durationRegex2, emailRegex2, _emojiRegex2, emojiRegex2, ipv4Regex2, ipv4CidrRegex2, ipv6Regex2, ipv6CidrRegex2, base64Regex2, base64urlRegex2, dateRegexSource2, dateRegex2, ZodString4, ZodNumber4, ZodBigInt4, ZodBoolean4, ZodDate4, ZodSymbol4, ZodUndefined4, ZodNull4, ZodAny4, ZodUnknown4, ZodNever4, ZodVoid4, ZodArray4, ZodObject4, ZodUnion4, getDiscriminator2, ZodDiscriminatedUnion4, ZodIntersection4, ZodTuple4, ZodRecord4, ZodMap4, ZodSet4, ZodFunction3, ZodLazy4, ZodLiteral4, ZodEnum4, ZodNativeEnum2, ZodPromise4, ZodEffects2, ZodOptional4, ZodNullable4, ZodDefault4, ZodCatch4, ZodNaN4, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly4, late2, ZodFirstPartyTypeKind3, stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, coerce2, init_types5, init_external4, init_v32, init_esm2, enumSchema, enumSchemaV1, indexColumn, index2, fk, sequenceSchema, roleSchema, sequenceSquashed, column2, checkConstraint, columnSquashed, compositePK, uniqueConstraint, policy, policySquashed, viewWithOption, matViewWithOption, mergedViewWithOption, view2, table8, schemaHash, kitInternals, gelSchemaExternal, gelSchemaInternal, tableSquashed, gelSchemaSquashed, gelSchema, dryGel, init_gelSchema, index22, fk2, column22, tableV3, compositePK2, uniqueConstraint2, checkConstraint2, tableV4, table22, viewMeta, view22, kitInternals2, dialect2, schemaHash2, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema2, tableSquashedV4, tableSquashed2, viewSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql, init_mysqlSchema, indexV2, columnV2, tableV2, enumSchemaV12, enumSchema2, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn2, index3, indexV4, indexV5, indexV6, fk3, sequenceSchema2, roleSchema2, sequenceSquashed2, columnV7, column3, checkConstraint3, columnSquashed2, tableV32, compositePK3, uniqueConstraint3, policy2, policySquashed2, viewWithOption2, matViewWithOption2, mergedViewWithOption2, view3, tableV42, tableV5, tableV6, tableV7, table32, schemaHash3, kitInternals3, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed3, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg, init_pgSchema, index4, column4, compositePK4, uniqueConstraint4, table42, viewMeta2, kitInternals4, dialect22, schemaHash4, schemaInternal2, schema22, tableSquashed4, schemaSquashed2, SingleStoreSquasher, squashSingleStoreScheme, singlestoreSchema, singlestoreSchemaSquashed, backwardCompatibleSingleStoreSchema, drySingleStore, init_singlestoreSchema, index5, fk4, compositePK5, column5, tableV33, uniqueConstraint5, checkConstraint4, table52, view4, dialect3, schemaHash5, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals5, latestVersion, schemaInternal3, schemaV32, schemaV42, schemaV52, schema3, tableSquashed5, schemaSquashed3, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema, init_sqliteSchema, copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, init_utils7, import_hanji, warning, error88, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelectNamed, ResolveSelect, ResolveSchemasSelect, Spinner2, ProgressView, init_views, glob, init_serializer, fillPgSnapshot, init_migrationPreparator, require_heap, require_heap2, require_difflib, require_difflib2, require_util2, require_styles, require_has_flag2, require_supports_colors, require_trap, require_zalgo, require_america, require_zebra, require_rainbow, require_random, require_colors, require_safe, require_colorize, require_lib4, import_json_diff, mapArraysDiff, findAlternationsInTable, alternationsInColumn, init_jsonDiffer, parseType, Convertor, PgCreateRoleConvertor, PgDropRoleConvertor, PgRenameRoleConvertor, PgAlterRoleConvertor, PgCreatePolicyConvertor, PgDropPolicyConvertor, PgRenamePolicyConvertor, PgAlterPolicyConvertor, PgCreateIndPolicyConvertor, PgDropIndPolicyConvertor, PgRenameIndPolicyConvertor, PgAlterIndPolicyConvertor, PgEnableRlsConvertor, PgDisableRlsConvertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SingleStoreCreateTableConvertor, SQLiteCreateTableConvertor, PgCreateViewConvertor, MySqlCreateViewConvertor, SqliteCreateViewConvertor, PgDropViewConvertor, MySqlDropViewConvertor, SqliteDropViewConvertor, MySqlAlterViewConvertor, PgRenameViewConvertor, MySqlRenameViewConvertor, PgAlterViewSchemaConvertor, PgAlterViewAddWithOptionConvertor, PgAlterViewDropWithOptionConvertor, PgAlterViewAlterTablespaceConvertor, PgAlterViewAlterUsingConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, SingleStoreAlterTableAddUniqueConstraintConvertor, SingleStoreAlterTableDropUniqueConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SingleStoreDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, SingleStoreRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SingleStoreAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SingleStoreAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SingleStoreAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, SingleStoreAlterTableAlterColumnAlterrGeneratedConvertor, SingleStoreAlterTableAddPk, SingleStoreAlterTableDropPk, SingleStoreModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSingleStoreIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SingleStoreDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, SingleStoreRecreateTableConvertor, convertors, init_sqlgenerator, _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn, init_sqlitePushUtils, preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSingleStoreCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateRoleJson, prepareAlterRoleJson, prepareDropRoleJson, prepareRenameRoleJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, prepareRenamePolicyJsons, prepareRenameIndPolicyJsons, prepareCreatePolicyJsons, prepareCreateIndPolicyJsons, prepareDropPolicyJsons, prepareDropIndPolicyJsons, prepareAlterPolicyJson, prepareAlterIndPolicyJson, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql, preparePgCreateViewJson, prepareMySqlCreateViewJson, prepareSqliteCreateViewJson, prepareDropViewJson, prepareRenameViewJson, preparePgAlterViewAlterSchemaJson, preparePgAlterViewAddWithOptionJson, preparePgAlterViewDropWithOptionJson, preparePgAlterViewAlterTablespaceJson, preparePgAlterViewAlterUsingJson, prepareMySqlAlterView, init_jsonStatements, prepareLibSQLRecreateTable, prepareSQLiteRecreateTable, libSQLCombineStatements, sqliteCombineStatements, prepareSingleStoreRecreateTable, singleStoreCombineStatements, init_statementCombiner, snapshotsDiffer_exports, makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema3, changedEnumSchema, tableScheme, alteredTableScheme, alteredViewCommon, alteredPgViewSchema, alteredMySqlViewSchema, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSingleStore, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySingleStoreSnapshotsDiff, applySqliteSnapshotsDiff, applyLibSQLSnapshotsDiff, init_snapshotsDiffer, init_words, dialects, dialect4, commonSquashedSchema, commonSchema, init_schemaValidator, sqliteDriversLiterals, postgresqlDriversLiterals, prefixes, prefix, casingTypes, casingType, sqliteDriver, postgresDriver, driver2, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema, init_common2, withStyle, init_outputs, import_hanji2, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, roleResolver, policyResolver, indPolicyResolver, enumsResolver, columnsResolver, promptColumnsConflicts, promptNamedConflict, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, init_migrate, posixClasses, braceEscape, regexpEscape, rangesToString, parseClass, init_brace_expressions, escape, init_escape, unescape, init_unescape, import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep3, GLOBSTAR, plTypes, qmark, star, twoStarDot, twoStarNoDot, charSet, reSpecials, addPatternStartSet, filter, ext, defaults, braceExpand, MAX_PATTERN_LENGTH, assertValidPattern, makeRe, match2, globUnescape, globMagic, regExpEscape, Minimatch, init_mjs, entityKind2, hasOwnEntityKind2, init_entity2, _a3, Column2, init_column2, _a22, ColumnBuilder2, init_column_builder2, TableName2, init_table_utils2, _a32, ForeignKeyBuilder2, _a4, ForeignKey2, init_foreign_keys2, init_tracing_utils2, _a5, UniqueConstraintBuilder, _a6, UniqueOnConstraintBuilder, _a7, UniqueConstraint, init_unique_constraint2, init_array2, _a8, _b, PgColumnBuilder2, _a9, _b2, PgColumn2, _a10, _b3, ExtraConfigColumn2, _a11, IndexedColumn2, _a12, _b4, PgArrayBuilder2, _a13, _b5, _PgArray, PgArray2, init_common22, _a14, _b6, PgEnumObjectColumnBuilder2, _a15, _b7, PgEnumObjectColumn2, isPgEnumSym2, _a16, _b8, PgEnumColumnBuilder2, _a17, _b9, PgEnumColumn2, init_enum2, _a18, Subquery2, _a19, _b10, WithSubquery2, init_subquery2, version4, init_version2, otel2, rawTracer2, tracer2, init_tracing2, ViewBaseConfig2, init_view_common3, Schema2, Columns2, ExtraConfigColumns2, OriginalName2, BaseName2, IsAlias2, ExtraConfigBuilder2, IsDrizzleTable2, _a20, _b11, _c, _d, _e3, _f, _g, _h, _i, _j, Table2, init_table8, _a21, FakePrimitiveParam, _a222, StringChunk2, _a23, _SQL, SQL2, _a24, Name2, noopDecoder2, noopEncoder2, noopMapper2, _a25, Param2, _a26, Placeholder2, IsDrizzleView2, _a27, _b12, _c2, View3, init_sql5, _a28, ColumnAliasProxyHandler2, _a29, TableAliasProxyHandler2, _a30, RelationTableAliasProxyHandler, init_alias3, _a31, _b13, DrizzleError2, DrizzleQueryError, _a322, _b14, TransactionRollbackError2, init_errors22, _a33, ConsoleLogWriter2, _a34, DefaultLogger2, _a35, NoopLogger2, init_logger3, init_operations, _a36, _b15, QueryPromise2, init_query_promise2, textDecoder, init_utils22, _a37, _b16, PgIntColumnBaseBuilder2, init_int_common2, _a38, _b17, PgBigInt53Builder2, _a39, _b18, PgBigInt532, _a40, _b19, PgBigInt64Builder2, _a41, _b20, PgBigInt642, init_bigint2, _a42, _b21, PgBigSerial53Builder2, _a43, _b22, PgBigSerial532, _a44, _b23, PgBigSerial64Builder2, _a45, _b24, PgBigSerial642, init_bigserial2, _a46, _b25, PgBooleanBuilder2, _a47, _b26, PgBoolean2, init_boolean2, _a48, _b27, PgCharBuilder2, _a49, _b28, PgChar2, init_char2, _a50, _b29, PgCidrBuilder2, _a51, _b30, PgCidr2, init_cidr2, _a52, _b31, PgCustomColumnBuilder2, _a53, _b32, PgCustomColumn2, init_custom2, _a54, _b33, PgDateColumnBaseBuilder2, init_date_common2, _a55, _b34, PgDateBuilder2, _a56, _b35, PgDate2, _a57, _b36, PgDateStringBuilder2, _a58, _b37, PgDateString2, init_date2, _a59, _b38, PgDoublePrecisionBuilder2, _a60, _b39, PgDoublePrecision2, init_double_precision2, _a61, _b40, PgInetBuilder2, _a62, _b41, PgInet2, init_inet2, _a63, _b42, PgIntegerBuilder2, _a64, _b43, PgInteger2, init_integer2, _a65, _b44, PgIntervalBuilder2, _a66, _b45, PgInterval2, init_interval2, _a67, _b46, PgJsonBuilder2, _a68, _b47, PgJson2, init_json2, _a69, _b48, PgJsonbBuilder2, _a70, _b49, PgJsonb2, init_jsonb2, _a71, _b50, PgLineBuilder2, _a72, _b51, PgLineTuple2, _a73, _b52, PgLineABCBuilder2, _a74, _b53, PgLineABC2, init_line2, _a75, _b54, PgMacaddrBuilder2, _a76, _b55, PgMacaddr2, init_macaddr2, _a77, _b56, PgMacaddr8Builder2, _a78, _b57, PgMacaddr82, init_macaddr82, _a79, _b58, PgNumericBuilder2, _a80, _b59, PgNumeric2, _a81, _b60, PgNumericNumberBuilder2, _a82, _b61, PgNumericNumber2, _a83, _b62, PgNumericBigIntBuilder2, _a84, _b63, PgNumericBigInt2, init_numeric2, _a85, _b64, PgPointTupleBuilder2, _a86, _b65, PgPointTuple2, _a87, _b66, PgPointObjectBuilder2, _a88, _b67, PgPointObject2, init_point2, init_utils32, _a89, _b68, PgGeometryBuilder2, _a90, _b69, PgGeometry2, _a91, _b70, PgGeometryObjectBuilder2, _a92, _b71, PgGeometryObject2, init_geometry2, _a93, _b72, PgRealBuilder2, _a94, _b73, PgReal2, init_real2, _a95, _b74, PgSerialBuilder2, _a96, _b75, PgSerial2, init_serial2, _a97, _b76, PgSmallIntBuilder2, _a98, _b77, PgSmallInt2, init_smallint2, _a99, _b78, PgSmallSerialBuilder2, _a100, _b79, PgSmallSerial2, init_smallserial2, _a101, _b80, PgTextBuilder2, _a102, _b81, PgText2, init_text2, _a103, _b82, PgTimeBuilder2, _a104, _b83, PgTime2, init_time2, _a105, _b84, PgTimestampBuilder2, _a106, _b85, PgTimestamp2, _a107, _b86, PgTimestampStringBuilder2, _a108, _b87, PgTimestampString2, init_timestamp2, _a109, _b88, PgUUIDBuilder2, _a110, _b89, PgUUID2, init_uuid3, _a111, _b90, PgVarcharBuilder2, _a112, _b91, PgVarchar2, init_varchar2, _a113, _b92, PgBinaryVectorBuilder2, _a114, _b93, PgBinaryVector2, init_bit2, _a115, _b94, PgHalfVectorBuilder2, _a116, _b95, PgHalfVector2, init_halfvec2, _a117, _b96, PgSparseVectorBuilder2, _a118, _b97, PgSparseVector2, init_sparsevec2, _a119, _b98, PgVectorBuilder2, _a120, _b99, PgVector2, init_vector3, init_all2, InlineForeignKeys2, EnableRLS2, _a121, _b100, _c3, _d2, _e22, _f2, PgTable2, pgTable2, init_table22, _a122, PrimaryKeyBuilder2, _a123, PrimaryKey2, init_primary_keys2, eq2, ne4, gt3, gte2, lt4, lte2, init_conditions2, init_select3, init_expressions2, _a124, Relation2, _a125, Relations2, _a126, _b101, _One, One2, _a127, _b102, _Many, Many2, init_relations2, init_aggregate2, init_vector22, init_functions2, init_sql22, dist_exports, init_dist9, init_alias22, _a128, CheckBuilder2, _a129, Check2, init_checks6, init_columns2, _a130, _SelectionProxyHandler, SelectionProxyHandler2, init_selection_proxy2, _a131, IndexBuilderOn2, _a132, IndexBuilder2, _a133, Index2, init_indexes2, _a134, PgPolicy, init_policies2, PgViewConfig2, init_view_common22, _a135, CasingCache2, init_casing2, _a136, _b103, PgViewBase2, init_view_base2, _a137, PgDialect2, init_dialect2, _a138, TypedQueryBuilder2, init_query_builder3, _a139, PgSelectBuilder2, _a140, _b104, PgSelectQueryBuilderBase2, _a141, _b105, PgSelectBase2, getPgSetOperators2, union22, unionAll2, intersect2, intersectAll2, except2, exceptAll2, init_select22, _a142, QueryBuilder2, init_query_builder22, _a143, DefaultViewBuilderCore, _a144, _b106, ViewBuilder, _a145, _b107, ManualViewBuilder, _a146, MaterializedViewBuilderCore, _a147, _b108, MaterializedViewBuilder, _a148, _b109, ManualMaterializedViewBuilder, _a149, _b110, _c4, PgView2, PgMaterializedViewConfig2, _a150, _b111, _c5, PgMaterializedView, init_view2, init_utils42, _a151, _b112, PgDeleteBase2, init_delete2, _a152, PgInsertBuilder2, _a153, _b113, PgInsertBase2, init_insert2, _a154, _b114, PgRefreshMaterializedView2, init_refresh_materialized_view2, init_select_types, _a155, PgUpdateBuilder2, _a156, _b115, PgUpdateBase2, init_update2, init_query_builders2, _a157, _b116, _c6, _PgCountBuilder, PgCountBuilder2, init_count2, _a158, RelationalQueryBuilder2, _a159, _b117, PgRelationalQuery2, init_query2, _a160, _b118, PgRaw2, init_raw2, _a161, PgDatabase2, init_db2, _a162, PgRole, init_roles2, _a163, PgSequence, init_sequence2, _a164, PgSchema5, init_schema4, _a165, Cache, _a166, _b119, NoopCache, init_cache, _a167, PgPreparedQuery2, _a168, PgSession2, _a169, _b120, PgTransaction2, init_session3, init_subquery22, init_utils52, init_pg_core2, vectorOps, init_vector32, sqlToStr, init_utils62, indexName, generatePgSnapshot, trimChar, fromDatabase, defaultForColumn, getColumnsInfoQuery, init_pgSerializer, import_hanji4, Select, init_selector_ui, init_alias32, _a170, CheckBuilder22, _a171, Check22, init_checks22, _a172, ForeignKeyBuilder22, _a173, ForeignKey22, init_foreign_keys22, _a174, UniqueConstraintBuilder2, _a175, UniqueOnConstraintBuilder2, _a176, UniqueConstraint2, init_unique_constraint22, _a177, _b121, SQLiteColumnBuilder, _a178, _b122, SQLiteColumn, init_common3, _a179, _b123, SQLiteBigIntBuilder, _a180, _b124, SQLiteBigInt, _a181, _b125, SQLiteBlobJsonBuilder, _a182, _b126, SQLiteBlobJson, _a183, _b127, SQLiteBlobBufferBuilder, _a184, _b128, SQLiteBlobBuffer, init_blob, _a185, _b129, SQLiteCustomColumnBuilder, _a186, _b130, SQLiteCustomColumn, init_custom22, _a187, _b131, SQLiteBaseIntegerBuilder, _a188, _b132, SQLiteBaseInteger, _a189, _b133, SQLiteIntegerBuilder, _a190, _b134, SQLiteInteger, _a191, _b135, SQLiteTimestampBuilder, _a192, _b136, SQLiteTimestamp, _a193, _b137, SQLiteBooleanBuilder, _a194, _b138, SQLiteBoolean, init_integer22, _a195, _b139, SQLiteNumericBuilder, _a196, _b140, SQLiteNumeric, _a197, _b141, SQLiteNumericNumberBuilder, _a198, _b142, SQLiteNumericNumber, _a199, _b143, SQLiteNumericBigIntBuilder, _a200, _b144, SQLiteNumericBigInt, init_numeric22, _a201, _b145, SQLiteRealBuilder, _a202, _b146, SQLiteReal, init_real22, _a203, _b147, SQLiteTextBuilder, _a204, _b148, SQLiteText, _a205, _b149, SQLiteTextJsonBuilder, _a206, _b150, SQLiteTextJson, init_text22, init_columns22, init_all22, InlineForeignKeys22, _a207, _b151, _c7, _d3, _e32, SQLiteTable, sqliteTable, init_table32, _a208, IndexBuilderOn22, _a209, IndexBuilder22, _a210, Index4, init_indexes22, _a211, PrimaryKeyBuilder22, _a212, PrimaryKey22, init_primary_keys22, init_utils72, _a213, _b152, SQLiteDeleteBase, init_delete22, _a214, _b153, SQLiteViewBase, init_view_base22, _a215, SQLiteDialect, _a216, _b154, SQLiteSyncDialect, _a217, _b155, SQLiteAsyncDialect, init_dialect22, _a218, SQLiteSelectBuilder, _a219, _b156, SQLiteSelectQueryBuilderBase, _a220, _b157, SQLiteSelectBase, getSQLiteSetOperators, union32, unionAll22, intersect22, except22, init_select32, _a221, QueryBuilder22, init_query_builder32, _a2222, SQLiteInsertBuilder, _a223, _b158, SQLiteInsertBase, init_insert22, init_select_types2, _a224, SQLiteUpdateBuilder, _a225, _b159, SQLiteUpdateBase, init_update22, init_query_builders22, _a226, _b160, _c8, _SQLiteCountBuilder, SQLiteCountBuilder, init_count22, _a227, RelationalQueryBuilder22, _a228, _b161, SQLiteRelationalQuery, _a229, _b162, SQLiteSyncRelationalQuery, init_query22, _a230, _b163, SQLiteRaw, init_raw22, _a231, BaseSQLiteDatabase, init_db22, _a232, _b164, ExecuteResultSync, _a233, SQLitePreparedQuery, _a234, SQLiteSession, _a235, _b165, SQLiteTransaction, init_session22, init_subquery3, _a236, ViewBuilderCore, _a237, _b166, ViewBuilder2, _a238, _b167, ManualViewBuilder2, _a239, _b168, SQLiteView2, init_view22, init_sqlite_core, generateSqliteSnapshot, fromDatabase2, init_sqliteSerializer, getTablesFilterByExtensions, init_getTablesFilterByExtensions, init_alias4, _a240, CheckBuilder3, _a241, Check3, init_checks32, _a242, ForeignKeyBuilder3, _a243, ForeignKey3, init_foreign_keys3, _a244, UniqueConstraintBuilder3, _a245, UniqueOnConstraintBuilder3, _a246, UniqueConstraint3, init_unique_constraint3, _a247, _b169, MySqlColumnBuilder, _a248, _b170, MySqlColumn, _a249, _b171, MySqlColumnBuilderWithAutoIncrement, _a250, _b172, MySqlColumnWithAutoIncrement, init_common4, _a251, _b173, MySqlBigInt53Builder, _a252, _b174, MySqlBigInt53, _a253, _b175, MySqlBigInt64Builder, _a254, _b176, MySqlBigInt64, init_bigint22, _a255, _b177, MySqlBinaryBuilder, _a256, _b178, MySqlBinary, init_binary, _a257, _b179, MySqlBooleanBuilder, _a258, _b180, MySqlBoolean, init_boolean22, _a259, _b181, MySqlCharBuilder, _a260, _b182, MySqlChar, init_char22, _a261, _b183, MySqlCustomColumnBuilder, _a262, _b184, MySqlCustomColumn, init_custom3, _a263, _b185, MySqlDateBuilder, _a264, _b186, MySqlDate, _a265, _b187, MySqlDateStringBuilder, _a266, _b188, MySqlDateString, init_date22, _a267, _b189, MySqlDateTimeBuilder, _a268, _b190, MySqlDateTime, _a269, _b191, MySqlDateTimeStringBuilder, _a270, _b192, MySqlDateTimeString, init_datetime, _a271, _b193, MySqlDecimalBuilder, _a272, _b194, MySqlDecimal, _a273, _b195, MySqlDecimalNumberBuilder, _a274, _b196, MySqlDecimalNumber, _a275, _b197, MySqlDecimalBigIntBuilder, _a276, _b198, MySqlDecimalBigInt, init_decimal, _a277, _b199, MySqlDoubleBuilder, _a278, _b200, MySqlDouble, init_double, _a279, _b201, MySqlEnumColumnBuilder, _a280, _b202, MySqlEnumColumn, _a281, _b203, MySqlEnumObjectColumnBuilder, _a282, _b204, MySqlEnumObjectColumn, init_enum22, _a283, _b205, MySqlFloatBuilder, _a284, _b206, MySqlFloat, init_float, _a285, _b207, MySqlIntBuilder, _a286, _b208, MySqlInt, init_int, _a287, _b209, MySqlJsonBuilder, _a288, _b210, MySqlJson, init_json22, _a289, _b211, MySqlMediumIntBuilder, _a290, _b212, MySqlMediumInt, init_mediumint, _a291, _b213, MySqlRealBuilder, _a292, _b214, MySqlReal, init_real3, _a293, _b215, MySqlSerialBuilder, _a294, _b216, MySqlSerial, init_serial22, _a295, _b217, MySqlSmallIntBuilder, _a296, _b218, MySqlSmallInt, init_smallint22, _a297, _b219, MySqlTextBuilder, _a298, _b220, MySqlText, init_text3, _a299, _b221, MySqlTimeBuilder, _a300, _b222, MySqlTime, init_time22, _a301, _b223, MySqlDateColumnBaseBuilder, _a302, _b224, MySqlDateBaseColumn, init_date_common22, _a303, _b225, MySqlTimestampBuilder, _a304, _b226, MySqlTimestamp, _a305, _b227, MySqlTimestampStringBuilder, _a306, _b228, MySqlTimestampString, init_timestamp22, _a307, _b229, MySqlTinyIntBuilder, _a308, _b230, MySqlTinyInt, init_tinyint, _a309, _b231, MySqlVarBinaryBuilder, _a310, _b232, MySqlVarBinary, init_varbinary, _a311, _b233, MySqlVarCharBuilder, _a312, _b234, MySqlVarChar, init_varchar22, _a313, _b235, MySqlYearBuilder, _a314, _b236, MySqlYear, init_year, init_columns3, _a315, _b237, _c9, _MySqlCountBuilder, MySqlCountBuilder, init_count3, _a316, IndexBuilderOn3, _a317, IndexBuilder3, _a318, Index5, init_indexes3, init_all3, InlineForeignKeys3, _a319, _b238, _c10, _d4, _e4, MySqlTable, mysqlTable, init_table42, _a320, PrimaryKeyBuilder3, _a321, PrimaryKey3, init_primary_keys3, MySqlViewConfig, init_view_common32, init_utils8, _a3222, _b239, MySqlDeleteBase, init_delete3, _a323, _b240, MySqlViewBase, init_view_base3, _a324, MySqlDialect, init_dialect3, _a325, MySqlSelectBuilder, _a326, _b241, MySqlSelectQueryBuilderBase, _a327, _b242, MySqlSelectBase, getMySqlSetOperators, union4, unionAll3, intersect3, intersectAll22, except3, exceptAll22, init_select4, _a328, QueryBuilder3, init_query_builder4, _a329, MySqlInsertBuilder, _a330, _b243, MySqlInsertBase, init_insert3, init_select_types3, _a331, MySqlUpdateBuilder, _a332, _b244, MySqlUpdateBase, init_update3, init_query_builders3, _a333, RelationalQueryBuilder3, _a334, _b245, MySqlRelationalQuery, init_query3, _a335, MySqlDatabase, init_db3, _a336, ViewBuilderCore2, _a337, _b246, ViewBuilder3, _a338, _b247, ManualViewBuilder3, _a339, _b248, _c11, MySqlView2, init_view3, _a340, MySqlSchema5, init_schema22, _a341, MySqlPreparedQuery, _a342, MySqlSession, _a343, _b249, MySqlTransaction, init_session32, init_subquery4, init_mysql_core, handleEnumType, generateMySqlSnapshot, fromDatabase3, init_mysqlSerializer, cliConfigGenerate, pushParams, pullParams, configCheck, cliConfigCheck, init_cli, gelCredentials, init_gel, libSQLCredentials, init_libsql, mysqlCredentials, init_mysql, postgresCredentials, init_postgres, singlestoreCredentials, init_singlestore, sqliteCredentials, init_sqlite, credentials, studioCliParams, studioConfig, init_studio, es5_exports, _3, es5_default, init_es5, import_hanji7, assertES5, safeRegister, migrateConfig, init_utils9, prepareFromExports, init_pgImports, init_alias5, _a344, UniqueConstraintBuilder4, _a345, UniqueOnConstraintBuilder4, _a346, UniqueConstraint4, init_unique_constraint4, _a347, _b250, SingleStoreColumnBuilder, _a348, _b251, SingleStoreColumn, _a349, _b252, SingleStoreColumnBuilderWithAutoIncrement, _a350, _b253, SingleStoreColumnWithAutoIncrement, init_common5, _a351, _b254, SingleStoreBigInt53Builder, _a352, _b255, SingleStoreBigInt53, _a353, _b256, SingleStoreBigInt64Builder, _a354, _b257, SingleStoreBigInt64, init_bigint3, _a355, _b258, SingleStoreBinaryBuilder, _a356, _b259, SingleStoreBinary, init_binary2, _a357, _b260, SingleStoreBooleanBuilder, _a358, _b261, SingleStoreBoolean, init_boolean3, _a359, _b262, SingleStoreCharBuilder, _a360, _b263, SingleStoreChar, init_char3, _a361, _b264, SingleStoreCustomColumnBuilder, _a362, _b265, SingleStoreCustomColumn, init_custom4, _a363, _b266, SingleStoreDateBuilder, _a364, _b267, SingleStoreDate, _a365, _b268, SingleStoreDateStringBuilder, _a366, _b269, SingleStoreDateString, init_date3, _a367, _b270, SingleStoreDateTimeBuilder, _a368, _b271, SingleStoreDateTime, _a369, _b272, SingleStoreDateTimeStringBuilder, _a370, _b273, SingleStoreDateTimeString, init_datetime2, _a371, _b274, SingleStoreDecimalBuilder, _a372, _b275, SingleStoreDecimal, _a373, _b276, SingleStoreDecimalNumberBuilder, _a374, _b277, SingleStoreDecimalNumber, _a375, _b278, SingleStoreDecimalBigIntBuilder, _a376, _b279, SingleStoreDecimalBigInt, init_decimal2, _a377, _b280, SingleStoreDoubleBuilder, _a378, _b281, SingleStoreDouble, init_double2, _a379, _b282, SingleStoreEnumColumnBuilder, _a380, _b283, SingleStoreEnumColumn, init_enum3, _a381, _b284, SingleStoreFloatBuilder, _a382, _b285, SingleStoreFloat, init_float2, _a383, _b286, SingleStoreIntBuilder, _a384, _b287, SingleStoreInt, init_int2, _a385, _b288, SingleStoreJsonBuilder, _a386, _b289, SingleStoreJson, init_json3, _a387, _b290, SingleStoreMediumIntBuilder, _a388, _b291, SingleStoreMediumInt, init_mediumint2, _a389, _b292, SingleStoreRealBuilder, _a390, _b293, SingleStoreReal, init_real4, _a391, _b294, SingleStoreSerialBuilder, _a392, _b295, SingleStoreSerial, init_serial3, _a393, _b296, SingleStoreSmallIntBuilder, _a394, _b297, SingleStoreSmallInt, init_smallint3, _a395, _b298, SingleStoreTextBuilder, _a396, _b299, SingleStoreText, init_text4, _a397, _b300, SingleStoreTimeBuilder, _a398, _b301, SingleStoreTime, init_time3, _a399, _b302, SingleStoreDateColumnBaseBuilder, _a400, _b303, SingleStoreDateBaseColumn, init_date_common3, _a401, _b304, SingleStoreTimestampBuilder, _a402, _b305, SingleStoreTimestamp, _a403, _b306, SingleStoreTimestampStringBuilder, _a404, _b307, SingleStoreTimestampString, init_timestamp3, _a405, _b308, SingleStoreTinyIntBuilder, _a406, _b309, SingleStoreTinyInt, init_tinyint2, _a407, _b310, SingleStoreVarBinaryBuilder, _a408, _b311, SingleStoreVarBinary, init_varbinary2, _a409, _b312, SingleStoreVarCharBuilder, _a410, _b313, SingleStoreVarChar, init_varchar3, _a411, _b314, SingleStoreVectorBuilder, _a412, _b315, SingleStoreVector, init_vector4, _a413, _b316, SingleStoreYearBuilder, _a414, _b317, SingleStoreYear, init_year2, init_columns4, _a415, _b318, _c12, _SingleStoreCountBuilder, SingleStoreCountBuilder, init_count4, _a416, IndexBuilderOn4, _a417, IndexBuilder4, _a418, Index6, init_indexes4, init_all4, _a419, _b319, _c13, _d5, SingleStoreTable, init_table52, _a420, PrimaryKeyBuilder4, _a421, PrimaryKey4, init_primary_keys4, init_utils10, _a422, _b320, SingleStoreDeleteBase, init_delete4, _a423, SingleStoreInsertBuilder, _a424, _b321, SingleStoreInsertBase, init_insert4, _a425, SingleStoreDialect, init_dialect4, _a426, SingleStoreSelectBuilder, _a427, _b322, SingleStoreSelectQueryBuilderBase, _a428, _b323, SingleStoreSelectBase, getSingleStoreSetOperators, union5, unionAll4, intersect4, except4, minus, init_select5, _a429, QueryBuilder4, init_query_builder5, init_select_types4, _a430, SingleStoreUpdateBuilder, _a431, _b324, SingleStoreUpdateBase, init_update4, init_query_builders4, _a432, SingleStoreDatabase, init_db4, _a433, SingleStoreSchema5, init_schema32, _a434, SingleStorePreparedQuery, _a435, SingleStoreSession, _a436, _b325, SingleStoreTransaction, init_session4, init_subquery5, init_singlestore_core, dialect5, generateSingleStoreSnapshot, fromDatabase4, init_singlestoreSerializer, sqliteImports_exports, prepareFromExports2, prepareFromSqliteImports, init_sqliteImports, mysqlImports_exports, prepareFromExports3, prepareFromMySqlImports, init_mysqlImports, mysqlPushUtils_exports, import_hanji8, filterStatements, logSuggestionsAndReturn2, init_mysqlPushUtils, mysqlIntrospect_exports, import_hanji9, mysqlPushIntrospect, init_mysqlIntrospect, singlestoreImports_exports, prepareFromExports4, prepareFromSingleStoreImports, init_singlestoreImports, singlestorePushUtils_exports, import_hanji10, filterStatements2, logSuggestionsAndReturn3, init_singlestorePushUtils, singlestoreIntrospect_exports, import_hanji11, singlestorePushIntrospect, init_singlestoreIntrospect, import_hanji3, pgPushIntrospect = async (db2, filters, schemaFilters, entities, tsSchema) => {
117948
+ }, __toESM5 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target, mod)), __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value), ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles2, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default, init_ansi_styles, env, flagForceColor, supportsColor, supports_color_default, init_supports_color, init_utilities, stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles22, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default, init_source, require_old, require_fs, require_path, require_balanced_match, require_brace_expansion, require_minimatch, require_inherits_browser2, require_inherits2, require_common3, require_sync, require_wrappy, require_once, require_inflight, require_glob, require_readline, require_src3, require_utils4, require_lodash, require_hanji, originUUID, snapshotVersion, mapValues, mapKeys, mapEntries, customMapEntries, init_global2, util3, objectUtil2, ZodParsedType2, getParsedType4, init_util5, ZodIssueCode4, ZodError5, init_ZodError2, errorMap2, en_default4, init_en4, overrideErrorMap2, init_errors9, makeIssue2, ParseStatus2, INVALID3, DIRTY2, OK2, isAborted2, isDirty2, isValid2, isAsync2, init_parseUtil2, init_typeAliases2, errorUtil2, init_errorUtil2, ParseInputLazyPath2, handleResult2, ZodType4, cuidRegex2, cuid2Regex2, ulidRegex2, uuidRegex2, nanoidRegex2, jwtRegex2, durationRegex2, emailRegex2, _emojiRegex2, emojiRegex2, ipv4Regex2, ipv4CidrRegex2, ipv6Regex2, ipv6CidrRegex2, base64Regex2, base64urlRegex2, dateRegexSource2, dateRegex2, ZodString4, ZodNumber4, ZodBigInt4, ZodBoolean4, ZodDate4, ZodSymbol4, ZodUndefined4, ZodNull4, ZodAny4, ZodUnknown4, ZodNever4, ZodVoid4, ZodArray4, ZodObject4, ZodUnion4, getDiscriminator2, ZodDiscriminatedUnion4, ZodIntersection4, ZodTuple4, ZodRecord4, ZodMap4, ZodSet4, ZodFunction3, ZodLazy4, ZodLiteral4, ZodEnum4, ZodNativeEnum2, ZodPromise4, ZodEffects2, ZodOptional4, ZodNullable4, ZodDefault4, ZodCatch4, ZodNaN4, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly4, late2, ZodFirstPartyTypeKind3, stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, coerce2, init_types6, init_external4, init_v32, init_esm2, enumSchema, enumSchemaV1, indexColumn, index2, fk, sequenceSchema, roleSchema, sequenceSquashed, column2, checkConstraint, columnSquashed, compositePK, uniqueConstraint, policy, policySquashed, viewWithOption, matViewWithOption, mergedViewWithOption, view2, table8, schemaHash, kitInternals, gelSchemaExternal, gelSchemaInternal, tableSquashed, gelSchemaSquashed, gelSchema, dryGel, init_gelSchema, index22, fk2, column22, tableV3, compositePK2, uniqueConstraint2, checkConstraint2, tableV4, table22, viewMeta, view22, kitInternals2, dialect2, schemaHash2, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema2, tableSquashedV4, tableSquashed2, viewSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql, init_mysqlSchema, indexV2, columnV2, tableV2, enumSchemaV12, enumSchema2, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn2, index3, indexV4, indexV5, indexV6, fk3, sequenceSchema2, roleSchema2, sequenceSquashed2, columnV7, column3, checkConstraint3, columnSquashed2, tableV32, compositePK3, uniqueConstraint3, policy2, policySquashed2, viewWithOption2, matViewWithOption2, mergedViewWithOption2, view3, tableV42, tableV5, tableV6, tableV7, table32, schemaHash3, kitInternals3, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed3, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg, init_pgSchema, index4, column4, compositePK4, uniqueConstraint4, table42, viewMeta2, kitInternals4, dialect22, schemaHash4, schemaInternal2, schema22, tableSquashed4, schemaSquashed2, SingleStoreSquasher, squashSingleStoreScheme, singlestoreSchema, singlestoreSchemaSquashed, backwardCompatibleSingleStoreSchema, drySingleStore, init_singlestoreSchema, index5, fk4, compositePK5, column5, tableV33, uniqueConstraint5, checkConstraint4, table52, view4, dialect3, schemaHash5, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals5, latestVersion, schemaInternal3, schemaV32, schemaV42, schemaV52, schema3, tableSquashed5, schemaSquashed3, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema, init_sqliteSchema, copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, init_utils8, import_hanji, warning, error88, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelectNamed, ResolveSelect, ResolveSchemasSelect, Spinner2, ProgressView, init_views, glob, init_serializer, fillPgSnapshot, init_migrationPreparator, require_heap, require_heap2, require_difflib, require_difflib2, require_util2, require_styles, require_has_flag2, require_supports_colors, require_trap, require_zalgo, require_america, require_zebra, require_rainbow, require_random, require_colors, require_safe, require_colorize, require_lib4, import_json_diff, mapArraysDiff, findAlternationsInTable, alternationsInColumn, init_jsonDiffer, parseType, Convertor, PgCreateRoleConvertor, PgDropRoleConvertor, PgRenameRoleConvertor, PgAlterRoleConvertor, PgCreatePolicyConvertor, PgDropPolicyConvertor, PgRenamePolicyConvertor, PgAlterPolicyConvertor, PgCreateIndPolicyConvertor, PgDropIndPolicyConvertor, PgRenameIndPolicyConvertor, PgAlterIndPolicyConvertor, PgEnableRlsConvertor, PgDisableRlsConvertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SingleStoreCreateTableConvertor, SQLiteCreateTableConvertor, PgCreateViewConvertor, MySqlCreateViewConvertor, SqliteCreateViewConvertor, PgDropViewConvertor, MySqlDropViewConvertor, SqliteDropViewConvertor, MySqlAlterViewConvertor, PgRenameViewConvertor, MySqlRenameViewConvertor, PgAlterViewSchemaConvertor, PgAlterViewAddWithOptionConvertor, PgAlterViewDropWithOptionConvertor, PgAlterViewAlterTablespaceConvertor, PgAlterViewAlterUsingConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, SingleStoreAlterTableAddUniqueConstraintConvertor, SingleStoreAlterTableDropUniqueConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SingleStoreDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, SingleStoreRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SingleStoreAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SingleStoreAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SingleStoreAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, SingleStoreAlterTableAlterColumnAlterrGeneratedConvertor, SingleStoreAlterTableAddPk, SingleStoreAlterTableDropPk, SingleStoreModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSingleStoreIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SingleStoreDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, SingleStoreRecreateTableConvertor, convertors, init_sqlgenerator, _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn, init_sqlitePushUtils, preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSingleStoreCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateRoleJson, prepareAlterRoleJson, prepareDropRoleJson, prepareRenameRoleJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, prepareRenamePolicyJsons, prepareRenameIndPolicyJsons, prepareCreatePolicyJsons, prepareCreateIndPolicyJsons, prepareDropPolicyJsons, prepareDropIndPolicyJsons, prepareAlterPolicyJson, prepareAlterIndPolicyJson, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql, preparePgCreateViewJson, prepareMySqlCreateViewJson, prepareSqliteCreateViewJson, prepareDropViewJson, prepareRenameViewJson, preparePgAlterViewAlterSchemaJson, preparePgAlterViewAddWithOptionJson, preparePgAlterViewDropWithOptionJson, preparePgAlterViewAlterTablespaceJson, preparePgAlterViewAlterUsingJson, prepareMySqlAlterView, init_jsonStatements, prepareLibSQLRecreateTable, prepareSQLiteRecreateTable, libSQLCombineStatements, sqliteCombineStatements, prepareSingleStoreRecreateTable, singleStoreCombineStatements, init_statementCombiner, snapshotsDiffer_exports, makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema3, changedEnumSchema, tableScheme, alteredTableScheme, alteredViewCommon, alteredPgViewSchema, alteredMySqlViewSchema, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSingleStore, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySingleStoreSnapshotsDiff, applySqliteSnapshotsDiff, applyLibSQLSnapshotsDiff, init_snapshotsDiffer, init_words, dialects, dialect4, commonSquashedSchema, commonSchema, init_schemaValidator, sqliteDriversLiterals, postgresqlDriversLiterals, prefixes, prefix, casingTypes, casingType, sqliteDriver, postgresDriver, driver2, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema, init_common2, withStyle, init_outputs, import_hanji2, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, roleResolver, policyResolver, indPolicyResolver, enumsResolver, columnsResolver, promptColumnsConflicts, promptNamedConflict, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, init_migrate, posixClasses, braceEscape, regexpEscape, rangesToString, parseClass, init_brace_expressions, escape, init_escape, unescape, init_unescape, import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path, sep3, GLOBSTAR, plTypes, qmark, star, twoStarDot, twoStarNoDot, charSet, reSpecials, addPatternStartSet, filter, ext, defaults, braceExpand, MAX_PATTERN_LENGTH, assertValidPattern, makeRe, match2, globUnescape, globMagic, regExpEscape, Minimatch, init_mjs, entityKind2, hasOwnEntityKind2, init_entity2, _a3, Column2, init_column2, _a22, ColumnBuilder2, init_column_builder2, TableName2, init_table_utils2, _a32, ForeignKeyBuilder2, _a4, ForeignKey2, init_foreign_keys2, init_tracing_utils2, _a5, UniqueConstraintBuilder, _a6, UniqueOnConstraintBuilder, _a7, UniqueConstraint, init_unique_constraint2, init_array2, _a8, _b, PgColumnBuilder2, _a9, _b2, PgColumn2, _a10, _b3, ExtraConfigColumn2, _a11, IndexedColumn2, _a12, _b4, PgArrayBuilder2, _a13, _b5, _PgArray, PgArray2, init_common22, _a14, _b6, PgEnumObjectColumnBuilder2, _a15, _b7, PgEnumObjectColumn2, isPgEnumSym2, _a16, _b8, PgEnumColumnBuilder2, _a17, _b9, PgEnumColumn2, init_enum2, _a18, Subquery2, _a19, _b10, WithSubquery2, init_subquery2, version4, init_version2, otel2, rawTracer2, tracer2, init_tracing2, ViewBaseConfig2, init_view_common3, Schema2, Columns2, ExtraConfigColumns2, OriginalName2, BaseName2, IsAlias2, ExtraConfigBuilder2, IsDrizzleTable2, _a20, _b11, _c, _d, _e3, _f, _g, _h, _i, _j, Table2, init_table8, _a21, FakePrimitiveParam, _a222, StringChunk2, _a23, _SQL, SQL2, _a24, Name2, noopDecoder2, noopEncoder2, noopMapper2, _a25, Param2, _a26, Placeholder2, IsDrizzleView2, _a27, _b12, _c2, View3, init_sql5, _a28, ColumnAliasProxyHandler2, _a29, TableAliasProxyHandler2, _a30, RelationTableAliasProxyHandler, init_alias3, _a31, _b13, DrizzleError2, DrizzleQueryError, _a322, _b14, TransactionRollbackError2, init_errors22, _a33, ConsoleLogWriter2, _a34, DefaultLogger2, _a35, NoopLogger2, init_logger3, init_operations, _a36, _b15, QueryPromise2, init_query_promise2, textDecoder, init_utils22, _a37, _b16, PgIntColumnBaseBuilder2, init_int_common2, _a38, _b17, PgBigInt53Builder2, _a39, _b18, PgBigInt532, _a40, _b19, PgBigInt64Builder2, _a41, _b20, PgBigInt642, init_bigint2, _a42, _b21, PgBigSerial53Builder2, _a43, _b22, PgBigSerial532, _a44, _b23, PgBigSerial64Builder2, _a45, _b24, PgBigSerial642, init_bigserial2, _a46, _b25, PgBooleanBuilder2, _a47, _b26, PgBoolean2, init_boolean2, _a48, _b27, PgCharBuilder2, _a49, _b28, PgChar2, init_char2, _a50, _b29, PgCidrBuilder2, _a51, _b30, PgCidr2, init_cidr2, _a52, _b31, PgCustomColumnBuilder2, _a53, _b32, PgCustomColumn2, init_custom2, _a54, _b33, PgDateColumnBaseBuilder2, init_date_common2, _a55, _b34, PgDateBuilder2, _a56, _b35, PgDate2, _a57, _b36, PgDateStringBuilder2, _a58, _b37, PgDateString2, init_date2, _a59, _b38, PgDoublePrecisionBuilder2, _a60, _b39, PgDoublePrecision2, init_double_precision2, _a61, _b40, PgInetBuilder2, _a62, _b41, PgInet2, init_inet2, _a63, _b42, PgIntegerBuilder2, _a64, _b43, PgInteger2, init_integer2, _a65, _b44, PgIntervalBuilder2, _a66, _b45, PgInterval2, init_interval2, _a67, _b46, PgJsonBuilder2, _a68, _b47, PgJson2, init_json2, _a69, _b48, PgJsonbBuilder2, _a70, _b49, PgJsonb2, init_jsonb2, _a71, _b50, PgLineBuilder2, _a72, _b51, PgLineTuple2, _a73, _b52, PgLineABCBuilder2, _a74, _b53, PgLineABC2, init_line2, _a75, _b54, PgMacaddrBuilder2, _a76, _b55, PgMacaddr2, init_macaddr2, _a77, _b56, PgMacaddr8Builder2, _a78, _b57, PgMacaddr82, init_macaddr82, _a79, _b58, PgNumericBuilder2, _a80, _b59, PgNumeric2, _a81, _b60, PgNumericNumberBuilder2, _a82, _b61, PgNumericNumber2, _a83, _b62, PgNumericBigIntBuilder2, _a84, _b63, PgNumericBigInt2, init_numeric2, _a85, _b64, PgPointTupleBuilder2, _a86, _b65, PgPointTuple2, _a87, _b66, PgPointObjectBuilder2, _a88, _b67, PgPointObject2, init_point2, init_utils32, _a89, _b68, PgGeometryBuilder2, _a90, _b69, PgGeometry2, _a91, _b70, PgGeometryObjectBuilder2, _a92, _b71, PgGeometryObject2, init_geometry2, _a93, _b72, PgRealBuilder2, _a94, _b73, PgReal2, init_real2, _a95, _b74, PgSerialBuilder2, _a96, _b75, PgSerial2, init_serial2, _a97, _b76, PgSmallIntBuilder2, _a98, _b77, PgSmallInt2, init_smallint2, _a99, _b78, PgSmallSerialBuilder2, _a100, _b79, PgSmallSerial2, init_smallserial2, _a101, _b80, PgTextBuilder2, _a102, _b81, PgText2, init_text2, _a103, _b82, PgTimeBuilder2, _a104, _b83, PgTime2, init_time2, _a105, _b84, PgTimestampBuilder2, _a106, _b85, PgTimestamp2, _a107, _b86, PgTimestampStringBuilder2, _a108, _b87, PgTimestampString2, init_timestamp2, _a109, _b88, PgUUIDBuilder2, _a110, _b89, PgUUID2, init_uuid3, _a111, _b90, PgVarcharBuilder2, _a112, _b91, PgVarchar2, init_varchar2, _a113, _b92, PgBinaryVectorBuilder2, _a114, _b93, PgBinaryVector2, init_bit2, _a115, _b94, PgHalfVectorBuilder2, _a116, _b95, PgHalfVector2, init_halfvec2, _a117, _b96, PgSparseVectorBuilder2, _a118, _b97, PgSparseVector2, init_sparsevec2, _a119, _b98, PgVectorBuilder2, _a120, _b99, PgVector2, init_vector3, init_all2, InlineForeignKeys2, EnableRLS2, _a121, _b100, _c3, _d2, _e22, _f2, PgTable2, pgTable2, init_table22, _a122, PrimaryKeyBuilder2, _a123, PrimaryKey2, init_primary_keys2, eq2, ne4, gt3, gte2, lt4, lte2, init_conditions2, init_select3, init_expressions2, _a124, Relation2, _a125, Relations2, _a126, _b101, _One, One2, _a127, _b102, _Many, Many2, init_relations2, init_aggregate2, init_vector22, init_functions2, init_sql22, dist_exports, init_dist9, init_alias22, _a128, CheckBuilder2, _a129, Check2, init_checks6, init_columns2, _a130, _SelectionProxyHandler, SelectionProxyHandler2, init_selection_proxy2, _a131, IndexBuilderOn2, _a132, IndexBuilder2, _a133, Index2, init_indexes2, _a134, PgPolicy, init_policies2, PgViewConfig2, init_view_common22, _a135, CasingCache2, init_casing2, _a136, _b103, PgViewBase2, init_view_base2, _a137, PgDialect2, init_dialect2, _a138, TypedQueryBuilder2, init_query_builder3, _a139, PgSelectBuilder2, _a140, _b104, PgSelectQueryBuilderBase2, _a141, _b105, PgSelectBase2, getPgSetOperators2, union22, unionAll2, intersect2, intersectAll2, except2, exceptAll2, init_select22, _a142, QueryBuilder2, init_query_builder22, _a143, DefaultViewBuilderCore, _a144, _b106, ViewBuilder, _a145, _b107, ManualViewBuilder, _a146, MaterializedViewBuilderCore, _a147, _b108, MaterializedViewBuilder, _a148, _b109, ManualMaterializedViewBuilder, _a149, _b110, _c4, PgView2, PgMaterializedViewConfig2, _a150, _b111, _c5, PgMaterializedView, init_view2, init_utils42, _a151, _b112, PgDeleteBase2, init_delete2, _a152, PgInsertBuilder2, _a153, _b113, PgInsertBase2, init_insert2, _a154, _b114, PgRefreshMaterializedView2, init_refresh_materialized_view2, init_select_types, _a155, PgUpdateBuilder2, _a156, _b115, PgUpdateBase2, init_update2, init_query_builders2, _a157, _b116, _c6, _PgCountBuilder, PgCountBuilder2, init_count2, _a158, RelationalQueryBuilder2, _a159, _b117, PgRelationalQuery2, init_query2, _a160, _b118, PgRaw2, init_raw2, _a161, PgDatabase2, init_db2, _a162, PgRole, init_roles2, _a163, PgSequence, init_sequence2, _a164, PgSchema5, init_schema4, _a165, Cache, _a166, _b119, NoopCache, init_cache, _a167, PgPreparedQuery2, _a168, PgSession2, _a169, _b120, PgTransaction2, init_session3, init_subquery22, init_utils52, init_pg_core2, vectorOps, init_vector32, sqlToStr, init_utils62, indexName, generatePgSnapshot, trimChar, fromDatabase, defaultForColumn, getColumnsInfoQuery, init_pgSerializer, import_hanji4, Select, init_selector_ui, init_alias32, _a170, CheckBuilder22, _a171, Check22, init_checks22, _a172, ForeignKeyBuilder22, _a173, ForeignKey22, init_foreign_keys22, _a174, UniqueConstraintBuilder2, _a175, UniqueOnConstraintBuilder2, _a176, UniqueConstraint2, init_unique_constraint22, _a177, _b121, SQLiteColumnBuilder, _a178, _b122, SQLiteColumn, init_common3, _a179, _b123, SQLiteBigIntBuilder, _a180, _b124, SQLiteBigInt, _a181, _b125, SQLiteBlobJsonBuilder, _a182, _b126, SQLiteBlobJson, _a183, _b127, SQLiteBlobBufferBuilder, _a184, _b128, SQLiteBlobBuffer, init_blob, _a185, _b129, SQLiteCustomColumnBuilder, _a186, _b130, SQLiteCustomColumn, init_custom22, _a187, _b131, SQLiteBaseIntegerBuilder, _a188, _b132, SQLiteBaseInteger, _a189, _b133, SQLiteIntegerBuilder, _a190, _b134, SQLiteInteger, _a191, _b135, SQLiteTimestampBuilder, _a192, _b136, SQLiteTimestamp, _a193, _b137, SQLiteBooleanBuilder, _a194, _b138, SQLiteBoolean, init_integer22, _a195, _b139, SQLiteNumericBuilder, _a196, _b140, SQLiteNumeric, _a197, _b141, SQLiteNumericNumberBuilder, _a198, _b142, SQLiteNumericNumber, _a199, _b143, SQLiteNumericBigIntBuilder, _a200, _b144, SQLiteNumericBigInt, init_numeric22, _a201, _b145, SQLiteRealBuilder, _a202, _b146, SQLiteReal, init_real22, _a203, _b147, SQLiteTextBuilder, _a204, _b148, SQLiteText, _a205, _b149, SQLiteTextJsonBuilder, _a206, _b150, SQLiteTextJson, init_text22, init_columns22, init_all22, InlineForeignKeys22, _a207, _b151, _c7, _d3, _e32, SQLiteTable, sqliteTable, init_table32, _a208, IndexBuilderOn22, _a209, IndexBuilder22, _a210, Index4, init_indexes22, _a211, PrimaryKeyBuilder22, _a212, PrimaryKey22, init_primary_keys22, init_utils72, _a213, _b152, SQLiteDeleteBase, init_delete22, _a214, _b153, SQLiteViewBase, init_view_base22, _a215, SQLiteDialect, _a216, _b154, SQLiteSyncDialect, _a217, _b155, SQLiteAsyncDialect, init_dialect22, _a218, SQLiteSelectBuilder, _a219, _b156, SQLiteSelectQueryBuilderBase, _a220, _b157, SQLiteSelectBase, getSQLiteSetOperators, union32, unionAll22, intersect22, except22, init_select32, _a221, QueryBuilder22, init_query_builder32, _a2222, SQLiteInsertBuilder, _a223, _b158, SQLiteInsertBase, init_insert22, init_select_types2, _a224, SQLiteUpdateBuilder, _a225, _b159, SQLiteUpdateBase, init_update22, init_query_builders22, _a226, _b160, _c8, _SQLiteCountBuilder, SQLiteCountBuilder, init_count22, _a227, RelationalQueryBuilder22, _a228, _b161, SQLiteRelationalQuery, _a229, _b162, SQLiteSyncRelationalQuery, init_query22, _a230, _b163, SQLiteRaw, init_raw22, _a231, BaseSQLiteDatabase, init_db22, _a232, _b164, ExecuteResultSync, _a233, SQLitePreparedQuery, _a234, SQLiteSession, _a235, _b165, SQLiteTransaction, init_session22, init_subquery3, _a236, ViewBuilderCore, _a237, _b166, ViewBuilder2, _a238, _b167, ManualViewBuilder2, _a239, _b168, SQLiteView2, init_view22, init_sqlite_core, generateSqliteSnapshot, fromDatabase2, init_sqliteSerializer, getTablesFilterByExtensions, init_getTablesFilterByExtensions, init_alias4, _a240, CheckBuilder3, _a241, Check3, init_checks32, _a242, ForeignKeyBuilder3, _a243, ForeignKey3, init_foreign_keys3, _a244, UniqueConstraintBuilder3, _a245, UniqueOnConstraintBuilder3, _a246, UniqueConstraint3, init_unique_constraint3, _a247, _b169, MySqlColumnBuilder, _a248, _b170, MySqlColumn, _a249, _b171, MySqlColumnBuilderWithAutoIncrement, _a250, _b172, MySqlColumnWithAutoIncrement, init_common4, _a251, _b173, MySqlBigInt53Builder, _a252, _b174, MySqlBigInt53, _a253, _b175, MySqlBigInt64Builder, _a254, _b176, MySqlBigInt64, init_bigint22, _a255, _b177, MySqlBinaryBuilder, _a256, _b178, MySqlBinary, init_binary, _a257, _b179, MySqlBooleanBuilder, _a258, _b180, MySqlBoolean, init_boolean22, _a259, _b181, MySqlCharBuilder, _a260, _b182, MySqlChar, init_char22, _a261, _b183, MySqlCustomColumnBuilder, _a262, _b184, MySqlCustomColumn, init_custom3, _a263, _b185, MySqlDateBuilder, _a264, _b186, MySqlDate, _a265, _b187, MySqlDateStringBuilder, _a266, _b188, MySqlDateString, init_date22, _a267, _b189, MySqlDateTimeBuilder, _a268, _b190, MySqlDateTime, _a269, _b191, MySqlDateTimeStringBuilder, _a270, _b192, MySqlDateTimeString, init_datetime, _a271, _b193, MySqlDecimalBuilder, _a272, _b194, MySqlDecimal, _a273, _b195, MySqlDecimalNumberBuilder, _a274, _b196, MySqlDecimalNumber, _a275, _b197, MySqlDecimalBigIntBuilder, _a276, _b198, MySqlDecimalBigInt, init_decimal, _a277, _b199, MySqlDoubleBuilder, _a278, _b200, MySqlDouble, init_double, _a279, _b201, MySqlEnumColumnBuilder, _a280, _b202, MySqlEnumColumn, _a281, _b203, MySqlEnumObjectColumnBuilder, _a282, _b204, MySqlEnumObjectColumn, init_enum22, _a283, _b205, MySqlFloatBuilder, _a284, _b206, MySqlFloat, init_float, _a285, _b207, MySqlIntBuilder, _a286, _b208, MySqlInt, init_int, _a287, _b209, MySqlJsonBuilder, _a288, _b210, MySqlJson, init_json22, _a289, _b211, MySqlMediumIntBuilder, _a290, _b212, MySqlMediumInt, init_mediumint, _a291, _b213, MySqlRealBuilder, _a292, _b214, MySqlReal, init_real3, _a293, _b215, MySqlSerialBuilder, _a294, _b216, MySqlSerial, init_serial22, _a295, _b217, MySqlSmallIntBuilder, _a296, _b218, MySqlSmallInt, init_smallint22, _a297, _b219, MySqlTextBuilder, _a298, _b220, MySqlText, init_text3, _a299, _b221, MySqlTimeBuilder, _a300, _b222, MySqlTime, init_time22, _a301, _b223, MySqlDateColumnBaseBuilder, _a302, _b224, MySqlDateBaseColumn, init_date_common22, _a303, _b225, MySqlTimestampBuilder, _a304, _b226, MySqlTimestamp, _a305, _b227, MySqlTimestampStringBuilder, _a306, _b228, MySqlTimestampString, init_timestamp22, _a307, _b229, MySqlTinyIntBuilder, _a308, _b230, MySqlTinyInt, init_tinyint, _a309, _b231, MySqlVarBinaryBuilder, _a310, _b232, MySqlVarBinary, init_varbinary, _a311, _b233, MySqlVarCharBuilder, _a312, _b234, MySqlVarChar, init_varchar22, _a313, _b235, MySqlYearBuilder, _a314, _b236, MySqlYear, init_year, init_columns3, _a315, _b237, _c9, _MySqlCountBuilder, MySqlCountBuilder, init_count3, _a316, IndexBuilderOn3, _a317, IndexBuilder3, _a318, Index5, init_indexes3, init_all3, InlineForeignKeys3, _a319, _b238, _c10, _d4, _e4, MySqlTable, mysqlTable, init_table42, _a320, PrimaryKeyBuilder3, _a321, PrimaryKey3, init_primary_keys3, MySqlViewConfig, init_view_common32, init_utils82, _a3222, _b239, MySqlDeleteBase, init_delete3, _a323, _b240, MySqlViewBase, init_view_base3, _a324, MySqlDialect, init_dialect3, _a325, MySqlSelectBuilder, _a326, _b241, MySqlSelectQueryBuilderBase, _a327, _b242, MySqlSelectBase, getMySqlSetOperators, union4, unionAll3, intersect3, intersectAll22, except3, exceptAll22, init_select4, _a328, QueryBuilder3, init_query_builder4, _a329, MySqlInsertBuilder, _a330, _b243, MySqlInsertBase, init_insert3, init_select_types3, _a331, MySqlUpdateBuilder, _a332, _b244, MySqlUpdateBase, init_update3, init_query_builders3, _a333, RelationalQueryBuilder3, _a334, _b245, MySqlRelationalQuery, init_query3, _a335, MySqlDatabase, init_db3, _a336, ViewBuilderCore2, _a337, _b246, ViewBuilder3, _a338, _b247, ManualViewBuilder3, _a339, _b248, _c11, MySqlView2, init_view3, _a340, MySqlSchema5, init_schema22, _a341, MySqlPreparedQuery, _a342, MySqlSession, _a343, _b249, MySqlTransaction, init_session32, init_subquery4, init_mysql_core, handleEnumType, generateMySqlSnapshot, fromDatabase3, init_mysqlSerializer, cliConfigGenerate, pushParams, pullParams, configCheck, cliConfigCheck, init_cli, gelCredentials, init_gel, libSQLCredentials, init_libsql, mysqlCredentials, init_mysql, postgresCredentials, init_postgres, singlestoreCredentials, init_singlestore, sqliteCredentials, init_sqlite, credentials, studioCliParams, studioConfig, init_studio, es5_exports, _3, es5_default, init_es5, import_hanji7, assertES5, safeRegister, migrateConfig, init_utils9, prepareFromExports, init_pgImports, init_alias5, _a344, UniqueConstraintBuilder4, _a345, UniqueOnConstraintBuilder4, _a346, UniqueConstraint4, init_unique_constraint4, _a347, _b250, SingleStoreColumnBuilder, _a348, _b251, SingleStoreColumn, _a349, _b252, SingleStoreColumnBuilderWithAutoIncrement, _a350, _b253, SingleStoreColumnWithAutoIncrement, init_common5, _a351, _b254, SingleStoreBigInt53Builder, _a352, _b255, SingleStoreBigInt53, _a353, _b256, SingleStoreBigInt64Builder, _a354, _b257, SingleStoreBigInt64, init_bigint3, _a355, _b258, SingleStoreBinaryBuilder, _a356, _b259, SingleStoreBinary, init_binary2, _a357, _b260, SingleStoreBooleanBuilder, _a358, _b261, SingleStoreBoolean, init_boolean3, _a359, _b262, SingleStoreCharBuilder, _a360, _b263, SingleStoreChar, init_char3, _a361, _b264, SingleStoreCustomColumnBuilder, _a362, _b265, SingleStoreCustomColumn, init_custom4, _a363, _b266, SingleStoreDateBuilder, _a364, _b267, SingleStoreDate, _a365, _b268, SingleStoreDateStringBuilder, _a366, _b269, SingleStoreDateString, init_date3, _a367, _b270, SingleStoreDateTimeBuilder, _a368, _b271, SingleStoreDateTime, _a369, _b272, SingleStoreDateTimeStringBuilder, _a370, _b273, SingleStoreDateTimeString, init_datetime2, _a371, _b274, SingleStoreDecimalBuilder, _a372, _b275, SingleStoreDecimal, _a373, _b276, SingleStoreDecimalNumberBuilder, _a374, _b277, SingleStoreDecimalNumber, _a375, _b278, SingleStoreDecimalBigIntBuilder, _a376, _b279, SingleStoreDecimalBigInt, init_decimal2, _a377, _b280, SingleStoreDoubleBuilder, _a378, _b281, SingleStoreDouble, init_double2, _a379, _b282, SingleStoreEnumColumnBuilder, _a380, _b283, SingleStoreEnumColumn, init_enum3, _a381, _b284, SingleStoreFloatBuilder, _a382, _b285, SingleStoreFloat, init_float2, _a383, _b286, SingleStoreIntBuilder, _a384, _b287, SingleStoreInt, init_int2, _a385, _b288, SingleStoreJsonBuilder, _a386, _b289, SingleStoreJson, init_json3, _a387, _b290, SingleStoreMediumIntBuilder, _a388, _b291, SingleStoreMediumInt, init_mediumint2, _a389, _b292, SingleStoreRealBuilder, _a390, _b293, SingleStoreReal, init_real4, _a391, _b294, SingleStoreSerialBuilder, _a392, _b295, SingleStoreSerial, init_serial3, _a393, _b296, SingleStoreSmallIntBuilder, _a394, _b297, SingleStoreSmallInt, init_smallint3, _a395, _b298, SingleStoreTextBuilder, _a396, _b299, SingleStoreText, init_text4, _a397, _b300, SingleStoreTimeBuilder, _a398, _b301, SingleStoreTime, init_time3, _a399, _b302, SingleStoreDateColumnBaseBuilder, _a400, _b303, SingleStoreDateBaseColumn, init_date_common3, _a401, _b304, SingleStoreTimestampBuilder, _a402, _b305, SingleStoreTimestamp, _a403, _b306, SingleStoreTimestampStringBuilder, _a404, _b307, SingleStoreTimestampString, init_timestamp3, _a405, _b308, SingleStoreTinyIntBuilder, _a406, _b309, SingleStoreTinyInt, init_tinyint2, _a407, _b310, SingleStoreVarBinaryBuilder, _a408, _b311, SingleStoreVarBinary, init_varbinary2, _a409, _b312, SingleStoreVarCharBuilder, _a410, _b313, SingleStoreVarChar, init_varchar3, _a411, _b314, SingleStoreVectorBuilder, _a412, _b315, SingleStoreVector, init_vector4, _a413, _b316, SingleStoreYearBuilder, _a414, _b317, SingleStoreYear, init_year2, init_columns4, _a415, _b318, _c12, _SingleStoreCountBuilder, SingleStoreCountBuilder, init_count4, _a416, IndexBuilderOn4, _a417, IndexBuilder4, _a418, Index6, init_indexes4, init_all4, _a419, _b319, _c13, _d5, SingleStoreTable, init_table52, _a420, PrimaryKeyBuilder4, _a421, PrimaryKey4, init_primary_keys4, init_utils10, _a422, _b320, SingleStoreDeleteBase, init_delete4, _a423, SingleStoreInsertBuilder, _a424, _b321, SingleStoreInsertBase, init_insert4, _a425, SingleStoreDialect, init_dialect4, _a426, SingleStoreSelectBuilder, _a427, _b322, SingleStoreSelectQueryBuilderBase, _a428, _b323, SingleStoreSelectBase, getSingleStoreSetOperators, union5, unionAll4, intersect4, except4, minus, init_select5, _a429, QueryBuilder4, init_query_builder5, init_select_types4, _a430, SingleStoreUpdateBuilder, _a431, _b324, SingleStoreUpdateBase, init_update4, init_query_builders4, _a432, SingleStoreDatabase, init_db4, _a433, SingleStoreSchema5, init_schema32, _a434, SingleStorePreparedQuery, _a435, SingleStoreSession, _a436, _b325, SingleStoreTransaction, init_session4, init_subquery5, init_singlestore_core, dialect5, generateSingleStoreSnapshot, fromDatabase4, init_singlestoreSerializer, sqliteImports_exports, prepareFromExports2, prepareFromSqliteImports, init_sqliteImports, mysqlImports_exports, prepareFromExports3, prepareFromMySqlImports, init_mysqlImports, mysqlPushUtils_exports, import_hanji8, filterStatements, logSuggestionsAndReturn2, init_mysqlPushUtils, mysqlIntrospect_exports, import_hanji9, mysqlPushIntrospect, init_mysqlIntrospect, singlestoreImports_exports, prepareFromExports4, prepareFromSingleStoreImports, init_singlestoreImports, singlestorePushUtils_exports, import_hanji10, filterStatements2, logSuggestionsAndReturn3, init_singlestorePushUtils, singlestoreIntrospect_exports, import_hanji11, singlestorePushIntrospect, init_singlestoreIntrospect, import_hanji3, pgPushIntrospect = async (db2, filters, schemaFilters, entities, tsSchema) => {
117209
117949
  const matchers = filters.map((it3) => {
117210
117950
  return new Minimatch(it3);
117211
117951
  });
@@ -117462,7 +118202,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117462
118202
  return { schema: schema5 };
117463
118203
  }, generateDrizzleJson = (imports, prevId, schemaFilters, casing2) => {
117464
118204
  const prepared = prepareFromExports(imports);
117465
- const id = randomUUID();
118205
+ const id = randomUUID2();
117466
118206
  const snapshot = generatePgSnapshot(prepared.tables, prepared.enums, prepared.schemas, prepared.sequences, prepared.roles, prepared.policies, prepared.views, prepared.matViews, casing2, schemaFilters);
117467
118207
  return fillPgSnapshot({
117468
118208
  serialized: snapshot,
@@ -117508,7 +118248,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117508
118248
  }, generateSQLiteDrizzleJson = async (imports, prevId, casing2) => {
117509
118249
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_sqliteImports(), sqliteImports_exports));
117510
118250
  const prepared = prepareFromExports5(imports);
117511
- const id = randomUUID();
118251
+ const id = randomUUID2();
117512
118252
  const snapshot = generateSqliteSnapshot(prepared.tables, prepared.views, casing2);
117513
118253
  return {
117514
118254
  ...snapshot,
@@ -117556,7 +118296,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117556
118296
  }, generateMySQLDrizzleJson = async (imports, prevId, casing2) => {
117557
118297
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_mysqlImports(), mysqlImports_exports));
117558
118298
  const prepared = prepareFromExports5(imports);
117559
- const id = randomUUID();
118299
+ const id = randomUUID2();
117560
118300
  const snapshot = generateMySqlSnapshot(prepared.tables, prepared.views, casing2);
117561
118301
  return {
117562
118302
  ...snapshot,
@@ -117603,7 +118343,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117603
118343
  }, generateSingleStoreDrizzleJson = async (imports, prevId, casing2) => {
117604
118344
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_singlestoreImports(), singlestoreImports_exports));
117605
118345
  const prepared = prepareFromExports5(imports);
117606
- const id = randomUUID();
118346
+ const id = randomUUID2();
117607
118347
  const snapshot = generateSingleStoreSnapshot(prepared.tables, casing2);
117608
118348
  return {
117609
118349
  ...snapshot,
@@ -121215,7 +121955,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
121215
121955
  })(errorUtil2 || (errorUtil2 = {}));
121216
121956
  }
121217
121957
  });
121218
- init_types5 = __esm2({
121958
+ init_types6 = __esm2({
121219
121959
  "../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/types.js"() {
121220
121960
  init_ZodError2();
121221
121961
  init_errors9();
@@ -124380,7 +125120,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
124380
125120
  init_parseUtil2();
124381
125121
  init_typeAliases2();
124382
125122
  init_util5();
124383
- init_types5();
125123
+ init_types6();
124384
125124
  init_ZodError2();
124385
125125
  }
124386
125126
  });
@@ -126113,7 +126853,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
126113
126853
  backwardCompatibleSqliteSchema = unionType2([sqliteSchemaV5, schema3]);
126114
126854
  }
126115
126855
  });
126116
- init_utils7 = __esm2({
126856
+ init_utils8 = __esm2({
126117
126857
  "src/utils.ts"() {
126118
126858
  init_views();
126119
126859
  init_global2();
@@ -126165,7 +126905,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
126165
126905
  "src/cli/views.ts"() {
126166
126906
  init_source();
126167
126907
  import_hanji = __toESM5(require_hanji());
126168
- init_utils7();
126908
+ init_utils8();
126169
126909
  warning = (msg) => {
126170
126910
  (0, import_hanji.render)(`[${source_default.yellow("Warning")}] ${msg}`);
126171
126911
  };
@@ -128873,7 +129613,7 @@ Is ${source_default.bold.blue(this.base.name)} schema created or renamed from an
128873
129613
  init_pgSchema();
128874
129614
  init_singlestoreSchema();
128875
129615
  init_sqliteSchema();
128876
- init_utils7();
129616
+ init_utils8();
128877
129617
  parseType = (schemaPrefix, type) => {
128878
129618
  const pgNativeTypes = [
128879
129619
  "uuid",
@@ -131369,7 +132109,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
131369
132109
  init_source();
131370
132110
  init_sqliteSchema();
131371
132111
  init_sqlgenerator();
131372
- init_utils7();
132112
+ init_utils8();
131373
132113
  _moveDataStatements = (tableName, json42, dataLoss = false) => {
131374
132114
  const statements = [];
131375
132115
  const newTableName = `__new_${tableName}`;
@@ -133527,7 +134267,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
133527
134267
  init_singlestoreSchema();
133528
134268
  init_sqliteSchema();
133529
134269
  init_statementCombiner();
133530
- init_utils7();
134270
+ init_utils8();
133531
134271
  makeChanged = (schema5) => {
133532
134272
  return objectType2({
133533
134273
  type: enumType2(["changed"]),
@@ -135752,7 +136492,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
135752
136492
  init_pgSchema();
135753
136493
  init_sqliteSchema();
135754
136494
  init_snapshotsDiffer();
135755
- init_utils7();
136495
+ init_utils8();
135756
136496
  init_words();
135757
136497
  init_outputs();
135758
136498
  init_views();
@@ -142312,7 +143052,7 @@ params: ${params}`);
142312
143052
  init_pg_core2();
142313
143053
  init_vector32();
142314
143054
  init_outputs();
142315
- init_utils7();
143055
+ init_utils8();
142316
143056
  init_utils62();
142317
143057
  indexName = (tableName, columns2) => {
142318
143058
  return `${tableName}_${columns2.join("_")}_index`;
@@ -146321,7 +147061,7 @@ ORDER BY
146321
147061
  init_dist9();
146322
147062
  init_sqlite_core();
146323
147063
  init_outputs();
146324
- init_utils7();
147064
+ init_utils8();
146325
147065
  init_utils62();
146326
147066
  generateSqliteSnapshot = (tables, views, casing2) => {
146327
147067
  const dialect6 = new SQLiteSyncDialect({ casing: casing2 });
@@ -148274,7 +149014,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
148274
149014
  MySqlViewConfig = Symbol.for("drizzle:MySqlViewConfig");
148275
149015
  }
148276
149016
  });
148277
- init_utils8 = __esm2({
149017
+ init_utils82 = __esm2({
148278
149018
  "../drizzle-orm/dist/mysql-core/utils.js"() {
148279
149019
  init_entity2();
148280
149020
  init_dist9();
@@ -148296,7 +149036,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
148296
149036
  init_query_promise2();
148297
149037
  init_selection_proxy2();
148298
149038
  init_table8();
148299
- init_utils8();
149039
+ init_utils82();
148300
149040
  MySqlDeleteBase = class extends (_b239 = QueryPromise2, _a3222 = entityKind2, _b239) {
148301
149041
  constructor(table62, session3, dialect6, withList) {
148302
149042
  super();
@@ -149144,7 +149884,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
149144
149884
  init_table8();
149145
149885
  init_utils22();
149146
149886
  init_view_common3();
149147
- init_utils8();
149887
+ init_utils82();
149148
149888
  init_view_base3();
149149
149889
  _a325 = entityKind2;
149150
149890
  MySqlSelectBuilder = class {
@@ -149543,7 +150283,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
149543
150283
  init_sql5();
149544
150284
  init_table8();
149545
150285
  init_utils22();
149546
- init_utils8();
150286
+ init_utils82();
149547
150287
  init_query_builder4();
149548
150288
  _a329 = entityKind2;
149549
150289
  MySqlInsertBuilder = class {
@@ -149647,7 +150387,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
149647
150387
  init_selection_proxy2();
149648
150388
  init_table8();
149649
150389
  init_utils22();
149650
- init_utils8();
150390
+ init_utils82();
149651
150391
  _a331 = entityKind2;
149652
150392
  MySqlUpdateBuilder = class {
149653
150393
  constructor(table62, session3, dialect6, withList) {
@@ -150183,7 +150923,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
150183
150923
  init_subquery4();
150184
150924
  init_table42();
150185
150925
  init_unique_constraint3();
150186
- init_utils8();
150926
+ init_utils82();
150187
150927
  init_view_common32();
150188
150928
  init_view3();
150189
150929
  }
@@ -150194,7 +150934,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
150194
150934
  init_dist9();
150195
150935
  init_mysql_core();
150196
150936
  init_outputs();
150197
- init_utils7();
150937
+ init_utils8();
150198
150938
  init_utils62();
150199
150939
  handleEnumType = (type) => {
150200
150940
  let str = type.split("(")[1];
@@ -154628,7 +155368,7 @@ The unique index ${source_default.underline.blue(name22)} on the ${source_defaul
154628
155368
  import_hanji10 = __toESM5(require_hanji());
154629
155369
  init_sqlgenerator();
154630
155370
  init_singlestoreSchema();
154631
- init_utils7();
155371
+ init_utils8();
154632
155372
  init_selector_ui();
154633
155373
  init_outputs();
154634
155374
  filterStatements2 = (statements, currentSchema, prevSchema) => {
@@ -154891,7 +155631,7 @@ The unique index ${source_default.underline.blue(name22)} on the ${source_defaul
154891
155631
  init_sqlgenerator();
154892
155632
  init_selector_ui();
154893
155633
  init_pgSchema();
154894
- init_utils7();
155634
+ init_utils8();
154895
155635
  import_hanji6 = __toESM5(require_hanji());
154896
155636
  init_mjs();
154897
155637
  init_global2();
@@ -155779,346 +156519,11 @@ var init_manifest = __esm(async () => {
155779
156519
  });
155780
156520
  });
155781
156521
 
155782
- // ../api-core/src/types/context.type.ts
155783
- function isAuthenticated(ctx) {
155784
- return ctx.user != null;
155785
- }
155786
-
155787
- // ../api-core/src/types/index.ts
155788
- var init_types6 = () => {};
155789
-
155790
- // ../api-core/src/utils/auth.util.ts
155791
- function hasGameManagementAccess(user) {
155792
- return user.role === "admin" || user.role === "teacher" || user.role === "developer" && user.developerStatus === "approved";
155793
- }
155794
- function isDashboardWorkerKey(key) {
155795
- return Boolean(key?.permissions?.[DASHBOARD_PERMISSION_NAMESPACE]);
155796
- }
155797
- function workerKeyGrantsGameRead(key, slug2) {
155798
- if (!isDashboardWorkerKey(key) && !isGameWorkerKey(key)) {
155799
- return false;
155800
- }
155801
- const games2 = key?.permissions?.games;
155802
- return Boolean(games2?.includes(`read:${slug2}`) || games2?.includes(`write:${slug2}`));
155803
- }
155804
- function isGameWorkerKey(key) {
155805
- return Boolean(key?.name?.startsWith(GAME_WORKER_KEY_PREFIX));
155806
- }
155807
- function deniedWorkerKeyRequest(key, method, pathname) {
155808
- if (isDashboardWorkerKey(key) && !isAllowedDashboardWorkerRequest(method, pathname, key.permissions)) {
155809
- return DASHBOARD_WORKER_KEY_RESTRICTED;
155810
- }
155811
- return null;
155812
- }
155813
- function rejectDashboardWorkerKey(ctx) {
155814
- if (isDashboardWorkerKey(ctx.apiKey)) {
155815
- throw ApiError.forbidden(DASHBOARD_WORKER_KEY_RESTRICTED);
155816
- }
155817
- }
155818
- function assertAuthenticatedRequest(ctx) {
155819
- if (!isAuthenticated(ctx)) {
155820
- throw ApiError.unauthorized("Valid session or bearer token required");
155821
- }
155822
- if (ctx.apiKey) {
155823
- const denied = deniedWorkerKeyRequest(ctx.apiKey, ctx.request.method, ctx.url.pathname);
155824
- if (denied) {
155825
- throw ApiError.forbidden(denied);
155826
- }
155827
- }
155828
- }
155829
- function requireAuth(handler) {
155830
- return async (ctx) => {
155831
- assertAuthenticatedRequest(ctx);
155832
- return handler(ctx);
155833
- };
155834
- }
155835
- function requireNonAnonymous(handler) {
155836
- return async (ctx) => {
155837
- assertAuthenticatedRequest(ctx);
155838
- if (ctx.user.isAnonymous) {
155839
- throw ApiError.forbidden("This operation is not available for demo/anonymous users");
155840
- }
155841
- return handler(ctx);
155842
- };
155843
- }
155844
- function requireAnonymous(handler) {
155845
- return async (ctx) => {
155846
- assertAuthenticatedRequest(ctx);
155847
- if (!ctx.user.isAnonymous) {
155848
- throw ApiError.forbidden("This operation is only available for demo/anonymous users");
155849
- }
155850
- return handler(ctx);
155851
- };
155852
- }
155853
- function requireDeveloper(handler) {
155854
- return async (ctx) => {
155855
- assertAuthenticatedRequest(ctx);
155856
- rejectDashboardWorkerKey(ctx);
155857
- const isAdmin = ctx.user.role === "admin";
155858
- const isApprovedDev = ctx.user.role === "developer" && ctx.user.developerStatus === "approved";
155859
- if (!isAdmin && !isApprovedDev) {
155860
- throw ApiError.forbidden("Must be an approved developer");
155861
- }
155862
- return handler(ctx);
155863
- };
155864
- }
155865
- function requireHumanDeveloper(handler) {
155866
- return requireDeveloper(async (ctx) => {
155867
- if (isDashboardWorkerKey(ctx.apiKey) || isGameWorkerKey(ctx.apiKey)) {
155868
- throw ApiError.forbidden(WORKER_KEY_HUMAN_ONLY);
155869
- }
155870
- return handler(ctx);
155871
- });
155872
- }
155873
- function requireGameManagementAccess(handler) {
155874
- return async (ctx) => {
155875
- assertAuthenticatedRequest(ctx);
155876
- rejectDashboardWorkerKey(ctx);
155877
- if (!hasGameManagementAccess(ctx.user)) {
155878
- throw ApiError.forbidden("Game management access required");
155879
- }
155880
- return handler(ctx);
155881
- };
155882
- }
155883
- var WORKER_KEY_HUMAN_ONLY = "This operation requires your own credential — platform worker keys are refused";
155884
- var init_auth_util = __esm(() => {
155885
- init_errors2();
155886
- init_types6();
155887
- init_dashboard_util();
155888
- init_deployment_util();
155889
- });
155890
-
155891
- // ../api-core/src/utils/controller.util.ts
155892
- function defineControllerNames(namespace, handlers) {
155893
- for (const [key, handler] of Object.entries(handlers)) {
155894
- Object.defineProperty(handler, "name", {
155895
- value: `${namespace}.${key}`,
155896
- configurable: true
155897
- });
155898
- }
155899
- return handlers;
155900
- }
155901
-
155902
- // ../api-core/src/utils/lti.util.ts
155903
- function generateUsername(email5) {
155904
- const baseUsername = (email5.split("@")[0] || "user").toLowerCase();
155905
- const cleanUsername = baseUsername.replace(/[^a-z0-9]/g, "");
155906
- const randomSuffix = Math.random().toString(36).substring(2, 7);
155907
- return `${cleanUsername}_${randomSuffix}`;
155908
- }
155909
- function extractRedirectPath(targetUri, currentHost) {
155910
- try {
155911
- const targetUrl = new URL(targetUri);
155912
- if (targetUrl.hostname === currentHost) {
155913
- return targetUrl.pathname + targetUrl.search;
155914
- }
155915
- } catch {}
155916
- return "/";
155917
- }
155918
- function validateLtiClaims(claims) {
155919
- const messageType = claims["https://purl.imsglobal.org/spec/lti/claim/message_type"];
155920
- const version6 = claims["https://purl.imsglobal.org/spec/lti/claim/version"];
155921
- if (messageType !== "LtiResourceLinkRequest") {
155922
- return `Invalid LTI message type: ${messageType}`;
155923
- }
155924
- if (version6 !== "1.3.0") {
155925
- return `Unsupported LTI version: ${version6}`;
155926
- }
155927
- return null;
155928
- }
155929
- var init_lti_util = () => {};
155930
-
155931
- // ../api-core/src/utils/lti-provisioning.ts
155932
- import * as crypto4 from "node:crypto";
155933
- async function provisionLtiUser(db2, claims) {
155934
- const database = db2;
155935
- const email5 = claims.email;
155936
- const ltiTimebackId = claims.sub;
155937
- const providerId = AUTH_PROVIDER_IDS.TIMEBACK_LTI;
155938
- if (!email5) {
155939
- throw new ValidationError("Email is required in LTI claims");
155940
- }
155941
- const existingAccount = await database.query.accounts.findFirst({
155942
- where: and(eq(accounts.accountId, ltiTimebackId), eq(accounts.providerId, providerId))
155943
- });
155944
- if (existingAccount) {
155945
- const user = await database.query.users.findFirst({
155946
- where: eq(users.id, existingAccount.userId)
155947
- });
155948
- if (user) {
155949
- setAttribute("app.lti.provision", "existing_account");
155950
- return user;
155951
- }
155952
- }
155953
- const existingUser = await database.query.users.findFirst({
155954
- where: eq(users.email, email5)
155955
- });
155956
- if (existingUser) {
155957
- await database.transaction(async (tx) => {
155958
- const existingLtiAccount = await tx.query.accounts.findFirst({
155959
- where: and(eq(accounts.userId, existingUser.id), eq(accounts.providerId, providerId))
155960
- });
155961
- if (!existingLtiAccount) {
155962
- const [account] = await tx.insert(accounts).values({
155963
- id: crypto4.randomUUID(),
155964
- userId: existingUser.id,
155965
- accountId: ltiTimebackId,
155966
- providerId,
155967
- accessToken: null,
155968
- refreshToken: null,
155969
- accessTokenExpiresAt: null,
155970
- refreshTokenExpiresAt: null,
155971
- createdAt: new Date,
155972
- updatedAt: new Date
155973
- }).returning({ id: accounts.id });
155974
- if (!account) {
155975
- throw new InternalError("Failed to link LTI account");
155976
- }
155977
- }
155978
- });
155979
- setAttribute("app.lti.provision", "linked_account");
155980
- return existingUser;
155981
- }
155982
- const newUserId = crypto4.randomUUID();
155983
- const createdUser = await database.transaction(async (tx) => {
155984
- const [insertedUser] = await tx.insert(users).values({
155985
- id: newUserId,
155986
- email: email5,
155987
- emailVerified: true,
155988
- username: generateUsername(email5),
155989
- name: claims.name || claims.given_name || email5.split("@")[0] || "Timeback User",
155990
- createdAt: new Date,
155991
- updatedAt: new Date
155992
- }).returning();
155993
- if (!insertedUser) {
155994
- throw new InternalError("Failed to create user");
155995
- }
155996
- await tx.insert(accounts).values({
155997
- id: crypto4.randomUUID(),
155998
- userId: newUserId,
155999
- accountId: ltiTimebackId,
156000
- providerId,
156001
- accessToken: null,
156002
- refreshToken: null,
156003
- accessTokenExpiresAt: null,
156004
- refreshTokenExpiresAt: null,
156005
- createdAt: new Date,
156006
- updatedAt: new Date
156007
- });
156008
- setAttribute("app.lti.provision", "created_user");
156009
- return insertedUser;
156010
- });
156011
- return createdUser;
156012
- }
156013
- var init_lti_provisioning = __esm(() => {
156014
- init_drizzle_orm();
156015
- init_src();
156016
- init_tables_index();
156017
- init_spans();
156018
- init_errors2();
156019
- init_lti_util();
156020
- });
156021
-
156022
- // ../api-core/src/utils/params.util.ts
156023
- function requireGameId(gameId) {
156024
- if (!gameId) {
156025
- throw ApiError.badRequest("Missing game ID");
156026
- }
156027
- if (!isValidUUID(gameId)) {
156028
- throw ApiError.unprocessableEntity("gameId must be a valid UUID format");
156029
- }
156030
- return gameId;
156031
- }
156032
- function requireSlug(slug2) {
156033
- if (!slug2) {
156034
- throw ApiError.badRequest("Missing game slug");
156035
- }
156036
- return slug2;
156037
- }
156038
- function requireUserId(userId) {
156039
- if (!userId) {
156040
- throw ApiError.badRequest("Missing user ID");
156041
- }
156042
- if (!isValidUUID(userId)) {
156043
- throw ApiError.unprocessableEntity("userId must be a valid UUID format");
156044
- }
156045
- return userId;
156046
- }
156047
- function parseLimitParam(url4, max2) {
156048
- const raw2 = url4.searchParams.get("limit");
156049
- if (raw2 === null) {
156050
- return;
156051
- }
156052
- const limit = Number(raw2);
156053
- if (!Number.isInteger(limit) || limit < 1 || limit > max2) {
156054
- throw ApiError.badRequest(`limit must be an integer between 1 and ${max2}`);
156055
- }
156056
- return limit;
156057
- }
156058
- var init_params_util = __esm(() => {
156059
- init_src9();
156060
- init_errors2();
156061
- });
156062
-
156063
- // ../api-core/src/utils/validation.util.ts
156064
- function formatZodError(error89) {
156065
- const flat = error89.flatten();
156066
- const result = {};
156067
- if (Object.keys(flat.fieldErrors).length > 0) {
156068
- result.fields = {};
156069
- for (const [field, messages] of Object.entries(flat.fieldErrors)) {
156070
- if (messages && messages.length > 0) {
156071
- result.fields[field] = messages[0];
156072
- }
156073
- }
156074
- }
156075
- if (flat.formErrors.length > 0) {
156076
- result.errors = flat.formErrors;
156077
- }
156078
- return result;
156079
- }
156080
- function recordValidationFailure(details) {
156081
- setAttribute("app.request.outcome", "validation_failed");
156082
- addEvent("request.validation_failed", {
156083
- "app.validation.error": JSON.stringify(details)
156084
- });
156085
- }
156086
- async function parseRequestBody(request, schema4) {
156087
- try {
156088
- return schema4.parse(await request.json());
156089
- } catch (error89) {
156090
- if (error89 instanceof exports_external.ZodError) {
156091
- const details = formatZodError(error89);
156092
- recordValidationFailure(details);
156093
- throw ApiError.unprocessableEntity("Validation failed", details);
156094
- }
156095
- throw ApiError.invalidJsonBody();
156096
- }
156097
- }
156098
- var init_validation_util = __esm(() => {
156099
- init_esm();
156100
- init_spans();
156101
- init_errors2();
156102
- });
156103
- // ../api-core/src/utils/index.ts
156104
- var init_utils11 = __esm(() => {
156105
- init_auth_util();
156106
- init_dashboard_util();
156107
- init_deployment_util();
156108
- init_leaderboard_util();
156109
- init_lti_util();
156110
- init_lti_provisioning();
156111
- init_params_util();
156112
- init_secrets_util();
156113
- init_timeback_util();
156114
- init_validation_util();
156115
- });
156116
-
156117
156522
  // ../api-core/src/controllers/bucket.controller.ts
156118
156523
  var listFiles, getFile, putFile, deleteFile, initiateUpload, bucket;
156119
156524
  var init_bucket_controller = __esm(() => {
156120
156525
  init_errors2();
156121
- init_utils11();
156526
+ init_utils7();
156122
156527
  listFiles = requireDeveloper(async (ctx) => {
156123
156528
  const slug2 = ctx.params.slug;
156124
156529
  if (!slug2) {
@@ -156210,7 +156615,7 @@ var listUsers, addUser, issueRecoveryLink, removeUser, remove, verifyLogin, acce
156210
156615
  var init_dashboard_controller = __esm(() => {
156211
156616
  init_schemas_index();
156212
156617
  init_errors2();
156213
- init_utils11();
156618
+ init_utils7();
156214
156619
  listUsers = requireHumanDeveloper(async (ctx) => {
156215
156620
  const slug2 = requireSlug(ctx.params.slug);
156216
156621
  const users2 = await ctx.services.dashboard.listUsers(slug2, ctx.user);
@@ -156282,7 +156687,7 @@ var init_database_controller = __esm(() => {
156282
156687
  init_esm();
156283
156688
  init_schemas_index();
156284
156689
  init_errors2();
156285
- init_utils11();
156690
+ init_utils7();
156286
156691
  reset = requireDeveloper(async (ctx) => {
156287
156692
  const slug2 = ctx.params.slug;
156288
156693
  if (!slug2) {
@@ -156345,7 +156750,7 @@ var init_deploy_controller = __esm(() => {
156345
156750
  init_esm();
156346
156751
  init_schemas_index();
156347
156752
  init_errors2();
156348
- init_utils11();
156753
+ init_utils7();
156349
156754
  deploy = defineControllerNames("deploy", {
156350
156755
  createJob: requireDeveloper(createJob),
156351
156756
  getJob: requireDeveloper(getJob)
@@ -156357,7 +156762,7 @@ var get, baseline, realignMigration, resolveMigration, history, restorePoints, r
156357
156762
  var init_deployment_state_controller = __esm(() => {
156358
156763
  init_schemas_index();
156359
156764
  init_errors2();
156360
- init_utils11();
156765
+ init_utils7();
156361
156766
  get = requireDeveloper(async (ctx) => {
156362
156767
  const slug2 = requireSlug(ctx.params.slug);
156363
156768
  const include = ctx.url.searchParams.getAll("include").flatMap((value) => value.split(",")).filter(Boolean);
@@ -156427,7 +156832,7 @@ var init_deployment_state_controller = __esm(() => {
156427
156832
  // ../api-core/src/controllers/developer.controller.ts
156428
156833
  var apply, getStatus, developer;
156429
156834
  var init_developer_controller = __esm(() => {
156430
- init_utils11();
156835
+ init_utils7();
156431
156836
  apply = requireNonAnonymous(async (ctx) => {
156432
156837
  await ctx.services.developer.apply(ctx.user);
156433
156838
  });
@@ -156448,7 +156853,7 @@ var init_domain_controller = __esm(() => {
156448
156853
  init_schemas_index();
156449
156854
  init_config2();
156450
156855
  init_errors2();
156451
- init_utils11();
156856
+ init_utils7();
156452
156857
  add = requireDeveloper(async (ctx) => {
156453
156858
  const slug2 = ctx.params.slug;
156454
156859
  if (!slug2) {
@@ -156522,7 +156927,7 @@ var listMembers, addMember, updateMemberRole, removeMember, searchUsersForMember
156522
156927
  var init_game_member_controller = __esm(() => {
156523
156928
  init_schemas_index();
156524
156929
  init_errors2();
156525
- init_utils11();
156930
+ init_utils7();
156526
156931
  listMembers = requireNonAnonymous(async (ctx) => {
156527
156932
  const gameId = requireGameId(ctx.params.gameId);
156528
156933
  return ctx.services.gameMember.list(gameId, ctx.user);
@@ -156563,7 +156968,7 @@ var init_game_controller = __esm(() => {
156563
156968
  init_esm();
156564
156969
  init_schemas_index();
156565
156970
  init_errors2();
156566
- init_utils11();
156971
+ init_utils7();
156567
156972
  init_auth_util();
156568
156973
  list2 = requireNonAnonymous(async (ctx) => ctx.services.game.list(ctx.user));
156569
156974
  listAccessible = requireNonAnonymous(async (ctx) => ctx.services.game.listAccessible(ctx.user));
@@ -156634,7 +157039,7 @@ var init_kv_controller = __esm(() => {
156634
157039
  init_esm();
156635
157040
  init_schemas_index();
156636
157041
  init_errors2();
156637
- init_utils11();
157042
+ init_utils7();
156638
157043
  listKeys = requireDeveloper(async (ctx) => {
156639
157044
  const slug2 = ctx.params.slug;
156640
157045
  if (!slug2) {
@@ -156738,7 +157143,7 @@ var init_leaderboard_controller = __esm(() => {
156738
157143
  init_esm();
156739
157144
  init_schemas_index();
156740
157145
  init_errors2();
156741
- init_utils11();
157146
+ init_utils7();
156742
157147
  submitScore = requireAuth(async (ctx) => {
156743
157148
  const gameId = ctx.params.gameId;
156744
157149
  if (!gameId) {
@@ -156847,7 +157252,7 @@ var init_leaderboard_controller = __esm(() => {
156847
157252
  var generateToken, logs;
156848
157253
  var init_logs_controller = __esm(() => {
156849
157254
  init_errors2();
156850
- init_utils11();
157255
+ init_utils7();
156851
157256
  generateToken = requireDeveloper(async (ctx) => {
156852
157257
  const slug2 = ctx.params.slug;
156853
157258
  if (!slug2) {
@@ -156882,7 +157287,7 @@ var init_logs_controller = __esm(() => {
156882
157287
  // ../api-core/src/controllers/lti.controller.ts
156883
157288
  var getStatus3, lti;
156884
157289
  var init_lti_controller = __esm(() => {
156885
- init_utils11();
157290
+ init_utils7();
156886
157291
  getStatus3 = requireNonAnonymous(async (ctx) => ctx.services.lti.getStatus(ctx.user));
156887
157292
  lti = defineControllerNames("lti", {
156888
157293
  getStatus: getStatus3
@@ -156895,7 +157300,7 @@ var init_secrets_controller = __esm(() => {
156895
157300
  init_esm();
156896
157301
  init_schemas_index();
156897
157302
  init_errors2();
156898
- init_utils11();
157303
+ init_utils7();
156899
157304
  listKeys2 = requireDeveloper(async (ctx) => {
156900
157305
  const slug2 = ctx.params.slug;
156901
157306
  if (!slug2) {
@@ -156958,7 +157363,7 @@ var init_seed_controller = __esm(() => {
156958
157363
  init_esm();
156959
157364
  init_schemas_index();
156960
157365
  init_errors2();
156961
- init_utils11();
157366
+ init_utils7();
156962
157367
  seed2 = requireDeveloper(async (ctx) => {
156963
157368
  const slug2 = ctx.params.slug;
156964
157369
  if (!slug2) {
@@ -156990,7 +157395,7 @@ var init_session_controller = __esm(() => {
156990
157395
  init_spans();
156991
157396
  init_tunnel();
156992
157397
  init_errors2();
156993
- init_utils11();
157398
+ init_utils7();
156994
157399
  MintTokenBody = exports_external.object({
156995
157400
  reason: exports_external.enum(["initial", "refresh_scheduled", "refresh_stale"]).optional()
156996
157401
  });
@@ -157039,7 +157444,7 @@ function parseQtiLibraryParams(searchParams) {
157039
157444
  limit
157040
157445
  };
157041
157446
  }
157042
- var populateStudent, getUser, getUserEnrollments, getUserById, setupIntegration, getIntegrations, getRemovedIntegrations, createIntegration, updateIntegration, deactivateCourse, reactivateCourse, getIntegrationConfig, verifyIntegration, getConfig, deleteIntegrations, endActivity, heartbeat, advanceCourse, unenrollCourse, startRuntimeAssessment, getRuntimeAssessment, getLatestRuntimeAssessment, saveRuntimeAssessment, submitRuntimeAssessmentItem, submitRuntimeAssessment, exportRuntimeAssessmentFixture, getStudentXp, getStudentMastery, getStudentHighestGradeMastered, getRoster, getStudentOverview, getGameMetrics, getStudentActivity, getGradeLevelTestResults, getGradeLevelTestReview, getActivityDetail, listMetricDiscrepancies, verifyMetricDiscrepancy, grantXp, adjustTime, adjustMastery, reconcileMasteryForConfigChange, searchStudents, enrollStudent, unenrollStudent, reactivateEnrollment, listAssessments, createAssessment, attachExistingAssessments, updateAssessment, reorderAssessments, reorderQuestions, removeAssessment, listQuestions, listQuestionLibrary, listTestLibrary, copyAssessment, createQuestion, updateQuestion, removeQuestion, timeback2;
157447
+ var populateStudent, getUser, getUserEnrollments, getUserById, setupIntegration, getIntegrations, getRemovedIntegrations, createIntegration, updateIntegration, deactivateCourse, reactivateCourse, getIntegrationConfig, verifyIntegration, getConfig, deleteIntegrations, endActivity, heartbeat, advanceCourse, unenrollCourse, startRuntimeAssessment, getRuntimeAssessment, getLatestRuntimeAssessment, saveRuntimeAssessment, submitRuntimeAssessmentItem, submitRuntimeAssessment, exportRuntimeAssessmentFixture, getStudentXp, getStudentMastery, getStudentHighestGradeMastered, getRoster, getStudentOverview, getGameMetrics, getStudentActivity, getGradeLevelTestResults, getGradeLevelTestReview, getActivityDetail, listMetricDiscrepancies, verifyMetricDiscrepancy, grantXp, adjustTime, adjustMastery, reconcileMasteryForConfigChange, searchStudents, enrollStudent, unenrollStudent, reactivateEnrollment, listAssessments, createAssessment, attachExistingAssessments, updateAssessment, updateReviewMapping, reorderAssessments, reorderQuestions, removeAssessment, listQuestions, listQuestionLibrary, listTestLibrary, copyAssessment, createQuestion, updateQuestion, removeQuestion, timeback2;
157043
157448
  var init_timeback_controller = __esm(() => {
157044
157449
  init_esm();
157045
157450
  init_src();
@@ -157048,7 +157453,7 @@ var init_timeback_controller = __esm(() => {
157048
157453
  init_src9();
157049
157454
  init_timeback3();
157050
157455
  init_errors2();
157051
- init_utils11();
157456
+ init_utils7();
157052
157457
  populateStudent = requireNonAnonymous(async (ctx) => {
157053
157458
  let providedNames;
157054
157459
  try {
@@ -157713,6 +158118,14 @@ var init_timeback_controller = __esm(() => {
157713
158118
  const body2 = await parseRequestBody(ctx.request, UpdateAssessmentRequestSchema);
157714
158119
  return ctx.services.timebackAssessments.updateAssessment(integrationId, testIdentifier, body2);
157715
158120
  });
158121
+ updateReviewMapping = requireDeveloper(async (ctx) => {
158122
+ const { gameId, courseId, testIdentifier } = ctx.params;
158123
+ if (!gameId || !courseId || !testIdentifier) {
158124
+ throw ApiError.badRequest("Missing gameId, courseId, or testIdentifier parameter");
158125
+ }
158126
+ const integrationId = await ctx.services.timebackAssessments.resolveIntegrationId(gameId, courseId, ctx.user);
158127
+ return ctx.services.timebackAssessments.updateReviewMapping(integrationId, testIdentifier);
158128
+ });
157716
158129
  reorderAssessments = requireDeveloper(async (ctx) => {
157717
158130
  const { gameId, courseId } = ctx.params;
157718
158131
  if (!gameId || !courseId) {
@@ -157855,6 +158268,7 @@ var init_timeback_controller = __esm(() => {
157855
158268
  createAssessment,
157856
158269
  attachExistingAssessments,
157857
158270
  updateAssessment,
158271
+ updateReviewMapping,
157858
158272
  reorderAssessments,
157859
158273
  removeAssessment,
157860
158274
  reorderQuestions,
@@ -157874,7 +158288,7 @@ var init_upload_controller = __esm(() => {
157874
158288
  init_esm();
157875
158289
  init_schemas_index();
157876
158290
  init_errors2();
157877
- init_utils11();
158291
+ init_utils7();
157878
158292
  initiate = requireDeveloper(async (ctx) => {
157879
158293
  let body2;
157880
158294
  try {
@@ -157900,7 +158314,7 @@ var getMe, getDemoProfile, updateDemoProfile, users2;
157900
158314
  var init_user_controller = __esm(() => {
157901
158315
  init_src();
157902
158316
  init_schemas_index();
157903
- init_utils11();
158317
+ init_utils7();
157904
158318
  getMe = requireNonAnonymous(async (ctx) => ctx.services.user.getMe(ctx.user, ctx.gameId, ctx.request.headers.get(PLAYCADEMY_BROWSER_TIME_ZONE_HEADER)));
157905
158319
  getDemoProfile = requireAnonymous(async (ctx) => ctx.services.user.getDemoProfile(ctx.user.id));
157906
158320
  updateDemoProfile = requireAnonymous(async (ctx) => {
@@ -157935,7 +158349,7 @@ var init_verify_controller = __esm(() => {
157935
158349
  init_esm();
157936
158350
  init_schemas_index();
157937
158351
  init_errors2();
157938
- init_utils11();
158352
+ init_utils7();
157939
158353
  verify = defineControllerNames("verify", {
157940
158354
  verifyToken
157941
158355
  });
@@ -158124,7 +158538,7 @@ async function buildMockUserResponse(db2, user, gameId, observedTimeZone) {
158124
158538
  var LEARNING_TIME_ZONE_REFRESH_INTERVAL_MS2;
158125
158539
  var init_timeback7 = __esm(() => {
158126
158540
  init_drizzle_orm();
158127
- init_utils11();
158541
+ init_utils7();
158128
158542
  init_src();
158129
158543
  init_tables_index();
158130
158544
  init_src6();
@@ -158554,7 +158968,7 @@ var init_seed2 = __esm(async () => {
158554
158968
  init_dist7();
158555
158969
  init_esm();
158556
158970
  init_errors2();
158557
- init_utils11();
158971
+ init_utils7();
158558
158972
  init_schemas_index();
158559
158973
  await init_api3();
158560
158974
  gameSeedRouter = new Hono2;
@@ -158794,7 +159208,7 @@ var init_timeback8 = __esm(async () => {
158794
159208
  init_dist7();
158795
159209
  init_controllers();
158796
159210
  init_errors2();
158797
- init_utils11();
159211
+ init_utils7();
158798
159212
  init_src();
158799
159213
  init_schemas_index();
158800
159214
  init_timeback3();
@@ -159034,7 +159448,7 @@ var init_lti = __esm(async () => {
159034
159448
  init_drizzle_orm();
159035
159449
  init_dist7();
159036
159450
  init_controllers();
159037
- init_utils11();
159451
+ init_utils7();
159038
159452
  init_tables_index();
159039
159453
  init_src6();
159040
159454
  init_constants();