@nestia/core 2.6.3-dev.20240328 → 2.6.3

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.
Files changed (32) hide show
  1. package/package.json +3 -3
  2. package/src/decorators/EncryptedBody.ts +105 -105
  3. package/src/decorators/EncryptedModule.ts +96 -96
  4. package/src/decorators/PlainBody.ts +75 -75
  5. package/src/decorators/SwaggerCustomizer.ts +116 -116
  6. package/src/decorators/TypedBody.ts +62 -62
  7. package/src/decorators/TypedException.ts +90 -90
  8. package/src/decorators/TypedFormData.ts +219 -219
  9. package/src/decorators/TypedQuery.ts +251 -251
  10. package/src/decorators/TypedRoute.ts +144 -144
  11. package/src/decorators/internal/get_path_and_querify.ts +106 -106
  12. package/src/decorators/internal/load_controller.ts +51 -51
  13. package/src/decorators/internal/validate_request_body.ts +72 -72
  14. package/src/decorators/internal/validate_request_form_data.ts +75 -75
  15. package/src/decorators/internal/validate_request_headers.ts +83 -83
  16. package/src/decorators/internal/validate_request_query.ts +71 -71
  17. package/src/module.ts +16 -16
  18. package/src/options/IRequestFormDataProps.ts +27 -27
  19. package/src/programmers/PlainBodyProgrammer.ts +52 -52
  20. package/src/programmers/TypedExceptionProgrammer.ts +71 -71
  21. package/src/programmers/TypedFormDataBodyProgrammer.ts +108 -108
  22. package/src/programmers/http/HttpQuerifyProgrammer.ts +96 -96
  23. package/src/structures/ISwagger.ts +91 -91
  24. package/src/structures/ISwaggerComponents.ts +29 -29
  25. package/src/structures/ISwaggerInfo.ts +80 -80
  26. package/src/structures/ISwaggerRoute.ts +50 -50
  27. package/src/structures/ISwaggerSecurityScheme.ts +65 -65
  28. package/src/transformers/NodeTransformer.ts +16 -16
  29. package/src/transformers/ParameterDecoratorTransformer.ts +120 -120
  30. package/src/transformers/TypedExceptionTransformer.ts +48 -48
  31. package/src/transformers/TypedRouteTransformer.ts +88 -88
  32. package/src/utils/Singleton.ts +20 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestia/core",
3
- "version": "2.6.3-dev.20240328",
3
+ "version": "2.6.3",
4
4
  "description": "Super-fast validation decorators of NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "homepage": "https://nestia.io",
38
38
  "dependencies": {
39
- "@nestia/fetcher": "^2.6.3-dev.20240328",
39
+ "@nestia/fetcher": "^2.6.3",
40
40
  "@nestjs/common": ">=7.0.1",
41
41
  "@nestjs/core": ">=7.0.1",
42
42
  "detect-ts-node": "^1.0.5",
@@ -48,7 +48,7 @@
48
48
  "typia": "^5.5.7"
49
49
  },
