@sungen/driver-api 3.1.2-beta.108 → 3.1.2-beta.109

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.ts +27 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sungen/driver-api",
3
- "version": "3.1.2-beta.108",
3
+ "version": "3.1.2-beta.109",
4
4
  "description": "Sungen API capability — the @api annotation, API catalog, OpenAPI import + `sungen api import`, and the specs/api.ts runtime template. Plugs into @sun-asterisk/sungen via the capability SPI.",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -13,7 +13,7 @@
13
13
  "author": "eqe team (engineer & quality) — Sun Asterisk",
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@sun-asterisk/sungen": "3.1.2-beta.108",
16
+ "@sun-asterisk/sungen": "3.1.2-beta.109",
17
17
  "commander": "^14.0.2",
18
18
  "yaml": "^2.8.2"
19
19
  },
package/src/index.ts CHANGED
@@ -12,11 +12,37 @@
12
12
  * template `specs-api.ts` remains in core's templates dir (emitted by the core generator via
13
13
  * `runtimeHelpers`, resolved by filename) — consistent with the base/db templates staying in core.
14
14
  */
15
+ // Import ONLY types from core (erased at runtime) — never a runtime value. A runtime import of
16
+ // @sun-asterisk/sungen forces core to be resolved when this driver loads, which fails if a stale or
17
+ // wrong-version core is on the module path (the source of repeated "Cannot find …/dist/index.js" /
18
+ // "not resolvable" install errors). Keeping core type-only makes the driver load with no core on disk.
15
19
  import type { CapabilityRegistry, Sensor, GateInput } from '@sun-asterisk/sungen';
16
- import { parseQueryOverrides } from '@sun-asterisk/sungen';
17
20
  import { resolveApi, apiParamNames, lintApiCatalog } from './api-catalog';
18
21
  import { registerApiCommand } from './cli-import';
19
22
 
23
+ /**
24
+ * Parse `name(a={{x}},b="lit",c=3)` annotation overrides → JS expressions. Inlined from core
25
+ * (was `parseQueryOverrides`) so this driver has NO runtime dependency on @sun-asterisk/sungen.
26
+ */
27
+ function parseQueryOverrides(raw?: string): Record<string, string> {
28
+ const out: Record<string, string> = {};
29
+ if (!raw) return out;
30
+ for (const part of raw.split(',')) {
31
+ const eq = part.indexOf('=');
32
+ if (eq < 0) continue;
33
+ const key = part.slice(0, eq).trim();
34
+ const val = part.slice(eq + 1).trim();
35
+ if (!key) continue;
36
+ const v = val.match(/^\{\{\s*([^}]+?)\s*\}\}$/);
37
+ const q = val.match(/^["'](.*)["']$/);
38
+ if (v) out[key] = `testData.get(${JSON.stringify(v[1])})`;
39
+ else if (q) out[key] = JSON.stringify(q[1]);
40
+ else if (/^-?\d+(?:\.\d+)?$/.test(val)) out[key] = val;
41
+ else out[key] = JSON.stringify(val);
42
+ }
43
+ return out;
44
+ }
45
+
20
46
  export { importOpenApi } from './openapi-import';
21
47
  export type { ImportedApiEntry, ImportResult } from './openapi-import';
22
48
  export { importCsv, parseCsv } from './csv-import';