@mgamadeus/ddd-web 0.6.1 → 0.6.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.
@@ -412,6 +412,9 @@ Idempotent; an existing symlink is repointed, a real file or directory is never
412
412
  | `No tag for <endpoint> — no cache tags generated` | Operation without a matching tag: add a tag on the backend controller or an `endpointOverrides` |
413
413
  | `--schema needs exactly one api` | Combine with `--api <exportName>` |
414
414
  | `All apis must share one output directory when modelsDir is not set` | Set `modelsDir` |
415
+ | `Cannot find module 'ajv/dist/core'` (or another ajv 8 module) while the generator loads | A consumer with `legacy-peer-deps` and an `ajv` 6 at the top of `node_modules`: since 0.6.2 the generator answers the parser's `ajv` from its own `ajv` 8 — update the package |
416
+ | The type check is slow or reports errors your compiler does not | It ran another compiler: since 0.6.2 it takes the project's `typescript` through its package.json `bin` (TypeScript 7 included) and logs `Type check with TypeScript <version> (the project's compiler)` |
417
+ | A polling read aborts with no visible reason (`subscribe: false`, `keepUnusedDataFor: 0`) | The removal timer of the previous answer removes the cache entry and aborts the next identical read. Subscribe while the read runs and unsubscribe after the answer: `const read = dispatch(api.endpoints.x.initiate(arg, { forceRefetch: true })); try { return await read.unwrap(); } finally { read.unsubscribe(); }` |
415
418
  | `type check failed — previous output restored` | Fix the reported type error (often app code using a renamed hook), or `--skip-tsc` to inspect |
416
419
  | A list does not refresh after a write | `<stem>Enhanced.ts` not imported; or the write has no tag — see section 3 |
417
420
  | A screen shows stale data after a write that changes more than its own entity | Writes invalidate by identity since 0.3 — add an `invalidation` resolver for that endpoint (section 3), or `broadInvalidation` for the 0.2 behaviour |
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.2
4
+
5
+ ### Fixed
6
+ - The generator loads in a consumer that installs with `legacy-peer-deps` and has `ajv` 6 at the top of
7
+ `node_modules`: the `ajv` lookups of `ajv-draft-04` (the OpenAPI parser's) are answered from the parser's own `ajv`
8
+ 8, and the codegen is loaded after that hook.
9
+ - The closing type check runs the PROJECT's compiler, found through `typescript/package.json` `bin` (TypeScript 7
10
+ exports no `typescript/bin/tsc`; the check fell back silently to the codegen's older TypeScript), and logs which one
11
+ ran. The generator's own compiler only when the project has no `typescript`.
12
+ - Troubleshooting: a polling read with `subscribe: false` and `keepUnusedDataFor: 0` is aborted by the removal timer of
13
+ the previous answer — subscribe while the read runs, unsubscribe after the answer.
14
+
3
15
  ## 0.6.1
4
16
 
5
17
  ### Fixed
@@ -96,17 +96,17 @@ var SdkGenerationError = class extends Error {
96
96
  var HTTP_METHODS = ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
97
97
  function listOperations(doc) {
98
98
  const result = [];
99
- for (const [path10, item] of Object.entries(doc.paths ?? {})) {
99
+ for (const [path11, item] of Object.entries(doc.paths ?? {})) {
100
100
  if (!item) continue;
101
101
  for (const method of HTTP_METHODS) {
102
102
  const operation = item[method];
103
- if (operation) result.push({ method, path: path10, operation });
103
+ if (operation) result.push({ method, path: path11, operation });
104
104
  }
105
105
  }
106
106
  return result;
107
107
  }
108
- function operationKey(method, path10) {
109
- return `${method.toUpperCase()} ${path10}`;
108
+ function operationKey(method, path11) {
109
+ return `${method.toUpperCase()} ${path11}`;
110
110
  }
111
111
 
112
112
  // src/codegen/tags.ts
@@ -163,9 +163,9 @@ function segmentToPascal(segment) {
163
163
  if (/[A-Z]/.test(segment)) return segment;
164
164
  return segment.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
165
165
  }
166
- function tagFromPath(path10, lookup) {
166
+ function tagFromPath(path11, lookup) {
167
167
  let matched = null;
168
- for (const segment of path10.replace(/\{[^}]+\}/g, "").split("/").filter(Boolean)) {
168
+ for (const segment of path11.replace(/\{[^}]+\}/g, "").split("/").filter(Boolean)) {
169
169
  matched = lookup.get(segmentToPascal(segment).toLowerCase()) ?? matched;
170
170
  }
171
171
  return matched;
@@ -177,11 +177,11 @@ function tagFromOperation(info, audience, lookup) {
177
177
  }
178
178
  return null;
179
179
  }
180
- function trailingPlaceholder(path10) {
181
- return path10.match(/\{([^}]+)\}\/?$/)?.[1] ?? null;
180
+ function trailingPlaceholder(path11) {
181
+ return path11.match(/\{([^}]+)\}\/?$/)?.[1] ?? null;
182
182
  }
183
- function isPrimaryEntityPath(path10, tag) {
184
- const segments = path10.replace(/\{[^}]+\}\/?$/, "").split("/").filter(Boolean);
183
+ function isPrimaryEntityPath(path11, tag) {
184
+ const segments = path11.replace(/\{[^}]+\}\/?$/, "").split("/").filter(Boolean);
185
185
  const last = segments[segments.length - 1];
186
186
  return last !== void 0 && segmentToPascal(last).toLowerCase() === tag.toLowerCase();
187
187
  }
@@ -220,9 +220,9 @@ function singularForms(tag) {
220
220
  if (lower.endsWith("s")) forms.add(lower.slice(0, -1));
221
221
  return [...forms];
222
222
  }
223
- function identityPathParameter(path10, tag) {
223
+ function identityPathParameter(path11, tag) {
224
224
  const singulars = singularForms(tag);
225
- const segments = path10.split("/").filter(Boolean);
225
+ const segments = path11.split("/").filter(Boolean);
226
226
  let found = null;
227
227
  segments.forEach((segment, index) => {
228
228
  const name = segment.match(/^\{([^}]+)\}$/)?.[1];
@@ -528,7 +528,7 @@ function validateSpec(doc, source, logger) {
528
528
  // src/codegen/generate.ts
529
529
  import * as fs8 from "fs";
530
530
  import * as os from "os";
531
- import * as path8 from "path";
531
+ import * as path9 from "path";
532
532
 
533
533
  // src/codegen/typescript.ts
534
534
  import { createRequire } from "module";
@@ -604,8 +604,8 @@ function readEndpoint(ts, key, buildType, call, sourceFile, location, logger) {
604
604
  logger.warn(`No extractable URL for endpoint "${key}" \u2014 skipping.`);
605
605
  return null;
606
606
  }
607
- const path10 = location?.path ?? toOpenApiPath(url);
608
- const placeholders = [...path10.matchAll(/\{([^}]+)\}/g)].map((match) => match[1]);
607
+ const path11 = location?.path ?? toOpenApiPath(url);
608
+ const placeholders = [...path11.matchAll(/\{([^}]+)\}/g)].map((match) => match[1]);
609
609
  const pathArgs = {};
610
610
  placeholders.forEach((name, index) => {
611
611
  const accessor = accessors[index];
@@ -616,7 +616,7 @@ function readEndpoint(ts, key, buildType, call, sourceFile, location, logger) {
616
616
  buildType,
617
617
  url,
618
618
  method: (location?.method ?? method ?? "GET").toUpperCase(),
619
- path: path10,
619
+ path: path11,
620
620
  pathArgs,
621
621
  ...bodyArg ? { bodyArg } : {},
622
622
  ...responseType ? { responseType } : {}
@@ -702,24 +702,46 @@ async function formatFiles(files) {
702
702
  files.set(filePath, await prettier.format(files.get(filePath), { ...options, filepath: filePath }));
703
703
  }
704
704
  }
705
- function resolveTsc(rootDir) {
706
- const candidates = [path3.join(rootDir, "package.json"), import.meta.url];
707
- for (const base of candidates) {
708
- try {
709
- return createRequire2(base).resolve("typescript/bin/tsc");
710
- } catch {
711
- }
705
+ function resolveTscOfInstallation(base) {
706
+ let packageJsonPath;
707
+ try {
708
+ packageJsonPath = createRequire2(base).resolve("typescript/package.json");
709
+ } catch {
710
+ return null;
712
711
  }
713
- const codegen = createRequire2(import.meta.url).resolve("@rtk-query/codegen-openapi");
714
- return createRequire2(codegen).resolve("typescript/bin/tsc");
712
+ const packageJson = JSON.parse(fs4.readFileSync(packageJsonPath, "utf-8"));
713
+ const binEntry = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin?.tsc;
714
+ if (!binEntry) return null;
715
+ const executable = path3.resolve(path3.dirname(packageJsonPath), binEntry);
716
+ return fs4.existsSync(executable) ? { executable, version: packageJson.version ?? "unknown" } : null;
717
+ }
718
+ function resolveTypeScriptCompiler(rootDir) {
719
+ const projectCompiler = resolveTscOfInstallation(path3.join(rootDir, "package.json"));
720
+ if (projectCompiler) return { ...projectCompiler, origin: "project" };
721
+ const ownRequire = createRequire2(import.meta.url);
722
+ for (const base of [import.meta.url, ownRequire.resolve("@rtk-query/codegen-openapi")]) {
723
+ const generatorCompiler = resolveTscOfInstallation(base);
724
+ if (generatorCompiler) return { ...generatorCompiler, origin: "generator" };
725
+ }
726
+ throw new SdkGenerationError("No TypeScript compiler found for the type check (install typescript in the project, or pass --skip-tsc).");
727
+ }
728
+ function buildCompilerCommand(executable, args) {
729
+ if (/\.(c|m)?js$/.test(executable)) return [process.execPath, [executable, ...args]];
730
+ const head = fs4.readFileSync(executable).subarray(0, 100).toString("latin1");
731
+ return head.startsWith("#!") && head.split("\n", 1)[0].includes("node") ? [process.execPath, [executable, ...args]] : [executable, args];
715
732
  }
716
733
  function typecheck(rootDir, tsconfig, logger) {
717
734
  if (!fs4.existsSync(tsconfig)) {
718
735
  logger.warn(`No ${path3.relative(rootDir, tsconfig) || tsconfig} \u2014 skipping the type check.`);
719
736
  return false;
720
737
  }
738
+ const compiler = resolveTypeScriptCompiler(rootDir);
739
+ logger.info(
740
+ `Type check with TypeScript ${compiler.version} (${compiler.origin === "project" ? "the project's compiler" : "the generator's own compiler \u2014 the project has no typescript"}).`
741
+ );
742
+ const [command, args] = buildCompilerCommand(compiler.executable, ["--noEmit", "-p", tsconfig]);
721
743
  try {
722
- execFileSync(process.execPath, [resolveTsc(rootDir), "--noEmit", "-p", tsconfig], {
744
+ execFileSync(command, args, {
723
745
  cwd: rootDir,
724
746
  stdio: ["ignore", "pipe", "pipe"],
725
747
  encoding: "utf-8"
@@ -751,9 +773,9 @@ function testPattern(pattern, value) {
751
773
  pattern.lastIndex = 0;
752
774
  return result;
753
775
  }
754
- function matchesOperation(override, method, path10) {
776
+ function matchesOperation(override, method, path11) {
755
777
  if (override.method && override.method.toLowerCase() !== method) return false;
756
- return typeof override.path === "string" ? override.path === path10 : testPattern(override.path, path10);
778
+ return typeof override.path === "string" ? override.path === path11 : testPattern(override.path, path11);
757
779
  }
758
780
  function canonical(value) {
759
781
  return JSON.stringify(
@@ -777,9 +799,9 @@ function isEntityExtension(value) {
777
799
  }
778
800
  function indexOperations(doc, overrides, skipUpdatePostTwins) {
779
801
  const byKey = /* @__PURE__ */ new Map();
780
- for (const { method, path: path10, operation } of listOperations(doc)) {
802
+ for (const { method, path: path11, operation } of listOperations(doc)) {
781
803
  const extension = operation["x-ddd-side-effects"];
782
- const override = overrides.find((candidate) => matchesOperation(candidate, method, path10));
804
+ const override = overrides.find((candidate) => matchesOperation(candidate, method, path11));
783
805
  let sideEffects = hasSideEffects(method, operation);
784
806
  let explicit = false;
785
807
  if (typeof extension === "boolean") {
@@ -793,9 +815,9 @@ function indexOperations(doc, overrides, skipUpdatePostTwins) {
793
815
  const classifiedType = explicit ? sideEffects ? "mutation" : "query" : naturalType;
794
816
  const endpointType = typeof extension !== "boolean" && override?.endpointType || classifiedType;
795
817
  const entity = isEntityExtension(operation["x-ddd-entity"]) ? operation["x-ddd-entity"] : void 0;
796
- byKey.set(operationKey(method, path10), {
818
+ byKey.set(operationKey(method, path11), {
797
819
  method,
798
- path: path10,
820
+ path: path11,
799
821
  operation,
800
822
  sideEffects,
801
823
  sideEffectsExplicit: explicit,
@@ -805,11 +827,11 @@ function indexOperations(doc, overrides, skipUpdatePostTwins) {
805
827
  }
806
828
  const skippedTwins = /* @__PURE__ */ new Set();
807
829
  if (skipUpdatePostTwins) {
808
- for (const [path10, item] of Object.entries(doc.paths ?? {})) {
830
+ for (const [path11, item] of Object.entries(doc.paths ?? {})) {
809
831
  const post = item?.post;
810
832
  const patch = item?.patch;
811
833
  if (post && patch && isUpsertTwin(post, patch)) {
812
- skippedTwins.add(operationKey("post", path10));
834
+ skippedTwins.add(operationKey("post", path11));
813
835
  }
814
836
  }
815
837
  }
@@ -863,10 +885,10 @@ function detectResponseKind(responses) {
863
885
  }
864
886
  function detectResponseHandlerEndpoints(doc, endpoints, overrides = []) {
865
887
  const kinds = /* @__PURE__ */ new Map();
866
- for (const { method, path: path10, operation } of listOperations(doc)) {
867
- const override = overrides.find((candidate) => matchesOperation(candidate, method, path10));
888
+ for (const { method, path: path11, operation } of listOperations(doc)) {
889
+ const override = overrides.find((candidate) => matchesOperation(candidate, method, path11));
868
890
  const kind = override ? override.handler : detectResponseKind(operation.responses);
869
- if (kind !== "json") kinds.set(operationKey(method, path10), kind);
891
+ if (kind !== "json") kinds.set(operationKey(method, path11), kind);
870
892
  }
871
893
  const keys = /* @__PURE__ */ new Map();
872
894
  if (kinds.size === 0) return keys;
@@ -1258,9 +1280,9 @@ function readMultipartOperation(doc, requestBody) {
1258
1280
  }
1259
1281
  function detectMultipartEndpoints(doc, endpoints) {
1260
1282
  const byOperation = /* @__PURE__ */ new Map();
1261
- for (const { method, path: path10, operation } of listOperations(doc)) {
1283
+ for (const { method, path: path11, operation } of listOperations(doc)) {
1262
1284
  const multipart = readMultipartOperation(doc, operation.requestBody);
1263
- if (multipart) byOperation.set(operationKey(method, path10), multipart);
1285
+ if (multipart) byOperation.set(operationKey(method, path11), multipart);
1264
1286
  }
1265
1287
  const keys = /* @__PURE__ */ new Map();
1266
1288
  if (byOperation.size === 0) return keys;
@@ -1488,34 +1510,68 @@ function resolveParameter(doc, parameter) {
1488
1510
  }
1489
1511
  function repairMissingPathParameters(doc, logger) {
1490
1512
  const repairs = [];
1491
- for (const { method, path: path10, operation } of listOperations(doc)) {
1492
- const placeholders = [...path10.matchAll(/\{([^}]+)\}/g)].map((match) => match[1]);
1513
+ for (const { method, path: path11, operation } of listOperations(doc)) {
1514
+ const placeholders = [...path11.matchAll(/\{([^}]+)\}/g)].map((match) => match[1]);
1493
1515
  if (placeholders.length === 0) continue;
1494
- const pathLevel = doc.paths?.[path10]?.parameters ?? [];
1516
+ const pathLevel = doc.paths?.[path11]?.parameters ?? [];
1495
1517
  const declared = new Set(
1496
1518
  [...pathLevel, ...operation.parameters ?? []].map((parameter) => resolveParameter(doc, parameter)).filter((parameter) => parameter !== null && parameter.in === "path").map((parameter) => parameter.name)
1497
1519
  );
1498
1520
  const missing = placeholders.filter((name) => !declared.has(name));
1499
- if (missing.length > 0) repairs.push({ path: path10, method, names: missing });
1521
+ if (missing.length > 0) repairs.push({ path: path11, method, names: missing });
1500
1522
  }
1501
1523
  if (repairs.length === 0) return doc;
1502
1524
  const copy = structuredClone(doc);
1503
- for (const { path: path10, method, names } of repairs) {
1504
- const operation = copy.paths[path10][method];
1525
+ for (const { path: path11, method, names } of repairs) {
1526
+ const operation = copy.paths[path11][method];
1505
1527
  operation.parameters = [
1506
1528
  ...names.map((name) => ({ name, in: "path", required: true, schema: { type: "string" } })),
1507
1529
  ...operation.parameters ?? []
1508
1530
  ];
1509
- logger.warn(`${method.toUpperCase()} ${path10}: path parameter(s) ${names.join(", ")} not declared in the spec \u2014 added as string.`);
1531
+ logger.warn(`${method.toUpperCase()} ${path11}: path parameter(s) ${names.join(", ")} not declared in the spec \u2014 added as string.`);
1510
1532
  }
1511
1533
  return copy;
1512
1534
  }
1513
1535
 
1514
1536
  // src/codegen/rtk.ts
1515
1537
  import * as fs6 from "fs";
1516
- import * as path6 from "path";
1517
- import { generateEndpoints } from "@rtk-query/codegen-openapi";
1538
+ import * as path7 from "path";
1518
1539
  import prettier2 from "prettier";
1540
+
1541
+ // src/codegen/module-resolution.ts
1542
+ import Module, { createRequire as createRequire3 } from "module";
1543
+ import * as path6 from "path";
1544
+ var installed = false;
1545
+ function installParserModuleResolution() {
1546
+ if (installed) return;
1547
+ installed = true;
1548
+ const require2 = createRequire3(import.meta.url);
1549
+ let parserRequire;
1550
+ try {
1551
+ const codegenRequire = createRequire3(require2.resolve("@rtk-query/codegen-openapi"));
1552
+ parserRequire = createRequire3(codegenRequire.resolve("@apidevtools/swagger-parser"));
1553
+ } catch {
1554
+ return;
1555
+ }
1556
+ const ajvDraft04Folder = `${path6.sep}ajv-draft-04${path6.sep}`;
1557
+ const moduleWithResolver = Module;
1558
+ const defaultResolveFilename = moduleWithResolver._resolveFilename;
1559
+ moduleWithResolver._resolveFilename = function resolveAjvOfTheParser(request, parent, ...rest) {
1560
+ if ((request === "ajv" || request.startsWith("ajv/")) && parent?.filename?.includes(ajvDraft04Folder)) {
1561
+ try {
1562
+ return parserRequire.resolve(request);
1563
+ } catch {
1564
+ }
1565
+ }
1566
+ return defaultResolveFilename.call(this, request, parent, ...rest);
1567
+ };
1568
+ }
1569
+ async function loadRtkCodegen() {
1570
+ installParserModuleResolution();
1571
+ return import("@rtk-query/codegen-openapi");
1572
+ }
1573
+
1574
+ // src/codegen/rtk.ts
1519
1575
  var OWN_KEYS = /* @__PURE__ */ new Set(["schemaFile", "apiFile", "outputFile", "audience", "baseApiImport", "skipUpdatePostTwins", "sideEffects", "responseHandlers", "invalidation"]);
1520
1576
  function matches(matcher, name, definition) {
1521
1577
  if (matcher === void 0) return true;
@@ -1541,7 +1597,7 @@ function mergeEndpointOverrides(userOverrides, typeOverrides) {
1541
1597
  }
1542
1598
  function relativeImport(fromDir, target) {
1543
1599
  if (!isPathLike(target)) return target;
1544
- let relative6 = path6.relative(fromDir, target).replace(/\\/g, "/");
1600
+ let relative6 = path7.relative(fromDir, target).replace(/\\/g, "/");
1545
1601
  if (!relative6.startsWith(".")) relative6 = `./${relative6}`;
1546
1602
  return relative6;
1547
1603
  }
@@ -1574,17 +1630,18 @@ async function runRtkCodegen(api, doc, index, specFile, prettierConfigFile) {
1574
1630
  filterEndpoints,
1575
1631
  ...prettierConfigFile ? { prettierConfigFile } : {}
1576
1632
  };
1577
- const code = await generateEndpoints(options);
1633
+ const { generateEndpoints: generateRtkEndpoints } = await loadRtkCodegen();
1634
+ const code = await generateRtkEndpoints(options);
1578
1635
  if (typeof code !== "string") throw new Error(`RTK codegen returned no code for ${api.stem}.`);
1579
1636
  return { code, locations };
1580
1637
  }
1581
1638
  async function findPrettierConfigFile(rootDir) {
1582
- return await prettier2.resolveConfigFile(path6.join(rootDir, "openapi-config.ts")) ?? void 0;
1639
+ return await prettier2.resolveConfigFile(path7.join(rootDir, "openapi-config.ts")) ?? void 0;
1583
1640
  }
1584
1641
 
1585
1642
  // src/codegen/workspace.ts
1586
1643
  import * as fs7 from "fs";
1587
- import * as path7 from "path";
1644
+ import * as path8 from "path";
1588
1645
  import * as readline from "readline";
1589
1646
  var DEFAULT_ENV_FILES = [".env", ".env.local"];
1590
1647
  var DEFAULT_URL_KEYS = ["NEXT_PUBLIC_API_URL", "EXPO_PUBLIC_API_URL", "VITE_API_URL", "VITE_API_ENDPOINT", "API_URL"];
@@ -1609,7 +1666,7 @@ function firstHostLabel(url) {
1609
1666
  }
1610
1667
  function sniffWorkspace(rootDir, options) {
1611
1668
  for (const file of options.envFiles ?? DEFAULT_ENV_FILES) {
1612
- const vars = parseEnvFile(path7.join(rootDir, file));
1669
+ const vars = parseEnvFile(path8.join(rootDir, file));
1613
1670
  for (const key of options.urlKeys ?? DEFAULT_URL_KEYS) {
1614
1671
  const value = vars[key];
1615
1672
  const label = value ? firstHostLabel(value) : null;
@@ -1619,11 +1676,11 @@ function sniffWorkspace(rootDir, options) {
1619
1676
  return null;
1620
1677
  }
1621
1678
  function ask(question) {
1622
- return new Promise((resolve6) => {
1679
+ return new Promise((resolve7) => {
1623
1680
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1624
- rl.on("close", () => resolve6(""));
1681
+ rl.on("close", () => resolve7(""));
1625
1682
  rl.question(question, (answer) => {
1626
- resolve6(answer.trim());
1683
+ resolve7(answer.trim());
1627
1684
  rl.close();
1628
1685
  });
1629
1686
  });
@@ -1649,9 +1706,9 @@ async function resolveWorkspace(rootDir, options, explicit, logger) {
1649
1706
  // src/codegen/generate.ts
1650
1707
  async function load(options, cwd) {
1651
1708
  if (options.config && typeof options.config === "object") {
1652
- return { config: options.config, configPath: path8.join(cwd, "<inline config>"), rootDir: cwd };
1709
+ return { config: options.config, configPath: path9.join(cwd, "<inline config>"), rootDir: cwd };
1653
1710
  }
1654
- return loadConfig(path8.resolve(cwd, options.config ?? "openapi-config.ts"));
1711
+ return loadConfig(path9.resolve(cwd, options.config ?? "openapi-config.ts"));
1655
1712
  }
1656
1713
  function selectApis(all, options) {
1657
1714
  let selected = all;
@@ -1663,14 +1720,14 @@ function selectApis(all, options) {
1663
1720
  }
1664
1721
  if (options.schema) {
1665
1722
  if (selected.length !== 1) throw new SdkGenerationError("--schema needs exactly one api (use --api).");
1666
- const schemaSource = isUrl(options.schema) ? options.schema : path8.resolve(options.cwd ?? process.cwd(), options.schema);
1723
+ const schemaSource = isUrl(options.schema) ? options.schema : path9.resolve(options.cwd ?? process.cwd(), options.schema);
1667
1724
  selected = [{ ...selected[0], schemaSource }];
1668
1725
  }
1669
1726
  return selected;
1670
1727
  }
1671
1728
  async function generateSdk(options = {}) {
1672
1729
  const logger = options.logger ?? consoleLogger;
1673
- const cwd = path8.resolve(options.cwd ?? process.cwd());
1730
+ const cwd = path9.resolve(options.cwd ?? process.cwd());
1674
1731
  let loaded = await load(options, cwd);
1675
1732
  if (loaded.config.workspace) {
1676
1733
  const value = await resolveWorkspace(loaded.rootDir, loaded.config.workspace, options.workspace, logger);
@@ -1717,14 +1774,14 @@ async function generateSdk(options = {}) {
1717
1774
  const files = new OutputFiles();
1718
1775
  if (steps.length < pipeline.length) files.seedFromDisk(modelsDir);
1719
1776
  const prettierConfigFile = await findPrettierConfigFile(loaded.rootDir);
1720
- const specDir = fs8.mkdtempSync(path8.join(os.tmpdir(), "ddd-web-spec-"));
1777
+ const specDir = fs8.mkdtempSync(path9.join(os.tmpdir(), "ddd-web-spec-"));
1721
1778
  try {
1722
1779
  for (const [i, { api, write, doc: rawDoc }] of steps.entries()) {
1723
1780
  const doc = repairMissingPathParameters(rawDoc, logger);
1724
1781
  logger.info(`\u2500\u2500 ${api.stem} (${i + 1}/${steps.length})${write ? "" : " (models only)"}`);
1725
1782
  const index = indexOperations(doc, api.sideEffects, api.skipUpdatePostTwins);
1726
1783
  if (index.skippedTwins.size > 0) logger.info(` skipping ${index.skippedTwins.size} POST twin(s) of PATCH upserts`);
1727
- const rtk = await runRtkCodegen(api, doc, index, path8.join(specDir, `${i}.json`), prettierConfigFile);
1784
+ const rtk = await runRtkCodegen(api, doc, index, path9.join(specDir, `${i}.json`), prettierConfigFile);
1728
1785
  const endpoints = parseApiEndpoints(rtk.code, logger, rtk.locations);
1729
1786
  const handlerEndpoints = detectResponseHandlerEndpoints(doc, endpoints, api.responseHandlers);
1730
1787
  const responseKinds = /* @__PURE__ */ new Map();
@@ -1766,8 +1823,8 @@ ${withHandlers}` : withHandlers);
1766
1823
  invalidation: api.invalidation,
