@514labs/moose-lib 0.6.267-ci-5-gfe9b0c33 → 0.6.268

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.js CHANGED
@@ -803,96 +803,33 @@ var getMooseInternal = () => globalThis.moose_internal;
803
803
  if (getMooseInternal() === void 0) {
804
804
  globalThis.moose_internal = moose_internal;
805
805
  }
806
- var indexLoadState = "unloaded";
807
- var indexLoadPromise = null;
808
- var loadIndex = async () => {
809
- const workerInfo = `[Worker ${import_process.default.pid}]`;
810
- if (indexLoadState === "loaded") {
811
- console.log(
812
- `${workerInfo} loadIndex: already loaded, returning immediately`
813
- );
814
- return;
815
- }
816
- if (indexLoadState === "loading" && indexLoadPromise) {
817
- console.log(
818
- `${workerInfo} loadIndex: already loading, waiting for completion`
819
- );
820
- return indexLoadPromise;
821
- }
822
- console.log(`${workerInfo} loadIndex: starting load process`);
823
- const startTime = Date.now();
824
- const delay = Math.random() * 500;
825
- console.log(
826
- `${workerInfo} loadIndex: waiting ${delay.toFixed(0)}ms to stagger load`
827
- );
828
- await new Promise((resolve) => setTimeout(resolve, delay));
829
- if (indexLoadState === "loading" && indexLoadPromise) {
830
- console.log(
831
- `${workerInfo} loadIndex: another worker started loading during delay, waiting`
832
- );
833
- return indexLoadPromise;
834
- }
835
- if (indexLoadState === "loaded") {
836
- console.log(
837
- `${workerInfo} loadIndex: loaded by another worker during delay`
838
- );
839
- return;
806
+ var loadIndex = () => {
807
+ const registry = getMooseInternal();
808
+ registry.tables.clear();
809
+ registry.streams.clear();
810
+ registry.ingestApis.clear();
811
+ registry.apis.clear();
812
+ registry.sqlResources.clear();
813
+ registry.workflows.clear();
814
+ registry.webApps.clear();
815
+ const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
816
+ Object.keys(require.cache).forEach((key) => {
817
+ if (key.startsWith(appDir)) {
818
+ delete require.cache[key];
819
+ }
820
+ });
821
+ try {
822
+ require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
823
+ } catch (error) {
824
+ let hint;
825
+ const details = error instanceof Error ? error.message : String(error);
826
+ if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
827
+ hint = "The file or its dependencies are ESM-only. Switch to packages that dual-support CJS & ESM, or upgrade to Node 22.12+. If you must use Node 20, you may try Node 20.19\n\n";
828
+ }
829
+ const errorMsg = `${hint ?? ""}${details}`;
830
+ const cause = error instanceof Error ? error : void 0;
831
+ throw new Error(errorMsg, { cause });
840
832
  }
841
- indexLoadState = "loading";
842
- indexLoadPromise = (async () => {
843
- try {
844
- console.log(`${workerInfo} loadIndex: clearing registry...`);
845
- const clearStart = Date.now();
846
- const registry = getMooseInternal();
847
- registry.tables.clear();
848
- registry.streams.clear();
849
- registry.ingestApis.clear();
850
- registry.apis.clear();
851
- registry.sqlResources.clear();
852
- registry.workflows.clear();
853
- registry.webApps.clear();
854
- console.log(
855
- `${workerInfo} loadIndex: registry cleared in ${Date.now() - clearStart}ms`
856
- );
857
- console.log(`${workerInfo} loadIndex: clearing require cache...`);
858
- const cacheStart = Date.now();
859
- const appDir = `${import_process.default.cwd()}/${getSourceDir()}`;
860
- Object.keys(require.cache).forEach((key) => {
861
- if (key.startsWith(appDir)) {
862
- delete require.cache[key];
863
- }
864
- });
865
- console.log(
866
- `${workerInfo} loadIndex: require cache cleared in ${Date.now() - cacheStart}ms`
867
- );
868
- console.log(`${workerInfo} loadIndex: requiring index.ts...`);
869
- const requireStart = Date.now();
870
- require(`${import_process.default.cwd()}/${getSourceDir()}/index.ts`);
871
- console.log(
872
- `${workerInfo} loadIndex: require completed in ${Date.now() - requireStart}ms`
873
- );
874
- indexLoadState = "loaded";
875
- console.log(
876
- `${workerInfo} loadIndex: total load time ${Date.now() - startTime}ms`
877
- );
878
- } catch (error) {
879
- console.error(
880
- `${workerInfo} loadIndex: FAILED after ${Date.now() - startTime}ms`,
881
- error
882
- );
883
- indexLoadState = "unloaded";
884
- indexLoadPromise = null;
885
- let hint;
886
- const details = error instanceof Error ? error.message : String(error);
887
- if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
888
- hint = "The file or its dependencies are ESM-only. Switch to packages that dual-support CJS & ESM, or upgrade to Node 22.12+. If you must use Node 20, you may try Node 20.19\n\n";
889
- }
890
- const errorMsg = `${hint ?? ""}${details}`;
891
- const cause = error instanceof Error ? error : void 0;
892
- throw new Error(errorMsg, { cause });
893
- }
894
- })();
895
- return indexLoadPromise;
896
833
  };
897
834
  var dlqSchema = {
898
835
  version: "3.1",
@@ -1014,7 +951,7 @@ var dlqColumns = [
1014
951
  }
1015
952
  ];
1016
953
  var getWorkflows = async () => {
1017
- await loadIndex();
954
+ loadIndex();
1018
955
  const registry = getMooseInternal();
1019
956
  return registry.workflows;
1020
957
  };