@goast/typescript 0.5.1 → 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.
Files changed (87) hide show
  1. package/LICENSE +21 -21
  2. package/assets/client/k6/request-builder.js +29 -4
  3. package/assets/client/k6/request-builder.ts +362 -341
  4. package/package.json +1 -1
  5. package/src/mod.ts +0 -7
  6. package/src/src/assets.ts +0 -9
  7. package/src/src/ast/_index.ts +0 -54
  8. package/src/src/ast/common.ts +0 -1
  9. package/src/src/ast/index.ts +0 -1
  10. package/src/src/ast/node.ts +0 -10
  11. package/src/src/ast/nodes/argument.ts +0 -40
  12. package/src/src/ast/nodes/array-type.ts +0 -49
  13. package/src/src/ast/nodes/arrow-function.ts +0 -91
  14. package/src/src/ast/nodes/call.ts +0 -55
  15. package/src/src/ast/nodes/class.ts +0 -133
  16. package/src/src/ast/nodes/constructor-parameter.ts +0 -70
  17. package/src/src/ast/nodes/constructor.ts +0 -77
  18. package/src/src/ast/nodes/decorator.ts +0 -76
  19. package/src/src/ast/nodes/doc-tag.ts +0 -291
  20. package/src/src/ast/nodes/doc.ts +0 -102
  21. package/src/src/ast/nodes/enum-value.ts +0 -72
  22. package/src/src/ast/nodes/enum.ts +0 -77
  23. package/src/src/ast/nodes/export.ts +0 -54
  24. package/src/src/ast/nodes/function-type.ts +0 -60
  25. package/src/src/ast/nodes/function.ts +0 -107
  26. package/src/src/ast/nodes/generic-parameter.ts +0 -71
  27. package/src/src/ast/nodes/indexer.ts +0 -60
  28. package/src/src/ast/nodes/interface.ts +0 -117
  29. package/src/src/ast/nodes/intersection-type.ts +0 -67
  30. package/src/src/ast/nodes/lookup-type.ts +0 -53
  31. package/src/src/ast/nodes/method.ts +0 -138
  32. package/src/src/ast/nodes/object-type.ts +0 -52
  33. package/src/src/ast/nodes/object.ts +0 -48
  34. package/src/src/ast/nodes/parameter.ts +0 -85
  35. package/src/src/ast/nodes/property-accessor.ts +0 -173
  36. package/src/src/ast/nodes/property.ts +0 -192
  37. package/src/src/ast/nodes/reference.ts +0 -194
  38. package/src/src/ast/nodes/string.ts +0 -49
  39. package/src/src/ast/nodes/tuple.ts +0 -53
  40. package/src/src/ast/nodes/type-alias.ts +0 -75
  41. package/src/src/ast/nodes/typeof.ts +0 -42
  42. package/src/src/ast/nodes/types.ts +0 -40
  43. package/src/src/ast/nodes/union-type.ts +0 -62
  44. package/src/src/ast/nodes/variable.ts +0 -73
  45. package/src/src/ast/references/angular.ts +0 -24
  46. package/src/src/ast/references/easy-network-stub.ts +0 -21
  47. package/src/src/ast/references/index.ts +0 -5
  48. package/src/src/ast/references/k6.ts +0 -8
  49. package/src/src/ast/references/rxjs.ts +0 -7
  50. package/src/src/ast/references/typescript.ts +0 -35
  51. package/src/src/ast/utils/get-type-script-builder-options.ts +0 -19
  52. package/src/src/ast/utils/to-ts-node.ts +0 -27
  53. package/src/src/ast/utils/write-ts-generic-parameters.ts +0 -25
  54. package/src/src/ast/utils/write-ts-members.ts +0 -28
  55. package/src/src/ast/utils/write-ts-nodes.ts +0 -35
  56. package/src/src/ast/utils/write-ts-parameters.ts +0 -25
  57. package/src/src/common-results.ts +0 -26
  58. package/src/src/config.ts +0 -89
  59. package/src/src/file-builder.ts +0 -136
  60. package/src/src/generators/file-generator.ts +0 -15
  61. package/src/src/generators/index.ts +0 -6
  62. package/src/src/generators/models/index.ts +0 -3
  63. package/src/src/generators/models/model-generator.ts +0 -469
  64. package/src/src/generators/models/models-generator.ts +0 -108
  65. package/src/src/generators/models/models.ts +0 -121
  66. package/src/src/generators/services/angular-services/angular-service-generator.ts +0 -406
  67. package/src/src/generators/services/angular-services/angular-services-generator.ts +0 -295
  68. package/src/src/generators/services/angular-services/index.ts +0 -3
  69. package/src/src/generators/services/angular-services/models.ts +0 -277
  70. package/src/src/generators/services/angular-services/refs.ts +0 -54
  71. package/src/src/generators/services/easy-network-stub/easy-network-stub-generator.ts +0 -242
  72. package/src/src/generators/services/easy-network-stub/easy-network-stubs-generator.ts +0 -211
  73. package/src/src/generators/services/easy-network-stub/index.ts +0 -3
  74. package/src/src/generators/services/easy-network-stub/models.ts +0 -124
  75. package/src/src/generators/services/easy-network-stub/refs.ts +0 -45
  76. package/src/src/generators/services/fetch-clients/fetch-client-generator.ts +0 -267
  77. package/src/src/generators/services/fetch-clients/fetch-clients-generator.ts +0 -163
  78. package/src/src/generators/services/fetch-clients/index.ts +0 -3
  79. package/src/src/generators/services/fetch-clients/models.ts +0 -130
  80. package/src/src/generators/services/fetch-clients/refs.ts +0 -21
  81. package/src/src/generators/services/k6-clients/index.ts +0 -3
  82. package/src/src/generators/services/k6-clients/k6-client-generator.ts +0 -465
  83. package/src/src/generators/services/k6-clients/k6-clients-generator.ts +0 -171
  84. package/src/src/generators/services/k6-clients/models.ts +0 -247
  85. package/src/src/generators/services/k6-clients/refs.ts +0 -16
  86. package/src/src/import-collection.ts +0 -236
  87. package/src/src/utils.ts +0 -72
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Marc Schmidt
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Marc Schmidt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,5 +1,6 @@
1
1
  // @ts-check
