@api-client/core 0.3.4 → 0.3.7

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 (109) hide show
  1. package/build/browser.d.ts +6 -0
  2. package/build/browser.js +15 -0
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +14 -2
  5. package/build/index.js +26 -2
  6. package/build/index.js.map +1 -1
  7. package/build/src/lib/calculators/DataCalculator.d.ts +27 -0
  8. package/build/src/lib/calculators/DataCalculator.js +88 -0
  9. package/build/src/lib/calculators/DataCalculator.js.map +1 -0
  10. package/build/src/lib/fs/Fs.d.ts +52 -0
  11. package/build/src/lib/fs/Fs.js +245 -0
  12. package/build/src/lib/fs/Fs.js.map +1 -0
  13. package/build/src/lib/parsers/UrlEncoder.d.ts +51 -0
  14. package/build/src/lib/parsers/UrlEncoder.js +74 -0
  15. package/build/src/lib/parsers/UrlEncoder.js.map +1 -0
  16. package/build/src/lib/parsers/UrlParser.d.ts +104 -0
  17. package/build/src/lib/parsers/UrlParser.js +189 -0
  18. package/build/src/lib/parsers/UrlParser.js.map +1 -0
  19. package/build/src/lib/parsers/UrlValueParser.d.ts +92 -0
  20. package/build/src/lib/parsers/UrlValueParser.js +172 -0
  21. package/build/src/lib/parsers/UrlValueParser.js.map +1 -0
  22. package/build/src/lib/timers/Timers.d.ts +5 -0
  23. package/build/src/lib/timers/Timers.js +10 -0
  24. package/build/src/lib/timers/Timers.js.map +1 -0
  25. package/build/src/mocking/ProjectMock.d.ts +13 -0
  26. package/build/src/mocking/ProjectMock.js +16 -0
  27. package/build/src/mocking/ProjectMock.js.map +1 -0
  28. package/build/src/mocking/lib/Request.d.ts +32 -0
  29. package/build/src/mocking/lib/Request.js +63 -0
  30. package/build/src/mocking/lib/Request.js.map +1 -0
  31. package/build/src/mocking/lib/Response.d.ts +33 -0
  32. package/build/src/mocking/lib/Response.js +79 -0
  33. package/build/src/mocking/lib/Response.js.map +1 -0
  34. package/build/src/models/ErrorResponse.d.ts +5 -4
  35. package/build/src/models/ErrorResponse.js +18 -5
  36. package/build/src/models/ErrorResponse.js.map +1 -1
  37. package/build/src/models/SerializableError.d.ts +30 -0
  38. package/build/src/models/SerializableError.js +63 -0
  39. package/build/src/models/SerializableError.js.map +1 -0
  40. package/build/src/runtime/http-engine/ArcEngine.js +8 -4
  41. package/build/src/runtime/http-engine/ArcEngine.js.map +1 -1
  42. package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
  43. package/build/src/runtime/http-engine/HttpEngine.js +3 -3
  44. package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
  45. package/build/src/runtime/http-engine/NodeEngine.js +9 -4
  46. package/build/src/runtime/http-engine/NodeEngine.js.map +1 -1
  47. package/build/src/runtime/http-engine/NodeEngineDirect.js +8 -2
  48. package/build/src/runtime/http-engine/NodeEngineDirect.js.map +1 -1
  49. package/build/src/runtime/node/BaseRunner.d.ts +21 -0
  50. package/build/src/runtime/node/BaseRunner.js +27 -0
  51. package/build/src/runtime/node/BaseRunner.js.map +1 -0
  52. package/build/src/runtime/node/ProjectParallelRunner.d.ts +81 -0
  53. package/build/src/runtime/node/ProjectParallelRunner.js +173 -0
  54. package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -0
  55. package/build/src/runtime/node/ProjectRequestRunner.d.ts +125 -0
  56. package/build/src/runtime/node/ProjectRequestRunner.js +185 -0
  57. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -0
  58. package/build/src/runtime/node/ProjectRunner.d.ts +166 -64
  59. package/build/src/runtime/node/ProjectRunner.js +191 -139
  60. package/build/src/runtime/node/ProjectRunner.js.map +1 -1
  61. package/build/src/runtime/node/ProjectRunnerWorker.d.ts +1 -0
  62. package/build/src/runtime/node/ProjectRunnerWorker.js +58 -0
  63. package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -0
  64. package/build/src/runtime/node/ProjectSerialRunner.d.ts +11 -0
  65. package/build/src/runtime/node/ProjectSerialRunner.js +34 -0
  66. package/build/src/runtime/node/ProjectSerialRunner.js.map +1 -0
  67. package/build/src/runtime/reporters/ProjectRunCliReporter.d.ts +7 -0
  68. package/build/src/runtime/reporters/ProjectRunCliReporter.js +73 -0
  69. package/build/src/runtime/reporters/ProjectRunCliReporter.js.map +1 -0
  70. package/build/src/runtime/reporters/Reporter.d.ts +62 -0
  71. package/build/src/runtime/reporters/Reporter.js +98 -0
  72. package/build/src/runtime/reporters/Reporter.js.map +1 -0
  73. package/build/src/testing/TestCliHelper.d.ts +29 -0
  74. package/build/src/testing/TestCliHelper.js +80 -0
  75. package/build/src/testing/TestCliHelper.js.map +1 -0
  76. package/build/src/testing/getPort.d.ts +52 -0
  77. package/build/src/testing/getPort.js +169 -0
  78. package/build/src/testing/getPort.js.map +1 -0
  79. package/package.json +2 -1
  80. package/src/lib/calculators/DataCalculator.ts +91 -0
  81. package/src/lib/fs/Fs.ts +258 -0
  82. package/src/lib/parsers/UrlEncoder.ts +74 -0
  83. package/src/lib/parsers/UrlParser.ts +201 -0
  84. package/src/lib/parsers/UrlValueParser.ts +211 -0
  85. package/src/lib/timers/Timers.ts +9 -0
  86. package/src/mocking/LegacyInterfaces.ts +1 -1
  87. package/src/mocking/ProjectMock.ts +20 -0
  88. package/src/mocking/lib/Request.ts +85 -0
  89. package/src/mocking/lib/Response.ts +101 -0
  90. package/src/models/ErrorResponse.ts +20 -8
  91. package/src/models/SerializableError.ts +80 -0
  92. package/src/runtime/http-engine/ArcEngine.ts +8 -4
  93. package/src/runtime/http-engine/HttpEngine.ts +5 -5
  94. package/src/runtime/http-engine/NodeEngine.ts +10 -5
  95. package/src/runtime/http-engine/NodeEngineDirect.ts +9 -3
  96. package/src/runtime/node/BaseRunner.ts +29 -0
  97. package/src/runtime/node/ProjectParallelRunner.ts +234 -0
  98. package/src/runtime/node/ProjectRequestRunner.ts +281 -0
  99. package/src/runtime/node/ProjectRunner.ts +281 -182
  100. package/src/runtime/node/ProjectRunnerWorker.ts +62 -0
  101. package/src/runtime/node/ProjectSerialRunner.ts +36 -0
  102. package/src/runtime/reporters/ProjectRunCliReporter.ts +79 -0
  103. package/src/runtime/reporters/Reporter.ts +142 -0
  104. package/src/testing/TestCliHelper.ts +87 -0
  105. package/src/testing/getPort.ts +212 -0
  106. package/build/src/runtime/http-engine/Errors.d.ts +0 -10
  107. package/build/src/runtime/http-engine/Errors.js +0 -14
  108. package/build/src/runtime/http-engine/Errors.js.map +0 -1
  109. package/src/runtime/http-engine/Errors.ts +0 -13
