@intentius/chant-lexicon-otel 0.81.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 (206) hide show
  1. package/README.md +49 -0
  2. package/dist/catalog.d.ts +18 -0
  3. package/dist/catalog.d.ts.map +1 -0
  4. package/dist/codegen/docs-cli.d.ts +3 -0
  5. package/dist/codegen/docs-cli.d.ts.map +1 -0
  6. package/dist/codegen/docs.d.ts +8 -0
  7. package/dist/codegen/docs.d.ts.map +1 -0
  8. package/dist/codegen/generate-cli.d.ts +3 -0
  9. package/dist/codegen/generate-cli.d.ts.map +1 -0
  10. package/dist/codegen/generate.d.ts +19 -0
  11. package/dist/codegen/generate.d.ts.map +1 -0
  12. package/dist/codegen/package.d.ts +7 -0
  13. package/dist/codegen/package.d.ts.map +1 -0
  14. package/dist/collector.d.ts +29 -0
  15. package/dist/collector.d.ts.map +1 -0
  16. package/dist/components/common.d.ts +144 -0
  17. package/dist/components/common.d.ts.map +1 -0
  18. package/dist/components/exporters.d.ts +86 -0
  19. package/dist/components/exporters.d.ts.map +1 -0
  20. package/dist/components/extensions.d.ts +32 -0
  21. package/dist/components/extensions.d.ts.map +1 -0
  22. package/dist/components/index.d.ts +6 -0
  23. package/dist/components/index.d.ts.map +1 -0
  24. package/dist/components/processors.d.ts +118 -0
  25. package/dist/components/processors.d.ts.map +1 -0
  26. package/dist/components/receivers.d.ts +118 -0
  27. package/dist/components/receivers.d.ts.map +1 -0
  28. package/dist/define.d.ts +136 -0
  29. package/dist/define.d.ts.map +1 -0
  30. package/dist/detect.d.ts +2 -0
  31. package/dist/detect.d.ts.map +1 -0
  32. package/dist/index.d.ts +12 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/integrity.json +25 -0
  35. package/dist/lint/audit-catalog.d.ts +13 -0
  36. package/dist/lint/audit-catalog.d.ts.map +1 -0
  37. package/dist/lint/post-synth/index.d.ts +3 -0
  38. package/dist/lint/post-synth/index.d.ts.map +1 -0
  39. package/dist/lint/post-synth/otel-helpers.d.ts +22 -0
  40. package/dist/lint/post-synth/otel-helpers.d.ts.map +1 -0
  41. package/dist/lint/post-synth/otel101.d.ts +8 -0
  42. package/dist/lint/post-synth/otel101.d.ts.map +1 -0
  43. package/dist/lint/post-synth/otel102.d.ts +8 -0
  44. package/dist/lint/post-synth/otel102.d.ts.map +1 -0
  45. package/dist/lint/post-synth/otel103.d.ts +8 -0
  46. package/dist/lint/post-synth/otel103.d.ts.map +1 -0
  47. package/dist/lint/post-synth/otel104.d.ts +8 -0
  48. package/dist/lint/post-synth/otel104.d.ts.map +1 -0
  49. package/dist/lint/post-synth/otel105.d.ts +8 -0
  50. package/dist/lint/post-synth/otel105.d.ts.map +1 -0
  51. package/dist/lint/post-synth/otel106.d.ts +8 -0
  52. package/dist/lint/post-synth/otel106.d.ts.map +1 -0
  53. package/dist/lint/post-synth/otel107.d.ts +8 -0
  54. package/dist/lint/post-synth/otel107.d.ts.map +1 -0
  55. package/dist/lint/post-synth/otel108.d.ts +8 -0
  56. package/dist/lint/post-synth/otel108.d.ts.map +1 -0
  57. package/dist/lint/post-synth/otel109.d.ts +8 -0
  58. package/dist/lint/post-synth/otel109.d.ts.map +1 -0
  59. package/dist/lint/rules/component-id-syntax.d.ts +14 -0
  60. package/dist/lint/rules/component-id-syntax.d.ts.map +1 -0
  61. package/dist/lint/rules/index.d.ts +6 -0
  62. package/dist/lint/rules/index.d.ts.map +1 -0
  63. package/dist/lint/rules/literal-credential.d.ts +13 -0
  64. package/dist/lint/rules/literal-credential.d.ts.map +1 -0
  65. package/dist/lint/rules/otel-ast.d.ts +14 -0
  66. package/dist/lint/rules/otel-ast.d.ts.map +1 -0
  67. package/dist/lsp/completions.d.ts +4 -0
  68. package/dist/lsp/completions.d.ts.map +1 -0
  69. package/dist/lsp/hover.d.ts +4 -0
  70. package/dist/lsp/hover.d.ts.map +1 -0
  71. package/dist/manifest.json +8 -0
  72. package/dist/meta.json +102 -0
  73. package/dist/model.d.ts +53 -0
  74. package/dist/model.d.ts.map +1 -0
  75. package/dist/okf/index.md +40 -0
  76. package/dist/okf/rules/OTEL001.md +15 -0
  77. package/dist/okf/rules/OTEL002.md +11 -0
  78. package/dist/okf/rules/OTEL101.md +11 -0
  79. package/dist/okf/rules/OTEL102.md +11 -0
  80. package/dist/okf/rules/OTEL103.md +11 -0
  81. package/dist/okf/rules/OTEL104.md +11 -0
  82. package/dist/okf/rules/OTEL105.md +11 -0
  83. package/dist/okf/rules/OTEL106.md +11 -0
  84. package/dist/okf/rules/OTEL107.md +11 -0
  85. package/dist/okf/rules/OTEL108.md +11 -0
  86. package/dist/okf/rules/OTEL109.md +11 -0
  87. package/dist/okf/types/AttributesProcessor.md +9 -0
  88. package/dist/okf/types/BatchProcessor.md +9 -0
  89. package/dist/okf/types/DebugExporter.md +9 -0
  90. package/dist/okf/types/FileLogReceiver.md +9 -0
  91. package/dist/okf/types/GoogleCloudExporter.md +9 -0
  92. package/dist/okf/types/HealthCheckExtension.md +9 -0
  93. package/dist/okf/types/HostMetricsReceiver.md +9 -0
  94. package/dist/okf/types/K8sAttributesProcessor.md +9 -0
  95. package/dist/okf/types/MemoryLimiterProcessor.md +9 -0
  96. package/dist/okf/types/OtlpExporter.md +9 -0
  97. package/dist/okf/types/OtlpHttpExporter.md +9 -0
  98. package/dist/okf/types/OtlpReceiver.md +9 -0
  99. package/dist/okf/types/Pipeline.md +13 -0
  100. package/dist/okf/types/PprofExtension.md +9 -0
  101. package/dist/okf/types/PrometheusExporter.md +9 -0
  102. package/dist/okf/types/PrometheusReceiver.md +9 -0
  103. package/dist/okf/types/ResourceDetectionProcessor.md +9 -0
  104. package/dist/okf/types/ResourceProcessor.md +9 -0
  105. package/dist/okf/types/Service.md +9 -0
  106. package/dist/okf/types/ZPagesExtension.md +9 -0
  107. package/dist/package-cli.d.ts +3 -0
  108. package/dist/package-cli.d.ts.map +1 -0
  109. package/dist/pipeline.d.ts +66 -0
  110. package/dist/pipeline.d.ts.map +1 -0
  111. package/dist/platform.d.ts +57 -0
  112. package/dist/platform.d.ts.map +1 -0
  113. package/dist/plugin.d.ts +11 -0
  114. package/dist/plugin.d.ts.map +1 -0
  115. package/dist/rules/component-id-syntax.ts +68 -0
  116. package/dist/rules/literal-credential.ts +62 -0
  117. package/dist/rules/otel-ast.ts +30 -0
  118. package/dist/rules/otel-helpers.ts +70 -0
  119. package/dist/rules/otel101.ts +17 -0
  120. package/dist/rules/otel102.ts +17 -0
  121. package/dist/rules/otel103.ts +17 -0
  122. package/dist/rules/otel104.ts +17 -0
  123. package/dist/rules/otel105.ts +17 -0
  124. package/dist/rules/otel106.ts +17 -0
  125. package/dist/rules/otel107.ts +17 -0
  126. package/dist/rules/otel108.ts +17 -0
  127. package/dist/rules/otel109.ts +17 -0
  128. package/dist/serializer.d.ts +16 -0
  129. package/dist/serializer.d.ts.map +1 -0
  130. package/dist/skill-defs.d.ts +3 -0
  131. package/dist/skill-defs.d.ts.map +1 -0
  132. package/dist/skills/chant-otel-custom-components.md +51 -0
  133. package/dist/skills/chant-otel-platforms.md +34 -0
  134. package/dist/skills/chant-otel.md +60 -0
  135. package/dist/topology.d.ts +56 -0
  136. package/dist/topology.d.ts.map +1 -0
  137. package/dist/types/index.d.ts +3 -0
  138. package/dist/validate-cli.d.ts +3 -0
  139. package/dist/validate-cli.d.ts.map +1 -0
  140. package/dist/validate-config.d.ts +30 -0
  141. package/dist/validate-config.d.ts.map +1 -0
  142. package/dist/validate.d.ts +11 -0
  143. package/dist/validate.d.ts.map +1 -0
  144. package/dist/yaml.d.ts +27 -0
  145. package/dist/yaml.d.ts.map +1 -0
  146. package/package.json +74 -0
  147. package/src/catalog.ts +56 -0
  148. package/src/codegen/docs-cli.ts +4 -0
  149. package/src/codegen/docs.ts +90 -0
  150. package/src/codegen/generate-cli.ts +8 -0
  151. package/src/codegen/generate.ts +50 -0
  152. package/src/codegen/package.ts +41 -0
  153. package/src/collector.ts +147 -0
  154. package/src/components/common.ts +151 -0
  155. package/src/components/exporters.ts +141 -0
  156. package/src/components/extensions.ts +51 -0
  157. package/src/components/index.ts +5 -0
  158. package/src/components/processors.ts +208 -0
  159. package/src/components/receivers.ts +177 -0
  160. package/src/define.test.ts +131 -0
  161. package/src/define.ts +249 -0
  162. package/src/detect.ts +11 -0
  163. package/src/generated/lexicon-otel.json +102 -0
  164. package/src/index.ts +73 -0
  165. package/src/lint/audit-catalog.ts +102 -0
  166. package/src/lint/post-synth/index.ts +23 -0
  167. package/src/lint/post-synth/otel-helpers.ts +70 -0
  168. package/src/lint/post-synth/otel101.ts +17 -0
  169. package/src/lint/post-synth/otel102.ts +17 -0
  170. package/src/lint/post-synth/otel103.ts +17 -0
  171. package/src/lint/post-synth/otel104.ts +17 -0
  172. package/src/lint/post-synth/otel105.ts +17 -0
  173. package/src/lint/post-synth/otel106.ts +17 -0
  174. package/src/lint/post-synth/otel107.ts +17 -0
  175. package/src/lint/post-synth/otel108.ts +17 -0
  176. package/src/lint/post-synth/otel109.ts +17 -0
  177. package/src/lint/post-synth/post-synth.test.ts +184 -0
  178. package/src/lint/rules/component-id-syntax.ts +68 -0
  179. package/src/lint/rules/index.ts +9 -0
  180. package/src/lint/rules/literal-credential.ts +62 -0
  181. package/src/lint/rules/otel-ast.ts +30 -0
  182. package/src/lint/rules/rules.test.ts +70 -0
  183. package/src/lsp/completions.test.ts +23 -0
  184. package/src/lsp/completions.ts +15 -0
  185. package/src/lsp/hover.test.ts +20 -0
  186. package/src/lsp/hover.ts +30 -0
  187. package/src/model.ts +88 -0
  188. package/src/package-cli.ts +17 -0
  189. package/src/pipeline.ts +89 -0
  190. package/src/platform.test.ts +79 -0
  191. package/src/platform.ts +143 -0
  192. package/src/plugin.test.ts +55 -0
  193. package/src/plugin.ts +111 -0
  194. package/src/serializer.test.ts +187 -0
  195. package/src/serializer.ts +31 -0
  196. package/src/skill-defs.ts +36 -0
  197. package/src/skills/chant-otel-custom-components.md +51 -0
  198. package/src/skills/chant-otel-platforms.md +34 -0
  199. package/src/skills/chant-otel.md +60 -0
  200. package/src/topology.test.ts +80 -0
  201. package/src/topology.ts +122 -0
  202. package/src/validate-cli.ts +7 -0
  203. package/src/validate-config.ts +232 -0
  204. package/src/validate.ts +82 -0
  205. package/src/yaml.test.ts +56 -0
  206. package/src/yaml.ts +145 -0