1767
1824
  logger
1768
1825
  });
1769
- files.set(path8.join(api.outputDir, `${api.stem}Enhanced.ts`), enhanced.source);
1770
- files.set(path8.join(api.outputDir, `${api.stem}Tags.ts`), renderTagsFile(api.stem, enhanced.tagTypes));
1826
+ files.set(path9.join(api.outputDir, `${api.stem}Enhanced.ts`), enhanced.source);
1827
+ files.set(path9.join(api.outputDir, `${api.stem}Tags.ts`), renderTagsFile(api.stem, enhanced.tagTypes));
1771
1828
  }
1772
1829
  } finally {
1773
1830
  fs8.rmSync(specDir, { recursive: true, force: true });
@@ -1781,7 +1838,7 @@ ${withHandlers}` : withHandlers);
1781
1838
  if (!options.skipTsc) {
1782
1839
  logger.info("type check (tsc --noEmit)");
1783
1840
  try {
1784
- typechecked = typecheck(loaded.rootDir, path8.resolve(loaded.rootDir, loaded.config.tsconfig ?? "tsconfig.json"), logger);
1841
+ typechecked = typecheck(loaded.rootDir, path9.resolve(loaded.rootDir, loaded.config.tsconfig ?? "tsconfig.json"), logger);
1785
1842
  } catch (error) {
1786
1843
  committed.rollback();
1787
1844
  logger.error("type check failed \u2014 previous output restored");
@@ -1795,11 +1852,11 @@ ${withHandlers}` : withHandlers);
1795
1852
 
