@mgamadeus/ddd-web 0.17.1 → 0.19.0

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.
@@ -4,17 +4,18 @@ import {
4
4
  consoleLogger,
5
5
  generateSdk,
6
6
  runSkillLinks
7
- } from "../chunk-3V22MYDI.js";
7
+ } from "../chunk-HZ4VYIHY.js";
8
8
 
9
9
  // src/codegen/cli.ts
10
10
  import { parseArgs } from "util";
11
11
  var HELP = `Usage:
12
- ddd-web-sdk [options] Generate the RTK Query SDK (same as "ddd-web sdk")
12
+ ddd-web-sdk [options] Generate the SDK (same as "ddd-web sdk")
13
13
  ddd-web sdk [options]
14
14
  ddd-web link-skills [options] Link the agent skills of every installed DDD package into .claude/skills/
15
15
 
16
16
  SDK options:
17
17
  --config <path> Config file (default: openapi-config.ts)
18
+ --mode <mode> default (DDD RTK Query), future, or legacy
18
19
  --api <exportName> Generate only this api entry
19
20
  --schema <url|file> Spec source for the selected api (overrides schemaFile)
20
21
  --workspace <value> Value for config.workspace.envVar (alias: --subdomain)
@@ -64,6 +65,7 @@ async function main(argv) {
64
65
  args,
65
66
  options: {
66
67
  config: { type: "string" },
68
+ mode: { type: "string" },
67
69
  api: { type: "string" },
68
70
  schema: { type: "string" },
69
71
  workspace: { type: "string" },
@@ -79,8 +81,13 @@ async function main(argv) {
79
81
  return 0;
80
82
  }
81
83
  const workspace = values.workspace ?? values.subdomain;
84
+ const { mode } = values;
85
+ if (mode !== void 0 && mode !== "default" && mode !== "future" && mode !== "legacy") {
86
+ throw new SdkGenerationError("SDK generator mode must be default, future, or legacy.");
87
+ }
82
88
  await generateSdk({
83
89
  ...values.config ? { config: values.config } : {},
90
+ ...mode ? { mode } : {},
84
91
  ...values.api ? { api: values.api } : {},
85
92
  ...values.schema ? { schema: values.schema } : {},
86
93
  ...workspace ? { workspace } : {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/codegen/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from 'node:util';\nimport { generateSdk } from './generate';\nimport { runSkillLinks } from './link-skills';\nimport { consoleLogger, SdkGenerationError } from './log';\n\nconst HELP = `Usage:\n ddd-web-sdk [options] Generate the RTK Query SDK (same as \"ddd-web sdk\")\n ddd-web sdk [options]\n ddd-web link-skills [options] Link the agent skills of every installed DDD package into .claude/skills/\n\nSDK options:\n --config <path> Config file (default: openapi-config.ts)\n --api <exportName> Generate only this api entry\n --schema <url|file> Spec source for the selected api (overrides schemaFile)\n --workspace <value> Value for config.workspace.envVar (alias: --subdomain)\n --skip-prettier Do not format the generated files\n --skip-tsc Do not run tsc --noEmit after generation\n -h, --help Show this help\n\nlink-skills options:\n --check Change nothing; exit 1 on missing, stale or broken links, clashes, generated links still\n tracked by git and edited vendor skills\n --dry-run Print what would change, change nothing\n --quiet Print only warnings and problems\n --root <dir> Repository root (default: nearest ancestor with .git, else with .claude; env DDD_SKILLS_ROOT)\n`;\n\nasync function main(argv: string[]): Promise<number> {\n const [first, ...rest] = argv;\n const command = first === 'sdk' || first === 'link-skills' || first === 'help' ? first : 'sdk';\n const args = command === first ? rest : argv;\n\n if (command === 'help') {\n process.stdout.write(HELP);\n return 0;\n }\n if (command === 'link-skills') {\n const { values: linkValues } = parseArgs({\n args,\n options: {\n check: { type: 'boolean' },\n 'dry-run': { type: 'boolean' },\n quiet: { type: 'boolean', short: 'q' },\n root: { type: 'string' },\n help: { type: 'boolean', short: 'h' },\n },\n strict: true,\n });\n if (linkValues.help) {\n process.stdout.write(HELP);\n return 0;\n }\n return runSkillLinks({\n ...(linkValues.root ? { root: linkValues.root } : {}),\n check: linkValues.check ?? false,\n dryRun: linkValues['dry-run'] ?? false,\n quiet: linkValues.quiet ?? false,\n }).exitCode;\n }\n\n const { values } = parseArgs({\n args,\n options: {\n config: { type: 'string' },\n api: { type: 'string' },\n schema: { type: 'string' },\n workspace: { type: 'string' },\n subdomain: { type: 'string' },\n 'skip-prettier': { type: 'boolean' },\n 'skip-tsc': { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n },\n strict: true,\n });\n if (values.help) {\n process.stdout.write(HELP);\n return 0;\n }\n const workspace = values.workspace ?? values.subdomain;\n await generateSdk({\n ...(values.config ? { config: values.config } : {}),\n ...(values.api ? { api: values.api } : {}),\n ...(values.schema ? { schema: values.schema } : {}),\n ...(workspace ? { workspace } : {}),\n skipPrettier: values['skip-prettier'] ?? false,\n skipTsc: values['skip-tsc'] ?? false,\n });\n return 0;\n}\n\nmain(process.argv.slice(2)).then(\n (code) => process.exit(code),\n (error: unknown) => {\n if (error instanceof SdkGenerationError || (error as { code?: string }).code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION') {\n consoleLogger.error((error as Error).message);\n } else {\n consoleLogger.error(error instanceof Error ? (error.stack ?? error.message) : String(error));\n }\n process.exit(1);\n },\n);\n"],"mappings":";;;;;;;;;AACA,SAAS,iBAAiB;AAK1B,IAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBb,eAAe,KAAK,MAAiC;AACnD,QAAM,CAAC,OAAO,GAAG,IAAI,IAAI;AACzB,QAAM,UAAU,UAAU,SAAS,UAAU,iBAAiB,UAAU,SAAS,QAAQ;AACzF,QAAM,OAAO,YAAY,QAAQ,OAAO;AAExC,MAAI,YAAY,QAAQ;AACtB,YAAQ,OAAO,MAAM,IAAI;AACzB,WAAO;AAAA,EACT;AACA,MAAI,YAAY,eAAe;AAC7B,UAAM,EAAE,QAAQ,WAAW,IAAI,UAAU;AAAA,MACvC;AAAA,MACA,SAAS;AAAA,QACP,OAAO,EAAE,MAAM,UAAU;AAAA,QACzB,WAAW,EAAE,MAAM,UAAU;AAAA,QAC7B,OAAO,EAAE,MAAM,WAAW,OAAO,IAAI;AAAA,QACrC,MAAM,EAAE,MAAM,SAAS;AAAA,QACvB,MAAM,EAAE,MAA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K;AAAA,EACjC,CAAC;AACD,SAAO;AACT;AAEA,KAAK,QAAQ,KAAK,MAAM,CAAC,CAAC,EAAE;AAAA,EAC1B,CAAC,SAAS,QAAQ,KAAK,IAAI;AAAA,EAC3B,CAAC,UAAmB;AAClB,QAAI,iBAAiB,sBAAuB,MAA4B,SAAS,iCAAiC;AAChH,oBAAc,MAAO,MAAgB,OAAO;AAAA,IAC9C,OAAO;AACL,oBAAc,MAAM,iBAAiB,QAAS,MAAM,SAAS,MAAM,UAAW,OAAO,KAAK,CAAC;AAAA,IAC7F;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/codegen/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from 'node:util';\nimport { generateSdk } from './generate';\nimport { runSkillLinks } from './link-skills';\nimport { consoleLogger, SdkGenerationError } from './log';\n\nconst HELP = `Usage:\n ddd-web-sdk [options] Generate the SDK (same as \"ddd-web sdk\")\n ddd-web sdk [options]\n ddd-web link-skills [options] Link the agent skills of every installed DDD package into .claude/skills/\n\nSDK options:\n --config <path> Config file (default: openapi-config.ts)\n --mode <mode> default (DDD RTK Query), future, or legacy\n --api <exportName> Generate only this api entry\n --schema <url|file> Spec source for the selected api (overrides schemaFile)\n --workspace <value> Value for config.workspace.envVar (alias: --subdomain)\n --skip-prettier Do not format the generated files\n --skip-tsc Do not run tsc --noEmit after generation\n -h, --help Show this help\n\nlink-skills options:\n --check Change nothing; exit 1 on missing, stale or broken links, clashes, generated links still\n tracked by git and edited vendor skills\n --dry-run Print what would change, change nothing\n --quiet Print only warnings and problems\n --root <dir> Repository root (default: nearest ancestor with .git, else with .claude; env DDD_SKILLS_ROOT)\n`;\n\nasync function main(argv: string[]): Promise<number> {\n const [first, ...rest] = argv;\n const command = first === 'sdk' || first === 'link-skills' || first === 'help' ? first : 'sdk';\n const args = command === first ? rest : argv;\n\n if (command === 'help') {\n process.stdout.write(HELP);\n return 0;\n }\n if (command === 'link-skills') {\n const { values: linkValues } = parseArgs({\n args,\n options: {\n check: { type: 'boolean' },\n 'dry-run': { type: 'boolean' },\n quiet: { type: 'boolean', short: 'q' },\n root: { type: 'string' },\n help: { type: 'boolean', short: 'h' },\n },\n strict: true,\n });\n if (linkValues.help) {\n process.stdout.write(HELP);\n return 0;\n }\n return runSkillLinks({\n ...(linkValues.root ? { root: linkValues.root } : {}),\n check: linkValues.check ?? false,\n dryRun: linkValues['dry-run'] ?? false,\n quiet: linkValues.quiet ?? false,\n }).exitCode;\n }\n\n const { values } = parseArgs({\n args,\n options: {\n config: { type: 'string' },\n mode: { type: 'string' },\n api: { type: 'string' },\n schema: { type: 'string' },\n workspace: { type: 'string' },\n subdomain: { type: 'string' },\n 'skip-prettier': { type: 'boolean' },\n 'skip-tsc': { type: 'boolean' },\n help: { type: 'boolean', short: 'h' },\n },\n strict: true,\n });\n if (values.help) {\n process.stdout.write(HELP);\n return 0;\n }\n const workspace = values.workspace ?? values.subdomain;\n const { mode } = values;\n if (mode !== undefined && mode !== 'default' && mode !== 'future' && mode !== 'legacy') {\n throw new SdkGenerationError('SDK generator mode must be default, future, or legacy.');\n }\n await generateSdk({\n ...(values.config ? { config: values.config } : {}),\n ...(mode ? { mode } : {}),\n ...(values.api ? { api: values.api } : {}),\n ...(values.schema ? { schema: values.schema } : {}),\n ...(workspace ? { workspace } : {}),\n skipPrettier: values['skip-prettier'] ?? false,\n skipTsc: values['skip-tsc'] ?? false,\n });\n return 0;\n}\n\nmain(process.argv.slice(2)).then(\n (code) => process.exit(code),\n (error: unknown) => {\n if (error instanceof SdkGenerationError || (error as { code?: string }).code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION') {\n consoleLogger.error((error as Error).message);\n } else {\n consoleLogger.error(error instanceof Error ? (error.stack ?? error.message) : String(error));\n }\n process.exit(1);\n },\n);\n"],"mappings":";;;;;;;;;AACA,SAAS,iBAAiB;AAK1B,IAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;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;","names":[]}
