@nestia/core 11.0.0-dev.20260316 → 11.0.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.
Files changed (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +93 -93
  3. package/lib/decorators/NoTransformConfigurationError.d.ts +1 -24
  4. package/lib/decorators/NoTransformConfigurationError.js +2 -0
  5. package/lib/decorators/NoTransformConfigurationError.js.map +1 -1
  6. package/lib/decorators/doNotThrowTransformError.d.ts +1 -0
  7. package/lib/decorators/doNotThrowTransformError.js +9 -0
  8. package/lib/decorators/doNotThrowTransformError.js.map +1 -0
  9. package/lib/module.d.ts +1 -1
  10. package/lib/module.js +1 -1
  11. package/lib/module.js.map +1 -1
  12. package/package.json +8 -8
  13. package/src/adaptors/WebSocketAdaptor.ts +429 -429
  14. package/src/decorators/EncryptedBody.ts +96 -96
  15. package/src/decorators/EncryptedController.ts +40 -40
  16. package/src/decorators/EncryptedModule.ts +98 -98
  17. package/src/decorators/EncryptedRoute.ts +212 -212
  18. package/src/decorators/HumanRoute.ts +21 -21
  19. package/src/decorators/NoTransformConfigurationError.ts +37 -34
  20. package/src/decorators/SwaggerCustomizer.ts +97 -97
  21. package/src/decorators/TypedFormData.ts +187 -187
  22. package/src/decorators/TypedRoute.ts +196 -196
  23. package/src/decorators/doNotThrowTransformError.ts +5 -0
  24. package/src/decorators/internal/headers_to_object.ts +11 -11
  25. package/src/module.ts +23 -23
  26. package/src/options/INestiaTransformOptions.ts +34 -34
  27. package/src/options/INestiaTransformProject.ts +10 -10
  28. package/src/programmers/PlainBodyProgrammer.ts +72 -72
  29. package/src/programmers/TypedBodyProgrammer.ts +148 -148
  30. package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
  31. package/src/programmers/TypedHeadersProgrammer.ts +65 -65
  32. package/src/programmers/TypedParamProgrammer.ts +33 -33
  33. package/src/programmers/TypedQueryBodyProgrammer.ts +113 -113
  34. package/src/programmers/TypedQueryProgrammer.ts +115 -115
  35. package/src/programmers/TypedQueryRouteProgrammer.ts +107 -107
  36. package/src/programmers/TypedRouteProgrammer.ts +103 -103
  37. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +74 -74
  38. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +77 -77
  39. package/src/programmers/http/HttpQuerifyProgrammer.ts +110 -110
  40. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +78 -78
  41. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  42. package/src/transform.ts +35 -35
  43. package/src/transformers/FileTransformer.ts +109 -109
  44. package/src/transformers/MethodTransformer.ts +103 -103
  45. package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
  46. package/src/transformers/TypedRouteTransformer.ts +85 -85
  47. package/src/transformers/WebSocketRouteTransformer.ts +120 -120
@@ -1,72 +1,72 @@
1
- import {
2
- AssertProgrammer,
3
- MetadataCollection,
4
- MetadataFactory,
5
- MetadataSchema,
6
- TransformerError,
7
- } from "@typia/core";
8
- import ts from "typescript";
9
-
10
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
11
-
12
- export namespace PlainBodyProgrammer {
13
- export const generate = (props: {
14
- context: INestiaTransformContext;
15
- modulo: ts.LeftHandSideExpression;
16
- type: ts.Type;
17
- }): ts.Expression => {
18
- const result = MetadataFactory.analyze({
19
- checker: props.context.checker,
20
- transformer: props.context.transformer,
21
- options: {
22
- escape: false,
23
- constant: true,
24
- absorb: true,
25
- validate: ({ metadata }) => validate(metadata),
26
- },
27
- components: new MetadataCollection(),
28
- type: props.type,
29
- });
30
- if (result.success === false)
31
- throw TransformerError.from({
32
- code: "nestia.core.TypedParam",
33
- errors: result.errors,
34
- });
35
- return AssertProgrammer.write({
36
- context: {
37
- ...props.context,
38
- options: {
39
- numeric: false,
40
- finite: false,
41
- functional: false,
42
- },
43
- },
44
- modulo: props.modulo,
45
- config: {
46
- equals: false,
47
- guard: false,
48
- },
49
- type: props.type,
50
- name: undefined,
51
- });
52
- };
53
- }
54
-
55
- const validate = (metadata: MetadataSchema): string[] => {
56
- const errors: string[] = [];
57
- const insert = (msg: string) => errors.push(msg);
58
-
59
- const expected: number =
60
- (metadata.atomics.some((a) => a.type === "string") ? 1 : 0) +
61
- metadata.templates.length +
62
- metadata.constants
63
- .filter((c) => c.type === "string")
64
- .map((c) => c.values.length)
65
- .reduce((a, b) => a + b, 0);
66
- if (expected === 0 || expected !== metadata.size())
67
- insert(`only string type is allowed`);
68
- if (metadata.nullable === true) insert(`do not allow nullable type`);
69
- else if (metadata.any === true) insert(`do not allow any type`);
70
-
71
- return errors;
72
- };
1
+ import {
2
+ AssertProgrammer,
3
+ MetadataCollection,
4
+ MetadataFactory,
5
+ MetadataSchema,
6
+ TransformerError,
7
+ } from "@typia/core";
8
+ import ts from "typescript";
9
+
10
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
11
+
12
+ export namespace PlainBodyProgrammer {
13
+ export const generate = (props: {
14
+ context: INestiaTransformContext;
15
+ modulo: ts.LeftHandSideExpression;
16
+ type: ts.Type;
17
+ }): ts.Expression => {
18
+ const result = MetadataFactory.analyze({
19
+ checker: props.context.checker,
20
+ transformer: props.context.transformer,
21
+ options: {
22
+ escape: false,
23
+ constant: true,
24
+ absorb: true,
25
+ validate: ({ metadata }) => validate(metadata),
26
+ },
27
+ components: new MetadataCollection(),
28
+ type: props.type,
29
+ });
30
+ if (result.success === false)
31
+ throw TransformerError.from({
32
+ code: "nestia.core.TypedParam",
33
+ errors: result.errors,
34
+ });
35
+ return AssertProgrammer.write({
36
+ context: {
37
+ ...props.context,
38
+ options: {
39
+ numeric: false,
40
+ finite: false,
41
+ functional: false,
42
+ },
43
+ },
44
+ modulo: props.modulo,
45
+ config: {
46
+ equals: false,
47
+ guard: false,
48
+ },
49
+ type: props.type,
50
+ name: undefined,
51
+ });
52
+ };
53
+ }
54
+
55
+ const validate = (metadata: MetadataSchema): string[] => {
56
+ const errors: string[] = [];
57
+ const insert = (msg: string) => errors.push(msg);
58
+
59
+ const expected: number =
60
+ (metadata.atomics.some((a) => a.type === "string") ? 1 : 0) +
61
+ metadata.templates.length +
62
+ metadata.constants
63
+ .filter((c) => c.type === "string")
64
+ .map((c) => c.values.length)
65
+ .reduce((a, b) => a + b, 0);
66
+ if (expected === 0 || expected !== metadata.size())
67
+ insert(`only string type is allowed`);
68
+ if (metadata.nullable === true) insert(`do not allow nullable type`);
69
+ else if (metadata.any === true) insert(`do not allow any type`);
70
+
71
+ return errors;
72
+ };
@@ -1,148 +1,148 @@
1
- import {
2
- AssertProgrammer,
3
- ITypiaContext,
4
- IsProgrammer,
5
- JsonMetadataFactory,
6
- LlmSchemaProgrammer,
7
- MiscAssertCloneProgrammer,
8
- MiscAssertPruneProgrammer,
9
- MiscValidateCloneProgrammer,
10
- MiscValidatePruneProgrammer,
11
- ValidateProgrammer,
12
- } from "@typia/core";
13
- import ts from "typescript";
14
-
15
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
16
- import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
17
-
18
- export namespace TypedBodyProgrammer {
19
- export const generate = (props: {
20
- context: INestiaTransformContext;
21
- modulo: ts.LeftHandSideExpression;
22
- type: ts.Type;
23
- }): ts.ObjectLiteralExpression => {
24
- // VALIDATE TYPE
25
- JsonMetadataFactory.analyze({
26
- method: "@nestia.core.TypedBody",
27
- checker: props.context.checker,
28
- transformer: props.context.transformer,
29
- type: props.type,
30
- validate: props.context.options.llm
31
- ? (next) =>
32
- LlmSchemaProgrammer.validate({
33
- config: {
34
- strict:
35
- typeof props.context.options.llm === "boolean"
36
- ? false
37
- : (props.context.options.llm?.strict ?? false),
38
- },
39
- metadata: next.metadata,
40
- explore: next.explore,
41
- })
42
- : undefined,
43
- });
44
-
45
- // GENERATE VALIDATION PLAN
46
- const check =
47
- (key: IRequestBodyValidator<any>["type"]) =>
48
- (equals: boolean) =>
49
- (
50
- programmer: (next: {
51
- context: ITypiaContext;
52
- modulo: ts.LeftHandSideExpression;
53
- config: {
54
- equals: boolean;
55
- guard: boolean;
56
- };
57
- type: ts.Type;
58
- name: string | undefined;
59
- }) => ts.Expression,
60
- ) =>
61
- ts.factory.createObjectLiteralExpression([
62
- ts.factory.createPropertyAssignment(
63
- ts.factory.createIdentifier("type"),
64
- ts.factory.createStringLiteral(key),
65
- ),
66
- ts.factory.createPropertyAssignment(
67
- ts.factory.createIdentifier(key),
68
- programmer({
69
- context: {
70
- ...props.context,
71
- options: {
72
- numeric: false,
73
- finite: false,
74
- functional: false,
75
- },
76
- },
77
- modulo: props.modulo,
78
- config: {
79
- equals,
80
- guard: false,
81
- },
82
- type: props.type,
83
- name: undefined,
84
- }),
85
- ),
86
- ]);
87
- const misc =
88
- (key: IRequestBodyValidator<any>["type"]) =>
89
- (
90
- programmer: (next: {
91
- context: ITypiaContext;
92
- modulo: ts.LeftHandSideExpression;
93
- type: ts.Type;
94
- name: string | undefined;
95
- }) => ts.Expression,
96
- ) =>
97
- ts.factory.createObjectLiteralExpression([
98
- ts.factory.createPropertyAssignment(
99
- ts.factory.createIdentifier("type"),
100
- ts.factory.createStringLiteral(key),
101
- ),
102
- ts.factory.createPropertyAssignment(
103
- ts.factory.createIdentifier(key),
104
- programmer({
105
- context: {
106
- ...props.context,
107
- options: {
108
- numeric: false,
109
- finite: false,
110
- functional: false,
111
- },
112
- },
113
- modulo: props.modulo,
114
- type: props.type,
115
- name: undefined,
116
- }),
117
- ),
118
- ]);
119
-
120
- //----
121
- // RETURNS
122
- //----
123
- const category = props.context.options.validate;
124
- // NORMAL
125
- if (category === "assert")
126
- return check("assert")(false)(AssertProgrammer.write);
127
- else if (category === "is") return check("is")(false)(IsProgrammer.write);
128
- // STRICT
129
- else if (category === "validateEquals")
130
- return check("validate")(true)(ValidateProgrammer.write);
131
- else if (category === "equals")
132
- return check("is")(true)(IsProgrammer.write);
133
- else if (category === "assertEquals")
134
- return check("assert")(true)(AssertProgrammer.write);
135
- // CLONE
136
- else if (category === "assertClone")
137
- return misc("assert")(MiscAssertCloneProgrammer.write);
138
- else if (category === "validateClone")
139
- return misc("validate")(MiscValidateCloneProgrammer.write);
140
- // PRUNE
141
- else if (category === "assertPrune")
142
- return misc("assert")(MiscAssertPruneProgrammer.write);
143
- else if (category === "validatePrune")
144
- return misc("validate")(MiscValidatePruneProgrammer.write);
145
- // DEFAULT
146
- return check("validate")(false)(ValidateProgrammer.write);
147
- };
148
- }
1
+ import {
2
+ AssertProgrammer,
3
+ ITypiaContext,
4
+ IsProgrammer,
5
+ JsonMetadataFactory,
6
+ LlmSchemaProgrammer,
7
+ MiscAssertCloneProgrammer,
8
+ MiscAssertPruneProgrammer,
9
+ MiscValidateCloneProgrammer,
10
+ MiscValidatePruneProgrammer,
11
+ ValidateProgrammer,
12
+ } from "@typia/core";
13
+ import ts from "typescript";
14
+
15
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
16
+ import { IRequestBodyValidator } from "../options/IRequestBodyValidator";
17
+
18
+ export namespace TypedBodyProgrammer {
19
+ export const generate = (props: {
20
+ context: INestiaTransformContext;
21
+ modulo: ts.LeftHandSideExpression;
22
+ type: ts.Type;
23
+ }): ts.ObjectLiteralExpression => {
24
+ // VALIDATE TYPE
25
+ JsonMetadataFactory.analyze({
26
+ method: "@nestia.core.TypedBody",
27
+ checker: props.context.checker,
28
+ transformer: props.context.transformer,
29
+ type: props.type,
30
+ validate: props.context.options.llm
31
+ ? (next) =>
32
+ LlmSchemaProgrammer.validate({
33
+ config: {
34
+ strict:
35
+ typeof props.context.options.llm === "boolean"
36
+ ? false
37
+ : (props.context.options.llm?.strict ?? false),
38
+ },
39
+ metadata: next.metadata,
40
+ explore: next.explore,
41
+ })
42
+ : undefined,
43
+ });
44
+
45
+ // GENERATE VALIDATION PLAN
46
+ const check =
47
+ (key: IRequestBodyValidator<any>["type"]) =>
48
+ (equals: boolean) =>
49
+ (
50
+ programmer: (next: {
51
+ context: ITypiaContext;
52
+ modulo: ts.LeftHandSideExpression;
53
+ config: {
54
+ equals: boolean;
55
+ guard: boolean;
56
+ };
57
+ type: ts.Type;
58
+ name: string | undefined;
59
+ }) => ts.Expression,
60
+ ) =>
61
+ ts.factory.createObjectLiteralExpression([
62
+ ts.factory.createPropertyAssignment(
63
+ ts.factory.createIdentifier("type"),
64
+ ts.factory.createStringLiteral(key),
65
+ ),
66
+ ts.factory.createPropertyAssignment(
67
+ ts.factory.createIdentifier(key),
68
+ programmer({
69
+ context: {
70
+ ...props.context,
71
+ options: {
72
+ numeric: false,
73
+ finite: false,
74
+ functional: false,
75
+ },
76
+ },
77
+ modulo: props.modulo,
78
+ config: {
79
+ equals,
80
+ guard: false,
81
+ },
82
+ type: props.type,
83
+ name: undefined,
84
+ }),
85
+ ),
86
+ ]);
87
+ const misc =
88
+ (key: IRequestBodyValidator<any>["type"]) =>
89
+ (
90
+ programmer: (next: {
91
+ context: ITypiaContext;
92
+ modulo: ts.LeftHandSideExpression;
93
+ type: ts.Type;
94
+ name: string | undefined;
95
+ }) => ts.Expression,
96
+ ) =>
97
+ ts.factory.createObjectLiteralExpression([
98
+ ts.factory.createPropertyAssignment(
99
+ ts.factory.createIdentifier("type"),
100
+ ts.factory.createStringLiteral(key),
101
+ ),
102
+ ts.factory.createPropertyAssignment(
103
+ ts.factory.createIdentifier(key),
104
+ programmer({
105
+ context: {
106
+ ...props.context,
107
+ options: {
108
+ numeric: false,
109
+ finite: false,
110
+ functional: false,
111
+ },
112
+ },
113
+ modulo: props.modulo,
114
+ type: props.type,
115
+ name: undefined,
116
+ }),
117
+ ),
118
+ ]);
119
+
120
+ //----
121
+ // RETURNS
122
+ //----
123
+ const category = props.context.options.validate;
124
+ // NORMAL
125
+ if (category === "assert")
126
+ return check("assert")(false)(AssertProgrammer.write);
127
+ else if (category === "is") return check("is")(false)(IsProgrammer.write);
128
+ // STRICT
129
+ else if (category === "validateEquals")
130
+ return check("validate")(true)(ValidateProgrammer.write);
131
+ else if (category === "equals")
132
+ return check("is")(true)(IsProgrammer.write);
133
+ else if (category === "assertEquals")
134
+ return check("assert")(true)(AssertProgrammer.write);
135
+ // CLONE
136
+ else if (category === "assertClone")
137
+ return misc("assert")(MiscAssertCloneProgrammer.write);
138
+ else if (category === "validateClone")
139
+ return misc("validate")(MiscValidateCloneProgrammer.write);
140
+ // PRUNE
141
+ else if (category === "assertPrune")
142
+ return misc("assert")(MiscAssertPruneProgrammer.write);
143
+ else if (category === "validatePrune")
144
+ return misc("validate")(MiscValidatePruneProgrammer.write);
145
+ // DEFAULT
146
+ return check("validate")(false)(ValidateProgrammer.write);
147
+ };
148
+ }
@@ -1,118 +1,118 @@
1
- import {
2
- HttpAssertFormDataProgrammer,
3
- HttpFormDataProgrammer,
4
- HttpIsFormDataProgrammer,
5
- HttpValidateFormDataProgrammer,
6
- ITypiaContext,
7
- LiteralFactory,
8
- MetadataCollection,
9
- MetadataFactory,
10
- MetadataSchema,
11
- TransformerError,
12
- } from "@typia/core";
13
- import ts from "typescript";
14
-
15
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
16
- import { IRequestFormDataProps } from "../options/IRequestFormDataProps";
17
-
18
- export namespace TypedFormDataBodyProgrammer {
19
- export const generate = (props: {
20
- context: INestiaTransformContext;
21
- modulo: ts.LeftHandSideExpression;
22
- type: ts.Type;
23
- }): ts.ObjectLiteralExpression => {
24
- // VALIDATE TYPE
25
- const storage: MetadataCollection = new MetadataCollection();
26
- const result = MetadataFactory.analyze({
27
- checker: props.context.checker,
28
- transformer: props.context.transformer,
29
- options: {
30
- escape: false,
31
- constant: true,
32
- absorb: true,
33
- validate: HttpFormDataProgrammer.validate,
34
- },
35
- type: props.type,
36
- components: storage,
37
- });
38
- if (result.success === false)
39
- throw TransformerError.from({
40
- code: "nestia.core.TypedFormData.Body",
41
- errors: result.errors,
42
- });
43
-
44
- const files: IRequestFormDataProps.IFile[] =
45
- result.data.objects[0]!.type.properties.filter(
46
- (p) =>
47
- isFile(p.value) || p.value.arrays.some((a) => isFile(a.type.value)),
48
- ).map((p) => ({
49
- name: p.key.constants[0]!.values[0]!.value as string,
50
- limit: !!p.value.natives.length ? 1 : null,
51
- }));
52
-
53
- // GENERATE VALIDATION PLAN
54
- const parameter =
55
- (key: IRequestFormDataProps<any>["validator"]["type"]) =>
56
- (
57
- programmer: (next: {
58
- context: ITypiaContext;
59
- modulo: ts.LeftHandSideExpression;
60
- type: ts.Type;
61
- name: string | undefined;
62
- }) => ts.Expression,
63
- ) =>
64
- ts.factory.createObjectLiteralExpression(
65
- [
66
- ts.factory.createPropertyAssignment(
67
- ts.factory.createIdentifier("files"),
68
- LiteralFactory.write(files),
69
- ),
70
- ts.factory.createPropertyAssignment(
71
- ts.factory.createIdentifier("validator"),
72
- ts.factory.createObjectLiteralExpression(
73
- [
74
- ts.factory.createPropertyAssignment(
75
- ts.factory.createIdentifier("type"),
76
- ts.factory.createStringLiteral(key),
77
- ),
78
- ts.factory.createPropertyAssignment(
79
- ts.factory.createIdentifier(key),
80
- programmer({
81
- context: {
82
- ...props.context,
83
- options: {
84
- numeric: false,
85
- finite: false,
86
- functional: false,
87
- },
88
- },
89
- modulo: props.modulo,
90
- type: props.type,
91
- name: undefined,
92
- }),
93
- ),
94
- ],
95
- true,
96
- ),
97
- ),
98
- ],
99
- true,
100
- );
101
-
102
- // RETURNS
103
- const category = props.context.options.validate;
104
- if (category === "is" || category === "equals")
105
- return parameter("is")(HttpIsFormDataProgrammer.write);
106
- else if (
107
- category === "validate" ||
108
- category === "validateEquals" ||
109
- category === "validateClone" ||
110
- category === "validatePrune"
111
- )
112
- return parameter("validate")(HttpValidateFormDataProgrammer.write);
113
- return parameter("assert")(HttpAssertFormDataProgrammer.write);
114
- };
115
- }
116
-
117
- const isFile = (meta: MetadataSchema) =>
118
- meta.natives.some(({ name }) => name === "File" || name === "Blob");
1
+ import {
2
+ HttpAssertFormDataProgrammer,
3
+ HttpFormDataProgrammer,
4
+ HttpIsFormDataProgrammer,
5
+ HttpValidateFormDataProgrammer,
6
+ ITypiaContext,
7
+ LiteralFactory,
8
+ MetadataCollection,
9
+ MetadataFactory,
10
+ MetadataSchema,
11
+ TransformerError,
12
+ } from "@typia/core";
13
+ import ts from "typescript";
14
+
15
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
16
+ import { IRequestFormDataProps } from "../options/IRequestFormDataProps";
17
+
18
+ export namespace TypedFormDataBodyProgrammer {
19
+ export const generate = (props: {
20
+ context: INestiaTransformContext;
21
+ modulo: ts.LeftHandSideExpression;
22
+ type: ts.Type;
23
+ }): ts.ObjectLiteralExpression => {
24
+ // VALIDATE TYPE
25
+ const storage: MetadataCollection = new MetadataCollection();
26
+ const result = MetadataFactory.analyze({
27
+ checker: props.context.checker,
28
+ transformer: props.context.transformer,
29
+ options: {
30
+ escape: false,
31
+ constant: true,
32
+ absorb: true,
33
+ validate: HttpFormDataProgrammer.validate,
34
+ },
35
+ type: props.type,
36
+ components: storage,
37
+ });
38
+ if (result.success === false)
39
+ throw TransformerError.from({
40
+ code: "nestia.core.TypedFormData.Body",
41
+ errors: result.errors,
42
+ });
43
+
44
+ const files: IRequestFormDataProps.IFile[] =
45
+ result.data.objects[0]!.type.properties.filter(
46
+ (p) =>
47
+ isFile(p.value) || p.value.arrays.some((a) => isFile(a.type.value)),
48
+ ).map((p) => ({
49
+ name: p.key.constants[0]!.values[0]!.value as string,
50
+ limit: !!p.value.natives.length ? 1 : null,
51
+ }));
52
+
53
+ // GENERATE VALIDATION PLAN
54
+ const parameter =
55
+ (key: IRequestFormDataProps<any>["validator"]["type"]) =>
56
+ (
57
+ programmer: (next: {
58
+ context: ITypiaContext;
59
+ modulo: ts.LeftHandSideExpression;
60
+ type: ts.Type;
61
+ name: string | undefined;
62
+ }) => ts.Expression,
63
+ ) =>
64
+ ts.factory.createObjectLiteralExpression(
65
+ [
66
+ ts.factory.createPropertyAssignment(
67
+ ts.factory.createIdentifier("files"),
68
+ LiteralFactory.write(files),
69
+ ),
70
+ ts.factory.createPropertyAssignment(
71
+ ts.factory.createIdentifier("validator"),
72
+ ts.factory.createObjectLiteralExpression(
73
+ [
74
+ ts.factory.createPropertyAssignment(
75
+ ts.factory.createIdentifier("type"),
76
+ ts.factory.createStringLiteral(key),
77
+ ),
78
+ ts.factory.createPropertyAssignment(
79
+ ts.factory.createIdentifier(key),
80
+ programmer({
81
+ context: {
82
+ ...props.context,
83
+ options: {
84
+ numeric: false,
85
+ finite: false,
86
+ functional: false,
87
+ },
88
+ },
89
+ modulo: props.modulo,
90
+ type: props.type,
91
+ name: undefined,
92
+ }),
93
+ ),
94
+ ],
95
+ true,
96
+ ),
97
+ ),
98
+ ],
99
+ true,
100
+ );
101
+
102
+ // RETURNS
103
+ const category = props.context.options.validate;
104
+ if (category === "is" || category === "equals")
105
+ return parameter("is")(HttpIsFormDataProgrammer.write);
106
+ else if (
107
+ category === "validate" ||
108
+ category === "validateEquals" ||
109
+ category === "validateClone" ||
110
+ category === "validatePrune"
111
+ )
112
+ return parameter("validate")(HttpValidateFormDataProgrammer.write);
113
+ return parameter("assert")(HttpAssertFormDataProgrammer.write);
114
+ };
115
+ }
116
+
117
+ const isFile = (meta: MetadataSchema) =>
118
+ meta.natives.some(({ name }) => name === "File" || name === "Blob");