@intentius/chant-lexicon-otel 0.124.46 → 0.124.48
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 +2 -2
- package/dist/build/capability-plugin.d.ts +10 -0
- package/dist/build/capability-plugin.d.ts.map +1 -0
- package/dist/build/capability-plugin.js +19 -0
- package/dist/build/ocb-build.d.ts +38 -0
- package/dist/build/ocb-build.d.ts.map +1 -0
- package/dist/build/ocb-build.js +49 -0
- package/dist/clickhouse-tables.d.ts +73 -0
- package/dist/clickhouse-tables.d.ts.map +1 -0
- package/dist/clickhouse-tables.js +199 -0
- package/dist/codegen/docs.d.ts.map +1 -1
- package/dist/codegen/docs.js +4 -2
- package/dist/codegen/generate.d.ts +29 -10
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/codegen/generate.js +82 -17
- package/dist/components/common.d.ts +3 -1
- package/dist/components/common.d.ts.map +1 -1
- package/dist/components/common.js +2 -0
- package/dist/components/connectors.d.ts +25 -90
- package/dist/components/connectors.d.ts.map +1 -1
- package/dist/components/connectors.js +3 -0
- package/dist/components/exporters.d.ts +78 -34
- package/dist/components/exporters.d.ts.map +1 -1
- package/dist/components/exporters.js +26 -1
- package/dist/components/extensions.d.ts +16 -33
- package/dist/components/extensions.d.ts.map +1 -1
- package/dist/components/filtering.d.ts +13 -60
- package/dist/components/filtering.d.ts.map +1 -1
- package/dist/components/k8s-receivers.d.ts +5 -53
- package/dist/components/k8s-receivers.d.ts.map +1 -1
- package/dist/components/overlay.d.ts +25 -0
- package/dist/components/overlay.d.ts.map +1 -0
- package/dist/components/overlay.js +19 -0
- package/dist/components/processors.d.ts +18 -79
- package/dist/components/processors.d.ts.map +1 -1
- package/dist/components/receivers.d.ts +17 -71
- package/dist/components/receivers.d.ts.map +1 -1
- package/dist/components/receivers.js +3 -1
- package/dist/components/sampling.d.ts +19 -35
- package/dist/components/sampling.d.ts.map +1 -1
- package/dist/config-hygiene.d.ts +10 -8
- package/dist/config-hygiene.d.ts.map +1 -1
- package/dist/config-hygiene.js +36 -13
- package/dist/coverage.d.ts +50 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/coverage.js +92 -0
- package/dist/define.d.ts +8 -5
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +10 -6
- package/dist/distribution.d.ts +125 -0
- package/dist/distribution.d.ts.map +1 -0
- package/dist/distribution.js +227 -0
- package/dist/generated/index.d.ts +4234 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +23 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/init-templates.js +2 -2
- package/dist/integrity.json +11 -9
- package/dist/lint/audit-catalog.d.ts +3 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/audit-catalog.js +5 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/index.js +4 -0
- package/dist/lint/post-synth/otel-helpers.d.ts +2 -1
- package/dist/lint/post-synth/otel-helpers.d.ts.map +1 -1
- package/dist/lint/post-synth/otel-helpers.js +1 -1
- package/dist/lint/post-synth/otel119.d.ts +1 -1
- package/dist/lint/post-synth/otel119.js +1 -1
- package/dist/lint/post-synth/otel125.d.ts +1 -1
- package/dist/lint/post-synth/otel125.js +1 -1
- package/dist/lint/post-synth/otel126.d.ts +1 -1
- package/dist/lint/post-synth/otel126.js +1 -1
- package/dist/lint/post-synth/otel127.d.ts +1 -1
- package/dist/lint/post-synth/otel127.js +1 -1
- package/dist/lint/post-synth/otel128.d.ts +8 -0
- package/dist/lint/post-synth/otel128.d.ts.map +1 -0
- package/dist/lint/post-synth/otel128.js +17 -0
- package/dist/lint/post-synth/otel129.d.ts +15 -0
- package/dist/lint/post-synth/otel129.d.ts.map +1 -0
- package/dist/lint/post-synth/otel129.js +92 -0
- package/dist/lsp/completions.d.ts +10 -1
- package/dist/lsp/completions.d.ts.map +1 -1
- package/dist/lsp/completions.js +29 -1
- package/dist/lsp/hover.d.ts +5 -1
- package/dist/lsp/hover.d.ts.map +1 -1
- package/dist/lsp/hover.js +16 -3
- package/dist/lsp/properties.d.ts +34 -0
- package/dist/lsp/properties.d.ts.map +1 -0
- package/dist/lsp/properties.js +135 -0
- package/dist/manifest.json +1 -1
- package/dist/meta.json +5 -0
- package/dist/metric-names.d.ts +36 -8
- package/dist/metric-names.d.ts.map +1 -1
- package/dist/metric-names.js +42 -9
- package/dist/model.d.ts +1 -1
- package/dist/model.js +1 -1
- package/dist/okf/index.md +3 -0
- package/dist/okf/rules/OTEL128.md +11 -0
- package/dist/okf/rules/OTEL129.md +11 -0
- package/dist/okf/types/ClickHouseExporter.md +9 -0
- package/dist/op/activities/collector-audit.d.ts +18 -6
- package/dist/op/activities/collector-audit.d.ts.map +1 -1
- package/dist/op/activities/collector-audit.js +37 -21
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +51 -8
- package/dist/rules/otel-helpers.ts +1 -1
- package/dist/rules/otel119.ts +1 -1
- package/dist/rules/otel125.ts +1 -1
- package/dist/rules/otel126.ts +1 -1
- package/dist/rules/otel127.ts +1 -1
- package/dist/rules/otel128.ts +22 -0
- package/dist/rules/otel129.ts +99 -0
- package/dist/serializer.d.ts +3 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +12 -2
- package/dist/spec/builtins.d.ts +17 -0
- package/dist/spec/builtins.d.ts.map +1 -0
- package/dist/spec/builtins.js +45 -0
- package/dist/spec/fetch.d.ts +120 -0
- package/dist/spec/fetch.d.ts.map +1 -0
- package/dist/spec/fetch.js +282 -0
- package/dist/spec/parse.d.ts +77 -0
- package/dist/spec/parse.d.ts.map +1 -0
- package/dist/spec/parse.js +337 -0
- package/dist/spec/pin.d.ts +82 -0
- package/dist/spec/pin.d.ts.map +1 -0
- package/dist/spec/pin.js +126 -0
- package/dist/spec/snapshot-cli.d.ts +13 -0
- package/dist/spec/snapshot-cli.d.ts.map +1 -0
- package/dist/spec/snapshot-cli.js +31 -0
- package/dist/spec/snapshot.d.ts +9 -0
- package/dist/spec/snapshot.d.ts.map +1 -0
- package/dist/spec/snapshot.js +14 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/validate-config.d.ts +1 -1
- package/dist/validate-config.d.ts.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +1 -0
- package/dist/workspace-links.d.ts +25 -0
- package/dist/workspace-links.d.ts.map +1 -0
- package/dist/workspace-links.js +49 -0
- package/package.json +3 -2
- package/src/build/capability-plugin.ts +30 -0
- package/src/build/ocb-build.ts +73 -0
- package/src/clickhouse-exporter.e2e.test.ts +208 -0
- package/src/clickhouse-tables.test.ts +216 -0
- package/src/clickhouse-tables.ts +223 -0
- package/src/codegen/docs.ts +4 -2
- package/src/codegen/generate.ts +95 -19
- package/src/components/common.ts +4 -2
- package/src/components/connectors.ts +30 -77
- package/src/components/exporters.ts +128 -61
- package/src/components/extensions.ts +22 -36
- package/src/components/filtering.ts +17 -58
- package/src/components/k8s-receivers.test.ts +1 -1
- package/src/components/k8s-receivers.ts +3 -45
- package/src/components/overlay.ts +24 -0
- package/src/components/processors.ts +18 -63
- package/src/components/receivers.ts +20 -60
- package/src/components/sampling.ts +24 -37
- package/src/config-hygiene.ts +36 -13
- package/src/coverage.test.ts +37 -0
- package/src/coverage.ts +121 -0
- package/src/define.test.ts +2 -0
- package/src/define.ts +10 -6
- package/src/distribution.test.ts +250 -0
- package/src/distribution.ts +305 -0
- package/src/generated/index.ts +4576 -0
- package/src/generated/lexicon-otel.json +5 -0
- package/src/generated/properties.json +1 -0
- package/src/import/roundtrip.test.ts +16 -0
- package/src/import/testdata/clickhouse.yaml +37 -0
- package/src/import/testdata/fixtures.ts +17 -2
- package/src/import/testdata/upstream/clickhouse-exporter.yaml +60 -0
- package/src/index.ts +69 -0
- package/src/init-templates.ts +2 -2
- package/src/lint/audit-catalog.ts +15 -0
- package/src/lint/post-synth/index.ts +4 -0
- package/src/lint/post-synth/otel-helpers.ts +1 -1
- package/src/lint/post-synth/otel119.ts +1 -1
- package/src/lint/post-synth/otel125.ts +1 -1
- package/src/lint/post-synth/otel126.ts +1 -1
- package/src/lint/post-synth/otel127.ts +1 -1
- package/src/lint/post-synth/otel128.ts +22 -0
- package/src/lint/post-synth/otel129.ts +99 -0
- package/src/lsp/completions.ts +30 -1
- package/src/lsp/hover.ts +14 -3
- package/src/lsp/properties.test.ts +72 -0
- package/src/lsp/properties.ts +141 -0
- package/src/metric-names.test.ts +11 -0
- package/src/metric-names.ts +64 -16
- package/src/model.ts +1 -1
- package/src/op/activities/collector-audit.test.ts +29 -22
- package/src/op/activities/collector-audit.ts +38 -18
- package/src/plugin.test.ts +2 -0
- package/src/plugin.ts +57 -6
- package/src/serializer.ts +11 -2
- package/src/spec/builtins.ts +56 -0
- package/src/spec/fetch.ts +332 -0
- package/src/spec/otel-schemas.snapshot.json +13932 -0
- package/src/spec/parse.ts +364 -0
- package/src/spec/pin.ts +155 -0
- package/src/spec/snapshot-cli.ts +32 -0
- package/src/spec/snapshot.ts +19 -0
- package/src/spec/spec.test.ts +144 -0
- package/src/validate-config.ts +4 -3
- package/src/validate.ts +1 -0
- package/src/workspace-links.e2e.test.ts +91 -0
- package/src/workspace-links.ts +50 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `config.schema.yaml` to TypeScript (#3361).
|
|
3
|
+
*
|
|
4
|
+
* `schemagen` writes a small JSON Schema dialect: `type`, `properties`,
|
|
5
|
+
* `items`, `additionalProperties`, `enum`, `allOf` (an embedded struct,
|
|
6
|
+
* `mapstructure:",squash"`), `$ref` and `$defs`, `format: duration`, and three
|
|
7
|
+
* extensions:
|
|
8
|
+
*
|
|
9
|
+
* - `x-customType`, the Go type when the JSON type alone loses it (`int64`,
|
|
10
|
+
* `component.ID`, `time.Duration`, or a type from outside the collector);
|
|
11
|
+
* - `x-optional`, a `configoptional.Optional`: the key may be written with no
|
|
12
|
+
* value (`grpc:`) to turn the section on with its defaults, so it also takes
|
|
13
|
+
* `null`;
|
|
14
|
+
* - `x-pointer`, a Go pointer, which changes nothing in YAML.
|
|
15
|
+
*
|
|
16
|
+
* It writes no `required`, so every generated property is optional; what a
|
|
17
|
+
* component cannot start without is its definition's `validate` overlay.
|
|
18
|
+
*
|
|
19
|
+
* Every definition reached from a built-in becomes one named type alias,
|
|
20
|
+
* `<document><Definition>`, so recursive definitions (tail_sampling's `and`
|
|
21
|
+
* and `not` policies) are expressible. A `$ref` to a document upstream does
|
|
22
|
+
* not publish, or to a definition it lacks, becomes `unknown` and is listed in
|
|
23
|
+
* {@link GeneratedTypes.unresolved}.
|
|
24
|
+
*/
|
|
25
|
+
import { CONTRIB_MODULE, CORE_MODULE, resolveRef } from "./fetch.js";
|
|
26
|
+
/** How each `x-customType` reads in TypeScript. A type not listed falls back on the node's JSON `type`. */
|
|
27
|
+
const CUSTOM_TYPES = {
|
|
28
|
+
int: "number",
|
|
29
|
+
int8: "number",
|
|
30
|
+
int16: "number",
|
|
31
|
+
int32: "number",
|
|
32
|
+
int64: "number",
|
|
33
|
+
uint: "number",
|
|
34
|
+
uint8: "number",
|
|
35
|
+
uint16: "number",
|
|
36
|
+
uint32: "number",
|
|
37
|
+
uint64: "number",
|
|
38
|
+
float32: "number",
|
|
39
|
+
float64: "number",
|
|
40
|
+
any: "unknown",
|
|
41
|
+
"time.Duration": "Duration",
|
|
42
|
+
"go.opentelemetry.io/collector/component.ID": "string",
|
|
43
|
+
"go.opentelemetry.io/otel/attribute.key": "string",
|
|
44
|
+
"golang.org/x/time/rate.Limit": "number",
|
|
45
|
+
"net/url.values": "Record<string, string[]>",
|
|
46
|
+
"os.file_mode": "number | string",
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Definitions whose Go type has its own unmarshaller, so the JSON type
|
|
50
|
+
* `schemagen` writes (the underlying `int`, or the stored form) is not all a
|
|
51
|
+
* YAML config may hold. Keyed by `<document>#<definition>`; a function gets
|
|
52
|
+
* the type generated from the schema and widens it.
|
|
53
|
+
*/
|
|
54
|
+
const TEXT_DEFINITIONS = {
|
|
55
|
+
// configopaque.MapList is stored as name/value pairs and also read from a plain map.
|
|
56
|
+
"go.opentelemetry.io/collector/config/configopaque#map_list": (generated) => `Record<string, string> | ${generated}`,
|
|
57
|
+
// configtelemetry.Level implements UnmarshalText over these names.
|
|
58
|
+
"go.opentelemetry.io/collector/config/configtelemetry#level": '"none" | "basic" | "normal" | "detailed"',
|
|
59
|
+
// spanmetrics' histogram unit, `ms` or `s`.
|
|
60
|
+
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector/internal/metrics#unit": '"ms" | "s"',
|
|
61
|
+
// stanza's ByteSize takes `1MiB` as well as a byte count.
|
|
62
|
+
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/helper#byte_size": "number | string",
|
|
63
|
+
// Severities take a name (`INFO`, `warn`) as well as a number.
|
|
64
|
+
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/entry#severity": "number | string",
|
|
65
|
+
"go.opentelemetry.io/collector/pdata/plog#severity_number": "number | string",
|
|
66
|
+
"go.opentelemetry.io/collector/pdata/internal#severity_number": "number | string",
|
|
67
|
+
};
|
|
68
|
+
/** The TypeScript for one `x-customType`, or undefined when the JSON type should decide. */
|
|
69
|
+
export function customType(name) {
|
|
70
|
+
return CUSTOM_TYPES[name];
|
|
71
|
+
}
|
|
72
|
+
function pascal(s) {
|
|
73
|
+
return s
|
|
74
|
+
.split(/[^A-Za-z0-9]+/)
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.map((w) => w[0].toUpperCase() + w.slice(1))
|
|
77
|
+
.join("");
|
|
78
|
+
}
|
|
79
|
+
/** The type-name prefix for a document: its package path below the repository, PascalCased, with `Collector` for core packages. */
|
|
80
|
+
export function documentAlias(doc) {
|
|
81
|
+
if (doc.startsWith(`${CONTRIB_MODULE}/`))
|
|
82
|
+
return pascal(doc.slice(CONTRIB_MODULE.length + 1));
|
|
83
|
+
if (doc.startsWith(`${CORE_MODULE}/`))
|
|
84
|
+
return `Collector${pascal(doc.slice(CORE_MODULE.length + 1))}`;
|
|
85
|
+
return pascal(doc);
|
|
86
|
+
}
|
|
87
|
+
const IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
88
|
+
function propKey(name) {
|
|
89
|
+
return IDENT.test(name) ? name : JSON.stringify(name);
|
|
90
|
+
}
|
|
91
|
+
function jsdoc(description, indent, deprecated) {
|
|
92
|
+
const lines = [];
|
|
93
|
+
if (description)
|
|
94
|
+
lines.push(...description.replace(/\*\//g, "*\\/").split("\n"));
|
|
95
|
+
if (deprecated)
|
|
96
|
+
lines.push("@deprecated");
|
|
97
|
+
if (lines.length === 0)
|
|
98
|
+
return "";
|
|
99
|
+
if (lines.length === 1)
|
|
100
|
+
return `${indent}/** ${lines[0]} */\n`;
|
|
101
|
+
return `${indent}/**\n${lines.map((l) => `${indent} * ${l}`.trimEnd()).join("\n")}\n${indent} */\n`;
|
|
102
|
+
}
|
|
103
|
+
/** A description that says the field is deprecated, as Go comments do. */
|
|
104
|
+
export function isDeprecated(description) {
|
|
105
|
+
// `Deprecated: use X`, `Deprecated [v0.130.0]: use X`, or a comment that opens with it.
|
|
106
|
+
return description !== undefined && /^\s*Deprecated\b|\bDeprecated(\s*\[[^\]]*\])?:/.test(description);
|
|
107
|
+
}
|
|
108
|
+
/** True for a document that is only a `$defs` container. */
|
|
109
|
+
function isBareDocument(node) {
|
|
110
|
+
return !node.type && !node.properties && !node.allOf && !node.$ref;
|
|
111
|
+
}
|
|
112
|
+
/** A document's root type: the document itself, or its `config` definition when the document is only `$defs`. */
|
|
113
|
+
function rootOf(node) {
|
|
114
|
+
if (node && isBareDocument(node) && node.$defs?.config)
|
|
115
|
+
return node.$defs.config;
|
|
116
|
+
return node;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Generate TypeScript for the root documents in `roots` and every definition
|
|
120
|
+
* they reach. `docs` holds every available document, keyed by Go package path.
|
|
121
|
+
*/
|
|
122
|
+
export function generateTypes(docs, roots) {
|
|
123
|
+
const decls = new Map();
|
|
124
|
+
const unresolved = new Map();
|
|
125
|
+
const pending = [];
|
|
126
|
+
const named = new Map();
|
|
127
|
+
const noteUnresolved = (key, from) => {
|
|
128
|
+
if (!unresolved.has(key))
|
|
129
|
+
unresolved.set(key, new Set());
|
|
130
|
+
unresolved.get(key).add(from);
|
|
131
|
+
};
|
|
132
|
+
// The type name for `doc` + `def` (def "" is the document's root), queued for emission on first use.
|
|
133
|
+
const nameFor = (doc, def) => {
|
|
134
|
+
const key = `${doc}#${def}`;
|
|
135
|
+
const known = named.get(key);
|
|
136
|
+
if (known)
|
|
137
|
+
return known;
|
|
138
|
+
const node = docs[doc];
|
|
139
|
+
if (!node)
|
|
140
|
+
return undefined;
|
|
141
|
+
// A package whose `Config` lives under `$defs` (signaltometrics' `config`
|
|
142
|
+
// package) has no root type; the document stands for that definition.
|
|
143
|
+
if (def === "" && isBareDocument(node) && node.$defs?.config)
|
|
144
|
+
return nameFor(doc, "config");
|
|
145
|
+
// `pkg.config` names the package's `Config` struct, which schemagen
|
|
146
|
+
// writes as the document root rather than under `$defs`.
|
|
147
|
+
if (def !== "" && !node.$defs?.[def])
|
|
148
|
+
return def === "config" ? nameFor(doc, "") : undefined;
|
|
149
|
+
let name = documentAlias(doc) + (def === "" ? "Schema" : pascal(def));
|
|
150
|
+
while ([...named.values()].includes(name))
|
|
151
|
+
name += "_";
|
|
152
|
+
named.set(key, name);
|
|
153
|
+
pending.push({ doc, def, name });
|
|
154
|
+
return name;
|
|
155
|
+
};
|
|
156
|
+
const tsType = (node, doc, indent) => {
|
|
157
|
+
if (!node || typeof node !== "object")
|
|
158
|
+
return "unknown";
|
|
159
|
+
let t = baseType(node, doc, indent);
|
|
160
|
+
if (node["x-optional"])
|
|
161
|
+
t = `${parenthesize(t)} | null`;
|
|
162
|
+
return t;
|
|
163
|
+
};
|
|
164
|
+
const parenthesize = (t) => (/[|&]/.test(t) && !/^\{[\s\S]*\}$/.test(t) ? `(${t})` : t);
|
|
165
|
+
const objectBody = (props, doc, indent) => {
|
|
166
|
+
const inner = `${indent} `;
|
|
167
|
+
const lines = Object.keys(props)
|
|
168
|
+
.sort()
|
|
169
|
+
.map((k) => {
|
|
170
|
+
const p = props[k];
|
|
171
|
+
return `${jsdoc(p.description, inner, isDeprecated(p.description))}${inner}${propKey(k)}?: ${tsType(p, doc, inner)};\n`;
|
|
172
|
+
});
|
|
173
|
+
return `{\n${lines.join("")}${indent}}`;
|
|
174
|
+
};
|
|
175
|
+
const baseType = (node, doc, indent) => {
|
|
176
|
+
if (node.$ref) {
|
|
177
|
+
const { doc: target, def } = resolveRef(doc, node.$ref);
|
|
178
|
+
const name = nameFor(target, def);
|
|
179
|
+
if (!name) {
|
|
180
|
+
noteUnresolved(`${target}${def ? `.${def}` : ""}`, doc);
|
|
181
|
+
return "unknown";
|
|
182
|
+
}
|
|
183
|
+
return name;
|
|
184
|
+
}
|
|
185
|
+
if (node.allOf && node.allOf.length > 0) {
|
|
186
|
+
const parts = node.allOf.map((n) => parenthesize(tsType(n, doc, indent)));
|
|
187
|
+
if (node.properties && Object.keys(node.properties).length > 0)
|
|
188
|
+
parts.push(objectBody(node.properties, doc, indent));
|
|
189
|
+
const kept = parts.filter((p) => p !== "unknown");
|
|
190
|
+
return kept.length === 0 ? "unknown" : kept.join(" & ");
|
|
191
|
+
}
|
|
192
|
+
const custom = node["x-customType"];
|
|
193
|
+
if (custom) {
|
|
194
|
+
const mapped = customType(custom);
|
|
195
|
+
if (mapped)
|
|
196
|
+
return mapped;
|
|
197
|
+
}
|
|
198
|
+
const types = Array.isArray(node.type) ? node.type : node.type ? [node.type] : [];
|
|
199
|
+
if (types.length === 0) {
|
|
200
|
+
if (node.properties)
|
|
201
|
+
return objectBody(node.properties, doc, indent);
|
|
202
|
+
return "unknown";
|
|
203
|
+
}
|
|
204
|
+
return types.map((t) => jsonType(t, node, doc, indent)).join(" | ");
|
|
205
|
+
};
|
|
206
|
+
const jsonType = (t, node, doc, indent) => {
|
|
207
|
+
switch (t) {
|
|
208
|
+
case "string":
|
|
209
|
+
if (node.enum && node.enum.length > 0)
|
|
210
|
+
return node.enum.map((v) => JSON.stringify(v)).join(" | ");
|
|
211
|
+
return node.format === "duration" ? "Duration" : "string";
|
|
212
|
+
case "integer":
|
|
213
|
+
case "number":
|
|
214
|
+
if (node.format === "duration")
|
|
215
|
+
return "Duration";
|
|
216
|
+
return "number";
|
|
217
|
+
case "boolean":
|
|
218
|
+
return "boolean";
|
|
219
|
+
case "null":
|
|
220
|
+
return "null";
|
|
221
|
+
case "array":
|
|
222
|
+
return `Array<${tsType(node.items, doc, indent)}>`;
|
|
223
|
+
case "object": {
|
|
224
|
+
const hasProps = node.properties && Object.keys(node.properties).length > 0;
|
|
225
|
+
if (hasProps)
|
|
226
|
+
return objectBody(node.properties, doc, indent);
|
|
227
|
+
const ap = node.additionalProperties;
|
|
228
|
+
if (ap && typeof ap === "object")
|
|
229
|
+
return `Record<string, ${tsType(ap, doc, indent)}>`;
|
|
230
|
+
return "Record<string, unknown>";
|
|
231
|
+
}
|
|
232
|
+
default:
|
|
233
|
+
return "unknown";
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const roots_ = new Map();
|
|
237
|
+
for (const root of roots) {
|
|
238
|
+
const name = nameFor(root, "");
|
|
239
|
+
if (name)
|
|
240
|
+
roots_.set(root, name);
|
|
241
|
+
}
|
|
242
|
+
while (pending.length > 0) {
|
|
243
|
+
const { doc, def, name } = pending.shift();
|
|
244
|
+
const docNode = docs[doc];
|
|
245
|
+
const node = def === "" ? docNode : docNode.$defs[def];
|
|
246
|
+
const text = TEXT_DEFINITIONS[`${doc}#${def}`];
|
|
247
|
+
const body = typeof text === "string" ? text : text ? text(tsType(node, doc, "")) : tsType(node, doc, "");
|
|
248
|
+
decls.set(name, `${jsdoc(node.description, "")}export type ${name} = ${body};\n`);
|
|
249
|
+
}
|
|
250
|
+
const declarations = [...decls.keys()]
|
|
251
|
+
.sort()
|
|
252
|
+
.map((k) => decls.get(k))
|
|
253
|
+
.join("\n");
|
|
254
|
+
return { declarations, roots: roots_, unresolved };
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* The property tree of a root document, for completion and hover: each
|
|
258
|
+
* property's description and a short type label, nested objects expanded to
|
|
259
|
+
* `depth` levels, embedded structs (`allOf`) flattened in.
|
|
260
|
+
*/
|
|
261
|
+
export function propertyDocs(docs, root, depth = 4) {
|
|
262
|
+
const visit = (node, doc, level, stack) => {
|
|
263
|
+
const out = {};
|
|
264
|
+
const target = deref(node, doc);
|
|
265
|
+
if (!target)
|
|
266
|
+
return out;
|
|
267
|
+
const { node: n, doc: d, key } = target;
|
|
268
|
+
if (key && stack.includes(key))
|
|
269
|
+
return out;
|
|
270
|
+
const nextStack = key ? [...stack, key] : stack;
|
|
271
|
+
// A list of objects: complete the properties of one item.
|
|
272
|
+
if (n.items && (n.type === "array" || (Array.isArray(n.type) && n.type.includes("array"))))
|
|
273
|
+
return visit(n.items, d, level, nextStack);
|
|
274
|
+
// A map of objects: complete the properties of one value.
|
|
275
|
+
if (!n.properties && !n.allOf && n.additionalProperties && typeof n.additionalProperties === "object") {
|
|
276
|
+
return visit(n.additionalProperties, d, level, nextStack);
|
|
277
|
+
}
|
|
278
|
+
for (const part of n.allOf ?? [])
|
|
279
|
+
Object.assign(out, visit(part, d, level, nextStack));
|
|
280
|
+
for (const [name, p] of Object.entries(n.properties ?? {})) {
|
|
281
|
+
const entry = { type: label(p, d) };
|
|
282
|
+
const description = p.description ?? deref(p, d)?.node.description;
|
|
283
|
+
if (description)
|
|
284
|
+
entry.description = description;
|
|
285
|
+
if (isDeprecated(p.description))
|
|
286
|
+
entry.deprecated = true;
|
|
287
|
+
if (level < depth) {
|
|
288
|
+
const child = visit(p, d, level + 1, nextStack);
|
|
289
|
+
if (Object.keys(child).length > 0)
|
|
290
|
+
entry.properties = child;
|
|
291
|
+
}
|
|
292
|
+
out[name] = entry;
|
|
293
|
+
}
|
|
294
|
+
return out;
|
|
295
|
+
};
|
|
296
|
+
const deref = (node, doc) => {
|
|
297
|
+
let n = node;
|
|
298
|
+
let d = doc;
|
|
299
|
+
// Only a `$ref`ed definition can recur; an inline object gets no key.
|
|
300
|
+
let key = "";
|
|
301
|
+
for (let hops = 0; n?.$ref && hops < 16; hops++) {
|
|
302
|
+
const r = resolveRef(d, n.$ref);
|
|
303
|
+
const target = docs[r.doc];
|
|
304
|
+
n = r.def === "" ? rootOf(target) : (target?.$defs?.[r.def] ?? (r.def === "config" ? target : undefined));
|
|
305
|
+
d = r.doc;
|
|
306
|
+
key = `${r.doc}#${r.def}`;
|
|
307
|
+
}
|
|
308
|
+
return n ? { node: n, doc: d, key } : undefined;
|
|
309
|
+
};
|
|
310
|
+
const label = (node, doc) => {
|
|
311
|
+
const resolved = deref(node, doc);
|
|
312
|
+
const text = resolved && TEXT_DEFINITIONS[resolved.key];
|
|
313
|
+
if (typeof text === "string")
|
|
314
|
+
return text;
|
|
315
|
+
if (text)
|
|
316
|
+
return "map | list";
|
|
317
|
+
const target = resolved?.node ?? node;
|
|
318
|
+
const custom = target["x-customType"];
|
|
319
|
+
if (custom === "time.Duration" || target.format === "duration")
|
|
320
|
+
return "duration";
|
|
321
|
+
if (custom && customType(custom) === "number")
|
|
322
|
+
return "number";
|
|
323
|
+
if (custom === "go.opentelemetry.io/collector/component.ID")
|
|
324
|
+
return "component id";
|
|
325
|
+
const t = Array.isArray(target.type) ? target.type[0] : target.type;
|
|
326
|
+
if (t === "integer")
|
|
327
|
+
return "number";
|
|
328
|
+
if (t === "array")
|
|
329
|
+
return `${target.items ? label(target.items, doc) : "unknown"}[]`;
|
|
330
|
+
if (t === "string" && target.enum)
|
|
331
|
+
return target.enum.map((v) => JSON.stringify(v)).join(" | ");
|
|
332
|
+
if (!t && (target.allOf || target.properties))
|
|
333
|
+
return "object";
|
|
334
|
+
return t ?? "unknown";
|
|
335
|
+
};
|
|
336
|
+
return visit(rootOf(docs[root]), root, 1, []);
|
|
337
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the otel lexicon's generated config types are pinned to (#3361).
|
|
3
|
+
*
|
|
4
|
+
* ## The version pins
|
|
5
|
+
*
|
|
6
|
+
* Upstream publishes a `config.schema.yaml` next to each component's
|
|
7
|
+
* `config.go`, produced by `schemagen` from the Go structs. A collector
|
|
8
|
+
* *distribution* decides which components a given `otelcol` binary carries, so
|
|
9
|
+
* the types are scoped by a distribution's builder manifest
|
|
10
|
+
* (`distributions/<name>/manifest.yaml` in opentelemetry-collector-releases) at
|
|
11
|
+
* a release tag:
|
|
12
|
+
*
|
|
13
|
+
* - `otelcol-contrib`, the distribution the built-ins are generated against and
|
|
14
|
+
* the one `COLLECTOR_IMAGE` runs;
|
|
15
|
+
* - `otelcol-k8s`, a second pin, so the coverage report can say which built-ins
|
|
16
|
+
* the Kubernetes distribution leaves out.
|
|
17
|
+
*
|
|
18
|
+
* Each manifest names the component modules and their versions; the schemas
|
|
19
|
+
* are read from opentelemetry-collector and opentelemetry-collector-contrib at
|
|
20
|
+
* those versions. Every one of these is a git tag, so the content behind a pin
|
|
21
|
+
* never moves.
|
|
22
|
+
*
|
|
23
|
+
* ## The content pin
|
|
24
|
+
*
|
|
25
|
+
* The resolved set (both manifests' component index plus every schema document
|
|
26
|
+
* the built-ins reach through `$ref`) is committed as
|
|
27
|
+
* `otel-schemas.snapshot.json`, and generation reads only that file, offline.
|
|
28
|
+
* The digest below is over that resolved set, so a hand edit to the snapshot,
|
|
29
|
+
* or a refresh nobody accepted, refuses to generate. Moving a version is: bump
|
|
30
|
+
* the constant, run `just snapshot`, read the diff, and paste the printed pin
|
|
31
|
+
* here, in the same commit.
|
|
32
|
+
*/
|
|
33
|
+
/** The opentelemetry-collector-releases tag whose `otelcol-contrib` manifest scopes the built-ins. */
|
|
34
|
+
export declare const OTELCOL_CONTRIB_VERSION = "v0.162.0";
|
|
35
|
+
/** The opentelemetry-collector-releases tag whose `otelcol-k8s` manifest the coverage report also reads. */
|
|
36
|
+
export declare const OTELCOL_K8S_VERSION = "v0.162.0";
|
|
37
|
+
/** Env var that accepts a snapshot whose digest does not match the pin, printing the new pin. */
|
|
38
|
+
export declare const ACCEPT_ENV = "CHANT_ACCEPT_OTEL_SPEC";
|
|
39
|
+
export interface OtelSpecPin {
|
|
40
|
+
/** `sha256:…` over the resolved set, see {@link specDigest}. */
|
|
41
|
+
readonly digest: string;
|
|
42
|
+
/** How many schema documents the resolved set holds. */
|
|
43
|
+
readonly documents: number;
|
|
44
|
+
/** ISO date the pin was accepted, so a diff reads as a decision. */
|
|
45
|
+
readonly accepted: string;
|
|
46
|
+
}
|
|
47
|
+
/** The accepted resolved set. Paste the block `just snapshot` prints here. */
|
|
48
|
+
export declare const OTEL_SPEC_PIN: OtelSpecPin;
|
|
49
|
+
/**
|
|
50
|
+
* Refuse a snapshot taken at other versions than the constants above: a
|
|
51
|
+
* version bump without `just snapshot` would otherwise generate the old
|
|
52
|
+
* release's types under the new pin.
|
|
53
|
+
*/
|
|
54
|
+
export declare function assertSnapshotVersions(versions: {
|
|
55
|
+
"otelcol-contrib": string;
|
|
56
|
+
"otelcol-k8s": string;
|
|
57
|
+
}): void;
|
|
58
|
+
/** Stable JSON: object keys sorted at every level, so the digest ignores key order. */
|
|
59
|
+
export declare function canonicalJson(value: unknown): string;
|
|
60
|
+
/** The parts of a snapshot the digest covers. */
|
|
61
|
+
export interface DigestInput {
|
|
62
|
+
readonly versions: unknown;
|
|
63
|
+
readonly distributions: unknown;
|
|
64
|
+
readonly schemas: Readonly<Record<string, unknown>>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Digest the resolved set: the versions, the distribution index, and each
|
|
68
|
+
* schema document by key, in key order.
|
|
69
|
+
*/
|
|
70
|
+
export declare function specDigest(input: DigestInput): string;
|
|
71
|
+
/** The pin block to paste into this file for a resolved set. */
|
|
72
|
+
export declare function pinBlock(digest: string, documents: number, accepted?: string): string;
|
|
73
|
+
/**
|
|
74
|
+
* Refuse a snapshot whose digest does not match the pin. Under
|
|
75
|
+
* {@link ACCEPT_ENV} it warns with the block to paste instead.
|
|
76
|
+
*/
|
|
77
|
+
export declare function assertPinnedSnapshot(input: DigestInput, options?: {
|
|
78
|
+
pin?: OtelSpecPin;
|
|
79
|
+
env?: NodeJS.ProcessEnv;
|
|
80
|
+
warn?: (message: string) => void;
|
|
81
|
+
}): void;
|
|
82
|
+
//# sourceMappingURL=pin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../src/spec/pin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAIH,sGAAsG;AACtG,eAAO,MAAM,uBAAuB,aAAa,CAAC;AAElD,4GAA4G;AAC5G,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAE9C,iGAAiG;AACjG,eAAO,MAAM,UAAU,2BAA2B,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,8EAA8E;AAC9E,eAAO,MAAM,aAAa,EAAE,WAI3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAW3G;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWpD;AAED,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CASrD;AAED,gEAAgE;AAChE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,SAAwC,GAAG,MAAM,CAQpH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,WAAW,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAC7F,IAAI,CAsBN"}
|
package/dist/spec/pin.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the otel lexicon's generated config types are pinned to (#3361).
|
|
3
|
+
*
|
|
4
|
+
* ## The version pins
|
|
5
|
+
*
|
|
6
|
+
* Upstream publishes a `config.schema.yaml` next to each component's
|
|
7
|
+
* `config.go`, produced by `schemagen` from the Go structs. A collector
|
|
8
|
+
* *distribution* decides which components a given `otelcol` binary carries, so
|
|
9
|
+
* the types are scoped by a distribution's builder manifest
|
|
10
|
+
* (`distributions/<name>/manifest.yaml` in opentelemetry-collector-releases) at
|
|
11
|
+
* a release tag:
|
|
12
|
+
*
|
|
13
|
+
* - `otelcol-contrib`, the distribution the built-ins are generated against and
|
|
14
|
+
* the one `COLLECTOR_IMAGE` runs;
|
|
15
|
+
* - `otelcol-k8s`, a second pin, so the coverage report can say which built-ins
|
|
16
|
+
* the Kubernetes distribution leaves out.
|
|
17
|
+
*
|
|
18
|
+
* Each manifest names the component modules and their versions; the schemas
|
|
19
|
+
* are read from opentelemetry-collector and opentelemetry-collector-contrib at
|
|
20
|
+
* those versions. Every one of these is a git tag, so the content behind a pin
|
|
21
|
+
* never moves.
|
|
22
|
+
*
|
|
23
|
+
* ## The content pin
|
|
24
|
+
*
|
|
25
|
+
* The resolved set (both manifests' component index plus every schema document
|
|
26
|
+
* the built-ins reach through `$ref`) is committed as
|
|
27
|
+
* `otel-schemas.snapshot.json`, and generation reads only that file, offline.
|
|
28
|
+
* The digest below is over that resolved set, so a hand edit to the snapshot,
|
|
29
|
+
* or a refresh nobody accepted, refuses to generate. Moving a version is: bump
|
|
30
|
+
* the constant, run `just snapshot`, read the diff, and paste the printed pin
|
|
31
|
+
* here, in the same commit.
|
|
32
|
+
*/
|
|
33
|
+
import { createHash } from "crypto";
|
|
34
|
+
/** The opentelemetry-collector-releases tag whose `otelcol-contrib` manifest scopes the built-ins. */
|
|
35
|
+
export const OTELCOL_CONTRIB_VERSION = "v0.162.0";
|
|
36
|
+
/** The opentelemetry-collector-releases tag whose `otelcol-k8s` manifest the coverage report also reads. */
|
|
37
|
+
export const OTELCOL_K8S_VERSION = "v0.162.0";
|
|
38
|
+
/** Env var that accepts a snapshot whose digest does not match the pin, printing the new pin. */
|
|
39
|
+
export const ACCEPT_ENV = "CHANT_ACCEPT_OTEL_SPEC";
|
|
40
|
+
/** The accepted resolved set. Paste the block `just snapshot` prints here. */
|
|
41
|
+
export const OTEL_SPEC_PIN = {
|
|
42
|
+
digest: "sha256:90ac78ed3f40aac1ef29b4df9a11574a829f08de2758c379817a92e557bb9d05",
|
|
43
|
+
documents: 133,
|
|
44
|
+
accepted: "2026-10-24",
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Refuse a snapshot taken at other versions than the constants above: a
|
|
48
|
+
* version bump without `just snapshot` would otherwise generate the old
|
|
49
|
+
* release's types under the new pin.
|
|
50
|
+
*/
|
|
51
|
+
export function assertSnapshotVersions(versions) {
|
|
52
|
+
const wrong = [
|
|
53
|
+
versions["otelcol-contrib"] !== OTELCOL_CONTRIB_VERSION ? `otelcol-contrib ${versions["otelcol-contrib"]} (pin ${OTELCOL_CONTRIB_VERSION})` : "",
|
|
54
|
+
versions["otelcol-k8s"] !== OTELCOL_K8S_VERSION ? `otelcol-k8s ${versions["otelcol-k8s"]} (pin ${OTELCOL_K8S_VERSION})` : "",
|
|
55
|
+
].filter(Boolean);
|
|
56
|
+
if (wrong.length > 0) {
|
|
57
|
+
throw new Error(`The otel schema snapshot was taken at ${wrong.join(" and ")}. Run \`just snapshot\` in lexicons/otel, ` +
|
|
58
|
+
"paste the printed OTEL_SPEC_PIN into src/spec/pin.ts, and generate again.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Stable JSON: object keys sorted at every level, so the digest ignores key order. */
|
|
62
|
+
export function canonicalJson(value) {
|
|
63
|
+
if (Array.isArray(value))
|
|
64
|
+
return `[${value.map(canonicalJson).join(",")}]`;
|
|
65
|
+
if (value !== null && typeof value === "object") {
|
|
66
|
+
const obj = value;
|
|
67
|
+
return `{${Object.keys(obj)
|
|
68
|
+
.sort()
|
|
69
|
+
.filter((k) => obj[k] !== undefined)
|
|
70
|
+
.map((k) => `${JSON.stringify(k)}:${canonicalJson(obj[k])}`)
|
|
71
|
+
.join(",")}}`;
|
|
72
|
+
}
|
|
73
|
+
return JSON.stringify(value);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Digest the resolved set: the versions, the distribution index, and each
|
|
77
|
+
* schema document by key, in key order.
|
|
78
|
+
*/
|
|
79
|
+
export function specDigest(input) {
|
|
80
|
+
const hash = createHash("sha256");
|
|
81
|
+
hash.update(canonicalJson(input.versions));
|
|
82
|
+
hash.update(canonicalJson(input.distributions));
|
|
83
|
+
for (const key of Object.keys(input.schemas).sort()) {
|
|
84
|
+
hash.update(key);
|
|
85
|
+
hash.update(createHash("sha256").update(canonicalJson(input.schemas[key])).digest());
|
|
86
|
+
}
|
|
87
|
+
return `sha256:${hash.digest("hex")}`;
|
|
88
|
+
}
|
|
89
|
+
/** The pin block to paste into this file for a resolved set. */
|
|
90
|
+
export function pinBlock(digest, documents, accepted = new Date().toISOString().slice(0, 10)) {
|
|
91
|
+
return [
|
|
92
|
+
"export const OTEL_SPEC_PIN: OtelSpecPin = {",
|
|
93
|
+
` digest: "${digest}",`,
|
|
94
|
+
` documents: ${documents},`,
|
|
95
|
+
` accepted: "${accepted}",`,
|
|
96
|
+
"};",
|
|
97
|
+
].join("\n");
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Refuse a snapshot whose digest does not match the pin. Under
|
|
101
|
+
* {@link ACCEPT_ENV} it warns with the block to paste instead.
|
|
102
|
+
*/
|
|
103
|
+
export function assertPinnedSnapshot(input, options = {}) {
|
|
104
|
+
const pin = options.pin ?? OTEL_SPEC_PIN;
|
|
105
|
+
const digest = specDigest(input);
|
|
106
|
+
if (digest === pin.digest)
|
|
107
|
+
return;
|
|
108
|
+
const documents = Object.keys(input.schemas).length;
|
|
109
|
+
const message = [
|
|
110
|
+
"The otel schema snapshot (src/spec/otel-schemas.snapshot.json) does not match OTEL_SPEC_PIN.",
|
|
111
|
+
"",
|
|
112
|
+
` pinned ${pin.digest} (${pin.documents} documents, accepted ${pin.accepted})`,
|
|
113
|
+
` snapshot ${digest} (${documents} documents)`,
|
|
114
|
+
"",
|
|
115
|
+
"If the snapshot was refreshed on purpose (`just snapshot`), read its diff and",
|
|
116
|
+
"paste this into lexicons/otel/src/spec/pin.ts in the same commit:",
|
|
117
|
+
"",
|
|
118
|
+
pinBlock(digest, documents),
|
|
119
|
+
].join("\n");
|
|
120
|
+
const env = options.env ?? process.env;
|
|
121
|
+
if (env[ACCEPT_ENV]) {
|
|
122
|
+
(options.warn ?? ((m) => console.error(m)))(message);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
throw new Error(`${message}\n\nOr re-run with ${ACCEPT_ENV}=1 to generate from it this once.`);
|
|
126
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Refresh the committed schema snapshot (`just snapshot`, #3361).
|
|
4
|
+
*
|
|
5
|
+
* Reads both distribution manifests at the versions in `pin.ts`, indexes every
|
|
6
|
+
* component they list, and keeps the schema documents the built-ins reach. The
|
|
7
|
+
* output is re-indented so a version move reads as a diff. Run it on a
|
|
8
|
+
* networked machine after bumping `OTELCOL_CONTRIB_VERSION` or
|
|
9
|
+
* `OTELCOL_K8S_VERSION`, then paste the printed pin into `pin.ts` and run
|
|
10
|
+
* `just generate`, all in one commit.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=snapshot-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-cli.d.ts","sourceRoot":"","sources":["../../src/spec/snapshot-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env tsx
|
|
2
|
+
/**
|
|
3
|
+
* Refresh the committed schema snapshot (`just snapshot`, #3361).
|
|
4
|
+
*
|
|
5
|
+
* Reads both distribution manifests at the versions in `pin.ts`, indexes every
|
|
6
|
+
* component they list, and keeps the schema documents the built-ins reach. The
|
|
7
|
+
* output is re-indented so a version move reads as a diff. Run it on a
|
|
8
|
+
* networked machine after bumping `OTELCOL_CONTRIB_VERSION` or
|
|
9
|
+
* `OTELCOL_K8S_VERSION`, then paste the printed pin into `pin.ts` and run
|
|
10
|
+
* `just generate`, all in one commit.
|
|
11
|
+
*/
|
|
12
|
+
import { writeFileSync } from "fs";
|
|
13
|
+
import { fetchUpstreamSpec } from "./fetch.js";
|
|
14
|
+
import { OTELCOL_CONTRIB_VERSION, OTELCOL_K8S_VERSION, pinBlock, specDigest } from "./pin.js";
|
|
15
|
+
import { BUILTIN_SPECS } from "./builtins.js";
|
|
16
|
+
import { SNAPSHOT_FILE } from "./snapshot.js";
|
|
17
|
+
const snapshot = await fetchUpstreamSpec({
|
|
18
|
+
contribVersion: OTELCOL_CONTRIB_VERSION,
|
|
19
|
+
k8sVersion: OTELCOL_K8S_VERSION,
|
|
20
|
+
keep: BUILTIN_SPECS,
|
|
21
|
+
force: process.argv.includes("--force"),
|
|
22
|
+
log: (m) => console.error(m),
|
|
23
|
+
});
|
|
24
|
+
const json = `${JSON.stringify(snapshot, null, 1)}\n`;
|
|
25
|
+
writeFileSync(SNAPSHOT_FILE, json);
|
|
26
|
+
const documents = Object.keys(snapshot.schemas).length;
|
|
27
|
+
console.error(`Wrote ${documents} schema documents (${(json.length / 1024).toFixed(0)} KB) to ${SNAPSHOT_FILE}`);
|
|
28
|
+
const unresolved = Object.keys(snapshot.unresolved);
|
|
29
|
+
if (unresolved.length > 0)
|
|
30
|
+
console.error(`Unresolved $ref documents (typed as unknown): ${unresolved.join(", ")}`);
|
|
31
|
+
console.error(`\nPaste into src/spec/pin.ts:\n\n${pinBlock(specDigest(snapshot), documents)}`);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The committed schema snapshot (#3361): what generation, the coverage report
|
|
3
|
+
* and the LSP read. Never fetched here; `just snapshot` refreshes it.
|
|
4
|
+
*/
|
|
5
|
+
import type { OtelSpecSnapshot } from "./fetch.js";
|
|
6
|
+
export declare const SNAPSHOT_FILE: string;
|
|
7
|
+
/** The snapshot as committed, parsed once per process. */
|
|
8
|
+
export declare function loadSnapshot(): OtelSpecSnapshot;
|
|
9
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/spec/snapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,aAAa,QAAuE,CAAC;AAIlG,0DAA0D;AAC1D,wBAAgB,YAAY,IAAI,gBAAgB,CAG/C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The committed schema snapshot (#3361): what generation, the coverage report
|
|
3
|
+
* and the LSP read. Never fetched here; `just snapshot` refreshes it.
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync } from "fs";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
import { moduleSourceDir } from "@intentius/chant/module-source";
|
|
8
|
+
export const SNAPSHOT_FILE = join(moduleSourceDir(import.meta.url), "otel-schemas.snapshot.json");
|
|
9
|
+
let cached;
|
|
10
|
+
/** The snapshot as committed, parsed once per process. */
|
|
11
|
+
export function loadSnapshot() {
|
|
12
|
+
cached ?? (cached = JSON.parse(readFileSync(SNAPSHOT_FILE, "utf-8")));
|
|
13
|
+
return cached;
|
|
14
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
// The otel lexicon's entity classes and config types are
|
|
2
|
-
//
|
|
1
|
+
// The otel lexicon's entity classes and config types are compiled to
|
|
2
|
+
// dist/index.d.ts (config types generated from upstream config.schema.yaml);
|
|
3
|
+
// this entry re-exports them.
|
|
3
4
|
export * from "../index.js";
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import type { Declarable } from "@intentius/chant/declarable";
|
|
11
11
|
import { type CollectorConfig } from "./model.js";
|
|
12
12
|
import "./components/connectors.js";
|
|
13
|
-
export type CollectorIssueCode = "OTEL101" | "OTEL102" | "OTEL103" | "OTEL104" | "OTEL105" | "OTEL106" | "OTEL107" | "OTEL108" | "OTEL109" | "OTEL112" | "OTEL113" | "OTEL114" | "OTEL115" | "OTEL116" | "OTEL117" | "OTEL118" | "OTEL119" | "OTEL120" | "OTEL121" | "OTEL122" | "OTEL123" | "OTEL124" | "OTEL125" | "OTEL126" | "OTEL127";
|
|
13
|
+
export type CollectorIssueCode = "OTEL101" | "OTEL102" | "OTEL103" | "OTEL104" | "OTEL105" | "OTEL106" | "OTEL107" | "OTEL108" | "OTEL109" | "OTEL112" | "OTEL113" | "OTEL114" | "OTEL115" | "OTEL116" | "OTEL117" | "OTEL118" | "OTEL119" | "OTEL120" | "OTEL121" | "OTEL122" | "OTEL123" | "OTEL124" | "OTEL125" | "OTEL126" | "OTEL127" | "OTEL128";
|
|
14
14
|
export interface CollectorIssue {
|
|
15
15
|
code: CollectorIssueCode;
|
|
16
16
|
severity: "error" | "warning";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-config.d.ts","sourceRoot":"","sources":["../src/validate-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAoF,KAAK,eAAe,EAA4B,MAAM,SAAS,CAAC;AAO3J,OAAO,yBAAyB,CAAC;AAEjC,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,CAAC;AAEd,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAkBD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,EAAE,CAmKjF;AA6OD,kDAAkD;AAClD,MAAM,WAAW,QAAQ;IACvB,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;CAC1B;AA4ED,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;CAC1B;AAYD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,YAAY,EAAE,CAExG;AAuBD,kGAAkG;AAClG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,EAAE,CAWrH;AAqHD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,cAAc,EAAE,CAyDpH"}
|
|
1
|
+
{"version":3,"file":"validate-config.d.ts","sourceRoot":"","sources":["../src/validate-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAoF,KAAK,eAAe,EAA4B,MAAM,SAAS,CAAC;AAO3J,OAAO,yBAAyB,CAAC;AAEjC,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,CAAC;AAEd,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAkBD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,EAAE,CAmKjF;AA6OD,kDAAkD;AAClD,MAAM,WAAW,QAAQ;IACvB,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;CAC1B;AA4ED,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;CAC1B;AAYD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,YAAY,EAAE,CAExG;AAuBD,kGAAkG;AAClG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,EAAE,CAWrH;AAqHD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,cAAc,EAAE,CAyDpH"}
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAMvF,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEvF,0DAA0D;AAC1D,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAMvF,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEvF,0DAA0D;AAC1D,eAAO,MAAM,cAAc,UAuC1B,CAAC;AAEF,wBAAsB,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,CAmDxD"}
|