@@ -259,6 +259,46 @@ interface ModelOptions {
259
259
  idType?: 'document' | 'number' | 'string';
260
260
  }
261
261
 
262
+ interface Logger {
263
+ info(message: string): void;
264
+ warn(message: string): void;
265
+ error(message: string): void;
266
+ }
267
+ declare const consoleLogger: Logger;
268
+ declare const silentLogger: Logger;
269
+ /** Thrown for expected aborts (bad spec, bad config); the CLI prints the message without a stack. */
270
+ declare class SdkGenerationError extends Error {
271
+ name: string;
272
+ }
273
+
274
+ /** Where the default answer of a generated MSW handler comes from: the application's model mock functions. */
275
+ interface ModelMocksOptions {
276
+ /**
277
+ * Module specifier prefix of the model mocks; the model's path below the models directory follows it, then
278
+ * `fileSuffix`. `'@mocks/models/'` + `App/Domain/Library/Entities/Books/Book` + `'.mock'`.
279
+ */
280
+ importPrefix: string;
281
+ /** Named export of a model's mock function (called without arguments). Default `get<ModelName>Mock`. */
282
+ exportName?: (modelName: string, modelPath: string) => string;
283
+ /** Appended to the model path in the import specifier. Default `'.mock'`. */
284
+ fileSuffix?: string;
285
+ }
286
+ /**
287
+ * Generated MSW request handlers, one factory per operation that has a request builder (`<stem>Mocks.ts`). The
288
+ * generated file imports `msw` (a dependency of the consuming project, never of DDD Web).
289
+ */
290
+ interface MswHandlersOptions {
291
+ /** Default answers from the application's model mocks; without it every handler answers `null`. */
292
+ modelMocks?: ModelMocksOptions;
293
+ }
294
+ /** Per api: `false` turns the handlers off for this api; the fields override the config-level ones. */
295
+ interface ApiMswHandlersOptions extends MswHandlersOptions {
296
+ /** The handlers file. Default `<stem>Mocks.ts` next to the api output file. */
297
+ outputFile?: string;
298
+ /** Name of the exported handler object. Default `<stem>Mocks`. */
299
+ exportName?: string;
300
+ }
301
+
262
302
  /** Selects operations by HTTP method (optional, case-insensitive) and path (exact string or RegExp). */
