Skip to content

Commit ac447e1

Browse files
committed
fixx error
1 parent 9bac4a3 commit ac447e1

File tree

21 files changed

+386
-60
lines changed

21 files changed

+386
-60
lines changed

src/LoggingInterface.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
*/
55
import pc from 'picocolors';
66

7-
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'verbose' | 'debug';
7+
export type LogLevel =
8+
| 'silent'
9+
| 'error'
10+
| 'warn'
11+
| 'info'
12+
| 'verbose'
13+
| 'debug';
814

915
const LOG_LEVEL_PRIORITY: Record<LogLevel, number> = {
1016
silent: 0,
@@ -104,6 +110,7 @@ export class LoggerClass implements ExtendedLoggingInterface {
104110
private pauseSpinner(): void {
105111
if (this.spinner?.interval) {
106112
clearInterval(this.spinner.interval);
113+
this.spinner.interval = null;
107114
// Clear the current line
108115
if (process.stdout.isTTY) {
109116
process.stdout.clearLine(0);
@@ -266,8 +273,9 @@ export class LoggerClass implements ExtendedLoggingInterface {
266273
* Stop the spinner with a success message
267274
*/
268275
succeedSpinner(text?: string): void {
276+
const spinnerText = this.spinner?.text;
269277
this.stopSpinner();
270-
const displayText = text || this.spinner?.text || '';
278+
const displayText = text || spinnerText || '';
271279
if (displayText && this.shouldLog('info')) {
272280
const symbol = this.colorsEnabled ? pc.green('✓') : '[OK]';
273281
console.log(`${symbol} ${displayText}`);
@@ -278,8 +286,9 @@ export class LoggerClass implements ExtendedLoggingInterface {
278286
* Stop the spinner with a failure message
279287
*/
280288
failSpinner(text?: string): void {
289+
const spinnerText = this.spinner?.text;
281290
this.stopSpinner();
282-
const displayText = text || this.spinner?.text || '';
291+
const displayText = text || spinnerText || '';
283292
if (displayText && this.shouldLog('error')) {
284293
const symbol = this.colorsEnabled ? pc.red('✗') : '[FAIL]';
285294
console.log(`${symbol} ${displayText}`);

src/codegen/errors.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,3 @@ export function parseZodErrors(zodError: any): string[] {
344344

345345
return errors;
346346
}
347-

src/codegen/generators/typescript/channels/asyncapi.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ export async function generateTypeScriptChannelsForAsyncAPI(
116116
if (channel.parameters().length > 0) {
117117
parameter = parameters.channelModels[channel.id()];
118118
if (parameter === undefined) {
119-
throw createMissingParameterError({channelOrOperation: channel.id(), protocol: 'channels'});
119+
throw createMissingParameterError({
120+
channelOrOperation: channel.id(),
121+
protocol: 'channels'
122+
});
120123
}
121124
}
122125

@@ -210,10 +213,16 @@ function validateAsyncapiContext(context: TypeScriptChannelsContext): {
210213
} {
211214
const {asyncapiDocument, inputType} = context;
212215
if (inputType !== 'asyncapi') {
213-
throw createMissingInputDocumentError({expectedType: 'asyncapi', generatorPreset: 'channels'});
216+
throw createMissingInputDocumentError({
217+
expectedType: 'asyncapi',
218+
generatorPreset: 'channels'
219+
});
214220
}
215221
if (asyncapiDocument === undefined) {
216-
throw createMissingInputDocumentError({expectedType: 'asyncapi', generatorPreset: 'channels'});
222+
throw createMissingInputDocumentError({
223+
expectedType: 'asyncapi',
224+
generatorPreset: 'channels'
225+
});
217226
}
218227
return {asyncapiDocument};
219228
}

src/codegen/generators/typescript/channels/openapi.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,16 @@ function validateOpenAPIContext(context: TypeScriptChannelsContext): {
243243
} {
244244
const {openapiDocument, inputType} = context;
245245
if (inputType !== 'openapi') {
246-
throw createMissingInputDocumentError({expectedType: 'openapi', generatorPreset: 'channels'});
246+
throw createMissingInputDocumentError({
247+
expectedType: 'openapi',
248+
generatorPreset: 'channels'
249+
});
247250
}
248251
if (!openapiDocument) {
249-
throw createMissingInputDocumentError({expectedType: 'openapi', generatorPreset: 'channels'});
252+
throw createMissingInputDocumentError({
253+
expectedType: 'openapi',
254+
generatorPreset: 'channels'
255+
});
250256
}
251257
return {openapiDocument};
252258
}

src/codegen/generators/typescript/channels/protocols/amqp/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ async function generateForOperations(
101101
const payloadId = findOperationId(operation, channel);
102102
const payload = payloads.operationModels[payloadId];
103103
if (!payload) {
104-
throw createMissingPayloadError({channelOrOperation: payloadId, protocol: 'AMQP'});
104+
throw createMissingPayloadError({
105+
channelOrOperation: payloadId,
106+
protocol: 'AMQP'
107+
});
105108
}
106109

107110
const {messageModule, messageType} = getMessageTypeAndModule(payload);
@@ -186,7 +189,10 @@ async function generateForChannels(
186189

187190
const payload = payloads.channelModels[channel.id()];
188191
if (!payload) {
189-
throw createMissingPayloadError({channelOrOperation: channel.id(), protocol: 'AMQP'});
192+
throw createMissingPayloadError({
193+
channelOrOperation: channel.id(),
194+
protocol: 'AMQP'
195+
});
190196
}
191197

192198
const {messageModule, messageType} = getMessageTypeAndModule(payload);

src/codegen/generators/typescript/channels/protocols/eventsource/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ async function generateForChannels(
184184

185185
const payload = payloads.channelModels[channel.id()];
186186
if (!payload) {
187-
throw createMissingPayloadError({channelOrOperation: channel.id(), protocol: 'EventSource'});
187+
throw createMissingPayloadError({
188+
channelOrOperation: channel.id(),
189+
protocol: 'EventSource'
190+
});
188191
}
189192

190193
const {messageModule, messageType} = getMessageTypeAndModule(payload);

src/codegen/generators/typescript/channels/protocols/kafka/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ async function generateForOperations(
101101
const payloadId = findOperationId(operation, channel);
102102
const payload = payloads.operationModels[payloadId];
103103
if (!payload) {
104-
throw createMissingPayloadError({channelOrOperation: payloadId, protocol: 'Kafka'});
104+
throw createMissingPayloadError({
105+
channelOrOperation: payloadId,
106+
protocol: 'Kafka'
107+
});
105108
}
106109

107110
const {messageModule, messageType} = getMessageTypeAndModule(payload);
@@ -175,7 +178,10 @@ async function generateForChannels(
175178

176179
const payload = payloads.channelModels[channel.id()];
177180
if (!payload) {
178-
throw createMissingPayloadError({channelOrOperation: channel.id(), protocol: 'Kafka'});
181+
throw createMissingPayloadError({
182+
channelOrOperation: channel.id(),
183+
protocol: 'Kafka'
184+
});
179185
}
180186

181187
const {messageModule, messageType} = getMessageTypeAndModule(payload);

src/codegen/generators/typescript/channels/protocols/mqtt/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ function generateForOperations(
9999
const payloadId = findOperationId(operation, channel);
100100
const payload = payloads.operationModels[payloadId];
101101
if (payload === undefined) {
102-
throw createMissingPayloadError({channelOrOperation: payloadId, protocol: 'MQTT'});
102+
throw createMissingPayloadError({
103+
channelOrOperation: payloadId,
104+
protocol: 'MQTT'
105+
});
103106
}
104107
const {messageModule, messageType} = getMessageTypeAndModule(payload);
105108
if (messageType === undefined) {
@@ -152,7 +155,10 @@ function generateForChannels(
152155
getFunctionTypeMappingFromAsyncAPI(channel) ?? functionTypeMapping;
153156
const payload = payloads.channelModels[channel.id()];
154157
if (payload === undefined) {
155-
throw createMissingPayloadError({channelOrOperation: channel.id(), protocol: 'MQTT'});
158+
throw createMissingPayloadError({
159+
channelOrOperation: channel.id(),
160+
protocol: 'MQTT'
161+
});
156162
}
157163
const {messageModule, messageType} = getMessageTypeAndModule(payload);
158164
if (messageType === undefined) {

src/codegen/generators/typescript/channels/protocols/nats/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ async function generateForChannels(
324324

325325
const payload = payloads.channelModels[channel.id()];
326326
if (!payload) {
327-
throw createMissingPayloadError({channelOrOperation: channel.id(), protocol: 'NATS'});
327+
throw createMissingPayloadError({
328+
channelOrOperation: channel.id(),
329+
protocol: 'NATS'
330+
});
328331
}
329332

330333
const {messageModule, messageType} = getMessageTypeAndModule(payload);

src/codegen/generators/typescript/channels/protocols/websocket/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ async function generateForChannels(
204204

205205
const payload = payloads.channelModels[channel.id()];
206206
if (!payload) {
207-
throw createMissingPayloadError({channelOrOperation: channel.id(), protocol: 'WebSocket'});
207+
throw createMissingPayloadError({
208+
channelOrOperation: channel.id(),
209+
protocol: 'WebSocket'
210+
});
208211
}
209212

210213
const {messageModule, messageType} = getMessageTypeAndModule(payload);

0 commit comments

Comments
 (0)