1796
1853
  // src/codegen/link-skills.ts
1797
1854
  import * as fs9 from "fs";
1798
- import * as path9 from "path";
1855
+ import * as path10 from "path";
1799
1856
  function packageLabel(packageDir) {
1800
1857
  if (packageDir) {
1801
1858
  try {
1802
- const version = JSON.parse(fs9.readFileSync(path9.join(packageDir, "package.json"), "utf-8")).version;
1859
+ const version = JSON.parse(fs9.readFileSync(path10.join(packageDir, "package.json"), "utf-8")).version;
1803
1860
  if (typeof version === "string") return `@mgamadeus/ddd-web ${version}`;
1804
1861
  } catch {
1805
1862
  }
@@ -1807,10 +1864,10 @@ function packageLabel(packageDir) {
1807
1864
  return "@mgamadeus/ddd-web";
1808
1865
  }
1809
1866
  function linkSkills(options = {}) {
1810
- const cwd = path9.resolve(options.cwd ?? process.cwd());
1867
+ const cwd = path10.resolve(options.cwd ?? process.cwd());
1811
1868
  const logger = options.logger ?? consoleLogger;
1812
- const packageDir = path9.join(cwd, "node_modules", "@mgamadeus", "ddd-web");
1813
- const sourceDir = options.sourceDir ? path9.resolve(cwd, options.sourceDir) : path9.join(packageDir, ".claude", "skills");
1869
+ const packageDir = path10.join(cwd, "node_modules", "@mgamadeus", "ddd-web");
1870
+ const sourceDir = options.sourceDir ? path10.resolve(cwd, options.sourceDir) : path10.join(packageDir, ".claude", "skills");
1814
1871
  if (!options.sourceDir && !fs9.existsSync(packageDir)) {
1815
1872
  logger.warn(`@mgamadeus/ddd-web is not installed in ${cwd} (no ${packageDir}) \u2014 nothing to link.`);
1816
1873
  return [];
@@ -1820,12 +1877,12 @@ function linkSkills(options = {}) {
1820
1877
  logger.info(`${packageLabel(options.sourceDir ? void 0 : packageDir)} ships no agent skills (${sourceDir}) \u2014 nothing to link.`);
1821
1878
  return [];
1822
1879
  }
1823
- const targetDir = path9.join(cwd, ".claude", "skills");
1880
+ const targetDir = path10.join(cwd, ".claude", "skills");
1824
1881
  fs9.mkdirSync(targetDir, { recursive: true });
1825
1882
  const results = [];
1826
1883
  for (const entry of skills) {
1827
- const linkPath = path9.join(targetDir, entry.name);
1828
- const linkTarget = path9.relative(targetDir, path9.join(sourceDir, entry.name));
1884
+ const linkPath = path10.join(targetDir, entry.name);
1885
+ const linkTarget = path10.relative(targetDir, path10.join(sourceDir, entry.name));
1829
1886
  let action;
1830
1887
  const existing = fs9.lstatSync(linkPath, { throwIfNoEntry: false });
1831
1888
  if (!existing) {
@@ -1861,4 +1918,4 @@ export {
1861
1918
  generateSdk,
1862
1919
  linkSkills
1863
1920
  };
1864
- //# sourceMappingURL=chunk-EI2J6H2U.js.map
1921
+ //# sourceMappingURL=chunk-RCXFU5IA.js.map