@nestia/core 11.0.0-dev.20260313-5 → 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 (60) 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/lib/options/INestiaTransformOptions.d.ts +1 -1
  13. package/lib/programmers/PlainBodyProgrammer.js +1 -1
  14. package/lib/programmers/PlainBodyProgrammer.js.map +1 -1
  15. package/lib/programmers/TypedBodyProgrammer.js +6 -3
  16. package/lib/programmers/TypedBodyProgrammer.js.map +1 -1
  17. package/lib/programmers/TypedQueryBodyProgrammer.js +9 -4
  18. package/lib/programmers/TypedQueryBodyProgrammer.js.map +1 -1
  19. package/lib/programmers/TypedQueryProgrammer.js +9 -4
  20. package/lib/programmers/TypedQueryProgrammer.js.map +1 -1
  21. package/lib/programmers/TypedQueryRouteProgrammer.js +14 -8
  22. package/lib/programmers/TypedQueryRouteProgrammer.js.map +1 -1
  23. package/lib/programmers/TypedRouteProgrammer.js +11 -6
  24. package/lib/programmers/TypedRouteProgrammer.js.map +1 -1
  25. package/package.json +8 -8
  26. package/src/adaptors/WebSocketAdaptor.ts +429 -429
  27. package/src/decorators/EncryptedBody.ts +96 -96
  28. package/src/decorators/EncryptedController.ts +40 -40
  29. package/src/decorators/EncryptedModule.ts +98 -98
  30. package/src/decorators/EncryptedRoute.ts +212 -212
  31. package/src/decorators/HumanRoute.ts +21 -21
  32. package/src/decorators/NoTransformConfigurationError.ts +37 -34
  33. package/src/decorators/SwaggerCustomizer.ts +97 -97
  34. package/src/decorators/TypedFormData.ts +187 -187
  35. package/src/decorators/TypedRoute.ts +196 -196
  36. package/src/decorators/doNotThrowTransformError.ts +5 -0
  37. package/src/decorators/internal/headers_to_object.ts +11 -11
  38. package/src/module.ts +23 -23
  39. package/src/options/INestiaTransformOptions.ts +34 -34
  40. package/src/options/INestiaTransformProject.ts +10 -10
  41. package/src/programmers/PlainBodyProgrammer.ts +72 -72
  42. package/src/programmers/TypedBodyProgrammer.ts +148 -144
  43. package/src/programmers/TypedFormDataBodyProgrammer.ts +118 -118
  44. package/src/programmers/TypedHeadersProgrammer.ts +65 -65
  45. package/src/programmers/TypedParamProgrammer.ts +33 -33
  46. package/src/programmers/TypedQueryBodyProgrammer.ts +113 -111
  47. package/src/programmers/TypedQueryProgrammer.ts +115 -113
  48. package/src/programmers/TypedQueryRouteProgrammer.ts +107 -104
  49. package/src/programmers/TypedRouteProgrammer.ts +103 -96
  50. package/src/programmers/http/HttpAssertQuerifyProgrammer.ts +74 -74
  51. package/src/programmers/http/HttpIsQuerifyProgrammer.ts +77 -77
  52. package/src/programmers/http/HttpQuerifyProgrammer.ts +110 -110
  53. package/src/programmers/http/HttpValidateQuerifyProgrammer.ts +78 -78
  54. package/src/programmers/internal/CoreMetadataUtil.ts +21 -21
  55. package/src/transform.ts +35 -35
  56. package/src/transformers/FileTransformer.ts +109 -109
  57. package/src/transformers/MethodTransformer.ts +103 -103
  58. package/src/transformers/ParameterDecoratorTransformer.ts +143 -143
  59. package/src/transformers/TypedRouteTransformer.ts +85 -85
  60. package/src/transformers/WebSocketRouteTransformer.ts +120 -120
