@mgamadeus/ddd-web 0.17.0 → 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.
- package/.claude/skills/ddd-web-specialist/SKILL.md +9 -2
- package/.claude/skills/ddd-web-specialist/references/consumer.md +15 -0
- package/CHANGELOG.md +32 -0
- package/README.md +20 -0
- package/dist/{chunk-3V22MYDI.js → chunk-AGECBV52.js} +816 -606
- package/dist/chunk-AGECBV52.js.map +1 -0
- package/dist/codegen/cli.js +9 -2
- package/dist/codegen/cli.js.map +1 -1
- package/dist/codegen/index.d.ts +53 -2
- package/dist/codegen/index.js +3 -1
- package/package.json +17 -9
- package/dist/chunk-3V22MYDI.js.map +0 -1
|
@@ -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),
|
|
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
|
+
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,37 @@
|
|
|
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
|
+
|
|
20
|
+
## 0.17.1
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- A CommonJS script that loads code importing `@mgamadeus/ddd-web/contract` no longer fails with
|
|
24
|
+
`ERR_PACKAGE_PATH_NOT_EXPORTED`: the entries without runtime dependencies (`/contract`, `/query`, `/auth`,
|
|
25
|
+
`/fetch-api-request`, `/issues`, `/issues/browser`, `/issues/node`, `/issues/wire`) have a `default` condition on
|
|
26
|
+
their ES module build, so `require()` loads them on Node ≥ 20.19 / ≥ 22.12 (require of an ES module; no entry uses
|
|
27
|
+
top-level await). On an older Node 20 the error is now `ERR_REQUIRE_ESM`.
|
|
28
|
+
- No CommonJS build: one module instance per entry, no dual-package state. `/api` (RTK Query peer dependency),
|
|
29
|
+
`/vite` and `/codegen` stay import-only.
|
|
30
|
+
|
|
31
|
+
### Tests
|
|
32
|
+
- The consumer check requires every entry with a `default` condition from a CommonJS script against the packed
|
|
33
|
+
tarball (`test/consumer/smoke-require.cjs`); a manifest test pins which entries are requirable.
|
|
34
|
+
|
|
3
35
|
## 0.17.0
|
|
4
36
|
|
|
5
37
|
### Changed
|
package/README.md
CHANGED
|
@@ -54,6 +54,18 @@ Subpaths: `@mgamadeus/ddd-web/codegen`, `/query`, `/api`, `/auth`, `/contract`,
|
|
|
54
54
|
(pages whose global `Request` is not the Fetch API's, e.g. MooTools or Prototype: `dddFetchApiRequestPlugin()`) and
|
|
55
55
|
`/issues`, `/issues/browser`, `/issues/node`, `/issues/wire` (client errors, below).
|
|
56
56
|
|
|
57
|
+
The package is an ES module. A CommonJS script may `require()` the entries without runtime dependencies — `/contract`,
|
|
58
|
+
`/query`, `/auth`, `/fetch-api-request`, `/issues`, `/issues/browser`, `/issues/node`, `/issues/wire` — on Node
|
|
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
|
+
and `/codegen` are import-only.
|
|
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
|
+
|
|
57
69
|
### File downloads
|
|
58
70
|
|
|
59
71
|
Endpoints whose 2xx responses are files (`application/octet-stream`, `application/zip`, `application/pdf`,
|
|
@@ -198,6 +210,14 @@ Everything is redacted on the device (tokens in paths and queries, e-mails, bear
|
|
|
198
210
|
known noise is dropped, repeats are folded into `count`, and caps, batching, retry and backoff keep a broken page from
|
|
199
211
|
flooding the endpoint. Details: the agent skill, `references/consumer.md` › Client errors.
|
|
200
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
|
+
|
|
201
221
|
## Agent skills (`link-skills`)
|
|
202
222
|
|
|
203
223
|
The package ships the agent skill `ddd-web-specialist` (consumer guide + maintaining guide). `ddd-web link-skills`
|