@mgamadeus/ddd-web 0.13.0 → 0.15.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/references/consumer.md +1 -1
- package/CHANGELOG.md +19 -0
- package/dist/{chunk-J2RLNVKK.js → chunk-6CQEUZ3B.js} +174 -40
- package/dist/chunk-6CQEUZ3B.js.map +1 -0
- package/dist/codegen/cli.js +1 -1
- package/dist/codegen/index.d.ts +13 -0
- package/dist/codegen/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-J2RLNVKK.js.map +0 -1
|
@@ -50,7 +50,7 @@ too). A plain RTK-codegen file with `export const apis = [...]` is accepted as w
|
|
|
50
50
|
| `invalidation` | `(operation: InvalidationOperation) => InvalidationTag[] \| undefined`: overrides the tags a mutation invalidates; `undefined` keeps the default. `broadInvalidation` (exported) restores the 0.2 behaviour. See section 3. |
|
|
51
51
|
| `workspace` | `{ envVar, envFiles?, urlKeys?, prompt? }`: resolves a workspace / subdomain value (CLI `--workspace` → env → URL sniffed from `.env` / `.env.local` → TTY prompt) into `process.env[envVar]` before the config is evaluated again. |
|
|
52
52
|
| `tsconfig` | tsconfig of the final type check. Default `tsconfig.json` next to the config. |
|
|
53
|
-
| `endpoints` | How endpoints and their body argument are named; off by default. `naming: 'path'`: a pure function of verb and path — `stripPathPrefix` (default `/api` or `/app/api`) cut, every `{param}/` cut out and only the LAST one kept, the rest split on `/ _ - .` and capitalised behind the verb, `By<LastInner>` appended, a trailing `{param}` becomes `By<Param>` where it stands (`POST /api/client/ai/conversations/{locationId}/purposed/{purposeName}` → `postClientAiConversationsPurposedByPurposeNameByLocationId`; `buildEndpointNameFromPath` is exported). `naming` may be a function `({ method, path, operation }) => name`. The built name is used verbatim (no second camel-casing); your `filterEndpoints` / `endpointOverrides` match it. Two operations with one name stop the run. `bodyArg: 'requestBody'`: the body is the argument's `requestBody`, whatever its DTO is called. Query and path parameters stay flat in the argument. |
|
|
53
|
+
| `endpoints` | How endpoints and their body argument are named; off by default. `naming: 'path'`: a pure function of verb and path — `stripPathPrefix` (default `/api` or `/app/api`) cut, every `{param}/` cut out and only the LAST one kept, the rest split on `/ _ - .` and capitalised behind the verb, `By<LastInner>` appended, a trailing `{param}` becomes `By<Param>` where it stands (`POST /api/client/ai/conversations/{locationId}/purposed/{purposeName}` → `postClientAiConversationsPurposedByPurposeNameByLocationId`; `buildEndpointNameFromPath` is exported). `naming` may be a function `({ method, path, operation }) => name`. The built name is used verbatim (no second camel-casing); your `filterEndpoints` / `endpointOverrides` match it. Two operations with one name stop the run. `bodyArg: 'requestBody'`: the body is the argument's `requestBody`, whatever its DTO is called. `requestBuilders: true`: every endpoint's request builder goes into `<stem>Requests.ts` (`export const <stem>Requests = { <endpoint>: (queryArg: <Arg>): string \| FetchArgs => ({ url, params, body, … }) }`) and the endpoint uses it — a bundle that only builds requests imports that module without the endpoint injection. `requestBuilders: 'all'`: the module holds the builder of every operation (their argument types are written) while `filterEndpoints` still decides what the api file injects. `cookieParameters: 'drop'` (default): parameters `in: cookie` leave the endpoints (a browser sends cookies itself; `FetchArgs` has no field for them); `'keep'` restores RTK's output. Query and path parameters stay flat in the argument. |
|
|
54
54
|
| `models` | How the models of the component schemas are written; every option off by default. `naming: 'document'`: the model is named by the schema name's last dot segment exactly (`AIConversationMessage`, not `AiConversationMessage`), the segments before it are its folders — a neighbour namespace that prefixes the name never splits it. `enums: 'const'` (needs `naming: 'document'`): an enum property becomes `export const <Model><Property> = {…}` and `<Model><Property>Strict = {…} as const` in the model's file, the property typed `(typeof XStrict)[keyof typeof XStrict]` (`\| null` when nullable; `Array<…>` for an enum of array items); keys are the values with spaces, `/`, `\` as `_`, `""` as `EMPTY`. `nullableRefs: true`: `\| null` beside a nullable `$ref`. `idType: 'number' \| 'string'`: an `id` declared `string \| integer` gets that type. With `naming: 'document'` every file exports its own schema's name, also when another folder holds it too; importers alias it, the barrel leaves such a name out, and the api file imports each model by its path. `index: false`: no barrel. `enumPropertyType: 'wide'`: the property typed from the plain object (`string` in effect) instead of the Strict one. `objectType: 'const'`: a string `objectType` gets the one-value const of its schema name (`.` → `\\`, key `.` → `_`) and is required. Enum keys camel-case a dash (`gpt-realtime` → `gptRealtime`); a value that still gives no identifier is its own quoted key; an enum on an array schema stays an array. `scope: 'all'`: the models of every operation are written also when `filterEndpoints` keeps them out of the api file (their argument types are not). With several documents a shared model and its enum consts come from the first-listed one. |
|
|
55
55
|
|
|
56
56
|
```ts
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.15.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `endpoints.requestBuilders: 'all'`: `<stem>Requests.ts` holds the request builder of every operation of the
|
|
7
|
+
document (their argument types are written), while the api file injects only what `filterEndpoints` keeps.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- Parameters `in: cookie` leave the generated endpoints by default (`endpoints.cookieParameters: 'drop'`): a browser
|
|
11
|
+
sends its cookies itself and RTK Query's `FetchArgs` has no field for them — a request builder carrying `cookies`
|
|
12
|
+
failed the type check. `cookieParameters: 'keep'` restores the former output.
|
|
13
|
+
|
|
14
|
+
## 0.14.0
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- `endpoints.requestBuilders: true`: the request builder of every endpoint (its `query`) goes into
|
|
18
|
+
`<stem>Requests.ts` next to the api file — `export const <stem>Requests = { <endpoint>: (queryArg: <Arg>): string |
|
|
19
|
+
FetchArgs => ({ url, params, body, … }) }` — and the endpoint uses it (`query: <stem>Requests.<endpoint>`). A bundle
|
|
20
|
+
that only builds requests imports that module without the endpoint injection. Off by default.
|
|
21
|
+
|
|
3
22
|
## 0.13.0
|
|
4
23
|
|
|
5
24
|
### Added
|
|
@@ -494,9 +494,13 @@ function buildEndpointNameFromPath(method, path11, stripPathPrefix = DEFAULT_STR
|
|
|
494
494
|
function prepareDocumentForEndpoints(doc, options) {
|
|
495
495
|
const naming = options.naming ?? "rtk";
|
|
496
496
|
const bodyArg = options.bodyArg ?? "rtk";
|
|
497
|
+
const dropsCookieParameters = (options.cookieParameters ?? "drop") === "drop";
|
|
497
498
|
const endpointNamesByPlaceholder = /* @__PURE__ */ new Map();
|
|
498
|
-
if (naming === "rtk" && bodyArg === "rtk"
|
|
499
|
+
if (naming === "rtk" && bodyArg === "rtk" && !(dropsCookieParameters && hasCookieParameters(doc))) {
|
|
500
|
+
return { doc, endpointNamesByPlaceholder };
|
|
501
|
+
}
|
|
499
502
|
const prepared = structuredClone(doc);
|
|
503
|
+
if (dropsCookieParameters) dropCookieParameters(prepared);
|
|
500
504
|
const pathByName = /* @__PURE__ */ new Map();
|
|
501
505
|
for (const [path11, item] of Object.entries(prepared.paths ?? {})) {
|
|
502
506
|
if (!item) continue;
|
|
@@ -533,6 +537,35 @@ function restoreEndpointNames(code, locations, endpointNamesByPlaceholder) {
|
|
|
533
537
|
for (const [key, location] of locations) restoredLocations.set(restore(key), location);
|
|
534
538
|
return { code: restore(code), locations: restoredLocations };
|
|
535
539
|
}
|
|
540
|
+
var isCookieParameter = (parameter, doc) => {
|
|
541
|
+
const resolved = resolveParameter(parameter, doc);
|
|
542
|
+
return typeof resolved === "object" && resolved !== null && resolved.in === "cookie";
|
|
543
|
+
};
|
|
544
|
+
function resolveParameter(parameter, doc) {
|
|
545
|
+
const ref = parameter?.$ref;
|
|
546
|
+
if (typeof ref !== "string" || !ref.startsWith("#/components/parameters/")) return parameter;
|
|
547
|
+
return doc.components?.parameters?.[ref.slice("#/components/parameters/".length)];
|
|
548
|
+
}
|
|
549
|
+
function hasCookieParameters(doc) {
|
|
550
|
+
for (const item of Object.values(doc.paths ?? {})) {
|
|
551
|
+
if (!item) continue;
|
|
552
|
+
const lists = [item.parameters, ...HTTP_METHODS.map((method) => item[method]?.parameters)];
|
|
553
|
+
if (lists.some((list2) => Array.isArray(list2) && list2.some((parameter) => isCookieParameter(parameter, doc)))) return true;
|
|
554
|
+
}
|
|
555
|
+
return false;
|
|
556
|
+
}
|
|
557
|
+
function dropCookieParameters(doc) {
|
|
558
|
+
for (const item of Object.values(doc.paths ?? {})) {
|
|
559
|
+
if (!item) continue;
|
|
560
|
+
if (Array.isArray(item.parameters)) item.parameters = item.parameters.filter((parameter) => !isCookieParameter(parameter, doc));
|
|
561
|
+
for (const method of HTTP_METHODS) {
|
|
562
|
+
const operation = item[method];
|
|
563
|
+
if (operation && Array.isArray(operation.parameters)) {
|
|
564
|
+
operation.parameters = operation.parameters.filter((parameter) => !isCookieParameter(parameter, doc));
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
536
569
|
function titleRequestBody(operation) {
|
|
537
570
|
const content = operation.requestBody?.content;
|
|
538
571
|
for (const media of Object.values(content ?? {})) {
|
|
@@ -725,6 +758,101 @@ function replacePropertyTypes(body, typeTexts, requiredNames = /* @__PURE__ */ n
|
|
|
725
758
|
return result;
|
|
726
759
|
}
|
|
727
760
|
|
|
761
|
+
// src/codegen/request-builders.ts
|
|
762
|
+
function splitRequestBuilders(apiSource, requestsObjectName, requestsModuleSpecifier) {
|
|
763
|
+
const ts = loadTypeScript();
|
|
764
|
+
const sourceFile = ts.createSourceFile("api.ts", apiSource, ts.ScriptTarget.Latest, true);
|
|
765
|
+
const builders = [];
|
|
766
|
+
const replacements = [];
|
|
767
|
+
const visit = (node) => {
|
|
768
|
+
if (ts.isPropertyAssignment(node) && ts.isCallExpression(node.initializer)) {
|
|
769
|
+
const call = node.initializer;
|
|
770
|
+
const callee = call.expression;
|
|
771
|
+
const isBuildCall2 = ts.isPropertyAccessExpression(callee) && ["query", "mutation"].includes(callee.name.text) && ts.isIdentifier(callee.expression);
|
|
772
|
+
const definition = call.arguments[0];
|
|
773
|
+
if (isBuildCall2 && definition && ts.isObjectLiteralExpression(definition)) {
|
|
774
|
+
const endpointName = node.name.getText(sourceFile).replace(/^["']|["']$/g, "");
|
|
775
|
+
const queryProperty = definition.properties.find(
|
|
776
|
+
(property) => ts.isPropertyAssignment(property) && property.name.getText(sourceFile) === "query" && ts.isArrowFunction(property.initializer)
|
|
777
|
+
);
|
|
778
|
+
if (queryProperty && ts.isArrowFunction(queryProperty.initializer)) {
|
|
779
|
+
const builder = queryProperty.initializer;
|
|
780
|
+
const argType = call.typeArguments?.[1]?.getText(sourceFile);
|
|
781
|
+
const parameter = builder.parameters[0];
|
|
782
|
+
const parameterText = parameter && !parameter.type && argType && argType !== "void" ? `(${parameter.name.getText(sourceFile)}: ${argType})` : `(${builder.parameters.map((current) => current.getText(sourceFile)).join(", ")})`;
|
|
783
|
+
const bodyText = builder.body.getText(sourceFile);
|
|
784
|
+
builders.push({ name: endpointName, text: `${parameterText}: string | FetchArgs => ${bodyText}` });
|
|
785
|
+
replacements.push({
|
|
786
|
+
start: builder.getStart(sourceFile),
|
|
787
|
+
end: builder.getEnd(),
|
|
788
|
+
text: `${requestsObjectName}.${endpointName}`
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
ts.forEachChild(node, visit);
|
|
794
|
+
};
|
|
795
|
+
visit(sourceFile);
|
|
796
|
+
if (builders.length === 0) return { apiSource, requestsSource: "", count: 0 };
|
|
797
|
+
let replacedApiSource = apiSource;
|
|
798
|
+
for (const { start, end, text } of replacements.sort((a, b) => b.start - a.start)) {
|
|
799
|
+
replacedApiSource = replacedApiSource.slice(0, start) + text + replacedApiSource.slice(end);
|
|
800
|
+
}
|
|
801
|
+
const importDeclarations = sourceFile.statements.filter(ts.isImportDeclaration);
|
|
802
|
+
const importTexts = importDeclarations.map((declaration) => declaration.getText(sourceFile));
|
|
803
|
+
const requestsBody = `export const ${requestsObjectName} = {
|
|
804
|
+
` + builders.map(({ name, text }) => ` ${/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) ? name : JSON.stringify(name)}: ${text},`).join("\n") + "\n};\n";
|
|
805
|
+
const requestsSource = [
|
|
806
|
+
`import type { FetchArgs } from '@reduxjs/toolkit/query';`,
|
|
807
|
+
...keepUsedImports(ts, importTexts, requestsBody)
|
|
808
|
+
].join("\n") + `
|
|
809
|
+
|
|
810
|
+
${requestsBody}`;
|
|
811
|
+
const apiWithoutImports = stripImports(ts, replacedApiSource);
|
|
812
|
+
const apiImports = [
|
|
813
|
+
...keepUsedImports(ts, importTexts, apiWithoutImports),
|
|
814
|
+
`import { ${requestsObjectName} } from '${requestsModuleSpecifier}';`
|
|
815
|
+
];
|
|
816
|
+
return { apiSource: `${apiImports.join("\n")}
|
|
817
|
+
${apiWithoutImports}`, requestsSource, count: builders.length };
|
|
818
|
+
}
|
|
819
|
+
function stripImports(ts, source) {
|
|
820
|
+
const sourceFile = ts.createSourceFile("api.ts", source, ts.ScriptTarget.Latest, true);
|
|
821
|
+
let result = source;
|
|
822
|
+
for (const declaration of [...sourceFile.statements.filter(ts.isImportDeclaration)].reverse()) {
|
|
823
|
+
result = result.slice(0, declaration.getFullStart()) + result.slice(declaration.getEnd());
|
|
824
|
+
}
|
|
825
|
+
return result.replace(/^\s+/, "\n");
|
|
826
|
+
}
|
|
827
|
+
function keepUsedImports(ts, importTexts, body) {
|
|
828
|
+
const usedNames = /* @__PURE__ */ new Set();
|
|
829
|
+
const bodyFile = ts.createSourceFile("body.ts", body, ts.ScriptTarget.Latest, true);
|
|
830
|
+
const collect = (node) => {
|
|
831
|
+
if (ts.isIdentifier(node) && !(ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) && !(ts.isPropertyAssignment(node.parent) && node.parent.name === node)) {
|
|
832
|
+
usedNames.add(node.text);
|
|
833
|
+
}
|
|
834
|
+
ts.forEachChild(node, collect);
|
|
835
|
+
};
|
|
836
|
+
collect(bodyFile);
|
|
837
|
+
const used = (name) => usedNames.has(name);
|
|
838
|
+
const kept = [];
|
|
839
|
+
for (const importText of importTexts) {
|
|
840
|
+
const sourceFile = ts.createSourceFile("import.ts", importText, ts.ScriptTarget.Latest, true);
|
|
841
|
+
const declaration = sourceFile.statements.find(ts.isImportDeclaration);
|
|
842
|
+
const bindings = declaration?.importClause?.namedBindings;
|
|
843
|
+
if (!declaration || !bindings || !ts.isNamedImports(bindings) || declaration.importClause?.name) {
|
|
844
|
+
kept.push(importText);
|
|
845
|
+
continue;
|
|
846
|
+
}
|
|
847
|
+
const elements = bindings.elements.filter((element) => used(element.name.text));
|
|
848
|
+
if (elements.length === 0) continue;
|
|
849
|
+
const typeOnly = declaration.importClause?.isTypeOnly ? "type " : "";
|
|
850
|
+
const specifier = declaration.moduleSpecifier.getText(sourceFile);
|
|
851
|
+
kept.push(`import ${typeOnly}{ ${elements.map((element) => element.getText(sourceFile)).join(", ")} } from ${specifier};`);
|
|
852
|
+
}
|
|
853
|
+
return kept;
|
|
854
|
+
}
|
|
855
|
+
|
|
728
856
|
// src/codegen/endpoints.ts
|
|
729
857
|
function toOpenApiPath(url) {
|
|
730
858
|
return url.replace(/\$\{encodeURIComponent\(String\(queryArg\.([A-Za-z0-9_]+)\)\)\}/g, "{$1}").replace(/\$\{queryArg\.([A-Za-z0-9_]+)\}/g, "{$1}");
|
|
@@ -1741,7 +1869,7 @@ function buildRegistry(docs, logger) {
|
|
|
1741
1869
|
}
|
|
1742
1870
|
|
|
1743
1871
|
// src/codegen/repair.ts
|
|
1744
|
-
function
|
|
1872
|
+
function resolveParameter2(doc, parameter) {
|
|
1745
1873
|
let current = parameter;
|
|
1746
1874
|
for (let hops = 0; current?.$ref !== void 0 && hops < 10; hops++) {
|
|
1747
1875
|
const match = /^#\/components\/parameters\/(.+)$/.exec(current.$ref);
|
|
@@ -1758,7 +1886,7 @@ function repairMissingPathParameters(doc, logger) {
|
|
|
1758
1886
|
if (placeholders.length === 0) continue;
|
|
1759
1887
|
const pathLevel = doc.paths?.[path11]?.parameters ?? [];
|
|
1760
1888
|
const declared = new Set(
|
|
1761
|
-
[...pathLevel, ...operation.parameters ?? []].map((parameter) =>
|
|
1889
|
+
[...pathLevel, ...operation.parameters ?? []].map((parameter) => resolveParameter2(doc, parameter)).filter((parameter) => parameter !== null && parameter.in === "path").map((parameter) => parameter.name)
|
|
1762
1890
|
);
|
|
1763
1891
|
const missing = placeholders.filter((name) => !declared.has(name));
|
|
1764
1892
|
if (missing.length > 0) repairs.push({ path: path11, method, names: missing });
|
|
@@ -2031,22 +2159,15 @@ async function generateSdk(options = {}) {
|
|
|
2031
2159
|
const modelOptions = loaded.config.models ?? {};
|
|
2032
2160
|
const prepared = prepareDocumentForModels(doc, modelOptions);
|
|
2033
2161
|
const preparedEndpoints = prepareDocumentForEndpoints(prepared.doc, loaded.config.endpoints ?? {});
|
|
2034
|
-
const
|
|
2035
|
-
|
|
2036
|
-
preparedEndpoints.doc,
|
|
2037
|
-
index,
|
|
2038
|
-
path9.join(specDir, `${i}.json`),
|
|
2039
|
-
prettierConfigFile,
|
|
2040
|
-
(rtkName) => preparedEndpoints.endpointNamesByPlaceholder.get(rtkName) ?? rtkName
|
|
2041
|
-
);
|
|
2042
|
-
const rtk = restoreEndpointNames(generated.code, generated.locations, preparedEndpoints.endpointNamesByPlaceholder);
|
|
2162
|
+
const endpointOptions = loaded.config.endpoints ?? {};
|
|
2163
|
+
const esm = api.config.esmExtensions === true;
|
|
2043
2164
|
const extractOptions = {
|
|
2044
2165
|
apiFilePath: api.outputFile,
|
|
2045
2166
|
modelsDir,
|
|
2046
2167
|
registry,
|
|
2047
2168
|
files,
|
|
2048
2169
|
logger,
|
|
2049
|
-
esm
|
|
2170
|
+
esm,
|
|
2050
2171
|
documentModels: prepared.documentModels,
|
|
2051
2172
|
enumConsts: modelOptions.enums === "const",
|
|
2052
2173
|
constsByFile,
|
|
@@ -2054,36 +2175,49 @@ async function generateSdk(options = {}) {
|
|
|
2054
2175
|
writeIndex: modelOptions.index !== false,
|
|
2055
2176
|
uniqueNameByPath
|
|
2056
2177
|
};
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2178
|
+
const endpointNameOf = (rtkName) => preparedEndpoints.endpointNamesByPlaceholder.get(rtkName) ?? rtkName;
|
|
2179
|
+
const runPass = async (passApi, specName, modelsOnly) => {
|
|
2180
|
+
const generated = await runRtkCodegen(passApi, preparedEndpoints.doc, index, path9.join(specDir, specName), prettierConfigFile, endpointNameOf);
|
|
2181
|
+
const rtk = restoreEndpointNames(generated.code, generated.locations, preparedEndpoints.endpointNamesByPlaceholder);
|
|
2182
|
+
const endpoints2 = parseApiEndpoints(rtk.code, logger, rtk.locations);
|
|
2183
|
+
const handlerEndpoints2 = detectResponseHandlerEndpoints(doc, endpoints2, api.responseHandlers);
|
|
2184
|
+
const responseKinds = /* @__PURE__ */ new Map();
|
|
2185
|
+
for (const endpoint of endpoints2) {
|
|
2186
|
+
const kind = handlerEndpoints2.get(endpoint.key);
|
|
2187
|
+
if (kind && endpoint.responseType) responseKinds.set(endpoint.responseType, kind);
|
|
2188
|
+
}
|
|
2189
|
+
const multipart = injectMultipartBodies(rtk.code, detectMultipartEndpoints(doc, endpoints2), logger);
|
|
2190
|
+
const apiSource = extractModels({ ...extractOptions, apiSource: multipart.source, responseKinds, modelsOnly });
|
|
2191
|
+
const withHandlers = injectResponseHandlers(apiSource, handlerEndpoints2);
|
|
2192
|
+
const finalApiSource2 = multipart.injected.length > 0 ? `${MULTIPART_IMPORT}
|
|
2193
|
+
${withHandlers}` : withHandlers;
|
|
2194
|
+
return { endpoints: endpoints2, handlerEndpoints: handlerEndpoints2, multipartCount: multipart.injected.length, finalApiSource: finalApiSource2 };
|
|
2195
|
+
};
|
|
2196
|
+
const buildersOfAllOperations = endpointOptions.requestBuilders === "all" && api.config.filterEndpoints !== void 0;
|
|
2197
|
+
let requestsSourceOfAllOperations = null;
|
|
2198
|
+
if ((modelOptions.scope === "all" || buildersOfAllOperations) && api.config.filterEndpoints !== void 0) {
|
|
2199
|
+
const unfiltered = await runPass({ ...api, config: { ...api.config, filterEndpoints: void 0 } }, `${i}-all.json`, !buildersOfAllOperations);
|
|
2200
|
+
if (buildersOfAllOperations) {
|
|
2201
|
+
const requestsStem = `${api.stem}Requests`;
|
|
2202
|
+
requestsSourceOfAllOperations = splitRequestBuilders(unfiltered.finalApiSource, requestsStem, `./${requestsStem}`).requestsSource;
|
|
2203
|
+
logger.info(" request builders of all operations (endpoints.requestBuilders all)");
|
|
2204
|
+
}
|
|
2205
|
+
if (modelOptions.scope === "all") logger.info(" models of all operations written (models.scope all)");
|
|
2076
2206
|
}
|
|
2207
|
+
const { endpoints, handlerEndpoints, multipartCount, finalApiSource } = await runPass(api, `${i}.json`, false);
|
|
2077
2208
|
const fileCount = [...handlerEndpoints.values()].filter((kind) => kind === "blob").length;
|
|
2078
2209
|
if (fileCount > 0) logger.info(` ${fileCount} file download endpoint(s) (blobResponseHandler)`);
|
|
2079
|
-
|
|
2080
|
-
if (multipart.injected.length > 0) logger.info(` ${multipart.injected.length} multipart endpoint(s) (multipartFiles)`);
|
|
2081
|
-
const esm = api.config.esmExtensions === true;
|
|
2082
|
-
const apiSource = extractModels({ ...extractOptions, apiSource: multipart.source, responseKinds });
|
|
2210
|
+
if (multipartCount > 0) logger.info(` ${multipartCount} multipart endpoint(s) (multipartFiles)`);
|
|
2083
2211
|
if (!write) continue;
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2212
|
+
if (endpointOptions.requestBuilders) {
|
|
2213
|
+
const requestsStem = `${api.stem}Requests`;
|
|
2214
|
+
const split = splitRequestBuilders(finalApiSource, requestsStem, esm ? `./${requestsStem}.js` : `./${requestsStem}`);
|
|
2215
|
+
files.set(api.outputFile, split.apiSource);
|
|
2216
|
+
files.set(path9.join(api.outputDir, `${requestsStem}.ts`), requestsSourceOfAllOperations ?? split.requestsSource);
|
|
2217
|
+
logger.info(` ${split.count} request builder(s) used by ${api.stem}.ts`);
|
|
2218
|
+
} else {
|
|
2219
|
+
files.set(api.outputFile, finalApiSource);
|
|
2220
|
+
}
|
|
2087
2221
|
const withExtension = (specifier) => esm ? `${specifier}.js` : specifier;
|
|
2088
2222
|
const enhanced = buildEnhancedEndpoints({
|
|
2089
2223
|
stem: api.stem,
|
|
@@ -2195,4 +2329,4 @@ export {
|
|
|
2195
2329
|
generateSdk,
|
|
2196
2330
|
linkSkills
|
|
2197
2331
|
};
|
|
2198
|
-
//# sourceMappingURL=chunk-
|
|
2332
|
+
//# sourceMappingURL=chunk-6CQEUZ3B.js.map
|