@mgamadeus/ddd-web 0.17.1 → 0.18.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.
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  name: ddd-web-specialist
3
- description: "Use and maintain @mgamadeus/ddd-web, the TS client of mgamadeus/ddd: openapi-config.ts defineConfig (schemaFile, sideEffects, responseHandlers, invalidation), the RTK Query SDK from ddd-web-sdk (cache tags by entity identity, mergeDddTagTypes, blob downloads, multipartFiles uploads, progress via baseQuery.upload), QueryOptions builders, createDddBaseQuery (Bearer, shared refresh + retry, relogin, session-bound requests, normalizeDddError), token storage, JWT helpers, foreign global Request (MooTools: dddFetchApiRequestPlugin), the client-errors reporter /issues (browser, Node, React Native), link-skills (all DDD skills, --check), release. Use when wiring a frontend to a DDD API, regenerating the SDK, building filters, uploading files, FormData, upload or download progress, fixing token refresh, guest login, a request sent under the wrong account after a switch, stale cache tags, downloading an export, requests failing in a legacy page, reporting errors to the issues log, linking skills, or releasing ddd-web."
3
+ description: "Use and maintain @mgamadeus/ddd-web, the TS client of mgamadeus/ddd: openapi-config.ts defineConfig (schemaFile, sideEffects, responseHandlers, invalidation), ddd-web-sdk modes default, future and legacy (cache tags by entity identity, mergeDddTagTypes, blob downloads, multipartFiles uploads, progress via baseQuery.upload), QueryOptions builders, createDddBaseQuery (Bearer, shared refresh + retry, relogin, session-bound requests, normalizeDddError), token storage, JWT helpers, MooTools Request (dddFetchApiRequestPlugin), /issues reporting (browser, Node, React Native), link-skills (--check), release. Use when wiring a frontend to a DDD API, regenerating or switching SDK modes, building filters, uploading files, FormData, upload or download progress, fixing token refresh, guest login, a request sent under the wrong account after a switch, stale cache tags, downloading an export, requests failing in a legacy page, reporting errors to the issues log, linking skills, or releasing ddd-web."
4
4
  metadata:
5
5
  author: mgamadeus
6
- version: "1.6.0"
6
+ version: "1.7.0"
7
7
  package: "@mgamadeus/ddd-web"
8
8
  ---
9
9
 
@@ -85,6 +85,13 @@ const { data } = useGetApiAdminLibraryBooksListQuery({
85
85
  });
86
86
  ```
87
87
 
88
+ ## SDK modes
89
+
90
+ DDD RTK Query is the default. Use `ddd-web-sdk --mode future` with the consumer’s `swagger-sdk-generator@^3`
91
+ for models and a promise client. Use `--mode legacy` with `swagger-sdk-generator@^3.1` for legacy-dialect
92
+ models, stores, thunks, and mocks. Use `generator.mode` to select a mode in config.
93
+ Opt-in output goes to `src/generated-sdk/<mode>/<api-stem>/` by default. See [references/consumer.md](references/consumer.md).
94
+
88
95
  ## Rules
89
96
 
90
97
  - **Never edit generated files** (`<stem>.ts`, `<stem>Enhanced.ts`, `<stem>Tags.ts`, the models directory). Change the
@@ -44,6 +44,7 @@ too). A plain RTK-codegen file with `export const apis = [...]` is accepted as w
44
44
 
45
45
  | Option | Meaning |
46
46
  |---|---|
47
+ | `generator` | Select `{ mode: "future" }` or `{ mode: "legacy" }` for the consumer-installed SDK generator. The existing DDD RTK Query engine is the default. |
47
48
  | `modelsDir` | Model output directory. Default `<dir of the first outputFile>/../models`; without it every api must share one output directory. |
48
49
  | `skipUpdatePostTwins` | DDD `#[Update]` serves the same route as PATCH and POST; `true` generates only the PATCH hook. With `x-ddd-entity` both must be `upsert` of the same entity; without it summary, parameters, body and responses must be identical. Conflicting annotations never skip. Default `false` (keep it `false` when app code already calls the POST hooks). |
49
50
  | `sideEffects` | `SideEffectsOverride[]` for specs without `x-ddd-side-effects`: `{ method?, path: string \| RegExp, sideEffects, endpointType? }`. A writing GET becomes a mutation, a reading POST a query; `endpointType: 'mutation'` keeps a reading POST a mutation that invalidates nothing. |
