@nestia/migrate 8.0.5-dev.20250904-2 → 8.0.5

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.
@@ -1,343 +1,343 @@
1
- import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
- import ts from "typescript";
3
- import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
- import { StatementFactory } from "typia/lib/factories/StatementFactory";
5
- import { Escaper } from "typia/lib/utils/Escaper";
6
-
7
- import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
8
- import { FilePrinter } from "../utils/FilePrinter";
9
- import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
- import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
11
-
12
- export namespace NestiaMigrateApiFunctionProgrammer {
13
- export interface IContext {
14
- config: INestiaMigrateConfig;
15
- components: OpenApi.IComponents;
16
- importer: NestiaMigrateImportProgrammer;
17
- route: IHttpMigrateRoute;
18
- }
19
-
20
- export const write = (ctx: IContext): ts.FunctionDeclaration =>
21
- FilePrinter.description(
22
- ts.factory.createFunctionDeclaration(
23
- [
24
- ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
25
- ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
26
- ],
27
- undefined,
28
- ctx.route.accessor.at(-1)!,
29
- undefined,
30
- writeParameterDeclarations(ctx),
31
- ts.factory.createTypeReferenceNode("Promise", [
32
- ts.factory.createTypeReferenceNode(
33
- ctx.route.success === null
34
- ? "void"
35
- : `${ctx.route.accessor.at(-1)!}.Response`,
36
- ),
37
- ]),
38
- ts.factory.createBlock(writeBody(ctx), true),
39
- ),
40
- writeDescription(ctx.config, ctx.route),
41
- );
42
-
43
- export const writeParameterDeclarations = (
44
- ctx: IContext,
45
- connectionName?: string,
46
- ): ts.ParameterDeclaration[] => {
47
- const connection: ts.ParameterDeclaration = IdentifierFactory.parameter(
48
- connectionName ?? "connection",
49
- ts.factory.createTypeReferenceNode(
50
- ctx.importer.external({
51
- type: "instance",
52
- library: "@nestia/fetcher",
53
- name: "IConnection",
54
- }),
55
- ctx.route.headers
56
- ? [
57
- ts.factory.createTypeReferenceNode(
58
- `${ctx.route.accessor.at(-1)!}.Headers`,
59
- ),
60
- ]
61
- : undefined,
62
- ),
63
- );
64
- if (ctx.config.keyword === true) {
65
- const isProps: boolean =
66
- ctx.route.parameters.length > 0 ||
67
- !!ctx.route.query ||
68
- !!ctx.route.body;
69
- if (isProps === false) return [connection];
70
- return [
71
- connection,
72
- ts.factory.createParameterDeclaration(
73
- undefined,
74
- undefined,
75
- "props",
76
- undefined,
77
- ts.factory.createTypeReferenceNode(
78
- `${ctx.route.accessor.at(-1)!}.Props`,
79
- ),
80
- ),
81
- ];
82
- }
83
- return [
84
- connection,
85
- ...ctx.route.parameters.map((p) =>
86
- IdentifierFactory.parameter(
87
- p.key,
88
- NestiaMigrateSchemaProgrammer.write({
89
- components: ctx.components,
90
- importer: ctx.importer,
91
- schema: p.schema,
92
- }),
93
- ),
94
- ),
95
- ...(ctx.route.query
96
- ? [
97
- IdentifierFactory.parameter(
98
- ctx.route.query.key,
99
- ts.factory.createTypeReferenceNode(
100
- `${ctx.route.accessor.at(-1)!}.Query`,
101
- ),
102
- ),
103
- ]
104
- : []),
105
- ...(ctx.route.body
106
- ? [
107
- IdentifierFactory.parameter(
108
- ctx.route.body.key,
109
- ts.factory.createTypeReferenceNode(
110
- `${ctx.route.accessor.at(-1)!}.Body`,
111
- ),
112
- (ctx.route.body.type === "application/json" ||
113
- ctx.route.body.type === "text/plain") &&
114
- ctx.route.operation().requestBody?.required === false
115
- ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
116
- : undefined,
117
- ),
118
- ]
119
- : []),
120
- ];
121
- };
122
-
123
- const writeDescription = (
124
- config: INestiaMigrateConfig,
125
- route: IHttpMigrateRoute,
126
- ): string => {
127
- const comment: string = route.comment();
128
- return [
129
- config.keyword === true
130
- ? comment.split("@param ").join("@param props.")
131
- : comment,
132
- `@path ${route.emendedPath}`,
133
- `@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
134
- ].join("\n");
135
- };
136
-
137
- const writeBody = (ctx: IContext): ts.Statement[] => {
138
- const encrypted: boolean = !!ctx.route.success?.["x-nestia-encrypted"];
139
- const contentType: string = ctx.route.body?.type ?? "application/json";
140
-
141
- const property = (key: string): ts.Expression =>
142
- ctx.config.keyword === true
143
- ? IdentifierFactory.access(ts.factory.createIdentifier("props"), key)
144
- : ts.factory.createIdentifier(key);
145
- const fetch = () =>
146
- ts.factory.createAwaitExpression(
147
- ts.factory.createCallExpression(
148
- IdentifierFactory.access(
149
- ts.factory.createIdentifier(
150
- ctx.importer.external({
151
- type: "instance",
152
- library: `@nestia/fetcher/lib/${encrypted ? "EncryptedFetcher" : "PlainFetcher"}`,
153
- name: encrypted ? "EncryptedFetcher" : "PlainFetcher",
154
- }),
155
- ),
156
- "fetch",
157
- ),
158
- undefined,
159
- [
160
- contentType && contentType !== "multipart/form-data"
161
- ? ts.factory.createObjectLiteralExpression(
162
- [
163
- ts.factory.createSpreadAssignment(
164
- ts.factory.createIdentifier("connection"),
165
- ),
166
- ts.factory.createPropertyAssignment(
167
- "headers",
168
- ts.factory.createObjectLiteralExpression(
169
- [
170
- ts.factory.createSpreadAssignment(
171
- IdentifierFactory.access(
172
- ts.factory.createIdentifier("connection"),
173
- "headers",
174
- ),
175
- ),
176
- ts.factory.createPropertyAssignment(
177
- ts.factory.createStringLiteral("Content-Type"),
178
- ts.factory.createStringLiteral(contentType),
179
- ),
180
- ],
181
- true,
182
- ),
183
- ),
184
- ],
185
- true,
186
- )
187
- : ts.factory.createIdentifier("connection"),
188
- ts.factory.createObjectLiteralExpression(
189
- [
190
- ts.factory.createSpreadAssignment(
191
- IdentifierFactory.access(
192
- ts.factory.createIdentifier(ctx.route.accessor.at(-1)!),
193
- "METADATA",
194
- ),
195
- ),
196
- ts.factory.createPropertyAssignment(
197
- "path",
198
- ts.factory.createCallExpression(
199
- IdentifierFactory.access(
200
- ts.factory.createIdentifier(ctx.route.accessor.at(-1)!),
201
- "path",
202
- ),
203
- undefined,
204
- getArguments(ctx, false),
205
- ),
206
- ),
207
- ts.factory.createPropertyAssignment(
208
- "status",
209
- ts.factory.createNull(),
210
- ),
211
- ],
212
- true,
213
- ),
214
- ...(ctx.route.body ? [property(ctx.route.body.key)] : []),
215
- ],
216
- ),
217
- );
218
-
219
- const value: ts.Expression =
220
- ctx.config.simulate !== true
221
- ? fetch()
222
- : ts.factory.createConditionalExpression(
223
- ts.factory.createStrictEquality(
224
- ts.factory.createTrue(),
225
- ts.factory.createIdentifier("connection.simulate"),
226
- ),
227
- undefined,
228
- ts.factory.createCallExpression(
229
- ts.factory.createIdentifier(
230
- `${ctx.route.accessor.at(-1)!}.simulate`,
231
- ),
232
- [],
233
- [
234
- ts.factory.createIdentifier("connection"),
235
- ...getArguments(ctx, true),
236
- ],
237
- ),
238
- undefined,
239
- fetch(),
240
- );
241
- const headers: Array<IAssignHeader | ISetHeader> = getHeaders(
242
- ctx.route.comment(),
243
- );
244
- if (headers.length === 0) return [ts.factory.createReturnStatement(value)];
245
- return [
246
- StatementFactory.constant({
247
- name: "output",
248
- type: ts.factory.createTypeReferenceNode(
249
- `${ctx.route.accessor.at(-1)!}.Response`,
250
- ),
251
- value,
252
- }),
253
- ts.factory.createExpressionStatement(
254
- ts.factory.createBinaryExpression(
255
- ts.factory.createIdentifier("connection.headers"),
256
- ts.factory.createToken(ts.SyntaxKind.QuestionQuestionEqualsToken),
257
- ts.factory.createObjectLiteralExpression([]),
258
- ),
259
- ),
260
- ...headers.map((h) =>
261
- ts.factory.createExpressionStatement(
262
- h.type === "assign"
263
- ? ts.factory.createCallExpression(
264
- ts.factory.createIdentifier("Object.assign"),
265
- undefined,
266
- [
267
- ts.factory.createIdentifier("connection.headers"),
268
- ts.factory.createIdentifier(`output.${h.accessor}`),
269
- ],
270
- )
271
- : ts.factory.createBinaryExpression(
272
- ts.factory.createIdentifier(
273
- `connection.headers${Escaper.variable(h.property) ? `.${h.property}` : `[${JSON.stringify(h.property)}]`}`,
274
- ),
275
- ts.factory.createToken(ts.SyntaxKind.EqualsToken),
276
- ts.factory.createIdentifier(`output.${h.accessor}`),
277
- ),
278
- ),
279
- ),
280
- ts.factory.createReturnStatement(ts.factory.createIdentifier("output")),
281
- ];
282
- };
283
-
284
- const getArguments = (ctx: IContext, body: boolean): ts.Expression[] => {
285
- if (
286
- ctx.route.parameters.length === 0 &&
287
- ctx.route.query === null &&
288
- (body === false || ctx.route.body === null)
289
- )
290
- return [];
291
- else if (ctx.config.keyword === true)
292
- return [ts.factory.createIdentifier("props")];
293
- return [
294
- ...ctx.route.parameters.map((p) => ts.factory.createIdentifier(p.key)),
295
- ...(ctx.route.query
296
- ? [ts.factory.createIdentifier(ctx.route.query.key)]
297
- : []),
298
- ...(body && ctx.route.body
299
- ? [ts.factory.createIdentifier(ctx.route.body.key)]
300
- : []),
301
- ];
302
- };
303
-
304
- const getHeaders = (
305
- description: string,
306
- ): Array<IAssignHeader | ISetHeader> => {
307
- const directives: Array<IAssignHeader | ISetHeader> = [];
308
- for (const line of description.split("\n").map((l) => l.trim())) {
309
- if (line.startsWith("@setHeader ")) {
310
- const parts: string[] = line
311
- .substring("@setHeader ".length)
312
- .trim()
313
- .split(/\s+/);
314
- if (parts.length >= 2)
315
- directives.push({
316
- type: "set",
317
- accessor: parts[0],
318
- property: parts[1],
319
- });
320
- } else if (line.startsWith("@assignHeaders ")) {
321
- const accessor: string = line
322
- .substring("@assignHeaders ".length)
323
- .trim();
324
- if (accessor.length !== 0)
325
- directives.push({
326
- type: "assign",
327
- accessor,
328
- });
329
- }
330
- }
331
- return directives;
332
- };
333
- }
334
-
335
- interface IAssignHeader {
336
- type: "assign";
337
- accessor: string;
338
- }
339
- interface ISetHeader {
340
- type: "set";
341
- accessor: string;
342
- property: string;
343
- }
1
+ import { IHttpMigrateRoute, OpenApi } from "@samchon/openapi";
2
+ import ts from "typescript";
3
+ import { IdentifierFactory } from "typia/lib/factories/IdentifierFactory";
4
+ import { StatementFactory } from "typia/lib/factories/StatementFactory";
5
+ import { Escaper } from "typia/lib/utils/Escaper";
6
+
7
+ import { INestiaMigrateConfig } from "../structures/INestiaMigrateConfig";
8
+ import { FilePrinter } from "../utils/FilePrinter";
9
+ import { NestiaMigrateImportProgrammer } from "./NestiaMigrateImportProgrammer";
10
+ import { NestiaMigrateSchemaProgrammer } from "./NestiaMigrateSchemaProgrammer";
11
+
12
+ export namespace NestiaMigrateApiFunctionProgrammer {
13
+ export interface IContext {
14
+ config: INestiaMigrateConfig;
15
+ components: OpenApi.IComponents;
16
+ importer: NestiaMigrateImportProgrammer;
17
+ route: IHttpMigrateRoute;
18
+ }
19
+
20
+ export const write = (ctx: IContext): ts.FunctionDeclaration =>
21
+ FilePrinter.description(
22
+ ts.factory.createFunctionDeclaration(
23
+ [
24
+ ts.factory.createModifier(ts.SyntaxKind.ExportKeyword),
25
+ ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword),
26
+ ],
27
+ undefined,
28
+ ctx.route.accessor.at(-1)!,
29
+ undefined,
30
+ writeParameterDeclarations(ctx),
31
+ ts.factory.createTypeReferenceNode("Promise", [
32
+ ts.factory.createTypeReferenceNode(
33
+ ctx.route.success === null
34
+ ? "void"
35
+ : `${ctx.route.accessor.at(-1)!}.Response`,
36
+ ),
37
+ ]),
38
+ ts.factory.createBlock(writeBody(ctx), true),
39
+ ),
40
+ writeDescription(ctx.config, ctx.route),
41
+ );
42
+
43
+ export const writeParameterDeclarations = (
44
+ ctx: IContext,
45
+ connectionName?: string,
46
+ ): ts.ParameterDeclaration[] => {
47
+ const connection: ts.ParameterDeclaration = IdentifierFactory.parameter(
48
+ connectionName ?? "connection",
49
+ ts.factory.createTypeReferenceNode(
50
+ ctx.importer.external({
51
+ type: "instance",
52
+ library: "@nestia/fetcher",
53
+ name: "IConnection",
54
+ }),
55
+ ctx.route.headers
56
+ ? [
57
+ ts.factory.createTypeReferenceNode(
58
+ `${ctx.route.accessor.at(-1)!}.Headers`,
59
+ ),
60
+ ]
61
+ : undefined,
62
+ ),
63
+ );
64
+ if (ctx.config.keyword === true) {
65
+ const isProps: boolean =
66
+ ctx.route.parameters.length > 0 ||
67
+ !!ctx.route.query ||
68
+ !!ctx.route.body;
69
+ if (isProps === false) return [connection];
70
+ return [
71
+ connection,
72
+ ts.factory.createParameterDeclaration(
73
+ undefined,
74
+ undefined,
75
+ "props",
76
+ undefined,
77
+ ts.factory.createTypeReferenceNode(
78
+ `${ctx.route.accessor.at(-1)!}.Props`,
79
+ ),
80
+ ),
81
+ ];
82
+ }
83
+ return [
84
+ connection,
85
+ ...ctx.route.parameters.map((p) =>
86
+ IdentifierFactory.parameter(
87
+ p.key,
88
+ NestiaMigrateSchemaProgrammer.write({
89
+ components: ctx.components,
90
+ importer: ctx.importer,
91
+ schema: p.schema,
92
+ }),
93
+ ),
94
+ ),
95
+ ...(ctx.route.query
96
+ ? [
97
+ IdentifierFactory.parameter(
98
+ ctx.route.query.key,
99
+ ts.factory.createTypeReferenceNode(
100
+ `${ctx.route.accessor.at(-1)!}.Query`,
101
+ ),
102
+ ),
103
+ ]
104
+ : []),
105
+ ...(ctx.route.body
106
+ ? [
107
+ IdentifierFactory.parameter(
108
+ ctx.route.body.key,
109
+ ts.factory.createTypeReferenceNode(
110
+ `${ctx.route.accessor.at(-1)!}.Body`,
111
+ ),
112
+ (ctx.route.body.type === "application/json" ||
113
+ ctx.route.body.type === "text/plain") &&
114
+ ctx.route.operation().requestBody?.required === false
115
+ ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
116
+ : undefined,
117
+ ),
118
+ ]
119
+ : []),
120
+ ];
121
+ };
122
+
123
+ const writeDescription = (
124
+ config: INestiaMigrateConfig,
125
+ route: IHttpMigrateRoute,
126
+ ): string => {
127
+ const comment: string = route.comment();
128
+ return [
129
+ config.keyword === true
130
+ ? comment.split("@param ").join("@param props.")
131
+ : comment,
132
+ `@path ${route.emendedPath}`,
133
+ `@${config.author?.tag ?? "nestia"} ${config.author?.value ?? "Generated by Nestia - https://github.com/samchon/nestia"}`,
134
+ ].join("\n");
135
+ };
136
+
137
+ const writeBody = (ctx: IContext): ts.Statement[] => {
138
+ const encrypted: boolean = !!ctx.route.success?.["x-nestia-encrypted"];
139
+ const contentType: string = ctx.route.body?.type ?? "application/json";
140
+
141
+ const property = (key: string): ts.Expression =>
142
+ ctx.config.keyword === true
143
+ ? IdentifierFactory.access(ts.factory.createIdentifier("props"), key)
144
+ : ts.factory.createIdentifier(key);
145
+ const fetch = () =>
146
+ ts.factory.createAwaitExpression(
147
+ ts.factory.createCallExpression(
148
+ IdentifierFactory.access(
149
+ ts.factory.createIdentifier(
150
+ ctx.importer.external({
151
+ type: "instance",
152
+ library: `@nestia/fetcher/lib/${encrypted ? "EncryptedFetcher" : "PlainFetcher"}`,
153
+ name: encrypted ? "EncryptedFetcher" : "PlainFetcher",
154
+ }),
155
+ ),
156
+ "fetch",
157
+ ),
158
+ undefined,
159
+ [
160
+ contentType && contentType !== "multipart/form-data"
161
+ ? ts.factory.createObjectLiteralExpression(
162
+ [
163
+ ts.factory.createSpreadAssignment(
164
+ ts.factory.createIdentifier("connection"),
165
+ ),
166
+ ts.factory.createPropertyAssignment(
167
+ "headers",
168
+ ts.factory.createObjectLiteralExpression(
169
+ [
170
+ ts.factory.createSpreadAssignment(
171
+ IdentifierFactory.access(
172
+ ts.factory.createIdentifier("connection"),
173
+ "headers",
174
+ ),
175
+ ),
176
+ ts.factory.createPropertyAssignment(
177
+ ts.factory.createStringLiteral("Content-Type"),
178
+ ts.factory.createStringLiteral(contentType),
179
+ ),
180
+ ],
181
+ true,
182
+ ),
183
+ ),
184
+ ],
185
+ true,
186
+ )
187
+ : ts.factory.createIdentifier("connection"),
188
+ ts.factory.createObjectLiteralExpression(
189
+ [
190
+ ts.factory.createSpreadAssignment(
191
+ IdentifierFactory.access(
192
+ ts.factory.createIdentifier(ctx.route.accessor.at(-1)!),
193
+ "METADATA",
194
+ ),
195
+ ),
196
+ ts.factory.createPropertyAssignment(
197
+ "path",
198
+ ts.factory.createCallExpression(
199
+ IdentifierFactory.access(
200
+ ts.factory.createIdentifier(ctx.route.accessor.at(-1)!),
201
+ "path",
202
+ ),
203
+ undefined,
204
+ getArguments(ctx, false),
205
+ ),
206
+ ),
207
+ ts.factory.createPropertyAssignment(
208
+ "status",
209
+ ts.factory.createNull(),
210
+ ),
211
+ ],
212
+ true,
213
+ ),
214
+ ...(ctx.route.body ? [property(ctx.route.body.key)] : []),
215
+ ],
216
+ ),
217
+ );
218
+
219
+ const value: ts.Expression =
220
+ ctx.config.simulate !== true
221
+ ? fetch()
222
+ : ts.factory.createConditionalExpression(
223
+ ts.factory.createStrictEquality(
224
+ ts.factory.createTrue(),
225
+ ts.factory.createIdentifier("connection.simulate"),
226
+ ),
227
+ undefined,
228
+ ts.factory.createCallExpression(
229
+ ts.factory.createIdentifier(
230
+ `${ctx.route.accessor.at(-1)!}.simulate`,
231
+ ),
232
+ [],
233
+ [
234
+ ts.factory.createIdentifier("connection"),
235
+ ...getArguments(ctx, true),
236
+ ],
237
+ ),
238
+ undefined,
239
+ fetch(),
240
+ );
241
+ const headers: Array<IAssignHeader | ISetHeader> = getHeaders(
242
+ ctx.route.comment(),
243
+ );
244
+ if (headers.length === 0) return [ts.factory.createReturnStatement(value)];
245
+ return [
246
+ StatementFactory.constant({
247
+ name: "output",
248
+ type: ts.factory.createTypeReferenceNode(
249
+ `${ctx.route.accessor.at(-1)!}.Response`,
250
+ ),
251
+ value,
252
+ }),
253
+ ts.factory.createExpressionStatement(
254
+ ts.factory.createBinaryExpression(
255
+ ts.factory.createIdentifier("connection.headers"),
256
+ ts.factory.createToken(ts.SyntaxKind.QuestionQuestionEqualsToken),
257
+ ts.factory.createObjectLiteralExpression([]),
258
+ ),
259
+ ),
260
+ ...headers.map((h) =>
261
+ ts.factory.createExpressionStatement(
262
+ h.type === "assign"
263
+ ? ts.factory.createCallExpression(
264
+ ts.factory.createIdentifier("Object.assign"),
265
+ undefined,
266
+ [
267
+ ts.factory.createIdentifier("connection.headers"),
268
+ ts.factory.createIdentifier(`output.${h.accessor}`),
269
+ ],
270
+ )
271
+ : ts.factory.createBinaryExpression(
272
+ ts.factory.createIdentifier(
273
+ `connection.headers${Escaper.variable(h.property) ? `.${h.property}` : `[${JSON.stringify(h.property)}]`}`,
274
+ ),
275
+ ts.factory.createToken(ts.SyntaxKind.EqualsToken),
276
+ ts.factory.createIdentifier(`output.${h.accessor}`),
277
+ ),
278
+ ),
279
+ ),
280
+ ts.factory.createReturnStatement(ts.factory.createIdentifier("output")),
281
+ ];
282
+ };
283
+
284
+ const getArguments = (ctx: IContext, body: boolean): ts.Expression[] => {
285
+ if (
286
+ ctx.route.parameters.length === 0 &&
287
+ ctx.route.query === null &&
288
+ (body === false || ctx.route.body === null)
289
+ )
290
+ return [];
291
+ else if (ctx.config.keyword === true)
292
+ return [ts.factory.createIdentifier("props")];
293
+ return [
294
+ ...ctx.route.parameters.map((p) => ts.factory.createIdentifier(p.key)),
295
+ ...(ctx.route.query
296
+ ? [ts.factory.createIdentifier(ctx.route.query.key)]
297
+ : []),
298
+ ...(body && ctx.route.body
299
+ ? [ts.factory.createIdentifier(ctx.route.body.key)]
300
+ : []),
301
+ ];
302
+ };
303
+
304
+ const getHeaders = (
305
+ description: string,
306
+ ): Array<IAssignHeader | ISetHeader> => {
307
+ const directives: Array<IAssignHeader | ISetHeader> = [];
308
+ for (const line of description.split("\n").map((l) => l.trim())) {
309
+ if (line.startsWith("@setHeader ")) {
310
+ const parts: string[] = line
311
+ .substring("@setHeader ".length)
312
+ .trim()
313
+ .split(/\s+/);
314
+ if (parts.length >= 2)
315
+ directives.push({
316
+ type: "set",
317
+ accessor: parts[0],
318
+ property: parts[1],
319
+ });
320
+ } else if (line.startsWith("@assignHeaders ")) {
321
+ const accessor: string = line
322
+ .substring("@assignHeaders ".length)
323
+ .trim();
324
+ if (accessor.length !== 0)
325
+ directives.push({
326
+ type: "assign",
327
+ accessor,
328
+ });
329
+ }
330
+ }
331
+ return directives;
332
+ };
333
+ }
334
+
335
+ interface IAssignHeader {
336
+ type: "assign";
337
+ accessor: string;
338
+ }
339
+ interface ISetHeader {
340
+ type: "set";
341
+ accessor: string;
342
+ property: string;
343
+ }