package/src/yaml.ts ADDED
@@ -0,0 +1,145 @@
1
+ /**
2
+ * The collector YAML emitter.
3
+ *
4
+ * Its style is the one collector configs are usually written in, and the one
5
+ * the k8s lexicon's `GkeOtelCollector` wrote by hand before it moved onto this
6
+ * lexicon:
7
+ *
8
+ * - top-level sections in the order receivers, processors, exporters,
9
+ * connectors, extensions, service, separated by a blank line;
10
+ * - two-space indent;
11
+ * - a list of scalars in flow style (`receivers: [otlp, batch]`), any other
12
+ * list in block style with `- ` indented under its key;
13
+ * - strings plain where YAML reads them back as the same string, double-quoted
14
+ * otherwise (`"true"`, `"8080"`, `"a: b"`, `"${env:X}"` inside a flow list).
15
+ *
16
+ * The output always parses back to the value it was given.
17
+ */
18
+
19
+ import type { CollectorConfig } from "./model";
20
+
21
+ const SECTION_ORDER = ["receivers", "processors", "exporters", "connectors", "extensions", "service"] as const;
22
+
23
+ const RESERVED = new Set(["true", "false", "null", "yes", "no", "on", "off", "y", "n", "~"]);
24
+ const LEADING_INDICATOR = /^[-?:,[\]{}#&*!|>'"%@`]/;
25
+
26
+ function isPlainObject(v: unknown): v is Record<string, unknown> {
27
+ return typeof v === "object" && v !== null && !Array.isArray(v);
28
+ }
29
+
30
+ function isScalar(v: unknown): boolean {
31
+ return v === null || typeof v === "string" || typeof v === "number" || typeof v === "boolean";
32
+ }
33
+
34
+ /** True when `s` can be written unquoted and still read back as the string `s`. */
35
+ export function isPlainSafe(s: string, flow: boolean): boolean {
36
+ if (s === "") return false;
37
+ if (/^\s|\s$/.test(s)) return false;
38
+ if (/[\n\r\t\u0000-\u001f\u007f]/.test(s)) return false;
39
+ if (RESERVED.has(s.toLowerCase())) return false;
40
+ if (!Number.isNaN(Number(s))) return false;
41
+ if (/^[-+]?\.(inf|nan)$/i.test(s)) return false;
42
+ if (/^0[xob]/i.test(s)) return false;
43
+ if (/^\d+(:\d+)+$/.test(s)) return false;
44
+ if (LEADING_INDICATOR.test(s)) return false;
45
+ if (s.includes(": ") || s.includes(" #") || s.endsWith(":")) return false;
46
+ if (flow && /[,[\]{}]/.test(s)) return false;
47
+ return true;
48
+ }
49
+
50
+ function scalar(v: unknown, flow: boolean): string {
51
+ if (v === null) return "null";
52
+ if (typeof v === "boolean") return v ? "true" : "false";
53
+ if (typeof v === "number") return Number.isFinite(v) ? String(v) : JSON.stringify(String(v));
54
+ if (typeof v === "string") return isPlainSafe(v, flow) ? v : JSON.stringify(v);
55
+ return JSON.stringify(String(v));
56
+ }
57
+
58
+ function key(k: string): string {
59
+ return isPlainSafe(k, false) ? k : JSON.stringify(k);
60
+ }
61
+
62
+ function emitMap(obj: Record<string, unknown>, indent: number, out: string[]): void {
63
+ const pad = " ".repeat(indent);
64
+ for (const [k, v] of Object.entries(obj)) {
65
+ if (v === undefined) continue;
66
+ const kk = key(k);
67
+ if (v === null) {
68
+ out.push(`${pad}${kk}:`);
69
+ } else if (isPlainObject(v)) {
70
+ if (Object.values(v).every((x) => x === undefined)) {
71
+ out.push(`${pad}${kk}: {}`);
72
+ } else {
73
+ out.push(`${pad}${kk}:`);
74
+ emitMap(v, indent + 2, out);
75
+ }
76
+ } else if (Array.isArray(v)) {
77
+ emitList(kk, v, indent, out);
78
+ } else {
79
+ out.push(`${pad}${kk}: ${scalar(v, false)}`);
80
+ }
81
+ }
82
+ }
83
+
84
+ function emitList(kk: string, list: unknown[], indent: number, out: string[]): void {
85
+ const pad = " ".repeat(indent);
86
+ if (list.length === 0) {
87
+ out.push(`${pad}${kk}: []`);
88
+ return;
89
+ }
90
+ if (list.every((x) => isScalar(x))) {
91
+ out.push(`${pad}${kk}: [${list.map((x) => scalar(x, true)).join(", ")}]`);
92
+ return;
93
+ }
94
+ out.push(`${pad}${kk}:`);
95
+ for (const item of list) emitItem(item, indent + 2, out);
96
+ }
97
+
98
+ function emitItem(item: unknown, indent: number, out: string[]): void {
99
+ const pad = " ".repeat(indent);
100
+ if (isPlainObject(item) && Object.values(item).some((x) => x !== undefined)) {
101
+ const lines: string[] = [];
102
+ emitMap(item, indent + 2, lines);
103
+ lines[0] = `${pad}- ${lines[0].slice(indent + 2)}`;
104
+ out.push(...lines);
105
+ } else if (isPlainObject(item)) {
106
+ out.push(`${pad}- {}`);
107
+ } else if (Array.isArray(item)) {
108
+ if (item.length === 0) {
109
+ out.push(`${pad}- []`);
110
+ } else if (item.every((x) => isScalar(x))) {
111
+ out.push(`${pad}- [${item.map((x) => scalar(x, true)).join(", ")}]`);
112
+ } else {
113
+ out.push(`${pad}-`);
114
+ for (const inner of item) emitItem(inner, indent + 2, out);
115
+ }
116
+ } else {
117
+ out.push(`${pad}- ${scalar(item, false)}`);
118
+ }
119
+ }
120
+
121
+ export interface EmitOptions {
122
+ /** Comment lines (without `# `) written above the config. */
123
+ header?: string[];
124
+ }
125
+
126
+ /** Print a collector config as YAML. Empty sections are left out. */
127
+ export function emitCollectorYaml(config: CollectorConfig, options: EmitOptions = {}): string {
128
+ const blocks: string[] = [];
129
+ if (options.header && options.header.length > 0) {
130
+ blocks.push(options.header.map((l) => `# ${l}`).join("\n"));
131
+ }
132
+ const cfg = config as Record<string, unknown>;
133
+ const known = new Set<string>(SECTION_ORDER);
134
+ const order = [...SECTION_ORDER, ...Object.keys(cfg).filter((k) => !known.has(k))];
135
+ for (const section of order) {
136
+ const value = cfg[section];
137
+ if (value === undefined) continue;
138
+ if (isPlainObject(value) && Object.values(value).every((x) => x === undefined)) continue;
139
+ const lines: string[] = [];
140
+ emitMap({ [section]: value }, 0, lines);
141
+ blocks.push(lines.join("\n"));
142
+ }
143
+ if (blocks.length === 0) return "";
144
+ return `${blocks.join("\n\n")}\n`;
145
+ }