@@ -0,0 +1,51 @@
1
+ export declare class UrlEncoder {
2
+ /**
3
+ * Returns a string where all characters that are not valid for a URL
4
+ * component have been escaped. The escaping of a character is done by
5
+ * converting it into its UTF-8 encoding and then encoding each of the
6
+ * resulting bytes as a %xx hexadecimal escape sequence.
7
+ * <p>
8
+ * Note: this method will convert any the space character into its escape
9
+ * short form, '+' rather than %20. It should therefore only be used for
10
+ * query-string parts.
11
+ *
12
+ * <p>
13
+ * The following character sets are <em>not</em> escaped by this method:
14
+ * <ul>
15
+ * <li>ASCII digits or letters</li>
16
+ * <li>ASCII punctuation characters:
17
+ *
18
+ * <pre>- _ . ! ~ * ' ( )</pre>
19
+ * </li>
20
+ * </ul>
21
+ * </p>
22
+ *
23
+ * <p>
24
+ * Notice that this method <em>does</em> encode the URL component delimiter
25
+ * characters:<blockquote>
26
+ *
27
+ * <pre>
28
+ * ; / ? : &amp; = + $ , #
29
+ * </pre>
30
+ *
31
+ * </blockquote>
32
+ * </p>
33
+ *
34
+ * @param str A string containing invalid URL characters
35
+ * @param replacePlus When set it replaces `%20` with `+`.
36
+ * @returns a string with all invalid URL characters escaped
37
+ */
38
+ static encodeQueryString(str: string, replacePlus?: boolean): string;
39
+ /**
40
+ * Returns a string where all URL component escape sequences have been
41
+ * converted back to their original character representations.
42
+ *
43
+ * Note: this method will convert the space character escape short form, '+',
44
+ * into a space. It should therefore only be used for query-string parts.
45
+ *
46
+ * @param str A string containing encoded URL component sequences
47
+ * @param replacePlus When set it replaces `+` with `%20`.
48
+ * @returns string with no encoded URL component encoded sequences
49
+ */
50
+ static decodeQueryString(str: string, replacePlus?: boolean): string;
51
+ }
@@ -0,0 +1,74 @@
1
+ export class UrlEncoder {
2
+ /**
3
+ * Returns a string where all characters that are not valid for a URL
4
+ * component have been escaped. The escaping of a character is done by
5
+ * converting it into its UTF-8 encoding and then encoding each of the
6
+ * resulting bytes as a %xx hexadecimal escape sequence.
7
+ * <p>
8
+ * Note: this method will convert any the space character into its escape
9
+ * short form, '+' rather than %20. It should therefore only be used for
10
+ * query-string parts.
11
+ *
12
+ * <p>
13
+ * The following character sets are <em>not</em> escaped by this method:
14
+ * <ul>
15
+ * <li>ASCII digits or letters</li>
16
+ * <li>ASCII punctuation characters:
17
+ *
18
+ * <pre>- _ . ! ~ * ' ( )</pre>
19
+ * </li>
20
+ * </ul>
21
+ * </p>
22
+ *
23
+ * <p>
24
+ * Notice that this method <em>does</em> encode the URL component delimiter
25
+ * characters:<blockquote>
26
+ *
27
+ * <pre>
28
+ * ; / ? : &amp; = + $ , #
29
+ * </pre>
30
+ *
31
+ * </blockquote>
32
+ * </p>
33
+ *
34
+ * @param str A string containing invalid URL characters
35
+ * @param replacePlus When set it replaces `%20` with `+`.
36
+ * @returns a string with all invalid URL characters escaped
37
+ */
38
+ static encodeQueryString(str, replacePlus) {
39
+ if (!str) {
40
+ return str;
41
+ }
42
+ // normalize
43
+ let result = str.toString().replace(/\r?\n/g, "\r\n");
44
+ // encode
45
+ result = encodeURIComponent(result);
46
+ if (replacePlus) {
47
+ // replace "%20" with "+" when needed
48
+ result = result.replace(/%20/g, "+");
49
+ }
50
+ return result;
51
+ }
52
+ /**
53
+ * Returns a string where all URL component escape sequences have been
54
+ * converted back to their original character representations.
55
+ *
56
+ * Note: this method will convert the space character escape short form, '+',
57
+ * into a space. It should therefore only be used for query-string parts.
58
+ *
59
+ * @param str A string containing encoded URL component sequences
60
+ * @param replacePlus When set it replaces `+` with `%20`.
61
+ * @returns string with no encoded URL component encoded sequences
62
+ */
63
+ static decodeQueryString(str, replacePlus) {
64
+ if (!str) {
65
+ return str;
66
+ }
67
+ let result = str;
68
+ if (replacePlus) {
69
+ result = str.replace(/\+/g, "%20");
70
+ }
71
+ return decodeURIComponent(result);
72
+ }
73
+ }
74
+ //# sourceMappingURL=UrlEncoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UrlEncoder.js","sourceRoot":"","sources":["../../../../src/lib/parsers/UrlEncoder.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAU;IACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAW,EAAE,WAAqB;QACzD,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,GAAG,CAAC;SACZ;QACD,YAAY;QACZ,IAAI,MAAM,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACtD,SAAS;QACT,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,WAAW,EAAE;YACf,qCAAqC;YACrC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SACtC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAW,EAAE,WAAqB;QACzD,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,GAAG,CAAC;SACZ;QACD,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,IAAI,WAAW,EAAE;YACf,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;SACpC;QACD,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,104 @@
1
+ import { UrlValueParser, IUrlValueParserOptions } from './UrlValueParser.js';
2
+ /**
3
+ * A class to parse URL string.
4
+ */
5
+ export declare class UrlParser extends UrlValueParser {
6
+ /**
7
+ * @param value The URL value
8
+ */
9
+ constructor(value: string, opts?: IUrlValueParserOptions);
10
+ /**
11
+ * Returns protocol value in format `protocol` + ':'
12
+ *
13
+ * @return The value of the protocol or `undefined` if the value is not set
14
+ */
15
+ get protocol(): string | undefined;
16
+ /**
17
+ * Sets value of the `protocol`
18
+ *
19
+ * @param value Protocol value.
20
+ */
21
+ set protocol(value: string | undefined);
22
+ /**
23
+ * It reads the authority part of the URL value. It doesn't parses it
24
+ * to host, port and credentials parts.
25
+ *
26
+ * @return The value of the host or `undefined` if the value is not set
27
+ */
28
+ get host(): string | undefined;
29
+ /**
30
+ * Sets value of the `host`
31
+ *
32
+ * @param value Host value.
33
+ */
34
+ set host(value: string | undefined);
35
+ /**
36
+ * Returns path part of the URL.
37
+ *
38
+ * @returns The value of the path or `undefined` if the value not set
39
+ */
40
+ get path(): string | undefined;
41
+ /**
42
+ * Sets value of the `path`
43
+ *
44
+ * @param value Path value.
45
+ */
46
+ set path(value: string | undefined);
47
+ /**
48
+ * Returns anchor part of the URL.
49
+ *
50
+ * @returns The value of the anchor or `undefined` if the value not set
51
+ */
52
+ get anchor(): string | undefined;
53
+ /**
54
+ * Sets value of the `anchor`
55
+ *
56
+ * @param value The anchor value.
57
+ */
58
+ set anchor(value: string | undefined);
59
+ /**
60
+ * Returns search part of the URL.
61
+ *
62
+ * @returns the value of the search or `undefined` if the value not set
63
+ */
64
+ get search(): string | undefined;
65
+ /**
66
+ * Sets value of the `search`
67
+ *
68
+ * @param value Search value.
69
+ */
70
+ set search(value: string | undefined);
71
+ /**
72
+ * The URL value. It is the same as calling `toString()`.
73
+ *
74
+ * @return The URL value for current configuration.
75
+ */
76
+ get value(): string;
77
+ /**
78
+ * Sets value of the URL.
79
+ * It parses the url and sets properties.
80
+ *
81
+ * @param value The URL value.
82
+ */
83
+ set value(value: string);
84
+ /**
85
+ * Returns an array of search params.
86
+ *
87
+ * @returns The list of search params. Each item contains an
88
+ * array where the first item is the name of the parameter and the second item is the
89
+ * value.
90
+ */
91
+ get searchParams(): string[][];
92
+ /**
93
+ * Sets the value of `search` and `searchParams`.
94
+ *
95
+ * @param value Search params list.
96
+ */
97
+ set searchParams(value: string[][]);
98
+ /**
99
+ * Returns the URL for current settings.
100
+ *
101
+ * @return The URL value.
102
+ */
103
+ toString(): string;
104
+ }
@@ -0,0 +1,189 @@
1
+ import { UrlValueParser } from './UrlValueParser.js';
2
+ /**
3
+ * A class to parse URL string.
4
+ */
5
+ export class UrlParser extends UrlValueParser {
6
+ /**
7
+ * @param value The URL value
8
+ */
9
+ constructor(value, opts) {
10
+ super(opts);
11
+ this.value = value;
12
+ }
13
+ /**
14
+ * Returns protocol value in format `protocol` + ':'
15
+ *
16
+ * @return The value of the protocol or `undefined` if the value is not set
17
+ */
18
+ get protocol() {
19
+ return this.__data.protocol;
20
+ }
21
+ /**
22
+ * Sets value of the `protocol`
23
+ *
24
+ * @param value Protocol value.
25
+ */
26
+ set protocol(value) {
27
+ this.__data.protocol = value;
28
+ }
29
+ /**
30
+ * It reads the authority part of the URL value. It doesn't parses it
31
+ * to host, port and credentials parts.
32
+ *
33
+ * @return The value of the host or `undefined` if the value is not set
34
+ */
35
+ get host() {
36
+ return this.__data.host;
37
+ }
38
+ /**
39
+ * Sets value of the `host`
40
+ *
41
+ * @param value Host value.
42
+ */
43
+ set host(value) {
44
+ this.__data.host = value;
45
+ }
46
+ /**
47
+ * Returns path part of the URL.
48
+ *
49
+ * @returns The value of the path or `undefined` if the value not set
50
+ */
51
+ get path() {
52
+ return this.__data.path || '/';
53
+ }
54
+ /**
55
+ * Sets value of the `path`
56
+ *
57
+ * @param value Path value.
58
+ */
59
+ set path(value) {
60
+ this.__data.path = value;
61
+ }
62
+ /**
63
+ * Returns anchor part of the URL.
64
+ *
65
+ * @returns The value of the anchor or `undefined` if the value not set
66
+ */
67
+ get anchor() {
68
+ return this.__data.anchor;
69
+ }
70
+ /**
71
+ * Sets value of the `anchor`
72
+ *
73
+ * @param value The anchor value.
74
+ */
75
+ set anchor(value) {
76
+ this.__data.anchor = value;
77
+ }
78
+ /**
79
+ * Returns search part of the URL.
80
+ *
81
+ * @returns the value of the search or `undefined` if the value not set
82
+ */
83
+ get search() {
84
+ return this.__data.search;
85
+ }
86
+ /**
87
+ * Sets value of the `search`
88
+ *
89
+ * @param value Search value.
90
+ */
91
+ set search(value) {
92
+ this.__data.search = value;
93
+ }
94
+ /**
95
+ * The URL value. It is the same as calling `toString()`.
96
+ *
97
+ * @return The URL value for current configuration.
98
+ */
99
+ get value() {
100
+ return this.toString();
101
+ }
102
+ /**
103
+ * Sets value of the URL.
104
+ * It parses the url and sets properties.
105
+ *
106
+ * @param value The URL value.
107
+ */
108
+ set value(value) {
109
+ this.protocol = this._parseProtocol(value);
110
+ this.host = this._parseHost(value);
111
+ this.path = this._parsePath(value);
112
+ this.anchor = this._parseAnchor(value);
113
+ this.search = this._parseSearch(value);
114
+ }
115
+ /**
116
+ * Returns an array of search params.
117
+ *
118
+ * @returns The list of search params. Each item contains an
119
+ * array where the first item is the name of the parameter and the second item is the
120
+ * value.
121
+ */
122
+ get searchParams() {
123
+ return this._parseSearchParams(this.search);
124
+ }
125
+ /**
126
+ * Sets the value of `search` and `searchParams`.
127
+ *
128
+ * @param value Search params list.
129
+ */
130
+ set searchParams(value) {
131
+ if (!value || !value.length) {
132
+ this.search = undefined;
133
+ return;
134
+ }
135
+ this.search = value.map((item) => {
136
+ let itemValue = item[1];
137
+ if (!item[0] && !itemValue) {
138
+ return '';
139
+ }
140
+ if (itemValue === undefined) {
141
+ itemValue = '';
142
+ }
143
+ else if (typeof itemValue !== 'string') {
144
+ itemValue = String(itemValue);
145
+ }
146
+ return `${item[0]}=${itemValue}`;
147
+ })
148
+ .join(this.opts.queryDelimiter);
149
+ }
150
+ /**
151
+ * Returns the URL for current settings.
152
+ *
153
+ * @return The URL value.
154
+ */
155
+ toString() {
156
+ let result = '';
157
+ if (this.protocol) {
158
+ result += this.protocol;
159
+ result += '//';
160
+ }
161
+ if (this.host) {
162
+ result += this.host;
163
+ }
164
+ if (this.path) {
165
+ if (this.path === '/' && !this.host && !this.search && !this.anchor) {
166
+ // ???
167
+ }
168
+ else {
169
+ if (this.path[0] !== '/') {
170
+ result += '/';
171
+ }
172
+ result += this.path;
173
+ }
174
+ }
175
+ else if (this.search || this.anchor) {
176
+ result += '/';
177
+ }
178
+ if (this.search) {
179
+ const p = this.searchParams;
180
+ this.searchParams = p;
181
+ result += `?${this.search}`;
182
+ }
183
+ if (this.anchor) {
184
+ result += `#${this.anchor}`;
185
+ }
186
+ return result;
187
+ }
188
+ }
189
+ //# sourceMappingURL=UrlParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UrlParser.js","sourceRoot":"","sources":["../../../../src/lib/parsers/UrlParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA0B,MAAM,qBAAqB,CAAC;AAE7E;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,cAAc;IAC3C;;OAEG;IACH,YAAY,KAAa,EAAE,IAA6B;QACtD,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,IAAI,QAAQ,CAAC,KAAyB;QACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI,CAAC,KAAyB;QAChC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,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GAAG,CAAC;iBACf;gBACD,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC;aACrB;SACF;aAAM,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE;YACnC,MAAM,IAAI,GAAG,CAAC;SACf;QACH,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;YAC5B,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;YACtB,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;SAC7B;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;SAC7B;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,92 @@
1
+ export interface IUrlValueParserOptions {
2
+ /**
3
+ * A query string delimiter to use when processing query parameters.
4
+ */
5
+ queryDelimiter?: string;
6
+ }
7
+ interface DataValues {
8
+ /**
9
+ * A protocol value in format `protocol` + ':'
10
+ */
11
+ protocol?: string;
12
+ /**
13
+ * The authority part of the URL value
14
+ */
15
+ host?: string;
16
+ /**
17
+ * Path part of the URL.
18
+ */
19
+ path?: string;
20
+ /**
21
+ * Anchor part of the URL.
22
+ */
23
+ anchor?: string;
24
+ /**
25
+ * Search part of the URL.
26
+ */
27
+ search?: string;
28
+ opts?: IUrlValueParserOptions | undefined;
29
+ }
30
+ /**
31
+ * Implements logic for parsing URL string.
32
+ */
33
+ export declare class UrlValueParser {
34
+ protected __data: DataValues;
35
+ constructor(opts?: IUrlValueParserOptions);
36
+ /**
37
+ * @returns Class options.
38
+ */
39
+ get opts(): IUrlValueParserOptions;
40
+ /**
41
+ * Sets parser options.
42
+ * Unknown options are ignored.
43
+ */
44
+ set opts(opts: IUrlValueParserOptions | undefined);
45
+ /**
46
+ * Returns protocol value in format `protocol` + ':'
47
+ *
48
+ * @param value URL to parse.
49
+ * @return Value of the protocol or undefined if value not set
50
+ */
51
+ protected _parseProtocol(value: string): string | undefined;
52
+ /**
53
+ * Gets a host value from the url.
54
+ * It reads the whole authority value of given `value`. It doesn't parses it
55
+ * to host, port and
56
+ * credentials parts. For URL panel it's enough.
57
+ *
58
+ * @param value The URL to parse
59
+ * @return Value of the host or undefined.
60
+ */
61
+ protected _parseHost(value: string): string | undefined;
62
+ /**
63
+ * Parses the path part of the URL.
64
+ *
65
+ * @param value URL value
66
+ * @returns Path part of the URL
67
+ */
68
+ protected _parsePath(value: string): string | undefined;
69
+ /**
70
+ * Returns query parameters string (without the '?' sign) as a whole.
71
+ *
72
+ * @param value The URL to parse
73
+ * @returns Value of the search string or undefined.
74
+ */
75
+ protected _parseSearch(value: string): string | undefined;
76
+ /**
77
+ * Reads a value of the anchor (or hash) parameter without the `#` sign.
78
+ *
79
+ * @param value The URL to parse
80
+ * @returns Value of the anchor (hash) or undefined.
81
+ */
82
+ protected _parseAnchor(value: string): string | undefined;
83
+ /**
84
+ * Returns an array of items where each item is an array where first
85
+ * item is param name and second is it's value. Both always strings.
86
+ *
87
+ * @param search Parsed search parameter
88
+ * @returns Always returns an array.
89
+ */
90
+ protected _parseSearchParams(search?: string): string[][];
91
+ }
92
+ export {};
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Implements logic for parsing URL string.
3
+ */
4
+ export class UrlValueParser {
5
+ __data;
6
+ constructor(opts) {
7
+ this.__data = {};
8
+ this.opts = opts;
9
+ }
10
+ /**
11
+ * @returns Class options.
12
+ */
13
+ get opts() {
14
+ return this.__data.opts || {
15
+ queryDelimiter: '&',
16
+ };
17
+ }
18
+ /**
19
+ * Sets parser options.
20
+ * Unknown options are ignored.
21
+ */
22
+ set opts(opts) {
23
+ const options = (opts || {});
24
+ this.__data.opts = {
25
+ queryDelimiter: options.queryDelimiter || '&'
26
+ };
27
+ }
28
+ /**
29
+ * Returns protocol value in format `protocol` + ':'
30
+ *
31
+ * @param value URL to parse.
32
+ * @return Value of the protocol or undefined if value not set
33
+ */
34
+ _parseProtocol(value) {
35
+ if (!value) {
36
+ return undefined;
37
+ }
38
+ const delimiterIndex = value.indexOf('://');
39
+ if (delimiterIndex !== -1) {
40
+ return value.substring(0, delimiterIndex + 1);
41
+ }
42
+ return undefined;
43
+ }
44
+ /**
45
+ * Gets a host value from the url.
46
+ * It reads the whole authority value of given `value`. It doesn't parses it
47
+ * to host, port and
48
+ * credentials parts. For URL panel it's enough.
49
+ *
50
+ * @param value The URL to parse
51
+ * @return Value of the host or undefined.
52
+ */
53
+ _parseHost(value) {
54
+ if (!value) {
55
+ return undefined;
56
+ }
57
+ let result = value;
58
+ const delimiterIndex = result.indexOf('://');
59
+ if (delimiterIndex !== -1) {
60
+ result = result.substring(delimiterIndex + 3);
61
+ }
62
+ if (!result) {
63
+ return undefined;
64
+ }
65
+ // We don't need specifics here (username, password, port)
66
+ const host = result.split('/')[0];
67
+ return host;
68
+ }
69
+ /**
70
+ * Parses the path part of the URL.
71
+ *
72
+ * @param value URL value
73
+ * @returns Path part of the URL
74
+ */
75
+ _parsePath(value) {
76
+ if (!value) {
77
+ return undefined;
78
+ }
79
+ let result = value;
80
+ const isBasePath = result[0] === '/';
81
+ if (!isBasePath) {
82
+ const index = result.indexOf('://');
83
+ if (index !== -1) {
84
+ result = result.substring(index + 3);
85
+ }
86
+ }
87
+ let index = result.indexOf('?');
88
+ if (index !== -1) {
89
+ result = result.substring(0, index);
90
+ }
91
+ index = result.indexOf('#');
92
+ if (index !== -1) {
93
+ result = result.substring(0, index);
94
+ }
95
+ const lastIsSlash = result[result.length - 1] === '/';
96
+ const parts = result.split('/').filter((part) => !!part);
97
+ if (!isBasePath) {
98
+ parts.shift();
99
+ }
100
+ let path = `/${parts.join('/')}`;
101
+ if (lastIsSlash && parts.length > 1) {
102
+ path += '/';
103
+ }
104
+ return path;
105
+ }
106
+ /**
107
+ * Returns query parameters string (without the '?' sign) as a whole.
108
+ *
109
+ * @param value The URL to parse
110
+ * @returns Value of the search string or undefined.
111
+ */
112
+ _parseSearch(value) {
113
+ if (!value) {
114
+ return undefined;
115
+ }
116
+ let index = value.indexOf('?');
117
+ if (index === -1) {
118
+ return undefined;
119
+ }
120
+ const result = value.substring(index + 1);
121
+ index = result.indexOf('#');
122
+ if (index === -1) {
123
+ return result;
124
+ }
125
+ return result.substring(0, index);
126
+ }
127
+ /**
128
+ * Reads a value of the anchor (or hash) parameter without the `#` sign.
129
+ *
130
+ * @param value The URL to parse
131
+ * @returns Value of the anchor (hash) or undefined.
132
+ */
133
+ _parseAnchor(value) {
134
+ if (!value) {
135
+ return undefined;
136
+ }
137
+ const index = value.indexOf('#');
138
+ if (index === -1) {
139
+ return undefined;
140
+ }
141
+ return value.substring(index + 1);
142
+ }
143
+ /**
144
+ * Returns an array of items where each item is an array where first
145
+ * item is param name and second is it's value. Both always strings.
146
+ *
147
+ * @param search Parsed search parameter
148
+ * @returns Always returns an array.
149
+ */
150
+ _parseSearchParams(search) {
151
+ const result = [];
152
+ if (!search) {
153
+ return result;
154
+ }
155
+ const parts = search.split(this.opts.queryDelimiter);
156
+ parts.forEach((item) => {
157
+ const _part = ['', ''];
158
+ const _params = item.split('=');
159
+ let _name = _params.shift();
160
+ if (!_name && _name !== '') {
161
+ return;
162
+ }
163
+ _name = _name.trim();
164
+ const _value = _params.join('=').trim();
165
+ _part[0] = _name;
166
+ _part[1] = _value;
167
+ result.push(_part);
168
+ });
169
+ return result;
170
+ }
171
+ }
172
+ //# sourceMappingURL=UrlValueParser.js.map