arkormx 0.1.9 → 0.1.11
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/cli.mjs +29 -17
- package/dist/index.cjs +31 -17
- package/dist/index.d.cts +5 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.mjs +30 -18
- package/package.json +4 -2
package/dist/cli.mjs
CHANGED
|
@@ -26,18 +26,6 @@ var ArkormException = class extends Error {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/database/Migration.ts
|
|
31
|
-
/**
|
|
32
|
-
* The Migration class serves as a base for defining database migrations, requiring
|
|
33
|
-
* the implementation of `up` and `down` methods to specify the changes to be
|
|
34
|
-
* applied or reverted in the database schema.
|
|
35
|
-
*
|
|
36
|
-
* @author Legacy (3m1n3nc3)
|
|
37
|
-
* @since 0.1.0
|
|
38
|
-
*/
|
|
39
|
-
var Migration = class {};
|
|
40
|
-
|
|
41
29
|
//#endregion
|
|
42
30
|
//#region src/database/TableBuilder.ts
|
|
43
31
|
/**
|
|
@@ -786,7 +774,7 @@ const generateMigrationFile = (name, options = {}) => {
|
|
|
786
774
|
* @returns A promise that resolves to an array of schema operations that would be performed.
|
|
787
775
|
*/
|
|
788
776
|
const getMigrationPlan = async (migration, direction = "up") => {
|
|
789
|
-
const instance = migration
|
|
777
|
+
const instance = typeof migration === "function" ? new migration() : migration;
|
|
790
778
|
const schema = new SchemaBuilder();
|
|
791
779
|
if (direction === "up") await instance.up(schema);
|
|
792
780
|
else await instance.down(schema);
|
|
@@ -1578,6 +1566,21 @@ var MakeSeederCommand = class extends Command {
|
|
|
1578
1566
|
}
|
|
1579
1567
|
};
|
|
1580
1568
|
|
|
1569
|
+
//#endregion
|
|
1570
|
+
//#region src/database/Migration.ts
|
|
1571
|
+
const MIGRATION_BRAND = Symbol.for("arkormx.migration");
|
|
1572
|
+
/**
|
|
1573
|
+
* The Migration class serves as a base for defining database migrations, requiring
|
|
1574
|
+
* the implementation of `up` and `down` methods to specify the changes to be
|
|
1575
|
+
* applied or reverted in the database schema.
|
|
1576
|
+
*
|
|
1577
|
+
* @author Legacy (3m1n3nc3)
|
|
1578
|
+
* @since 0.1.0
|
|
1579
|
+
*/
|
|
1580
|
+
var Migration = class {
|
|
1581
|
+
static [MIGRATION_BRAND] = true;
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1581
1584
|
//#endregion
|
|
1582
1585
|
//#region src/cli/commands/MigrateCommand.ts
|
|
1583
1586
|
/**
|
|
@@ -1673,7 +1676,9 @@ var MigrateCommand = class extends Command {
|
|
|
1673
1676
|
const imported = await import(`${pathToFileURL$1(resolve(filePath)).href}?arkorm_migrate=${Date.now()}`);
|
|
1674
1677
|
return Object.values(imported).filter((value) => {
|
|
1675
1678
|
if (typeof value !== "function") return false;
|
|
1676
|
-
|
|
1679
|
+
const candidate = value;
|
|
1680
|
+
const prototype = candidate.prototype;
|
|
1681
|
+
return candidate[MIGRATION_BRAND] === true || typeof prototype?.up === "function" && typeof prototype?.down === "function";
|
|
1677
1682
|
});
|
|
1678
1683
|
}
|
|
1679
1684
|
};
|
|
@@ -1706,6 +1711,7 @@ var ModelsSyncCommand = class extends Command {
|
|
|
1706
1711
|
|
|
1707
1712
|
//#endregion
|
|
1708
1713
|
//#region src/database/Seeder.ts
|
|
1714
|
+
const SEEDER_BRAND = Symbol.for("arkormx.seeder");
|
|
1709
1715
|
/**
|
|
1710
1716
|
* The Seeder class serves as a base for defining database seeders, which are
|
|
1711
1717
|
* used to populate the database with initial or test data.
|
|
@@ -1714,6 +1720,7 @@ var ModelsSyncCommand = class extends Command {
|
|
|
1714
1720
|
* @since 0.1.0
|
|
1715
1721
|
*/
|
|
1716
1722
|
var Seeder = class Seeder {
|
|
1723
|
+
static [SEEDER_BRAND] = true;
|
|
1717
1724
|
/**
|
|
1718
1725
|
* Runs one or more seeders.
|
|
1719
1726
|
*
|
|
@@ -1729,8 +1736,11 @@ var Seeder = class Seeder {
|
|
|
1729
1736
|
* @returns A Seeder instance.
|
|
1730
1737
|
*/
|
|
1731
1738
|
static toSeederInstance(input) {
|
|
1732
|
-
if (input
|
|
1733
|
-
|
|
1739
|
+
if (typeof input === "function") return new input();
|
|
1740
|
+
if (typeof input === "object" && input !== null) {
|
|
1741
|
+
if (typeof input.run === "function") return input;
|
|
1742
|
+
}
|
|
1743
|
+
return input;
|
|
1734
1744
|
}
|
|
1735
1745
|
/**
|
|
1736
1746
|
* Runs the given seeders in sequence.
|
|
@@ -1820,7 +1830,9 @@ var SeedCommand = class extends Command {
|
|
|
1820
1830
|
const imported = await import(`${pathToFileURL$1(resolve(filePath)).href}?arkorm_seed=${Date.now()}`);
|
|
1821
1831
|
return Object.values(imported).filter((value) => {
|
|
1822
1832
|
if (typeof value !== "function") return false;
|
|
1823
|
-
|
|
1833
|
+
const candidate = value;
|
|
1834
|
+
const prototype = candidate.prototype;
|
|
1835
|
+
return candidate[SEEDER_BRAND] === true || typeof prototype?.run === "function";
|
|
1824
1836
|
});
|
|
1825
1837
|
}
|
|
1826
1838
|
};
|
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
|
|
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);
|
|
@@ -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
|
-
|
|
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
|
|
1941
|
-
|
|
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
|
-
|
|
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
|
|
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);
|
|
@@ -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
|
-
|
|
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
|
|
1912
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Modern TypeScript-first ORM for Node.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -72,9 +72,11 @@
|
|
|
72
72
|
"@h3ravel/musket": "^0.10.1",
|
|
73
73
|
"@h3ravel/shared": "^0.27.13",
|
|
74
74
|
"@h3ravel/support": "^0.15.11",
|
|
75
|
-
"@prisma/client": "^7.4.2",
|
|
76
75
|
"dotenv": "^17.3.1"
|
|
77
76
|
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"@prisma/client": "^7.4.2"
|
|
79
|
+
},
|
|
78
80
|
"scripts": {
|
|
79
81
|
"cmd": "tsx src/cli/index.ts",
|
|
80
82
|
"lint": "eslint",
|