@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.
@@ -1113,30 +1113,42 @@ async function getMooseUtils(req) {
1113
1113
  if (runtimeContext) {
1114
1114
  return {
1115
1115
  client: runtimeContext.client,
1116
- sql
1116
+ sql,
1117
+ jwt: runtimeContext.jwt
1117
1118
  };
1118
1119
  }
1119
1120
  if (standaloneUtils) {
1120
1121
  return standaloneUtils;
1121
1122
  }
1122
- await Promise.resolve().then(() => (init_runtime(), runtime_exports));
1123
- const configRegistry = globalThis._mooseConfigRegistry;
1124
- if (!configRegistry) {
1125
- throw new Error(
1126
- "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)
1127
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;
1128
1151
  }
1129
- const clickhouseConfig = await configRegistry.getStandaloneClickhouseConfig();
1130
- const clickhouseClient = getClickhouseClient(
1131
- toClientConfig(clickhouseConfig)
1132
- );
1133
- const queryClient = new QueryClient(clickhouseClient, "standalone");
1134
- const mooseClient = new MooseClient(queryClient);
1135
- standaloneUtils = {
1136
- client: mooseClient,
1137
- sql
1138
- };
1139
- return standaloneUtils;
1140
1152
  }
1141
1153
  async function getMooseClients(config) {
1142
1154
  console.warn(
@@ -1161,7 +1173,7 @@ async function getMooseClients(config) {
1161
1173
  const utils = await getMooseUtils();
1162
1174
  return { client: utils.client };
1163
1175
  }
1164
- var standaloneUtils, toClientConfig;
1176
+ var standaloneUtils, initPromise, toClientConfig;
1165
1177
  var init_standalone = __esm({
1166
1178
  "src/consumption-apis/standalone.ts"() {
1167
1179
  "use strict";
@@ -1169,6 +1181,7 @@ var init_standalone = __esm({
1169
1181
  init_commons();
1170
1182
  init_sqlHelpers();
1171
1183
  standaloneUtils = null;
1184
+ initPromise = null;
1172
1185
  toClientConfig = (config) => ({
1173
1186
  ...config,
1174
1187
  useSSL: config.useSSL ? "true" : "false"