@514labs/moose-lib 0.6.290-ci-8-g57f77993 → 0.6.290-ci-10-gaf565d22

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.
@@ -1127,30 +1127,42 @@ async function getMooseUtils(req) {
1127
1127
  if (runtimeContext) {
1128
1128
  return {
1129
1129
  client: runtimeContext.client,
1130
- sql
1130
+ sql,
1131
+ jwt: runtimeContext.jwt
1131
1132
  };
1132
1133
  }
1133
1134
  if (standaloneUtils) {
1134
1135
  return standaloneUtils;
1135
1136
  }
1136
- await Promise.resolve().then(() => (init_runtime(), runtime_exports));
1137
- const configRegistry = globalThis._mooseConfigRegistry;
1138
- if (!configRegistry) {
1139
- throw new Error(
1140
- "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)
1141
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;
1142
1165
  }
1143
- const clickhouseConfig = await configRegistry.getStandaloneClickhouseConfig();
1144
- const clickhouseClient = getClickhouseClient(
1145
- toClientConfig(clickhouseConfig)
1146
- );
1147
- const queryClient = new QueryClient(clickhouseClient, "standalone");
1148
- const mooseClient = new MooseClient(queryClient);
1149
- standaloneUtils = {
1150
- client: mooseClient,
1151
- sql
1152
- };
1153
- return standaloneUtils;
1154
1166
  }
1155
1167
  async function getMooseClients(config) {
1156
1168
  console.warn(
@@ -1175,7 +1187,7 @@ async function getMooseClients(config) {
1175
1187
  const utils = await getMooseUtils();
1176
1188
  return { client: utils.client };
1177
1189
  }
1178
- var standaloneUtils, toClientConfig;
1190
+ var standaloneUtils, initPromise, toClientConfig;
1179
1191
  var init_standalone = __esm({
1180
1192
  "src/consumption-apis/standalone.ts"() {
1181
1193
  "use strict";
@@ -1183,6 +1195,7 @@ var init_standalone = __esm({
1183
1195
  init_commons();
1184
1196
  init_sqlHelpers();
1185
1197
  standaloneUtils = null;
1198
+ initPromise = null;
1186
1199
  toClientConfig = (config) => ({
1187
1200
  ...config,
1188
1201
  useSSL: config.useSSL ? "true" : "false"