@goast/typescript 0.5.1-k6.3 → 0.5.2-k6.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/README.md +52 -52
- package/assets/client/angular/angular-service.utils.ts +82 -82
- package/assets/client/angular/request-builder.ts +377 -377
- package/assets/client/fetch/fetch-client.utils.ts +52 -52
- package/assets/client/k6/request-builder.js +444 -419
- package/assets/client/k6/request-builder.ts +24 -3
- package/assets/stubs/easy-network-stub/easy-network-stub.utils.ts +259 -259
- package/esm/src/generators/models/models.d.ts +1 -1
- package/esm/src/generators/models/models.d.ts.map +1 -1
- package/esm/src/generators/services/angular-services/angular-service-generator.js +9 -9
- package/esm/src/generators/services/easy-network-stub/easy-network-stub-generator.js +9 -9
- package/esm/src/generators/services/fetch-clients/fetch-client-generator.js +2 -2
- package/esm/src/generators/services/k6-clients/k6-client-generator.js +11 -11
- package/package.json +1 -1
- package/script/src/generators/models/models.d.ts +1 -1
- package/script/src/generators/models/models.d.ts.map +1 -1
- package/script/src/generators/services/angular-services/angular-service-generator.js +9 -9
- package/script/src/generators/services/easy-network-stub/easy-network-stub-generator.js +9 -9
- package/script/src/generators/services/fetch-clients/fetch-client-generator.js +2 -2
- package/script/src/generators/services/k6-clients/k6-client-generator.js +11 -11
|
@@ -229,7 +229,7 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
229
229
|
ts.constructorParameter('rootUrl', { type: isJs ? undefined : rootUrlType }),
|
|
230
230
|
ts.constructorParameter('defaultK6ParamsFactory', { type: isJs ? undefined : paramType, optional: true }),
|
|
231
231
|
],
|
|
232
|
-
body: s `this.rootUrl = rootUrl;
|
|
232
|
+
body: s `this.rootUrl = rootUrl;
|
|
233
233
|
this._defaultK6ParamsFactory = defaultK6ParamsFactory;`,
|
|
234
234
|
}),
|
|
235
235
|
...ctx.service.endpoints.map((e) => this.getEndpointMethod(ctx, e)),
|
|
@@ -291,17 +291,17 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
291
291
|
: null,
|
|
292
292
|
'',
|
|
293
293
|
ctx.config.language === 'javascript'
|
|
294
|
-
? s `return /** @type {${returnType}} */ (${s.indent `
|
|
295
|
-
${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${s.indent `
|
|
296
|
-
accept: ${ts.string(accept)},
|
|
297
|
-
params: this.getK6Params(k6Params),`}
|
|
298
|
-
})`}
|
|
294
|
+
? s `return /** @type {${returnType}} */ (${s.indent `
|
|
295
|
+
${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${s.indent `
|
|
296
|
+
accept: ${ts.string(accept)},
|
|
297
|
+
params: this.getK6Params(k6Params),`}
|
|
298
|
+
})`}
|
|
299
299
|
);`
|
|
300
|
-
: s `return (${s.indent `
|
|
301
|
-
${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${s.indent `
|
|
302
|
-
accept: ${ts.string(accept)},
|
|
303
|
-
params: this.getK6Params(k6Params),`}
|
|
304
|
-
})`}
|
|
300
|
+
: s `return (${s.indent `
|
|
301
|
+
${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${s.indent `
|
|
302
|
+
accept: ${ts.string(accept)},
|
|
303
|
+
params: this.getK6Params(k6Params),`}
|
|
304
|
+
})`}
|
|
305
305
|
) as unknown as ${returnType};`,
|
|
306
306
|
], '\n'),
|
|
307
307
|
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import type { ApiSchema, DefaultGenerationProviderConfig, ExtendedStringCasing,
|
|
|
2
2
|
import { ts } from '../../ast/index.js';
|
|
3
3
|
import type { TypeScriptComponentOutput } from '../../common-results.js';
|
|
4
4
|
import { type TypeScriptGeneratorConfig } from '../../config.js';
|
|
5
|
-
import { TypeScriptFileBuilder } from '../../file-builder.js';
|
|
5
|
+
import type { TypeScriptFileBuilder } from '../../file-builder.js';
|
|
6
6
|
export type TypeScriptModelGeneratorConfig = TypeScriptGeneratorConfig & {
|
|
7
7
|
/**
|
|
8
8
|
* Determines how to generate enums.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,oBAAoB,EACpB,QAAQ,EACR,uCAAuC,EACxC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAoC,KAAK,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,oBAAoB,EACpB,QAAQ,EACR,uCAAuC,EACxC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAoC,KAAK,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,GAAG;IACvE;;;;;OAKG;IACH,cAAc,EAAE,OAAO,GAAG,aAAa,CAAC;IAExC;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAE9B;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,mBAAmB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,eAAe,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAE7C;;;OAGG;IACH,2BAA2B,EAAE,oBAAoB,CAAC;IAElD;;;OAGG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,8BAA8B,GAAG;IAC7E;;;OAGG;IACH,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,qCAAqC,EAAE,+BAA+B,CAAC,8BAA8B,CAWjH,CAAC;AAEF,eAAO,MAAM,sCAAsC,EAAE,+BAA+B,CAAC,+BAA+B,CAKjH,CAAC;AAGJ,MAAM,MAAM,8BAA8B,GAAG,EAAE,CAAC;AAEhD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,UAAU,EAAE;QACV,MAAM,EAAE;YACN,CAAC,QAAQ,EAAE,MAAM,GAAG,8BAA8B,CAAC;SACpD,CAAC;QACF,UAAU,EAAE;YACV,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;SAC1B,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;AAEvE,MAAM,MAAM,gCAAgC,GAAG,uCAAuC,CACpF,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,CAC/B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,gCAAgC,GAAG;IAC/E,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC"}
|
|
@@ -232,13 +232,13 @@ class DefaultTypeScriptAngularServiceGenerator extends file_generator_js_1.TypeS
|
|
|
232
232
|
], '\n'), { multiline: true })
|
|
233
233
|
: null,
|
|
234
234
|
'',
|
|
235
|
-
(0, core_1.builderTemplate) `return ${ctx.refs.waitForResponse([responseModelType])}(${core_1.builderTemplate.indent `
|
|
236
|
-
this.http.request(rb.build({${core_1.builderTemplate.indent `
|
|
237
|
-
responseType: ${index_js_1.ts.string(responseType)},
|
|
238
|
-
accept: ${index_js_1.ts.string(accept)},
|
|
239
|
-
context,`}
|
|
240
|
-
})),
|
|
241
|
-
{${core_1.builderTemplate.indent `
|
|
235
|
+
(0, core_1.builderTemplate) `return ${ctx.refs.waitForResponse([responseModelType])}(${core_1.builderTemplate.indent `
|
|
236
|
+
this.http.request(rb.build({${core_1.builderTemplate.indent `
|
|
237
|
+
responseType: ${index_js_1.ts.string(responseType)},
|
|
238
|
+
accept: ${index_js_1.ts.string(accept)},
|
|
239
|
+
context,`}
|
|
240
|
+
})),
|
|
241
|
+
{${core_1.builderTemplate.indent `
|
|
242
242
|
errorResponseTypes: ${index_js_1.ts.object({
|
|
243
243
|
members: [
|
|
244
244
|
...Object.entries(this.getEndpointStatusCodes(ctx, endpoint))
|
|
@@ -247,8 +247,8 @@ class DefaultTypeScriptAngularServiceGenerator extends file_generator_js_1.TypeS
|
|
|
247
247
|
return index_js_1.ts.property(key, { value: index_js_1.ts.string(value.parser) });
|
|
248
248
|
}),
|
|
249
249
|
],
|
|
250
|
-
})}`}
|
|
251
|
-
}`}
|
|
250
|
+
})}`}
|
|
251
|
+
}`}
|
|
252
252
|
)`,
|
|
253
253
|
], '\n'),
|
|
254
254
|
});
|
|
@@ -97,15 +97,15 @@ class DefaultTypeScriptEasyNetworkStubGenerator extends file_generator_js_1.Type
|
|
|
97
97
|
],
|
|
98
98
|
returnType: 'this',
|
|
99
99
|
body: (0, core_1.appendValueGroup)([
|
|
100
|
-
(0, core_1.builderTemplate) `this.stubWrapper.stub2<${requestType}>()(${core_1.builderTemplate.indent `
|
|
101
|
-
${index_js_1.ts.string(endpoint.method.toUpperCase())},
|
|
102
|
-
${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
|
|
103
|
-
async (request) => {${core_1.builderTemplate.indent `
|
|
104
|
-
if (this.stubWrapper.options.rememberRequests) {${core_1.builderTemplate.indent `
|
|
105
|
-
this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.push(request);`}
|
|
106
|
-
}
|
|
107
|
-
throw await response(${this.getResponderVariableName(ctx, endpoint)}, request);`}
|
|
108
|
-
}`}
|
|
100
|
+
(0, core_1.builderTemplate) `this.stubWrapper.stub2<${requestType}>()(${core_1.builderTemplate.indent `
|
|
101
|
+
${index_js_1.ts.string(endpoint.method.toUpperCase())},
|
|
102
|
+
${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
|
|
103
|
+
async (request) => {${core_1.builderTemplate.indent `
|
|
104
|
+
if (this.stubWrapper.options.rememberRequests) {${core_1.builderTemplate.indent `
|
|
105
|
+
this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.push(request);`}
|
|
106
|
+
}
|
|
107
|
+
throw await response(${this.getResponderVariableName(ctx, endpoint)}, request);`}
|
|
108
|
+
}`}
|
|
109
109
|
);`,
|
|
110
110
|
'return this;',
|
|
111
111
|
], '\n'),
|
|
@@ -134,7 +134,7 @@ class DefaultTypeScriptFetchClientGenerator extends file_generator_js_1.TypeScri
|
|
|
134
134
|
const method = this.getInterfaceEndpointMethod(ctx, endpoint);
|
|
135
135
|
method.accessModifier = 'public';
|
|
136
136
|
method.body = (0, core_1.appendValueGroup)([
|
|
137
|
-
(0, core_1.builderTemplate) `const url = new ${ctx.refs.urlBuilder()}(this.options.baseUrl)${core_1.builderTemplate.indent `
|
|
137
|
+
(0, core_1.builderTemplate) `const url = new ${ctx.refs.urlBuilder()}(this.options.baseUrl)${core_1.builderTemplate.indent `
|
|
138
138
|
.withPath(${index_js_1.ts.string(endpoint.path)})${(b) => b.forEach(endpoint.parameters, (b, p) => {
|
|
139
139
|
switch (p.target) {
|
|
140
140
|
case 'path':
|
|
@@ -144,7 +144,7 @@ class DefaultTypeScriptFetchClientGenerator extends file_generator_js_1.TypeScri
|
|
|
144
144
|
b.append((0, core_1.builderTemplate) `\n.withQueryParam(${index_js_1.ts.string(p.name)}, params.${(0, core_1.toCasing)(p.name, ctx.config.paramNameCasing)})`);
|
|
145
145
|
break;
|
|
146
146
|
}
|
|
147
|
-
})}
|
|
147
|
+
})}
|
|
148
148
|
.build();`}`,
|
|
149
149
|
(0, core_1.builderTemplate) `const response = (this.options.fetch ?? fetch)(url, ${index_js_1.ts.object({
|
|
150
150
|
members: [
|
|
@@ -232,7 +232,7 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
232
232
|
index_js_1.ts.constructorParameter('rootUrl', { type: isJs ? undefined : rootUrlType }),
|
|
233
233
|
index_js_1.ts.constructorParameter('defaultK6ParamsFactory', { type: isJs ? undefined : paramType, optional: true }),
|
|
234
234
|
],
|
|
235
|
-
body: (0, core_1.builderTemplate) `this.rootUrl = rootUrl;
|
|
235
|
+
body: (0, core_1.builderTemplate) `this.rootUrl = rootUrl;
|
|
236
236
|
this._defaultK6ParamsFactory = defaultK6ParamsFactory;`,
|
|
237
237
|
}),
|
|
238
238
|
...ctx.service.endpoints.map((e) => this.getEndpointMethod(ctx, e)),
|
|
@@ -294,17 +294,17 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
294
294
|
: null,
|
|
295
295
|
'',
|
|
296
296
|
ctx.config.language === 'javascript'
|
|
297
|
-
? (0, core_1.builderTemplate) `return /** @type {${returnType}} */ (${core_1.builderTemplate.indent `
|
|
298
|
-
${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${core_1.builderTemplate.indent `
|
|
299
|
-
accept: ${index_js_1.ts.string(accept)},
|
|
300
|
-
params: this.getK6Params(k6Params),`}
|
|
301
|
-
})`}
|
|
297
|
+
? (0, core_1.builderTemplate) `return /** @type {${returnType}} */ (${core_1.builderTemplate.indent `
|
|
298
|
+
${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${core_1.builderTemplate.indent `
|
|
299
|
+
accept: ${index_js_1.ts.string(accept)},
|
|
300
|
+
params: this.getK6Params(k6Params),`}
|
|
301
|
+
})`}
|
|
302
302
|
);`
|
|
303
|
-
: (0, core_1.builderTemplate) `return (${core_1.builderTemplate.indent `
|
|
304
|
-
${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${core_1.builderTemplate.indent `
|
|
305
|
-
accept: ${index_js_1.ts.string(accept)},
|
|
306
|
-
params: this.getK6Params(k6Params),`}
|
|
307
|
-
})`}
|
|
303
|
+
: (0, core_1.builderTemplate) `return (${core_1.builderTemplate.indent `
|
|
304
|
+
${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${core_1.builderTemplate.indent `
|
|
305
|
+
accept: ${index_js_1.ts.string(accept)},
|
|
306
|
+
params: this.getK6Params(k6Params),`}
|
|
307
|
+
})`}
|
|
308
308
|
) as unknown as ${returnType};`,
|
|
309
309
|
], '\n'),
|
|
310
310
|
});
|