@xylex-group/athena 1.6.0 → 1.6.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # athena-js
2
2
 
3
- current version: `1.6.0`
3
+ current version: `1.6.1`
4
4
  `@xylex-group/athena` is a database driver and API gateway SDK that lets you interact with SQL backends over HTTP through a fluent builder API. It ships a typed query builder for Node.js / server environments plus Athena-native React hooks for client-side use.
5
5
 
6
6
  ## Install
@@ -331,6 +331,13 @@ function normalizeOutputConfig(output) {
331
331
  }
332
332
  };
333
333
  }
334
+ function isAthenaGeneratorConfig(value) {
335
+ if (!value || typeof value !== "object") {
336
+ return false;
337
+ }
338
+ const record = value;
339
+ return Boolean(record.provider && typeof record.provider === "object") && Boolean(record.output && typeof record.output === "object");
340
+ }
334
341
  function normalizeGeneratorConfig(input) {
335
342
  return {
336
343
  provider: input.provider,
@@ -359,18 +366,41 @@ function findGeneratorConfigPath(cwd = process.cwd()) {
359
366
  return void 0;
360
367
  }
361
368
  function extractConfigExport(module) {
362
- if (module && typeof module === "object") {
363
- const record = module;
369
+ const visited = /* @__PURE__ */ new Set();
370
+ const queue = [module];
371
+ while (queue.length > 0) {
372
+ const current = queue.shift();
373
+ if (!current || typeof current !== "object" || visited.has(current)) {
374
+ continue;
375
+ }
376
+ visited.add(current);
377
+ const record = current;
378
+ if (isAthenaGeneratorConfig(record)) {
379
+ return record;
380
+ }
364
381
  const defaultExport = record.default;
365
382
  if (defaultExport && typeof defaultExport === "object") {
366
- return defaultExport;
383
+ queue.push(defaultExport);
367
384
  }
368
385
  const namedConfigExport = record.config;
369
386
  if (namedConfigExport && typeof namedConfigExport === "object") {
370
- return namedConfigExport;
387
+ queue.push(namedConfigExport);
388
+ }
389
+ const moduleExports = record["module.exports"];
390
+ if (moduleExports && typeof moduleExports === "object") {
391
+ queue.push(moduleExports);
371
392
  }
372
393
  }
373
- throw new Error("Generator config file must export a config object as default export or `config`.");
394
+ throw new Error(
395
+ "Generator config file must export a config object as default export or `config`."
396
+ );
397
+ }
398
+ function importConfigModule(moduleSpecifier) {
399
+ const runtimeImport = new Function(
400
+ "moduleSpecifier",
401
+ "return import(moduleSpecifier)"
402
+ );
403
+ return runtimeImport(moduleSpecifier);
374
404
  }
375
405
  async function loadGeneratorConfig(options = {}) {
376
406
  const cwd = options.cwd ?? process.cwd();
@@ -381,7 +411,7 @@ async function loadGeneratorConfig(options = {}) {
381
411
  );
382
412
  }
383
413
  const moduleUrl = url.pathToFileURL(resolvedPath);
384
- const module = await import(`${moduleUrl.href}?cacheBust=${Date.now()}`);
414
+ const module = await importConfigModule(`${moduleUrl.href}?cacheBust=${Date.now()}`);
385
415
  const rawConfig = extractConfigExport(module);
386
416
  return {
387
417
  configPath: resolvedPath,