@@ -1,113 +1,115 @@
1
- import {
2
- HttpAssertQueryProgrammer,
3
- HttpIsQueryProgrammer,
4
- HttpQueryProgrammer,
5
- HttpValidateQueryProgrammer,
6
- ITypiaContext,
7
- LlmSchemaProgrammer,
8
- MetadataCollection,
9
- MetadataFactory,
10
- MetadataSchema,
11
- TransformerError,
12
- } from "@typia/core";
13
- import { ValidationPipe } from "@typia/interface";
14
- import ts from "typescript";
15
-
16
- import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
17
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
18
- import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
19
-
20
- export namespace TypedQueryProgrammer {
21
- export const generate = (props: {
22
- context: INestiaTransformContext;
23
- modulo: ts.LeftHandSideExpression;
24
- type: ts.Type;
25
- }): ts.Expression => {
26
- // VALIDATE TYPE
27
- if (props.context.options.llm) {
28
- const llm: INestiaTransformOptions.ILlm = props.context.options.llm;
29
- const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
30
- MetadataFactory.analyze({
31
- checker: props.context.checker,
32
- transformer: props.context.transformer,
33
- options: {
34
- escape: false,
35
- constant: true,
36
- absorb: true,
37
- validate: (meta, explore) => {
38
- const errors: string[] = HttpQueryProgrammer.validate(
39
- meta,
40
- explore,
41
- true,
42
- );
43
- errors.push(
44
- ...LlmSchemaProgrammer.validate({
45
- config: {
46
- strict: llm.strict ?? false,
47
- },
48
- metadata: meta,
49
- }),
50
- );
51
- return errors;
52
- },
53
- },
54
- components: new MetadataCollection(),
55
- type: props.type,
56
- });
57
- if (result.success === false)
58
- throw TransformerError.from({
59
- code: "@nestia.core.TypedQuery",
60
- errors: result.errors,
61
- });
62
- }
63
-
64
- // GENERATE VALIDATION PLAN
65
- const parameter =
66
- (key: IRequestQueryValidator<any>["type"]) =>
67
- (
68
- programmer: (next: {
69
- context: ITypiaContext;
70
- modulo: ts.LeftHandSideExpression;
71
- type: ts.Type;
72
- name: string | undefined;
73
- allowOptional: boolean;
74
- }) => ts.Expression,
75
- ) =>
76
- ts.factory.createObjectLiteralExpression([
77
- ts.factory.createPropertyAssignment(
78
- ts.factory.createIdentifier("type"),
79
- ts.factory.createStringLiteral(key),
80
- ),
81
- ts.factory.createPropertyAssignment(
82
- ts.factory.createIdentifier(key),
83
- programmer({
84
- context: {
85
- ...props.context,
86
- options: {
87
- numeric: false,
88
- finite: false,
89
- functional: false,
90
- },
91
- },
92
- modulo: props.modulo,
93
- type: props.type,
94
- name: undefined,
95
- allowOptional: true,
96
- }),
97
- ),
98
- ]);
99
-
100
- // RETURNS
101
- const category = props.context.options.validate;
102
- if (category === "is" || category === "equals")
103
- return parameter("is")(HttpIsQueryProgrammer.write);
104
- else if (
105
- category === "validate" ||
106
- category === "validateEquals" ||
107
- category === "validateClone" ||
108
- category === "validatePrune"
109
- )
110
- return parameter("validate")(HttpValidateQueryProgrammer.write);
111
- return parameter("assert")(HttpAssertQueryProgrammer.write);
112
- };
113
- }
1
+ import {
2
+ HttpAssertQueryProgrammer,
3
+ HttpIsQueryProgrammer,
4
+ HttpQueryProgrammer,
5
+ HttpValidateQueryProgrammer,
6
+ ITypiaContext,
7
+ LlmSchemaProgrammer,
8
+ MetadataCollection,
9
+ MetadataFactory,
10
+ MetadataSchema,
11
+ TransformerError,
12
+ } from "@typia/core";
13
+ import { ValidationPipe } from "@typia/interface";
14
+ import ts from "typescript";
15
+
16
+ import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
17
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
18
+ import { IRequestQueryValidator } from "../options/IRequestQueryValidator";
19
+
20
+ export namespace TypedQueryProgrammer {
21
+ export const generate = (props: {
22
+ context: INestiaTransformContext;
23
+ modulo: ts.LeftHandSideExpression;
24
+ type: ts.Type;
25
+ }): ts.Expression => {
26
+ // VALIDATE TYPE
27
+ if (props.context.options.llm) {
28
+ const llm: INestiaTransformOptions.ILlm | true =
29
+ props.context.options.llm;
30
+ const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
31
+ MetadataFactory.analyze({
32
+ checker: props.context.checker,
33
+ transformer: props.context.transformer,
34
+ options: {
35
+ escape: false,
36
+ constant: true,
37
+ absorb: true,
38
+ validate: (next) => {
39
+ const errors: string[] = HttpQueryProgrammer.validate({
40
+ metadata: next.metadata,
41
+ explore: next.explore,
42
+ allowOptional: true,
43
+ });
44
+ errors.push(
45
+ ...LlmSchemaProgrammer.validate({
46
+ config: {
47
+ strict: llm === true ? false : (llm.strict ?? false),
48
+ },
49
+ metadata: next.metadata,
50
+ explore: next.explore,
51
+ }),
52
+ );
53
+ return errors;
54
+ },
55
+ },
56
+ components: new MetadataCollection(),
57
+ type: props.type,
58
+ });
59
+ if (result.success === false)
60
+ throw TransformerError.from({
61
+ code: "@nestia.core.TypedQuery",
62
+ errors: result.errors,
63
+ });
64
+ }
65
+
66
+ // GENERATE VALIDATION PLAN
67
+ const parameter =
68
+ (key: IRequestQueryValidator<any>["type"]) =>
69
+ (
70
+ programmer: (next: {
71
+ context: ITypiaContext;
72
+ modulo: ts.LeftHandSideExpression;
73
+ type: ts.Type;
74
+ name: string | undefined;
75
+ allowOptional: boolean;
76
+ }) => ts.Expression,
77
+ ) =>
78
+ ts.factory.createObjectLiteralExpression([
79
+ ts.factory.createPropertyAssignment(
80
+ ts.factory.createIdentifier("type"),
81
+ ts.factory.createStringLiteral(key),
82
+ ),
83
+ ts.factory.createPropertyAssignment(
84
+ ts.factory.createIdentifier(key),
85
+ programmer({
86
+ context: {
87
+ ...props.context,
88
+ options: {
89
+ numeric: false,
90
+ finite: false,
91
+ functional: false,
92
+ },
93
+ },
94
+ modulo: props.modulo,
95
+ type: props.type,
96
+ name: undefined,
97
+ allowOptional: true,
98
+ }),
99
+ ),
100
+ ]);
101
+
102
+ // RETURNS
103
+ const category = props.context.options.validate;
104
+ if (category === "is" || category === "equals")
105
+ return parameter("is")(HttpIsQueryProgrammer.write);
106
+ else if (
107
+ category === "validate" ||
108
+ category === "validateEquals" ||
109
+ category === "validateClone" ||
110
+ category === "validatePrune"
111
+ )
112
+ return parameter("validate")(HttpValidateQueryProgrammer.write);
113
+ return parameter("assert")(HttpAssertQueryProgrammer.write);
114
+ };
115
+ }
@@ -1,104 +1,107 @@
1
- import {
2
- HttpQueryProgrammer,
3
- ITypiaContext,
4
- LlmSchemaProgrammer,
5
- MetadataCollection,
6
- MetadataFactory,
7
- MetadataSchema,
8
- TransformerError,
9
- } from "@typia/core";
10
- import { ValidationPipe } from "@typia/interface";
11
- import ts from "typescript";
12
-
13
- import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
14
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
15
- import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
16
- import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
17
- import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
18
- import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
19
-
20
- export namespace TypedQueryRouteProgrammer {
21
- export const generate = (props: {
22
- context: INestiaTransformContext;
23
- modulo: ts.LeftHandSideExpression;
24
- type: ts.Type;
25
- }): ts.Expression => {
26
- // VALIDATE TYPE
27
- if (props.context.options.llm) {
28
- const llm: INestiaTransformOptions.ILlm = props.context.options.llm;
29
- const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
30
- MetadataFactory.analyze({
31
- checker: props.context.checker,
32
- transformer: props.context.transformer,
33
- options: {
34
- escape: false,
35
- constant: true,
36
- absorb: true,
37
- validate: (meta, explore) => {
38
- const errors: string[] = HttpQueryProgrammer.validate(
39
- meta,
40
- explore,
41
- true,
42
- );
43
- errors.push(
44
- ...LlmSchemaProgrammer.validate({
45
- config: {
46
- strict: llm.strict ?? false,
47
- },
48
- metadata: meta,
49
- }),
50
- );
51
- return errors;
52
- },
53
- },
54
- components: new MetadataCollection(),
55
- type: props.type,
56
- });
57
- if (result.success === false)
58
- throw TransformerError.from({
59
- code: props.modulo.getText(),
60
- errors: result.errors,
61
- });
62
- }
63
-
64
- // GENERATE STRINGIFY PLAN
65
- const parameter = (
66
- key: string,
67
- programmer: (next: {
68
- context: ITypiaContext;
69
- modulo: ts.LeftHandSideExpression;
70
- type: ts.Type;
71
- }) => ts.ArrowFunction,
72
- ) =>
73
- ts.factory.createObjectLiteralExpression([
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: {}, // use default option
84
- },
85
- modulo: props.modulo,
86
- type: props.type,
87
- }),
88
- ),
89
- ]);
90
-
91
- // RETURNS
92
- if (props.context.options.stringify === "is")
93
- return parameter("is", HttpIsQuerifyProgrammer.write);
94
- else if (props.context.options.stringify === "validate")
95
- return parameter("validate", HttpValidateQuerifyProgrammer.write);
96
- else if (props.context.options.stringify === "stringify")
97
- return parameter("stringify", HttpQuerifyProgrammer.write);
98
- else if (props.context.options.stringify === null)
99
- return ts.factory.createNull();
100
-
101
- // ASSERT IS DEFAULT
102
- return parameter("assert", HttpAssertQuerifyProgrammer.write);
103
- };
104
- }
1
+ import {
2
+ HttpQueryProgrammer,
3
+ ITypiaContext,
4
+ LlmParametersProgrammer,
5
+ MetadataCollection,
6
+ MetadataFactory,
7
+ MetadataSchema,
8
+ TransformerError,
9
+ } from "@typia/core";
10
+ import { ValidationPipe } from "@typia/interface";
11
+ import ts from "typescript";
12
+
13
+ import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
14
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
15
+ import { HttpAssertQuerifyProgrammer } from "./http/HttpAssertQuerifyProgrammer";
16
+ import { HttpIsQuerifyProgrammer } from "./http/HttpIsQuerifyProgrammer";
17
+ import { HttpQuerifyProgrammer } from "./http/HttpQuerifyProgrammer";
18
+ import { HttpValidateQuerifyProgrammer } from "./http/HttpValidateQuerifyProgrammer";
19
+
20
+ export namespace TypedQueryRouteProgrammer {
21
+ export const generate = (props: {
22
+ context: INestiaTransformContext;
23
+ modulo: ts.LeftHandSideExpression;
24
+ type: ts.Type;
25
+ }): ts.Expression => {
26
+ // VALIDATE TYPE
27
+ if (props.context.options.llm) {
28
+ const llm: INestiaTransformOptions.ILlm | true =
29
+ props.context.options.llm;
30
+ const result: ValidationPipe<MetadataSchema, MetadataFactory.IError> =
31
+ MetadataFactory.analyze({
32
+ checker: props.context.checker,
33
+ transformer: props.context.transformer,
34
+ options: {
35
+ escape: false,
36
+ constant: true,
37
+ absorb: true,
38
+ validate: (next) => {
39
+ const errors: string[] = HttpQueryProgrammer.validate({
40
+ metadata: next.metadata,
41
+ explore: next.explore,
42
+ allowOptional: true,
43
+ });
44
+ if (next.metadata.size() !== 0)
45
+ errors.push(
46
+ ...LlmParametersProgrammer.validate({
47
+ config: {
48
+ strict: llm === true ? false : (llm.strict ?? false),
49
+ },
50
+ metadata: next.metadata,
51
+ explore: next.explore,
52
+ }),
53
+ );
54
+ return errors;
55
+ },
56
+ },
57
+ components: new MetadataCollection(),
58
+ type: props.type,
59
+ });
60
+ if (result.success === false)
61
+ throw TransformerError.from({
62
+ code: props.modulo.getText(),
63
+ errors: result.errors,
64
+ });
65
+ }
66
+
67
+ // GENERATE STRINGIFY PLAN
68
+ const parameter = (
69
+ key: string,
70
+ programmer: (next: {
71
+ context: ITypiaContext;
72
+ modulo: ts.LeftHandSideExpression;
73
+ type: ts.Type;
74
+ }) => ts.ArrowFunction,
75
+ ) =>
76
+ ts.factory.createObjectLiteralExpression([
77
+ ts.factory.createPropertyAssignment(
78
+ ts.factory.createIdentifier("type"),
79
+ ts.factory.createStringLiteral(key),
80
+ ),
81
+ ts.factory.createPropertyAssignment(
82
+ ts.factory.createIdentifier(key),
83
+ programmer({
84
+ context: {
85
+ ...props.context,
86
+ options: {}, // use default option
87
+ },
88
+ modulo: props.modulo,
89
+ type: props.type,
90
+ }),
91
+ ),
92
+ ]);
93
+
94
+ // RETURNS
95
+ if (props.context.options.stringify === "is")
96
+ return parameter("is", HttpIsQuerifyProgrammer.write);
97
+ else if (props.context.options.stringify === "validate")
98
+ return parameter("validate", HttpValidateQuerifyProgrammer.write);
99
+ else if (props.context.options.stringify === "stringify")
100
+ return parameter("stringify", HttpQuerifyProgrammer.write);
101
+ else if (props.context.options.stringify === null)
102
+ return ts.factory.createNull();
103
+
104
+ // ASSERT IS DEFAULT
105
+ return parameter("assert", HttpAssertQuerifyProgrammer.write);
106
+ };
107
+ }
@@ -1,96 +1,103 @@
1
- import {
2
- IProgrammerProps,
3
- JsonAssertStringifyProgrammer,
4
- JsonIsStringifyProgrammer,
5
- JsonMetadataFactory,
6
- JsonStringifyProgrammer,
7
- JsonValidateStringifyProgrammer,
8
- LlmSchemaProgrammer,
9
- } from "@typia/core";
10
- import ts from "typescript";
11
-
12
- import { INestiaTransformContext } from "../options/INestiaTransformProject";
13
-
14
- export namespace TypedRouteProgrammer {
15
- export const generate = (props: {
16
- context: INestiaTransformContext;
17
- modulo: ts.LeftHandSideExpression;
18
- type: ts.Type;
19
- }): ts.Expression => {
20
- // VALIDATE TYPE
21
- if (props.context.options.llm)
22
- JsonMetadataFactory.analyze({
23
- method: "@nestia.core.TypedRoute",
24
- checker: props.context.checker,
25
- transformer: props.context.transformer,
26
- type: props.type,
27
- validate: (metadata) =>
28
- LlmSchemaProgrammer.validate({
29
- config: {
30
- strict: props.context.options.llm?.strict ?? false,
31
- },
32
- metadata,
33
- }),
34
- });
35
-
36
- // GENERATE STRINGIFY PLAN
37
- const parameter = (next: {
38
- type: string;
39
- key: string;
40
- programmer: (next: IProgrammerProps) => ts.Expression;
41
- }) =>
42
- ts.factory.createObjectLiteralExpression([
43
- ts.factory.createPropertyAssignment(
44
- ts.factory.createIdentifier("type"),
45
- ts.factory.createStringLiteral(next.type),
46
- ),
47
- ts.factory.createPropertyAssignment(
48
- ts.factory.createIdentifier(next.key),
49
- next.programmer({
50
- context: {
51
- ...props.context,
52
- options: {}, // use default option
53
- },
54
- modulo: props.modulo,
55
- type: props.type,
56
- name: undefined,
57
- }),
58
- ),
59
- ]);
60
-
61
- // RETURNS
62
- if (props.context.options.stringify === "is")
63
- return parameter({
64
- type: "is",
65
- key: "is",
66
- programmer: JsonIsStringifyProgrammer.write,
67
- });
68
- else if (props.context.options.stringify === "validate")
69
- return parameter({
70
- type: "validate",
71
- key: "validate",
72
- programmer: JsonValidateStringifyProgrammer.write,
73
- });
74
- else if (props.context.options.stringify === "stringify")
75
- return parameter({
76
- type: "stringify",
77
- key: "stringify",
78
- programmer: JsonStringifyProgrammer.write,
79
- });
80
- else if (props.context.options.stringify === "validate.log")
81
- return parameter({
82
- type: "validate.log",
83
- key: "validate",
84
- programmer: JsonValidateStringifyProgrammer.write,
85
- });
86
- else if (props.context.options.stringify === null)
87
- return ts.factory.createNull();
88
-
89
- // ASSERT IS DEFAULT
90
- return parameter({
91
- type: "assert",
92
- key: "assert",
93
- programmer: JsonAssertStringifyProgrammer.write,
94
- });
95
- };
96
- }
1
+ import {
2
+ IProgrammerProps,
3
+ JsonAssertStringifyProgrammer,
4
+ JsonIsStringifyProgrammer,
5
+ JsonMetadataFactory,
6
+ JsonStringifyProgrammer,
7
+ JsonValidateStringifyProgrammer,
8
+ LlmParametersProgrammer,
9
+ } from "@typia/core";
10
+ import ts from "typescript";
11
+
12
+ import { INestiaTransformOptions } from "../options/INestiaTransformOptions";
13
+ import { INestiaTransformContext } from "../options/INestiaTransformProject";
14
+
15
+ export namespace TypedRouteProgrammer {
16
+ export const generate = (props: {
17
+ context: INestiaTransformContext;
18
+ modulo: ts.LeftHandSideExpression;
19
+ type: ts.Type;
20
+ }): ts.Expression => {
21
+ // VALIDATE TYPE
22
+ if (props.context.options.llm) {
23
+ const llm: INestiaTransformOptions.ILlm | true =
24
+ props.context.options.llm;
25
+ JsonMetadataFactory.analyze({
26
+ method: "@nestia.core.TypedRoute",
27
+ checker: props.context.checker,
28
+ transformer: props.context.transformer,
29
+ type: props.type,
30
+ validate: (next) => {
31
+ if (next.metadata.size() === 0) return [];
32
+ return LlmParametersProgrammer.validate({
33
+ config: {
34
+ strict: llm === true ? false : (llm.strict ?? false),
35
+ },
36
+ metadata: next.metadata,
37
+ explore: next.explore,
38
+ });
39
+ },
40
+ });
41
+ }
42
+
43
+ // GENERATE STRINGIFY PLAN
44
+ const parameter = (next: {
45
+ type: string;
46
+ key: string;
47
+ programmer: (next: IProgrammerProps) => ts.Expression;
48
+ }) =>
49
+ ts.factory.createObjectLiteralExpression([
50
+ ts.factory.createPropertyAssignment(
51
+ ts.factory.createIdentifier("type"),
52
+ ts.factory.createStringLiteral(next.type),
53
+ ),
54
+ ts.factory.createPropertyAssignment(
55
+ ts.factory.createIdentifier(next.key),
56
+ next.programmer({
57
+ context: {
58
+ ...props.context,
59
+ options: {}, // use default option
60
+ },
61
+ modulo: props.modulo,
62
+ type: props.type,
63
+ name: undefined,
64
+ }),
65
+ ),
66
+ ]);
67
+
68
+ // RETURNS
69
+ if (props.context.options.stringify === "is")
70
+ return parameter({
71
+ type: "is",
72
+ key: "is",
73
+ programmer: JsonIsStringifyProgrammer.write,
74
+ });
75
+ else if (props.context.options.stringify === "validate")
76
+ return parameter({
77
+ type: "validate",
78
+ key: "validate",
79
+ programmer: JsonValidateStringifyProgrammer.write,
80
+ });
81
+ else if (props.context.options.stringify === "stringify")
82
+ return parameter({
83
+ type: "stringify",
84
+ key: "stringify",
85
+ programmer: JsonStringifyProgrammer.write,
86
+ });
87
+ else if (props.context.options.stringify === "validate.log")
88
+ return parameter({
89
+ type: "validate.log",
90
+ key: "validate",
91
+ programmer: JsonValidateStringifyProgrammer.write,
92
+ });
93
+ else if (props.context.options.stringify === null)
94
+ return ts.factory.createNull();
95
+
96
+ // ASSERT IS DEFAULT
97
+ return parameter({
98
+ type: "assert",
99
+ key: "assert",
100
+ programmer: JsonAssertStringifyProgrammer.write,
101
+ });
102
+ };
103
+ }