@@ -94,6 +95,20 @@ skipTsc, logger })` from `/codegen`.
94
95
 
95
96
  Add a script: `"gen:sdk": "ddd-web-sdk"`. Commit the generated files and, if you use snapshots, the snapshot.
96
97
 
98
+ ### Opt-in generation
99
+
100
+ Select `--mode future` or `--mode legacy` to override the configured mode for a run. Future mode needs
101
+ `swagger-sdk-generator@^3` as an app dependency. Legacy mode needs `swagger-sdk-generator@^3.1`. Legacy output uses Redux Toolkit, RxJS, Faker, and the configured model aliases.
102
+
103
+ Output goes to `src/generated-sdk/<mode>/<output-file-stem>/` unless `generator.outputDir` sets another base.
104
+ Use `generator.outputs` to pass model, client, store or mock options supported by the selected mode. Future
105
+ mode generates a promise client and models. Set `outputs.mocks: {}` to add seeded mocks. Set
106
+ `outputs.client.transport: 'none'` to require an injected transport. Pass a custom transport or use
107
+ `createAxiosTransport` from `swagger-sdk-generator/runtime` with the app’s own Axios instance.
108
+
109
+ The opt-in modes use bundler-style TypeScript module resolution. They retain DDD document validation,
110
+ path-parameter repair, `skipUpdatePostTwins` and type-check rollback. DDD RTK-specific options apply in default mode.
111
+
97
112
  ## 3. Generated files and cache tags
98
113
 
99
114
  | File | Content |
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Added
6
+ - Opt-in SDK modes over the consumer's `swagger-sdk-generator` (`ddd-web-sdk --mode future|legacy`, or
7
+ `generator.mode` in `openapi-config.ts`). Without a mode the generator is unchanged: DDD RTK Query, same output.
8
+ - `future` (`swagger-sdk-generator@^3`): models and a typed promise client with a configurable transport (Fetch by
9
+ default, an injected Axios instance, or a custom one) and optional seeded mocks.
10
+ - `legacy` (`swagger-sdk-generator@^3.1`): legacy-dialect models, Redux-RxJS stores with thunks, and mocks.
11
+ - Each opt-in API writes to `src/generated-sdk/<mode>/<output-file-stem>/` (`generator.outputDir` sets the base),
12
+ is checked against the DDD contract, gets missing path parameters repaired, honours `skipUpdatePostTwins`, and is
13
+ restored with every other selected API when the type check fails; `--api` and `--schema` work as for the default.
14
+ - `generator.outputs` passes output options through, e.g. `client.transport` or `stores.runtimeModule` (one
15
+ application-owned store runtime instead of a generated one).
16
+ - `generateLegacySdk()` from `/codegen`: runs legacy mode for an application that keeps its own sources and output
17
+ directories (plain OpenAPI documents, staged before writing; files outside the plan stay).
18
+ - Docs: `docs/sdk-generator-integration.md`.
19
+
3
20
  ## 0.17.1
4
21
 
5
22
  ### Fixed
package/README.md CHANGED
@@ -59,6 +59,13 @@ The package is an ES module. A CommonJS script may `require()` the entries witho
59
59
  ≥ 20.19 or ≥ 22.12 (Node's require of an ES module; none of them uses top-level await). `/api` (RTK Query), `/vite`
60
60
  and `/codegen` are import-only.
61
61
 
62
+ ### Opt-in SDK modes
63
+
64
+ The default command generates the DDD RTK Query SDK. Install `swagger-sdk-generator@^3` and run
65
+ `pnpm exec ddd-web-sdk --mode future` to generate a typed promise client and models. `--mode legacy`
66
+ generates legacy-dialect models, stores, thunks and mocks and needs `swagger-sdk-generator@^3.1`. Each opt-in mode writes to a separate
67
+ generated directory and uses the consumer’s generator installation. See [SDK generation modes](docs/sdk-generator-integration.md).
68
+
62
69
  ### File downloads
63
70
 
64
71
  Endpoints whose 2xx responses are files (`application/octet-stream`, `application/zip`, `application/pdf`,
@@ -203,6 +210,14 @@ Everything is redacted on the device (tokens in paths and queries, e-mails, bear
203
210
  known noise is dropped, repeats are folded into `count`, and caps, batching, retry and backoff keep a broken page from
204
211
  flooding the endpoint. Details: the agent skill, `references/consumer.md` › Client errors.
205
212
 
213
+ ## Untrusted content
214
+
215
+ Generated clients return what the backend sends, including text and files users, mail, third parties or a model wrote.
216
+ Treat it as foreign: never pass it to `dangerouslySetInnerHTML`, `eval`, `new Function` or an `iframe` with
217
+ `allow-same-origin`; open foreign files through their download URLs (the backend serves them with
218
+ `UntrustedContentResponseDto`: attachment, `nosniff`, `CSP: sandbox`). The backend rule and its helpers: skill
219
+ `ddd-untrusted-input-specialist` of `mgamadeus/ddd`.
220
+
206
221
  ## Agent skills (`link-skills`)
207
222
 
208
223
  The package ships the agent skill `ddd-web-specialist` (consumer guide + maintaining guide). `ddd-web link-skills`