@lokalise/fastify-extras 20.2.2 → 21.1.0
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 -11
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/plugins/healthcheck/healthcheckMetricsPlugin.spec.js +9 -5
- package/dist/plugins/healthcheck/healthcheckMetricsPlugin.spec.js.map +1 -1
- package/dist/plugins/metricsPlugin.spec.js +5 -2
- package/dist/plugins/metricsPlugin.spec.js.map +1 -1
- package/dist/plugins/requestContextProviderPlugin.d.ts +0 -6
- package/dist/plugins/requestContextProviderPlugin.js +1 -5
- package/dist/plugins/requestContextProviderPlugin.js.map +1 -1
- package/dist/plugins/unhandledExceptionPlugin.js +1 -7
- package/dist/plugins/unhandledExceptionPlugin.js.map +1 -1
- package/package.json +4 -14
- package/dist/plugins/opentelemetry/prismaOtelTracingPlugin.d.ts +0 -10
- package/dist/plugins/opentelemetry/prismaOtelTracingPlugin.js +0 -43
- package/dist/plugins/opentelemetry/prismaOtelTracingPlugin.js.map +0 -1
- package/dist/plugins/opentelemetry/spanProcessors.d.ts +0 -16
- package/dist/plugins/opentelemetry/spanProcessors.js +0 -29
- package/dist/plugins/opentelemetry/spanProcessors.js.map +0 -1
package/README.md
CHANGED
|
@@ -23,14 +23,6 @@ The following needs to be taken into consideration when adding new runtime depen
|
|
|
23
23
|
### Dependencies
|
|
24
24
|
|
|
25
25
|
- `@bugsnag/js`;
|
|
26
|
-
- `@opentelemetry/api`;
|
|
27
|
-
- `@opentelemetry/exporter-trace-otlp-grpc`;
|
|
28
|
-
- `@opentelemetry/instrumentation`;
|
|
29
|
-
- `@opentelemetry/resources`;
|
|
30
|
-
- `@opentelemetry/sdk-trace-base`;
|
|
31
|
-
- `@opentelemetry/sdk-trace-node`;
|
|
32
|
-
- `@opentelemetry/semantic-conventions`;
|
|
33
|
-
- `@prisma/instrumentation`;
|
|
34
26
|
- `@splitsoftware/splitio`;
|
|
35
27
|
- `fastify-metrics`;
|
|
36
28
|
- `fastify-plugin`;
|
|
@@ -38,7 +30,6 @@ The following needs to be taken into consideration when adding new runtime depen
|
|
|
38
30
|
|
|
39
31
|
### Peer Dependencies
|
|
40
32
|
|
|
41
|
-
- `@fastify/request-context`;
|
|
42
33
|
- `@fastify/jwt`;
|
|
43
34
|
- `fastify`;
|
|
44
35
|
- `newrelic`;
|
|
@@ -51,9 +42,8 @@ The following needs to be taken into consideration when adding new runtime depen
|
|
|
51
42
|
Plugin to:
|
|
52
43
|
|
|
53
44
|
- extend existing `FastifyRequest` with request context by setting the following:
|
|
54
|
-
- `logger`,
|
|
45
|
+
- `logger`, a child logger of app.log, with prepopulated header `x-request-id`;
|
|
55
46
|
- `reqId`, the request-id;
|
|
56
|
-
- store the request-id in Asynchronous Local Storage to be picked up by instrumentation tooling (e. g. OpenTelemetry).
|
|
57
47
|
|
|
58
48
|
No options are required to register the plugin.
|
|
59
49
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { bugsnagPlugin, reportErrorToBugsnag, bugsnagErrorReporter, addFeatureFlag, } from './plugins/bugsnagPlugin';
|
|
2
2
|
export type { ErrorReport } from './plugins/bugsnagPlugin';
|
|
3
|
-
export { requestContextProviderPlugin, getRequestIdFastifyAppConfig,
|
|
3
|
+
export { requestContextProviderPlugin, getRequestIdFastifyAppConfig, } from './plugins/requestContextProviderPlugin';
|
|
4
4
|
export type { BaseRequestContext as RequestContext } from './plugins/requestContextProviderPlugin';
|
|
5
5
|
export { newrelicTransactionManagerPlugin, NewRelicTransactionManager, } from './plugins/newrelicTransactionManagerPlugin';
|
|
6
6
|
export type { NewRelicTransactionManagerOptions } from './plugins/newrelicTransactionManagerPlugin';
|
|
@@ -10,8 +10,6 @@ export { healthcheckMetricsPlugin, wrapHealthCheckForPrometheus, } from './plugi
|
|
|
10
10
|
export type { PrometheusHealthCheck, HealthcheckResult, HealthcheckMetricsPluginOptions, } from './plugins/healthcheck/healthcheckMetricsPlugin';
|
|
11
11
|
export { metricsPlugin } from './plugins/metricsPlugin';
|
|
12
12
|
export type { ErrorObjectResolver, MetricsPluginOptions } from './plugins/metricsPlugin';
|
|
13
|
-
export { prismaOtelTracingPlugin } from './plugins/opentelemetry/prismaOtelTracingPlugin';
|
|
14
|
-
export type { PrismaOtelTracingPluginConfig } from './plugins/opentelemetry/prismaOtelTracingPlugin';
|
|
15
13
|
export { publicHealthcheckPlugin } from './plugins/healthcheck/publicHealthcheckPlugin';
|
|
16
14
|
export type { PublicHealthcheckPluginOptions, HealthCheck, InfoProvider, } from './plugins/healthcheck/publicHealthcheckPlugin';
|
|
17
15
|
export { wrapHealthCheck } from './plugins/healthcheck/healthcheckCommons';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeJwtToken = exports.generateJwtToken = exports.isZodError = exports.createErrorHandler = exports.commonErrorObjectResolver = exports.unhandledExceptionPlugin = exports.AMPLITUDE_BASE_MESSAGE_SCHEMA = exports.AmplitudeAdapter = exports.Amplitude = exports.amplitudePlugin = exports.wrapHealthCheck = exports.publicHealthcheckPlugin = exports.
|
|
3
|
+
exports.decodeJwtToken = exports.generateJwtToken = exports.isZodError = exports.createErrorHandler = exports.commonErrorObjectResolver = exports.unhandledExceptionPlugin = exports.AMPLITUDE_BASE_MESSAGE_SCHEMA = exports.AmplitudeAdapter = exports.Amplitude = exports.amplitudePlugin = exports.wrapHealthCheck = exports.publicHealthcheckPlugin = exports.metricsPlugin = exports.wrapHealthCheckForPrometheus = exports.healthcheckMetricsPlugin = exports.SplitIOFeatureManager = exports.splitIOFeatureManagerPlugin = exports.NewRelicTransactionManager = exports.newrelicTransactionManagerPlugin = exports.getRequestIdFastifyAppConfig = exports.requestContextProviderPlugin = exports.addFeatureFlag = exports.bugsnagErrorReporter = exports.reportErrorToBugsnag = exports.bugsnagPlugin = void 0;
|
|
4
4
|
var bugsnagPlugin_1 = require("./plugins/bugsnagPlugin");
|
|
5
5
|
Object.defineProperty(exports, "bugsnagPlugin", { enumerable: true, get: function () { return bugsnagPlugin_1.bugsnagPlugin; } });
|
|
6
6
|
Object.defineProperty(exports, "reportErrorToBugsnag", { enumerable: true, get: function () { return bugsnagPlugin_1.reportErrorToBugsnag; } });
|
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "addFeatureFlag", { enumerable: true, get: functi
|
|
|
9
9
|
var requestContextProviderPlugin_1 = require("./plugins/requestContextProviderPlugin");
|
|
10
10
|
Object.defineProperty(exports, "requestContextProviderPlugin", { enumerable: true, get: function () { return requestContextProviderPlugin_1.requestContextProviderPlugin; } });
|
|
11
11
|
Object.defineProperty(exports, "getRequestIdFastifyAppConfig", { enumerable: true, get: function () { return requestContextProviderPlugin_1.getRequestIdFastifyAppConfig; } });
|
|
12
|
-
Object.defineProperty(exports, "REQUEST_ID_STORE_KEY", { enumerable: true, get: function () { return requestContextProviderPlugin_1.REQUEST_ID_STORE_KEY; } });
|
|
13
12
|
var newrelicTransactionManagerPlugin_1 = require("./plugins/newrelicTransactionManagerPlugin");
|
|
14
13
|
Object.defineProperty(exports, "newrelicTransactionManagerPlugin", { enumerable: true, get: function () { return newrelicTransactionManagerPlugin_1.newrelicTransactionManagerPlugin; } });
|
|
15
14
|
Object.defineProperty(exports, "NewRelicTransactionManager", { enumerable: true, get: function () { return newrelicTransactionManagerPlugin_1.NewRelicTransactionManager; } });
|
|
@@ -21,8 +20,6 @@ Object.defineProperty(exports, "healthcheckMetricsPlugin", { enumerable: true, g
|
|
|
21
20
|
Object.defineProperty(exports, "wrapHealthCheckForPrometheus", { enumerable: true, get: function () { return healthcheckMetricsPlugin_1.wrapHealthCheckForPrometheus; } });
|
|
22
21
|
var metricsPlugin_1 = require("./plugins/metricsPlugin");
|
|
23
22
|
Object.defineProperty(exports, "metricsPlugin", { enumerable: true, get: function () { return metricsPlugin_1.metricsPlugin; } });
|
|
24
|
-
var prismaOtelTracingPlugin_1 = require("./plugins/opentelemetry/prismaOtelTracingPlugin");
|
|
25
|
-
Object.defineProperty(exports, "prismaOtelTracingPlugin", { enumerable: true, get: function () { return prismaOtelTracingPlugin_1.prismaOtelTracingPlugin; } });
|
|
26
23
|
var publicHealthcheckPlugin_1 = require("./plugins/healthcheck/publicHealthcheckPlugin");
|
|
27
24
|
Object.defineProperty(exports, "publicHealthcheckPlugin", { enumerable: true, get: function () { return publicHealthcheckPlugin_1.publicHealthcheckPlugin; } });
|
|
28
25
|
var healthcheckCommons_1 = require("./plugins/healthcheck/healthcheckCommons");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;AAAA,yDAKgC;AAJ9B,8GAAA,aAAa,OAAA;AACb,qHAAA,oBAAoB,OAAA;AACpB,qHAAA,oBAAoB,OAAA;AACpB,+GAAA,cAAc,OAAA;AAIhB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;AAAA,yDAKgC;AAJ9B,8GAAA,aAAa,OAAA;AACb,qHAAA,oBAAoB,OAAA;AACpB,qHAAA,oBAAoB,OAAA;AACpB,+GAAA,cAAc,OAAA;AAIhB,uFAG+C;AAF7C,4IAAA,4BAA4B,OAAA;AAC5B,4IAAA,4BAA4B,OAAA;AAI9B,+FAGmD;AAFjD,oJAAA,gCAAgC,OAAA;AAChC,8IAAA,0BAA0B,OAAA;AAI5B,qFAG8C;AAF5C,0IAAA,2BAA2B,OAAA;AAC3B,oIAAA,qBAAqB,OAAA;AAIvB,2FAGuD;AAFrD,oIAAA,wBAAwB,OAAA;AACxB,wIAAA,4BAA4B,OAAA;AAQ9B,yDAAuD;AAA9C,8GAAA,aAAa,OAAA;AAGtB,yFAAuF;AAA9E,kIAAA,uBAAuB,OAAA;AAOhC,+EAA0E;AAAjE,qHAAA,eAAe,OAAA;AAGxB,uEAI4C;AAH1C,kHAAA,eAAe,OAAA;AAIjB,2DAAyD;AAAhD,sGAAA,SAAS,OAAA;AAClB,yEAK6C;AAJ3C,oHAAA,gBAAgB,OAAA;AAChB,iIAAA,6BAA6B,OAAA;AAO/B,+EAG2C;AAFzC,oIAAA,wBAAwB,OAAA;AACxB,qIAAA,yBAAyB,OAAA;AAI3B,sDAAsE;AAA7D,kHAAA,kBAAkB,OAAA;AAAE,0GAAA,UAAU,OAAA;AAGvC,qDAAyE;AAAhE,8GAAA,gBAAgB,OAAA;AAAE,4GAAA,cAAc,OAAA"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const backend_http_client_1 = require("@lokalise/backend-http-client");
|
|
5
5
|
const fastify_1 = tslib_1.__importDefault(require("fastify"));
|
|
6
6
|
const metricsPlugin_1 = require("../metricsPlugin");
|
|
7
7
|
const healthcheckMetricsPlugin_1 = require("./healthcheckMetricsPlugin");
|
|
8
8
|
let app;
|
|
9
|
+
const TEST_REQUEST_OPTIONS = {
|
|
10
|
+
requestLabel: 'test',
|
|
11
|
+
responseSchema: backend_http_client_1.UNKNOWN_RESPONSE_SCHEMA
|
|
12
|
+
};
|
|
9
13
|
async function initApp(healthChecks) {
|
|
10
14
|
const testApp = (0, fastify_1.default)();
|
|
11
15
|
app = testApp;
|
|
@@ -37,7 +41,7 @@ describe('healthcheckMetricsPlugin', () => {
|
|
|
37
41
|
},
|
|
38
42
|
},
|
|
39
43
|
]);
|
|
40
|
-
const response = await (0,
|
|
44
|
+
const response = await (0, backend_http_client_1.sendGet)((0, backend_http_client_1.buildClient)('http://127.0.0.1:9080'), '/metrics', TEST_REQUEST_OPTIONS);
|
|
41
45
|
expect(response.result.statusCode).toBe(200);
|
|
42
46
|
expect(response.result.body).toContain('test_healthcheck_availability 1');
|
|
43
47
|
expect(response.result.body).toContain('test_healthcheck_latency_msecs 345');
|
|
@@ -55,7 +59,7 @@ describe('healthcheckMetricsPlugin', () => {
|
|
|
55
59
|
},
|
|
56
60
|
},
|
|
57
61
|
]);
|
|
58
|
-
const response = await (0,
|
|
62
|
+
const response = await (0, backend_http_client_1.sendGet)((0, backend_http_client_1.buildClient)('http://127.0.0.1:9080'), '/metrics', TEST_REQUEST_OPTIONS);
|
|
59
63
|
expect(response.result.statusCode).toBe(200);
|
|
60
64
|
expect(response.result.body).toContain('test_healthcheck_availability 0');
|
|
61
65
|
expect(response.result.body).toContain('test_healthcheck_latency_msecs 1450');
|
|
@@ -83,7 +87,7 @@ describe('healthcheckMetricsPlugin', () => {
|
|
|
83
87
|
},
|
|
84
88
|
},
|
|
85
89
|
]);
|
|
86
|
-
const response = await (0,
|
|
90
|
+
const response = await (0, backend_http_client_1.sendGet)((0, backend_http_client_1.buildClient)('http://127.0.0.1:9080'), '/metrics', TEST_REQUEST_OPTIONS);
|
|
87
91
|
expect(response.result.statusCode).toBe(200);
|
|
88
92
|
expect(response.result.body).toContain('test_healthcheck_1_availability 1');
|
|
89
93
|
expect(response.result.body).toContain('test_healthcheck_1_latency_msecs 345');
|
|
@@ -112,7 +116,7 @@ describe('healthcheckMetricsPlugin', () => {
|
|
|
112
116
|
});
|
|
113
117
|
}, 'test_healthcheck'),
|
|
114
118
|
]);
|
|
115
|
-
const response = await (0,
|
|
119
|
+
const response = await (0, backend_http_client_1.sendGet)((0, backend_http_client_1.buildClient)('http://127.0.0.1:9080'), '/metrics', TEST_REQUEST_OPTIONS);
|
|
116
120
|
expect(response.result.statusCode).toBe(200);
|
|
117
121
|
expect(response.result.body).toContain('test_healthcheck_availability 1');
|
|
118
122
|
expect(response.result.body).toContain('test_healthcheck_latency_msecs');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"healthcheckMetricsPlugin.spec.js","sourceRoot":"","sources":["../../../lib/plugins/healthcheck/healthcheckMetricsPlugin.spec.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"healthcheckMetricsPlugin.spec.js","sourceRoot":"","sources":["../../../lib/plugins/healthcheck/healthcheckMetricsPlugin.spec.ts"],"names":[],"mappings":";;;AAAA,uEAA6F;AAG7F,8DAA6B;AAE7B,oDAAgD;AAGhD,yEAAmG;AAEnG,IAAI,GAAoB,CAAA;AAExB,MAAM,oBAAoB,GAAG;IAC3B,YAAY,EAAE,MAAM;IACpB,cAAc,EAAE,6CAAuB;CACxC,CAAA;AAED,KAAK,UAAU,OAAO,CAAC,YAAqC;IAC1D,MAAM,OAAO,GAAG,IAAA,iBAAO,GAAE,CAAA;IACzB,GAAG,GAAG,OAAO,CAAA;IACb,MAAM,GAAG,CAAC,QAAQ,CAAC,6BAAa,EAAE;QAChC,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,KAAK;QACpB,mBAAmB,EAAE,CAAC,GAAY,EAAE,EAAE,CAAC,GAAG;KAC3C,CAAC,CAAA;IACF,MAAM,GAAG,CAAC,QAAQ,CAAC,mDAAwB,EAAE;QAC3C,YAAY;KACb,CAAC,CAAA;IAEF,MAAM,GAAG,CAAC,KAAK,EAAE,CAAA;IACjB,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,GAAG,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QACpD,GAAG,GAAG,MAAM,OAAO,CAAC;YAClB;gBACE,IAAI,EAAE,kBAAkB;gBACxB,4DAA4D;gBAC5D,OAAO,EAAE,KAAK,IAAI,EAAE;oBAClB,OAAO;wBACL,WAAW,EAAE,IAAI;wBACjB,gBAAgB,EAAE,GAAG;qBACtB,CAAA;gBAC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KAAK;wBAClB,gBAAgB,EAAE,IAAI;qBACvB,CAAA;gBACH,CAAC;aACF;SACF,CAAC,CACH,CAAC,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;QACxE,GAAG,GAAG,MAAM,OAAO,CAAC;YAClB,IAAA,uDAA4B,EAAC,GAAiC,EAAE;gBAC9D,OAAO,OAAO,CAAC,OAAO,CAAC;oBACrB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAA;YACJ,CAAC,EAAE,kBAAkB,CAAC;SACvB,CAAC,CAAA;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAO,EAAC,IAAA,iCAAW,EAAC,uBAAuB,CAAC,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAA;QAEtG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAA;QACzE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAA;IAC1E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
4
|
+
const backend_http_client_1 = require("@lokalise/backend-http-client");
|
|
5
5
|
const fastify_1 = tslib_1.__importDefault(require("fastify"));
|
|
6
6
|
const metricsPlugin_1 = require("./metricsPlugin");
|
|
7
7
|
async function initApp(errorObjectResolver = (err) => err) {
|
|
@@ -23,7 +23,10 @@ describe('metricsPlugin', () => {
|
|
|
23
23
|
await app.close();
|
|
24
24
|
});
|
|
25
25
|
it('returns Prometheus metrics', async () => {
|
|
26
|
-
const response = await (0,
|
|
26
|
+
const response = await (0, backend_http_client_1.sendGet)((0, backend_http_client_1.buildClient)('http://127.0.0.1:9080'), '/metrics', {
|
|
27
|
+
requestLabel: 'test',
|
|
28
|
+
responseSchema: backend_http_client_1.UNKNOWN_RESPONSE_SCHEMA,
|
|
29
|
+
});
|
|
27
30
|
expect(response.result.statusCode).toBe(200);
|
|
28
31
|
expect(response.result.body).toEqual(expect.any(String));
|
|
29
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metricsPlugin.spec.js","sourceRoot":"","sources":["../../lib/plugins/metricsPlugin.spec.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"metricsPlugin.spec.js","sourceRoot":"","sources":["../../lib/plugins/metricsPlugin.spec.ts"],"names":[],"mappings":";;;AAAA,uEAA8F;AAE9F,8DAA6B;AAE7B,mDAA+C;AAE/C,KAAK,UAAU,OAAO,CAAC,sBAAsB,CAAC,GAAY,EAAE,EAAE,CAAC,GAAG;IAChE,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAA;IACrB,MAAM,GAAG,CAAC,QAAQ,CAAC,6BAAa,EAAE;QAChC,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,KAAK;QACpB,mBAAmB;KACpB,CAAC,CAAA;IAEF,MAAM,GAAG,CAAC,KAAK,EAAE,CAAA;IACjB,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,GAAoB,CAAA;IACxB,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,GAAG,GAAG,MAAM,OAAO,EAAE,CAAA;IACvB,CAAC,CAAC,CAAA;IACF,QAAQ,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,GAAG,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,QAAQ,GAAG,MAAM,IAAA,6BAAO,EAAC,IAAA,iCAAW,EAAC,uBAAuB,CAAC,EAAE,UAAU,EAAE;YAC/E,YAAY,EAAE,MAAM;YACpB,cAAc,EAAE,6CAAuB;SACxC,CAAC,CAAA;QAEF,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAC1D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAChC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QACpB,IAAI,YAAY,CAAA;QAChB,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACpB,YAAY,GAAG,GAAG,CAAA;gBAClB,OAAO,GAAG,CAAA;YACZ,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC;gBACxB,OAAO,EAAE,qDAAqD;aAC/D,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,CAAC,YAAY,CAAC,CAAC,aAAa,CAAC;YACjC,IAAI,EAAE,YAAY;SACnB,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { CommonLogger } from '@lokalise/node-core';
|
|
2
2
|
import type { FastifyInstance, FastifyServerOptions } from 'fastify';
|
|
3
|
-
export declare const REQUEST_ID_STORE_KEY = "request_id";
|
|
4
3
|
declare module 'fastify' {
|
|
5
4
|
interface FastifyRequest {
|
|
6
5
|
reqContext: RequestContext;
|
|
@@ -14,11 +13,6 @@ declare module 'fastify' {
|
|
|
14
13
|
interface RequestContext extends BaseRequestContext {
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
declare module '@fastify/request-context' {
|
|
18
|
-
interface RequestContextData {
|
|
19
|
-
[REQUEST_ID_STORE_KEY]: string;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
16
|
export declare function getRequestIdFastifyAppConfig(): Pick<FastifyServerOptions, 'genReqId' | 'requestIdHeader'>;
|
|
23
17
|
declare function plugin(fastify: FastifyInstance, opts: unknown, done: () => void): void;
|
|
24
18
|
export declare const requestContextProviderPlugin: typeof plugin;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requestContextProviderPlugin = exports.getRequestIdFastifyAppConfig =
|
|
3
|
+
exports.requestContextProviderPlugin = exports.getRequestIdFastifyAppConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_crypto_1 = require("node:crypto");
|
|
6
|
-
const request_context_1 = require("@fastify/request-context");
|
|
7
6
|
const fastify_plugin_1 = tslib_1.__importDefault(require("fastify-plugin"));
|
|
8
|
-
exports.REQUEST_ID_STORE_KEY = 'request_id';
|
|
9
7
|
function getRequestIdFastifyAppConfig() {
|
|
10
8
|
return {
|
|
11
9
|
genReqId: () => (0, node_crypto_1.randomUUID)(),
|
|
@@ -21,8 +19,6 @@ function plugin(fastify, opts, done) {
|
|
|
21
19
|
}),
|
|
22
20
|
reqId: req.id,
|
|
23
21
|
};
|
|
24
|
-
// Store request_id in AsyncLocalStorage to be picked up by instrumentation tooling, such as OpenTelemetry
|
|
25
|
-
request_context_1.requestContext.set(exports.REQUEST_ID_STORE_KEY, req.id);
|
|
26
22
|
next();
|
|
27
23
|
});
|
|
28
24
|
fastify.addHook('onSend', (req, res, payload, next) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestContextProviderPlugin.js","sourceRoot":"","sources":["../../lib/plugins/requestContextProviderPlugin.ts"],"names":[],"mappings":";;;;AAAA,6CAAwC;
|
|
1
|
+
{"version":3,"file":"requestContextProviderPlugin.js","sourceRoot":"","sources":["../../lib/plugins/requestContextProviderPlugin.ts"],"names":[],"mappings":";;;;AAAA,6CAAwC;AAUxC,4EAA+B;AAmB/B,SAAgB,4BAA4B;IAI1C,OAAO;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAA,wBAAU,GAAE;QAC5B,eAAe,EAAE,cAAc;KAChC,CAAA;AACH,CAAC;AARD,oEAQC;AAED,SAAS,MAAM,CAAC,OAAwB,EAAE,IAAa,EAAE,IAAgB;IACvE,OAAO,CAAC,OAAO,CACb,WAAW,EACX,SAAS,wBAAwB,CAC/B,GAAmB,EACnB,GAAiB,EACjB,IAA6B;QAE7B,GAAG,CAAC,UAAU,GAAG;YACf,MAAM,EAAG,GAAG,CAAC,GAAoB,CAAC,KAAK,CAAC;gBACtC,cAAc,EAAE,GAAG,CAAC,EAAE;aACvB,CAAC;YACF,KAAK,EAAE,GAAG,CAAC,EAAE;SACd,CAAA;QAED,IAAI,EAAE,CAAA;IACR,CAAC,CACF,CAAA;IAED,OAAO,CAAC,OAAO,CACb,QAAQ,EACR,CAAC,GAAmB,EAAE,GAAiB,EAAE,OAAO,EAAE,IAA6B,EAAE,EAAE;QACjF,KAAK,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,EAAE,CAAC,CAAA;QACvC,IAAI,EAAE,CAAA;IACR,CAAC,CACF,CAAA;IAED,IAAI,EAAE,CAAA;AACR,CAAC;AAEY,QAAA,4BAA4B,GAAG,IAAA,wBAAE,EAAC,MAAM,EAAE;IACrD,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,iCAAiC;CACxC,CAAC,CAAA"}
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unhandledExceptionPlugin = exports.commonErrorObjectResolver = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const request_context_1 = require("@fastify/request-context");
|
|
6
5
|
const node_core_1 = require("@lokalise/node-core");
|
|
7
6
|
const fastify_plugin_1 = tslib_1.__importDefault(require("fastify-plugin"));
|
|
8
7
|
const pino_1 = require("pino");
|
|
9
|
-
const requestContextProviderPlugin_1 = require("./requestContextProviderPlugin");
|
|
10
8
|
const commonErrorObjectResolver = (err, correlationId) => {
|
|
11
9
|
return {
|
|
12
10
|
...pino_1.stdSerializers.err(err),
|
|
@@ -15,14 +13,10 @@ const commonErrorObjectResolver = (err, correlationId) => {
|
|
|
15
13
|
};
|
|
16
14
|
exports.commonErrorObjectResolver = commonErrorObjectResolver;
|
|
17
15
|
function handler(app, opts, err) {
|
|
18
|
-
const
|
|
19
|
-
const logObject = opts.errorObjectResolver(err, reqId);
|
|
16
|
+
const logObject = opts.errorObjectResolver(err);
|
|
20
17
|
app.log.fatal(logObject, 'uncaught exception detected');
|
|
21
18
|
opts.errorReporter.report({
|
|
22
19
|
error: err,
|
|
23
|
-
context: {
|
|
24
|
-
'x-request-id': reqId,
|
|
25
|
-
},
|
|
26
20
|
});
|
|
27
21
|
if (opts.shutdownAfterHandling) {
|
|
28
22
|
// shutdown the server gracefully
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unhandledExceptionPlugin.js","sourceRoot":"","sources":["../../lib/plugins/unhandledExceptionPlugin.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"unhandledExceptionPlugin.js","sourceRoot":"","sources":["../../lib/plugins/unhandledExceptionPlugin.ts"],"names":[],"mappings":";;;;AACA,mDAA4D;AAE5D,4EAA+B;AAC/B,+BAAqC;AAE9B,MAAM,yBAAyB,GAAwB,CAC5D,GAAY,EACZ,aAAsB,EACb,EAAE;IACX,OAAO;QACL,GAAG,qBAAc,CAAC,GAAG,CAAC,GAAY,C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;AACR,CAAC;AAEY,QAAA,wBAAwB,GAAG,IAAA,wBAAE,EAAC,MAAM,EAAE;IACjD,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,4BAA4B;CACnC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/fastify-extras",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.1.0",
|
|
4
4
|
"description": "Opinionated set of fastify plugins, commonly used in Lokalise",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Lokalise",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"newrelic",
|
|
17
17
|
"bugsnag",
|
|
18
18
|
"request-context",
|
|
19
|
-
"als",
|
|
20
19
|
"request-id",
|
|
21
20
|
"split-io"
|
|
22
21
|
],
|
|
@@ -44,14 +43,6 @@
|
|
|
44
43
|
"dependencies": {
|
|
45
44
|
"@bugsnag/js": "^7.22.7",
|
|
46
45
|
"@lokalise/error-utils": "^1.2.2",
|
|
47
|
-
"@opentelemetry/api": "1.8.0",
|
|
48
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "0.50.0",
|
|
49
|
-
"@opentelemetry/instrumentation": "0.50.0",
|
|
50
|
-
"@opentelemetry/resources": "1.23.0",
|
|
51
|
-
"@opentelemetry/sdk-trace-base": "1.23.0",
|
|
52
|
-
"@opentelemetry/sdk-trace-node": "1.23.0",
|
|
53
|
-
"@opentelemetry/semantic-conventions": "1.23.0",
|
|
54
|
-
"@prisma/instrumentation": "^5.13.0",
|
|
55
46
|
"@splitsoftware/splitio": "^10.25.2",
|
|
56
47
|
"@amplitude/analytics-node": "^1.3.5",
|
|
57
48
|
"fastify-metrics": "^11.0.0",
|
|
@@ -60,7 +51,6 @@
|
|
|
60
51
|
"tslib": "^2.6.2"
|
|
61
52
|
},
|
|
62
53
|
"peerDependencies": {
|
|
63
|
-
"@fastify/request-context": "^5.1.0",
|
|
64
54
|
"fastify": "^4.24.3",
|
|
65
55
|
"@fastify/jwt": "^8.0.1",
|
|
66
56
|
"newrelic": "^11.13.0",
|
|
@@ -68,8 +58,8 @@
|
|
|
68
58
|
"zod": "^3.22.4"
|
|
69
59
|
},
|
|
70
60
|
"devDependencies": {
|
|
71
|
-
"@
|
|
72
|
-
"@lokalise/
|
|
61
|
+
"@lokalise/node-core": "^10.0.0",
|
|
62
|
+
"@lokalise/backend-http-client": "^1.0.0",
|
|
73
63
|
"@types/newrelic": "^9.14.3",
|
|
74
64
|
"@types/node": "^20.12.13",
|
|
75
65
|
"@amplitude/analytics-types": "^2.5.0",
|
|
@@ -81,7 +71,7 @@
|
|
|
81
71
|
"eslint-plugin-import": "^2.29.1",
|
|
82
72
|
"eslint-plugin-vitest": "0.4.1",
|
|
83
73
|
"fastify": "^4.27.0",
|
|
84
|
-
"newrelic": "11.
|
|
74
|
+
"newrelic": "11.19.0",
|
|
85
75
|
"pino": "^9.1.0",
|
|
86
76
|
"pino-pretty": "^11.1.0",
|
|
87
77
|
"prettier": "^3.2.5",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { FastifyInstance } from 'fastify';
|
|
2
|
-
export interface PrismaOtelTracingPluginConfig {
|
|
3
|
-
isEnabled: boolean;
|
|
4
|
-
useBatchSpans: boolean;
|
|
5
|
-
samplingRatio: number;
|
|
6
|
-
serviceName: string;
|
|
7
|
-
}
|
|
8
|
-
declare function plugin(app: FastifyInstance, opts: PrismaOtelTracingPluginConfig, done: () => void): void;
|
|
9
|
-
export declare const prismaOtelTracingPlugin: typeof plugin;
|
|
10
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prismaOtelTracingPlugin = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const exporter_trace_otlp_grpc_1 = require("@opentelemetry/exporter-trace-otlp-grpc");
|
|
6
|
-
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
7
|
-
const resources_1 = require("@opentelemetry/resources");
|
|
8
|
-
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
9
|
-
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
10
|
-
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
11
|
-
const instrumentation_2 = require("@prisma/instrumentation");
|
|
12
|
-
const fastify_plugin_1 = tslib_1.__importDefault(require("fastify-plugin"));
|
|
13
|
-
const spanProcessors_1 = require("./spanProcessors");
|
|
14
|
-
function plugin(app, opts, done) {
|
|
15
|
-
if (opts.isEnabled) {
|
|
16
|
-
const provider = new sdk_trace_node_1.NodeTracerProvider({
|
|
17
|
-
sampler: new sdk_trace_base_1.TraceIdRatioBasedSampler(opts.samplingRatio),
|
|
18
|
-
resource: new resources_1.Resource({
|
|
19
|
-
[semantic_conventions_1.SEMRESATTRS_SERVICE_NAME]: opts.serviceName,
|
|
20
|
-
}),
|
|
21
|
-
});
|
|
22
|
-
// Is configured by OTEL_EXPORTER_OTLP_* env vars
|
|
23
|
-
const otlpExporter = new exporter_trace_otlp_grpc_1.OTLPTraceExporter();
|
|
24
|
-
// Production sends spans in batches
|
|
25
|
-
if (opts.useBatchSpans) {
|
|
26
|
-
provider.addSpanProcessor(new spanProcessors_1.LokaliseBatchSpanProcessor(otlpExporter));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
provider.addSpanProcessor(new spanProcessors_1.LokaliseSimpleSpanProcessor(otlpExporter));
|
|
30
|
-
}
|
|
31
|
-
(0, instrumentation_1.registerInstrumentations)({
|
|
32
|
-
instrumentations: [new instrumentation_2.PrismaInstrumentation()],
|
|
33
|
-
tracerProvider: provider,
|
|
34
|
-
});
|
|
35
|
-
provider.register();
|
|
36
|
-
}
|
|
37
|
-
done();
|
|
38
|
-
}
|
|
39
|
-
exports.prismaOtelTracingPlugin = (0, fastify_plugin_1.default)(plugin, {
|
|
40
|
-
fastify: '4.x',
|
|
41
|
-
name: 'prisma-otel-tracing-plugin',
|
|
42
|
-
});
|
|
43
|
-
//# sourceMappingURL=prismaOtelTracingPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prismaOtelTracingPlugin.js","sourceRoot":"","sources":["../../../lib/plugins/opentelemetry/prismaOtelTracingPlugin.ts"],"names":[],"mappings":";;;;AAAA,sFAA2E;AAC3E,oEAAyE;AACzE,wDAAmD;AACnD,kEAAwE;AACxE,kEAAkE;AAClE,8EAA8E;AAC9E,6DAA+D;AAE/D,4EAA+B;AAE/B,qDAA0F;AAS1F,SAAS,MAAM,CAAC,GAAoB,EAAE,IAAmC,EAAE,IAAgB;IACzF,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,IAAI,mCAAkB,CAAC;YACtC,OAAO,EAAE,IAAI,yCAAwB,CAAC,IAAI,CAAC,aAAa,CAAC;YACzD,QAAQ,EAAE,IAAI,oBAAQ,CAAC;gBACrB,CAAC,+CAAwB,CAAC,EAAE,IAAI,CAAC,WAAW;aAC7C,CAAC;SACH,CAAC,CAAA;QAEF,iDAAiD;QACjD,MAAM,YAAY,GAAG,IAAI,4CAAiB,EAAE,CAAA;QAE5C,oCAAoC;QACpC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,QAAQ,CAAC,gBAAgB,CAAC,IAAI,2CAA0B,CAAC,YAAY,CAAC,CAAC,CAAA;QACzE,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,gBAAgB,CAAC,IAAI,4CAA2B,CAAC,YAAY,CAAC,CAAC,CAAA;QAC1E,CAAC;QAED,IAAA,0CAAwB,EAAC;YACvB,gBAAgB,EAAE,CAAC,IAAI,uCAAqB,EAAE,CAAC;YAC/C,cAAc,EAAE,QAAQ;SACzB,CAAC,CAAA;QAEF,QAAQ,CAAC,QAAQ,EAAE,CAAA;IACrB,CAAC;IAED,IAAI,EAAE,CAAA;AACR,CAAC;AAEY,QAAA,uBAAuB,GAAG,IAAA,wBAAE,EAAC,MAAM,EAAE;IAChD,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,4BAA4B;CACnC,CAAC,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Span } from '@opentelemetry/sdk-trace-base';
|
|
2
|
-
import { BatchSpanProcessor, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
3
|
-
/**
|
|
4
|
-
* Extends span processor to be able to attach custom attributes request id to spans.
|
|
5
|
-
*
|
|
6
|
-
* This might be easier in the future once the opentelemetry instrumentation for prisma
|
|
7
|
-
* has matured a bit more.
|
|
8
|
-
*
|
|
9
|
-
* @see https://github.com/prisma/prisma/issues/14640#issuecomment-1209931862
|
|
10
|
-
*/
|
|
11
|
-
export declare class LokaliseSimpleSpanProcessor extends SimpleSpanProcessor {
|
|
12
|
-
onStart(span: Span): void;
|
|
13
|
-
}
|
|
14
|
-
export declare class LokaliseBatchSpanProcessor extends BatchSpanProcessor {
|
|
15
|
-
onStart(span: Span): void;
|
|
16
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LokaliseBatchSpanProcessor = exports.LokaliseSimpleSpanProcessor = void 0;
|
|
4
|
-
const request_context_1 = require("@fastify/request-context");
|
|
5
|
-
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
6
|
-
const requestContextProviderPlugin_1 = require("../requestContextProviderPlugin");
|
|
7
|
-
/**
|
|
8
|
-
* Extends span processor to be able to attach custom attributes request id to spans.
|
|
9
|
-
*
|
|
10
|
-
* This might be easier in the future once the opentelemetry instrumentation for prisma
|
|
11
|
-
* has matured a bit more.
|
|
12
|
-
*
|
|
13
|
-
* @see https://github.com/prisma/prisma/issues/14640#issuecomment-1209931862
|
|
14
|
-
*/
|
|
15
|
-
class LokaliseSimpleSpanProcessor extends sdk_trace_base_1.SimpleSpanProcessor {
|
|
16
|
-
onStart(span) {
|
|
17
|
-
const requestId = request_context_1.requestContext.get(requestContextProviderPlugin_1.REQUEST_ID_STORE_KEY);
|
|
18
|
-
span.setAttribute(requestContextProviderPlugin_1.REQUEST_ID_STORE_KEY, requestId);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.LokaliseSimpleSpanProcessor = LokaliseSimpleSpanProcessor;
|
|
22
|
-
class LokaliseBatchSpanProcessor extends sdk_trace_base_1.BatchSpanProcessor {
|
|
23
|
-
onStart(span) {
|
|
24
|
-
const requestId = request_context_1.requestContext.get(requestContextProviderPlugin_1.REQUEST_ID_STORE_KEY);
|
|
25
|
-
span.setAttribute(requestContextProviderPlugin_1.REQUEST_ID_STORE_KEY, requestId);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.LokaliseBatchSpanProcessor = LokaliseBatchSpanProcessor;
|
|
29
|
-
//# sourceMappingURL=spanProcessors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"spanProcessors.js","sourceRoot":"","sources":["../../../lib/plugins/opentelemetry/spanProcessors.ts"],"names":[],"mappings":";;;AAAA,8DAAyD;AAEzD,kEAAuF;AAEvF,kFAAsE;AAEtE;;;;;;;GAOG;AACH,MAAa,2BAA4B,SAAQ,oCAAmB;IAClE,OAAO,CAAC,IAAU;QAChB,MAAM,SAAS,GAAG,gCAAc,CAAC,GAAG,CAAC,mDAAoB,CAAC,CAAA;QAC1D,IAAI,CAAC,YAAY,CAAC,mDAAoB,EAAE,SAAS,CAAC,CAAA;IACpD,CAAC;CACF;AALD,kEAKC;AAED,MAAa,0BAA2B,SAAQ,mCAAkB;IAChE,OAAO,CAAC,IAAU;QAChB,MAAM,SAAS,GAAG,gCAAc,CAAC,GAAG,CAAC,mDAAoB,CAAC,CAAA;QAC1D,IAAI,CAAC,YAAY,CAAC,mDAAoB,EAAE,SAAS,CAAC,CAAA;IACpD,CAAC;CACF;AALD,gEAKC"}
|