50
50
  "peerDependencies": {
51
- "@nestia/fetcher": ">=2.6.3-dev.20240328",
51
+ "@nestia/fetcher": ">=2.6.3",
52
52
  "@nestjs/common": ">=7.0.1",
53
53
  "@nestjs/core": ">=7.0.1",
54
54
  "reflect-metadata": ">=0.1.12",
@@ -1,105 +1,105 @@
1
- import { AesPkcs5 } from "@nestia/fetcher/lib/AesPkcs5";
2
- import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
3
- import {
4
- BadRequestException,
5
- ExecutionContext,
6
- createParamDecorator,
7
- } from "@nestjs/common";
8
- import type express from "express";
9
- import type { FastifyRequest } from "fastify";
10
- import { assert, is, validate } from "typia";
11
-
12
- import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
13
- import { Singleton } from "../utils/Singleton";
14
- import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
15
- import { get_text_body } from "./internal/get_text_body";
16
- import { headers_to_object } from "./internal/headers_to_object";
17
- import { validate_request_body } from "./internal/validate_request_body";
18
-
19
- /**
20
- * Encrypted body decorator.
21
- *
22
- * `EncryptedBody` is a decorator function getting `application/json` typed data from
23
- * requeset body which has been encrypted by AES-128/256 algorithm. Also,
24
- * `EncyrptedBody` validates the request body data type through
25
- * [typia](https://github.com/samchon/typia) ad the validation speed is
26
- * maximum 15,000x times faster than `class-validator`.
27
- *
28
- * For reference, when the request body data is not following the promised type `T`,
29
- * `BadRequestException` error (status code: 400) would be thrown. Also,
30
- * `EncryptedRoute` decrypts request body using those options.
31
- *
32
- * - AES-128/256
33
- * - CBC mode
34
- * - PKCS #5 Padding
35
- * - Base64 Encoding
36
- *
37
- * @return Parameter decorator
38
- * @author Jeongho Nam - https://github.com/samchon
39
- */
40
- export function EncryptedBody<T>(
41
- validator?: IRequestBodyValidator<T>,
42
- ): ParameterDecorator {
43
- const checker = validate_request_body("EncryptedBody")(validator);
44
- return createParamDecorator(async function EncryptedBody(
45
- _unknown: any,
46
- context: ExecutionContext,
47
- ) {
48
- const request: express.Request | FastifyRequest = context
49
- .switchToHttp()
50
- .getRequest();
51
- if (isTextPlain(request.headers["content-type"]) === false)
52
- throw new BadRequestException(`Request body type is not "text/plain".`);
53
-
54
- const param: IEncryptionPassword | IEncryptionPassword.Closure | undefined =
55
- Reflect.getMetadata(ENCRYPTION_METADATA_KEY, context.getClass());
56
- if (!param)
57
- throw new Error(
58
- "Error on nestia.core.EncryptedBody(): no encryption password is given.",
59
- );
60
-
61
- // GET BODY DATA
62
- const headers: Singleton<Record<string, string>> = new Singleton(() =>
63
- headers_to_object(request.headers),
64
- );
65
- const body: string = await get_text_body(request);
66
- const password: IEncryptionPassword =
67
- typeof param === "function"
68
- ? param({ headers: headers.get(), body, direction: "decode" })
69
- : param;
70
-
71
- // PARSE AND VALIDATE DATA
72
- const data: any = JSON.parse(decrypt(body, password.key, password.iv));
73
- const error: Error | null = checker(data);
74
- if (error !== null) throw error;
75
- return data;
76
- })();
77
- }
78
- Object.assign(EncryptedBody, is);
79
- Object.assign(EncryptedBody, assert);
80
- Object.assign(EncryptedBody, validate);
81
-
82
- /**
83
- * @internal
84
- */
85
- const decrypt = (body: string, key: string, iv: string): string => {
86
- try {
87
- return AesPkcs5.decrypt(body, key, iv);
88
- } catch (exp) {
89
- if (exp instanceof Error)
90
- throw new BadRequestException(
91
- "Failed to decrypt the request body. Check your body content or encryption password.",
92
- );
93
- else throw exp;
94
- }
95
- };
96
-
97
- /**
98
- * @internal
99
- */
100
- const isTextPlain = (text?: string): boolean =>
101
- text !== undefined &&
102
- text
103
- .split(";")
104
- .map((str) => str.trim())
105
- .some((str) => str === "text/plain");
1
+ import { AesPkcs5 } from "@nestia/fetcher/lib/AesPkcs5";
2
+ import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
3
+ import {
4
+ BadRequestException,
5
+ ExecutionContext,
6
+ createParamDecorator,
7
+ } from "@nestjs/common";
8
+ import type express from "express";
9
+ import type { FastifyRequest } from "fastify";
10
+ import { assert, is, validate } from "typia";
11
+
12
+ import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
13
+ import { Singleton } from "../utils/Singleton";
14
+ import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
15
+ import { get_text_body } from "./internal/get_text_body";
16
+ import { headers_to_object } from "./internal/headers_to_object";
17
+ import { validate_request_body } from "./internal/validate_request_body";
18
+
19
+ /**
20
+ * Encrypted body decorator.
21
+ *
22
+ * `EncryptedBody` is a decorator function getting `application/json` typed data from
23
+ * requeset body which has been encrypted by AES-128/256 algorithm. Also,
24
+ * `EncyrptedBody` validates the request body data type through
25
+ * [typia](https://github.com/samchon/typia) ad the validation speed is
26
+ * maximum 15,000x times faster than `class-validator`.
27
+ *
28
+ * For reference, when the request body data is not following the promised type `T`,
29
+ * `BadRequestException` error (status code: 400) would be thrown. Also,
30
+ * `EncryptedRoute` decrypts request body using those options.
31
+ *
32
+ * - AES-128/256
33
+ * - CBC mode
34
+ * - PKCS #5 Padding
35
+ * - Base64 Encoding
36
+ *
37
+ * @return Parameter decorator
38
+ * @author Jeongho Nam - https://github.com/samchon
39
+ */
40
+ export function EncryptedBody<T>(
41
+ validator?: IRequestBodyValidator<T>,
42
+ ): ParameterDecorator {
43
+ const checker = validate_request_body("EncryptedBody")(validator);
44
+ return createParamDecorator(async function EncryptedBody(
45
+ _unknown: any,
46
+ context: ExecutionContext,
47
+ ) {
48
+ const request: express.Request | FastifyRequest = context
49
+ .switchToHttp()
50
+ .getRequest();
51
+ if (isTextPlain(request.headers["content-type"]) === false)
52
+ throw new BadRequestException(`Request body type is not "text/plain".`);
53
+
54
+ const param: IEncryptionPassword | IEncryptionPassword.Closure | undefined =
55
+ Reflect.getMetadata(ENCRYPTION_METADATA_KEY, context.getClass());
56
+ if (!param)
57
+ throw new Error(
58
+ "Error on nestia.core.EncryptedBody(): no encryption password is given.",
59
+ );
60
+
61
+ // GET BODY DATA
62
+ const headers: Singleton<Record<string, string>> = new Singleton(() =>
63
+ headers_to_object(request.headers),
64
+ );
65
+ const body: string = await get_text_body(request);
66
+ const password: IEncryptionPassword =
67
+ typeof param === "function"
68
+ ? param({ headers: headers.get(), body, direction: "decode" })
69
+ : param;
70
+
71
+ // PARSE AND VALIDATE DATA
72
+ const data: any = JSON.parse(decrypt(body, password.key, password.iv));
73
+ const error: Error | null = checker(data);
74
+ if (error !== null) throw error;
75
+ return data;
76
+ })();
77
+ }
78
+ Object.assign(EncryptedBody, is);
79
+ Object.assign(EncryptedBody, assert);
80
+ Object.assign(EncryptedBody, validate);
81
+
82
+ /**
83
+ * @internal
84
+ */
85
+ const decrypt = (body: string, key: string, iv: string): string => {
86
+ try {
87
+ return AesPkcs5.decrypt(body, key, iv);
88
+ } catch (exp) {
89
+ if (exp instanceof Error)
90
+ throw new BadRequestException(
91
+ "Failed to decrypt the request body. Check your body content or encryption password.",
92
+ );
93
+ else throw exp;
94
+ }
95
+ };
96
+
97
+ /**
98
+ * @internal
99
+ */
100
+ const isTextPlain = (text?: string): boolean =>
101
+ text !== undefined &&
102
+ text
103
+ .split(";")
104
+ .map((str) => str.trim())
105
+ .some((str) => str === "text/plain");
@@ -1,96 +1,96 @@
1
- import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
2
- import { Module } from "@nestjs/common";
3
-
4
- import { Creator } from "../typings/Creator";
5
- import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
6
- import { load_controllers } from "./internal/load_controller";
7
-
8
- /**
9
- * Encrypted module.
10
- *
11
- * `EncryptedModule` is an extension of the {@link Module} class decorator function
12
- * who configures encryption password of the AES-128/256 algorithm. The encryption
13
- * algorithm and password would be used by {@link EncryptedRoute} and {@link EncryptedBody}
14
- * to encrypt the request and response bod of the HTTP protocol.
15
- *
16
- * By using this `EncryptedModule` decorator function, all of the
17
- * {@link Controller controllers} configured in the *metadata* would be automatically
18
- * changed to the {@link EncryptedController} with the *password*. If there're some
19
- * original {@link EncryptedController} decorated classes in the *metadata*, their
20
- * encryption password would be kept.
21
- *
22
- * Therefore, if you're planning to place original {@link EncryptedController} decorated
23
- * classes in the *metadata*, I hope them to have different encryption password from the
24
- * module level. If not, I recommend you use the {@link Controller} decorator
25
- * function instead.
26
- *
27
- * In addition, the `EncryptedModule` supports a convenient dynamic controller importing
28
- * function, {@link EncryptedModule.dynamic}. If you utilize the function with directory
29
- * path of the controller classes, it imports and configures the controller classes into
30
- * the `Module`, automatically.
31
- *
32
- * @param metadata Module configuration metadata
33
- * @param password Encryption password or its getter function
34
- * @returns Class decorator
35
- *
36
- * @author Jeongho Nam - https://github.com/samchon
37
- */
38
- export function EncryptedModule(
39
- metadata: Parameters<typeof Module>[0],
40
- password: IEncryptionPassword.Closure,
41
- ): ClassDecorator {
42
- return function (target: any) {
43
- Module(metadata)(target);
44
- iterate(password)(target);
45
- };
46
- }
47
-
48
- export namespace EncryptedModule {
49
- /**
50
- * Dynamic encrypted module.
51
- *
52
- * `EncryptedModule.dynamic` is an extension of the {@link EncryptedModule} function
53
- * who configures controller classes by the dynamic importing. By specifying directory
54
- * path of the controller classes, those controllers would be automatically imported
55
- * and configured.
56
- *
57
- * @param path Directory path of the controller classes
58
- * @param password Encryption password or its getter function
59
- * @param options Additional options except controller
60
- * @returns Class decorated module instance
61
- */
62
- export async function dynamic(
63
- path: string | string[] | { include: string[]; exclude?: string[] },
64
- password: IEncryptionPassword | IEncryptionPassword.Closure,
65
- options: Omit<Parameters<typeof Module>[0], "controllers"> = {},
66
- ): Promise<object> {
67
- // LOAD CONTROLLERS
68
- const controllers: Creator<object>[] = await load_controllers(path);
69
-
70
- // RETURNS WITH DECORATING
71
- @EncryptedModule(
72
- { ...options, controllers },
73
- typeof password === "object" ? () => password : password,
74
- )
75
- class NestiaModule {}
76
- return NestiaModule;
77
- }
78
- }
79
-
80
- /**
81
- * @internal
82
- */
83
- const iterate =
84
- (password: IEncryptionPassword.Closure) =>
85
- (modulo: any): void => {
86
- const imports = Reflect.getMetadata("imports", modulo);
87
- if (Array.isArray(imports))
88
- for (const imp of imports)
89
- if (typeof imp === "function") iterate(password)(imp);
90
-
91
- const controllers = Reflect.getMetadata("controllers", modulo);
92
- if (Array.isArray(controllers))
93
- for (const c of controllers)
94
- if (typeof c === "function")
95
- Reflect.defineMetadata(ENCRYPTION_METADATA_KEY, password, c);
96
- };
1
+ import { IEncryptionPassword } from "@nestia/fetcher/lib/IEncryptionPassword";
2
+ import { Module } from "@nestjs/common";
3
+
4
+ import { Creator } from "../typings/Creator";
5
+ import { ENCRYPTION_METADATA_KEY } from "./internal/EncryptedConstant";
6
+ import { load_controllers } from "./internal/load_controller";
7
+
8
+ /**
9
+ * Encrypted module.
10
+ *
11
+ * `EncryptedModule` is an extension of the {@link Module} class decorator function
12
+ * who configures encryption password of the AES-128/256 algorithm. The encryption
13
+ * algorithm and password would be used by {@link EncryptedRoute} and {@link EncryptedBody}
14
+ * to encrypt the request and response bod of the HTTP protocol.
15
+ *
16
+ * By using this `EncryptedModule` decorator function, all of the
17
+ * {@link Controller controllers} configured in the *metadata* would be automatically
18
+ * changed to the {@link EncryptedController} with the *password*. If there're some
19
+ * original {@link EncryptedController} decorated classes in the *metadata*, their
20
+ * encryption password would be kept.
21
+ *
22
+ * Therefore, if you're planning to place original {@link EncryptedController} decorated
23
+ * classes in the *metadata*, I hope them to have different encryption password from the
24
+ * module level. If not, I recommend you use the {@link Controller} decorator
25
+ * function instead.
26
+ *
27
+ * In addition, the `EncryptedModule` supports a convenient dynamic controller importing
28
+ * function, {@link EncryptedModule.dynamic}. If you utilize the function with directory
29
+ * path of the controller classes, it imports and configures the controller classes into
30
+ * the `Module`, automatically.
31
+ *
32
+ * @param metadata Module configuration metadata
33
+ * @param password Encryption password or its getter function
34
+ * @returns Class decorator
35
+ *
36
+ * @author Jeongho Nam - https://github.com/samchon
37
+ */
38
+ export function EncryptedModule(
39
+ metadata: Parameters<typeof Module>[0],
40
+ password: IEncryptionPassword.Closure,
41
+ ): ClassDecorator {
42
+ return function (target: any) {
43
+ Module(metadata)(target);
44
+ iterate(password)(target);
45
+ };
46
+ }
47
+
48
+ export namespace EncryptedModule {
49
+ /**
50
+ * Dynamic encrypted module.
51
+ *
52
+ * `EncryptedModule.dynamic` is an extension of the {@link EncryptedModule} function
53
+ * who configures controller classes by the dynamic importing. By specifying directory
54
+ * path of the controller classes, those controllers would be automatically imported
55
+ * and configured.
56
+ *
57
+ * @param path Directory path of the controller classes
58
+ * @param password Encryption password or its getter function
59
+ * @param options Additional options except controller
60
+ * @returns Class decorated module instance
61
+ */
62
+ export async function dynamic(
63
+ path: string | string[] | { include: string[]; exclude?: string[] },
64
+ password: IEncryptionPassword | IEncryptionPassword.Closure,
65
+ options: Omit<Parameters<typeof Module>[0], "controllers"> = {},
66
+ ): Promise<object> {
67
+ // LOAD CONTROLLERS
68
+ const controllers: Creator<object>[] = await load_controllers(path);
69
+
70
+ // RETURNS WITH DECORATING
71
+ @EncryptedModule(
72
+ { ...options, controllers },
73
+ typeof password === "object" ? () => password : password,
74
+ )
75
+ class NestiaModule {}
76
+ return NestiaModule;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * @internal
82
+ */
83
+ const iterate =
84
+ (password: IEncryptionPassword.Closure) =>
85
+ (modulo: any): void => {
86
+ const imports = Reflect.getMetadata("imports", modulo);
87
+ if (Array.isArray(imports))
88
+ for (const imp of imports)
89
+ if (typeof imp === "function") iterate(password)(imp);
90
+
91
+ const controllers = Reflect.getMetadata("controllers", modulo);
92
+ if (Array.isArray(controllers))
93
+ for (const c of controllers)
94
+ if (typeof c === "function")
95
+ Reflect.defineMetadata(ENCRYPTION_METADATA_KEY, password, c);
96
+ };
@@ -1,75 +1,75 @@
1
- import {
2
- BadRequestException,
3
- ExecutionContext,
4
- createParamDecorator,
5
- } from "@nestjs/common";
6
- import type express from "express";
7
- import type { FastifyRequest } from "fastify";
8
- import { assert } from "typia";
9
-
10
- import { get_text_body } from "./internal/get_text_body";
11
- import { validate_request_body } from "./internal/validate_request_body";
12
-
13
- /**
14
- * Plain body decorator.
15
- *
16
- * `PlainBody` is a decorator function getting full body text from the HTTP request.
17
- *
18
- * If you adjust the regular {@link Body} decorator function to the body parameter,
19
- * you can't get the full body text because the {@link Body} tries to convert the
20
- * body text to JSON object. Therefore, `@nestia/core` provides this `PlainBody`
21
- * decorator function to get the full body text.
22
- *
23
- * ```typescript
24
- * \@TypedRoute.Post("memo")
25
- * public store
26
- * (
27
- * \@PlainBody() body: string
28
- * ): void;
29
- * ```
30
- *
31
- * @return Parameter decorator
32
- * @author Jeongho Nam - https://github.com/samchon
33
- */
34
- export function PlainBody(): ParameterDecorator;
35
-
36
- /**
37
- * @internal
38
- */
39
- export function PlainBody(
40
- assert?: (input: unknown) => string,
41
- ): ParameterDecorator {
42
- const checker = assert
43
- ? validate_request_body("PlainBody")({
44
- type: "assert",
45
- assert,
46
- })
47
- : null;
48
- return createParamDecorator(async function PlainBody(
49
- _data: any,
50
- context: ExecutionContext,
51
- ) {
52
- const request: express.Request | FastifyRequest = context
53
- .switchToHttp()
54
- .getRequest();
55
- if (!isTextPlain(request.headers["content-type"]))
56
- throw new BadRequestException(`Request body type is not "text/plain".`);
57
- const value: string = await get_text_body(request);
58
- if (checker) {
59
- const error: Error | null = checker(value);
60
- if (error !== null) throw error;
61
- }
62
- return value;
63
- })();
64
- }
65
- Object.assign(PlainBody, assert);
66
-
67
- /**
68
- * @internal
69
- */
70
- const isTextPlain = (text?: string): boolean =>
71
- text !== undefined &&
72
- text
73
- .split(";")
74
- .map((str) => str.trim())
75
- .some((str) => str === "text/plain");
1
+ import {
2
+ BadRequestException,
3
+ ExecutionContext,
4
+ createParamDecorator,
5
+ } from "@nestjs/common";
6
+ import type express from "express";
7
+ import type { FastifyRequest } from "fastify";
8
+ import { assert } from "typia";
9
+
10
+ import { get_text_body } from "./internal/get_text_body";
11
+ import { validate_request_body } from "./internal/validate_request_body";
12
+
13
+ /**
14
+ * Plain body decorator.
15
+ *
16
+ * `PlainBody` is a decorator function getting full body text from the HTTP request.
17
+ *
18
+ * If you adjust the regular {@link Body} decorator function to the body parameter,
19
+ * you can't get the full body text because the {@link Body} tries to convert the
20
+ * body text to JSON object. Therefore, `@nestia/core` provides this `PlainBody`
21
+ * decorator function to get the full body text.
22
+ *
23
+ * ```typescript
24
+ * \@TypedRoute.Post("memo")
25
+ * public store
26
+ * (
27
+ * \@PlainBody() body: string
28
+ * ): void;
29
+ * ```
30
+ *
31
+ * @return Parameter decorator
32
+ * @author Jeongho Nam - https://github.com/samchon
33
+ */
34
+ export function PlainBody(): ParameterDecorator;
35
+
36
+ /**
37
+ * @internal
38
+ */
39
+ export function PlainBody(
40
+ assert?: (input: unknown) => string,
41
+ ): ParameterDecorator {
42
+ const checker = assert
43
+ ? validate_request_body("PlainBody")({
44
+ type: "assert",
45
+ assert,
46
+ })
47
+ : null;
48
+ return createParamDecorator(async function PlainBody(
49
+ _data: any,
50
+ context: ExecutionContext,
51
+ ) {
52
+ const request: express.Request | FastifyRequest = context
53
+ .switchToHttp()
54
+ .getRequest();
55
+ if (!isTextPlain(request.headers["content-type"]))
56
+ throw new BadRequestException(`Request body type is not "text/plain".`);
57
+ const value: string = await get_text_body(request);
58
+ if (checker) {
59
+ const error: Error | null = checker(value);
60
+ if (error !== null) throw error;
61
+ }
62
+ return value;
63
+ })();
64
+ }
65
+ Object.assign(PlainBody, assert);
66
+
67
+ /**
68
+ * @internal
69
+ */
70
+ const isTextPlain = (text?: string): boolean =>
71
+ text !== undefined &&
72
+ text
73
+ .split(";")
74
+ .map((str) => str.trim())
75
+ .some((str) => str === "text/plain");