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.js
CHANGED
|
@@ -1453,15 +1453,6 @@ const createRepo = (table, methods) => {
|
|
|
1453
1453
|
});
|
|
1454
1454
|
};
|
|
1455
1455
|
|
|
1456
|
-
const toPascalCase = (s) => {
|
|
1457
|
-
const words = s.match(/(\w)(\w*)/g) || [];
|
|
1458
|
-
return words.map((word) => word[0].toUpperCase() + word.slice(1)).join("");
|
|
1459
|
-
};
|
|
1460
|
-
const toCamelCase = (s) => {
|
|
1461
|
-
const pascal = toPascalCase(s);
|
|
1462
|
-
return pascal[0].toLowerCase() + pascal.slice(1);
|
|
1463
|
-
};
|
|
1464
|
-
|
|
1465
1456
|
class FileChanges {
|
|
1466
1457
|
constructor(content) {
|
|
1467
1458
|
this.content = content;
|
|
@@ -1717,10 +1708,10 @@ const updateMainFile = async (filePath, tablePath, ast, options, logger) => {
|
|
|
1717
1708
|
}
|
|
1718
1709
|
};
|
|
1719
1710
|
const createTable$1 = ({ filePath, tablePath, statements, object, content, spaces }, ast) => {
|
|
1720
|
-
const key = toCamelCase(ast.name);
|
|
1721
|
-
const value = `${toPascalCase(ast.name)}Table`;
|
|
1711
|
+
const key = orchidCore.toCamelCase(ast.name);
|
|
1712
|
+
const value = `${orchidCore.toPascalCase(ast.name)}Table`;
|
|
1722
1713
|
const changes = new FileChanges(content);
|
|
1723
|
-
const importPath = getImportPath(filePath, tablePath(ast.name));
|
|
1714
|
+
const importPath = getImportPath(filePath, tablePath(orchidCore.toCamelCase(ast.name)));
|
|
1724
1715
|
const existing = Array.from(
|
|
1725
1716
|
ts.import.iterateWithSource(statements, importPath)
|
|
1726
1717
|
);
|
|
@@ -1750,8 +1741,8 @@ ${spaces}`;
|
|
|
1750
1741
|
};
|
|
1751
1742
|
const dropTable = ({ filePath, tablePath, statements, object, content }, ast) => {
|
|
1752
1743
|
const changes = new FileChanges(content);
|
|
1753
|
-
const importPath = getImportPath(filePath, tablePath(ast.name));
|
|
1754
|
-
const tableClassName = `${toPascalCase(ast.name)}Table`;
|
|
1744
|
+
const importPath = getImportPath(filePath, tablePath(orchidCore.toCamelCase(ast.name)));
|
|
1745
|
+
const tableClassName = `${orchidCore.toPascalCase(ast.name)}Table`;
|
|
1755
1746
|
const importNames = [];
|
|
1756
1747
|
for (const node of ts.import.iterateWithSource(statements, importPath)) {
|
|
1757
1748
|
changes.remove(node.pos, node.end);
|
|
@@ -1815,7 +1806,7 @@ const createTable = async (_a) => {
|
|
|
1815
1806
|
"ast",
|
|
1816
1807
|
"logger"
|
|
1817
1808
|
]);
|
|
1818
|
-
const tablePath = params.tablePath(ast.name);
|
|
1809
|
+
const tablePath = params.tablePath(orchidCore.toCamelCase(ast.name));
|
|
1819
1810
|
const baseTablePath = getImportPath(tablePath, params.baseTablePath);
|
|
1820
1811
|
const props = [];
|
|
1821
1812
|
if (ast.schema) {
|
|
@@ -1833,7 +1824,7 @@ const createTable = async (_a) => {
|
|
|
1833
1824
|
const code = [
|
|
1834
1825
|
`import { ${params.baseTableName} } from '${baseTablePath}';
|
|
1835
1826
|
`,
|
|
1836
|
-
`export class ${toPascalCase(ast.name)}Table extends ${params.baseTableName} {`,
|
|
1827
|
+
`export class ${orchidCore.toPascalCase(ast.name)}Table extends ${params.baseTableName} {`,
|
|
1837
1828
|
props,
|
|
1838
1829
|
"}\n"
|
|
1839
1830
|
];
|
|
@@ -1871,13 +1862,13 @@ const changeTable = async (_a) => {
|
|
|
1871
1862
|
"ast",
|
|
1872
1863
|
"logger"
|
|
1873
1864
|
]);
|
|
1874
|
-
const tablePath = params.tablePath(ast.name);
|
|
1865
|
+
const tablePath = params.tablePath(orchidCore.toCamelCase(ast.name));
|
|
1875
1866
|
const content = await fs__default["default"].readFile(tablePath, "utf-8").catch(() => void 0);
|
|
1876
1867
|
if (!content)
|
|
1877
1868
|
return;
|
|
1878
1869
|
const changes = new FileChanges(content);
|
|
1879
1870
|
const statements = ts.getStatements(content);
|
|
1880
|
-
const className = toPascalCase(ast.name) + "Table";
|
|
1871
|
+
const className = orchidCore.toPascalCase(ast.name) + "Table";
|
|
1881
1872
|
for (const { t, object } of iterateColumnsShapes(statements, className)) {
|
|
1882
1873
|
const context = makeChangeContext(changes, ast, content, object, t);
|
|
1883
1874
|
prependSpaces(context);
|
|
@@ -2288,13 +2279,13 @@ const renameTable = async (_a) => {
|
|
|
2288
2279
|
"logger"
|
|
2289
2280
|
]);
|
|
2290
2281
|
var _a2;
|
|
2291
|
-
const tablePath = params.tablePath(ast.from);
|
|
2282
|
+
const tablePath = params.tablePath(orchidCore.toCamelCase(ast.from));
|
|
2292
2283
|
const content = await fs__default["default"].readFile(tablePath, "utf-8").catch(() => void 0);
|
|
2293
2284
|
if (!content)
|
|
2294
2285
|
return;
|
|
2295
2286
|
const changes = new FileChanges(content);
|
|
2296
2287
|
const statements = ts.getStatements(content);
|
|
2297
|
-
const className = toPascalCase(ast.from) + "Table";
|
|
2288
|
+
const className = orchidCore.toPascalCase(ast.from) + "Table";
|
|
2298
2289
|
const changeSchema = ast.fromSchema !== ast.toSchema;
|
|
2299
2290
|
for (const node of ts.class.iterate(statements)) {
|
|
2300
2291
|
if (((_a2 = node.name) == null ? void 0 : _a2.escapedText) !== className)
|