persona-community-5/.pnpm-store/v3/files/b4/777b2ceff820c347a0bb0be46deaa401f1ce245a70c92cdd7655c6fe19390fbe798881d8c36d493322fb440ea9abe672ec0b35fb10d0d64814f4db2d9da650
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

63 lines
2.0 KiB
Plaintext

import ts from 'typescript';
import { tsModifiers, tsPropertyIndex, addJSDocComment, QUESTION_TOKEN, NEVER } from '../lib/ts.mjs';
import { getEntries, createRef } from '../lib/utils.mjs';
import transformMediaTypeObject from './media-type-object.mjs';
import transformSchemaObject from './schema-object.mjs';
function transformRequestBodyObject(requestBodyObject, options) {
const type = [];
for (const [contentType, mediaTypeObject] of getEntries(requestBodyObject.content ?? {}, options.ctx)) {
const nextPath = createRef([options.path, "content", contentType]);
const mediaType = "$ref" in mediaTypeObject ? transformSchemaObject(mediaTypeObject, {
...options,
path: nextPath
}) : transformMediaTypeObject(mediaTypeObject, {
...options,
path: nextPath
});
const property = ts.factory.createPropertySignature(
/* modifiers */
tsModifiers({ readonly: options.ctx.immutable }),
/* name */
tsPropertyIndex(contentType),
/* questionToken */
void 0,
/* type */
mediaType
);
addJSDocComment(mediaTypeObject, property);
type.push(property);
}
return ts.factory.createTypeLiteralNode([
ts.factory.createPropertySignature(
/* modifiers */
tsModifiers({ readonly: options.ctx.immutable }),
/* name */
tsPropertyIndex("content"),
/* questionToken */
void 0,
/* type */
ts.factory.createTypeLiteralNode(
type.length ? type : (
// add `"*/*": never` if no media types are defined
[
ts.factory.createPropertySignature(
/* modifiers */
void 0,
/* name */
tsPropertyIndex("*/*"),
/* questionToken */
QUESTION_TOKEN,
/* type */
NEVER
)
]
)
)
)
]);
}
export { transformRequestBodyObject as default };
//# sourceMappingURL=request-body-object.mjs.map