arkormx 2.1.1 → 2.2.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.
@@ -744,6 +744,7 @@ const buildMigrationIdentity = (filePath, className) => {
744
744
  return `${fileName.slice(0, fileName.length - (0, node_path.extname)(fileName).length)}:${className}`;
745
745
  };
746
746
  const computeMigrationChecksum = (filePath) => {
747
+ if (!(0, node_fs.existsSync)(filePath)) return (0, node_crypto.createHash)("sha256").update(filePath).digest("hex");
747
748
  const source = (0, node_fs.readFileSync)(filePath, "utf-8");
748
749
  return (0, node_crypto.createHash)("sha256").update(source).digest("hex");
749
750
  };
@@ -2618,6 +2619,149 @@ const getPersistedEnumTsType = (values) => {
2618
2619
  return buildEnumUnionType(values);
2619
2620
  };
2620
2621
 
2622
+ //#endregion
2623
+ //#region src/helpers/runtime-registry.ts
2624
+ const createEmptyRegistry = () => ({
2625
+ paths: {
2626
+ models: [],
2627
+ seeders: [],
2628
+ migrations: [],
2629
+ factories: []
2630
+ },
2631
+ migrations: [],
2632
+ seeders: [],
2633
+ models: [],
2634
+ factories: []
2635
+ });
2636
+ const registry = createEmptyRegistry();
2637
+ const pushUnique = (items, values) => {
2638
+ values.forEach((value) => {
2639
+ if (!items.includes(value)) items.push(value);
2640
+ });
2641
+ };
2642
+ const normalizePathInput = (paths) => {
2643
+ if (paths === void 0) return [];
2644
+ return (Array.isArray(paths) ? paths : [paths]).filter((path) => typeof path === "string" && path.trim().length > 0);
2645
+ };
2646
+ const normalizeConstructors = (items) => items.flatMap((item) => Array.isArray(item) ? item : [item]).filter(Boolean);
2647
+ /**
2648
+ * Register additional runtime discovery paths without replacing configured paths.
2649
+ *
2650
+ * @param paths
2651
+ */
2652
+ const registerPaths = (paths) => {
2653
+ Object.entries(paths).forEach(([key, value]) => {
2654
+ pushUnique(registry.paths[key], normalizePathInput(value));
2655
+ });
2656
+ };
2657
+ /**
2658
+ * Register additional runtime discovery paths for migrations without replacing configured paths.
2659
+ *
2660
+ * @param paths
2661
+ * @returns
2662
+ */
2663
+ const loadMigrationsFrom = (paths) => registerPaths({ migrations: paths });
2664
+ /**
2665
+ * Register additional runtime discovery paths for seeders without replacing configured paths.
2666
+ *
2667
+ * @param paths
2668
+ * @returns
2669
+ */
2670
+ const loadSeedersFrom = (paths) => registerPaths({ seeders: paths });
2671
+ /**
2672
+ * Register additional runtime discovery paths for models without replacing configured paths.
2673
+ *
2674
+ * @param paths
2675
+ * @returns
2676
+ */
2677
+ const loadModelsFrom = (paths) => registerPaths({ models: paths });
2678
+ /**
2679
+ * Register additional runtime discovery paths for factories without replacing configured paths.
2680
+ *
2681
+ * @param paths
2682
+ * @returns
2683
+ */
2684
+ const loadFactoriesFrom = (paths) => registerPaths({ factories: paths });
2685
+ /**
2686
+ * Register migration constructors directly without relying on runtime discovery.
2687
+ *
2688
+ * @param migrations
2689
+ */
2690
+ const registerMigrations = (...migrations) => {
2691
+ pushUnique(registry.migrations, normalizeConstructors(migrations));
2692
+ };
2693
+ /**
2694
+ * Register seeder constructors directly without relying on runtime discovery.
2695
+ *
2696
+ * @param seeders
2697
+ */
2698
+ const registerSeeders = (...seeders) => {
2699
+ pushUnique(registry.seeders, normalizeConstructors(seeders));
2700
+ };
2701
+ /**
2702
+ * Register model constructors directly without relying on runtime discovery.
2703
+ *
2704
+ * @param models
2705
+ */
2706
+ const registerModels = (...models) => {
2707
+ pushUnique(registry.models, normalizeConstructors(models));
2708
+ };
2709
+ /**
2710
+ * Register factory constructors or instances directly without relying on runtime discovery.
2711
+ *
2712
+ * @param factories
2713
+ */
2714
+ const registerFactories = (...factories) => {
2715
+ pushUnique(registry.factories, normalizeConstructors(factories));
2716
+ };
2717
+ /**
2718
+ * Get registered runtime discovery paths or registered constructors for a specific type.
2719
+ *
2720
+ * @param key
2721
+ * @returns
2722
+ */
2723
+ const getRegisteredPaths = (key) => {
2724
+ if (key) return [...registry.paths[key]];
2725
+ return {
2726
+ models: [...registry.paths.models],
2727
+ seeders: [...registry.paths.seeders],
2728
+ migrations: [...registry.paths.migrations],
2729
+ factories: [...registry.paths.factories]
2730
+ };
2731
+ };
2732
+ /**
2733
+ * Get registered migration constructors instances.
2734
+ *
2735
+ * @returns
2736
+ */
2737
+ const getRegisteredMigrations = () => [...registry.migrations];
2738
+ /**
2739
+ * Get registered seeder constructors instances.
2740
+ *
2741
+ * @returns
2742
+ */
2743
+ const getRegisteredSeeders = () => [...registry.seeders];
2744
+ /**
2745
+ * Get registered model constructors instances.
2746
+ *
2747
+ * @returns
2748
+ */
2749
+ const getRegisteredModels = () => [...registry.models];
2750
+ /**
2751
+ * Get registered factory constructors or instances.
2752
+ *
2753
+ * @returns
2754
+ */
2755
+ const getRegisteredFactories = () => [...registry.factories];
2756
+ const resetRuntimeRegistryForTests = () => {
2757
+ const empty = createEmptyRegistry();
2758
+ registry.paths = empty.paths;
2759
+ registry.migrations = empty.migrations;
2760
+ registry.seeders = empty.seeders;
2761
+ registry.models = empty.models;
2762
+ registry.factories = empty.factories;
2763
+ };
2764
+
2621
2765
  //#endregion