263
303
  interface OperationMatcher {
264
304
  method?: Uppercase<HttpMethod> | HttpMethod;
@@ -367,6 +407,11 @@ interface SdkApiConfig {
367
407
  responseHandlers?: ResponseHandlerOverride[];
368
408
  /** Checked before the global `invalidation`; the first resolver that returns a list wins. */
369
409
  invalidation?: InvalidationResolver;
410
+ /**
411
+ * MSW handlers for this api (default mode): `false` turns them off; an object enables them (also without the
412
+ * config-level `mswHandlers`) and overrides its fields, e.g. `outputFile`.
413
+ */
414
+ mswHandlers?: ApiMswHandlersOptions | false;
370
415
  /** Any further RTK codegen option (`argSuffix`, `flattenArg`, `endpointOverrides`, `filterEndpoints`, …). */
371
416
  [rtkOption: string]: unknown;
372
417
  }
@@ -381,8 +426,24 @@ interface WorkspaceOptions {
381
426
  /** Ask on a TTY when nothing else resolves it. Never asks without a TTY. Default `true`. */
382
427
  prompt?: boolean;
383
428
  }
429
+ type SdkGeneratorMode = 'default' | 'future' | 'legacy';
430
+ interface DelegatedGeneratorOptions<Output extends string> {
431
+ /** Base directory for generated files. Default ./src/generated-sdk; each mode and API has its own directory. */
432
+ outputDir?: string;
433
+ /** Options for the SDK generator outputs. DDD Web sets the output directories. Set mocks to {} to add them in future mode. */
434
+ outputs?: Partial<Record<Output, Record<string, unknown>>>;
435
+ }
436
+ type SdkGeneratorConfig = {
437
+ mode: 'default';
438
+ } | ({
439
+ mode: 'future';
440
+ } & DelegatedGeneratorOptions<'models' | 'client' | 'mocks'>) | ({
441
+ mode: 'legacy';
442
+ } & DelegatedGeneratorOptions<'models' | 'stores' | 'mocks'>);
384
443
  interface SdkConfig {
385
444
  apis: SdkApiConfig[];
445
+ /** Defaults to the built-in DDD RTK Query generator. Other modes use the consumer's SDK generator installation. */
446
+ generator?: SdkGeneratorConfig;
386
447
  /** Directory of generated model files. Default `<dir of first outputFile>/../models`. */
387
448
  modelsDir?: string;
388
449
  /**
@@ -415,6 +476,12 @@ interface SdkConfig {
415
476
  * your own function; the body as `requestBody` (see {@link EndpointOptions}).
416
477
  */
417
478
  endpoints?: EndpointOptions;
479
+ /**
480
+ * Generate MSW request handlers (default mode): per api a `<stem>Mocks.ts` next to the api file with one handler
481
+ * factory per operation that has a request builder, answering the response model's mock from `modelMocks`. Off
482
+ * when absent: nothing changes. The generated file imports `msw`, which the consuming project installs.
483
+ */
484
+ mswHandlers?: MswHandlersOptions;
418
485
  /** tsconfig used for the final type check. Default `tsconfig.json` next to the config file. */
419
486
  tsconfig?: string;
420
487
  }
@@ -430,18 +497,6 @@ interface LoadedConfig {
430
497
  */
431
498
  declare function loadConfig(configPath: string): Promise<LoadedConfig>;
432
499
 
433
- interface Logger {
434
- info(message: string): void;
435
- warn(message: string): void;
436
- error(message: string): void;
437
- }
438
- declare const consoleLogger: Logger;
439
- declare const silentLogger: Logger;
440
- /** Thrown for expected aborts (bad spec, bad config); the CLI prints the message without a stack. */
441
- declare class SdkGenerationError extends Error {
442
- name: string;
443
- }
444
-
445
500
  /**
446
501
  * `invalidation` resolver that restores the 0.2 default: writes without an identity from `x-ddd-entity` (a path
447
502
  * identity on an upsert / delete) invalidate LIST plus their whole tag type instead of the derived identity.
@@ -452,6 +507,8 @@ declare const broadInvalidation: InvalidationResolver;
452
507
  interface GenerateSdkOptions {
453
508
  /** Config file path (default `openapi-config.ts`, relative to `cwd`) or an inline config. */
454
509
  config?: string | SdkConfig;
510
+ /** Override the config's SDK generator mode for this run. */
511
+ mode?: SdkGeneratorMode;
455
512
  /** Base directory for a relative config path and for an inline config's relative paths. Default `process.cwd()`. */
456
513
  cwd?: string;
457
514
  /** Generate only the api with this `exportName` (or output file stem). */
@@ -469,10 +526,60 @@ interface GenerateSdkResult {
469
526
  /** Absolute paths of all written files. */
470
527
  files: string[];
471
528
  modelsDir: string;
529
+ /** Model directories for each selected API in an opt-in mode. */
530
+ modelsByApi?: Record<string, string>;
472
531
  typechecked: boolean;
473
532
  }
474
533
  declare function generateSdk(options?: GenerateSdkOptions): Promise<GenerateSdkResult>;
475
534
 
535
+ interface LegacySdkSource {
536
+ name: string;
537
+ file?: string;
538
+ url?: string;
539
+ onError?: string;
540
+ outputs: Record<string, Record<string, unknown>>;
541
+ }
542
+ /** One source's result of a legacy run. */
543
+ interface LegacySdkResult {
544
+ source: string;
545
+ ok: boolean;
546
+ skipped?: boolean;
547
+ error?: Error;
548
+ planned?: Array<{
549
+ dir: string;
550
+ files: Array<{
551
+ path: string;
552
+ content: string;
553
+ }>;
554
+ }>;
555
+ /**
556
+ * With `prune`: the absolute paths of the files this source wrote on an earlier run and no longer writes, deleted
557
+ * by this run (with `dryRun`: the files the run would delete). Absent without `prune`.
558
+ */
559
+ pruned?: string[];
560
+ }
561
+ interface GenerateLegacySdkOptions {
562
+ /** Explicit sources and directories for an existing SDK layout, processed in the given order. */
563
+ sources: LegacySdkSource[];
564
+ cwd?: string;
565
+ dryRun?: boolean;
566
+ targetOptions?: Record<string, unknown>;
567
+ logger?: Logger;
568
+ /**
569
+ * Delete the files an earlier run wrote and this run no longer plans (a store of a removed controller, a model or
570
+ * mock of a removed schema). Only files recorded in the manifest (`manifestFile`) are ever deleted, so hand-written
571
+ * files in a shared output directory stay. Scoped per source and output: an output of a source that did not run
572
+ * (left out, skipped, or without that output this time) deletes nothing, and a file it lists is kept. The first
573
+ * run with `prune` writes the manifest and deletes nothing. Default `false`: nothing is deleted, no manifest is
574
+ * read or written.
575
+ */
576
+ prune?: boolean;
577
+ /** The manifest of the files each source and output wrote, relative to `cwd`. Default `.ddd-web-legacy-sdk.json`. */
578
+ manifestFile?: string;
579
+ }
580
+ /** Runs the legacy generator for an app that owns its spec sources and generated file layout. */
581
+ declare function generateLegacySdk(options: GenerateLegacySdkOptions): Promise<LegacySdkResult[]>;
582
+
476
583
  /** One entry of `.ddd-skills.json` → `skills`. */
477
584
  interface SkillsManifestEntry {
478
585
  package: string | null;
@@ -559,5 +666,5 @@ declare function loadSpec(source: string, timeoutMs?: number): Promise<OpenApiDo
559
666
  */
560
667
  declare function validateSpec(doc: OpenApiDocument, source: string, logger: Logger): void;
561
668
 
562
- export { SUPPORTED_CONTRACT, SdkGenerationError, broadInvalidation, buildEndpointNameFromPath, consoleLogger, defineConfig, findSkillsRepositoryRoot, generateSdk, linkSkills, loadConfig, loadSpec, runSkillLinks, silentLogger, validateSpec };
563
- export type { EndpointNamingOperation, EndpointOptions, GenerateSdkOptions, GenerateSdkResult, HooksOptions, InvalidationOperation, InvalidationResolver, InvalidationTag, LinkSkillAction, LinkSkillsOptions, LinkSkillsResult, LoadedConfig, Logger, ModelOptions, OpenApiDocument, OperationMatcher, ResponseHandlerOverride, SdkApiConfig, SdkConfig, SideEffectsOverride, SkillLinksOptions, SkillLinksReport, SkillsManifest, SkillsManifestEntry, WorkspaceOptions };
669
+ export { SUPPORTED_CONTRACT, SdkGenerationError, broadInvalidation, buildEndpointNameFromPath, consoleLogger, defineConfig, findSkillsRepositoryRoot, generateLegacySdk, generateSdk, linkSkills, loadConfig, loadSpec, runSkillLinks, silentLogger, validateSpec };
670
+ export type { ApiMswHandlersOptions, EndpointNamingOperation, EndpointOptions, GenerateLegacySdkOptions, GenerateSdkOptions, GenerateSdkResult, HooksOptions, InvalidationOperation, InvalidationResolver, InvalidationTag, LegacySdkResult, LegacySdkSource, LinkSkillAction, LinkSkillsOptions, LinkSkillsResult, LoadedConfig, Logger, ModelMocksOptions, ModelOptions, MswHandlersOptions, OpenApiDocument, OperationMatcher, ResponseHandlerOverride, SdkApiConfig, SdkConfig, SdkGeneratorConfig, SdkGeneratorMode, SideEffectsOverride, SkillLinksOptions, SkillLinksReport, SkillsManifest, SkillsManifestEntry, WorkspaceOptions };
@@ -6,6 +6,7 @@ import {
6
6
  consoleLogger,
7
7
  defineConfig,
8
8
  findSkillsRepositoryRoot,
9
+ generateLegacySdk,
9
10
  generateSdk,
10
11
  linkSkills,
11
12
  loadConfig,
@@ -13,7 +14,7 @@ import {
13
14
  runSkillLinks,
14
15
  silentLogger,
15
16
  validateSpec
16
- } from "../chunk-3V22MYDI.js";
17
+ } from "../chunk-HZ4VYIHY.js";
17
18
  export {
18
19
  SUPPORTED_CONTRACT,
19
20
  SdkGenerationError,
@@ -22,6 +23,7 @@ export {
22
23
  consoleLogger,
23
24
  defineConfig,
24
25
  findSkillsRepositoryRoot,
26
+ generateLegacySdk,
25
27
  generateSdk,
26
28
  linkSkills,
27
29
  loadConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mgamadeus/ddd-web",
3
- "version": "0.17.1",
3
+ "version": "0.19.0",
4
4
  "description": "TypeScript web client for backends built with mgamadeus/ddd, the DDD entity framework for Symfony and Doctrine (Composer/Packagist). Generates a typed RTK Query SDK from the backend's OpenAPI document, builds DDD QueryOptions (filters, orderBy, expand, select, paging) and handles JWT auth with token refresh.",
5
5
  "keywords": [
6
6
  "ddd",
@@ -116,6 +116,7 @@
116
116
  "devDependencies": {
117
117
  "@reduxjs/toolkit": "^2.13.0",
118
118
  "@types/node": "^26.6.6",
119
+ "msw": "^2.12.10",
119
120
  "tsup": "^9.0.0",
120
121
  "typescript": "^6.0.3",
121
122
  "vitest": "^5.0.5"