orchid-orm 1.7.0 → 1.8.1

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.d.ts CHANGED
@@ -155,6 +155,8 @@ declare const createBaseTable: <CT extends ColumnTypesBase>({ columnTypes, snake
155
155
  table: string;
156
156
  columns: TableConfig;
157
157
  schema?: string | undefined;
158
+ noPrimaryKey?: boolean | undefined;
159
+ snakeCase: boolean | undefined;
158
160
  columnTypes: ColumnTypesBase extends CT ? {
159
161
  timestamps: <T extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
160
162
  name(name: string): {
@@ -272,8 +274,6 @@ declare const createBaseTable: <CT extends ColumnTypesBase>({ columnTypes, snake
272
274
  }) | undefined): {};
273
275
  check(check: orchid_core.RawExpression): {};
274
276
  } : CT;
275
- noPrimaryKey?: boolean | undefined;
276
- snakeCase: boolean | undefined;
277
277
  setColumns: <T_18 extends ColumnsShape>(fn: (t: ColumnTypesBase extends CT ? {
278
278
  timestamps: <T extends orchid_core.ColumnTypeBase<unknown, orchid_core.BaseOperators, unknown, orchid_core.ColumnDataBase>>(this: {
279
279
  name(name: string): {
package/dist/index.js CHANGED
@@ -37,7 +37,7 @@ const createBaseTable = ({
37
37
  );
38
38
  };
39
39
  const create = (columnTypes, snakeCase) => {
40
- return class BaseTable {
40
+ const base = class BaseTable {
41
41
  constructor() {
42
42
  this.snakeCase = snakeCase;
43
43
  this.setColumns = (fn) => {
@@ -94,6 +94,8 @@ const create = (columnTypes, snakeCase) => {
94
94
  };
95
95
  }
96
96
  };
97
+ base.prototype.columnTypes = columnTypes;
98
+ return base;
97
99
  };
98
100
 
99
101
  class BelongsToVirtualColumn extends pqb.VirtualColumn {
@@ -1615,12 +1617,6 @@ const ts = {
1615
1617
  }
1616
1618
  };
1617
1619
 
1618
- const getImportPath = (from, to) => {
1619
- const rel = path.relative(path.dirname(from), to).split(path.sep).join(path.posix.sep);
1620
- const importPath = rel.startsWith("./") || rel.startsWith("../") ? rel : `./${rel}`;
1621
- return importPath.replace(/\.[tj]s$/, "");
1622
- };
1623
-
1624
1620
  const libraryName = "orchid-orm";
1625
1621
  const importKey = "orchidORM";
1626
1622
  const newFile = (options) => `import { orchidORM } from 'orchid-orm';
@@ -1701,7 +1697,7 @@ const createTable$1 = ({ filePath, tablePath, statements, object, content, space
1701
1697
  const key = orchidCore.toCamelCase(ast.name);
1702
1698
  const value = `${orchidCore.toPascalCase(ast.name)}Table`;
1703
1699
  const changes = new FileChanges(content);
1704
- const importPath = getImportPath(filePath, tablePath(orchidCore.toCamelCase(ast.name)));
1700
+ const importPath = orchidCore.getImportPath(filePath, tablePath(orchidCore.toCamelCase(ast.name)));
1705
1701
  const existing = Array.from(
1706
1702
  ts.import.iterateWithSource(statements, importPath)
1707
1703
  );
@@ -1731,7 +1727,7 @@ ${spaces}`;
1731
1727
  };
1732
1728
  const dropTable = ({ filePath, tablePath, statements, object, content }, ast) => {
1733
1729
  const changes = new FileChanges(content);
1734
- const importPath = getImportPath(filePath, tablePath(orchidCore.toCamelCase(ast.name)));
1730
+ const importPath = orchidCore.getImportPath(filePath, tablePath(orchidCore.toCamelCase(ast.name)));
1735
1731
  const tableClassName = `${orchidCore.toPascalCase(ast.name)}Table`;
1736
1732
  const importNames = [];
1737
1733
  for (const node of ts.import.iterateWithSource(statements, importPath)) {
@@ -1797,7 +1793,7 @@ const createTable = async (_a) => {
1797
1793
  "logger"
1798
1794
  ]);
1799
1795
  const tablePath = params.tablePath(orchidCore.toCamelCase(ast.name));
1800
- const baseTablePath = getImportPath(tablePath, params.baseTablePath);
1796
+ const baseTablePath = orchidCore.getImportPath(tablePath, params.baseTablePath);
1801
1797
  const props = [];
1802
1798
  if (ast.schema) {
1803
1799
  props.push(`schema = ${orchidCore.singleQuote(ast.schema)};`);