@514labs/moose-lib 0.6.290-ci-9-ge4e27fd3 → 0.6.290-ci-11-gedbe6a3f

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.
@@ -1120,25 +1120,35 @@ async function getMooseUtils(req) {
1120
1120
  if (standaloneUtils) {
1121
1121
  return standaloneUtils;
1122
1122
  }
1123
- await Promise.resolve().then(() => (init_runtime(), runtime_exports));
1124
- const configRegistry = globalThis._mooseConfigRegistry;
1125
- if (!configRegistry) {
1126
- throw new Error(
1127
- "Moose not initialized. Ensure you're running within a Moose app or have proper configuration set up."
1123
+ if (initPromise) {
1124
+ return initPromise;
1125
+ }
1126
+ initPromise = (async () => {
1127
+ await Promise.resolve().then(() => (init_runtime(), runtime_exports));
1128
+ const configRegistry = globalThis._mooseConfigRegistry;
1129
+ if (!configRegistry) {
1130
+ throw new Error(
1131
+ "Moose not initialized. Ensure you're running within a Moose app or have proper configuration set up."
1132
+ );
1133
+ }
1134
+ const clickhouseConfig = await configRegistry.getStandaloneClickhouseConfig();
1135
+ const clickhouseClient = getClickhouseClient(
1136
+ toClientConfig(clickhouseConfig)
1128
1137
  );
1138
+ const queryClient = new QueryClient(clickhouseClient, "standalone");
1139
+ const mooseClient = new MooseClient(queryClient);
1140
+ standaloneUtils = {
1141
+ client: mooseClient,
1142
+ sql,
1143
+ jwt: void 0
1144
+ };
1145
+ return standaloneUtils;
1146
+ })();
1147
+ try {
1148
+ return await initPromise;
1149
+ } finally {
1150
+ initPromise = null;
1129
1151
  }
1130
- const clickhouseConfig = await configRegistry.getStandaloneClickhouseConfig();
1131
- const clickhouseClient = getClickhouseClient(
1132
- toClientConfig(clickhouseConfig)
1133
- );
1134
- const queryClient = new QueryClient(clickhouseClient, "standalone");
1135
- const mooseClient = new MooseClient(queryClient);
1136
- standaloneUtils = {
1137
- client: mooseClient,
1138
- sql,
1139
- jwt: void 0
1140
- };
1141
- return standaloneUtils;
1142
1152
  }
1143
1153
  async function getMooseClients(config) {
1144
1154
  console.warn(
@@ -1163,7 +1173,7 @@ async function getMooseClients(config) {
1163
1173
  const utils = await getMooseUtils();
1164
1174
  return { client: utils.client };
1165
1175
  }
1166
- var standaloneUtils, toClientConfig;
1176
+ var standaloneUtils, initPromise, toClientConfig;
1167
1177
  var init_standalone = __esm({
1168
1178
  "src/consumption-apis/standalone.ts"() {
1169
1179
  "use strict";
@@ -1171,6 +1181,7 @@ var init_standalone = __esm({
1171
1181
  init_commons();
1172
1182
  init_sqlHelpers();
1173
1183
  standaloneUtils = null;
1184
+ initPromise = null;
1174
1185
  toClientConfig = (config) => ({
1175
1186
  ...config,
1176
1187
  useSSL: config.useSSL ? "true" : "false"