@goast/typescript 0.7.0 → 0.7.1
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.
- package/esm/src/generators/services/easy-network-stub/easy-network-stub-generator.d.ts +0 -3
- package/esm/src/generators/services/easy-network-stub/easy-network-stub-generator.d.ts.map +1 -1
- package/esm/src/generators/services/easy-network-stub/easy-network-stub-generator.js +1 -28
- package/package.json +1 -1
- package/script/src/generators/services/easy-network-stub/easy-network-stub-generator.d.ts +0 -3
- package/script/src/generators/services/easy-network-stub/easy-network-stub-generator.d.ts.map +1 -1
- package/script/src/generators/services/easy-network-stub/easy-network-stub-generator.js +1 -28
- package/src/src/generators/services/easy-network-stub/easy-network-stub-generator.ts +1 -40
|
@@ -23,11 +23,8 @@ export declare class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScrip
|
|
|
23
23
|
protected getStubClassName(ctx: Context): string;
|
|
24
24
|
protected getEndpointPathPropertyName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
25
25
|
protected getEndpointRequestsFieldName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
26
|
-
protected getEndpointStubHandleFieldName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
27
26
|
protected getEndpointRequestsPropertyName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
28
27
|
protected getEndpointStubMethodName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
29
|
-
protected getEndpointUnregisterMethodName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
30
|
-
protected getEndpointUnregisterMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
31
28
|
protected getStubRoute(ctx: Context, endpoint: ApiEndpoint): string;
|
|
32
29
|
protected getEndpointStatusCodes(ctx: Context, endpoint: ApiEndpoint): Record<number, ts.Type<Builder>>;
|
|
33
30
|
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, fallback?: ts.Type<Builder>): ts.Type<Builder>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"easy-network-stub-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/easy-network-stub/easy-network-stub-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,yCAAyC,EAAE,wCAAwC,EAAE,MAAM,aAAa,CAAC;AAEvH,KAAK,OAAO,GAAG,yCAAyC,CAAC;AACzD,KAAK,MAAM,GAAG,wCAAwC,CAAC;AACvD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,kCAAkC,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACjF,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,yCAA0C,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CACpG,YAAW,kCAAkC;IACtC,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC;IAwBnD,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAOrE,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;IAgBzF,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"easy-network-stub-generator.d.ts","sourceRoot":"","sources":["../../../../../src/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extends TypeScriptFileGen
|
|
|
55
55
|
value: ts.tuple([]),
|
|
56
56
|
})),
|
|
57
57
|
'\n',
|
|
58
|
-
...ctx.service.endpoints.map((endpoint) => ts.property(this.getEndpointStubHandleFieldName(ctx, endpoint), {
|
|
59
|
-
accessModifier: 'private',
|
|
60
|
-
type: s `${ctx.refs.stubHandle()} | undefined`,
|
|
61
|
-
})),
|
|
62
|
-
'\n',
|
|
63
58
|
...ctx.service.endpoints.map((endpoint) => ts.property(this.getEndpointRequestsPropertyName(ctx, endpoint), {
|
|
64
59
|
readonly: true,
|
|
65
60
|
accessModifier: 'public',
|
|
@@ -69,13 +64,11 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
69
64
|
}),
|
|
70
65
|
})),
|
|
71
66
|
...ctx.service.endpoints.map((endpoint) => this.getEndpointStubMethod(ctx, endpoint)),
|
|
72
|
-
...ctx.service.endpoints.map((endpoint) => this.getEndpointUnregisterMethod(ctx, endpoint)),
|
|
73
67
|
ts.method('reset', {
|
|
74
68
|
accessModifier: 'public',
|
|
75
69
|
override: true,
|
|
76
70
|
returnType: ts.refs.void_(),
|
|
77
71
|
body: appendValueGroup([
|
|
78
|
-
...ctx.service.endpoints.map((endpoint) => `this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = undefined;`),
|
|
79
72
|
...ctx.service.endpoints.map((endpoint) => `this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.length = 0;`),
|
|
80
73
|
'super.reset();',
|
|
81
74
|
], '\n'),
|
|
@@ -106,11 +99,7 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
106
99
|
],
|
|
107
100
|
returnType: 'this',
|
|
108
101
|
body: appendValueGroup([
|
|
109
|
-
s `
|
|
110
|
-
throw new Error('${this.getEndpointStubMethodName(ctx, endpoint)} has already been called. Call ${this.getEndpointUnregisterMethodName(ctx, endpoint)}() or reset() before stubbing again.');`}
|
|
111
|
-
}`,
|
|
112
|
-
s `this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = this.stubWrapper.stub2<${requestType}>()(${s
|
|
113
|
-
.indent `
|
|
102
|
+
s `this.stubWrapper.stub2<${requestType}>()(${s.indent `
|
|
114
103
|
${ts.string(endpoint.method.toUpperCase())},
|
|
115
104
|
${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
|
|
116
105
|
async (request) => {${s.indent `
|
|
@@ -140,28 +129,12 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
140
129
|
getEndpointRequestsFieldName(ctx, endpoint) {
|
|
141
130
|
return toCasing(endpoint.name + '_Requests', adjustCasing(ctx.config.propertyNameCasing, { prefix: '_' }));
|
|
142
131
|
}
|
|
143
|
-
getEndpointStubHandleFieldName(ctx, endpoint) {
|
|
144
|
-
return toCasing('stub_' + endpoint.name + '_Handle', adjustCasing(ctx.config.propertyNameCasing, { prefix: '_' }));
|
|
145
|
-
}
|
|
146
132
|
getEndpointRequestsPropertyName(ctx, endpoint) {
|
|
147
133
|
return toCasing(endpoint.name + '_Requests', ctx.config.propertyNameCasing);
|
|
148
134
|
}
|
|
149
135
|
getEndpointStubMethodName(ctx, endpoint) {
|
|
150
136
|
return toCasing('stub_' + endpoint.name, ctx.config.functionNameCasing);
|
|
151
137
|
}
|
|
152
|
-
getEndpointUnregisterMethodName(ctx, endpoint) {
|
|
153
|
-
return toCasing('unregister_stub_' + endpoint.name, ctx.config.functionNameCasing);
|
|
154
|
-
}
|
|
155
|
-
getEndpointUnregisterMethod(ctx, endpoint) {
|
|
156
|
-
return ts.method(this.getEndpointUnregisterMethodName(ctx, endpoint), {
|
|
157
|
-
accessModifier: 'public',
|
|
158
|
-
returnType: ts.refs.void_(),
|
|
159
|
-
body: appendValueGroup([
|
|
160
|
-
`this.${this.getEndpointStubHandleFieldName(ctx, endpoint)}?.unregister();`,
|
|
161
|
-
`this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = undefined;`,
|
|
162
|
-
], '\n'),
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
138
|
getStubRoute(ctx, endpoint) {
|
|
166
139
|
var _a, _b;
|
|
167
140
|
let path = endpoint.path;
|
package/package.json
CHANGED
|
@@ -23,11 +23,8 @@ export declare class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScrip
|
|
|
23
23
|
protected getStubClassName(ctx: Context): string;
|
|
24
24
|
protected getEndpointPathPropertyName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
25
25
|
protected getEndpointRequestsFieldName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
26
|
-
protected getEndpointStubHandleFieldName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
27
26
|
protected getEndpointRequestsPropertyName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
28
27
|
protected getEndpointStubMethodName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
29
|
-
protected getEndpointUnregisterMethodName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
30
|
-
protected getEndpointUnregisterMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
31
28
|
protected getStubRoute(ctx: Context, endpoint: ApiEndpoint): string;
|
|
32
29
|
protected getEndpointStatusCodes(ctx: Context, endpoint: ApiEndpoint): Record<number, ts.Type<Builder>>;
|
|
33
30
|
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, fallback?: ts.Type<Builder>): ts.Type<Builder>;
|
package/script/src/generators/services/easy-network-stub/easy-network-stub-generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"easy-network-stub-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/easy-network-stub/easy-network-stub-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,yCAAyC,EAAE,wCAAwC,EAAE,MAAM,aAAa,CAAC;AAEvH,KAAK,OAAO,GAAG,yCAAyC,CAAC;AACzD,KAAK,MAAM,GAAG,wCAAwC,CAAC;AACvD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,kCAAkC,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IACjF,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,yCAA0C,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CACpG,YAAW,kCAAkC;IACtC,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC;IAwBnD,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAOrE,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;IAgBzF,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"easy-network-stub-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/easy-network-stub/easy-network-stub-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC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CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAI/E,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAIhD,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIlF,SAAS,CAAC,4BAA4B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAInF,SAAS,CAAC,+BAA+B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAItF,SAAS,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIhF,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAyBnE,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAYvG,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;CAKpH"}
|
|
@@ -58,11 +58,6 @@ class DefaultTypeScriptEasyNetworkStubGenerator extends file_generator_js_1.Type
|
|
|
58
58
|
value: index_js_1.ts.tuple([]),
|
|
59
59
|
})),
|
|
60
60
|
'\n',
|
|
61
|
-
...ctx.service.endpoints.map((endpoint) => index_js_1.ts.property(this.getEndpointStubHandleFieldName(ctx, endpoint), {
|
|
62
|
-
accessModifier: 'private',
|
|
63
|
-
type: (0, core_1.builderTemplate) `${ctx.refs.stubHandle()} | undefined`,
|
|
64
|
-
})),
|
|
65
|
-
'\n',
|
|
66
61
|
...ctx.service.endpoints.map((endpoint) => index_js_1.ts.property(this.getEndpointRequestsPropertyName(ctx, endpoint), {
|
|
67
62
|
readonly: true,
|
|
68
63
|
accessModifier: 'public',
|
|
@@ -72,13 +67,11 @@ class DefaultTypeScriptEasyNetworkStubGenerator extends file_generator_js_1.Type
|
|
|
72
67
|
}),
|
|
73
68
|
})),
|
|
74
69
|
...ctx.service.endpoints.map((endpoint) => this.getEndpointStubMethod(ctx, endpoint)),
|
|
75
|
-
...ctx.service.endpoints.map((endpoint) => this.getEndpointUnregisterMethod(ctx, endpoint)),
|
|
76
70
|
index_js_1.ts.method('reset', {
|
|
77
71
|
accessModifier: 'public',
|
|
78
72
|
override: true,
|
|
79
73
|
returnType: index_js_1.ts.refs.void_(),
|
|
80
74
|
body: (0, core_1.appendValueGroup)([
|
|
81
|
-
...ctx.service.endpoints.map((endpoint) => `this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = undefined;`),
|
|
82
75
|
...ctx.service.endpoints.map((endpoint) => `this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.length = 0;`),
|
|
83
76
|
'super.reset();',
|
|
84
77
|
], '\n'),
|
|
@@ -109,11 +102,7 @@ class DefaultTypeScriptEasyNetworkStubGenerator extends file_generator_js_1.Type
|
|
|
109
102
|
],
|
|
110
103
|
returnType: 'this',
|
|
111
104
|
body: (0, core_1.appendValueGroup)([
|
|
112
|
-
(0, core_1.builderTemplate) `
|
|
113
|
-
throw new Error('${this.getEndpointStubMethodName(ctx, endpoint)} has already been called. Call ${this.getEndpointUnregisterMethodName(ctx, endpoint)}() or reset() before stubbing again.');`}
|
|
114
|
-
}`,
|
|
115
|
-
(0, core_1.builderTemplate) `this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = this.stubWrapper.stub2<${requestType}>()(${core_1.builderTemplate
|
|
116
|
-
.indent `
|
|
105
|
+
(0, core_1.builderTemplate) `this.stubWrapper.stub2<${requestType}>()(${core_1.builderTemplate.indent `
|
|
117
106
|
${index_js_1.ts.string(endpoint.method.toUpperCase())},
|
|
118
107
|
${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
|
|
119
108
|
async (request) => {${core_1.builderTemplate.indent `
|
|
@@ -143,28 +132,12 @@ class DefaultTypeScriptEasyNetworkStubGenerator extends file_generator_js_1.Type
|
|
|
143
132
|
getEndpointRequestsFieldName(ctx, endpoint) {
|
|
144
133
|
return (0, core_1.toCasing)(endpoint.name + '_Requests', (0, core_1.adjustCasing)(ctx.config.propertyNameCasing, { prefix: '_' }));
|
|
145
134
|
}
|
|
146
|
-
getEndpointStubHandleFieldName(ctx, endpoint) {
|
|
147
|
-
return (0, core_1.toCasing)('stub_' + endpoint.name + '_Handle', (0, core_1.adjustCasing)(ctx.config.propertyNameCasing, { prefix: '_' }));
|
|
148
|
-
}
|
|
149
135
|
getEndpointRequestsPropertyName(ctx, endpoint) {
|
|
150
136
|
return (0, core_1.toCasing)(endpoint.name + '_Requests', ctx.config.propertyNameCasing);
|
|
151
137
|
}
|
|
152
138
|
getEndpointStubMethodName(ctx, endpoint) {
|
|
153
139
|
return (0, core_1.toCasing)('stub_' + endpoint.name, ctx.config.functionNameCasing);
|
|
154
140
|
}
|
|
155
|
-
getEndpointUnregisterMethodName(ctx, endpoint) {
|
|
156
|
-
return (0, core_1.toCasing)('unregister_stub_' + endpoint.name, ctx.config.functionNameCasing);
|
|
157
|
-
}
|
|
158
|
-
getEndpointUnregisterMethod(ctx, endpoint) {
|
|
159
|
-
return index_js_1.ts.method(this.getEndpointUnregisterMethodName(ctx, endpoint), {
|
|
160
|
-
accessModifier: 'public',
|
|
161
|
-
returnType: index_js_1.ts.refs.void_(),
|
|
162
|
-
body: (0, core_1.appendValueGroup)([
|
|
163
|
-
`this.${this.getEndpointStubHandleFieldName(ctx, endpoint)}?.unregister();`,
|
|
164
|
-
`this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = undefined;`,
|
|
165
|
-
], '\n'),
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
141
|
getStubRoute(ctx, endpoint) {
|
|
169
142
|
var _a, _b;
|
|
170
143
|
let path = endpoint.path;
|
|
@@ -97,13 +97,6 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
97
97
|
})
|
|
98
98
|
),
|
|
99
99
|
'\n',
|
|
100
|
-
...ctx.service.endpoints.map((endpoint) =>
|
|
101
|
-
ts.property<Builder>(this.getEndpointStubHandleFieldName(ctx, endpoint), {
|
|
102
|
-
accessModifier: 'private',
|
|
103
|
-
type: s`${ctx.refs.stubHandle()} | undefined`,
|
|
104
|
-
})
|
|
105
|
-
),
|
|
106
|
-
'\n',
|
|
107
100
|
...ctx.service.endpoints.map((endpoint) =>
|
|
108
101
|
ts.property<Builder>(this.getEndpointRequestsPropertyName(ctx, endpoint), {
|
|
109
102
|
readonly: true,
|
|
@@ -115,16 +108,12 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
115
108
|
})
|
|
116
109
|
),
|
|
117
110
|
...ctx.service.endpoints.map((endpoint) => this.getEndpointStubMethod(ctx, endpoint)),
|
|
118
|
-
...ctx.service.endpoints.map((endpoint) => this.getEndpointUnregisterMethod(ctx, endpoint)),
|
|
119
111
|
ts.method('reset', {
|
|
120
112
|
accessModifier: 'public',
|
|
121
113
|
override: true,
|
|
122
114
|
returnType: ts.refs.void_(),
|
|
123
115
|
body: appendValueGroup(
|
|
124
116
|
[
|
|
125
|
-
...ctx.service.endpoints.map((endpoint) =>
|
|
126
|
-
`this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = undefined;`
|
|
127
|
-
),
|
|
128
117
|
...ctx.service.endpoints.map((endpoint) =>
|
|
129
118
|
`this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.length = 0;`
|
|
130
119
|
),
|
|
@@ -167,13 +156,7 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
167
156
|
returnType: 'this',
|
|
168
157
|
body: appendValueGroup(
|
|
169
158
|
[
|
|
170
|
-
s`
|
|
171
|
-
throw new Error('${this.getEndpointStubMethodName(ctx, endpoint)} has already been called. Call ${
|
|
172
|
-
this.getEndpointUnregisterMethodName(ctx, endpoint)
|
|
173
|
-
}() or reset() before stubbing again.');`}
|
|
174
|
-
}`,
|
|
175
|
-
s`this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = this.stubWrapper.stub2<${requestType}>()(${s
|
|
176
|
-
.indent`
|
|
159
|
+
s`this.stubWrapper.stub2<${requestType}>()(${s.indent`
|
|
177
160
|
${ts.string(endpoint.method.toUpperCase())},
|
|
178
161
|
${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
|
|
179
162
|
async (request) => {${s.indent`
|
|
@@ -214,10 +197,6 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
214
197
|
return toCasing(endpoint.name + '_Requests', adjustCasing(ctx.config.propertyNameCasing, { prefix: '_' }));
|
|
215
198
|
}
|
|
216
199
|
|
|
217
|
-
protected getEndpointStubHandleFieldName(ctx: Context, endpoint: ApiEndpoint): string {
|
|
218
|
-
return toCasing('stub_' + endpoint.name + '_Handle', adjustCasing(ctx.config.propertyNameCasing, { prefix: '_' }));
|
|
219
|
-
}
|
|
220
|
-
|
|
221
200
|
protected getEndpointRequestsPropertyName(ctx: Context, endpoint: ApiEndpoint): string {
|
|
222
201
|
return toCasing(endpoint.name + '_Requests', ctx.config.propertyNameCasing);
|
|
223
202
|
}
|
|
@@ -226,24 +205,6 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
226
205
|
return toCasing('stub_' + endpoint.name, ctx.config.functionNameCasing);
|
|
227
206
|
}
|
|
228
207
|
|
|
229
|
-
protected getEndpointUnregisterMethodName(ctx: Context, endpoint: ApiEndpoint): string {
|
|
230
|
-
return toCasing('unregister_stub_' + endpoint.name, ctx.config.functionNameCasing);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
protected getEndpointUnregisterMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder> {
|
|
234
|
-
return ts.method(this.getEndpointUnregisterMethodName(ctx, endpoint), {
|
|
235
|
-
accessModifier: 'public',
|
|
236
|
-
returnType: ts.refs.void_(),
|
|
237
|
-
body: appendValueGroup(
|
|
238
|
-
[
|
|
239
|
-
`this.${this.getEndpointStubHandleFieldName(ctx, endpoint)}?.unregister();`,
|
|
240
|
-
`this.${this.getEndpointStubHandleFieldName(ctx, endpoint)} = undefined;`,
|
|
241
|
-
],
|
|
242
|
-
'\n',
|
|
243
|
-
),
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
208
|
protected getStubRoute(ctx: Context, endpoint: ApiEndpoint): string {
|
|
248
209
|
let path = endpoint.path;
|
|
249
210
|
let isFirstQueryParam = true;
|