@qvac/sdk 0.12.1 → 0.12.2

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.
@@ -2,7 +2,7 @@ import { type QvacConfig } from "./config-utils";
2
2
  /**
3
3
  * Resolution order for Bare:
4
4
  * 1. QVAC_CONFIG_PATH environment variable
5
- * 2. Config file in project root (qvac.config.ts, qvac.config.js, qvac.config.json)
5
+ * 2. Config file in project root (qvac.config.js, qvac.config.json)
6
6
  * 3. SDK defaults
7
7
  */
8
8
  export declare function resolveConfig(): Promise<QvacConfig | undefined>;
@@ -5,9 +5,10 @@
5
5
  import fs from "bare-fs";
6
6
  import path from "bare-path";
7
7
  import process from "bare-process";
8
- import { validateConfig, parseJsonConfig, } from "./config-utils.js";
9
- import { ConfigFileParseFailedError } from "../../utils/errors-client.js";
8
+ import { validateConfig } from "./config-utils.js";
9
+ import { ConfigFileInvalidError, ConfigFileParseFailedError, } from "../../utils/errors-client.js";
10
10
  import { getClientLogger } from "../../logging/index.js";
11
+ const SUPPORTED_CONFIG_FILE_EXTS = [".js", ".json"];
11
12
  const logger = getClientLogger();
12
13
  function findProjectRoot() {
13
14
  return process.cwd();
@@ -15,19 +16,16 @@ function findProjectRoot() {
15
16
  function fileExists(filePath) {
16
17
  return fs.existsSync(filePath);
17
18
  }
18
- function readFile(filePath) {
19
- const result = fs.readFileSync(filePath, "utf-8");
20
- return typeof result === "string" ? result : result.toString("utf-8");
21
- }
22
- function loadJsonConfig(filePath) {
23
- const content = readFile(filePath);
24
- const parsed = parseJsonConfig(content, filePath);
25
- return validateConfig(parsed);
19
+ function assertBareConfigExtension(filePath) {
20
+ const ext = path.extname(filePath).toLowerCase();
21
+ if (!SUPPORTED_CONFIG_FILE_EXTS.includes(ext)) {
22
+ throw new ConfigFileInvalidError(filePath, "Given config file format unsupported on this platform. Use qvac.config.js or qvac.config.json in the project root, or set QVAC_CONFIG_PATH to a .js or .json file.");
23
+ }
26
24
  }
27
- async function loadJsConfig(filePath) {
25
+ function loadConfigFromPath(filePath) {
26
+ assertBareConfigExtension(filePath);
28
27
  try {
29
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
30
- const configModule = await import(filePath);
28
+ const configModule = require(filePath);
31
29
  return validateConfig(configModule.default || configModule);
32
30
  }
33
31
  catch (error) {
@@ -35,15 +33,11 @@ async function loadJsConfig(filePath) {
35
33
  }
36
34
  }
37
35
  function findConfigFile(searchDir) {
38
- const configFiles = [
39
- { name: "qvac.config.ts", type: "ts" },
40
- { name: "qvac.config.js", type: "js" },
41
- { name: "qvac.config.json", type: "json" },
42
- ];
43
- for (const { name, type } of configFiles) {
36
+ const configFiles = SUPPORTED_CONFIG_FILE_EXTS.map((ext) => `qvac.config${ext}`);
37
+ for (const name of configFiles) {
44
38
  const filePath = path.resolve(searchDir, name);
45
39
  if (fileExists(filePath)) {
46
- return { path: filePath, type };
40
+ return filePath;
47
41
  }
48
42
  }
49
43
  return undefined;
@@ -51,34 +45,26 @@ function findConfigFile(searchDir) {
51
45
  /**
52
46
  * Resolution order for Bare:
53
47
  * 1. QVAC_CONFIG_PATH environment variable
54
- * 2. Config file in project root (qvac.config.ts, qvac.config.js, qvac.config.json)
48
+ * 2. Config file in project root (qvac.config.js, qvac.config.json)
55
49
  * 3. SDK defaults
56
50
  */
51
+ // eslint-disable-next-line @typescript-eslint/require-await -- matches Node/Expo resolver signature
57
52
  export async function resolveConfig() {
58
53
  const configPath = process.env["QVAC_CONFIG_PATH"];
59
54
  if (configPath) {
60
55
  const normalizedPath = path.resolve(configPath);
61
56
  if (fileExists(normalizedPath)) {
62
- const ext = normalizedPath.endsWith(".json")
63
- ? "json"
64
- : normalizedPath.endsWith(".ts")
65
- ? "ts"
66
- : "js";
67
- const config = ext === "json"
68
- ? loadJsonConfig(normalizedPath)
69
- : await loadJsConfig(normalizedPath);
57
+ const config = loadConfigFromPath(normalizedPath);
70
58
  logger.info(`✅ Loaded config from: ${normalizedPath}`);
71
59
  return config;
72
60
  }
73
61
  }
74
62
  const projectRoot = findProjectRoot();
75
63
  if (projectRoot) {
76
- const configFile = findConfigFile(projectRoot);
77
- if (configFile) {
78
- const config = configFile.type === "json"
79
- ? loadJsonConfig(configFile.path)
80
- : await loadJsConfig(configFile.path);
81
- logger.info(`✅ Loaded config from: ${configFile.path}`);
64
+ const configFilePath = findConfigFile(projectRoot);
65
+ if (configFilePath) {
66
+ const config = loadConfigFromPath(configFilePath);
67
+ logger.info(`✅ Loaded config from: ${configFilePath}`);
82
68
  return config;
83
69
  }
84
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/sdk",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -131,6 +131,11 @@
131
131
  "types": "./dist/commands/index.d.ts",
132
132
  "import": "./dist/commands/index.js"
133
133
  },
134
+ "./models": {
135
+ "types": "./dist/models/registry/index.d.ts",
136
+ "import": "./dist/models/registry/index.js",
137
+ "require": "./dist/models/registry/index.js"
138
+ },
134
139
  "./pear-pre": "./dist/pear/pre.js"
135
140
  },
136
141
  "imports": {