@ama-sdk/core 13.0.0-next.0 → 13.0.0-next.10
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 +1 -7
- package/cjs/fwk/mocks/helpers.js +2 -1
- package/cjs/plugins/core/index.js +0 -1
- package/cjs/plugins/index.js +1 -7
- package/cjs/plugins/mock-intercept/index.js +0 -1
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +0 -192
- package/cjs/plugins/{abort → open-telemetry}/index.js +1 -1
- package/cjs/plugins/{keepalive → open-telemetry/traceparent}/index.js +3 -1
- package/cjs/plugins/open-telemetry/traceparent/interfaces.js +18 -0
- package/cjs/plugins/open-telemetry/traceparent/open-telemetry.traceparent.reply.js +234 -0
- package/cjs/plugins/open-telemetry/traceparent/open-telemetry.traceparent.reply.spec.js +550 -0
- package/cjs/plugins/open-telemetry/traceparent/open-telemetry.traceparent.request.js +146 -0
- package/cjs/plugins/{retry/retry.spec.js → open-telemetry/traceparent/open-telemetry.traceparent.request.spec.js} +119 -130
- package/cjs/public_api.js +0 -1
- package/cjs/utils/index.js +1 -0
- package/cjs/{plugins/concurrent → utils/perf}/index.js +1 -1
- package/cjs/{plugins/perf-metric/perf-metric.probe.spec.js → utils/perf/perf-metric.serivce.spec.js} +3 -3
- package/cjs/{plugins/perf-metric/perf-metric.fetch.js → utils/perf/perf-metric.service.js} +7 -181
- package/esm2015/fwk/mocks/helpers.js +5 -2
- package/esm2015/plugins/core/index.js +0 -1
- package/esm2015/plugins/index.js +1 -7
- package/esm2015/plugins/mock-intercept/index.js +0 -1
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +1 -193
- package/esm2015/plugins/open-telemetry/index.js +1 -0
- package/esm2015/plugins/open-telemetry/traceparent/index.js +3 -0
- package/esm2015/plugins/open-telemetry/traceparent/interfaces.js +8 -0
- package/esm2015/plugins/open-telemetry/traceparent/open-telemetry.traceparent.reply.js +225 -0
- package/esm2015/plugins/open-telemetry/traceparent/open-telemetry.traceparent.reply.spec.js +546 -0
- package/esm2015/plugins/open-telemetry/traceparent/open-telemetry.traceparent.request.js +139 -0
- package/esm2015/plugins/{retry/retry.spec.js → open-telemetry/traceparent/open-telemetry.traceparent.request.spec.js} +119 -130
- package/esm2015/public_api.js +0 -1
- package/esm2015/utils/index.js +1 -0
- package/esm2015/utils/perf/index.js +1 -0
- package/esm2015/{plugins/perf-metric/perf-metric.probe.spec.js → utils/perf/perf-metric.serivce.spec.js} +3 -3
- package/esm2015/{plugins/perf-metric/perf-metric.fetch.js → utils/perf/perf-metric.service.js} +5 -180
- package/package.json +23 -74
- package/src/fwk/mocks/helpers.d.ts +3 -1
- package/src/fwk/mocks/helpers.d.ts.map +1 -1
- package/src/fwk/mocks/helpers.js +5 -2
- package/src/fwk/mocks/helpers.js.map +1 -1
- package/src/fwk/mocks/path-object.d.ts +3 -1
- package/src/fwk/mocks/path-object.d.ts.map +1 -1
- package/src/plugins/core/index.d.ts +0 -1
- package/src/plugins/core/index.d.ts.map +1 -1
- package/src/plugins/core/index.js +0 -1
- package/src/plugins/core/index.js.map +1 -1
- package/src/plugins/index.d.ts +1 -7
- package/src/plugins/index.d.ts.map +1 -1
- package/src/plugins/index.js +1 -7
- package/src/plugins/index.js.map +1 -1
- package/src/plugins/mock-intercept/index.d.ts +0 -1
- package/src/plugins/mock-intercept/index.d.ts.map +1 -1
- package/src/plugins/mock-intercept/index.js +0 -1
- package/src/plugins/mock-intercept/index.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts +1 -11
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.interface.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.d.ts +2 -2
- package/src/plugins/mock-intercept/mock-intercept.request.d.ts.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.js.map +1 -1
- package/src/plugins/open-telemetry/index.d.ts +2 -0
- package/src/plugins/open-telemetry/index.d.ts.map +1 -0
- package/src/plugins/open-telemetry/index.js +2 -0
- package/src/plugins/open-telemetry/index.js.map +1 -0
- package/src/plugins/open-telemetry/traceparent/index.d.ts +4 -0
- package/src/plugins/open-telemetry/traceparent/index.d.ts.map +1 -0
- package/src/plugins/open-telemetry/traceparent/index.js +4 -0
- package/src/plugins/open-telemetry/traceparent/index.js.map +1 -0
- package/src/plugins/open-telemetry/traceparent/interfaces.d.ts +38 -0
- package/src/plugins/open-telemetry/traceparent/interfaces.d.ts.map +1 -0
- package/src/plugins/open-telemetry/traceparent/interfaces.js +6 -0
- package/src/plugins/open-telemetry/traceparent/interfaces.js.map +1 -0
- package/src/plugins/open-telemetry/traceparent/open-telemetry.traceparent.reply.d.ts +36 -0
- package/src/plugins/open-telemetry/traceparent/open-telemetry.traceparent.reply.d.ts.map +1 -0
- package/src/plugins/open-telemetry/traceparent/open-telemetry.traceparent.reply.js +87 -0
- package/src/plugins/open-telemetry/traceparent/open-telemetry.traceparent.reply.js.map +1 -0
- package/src/plugins/open-telemetry/traceparent/open-telemetry.traceparent.request.d.ts +39 -0
- package/src/plugins/open-telemetry/traceparent/open-telemetry.traceparent.request.d.ts.map +1 -0
- package/src/plugins/open-telemetry/traceparent/open-telemetry.traceparent.request.js +56 -0
- package/src/plugins/open-telemetry/traceparent/open-telemetry.traceparent.request.js.map +1 -0
- package/src/public_api.d.ts +0 -1
- package/src/public_api.d.ts.map +1 -1
- package/src/public_api.js +0 -1
- package/src/public_api.js.map +1 -1
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.d.ts.map +1 -1
- package/src/utils/index.js +1 -0
- package/src/utils/index.js.map +1 -1
- package/src/utils/perf/index.d.ts +2 -0
- package/src/utils/perf/index.d.ts.map +1 -0
- package/src/utils/perf/index.js +2 -0
- package/src/utils/perf/index.js.map +1 -0
- package/src/{plugins/perf-metric/perf-metric.fetch.d.ts → utils/perf/perf-metric.service.d.ts} +9 -11
- package/src/utils/perf/perf-metric.service.d.ts.map +1 -0
- package/src/{plugins/perf-metric/perf-metric.fetch.js → utils/perf/perf-metric.service.js} +2 -21
- package/src/utils/perf/perf-metric.service.js.map +1 -0
- package/cjs/clients/api-angular-client.js +0 -634
- package/cjs/clients/api-beacon-client.js +0 -242
- package/cjs/clients/api-fetch-client.js +0 -637
- package/cjs/clients/index.js +0 -19
- package/cjs/plugins/abort/abort.fetch.js +0 -84
- package/cjs/plugins/abort/abort.spec.js +0 -206
- package/cjs/plugins/concurrent/concurrent.fetch.js +0 -251
- package/cjs/plugins/concurrent/concurrent.spec.js +0 -239
- package/cjs/plugins/core/angular-plugin.js +0 -4
- package/cjs/plugins/core/fetch-plugin.js +0 -4
- package/cjs/plugins/keepalive/keepalive.request.js +0 -284
- package/cjs/plugins/keepalive/keepalive.spec.js +0 -160
- package/cjs/plugins/mock-intercept/mock-intercept.angular.js +0 -363
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +0 -302
- package/cjs/plugins/perf-metric/index.js +0 -18
- package/cjs/plugins/retry/index.js +0 -18
- package/cjs/plugins/retry/retry.fetch.js +0 -347
- package/cjs/plugins/timeout/index.js +0 -18
- package/cjs/plugins/timeout/timeout.fetch.js +0 -323
- package/cjs/plugins/timeout/timeout.spec.js +0 -449
- package/cjs/plugins/wait-for/index.js +0 -18
- package/cjs/plugins/wait-for/wait-for.fetch.js +0 -340
- package/cjs/plugins/wait-for/wait-for.spec.js +0 -391
- package/esm2015/clients/api-angular-client.js +0 -627
- package/esm2015/clients/api-beacon-client.js +0 -235
- package/esm2015/clients/api-fetch-client.js +0 -630
- package/esm2015/clients/index.js +0 -2
- package/esm2015/plugins/abort/abort.fetch.js +0 -74
- package/esm2015/plugins/abort/abort.spec.js +0 -202
- package/esm2015/plugins/abort/index.js +0 -1
- package/esm2015/plugins/concurrent/concurrent.fetch.js +0 -244
- package/esm2015/plugins/concurrent/concurrent.spec.js +0 -235
- package/esm2015/plugins/concurrent/index.js +0 -1
- package/esm2015/plugins/core/angular-plugin.js +0 -4
- package/esm2015/plugins/core/fetch-plugin.js +0 -5
- package/esm2015/plugins/keepalive/index.js +0 -1
- package/esm2015/plugins/keepalive/keepalive.request.js +0 -277
- package/esm2015/plugins/keepalive/keepalive.spec.js +0 -156
- package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +0 -359
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +0 -298
- package/esm2015/plugins/perf-metric/index.js +0 -1
- package/esm2015/plugins/retry/index.js +0 -1
- package/esm2015/plugins/retry/retry.fetch.js +0 -340
- package/esm2015/plugins/timeout/index.js +0 -1
- package/esm2015/plugins/timeout/timeout.fetch.js +0 -312
- package/esm2015/plugins/timeout/timeout.spec.js +0 -445
- package/esm2015/plugins/wait-for/index.js +0 -1
- package/esm2015/plugins/wait-for/wait-for.fetch.js +0 -370
- package/esm2015/plugins/wait-for/wait-for.spec.js +0 -387
- package/src/clients/api-angular-client.d.ts +0 -95
- package/src/clients/api-angular-client.d.ts.map +0 -1
- package/src/clients/api-angular-client.js +0 -175
- package/src/clients/api-angular-client.js.map +0 -1
- package/src/clients/api-beacon-client.d.ts +0 -84
- package/src/clients/api-beacon-client.d.ts.map +0 -1
- package/src/clients/api-beacon-client.js +0 -117
- package/src/clients/api-beacon-client.js.map +0 -1
- package/src/clients/api-fetch-client.d.ts +0 -88
- package/src/clients/api-fetch-client.d.ts.map +0 -1
- package/src/clients/api-fetch-client.js +0 -169
- package/src/clients/api-fetch-client.js.map +0 -1
- package/src/clients/index.d.ts +0 -3
- package/src/clients/index.d.ts.map +0 -1
- package/src/clients/index.js +0 -3
- package/src/clients/index.js.map +0 -1
- package/src/plugins/abort/abort.fetch.d.ts +0 -66
- package/src/plugins/abort/abort.fetch.d.ts.map +0 -1
- package/src/plugins/abort/abort.fetch.js +0 -32
- package/src/plugins/abort/abort.fetch.js.map +0 -1
- package/src/plugins/abort/index.d.ts +0 -2
- package/src/plugins/abort/index.d.ts.map +0 -1
- package/src/plugins/abort/index.js +0 -2
- package/src/plugins/abort/index.js.map +0 -1
- package/src/plugins/concurrent/concurrent.fetch.d.ts +0 -34
- package/src/plugins/concurrent/concurrent.fetch.d.ts.map +0 -1
- package/src/plugins/concurrent/concurrent.fetch.js +0 -53
- package/src/plugins/concurrent/concurrent.fetch.js.map +0 -1
- package/src/plugins/concurrent/index.d.ts +0 -2
- package/src/plugins/concurrent/index.d.ts.map +0 -1
- package/src/plugins/concurrent/index.js +0 -2
- package/src/plugins/concurrent/index.js.map +0 -1
- package/src/plugins/core/angular-plugin.d.ts +0 -40
- package/src/plugins/core/angular-plugin.d.ts.map +0 -1
- package/src/plugins/core/angular-plugin.js +0 -2
- package/src/plugins/core/angular-plugin.js.map +0 -1
- package/src/plugins/core/fetch-plugin.d.ts +0 -46
- package/src/plugins/core/fetch-plugin.d.ts.map +0 -1
- package/src/plugins/core/fetch-plugin.js +0 -2
- package/src/plugins/core/fetch-plugin.js.map +0 -1
- package/src/plugins/keepalive/index.d.ts +0 -2
- package/src/plugins/keepalive/index.d.ts.map +0 -1
- package/src/plugins/keepalive/index.js +0 -2
- package/src/plugins/keepalive/index.js.map +0 -1
- package/src/plugins/keepalive/keepalive.request.d.ts +0 -19
- package/src/plugins/keepalive/keepalive.request.d.ts.map +0 -1
- package/src/plugins/keepalive/keepalive.request.js +0 -40
- package/src/plugins/keepalive/keepalive.request.js.map +0 -1
- package/src/plugins/mock-intercept/mock-intercept.angular.d.ts +0 -17
- package/src/plugins/mock-intercept/mock-intercept.angular.d.ts.map +0 -1
- package/src/plugins/mock-intercept/mock-intercept.angular.js +0 -79
- package/src/plugins/mock-intercept/mock-intercept.angular.js.map +0 -1
- package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts +0 -16
- package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts.map +0 -1
- package/src/plugins/mock-intercept/mock-intercept.fetch.js +0 -58
- package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +0 -1
- package/src/plugins/perf-metric/index.d.ts +0 -2
- package/src/plugins/perf-metric/index.d.ts.map +0 -1
- package/src/plugins/perf-metric/index.js +0 -2
- package/src/plugins/perf-metric/index.js.map +0 -1
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts.map +0 -1
- package/src/plugins/perf-metric/perf-metric.fetch.js.map +0 -1
- package/src/plugins/retry/index.d.ts +0 -2
- package/src/plugins/retry/index.d.ts.map +0 -1
- package/src/plugins/retry/index.js +0 -2
- package/src/plugins/retry/index.js.map +0 -1
- package/src/plugins/retry/retry.fetch.d.ts +0 -55
- package/src/plugins/retry/retry.fetch.d.ts.map +0 -1
- package/src/plugins/retry/retry.fetch.js +0 -68
- package/src/plugins/retry/retry.fetch.js.map +0 -1
- package/src/plugins/timeout/index.d.ts +0 -2
- package/src/plugins/timeout/index.d.ts.map +0 -1
- package/src/plugins/timeout/index.js +0 -2
- package/src/plugins/timeout/index.js.map +0 -1
- package/src/plugins/timeout/timeout.fetch.d.ts +0 -47
- package/src/plugins/timeout/timeout.fetch.d.ts.map +0 -1
- package/src/plugins/timeout/timeout.fetch.js +0 -107
- package/src/plugins/timeout/timeout.fetch.js.map +0 -1
- package/src/plugins/wait-for/index.d.ts +0 -2
- package/src/plugins/wait-for/index.d.ts.map +0 -1
- package/src/plugins/wait-for/index.js +0 -2
- package/src/plugins/wait-for/index.js.map +0 -1
- package/src/plugins/wait-for/wait-for.fetch.d.ts +0 -86
- package/src/plugins/wait-for/wait-for.fetch.d.ts.map +0 -1
- package/src/plugins/wait-for/wait-for.fetch.js +0 -105
- package/src/plugins/wait-for/wait-for.fetch.js.map +0 -1
package/README.md
CHANGED
|
@@ -9,12 +9,10 @@ Please refer to the [ama-sdk-schematics](../schematics/README.md) package for ge
|
|
|
9
9
|
|
|
10
10
|
## Available plugins
|
|
11
11
|
|
|
12
|
-
- [abort](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/abort) *(deprecated, now available [here](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/abort))*
|
|
13
12
|
- [additional-params](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/additional-params)
|
|
14
13
|
- [api-configuration-override](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/api-configuration-override)
|
|
15
14
|
- [api-key](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/api-key)
|
|
16
15
|
- [bot-protection-fingerprint](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/bot-protection-fingerprint)
|
|
17
|
-
- [concurrent](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/concurrent) *(deprecated, now available [here](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/concurrent))*
|
|
18
16
|
- [core](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/core)
|
|
19
17
|
- [client-facts](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/client-facts)
|
|
20
18
|
- [custom-info](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/custom-info)
|
|
@@ -22,19 +20,15 @@ Please refer to the [ama-sdk-schematics](../schematics/README.md) package for ge
|
|
|
22
20
|
- [fetch-cache](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/fetch-cache)
|
|
23
21
|
- [fetch-credentials](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/fetch-credentials)
|
|
24
22
|
- [json-token](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/json-token)
|
|
25
|
-
- [keepalive](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/keepalive) *(deprecated, now available [here](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/keepalive))*
|
|
26
23
|
- [mock-intercept](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/mock-intercept)
|
|
27
|
-
- [
|
|
24
|
+
- [OpenTelemetry Traceparent](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/open-telemetry/traceparent)
|
|
28
25
|
- [pii-tokenizer](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/pii-tokenizer)
|
|
29
26
|
- [raw-response-info](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/raw-response-info)
|
|
30
|
-
- [retry](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/retry) *(deprecated, now available [here](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/retry))*
|
|
31
27
|
- [reviver](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/reviver)
|
|
32
28
|
- [session-id](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/session-id)
|
|
33
29
|
- [si-token](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/si-token)
|
|
34
30
|
- [simple-api-key-authentication](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/simple-api-key-authentication)
|
|
35
31
|
- [url-rewrite](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/url-rewrite)
|
|
36
|
-
- [timeout](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/timeout) *(deprecated, now available [here](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/timeout))*
|
|
37
|
-
- [wait-for](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core/src/plugins/wait-for) *(deprecated, now available [here](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/wait-for))*
|
|
38
32
|
|
|
39
33
|
## Available API Client
|
|
40
34
|
|
package/cjs/fwk/mocks/helpers.js
CHANGED
|
@@ -33,7 +33,8 @@ function getPath(requestUrl, pathObjects, method) {
|
|
|
33
33
|
}
|
|
34
34
|
// Find all matching paths
|
|
35
35
|
var matches = pathObjects.reduce(function(newMatches, pathObject, index) {
|
|
36
|
-
|
|
36
|
+
var regexp = pathObject.urlPattern ? new RegExp(pathObject.urlPattern) : pathObject.regexp;
|
|
37
|
+
if (regexp.test(pathName)) {
|
|
37
38
|
newMatches.push({
|
|
38
39
|
index: index,
|
|
39
40
|
segments: pathObject.path.split('/'),
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./fetch-plugin"), exports);
|
|
6
5
|
_export_star(require("./plugin"), exports);
|
|
7
6
|
_export_star(require("./reply-plugin"), exports);
|
|
8
7
|
_export_star(require("./request-plugin"), exports);
|
package/cjs/plugins/index.js
CHANGED
|
@@ -2,33 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./abort/index"), exports);
|
|
6
5
|
_export_star(require("./additional-params/index"), exports);
|
|
7
6
|
_export_star(require("./api-configuration-override/index"), exports);
|
|
8
7
|
_export_star(require("./api-key/index"), exports);
|
|
9
8
|
_export_star(require("./bot-protection-fingerprint/index"), exports);
|
|
10
9
|
_export_star(require("./client-facts/index"), exports);
|
|
11
|
-
_export_star(require("./concurrent/index"), exports);
|
|
12
10
|
_export_star(require("./core/index"), exports);
|
|
13
11
|
_export_star(require("./custom-info/index"), exports);
|
|
14
12
|
_export_star(require("./exception/index"), exports);
|
|
15
13
|
_export_star(require("./fetch-cache/index"), exports);
|
|
16
14
|
_export_star(require("./fetch-credentials/index"), exports);
|
|
17
15
|
_export_star(require("./json-token/index"), exports);
|
|
18
|
-
_export_star(require("./keepalive/index"), exports);
|
|
19
16
|
_export_star(require("./mgw-mdw-auth/index"), exports);
|
|
17
|
+
_export_star(require("./open-telemetry/traceparent/index"), exports);
|
|
20
18
|
_export_star(require("./mock-intercept/index"), exports);
|
|
21
|
-
_export_star(require("./perf-metric/index"), exports);
|
|
22
19
|
_export_star(require("./pii-tokenizer/index"), exports);
|
|
23
20
|
_export_star(require("./raw-response-info/index"), exports);
|
|
24
|
-
_export_star(require("./retry/index"), exports);
|
|
25
21
|
_export_star(require("./reviver/index"), exports);
|
|
26
22
|
_export_star(require("./session-id/index"), exports);
|
|
27
23
|
_export_star(require("./si-token/index"), exports);
|
|
28
24
|
_export_star(require("./simple-api-key-authentication/index"), exports);
|
|
29
|
-
_export_star(require("./timeout/index"), exports);
|
|
30
25
|
_export_star(require("./url-rewrite/index"), exports);
|
|
31
|
-
_export_star(require("./wait-for/index"), exports);
|
|
32
26
|
function _export_star(from, to) {
|
|
33
27
|
Object.keys(from).forEach(function(k) {
|
|
34
28
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./mock-intercept.fetch"), exports);
|
|
6
5
|
_export_star(require("./mock-intercept.interface"), exports);
|
|
7
6
|
_export_star(require("./mock-intercept.request"), exports);
|
|
8
7
|
function _export_star(from, to) {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
var _fwk = require("../../fwk");
|
|
6
|
-
var _mockinterceptfetch = require("./mock-intercept.fetch");
|
|
7
5
|
var _mockinterceptinterface = require("./mock-intercept.interface");
|
|
8
6
|
var _mockinterceptrequest = require("./mock-intercept.request");
|
|
9
7
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -35,19 +33,6 @@ function _async_to_generator(fn) {
|
|
|
35
33
|
});
|
|
36
34
|
};
|
|
37
35
|
}
|
|
38
|
-
function _define_property(obj, key, value) {
|
|
39
|
-
if (key in obj) {
|
|
40
|
-
Object.defineProperty(obj, key, {
|
|
41
|
-
value: value,
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true
|
|
45
|
-
});
|
|
46
|
-
} else {
|
|
47
|
-
obj[key] = value;
|
|
48
|
-
}
|
|
49
|
-
return obj;
|
|
50
|
-
}
|
|
51
36
|
function _ts_generator(thisArg, body) {
|
|
52
37
|
var f, y, t, _ = {
|
|
53
38
|
label: 0,
|
|
@@ -152,18 +137,6 @@ var testMockAdapter = {
|
|
|
152
137
|
initialize: initializeSpy,
|
|
153
138
|
retrieveOperationId: retrieveOperationIdSpy
|
|
154
139
|
};
|
|
155
|
-
var requestPlugins = [
|
|
156
|
-
new _mockinterceptrequest.MockInterceptRequest({
|
|
157
|
-
adapter: new _fwk.SequentialMockAdapter([], {})
|
|
158
|
-
})
|
|
159
|
-
];
|
|
160
|
-
var apiClient = {
|
|
161
|
-
options: {
|
|
162
|
-
requestPlugins: requestPlugins,
|
|
163
|
-
basePath: 'test',
|
|
164
|
-
replyPlugins: []
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
140
|
describe('Mock intercept', function() {
|
|
168
141
|
beforeEach(function() {
|
|
169
142
|
return jest.clearAllMocks();
|
|
@@ -284,169 +257,4 @@ describe('Mock intercept', function() {
|
|
|
284
257
|
})();
|
|
285
258
|
});
|
|
286
259
|
});
|
|
287
|
-
describe('fetch plugin', function() {
|
|
288
|
-
describe('when using an initialization function', function() {
|
|
289
|
-
var plugin;
|
|
290
|
-
var asyncMockAdapter;
|
|
291
|
-
beforeEach(function() {
|
|
292
|
-
asyncMockAdapter = {
|
|
293
|
-
initialize: initializeSpy,
|
|
294
|
-
getMock: getMockSpy,
|
|
295
|
-
getLatestMock: getLatestMockSpy,
|
|
296
|
-
retrieveOperationId: retrieveOperationIdSpy
|
|
297
|
-
};
|
|
298
|
-
plugin = new _mockinterceptfetch.MockInterceptFetch({
|
|
299
|
-
adapter: asyncMockAdapter
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
it('should call initialize fn', function() {
|
|
303
|
-
return _async_to_generator(function() {
|
|
304
|
-
var loadedPlugin, testData;
|
|
305
|
-
return _ts_generator(this, function(_state) {
|
|
306
|
-
switch(_state.label){
|
|
307
|
-
case 0:
|
|
308
|
-
loadedPlugin = plugin.load({
|
|
309
|
-
fetchPlugins: [],
|
|
310
|
-
url: 'myurl',
|
|
311
|
-
apiClient: apiClient,
|
|
312
|
-
options: {
|
|
313
|
-
headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
testData = {
|
|
317
|
-
test: true
|
|
318
|
-
};
|
|
319
|
-
return [
|
|
320
|
-
4,
|
|
321
|
-
loadedPlugin.transform(Promise.resolve(testData))
|
|
322
|
-
];
|
|
323
|
-
case 1:
|
|
324
|
-
_state.sent();
|
|
325
|
-
expect(initializeSpy).toHaveBeenCalled();
|
|
326
|
-
expect(getMockSpy).not.toHaveBeenCalled();
|
|
327
|
-
expect(getLatestMockSpy).toHaveBeenCalledWith('testOperation');
|
|
328
|
-
return [
|
|
329
|
-
2
|
|
330
|
-
];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
})();
|
|
334
|
-
});
|
|
335
|
-
it('should throw if there is no request plugin', function() {
|
|
336
|
-
var config = {
|
|
337
|
-
fetchPlugins: [],
|
|
338
|
-
url: 'myurl',
|
|
339
|
-
apiClient: {
|
|
340
|
-
options: {
|
|
341
|
-
requestPlugins: []
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
options: {
|
|
345
|
-
headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
expect(function() {
|
|
349
|
-
return plugin.load(config);
|
|
350
|
-
}).toThrow();
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
describe('with delay', function() {
|
|
355
|
-
it('should delay the response of the specific number', function() {
|
|
356
|
-
return _async_to_generator(function() {
|
|
357
|
-
var plugin, loadedPlugin, callback, run;
|
|
358
|
-
return _ts_generator(this, function(_state) {
|
|
359
|
-
switch(_state.label){
|
|
360
|
-
case 0:
|
|
361
|
-
plugin = new _mockinterceptfetch.MockInterceptFetch({
|
|
362
|
-
adapter: testMockAdapter,
|
|
363
|
-
delayTiming: 700
|
|
364
|
-
});
|
|
365
|
-
loadedPlugin = plugin.load({
|
|
366
|
-
fetchPlugins: [],
|
|
367
|
-
url: '',
|
|
368
|
-
apiClient: apiClient,
|
|
369
|
-
options: {
|
|
370
|
-
headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
callback = jest.fn();
|
|
374
|
-
run = loadedPlugin.transform(Promise.resolve({})).then(callback);
|
|
375
|
-
return [
|
|
376
|
-
4,
|
|
377
|
-
jest.advanceTimersByTimeAsync(699)
|
|
378
|
-
];
|
|
379
|
-
case 1:
|
|
380
|
-
_state.sent();
|
|
381
|
-
expect(callback).not.toHaveBeenCalled();
|
|
382
|
-
return [
|
|
383
|
-
4,
|
|
384
|
-
jest.advanceTimersByTimeAsync(1)
|
|
385
|
-
];
|
|
386
|
-
case 2:
|
|
387
|
-
_state.sent();
|
|
388
|
-
expect(callback).toHaveBeenCalled();
|
|
389
|
-
return [
|
|
390
|
-
4,
|
|
391
|
-
run
|
|
392
|
-
];
|
|
393
|
-
case 3:
|
|
394
|
-
_state.sent();
|
|
395
|
-
return [
|
|
396
|
-
2
|
|
397
|
-
];
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
})();
|
|
401
|
-
});
|
|
402
|
-
it('should delay the response based on callback', function() {
|
|
403
|
-
return _async_to_generator(function() {
|
|
404
|
-
var plugin, loadedPlugin, callback, run;
|
|
405
|
-
return _ts_generator(this, function(_state) {
|
|
406
|
-
switch(_state.label){
|
|
407
|
-
case 0:
|
|
408
|
-
plugin = new _mockinterceptfetch.MockInterceptFetch({
|
|
409
|
-
adapter: testMockAdapter,
|
|
410
|
-
delayTiming: function() {
|
|
411
|
-
return 800;
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
loadedPlugin = plugin.load({
|
|
415
|
-
fetchPlugins: [],
|
|
416
|
-
url: '',
|
|
417
|
-
apiClient: apiClient,
|
|
418
|
-
options: {
|
|
419
|
-
headers: new Headers(_define_property({}, _mockinterceptinterface.CUSTOM_MOCK_OPERATION_ID_HEADER, 'testOperation'))
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
callback = jest.fn();
|
|
423
|
-
run = loadedPlugin.transform(Promise.resolve({})).then(callback);
|
|
424
|
-
return [
|
|
425
|
-
4,
|
|
426
|
-
jest.advanceTimersByTimeAsync(799)
|
|
427
|
-
];
|
|
428
|
-
case 1:
|
|
429
|
-
_state.sent();
|
|
430
|
-
expect(callback).not.toHaveBeenCalled();
|
|
431
|
-
return [
|
|
432
|
-
4,
|
|
433
|
-
jest.advanceTimersByTimeAsync(1)
|
|
434
|
-
];
|
|
435
|
-
case 2:
|
|
436
|
-
_state.sent();
|
|
437
|
-
expect(callback).toHaveBeenCalled();
|
|
438
|
-
return [
|
|
439
|
-
4,
|
|
440
|
-
run
|
|
441
|
-
];
|
|
442
|
-
case 3:
|
|
443
|
-
_state.sent();
|
|
444
|
-
return [
|
|
445
|
-
2
|
|
446
|
-
];
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
})();
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
260
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./
|
|
5
|
+
_export_star(require("./traceparent/index"), exports);
|
|
6
6
|
function _export_star(from, to) {
|
|
7
7
|
Object.keys(from).forEach(function(k) {
|
|
8
8
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./
|
|
5
|
+
_export_star(require("./interfaces"), exports);
|
|
6
|
+
_export_star(require("./open-telemetry.traceparent.reply"), exports);
|
|
7
|
+
_export_star(require("./open-telemetry.traceparent.request"), exports);
|
|
6
8
|
function _export_star(from, to) {
|
|
7
9
|
Object.keys(from).forEach(function(k) {
|
|
8
10
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface reporting the decoded {@link https://www.w3.org/TR/trace-context/#traceparent-header | Traceparent header} information for the
|
|
3
|
+
* {@link https://opentelemetry.io/ | OpenTelemetry} specification.
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "DEFAULT_COMMON_OPTIONS", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return DEFAULT_COMMON_OPTIONS;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var DEFAULT_COMMON_OPTIONS = {
|
|
15
|
+
storage: globalThis.sessionStorage,
|
|
16
|
+
parentIdStorageKey: 'traceparent-parent-id',
|
|
17
|
+
traceparentHeader: 'traceparent'
|
|
18
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get OpenTelemetryTraceparentReply () {
|
|
13
|
+
return OpenTelemetryTraceparentReply;
|
|
14
|
+
},
|
|
15
|
+
get decodeTraceparentHeader () {
|
|
16
|
+
return decodeTraceparentHeader;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _interfaces = require("./interfaces");
|
|
20
|
+
function _array_like_to_array(arr, len) {
|
|
21
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
22
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
23
|
+
return arr2;
|
|
24
|
+
}
|
|
25
|
+
function _array_with_holes(arr) {
|
|
26
|
+
if (Array.isArray(arr)) return arr;
|
|
27
|
+
}
|
|
28
|
+
function _class_call_check(instance, Constructor) {
|
|
29
|
+
if (!(instance instanceof Constructor)) {
|
|
30
|
+
throw new TypeError("Cannot call a class as a function");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function _defineProperties(target, props) {
|
|
34
|
+
for(var i = 0; i < props.length; i++){
|
|
35
|
+
var descriptor = props[i];
|
|
36
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
37
|
+
descriptor.configurable = true;
|
|
38
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
39
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
43
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
44
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
45
|
+
return Constructor;
|
|
46
|
+
}
|
|
47
|
+
function _define_property(obj, key, value) {
|
|
48
|
+
if (key in obj) {
|
|
49
|
+
Object.defineProperty(obj, key, {
|
|
50
|
+
value: value,
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
obj[key] = value;
|
|
57
|
+
}
|
|
58
|
+
return obj;
|
|
59
|
+
}
|
|
60
|
+
function _iterable_to_array_limit(arr, i) {
|
|
61
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
62
|
+
if (_i == null) return;
|
|
63
|
+
var _arr = [];
|
|
64
|
+
var _n = true;
|
|
65
|
+
var _d = false;
|
|
66
|
+
var _s, _e;
|
|
67
|
+
try {
|
|
68
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
69
|
+
_arr.push(_s.value);
|
|
70
|
+
if (i && _arr.length === i) break;
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
_d = true;
|
|
74
|
+
_e = err;
|
|
75
|
+
} finally{
|
|
76
|
+
try {
|
|
77
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
78
|
+
} finally{
|
|
79
|
+
if (_d) throw _e;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return _arr;
|
|
83
|
+
}
|
|
84
|
+
function _non_iterable_rest() {
|
|
85
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
86
|
+
}
|
|
87
|
+
function _object_spread(target) {
|
|
88
|
+
for(var i = 1; i < arguments.length; i++){
|
|
89
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
90
|
+
var ownKeys = Object.keys(source);
|
|
91
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
92
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
93
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
ownKeys.forEach(function(key) {
|
|
97
|
+
_define_property(target, key, source[key]);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return target;
|
|
101
|
+
}
|
|
102
|
+
function ownKeys(object, enumerableOnly) {
|
|
103
|
+
var keys = Object.keys(object);
|
|
104
|
+
if (Object.getOwnPropertySymbols) {
|
|
105
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
106
|
+
if (enumerableOnly) {
|
|
107
|
+
symbols = symbols.filter(function(sym) {
|
|
108
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
keys.push.apply(keys, symbols);
|
|
112
|
+
}
|
|
113
|
+
return keys;
|
|
114
|
+
}
|
|
115
|
+
function _object_spread_props(target, source) {
|
|
116
|
+
source = source != null ? source : {};
|
|
117
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
118
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
119
|
+
} else {
|
|
120
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
121
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return target;
|
|
125
|
+
}
|
|
126
|
+
function _sliced_to_array(arr, i) {
|
|
127
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
128
|
+
}
|
|
129
|
+
function _type_of(obj) {
|
|
130
|
+
"@swc/helpers - typeof";
|
|
131
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
132
|
+
}
|
|
133
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
134
|
+
if (!o) return;
|
|
135
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
136
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
137
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
138
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
139
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
140
|
+
}
|
|
141
|
+
var DEFAULT_OPTIONS = _object_spread_props(_object_spread({}, _interfaces.DEFAULT_COMMON_OPTIONS), {
|
|
142
|
+
dataField: '_traceparent'
|
|
143
|
+
});
|
|
144
|
+
var TRACE_ID_LENGTH = 32;
|
|
145
|
+
var PARENT_ID_LENGTH = 16;
|
|
146
|
+
var TRACE_ID_REGEXP = new RegExp("^[a-f0-9]{".concat(TRACE_ID_LENGTH, "}$"));
|
|
147
|
+
var PARENT_ID_REGEXP = new RegExp("^[a-f0-9]{".concat(PARENT_ID_LENGTH, "}$"));
|
|
148
|
+
var decodeTraceparentHeader = function(traceparent, options) {
|
|
149
|
+
var content = traceparent.split('-');
|
|
150
|
+
var dataField = {};
|
|
151
|
+
var logWarning = function() {
|
|
152
|
+
var _options_logger;
|
|
153
|
+
return options === null || options === void 0 ? void 0 : (_options_logger = options.logger) === null || _options_logger === void 0 ? void 0 : _options_logger.warn("Invalid traceparent header ".concat(traceparent, ", will be ignored"));
|
|
154
|
+
};
|
|
155
|
+
if (content.length < 2) {
|
|
156
|
+
logWarning();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (content[0].length < PARENT_ID_LENGTH) {
|
|
160
|
+
var ref;
|
|
161
|
+
ref = _sliced_to_array(content, 4), dataField.version = ref[0], dataField.traceId = ref[1], dataField.parentId = ref[2], dataField.traceFlags = ref[3], ref;
|
|
162
|
+
} else {
|
|
163
|
+
var ref1;
|
|
164
|
+
ref1 = _sliced_to_array(content, 3), dataField.traceId = ref1[0], dataField.parentId = ref1[1], dataField.traceFlags = ref1[2], ref1;
|
|
165
|
+
dataField.version = '00';
|
|
166
|
+
}
|
|
167
|
+
if (!PARENT_ID_REGEXP.test(dataField.parentId) || !TRACE_ID_REGEXP.test(dataField.traceId)) {
|
|
168
|
+
logWarning();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
return dataField;
|
|
172
|
+
};
|
|
173
|
+
var OpenTelemetryTraceparentReply = /*#__PURE__*/ function() {
|
|
174
|
+
"use strict";
|
|
175
|
+
function OpenTelemetryTraceparentReply(options) {
|
|
176
|
+
_class_call_check(this, OpenTelemetryTraceparentReply);
|
|
177
|
+
_define_property(this, "options", void 0);
|
|
178
|
+
this.options = _object_spread({}, DEFAULT_OPTIONS, options);
|
|
179
|
+
}
|
|
180
|
+
_create_class(OpenTelemetryTraceparentReply, [
|
|
181
|
+
{
|
|
182
|
+
key: "updateParentId",
|
|
183
|
+
value: function updateParentId(parentId, logger) {
|
|
184
|
+
if (parentId) {
|
|
185
|
+
var currentParentId = this.options.storage.getItem(this.options.parentIdStorageKey);
|
|
186
|
+
if (!currentParentId || currentParentId !== parentId) {
|
|
187
|
+
var _logger_info;
|
|
188
|
+
logger === null || logger === void 0 ? void 0 : (_logger_info = logger.info) === null || _logger_info === void 0 ? void 0 : _logger_info.call(logger, "The current Traceparent ParentId ".concat(currentParentId, " will be replaced by the received one ").concat(parentId, "."));
|
|
189
|
+
this.options.storage.setItem(this.options.parentIdStorageKey, parentId);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
key: "decodeTraceparentHeader",
|
|
196
|
+
value: function decodeTraceparentHeader1(traceparent, logger) {
|
|
197
|
+
var dataField = decodeTraceparentHeader(traceparent, {
|
|
198
|
+
logger: logger
|
|
199
|
+
});
|
|
200
|
+
if (dataField) {
|
|
201
|
+
this.updateParentId(dataField.parentId, logger);
|
|
202
|
+
}
|
|
203
|
+
return dataField;
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
key: "load",
|
|
208
|
+
value: /** @inheritdoc */ function load(context) {
|
|
209
|
+
var _this = this;
|
|
210
|
+
return {
|
|
211
|
+
transform: function(data) {
|
|
212
|
+
if (!context.response) {
|
|
213
|
+
return data;
|
|
214
|
+
}
|
|
215
|
+
var content = context.response.headers.get(_this.options.traceparentHeader);
|
|
216
|
+
if (!content) {
|
|
217
|
+
var _context_logger_debug, _context_logger;
|
|
218
|
+
(_context_logger = context.logger) === null || _context_logger === void 0 ? void 0 : (_context_logger_debug = _context_logger.debug) === null || _context_logger_debug === void 0 ? void 0 : _context_logger_debug.call(_context_logger, "The reply of the request ".concat(context.url, " does not contain ").concat(_this.options.traceparentHeader, " header, the open telemetry information will not be retrieved."));
|
|
219
|
+
return data;
|
|
220
|
+
}
|
|
221
|
+
var dataField = _this.decodeTraceparentHeader(content, context.logger);
|
|
222
|
+
var extendedData = _define_property({}, _this.options.dataField, dataField);
|
|
223
|
+
if ((typeof data === "undefined" ? "undefined" : _type_of(data)) === 'object' && data && _this.options.dataField in data) {
|
|
224
|
+
var _context_logger1;
|
|
225
|
+
(_context_logger1 = context.logger) === null || _context_logger1 === void 0 ? void 0 : _context_logger1.warn('The field "'.concat(_this.options.dataField, '" already exist in the response, it will be overridden by the traceparent information.'));
|
|
226
|
+
}
|
|
227
|
+
return data ? Object.assign(data, extendedData) : extendedData;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
]);
|
|
233
|
+
return OpenTelemetryTraceparentReply;
|
|
234
|
+
}();
|