arkormx 0.1.8 → 0.1.10

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.cjs CHANGED
@@ -117,18 +117,6 @@ var ArkormException = class extends Error {
117
117
  }
118
118
  };
119
119
 
120
- //#endregion
121
- //#region src/database/Migration.ts
122
- /**
123
- * The Migration class serves as a base for defining database migrations, requiring
124
- * the implementation of `up` and `down` methods to specify the changes to be
125
- * applied or reverted in the database schema.
126
- *
127
- * @author Legacy (3m1n3nc3)
128
- * @since 0.1.0
129
- */
130
- var Migration = class {};
131
-
132
120
  //#endregion
133
121
  //#region src/database/TableBuilder.ts
134
122
  /**
@@ -877,7 +865,7 @@ const generateMigrationFile = (name, options = {}) => {
877
865
  * @returns A promise that resolves to an array of schema operations that would be performed.
878
866
  */
879
867
  const getMigrationPlan = async (migration, direction = "up") => {
880
- const instance = migration instanceof Migration ? migration : new migration();
868
+ const instance = typeof migration === "function" ? new migration() : migration;
881
869
  const schema = new SchemaBuilder();
882
870
  if (direction === "up") await instance.up(schema);
883
871
  else await instance.down(schema);
@@ -974,7 +962,7 @@ const mergePathConfig = (paths) => {
974
962
  const defaults = baseConfig.paths ?? {};
975
963
  const current = userConfig.paths ?? {};
976
964
  const incoming = Object.entries(paths ?? {}).reduce((all, [key, value]) => {
977
- if (typeof value === "string" && value.trim().length > 0) all[key] = value;
965
+ if (typeof value === "string" && value.trim().length > 0) all[key] = path.default.isAbsolute(value) ? value : path.default.resolve(process.cwd(), value);
978
966
  return all;
979
967
  }, {});
980
968
  return {
@@ -1786,6 +1774,21 @@ var MakeSeederCommand = class extends _h3ravel_musket.Command {
1786
1774
  }
1787
1775
  };
1788
1776
 
1777
+ //#endregion
1778
+ //#region src/database/Migration.ts
1779
+ const MIGRATION_BRAND = Symbol.for("arkormx.migration");
1780
+ /**
1781
+ * The Migration class serves as a base for defining database migrations, requiring
1782
+ * the implementation of `up` and `down` methods to specify the changes to be
1783
+ * applied or reverted in the database schema.
1784
+ *
1785
+ * @author Legacy (3m1n3nc3)
1786
+ * @since 0.1.0
1787
+ */
1788
+ var Migration = class {
1789
+ static [MIGRATION_BRAND] = true;
1790
+ };
1791
+
1789
1792
  //#endregion
1790
1793
  //#region src/cli/commands/MigrateCommand.ts
1791
1794
  /**
@@ -1881,7 +1884,9 @@ var MigrateCommand = class extends _h3ravel_musket.Command {
1881
1884
  const imported = await import(`${(0, node_url.pathToFileURL)((0, node_path.resolve)(filePath)).href}?arkorm_migrate=${Date.now()}`);
1882
1885
  return Object.values(imported).filter((value) => {
1883
1886
  if (typeof value !== "function") return false;
1884
- return value.prototype instanceof Migration;
1887
+ const candidate = value;
1888
+ const prototype = candidate.prototype;
1889
+ return candidate[MIGRATION_BRAND] === true || typeof prototype?.up === "function" && typeof prototype?.down === "function";
1885
1890
  });
1886
1891
  }
1887
1892
  };
@@ -1914,6 +1919,7 @@ var ModelsSyncCommand = class extends _h3ravel_musket.Command {
1914
1919
 
1915
1920
  //#endregion
1916
1921
  //#region src/database/Seeder.ts
1922
+ const SEEDER_BRAND = Symbol.for("arkormx.seeder");
1917
1923
  /**
1918
1924
  * The Seeder class serves as a base for defining database seeders, which are
1919
1925
  * used to populate the database with initial or test data.
@@ -1922,6 +1928,7 @@ var ModelsSyncCommand = class extends _h3ravel_musket.Command {
1922
1928
  * @since 0.1.0
1923
1929
  */
1924
1930
  var Seeder = class Seeder {
1931
+ static [SEEDER_BRAND] = true;
1925
1932
  /**
1926
1933
  * Runs one or more seeders.
1927
1934
  *
@@ -1937,8 +1944,11 @@ var Seeder = class Seeder {
1937
1944
  * @returns A Seeder instance.
1938
1945
  */
1939
1946
  static toSeederInstance(input) {
1940
- if (input instanceof Seeder) return input;
1941
- return new input();
1947
+ if (typeof input === "function") return new input();
1948
+ if (typeof input === "object" && input !== null) {
1949
+ if (typeof input.run === "function") return input;
1950
+ }
1951
+ return input;
1942
1952
  }
1943
1953
  /**
1944
1954
  * Runs the given seeders in sequence.
@@ -2028,7 +2038,9 @@ var SeedCommand = class extends _h3ravel_musket.Command {
2028
2038
  const imported = await import(`${(0, node_url.pathToFileURL)((0, node_path.resolve)(filePath)).href}?arkorm_seed=${Date.now()}`);
2029
2039
  return Object.values(imported).filter((value) => {
2030
2040
  if (typeof value !== "function") return false;
2031
- return value.prototype instanceof Seeder;
2041
+ const candidate = value;
2042
+ const prototype = candidate.prototype;
2043
+ return candidate[SEEDER_BRAND] === true || typeof prototype?.run === "function";
2032
2044
  });
2033
2045
  }
2034
2046
  };
@@ -4653,6 +4665,7 @@ exports.CliApp = CliApp;
4653
4665
  exports.InitCommand = InitCommand;
4654
4666
  exports.InlineFactory = InlineFactory;
4655
4667
  exports.LengthAwarePaginator = LengthAwarePaginator;
4668
+ exports.MIGRATION_BRAND = MIGRATION_BRAND;
4656
4669
  exports.MakeFactoryCommand = MakeFactoryCommand;
4657
4670
  exports.MakeMigrationCommand = MakeMigrationCommand;
4658
4671
  exports.MakeModelCommand = MakeModelCommand;
@@ -4666,6 +4679,7 @@ exports.ModelsSyncCommand = ModelsSyncCommand;
4666
4679
  exports.PRISMA_MODEL_REGEX = PRISMA_MODEL_REGEX;
4667
4680
  exports.Paginator = Paginator;
4668
4681
  exports.QueryBuilder = QueryBuilder;
4682
+ exports.SEEDER_BRAND = SEEDER_BRAND;
4669
4683
  exports.SchemaBuilder = SchemaBuilder;
4670
4684
  exports.SeedCommand = SeedCommand;
4671
4685
  exports.Seeder = Seeder;
package/dist/index.d.cts CHANGED
@@ -2472,6 +2472,7 @@ declare class SchemaBuilder {
2472
2472
  }
2473
2473
  //#endregion
2474
2474
  //#region src/database/Migration.d.ts
2475
+ declare const MIGRATION_BRAND: unique symbol;
2475
2476
  /**
2476
2477
  * The Migration class serves as a base for defining database migrations, requiring
2477
2478
  * the implementation of `up` and `down` methods to specify the changes to be
@@ -2481,6 +2482,7 @@ declare class SchemaBuilder {
2481
2482
  * @since 0.1.0
2482
2483
  */
2483
2484
  declare abstract class Migration {
2485
+ static readonly [MIGRATION_BRAND] = true;
2484
2486
  /**
2485
2487
  * Defines the operations to be performed when applying the migration
2486
2488
  *
@@ -2499,6 +2501,7 @@ declare abstract class Migration {
2499
2501
  type SeederConstructor = new () => Seeder;
2500
2502
  type SeederInput = Seeder | SeederConstructor;
2501
2503
  type SeederCallArgument = SeederInput | SeederInput[];
2504
+ declare const SEEDER_BRAND: unique symbol;
2502
2505
  /**
2503
2506
  * The Seeder class serves as a base for defining database seeders, which are
2504
2507
  * used to populate the database with initial or test data.
@@ -2507,6 +2510,7 @@ type SeederCallArgument = SeederInput | SeederInput[];
2507
2510
  * @since 0.1.0
2508
2511
  */
2509
2512
  declare abstract class Seeder {
2513
+ static readonly [SEEDER_BRAND] = true;
2510
2514
  /**
2511
2515
  * Defines the operations to be performed when running the seeder.
2512
2516
  */
@@ -2858,4 +2862,4 @@ declare class URLDriver {
2858
2862
  url(page: number): string;
2859
2863
  }
2860
2864
  //#endregion
2861
- export { ArkormCollection, ArkormException, CliApp, InitCommand, InlineFactory, LengthAwarePaginator, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, Migration, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, SchemaBuilder, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildFieldLine, buildIndexLine, buildMigrationSource, buildModelBlock, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, ensureArkormConfigLoading, escapeRegex, findModelBlock, formatDefaultValue, generateMigrationFile, getDefaultStubsPath, getMigrationPlan, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, loadArkormConfig, pad, resetArkormRuntimeForTests, resolveCast, resolveMigrationClassName, resolvePrismaType, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName };
2865
+ export { ArkormCollection, ArkormException, CliApp, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, Migration, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, SEEDER_BRAND, SchemaBuilder, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildFieldLine, buildIndexLine, buildMigrationSource, buildModelBlock, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, ensureArkormConfigLoading, escapeRegex, findModelBlock, formatDefaultValue, generateMigrationFile, getDefaultStubsPath, getMigrationPlan, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, loadArkormConfig, pad, resetArkormRuntimeForTests, resolveCast, resolveMigrationClassName, resolvePrismaType, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName };
package/dist/index.d.mts CHANGED
@@ -2472,6 +2472,7 @@ declare class SchemaBuilder {
2472
2472
  }
2473
2473
  //#endregion
2474
2474
  //#region src/database/Migration.d.ts
2475
+ declare const MIGRATION_BRAND: unique symbol;
2475
2476
  /**
2476
2477
  * The Migration class serves as a base for defining database migrations, requiring
2477
2478
  * the implementation of `up` and `down` methods to specify the changes to be
@@ -2481,6 +2482,7 @@ declare class SchemaBuilder {
2481
2482
  * @since 0.1.0
2482
2483
  */
2483
2484
  declare abstract class Migration {
2485
+ static readonly [MIGRATION_BRAND] = true;
2484
2486
  /**
2485
2487
  * Defines the operations to be performed when applying the migration
2486
2488
  *
@@ -2499,6 +2501,7 @@ declare abstract class Migration {
2499
2501
  type SeederConstructor = new () => Seeder;
2500
2502
  type SeederInput = Seeder | SeederConstructor;
2501
2503
  type SeederCallArgument = SeederInput | SeederInput[];
2504
+ declare const SEEDER_BRAND: unique symbol;
2502
2505
  /**
2503
2506
  * The Seeder class serves as a base for defining database seeders, which are
2504
2507
  * used to populate the database with initial or test data.
@@ -2507,6 +2510,7 @@ type SeederCallArgument = SeederInput | SeederInput[];
2507
2510
  * @since 0.1.0
2508
2511
  */
2509
2512
  declare abstract class Seeder {
2513
+ static readonly [SEEDER_BRAND] = true;
2510
2514
  /**
2511
2515
  * Defines the operations to be performed when running the seeder.
2512
2516
  */
@@ -2858,4 +2862,4 @@ declare class URLDriver {
2858
2862
  url(page: number): string;
2859
2863
  }
2860
2864
  //#endregion
2861
- export { ArkormCollection, ArkormException, CliApp, InitCommand, InlineFactory, LengthAwarePaginator, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, Migration, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, SchemaBuilder, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildFieldLine, buildIndexLine, buildMigrationSource, buildModelBlock, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, ensureArkormConfigLoading, escapeRegex, findModelBlock, formatDefaultValue, generateMigrationFile, getDefaultStubsPath, getMigrationPlan, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, loadArkormConfig, pad, resetArkormRuntimeForTests, resolveCast, resolveMigrationClassName, resolvePrismaType, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName };
2865
+ export { ArkormCollection, ArkormException, CliApp, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, Migration, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_MODEL_REGEX, Paginator, PrismaDelegateMap, QueryBuilder, SEEDER_BRAND, SchemaBuilder, SeedCommand, Seeder, SeederCallArgument, SeederConstructor, SeederInput, TableBuilder, URLDriver, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildFieldLine, buildIndexLine, buildMigrationSource, buildModelBlock, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, ensureArkormConfigLoading, escapeRegex, findModelBlock, formatDefaultValue, generateMigrationFile, getDefaultStubsPath, getMigrationPlan, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, loadArkormConfig, pad, resetArkormRuntimeForTests, resolveCast, resolveMigrationClassName, resolvePrismaType, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName };
package/dist/index.mjs CHANGED
@@ -88,18 +88,6 @@ var ArkormException = class extends Error {
88
88
  }
89
89
  };
90
90
 
91
- //#endregion
92
- //#region src/database/Migration.ts
93
- /**
94
- * The Migration class serves as a base for defining database migrations, requiring
95
- * the implementation of `up` and `down` methods to specify the changes to be
96
- * applied or reverted in the database schema.
97
- *
98
- * @author Legacy (3m1n3nc3)
99
- * @since 0.1.0
100
- */
101
- var Migration = class {};
102
-
103
91
  //#endregion
104
92
  //#region src/database/TableBuilder.ts
105
93
  /**
@@ -848,7 +836,7 @@ const generateMigrationFile = (name, options = {}) => {
848
836
  * @returns A promise that resolves to an array of schema operations that would be performed.
849
837
  */
850
838
  const getMigrationPlan = async (migration, direction = "up") => {
851
- const instance = migration instanceof Migration ? migration : new migration();
839
+ const instance = typeof migration === "function" ? new migration() : migration;
852
840
  const schema = new SchemaBuilder();
853
841
  if (direction === "up") await instance.up(schema);
854
842
  else await instance.down(schema);
@@ -945,7 +933,7 @@ const mergePathConfig = (paths) => {
945
933
  const defaults = baseConfig.paths ?? {};
946
934
  const current = userConfig.paths ?? {};
947
935
  const incoming = Object.entries(paths ?? {}).reduce((all, [key, value]) => {
948
- if (typeof value === "string" && value.trim().length > 0) all[key] = value;
936
+ if (typeof value === "string" && value.trim().length > 0) all[key] = path.isAbsolute(value) ? value : path.resolve(process.cwd(), value);
949
937
  return all;
950
938
  }, {});
951
939
  return {
@@ -1757,6 +1745,21 @@ var MakeSeederCommand = class extends Command {
1757
1745
  }
1758
1746
  };
1759
1747
 
1748
+ //#endregion
1749
+ //#region src/database/Migration.ts
1750
+ const MIGRATION_BRAND = Symbol.for("arkormx.migration");
1751
+ /**
1752
+ * The Migration class serves as a base for defining database migrations, requiring
1753
+ * the implementation of `up` and `down` methods to specify the changes to be
1754
+ * applied or reverted in the database schema.
1755
+ *
1756
+ * @author Legacy (3m1n3nc3)
1757
+ * @since 0.1.0
1758
+ */
1759
+ var Migration = class {
1760
+ static [MIGRATION_BRAND] = true;
1761
+ };
1762
+
1760
1763
  //#endregion
1761
1764
  //#region src/cli/commands/MigrateCommand.ts
1762
1765
  /**
@@ -1852,7 +1855,9 @@ var MigrateCommand = class extends Command {
1852
1855
  const imported = await import(`${pathToFileURL$1(resolve(filePath)).href}?arkorm_migrate=${Date.now()}`);
1853
1856
  return Object.values(imported).filter((value) => {
1854
1857
  if (typeof value !== "function") return false;
1855
- return value.prototype instanceof Migration;
1858
+ const candidate = value;
1859
+ const prototype = candidate.prototype;
1860
+ return candidate[MIGRATION_BRAND] === true || typeof prototype?.up === "function" && typeof prototype?.down === "function";
1856
1861
  });
1857
1862
  }
1858
1863
  };
@@ -1885,6 +1890,7 @@ var ModelsSyncCommand = class extends Command {
1885
1890
 
1886
1891
  //#endregion
1887
1892
  //#region src/database/Seeder.ts
1893
+ const SEEDER_BRAND = Symbol.for("arkormx.seeder");
1888
1894
  /**
1889
1895
  * The Seeder class serves as a base for defining database seeders, which are
1890
1896
  * used to populate the database with initial or test data.
@@ -1893,6 +1899,7 @@ var ModelsSyncCommand = class extends Command {
1893
1899
  * @since 0.1.0
1894
1900
  */
1895
1901
  var Seeder = class Seeder {
1902
+ static [SEEDER_BRAND] = true;
1896
1903
  /**
1897
1904
  * Runs one or more seeders.
1898
1905
  *
@@ -1908,8 +1915,11 @@ var Seeder = class Seeder {
1908
1915
  * @returns A Seeder instance.
1909
1916
  */
1910
1917
  static toSeederInstance(input) {
1911
- if (input instanceof Seeder) return input;
1912
- return new input();
1918
+ if (typeof input === "function") return new input();
1919
+ if (typeof input === "object" && input !== null) {
1920
+ if (typeof input.run === "function") return input;
1921
+ }
1922
+ return input;
1913
1923
  }
1914
1924
  /**
1915
1925
  * Runs the given seeders in sequence.
@@ -1999,7 +2009,9 @@ var SeedCommand = class extends Command {
1999
2009
  const imported = await import(`${pathToFileURL$1(resolve(filePath)).href}?arkorm_seed=${Date.now()}`);
2000
2010
  return Object.values(imported).filter((value) => {
2001
2011
  if (typeof value !== "function") return false;
2002
- return value.prototype instanceof Seeder;
2012
+ const candidate = value;
2013
+ const prototype = candidate.prototype;
2014
+ return candidate[SEEDER_BRAND] === true || typeof prototype?.run === "function";
2003
2015
  });
2004
2016
  }
2005
2017
  };
@@ -4618,4 +4630,4 @@ var Model = class Model {
4618
4630
  };
4619
4631
 
4620
4632
  //#endregion
4621
- export { ArkormCollection, ArkormException, CliApp, InitCommand, InlineFactory, LengthAwarePaginator, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, Migration, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_MODEL_REGEX, Paginator, QueryBuilder, SchemaBuilder, SeedCommand, Seeder, TableBuilder, URLDriver, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildFieldLine, buildIndexLine, buildMigrationSource, buildModelBlock, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, ensureArkormConfigLoading, escapeRegex, findModelBlock, formatDefaultValue, generateMigrationFile, getDefaultStubsPath, getMigrationPlan, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, loadArkormConfig, pad, resetArkormRuntimeForTests, resolveCast, resolveMigrationClassName, resolvePrismaType, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName };
4633
+ export { ArkormCollection, ArkormException, CliApp, InitCommand, InlineFactory, LengthAwarePaginator, MIGRATION_BRAND, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, Migration, Model, ModelFactory, ModelNotFoundException, ModelsSyncCommand, PRISMA_MODEL_REGEX, Paginator, QueryBuilder, SEEDER_BRAND, SchemaBuilder, SeedCommand, Seeder, TableBuilder, URLDriver, applyAlterTableOperation, applyCreateTableOperation, applyDropTableOperation, applyMigrationToPrismaSchema, applyOperationsToPrismaSchema, buildFieldLine, buildIndexLine, buildMigrationSource, buildModelBlock, configureArkormRuntime, createMigrationTimestamp, createPrismaAdapter, createPrismaDelegateMap, defineConfig, defineFactory, ensureArkormConfigLoading, escapeRegex, findModelBlock, formatDefaultValue, generateMigrationFile, getDefaultStubsPath, getMigrationPlan, getRuntimePaginationURLDriverFactory, getRuntimePrismaClient, getUserConfig, inferDelegateName, isDelegateLike, loadArkormConfig, pad, resetArkormRuntimeForTests, resolveCast, resolveMigrationClassName, resolvePrismaType, runMigrationWithPrisma, runPrismaCommand, toMigrationFileSlug, toModelName };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkormx",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Modern TypeScript-first ORM for Node.js.",
5
5
  "keywords": [
6
6
  "orm",