@opentelemetry/configuration 0.222.0 → 0.300.0-development.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigFactory.cjs +12 -0
- package/dist/ConfigFactory.cjs.map +1 -0
- package/dist/ConfigFactory.d.cts +6 -0
- package/dist/ConfigFactory.d.cts.map +1 -0
- package/dist/ConfigFactory.d.mts +6 -0
- package/dist/ConfigFactory.d.mts.map +1 -0
- package/dist/ConfigFactory.mjs +12 -0
- package/dist/ConfigFactory.mjs.map +1 -0
- package/dist/EnvDefinition.cjs +34 -0
- package/dist/EnvDefinition.cjs.map +1 -0
- package/dist/EnvDefinition.mjs +33 -0
- package/dist/EnvDefinition.mjs.map +1 -0
- package/dist/EnvReader.cjs +37 -0
- package/dist/EnvReader.cjs.map +1 -0
- package/dist/EnvReader.mjs +36 -0
- package/dist/EnvReader.mjs.map +1 -0
- package/dist/EnvironmentConfigFactory.cjs +354 -0
- package/dist/EnvironmentConfigFactory.cjs.map +1 -0
- package/dist/EnvironmentConfigFactory.mjs +347 -0
- package/dist/EnvironmentConfigFactory.mjs.map +1 -0
- package/dist/FileConfigFactory.cjs +141 -0
- package/dist/FileConfigFactory.cjs.map +1 -0
- package/{build/src/FileConfigFactory.d.ts → dist/FileConfigFactory.d.cts} +8 -12
- package/dist/FileConfigFactory.d.cts.map +1 -0
- package/dist/FileConfigFactory.d.mts +28 -0
- package/dist/FileConfigFactory.d.mts.map +1 -0
- package/dist/FileConfigFactory.mjs +134 -0
- package/dist/FileConfigFactory.mjs.map +1 -0
- package/dist/IConfigFactory.d.cts +13 -0
- package/dist/IConfigFactory.d.cts.map +1 -0
- package/dist/IConfigFactory.d.mts +13 -0
- package/dist/IConfigFactory.d.mts.map +1 -0
- package/dist/_virtual/_rolldown/runtime.cjs +25 -0
- package/dist/_virtual/_rolldown/runtime.mjs +4 -0
- package/dist/generated/types.d.cts +1662 -0
- package/dist/generated/types.d.cts.map +1 -0
- package/dist/generated/types.d.mts +1662 -0
- package/dist/generated/types.d.mts.map +1 -0
- package/dist/generated/validator.cjs +14385 -0
- package/dist/generated/validator.cjs.map +1 -0
- package/dist/generated/validator.mjs +14381 -0
- package/dist/generated/validator.mjs.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +3 -0
- package/dist/utils.cjs +137 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.mjs +129 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +28 -19
- package/build/src/ConfigFactory.d.ts +0 -3
- package/build/src/ConfigFactory.js +0 -19
- package/build/src/ConfigFactory.js.map +0 -1
- package/build/src/EnvDefinition.d.ts +0 -15
- package/build/src/EnvDefinition.js +0 -36
- package/build/src/EnvDefinition.js.map +0 -1
- package/build/src/EnvReader.d.ts +0 -24
- package/build/src/EnvReader.js +0 -60
- package/build/src/EnvReader.js.map +0 -1
- package/build/src/EnvironmentConfigFactory.d.ts +0 -19
- package/build/src/EnvironmentConfigFactory.js +0 -540
- package/build/src/EnvironmentConfigFactory.js.map +0 -1
- package/build/src/FileConfigFactory.js +0 -177
- package/build/src/FileConfigFactory.js.map +0 -1
- package/build/src/IConfigFactory.d.ts +0 -10
- package/build/src/IConfigFactory.js +0 -7
- package/build/src/IConfigFactory.js.map +0 -1
- package/build/src/generated/types.d.ts +0 -1659
- package/build/src/generated/types.js +0 -13
- package/build/src/generated/types.js.map +0 -1
- package/build/src/generated/validator.d.ts +0 -17
- package/build/src/generated/validator.js +0 -8533
- package/build/src/generated/validator.js.map +0 -1
- package/build/src/index.d.ts +0 -5
- package/build/src/index.js +0 -14
- package/build/src/index.js.map +0 -1
- package/build/src/utils.d.ts +0 -20
- package/build/src/utils.js +0 -188
- package/build/src/utils.js.map +0 -1
- package/build/src/version.d.ts +0 -2
- package/build/src/version.js +0 -10
- package/build/src/version.js.map +0 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_utils = require("./utils.cjs");
|
|
3
|
+
const require_validator$1 = require("./generated/validator.cjs");
|
|
4
|
+
let _opentelemetry_core = require("@opentelemetry/core");
|
|
5
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
6
|
+
let yaml = require("yaml");
|
|
7
|
+
yaml = require_runtime.__toESM(yaml);
|
|
8
|
+
let fs = require("fs");
|
|
9
|
+
fs = require_runtime.__toESM(fs);
|
|
10
|
+
//#region src/FileConfigFactory.ts
|
|
11
|
+
const validateConfig = require_validator$1.default;
|
|
12
|
+
var FileConfigFactory = class {
|
|
13
|
+
_config;
|
|
14
|
+
constructor() {
|
|
15
|
+
this._config = parseConfigFile();
|
|
16
|
+
}
|
|
17
|
+
getConfigModel() {
|
|
18
|
+
return this._config;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const SUPPORTED_FILE_FORMAT_MAJOR = 1;
|
|
22
|
+
const SUPPORTED_FILE_FORMAT_MINOR = 1;
|
|
23
|
+
function validateFileFormat(configFile, fileFormat) {
|
|
24
|
+
if (typeof fileFormat !== "string" || fileFormat.length === 0) throw new Error(`${configFile}: Unsupported file_format: "${fileFormat}". Expected a "MAJOR.MINOR" version string.`);
|
|
25
|
+
const parts = fileFormat.split("-", 1)[0].split(".");
|
|
26
|
+
const major = Number(parts[0]);
|
|
27
|
+
const minor = parts.length > 1 ? Number(parts[1]) : 0;
|
|
28
|
+
if (!Number.isInteger(major) || !Number.isInteger(minor)) throw new Error(`${configFile}: Unsupported file_format: "${fileFormat}". Expected "MAJOR.MINOR" version numbers.`);
|
|
29
|
+
if (major !== SUPPORTED_FILE_FORMAT_MAJOR) throw new Error(`${configFile}: Unsupported file_format: "${fileFormat}". This SDK supports schema version ${SUPPORTED_FILE_FORMAT_MAJOR}.x.`);
|
|
30
|
+
if (minor > SUPPORTED_FILE_FORMAT_MINOR) _opentelemetry_api.diag.warn(`${configFile}: Configuration file_format "${fileFormat}" has a newer minor version than this SDK supports (${SUPPORTED_FILE_FORMAT_MAJOR}.${SUPPORTED_FILE_FORMAT_MINOR}); some settings may be ignored.`);
|
|
31
|
+
}
|
|
32
|
+
function parseConfigFile() {
|
|
33
|
+
const configFile = (0, _opentelemetry_core.getStringFromEnv)("OTEL_CONFIG_FILE") || "";
|
|
34
|
+
const file = fs.readFileSync(configFile, "utf8");
|
|
35
|
+
const doc = yaml.parseDocument(file, { version: "1.2" });
|
|
36
|
+
require_utils.substituteEnvVars(doc);
|
|
37
|
+
const processed = doc.toJS();
|
|
38
|
+
validateFileFormat(configFile, processed?.file_format);
|
|
39
|
+
if (!validateConfig(processed)) {
|
|
40
|
+
let detail;
|
|
41
|
+
if (!validateConfig.errors) detail = "unknown error";
|
|
42
|
+
else if (validateConfig.errors.length === 1) {
|
|
43
|
+
const err = validateConfig.errors[0];
|
|
44
|
+
detail = `${err.instancePath} ${err.message}`;
|
|
45
|
+
} else {
|
|
46
|
+
const sep = "\n ";
|
|
47
|
+
detail = sep + validateConfig.errors.map((e) => `${e.instancePath} ${e.message}`).join(sep);
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Invalid OpenTelemetry config file: ${configFile}: ${detail}`);
|
|
50
|
+
}
|
|
51
|
+
const data = processed;
|
|
52
|
+
delete data["file_format"];
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Merge attributes from `resource.attributes` and `resource.attributes_list`
|
|
57
|
+
* (comma-separated key=value pairs) into an `AttributeNameValue[]` array.
|
|
58
|
+
* Entries already in `resource.attributes` taking precedence.
|
|
59
|
+
*
|
|
60
|
+
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
61
|
+
*/
|
|
62
|
+
function mergeResourceAttributesConfig(attributes, attributes_list) {
|
|
63
|
+
if (!attributes_list) return attributes;
|
|
64
|
+
const mergedAttrs = attributes ? attributes.slice() : [];
|
|
65
|
+
const existingNames = new Set(mergedAttrs.map((a) => a.name));
|
|
66
|
+
let discard = false;
|
|
67
|
+
const listAttrs = {};
|
|
68
|
+
for (const pair of attributes_list.split(",")) {
|
|
69
|
+
if (pair.trim() === "") continue;
|
|
70
|
+
const parts = pair.split("=");
|
|
71
|
+
if (parts.length !== 2) {
|
|
72
|
+
_opentelemetry_api.diag.warn(`Invalid format for resource.attributes_list entry "${pair}": expected key=value with '=' percent-encoded in keys/values. Discarding all entries.`);
|
|
73
|
+
discard = true;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const rawName = parts[0].trim();
|
|
77
|
+
const rawValue = parts[1].trim();
|
|
78
|
+
if (rawName === "") {
|
|
79
|
+
_opentelemetry_api.diag.warn(`Empty attribute name in resource.attributes_list entry "${pair}". Discarding all entries.`);
|
|
80
|
+
discard = true;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
listAttrs[decodeURIComponent(rawName)] = decodeURIComponent(rawValue);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
_opentelemetry_api.diag.warn(`Failed to percent-decode resource.attributes_list entry "${pair}", discarding all entries: ${e}`);
|
|
87
|
+
discard = true;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!discard) {
|
|
92
|
+
for (const [name, value] of Object.entries(listAttrs)) if (!existingNames.has(name)) mergedAttrs.push({
|
|
93
|
+
name,
|
|
94
|
+
value,
|
|
95
|
+
type: "string"
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return mergedAttrs;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Merge headers from `headers` and `headers_list` (comma-separated key=value
|
|
102
|
+
* pairs) into a record. Entries in `headers` take precedence.
|
|
103
|
+
*/
|
|
104
|
+
function mergeHeadersConfig(headers, headers_list) {
|
|
105
|
+
if (!headers && !headers_list) return;
|
|
106
|
+
const mergedHeaders = (0, _opentelemetry_core.parseKeyPairsIntoRecord)(headers_list ?? void 0);
|
|
107
|
+
headers?.forEach((header) => {
|
|
108
|
+
if (header.value !== null) mergedHeaders[header.name] = header.value;
|
|
109
|
+
});
|
|
110
|
+
return mergedHeaders;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Merge propagator.composite_list (comma-separated propagator names) into
|
|
114
|
+
* propagator.composite, with entries already in composite taking precedence.
|
|
115
|
+
* Merge TextMapPropagator configs from `propagator.composite` and `propagator.composite_list`
|
|
116
|
+
* (comma-separated names) into a `TextMapPropagator[]` array.
|
|
117
|
+
* Entries already in `propagator.composite` taking precedence.
|
|
118
|
+
*
|
|
119
|
+
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
120
|
+
*/
|
|
121
|
+
function mergePropagatorCompositeConfig(composite, composite_list) {
|
|
122
|
+
if (!composite_list) return composite;
|
|
123
|
+
const mergedComposite = composite ? composite.slice() : [];
|
|
124
|
+
const existingNames = new Set(mergedComposite.map((c) => Object.keys(c)[0]));
|
|
125
|
+
for (const name of composite_list.split(",")) {
|
|
126
|
+
const trimmed = name.trim();
|
|
127
|
+
if (trimmed && !existingNames.has(trimmed)) {
|
|
128
|
+
mergedComposite.push({ [trimmed]: null });
|
|
129
|
+
existingNames.add(trimmed);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return mergedComposite;
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
exports.FileConfigFactory = FileConfigFactory;
|
|
136
|
+
exports.mergeHeadersConfig = mergeHeadersConfig;
|
|
137
|
+
exports.mergePropagatorCompositeConfig = mergePropagatorCompositeConfig;
|
|
138
|
+
exports.mergeResourceAttributesConfig = mergeResourceAttributesConfig;
|
|
139
|
+
exports.parseConfigFile = parseConfigFile;
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=FileConfigFactory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileConfigFactory.cjs","names":["getStringFromEnv","parseKeyPairsIntoRecord"],"sources":["../src/FileConfigFactory.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { diag } from '@opentelemetry/api';\nimport { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';\nimport * as fs from 'fs';\nimport * as yaml from 'yaml';\nimport type { ConfigFactory } from './IConfigFactory';\nimport { substituteEnvVars } from './utils';\nimport type {\n AttributeNameValue,\n ConfigurationModel,\n NameStringValuePair,\n TextMapPropagator,\n} from './generated/types';\n// Pre-compiled ajv validator — eliminates runtime schema compilation on cold start.\n// Generated by `npm run generate:config`; do not import ajv directly here.\n// The generated module uses CJS `module.exports = fn`. `import = require` is the\n// only TypeScript form that works equivalently under both CJS and ESM consumers.\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nimport validateConfig = require('./generated/validator');\n\nexport class FileConfigFactory implements ConfigFactory {\n private _config: ConfigurationModel;\n\n constructor() {\n this._config = parseConfigFile();\n }\n\n getConfigModel(): ConfigurationModel {\n return this._config;\n }\n}\n\n// The schema version this SDK targets. Per the configuration versioning spec,\n// an implementation MUST reject a config file whose MAJOR version differs (a\n// breaking-change boundary), accepts any MINOR version within that major, and\n// SHOULD warn when the MINOR version is newer than it targets since unknown\n// settings may be ignored. See\n// https://github.com/open-telemetry/opentelemetry-configuration/blob/main/VERSIONING.md\nconst SUPPORTED_FILE_FORMAT_MAJOR = 1;\nconst SUPPORTED_FILE_FORMAT_MINOR = 1;\n\nfunction validateFileFormat(configFile: string, fileFormat: unknown): void {\n if (typeof fileFormat !== 'string' || fileFormat.length === 0) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". Expected a \"MAJOR.MINOR\" version string.`\n );\n }\n\n // Drop any pre-release / meta tag, e.g. \"1.0-rc.2\" -> \"1.0\".\n const parts = fileFormat.split('-', 1)[0].split('.');\n const major = Number(parts[0]);\n const minor = parts.length > 1 ? Number(parts[1]) : 0;\n if (!Number.isInteger(major) || !Number.isInteger(minor)) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". Expected \"MAJOR.MINOR\" version numbers.`\n );\n }\n\n if (major !== SUPPORTED_FILE_FORMAT_MAJOR) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". This SDK supports schema version ${SUPPORTED_FILE_FORMAT_MAJOR}.x.`\n );\n }\n\n if (minor > SUPPORTED_FILE_FORMAT_MINOR) {\n diag.warn(\n `${configFile}: Configuration file_format \"${fileFormat}\" has a newer minor version than this SDK supports (${SUPPORTED_FILE_FORMAT_MAJOR}.${SUPPORTED_FILE_FORMAT_MINOR}); some settings may be ignored.`\n );\n }\n}\n\nexport function parseConfigFile(): ConfigurationModel {\n const configFile = getStringFromEnv('OTEL_CONFIG_FILE') || '';\n const file = fs.readFileSync(configFile, 'utf8');\n\n const doc = yaml.parseDocument(file, { version: '1.2' });\n substituteEnvVars(doc);\n const processed = doc.toJS() as Record<string, unknown>;\n\n validateFileFormat(configFile, processed?.file_format);\n\n const valid = validateConfig(processed);\n if (!valid) {\n let detail: string;\n if (!validateConfig.errors) {\n detail = 'unknown error';\n } else if (validateConfig.errors.length === 1) {\n const err = validateConfig.errors[0];\n detail = `${err.instancePath} ${err.message}`;\n } else {\n const sep = '\\n ';\n detail =\n sep +\n validateConfig.errors\n .map(e => `${e.instancePath} ${e.message}`)\n .join(sep);\n }\n throw new Error(\n `Invalid OpenTelemetry config file: ${configFile}: ${detail}`\n );\n }\n\n const data = processed as unknown as ConfigurationModel;\n\n // Strip file_format from output — it's a meta-field, not a config value\n delete (data as Record<string, unknown>)['file_format'];\n\n return data;\n}\n\n/**\n * Merge attributes from `resource.attributes` and `resource.attributes_list`\n * (comma-separated key=value pairs) into an `AttributeNameValue[]` array.\n * Entries already in `resource.attributes` taking precedence.\n *\n * Note: The returned array might not be a copy, so it should not be mutated.\n */\nexport function mergeResourceAttributesConfig(\n attributes?: AttributeNameValue[],\n attributes_list?: string | null\n): AttributeNameValue[] | undefined {\n if (!attributes_list) {\n return attributes;\n }\n\n const mergedAttrs = attributes ? attributes.slice() : [];\n const existingNames = new Set(mergedAttrs.map(a => a.name));\n\n let discard = false;\n const listAttrs: Record<string, string> = {};\n for (const pair of attributes_list.split(',')) {\n if (pair.trim() === '') continue;\n\n const parts = pair.split('=');\n if (parts.length !== 2) {\n diag.warn(\n `Invalid format for resource.attributes_list entry \"${pair}\": expected key=value with '=' percent-encoded in keys/values. Discarding all entries.`\n );\n discard = true;\n break;\n }\n\n const rawName = parts[0].trim();\n const rawValue = parts[1].trim();\n if (rawName === '') {\n diag.warn(\n `Empty attribute name in resource.attributes_list entry \"${pair}\". Discarding all entries.`\n );\n discard = true;\n break;\n }\n\n try {\n listAttrs[decodeURIComponent(rawName)] = decodeURIComponent(rawValue);\n } catch (e) {\n diag.warn(\n `Failed to percent-decode resource.attributes_list entry \"${pair}\", discarding all entries: ${e}`\n );\n discard = true;\n break;\n }\n }\n\n if (!discard) {\n for (const [name, value] of Object.entries(listAttrs)) {\n if (!existingNames.has(name)) {\n mergedAttrs.push({ name, value, type: 'string' });\n }\n }\n }\n\n return mergedAttrs;\n}\n\n/**\n * Merge headers from `headers` and `headers_list` (comma-separated key=value\n * pairs) into a record. Entries in `headers` take precedence.\n */\nexport function mergeHeadersConfig(\n headers?: NameStringValuePair[],\n headers_list?: string | null\n): Record<string, string> | undefined {\n if (!headers && !headers_list) {\n return undefined;\n }\n\n const mergedHeaders = parseKeyPairsIntoRecord(headers_list ?? undefined);\n headers?.forEach(header => {\n if (header.value !== null) {\n mergedHeaders[header.name] = header.value;\n }\n });\n return mergedHeaders;\n}\n\n/**\n * Merge propagator.composite_list (comma-separated propagator names) into\n * propagator.composite, with entries already in composite taking precedence.\n * Merge TextMapPropagator configs from `propagator.composite` and `propagator.composite_list`\n * (comma-separated names) into a `TextMapPropagator[]` array.\n * Entries already in `propagator.composite` taking precedence.\n *\n * Note: The returned array might not be a copy, so it should not be mutated.\n */\nexport function mergePropagatorCompositeConfig(\n composite?: TextMapPropagator[],\n composite_list?: string | null\n): TextMapPropagator[] | undefined {\n if (!composite_list) {\n return composite;\n }\n\n const mergedComposite = composite ? composite.slice() : [];\n const existingNames = new Set(mergedComposite.map(c => Object.keys(c)[0]));\n\n for (const name of composite_list.split(',')) {\n const trimmed = name.trim();\n if (trimmed && !existingNames.has(trimmed)) {\n mergedComposite.push({ [trimmed]: null });\n existingNames.add(trimmed);\n }\n }\n\n return mergedComposite;\n}\n"],"mappings":"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"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare class FileConfigFactory implements ConfigFactory {
|
|
4
|
-
private _config;
|
|
5
|
-
constructor();
|
|
6
|
-
getConfigModel(): ConfigurationModel;
|
|
7
|
-
}
|
|
8
|
-
export declare function parseConfigFile(): ConfigurationModel;
|
|
1
|
+
import { AttributeNameValue, NameStringValuePair, TextMapPropagator } from "./generated/types.cjs";
|
|
2
|
+
//#region src/FileConfigFactory.d.ts
|
|
9
3
|
/**
|
|
10
4
|
* Merge attributes from `resource.attributes` and `resource.attributes_list`
|
|
11
5
|
* (comma-separated key=value pairs) into an `AttributeNameValue[]` array.
|
|
@@ -13,12 +7,12 @@ export declare function parseConfigFile(): ConfigurationModel;
|
|
|
13
7
|
*
|
|
14
8
|
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
15
9
|
*/
|
|
16
|
-
|
|
10
|
+
declare function mergeResourceAttributesConfig(attributes?: AttributeNameValue[], attributes_list?: string | null): AttributeNameValue[] | undefined;
|
|
17
11
|
/**
|
|
18
12
|
* Merge headers from `headers` and `headers_list` (comma-separated key=value
|
|
19
13
|
* pairs) into a record. Entries in `headers` take precedence.
|
|
20
14
|
*/
|
|
21
|
-
|
|
15
|
+
declare function mergeHeadersConfig(headers?: NameStringValuePair[], headers_list?: string | null): Record<string, string> | undefined;
|
|
22
16
|
/**
|
|
23
17
|
* Merge propagator.composite_list (comma-separated propagator names) into
|
|
24
18
|
* propagator.composite, with entries already in composite taking precedence.
|
|
@@ -28,5 +22,7 @@ export declare function mergeHeadersConfig(headers?: NameStringValuePair[], head
|
|
|
28
22
|
*
|
|
29
23
|
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
30
24
|
*/
|
|
31
|
-
|
|
32
|
-
//#
|
|
25
|
+
declare function mergePropagatorCompositeConfig(composite?: TextMapPropagator[], composite_list?: string | null): TextMapPropagator[] | undefined;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { mergeHeadersConfig, mergePropagatorCompositeConfig, mergeResourceAttributesConfig };
|
|
28
|
+
//# sourceMappingURL=FileConfigFactory.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileConfigFactory.d.cts","names":[],"sources":["../src/FileConfigFactory.d.ts"],"mappings":";;;;;;;;;iBAewB,8BAA8B,aAAa,sBAAsB,kCAAkC;;;;;iBAKnG,mBAAmB,UAAU,uBAAuB,+BAA+B;;;;;;;;;;iBAUnF,+BAA+B,YAAY,qBAAqB,iCAAiC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AttributeNameValue, NameStringValuePair, TextMapPropagator } from "./generated/types.mjs";
|
|
2
|
+
//#region src/FileConfigFactory.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Merge attributes from `resource.attributes` and `resource.attributes_list`
|
|
5
|
+
* (comma-separated key=value pairs) into an `AttributeNameValue[]` array.
|
|
6
|
+
* Entries already in `resource.attributes` taking precedence.
|
|
7
|
+
*
|
|
8
|
+
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
9
|
+
*/
|
|
10
|
+
declare function mergeResourceAttributesConfig(attributes?: AttributeNameValue[], attributes_list?: string | null): AttributeNameValue[] | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Merge headers from `headers` and `headers_list` (comma-separated key=value
|
|
13
|
+
* pairs) into a record. Entries in `headers` take precedence.
|
|
14
|
+
*/
|
|
15
|
+
declare function mergeHeadersConfig(headers?: NameStringValuePair[], headers_list?: string | null): Record<string, string> | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Merge propagator.composite_list (comma-separated propagator names) into
|
|
18
|
+
* propagator.composite, with entries already in composite taking precedence.
|
|
19
|
+
* Merge TextMapPropagator configs from `propagator.composite` and `propagator.composite_list`
|
|
20
|
+
* (comma-separated names) into a `TextMapPropagator[]` array.
|
|
21
|
+
* Entries already in `propagator.composite` taking precedence.
|
|
22
|
+
*
|
|
23
|
+
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
24
|
+
*/
|
|
25
|
+
declare function mergePropagatorCompositeConfig(composite?: TextMapPropagator[], composite_list?: string | null): TextMapPropagator[] | undefined;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { mergeHeadersConfig, mergePropagatorCompositeConfig, mergeResourceAttributesConfig };
|
|
28
|
+
//# sourceMappingURL=FileConfigFactory.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileConfigFactory.d.mts","names":[],"sources":["../src/FileConfigFactory.d.ts"],"mappings":";;;;;;;;;iBAewB,8BAA8B,aAAa,sBAAsB,kCAAkC;;;;;iBAKnG,mBAAmB,UAAU,uBAAuB,+BAA+B;;;;;;;;;;iBAUnF,+BAA+B,YAAY,qBAAqB,iCAAiC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { substituteEnvVars } from "./utils.mjs";
|
|
2
|
+
import { require_validator } from "./generated/validator.mjs";
|
|
3
|
+
import { getStringFromEnv, parseKeyPairsIntoRecord } from "@opentelemetry/core";
|
|
4
|
+
import { diag } from "@opentelemetry/api";
|
|
5
|
+
import * as yaml from "yaml";
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
//#region src/FileConfigFactory.ts
|
|
8
|
+
const validateConfig = require_validator();
|
|
9
|
+
var FileConfigFactory = class {
|
|
10
|
+
_config;
|
|
11
|
+
constructor() {
|
|
12
|
+
this._config = parseConfigFile();
|
|
13
|
+
}
|
|
14
|
+
getConfigModel() {
|
|
15
|
+
return this._config;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const SUPPORTED_FILE_FORMAT_MAJOR = 1;
|
|
19
|
+
const SUPPORTED_FILE_FORMAT_MINOR = 1;
|
|
20
|
+
function validateFileFormat(configFile, fileFormat) {
|
|
21
|
+
if (typeof fileFormat !== "string" || fileFormat.length === 0) throw new Error(`${configFile}: Unsupported file_format: "${fileFormat}". Expected a "MAJOR.MINOR" version string.`);
|
|
22
|
+
const parts = fileFormat.split("-", 1)[0].split(".");
|
|
23
|
+
const major = Number(parts[0]);
|
|
24
|
+
const minor = parts.length > 1 ? Number(parts[1]) : 0;
|
|
25
|
+
if (!Number.isInteger(major) || !Number.isInteger(minor)) throw new Error(`${configFile}: Unsupported file_format: "${fileFormat}". Expected "MAJOR.MINOR" version numbers.`);
|
|
26
|
+
if (major !== SUPPORTED_FILE_FORMAT_MAJOR) throw new Error(`${configFile}: Unsupported file_format: "${fileFormat}". This SDK supports schema version ${SUPPORTED_FILE_FORMAT_MAJOR}.x.`);
|
|
27
|
+
if (minor > SUPPORTED_FILE_FORMAT_MINOR) diag.warn(`${configFile}: Configuration file_format "${fileFormat}" has a newer minor version than this SDK supports (${SUPPORTED_FILE_FORMAT_MAJOR}.${SUPPORTED_FILE_FORMAT_MINOR}); some settings may be ignored.`);
|
|
28
|
+
}
|
|
29
|
+
function parseConfigFile() {
|
|
30
|
+
const configFile = getStringFromEnv("OTEL_CONFIG_FILE") || "";
|
|
31
|
+
const file = fs.readFileSync(configFile, "utf8");
|
|
32
|
+
const doc = yaml.parseDocument(file, { version: "1.2" });
|
|
33
|
+
substituteEnvVars(doc);
|
|
34
|
+
const processed = doc.toJS();
|
|
35
|
+
validateFileFormat(configFile, processed?.file_format);
|
|
36
|
+
if (!validateConfig(processed)) {
|
|
37
|
+
let detail;
|
|
38
|
+
if (!validateConfig.errors) detail = "unknown error";
|
|
39
|
+
else if (validateConfig.errors.length === 1) {
|
|
40
|
+
const err = validateConfig.errors[0];
|
|
41
|
+
detail = `${err.instancePath} ${err.message}`;
|
|
42
|
+
} else {
|
|
43
|
+
const sep = "\n ";
|
|
44
|
+
detail = sep + validateConfig.errors.map((e) => `${e.instancePath} ${e.message}`).join(sep);
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Invalid OpenTelemetry config file: ${configFile}: ${detail}`);
|
|
47
|
+
}
|
|
48
|
+
const data = processed;
|
|
49
|
+
delete data["file_format"];
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Merge attributes from `resource.attributes` and `resource.attributes_list`
|
|
54
|
+
* (comma-separated key=value pairs) into an `AttributeNameValue[]` array.
|
|
55
|
+
* Entries already in `resource.attributes` taking precedence.
|
|
56
|
+
*
|
|
57
|
+
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
58
|
+
*/
|
|
59
|
+
function mergeResourceAttributesConfig(attributes, attributes_list) {
|
|
60
|
+
if (!attributes_list) return attributes;
|
|
61
|
+
const mergedAttrs = attributes ? attributes.slice() : [];
|
|
62
|
+
const existingNames = new Set(mergedAttrs.map((a) => a.name));
|
|
63
|
+
let discard = false;
|
|
64
|
+
const listAttrs = {};
|
|
65
|
+
for (const pair of attributes_list.split(",")) {
|
|
66
|
+
if (pair.trim() === "") continue;
|
|
67
|
+
const parts = pair.split("=");
|
|
68
|
+
if (parts.length !== 2) {
|
|
69
|
+
diag.warn(`Invalid format for resource.attributes_list entry "${pair}": expected key=value with '=' percent-encoded in keys/values. Discarding all entries.`);
|
|
70
|
+
discard = true;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
const rawName = parts[0].trim();
|
|
74
|
+
const rawValue = parts[1].trim();
|
|
75
|
+
if (rawName === "") {
|
|
76
|
+
diag.warn(`Empty attribute name in resource.attributes_list entry "${pair}". Discarding all entries.`);
|
|
77
|
+
discard = true;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
listAttrs[decodeURIComponent(rawName)] = decodeURIComponent(rawValue);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
diag.warn(`Failed to percent-decode resource.attributes_list entry "${pair}", discarding all entries: ${e}`);
|
|
84
|
+
discard = true;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!discard) {
|
|
89
|
+
for (const [name, value] of Object.entries(listAttrs)) if (!existingNames.has(name)) mergedAttrs.push({
|
|
90
|
+
name,
|
|
91
|
+
value,
|
|
92
|
+
type: "string"
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return mergedAttrs;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Merge headers from `headers` and `headers_list` (comma-separated key=value
|
|
99
|
+
* pairs) into a record. Entries in `headers` take precedence.
|
|
100
|
+
*/
|
|
101
|
+
function mergeHeadersConfig(headers, headers_list) {
|
|
102
|
+
if (!headers && !headers_list) return;
|
|
103
|
+
const mergedHeaders = parseKeyPairsIntoRecord(headers_list ?? void 0);
|
|
104
|
+
headers?.forEach((header) => {
|
|
105
|
+
if (header.value !== null) mergedHeaders[header.name] = header.value;
|
|
106
|
+
});
|
|
107
|
+
return mergedHeaders;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Merge propagator.composite_list (comma-separated propagator names) into
|
|
111
|
+
* propagator.composite, with entries already in composite taking precedence.
|
|
112
|
+
* Merge TextMapPropagator configs from `propagator.composite` and `propagator.composite_list`
|
|
113
|
+
* (comma-separated names) into a `TextMapPropagator[]` array.
|
|
114
|
+
* Entries already in `propagator.composite` taking precedence.
|
|
115
|
+
*
|
|
116
|
+
* Note: The returned array might not be a copy, so it should not be mutated.
|
|
117
|
+
*/
|
|
118
|
+
function mergePropagatorCompositeConfig(composite, composite_list) {
|
|
119
|
+
if (!composite_list) return composite;
|
|
120
|
+
const mergedComposite = composite ? composite.slice() : [];
|
|
121
|
+
const existingNames = new Set(mergedComposite.map((c) => Object.keys(c)[0]));
|
|
122
|
+
for (const name of composite_list.split(",")) {
|
|
123
|
+
const trimmed = name.trim();
|
|
124
|
+
if (trimmed && !existingNames.has(trimmed)) {
|
|
125
|
+
mergedComposite.push({ [trimmed]: null });
|
|
126
|
+
existingNames.add(trimmed);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return mergedComposite;
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { FileConfigFactory, mergeHeadersConfig, mergePropagatorCompositeConfig, mergeResourceAttributesConfig, parseConfigFile };
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=FileConfigFactory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileConfigFactory.mjs","names":[],"sources":["../src/FileConfigFactory.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { diag } from '@opentelemetry/api';\nimport { getStringFromEnv, parseKeyPairsIntoRecord } from '@opentelemetry/core';\nimport * as fs from 'fs';\nimport * as yaml from 'yaml';\nimport type { ConfigFactory } from './IConfigFactory';\nimport { substituteEnvVars } from './utils';\nimport type {\n AttributeNameValue,\n ConfigurationModel,\n NameStringValuePair,\n TextMapPropagator,\n} from './generated/types';\n// Pre-compiled ajv validator — eliminates runtime schema compilation on cold start.\n// Generated by `npm run generate:config`; do not import ajv directly here.\n// The generated module uses CJS `module.exports = fn`. `import = require` is the\n// only TypeScript form that works equivalently under both CJS and ESM consumers.\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nimport validateConfig = require('./generated/validator');\n\nexport class FileConfigFactory implements ConfigFactory {\n private _config: ConfigurationModel;\n\n constructor() {\n this._config = parseConfigFile();\n }\n\n getConfigModel(): ConfigurationModel {\n return this._config;\n }\n}\n\n// The schema version this SDK targets. Per the configuration versioning spec,\n// an implementation MUST reject a config file whose MAJOR version differs (a\n// breaking-change boundary), accepts any MINOR version within that major, and\n// SHOULD warn when the MINOR version is newer than it targets since unknown\n// settings may be ignored. See\n// https://github.com/open-telemetry/opentelemetry-configuration/blob/main/VERSIONING.md\nconst SUPPORTED_FILE_FORMAT_MAJOR = 1;\nconst SUPPORTED_FILE_FORMAT_MINOR = 1;\n\nfunction validateFileFormat(configFile: string, fileFormat: unknown): void {\n if (typeof fileFormat !== 'string' || fileFormat.length === 0) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". Expected a \"MAJOR.MINOR\" version string.`\n );\n }\n\n // Drop any pre-release / meta tag, e.g. \"1.0-rc.2\" -> \"1.0\".\n const parts = fileFormat.split('-', 1)[0].split('.');\n const major = Number(parts[0]);\n const minor = parts.length > 1 ? Number(parts[1]) : 0;\n if (!Number.isInteger(major) || !Number.isInteger(minor)) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". Expected \"MAJOR.MINOR\" version numbers.`\n );\n }\n\n if (major !== SUPPORTED_FILE_FORMAT_MAJOR) {\n throw new Error(\n `${configFile}: Unsupported file_format: \"${fileFormat}\". This SDK supports schema version ${SUPPORTED_FILE_FORMAT_MAJOR}.x.`\n );\n }\n\n if (minor > SUPPORTED_FILE_FORMAT_MINOR) {\n diag.warn(\n `${configFile}: Configuration file_format \"${fileFormat}\" has a newer minor version than this SDK supports (${SUPPORTED_FILE_FORMAT_MAJOR}.${SUPPORTED_FILE_FORMAT_MINOR}); some settings may be ignored.`\n );\n }\n}\n\nexport function parseConfigFile(): ConfigurationModel {\n const configFile = getStringFromEnv('OTEL_CONFIG_FILE') || '';\n const file = fs.readFileSync(configFile, 'utf8');\n\n const doc = yaml.parseDocument(file, { version: '1.2' });\n substituteEnvVars(doc);\n const processed = doc.toJS() as Record<string, unknown>;\n\n validateFileFormat(configFile, processed?.file_format);\n\n const valid = validateConfig(processed);\n if (!valid) {\n let detail: string;\n if (!validateConfig.errors) {\n detail = 'unknown error';\n } else if (validateConfig.errors.length === 1) {\n const err = validateConfig.errors[0];\n detail = `${err.instancePath} ${err.message}`;\n } else {\n const sep = '\\n ';\n detail =\n sep +\n validateConfig.errors\n .map(e => `${e.instancePath} ${e.message}`)\n .join(sep);\n }\n throw new Error(\n `Invalid OpenTelemetry config file: ${configFile}: ${detail}`\n );\n }\n\n const data = processed as unknown as ConfigurationModel;\n\n // Strip file_format from output — it's a meta-field, not a config value\n delete (data as Record<string, unknown>)['file_format'];\n\n return data;\n}\n\n/**\n * Merge attributes from `resource.attributes` and `resource.attributes_list`\n * (comma-separated key=value pairs) into an `AttributeNameValue[]` array.\n * Entries already in `resource.attributes` taking precedence.\n *\n * Note: The returned array might not be a copy, so it should not be mutated.\n */\nexport function mergeResourceAttributesConfig(\n attributes?: AttributeNameValue[],\n attributes_list?: string | null\n): AttributeNameValue[] | undefined {\n if (!attributes_list) {\n return attributes;\n }\n\n const mergedAttrs = attributes ? attributes.slice() : [];\n const existingNames = new Set(mergedAttrs.map(a => a.name));\n\n let discard = false;\n const listAttrs: Record<string, string> = {};\n for (const pair of attributes_list.split(',')) {\n if (pair.trim() === '') continue;\n\n const parts = pair.split('=');\n if (parts.length !== 2) {\n diag.warn(\n `Invalid format for resource.attributes_list entry \"${pair}\": expected key=value with '=' percent-encoded in keys/values. Discarding all entries.`\n );\n discard = true;\n break;\n }\n\n const rawName = parts[0].trim();\n const rawValue = parts[1].trim();\n if (rawName === '') {\n diag.warn(\n `Empty attribute name in resource.attributes_list entry \"${pair}\". Discarding all entries.`\n );\n discard = true;\n break;\n }\n\n try {\n listAttrs[decodeURIComponent(rawName)] = decodeURIComponent(rawValue);\n } catch (e) {\n diag.warn(\n `Failed to percent-decode resource.attributes_list entry \"${pair}\", discarding all entries: ${e}`\n );\n discard = true;\n break;\n }\n }\n\n if (!discard) {\n for (const [name, value] of Object.entries(listAttrs)) {\n if (!existingNames.has(name)) {\n mergedAttrs.push({ name, value, type: 'string' });\n }\n }\n }\n\n return mergedAttrs;\n}\n\n/**\n * Merge headers from `headers` and `headers_list` (comma-separated key=value\n * pairs) into a record. Entries in `headers` take precedence.\n */\nexport function mergeHeadersConfig(\n headers?: NameStringValuePair[],\n headers_list?: string | null\n): Record<string, string> | undefined {\n if (!headers && !headers_list) {\n return undefined;\n }\n\n const mergedHeaders = parseKeyPairsIntoRecord(headers_list ?? undefined);\n headers?.forEach(header => {\n if (header.value !== null) {\n mergedHeaders[header.name] = header.value;\n }\n });\n return mergedHeaders;\n}\n\n/**\n * Merge propagator.composite_list (comma-separated propagator names) into\n * propagator.composite, with entries already in composite taking precedence.\n * Merge TextMapPropagator configs from `propagator.composite` and `propagator.composite_list`\n * (comma-separated names) into a `TextMapPropagator[]` array.\n * Entries already in `propagator.composite` taking precedence.\n *\n * Note: The returned array might not be a copy, so it should not be mutated.\n */\nexport function mergePropagatorCompositeConfig(\n composite?: TextMapPropagator[],\n composite_list?: string | null\n): TextMapPropagator[] | undefined {\n if (!composite_list) {\n return composite;\n }\n\n const mergedComposite = composite ? composite.slice() : [];\n const existingNames = new Set(mergedComposite.map(c => Object.keys(c)[0]));\n\n for (const name of composite_list.split(',')) {\n const trimmed = name.trim();\n if (trimmed && !existingNames.has(trimmed)) {\n mergedComposite.push({ [trimmed]: null });\n existingNames.add(trimmed);\n }\n }\n\n return mergedComposite;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ConfigurationModel } from "./generated/types.cjs";
|
|
2
|
+
//#region src/IConfigFactory.d.ts
|
|
3
|
+
interface ConfigFactory {
|
|
4
|
+
/**
|
|
5
|
+
* Returns a ConfigurationModel.
|
|
6
|
+
*
|
|
7
|
+
* @returns ConfigurationModel a ConfigurationModel with all configuration attributes
|
|
8
|
+
*/
|
|
9
|
+
getConfigModel(): ConfigurationModel;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ConfigFactory };
|
|
13
|
+
//# sourceMappingURL=IConfigFactory.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConfigFactory.d.cts","names":[],"sources":["../src/IConfigFactory.d.ts"],"mappings":";;UACiB;;;;;;EAMb,kBAAkB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ConfigurationModel } from "./generated/types.mjs";
|
|
2
|
+
//#region src/IConfigFactory.d.ts
|
|
3
|
+
interface ConfigFactory {
|
|
4
|
+
/**
|
|
5
|
+
* Returns a ConfigurationModel.
|
|
6
|
+
*
|
|
7
|
+
* @returns ConfigurationModel a ConfigurationModel with all configuration attributes
|
|
8
|
+
*/
|
|
9
|
+
getConfigModel(): ConfigurationModel;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { ConfigFactory };
|
|
13
|
+
//# sourceMappingURL=IConfigFactory.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IConfigFactory.d.mts","names":[],"sources":["../src/IConfigFactory.d.ts"],"mappings":";;UACiB;;;;;;EAMb,kBAAkB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.__commonJSMin = __commonJSMin;
|
|
25
|
+
exports.__toESM = __toESM;
|