orchid-orm 1.5.14 → 1.5.16

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.
package/dist/index.mjs CHANGED
@@ -1644,7 +1644,7 @@ const updateMainFile = async (filePath, tablePath, ast, options) => {
1644
1644
  };
1645
1645
  const createTable$1 = ({ filePath, tablePath, statements, object, content, spaces }, ast) => {
1646
1646
  const key = toCamelCase(ast.name);
1647
- const value = toPascalCase(ast.name);
1647
+ const value = `${toPascalCase(ast.name)}Table`;
1648
1648
  const changes = new FileChanges(content);
1649
1649
  const importPath = getImportPath(filePath, tablePath(ast.name));
1650
1650
  const importPos = ts.import.getEndPos(statements);
@@ -1667,7 +1667,7 @@ ${spaces}`;
1667
1667
  const dropTable = ({ filePath, tablePath, statements, object, content }, ast) => {
1668
1668
  const changes = new FileChanges(content);
1669
1669
  const importPath = getImportPath(filePath, tablePath(ast.name));
1670
- const tableClassName = toPascalCase(ast.name);
1670
+ const tableClassName = `${toPascalCase(ast.name)}Table`;
1671
1671
  const importNames = [];
1672
1672
  for (const node of ts.import.iterateWithSource(statements, importPath)) {
1673
1673
  changes.remove(node.pos, node.end);
@@ -1747,12 +1747,18 @@ const createTable = async (_a) => {
1747
1747
  const code = [
1748
1748
  `import { ${params.baseTableName} } from '${baseTablePath}';
1749
1749
  `,
1750
- `export class ${toPascalCase(ast.name)} extends ${params.baseTableName} {`,
1750
+ `export class ${toPascalCase(ast.name)}Table extends ${params.baseTableName} {`,
1751
1751
  props,
1752
1752
  "}\n"
1753
1753
  ];
1754
1754
  await fs.mkdir(path__default.dirname(tablePath), { recursive: true });
1755
- await fs.writeFile(tablePath, codeToString(code, "", " "));
1755
+ try {
1756
+ await fs.writeFile(tablePath, codeToString(code, "", " "), { flag: "wx" });
1757
+ } catch (err) {
1758
+ if (err.code !== "EEXIST") {
1759
+ throw err;
1760
+ }
1761
+ }
1756
1762
  };
1757
1763
 
1758
1764
  var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
@@ -1782,7 +1788,7 @@ const changeTable = async (_a) => {
1782
1788
  return;
1783
1789
  const changes = new FileChanges(content);
1784
1790
  const statements = ts.getStatements(content);
1785
- const className = toPascalCase(ast.name);
1791
+ const className = toPascalCase(ast.name) + "Table";
1786
1792
  for (const { t, object } of iterateColumnsShapes(statements, className)) {
1787
1793
  const context = makeChangeContext(changes, ast, content, object, t);
1788
1794
  prependSpaces(context);
@@ -2193,7 +2199,7 @@ const renameTable = async (_a) => {
2193
2199
  return;
2194
2200
  const changes = new FileChanges(content);
2195
2201
  const statements = ts.getStatements(content);
2196
- const className = toPascalCase(ast.from);
2202
+ const className = toPascalCase(ast.from) + "Table";
2197
2203
  const changeSchema = ast.fromSchema !== ast.toSchema;
2198
2204
  for (const node of ts.class.iterate(statements)) {
2199
2205
  if (((_a2 = node.name) == null ? void 0 : _a2.escapedText) !== className)
@@ -2228,7 +2234,7 @@ const renameTable = async (_a) => {
2228
2234
  }
2229
2235
  }
2230
2236
  }
2231
- await fs.writeFile(params.tablePath(ast.to), changes.apply());
2237
+ await fs.writeFile(tablePath, changes.apply());
2232
2238
  };
2233
2239
 
2234
2240
  var __defProp$1 = Object.defineProperty;