@mgamadeus/ddd-web 0.8.0 → 0.10.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.
@@ -166,6 +166,63 @@ interface OpenApiDocument {
166
166
  [key: string]: unknown;
167
167
  }
168
168
 
169
+ /** One operation an endpoint name is chosen for. */
170
+ interface EndpointNamingOperation {
171
+ method: HttpMethod;
172
+ /** OpenAPI path, e.g. `/api/client/ai/conversations/{locationId}/list`. */
173
+ path: string;
174
+ operation: OpenApiOperation;
175
+ }
176
+ /** How the generator names the endpoints and their body argument. Every option is off by default. */
177
+ interface EndpointOptions {
178
+ /**
179
+ * The endpoint names (and so the hook names):
180
+ * - `rtk` (default): RTK codegen's names (the operation's `operationId`, else verb and path).
181
+ * - `path`: a pure function of verb and path — the prefix (`stripPathPrefix`) is cut; every `{param}/` is cut out
182
+ * and only the LAST one cut is kept; the rest is split on `/ _ - .`, each piece capitalised, the verb in front,
183
+ * the first letter lowered; `By<LastInner>` is appended; a trailing `{param}` becomes `By<Param>` where it
184
+ * stands. `POST /api/client/ai/conversations/{locationId}/purposed/{purposeName}` →
185
+ * `postClientAiConversationsPurposedByPurposeNameByLocationId`.
186
+ * - a function returning the name (a JavaScript identifier) per operation.
187
+ */
188
+ naming?: 'rtk' | 'path' | ((operation: EndpointNamingOperation) => string);
189
+ /** The prefix `naming: 'path'` cuts from a path. Default `/^\/(?:app\/)?api(?=\/)/` (`/api` or `/app/api`). */
190
+ stripPathPrefix?: string | RegExp;
191
+ /**
192
+ * `requestBody`: the request body is the argument's `requestBody` property, whatever its schema is called (a DTO
193
+ * class that moves keeps the name). `rtk` (default): the camel-cased schema name.
194
+ */
195
+ bodyArg?: 'rtk' | 'requestBody';
196
+ }
197
+ /** The endpoint name of `naming: 'path'` (see {@link EndpointOptions.naming}). */
198
+ declare function buildEndpointNameFromPath(method: string, path: string, stripPathPrefix?: string | RegExp): string;
199
+
200
+ /** How the generator writes the models of the document's component schemas. Every option is off by default. */
201
+ interface ModelOptions {
202
+ /**
203
+ * `document`: a model is named and placed by its schema name as the document writes it — the last dot segment is
204
+ * the model name, unchanged (`AIConversationMessage`, not `AiConversationMessage`), the segments before it are the
205
+ * folders; a folder that happens to prefix the last segment never splits it (`…Messages.DelegationResults` stays
206
+ * `DelegationResults` beside a `…Messages.Delegation` namespace). `rtk` (default): RTK codegen's names, placed by the
207
+ * namespace registry.
208
+ */
209
+ naming?: 'rtk' | 'document';
210
+ /**
211
+ * `const`: an enum property becomes two exported objects in its model's file, `<Model><Property>` and
212
+ * `<Model><Property>Strict` (`as const`), keyed by the enum values; the property is typed from the Strict object
213
+ * (`(typeof XStrict)[keyof typeof XStrict]`, `| null` when the property is nullable). `union` (default): the inline
214
+ * union of RTK codegen. Needs `naming: 'document'` (the const names start with the document's model name).
215
+ */
216
+ enums?: 'union' | 'const';
217
+ /** `| null` beside a `$ref` whose property is nullable (RTK codegen drops it). Default `false`. */
218
+ nullableRefs?: boolean;
219
+ /**
220
+ * The type of an `id` property the document declares as `string | integer`: `number` or `string`. Default
221
+ * `document` (the union as declared).
222
+ */
223
+ idType?: 'document' | 'number' | 'string';
224
+ }
225
+
169
226
  /** Selects operations by HTTP method (optional, case-insensitive) and path (exact string or RegExp). */
170
227
  interface OperationMatcher {
171
228
  method?: Uppercase<HttpMethod> | HttpMethod;
@@ -311,6 +368,17 @@ interface SdkConfig {
311
368
  */
312
369
  invalidation?: InvalidationResolver;
313
370
  workspace?: WorkspaceOptions;
371
+ /**
372
+ * How the models of the component schemas are written: names and folders as the document writes them, enums as
373
+ * const objects, `| null` beside a nullable `$ref`, the `id` type. Every option is off by default (see
374
+ * {@link ModelOptions}).
375
+ */
376
+ models?: ModelOptions;
377
+ /**
378
+ * How the endpoints and their body argument are named: RTK codegen's names (default), a rule of verb and path, or
379
+ * your own function; the body as `requestBody` (see {@link EndpointOptions}).
380
+ */
381
+ endpoints?: EndpointOptions;
314
382
  /** tsconfig used for the final type check. Default `tsconfig.json` next to the config file. */
315
383
  tsconfig?: string;
316
384
  }
@@ -401,5 +469,5 @@ declare function loadSpec(source: string, timeoutMs?: number): Promise<OpenApiDo
401
469
  */
402
470
  declare function validateSpec(doc: OpenApiDocument, source: string, logger: Logger): void;
403
471
 
404
- export { SUPPORTED_CONTRACT, SdkGenerationError, broadInvalidation, consoleLogger, defineConfig, generateSdk, linkSkills, loadConfig, loadSpec, silentLogger, validateSpec };
405
- export type { GenerateSdkOptions, GenerateSdkResult, HooksOptions, InvalidationOperation, InvalidationResolver, InvalidationTag, LinkSkillAction, LinkSkillsOptions, LinkSkillsResult, LoadedConfig, Logger, OpenApiDocument, OperationMatcher, ResponseHandlerOverride, SdkApiConfig, SdkConfig, SideEffectsOverride, WorkspaceOptions };
472
+ export { SUPPORTED_CONTRACT, SdkGenerationError, broadInvalidation, buildEndpointNameFromPath, consoleLogger, defineConfig, generateSdk, linkSkills, loadConfig, loadSpec, silentLogger, validateSpec };
473
+ export type { EndpointNamingOperation, EndpointOptions, GenerateSdkOptions, GenerateSdkResult, HooksOptions, InvalidationOperation, InvalidationResolver, InvalidationTag, LinkSkillAction, LinkSkillsOptions, LinkSkillsResult, LoadedConfig, Logger, ModelOptions, OpenApiDocument, OperationMatcher, ResponseHandlerOverride, SdkApiConfig, SdkConfig, SideEffectsOverride, WorkspaceOptions };
@@ -2,6 +2,7 @@ import {
2
2
  SUPPORTED_CONTRACT,
3
3
  SdkGenerationError,
4
4
  broadInvalidation,
5
+ buildEndpointNameFromPath,
5
6
  consoleLogger,
6
7
  defineConfig,
7
8
  generateSdk,
@@ -10,11 +11,12 @@ import {
10
11
  loadSpec,
11
12
  silentLogger,
12
13
  validateSpec
13
- } from "../chunk-RCXFU5IA.js";
14
+ } from "../chunk-PZ6AAETR.js";
14
15
  export {
15
16
  SUPPORTED_CONTRACT,
16
17
  SdkGenerationError,
17
18
  broadInvalidation,
19
+ buildEndpointNameFromPath,
18
20
  consoleLogger,
19
21
  defineConfig,
20
22
  generateSdk,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mgamadeus/ddd-web",
3
- "version": "0.8.0",
3
+ "version": "0.10.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",