2622
2766
  //#region src/helpers/runtime-config.ts
2623
2767
  const resolveDefaultStubsPath = () => {
@@ -2805,6 +2949,7 @@ const resetArkormRuntimeForTests = () => {
2805
2949
  runtimePaginationCurrentPageResolver = void 0;
2806
2950
  runtimeDebugHandler = void 0;
2807
2951
  resetPersistedColumnMappingsCache();
2952
+ resetRuntimeRegistryForTests();
2808
2953
  };
2809
2954
  /**
2810
2955
  * Resolve a runtime client instance from the provided resolver, which can be either
@@ -4975,6 +5120,36 @@ Object.defineProperty(exports, 'getPersistedTimestampColumns', {
4975
5120
  return getPersistedTimestampColumns;
4976
5121
  }
4977
5122
  });
5123
+ Object.defineProperty(exports, 'getRegisteredFactories', {
5124
+ enumerable: true,
5125
+ get: function () {
5126
+ return getRegisteredFactories;
5127
+ }
5128
+ });
5129
+ Object.defineProperty(exports, 'getRegisteredMigrations', {
5130
+ enumerable: true,
5131
+ get: function () {
5132
+ return getRegisteredMigrations;
5133
+ }
5134
+ });
5135
+ Object.defineProperty(exports, 'getRegisteredModels', {
5136
+ enumerable: true,
5137
+ get: function () {
5138
+ return getRegisteredModels;
5139
+ }
5140
+ });
5141
+ Object.defineProperty(exports, 'getRegisteredPaths', {
5142
+ enumerable: true,
5143
+ get: function () {
5144
+ return getRegisteredPaths;
5145
+ }
5146
+ });
5147
+ Object.defineProperty(exports, 'getRegisteredSeeders', {
5148
+ enumerable: true,
5149
+ get: function () {
5150
+ return getRegisteredSeeders;
5151
+ }
5152
+ });
4978
5153
  Object.defineProperty(exports, 'getRuntimeAdapter', {
4979
5154
  enumerable: true,
4980
5155
  get: function () {
@@ -5047,6 +5222,30 @@ Object.defineProperty(exports, 'loadArkormConfig', {
5047
5222
  return loadArkormConfig;
5048
5223
  }
5049
5224
  });
5225
+ Object.defineProperty(exports, 'loadFactoriesFrom', {
5226
+ enumerable: true,
5227
+ get: function () {
5228
+ return loadFactoriesFrom;
5229
+ }
5230
+ });
5231
+ Object.defineProperty(exports, 'loadMigrationsFrom', {
5232
+ enumerable: true,
5233
+ get: function () {
5234
+ return loadMigrationsFrom;
5235
+ }
5236
+ });
5237
+ Object.defineProperty(exports, 'loadModelsFrom', {
5238
+ enumerable: true,
5239
+ get: function () {
5240
+ return loadModelsFrom;
5241
+ }
5242
+ });
5243
+ Object.defineProperty(exports, 'loadSeedersFrom', {
5244
+ enumerable: true,
5245
+ get: function () {
5246
+ return loadSeedersFrom;
5247
+ }
5248
+ });
5050
5249
  Object.defineProperty(exports, 'markMigrationApplied', {
5051
5250
  enumerable: true,
5052
5251
  get: function () {
@@ -5089,6 +5288,36 @@ Object.defineProperty(exports, 'rebuildPersistedColumnMappingsState', {
5089
5288
  return rebuildPersistedColumnMappingsState;
5090
5289
  }
5091
5290
  });
5291
+ Object.defineProperty(exports, 'registerFactories', {
5292
+ enumerable: true,
5293
+ get: function () {
5294
+ return registerFactories;
5295
+ }
5296
+ });
5297
+ Object.defineProperty(exports, 'registerMigrations', {
5298
+ enumerable: true,
5299
+ get: function () {
5300
+ return registerMigrations;
5301
+ }
5302
+ });
5303
+ Object.defineProperty(exports, 'registerModels', {
5304
+ enumerable: true,
5305
+ get: function () {
5306
+ return registerModels;
5307
+ }
5308
+ });
5309
+ Object.defineProperty(exports, 'registerPaths', {
5310
+ enumerable: true,
5311
+ get: function () {
5312
+ return registerPaths;
5313
+ }
5314
+ });
5315
+ Object.defineProperty(exports, 'registerSeeders', {
5316
+ enumerable: true,
5317
+ get: function () {
5318
+ return registerSeeders;
5319
+ }
5320
+ });
5092
5321
  Object.defineProperty(exports, 'removeAppliedMigration', {
5093
5322
  enumerable: true,
5094
5323
  get: function () {
@@ -5107,6 +5336,12 @@ Object.defineProperty(exports, 'resetPersistedColumnMappingsCache', {
5107
5336
  return resetPersistedColumnMappingsCache;
5108
5337
  }
5109
5338
  });
5339
+ Object.defineProperty(exports, 'resetRuntimeRegistryForTests', {
5340
+ enumerable: true,
5341
+ get: function () {
5342
+ return resetRuntimeRegistryForTests;
5343
+ }
5344
+ });
5110
5345
  Object.defineProperty(exports, 'resolveColumnMappingsFilePath', {
5111
5346
  enumerable: true,
5112
5347
  get: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkormx",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "Modern TypeScript-first ORM for Node.js.",
5
5
  "keywords": [
6
6
  "orm",