aiex-cli 0.1.1-beta.6 → 0.1.1-beta.8

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 (118) hide show
  1. package/README.md +3 -3
  2. package/dist/cli.mjs +251 -323
  3. package/dist/{generate-drizzle-schema-DAeXmyrZ.mjs → generate-drizzle-schema-BcStmKUc.mjs} +275 -25
  4. package/dist/index.d.mts +2 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/infrastructure/schema/migrate-helper.mjs +1 -1
  7. package/dist/web/assets/DataBrowser-BGr3QUZO.css +1 -0
  8. package/dist/web/assets/DataBrowser-CDcSU_Cr.js +3 -0
  9. package/dist/web/assets/JsonSchemaEditor-p-bkrvS3.js +570 -0
  10. package/dist/web/assets/editor-D2tYHrWf.css +1 -0
  11. package/dist/web/assets/editor.api-BT2rf8f6.js +438 -0
  12. package/dist/web/assets/hoverContribution-CE0Jku7D.css +1 -0
  13. package/dist/web/assets/hoverContribution-LAh7vfny.js +1 -0
  14. package/dist/web/assets/{index-C2XZlABi.css → index-C_CYtI17.css} +1 -1
  15. package/dist/web/assets/{index-CuCVFoOf.js → index-UGHdtCGb.js} +2 -2
  16. package/dist/web/assets/{jsonMode-B4jaPYEr.js → jsonMode-alfaQCdM.js} +1 -1
  17. package/dist/web/assets/markers-Bp6AHK9A.css +1 -0
  18. package/dist/web/assets/markers-CggdBp2p.js +205 -0
  19. package/dist/web/assets/monaco.contribution-CNX4GSi9.js +2 -0
  20. package/dist/web/assets/xlsx-MTXtKFHS.js +105 -0
  21. package/dist/web/index.html +2 -2
  22. package/package.json +1 -1
  23. package/dist/web/assets/DataBrowser-BqRaZJrX.js +0 -97
  24. package/dist/web/assets/DataBrowser-DZT0kGQE.css +0 -1
  25. package/dist/web/assets/JsonSchemaEditor-JYjm5q34.js +0 -570
  26. package/dist/web/assets/abap-Bgec7Keq.js +0 -1
  27. package/dist/web/assets/apex-VBlPwEoQ.js +0 -1
  28. package/dist/web/assets/azcli-DKqrEFBx.js +0 -1
  29. package/dist/web/assets/bat-DdgQWy_0.js +0 -1
  30. package/dist/web/assets/bicep-CRMM43EB.js +0 -2
  31. package/dist/web/assets/cameligo-UatALtML.js +0 -1
  32. package/dist/web/assets/clojure-D8JU08RA.js +0 -1
  33. package/dist/web/assets/coffee-C56wu358.js +0 -1
  34. package/dist/web/assets/cpp-CyZLvhJG.js +0 -1
  35. package/dist/web/assets/csharp-BJl3ixva.js +0 -1
  36. package/dist/web/assets/csp-CxEKxmO-.js +0 -1
  37. package/dist/web/assets/css-B0t_muXd.js +0 -3
  38. package/dist/web/assets/cssMode-CPThwItX.js +0 -4
  39. package/dist/web/assets/cypher-D1hqiMFD.js +0 -1
  40. package/dist/web/assets/dart-Bz550Pyv.js +0 -1
  41. package/dist/web/assets/dockerfile-CIXgVAuA.js +0 -1
  42. package/dist/web/assets/ecl-D9qbvZoA.js +0 -1
  43. package/dist/web/assets/editor-BR-TvLsg.css +0 -1
  44. package/dist/web/assets/editor-DPKWm9GW.css +0 -1
  45. package/dist/web/assets/editor.api-C8BHpRhn.js +0 -642
  46. package/dist/web/assets/editor.main-DQ658ZNP.js +0 -53
  47. package/dist/web/assets/elixir-b2M38fAy.js +0 -1
  48. package/dist/web/assets/flow9-Dq1UYMkt.js +0 -1
  49. package/dist/web/assets/freemarker2-DWDTYVJR.js +0 -3
  50. package/dist/web/assets/fsharp-BaeLhgfq.js +0 -1
  51. package/dist/web/assets/go-Bd-NFKIC.js +0 -1
  52. package/dist/web/assets/graphql-DZVerJfy.js +0 -1
  53. package/dist/web/assets/handlebars-D4DzjGQ7.js +0 -1
  54. package/dist/web/assets/hcl-CAVzrZfH.js +0 -1
  55. package/dist/web/assets/html-DnzhKSoD.js +0 -1
  56. package/dist/web/assets/htmlMode-CR7UKfEH.js +0 -4
  57. package/dist/web/assets/ini-CyXdX58t.js +0 -1
  58. package/dist/web/assets/java-B5pNgvhy.js +0 -1
  59. package/dist/web/assets/javascript-D2srszZ8.js +0 -1
  60. package/dist/web/assets/julia-XRhmV3AN.js +0 -1
  61. package/dist/web/assets/kotlin-DOd3J5vr.js +0 -1
  62. package/dist/web/assets/less-veZSnyw6.js +0 -2
  63. package/dist/web/assets/lexon-QWGkuK0H.js +0 -1
  64. package/dist/web/assets/liquid-CIT2Wl_l.js +0 -1
  65. package/dist/web/assets/lua-CYGpjuO5.js +0 -1
  66. package/dist/web/assets/m3-yNnrZkdc.js +0 -1
  67. package/dist/web/assets/markdown-BCSWEPSX.js +0 -1
  68. package/dist/web/assets/mdx-CWLaEOFy.js +0 -1
  69. package/dist/web/assets/mips-OpYmcC30.js +0 -1
  70. package/dist/web/assets/monaco.contribution-BJhODGkt.js +0 -2
  71. package/dist/web/assets/msdax-2oxoTO9Z.js +0 -1
  72. package/dist/web/assets/mysql-5KlC-K_9.js +0 -1
  73. package/dist/web/assets/objective-c-CcDCgtLx.js +0 -1
  74. package/dist/web/assets/pascal-BZGsbaEV.js +0 -1
  75. package/dist/web/assets/pascaligo-DtD5qU3G.js +0 -1
  76. package/dist/web/assets/perl-C1jNNS3E.js +0 -1
  77. package/dist/web/assets/pgsql-CT0fhiZa.js +0 -1
  78. package/dist/web/assets/php-D6DrXoPM.js +0 -1
  79. package/dist/web/assets/pla-b3-HN2pF.js +0 -1
  80. package/dist/web/assets/postiats-Bin2ApVS.js +0 -1
  81. package/dist/web/assets/powerquery-7ASnn-ZG.js +0 -1
  82. package/dist/web/assets/powershell-t4p7sU1H.js +0 -1
  83. package/dist/web/assets/primeicons-DMOk5skT.eot +0 -0
  84. package/dist/web/assets/primeicons-Dr5RGzOO.svg +0 -345
  85. package/dist/web/assets/primeicons-MpK4pl85.ttf +0 -0
  86. package/dist/web/assets/primeicons-WjwUDZjB.woff +0 -0
  87. package/dist/web/assets/protobuf-BUGeWa_j.js +0 -2
  88. package/dist/web/assets/pug-BuKcgC9s.js +0 -1
  89. package/dist/web/assets/python-6CGfpCNq.js +0 -1
  90. package/dist/web/assets/qsharp-DxLLX8mo.js +0 -1
  91. package/dist/web/assets/r-DMlFgn7A.js +0 -1
  92. package/dist/web/assets/razor-DEMMh3TD.js +0 -1
  93. package/dist/web/assets/redis-cXItkC5u.js +0 -1
  94. package/dist/web/assets/redshift-BZVbW7HE.js +0 -1
  95. package/dist/web/assets/restructuredtext-BzjxwS8h.js +0 -1
  96. package/dist/web/assets/ruby-C5nyLV4l.js +0 -1
  97. package/dist/web/assets/rust-BcmMsHdf.js +0 -1
  98. package/dist/web/assets/sb-Dnb1iy6B.js +0 -1
  99. package/dist/web/assets/scala-anMIFYpA.js +0 -1
  100. package/dist/web/assets/scheme-BItQTe08.js +0 -1
  101. package/dist/web/assets/scss-BOv51BJ5.js +0 -3
  102. package/dist/web/assets/shell-BsRYRTNN.js +0 -1
  103. package/dist/web/assets/solidity-BtuLgGDx.js +0 -1
  104. package/dist/web/assets/sophia-B0Vkc5MF.js +0 -1
  105. package/dist/web/assets/sparql-B7lvkZQM.js +0 -1
  106. package/dist/web/assets/sql-DvP5MpA3.js +0 -1
  107. package/dist/web/assets/st-GVUeyB3U.js +0 -1
  108. package/dist/web/assets/swift-DSPIoCjm.js +0 -1
  109. package/dist/web/assets/systemverilog-Icj2-k23.js +0 -1
  110. package/dist/web/assets/tcl-Cd8KQcm-.js +0 -1
  111. package/dist/web/assets/tsMode-D6_qJNEr.js +0 -11
  112. package/dist/web/assets/twig-CBHmt8z3.js +0 -1
  113. package/dist/web/assets/typescript-BM9aPEFg.js +0 -1
  114. package/dist/web/assets/typespec-Ckc037mq.js +0 -1
  115. package/dist/web/assets/vb-B97GW9Wb.js +0 -1
  116. package/dist/web/assets/wgsl-DIKmb3YH.js +0 -298
  117. package/dist/web/assets/xml-CoSbvcg5.js +0 -1
  118. package/dist/web/assets/yaml-56GOgy8k.js +0 -1
