@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/cli.js CHANGED
@@ -1123,7 +1123,7 @@ var package_default;
1123
1123
  var init_package = __esm(() => {
1124
1124
  package_default = {
1125
1125
  name: "@playcademy/sandbox",
1126
- version: "0.7.1-beta.22",
1126
+ version: "0.7.1-beta.24",
1127
1127
  description: "Local development server for Playcademy game development",
1128
1128
  type: "module",
1129
1129
  exports: {
@@ -9456,6 +9456,9 @@ function isAssessmentAttemptOpen(attempt) {
9456
9456
  function isAssessmentAttemptCompleted(attempt) {
9457
9457
  return attempt.inProgress === ASSESSMENT_ATTEMPT_COMPLETED.inProgress && attempt.scoreStatus === ASSESSMENT_ATTEMPT_COMPLETED.scoreStatus;
9458
9458
  }
9459
+ function isAssessmentAttemptSuperseded(attempt) {
9460
+ return attempt.inProgress === ASSESSMENT_ATTEMPT_SUPERSEDED.inProgress && attempt.scoreStatus === ASSESSMENT_ATTEMPT_SUPERSEDED.scoreStatus;
9461
+ }
9459
9462
  function classifyAssessmentSubmission(attempt, submissionId) {
9460
9463
  if (isAssessmentAttemptCompleted(attempt)) {
9461
9464
  return attempt.submissionId === submissionId ? "replay" : "reject";
@@ -9513,6 +9516,15 @@ function assessmentReviewBankShortage(fulfillment) {
9513
9516
  function assessmentFlowForPurpose(purpose) {
9514
9517
  return purpose === "review" ? "item-submit" : "attempt-submit";
9515
9518
  }
9519
+ function compareCodeUnits(left, right) {
9520
+ if (left < right) {
9521
+ return -1;
9522
+ }
9523
+ if (left > right) {
9524
+ return 1;
9525
+ }
9526
+ return 0;
9527
+ }
9516
9528
  function canonicalJson(value) {
9517
9529
  if (value === null || typeof value !== "object") {
9518
9530
  return JSON.stringify(value) ?? "null";
@@ -9520,18 +9532,9 @@ function canonicalJson(value) {
9520
9532
  if (Array.isArray(value)) {
9521
9533
  return `[${value.map((item) => canonicalJson(item)).join(",")}]`;
9522
9534
  }
9523
- const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== undefined).toSorted(([left], [right]) => compareCanonicalKeys(left, right)).map(([key, entryValue]) => `${JSON.stringify(key)}:${canonicalJson(entryValue)}`);
9535
+ const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== undefined).toSorted(([left], [right]) => compareCodeUnits(left, right)).map(([key, entryValue]) => `${JSON.stringify(key)}:${canonicalJson(entryValue)}`);
9524
9536
  return `{${entries.join(",")}}`;
9525
9537
  }
9526
- function compareCanonicalKeys(left, right) {
9527
- if (left < right) {
9528
- return -1;
9529
- }
9530
- if (left > right) {
9531
- return 1;
9532
- }
9533
- return 0;
9534
- }
9535
9538
  async function diagnosticRoutingRevision(manifest) {
9536
9539
  const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonicalJson(manifest)));
9537
9540
  return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
@@ -10831,15 +10834,6 @@ function assessmentPresentationForAttempt(assessment, attemptId) {
10831
10834
  });
10832
10835
  return { ...assessment, items };
10833
10836
  }
10834
- function compareCodeUnits(left, right) {
10835
- if (left < right) {
10836
- return -1;
10837
- }
10838
- if (left > right) {
10839
- return 1;
10840
- }
10841
- return 0;
10842
- }
10843
10837
  function reviewStandardFieldsWithinLimits(input) {
10844
10838
  return input.framework.trim().length <= TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standardFieldLength && input.identifier.trim().length <= TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standardFieldLength;
10845
10839
  }
@@ -10850,6 +10844,19 @@ function canonicalReviewStandardRef(input) {
10850
10844
  }
10851
10845
  return standard.framework && standard.identifier ? standard : null;
10852
10846
  }
10847
+ function isKnownDescriptiveCurriculumFramework(framework) {
10848
+ return framework === "CCSS" || framework.startsWith("CCSS.");
10849
+ }
10850
+ function reviewRoutingStandardRefsFromMetadata(metadata2, options = {}) {
10851
+ const refs = new Map;
10852
+ for (const authored of qtiAssessmentStandardRefsFromMetadata(metadata2)) {
10853
+ const standard = canonicalReviewStandardRef(authored);
10854
+ if (standard && (!options.customOnly || !isKnownDescriptiveCurriculumFramework(standard.framework))) {
10855
+ refs.set(assessmentStandardRefKey(standard), standard);
10856
+ }
10857
+ }
10858
+ return [...refs.values()];
10859
+ }
10853
10860
  function canonicalRequestStandards(standards) {
10854
10861
  if (standards.length > TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standards) {
10855
10862
  throw new RangeError(`A review request may contain at most ${TIMEBACK_ASSESSMENT_REVIEW_REQUEST_LIMITS.standards} standards`);
@@ -10905,42 +10912,172 @@ function qtiQuestionByIdentifier(questions) {
10905
10912
  }
10906
10913
  return byIdentifier;
10907
10914
  }
10908
- async function buildReviewBankIndex(assessment, questions) {
10915
+ async function reviewBankRevision(input) {
10916
+ const alignmentSignature = input.items.map((item) => ({
10917
+ itemIdentifier: item.itemIdentifier,
10918
+ standardKeys: item.standards.map(assessmentStandardRefKey)
10919
+ }));
10920
+ const bankRevisionUuid = await deterministicUUID(`playcademy:review-bank:v1:${JSON.stringify({
10921
+ bankIdentifier: input.bankIdentifier,
10922
+ contentRevision: input.sourceContentRevision,
10923
+ alignments: alignmentSignature
10924
+ })}`);
10925
+ return `review-bank-v1:${bankRevisionUuid}`;
10926
+ }
10927
+ async function reviewBankIndex(input) {
10928
+ return {
10929
+ ...input,
10930
+ bankRevision: await reviewBankRevision(input)
10931
+ };
10932
+ }
10933
+ async function reviewBankSourceFingerprint(input) {
10934
+ const fingerprintUuid = await deterministicUUID(`playcademy:review-bank-source:v1:${JSON.stringify({
10935
+ bankIdentifier: input.bankIdentifier,
10936
+ items: input.items.map((item) => ({
10937
+ itemIdentifier: item.itemIdentifier,
10938
+ standardKeys: item.standards.map(assessmentStandardRefKey)
10939
+ }))
10940
+ })}`);
10941
+ return `review-bank-source-v1:${fingerprintUuid}`;
10942
+ }
10943
+ async function buildReviewBankIndex(assessment, questions, options = {}) {
10909
10944
  if (assessment.identifier !== questions.assessmentTest) {
10910
10945
  throw new Error(`QTI questions for ${questions.assessmentTest} do not describe assessment ${assessment.identifier}`);
10911
10946
  }
10912
10947
  const questionByIdentifier = qtiQuestionByIdentifier(questions);
10913
10948
  const items = assessment.items.map((item) => {
10914
10949
  const question = questionByIdentifier.get(item.identifier);
10915
- const canonical = new Map;
10916
- for (const authored of qtiAssessmentStandardRefsFromMetadata(question?.metadata)) {
10917
- const standard = canonicalReviewStandardRef(authored);
10918
- if (standard) {
10919
- canonical.set(assessmentStandardRefKey(standard), standard);
10920
- }
10921
- }
10922
- const standards = [...canonical.values()].toSorted((left, right) => compareCodeUnits(assessmentStandardRefKey(left), assessmentStandardRefKey(right)));
10950
+ const standards = reviewRoutingStandardRefsFromMetadata(question?.metadata, options).toSorted((left, right) => compareCodeUnits(assessmentStandardRefKey(left), assessmentStandardRefKey(right)));
10923
10951
  return {
10924
10952
  itemIdentifier: item.identifier,
10925
10953
  standards
10926
10954
  };
10927
10955
  });
10928
- const alignmentSignature = items.map((item) => ({
10929
- itemIdentifier: item.itemIdentifier,
10930
- standardKeys: item.standards.map(assessmentStandardRefKey)
10931
- }));
10932
- const bankRevisionUuid = await deterministicUUID(`playcademy:review-bank:v1:${JSON.stringify({
10933
- bankIdentifier: assessment.identifier,
10934
- contentRevision: assessment.contentRevision,
10935
- alignments: alignmentSignature
10936
- })}`);
10937
- return {
10956
+ return reviewBankIndex({
10938
10957
  bankIdentifier: assessment.identifier,
10939
10958
  sourceContentRevision: assessment.contentRevision,
10940
- bankRevision: `review-bank-v1:${bankRevisionUuid}`,
10941
10959
  items
10960
+ });
10961
+ }
10962
+ function emptyReviewBankManifest(bankIdentifier) {
10963
+ return {
10964
+ version: PLAYCADEMY_REVIEW_BANK_MANIFEST_VERSION,
10965
+ bankIdentifier,
10966
+ sourceFingerprint: null,
10967
+ sourceContentRevision: null,
10968
+ bankRevision: null,
10969
+ itemsByStandard: {}
10970
+ };
10971
+ }
10972
+ function reviewBankMappingIssues(bank) {
10973
+ return {
10974
+ missingOrInvalidItemIdentifiers: bank.items.filter((item) => item.standards.length === 0).map((item) => item.itemIdentifier),
10975
+ multipleStandardItemIdentifiers: bank.items.filter((item) => item.standards.length > 1).map((item) => item.itemIdentifier)
10976
+ };
10977
+ }
10978
+ async function buildReviewBankManifest(bank) {
10979
+ const itemsByStandard = new Map;
10980
+ for (const item of bank.items) {
10981
+ for (const standard of item.standards) {
10982
+ const key = assessmentStandardRefKey(standard);
10983
+ const identifiers = itemsByStandard.get(key) ?? [];
10984
+ identifiers.push(item.itemIdentifier);
10985
+ itemsByStandard.set(key, identifiers);
10986
+ }
10987
+ }
10988
+ return {
10989
+ version: PLAYCADEMY_REVIEW_BANK_MANIFEST_VERSION,
10990
+ bankIdentifier: bank.bankIdentifier,
10991
+ sourceFingerprint: await reviewBankSourceFingerprint(bank),
10992
+ sourceContentRevision: bank.sourceContentRevision,
10993
+ bankRevision: bank.bankRevision,
10994
+ itemsByStandard: Object.fromEntries([...itemsByStandard.entries()].toSorted(([left], [right]) => compareCodeUnits(left, right)))
10942
10995
  };
10943
10996
  }
10997
+ function requiredManifestString(record, field) {
10998
+ const value = record[field];
10999
+ if (typeof value !== "string" || !value.trim()) {
11000
+ throw new Error(`Review-bank manifest requires ${field}`);
11001
+ }
11002
+ return value.trim();
11003
+ }
11004
+ function standardFromManifestKey(key) {
11005
+ try {
11006
+ const parsed = JSON.parse(key);
11007
+ if (!Array.isArray(parsed) || parsed.length !== 2 || typeof parsed[0] !== "string" || typeof parsed[1] !== "string") {
11008
+ return null;
11009
+ }
11010
+ const standard = canonicalReviewStandardRef({
11011
+ framework: parsed[0],
11012
+ identifier: parsed[1]
11013
+ });
11014
+ return standard && assessmentStandardRefKey(standard) === key ? standard : null;
11015
+ } catch {
11016
+ return null;
11017
+ }
11018
+ }
11019
+ async function reviewBankIndexFromManifest(metadata2, input) {
11020
+ const raw = isRecord(metadata2) ? metadata2[PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY] : undefined;
11021
+ if (raw === undefined) {
11022
+ return null;
11023
+ }
11024
+ if (!isRecord(raw) || raw.version !== PLAYCADEMY_REVIEW_BANK_MANIFEST_VERSION) {
11025
+ throw new Error("Review-bank manifest has an unsupported version or shape");
11026
+ }
11027
+ const manifest = raw;
11028
+ const bankIdentifier = requiredManifestString(manifest, "bankIdentifier");
11029
+ if (bankIdentifier !== input.bankIdentifier) {
11030
+ throw new Error(`Review-bank manifest for ${bankIdentifier} does not describe ${input.bankIdentifier}`);
11031
+ }
11032
+ if (manifest.sourceFingerprint === null && manifest.sourceContentRevision === null && manifest.bankRevision === null) {
11033
+ return null;
11034
+ }
11035
+ const sourceFingerprint = requiredManifestString(manifest, "sourceFingerprint");
11036
+ const sourceContentRevision = requiredManifestString(manifest, "sourceContentRevision");
11037
+ const declaredBankRevision = requiredManifestString(manifest, "bankRevision");
11038
+ const itemsByStandard = manifest.itemsByStandard;
11039
+ if (!isRecord(itemsByStandard)) {
11040
+ throw new Error("Review-bank manifest requires an itemsByStandard mapping");
11041
+ }
11042
+ const membership = new Set(input.membershipItemIdentifiers);
11043
+ const standardsByItem = new Map;
11044
+ for (const [standardKey, rawItemIdentifiers] of Object.entries(itemsByStandard)) {
11045
+ const standard = standardFromManifestKey(standardKey);
11046
+ if (!standard || !Array.isArray(rawItemIdentifiers)) {
11047
+ throw new Error("Review-bank manifest contains an invalid standard mapping");
11048
+ }
11049
+ for (const rawItemIdentifier of rawItemIdentifiers) {
11050
+ if (typeof rawItemIdentifier !== "string" || !rawItemIdentifier.trim()) {
11051
+ throw new Error("Review-bank manifest contains an invalid item identifier");
11052
+ }
11053
+ const itemIdentifier = rawItemIdentifier.trim();
11054
+ if (membership.has(itemIdentifier)) {
11055
+ const standards = standardsByItem.get(itemIdentifier) ?? new Map;
11056
+ standards.set(assessmentStandardRefKey(standard), standard);
11057
+ standardsByItem.set(itemIdentifier, standards);
11058
+ }
11059
+ }
11060
+ }
11061
+ const index = await reviewBankIndex({
11062
+ bankIdentifier,
11063
+ sourceContentRevision,
11064
+ items: input.membershipItemIdentifiers.map((itemIdentifier) => ({
11065
+ itemIdentifier,
11066
+ standards: [...standardsByItem.get(itemIdentifier)?.values() ?? []].toSorted((left, right) => compareCodeUnits(assessmentStandardRefKey(left), assessmentStandardRefKey(right)))
11067
+ }))
11068
+ });
11069
+ const issues = reviewBankMappingIssues(index);
11070
+ if (issues.missingOrInvalidItemIdentifiers.length > 0 || issues.multipleStandardItemIdentifiers.length > 0) {
11071
+ throw new Error("Review-bank manifest must map every member to exactly one standard/node key");
11072
+ }
11073
+ if (await reviewBankSourceFingerprint(index) !== sourceFingerprint) {
11074
+ throw new Error("Review-bank manifest source fingerprint is stale");
11075
+ }
11076
+ if (index.bankRevision !== declaredBankRevision) {
11077
+ throw new Error("Review-bank manifest revision does not match its candidate index");
11078
+ }
11079
+ return index;
11080
+ }
10944
11081
  function exposureTimestamp(value) {
10945
11082
  const timestamp = Date.parse(value);
10946
11083
  return Number.isFinite(timestamp) ? timestamp : 0;
@@ -11391,7 +11528,7 @@ function playcademyDiagnosticAssessmentItemResultMetadata(value) {
11391
11528
  const normalized = metadata2.responses === undefined ? { ...metadata2, responses: {} } : metadata2;
11392
11529
  return isPlaycademyDiagnosticAssessmentItemResultMetadataV1(normalized) ? normalized : null;
11393
11530
  }
11394
- 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;
11531
+ 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;
11395
11532
  var init_assessment_runtime2 = __esm(() => {
11396
11533
  init_timeback3();
11397
11534
  init_timeback3();
@@ -11576,6 +11713,10 @@ var init_assessment_runtime2 = __esm(() => {
11576
11713
  inProgress: "false",
11577
11714
  scoreStatus: "fully graded"
11578
11715
  };
11716
+ ASSESSMENT_ATTEMPT_SUPERSEDED = {
11717
+ inProgress: "false",
11718
+ scoreStatus: "not submitted"
11719
+ };
11579
11720
  ASSESSMENT_RUNTIME_ERROR_STATUS = {
11580
11721
  NO_ELIGIBLE_TESTS: 404,
11581
11722
  REVIEW_BANK_SHORTAGE: 422,
@@ -38331,71 +38472,6 @@ var init_infra2 = __esm(() => {
38331
38472
  init_kv_backup_service();
38332
38473
  });
38333
38474
 
38334
- // ../data/src/locks.ts
38335
- function createInMemoryDatabaseLock() {
38336
- const tails = new Map;
38337
- return async (db2, key, operation) => {
38338
- const previous = tails.get(key) ?? Promise.resolve();
38339
- let release;
38340
- const gate = new Promise((resolve) => {
38341
- release = resolve;
38342
- });
38343
- const tail = previous.then(() => gate);
38344
- tails.set(key, tail);
38345
- await previous;
38346
- try {
38347
- return await operation(db2);
38348
- } finally {
38349
- release();
38350
- if (tails.get(key) === tail) {
38351
- tails.delete(key);
38352
- }
38353
- }
38354
- };
38355
- }
38356
- var LockContentionError;
38357
- var init_locks = __esm(() => {
38358
- init_src6();
38359
- LockContentionError = class LockContentionError extends Error {
38360
- constructor(key) {
38361
- super(`Lock is already held: ${key}`);
38362
- this.name = "LockContentionError";
38363
- }
38364
- };
38365
- });
38366
-
38367
- // ../api-core/src/utils/assessment-runtime-lock.util.ts
38368
- function assessmentRuntimeStartLockKey(input) {
38369
- return JSON.stringify([
38370
- ASSESSMENT_RUNTIME_LOCK_NAMESPACE,
38371
- "start",
38372
- input.studentId,
38373
- input.activityId,
38374
- input.purpose,
38375
- input.courseId
38376
- ]);
38377
- }
38378
- function assessmentRuntimeAttemptLockKey(attemptId) {
38379
- return JSON.stringify([ASSESSMENT_RUNTIME_LOCK_NAMESPACE, "attempt", attemptId]);
38380
- }
38381
- function createAssessmentRuntimeLock(lock) {
38382
- return async (db2, key, operation) => {
38383
- try {
38384
- return await lock(db2, key, operation);
38385
- } catch (error) {
38386
- if (error instanceof LockContentionError) {
38387
- throw new ServiceUnavailableError("Another assessment operation is in progress. Try again shortly.", { retryable: true });
38388
- }
38389
- throw error;
38390
- }
38391
- };
38392
- }
38393
- var ASSESSMENT_RUNTIME_LOCK_NAMESPACE = "playcademy-assessment-runtime-v1";
38394
- var init_assessment_runtime_lock_util = __esm(() => {
38395
- init_locks();
38396
- init_errors2();
38397
- });
38398
-
38399
38475
  // ../api-core/src/services/bucket.service.ts
38400
38476
  function hasPagingOptions(options) {
38401
38477
  return options.cursor !== undefined || options.limit !== undefined || options.delimiter !== undefined;
@@ -89178,73 +89254,6 @@ function stringField2(value) {
89178
89254
  function firstStringField2(...values) {
89179
89255
  return values.map(stringField2).find(Boolean) ?? "";
89180
89256
  }
89181
- function normalizedWhitespace2(value) {
89182
- return value.normalize("NFKC").trim().replace(/\s+/g, " ");
89183
- }
89184
- function normalizedIdentityCase2(value) {
89185
- return value.toLocaleUpperCase("en-US");
89186
- }
89187
- function frameworkAliasKey2(value) {
89188
- return value.normalize("NFKC").toLocaleLowerCase("en-US").replace(/[^a-z0-9]+/g, "");
89189
- }
89190
- function isUuidShaped2(value) {
89191
- return UUID_PATTERN2.test(value.trim());
89192
- }
89193
- function isCommonCoreMathIdentifier2(identifier) {
89194
- const canonical = normalizedIdentityCase2(normalizedWhitespace2(identifier));
89195
- 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);
89196
- }
89197
- function isCommonCoreElaIdentifier2(identifier) {
89198
- const canonical = normalizedIdentityCase2(normalizedWhitespace2(identifier));
89199
- 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);
89200
- }
89201
- function canonicalFramework2(authoredFramework, identifier) {
89202
- const aliasKey = frameworkAliasKey2(authoredFramework);
89203
- if (COMMON_CORE_MATH_FRAMEWORK_ALIASES2.has(aliasKey) || COMMON_CORE_FRAMEWORK_ALIASES2.has(aliasKey) && isCommonCoreMathIdentifier2(identifier)) {
89204
- return "CCSS.Math";
89205
- }
89206
- if (COMMON_CORE_ELA_FRAMEWORK_ALIASES2.has(aliasKey) || COMMON_CORE_FRAMEWORK_ALIASES2.has(aliasKey) && isCommonCoreElaIdentifier2(identifier)) {
89207
- return "CCSS.ELA-Literacy";
89208
- }
89209
- if (COMMON_CORE_FRAMEWORK_ALIASES2.has(aliasKey)) {
89210
- return "CCSS";
89211
- }
89212
- return normalizedIdentityCase2(authoredFramework);
89213
- }
89214
- function canonicalIdentifier2(framework, authoredIdentifier) {
89215
- const identifier = normalizedIdentityCase2(normalizedWhitespace2(authoredIdentifier));
89216
- if (framework === "CCSS.Math") {
89217
- return identifier.replace(/^CCSS\.MATH\.CONTENT\./, "").replace(/^CCSS\.MATH\.PRACTICE\./, "").replace(/^CCSS\.MATH\./, "");
89218
- }
89219
- if (framework === "CCSS.ELA-Literacy") {
89220
- return identifier.replace(/^CCSS\.ELA-LITERACY\./, "");
89221
- }
89222
- return identifier;
89223
- }
89224
- function readableAlignmentIdentifier2(alignment) {
89225
- const identifier = alignment.identifier?.trim() ?? "";
89226
- if (identifier && !isUuidShaped2(identifier)) {
89227
- return identifier;
89228
- }
89229
- const id = alignment.id.trim();
89230
- return id && !isUuidShaped2(id) ? id : "";
89231
- }
89232
- function canonicalAssessmentStandardRef2(standard) {
89233
- const authoredFramework = normalizedWhitespace2(standard.framework);
89234
- const framework = canonicalFramework2(authoredFramework, standard.identifier);
89235
- const identifier = canonicalIdentifier2(framework, standard.identifier);
89236
- return {
89237
- framework,
89238
- identifier
89239
- };
89240
- }
89241
- function assessmentStandardRefKey2(standard) {
89242
- const canonical = canonicalAssessmentStandardRef2(standard);
89243
- return JSON.stringify([
89244
- normalizedIdentityCase2(canonical.framework),
89245
- normalizedIdentityCase2(canonical.identifier)
89246
- ]);
89247
- }
89248
89257
  function dedupeStandards2(standards) {
89249
89258
  const deduped = new Map;
89250
89259
  for (const standard of standards) {
@@ -89335,23 +89344,7 @@ function qtiStandardsFromMetadata(metadata2) {
89335
89344
  standards.push(...qtiAlignmentStandardsFromMetadata2(metadata2));
89336
89345
  return dedupeStandards2(standards);
89337
89346
  }
89338
- function qtiAssessmentStandardRefsFromMetadata2(metadata2) {
89339
- const refs = new Map;
89340
- for (const alignment of qtiAlignmentStandardsFromMetadata2(metadata2)) {
89341
- const identifier = readableAlignmentIdentifier2(alignment);
89342
- if (identifier) {
89343
- const canonical = canonicalAssessmentStandardRef2({
89344
- framework: alignment.source,
89345
- identifier
89346
- });
89347
- if (canonical.framework && canonical.identifier) {
89348
- refs.set(assessmentStandardRefKey2(canonical), canonical);
89349
- }
89350
- }
89351
- }
89352
- return [...refs.values()];
89353
- }
89354
- 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;
89347
+ 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;
89355
89348
  var init_qti = __esm(() => {
89356
89349
  init_timeback3();
89357
89350
  init_timeback3();
@@ -89601,7 +89594,6 @@ var init_qti = __esm(() => {
89601
89594
  "qti-sum",
89602
89595
  "qti-base-value"
89603
89596
  ]);
89604
- 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;
89605
89597
  COMMON_CORE_MATH_FRAMEWORK_ALIASES2 = new Set([
89606
89598
  "ccssm",
89607
89599
  "ccssmath",
@@ -91962,6 +91954,110 @@ var init_timeback_admin_service = __esm(async () => {
91962
91954
  ]);
91963
91955
  });
91964
91956
 
91957
+ // ../data/src/locks.ts
91958
+ function createInMemoryDatabaseLock() {
91959
+ const tails = new Map;
91960
+ return async (db2, key, operation) => {
91961
+ const previous = tails.get(key) ?? Promise.resolve();
91962
+ let release;
91963
+ const gate = new Promise((resolve) => {
91964
+ release = resolve;
91965
+ });
91966
+ const tail = previous.then(() => gate);
91967
+ tails.set(key, tail);
91968
+ await previous;
91969
+ try {
91970
+ return await operation(db2);
91971
+ } finally {
91972
+ release();
91973
+ if (tails.get(key) === tail) {
91974
+ tails.delete(key);
91975
+ }
91976
+ }
91977
+ };
91978
+ }
91979
+ var LockContentionError;
91980
+ var init_locks = __esm(() => {
91981
+ LockContentionError = class LockContentionError extends Error {
91982
+ constructor(key) {
91983
+ super(`Lock is already held: ${key}`);
91984
+ this.name = "LockContentionError";
91985
+ }
91986
+ };
91987
+ });
91988
+
91989
+ // ../api-core/src/utils/assessment-runtime-lock.util.ts
91990
+ function normalizeKeys(keys) {
91991
+ return [...new Set(keys)].toSorted();
91992
+ }
91993
+ function errorCode(error88) {
91994
+ if (typeof error88 !== "object" || error88 === null || !("code" in error88)) {
91995
+ return;
91996
+ }
91997
+ return typeof error88.code === "string" ? error88.code : undefined;
91998
+ }
91999
+ function translateAssessmentRuntimeLockError(error88) {
92000
+ if (error88 instanceof LockContentionError) {
92001
+ throw new ServiceUnavailableError("Another assessment operation is in progress. Try again shortly.", { retryable: true });
92002
+ }
92003
+ if (error88 instanceof AssessmentRuntimeLockTimeoutError) {
92004
+ throw new ServiceUnavailableError("The assessment operation took too long. Try again shortly.", { retryable: true, reason: "LOCK_TIMEOUT" });
92005
+ }
92006
+ const code = errorCode(error88);
92007
+ if (code && POSTGRES_TIMEOUT_ERROR_CODES.has(code)) {
92008
+ throw new ServiceUnavailableError("The assessment operation took too long. Try again shortly.", { retryable: true, reason: "LOCK_TIMEOUT" });
92009
+ }
92010
+ if (code && POSTGRES_CONNECTION_ERROR_CODES.has(code)) {
92011
+ throw new ServiceUnavailableError("The assessment lock connection was interrupted. Try again shortly.", { retryable: true, reason: "LOCK_CONNECTION_LOST" });
92012
+ }
92013
+ throw error88;
92014
+ }
92015
+ function createInMemoryAssessmentRuntimeLock() {
92016
+ const lock = createInMemoryDatabaseLock();
92017
+ return async (db2, keys, operation) => {
92018
+ const ordered = normalizeKeys(keys);
92019
+ function acquire(index2, operationDb) {
92020
+ const key = ordered[index2];
92021
+ return key ? lock(operationDb, key, (nested) => acquire(index2 + 1, nested)) : operation(operationDb);
92022
+ }
92023
+ try {
92024
+ return await acquire(0, db2);
92025
+ } catch (error88) {
92026
+ return translateAssessmentRuntimeLockError(error88);
92027
+ }
92028
+ };
92029
+ }
92030
+ function assessmentRuntimeStartLockKey(input) {
92031
+ return JSON.stringify([
92032
+ ASSESSMENT_RUNTIME_LOCK_NAMESPACE,
92033
+ "start",
92034
+ input.studentId,
92035
+ input.activityId,
92036
+ input.purpose,
92037
+ input.courseId
92038
+ ]);
92039
+ }
92040
+ function assessmentRuntimeAttemptLockKey(attemptId) {
92041
+ return JSON.stringify([ASSESSMENT_RUNTIME_LOCK_NAMESPACE, "attempt", attemptId]);
92042
+ }
92043
+ var ASSESSMENT_RUNTIME_LOCK_NAMESPACE = "playcademy-assessment-runtime-v1", POSTGRES_TIMEOUT_ERROR_CODES, POSTGRES_CONNECTION_ERROR_CODES, AssessmentRuntimeLockTimeoutError;
92044
+ var init_assessment_runtime_lock_util = __esm(() => {
92045
+ init_locks();
92046
+ init_errors2();
92047
+ POSTGRES_TIMEOUT_ERROR_CODES = new Set(["25P03", "57014"]);
92048
+ POSTGRES_CONNECTION_ERROR_CODES = new Set([
92049
+ "CONNECTION_CLOSED",
92050
+ "CONNECTION_DESTROYED",
92051
+ "CONNECTION_ENDED"
92052
+ ]);
92053
+ AssessmentRuntimeLockTimeoutError = class AssessmentRuntimeLockTimeoutError extends Error {
92054
+ constructor(timeoutMs) {
92055
+ super(`Assessment operation exceeded its ${timeoutMs}ms lock deadline`);
92056
+ this.name = "AssessmentRuntimeLockTimeoutError";
92057
+ }
92058
+ };
92059
+ });
92060
+
91965
92061
  // ../api-core/src/utils/timeback-assessment-rules.util.ts
91966
92062
  function validateAssessmentStatusTransition(current, next) {
91967
92063
  if (current === next) {
@@ -92007,8 +92103,8 @@ function assertAssessmentHasQuestions(questions) {
92007
92103
  }
92008
92104
  }
92009
92105
  function assertReviewAssessmentHasStandards(standardCounts) {
92010
- if (standardCounts.some((count) => count <= 0)) {
92011
- throw new ValidationError("Every question in a review assessment must have a standards alignment");
92106
+ if (standardCounts.some((count) => count !== 1)) {
92107
+ throw new ValidationError("Every question in a review assessment must have exactly one standards alignment");
92012
92108
  }
92013
92109
  }
92014
92110
  function planAssessmentRemoval(status) {
@@ -92073,6 +92169,41 @@ var init_timeback_assessment_rules_util = __esm(() => {
92073
92169
  });
92074
92170
 
92075
92171
  // ../api-core/src/utils/timeback-assessment-runtime.util.ts
92172
+ function stageAssessmentAttemptSupersession(attempt) {
92173
+ Object.assign(attempt.result, ASSESSMENT_ATTEMPT_SUPERSEDED);
92174
+ Object.assign(attempt.selection, ASSESSMENT_ATTEMPT_SUPERSEDED);
92175
+ }
92176
+ function shouldConfirmAssessmentVersionUnavailable(details) {
92177
+ return typeof details === "object" && details !== null && "expectedRevision" in details && typeof details.expectedRevision === "string" && !("currentRevision" in details);
92178
+ }
92179
+ function buildAssessmentAttemptSupersessionUpdate(result) {
92180
+ if (result.status !== "active" || !isAssessmentAttemptOpen({
92181
+ inProgress: result.inProgress ?? "",
92182
+ scoreStatus: result.scoreStatus
92183
+ })) {
92184
+ return null;
92185
+ }
92186
+ return {
92187
+ status: "active",
92188
+ assessmentLineItem: result.assessmentLineItem,
92189
+ student: result.student,
92190
+ score: result.score ?? 0,
92191
+ scoreDate: result.scoreDate,
92192
+ ...ASSESSMENT_ATTEMPT_SUPERSEDED,
92193
+ metadata: result.metadata ?? {}
92194
+ };
92195
+ }
92196
+ async function resolveAvailableAssessmentAttempt(initialDecision, select3, resume) {
92197
+ let decision = initialDecision;
92198
+ while (decision?.kind === "resume") {
92199
+ const snapshot = await resume(decision);
92200
+ if (snapshot !== null) {
92201
+ return { kind: "resumed", snapshot };
92202
+ }
92203
+ decision = select3();
92204
+ }
92205
+ return { kind: "continue", decision };
92206
+ }
92076
92207
  function buildReviewItemResultMetadata(input) {
92077
92208
  const administration = itemAdministration(input.metadata.itemSubmissions, input.selection.itemIdentifier);
92078
92209
  if (!administration) {
@@ -92517,8 +92648,8 @@ function parsePlayableItem(question) {
92517
92648
  function assessmentContentRevision(test, questions) {
92518
92649
  return sha256Hex(canonicalJson2({
92519
92650
  identifier: test.identifier,
92651
+ title: test.title,
92520
92652
  qtiVersion: test.qtiVersion,
92521
- rawXml: test.rawXml,
92522
92653
  parts: test["qti-test-part"],
92523
92654
  questions: questions.questions.map(({ reference, question }) => ({
92524
92655
  identifier: reference.identifier,
@@ -92676,11 +92807,30 @@ async function hydrateQtiTestQuestions(client2, references) {
92676
92807
  }));
92677
92808
  return { ...references, questions };
92678
92809
  }
92679
- async function loadHydratedQtiTest(client2, identifier) {
92810
+ async function hydrateQtiTestQuestionSelection(client2, references, itemIdentifiers) {
92811
+ const referenceByIdentifier = new Map(references.questions.map((reference) => [reference.reference.identifier, reference]));
92812
+ const selectedReferences = itemIdentifiers.map((itemIdentifier) => {
92813
+ const reference = referenceByIdentifier.get(itemIdentifier);
92814
+ if (!reference) {
92815
+ throw new Error(`QTI assessment ${references.assessmentTest} does not contain item ${itemIdentifier}`);
92816
+ }
92817
+ return reference;
92818
+ });
92819
+ return hydrateQtiTestQuestions(client2, {
92820
+ ...references,
92821
+ totalQuestions: selectedReferences.length,
92822
+ questions: selectedReferences
92823
+ });
92824
+ }
92825
+ async function loadQtiTestReferences(client2, identifier) {
92680
92826
  const [test, references] = await Promise.all([
92681
92827
  client2.qtiApi.assessmentTests.get(identifier),
92682
92828
  client2.qtiApi.assessmentTests.getQuestions(identifier)
92683
92829
  ]);
92830
+ return { test, references };
92831
+ }
92832
+ async function loadHydratedQtiTest(client2, identifier) {
92833
+ const { test, references } = await loadQtiTestReferences(client2, identifier);
92684
92834
  return {
92685
92835
  test,
92686
92836
  questions: await hydrateQtiTestQuestions(client2, references)
@@ -92695,6 +92845,7 @@ class TimebackAssessmentRuntimeService {
92695
92845
  static ASSESSMENT_CACHE_TTL_MS = 60000;
92696
92846
  static EXPORT_CONCURRENCY = 4;
92697
92847
  static ITEM_SUBMISSION_MAX_PREPARATION_ATTEMPTS = 3;
92848
+ static ASSESSMENT_VERSION_CONFIRMATION_DELAY_MS = 25;
92698
92849
  static PROJECTION_BARRIER_MAX_ATTEMPTS = 5;
92699
92850
  static PROJECTION_BARRIER_RETRY_DELAY_MS = 25;
92700
92851
  static SCORING_CONCURRENCY = 4;
@@ -92707,6 +92858,10 @@ class TimebackAssessmentRuntimeService {
92707
92858
  defaultTTL: TimebackAssessmentRuntimeService.ASSESSMENT_CACHE_TTL_MS,
92708
92859
  maxSize: TimebackAssessmentRuntimeService.ASSESSMENT_CACHE_LIMIT
92709
92860
  });
92861
+ reviewSelectionCache = new TimebackCache({
92862
+ defaultTTL: TimebackAssessmentRuntimeService.ASSESSMENT_CACHE_TTL_MS,
92863
+ maxSize: TimebackAssessmentRuntimeService.ASSESSMENT_CACHE_LIMIT
92864
+ });
92710
92865
  constructor(deps) {
92711
92866
  this.deps = deps;
92712
92867
  }
@@ -92725,14 +92880,15 @@ class TimebackAssessmentRuntimeService {
92725
92880
  }
92726
92881
  const masteryStandard = input.purpose === "mastery" ? normalizeMasteryStandard(input.standard) : undefined;
92727
92882
  const requestFingerprint = this.startRequestFingerprint(input);
92883
+ const pendingSupersessions = new Set;
92728
92884
  const candidates = await this.candidateIntegrations(gameId, studentId, input);
92729
92885
  const lockKeys = candidates.rows.map((row) => assessmentRuntimeStartLockKey({
92730
92886
  studentId,
92731
92887
  activityId: input.activityId,
92732
92888
  purpose: input.purpose,
92733
92889
  courseId: row.courseId
92734
- })).toSorted();
92735
- return this.withStartLocks(lockKeys, async (db2) => {
92890
+ }));
92891
+ return this.deps.assessmentRuntimeLock(this.deps.db, lockKeys, async (db2) => {
92736
92892
  const context2 = await this.selectIntegration(candidates, studentId, input);
92737
92893
  const attemptScope = {
92738
92894
  studentId,
@@ -92747,20 +92903,21 @@ class TimebackAssessmentRuntimeService {
92747
92903
  this.listAttempts(attemptScope)
92748
92904
  ]);
92749
92905
  const attempts = listing.attempts;
92750
- const compatibleAttempts = this.attemptsMatchingRequest(attempts, requestFingerprint);
92751
- let decision = this.requireDecision(selectRuntimeAssessment(tests, [...compatibleAttempts.values()].map((entry) => entry.selection)), input.purpose);
92752
- if (decision.kind === "resume") {
92753
- return this.resumeSnapshot(decision, attempts, context2.integration);
92906
+ const initialResolution = await this.resumeAvailableAttempt(tests, attempts, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeSnapshot(resumeDecision, attempts, context2.integration));
92907
+ if (initialResolution.kind === "resumed") {
92908
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
92909
+ return initialResolution.snapshot;
92754
92910
  }
92911
+ let decision = this.requireDecision(initialResolution.decision, input.purpose);
92755
92912
  let assessment = await this.loadAssessment(decision.test.qtiTestIdentifier);
92756
92913
  const refreshedListing = await this.listAttempts(attemptScope);
92757
92914
  const refreshed = refreshedListing.attempts;
92758
- const refreshedCompatible = this.attemptsMatchingRequest(refreshed, requestFingerprint);
92759
- const refreshedDecision = this.requireDecision(selectRuntimeAssessment(tests, [...refreshedCompatible.values()].map((entry) => entry.selection)), input.purpose);
92760
- if (refreshedDecision.kind === "resume") {
92761
- return this.resumeSnapshot(refreshedDecision, refreshed, context2.integration);
92915
+ const refreshedResolution = await this.resumeAvailableAttempt(tests, refreshed, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeSnapshot(resumeDecision, refreshed, context2.integration));
92916
+ if (refreshedResolution.kind === "resumed") {
92917
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
92918
+ return refreshedResolution.snapshot;
92762
92919
  }
92763
- decision = refreshedDecision;
92920
+ decision = this.requireDecision(refreshedResolution.decision, input.purpose);
92764
92921
  if (assessment.identifier !== decision.test.qtiTestIdentifier) {
92765
92922
  assessment = await this.loadAssessment(decision.test.qtiTestIdentifier);
92766
92923
  }
@@ -92818,6 +92975,7 @@ class TimebackAssessmentRuntimeService {
92818
92975
  grade: context2.integration.grade
92819
92976
  })
92820
92977
  });
92978
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
92821
92979
  return this.snapshot(result, metadata2, assessment, context2.integration);
92822
92980
  });
92823
92981
  }
@@ -92827,14 +92985,15 @@ class TimebackAssessmentRuntimeService {
92827
92985
  input
92828
92986
  }) {
92829
92987
  const requestFingerprint = this.startRequestFingerprint(input);
92988
+ const pendingSupersessions = new Set;
92830
92989
  const candidates = await this.candidateIntegrations(gameId, studentId, input);
92831
92990
  const lockKeys = candidates.rows.map((row) => assessmentRuntimeStartLockKey({
92832
92991
  studentId,
92833
92992
  activityId: input.activityId,
92834
92993
  purpose: input.purpose,
92835
92994
  courseId: row.courseId
92836
- })).toSorted();
92837
- return this.withStartLocks(lockKeys, async (db2) => {
92995
+ }));
92996
+ return this.deps.assessmentRuntimeLock(this.deps.db, lockKeys, async (db2) => {
92838
92997
  const context2 = await this.selectIntegration(candidates, studentId, input);
92839
92998
  const attemptScope = {
92840
92999
  studentId,
@@ -92848,22 +93007,23 @@ class TimebackAssessmentRuntimeService {
92848
93007
  this.liveTests(context2.integration.id, input.purpose, db2, undefined, input.diagnosticKey),
92849
93008
  this.listAttempts(attemptScope)
92850
93009
  ]);
92851
- const compatible = this.attemptsMatchingRequest(listing.attempts, requestFingerprint);
92852
- let decision = this.requireDecision(selectRuntimeAssessment(tests, [...compatible.values()].map((entry) => entry.selection)), input.purpose);
92853
- if (decision.kind === "resume") {
92854
- return this.resumeDiagnosticSnapshot(decision, listing.attempts, context2.integration, db2);
93010
+ const initialResolution = await this.resumeAvailableAttempt(tests, listing.attempts, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeDiagnosticSnapshot(resumeDecision, listing.attempts, context2.integration, db2));
93011
+ if (initialResolution.kind === "resumed") {
93012
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93013
+ return initialResolution.snapshot;
92855
93014
  }
93015
+ let decision = this.requireDecision(initialResolution.decision, input.purpose);
92856
93016
  let definition = await this.requireDiagnosticDefinition(decision.test.id, context2.integration.id, db2, true);
92857
93017
  let assessment = await this.loadAssessment(definition.qtiTestIdentifier);
92858
93018
  let routing = await this.initializeHostedDiagnostic(definition, assessment);
92859
93019
  const refreshedListing = await this.listAttempts(attemptScope);
92860
93020
  const refreshed = refreshedListing.attempts;
92861
- const refreshedCompatible = this.attemptsMatchingRequest(refreshed, requestFingerprint);
92862
- const refreshedDecision = this.requireDecision(selectRuntimeAssessment(tests, [...refreshedCompatible.values()].map((entry) => entry.selection)), input.purpose);
92863
- if (refreshedDecision.kind === "resume") {
92864
- return this.resumeDiagnosticSnapshot(refreshedDecision, refreshed, context2.integration, db2);
93021
+ const refreshedResolution = await this.resumeAvailableAttempt(tests, refreshed, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeDiagnosticSnapshot(resumeDecision, refreshed, context2.integration, db2));
93022
+ if (refreshedResolution.kind === "resumed") {
93023
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93024
+ return refreshedResolution.snapshot;
92865
93025
  }
92866
- decision = refreshedDecision;
93026
+ decision = this.requireDecision(refreshedResolution.decision, input.purpose);
92867
93027
  if (definition.id !== decision.test.id) {
92868
93028
  definition = await this.requireDiagnosticDefinition(decision.test.id, context2.integration.id, db2, true);
92869
93029
  assessment = await this.loadAssessment(definition.qtiTestIdentifier);
@@ -92932,6 +93092,7 @@ class TimebackAssessmentRuntimeService {
92932
93092
  grade: context2.integration.grade
92933
93093
  })
92934
93094
  });
93095
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
92935
93096
  return this.diagnosticSnapshot(result, metadata2, assessment, context2.integration, routing.state);
92936
93097
  });
92937
93098
  }
@@ -92940,7 +93101,9 @@ class TimebackAssessmentRuntimeService {
92940
93101
  studentId,
92941
93102
  input
92942
93103
  }) {
93104
+ const preparationStartedAt = Date.now();
92943
93105
  const requestFingerprint = reviewRequestFingerprint(input, DEFAULT_REVIEW_SELECTION_POLICY);
93106
+ const pendingSupersessions = new Set;
92944
93107
  const normalizedRequest = normalizeReviewRequest(input);
92945
93108
  const candidates = await this.candidateIntegrations(gameId, studentId, input);
92946
93109
  const lockKeys = candidates.rows.map((row) => assessmentRuntimeStartLockKey({
@@ -92948,8 +93111,8 @@ class TimebackAssessmentRuntimeService {
92948
93111
  activityId: input.activityId,
92949
93112
  purpose: input.purpose,
92950
93113
  courseId: row.courseId
92951
- })).toSorted();
92952
- return this.withStartLocks(lockKeys, async (db2) => {
93114
+ }));
93115
+ return this.deps.assessmentRuntimeLock(this.deps.db, lockKeys, async (db2) => {
92953
93116
  const context2 = await this.selectIntegration(candidates, studentId, input);
92954
93117
  const attemptScope = {
92955
93118
  studentId,
@@ -92964,38 +93127,44 @@ class TimebackAssessmentRuntimeService {
92964
93127
  this.listAttempts(attemptScope)
92965
93128
  ]);
92966
93129
  const attempts = listing.attempts;
92967
- const compatible = this.attemptsMatchingRequest(attempts, requestFingerprint);
92968
- let decision = selectRuntimeAssessment(tests, [...compatible.values()].map((entry) => entry.selection));
92969
- if (decision?.kind === "resume") {
92970
- return this.resumeReviewSnapshot(decision, compatible, listing.reviewChildren, context2);
93130
+ const initialResolution = await this.resumeAvailableAttempt(tests, attempts, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeReviewSnapshot(resumeDecision, attempts, listing.reviewChildren, context2));
93131
+ if (initialResolution.kind === "resumed") {
93132
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93133
+ return initialResolution.snapshot;
92971
93134
  }
93135
+ let decision = initialResolution.decision;
92972
93136
  if (tests.length === 0 || !decision) {
92973
93137
  throw AssessmentRuntimeError.from(assessmentNoEligibleTests(input.purpose));
92974
93138
  }
92975
93139
  if (tests.length > 1) {
92976
93140
  throw new ValidationError("Standards review requires exactly one live review-bank assessment.");
92977
93141
  }
92978
- let source = await this.loadReviewBank(decision.test.qtiTestIdentifier);
93142
+ const manifestStartedAt = Date.now();
93143
+ let catalog = await this.loadReviewBankCatalog(decision.test.qtiTestIdentifier);
93144
+ this.recordReviewPreparationPhase("manifest_load", manifestStartedAt, {
93145
+ candidateCount: catalog.bank.items.length
93146
+ });
92979
93147
  const refreshedListing = await this.listAttempts(attemptScope);
92980
93148
  const refreshed = refreshedListing.attempts;
92981
- const refreshedCompatible = this.attemptsMatchingRequest(refreshed, requestFingerprint);
92982
- const refreshedDecision = selectRuntimeAssessment(tests, [...refreshedCompatible.values()].map((entry) => entry.selection));
92983
- if (refreshedDecision?.kind === "resume") {
92984
- return this.resumeReviewSnapshot(refreshedDecision, refreshedCompatible, refreshedListing.reviewChildren, context2);
93149
+ const refreshedResolution = await this.resumeAvailableAttempt(tests, refreshed, requestFingerprint, pendingSupersessions, (resumeDecision) => this.resumeReviewSnapshot(resumeDecision, refreshed, refreshedListing.reviewChildren, context2));
93150
+ if (refreshedResolution.kind === "resumed") {
93151
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93152
+ return refreshedResolution.snapshot;
92985
93153
  }
93154
+ const refreshedDecision = refreshedResolution.decision;
92986
93155
  if (!refreshedDecision || refreshedDecision.kind !== "start") {
92987
93156
  throw AssessmentRuntimeError.from(assessmentNoEligibleTests(input.purpose));
92988
93157
  }
92989
93158
  decision = refreshedDecision;
92990
- if (source.assessment.identifier !== decision.test.qtiTestIdentifier) {
92991
- source = await this.loadReviewBank(decision.test.qtiTestIdentifier);
93159
+ if (catalog.test.identifier !== decision.test.qtiTestIdentifier) {
93160
+ catalog = await this.loadReviewBankCatalog(decision.test.qtiTestIdentifier);
92992
93161
  }
92993
93162
  const exposures = this.reviewExposures(refreshedListing.reviewChildren.values(), {
92994
- bankRevision: source.bank.bankRevision
93163
+ bankRevision: catalog.bank.bankRevision
92995
93164
  });
92996
93165
  const selected = selectReviewItems({
92997
93166
  request: input,
92998
- bank: source.bank,
93167
+ bank: catalog.bank,
92999
93168
  exposures
93000
93169
  });
93001
93170
  if (selected.selections.length === 0) {
@@ -93004,7 +93173,13 @@ class TimebackAssessmentRuntimeService {
93004
93173
  }
93005
93174
  throw AssessmentRuntimeError.from(assessmentReviewBankShortage(selected.fulfillment));
93006
93175
  }
93176
+ const hydrationStartedAt = Date.now();
93177
+ const source = await this.hydrateReviewBankSelection(catalog, selected.selections.map((selection) => selection.itemIdentifier));
93178
+ this.recordReviewPreparationPhase("selected_hydration", hydrationStartedAt, {
93179
+ selectedCount: selected.selections.length
93180
+ });
93007
93181
  const assessment = projectReviewAssessment(source.assessment, source.bank, selected.selections);
93182
+ const provisioningStartedAt = Date.now();
93008
93183
  const parentLineItemId = await this.ensureReviewBankLineItem({
93009
93184
  integration: context2.integration,
93010
93185
  activityId: input.activityId,
@@ -93067,6 +93242,12 @@ class TimebackAssessmentRuntimeService {
93067
93242
  existingChildResults: refreshedListing.reviewChildren,
93068
93243
  lookupMissingResults: false
93069
93244
  });
93245
+ await this.persistPendingSupersessionsBestEffort(db2, pendingSupersessions);
93246
+ this.recordReviewPreparationPhase("provisioning", provisioningStartedAt);
93247
+ this.recordReviewPreparationPhase("total", preparationStartedAt, {
93248
+ candidateCount: catalog.bank.items.length,
93249
+ selectedCount: selected.selections.length
93250
+ });
93070
93251
  return this.snapshot(result, metadata2, assessment, context2.integration);
93071
93252
  });
93072
93253
  }
@@ -93149,7 +93330,7 @@ class TimebackAssessmentRuntimeService {
93149
93330
  "app.error.message": errorMessage(error88)
93150
93331
  });
93151
93332
  }
93152
- return this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(params.attemptId), async (db2) => {
93333
+ return this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(params.attemptId)], async (db2) => {
93153
93334
  const attempt = await this.authorizeAttempt(params, {
93154
93335
  db: db2,
93155
93336
  developerAccessValidated: true
@@ -93197,7 +93378,7 @@ class TimebackAssessmentRuntimeService {
93197
93378
  let preview = await this.prepareItemSubmission(params, input);
93198
93379
  let preparationAttempts = 1;
93199
93380
  while (true) {
93200
- const committed = await this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(params.attemptId), async (db2) => {
93381
+ const committed = await this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(params.attemptId)], async (db2) => {
93201
93382
  const attempt = await this.authorizeAttempt(params, {
93202
93383
  db: db2,
93203
93384
  developerAccessValidated: true
@@ -93293,7 +93474,7 @@ class TimebackAssessmentRuntimeService {
93293
93474
  let preview = await this.prepareDiagnosticItemSubmission(params, input);
93294
93475
  let preparationAttempts = 1;
93295
93476
  while (true) {
93296
- const committed = await this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(params.attemptId), async (db2) => {
93477
+ const committed = await this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(params.attemptId)], async (db2) => {
93297
93478
  const attempt = await this.authorizeAttempt(params, {
93298
93479
  db: db2,
93299
93480
  developerAccessValidated: true
@@ -93420,7 +93601,7 @@ class TimebackAssessmentRuntimeService {
93420
93601
  preparationAttempts += 1;
93421
93602
  preview = await this.scoreDiagnosticItemSubmission(params, input);
93422
93603
  } else {
93423
- await this.projectDiagnosticItemResponse(committed.projection);
93604
+ await this.projectDiagnosticItemResponse(committed.projection, preview?.assessment);
93424
93605
  return committed.response;
93425
93606
  }
93426
93607
  }
@@ -93627,7 +93808,7 @@ class TimebackAssessmentRuntimeService {
93627
93808
  }) {
93628
93809
  await this.deps.validateDeveloperAccess(params.user, params.gameId);
93629
93810
  const preview = await this.prepareSubmission(params, input);
93630
- const submission = await this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(params.attemptId), async (db2) => {
93811
+ const submission = await this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(params.attemptId)], async (db2) => {
93631
93812
  const attempt = await this.authorizeAttempt(params, {
93632
93813
  db: db2,
93633
93814
  developerAccessValidated: true
@@ -93834,7 +94015,7 @@ class TimebackAssessmentRuntimeService {
93834
94015
  where: and(eq(gameTimebackAssessmentTests.id, test.id), eq(gameTimebackAssessmentTests.integrationId, integration.id))
93835
94016
  }) : undefined;
93836
94017
  const diagnostic = definition?.diagnosticKey ? await this.initializeHostedDiagnostic(definition, loaded.assessment) : null;
93837
- const reviewBank = purpose === "review" ? await buildReviewBankIndex(loaded.assessment, loaded.questions) : null;
94018
+ const reviewBank = purpose === "review" ? await buildReviewBankIndex(loaded.assessment, loaded.questions, { customOnly: true }) : null;
93838
94019
  return {
93839
94020
  ...test,
93840
94021
  live: true,
@@ -93897,7 +94078,13 @@ class TimebackAssessmentRuntimeService {
93897
94078
  const enrollmentByCourse = new Map(enrollments.map((enrollment) => [enrollment.course.id, enrollment]));
93898
94079
  const candidateRows = integrations.filter((integration) => enrollmentByCourse.has(integration.courseId));
93899
94080
  const liveTestRows = candidateRows.length === 0 ? [] : await db2.query.gameTimebackAssessmentTests.findMany({
93900
- where: and(inArray(gameTimebackAssessmentTests.integrationId, candidateRows.map((row) => row.id)), eq(gameTimebackAssessmentTests.purpose, input.purpose), eq(gameTimebackAssessmentTests.status, "live"))
94081
+ where: and(inArray(gameTimebackAssessmentTests.integrationId, candidateRows.map((row) => row.id)), eq(gameTimebackAssessmentTests.purpose, input.purpose), eq(gameTimebackAssessmentTests.status, "live")),
94082
+ columns: {
94083
+ integrationId: true,
94084
+ standardFramework: true,
94085
+ standardIdentifier: true,
94086
+ diagnosticKey: true
94087
+ }
93901
94088
  });
93902
94089
  const matchesMasteryStandard = input.purpose === "mastery" ? masteryStandardMatcher(input.standard) : undefined;
93903
94090
  const integrationIdsWithLiveTests = new Set(liveTestRows.filter((row) => (!matchesMasteryStandard || matchesMasteryStandard(assessmentStandardForRow(row))) && (input.purpose !== "diagnostic" || row.diagnosticKey === input.diagnosticKey)).map((row) => row.integrationId));
@@ -93944,10 +94131,6 @@ class TimebackAssessmentRuntimeService {
93944
94131
  enrollment: enrollmentByCourse.get(selection.selected.courseId)
93945
94132
  };
93946
94133
  }
93947
- async withStartLocks(keys, operation) {
93948
- const acquire = (index2, db2) => index2 === keys.length ? operation(db2) : this.deps.assessmentRuntimeLock(db2, keys[index2], (nested) => acquire(index2 + 1, nested));
93949
- return acquire(0, this.deps.db);
93950
- }
93951
94134
  async liveTests(integrationId, purpose, db2 = this.deps.db, requestedStandard, requestedDiagnosticKey) {
93952
94135
  const matchesMasteryStandard = requestedStandard ? masteryStandardMatcher(requestedStandard) : undefined;
93953
94136
  const rows = await db2.query.gameTimebackAssessmentTests.findMany({
@@ -94090,6 +94273,75 @@ class TimebackAssessmentRuntimeService {
94090
94273
  });
94091
94274
  return this.diagnosticSnapshot(resumed.result, resumed.metadata, assessment, integration, routing.state);
94092
94275
  }
94276
+ async resumeAvailableAttempt(tests, attempts, requestFingerprint, pendingSupersessions, resume) {
94277
+ const select3 = () => selectRuntimeAssessment(tests, [...this.attemptsMatchingRequest(attempts, requestFingerprint).values()].map((entry) => entry.selection));
94278
+ return resolveAvailableAssessmentAttempt(select3(), select3, (decision) => this.resumeSnapshotOrStageSupersession(decision, attempts, pendingSupersessions, () => resume(decision)));
94279
+ }
94280
+ async resumeSnapshotOrStageSupersession(decision, attempts, pendingSupersessions, resume) {
94281
+ try {
94282
+ return await resume();
94283
+ } catch (error88) {
94284
+ if (!(error88 instanceof AssessmentRuntimeError) || error88.runtimeCode !== "SELECTED_TEST_VERSION_UNAVAILABLE") {
94285
+ throw error88;
94286
+ }
94287
+ if (shouldConfirmAssessmentVersionUnavailable(error88.details)) {
94288
+ await sleep(TimebackAssessmentRuntimeService.ASSESSMENT_VERSION_CONFIRMATION_DELAY_MS);
94289
+ try {
94290
+ return await resume();
94291
+ } catch (confirmationError) {
94292
+ if (!(confirmationError instanceof AssessmentRuntimeError) || confirmationError.runtimeCode !== "SELECTED_TEST_VERSION_UNAVAILABLE") {
94293
+ throw confirmationError;
94294
+ }
94295
+ }
94296
+ }
94297
+ const staged = attempts.get(decision.attempt.attemptId);
94298
+ pendingSupersessions.add(staged.result.sourcedId);
94299
+ stageAssessmentAttemptSupersession(staged);
94300
+ addEvent("assessment.attempt_supersession_staged", {
94301
+ "app.assessment.attempt_id": decision.attempt.attemptId,
94302
+ "app.assessment.reason": "selected_test_version_unavailable"
94303
+ });
94304
+ return null;
94305
+ }
94306
+ }
94307
+ async persistPendingSupersessions(db2, attemptIds) {
94308
+ for (const attemptId of [...attemptIds].toSorted()) {
94309
+ await this.deps.assessmentRuntimeLock(db2, [assessmentRuntimeAttemptLockKey(attemptId)], async () => {
94310
+ let result;
94311
+ try {
94312
+ result = await this.requireClient().api.oneroster.assessmentResults.get(attemptId);
94313
+ } catch (error88) {
94314
+ if (isApiError(error88) && error88.statusCode === 404) {
94315
+ return;
94316
+ }
94317
+ throw error88;
94318
+ }
94319
+ const update2 = buildAssessmentAttemptSupersessionUpdate(result);
94320
+ if (!update2) {
94321
+ return;
94322
+ }
94323
+ await this.requireClient().api.oneroster.assessmentResults.upsert(attemptId, update2);
94324
+ addEvent("assessment.attempt_superseded", {
94325
+ "app.assessment.attempt_id": attemptId,
94326
+ "app.assessment.reason": "selected_test_version_unavailable"
94327
+ });
94328
+ });
94329
+ }
94330
+ }
94331
+ async persistPendingSupersessionsBestEffort(db2, attemptIds) {
94332
+ if (attemptIds.size === 0) {
94333
+ return;
94334
+ }
94335
+ try {
94336
+ await this.persistPendingSupersessions(db2, attemptIds);
94337
+ } catch (error88) {
94338
+ addEvent("assessment.attempt_supersession_persist_failed", {
94339
+ "app.assessment.attempt_ids": [...attemptIds].toSorted().join(","),
94340
+ "exception.type": errorType(error88),
94341
+ "app.error.message": errorMessage(error88)
94342
+ });
94343
+ }
94344
+ }
94093
94345
  async resumeReviewSnapshot(decision, attempts, existingChildResults, context2) {
94094
94346
  if (decision.additionalResumableAttemptIds.length > 0) {
94095
94347
  addEvent("assessment.multiple_resumable_attempts", {
@@ -94101,7 +94353,8 @@ class TimebackAssessmentRuntimeService {
94101
94353
  if (resumed.metadata.purpose !== "review") {
94102
94354
  throw new Error("A standards-review request selected a non-review attempt");
94103
94355
  }
94104
- const currentSource = await this.loadReviewBank(resumed.metadata.selectedTest.identifier, resumed.metadata.selectedTest.contentRevision);
94356
+ const catalog = await this.loadReviewBankCatalog(resumed.metadata.selectedTest.identifier, resumed.metadata.selectedTest.contentRevision);
94357
+ const currentSource = await this.hydrateReviewBankSelection(catalog, resumed.metadata.review.selections.map((selection) => selection.itemIdentifier));
94105
94358
  const source = this.pinnedReviewBankSource(currentSource, resumed.metadata);
94106
94359
  const assessment = projectReviewAssessment(source.assessment, source.bank, resumed.metadata.review.selections);
94107
94360
  await this.ensureReviewChildResults({
@@ -94115,20 +94368,68 @@ class TimebackAssessmentRuntimeService {
94115
94368
  });
94116
94369
  return this.snapshot(resumed.result, resumed.metadata, assessment, context2.integration);
94117
94370
  }
94118
- async loadReviewBank(identifier, expectedSourceRevision) {
94371
+ recordReviewPreparationPhase(phase, startedAt, counts = {}) {
94372
+ addEvent("assessment.review_preparation_phase", {
94373
+ "app.assessment.review_phase": phase,
94374
+ "app.assessment.duration_ms": Date.now() - startedAt,
94375
+ ...counts.candidateCount === undefined ? {} : { "app.assessment.candidate_count": counts.candidateCount },
94376
+ ...counts.selectedCount === undefined ? {} : { "app.assessment.selected_count": counts.selectedCount }
94377
+ });
94378
+ }
94379
+ async loadReviewBankCatalog(identifier, expectedSourceRevision) {
94119
94380
  if (expectedSourceRevision) {
94120
94381
  const cached3 = this.reviewBankCache.get(`${identifier}\x00${expectedSourceRevision}`);
94121
94382
  if (cached3) {
94122
94383
  return cached3;
94123
94384
  }
94124
94385
  }
94125
- const loaded = await this.loadAssessmentSource(identifier, expectedSourceRevision);
94126
- const source = {
94127
- assessment: loaded.assessment,
94128
- bank: await buildReviewBankIndex(loaded.assessment, loaded.questions)
94129
- };
94130
- this.reviewBankCache.set(`${identifier}\x00${source.assessment.contentRevision}`, source);
94131
- return source;
94386
+ let loaded;
94387
+ try {
94388
+ loaded = await loadQtiTestReferences(this.requireClient(), identifier);
94389
+ } catch (error88) {
94390
+ if (expectedSourceRevision && isApiError(error88) && error88.statusCode === 404) {
94391
+ throw new AssessmentRuntimeError("SELECTED_TEST_VERSION_UNAVAILABLE", `The selected assessment version for ${identifier} is no longer available.`, { identifier, expectedRevision: expectedSourceRevision });
94392
+ }
94393
+ throw error88;
94394
+ }
94395
+ let bank;
94396
+ try {
94397
+ bank = await reviewBankIndexFromManifest(loaded.test.metadata, {
94398
+ bankIdentifier: identifier,
94399
+ membershipItemIdentifiers: loaded.references.questions.map((question) => question.reference.identifier)
94400
+ });
94401
+ } catch (error88) {
94402
+ throw new ServiceUnavailableError(`Review bank ${identifier} has stale or invalid routing metadata. Use Update Mapping in assessment authoring.`, { reason: errorMessage(error88) });
94403
+ }
94404
+ if (!bank) {
94405
+ throw new ServiceUnavailableError(`Review bank ${identifier} needs its authoring mapping updated before it can serve review questions.`);
94406
+ }
94407
+ if (expectedSourceRevision && bank.sourceContentRevision !== expectedSourceRevision) {
94408
+ throw new AssessmentRuntimeError("SELECTED_TEST_VERSION_UNAVAILABLE", `The selected assessment version for ${identifier} is no longer available.`, {
94409
+ identifier,
94410
+ expectedRevision: expectedSourceRevision,
94411
+ currentRevision: bank.sourceContentRevision
94412
+ });
94413
+ }
94414
+ const catalog = { ...loaded, bank };
94415
+ this.reviewBankCache.set(`${identifier}\x00${bank.sourceContentRevision}`, catalog);
94416
+ return catalog;
94417
+ }
94418
+ async hydrateReviewBankSelection(catalog, itemIdentifiers) {
94419
+ const cacheKey2 = [
94420
+ catalog.test.identifier,
94421
+ catalog.bank.sourceContentRevision,
94422
+ ...itemIdentifiers
94423
+ ].join("\x00");
94424
+ const cached3 = this.reviewSelectionCache.get(cacheKey2);
94425
+ if (cached3) {
94426
+ return { assessment: cached3, bank: catalog.bank };
94427
+ }
94428
+ const questions = await hydrateQtiTestQuestionSelection(this.requireClient(), catalog.references, itemIdentifiers);
94429
+ const assessment = await buildPlayableAssessment(catalog.test, questions);
94430
+ assessment.contentRevision = catalog.bank.sourceContentRevision;
94431
+ this.reviewSelectionCache.set(cacheKey2, assessment);
94432
+ return { assessment, bank: catalog.bank };
94132
94433
  }
94133
94434
  pinnedReviewBankSource(source, metadata2) {
94134
94435
  return {
@@ -94159,7 +94460,8 @@ class TimebackAssessmentRuntimeService {
94159
94460
  if (metadata2.purpose !== "review") {
94160
94461
  return this.loadAssessment(metadata2.selectedTest.identifier, metadata2.selectedTest.contentRevision);
94161
94462
  }
94162
- const currentSource = await this.loadReviewBank(metadata2.selectedTest.identifier, metadata2.selectedTest.contentRevision);
94463
+ const catalog = await this.loadReviewBankCatalog(metadata2.selectedTest.identifier, metadata2.selectedTest.contentRevision);
94464
+ const currentSource = await this.hydrateReviewBankSelection(catalog, metadata2.review.selections.map((selection) => selection.itemIdentifier));
94163
94465
  const source = this.pinnedReviewBankSource(currentSource, metadata2);
94164
94466
  return projectReviewAssessment(source.assessment, source.bank, metadata2.review.selections);
94165
94467
  }
@@ -94657,7 +94959,7 @@ class TimebackAssessmentRuntimeService {
94657
94959
  async crossAttemptLockBarrier(attemptId) {
94658
94960
  for (let attempt = 1;attempt <= TimebackAssessmentRuntimeService.PROJECTION_BARRIER_MAX_ATTEMPTS; attempt += 1) {
94659
94961
  try {
94660
- await this.deps.assessmentRuntimeLock(this.deps.db, assessmentRuntimeAttemptLockKey(attemptId), async () => {
94962
+ await this.deps.assessmentRuntimeLock(this.deps.db, [assessmentRuntimeAttemptLockKey(attemptId)], async () => {
94661
94963
  return;
94662
94964
  });
94663
94965
  return;
@@ -94782,6 +95084,14 @@ class TimebackAssessmentRuntimeService {
94782
95084
  return AssessmentRuntimeError.from(assessmentAttemptUnauthorized(attemptId));
94783
95085
  }
94784
95086
  async snapshotForResult(result, metadata2, integration) {
95087
+ if (isAssessmentAttemptSuperseded({
95088
+ inProgress: result.inProgress ?? "",
95089
+ scoreStatus: result.scoreStatus
95090
+ })) {
95091
+ throw new GoneError("This assessment attempt has been superseded.", {
95092
+ attemptId: result.sourcedId
95093
+ });
95094
+ }
94785
95095
  const assessment = await this.loadAttemptAssessment(metadata2);
94786
95096
  if (this.isPlatformRoutedDiagnosticMetadata(metadata2)) {
94787
95097
  const routing = await this.loadAttemptDiagnosticRouting(metadata2, assessment);
@@ -96130,6 +96440,62 @@ function buildQtiLibraryListPlan(params) {
96130
96440
  }
96131
96441
  var PLAYCADEMY_QTI_SOURCE_PREFIX = "playcademy-test-", PLAYCADEMY_QTI_SOURCE_UPPER_BOUND = "playcademy-test.";
96132
96442
 
96443
+ // ../api-core/src/utils/timeback-review-mapping.util.ts
96444
+ function reviewMappingIssueSummary(label, identifiers) {
96445
+ if (identifiers.length === 0) {
96446
+ return null;
96447
+ }
96448
+ const displayed = identifiers.slice(0, 10).join(", ");
96449
+ const remainder = identifiers.length > 10 ? `, and ${identifiers.length - 10} more` : "";
96450
+ return `${label} (${identifiers.length}): ${displayed}${remainder}`;
96451
+ }
96452
+ async function prepareReviewMappingUpdate(test, questions) {
96453
+ const contentRevision = await assessmentContentRevision(test, questions);
96454
+ const assessment = {
96455
+ identifier: test.identifier,
96456
+ contractVersion: 1,
96457
+ contentRevision,
96458
+ title: test.title,
96459
+ items: questions.questions.map(({ question }) => ({
96460
+ identifier: question.identifier,
96461
+ title: question.title,
96462
+ prompt: "",
96463
+ maxScore: 1,
96464
+ interactions: []
96465
+ }))
96466
+ };
96467
+ const bank = await buildReviewBankIndex(assessment, questions, { customOnly: true });
96468
+ const issues = reviewBankMappingIssues(bank);
96469
+ if (issues.missingOrInvalidItemIdentifiers.length > 0 || issues.multipleStandardItemIdentifiers.length > 0) {
96470
+ const details = [
96471
+ reviewMappingIssueSummary("missing or invalid associations", issues.missingOrInvalidItemIdentifiers),
96472
+ reviewMappingIssueSummary("multiple associations", issues.multipleStandardItemIdentifiers)
96473
+ ].filter((detail) => detail !== null);
96474
+ throw new ValidationError(`Every review question must have exactly one valid standard/node association. ${details.join("; ")}.`);
96475
+ }
96476
+ const manifest = await buildReviewBankManifest(bank);
96477
+ return {
96478
+ update: {
96479
+ ...buildQtiTestUpdateInput(test, test.title),
96480
+ metadata: {
96481
+ ...test.metadata,
96482
+ [PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY]: manifest
96483
+ }
96484
+ },
96485
+ summary: {
96486
+ itemCount: bank.items.length,
96487
+ standardCount: Object.keys(manifest.itemsByStandard).length,
96488
+ sourceFingerprint: manifest.sourceFingerprint
96489
+ }
96490
+ };
96491
+ }
96492
+ var init_timeback_review_mapping_util = __esm(() => {
96493
+ init_assessment_runtime2();
96494
+ init_errors2();
96495
+ init_timeback_assessment_runtime_util();
96496
+ init_timeback_qti_authoring_util();
96497
+ });
96498
+
96133
96499
  // ../api-core/src/services/timeback-assessments.service.ts
96134
96500
  function databaseConstraintName(error88) {
96135
96501
  if (typeof error88 !== "object" || error88 === null) {
@@ -96212,7 +96578,8 @@ class TimebackAssessmentsService {
96212
96578
  ownerGameSlug: ownership.gameSlug,
96213
96579
  integrationId,
96214
96580
  subject: integration.subject,
96215
- grade: String(integration.grade)
96581
+ grade: String(integration.grade),
96582
+ [PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY]: emptyReviewBankManifest(input.qtiTestIdentifier)
96216
96583
  }
96217
96584
  });
96218
96585
  try {
@@ -96281,7 +96648,9 @@ class TimebackAssessmentsService {
96281
96648
  assertAssessmentHasQuestions(loaded.questions.questions);
96282
96649
  assertPlayableAssessmentImportQuestions(manifest.targetStatus, loaded.questions.questions.map(({ question }) => question));
96283
96650
  if (entry.purpose === "review") {
96284
- assertReviewAssessmentHasStandards(loaded.questions.questions.map(({ question }) => qtiAssessmentStandardRefsFromMetadata2(question.metadata).filter((standard) => canonicalReviewStandardRef(standard) !== null).length));
96651
+ assertReviewAssessmentHasStandards(loaded.questions.questions.map(({ question }) => reviewRoutingStandardRefsFromMetadata(question.metadata, {
96652
+ customOnly: true
96653
+ }).length));
96285
96654
  }
96286
96655
  return { entry, test: loaded.test };
96287
96656
  } catch (error88) {
@@ -96433,6 +96802,10 @@ class TimebackAssessmentsService {
96433
96802
  if (input.status !== undefined) {
96434
96803
  validateAssessmentStatusTransition(row.status, input.status);
96435
96804
  }
96805
+ if (!publishing && !activatingReview && nextPurpose === "review" && row.purpose !== "review") {
96806
+ const ownership = await this.requireQtiTestOwnershipContext(integrationId, tx);
96807
+ await this.rebuildReviewMapping(this.requireClient(), qtiTestIdentifier, ownership.gameSlug);
96808
+ }
96436
96809
  if (input.title !== undefined) {
96437
96810
  assertDraftAssessment(row);
96438
96811
  assertAllAssessmentAssociationsDraft(associations);
@@ -96451,7 +96824,8 @@ class TimebackAssessmentsService {
96451
96824
  updates.diagnosticKey = nextDiagnostic.diagnosticKey;
96452
96825
  updates.diagnosticRoutingManifest = nextDiagnostic.routingManifest;
96453
96826
  } else {
96454
- await this.validateAssessmentHasQuestions(qtiTestIdentifier, nextPurpose === "review" && nextStatus === "live");
96827
+ const reviewOwnership = nextPurpose === "review" && nextStatus === "live" ? await this.requireQtiTestOwnershipContext(integrationId, tx) : undefined;
96828
+ await this.validateAssessmentHasQuestions(qtiTestIdentifier, reviewOwnership?.gameSlug);
96455
96829
  }
96456
96830
  }
96457
96831
  let updated = row;
@@ -96546,6 +96920,19 @@ class TimebackAssessmentsService {
96546
96920
  });
96547
96921
  return { ...result, questions };
96548
96922
  }
96923
+ async updateReviewMapping(integrationId, qtiTestIdentifier) {
96924
+ return this.withLockedAssessmentAssociations(integrationId, qtiTestIdentifier, async (row, tx, associations) => {
96925
+ if (!associations.some((association) => association.purpose === "review")) {
96926
+ throw new ValidationError("Review mapping is available only for standards-review assessments.");
96927
+ }
96928
+ const client2 = this.requireClient();
96929
+ const ownership = await this.requireQtiTestOwnershipContext(integrationId, tx);
96930
+ const result = await this.rebuildReviewMapping(client2, qtiTestIdentifier, ownership.gameSlug);
96931
+ setAttribute("app.assessment.operation", "update_review_mapping");
96932
+ setAttribute("app.assessment.review_mapping_item_count", result.itemCount);
96933
+ return result;
96934
+ });
96935
+ }
96549
96936
  async listQuestionLibrary(integrationId, params) {
96550
96937
  const client2 = this.requireClient();
96551
96938
  await this.requireIntegration(integrationId);
@@ -96586,7 +96973,8 @@ class TimebackAssessmentsService {
96586
96973
  integrationId,
96587
96974
  subject: integration.subject,
96588
96975
  grade: String(integration.grade),
96589
- copiedFromTestIdentifier: sourceTestIdentifier
96976
+ copiedFromTestIdentifier: sourceTestIdentifier,
96977
+ [PLAYCADEMY_REVIEW_BANK_MANIFEST_METADATA_KEY]: emptyReviewBankManifest(targetTestIdentifier)
96590
96978
  }, itemPlan);
96591
96979
  const attemptedItemIdentifiers = [];
96592
96980
  let testCreationAttempted = false;
@@ -96974,16 +97362,20 @@ class TimebackAssessmentsService {
96974
97362
  const plan = buildQtiLibraryListPlan(params);
96975
97363
  return list(plan.params);
96976
97364
  }
96977
- async validateAssessmentHasQuestions(qtiTestIdentifier, requireReviewStandards = false) {
97365
+ async validateAssessmentHasQuestions(qtiTestIdentifier, reviewGameSlug) {
96978
97366
  const client2 = this.requireClient();
96979
- const result = await client2.qtiApi.assessmentTests.getQuestions(qtiTestIdentifier);
97367
+ const [test, result] = await Promise.all([
97368
+ client2.qtiApi.assessmentTests.get(qtiTestIdentifier),
97369
+ client2.qtiApi.assessmentTests.getQuestions(qtiTestIdentifier)
97370
+ ]);
96980
97371
  assertAssessmentHasQuestions(result.questions);
96981
97372
  const hydrated = await hydrateQtiTestQuestions(client2, result);
96982
97373
  for (const { question } of hydrated.questions) {
96983
97374
  assertPlayableQtiQuestion(question);
96984
97375
  }
96985
- if (requireReviewStandards) {
96986
- assertReviewAssessmentHasStandards(hydrated.questions.map(({ question }) => qtiAssessmentStandardRefsFromMetadata2(question.metadata).filter((standard) => canonicalReviewStandardRef(standard) !== null).length));
97376
+ if (reviewGameSlug) {
97377
+ assertQtiTestOwnedByGame(test, reviewGameSlug);
97378
+ await this.writeReviewMapping(client2, test, hydrated);
96987
97379
  }
96988
97380
  }
96989
97381
  async prepareDiagnosticAssociationChanges(row, nextPurpose, requested) {
@@ -97048,6 +97440,19 @@ class TimebackAssessmentsService {
97048
97440
  routingManifest: validation.manifest
97049
97441
  };
97050
97442
  }
97443
+ async rebuildReviewMapping(client2, qtiTestIdentifier, gameSlug) {
97444
+ const [test, references] = await Promise.all([
97445
+ client2.qtiApi.assessmentTests.get(qtiTestIdentifier),
97446
+ client2.qtiApi.assessmentTests.getQuestions(qtiTestIdentifier)
97447
+ ]);
97448
+ assertQtiTestOwnedByGame(test, gameSlug);
97449
+ return this.writeReviewMapping(client2, test, await hydrateQtiTestQuestions(client2, references));
97450
+ }
97451
+ async writeReviewMapping(client2, test, questions) {
97452
+ const prepared = await prepareReviewMappingUpdate(test, questions);
97453
+ await client2.qtiApi.assessmentTests.update(test.identifier, prepared.update);
97454
+ return prepared.summary;
97455
+ }
97051
97456
  }
97052
97457
  var init_timeback_assessments_service = __esm(async () => {
97053
97458
  init_drizzle_orm();
@@ -97055,7 +97460,6 @@ var init_timeback_assessments_service = __esm(async () => {
97055
97460
  init_tables_index();
97056
97461
  init_spans();
97057
97462
  init_assessment_runtime2();
97058
- init_qti();
97059
97463
  init_timeback3();
97060
97464
  init_errors2();
97061
97465
  init_timeback_assessment_import_util();
@@ -97063,6 +97467,7 @@ var init_timeback_assessments_service = __esm(async () => {
97063
97467
  init_timeback_assessment_runtime_util();
97064
97468
  init_timeback_qti_authoring_util();
97065
97469
  init_timeback_qti_hydration_util();
97470
+ init_timeback_review_mapping_util();
97066
97471
  await init_errors8();
97067
97472
  });
97068
97473
 
@@ -99070,7 +99475,7 @@ var init_upload_service = __esm(() => {
99070
99475
  function createPlatformServices(deps) {
99071
99476
  const {
99072
99477
  db: db2,
99073
- databaseLock,
99478
+ assessmentRuntimeLock,
99074
99479
  config: config5,
99075
99480
  cloudflare: cloudflare2,
99076
99481
  corsKvs,
@@ -99139,7 +99544,7 @@ function createPlatformServices(deps) {
99139
99544
  db: db2,
99140
99545
  timeback: timebackClient,
99141
99546
  validateDeveloperAccess,
99142
- assessmentRuntimeLock: createAssessmentRuntimeLock(databaseLock)
99547
+ assessmentRuntimeLock
99143
99548
  });
99144
99549
  return {
99145
99550
  bucket,
@@ -99157,7 +99562,6 @@ function createPlatformServices(deps) {
99157
99562
  };
99158
99563
  }
99159
99564
  var init_platform2 = __esm(async () => {
99160
- init_assessment_runtime_lock_util();
99161
99565
  init_bucket_service();
99162
99566
  init_database_service();
99163
99567
  init_deployment_state_service();
@@ -99852,7 +100256,7 @@ var init_standalone = __esm(() => {
99852
100256
 
99853
100257
  // ../api-core/src/services/factory/index.ts
99854
100258
  function createServices(ctx) {
99855
- const { db: db2, databaseLock, config: config5, providers, cloudflare: cloudflare2, timeback: timeback2, discord, corsKvs } = ctx;
100259
+ const { db: db2, assessmentRuntimeLock, config: config5, providers, cloudflare: cloudflare2, timeback: timeback2, discord, corsKvs } = ctx;
99856
100260
  const { auth: auth2, storage, r2Storage, cache } = providers;
99857
100261
  const infra2 = createInfraServices({
99858
100262
  db: db2,
@@ -99874,7 +100278,7 @@ function createServices(ctx) {
99874
100278
  });
99875
100279
  const platform2 = createPlatformServices({
99876
100280
  db: db2,
99877
- databaseLock,
100281
+ assessmentRuntimeLock,
99878
100282
  config: config5,
99879
100283
  cloudflare: cloudflare2,
99880
100284
  corsKvs,
@@ -99902,6 +100306,342 @@ var init_factory = __esm(async () => {
99902
100306
  await init_platform2();
99903
100307
  });
99904
100308
 
100309
+ // ../api-core/src/types/context.type.ts
100310
+ function isAuthenticated(ctx) {
100311
+ return ctx.user != null;
100312
+ }
100313
+
100314
+ // ../api-core/src/types/index.ts
100315
+ var init_types5 = () => {};
100316
+
100317
+ // ../api-core/src/utils/auth.util.ts
100318
+ function hasGameManagementAccess(user) {
100319
+ return user.role === "admin" || user.role === "teacher" || user.role === "developer" && user.developerStatus === "approved";
100320
+ }
100321
+ function isDashboardWorkerKey(key) {
100322
+ return Boolean(key?.permissions?.[DASHBOARD_PERMISSION_NAMESPACE]);
100323
+ }
100324
+ function workerKeyGrantsGameRead(key, slug2) {
100325
+ if (!isDashboardWorkerKey(key) && !isGameWorkerKey(key)) {
100326
+ return false;
100327
+ }
100328
+ const games2 = key?.permissions?.games;
100329
+ return Boolean(games2?.includes(`read:${slug2}`) || games2?.includes(`write:${slug2}`));
100330
+ }
100331
+ function isGameWorkerKey(key) {
100332
+ return Boolean(key?.name?.startsWith(GAME_WORKER_KEY_PREFIX));
100333
+ }
100334
+ function deniedWorkerKeyRequest(key, method, pathname) {
100335
+ if (isDashboardWorkerKey(key) && !isAllowedDashboardWorkerRequest(method, pathname, key.permissions)) {
100336
+ return DASHBOARD_WORKER_KEY_RESTRICTED;
100337
+ }
100338
+ return null;
100339
+ }
100340
+ function rejectDashboardWorkerKey(ctx) {
100341
+ if (isDashboardWorkerKey(ctx.apiKey)) {
100342
+ throw ApiError.forbidden(DASHBOARD_WORKER_KEY_RESTRICTED);
100343
+ }
100344
+ }
100345
+ function assertAuthenticatedRequest(ctx) {
100346
+ if (!isAuthenticated(ctx)) {
100347
+ throw ApiError.unauthorized("Valid session or bearer token required");
100348
+ }
100349
+ if (ctx.apiKey) {
100350
+ const denied = deniedWorkerKeyRequest(ctx.apiKey, ctx.request.method, ctx.url.pathname);
100351
+ if (denied) {
100352
+ throw ApiError.forbidden(denied);
100353
+ }
100354
+ }
100355
+ }
100356
+ function requireAuth(handler) {
100357
+ return async (ctx) => {
100358
+ assertAuthenticatedRequest(ctx);
100359
+ return handler(ctx);
100360
+ };
100361
+ }
100362
+ function requireNonAnonymous(handler) {
100363
+ return async (ctx) => {
100364
+ assertAuthenticatedRequest(ctx);
100365
+ if (ctx.user.isAnonymous) {
100366
+ throw ApiError.forbidden("This operation is not available for demo/anonymous users");
100367
+ }
100368
+ return handler(ctx);
100369
+ };
100370
+ }
100371
+ function requireAnonymous(handler) {
100372
+ return async (ctx) => {
100373
+ assertAuthenticatedRequest(ctx);
100374
+ if (!ctx.user.isAnonymous) {
100375
+ throw ApiError.forbidden("This operation is only available for demo/anonymous users");
100376
+ }
100377
+ return handler(ctx);
100378
+ };
100379
+ }
100380
+ function requireDeveloper(handler) {
100381
+ return async (ctx) => {
100382
+ assertAuthenticatedRequest(ctx);
100383
+ rejectDashboardWorkerKey(ctx);
100384
+ const isAdmin = ctx.user.role === "admin";
100385
+ const isApprovedDev = ctx.user.role === "developer" && ctx.user.developerStatus === "approved";
100386
+ if (!isAdmin && !isApprovedDev) {
100387
+ throw ApiError.forbidden("Must be an approved developer");
100388
+ }
100389
+ return handler(ctx);
100390
+ };
100391
+ }
100392
+ function requireHumanDeveloper(handler) {
100393
+ return requireDeveloper(async (ctx) => {
100394
+ if (isDashboardWorkerKey(ctx.apiKey) || isGameWorkerKey(ctx.apiKey)) {
100395
+ throw ApiError.forbidden(WORKER_KEY_HUMAN_ONLY);
100396
+ }
100397
+ return handler(ctx);
100398
+ });
100399
+ }
100400
+ function requireGameManagementAccess(handler) {
100401
+ return async (ctx) => {
100402
+ assertAuthenticatedRequest(ctx);
100403
+ rejectDashboardWorkerKey(ctx);
100404
+ if (!hasGameManagementAccess(ctx.user)) {
100405
+ throw ApiError.forbidden("Game management access required");
100406
+ }
100407
+ return handler(ctx);
100408
+ };
100409
+ }
100410
+ var WORKER_KEY_HUMAN_ONLY = "This operation requires your own credential — platform worker keys are refused";
100411
+ var init_auth_util = __esm(() => {
100412
+ init_errors2();
100413
+ init_types5();
100414
+ init_dashboard_util();
100415
+ init_deployment_util();
100416
+ });
100417
+
100418
+ // ../api-core/src/utils/controller.util.ts
100419
+ function defineControllerNames(namespace, handlers) {
100420
+ for (const [key, handler] of Object.entries(handlers)) {
100421
+ Object.defineProperty(handler, "name", {
100422
+ value: `${namespace}.${key}`,
100423
+ configurable: true
100424
+ });
100425
+ }
100426
+ return handlers;
100427
+ }
100428
+
100429
+ // ../api-core/src/utils/lti.util.ts
100430
+ function generateUsername(email5) {
100431
+ const baseUsername = (email5.split("@")[0] || "user").toLowerCase();
100432
+ const cleanUsername = baseUsername.replace(/[^a-z0-9]/g, "");
100433
+ const randomSuffix = Math.random().toString(36).substring(2, 7);
100434
+ return `${cleanUsername}_${randomSuffix}`;
100435
+ }
100436
+ function extractRedirectPath(targetUri, currentHost) {
100437
+ try {
100438
+ const targetUrl = new URL(targetUri);
100439
+ if (targetUrl.hostname === currentHost) {
100440
+ return targetUrl.pathname + targetUrl.search;
100441
+ }
100442
+ } catch {}
100443
+ return "/";
100444
+ }
100445
+ function validateLtiClaims(claims) {
100446
+ const messageType = claims["https://purl.imsglobal.org/spec/lti/claim/message_type"];
100447
+ const version4 = claims["https://purl.imsglobal.org/spec/lti/claim/version"];
100448
+ if (messageType !== "LtiResourceLinkRequest") {
100449
+ return `Invalid LTI message type: ${messageType}`;
100450
+ }
100451
+ if (version4 !== "1.3.0") {
100452
+ return `Unsupported LTI version: ${version4}`;
100453
+ }
100454
+ return null;
100455
+ }
100456
+ var init_lti_util = () => {};
100457
+
100458
+ // ../api-core/src/utils/lti-provisioning.ts
100459
+ import * as crypto4 from "node:crypto";
100460
+ async function provisionLtiUser(db2, claims) {
100461
+ const database = db2;
100462
+ const email5 = claims.email;
100463
+ const ltiTimebackId = claims.sub;
100464
+ const providerId = AUTH_PROVIDER_IDS.TIMEBACK_LTI;
100465
+ if (!email5) {
100466
+ throw new ValidationError("Email is required in LTI claims");
100467
+ }
100468
+ const existingAccount = await database.query.accounts.findFirst({
100469
+ where: and(eq(accounts.accountId, ltiTimebackId), eq(accounts.providerId, providerId))
100470
+ });
100471
+ if (existingAccount) {
100472
+ const user = await database.query.users.findFirst({
100473
+ where: eq(users.id, existingAccount.userId)
100474
+ });
100475
+ if (user) {
100476
+ setAttribute("app.lti.provision", "existing_account");
100477
+ return user;
100478
+ }
100479
+ }
100480
+ const existingUser = await database.query.users.findFirst({
100481
+ where: eq(users.email, email5)
100482
+ });
100483
+ if (existingUser) {
100484
+ await database.transaction(async (tx) => {
100485
+ const existingLtiAccount = await tx.query.accounts.findFirst({
100486
+ where: and(eq(accounts.userId, existingUser.id), eq(accounts.providerId, providerId))
100487
+ });
100488
+ if (!existingLtiAccount) {
100489
+ const [account] = await tx.insert(accounts).values({
100490
+ id: crypto4.randomUUID(),
100491
+ userId: existingUser.id,
100492
+ accountId: ltiTimebackId,
100493
+ providerId,
100494
+ accessToken: null,
100495
+ refreshToken: null,
100496
+ accessTokenExpiresAt: null,
100497
+ refreshTokenExpiresAt: null,
100498
+ createdAt: new Date,
100499
+ updatedAt: new Date
100500
+ }).returning({ id: accounts.id });
100501
+ if (!account) {
100502
+ throw new InternalError("Failed to link LTI account");
100503
+ }
100504
+ }
100505
+ });
100506
+ setAttribute("app.lti.provision", "linked_account");
100507
+ return existingUser;
100508
+ }
100509
+ const newUserId = crypto4.randomUUID();
100510
+ const createdUser = await database.transaction(async (tx) => {
100511
+ const [insertedUser] = await tx.insert(users).values({
100512
+ id: newUserId,
100513
+ email: email5,
100514
+ emailVerified: true,
100515
+ username: generateUsername(email5),
100516
+ name: claims.name || claims.given_name || email5.split("@")[0] || "Timeback User",
100517
+ createdAt: new Date,
100518
+ updatedAt: new Date
100519
+ }).returning();
100520
+ if (!insertedUser) {
100521
+ throw new InternalError("Failed to create user");
100522
+ }
100523
+ await tx.insert(accounts).values({
100524
+ id: crypto4.randomUUID(),
100525
+ userId: newUserId,
100526
+ accountId: ltiTimebackId,
100527
+ providerId,
100528
+ accessToken: null,
100529
+ refreshToken: null,
100530
+ accessTokenExpiresAt: null,
100531
+ refreshTokenExpiresAt: null,
100532
+ createdAt: new Date,
100533
+ updatedAt: new Date
100534
+ });
100535
+ setAttribute("app.lti.provision", "created_user");
100536
+ return insertedUser;
100537
+ });
100538
+ return createdUser;
100539
+ }
100540
+ var init_lti_provisioning = __esm(() => {
100541
+ init_drizzle_orm();
100542
+ init_src();
100543
+ init_tables_index();
100544
+ init_spans();
100545
+ init_errors2();
100546
+ init_lti_util();
100547
+ });
100548
+
100549
+ // ../api-core/src/utils/params.util.ts
100550
+ function requireGameId(gameId) {
100551
+ if (!gameId) {
100552
+ throw ApiError.badRequest("Missing game ID");
100553
+ }
100554
+ if (!isValidUUID(gameId)) {
100555
+ throw ApiError.unprocessableEntity("gameId must be a valid UUID format");
100556
+ }
100557
+ return gameId;
100558
+ }
100559
+ function requireSlug(slug2) {
100560
+ if (!slug2) {
100561
+ throw ApiError.badRequest("Missing game slug");
100562
+ }
100563
+ return slug2;
100564
+ }
100565
+ function requireUserId(userId) {
100566
+ if (!userId) {
100567
+ throw ApiError.badRequest("Missing user ID");
100568
+ }
100569
+ if (!isValidUUID(userId)) {
100570
+ throw ApiError.unprocessableEntity("userId must be a valid UUID format");
100571
+ }
100572
+ return userId;
100573
+ }
100574
+ function parseLimitParam(url4, max) {
100575
+ const raw = url4.searchParams.get("limit");
100576
+ if (raw === null) {
100577
+ return;
100578
+ }
100579
+ const limit = Number(raw);
100580
+ if (!Number.isInteger(limit) || limit < 1 || limit > max) {
100581
+ throw ApiError.badRequest(`limit must be an integer between 1 and ${max}`);
100582
+ }
100583
+ return limit;
100584
+ }
100585
+ var init_params_util = __esm(() => {
100586
+ init_src9();
100587
+ init_errors2();
100588
+ });
100589
+
100590
+ // ../api-core/src/utils/validation.util.ts
100591
+ function formatZodError(error88) {
100592
+ const flat = error88.flatten();
100593
+ const result = {};
100594
+ if (Object.keys(flat.fieldErrors).length > 0) {
100595
+ result.fields = {};
100596
+ for (const [field, messages] of Object.entries(flat.fieldErrors)) {
100597
+ if (messages && messages.length > 0) {
100598
+ result.fields[field] = messages[0];
100599
+ }
100600
+ }
100601
+ }
100602
+ if (flat.formErrors.length > 0) {
100603
+ result.errors = flat.formErrors;
100604
+ }
100605
+ return result;
100606
+ }
100607
+ function recordValidationFailure(details) {
100608
+ setAttribute("app.request.outcome", "validation_failed");
100609
+ addEvent("request.validation_failed", {
100610
+ "app.validation.error": JSON.stringify(details)
100611
+ });
100612
+ }
100613
+ async function parseRequestBody(request, schema2) {
100614
+ try {
100615
+ return schema2.parse(await request.json());
100616
+ } catch (error88) {
100617
+ if (error88 instanceof exports_external.ZodError) {
100618
+ const details = formatZodError(error88);
100619
+ recordValidationFailure(details);
100620
+ throw ApiError.unprocessableEntity("Validation failed", details);
100621
+ }
100622
+ throw ApiError.invalidJsonBody();
100623
+ }
100624
+ }
100625
+ var init_validation_util = __esm(() => {
100626
+ init_esm();
100627
+ init_spans();
100628
+ init_errors2();
100629
+ });
100630
+ // ../api-core/src/utils/index.ts
100631
+ var init_utils7 = __esm(() => {
100632
+ init_auth_util();
100633
+ init_assessment_runtime_lock_util();
100634
+ init_dashboard_util();
100635
+ init_deployment_util();
100636
+ init_leaderboard_util();
100637
+ init_lti_util();
100638
+ init_lti_provisioning();
100639
+ init_params_util();
100640
+ init_secrets_util();
100641
+ init_timeback_util();
100642
+ init_validation_util();
100643
+ });
100644
+
99905
100645
  // src/infrastructure/api/clients/timeback.ts
99906
100646
  function buildTimebackClient() {
99907
100647
  if (!hasTimebackCredentials()) {
@@ -100289,7 +101029,7 @@ function createSandboxContext(options) {
100289
101029
  const services = {};
100290
101030
  const ctx = {
100291
101031
  db: options.db,
100292
- databaseLock: createInMemoryDatabaseLock(),
101032
+ assessmentRuntimeLock: createInMemoryAssessmentRuntimeLock(),
100293
101033
  config: config5,
100294
101034
  providers,
100295
101035
  services,
@@ -100317,7 +101057,7 @@ function resetSandboxContext() {
100317
101057
  var cachedServiceContext = null, cachedDb = null;
100318
101058
  var init_context = __esm(async () => {
100319
101059
  init_config2();
100320
- init_locks();
101060
+ init_utils7();
100321
101061
  init_src6();
100322
101062
  init_providers();
100323
101063
  await __promiseAll([
@@ -114531,7 +115271,7 @@ __export(exports_api, {
114531
115271
  import process22 from "process";
114532
115272
  import os2 from "os";
114533
115273
  import tty from "tty";
114534
- import { randomUUID } from "crypto";
115274
+ import { randomUUID as randomUUID2 } from "crypto";
114535
115275
  function assembleStyles() {
114536
115276
  const codes = /* @__PURE__ */ new Map;
114537
115277
  for (const [groupName, group] of Object.entries(styles2)) {
@@ -117206,7 +117946,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117206
117946
  __defProp2(to, key, { get: () => from[key], enumerable: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
117207
117947
  }
117208
117948
  return to;
117209
- }, __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) => {
117949
+ }, __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) => {
117210
117950
  const matchers = filters.map((it3) => {
117211
117951
  return new Minimatch(it3);
117212
117952
  });
@@ -117463,7 +118203,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117463
118203
  return { schema: schema5 };
117464
118204
  }, generateDrizzleJson = (imports, prevId, schemaFilters, casing2) => {
117465
118205
  const prepared = prepareFromExports(imports);
117466
- const id = randomUUID();
118206
+ const id = randomUUID2();
117467
118207
  const snapshot = generatePgSnapshot(prepared.tables, prepared.enums, prepared.schemas, prepared.sequences, prepared.roles, prepared.policies, prepared.views, prepared.matViews, casing2, schemaFilters);
117468
118208
  return fillPgSnapshot({
117469
118209
  serialized: snapshot,
@@ -117509,7 +118249,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117509
118249
  }, generateSQLiteDrizzleJson = async (imports, prevId, casing2) => {
117510
118250
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_sqliteImports(), sqliteImports_exports));
117511
118251
  const prepared = prepareFromExports5(imports);
117512
- const id = randomUUID();
118252
+ const id = randomUUID2();
117513
118253
  const snapshot = generateSqliteSnapshot(prepared.tables, prepared.views, casing2);
117514
118254
  return {
117515
118255
  ...snapshot,
@@ -117557,7 +118297,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117557
118297
  }, generateMySQLDrizzleJson = async (imports, prevId, casing2) => {
117558
118298
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_mysqlImports(), mysqlImports_exports));
117559
118299
  const prepared = prepareFromExports5(imports);
117560
- const id = randomUUID();
118300
+ const id = randomUUID2();
117561
118301
  const snapshot = generateMySqlSnapshot(prepared.tables, prepared.views, casing2);
117562
118302
  return {
117563
118303
  ...snapshot,
@@ -117604,7 +118344,7 @@ var __create2, __defProp2, __getOwnPropDesc, __getOwnPropNames2, __getProtoOf2,
117604
118344
  }, generateSingleStoreDrizzleJson = async (imports, prevId, casing2) => {
117605
118345
  const { prepareFromExports: prepareFromExports5 } = await Promise.resolve().then(() => (init_singlestoreImports(), singlestoreImports_exports));
117606
118346
  const prepared = prepareFromExports5(imports);
117607
- const id = randomUUID();
118347
+ const id = randomUUID2();
117608
118348
  const snapshot = generateSingleStoreSnapshot(prepared.tables, casing2);
117609
118349
  return {
117610
118350
  ...snapshot,
@@ -121216,7 +121956,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
121216
121956
  })(errorUtil2 || (errorUtil2 = {}));
121217
121957
  }
121218
121958
  });
121219
- init_types5 = __esm2({
121959
+ init_types6 = __esm2({
121220
121960
  "../node_modules/.pnpm/zod@3.25.42/node_modules/zod/dist/esm/v3/types.js"() {
121221
121961
  init_ZodError2();
121222
121962
  init_errors9();
@@ -124381,7 +125121,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
124381
125121
  init_parseUtil2();
124382
125122
  init_typeAliases2();
124383
125123
  init_util5();
124384
- init_types5();
125124
+ init_types6();
124385
125125
  init_ZodError2();
124386
125126
  }
124387
125127
  });
@@ -126114,7 +126854,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
126114
126854
  backwardCompatibleSqliteSchema = unionType2([sqliteSchemaV5, schema3]);
126115
126855
  }
126116
126856
  });
126117
- init_utils7 = __esm2({
126857
+ init_utils8 = __esm2({
126118
126858
  "src/utils.ts"() {
126119
126859
  init_views();
126120
126860
  init_global2();
@@ -126166,7 +126906,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
126166
126906
  "src/cli/views.ts"() {
126167
126907
  init_source();
126168
126908
  import_hanji = __toESM5(require_hanji());
126169
- init_utils7();
126909
+ init_utils8();
126170
126910
  warning = (msg) => {
126171
126911
  (0, import_hanji.render)(`[${source_default.yellow("Warning")}] ${msg}`);
126172
126912
  };
@@ -128874,7 +129614,7 @@ Is ${source_default.bold.blue(this.base.name)} schema created or renamed from an
128874
129614
  init_pgSchema();
128875
129615
  init_singlestoreSchema();
128876
129616
  init_sqliteSchema();
128877
- init_utils7();
129617
+ init_utils8();
128878
129618
  parseType = (schemaPrefix, type) => {
128879
129619
  const pgNativeTypes = [
128880
129620
  "uuid",
@@ -131370,7 +132110,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
131370
132110
  init_source();
131371
132111
  init_sqliteSchema();
131372
132112
  init_sqlgenerator();
131373
- init_utils7();
132113
+ init_utils8();
131374
132114
  _moveDataStatements = (tableName, json42, dataLoss = false) => {
131375
132115
  const statements = [];
131376
132116
  const newTableName = `__new_${tableName}`;
@@ -133528,7 +134268,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
133528
134268
  init_singlestoreSchema();
133529
134269
  init_sqliteSchema();
133530
134270
  init_statementCombiner();
133531
- init_utils7();
134271
+ init_utils8();
133532
134272
  makeChanged = (schema5) => {
133533
134273
  return objectType2({
133534
134274
  type: enumType2(["changed"]),
@@ -135753,7 +136493,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
135753
136493
  init_pgSchema();
135754
136494
  init_sqliteSchema();
135755
136495
  init_snapshotsDiffer();
135756
- init_utils7();
136496
+ init_utils8();
135757
136497
  init_words();
135758
136498
  init_outputs();
135759
136499
  init_views();
@@ -142313,7 +143053,7 @@ params: ${params}`);
142313
143053
  init_pg_core2();
142314
143054
  init_vector32();
142315
143055
  init_outputs();
142316
- init_utils7();
143056
+ init_utils8();
142317
143057
  init_utils62();
142318
143058
  indexName = (tableName, columns2) => {
142319
143059
  return `${tableName}_${columns2.join("_")}_index`;
@@ -146322,7 +147062,7 @@ ORDER BY
146322
147062
  init_dist9();
146323
147063
  init_sqlite_core();
146324
147064
  init_outputs();
146325
- init_utils7();
147065
+ init_utils8();
146326
147066
  init_utils62();
146327
147067
  generateSqliteSnapshot = (tables, views, casing2) => {
146328
147068
  const dialect6 = new SQLiteSyncDialect({ casing: casing2 });
@@ -148275,7 +149015,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
148275
149015
  MySqlViewConfig = Symbol.for("drizzle:MySqlViewConfig");
148276
149016
  }
148277
149017
  });
148278
- init_utils8 = __esm2({
149018
+ init_utils82 = __esm2({
148279
149019
  "../drizzle-orm/dist/mysql-core/utils.js"() {
148280
149020
  init_entity2();
148281
149021
  init_dist9();
@@ -148297,7 +149037,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
148297
149037
  init_query_promise2();
148298
149038
  init_selection_proxy2();
148299
149039
  init_table8();
148300
- init_utils8();
149040
+ init_utils82();
148301
149041
  MySqlDeleteBase = class extends (_b239 = QueryPromise2, _a3222 = entityKind2, _b239) {
148302
149042
  constructor(table62, session3, dialect6, withList) {
148303
149043
  super();
@@ -149145,7 +149885,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
149145
149885
  init_table8();
149146
149886
  init_utils22();
149147
149887
  init_view_common3();
149148
- init_utils8();
149888
+ init_utils82();
149149
149889
  init_view_base3();
149150
149890
  _a325 = entityKind2;
149151
149891
  MySqlSelectBuilder = class {
@@ -149544,7 +150284,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
149544
150284
  init_sql5();
149545
150285
  init_table8();
149546
150286
  init_utils22();
149547
- init_utils8();
150287
+ init_utils82();
149548
150288
  init_query_builder4();
149549
150289
  _a329 = entityKind2;
149550
150290
  MySqlInsertBuilder = class {
@@ -149648,7 +150388,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
149648
150388
  init_selection_proxy2();
149649
150389
  init_table8();
149650
150390
  init_utils22();
149651
- init_utils8();
150391
+ init_utils82();
149652
150392
  _a331 = entityKind2;
149653
150393
  MySqlUpdateBuilder = class {
149654
150394
  constructor(table62, session3, dialect6, withList) {
@@ -150184,7 +150924,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
150184
150924
  init_subquery4();
150185
150925
  init_table42();
150186
150926
  init_unique_constraint3();
150187
- init_utils8();
150927
+ init_utils82();
150188
150928
  init_view_common32();
150189
150929
  init_view3();
150190
150930
  }
@@ -150195,7 +150935,7 @@ ${withStyle.errorWarning(`We've found duplicated view name across ${source_defau
150195
150935
  init_dist9();
150196
150936
  init_mysql_core();
150197
150937
  init_outputs();
150198
- init_utils7();
150938
+ init_utils8();
150199
150939
  init_utils62();
150200
150940
  handleEnumType = (type) => {
150201
150941
  let str = type.split("(")[1];
@@ -154629,7 +155369,7 @@ The unique index ${source_default.underline.blue(name22)} on the ${source_defaul
154629
155369
  import_hanji10 = __toESM5(require_hanji());
154630
155370
  init_sqlgenerator();
154631
155371
  init_singlestoreSchema();
154632
- init_utils7();
155372
+ init_utils8();
154633
155373
  init_selector_ui();
154634
155374
  init_outputs();
154635
155375
  filterStatements2 = (statements, currentSchema, prevSchema) => {
@@ -154892,7 +155632,7 @@ The unique index ${source_default.underline.blue(name22)} on the ${source_defaul
154892
155632
  init_sqlgenerator();
154893
155633
  init_selector_ui();
154894
155634
  init_pgSchema();
154895
- init_utils7();
155635
+ init_utils8();
154896
155636
  import_hanji6 = __toESM5(require_hanji());
154897
155637
  init_mjs();
154898
155638
  init_global2();
@@ -155780,346 +156520,11 @@ var init_manifest = __esm(async () => {
155780
156520
  });
155781
156521
  });
155782
156522
 
155783
- // ../api-core/src/types/context.type.ts
155784
- function isAuthenticated(ctx) {
155785
- return ctx.user != null;
155786
- }
155787
-
155788
- // ../api-core/src/types/index.ts
155789
- var init_types6 = () => {};
155790
-
155791
- // ../api-core/src/utils/auth.util.ts
155792
- function hasGameManagementAccess(user) {
155793
- return user.role === "admin" || user.role === "teacher" || user.role === "developer" && user.developerStatus === "approved";
155794
- }
155795
- function isDashboardWorkerKey(key) {
155796
- return Boolean(key?.permissions?.[DASHBOARD_PERMISSION_NAMESPACE]);
155797
- }
155798
- function workerKeyGrantsGameRead(key, slug2) {
155799
- if (!isDashboardWorkerKey(key) && !isGameWorkerKey(key)) {
155800
- return false;
155801
- }
155802
- const games2 = key?.permissions?.games;
155803
- return Boolean(games2?.includes(`read:${slug2}`) || games2?.includes(`write:${slug2}`));
155804
- }
155805
- function isGameWorkerKey(key) {
155806
- return Boolean(key?.name?.startsWith(GAME_WORKER_KEY_PREFIX));
155807
- }
155808
- function deniedWorkerKeyRequest(key, method, pathname) {
155809
- if (isDashboardWorkerKey(key) && !isAllowedDashboardWorkerRequest(method, pathname, key.permissions)) {
155810
- return DASHBOARD_WORKER_KEY_RESTRICTED;
155811
- }
155812
- return null;
155813
- }
155814
- function rejectDashboardWorkerKey(ctx) {
155815
- if (isDashboardWorkerKey(ctx.apiKey)) {
155816
- throw ApiError.forbidden(DASHBOARD_WORKER_KEY_RESTRICTED);
155817
- }
155818
- }
155819
- function assertAuthenticatedRequest(ctx) {
155820
- if (!isAuthenticated(ctx)) {
155821
- throw ApiError.unauthorized("Valid session or bearer token required");
155822
- }
155823
- if (ctx.apiKey) {
155824
- const denied = deniedWorkerKeyRequest(ctx.apiKey, ctx.request.method, ctx.url.pathname);
155825
- if (denied) {
155826
- throw ApiError.forbidden(denied);
155827
- }
155828
- }
155829
- }
155830
- function requireAuth(handler) {
155831
- return async (ctx) => {
155832
- assertAuthenticatedRequest(ctx);
155833
- return handler(ctx);
155834
- };
155835
- }
155836
- function requireNonAnonymous(handler) {
155837
- return async (ctx) => {
155838
- assertAuthenticatedRequest(ctx);
155839
- if (ctx.user.isAnonymous) {
155840
- throw ApiError.forbidden("This operation is not available for demo/anonymous users");
155841
- }
155842
- return handler(ctx);
155843
- };
155844
- }
155845
- function requireAnonymous(handler) {
155846
- return async (ctx) => {
155847
- assertAuthenticatedRequest(ctx);
155848
- if (!ctx.user.isAnonymous) {
155849
- throw ApiError.forbidden("This operation is only available for demo/anonymous users");
155850
- }
155851
- return handler(ctx);
155852
- };
155853
- }
155854
- function requireDeveloper(handler) {
155855
- return async (ctx) => {
155856
- assertAuthenticatedRequest(ctx);
155857
- rejectDashboardWorkerKey(ctx);
155858
- const isAdmin = ctx.user.role === "admin";
155859
- const isApprovedDev = ctx.user.role === "developer" && ctx.user.developerStatus === "approved";
155860
- if (!isAdmin && !isApprovedDev) {
155861
- throw ApiError.forbidden("Must be an approved developer");
155862
- }
155863
- return handler(ctx);
155864
- };
155865
- }
155866
- function requireHumanDeveloper(handler) {
155867
- return requireDeveloper(async (ctx) => {
155868
- if (isDashboardWorkerKey(ctx.apiKey) || isGameWorkerKey(ctx.apiKey)) {
155869
- throw ApiError.forbidden(WORKER_KEY_HUMAN_ONLY);
155870
- }
155871
- return handler(ctx);
155872
- });
155873
- }
155874
- function requireGameManagementAccess(handler) {
155875
- return async (ctx) => {
155876
- assertAuthenticatedRequest(ctx);
155877
- rejectDashboardWorkerKey(ctx);
155878
- if (!hasGameManagementAccess(ctx.user)) {
155879
- throw ApiError.forbidden("Game management access required");
155880
- }
155881
- return handler(ctx);
155882
- };
155883
- }
155884
- var WORKER_KEY_HUMAN_ONLY = "This operation requires your own credential — platform worker keys are refused";
155885
- var init_auth_util = __esm(() => {
155886
- init_errors2();
155887
- init_types6();
155888
- init_dashboard_util();
155889
- init_deployment_util();
155890
- });
155891
-
155892
- // ../api-core/src/utils/controller.util.ts
155893
- function defineControllerNames(namespace, handlers) {
155894
- for (const [key, handler] of Object.entries(handlers)) {
155895
- Object.defineProperty(handler, "name", {
155896
- value: `${namespace}.${key}`,
155897
- configurable: true
155898
- });
155899
- }
155900
- return handlers;
155901
- }
155902
-
155903
- // ../api-core/src/utils/lti.util.ts
155904
- function generateUsername(email5) {
155905
- const baseUsername = (email5.split("@")[0] || "user").toLowerCase();
155906
- const cleanUsername = baseUsername.replace(/[^a-z0-9]/g, "");
155907
- const randomSuffix = Math.random().toString(36).substring(2, 7);
155908
- return `${cleanUsername}_${randomSuffix}`;
155909
- }
155910
- function extractRedirectPath(targetUri, currentHost) {
155911
- try {
155912
- const targetUrl = new URL(targetUri);
155913
- if (targetUrl.hostname === currentHost) {
155914
- return targetUrl.pathname + targetUrl.search;
155915
- }
155916
- } catch {}
155917
- return "/";
155918
- }
155919
- function validateLtiClaims(claims) {
155920
- const messageType = claims["https://purl.imsglobal.org/spec/lti/claim/message_type"];
155921
- const version6 = claims["https://purl.imsglobal.org/spec/lti/claim/version"];
155922
- if (messageType !== "LtiResourceLinkRequest") {
155923
- return `Invalid LTI message type: ${messageType}`;
155924
- }
155925
- if (version6 !== "1.3.0") {
155926
- return `Unsupported LTI version: ${version6}`;
155927
- }
155928
- return null;
155929
- }
155930
- var init_lti_util = () => {};
155931
-
155932
- // ../api-core/src/utils/lti-provisioning.ts
155933
- import * as crypto4 from "node:crypto";
155934
- async function provisionLtiUser(db2, claims) {
155935
- const database = db2;
155936
- const email5 = claims.email;
155937
- const ltiTimebackId = claims.sub;
155938
- const providerId = AUTH_PROVIDER_IDS.TIMEBACK_LTI;
155939
- if (!email5) {
155940
- throw new ValidationError("Email is required in LTI claims");
155941
- }
155942
- const existingAccount = await database.query.accounts.findFirst({
155943
- where: and(eq(accounts.accountId, ltiTimebackId), eq(accounts.providerId, providerId))
155944
- });
155945
- if (existingAccount) {
155946
- const user = await database.query.users.findFirst({
155947
- where: eq(users.id, existingAccount.userId)
155948
- });
155949
- if (user) {
155950
- setAttribute("app.lti.provision", "existing_account");
155951
- return user;
155952
- }
155953
- }
155954
- const existingUser = await database.query.users.findFirst({
155955
- where: eq(users.email, email5)
155956
- });
155957
- if (existingUser) {
155958
- await database.transaction(async (tx) => {
155959
- const existingLtiAccount = await tx.query.accounts.findFirst({
155960
- where: and(eq(accounts.userId, existingUser.id), eq(accounts.providerId, providerId))
155961
- });
155962
- if (!existingLtiAccount) {
155963
- const [account] = await tx.insert(accounts).values({
155964
- id: crypto4.randomUUID(),
155965
- userId: existingUser.id,
155966
- accountId: ltiTimebackId,
155967
- providerId,
155968
- accessToken: null,
155969
- refreshToken: null,
155970
- accessTokenExpiresAt: null,
155971
- refreshTokenExpiresAt: null,
155972
- createdAt: new Date,
155973
- updatedAt: new Date
155974
- }).returning({ id: accounts.id });
155975
- if (!account) {
155976
- throw new InternalError("Failed to link LTI account");
155977
- }
155978
- }
155979
- });
155980
- setAttribute("app.lti.provision", "linked_account");
155981
- return existingUser;
155982
- }
155983
- const newUserId = crypto4.randomUUID();
155984
- const createdUser = await database.transaction(async (tx) => {
155985
- const [insertedUser] = await tx.insert(users).values({
155986
- id: newUserId,
155987
- email: email5,
155988
- emailVerified: true,
155989
- username: generateUsername(email5),
155990
- name: claims.name || claims.given_name || email5.split("@")[0] || "Timeback User",
155991
- createdAt: new Date,
155992
- updatedAt: new Date
155993
- }).returning();
155994
- if (!insertedUser) {
155995
- throw new InternalError("Failed to create user");
155996
- }
155997
- await tx.insert(accounts).values({
155998
- id: crypto4.randomUUID(),
155999
- userId: newUserId,
156000
- accountId: ltiTimebackId,
156001
- providerId,
156002
- accessToken: null,
156003
- refreshToken: null,
156004
- accessTokenExpiresAt: null,
156005
- refreshTokenExpiresAt: null,
156006
- createdAt: new Date,
156007
- updatedAt: new Date
156008
- });
156009
- setAttribute("app.lti.provision", "created_user");
156010
- return insertedUser;
156011
- });
156012
- return createdUser;
156013
- }
156014
- var init_lti_provisioning = __esm(() => {
156015
- init_drizzle_orm();
156016
- init_src();
156017
- init_tables_index();
156018
- init_spans();
156019
- init_errors2();
156020
- init_lti_util();
156021
- });
156022
-
156023
- // ../api-core/src/utils/params.util.ts
156024
- function requireGameId(gameId) {
156025
- if (!gameId) {
156026
- throw ApiError.badRequest("Missing game ID");
156027
- }
156028
- if (!isValidUUID(gameId)) {
156029
- throw ApiError.unprocessableEntity("gameId must be a valid UUID format");
156030
- }
156031
- return gameId;
156032
- }
156033
- function requireSlug(slug2) {
156034
- if (!slug2) {
156035
- throw ApiError.badRequest("Missing game slug");
156036
- }
156037
- return slug2;
156038
- }
156039
- function requireUserId(userId) {
156040
- if (!userId) {
156041
- throw ApiError.badRequest("Missing user ID");
156042
- }
156043
- if (!isValidUUID(userId)) {
156044
- throw ApiError.unprocessableEntity("userId must be a valid UUID format");
156045
- }
156046
- return userId;
156047
- }
156048
- function parseLimitParam(url4, max2) {
156049
- const raw2 = url4.searchParams.get("limit");
156050
- if (raw2 === null) {
156051
- return;
156052
- }
156053
- const limit = Number(raw2);
156054
- if (!Number.isInteger(limit) || limit < 1 || limit > max2) {
156055
- throw ApiError.badRequest(`limit must be an integer between 1 and ${max2}`);
156056
- }
156057
- return limit;
156058
- }
156059
- var init_params_util = __esm(() => {
156060
- init_src9();
156061
- init_errors2();
156062
- });
156063
-
156064
- // ../api-core/src/utils/validation.util.ts
156065
- function formatZodError(error89) {
156066
- const flat = error89.flatten();
156067
- const result = {};
156068
- if (Object.keys(flat.fieldErrors).length > 0) {
156069
- result.fields = {};
156070
- for (const [field, messages] of Object.entries(flat.fieldErrors)) {
156071
- if (messages && messages.length > 0) {
156072
- result.fields[field] = messages[0];
156073
- }
156074
- }
156075
- }
156076
- if (flat.formErrors.length > 0) {
156077
- result.errors = flat.formErrors;
156078
- }
156079
- return result;
156080
- }
156081
- function recordValidationFailure(details) {
156082
- setAttribute("app.request.outcome", "validation_failed");
156083
- addEvent("request.validation_failed", {
156084
- "app.validation.error": JSON.stringify(details)
156085
- });
156086
- }
156087
- async function parseRequestBody(request, schema4) {
156088
- try {
156089
- return schema4.parse(await request.json());
156090
- } catch (error89) {
156091
- if (error89 instanceof exports_external.ZodError) {
156092
- const details = formatZodError(error89);
156093
- recordValidationFailure(details);
156094
- throw ApiError.unprocessableEntity("Validation failed", details);
156095
- }
156096
- throw ApiError.invalidJsonBody();
156097
- }
156098
- }
156099
- var init_validation_util = __esm(() => {
156100
- init_esm();
156101
- init_spans();
156102
- init_errors2();
156103
- });
156104
- // ../api-core/src/utils/index.ts
156105
- var init_utils11 = __esm(() => {
156106
- init_auth_util();
156107
- init_dashboard_util();
156108
- init_deployment_util();
156109
- init_leaderboard_util();
156110
- init_lti_util();
156111
- init_lti_provisioning();
156112
- init_params_util();
156113
- init_secrets_util();
156114
- init_timeback_util();
156115
- init_validation_util();
156116
- });
156117
-
156118
156523
  // ../api-core/src/controllers/bucket.controller.ts
156119
156524
  var listFiles, getFile, putFile, deleteFile, initiateUpload, bucket;
156120
156525
  var init_bucket_controller = __esm(() => {
156121
156526
  init_errors2();
156122
- init_utils11();
156527
+ init_utils7();
156123
156528
  listFiles = requireDeveloper(async (ctx) => {
156124
156529
  const slug2 = ctx.params.slug;
156125
156530
  if (!slug2) {
@@ -156211,7 +156616,7 @@ var listUsers, addUser, issueRecoveryLink, removeUser, remove, verifyLogin, acce
156211
156616
  var init_dashboard_controller = __esm(() => {
156212
156617
  init_schemas_index();
156213
156618
  init_errors2();
156214
- init_utils11();
156619
+ init_utils7();
156215
156620
  listUsers = requireHumanDeveloper(async (ctx) => {
156216
156621
  const slug2 = requireSlug(ctx.params.slug);
156217
156622
  const users2 = await ctx.services.dashboard.listUsers(slug2, ctx.user);
@@ -156283,7 +156688,7 @@ var init_database_controller = __esm(() => {
156283
156688
  init_esm();
156284
156689
  init_schemas_index();
156285
156690
  init_errors2();
156286
- init_utils11();
156691
+ init_utils7();
156287
156692
  reset = requireDeveloper(async (ctx) => {
156288
156693
  const slug2 = ctx.params.slug;
156289
156694
  if (!slug2) {
@@ -156346,7 +156751,7 @@ var init_deploy_controller = __esm(() => {
156346
156751
  init_esm();
156347
156752
  init_schemas_index();
156348
156753
  init_errors2();
156349
- init_utils11();
156754
+ init_utils7();
156350
156755
  deploy = defineControllerNames("deploy", {
156351
156756
  createJob: requireDeveloper(createJob),
156352
156757
  getJob: requireDeveloper(getJob)
@@ -156358,7 +156763,7 @@ var get, baseline, realignMigration, resolveMigration, history, restorePoints, r
156358
156763
  var init_deployment_state_controller = __esm(() => {
156359
156764
  init_schemas_index();
156360
156765
  init_errors2();
156361
- init_utils11();
156766
+ init_utils7();
156362
156767
  get = requireDeveloper(async (ctx) => {
156363
156768
  const slug2 = requireSlug(ctx.params.slug);
156364
156769
  const include = ctx.url.searchParams.getAll("include").flatMap((value) => value.split(",")).filter(Boolean);
@@ -156428,7 +156833,7 @@ var init_deployment_state_controller = __esm(() => {
156428
156833
  // ../api-core/src/controllers/developer.controller.ts
156429
156834
  var apply, getStatus, developer;
156430
156835
  var init_developer_controller = __esm(() => {
156431
- init_utils11();
156836
+ init_utils7();
156432
156837
  apply = requireNonAnonymous(async (ctx) => {
156433
156838
  await ctx.services.developer.apply(ctx.user);
156434
156839
  });
@@ -156449,7 +156854,7 @@ var init_domain_controller = __esm(() => {
156449
156854
  init_schemas_index();
156450
156855
  init_config2();
156451
156856
  init_errors2();
156452
- init_utils11();
156857
+ init_utils7();
156453
156858
  add = requireDeveloper(async (ctx) => {
156454
156859
  const slug2 = ctx.params.slug;
156455
156860
  if (!slug2) {
@@ -156523,7 +156928,7 @@ var listMembers, addMember, updateMemberRole, removeMember, searchUsersForMember
156523
156928
  var init_game_member_controller = __esm(() => {
156524
156929
  init_schemas_index();
156525
156930
  init_errors2();
156526
- init_utils11();
156931
+ init_utils7();
156527
156932
  listMembers = requireNonAnonymous(async (ctx) => {
156528
156933
  const gameId = requireGameId(ctx.params.gameId);
156529
156934
  return ctx.services.gameMember.list(gameId, ctx.user);
@@ -156564,7 +156969,7 @@ var init_game_controller = __esm(() => {
156564
156969
  init_esm();
156565
156970
  init_schemas_index();
156566
156971
  init_errors2();
156567
- init_utils11();
156972
+ init_utils7();
156568
156973
  init_auth_util();
156569
156974
  list2 = requireNonAnonymous(async (ctx) => ctx.services.game.list(ctx.user));
156570
156975
  listAccessible = requireNonAnonymous(async (ctx) => ctx.services.game.listAccessible(ctx.user));
@@ -156635,7 +157040,7 @@ var init_kv_controller = __esm(() => {
156635
157040
  init_esm();
156636
157041
  init_schemas_index();
156637
157042
  init_errors2();
156638
- init_utils11();
157043
+ init_utils7();
156639
157044
  listKeys = requireDeveloper(async (ctx) => {
156640
157045
  const slug2 = ctx.params.slug;
156641
157046
  if (!slug2) {
@@ -156739,7 +157144,7 @@ var init_leaderboard_controller = __esm(() => {
156739
157144
  init_esm();
156740
157145
  init_schemas_index();
156741
157146
  init_errors2();
156742
- init_utils11();
157147
+ init_utils7();
156743
157148
  submitScore = requireAuth(async (ctx) => {
156744
157149
  const gameId = ctx.params.gameId;
156745
157150
  if (!gameId) {
@@ -156848,7 +157253,7 @@ var init_leaderboard_controller = __esm(() => {
156848
157253
  var generateToken, logs;
156849
157254
  var init_logs_controller = __esm(() => {
156850
157255
  init_errors2();
156851
- init_utils11();
157256
+ init_utils7();
156852
157257
  generateToken = requireDeveloper(async (ctx) => {
156853
157258
  const slug2 = ctx.params.slug;
156854
157259
  if (!slug2) {
@@ -156883,7 +157288,7 @@ var init_logs_controller = __esm(() => {
156883
157288
  // ../api-core/src/controllers/lti.controller.ts
156884
157289
  var getStatus3, lti;
156885
157290
  var init_lti_controller = __esm(() => {
156886
- init_utils11();
157291
+ init_utils7();
156887
157292
  getStatus3 = requireNonAnonymous(async (ctx) => ctx.services.lti.getStatus(ctx.user));
156888
157293
  lti = defineControllerNames("lti", {
156889
157294
  getStatus: getStatus3
@@ -156896,7 +157301,7 @@ var init_secrets_controller = __esm(() => {
156896
157301
  init_esm();
156897
157302
  init_schemas_index();
156898
157303
  init_errors2();
156899
- init_utils11();
157304
+ init_utils7();
156900
157305
  listKeys2 = requireDeveloper(async (ctx) => {
156901
157306
  const slug2 = ctx.params.slug;
156902
157307
  if (!slug2) {
@@ -156959,7 +157364,7 @@ var init_seed_controller = __esm(() => {
156959
157364
  init_esm();
156960
157365
  init_schemas_index();
156961
157366
  init_errors2();
156962
- init_utils11();
157367
+ init_utils7();
156963
157368
  seed2 = requireDeveloper(async (ctx) => {
156964
157369
  const slug2 = ctx.params.slug;
156965
157370
  if (!slug2) {
@@ -156991,7 +157396,7 @@ var init_session_controller = __esm(() => {
156991
157396
  init_spans();
156992
157397
  init_tunnel();
156993
157398
  init_errors2();
156994
- init_utils11();
157399
+ init_utils7();
156995
157400
  MintTokenBody = exports_external.object({
156996
157401
  reason: exports_external.enum(["initial", "refresh_scheduled", "refresh_stale"]).optional()
156997
157402
  });
@@ -157040,7 +157445,7 @@ function parseQtiLibraryParams(searchParams) {
157040
157445
  limit
157041
157446
  };
157042
157447
  }
157043
- 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;
157448
+ 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;
157044
157449
  var init_timeback_controller = __esm(() => {
157045
157450
  init_esm();
157046
157451
  init_src();
@@ -157049,7 +157454,7 @@ var init_timeback_controller = __esm(() => {
157049
157454
  init_src9();
157050
157455
  init_timeback3();
157051
157456
  init_errors2();
157052
- init_utils11();
157457
+ init_utils7();
157053
157458
  populateStudent = requireNonAnonymous(async (ctx) => {
157054
157459
  let providedNames;
157055
157460
  try {
@@ -157714,6 +158119,14 @@ var init_timeback_controller = __esm(() => {
157714
158119
  const body2 = await parseRequestBody(ctx.request, UpdateAssessmentRequestSchema);
157715
158120
  return ctx.services.timebackAssessments.updateAssessment(integrationId, testIdentifier, body2);
157716
158121
  });
158122
+ updateReviewMapping = requireDeveloper(async (ctx) => {
158123
+ const { gameId, courseId, testIdentifier } = ctx.params;
158124
+ if (!gameId || !courseId || !testIdentifier) {
158125
+ throw ApiError.badRequest("Missing gameId, courseId, or testIdentifier parameter");
158126
+ }
158127
+ const integrationId = await ctx.services.timebackAssessments.resolveIntegrationId(gameId, courseId, ctx.user);
158128
+ return ctx.services.timebackAssessments.updateReviewMapping(integrationId, testIdentifier);
158129
+ });
157717
158130
  reorderAssessments = requireDeveloper(async (ctx) => {
157718
158131
  const { gameId, courseId } = ctx.params;
157719
158132
  if (!gameId || !courseId) {
@@ -157856,6 +158269,7 @@ var init_timeback_controller = __esm(() => {
157856
158269
  createAssessment,
157857
158270
  attachExistingAssessments,
157858
158271
  updateAssessment,
158272
+ updateReviewMapping,
157859
158273
  reorderAssessments,
157860
158274
  removeAssessment,
157861
158275
  reorderQuestions,
@@ -157875,7 +158289,7 @@ var init_upload_controller = __esm(() => {
157875
158289
  init_esm();
157876
158290
  init_schemas_index();
157877
158291
  init_errors2();
157878
- init_utils11();
158292
+ init_utils7();
157879
158293
  initiate = requireDeveloper(async (ctx) => {
157880
158294
  let body2;
157881
158295
  try {
@@ -157901,7 +158315,7 @@ var getMe, getDemoProfile, updateDemoProfile, users2;
157901
158315
  var init_user_controller = __esm(() => {
157902
158316
  init_src();
157903
158317
  init_schemas_index();
157904
- init_utils11();
158318
+ init_utils7();
157905
158319
  getMe = requireNonAnonymous(async (ctx) => ctx.services.user.getMe(ctx.user, ctx.gameId, ctx.request.headers.get(PLAYCADEMY_BROWSER_TIME_ZONE_HEADER)));
157906
158320
  getDemoProfile = requireAnonymous(async (ctx) => ctx.services.user.getDemoProfile(ctx.user.id));
157907
158321
  updateDemoProfile = requireAnonymous(async (ctx) => {
@@ -157936,7 +158350,7 @@ var init_verify_controller = __esm(() => {
157936
158350
  init_esm();
157937
158351
  init_schemas_index();
157938
158352
  init_errors2();
157939
- init_utils11();
158353
+ init_utils7();
157940
158354
  verify = defineControllerNames("verify", {
157941
158355
  verifyToken
157942
158356
  });
@@ -158125,7 +158539,7 @@ async function buildMockUserResponse(db2, user, gameId, observedTimeZone) {
158125
158539
  var LEARNING_TIME_ZONE_REFRESH_INTERVAL_MS2;
158126
158540
  var init_timeback7 = __esm(() => {
158127
158541
  init_drizzle_orm();
158128
- init_utils11();
158542
+ init_utils7();
158129
158543
  init_src();
158130
158544
  init_tables_index();
158131
158545
  init_src6();
@@ -158555,7 +158969,7 @@ var init_seed2 = __esm(async () => {
158555
158969
  init_dist7();
158556
158970
  init_esm();
158557
158971
  init_errors2();
158558
- init_utils11();
158972
+ init_utils7();
158559
158973
  init_schemas_index();
158560
158974
  await init_api3();
158561
158975
  gameSeedRouter = new Hono2;
@@ -158795,7 +159209,7 @@ var init_timeback8 = __esm(async () => {
158795
159209
  init_dist7();
158796
159210
  init_controllers();
158797
159211
  init_errors2();
158798
- init_utils11();
159212
+ init_utils7();
158799
159213
  init_src();
158800
159214
  init_schemas_index();
158801
159215
  init_timeback3();
@@ -159035,7 +159449,7 @@ var init_lti = __esm(async () => {
159035
159449
  init_drizzle_orm();
159036
159450
  init_dist7();
159037
159451
  init_controllers();
159038
- init_utils11();
159452
+ init_utils7();
159039
159453
  init_tables_index();
159040
159454
  init_src6();
159041
159455
  init_constants();