2
2
 
3
+ import { FormData } from 'https://jslib.k6.io/formdata/0.0.2/index.js';
3
4
  import http from 'k6/http';
4
5
 
5
6
  /**
@@ -322,6 +323,13 @@ export class RequestBuilder {
322
323
  }
323
324
  }
324
325
  this._bodyContent = pairs.map((p) => `${encodeURIComponent(p[0])}=${encodeURIComponent(p[1])}`).join('&');
326
+ } else if (this._bodyContentType === 'multipart/form-data' && value !== null && typeof value === 'object') {
327
+ const fd = new FormData();
328
+ for (const key in value) {
329
+ fd.append(key, this.formDataValue(value[key]));
330
+ }
331
+ this._bodyContent = fd.body();
332
+ this._bodyContentType = 'multipart/form-data; boundary=' + fd.boundary;
325
333
  } else if (this._bodyContentType.indexOf('json') !== -1 && value !== null && typeof value === 'object') {
326
334
  this._bodyContent = JSON.stringify(value);
327
335
  } else {
@@ -339,10 +347,27 @@ export class RequestBuilder {
339
347
  if (value === null || value === undefined) {
340
348
  return null;
341
349
  }
342
- if (typeof value === 'object') {
343
- return JSON.stringify(value);
350
+ if (this.isFile(value)) {
351
+ return value;
344
352
  }
345
- return String(value);
353
+ return { data: JSON.stringify(value), content_type: 'application/json' };
354
+ }
355
+
356
+ /**
357
+ * @private
358
+ * @param {*} value
359
+ * @returns {boolean}
360
+ */
361
+ isFile(value) {
362
+ return (
363
+ typeof value === 'object' &&
364
+ value !== null &&
365
+ 'data' in value &&
366
+ (typeof value.data === 'string' || value.data instanceof ArrayBuffer) &&
367
+ (!('filename' in value) || typeof value.filename === 'string') &&
368
+ (!('content_type' in value) || typeof value.content_type === 'string') &&
369
+ Object.keys(value).every((key) => key === 'data' || key === 'filename' || key === 'content_type')
370
+ );
346
371
  }
347
372
 
348
373
  /**
@@ -403,7 +428,7 @@ export class RequestBuilder {
403
428
  }
404
429
 
405
430
  // Request content headers
406
- if (this._bodyContentType && this._bodyContentType !== 'multipart/form-data') {
431
+ if (this._bodyContentType) {
407
432
  httpHeaders['Content-Type'] = this._bodyContentType;
408
433
  }
409
434