@@ -3,15 +3,16 @@ import os from "node:os";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
5
  import { fileURLToPath } from "node:url";
6
- import Database from "better-sqlite3";
7
6
  import { execa } from "execa";
8
7
  import { readFile, writeFile } from "jsonfile";
9
8
  import Conf from "conf";
10
9
  import { z } from "zod";
10
+ import Database from "better-sqlite3";
11
+ import { Kysely, SqliteDialect, sql } from "kysely";
11
12
 
12
13
  //#region package.json
13
14
  var name = "aiex-cli";
14
- var version = "0.1.1-beta.6";
15
+ var version = "0.1.1-beta.8";
15
16
  var description = "JSON Schema → SQLite with AI-powered data extraction";
16
17
  var package_default = {
17
18
  name,
@@ -452,15 +453,15 @@ function describeColumnType(columnType) {
452
453
  switch (columnType.class) {
453
454
  case "text": return {
454
455
  drizzleType: columnType.mode === "json" ? `text({ mode: 'json' })` : "text()",
455
- sqliteType: "text"
456
+ databaseType: "text"
456
457
  };
457
458
  case "integer": return {
458
459
  drizzleType: columnType.mode ? `integer({ mode: '${columnType.mode}' })` : "integer()",
459
- sqliteType: "integer"
460
+ databaseType: "integer"
460
461
  };
461
462
  case "real": return {
462
463
  drizzleType: "real()",
463
- sqliteType: "real"
464
+ databaseType: "real"
464
465
  };
465
466
  }
466
467
  }
@@ -480,7 +481,7 @@ function mapColumnToReport(schemaPath, table, property, column, relation) {
480
481
  table,
481
482
  column: column.name,
482
483
  drizzleType: columnType.drizzleType,
483
- sqliteType: columnType.sqliteType,
484
+ databaseType: columnType.databaseType,
484
485
  nullable: column.isNullable,
485
486
  primary: column.isPrimary,
486
487
  unique: column.isUnique,
@@ -586,7 +587,7 @@ function parseNestedObject(propName, property, parentTableName, warnings, mappin
586
587
  table: nestedTableName,
587
588
  column: "id",
588
589
  drizzleType: "integer().primaryKey({ autoIncrement: true })",
589
- sqliteType: "integer",
590
+ databaseType: "integer",
590
591
  nullable: false,
591
592
  primary: true,
592
593
  unique: false,
@@ -611,7 +612,7 @@ function parseNestedObject(propName, property, parentTableName, warnings, mappin
611
612
  table: nestedTableName,
612
613
  column: `${parentTableName}_id`,
613
614
  drizzleType: "integer().references(...)",
614
- sqliteType: "integer",
615
+ databaseType: "integer",
615
616
  nullable: false,
616
617
  primary: false,
617
618
  unique: false,
@@ -916,6 +917,262 @@ async function addToGitignore(aiexDir, fileName) {
916
917
  }
917
918
  }
918
919
 
920
+ //#endregion
921
+ //#region src/infrastructure/extraction/insert-extracted-data.ts
922
+ function convertValue(value, column) {
923
+ if (value === null || value === void 0) return null;
924
+ const mode = column.columnType.class !== "real" ? column.columnType.mode : void 0;
925
+ if (mode === "json") return typeof value === "string" ? value : JSON.stringify(value);
926
+ if (mode === "boolean") return value ? 1 : 0;
927
+ if (mode === "timestamp" || mode === "timestamp_ms") {
928
+ if (typeof value === "string") {
929
+ const ms = Date.parse(value);
930
+ if (Number.isNaN(ms)) return value;
931
+ return mode === "timestamp_ms" ? ms : Math.floor(ms / 1e3);
932
+ }
933
+ return value;
934
+ }
935
+ return value;
936
+ }
937
+ function buildInsertSql(table, data) {
938
+ const columns = [];
939
+ const values = [];
940
+ for (const col of table.columns) {
941
+ if (col.isAutoIncrement) continue;
942
+ const value = data[col.name];
943
+ if (value === void 0) {
944
+ if (col.default !== void 0) {
945
+ columns.push(col.name);
946
+ values.push(convertValue(col.default, col));
947
+ }
948
+ continue;
949
+ }
950
+ columns.push(col.name);
951
+ values.push(convertValue(value, col));
952
+ }
953
+ const placeholders = values.map(() => "?").join(", ");
954
+ return {
955
+ sql: `INSERT INTO ${table.name} (${columns.join(", ")}) VALUES (${placeholders})`,
956
+ values
957
+ };
958
+ }
959
+ function insertTableRow({ db, table, data, parentRowId, foreignKeyColumn }) {
960
+ const rowData = { ...data };
961
+ if (parentRowId !== void 0 && foreignKeyColumn) rowData[foreignKeyColumn] = parentRowId;
962
+ const { sql: sql$1, values } = buildInsertSql(table, rowData);
963
+ const info = db.prepare(sql$1).run(...values);
964
+ return Number(info.lastInsertRowid);
965
+ }
966
+ function parseDataByColumns(data, schema, table) {
967
+ const result = {};
968
+ if ("properties" in schema) {
969
+ const s = schema;
970
+ for (const [propName, prop] of Object.entries(s.properties)) {
971
+ if (prop.nested?.enabled) continue;
972
+ if (prop.type === "array" && prop.items?.nested?.enabled) continue;
973
+ const colName = toSnakeCase(propName);
974
+ if (table.columns.some((c) => c.name === colName && c.isAutoIncrement)) continue;
975
+ if (propName in data) result[colName] = data[propName];
976
+ }
977
+ }
978
+ if (schema.table?.timestamps) {
979
+ if (!("created_at" in result)) result.created_at = Math.floor(Date.now() / 1e3);
980
+ if (!("updated_at" in result)) result.updated_at = Math.floor(Date.now() / 1e3);
981
+ }
982
+ return result;
983
+ }
984
+ function insertExtractedData(db, schema, data) {
985
+ const inserted = [];
986
+ try {
987
+ const parseResult = parseJsonSchema(schema);
988
+ const mainTable = parseResult.tables[0];
989
+ db.transaction(() => {
990
+ const mainRowId = insertTableRow({
991
+ db,
992
+ table: mainTable,
993
+ data: parseDataByColumns(data, schema, mainTable)
994
+ });
995
+ inserted.push({
996
+ table: mainTable.name,
997
+ rowId: mainRowId
998
+ });
999
+ for (const revRel of parseResult.reverseRelations) {
1000
+ const rel = parseResult.relations.find((r) => r.fromTable === revRel.toTable && r.toTable === revRel.fromTable);
1001
+ if (!rel) continue;
1002
+ const propEntry = Object.entries(schema.properties).find(([key]) => toSnakeCase(key) === revRel.name && key in data);
1003
+ if (!propEntry) continue;
1004
+ const [propName] = propEntry;
1005
+ const nestedValue = data[propName];
1006
+ if (nestedValue === null || nestedValue === void 0) continue;
1007
+ const nestedTable = parseResult.tables.find((t$1) => t$1.name === revRel.toTable);
1008
+ if (!nestedTable) continue;
1009
+ if (revRel.type === "has-one") {
1010
+ const rowId = insertTableRow({
1011
+ db,
1012
+ table: nestedTable,
1013
+ data: parseDataByColumns(nestedValue, schema.properties[propName], nestedTable),
1014
+ parentRowId: mainRowId,
1015
+ foreignKeyColumn: rel.fromColumn
1016
+ });
1017
+ inserted.push({
1018
+ table: revRel.toTable,
1019
+ rowId
1020
+ });
1021
+ } else if (revRel.type === "has-many") {
1022
+ const items = nestedValue;
1023
+ for (const item of items) {
1024
+ const rowId = insertTableRow({
1025
+ db,
1026
+ table: nestedTable,
1027
+ data: parseDataByColumns(item, schema.properties[propName].items, nestedTable),
1028
+ parentRowId: mainRowId,
1029
+ foreignKeyColumn: rel.fromColumn
1030
+ });
1031
+ inserted.push({
1032
+ table: revRel.toTable,
1033
+ rowId
1034
+ });
1035
+ }
1036
+ }
1037
+ }
1038
+ return mainRowId;
1039
+ })();
1040
+ return {
1041
+ success: true,
1042
+ tablesInserted: inserted
1043
+ };
1044
+ } catch (e) {
1045
+ return {
1046
+ success: false,
1047
+ tablesInserted: inserted,
1048
+ error: e instanceof Error ? e.message : String(e)
1049
+ };
1050
+ }
1051
+ }
1052
+
1053
+ //#endregion
1054
+ //#region src/infrastructure/database/sqlite-database.ts
1055
+ const INTERNAL_ROWID_COLUMN = "__aiex_rowid";
1056
+ function createReadonlyQueryDb(databasePath) {
1057
+ return new Kysely({ dialect: new SqliteDialect({ database: new Database(databasePath, { readonly: true }) }) });
1058
+ }
1059
+ var SqliteProjectDatabase = class {
1060
+ dialect = "sqlite";
1061
+ constructor(databasePath) {
1062
+ this.databasePath = databasePath;
1063
+ }
1064
+ async exists() {
1065
+ try {
1066
+ return (await fs.stat(this.databasePath)).isFile();
1067
+ } catch {
1068
+ return false;
1069
+ }
1070
+ }
1071
+ async listTableNames() {
1072
+ let db = null;
1073
+ try {
1074
+ db = createReadonlyQueryDb(this.databasePath);
1075
+ return (await sql`
1076
+ select name
1077
+ from sqlite_master
1078
+ where type = 'table' and name not like 'sqlite_%' and name not like '_%'
1079
+ order by name
1080
+ `.execute(db)).rows.map((row) => row.name);
1081
+ } finally {
1082
+ await db?.destroy();
1083
+ }
1084
+ }
1085
+ async verifyTables(tableNames) {
1086
+ const db = new Database(this.databasePath, { readonly: true });
1087
+ try {
1088
+ const missing = tableNames.filter((table) => {
1089
+ return !db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name=?`).get(table);
1090
+ });
1091
+ return {
1092
+ ok: missing.length === 0,
1093
+ missing
1094
+ };
1095
+ } catch (error) {
1096
+ return {
1097
+ ok: false,
1098
+ missing: [],
1099
+ error: error instanceof Error ? error.message : String(error)
1100
+ };
1101
+ } finally {
1102
+ db.close();
1103
+ }
1104
+ }
1105
+ insertExtracted(schema, data) {
1106
+ const db = new Database(this.databasePath);
1107
+ try {
1108
+ return insertExtractedData(db, schema, data);
1109
+ } finally {
1110
+ db.close();
1111
+ }
1112
+ }
1113
+ async readTableRows(query) {
1114
+ const { tableName, page, pageSize, search, sortField, sortOrder, all } = query;
1115
+ const db = createReadonlyQueryDb(this.databasePath);
1116
+ try {
1117
+ if ((await sql`
1118
+ select name
1119
+ from sqlite_master
1120
+ where type = 'table' and name = ${tableName}
1121
+ `.execute(db)).rows.length === 0) throw new Error(`Table not found: ${tableName}`);
1122
+ const columns = (await sql`
1123
+ pragma table_info(${sql.table(tableName)})
1124
+ `.execute(db)).rows.map((col) => ({
1125
+ name: col.name,
1126
+ type: col.type,
1127
+ notNull: !!col.notnull,
1128
+ pk: !!col.pk
1129
+ }));
1130
+ const searchConditions = columns.map((col) => sql`${sql.ref(col.name)} like ${`%${search}%`}`);
1131
+ const searchCondition = search ? sql`where ${sql.join(searchConditions, sql` or `)}` : sql``;
1132
+ const sortColumn = columns.find((col) => col.name === sortField);
1133
+ const orderBy = sortColumn ? sql`order by ${sql.ref(sortColumn.name)} ${sql.raw(sortOrder === "desc" ? "desc" : "asc")}` : sql``;
1134
+ const total = (await sql`
1135
+ select count(*) as count
1136
+ from ${sql.table(tableName)}
1137
+ ${searchCondition}
1138
+ `.execute(db)).rows[0]?.count ?? 0;
1139
+ const offset = (page - 1) * pageSize;
1140
+ const totalPages = all ? 1 : Math.max(1, Math.ceil(total / pageSize));
1141
+ const result = all ? await sql`
1142
+ select rowid as ${sql.raw(INTERNAL_ROWID_COLUMN)}, *
1143
+ from ${sql.table(tableName)}
1144
+ ${searchCondition}
1145
+ ${orderBy}
1146
+ `.execute(db) : await sql`
1147
+ select rowid as ${sql.raw(INTERNAL_ROWID_COLUMN)}, *
1148
+ from ${sql.table(tableName)}
1149
+ ${searchCondition}
1150
+ ${orderBy}
1151
+ limit ${pageSize}
1152
+ offset ${offset}
1153
+ `.execute(db);
1154
+ const rowIds = result.rows.map((row) => {
1155
+ const rowId = row[INTERNAL_ROWID_COLUMN];
1156
+ return rowId === null || rowId === void 0 ? void 0 : String(rowId);
1157
+ });
1158
+ return {
1159
+ columns,
1160
+ rows: result.rows.map(({ [INTERNAL_ROWID_COLUMN]: _rowid, ...row }) => row),
1161
+ rowIds,
1162
+ total,
1163
+ page,
1164
+ pageSize,
1165
+ totalPages
1166
+ };
1167
+ } finally {
1168
+ await db.destroy();
1169
+ }
1170
+ }
1171
+ };
1172
+ function createProjectDatabase(config) {
1173
+ return new SqliteProjectDatabase(config.databasePath);
1174
+ }
1175
+
919
1176
  //#endregion
920
1177
  //#region src/locales/en.ts
921
1178
  const en = {
@@ -1498,6 +1755,7 @@ async function checkImageOcrAvailability(imagePath, runtime = defaultRuntime) {
1498
1755
  //#region src/infrastructure/schema/migration-config.ts
1499
1756
  function createMigrationConfig(cwd) {
1500
1757
  return {
1758
+ databaseDialect: "sqlite",
1501
1759
  schemaPath: `${cwd}/.aiex/schema`,
1502
1760
  drizzleSchemaPath: `${cwd}/.aiex/drizzle/schema.ts`,
1503
1761
  migrationsPath: `${cwd}/.aiex/migrations`,
@@ -1636,26 +1894,18 @@ async function collectDoctorDiagnostics(options = {}) {
1636
1894
  error: error instanceof Error ? error.message : String(error)
1637
1895
  });
1638
1896
  }
1639
- let dbExists = false;
1640
- if (dirExists) try {
1641
- dbExists = (await fs.stat(migConfig.databasePath)).isFile();
1642
- } catch {
1643
- dbExists = false;
1644
- }
1897
+ const database = createProjectDatabase(migConfig);
1898
+ const dbExists = dirExists ? await database.exists() : false;
1645
1899
  let databaseTablesOk = null;
1646
1900
  let missingDatabaseTables = [];
1647
1901
  if (dbExists && expectedTables.size > 0) {
1648
- const db = new Database(migConfig.databasePath, { readonly: true });
1649
- try {
1650
- missingDatabaseTables = [...expectedTables].filter((table) => {
1651
- return !db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name=?`).get(table);
1652
- });
1653
- databaseTablesOk = missingDatabaseTables.length === 0;
1654
- } catch (error) {
1902
+ const tableCheck = await database.verifyTables([...expectedTables]);
1903
+ if (tableCheck.error) {
1655
1904
  databaseTablesOk = false;
1656
- errors.push(`Could not inspect database tables: ${error instanceof Error ? error.message : String(error)}`);
1657
- } finally {
1658
- db.close();
1905
+ errors.push(`Could not inspect database tables: ${tableCheck.error}`);
1906
+ } else {
1907
+ missingDatabaseTables = tableCheck.missing;
1908
+ databaseTablesOk = tableCheck.ok;
1659
1909
  }
1660
1910
  } else if (dbExists) databaseTablesOk = true;
1661
1911
  let migrationCount = 0;
@@ -1807,4 +2057,4 @@ function generateDrizzleSchema(result) {
1807
2057
  }
1808
2058
 
1809
2059
  //#endregion
1810
- export { seedConfig as A, CORRECTION_SYSTEM_PROMPT as C, PLACEHOLDER_TEXT as D, PLACEHOLDER_SCHEMA as E, name as M, package_default as N, buildCorrectionUserPrompt as O, version as P, DEFAULT_MINERU_CONFIG as S, EVIDENCE_INSTRUCTIONS as T, doctorDiagnosticsSeverityRows as _, recognizeImageText as a, DEFAULT_LITEPARSE_CONFIG as b, t as c, writeAIConfig as d, AIConfigSchema as f, buildDoctorDiagnostics as g, toSnakeCase as h, generateDrizzleConfig as i, description as j, createConfig as k, getDefaultAIConfig as l, parseJsonSchema as m, collectDoctorDiagnostics as n, shouldUseImageOcrFallback as o, JsonSchemaDefinitionSchema as p, createMigrationConfig as r, initI18n as s, generateDrizzleSchema as t, readAIConfig as u, doctorDiagnosticsTableRows as v, DEFAULT_PROMPT_CONFIG as w, DEFAULT_MINERU_API_CONFIG as x, formatDoctorDiagnosticsJson as y };
2060
+ export { seedConfig as A, CORRECTION_SYSTEM_PROMPT as C, PLACEHOLDER_TEXT as D, PLACEHOLDER_SCHEMA as E, name as M, package_default as N, buildCorrectionUserPrompt as O, version as P, DEFAULT_MINERU_CONFIG as S, EVIDENCE_INSTRUCTIONS as T, doctorDiagnosticsSeverityRows as _, recognizeImageText as a, DEFAULT_LITEPARSE_CONFIG as b, t as c, readAIConfig as d, writeAIConfig as f, buildDoctorDiagnostics as g, parseJsonSchema as h, generateDrizzleConfig as i, description as j, createConfig as k, createProjectDatabase as l, JsonSchemaDefinitionSchema as m, collectDoctorDiagnostics as n, shouldUseImageOcrFallback as o, AIConfigSchema as p, createMigrationConfig as r, initI18n as s, generateDrizzleSchema as t, getDefaultAIConfig as u, doctorDiagnosticsTableRows as v, DEFAULT_PROMPT_CONFIG as w, DEFAULT_MINERU_API_CONFIG as x, formatDoctorDiagnosticsJson as y };
package/dist/index.d.mts CHANGED
@@ -326,7 +326,7 @@ interface SchemaMappingEntry {
326
326
  table: string;
327
327
  column: string;
328
328
  drizzleType: string;
329
- sqliteType: 'text' | 'integer' | 'real';
329
+ databaseType: 'text' | 'integer' | 'real';
330
330
  nullable: boolean;
331
331
  primary: boolean;
332
332
  unique: boolean;
@@ -362,6 +362,7 @@ interface ParseResult {
362
362
  mapping?: SchemaMappingEntry[];
363
363
  }
364
364
  interface MigrationConfig {
365
+ databaseDialect: 'sqlite';
365
366
  schemaPath: string;
366
367
  drizzleSchemaPath: string;
367
368
  migrationsPath: string;
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as doctorDiagnosticsSeverityRows, g as buildDoctorDiagnostics, i as generateDrizzleConfig, m as parseJsonSchema, n as collectDoctorDiagnostics, p as JsonSchemaDefinitionSchema, r as createMigrationConfig, t as generateDrizzleSchema, v as doctorDiagnosticsTableRows, y as formatDoctorDiagnosticsJson } from "./generate-drizzle-schema-DAeXmyrZ.mjs";
1
+ import { _ as doctorDiagnosticsSeverityRows, g as buildDoctorDiagnostics, h as parseJsonSchema, i as generateDrizzleConfig, m as JsonSchemaDefinitionSchema, n as collectDoctorDiagnostics, r as createMigrationConfig, t as generateDrizzleSchema, v as doctorDiagnosticsTableRows, y as formatDoctorDiagnosticsJson } from "./generate-drizzle-schema-BcStmKUc.mjs";
2
2
 
3
3
  export { JsonSchemaDefinitionSchema, buildDoctorDiagnostics, collectDoctorDiagnostics, createMigrationConfig, doctorDiagnosticsSeverityRows, doctorDiagnosticsTableRows, formatDoctorDiagnosticsJson, generateDrizzleConfig, generateDrizzleSchema, parseJsonSchema };
@@ -3,8 +3,8 @@ import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
5
  import { fileURLToPath } from "node:url";
6
- import Database from "better-sqlite3";
7
6
  import { readFile, writeFile } from "jsonfile";
7
+ import Database from "better-sqlite3";
8
8
  import * as esbuild from "esbuild";
9
9
  import lockfile from "proper-lockfile";
10
10