serverless-plugin-datadog 5.3.0 → 5.5.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.
Files changed (53) hide show
  1. package/README.md +2 -0
  2. package/dist/package.json +2 -9
  3. package/dist/src/env.d.ts +2 -1
  4. package/dist/src/env.d.ts.map +1 -1
  5. package/dist/src/env.js +21 -52
  6. package/dist/src/env.js.map +1 -1
  7. package/dist/src/git.d.ts +0 -5
  8. package/dist/src/git.d.ts.map +1 -1
  9. package/dist/src/git.js +1 -63
  10. package/dist/src/git.js.map +1 -1
  11. package/dist/src/index.js +13 -30
  12. package/dist/src/index.js.map +1 -1
  13. package/dist/src/layers-gov.json +12 -12
  14. package/dist/src/layers.json +147 -147
  15. package/dist/src/output.js +1 -1
  16. package/dist/src/output.js.map +1 -1
  17. package/package.json +2 -9
  18. package/dist/src/git-metadata/interfaces.d.ts +0 -10
  19. package/dist/src/git-metadata/interfaces.d.ts.map +0 -1
  20. package/dist/src/git-metadata/interfaces.js +0 -43
  21. package/dist/src/git-metadata/interfaces.js.map +0 -1
  22. package/dist/src/helpers/apikey.d.ts +0 -13
  23. package/dist/src/helpers/apikey.d.ts.map +0 -1
  24. package/dist/src/helpers/apikey.js +0 -74
  25. package/dist/src/helpers/apikey.js.map +0 -1
  26. package/dist/src/helpers/errors.d.ts +0 -3
  27. package/dist/src/helpers/errors.d.ts.map +0 -1
  28. package/dist/src/helpers/errors.js +0 -7
  29. package/dist/src/helpers/errors.js.map +0 -1
  30. package/dist/src/helpers/interfaces.d.ts +0 -20
  31. package/dist/src/helpers/interfaces.d.ts.map +0 -1
  32. package/dist/src/helpers/interfaces.js +0 -3
  33. package/dist/src/helpers/interfaces.js.map +0 -1
  34. package/dist/src/helpers/retry.d.ts +0 -3
  35. package/dist/src/helpers/retry.d.ts.map +0 -1
  36. package/dist/src/helpers/retry.js +0 -39
  37. package/dist/src/helpers/retry.js.map +0 -1
  38. package/dist/src/helpers/tags.d.ts +0 -29
  39. package/dist/src/helpers/tags.d.ts.map +0 -1
  40. package/dist/src/helpers/tags.js +0 -50
  41. package/dist/src/helpers/tags.js.map +0 -1
  42. package/dist/src/helpers/upload.d.ts +0 -45
  43. package/dist/src/helpers/upload.d.ts.map +0 -1
  44. package/dist/src/helpers/upload.js +0 -70
  45. package/dist/src/helpers/upload.js.map +0 -1
  46. package/dist/src/helpers/utils.d.ts +0 -31
  47. package/dist/src/helpers/utils.d.ts.map +0 -1
  48. package/dist/src/helpers/utils.js +0 -115
  49. package/dist/src/helpers/utils.js.map +0 -1
  50. package/dist/src/source-code-integration.d.ts +0 -15
  51. package/dist/src/source-code-integration.d.ts.map +0 -1
  52. package/dist/src/source-code-integration.js +0 -76
  53. package/dist/src/source-code-integration.js.map +0 -1
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommitInfo = void 0;
4
- class CommitInfo {
5
- constructor(hash, remote, trackedFiles) {
6
- this.repositoryPayload = () => JSON.stringify({
7
- data: [
8
- {
9
- files: this.trackedFiles,
10
- hash: this.hash,
11
- repository_url: this.remote,
12
- },
13
- ],
14
- // Make sure to update the version if the format of the JSON payloads changes in any way.
15
- version: 1,
16
- });
17
- this.hash = hash;
18
- this.remote = remote;
19
- this.trackedFiles = trackedFiles;
20
- }
21
- asMultipartPayload(cliVersion) {
22
- return {
23
- content: new Map([
24
- ["cli_version", { value: cliVersion }],
25
- ["type", { value: "repository" }],
26
- [
27
- "repository",
28
- {
29
- options: {
30
- contentType: "application/json",
31
- filename: "repository",
32
- },
33
- value: this.repositoryPayload(),
34
- },
35
- ],
36
- ["git_repository_url", { value: this.remote }],
37
- ["git_commit_sha", { value: this.hash }],
38
- ]),
39
- };
40
- }
41
- }
42
- exports.CommitInfo = CommitInfo;
43
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/git-metadata/interfaces.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAKrB,YAAY,IAAY,EAAE,MAAc,EAAE,YAAsB;QA2BxD,sBAAiB,GAAG,GAAW,EAAE,CACvC,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE;gBACJ;oBACE,KAAK,EAAE,IAAI,CAAC,YAAY;oBACxB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,cAAc,EAAE,IAAI,CAAC,MAAM;iBAC5B;aACF;YACD,yFAAyF;YACzF,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QArCH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEM,kBAAkB,CAAC,UAAkB;QAC1C,OAAO;YACL,OAAO,EAAE,IAAI,GAAG,CAAC;gBACf,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;gBACtC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;gBACjC;oBACE,YAAY;oBACZ;wBACE,OAAO,EAAE;4BACP,WAAW,EAAE,kBAAkB;4BAC/B,QAAQ,EAAE,YAAY;yBACvB;wBACD,KAAK,EAAE,IAAI,CAAC,iBAAiB,EAAE;qBAChC;iBACF;gBACD,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC9C,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;aACzC,CAAC;SACH,CAAC;IACJ,CAAC;CAcF;AA5CD,gCA4CC"}
@@ -1,13 +0,0 @@
1
- import { AxiosError } from "axios";
2
- /** ApiKeyValidator is an helper interface to interpret Datadog error responses and possibly check the
3
- * validity of the api key.
4
- */
5
- export interface ApiKeyValidator {
6
- verifyApiKey(error: AxiosError): Promise<void>;
7
- }
8
- export interface ApiKeyValidatorParams {
9
- apiKey: string;
10
- datadogSite: string;
11
- }
12
- export declare const newApiKeyValidator: (params: ApiKeyValidatorParams) => ApiKeyValidator;
13
- //# sourceMappingURL=apikey.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apikey.d.ts","sourceRoot":"","sources":["../../../src/helpers/apikey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAoB,MAAM,OAAO,CAAC;AAIrD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,WAAY,qBAAqB,KAAG,eACL,CAAC"}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.newApiKeyValidator = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const chalk_1 = __importDefault(require("chalk"));
18
- const errors_1 = require("./errors");
19
- const newApiKeyValidator = (params) => new ApiKeyValidatorImplem(params.apiKey, params.datadogSite);
20
- exports.newApiKeyValidator = newApiKeyValidator;
21
- /** ApiKeyValidator is an helper class to interpret Datadog error responses and possibly check the
22
- * validity of the api key.
23
- */
24
- class ApiKeyValidatorImplem {
25
- constructor(apiKey, datadogSite) {
26
- this.apiKey = apiKey;
27
- this.datadogSite = datadogSite;
28
- }
29
- /** Check if an API key is valid, based on the Axios error and defaulting to verify the API key
30
- * through Datadog's API for ambiguous cases.
31
- * An exception is raised when the API key is invalid.
32
- * Callers should catch the exception to display it nicely.
33
- */
34
- verifyApiKey(error) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- if (error.response === undefined) {
37
- return;
38
- }
39
- if (error.response.status === 403 || (error.response.status === 400 && !(yield this.isApiKeyValid()))) {
40
- throw new errors_1.InvalidConfigurationError(`${chalk_1.default.red.bold("DATADOG_API_KEY")} does not contain a valid API key for Datadog site ${this.datadogSite}`);
41
- }
42
- });
43
- }
44
- getApiKeyValidationURL() {
45
- return `https://api.${this.datadogSite}/api/v1/validate`;
46
- }
47
- isApiKeyValid() {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- if (this.isValid === undefined) {
50
- this.isValid = yield this.validateApiKey();
51
- }
52
- return this.isValid;
53
- });
54
- }
55
- validateApiKey() {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- try {
58
- const response = yield axios_1.default.get(this.getApiKeyValidationURL(), {
59
- headers: {
60
- "DD-API-KEY": this.apiKey,
61
- },
62
- });
63
- return response.data.valid;
64
- }
65
- catch (error) {
66
- if (error.response && error.response.status === 403) {
67
- return false;
68
- }
69
- throw error;
70
- }
71
- });
72
- }
73
- }
74
- //# sourceMappingURL=apikey.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apikey.js","sourceRoot":"","sources":["../../../src/helpers/apikey.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAAqD;AACrD,kDAA0B;AAC1B,qCAAqD;AAc9C,MAAM,kBAAkB,GAAG,CAAC,MAA6B,EAAmB,EAAE,CACnF,IAAI,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAA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C,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;oBACnD,OAAO,KAAK,CAAC;iBACd;gBACD,MAAM,KAAK,CAAC;aACb;QACH,CAAC;KAAA;CACF"}
@@ -1,3 +0,0 @@
1
- export declare class InvalidConfigurationError extends Error {
2
- }
3
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/helpers/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,yBAA0B,SAAQ,KAAK;CAAG"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidConfigurationError = void 0;
4
- class InvalidConfigurationError extends Error {
5
- }
6
- exports.InvalidConfigurationError = InvalidConfigurationError;
7
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/helpers/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,yBAA0B,SAAQ,KAAK;CAAG;AAAvD,8DAAuD"}
@@ -1,20 +0,0 @@
1
- import { AxiosPromise, AxiosRequestConfig, AxiosResponse } from "axios";
2
- import { CI_JOB_NAME, CI_JOB_URL, CI_PIPELINE_ID, CI_PIPELINE_NAME, CI_PIPELINE_NUMBER, CI_PIPELINE_URL, CI_PROVIDER_NAME, CI_STAGE_NAME, CI_WORKSPACE_PATH, GIT_BRANCH, GIT_COMMIT_AUTHOR_DATE, GIT_COMMIT_AUTHOR_EMAIL, GIT_COMMIT_AUTHOR_NAME, GIT_COMMIT_COMMITTER_DATE, GIT_COMMIT_COMMITTER_EMAIL, GIT_COMMIT_COMMITTER_NAME, GIT_COMMIT_MESSAGE, GIT_REPOSITORY_URL, GIT_SHA, GIT_TAG } from "./tags";
3
- export interface Metadata {
4
- ci: {
5
- pipeline: {
6
- url?: string;
7
- };
8
- provider: {
9
- name: string;
10
- };
11
- };
12
- git: {
13
- branch?: string;
14
- commitSha?: string;
15
- };
16
- }
17
- export declare type SpanTag = typeof CI_JOB_NAME | typeof CI_JOB_URL | typeof CI_PIPELINE_ID | typeof CI_PIPELINE_NAME | typeof CI_PIPELINE_NUMBER | typeof CI_PIPELINE_URL | typeof CI_PROVIDER_NAME | typeof CI_STAGE_NAME | typeof CI_WORKSPACE_PATH | typeof GIT_BRANCH | typeof GIT_REPOSITORY_URL | typeof GIT_SHA | typeof GIT_TAG | typeof GIT_COMMIT_AUTHOR_EMAIL | typeof GIT_COMMIT_AUTHOR_NAME | typeof GIT_COMMIT_AUTHOR_DATE | typeof GIT_COMMIT_MESSAGE | typeof GIT_COMMIT_COMMITTER_DATE | typeof GIT_COMMIT_COMMITTER_EMAIL | typeof GIT_COMMIT_COMMITTER_NAME;
18
- export declare type SpanTags = Partial<Record<SpanTag, string>>;
19
- export declare type RequestBuilder = (args: AxiosRequestConfig) => AxiosPromise<AxiosResponse>;
20
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/helpers/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EACL,WAAW,EACX,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,OAAO,EACR,MAAM,QAAQ,CAAC;AAEhB,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE;QACF,QAAQ,EAAE;YACR,GAAG,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;QACF,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;IACF,GAAG,EAAE;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,oBAAY,OAAO,GACf,OAAO,WAAW,GAClB,OAAO,UAAU,GACjB,OAAO,cAAc,GACrB,OAAO,gBAAgB,GACvB,OAAO,kBAAkB,GACzB,OAAO,eAAe,GACtB,OAAO,gBAAgB,GACvB,OAAO,aAAa,GACpB,OAAO,iBAAiB,GACxB,OAAO,UAAU,GACjB,OAAO,kBAAkB,GACzB,OAAO,OAAO,GACd,OAAO,OAAO,GACd,OAAO,uBAAuB,GAC9B,OAAO,sBAAsB,GAC7B,OAAO,sBAAsB,GAC7B,OAAO,kBAAkB,GACzB,OAAO,yBAAyB,GAChC,OAAO,0BAA0B,GACjC,OAAO,yBAAyB,CAAC;AAErC,oBAAY,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAExD,oBAAY,cAAc,GAAG,CAAC,IAAI,EAAE,kBAAkB,KAAK,YAAY,CAAC,aAAa,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/helpers/interfaces.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import retry from "async-retry";
2
- export declare const retryRequest: (requestPerformer: () => Promise<any>, retryOpts: retry.Options) => Promise<void>;
3
- //# sourceMappingURL=retry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/helpers/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,aAAa,CAAC;AAIhC,eAAO,MAAM,YAAY,qBAA4B,MAAM,QAAQ,GAAG,CAAC,aAAa,MAAM,OAAO,KAAG,QAAQ,IAAI,CAoB/G,CAAC"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.retryRequest = void 0;
16
- const async_retry_1 = __importDefault(require("async-retry"));
17
- const errorCodesNoRetry = [400, 403, 413];
18
- const retryRequest = (requestPerformer, retryOpts) => __awaiter(void 0, void 0, void 0, function* () {
19
- // Request function, passed to async-retry
20
- const doRequest = (bail) => __awaiter(void 0, void 0, void 0, function* () {
21
- try {
22
- yield requestPerformer();
23
- }
24
- catch (error) {
25
- if (error.response && errorCodesNoRetry.includes(error.response.status)) {
26
- // If it's an axios error with a status code that is excluded from retries, we bail to avoid retrying
27
- bail(error);
28
- return;
29
- }
30
- // Other cases are retried: other axios HTTP errors as well as
31
- // non-axios errors such as DNS resolution errors and connection timeouts
32
- throw error;
33
- }
34
- });
35
- // Do the actual call
36
- return (0, async_retry_1.default)(doRequest, retryOpts);
37
- });
38
- exports.retryRequest = retryRequest;
39
- //# sourceMappingURL=retry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/helpers/retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8DAAgC;AAEhC,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAEnC,MAAM,YAAY,GAAG,CAAO,gBAAoC,EAAE,SAAwB,EAAiB,EAAE;IAClH,0CAA0C;IAC1C,MAAM,SAAS,GAAG,CAAO,IAAwB,EAAE,EAAE;QACnD,IAAI;YACF,MAAM,gBAAgB,EAAE,CAAC;SAC1B;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,KAAK,CAAC,QAAQ,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBACvE,qGAAqG;gBACrG,IAAI,CAAC,KAAK,CAAC,CAAC;gBAEZ,OAAO;aACR;YACD,8DAA8D;YAC9D,yEAAyE;YACzE,MAAM,KAAK,CAAC;SACb;IACH,CAAC,CAAA,CAAC;IAEF,qBAAqB;IACrB,OAAO,IAAA,qBAAK,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AApBW,QAAA,YAAY,gBAoBvB"}
@@ -1,29 +0,0 @@
1
- export declare const CI_PIPELINE_URL = "ci.pipeline.url";
2
- export declare const CI_PROVIDER_NAME = "ci.provider.name";
3
- export declare const CI_PIPELINE_ID = "ci.pipeline.id";
4
- export declare const CI_PIPELINE_NAME = "ci.pipeline.name";
5
- export declare const CI_PIPELINE_NUMBER = "ci.pipeline.number";
6
- export declare const CI_WORKSPACE_PATH = "ci.workspace_path";
7
- export declare const GIT_REPOSITORY_URL = "git.repository_url";
8
- export declare const CI_JOB_URL = "ci.job.url";
9
- export declare const CI_JOB_NAME = "ci.job.name";
10
- export declare const CI_STAGE_NAME = "ci.stage.name";
11
- export declare const CI_LEVEL = "_dd.ci.level";
12
- export declare const CI_BUILD_LEVEL = "_dd.ci.build_level";
13
- export declare const GIT_BRANCH = "git.branch";
14
- export declare const GIT_COMMIT_AUTHOR_DATE = "git.commit.author.date";
15
- export declare const GIT_COMMIT_AUTHOR_EMAIL = "git.commit.author.email";
16
- export declare const GIT_COMMIT_AUTHOR_NAME = "git.commit.author.name";
17
- export declare const GIT_COMMIT_COMMITTER_DATE = "git.commit.committer.date";
18
- export declare const GIT_COMMIT_COMMITTER_EMAIL = "git.commit.committer.email";
19
- export declare const GIT_COMMIT_COMMITTER_NAME = "git.commit.committer.name";
20
- export declare const GIT_COMMIT_MESSAGE = "git.commit.message";
21
- export declare const GIT_SHA = "git.commit.sha";
22
- export declare const GIT_TAG = "git.tag";
23
- export declare const SPAN_TYPE = "span.type";
24
- /**
25
- * Receives an array of the form ['key:value', 'key2:value2']
26
- * and returns an object of the form {key: 'value', key2: 'value2'}
27
- */
28
- export declare const parseTags: (tags: string[]) => {};
29
- //# sourceMappingURL=tags.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../src/helpers/tags.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AACrD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,eAAO,MAAM,QAAQ,iBAAiB,CAAC;AAEvC,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAGnD,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AACjE,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AACrE,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AACvE,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AACrE,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,OAAO,mBAAmB,CAAC;AACxC,eAAO,MAAM,OAAO,YAAY,CAAC;AAGjC,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,SAAS,SAAU,MAAM,EAAE,OAgBvC,CAAC"}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseTags = exports.SPAN_TYPE = exports.GIT_TAG = exports.GIT_SHA = exports.GIT_COMMIT_MESSAGE = exports.GIT_COMMIT_COMMITTER_NAME = exports.GIT_COMMIT_COMMITTER_EMAIL = exports.GIT_COMMIT_COMMITTER_DATE = exports.GIT_COMMIT_AUTHOR_NAME = exports.GIT_COMMIT_AUTHOR_EMAIL = exports.GIT_COMMIT_AUTHOR_DATE = exports.GIT_BRANCH = exports.CI_BUILD_LEVEL = exports.CI_LEVEL = exports.CI_STAGE_NAME = exports.CI_JOB_NAME = exports.CI_JOB_URL = exports.GIT_REPOSITORY_URL = exports.CI_WORKSPACE_PATH = exports.CI_PIPELINE_NUMBER = exports.CI_PIPELINE_NAME = exports.CI_PIPELINE_ID = exports.CI_PROVIDER_NAME = exports.CI_PIPELINE_URL = void 0;
4
- // Build
5
- exports.CI_PIPELINE_URL = "ci.pipeline.url";
6
- exports.CI_PROVIDER_NAME = "ci.provider.name";
7
- exports.CI_PIPELINE_ID = "ci.pipeline.id";
8
- exports.CI_PIPELINE_NAME = "ci.pipeline.name";
9
- exports.CI_PIPELINE_NUMBER = "ci.pipeline.number";
10
- exports.CI_WORKSPACE_PATH = "ci.workspace_path";
11
- exports.GIT_REPOSITORY_URL = "git.repository_url";
12
- exports.CI_JOB_URL = "ci.job.url";
13
- exports.CI_JOB_NAME = "ci.job.name";
14
- exports.CI_STAGE_NAME = "ci.stage.name";
15
- exports.CI_LEVEL = "_dd.ci.level";
16
- // @deprecated TODO: remove this once backend is updated
17
- exports.CI_BUILD_LEVEL = "_dd.ci.build_level";
18
- // Git
19
- exports.GIT_BRANCH = "git.branch";
20
- exports.GIT_COMMIT_AUTHOR_DATE = "git.commit.author.date";
21
- exports.GIT_COMMIT_AUTHOR_EMAIL = "git.commit.author.email";
22
- exports.GIT_COMMIT_AUTHOR_NAME = "git.commit.author.name";
23
- exports.GIT_COMMIT_COMMITTER_DATE = "git.commit.committer.date";
24
- exports.GIT_COMMIT_COMMITTER_EMAIL = "git.commit.committer.email";
25
- exports.GIT_COMMIT_COMMITTER_NAME = "git.commit.committer.name";
26
- exports.GIT_COMMIT_MESSAGE = "git.commit.message";
27
- exports.GIT_SHA = "git.commit.sha";
28
- exports.GIT_TAG = "git.tag";
29
- // General
30
- exports.SPAN_TYPE = "span.type";
31
- /**
32
- * Receives an array of the form ['key:value', 'key2:value2']
33
- * and returns an object of the form {key: 'value', key2: 'value2'}
34
- */
35
- const parseTags = (tags) => {
36
- try {
37
- return tags.reduce((acc, keyValuePair) => {
38
- if (!keyValuePair.includes(":")) {
39
- return acc;
40
- }
41
- const [key, value] = keyValuePair.split(":");
42
- return Object.assign(Object.assign({}, acc), { [key]: value });
43
- }, {});
44
- }
45
- catch (e) {
46
- return {};
47
- }
48
- };
49
- exports.parseTags = parseTags;
50
- //# sourceMappingURL=tags.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/helpers/tags.ts"],"names":[],"mappings":";;;AAAA,QAAQ;AACK,QAAA,eAAe,GAAG,iBAAiB,CAAC;AACpC,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,UAAU,G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ReadStream } from "fs";
4
- import { ApiKeyValidator } from "./apikey";
5
- import { RequestBuilder } from "./interfaces";
6
- /** Multipart payload destined to be sent to Datadog's API
7
- */
8
- export interface MultipartPayload {
9
- content: Map<string, MultipartValue>;
10
- }
11
- export interface MultipartValue {
12
- options?: FormData.AppendOptions | string;
13
- value: string | ReadStream;
14
- }
15
- export interface UploadOptions {
16
- /** ApiKeyValidator (optional) throws an InvalidConfigurationException when upload fails because
17
- * of an invalid API key. Callers should most likely catch this exception and display it as a
18
- * nice error message.
19
- */
20
- apiKeyValidator?: ApiKeyValidator;
21
- /** Retries is the amount of upload retries before giving up. Some requests are never retried
22
- * (400, 413).
23
- */
24
- retries: number;
25
- /** Callback when upload fails (retries are not considered as failure)
26
- */
27
- onError(error: Error): void;
28
- /** Callback to execute before retries
29
- */
30
- onRetry(error: Error, attempts: number): void;
31
- /** Callback to execute before upload.
32
- */
33
- onUpload(): void;
34
- }
35
- export declare enum UploadStatus {
36
- Success = 0,
37
- Failure = 1,
38
- Skipped = 2
39
- }
40
- /** Upload a MultipartPayload to Datadog's API using the provided RequestBuilder.
41
- * This handles retries as well as logging information about upload if a logger is provided in
42
- * the options
43
- */
44
- export declare const upload: (requestBuilder: RequestBuilder) => (payload: MultipartPayload, opts: UploadOptions) => Promise<UploadStatus>;
45
- //# sourceMappingURL=upload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/helpers/upload.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C;GACG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,QAAQ,CAAC,aAAa,GAAG,MAAM,CAAC;IAC1C,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;OACG;IACH,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAE5B;OACG;IACH,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9C;OACG;IACH,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,oBAAY,YAAY;IACtB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,OAAO,IAAA;CACR;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,mBACA,cAAc,eACf,gBAAgB,QAAQ,aAAa,KAAG,QAAQ,YAAY,CAwB3E,CAAC"}
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.upload = exports.UploadStatus = void 0;
16
- const form_data_1 = __importDefault(require("form-data"));
17
- const retry_1 = require("./retry");
18
- var UploadStatus;
19
- (function (UploadStatus) {
20
- UploadStatus[UploadStatus["Success"] = 0] = "Success";
21
- UploadStatus[UploadStatus["Failure"] = 1] = "Failure";
22
- UploadStatus[UploadStatus["Skipped"] = 2] = "Skipped";
23
- })(UploadStatus = exports.UploadStatus || (exports.UploadStatus = {}));
24
- /** Upload a MultipartPayload to Datadog's API using the provided RequestBuilder.
25
- * This handles retries as well as logging information about upload if a logger is provided in
26
- * the options
27
- */
28
- const upload = (requestBuilder) => (payload, opts) => __awaiter(void 0, void 0, void 0, function* () {
29
- opts.onUpload();
30
- try {
31
- yield (0, retry_1.retryRequest)(() => uploadMultipart(requestBuilder, payload), {
32
- onRetry: opts.onRetry,
33
- retries: opts.retries,
34
- });
35
- return UploadStatus.Success;
36
- }
37
- catch (error) {
38
- if (opts.apiKeyValidator) {
39
- // Raise an exception in case of invalid API key
40
- yield opts.apiKeyValidator.verifyApiKey(error);
41
- }
42
- if (error.response && error.response.statusText) {
43
- // Rewrite error to have formatted error string
44
- opts.onError(new Error(`${error.message} (${error.response.statusText})`));
45
- }
46
- else {
47
- // Default error handling
48
- opts.onError(error);
49
- }
50
- return UploadStatus.Failure;
51
- }
52
- });
53
- exports.upload = upload;
54
- // Dependency follows-redirects sets a default maxBodyLength of 10 MB https://github.com/follow-redirects/follow-redirects/blob/b774a77e582b97174813b3eaeb86931becba69db/index.js#L391
55
- // We don't want any hard limit enforced by the CLI, the backend will enforce a max size by returning 413 errors.
56
- const maxBodyLength = Infinity;
57
- const uploadMultipart = (request, payload) => __awaiter(void 0, void 0, void 0, function* () {
58
- const form = new form_data_1.default();
59
- payload.content.forEach((value, key) => {
60
- form.append(key, value.value, value.options);
61
- });
62
- return request({
63
- data: form,
64
- headers: form.getHeaders(),
65
- maxBodyLength,
66
- method: "POST",
67
- url: "v1/input",
68
- });
69
- });
70
- //# sourceMappingURL=upload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../src/helpers/upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAiC;AAIjC,mCAA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AAG,IAAI,mBAAQ,EAAE,CAAC;IAC5B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAqB,EAAE,GAAW,EAAE,EAAE;QAC7D,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;QACb,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;QAC1B,aAAa;QACb,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,UAAU;KAChB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC"}
@@ -1,31 +0,0 @@
1
- import { AxiosRequestConfig } from "axios";
2
- import ProxyAgent from "proxy-agent";
3
- import type { SpanTags } from "./interfaces";
4
- export declare const pick: <T extends object, K extends keyof T>(base: T, keys: K[]) => Partial<T>;
5
- export declare const getConfig: (configPath: string) => Promise<any>;
6
- declare type ProxyType = "http" | "https" | "socks" | "socks4" | "socks4a" | "socks5" | "socks5h" | "pac+data" | "pac+file" | "pac+ftp" | "pac+http" | "pac+https";
7
- export interface ProxyConfiguration {
8
- auth?: {
9
- password: string;
10
- username: string;
11
- };
12
- host?: string;
13
- port?: number;
14
- protocol: ProxyType;
15
- }
16
- export declare const getProxyUrl: (options?: ProxyConfiguration | undefined) => string;
17
- export interface RequestOptions {
18
- apiKey: string;
19
- appKey?: string;
20
- baseUrl: string;
21
- headers?: Map<string, string>;
22
- overrideUrl?: string;
23
- proxyOpts?: ProxyConfiguration;
24
- }
25
- export declare const getRequestBuilder: (options: RequestOptions) => (args: AxiosRequestConfig) => import("axios").AxiosPromise<any>;
26
- export declare const getProxyAgent: (proxyOpts?: ProxyConfiguration | undefined) => ReturnType<typeof ProxyAgent>;
27
- export declare const getApiHostForSite: (site: string) => string;
28
- export declare const buildPath: (...args: string[]) => string;
29
- export declare const removeEmptyValues: (tags: SpanTags) => {};
30
- export {};
31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AAIF,eAAO,MAAM,SAAS,YAAa,MAAM,EAAE,WAc7B,CAAC;AAEf,eAAO,MAAM,iBAAiB,SAAU,QAAQ,OAUxC,CAAC"}
@@ -1,115 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.removeEmptyValues = exports.buildPath = exports.getApiHostForSite = exports.getProxyAgent = exports.getRequestBuilder = exports.getProxyUrl = exports.getConfig = exports.pick = void 0;
16
- const axios_1 = __importDefault(require("axios"));
17
- const fs_1 = __importDefault(require("fs"));
18
- const proxy_agent_1 = __importDefault(require("proxy-agent"));
19
- const util_1 = require("util");
20
- const pick = (base, keys) => {
21
- const definedKeys = keys.filter((key) => !!base[key]);
22
- const pickedObject = {};
23
- for (const key of definedKeys) {
24
- pickedObject[key] = base[key];
25
- }
26
- return pickedObject;
27
- };
28
- exports.pick = pick;
29
- const getConfig = (configPath) => __awaiter(void 0, void 0, void 0, function* () {
30
- const configFile = yield (0, util_1.promisify)(fs_1.default.readFile)(configPath, "utf-8");
31
- return JSON.parse(configFile);
32
- });
33
- exports.getConfig = getConfig;
34
- const getProxyUrl = (options) => {
35
- if (!options) {
36
- return "";
37
- }
38
- const { auth, host, port, protocol } = options;
39
- if (!host || !port) {
40
- return "";
41
- }
42
- const authFragment = auth ? `${auth.username}:${auth.password}@` : "";
43
- return `${protocol}://${authFragment}${host}:${port}`;
44
- };
45
- exports.getProxyUrl = getProxyUrl;
46
- const getRequestBuilder = (options) => {
47
- const { apiKey, appKey, baseUrl, overrideUrl, proxyOpts } = options;
48
- const overrideArgs = (args) => {
49
- const newArguments = Object.assign(Object.assign({}, args), { headers: Object.assign(Object.assign({ "DD-API-KEY": apiKey }, (appKey ? { "DD-APPLICATION-KEY": appKey } : {})), args.headers) });
50
- if (overrideUrl !== undefined) {
51
- newArguments.url = overrideUrl;
52
- }
53
- const proxyAgent = (0, exports.getProxyAgent)(proxyOpts);
54
- if (proxyAgent) {
55
- newArguments.httpAgent = proxyAgent;
56
- newArguments.httpsAgent = proxyAgent;
57
- }
58
- if (options.headers !== undefined) {
59
- options.headers.forEach((value, key) => {
60
- newArguments.headers[key] = value;
61
- });
62
- }
63
- return newArguments;
64
- };
65
- const baseConfiguration = {
66
- baseURL: baseUrl,
67
- // Disabling proxy in Axios config as it's not working properly
68
- // the passed httpAgent/httpsAgent are handling the proxy instead.
69
- proxy: false,
70
- };
71
- return (args) => axios_1.default.create(baseConfiguration)(overrideArgs(args));
72
- };
73
- exports.getRequestBuilder = getRequestBuilder;
74
- const getProxyAgent = (proxyOpts) => {
75
- const proxyUrlFromConfiguration = (0, exports.getProxyUrl)(proxyOpts);
76
- return new proxy_agent_1.default(proxyUrlFromConfiguration);
77
- };
78
- exports.getProxyAgent = getProxyAgent;
79
- const getApiHostForSite = (site) => {
80
- switch (site) {
81
- case "datad0g.com":
82
- return `app.${site}`;
83
- case "datadoghq.com":
84
- case "datadoghq.eu":
85
- default:
86
- return `api.${site}`;
87
- }
88
- };
89
- exports.getApiHostForSite = getApiHostForSite;
90
- // The buildPath function is used to concatenate several paths. The goal is to have a function working for both unix
91
- // paths and URL whereas standard path.join does not work with both.
92
- const buildPath = (...args) => args
93
- .map((part, i) => {
94
- if (i === 0) {
95
- // For the first part, drop all / at the end of the path
96
- return part.trim().replace(/[\/]*$/g, "");
97
- }
98
- else {
99
- // For the following parts, remove all / at the beginning and at the end
100
- return part.trim().replace(/(^[\/]*|[\/]*$)/g, "");
101
- }
102
- })
103
- // Filter out emtpy parts
104
- .filter((x) => x.length)
105
- // Join all these parts with /
106
- .join("/");
107
- exports.buildPath = buildPath;
108
- const removeEmptyValues = (tags) => Object.keys(tags).reduce((filteredTags, tag) => {
109
- if (!tags[tag]) {
110
- return filteredTags;
111
- }
112
- return Object.assign(Object.assign({}, filteredTags), { [tag]: tags[tag] });
113
- }, {});
114
- exports.removeEmptyValues = removeEmptyValues;
115
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/helpers/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA6D;AAC7D,4CAAoB;AACpB,8DAAqC;AACrC,+BAAiC;AAG1B,MAAM,IAAI,GAAG,CAAsC,IAAO,EAAE,IAAS,EAAE,EAAE;IAC9E,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,MAAM,YAAY,GAAe,EAAE,CAAC;IAEpC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE;QAC7B,YAAY,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;KAC/B;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AATW,QAAA,IAAI,QASf;AAEK,MAAM,SAAS,GAAG,CAAO,UAAkB,EAAE,EAAE;IACpD,MAAM,UAAU,GAAG,MAAM,IAAA,gBAAS,EAAC,YAAE,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAErE,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC,CAAA,CAAC;AAJW,QAAA,SAAS,aAIpB;AA0BK,MAAM,WAAW,GAAG,CAAC,OAA4B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