@razvan11/paladin 1.0.6 → 1.0.8

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.
@@ -1 +1,9 @@
1
- export declare function database(): <T extends Function>(constructor: T) => T;
1
+ export interface DatabaseOptions {
2
+ migrations?: string;
3
+ migrationsTable?: string;
4
+ }
5
+ export declare function database(options?: DatabaseOptions): <T extends Function>(constructor: T) => T;
6
+ export declare function getDatabaseRegistry(): Map<Function, DatabaseOptions>;
7
+ export declare function getDataSourceForCLI<T extends {
8
+ getSource(): any;
9
+ }>(DatabaseClass: new (...args: any[]) => T, url: string): any;
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export { database } from './functions/database';
14
14
  export { default as config } from './functions/config';
15
15
  export { default as validator } from './functions/validator';
16
16
  export { default as env } from './functions/env';
17
+ export { getDataSourceForCLI } from './functions/database';
17
18
  export { render, renderElement, createRenderer } from './functions/render';
18
19
  export { LayoutView, PageLoader, type LayoutViewProps, } from './components/LayoutView';
19
20
  export { asset, publicAsset, setAssetBasePath, getAssetBasePath, } from './functions/asset';
package/dist/index.js CHANGED
@@ -19969,9 +19969,11 @@ function repository() {
19969
19969
  }
19970
19970
  // src/functions/database.ts
19971
19971
  var getContainer5 = () => globalThis.container;
19972
- function database() {
19972
+ var databaseRegistry = new Map;
19973
+ function database(options2 = {}) {
19973
19974
  return (constructor) => {
19974
19975
  W()(constructor);
19976
+ databaseRegistry.set(constructor, options2);
19975
19977
  const container2 = getContainer5();
19976
19978
  if (container2 && !container2.isBound(constructor)) {
19977
19979
  container2.bind(constructor).toSelf().inSingletonScope();
@@ -19979,6 +19981,18 @@ function database() {
19979
19981
  return constructor;
19980
19982
  };
19981
19983
  }
19984
+ function getDataSourceForCLI(DatabaseClass, url) {
19985
+ const options2 = databaseRegistry.get(DatabaseClass);
19986
+ const instance = new DatabaseClass(url);
19987
+ const source = instance.getSource();
19988
+ if (options2?.migrations) {
19989
+ source.setOptions({
19990
+ migrations: [options2.migrations + "/*.ts"],
19991
+ migrationsTableName: options2.migrationsTable || "migrations"
19992
+ });
19993
+ }
19994
+ return source;
19995
+ }
19982
19996
  // src/functions/config.ts
19983
19997
  var getContainer6 = () => globalThis.container;
19984
19998
  function config() {
@@ -21022,6 +21036,7 @@ export {
21022
21036
  options,
21023
21037
  logger,
21024
21038
  inject,
21039
+ getDataSourceForCLI,
21025
21040
  getAssetBasePath,
21026
21041
  get,
21027
21042
  env2 as env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razvan11/paladin",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "A Bun-based backend framework with decorators, dependency injection, and controller registration",
5
5
  "keywords": [
6
6
  "bun",
@@ -43,7 +43,8 @@
43
43
  "@biomejs/biome": "^2.3.10",
44
44
  "@types/bun": "latest",
45
45
  "@types/react": "^19.2.7",
46
- "@types/react-dom": "^19.2.3"
46
+ "@types/react-dom": "^19.2.3",
47
+ "typeorm": "^0.3.28"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "typescript": "^5",