@housekit/kit 0.1.28 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +23 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8196,8 +8196,25 @@ async function loadSchema(schemaPath, options) {
8196
8196
  allFiles = allFiles.concat(files);
8197
8197
  }
8198
8198
  }
8199
- const foundTables = [];
8199
+ const filesByBaseName = new Map;
8200
+ const extensionPriority = { ".ts": 0, ".mjs": 1, ".cjs": 2, ".js": 3 };
8200
8201
  for (const file of allFiles) {
8202
+ const ext2 = extensions.find((e) => file.endsWith(e)) || ".js";
8203
+ const baseNameWithoutExt = file.slice(0, -ext2.length);
8204
+ const existing = filesByBaseName.get(baseNameWithoutExt);
8205
+ if (existing) {
8206
+ const existingExt = extensions.find((e) => existing.endsWith(e)) || ".js";
8207
+ if (extensionPriority[ext2] < extensionPriority[existingExt]) {
8208
+ filesByBaseName.set(baseNameWithoutExt, file);
8209
+ }
8210
+ } else {
8211
+ filesByBaseName.set(baseNameWithoutExt, file);
8212
+ }
8213
+ }
8214
+ const deduplicatedFiles = Array.from(filesByBaseName.values());
8215
+ const foundTables = [];
8216
+ const tableSourceFile = {};
8217
+ for (const file of deduplicatedFiles) {
8201
8218
  const fullPath = resolve2(process.cwd(), file);
8202
8219
  try {
8203
8220
  const module = await jiti.import(fullPath);
@@ -8205,9 +8222,13 @@ async function loadSchema(schemaPath, options) {
8205
8222
  if (value && typeof value === "object" && "toSQL" in value && "$columns" in value && "$table" in value) {
8206
8223
  const table = value;
8207
8224
  if (tables[table.$table]) {
8208
- throw new Error(`Duplicate: Table "${table.$table}" is defined multiple times.`);
8225
+ if (tables[table.$table] === table) {
8226
+ continue;
8227
+ }
8228
+ throw new Error(`Duplicate: Table "${table.$table}" is defined multiple times (in ${tableSourceFile[table.$table]} and ${file}).`);
8209
8229
  }
8210
8230
  tables[table.$table] = table;
8231
+ tableSourceFile[table.$table] = file;
8211
8232
  foundTables.push(`${table.$table}${key !== table.$table ? ` (${key})` : ""}`);
8212
8233
  }
8213
8234
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@housekit/kit",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "CLI tool for HouseKit - manage ClickHouse schemas, migrations, and database operations with type-safe workflows.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@clickhouse/client": "^1.14.0",
51
- "@housekit/orm": "^0.1.34",
51
+ "@housekit/orm": "^0.1.36",
52
52
  "boxen": "8.0.1",
53
53
  "chalk": "^5.6.2",
54
54
  "cli-table3": "^0.6.5",