@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.mjs CHANGED
@@ -699,96 +699,33 @@ var getMooseInternal = () => globalThis.moose_internal;
699
699
  if (getMooseInternal() === void 0) {
700
700
  globalThis.moose_internal = moose_internal;
701
701
  }
702
- var indexLoadState = "unloaded";
703
- var indexLoadPromise = null;
704
- var loadIndex = async () => {
705
- const workerInfo = `[Worker ${process2.pid}]`;
706
- if (indexLoadState === "loaded") {
707
- console.log(
708
- `${workerInfo} loadIndex: already loaded, returning immediately`
709
- );
710
- return;
711
- }
712
- if (indexLoadState === "loading" && indexLoadPromise) {
713
- console.log(
714
- `${workerInfo} loadIndex: already loading, waiting for completion`
715
- );
716
- return indexLoadPromise;
717
- }
718
- console.log(`${workerInfo} loadIndex: starting load process`);
719
- const startTime = Date.now();
720
- const delay = Math.random() * 500;
721
- console.log(
722
- `${workerInfo} loadIndex: waiting ${delay.toFixed(0)}ms to stagger load`
723
- );
724
- await new Promise((resolve) => setTimeout(resolve, delay));
725
- if (indexLoadState === "loading" && indexLoadPromise) {
726
- console.log(
727
- `${workerInfo} loadIndex: another worker started loading during delay, waiting`
728
- );
729
- return indexLoadPromise;
730
- }
731
- if (indexLoadState === "loaded") {
732
- console.log(
733
- `${workerInfo} loadIndex: loaded by another worker during delay`
734
- );
735
- return;
702
+ var loadIndex = () => {
703
+ const registry = getMooseInternal();
704
+ registry.tables.clear();
705
+ registry.streams.clear();
706
+ registry.ingestApis.clear();
707
+ registry.apis.clear();
708
+ registry.sqlResources.clear();
709
+ registry.workflows.clear();
710
+ registry.webApps.clear();
711
+ const appDir = `${process2.cwd()}/${getSourceDir()}`;
712
+ Object.keys(__require.cache).forEach((key) => {
713
+ if (key.startsWith(appDir)) {
714
+ delete __require.cache[key];
715
+ }
716
+ });
717
+ try {
718
+ __require(`${process2.cwd()}/${getSourceDir()}/index.ts`);
719
+ } catch (error) {
720
+ let hint;
721
+ const details = error instanceof Error ? error.message : String(error);
722
+ if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
723
+ 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";
724
+ }
725
+ const errorMsg = `${hint ?? ""}${details}`;
726
+ const cause = error instanceof Error ? error : void 0;
727
+ throw new Error(errorMsg, { cause });
736
728
  }
737
- indexLoadState = "loading";
738
- indexLoadPromise = (async () => {
739
- try {
740
- console.log(`${workerInfo} loadIndex: clearing registry...`);
741
- const clearStart = Date.now();
742
- const registry = getMooseInternal();
743
- registry.tables.clear();
744
- registry.streams.clear();
745
- registry.ingestApis.clear();
746
- registry.apis.clear();
747
- registry.sqlResources.clear();
748
- registry.workflows.clear();
749
- registry.webApps.clear();
750
- console.log(
751
- `${workerInfo} loadIndex: registry cleared in ${Date.now() - clearStart}ms`
752
- );
753
- console.log(`${workerInfo} loadIndex: clearing require cache...`);
754
- const cacheStart = Date.now();
755
- const appDir = `${process2.cwd()}/${getSourceDir()}`;
756
- Object.keys(__require.cache).forEach((key) => {
757
- if (key.startsWith(appDir)) {
758
- delete __require.cache[key];
759
- }
760
- });
761
- console.log(
762
- `${workerInfo} loadIndex: require cache cleared in ${Date.now() - cacheStart}ms`
763
- );
764
- console.log(`${workerInfo} loadIndex: requiring index.ts...`);
765
- const requireStart = Date.now();
766
- __require(`${process2.cwd()}/${getSourceDir()}/index.ts`);
767
- console.log(
768
- `${workerInfo} loadIndex: require completed in ${Date.now() - requireStart}ms`
769
- );
770
- indexLoadState = "loaded";
771
- console.log(
772
- `${workerInfo} loadIndex: total load time ${Date.now() - startTime}ms`
773
- );
774
- } catch (error) {
775
- console.error(
776
- `${workerInfo} loadIndex: FAILED after ${Date.now() - startTime}ms`,
777
- error
778
- );
779
- indexLoadState = "unloaded";
780
- indexLoadPromise = null;
781
- let hint;
782
- const details = error instanceof Error ? error.message : String(error);
783
- if (details.includes("ERR_REQUIRE_ESM") || details.includes("ES Module")) {
784
- 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";
785
- }
786
- const errorMsg = `${hint ?? ""}${details}`;
787
- const cause = error instanceof Error ? error : void 0;
788
- throw new Error(errorMsg, { cause });
789
- }
790
- })();
791
- return indexLoadPromise;
792
729
  };
793
730
  var dlqSchema = {
794
731
  version: "3.1",
@@ -910,7 +847,7 @@ var dlqColumns = [
910
847
  }
911
848
  ];
912
849
  var getWorkflows = async () => {
913
- await loadIndex();
850
+ loadIndex();
914
851
  const registry = getMooseInternal();
915
852
  return registry.workflows;
916
853
  };