orchid-orm 1.6.19 → 1.6.22
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.js +11 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { columnTypes, getColumnTypes, addQueryOn, VirtualColumn, pushQueryValue, isQueryReturnsAll, getQueryAs, toSqlCacheKey, NotFoundError, relationQueryKey, Db, Adapter, anyShape, getClonedQueryData, columnsShapeToCode, primaryKeyToCode, indexToCode, foreignKeyToCode, columnIndexesToCode, columnForeignKeysToCode, columnCheckToCode } from 'pqb';
|
|
2
2
|
export { columnTypes } from 'pqb';
|
|
3
|
-
import { snakeCaseKey, toSnakeCase, emptyObject, pathToLog, singleQuote, codeToString, quoteObjectKey, addCode, columnDefaultArgumentToCode } from 'orchid-core';
|
|
3
|
+
import { snakeCaseKey, toSnakeCase, emptyObject, pathToLog, toCamelCase, toPascalCase, singleQuote, codeToString, quoteObjectKey, addCode, columnDefaultArgumentToCode } from 'orchid-core';
|
|
4
4
|
import * as path from 'path';
|
|
5
5
|
import path__default from 'path';
|
|
6
6
|
import fs from 'fs/promises';
|
|
@@ -1426,15 +1426,6 @@ const createRepo = (table, methods) => {
|
|
|
1426
1426
|
});
|
|
1427
1427
|
};
|
|
1428
1428
|
|
|
1429
|
-
const toPascalCase = (s) => {
|
|
1430
|
-
const words = s.match(/(\w)(\w*)/g) || [];
|
|
1431
|
-
return words.map((word) => word[0].toUpperCase() + word.slice(1)).join("");
|
|
1432
|
-
};
|
|
1433
|
-
const toCamelCase = (s) => {
|
|
1434
|
-
const pascal = toPascalCase(s);
|
|
1435
|
-
return pascal[0].toLowerCase() + pascal.slice(1);
|
|
1436
|
-
};
|
|
1437
|
-
|
|
1438
1429
|
class FileChanges {
|
|
1439
1430
|
constructor(content) {
|
|
1440
1431
|
this.content = content;
|
|
@@ -1693,7 +1684,7 @@ const createTable$1 = ({ filePath, tablePath, statements, object, content, space
|
|
|
1693
1684
|
const key = toCamelCase(ast.name);
|
|
1694
1685
|
const value = `${toPascalCase(ast.name)}Table`;
|
|
1695
1686
|
const changes = new FileChanges(content);
|
|
1696
|
-
const importPath = getImportPath(filePath, tablePath(ast.name));
|
|
1687
|
+
const importPath = getImportPath(filePath, tablePath(toCamelCase(ast.name)));
|
|
1697
1688
|
const existing = Array.from(
|
|
1698
1689
|
ts.import.iterateWithSource(statements, importPath)
|
|
1699
1690
|
);
|
|
@@ -1723,7 +1714,7 @@ ${spaces}`;
|
|
|
1723
1714
|
};
|
|
1724
1715
|
const dropTable = ({ filePath, tablePath, statements, object, content }, ast) => {
|
|
1725
1716
|
const changes = new FileChanges(content);
|
|
1726
|
-
const importPath = getImportPath(filePath, tablePath(ast.name));
|
|
1717
|
+
const importPath = getImportPath(filePath, tablePath(toCamelCase(ast.name)));
|
|
1727
1718
|
const tableClassName = `${toPascalCase(ast.name)}Table`;
|
|
1728
1719
|
const importNames = [];
|
|
1729
1720
|
for (const node of ts.import.iterateWithSource(statements, importPath)) {
|
|
@@ -1788,7 +1779,7 @@ const createTable = async (_a) => {
|
|
|
1788
1779
|
"ast",
|
|
1789
1780
|
"logger"
|
|
1790
1781
|
]);
|
|
1791
|
-
const tablePath = params.tablePath(ast.name);
|
|
1782
|
+
const tablePath = params.tablePath(toCamelCase(ast.name));
|
|
1792
1783
|
const baseTablePath = getImportPath(tablePath, params.baseTablePath);
|
|
1793
1784
|
const props = [];
|
|
1794
1785
|
if (ast.schema) {
|
|
@@ -1844,7 +1835,7 @@ const changeTable = async (_a) => {
|
|
|
1844
1835
|
"ast",
|
|
1845
1836
|
"logger"
|
|
1846
1837
|
]);
|
|
1847
|
-
const tablePath = params.tablePath(ast.name);
|
|
1838
|
+
const tablePath = params.tablePath(toCamelCase(ast.name));
|
|
1848
1839
|
const content = await fs.readFile(tablePath, "utf-8").catch(() => void 0);
|
|
1849
1840
|
if (!content)
|
|
1850
1841
|
return;
|
|
@@ -2261,7 +2252,7 @@ const renameTable = async (_a) => {
|
|
|
2261
2252
|
"logger"
|
|
2262
2253
|
]);
|
|
2263
2254
|
var _a2;
|
|
2264
|
-
const tablePath = params.tablePath(ast.from);
|
|
2255
|
+
const tablePath = params.tablePath(toCamelCase(ast.from));
|
|
2265
2256
|
const content = await fs.readFile(tablePath, "utf-8").catch(() => void 0);
|
|
2266
2257
|
if (!content)
|
|
2267
2258
|
return;
|