@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.
@@ -1134,25 +1134,35 @@ async function getMooseUtils(req) {
1134
1134
  if (standaloneUtils) {
1135
1135
  return standaloneUtils;
1136
1136
  }
1137
- await Promise.resolve().then(() => (init_runtime(), runtime_exports));
1138
- const configRegistry = globalThis._mooseConfigRegistry;
1139
- if (!configRegistry) {
1140
- throw new Error(
1141
- "Moose not initialized. Ensure you're running within a Moose app or have proper configuration set up."
1137
+ if (initPromise) {
1138
+ return initPromise;
1139
+ }
1140
+ initPromise = (async () => {
1141
+ await Promise.resolve().then(() => (init_runtime(), runtime_exports));
1142
+ const configRegistry = globalThis._mooseConfigRegistry;
1143
+ if (!configRegistry) {
1144
+ throw new Error(
1145
+ "Moose not initialized. Ensure you're running within a Moose app or have proper configuration set up."
1146
+ );
1147
+ }
1148
+ const clickhouseConfig = await configRegistry.getStandaloneClickhouseConfig();
1149
+ const clickhouseClient = getClickhouseClient(
1150
+ toClientConfig(clickhouseConfig)
1142
1151
  );
1152
+ const queryClient = new QueryClient(clickhouseClient, "standalone");
1153
+ const mooseClient = new MooseClient(queryClient);
1154
+ standaloneUtils = {
1155
+ client: mooseClient,
1156
+ sql,
1157
+ jwt: void 0
1158
+ };
1159
+ return standaloneUtils;
1160
+ })();
1161
+ try {
1162
+ return await initPromise;
1163
+ } finally {
1164
+ initPromise = null;
1143
1165
  }
1144
- const clickhouseConfig = await configRegistry.getStandaloneClickhouseConfig();
1145
- const clickhouseClient = getClickhouseClient(
1146
- toClientConfig(clickhouseConfig)
1147
- );
1148
- const queryClient = new QueryClient(clickhouseClient, "standalone");
1149
- const mooseClient = new MooseClient(queryClient);
1150
- standaloneUtils = {
1151
- client: mooseClient,
1152
- sql,
1153
- jwt: void 0
1154
- };
1155
- return standaloneUtils;
1156
1166
  }
1157
1167
  async function getMooseClients(config) {
1158
1168
  console.warn(
@@ -1177,7 +1187,7 @@ async function getMooseClients(config) {
1177
1187
  const utils = await getMooseUtils();
1178
1188
  return { client: utils.client };
1179
1189
  }
1180
- var standaloneUtils, toClientConfig;
1190
+ var standaloneUtils, initPromise, toClientConfig;
1181
1191
  var init_standalone = __esm({
1182
1192
  "src/consumption-apis/standalone.ts"() {
1183
1193
  "use strict";
@@ -1185,6 +1195,7 @@ var init_standalone = __esm({
1185
1195
  init_commons();
1186
1196
  init_sqlHelpers();
1187
1197
  standaloneUtils = null;
1198
+ initPromise = null;
1188
1199
  toClientConfig = (config) => ({
1189
1200
  ...config,
1190
1201
  useSSL: config.useSSL ? "true" : "false"