@ancplua/qyl-api-schema 10.0.1 → 11.0.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/README.md CHANGED
@@ -82,7 +82,7 @@ against the schema, so pair it with the matching type from `./types`.
82
82
 
83
83
  `scripts/emit-contract-revision.mjs` stamps a deterministic revision — `sha256:` plus
84
84
  the first 16 hex characters of the contract's canonical semantic digest — into both
85
- generated faces during `npm run compile`. A collector reports the revision it was built
85
+ generated faces during `bun run compile`. A collector reports the revision it was built
86
86
  against on its health response, so a client can detect a peer built from a different
87
87
  contract instead of discovering the mismatch one malformed field at a time. Read the
88
88
  current value from a running collector or the generated artifacts; it is derived, never
package/common/types.tsp CHANGED
@@ -255,7 +255,23 @@ model AttributeKeyValueListValue {
255
255
  values: Record<AttributeValue>;
256
256
  }
257
257
 
258
- @doc("Lossless JSON projection of an OpenTelemetry AnyValue attribute.")
258
+ @doc("Object-shaped AttributeValue variants. The variant name is the wire `type` tag.")
259
+ @discriminated(#{ envelope: "none", discriminatorPropertyName: "type" })
260
+ union AttributeObjectValue {
261
+ @doc("Lossless 64-bit integer value")
262
+ int: AttributeIntValue,
263
+
264
+ @doc("Lossless finite or non-finite 64-bit floating point value")
265
+ double: AttributeDoubleValue,
266
+
267
+ @doc("Bytes value projected as an explicit tagged object")
268
+ bytes: AttributeBytesValue,
269
+
270
+ @doc("Recursive key-value-list value")
271
+ kvlist: AttributeKeyValueListValue,
272
+ }
273
+
274
+ @doc("Lossless JSON projection of an OpenTelemetry AnyValue attribute. Primitive variants are bare JSON values; object variants carry a `type` tag.")
259
275
  union AttributeValue {
260
276
  @doc("Empty AnyValue")
261
277
  emptyValue: null,
@@ -266,20 +282,11 @@ union AttributeValue {
266
282
  @doc("Boolean value")
267
283
  boolValue: boolean,
268
284
 
269
- @doc("Lossless 64-bit integer value")
270
- intValue: AttributeIntValue,
271
-
272
- @doc("Lossless finite or non-finite 64-bit floating point value")
273
- doubleValue: AttributeDoubleValue,
274
-
275
- @doc("Bytes value projected as an explicit tagged object")
276
- bytesValue: AttributeBytesValue,
277
-
278
285
  @doc("Nested and heterogeneous array value")
279
286
  arrayValue: AttributeValue[],
280
287
 
281
- @doc("Recursive key-value-list value")
282
- keyValueListValue: AttributeKeyValueListValue,
288
+ @doc("Tagged object value")
289
+ objectValue: AttributeObjectValue,
283
290
  }
284
291
 
285
292
  @doc("Key-value attribute pair following OTel conventions")
@@ -142,25 +142,43 @@
142
142
  },
143
143
  "description": "Tagged recursive OTLP key-value-list, distinct from other object-shaped attribute variants."
144
144
  },
145
- "Common.AttributeValue": {
146
- "anyOf": [
145
+ "Common.AttributeObjectValue": {
146
+ "type": "object",
147
+ "oneOf": [
147
148
  {
148
- "type": "null"
149
+ "$ref": "#/$defs/Common.AttributeIntValue"
149
150
  },
150
151
  {
151
- "type": "string"
152
+ "$ref": "#/$defs/Common.AttributeDoubleValue"
152
153
  },
153
154
  {
154
- "type": "boolean"
155
+ "$ref": "#/$defs/Common.AttributeBytesValue"
155
156
  },
156
157
  {
157
- "$ref": "#/$defs/Common.AttributeIntValue"
158
+ "$ref": "#/$defs/Common.AttributeKeyValueListValue"
159
+ }
160
+ ],
161
+ "discriminator": {
162
+ "propertyName": "type",
163
+ "mapping": {
164
+ "int": "#/components/schemas/Common.AttributeIntValue",
165
+ "double": "#/components/schemas/Common.AttributeDoubleValue",
166
+ "bytes": "#/components/schemas/Common.AttributeBytesValue",
167
+ "kvlist": "#/components/schemas/Common.AttributeKeyValueListValue"
168
+ }
169
+ },
170
+ "description": "Object-shaped AttributeValue variants. The variant name is the wire `type` tag."
171
+ },
172
+ "Common.AttributeValue": {
173
+ "anyOf": [
174
+ {
175
+ "type": "null"
158
176
  },
159
177
  {
160
- "$ref": "#/$defs/Common.AttributeDoubleValue"
178
+ "type": "string"
161
179
  },
162
180
  {
163
- "$ref": "#/$defs/Common.AttributeBytesValue"
181
+ "type": "boolean"
164
182
  },
165
183
  {
166
184
  "type": "array",
@@ -169,10 +187,10 @@
169
187
  }
170
188
  },
171
189
  {
172
- "$ref": "#/$defs/Common.AttributeKeyValueListValue"
190
+ "$ref": "#/$defs/Common.AttributeObjectValue"
173
191
  }
174
192
  ],
175
- "description": "Lossless JSON projection of an OpenTelemetry AnyValue attribute."
193
+ "description": "Lossless JSON projection of an OpenTelemetry AnyValue attribute. Primitive variants are bare JSON values; object variants carry a `type` tag."
176
194
  },
177
195
  "Common.Attributes": {
178
196
  "type": "object",
@@ -2210,104 +2228,6 @@
2210
2228
  ],
2211
2229
  "description": "Telemetry SDK language"
2212
2230
  },
2213
- "OTel.Logs.LogBody": {
2214
- "type": "object",
2215
- "oneOf": [
2216
- {
2217
- "$ref": "#/$defs/OTel.Logs.LogBodyString"
2218
- },
2219
- {
2220
- "$ref": "#/$defs/OTel.Logs.LogBodyKvList"
2221
- },
2222
- {
2223
- "$ref": "#/$defs/OTel.Logs.LogBodyArray"
2224
- },
2225
- {
2226
- "$ref": "#/$defs/OTel.Logs.LogBodyBytes"
2227
- }
2228
- ],
2229
- "discriminator": {
2230
- "propertyName": "kind",
2231
- "mapping": {
2232
- "stringBody": "#/components/schemas/OTel.Logs.LogBodyString",
2233
- "kvListBody": "#/components/schemas/OTel.Logs.LogBodyKvList",
2234
- "arrayBody": "#/components/schemas/OTel.Logs.LogBodyArray",
2235
- "bytesBody": "#/components/schemas/OTel.Logs.LogBodyBytes"
2236
- }
2237
- },
2238
- "description": "Log body content - can be string, structured, or bytes"
2239
- },
2240
- "OTel.Logs.LogBodyArray": {
2241
- "type": "object",
2242
- "required": [
2243
- "array_value"
2244
- ],
2245
- "properties": {
2246
- "array_value": {
2247
- "type": "array",
2248
- "items": {
2249
- "$ref": "#/$defs/Common.AttributeValue"
2250
- },
2251
- "description": "Array of values"
2252
- }
2253
- },
2254
- "unevaluatedProperties": {
2255
- "not": {}
2256
- },
2257
- "description": "Array log body"
2258
- },
2259
- "OTel.Logs.LogBodyBytes": {
2260
- "type": "object",
2261
- "required": [
2262
- "bytes_value"
2263
- ],
2264
- "properties": {
2265
- "bytes_value": {
2266
- "type": "string",
2267
- "contentEncoding": "base64",
2268
- "description": "Binary value (base64 encoded)"
2269
- }
2270
- },
2271
- "unevaluatedProperties": {
2272
- "not": {}
2273
- },
2274
- "description": "Binary log body"
2275
- },
2276
- "OTel.Logs.LogBodyKvList": {
2277
- "type": "object",
2278
- "required": [
2279
- "kv_list_value"
2280
- ],
2281
- "properties": {
2282
- "kv_list_value": {
2283
- "type": "array",
2284
- "items": {
2285
- "$ref": "#/$defs/Common.Attribute"
2286
- },
2287
- "description": "Key-value pairs"
2288
- }
2289
- },
2290
- "unevaluatedProperties": {
2291
- "not": {}
2292
- },
2293
- "description": "Structured key-value log body"
2294
- },
2295
- "OTel.Logs.LogBodyString": {
2296
- "type": "object",
2297
- "required": [
2298
- "string_value"
2299
- ],
2300
- "properties": {
2301
- "string_value": {
2302
- "type": "string",
2303
- "description": "String value"
2304
- }
2305
- },
2306
- "unevaluatedProperties": {
2307
- "not": {}
2308
- },
2309
- "description": "String log body"
2310
- },
2311
2231
  "OTel.Logs.LogRecord": {
2312
2232
  "type": "object",
2313
2233
  "required": [
@@ -2335,8 +2255,8 @@
2335
2255
  "description": "Severity text (DEBUG, INFO, WARN, ERROR, etc.)"
2336
2256
  },
2337
2257
  "body": {
2338
- "$ref": "#/$defs/OTel.Logs.LogBody",
2339
- "description": "Log body - the main content"
2258
+ "$ref": "#/$defs/Common.AttributeValue",
2259
+ "description": "Log body: the OTLP AnyValue, projected exactly like an attribute value"
2340
2260
  },
2341
2261
  "attributes": {
2342
2262
  "type": "array",
@@ -13124,25 +13124,43 @@
13124
13124
  },
13125
13125
  "description": "Tagged recursive OTLP key-value-list, distinct from other object-shaped attribute variants."
13126
13126
  },
13127
- "Common.AttributeValue": {
13128
- "anyOf": [
13127
+ "Common.AttributeObjectValue": {
13128
+ "type": "object",
13129
+ "oneOf": [
13129
13130
  {
13130
- "type": "null"
13131
+ "$ref": "#/components/schemas/Common.AttributeIntValue"
13131
13132
  },
13132
13133
  {
13133
- "type": "string"
13134
+ "$ref": "#/components/schemas/Common.AttributeDoubleValue"
13134
13135
  },
13135
13136
  {
13136
- "type": "boolean"
13137
+ "$ref": "#/components/schemas/Common.AttributeBytesValue"
13137
13138
  },
13138
13139
  {
13139
- "$ref": "#/components/schemas/Common.AttributeIntValue"
13140
+ "$ref": "#/components/schemas/Common.AttributeKeyValueListValue"
13141
+ }
13142
+ ],
13143
+ "discriminator": {
13144
+ "propertyName": "type",
13145
+ "mapping": {
13146
+ "int": "#/components/schemas/Common.AttributeIntValue",
13147
+ "double": "#/components/schemas/Common.AttributeDoubleValue",
13148
+ "bytes": "#/components/schemas/Common.AttributeBytesValue",
13149
+ "kvlist": "#/components/schemas/Common.AttributeKeyValueListValue"
13150
+ }
13151
+ },
13152
+ "description": "Object-shaped AttributeValue variants. The variant name is the wire `type` tag."
13153
+ },
13154
+ "Common.AttributeValue": {
13155
+ "anyOf": [
13156
+ {
13157
+ "type": "null"
13140
13158
  },
13141
13159
  {
13142
- "$ref": "#/components/schemas/Common.AttributeDoubleValue"
13160
+ "type": "string"
13143
13161
  },
13144
13162
  {
13145
- "$ref": "#/components/schemas/Common.AttributeBytesValue"
13163
+ "type": "boolean"
13146
13164
  },
13147
13165
  {
13148
13166
  "type": "array",
@@ -13151,10 +13169,10 @@
13151
13169
  }
13152
13170
  },
13153
13171
  {
13154
- "$ref": "#/components/schemas/Common.AttributeKeyValueListValue"
13172
+ "$ref": "#/components/schemas/Common.AttributeObjectValue"
13155
13173
  }
13156
13174
  ],
13157
- "description": "Lossless JSON projection of an OpenTelemetry AnyValue attribute."
13175
+ "description": "Lossless JSON projection of an OpenTelemetry AnyValue attribute. Primitive variants are bare JSON values; object variants carry a `type` tag."
13158
13176
  },
13159
13177
  "Common.Attributes": {
13160
13178
  "type": "object",
@@ -15190,104 +15208,6 @@
15190
15208
  ],
15191
15209
  "description": "Telemetry SDK language"
15192
15210
  },
15193
- "OTel.Logs.LogBody": {
15194
- "type": "object",
15195
- "oneOf": [
15196
- {
15197
- "$ref": "#/components/schemas/OTel.Logs.LogBodyString"
15198
- },
15199
- {
15200
- "$ref": "#/components/schemas/OTel.Logs.LogBodyKvList"
15201
- },
15202
- {
15203
- "$ref": "#/components/schemas/OTel.Logs.LogBodyArray"
15204
- },
15205
- {
15206
- "$ref": "#/components/schemas/OTel.Logs.LogBodyBytes"
15207
- }
15208
- ],
15209
- "discriminator": {
15210
- "propertyName": "kind",
15211
- "mapping": {
15212
- "stringBody": "#/components/schemas/OTel.Logs.LogBodyString",
15213
- "kvListBody": "#/components/schemas/OTel.Logs.LogBodyKvList",
15214
- "arrayBody": "#/components/schemas/OTel.Logs.LogBodyArray",
15215
- "bytesBody": "#/components/schemas/OTel.Logs.LogBodyBytes"
15216
- }
15217
- },
15218
- "description": "Log body content - can be string, structured, or bytes"
15219
- },
15220
- "OTel.Logs.LogBodyArray": {
15221
- "type": "object",
15222
- "required": [
15223
- "array_value"
15224
- ],
15225
- "properties": {
15226
- "array_value": {
15227
- "type": "array",
15228
- "items": {
15229
- "$ref": "#/components/schemas/Common.AttributeValue"
15230
- },
15231
- "description": "Array of values"
15232
- }
15233
- },
15234
- "unevaluatedProperties": {
15235
- "not": {}
15236
- },
15237
- "description": "Array log body"
15238
- },
15239
- "OTel.Logs.LogBodyBytes": {
15240
- "type": "object",
15241
- "required": [
15242
- "bytes_value"
15243
- ],
15244
- "properties": {
15245
- "bytes_value": {
15246
- "type": "string",
15247
- "contentEncoding": "base64",
15248
- "description": "Binary value (base64 encoded)"
15249
- }
15250
- },
15251
- "unevaluatedProperties": {
15252
- "not": {}
15253
- },
15254
- "description": "Binary log body"
15255
- },
15256
- "OTel.Logs.LogBodyKvList": {
15257
- "type": "object",
15258
- "required": [
15259
- "kv_list_value"
15260
- ],
15261
- "properties": {
15262
- "kv_list_value": {
15263
- "type": "array",
15264
- "items": {
15265
- "$ref": "#/components/schemas/Common.Attribute"
15266
- },
15267
- "description": "Key-value pairs"
15268
- }
15269
- },
15270
- "unevaluatedProperties": {
15271
- "not": {}
15272
- },
15273
- "description": "Structured key-value log body"
15274
- },
15275
- "OTel.Logs.LogBodyString": {
15276
- "type": "object",
15277
- "required": [
15278
- "string_value"
15279
- ],
15280
- "properties": {
15281
- "string_value": {
15282
- "type": "string",
15283
- "description": "String value"
15284
- }
15285
- },
15286
- "unevaluatedProperties": {
15287
- "not": {}
15288
- },
15289
- "description": "String log body"
15290
- },
15291
15211
  "OTel.Logs.LogRecord": {
15292
15212
  "type": "object",
15293
15213
  "required": [
@@ -15315,8 +15235,8 @@
15315
15235
  "description": "Severity text (DEBUG, INFO, WARN, ERROR, etc.)"
15316
15236
  },
15317
15237
  "body": {
15318
- "$ref": "#/components/schemas/OTel.Logs.LogBody",
15319
- "description": "Log body - the main content"
15238
+ "$ref": "#/components/schemas/Common.AttributeValue",
15239
+ "description": "Log body: the OTLP AnyValue, projected exactly like an attribute value"
15320
15240
  },
15321
15241
  "attributes": {
15322
15242
  "type": "array",
@@ -0,0 +1,23 @@
1
+ import type { AttributeValue } from "@ancplua/qyl-api-schema/types";
2
+ export { AttributeObjectValueTags, isAttributeObjectValue, matchAttributeValue, } from "../../generated/ts-runtime/runtime.js";
3
+ export type { AttributeObjectValueTag, AttributeValueHandlers } from "../../generated/ts-runtime/runtime.js";
4
+ /** An AttributeValue with the wire tags removed: what a reader sees, not how it travelled. */
5
+ export type DecodedAttributeValue = null | string | boolean | number | DecodedAttributeValue[] | {
6
+ readonly type: "bytes";
7
+ readonly base64: string;
8
+ } | {
9
+ readonly [key: string]: DecodedAttributeValue;
10
+ };
11
+ /** Strip the tags. int64 stays text so no digit is lost; bytes stay marked so they never read as a string. */
12
+ export declare function decodeAttributeValue(value: AttributeValue): DecodedAttributeValue;
13
+ /** One line of text for any value; never `[object Object]`. */
14
+ export declare function formatAttributeValue(value: AttributeValue): string;
15
+ /** The value when it is a plain string, otherwise undefined. */
16
+ export declare function attributeString(value: AttributeValue | undefined): string | undefined;
17
+ /** A JavaScript number when one can represent the value exactly, otherwise undefined. */
18
+ export declare function attributeNumber(value: AttributeValue | undefined): number | undefined;
19
+ /**
20
+ * A stable text identity for grouping and hashing: the canonical wire JSON with object keys
21
+ * sorted. Two values with the same identity are the same attribute value.
22
+ */
23
+ export declare function attributeIdentity(value: AttributeValue): string;
@@ -0,0 +1,70 @@
1
+ import { matchAttributeValue } from "../../generated/ts-runtime/runtime.js";
2
+ export { AttributeObjectValueTags, isAttributeObjectValue, matchAttributeValue, } from "../../generated/ts-runtime/runtime.js";
3
+ /** Strip the tags. int64 stays text so no digit is lost; bytes stay marked so they never read as a string. */
4
+ export function decodeAttributeValue(value) {
5
+ return matchAttributeValue(value, {
6
+ emptyValue: () => null,
7
+ stringValue: (text) => text,
8
+ boolValue: (flag) => flag,
9
+ arrayValue: (items) => items.map(decodeAttributeValue),
10
+ int: (tagged) => tagged.value,
11
+ double: (tagged) => tagged.value,
12
+ bytes: (tagged) => ({ type: "bytes", base64: tagged.base64 }),
13
+ kvlist: (tagged) => Object.fromEntries(Object.entries(tagged.values).map(([key, nested]) => [key, decodeAttributeValue(nested)])),
14
+ });
15
+ }
16
+ /** One line of text for any value; never `[object Object]`. */
17
+ export function formatAttributeValue(value) {
18
+ const decoded = decodeAttributeValue(value);
19
+ if (decoded === null)
20
+ return "null";
21
+ if (typeof decoded === "string")
22
+ return decoded;
23
+ if (typeof decoded === "boolean" || typeof decoded === "number")
24
+ return String(decoded);
25
+ return JSON.stringify(decoded);
26
+ }
27
+ /** The value when it is a plain string, otherwise undefined. */
28
+ export function attributeString(value) {
29
+ return typeof value === "string" ? value : undefined;
30
+ }
31
+ /** A JavaScript number when one can represent the value exactly, otherwise undefined. */
32
+ export function attributeNumber(value) {
33
+ if (value === undefined)
34
+ return undefined;
35
+ return matchAttributeValue(value, {
36
+ emptyValue: () => undefined,
37
+ stringValue: () => undefined,
38
+ boolValue: () => undefined,
39
+ arrayValue: () => undefined,
40
+ int: (tagged) => {
41
+ const parsed = Number(tagged.value);
42
+ return Number.isSafeInteger(parsed) ? parsed : undefined;
43
+ },
44
+ double: (tagged) => Number(tagged.value),
45
+ bytes: () => undefined,
46
+ kvlist: () => undefined,
47
+ });
48
+ }
49
+ /**
50
+ * A stable text identity for grouping and hashing: the canonical wire JSON with object keys
51
+ * sorted. Two values with the same identity are the same attribute value.
52
+ */
53
+ export function attributeIdentity(value) {
54
+ return JSON.stringify(sortKeys(value));
55
+ }
56
+ function sortKeys(value) {
57
+ return matchAttributeValue(value, {
58
+ emptyValue: () => null,
59
+ stringValue: (text) => text,
60
+ boolValue: (flag) => flag,
61
+ arrayValue: (items) => items.map(sortKeys),
62
+ int: (tagged) => ({ type: "int", value: tagged.value }),
63
+ double: (tagged) => ({ type: "double", value: tagged.value }),
64
+ bytes: (tagged) => ({ base64: tagged.base64, type: "bytes" }),
65
+ kvlist: (tagged) => ({
66
+ type: "kvlist",
67
+ values: Object.fromEntries(Object.entries(tagged.values).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([key, nested]) => [key, sortKeys(nested)])),
68
+ }),
69
+ });
70
+ }
@@ -396,9 +396,9 @@ export declare const FetchTelemetryViewValues: {
396
396
  };
397
397
  export type FetchTelemetryView = typeof FetchTelemetryViewValues[keyof typeof FetchTelemetryViewValues];
398
398
  export type AttributeDouble = number | "NaN" | "Infinity" | "-Infinity";
399
- export type AttributeValue = null | string | boolean | AttributeIntValue | AttributeDoubleValue | AttributeBytesValue | AttributeValue[] | AttributeKeyValueListValue;
399
+ export type AttributeValue = null | string | boolean | AttributeValue[] | AttributeObjectValue;
400
+ export type AttributeObjectValue = AttributeIntValue | AttributeDoubleValue | AttributeBytesValue | AttributeKeyValueListValue;
400
401
  export type ApiError = NotFoundError | ValidationError | UnauthorizedError | ForbiddenError | ConflictError | RateLimitError | InternalServerError | BadGatewayError | ServiceUnavailableError;
401
- export type LogBody = LogBodyString | LogBodyKvList | LogBodyArray | LogBodyBytes;
402
402
  export type RunnerResourceEvents = RunnerResourceState;
403
403
  export type RunnerLogEvents = RunnerLogLine;
404
404
  export type WorkbenchServerConfiguration = WorkbenchStdioServerConfiguration | WorkbenchStreamableHttpServerConfiguration | WorkbenchBuiltinServerConfiguration;
@@ -643,7 +643,7 @@ export interface LogRecord {
643
643
  "observed_time_unix_nano": string;
644
644
  "severity_number": SeverityNumber;
645
645
  "severity_text"?: SeverityText;
646
- "body": LogBody;
646
+ "body": AttributeValue;
647
647
  "attributes"?: Attribute[];
648
648
  "dropped_attributes_count"?: number;
649
649
  "flags"?: number;
@@ -653,18 +653,6 @@ export interface LogRecord {
653
653
  "resource": Resource;
654
654
  "instrumentation_scope"?: InstrumentationScope;
655
655
  }
656
- export interface LogBodyString {
657
- "string_value": string;
658
- }
659
- export interface LogBodyKvList {
660
- "kv_list_value": Attribute[];
661
- }
662
- export interface LogBodyArray {
663
- "array_value": AttributeValue[];
664
- }
665
- export interface LogBodyBytes {
666
- "bytes_value": string;
667
- }
668
656
  export interface LogTemplate {
669
657
  "template": string;
670
658
  "parameters": Attribute[];
@@ -320,4 +320,4 @@ export const FetchTelemetryViewValues = {
320
320
  };
321
321
  // --- contract revision (scripts/emit-contract-revision.mjs) ---
322
322
  /** Revision of the API contract these types were emitted from; compare against HealthReport.contract_revision. */
323
- export const CONTRACT_REVISION = "sha256:cd69d9c37a41916c";
323
+ export const CONTRACT_REVISION = "sha256:5c1aa27ccdf48067";
@@ -0,0 +1,16 @@
1
+ import type { AttributeBytesValue, AttributeDoubleValue, AttributeIntValue, AttributeKeyValueListValue, AttributeObjectValue, AttributeValue } from "./api.js";
2
+ export declare const AttributeObjectValueTags: readonly ["int", "double", "bytes", "kvlist"];
3
+ export type AttributeObjectValueTag = typeof AttributeObjectValueTags[number];
4
+ export declare function isAttributeObjectValue(value: unknown): value is AttributeObjectValue;
5
+ export interface AttributeValueHandlers<R> {
6
+ emptyValue: () => R;
7
+ stringValue: (value: string) => R;
8
+ boolValue: (value: boolean) => R;
9
+ arrayValue: (value: AttributeValue[]) => R;
10
+ int: (value: AttributeIntValue) => R;
11
+ double: (value: AttributeDoubleValue) => R;
12
+ bytes: (value: AttributeBytesValue) => R;
13
+ kvlist: (value: AttributeKeyValueListValue) => R;
14
+ }
15
+ /** Exhaustive over every AttributeValue variant; a handler per variant, no default. */
16
+ export declare function matchAttributeValue<R>(value: AttributeValue, handlers: AttributeValueHandlers<R>): R;
@@ -0,0 +1,26 @@
1
+ // <auto-generated/>
2
+ // Copyright (c) 2025-2026 ancplua
3
+ export const AttributeObjectValueTags = ["int", "double", "bytes", "kvlist"];
4
+ export function isAttributeObjectValue(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value)
6
+ && AttributeObjectValueTags.includes(String(value.type));
7
+ }
8
+ /** Exhaustive over every AttributeValue variant; a handler per variant, no default. */
9
+ export function matchAttributeValue(value, handlers) {
10
+ if (value === null)
11
+ return handlers.emptyValue();
12
+ if (typeof value === "string")
13
+ return handlers.stringValue(value);
14
+ if (typeof value === "boolean")
15
+ return handlers.boolValue(value);
16
+ if (Array.isArray(value))
17
+ return handlers.arrayValue(value);
18
+ switch (value.type) {
19
+ case "int": return handlers.int(value);
20
+ case "double": return handlers.double(value);
21
+ case "bytes": return handlers.bytes(value);
22
+ case "kvlist": return handlers.kvlist(value);
23
+ default:
24
+ throw new TypeError(`AttributeObjectValue has unknown type tag '${String(value.type)}'.`);
25
+ }
26
+ }
package/otel/logs.tsp CHANGED
@@ -40,8 +40,8 @@ model LogRecord {
40
40
  @encodedName("application/json", "severity_text")
41
41
  severityText?: SeverityText;
42
42
 
43
- @doc("Log body - the main content")
44
- body: LogBody;
43
+ @doc("Log body: the OTLP AnyValue, projected exactly like an attribute value")
44
+ body: AttributeValue;
45
45
 
46
46
  @doc("Log attributes")
47
47
  attributes?: Attribute[];
@@ -77,50 +77,6 @@ model LogRecord {
77
77
  // Log Body Types (Discriminated Union)
78
78
  // =============================================================================
79
79
 
80
- @doc("Log body content - can be string, structured, or bytes")
81
- @discriminated(#{ envelope: "none" })
82
- union LogBody {
83
- @doc("Plain string body")
84
- stringBody: LogBodyString,
85
-
86
- @doc("Structured key-value body")
87
- kvListBody: LogBodyKvList,
88
-
89
- @doc("Array body")
90
- arrayBody: LogBodyArray,
91
-
92
- @doc("Binary body")
93
- bytesBody: LogBodyBytes,
94
- }
95
-
96
- @doc("String log body")
97
- model LogBodyString {
98
- @doc("String value")
99
- @encodedName("application/json", "string_value")
100
- stringValue: string;
101
- }
102
-
103
- @doc("Structured key-value log body")
104
- model LogBodyKvList {
105
- @doc("Key-value pairs")
106
- @encodedName("application/json", "kv_list_value")
107
- kvListValue: Attribute[];
108
- }
109
-
110
- @doc("Array log body")
111
- model LogBodyArray {
112
- @doc("Array of values")
113
- @encodedName("application/json", "array_value")
114
- arrayValue: AttributeValue[];
115
- }
116
-
117
- @doc("Binary log body")
118
- model LogBodyBytes {
119
- @doc("Binary value (base64 encoded)")
120
- @encodedName("application/json", "bytes_value")
121
- bytesValue: bytes;
122
- }
123
-
124
80
  // =============================================================================
125
81
  // Structured Log Templates
126
82
  // =============================================================================
package/package.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "name": "@ancplua/qyl-api-schema",
3
- "version": "10.0.1",
3
+ "version": "11.0.1",
4
4
  "description": "TypeSpec source of truth for qyl API contracts. Emits OpenAPI, JSON Schema, Qyl.Api.Contracts DTOs, and TypeScript contract types; not an OpenTelemetry package, storage schema, or server implementation.",
5
5
  "license": "Apache-2.0",
6
+ "packageManager": "bun@1.4.2",
7
+ "workspaces": [
8
+ "emitters/csharp",
9
+ "emitters/ts-types",
10
+ "emitters/qyl-lint"
11
+ ],
6
12
  "repository": {
7
13
  "type": "git",
8
14
  "url": "git+https://github.com/ANcpLua/qyl-api-schema.git"
@@ -47,6 +53,11 @@
47
53
  "types": "./generated/zod-runtime/index.d.ts",
48
54
  "import": "./generated/zod-runtime/index.js",
49
55
  "default": "./generated/zod-runtime/index.js"
56
+ },
57
+ "./runtime": {
58
+ "types": "./generated/runtime/index.d.ts",
59
+ "import": "./generated/runtime/index.js",
60
+ "default": "./generated/runtime/index.js"
50
61
  }
51
62
  },
52
63
  "files": [
@@ -70,12 +81,15 @@
70
81
  "otel/span.tsp",
71
82
  "generated/ts-runtime/api.d.ts",
72
83
  "generated/ts-runtime/api.js",
84
+ "generated/ts-runtime/runtime.d.ts",
85
+ "generated/ts-runtime/runtime.js",
73
86
  "generated/openapi/qyl.openapi.json",
74
87
  "generated/json-schema/qyl-api-schema.json",
75
88
  "generated/zod-runtime/index.d.ts",
76
89
  "generated/zod-runtime/index.js",
77
90
  "README.md",
78
- "LICENSE"
91
+ "LICENSE",
92
+ "generated/runtime"
79
93
  ],
80
94
  "publishConfig": {
81
95
  "access": "public",
@@ -89,16 +103,18 @@
89
103
  "build:zod-runtime": "tsc -p tsconfig.zod.json",
90
104
  "build:json-schema": "node scripts/openapi-to-json-schema.mjs",
91
105
  "emit:contract-revision": "node scripts/emit-contract-revision.mjs",
92
- "prepare": "npm run build:emitters",
93
- "prepack": "npm run compile",
94
- "compile": "npm run clean:generated && npm run build:emitters && tsp compile main.tsp && npm run emit:contract-revision && npm run build:json-schema && npm run build:ts-runtime && npm run build:zod-runtime",
106
+ "prepare": "bun run build:emitters",
107
+ "prepack": "bun run compile",
108
+ "compile": "bun run clean:generated && bun run build:emitters && tsp compile main.tsp && bun run emit:contract-revision && bun run build:json-schema && bun run build:ts-runtime && bun run build:runtime && bun run build:zod-runtime",
95
109
  "format": "tsp format **/*.tsp",
96
- "lint": "npm run build:emitters && tsp compile main.tsp --no-emit --warn-as-error",
97
- "lint:public": "npm run build:emitters && tsp compile index.tsp --no-emit --warn-as-error",
110
+ "lint": "bun run build:emitters && tsp compile main.tsp --no-emit --warn-as-error",
111
+ "lint:public": "bun run build:emitters && tsp compile index.tsp --no-emit --warn-as-error",
98
112
  "verify:routes": "node scripts/verify-route-contracts.mjs",
99
113
  "verify:contracts": "node scripts/verify-contract-fixtures.mjs",
100
- "verify:zod-contracts": "npm run build:zod-runtime && node scripts/verify-zod-contracts.mjs",
101
- "verify:lint-rules": "npm run build:emitters && node scripts/verify-lint-rules.mjs"
114
+ "verify:zod-contracts": "bun run build:zod-runtime && node scripts/verify-zod-contracts.mjs",
115
+ "verify:lint-rules": "bun run build:emitters && node scripts/verify-lint-rules.mjs",
116
+ "lint:js": "oxlint .",
117
+ "build:runtime": "tsc -p tsconfig.runtime.json"
102
118
  },
103
119
  "peerDependencies": {
104
120
  "@typespec/compiler": "^1.13.0 || >=1.13.0-dev.0",
@@ -133,9 +149,9 @@
133
149
  }
134
150
  },
135
151
  "devDependencies": {
136
- "@ancplua/typespec-emit-csharp": "file:./emitters/csharp",
137
- "@ancplua/typespec-emit-ts-types": "file:./emitters/ts-types",
138
- "@ancplua/typespec-qyl-lint": "file:./emitters/qyl-lint",
152
+ "@ancplua/typespec-emit-csharp": "*",
153
+ "@ancplua/typespec-emit-ts-types": "*",
154
+ "@ancplua/typespec-qyl-lint": "*",
139
155
  "@types/node": "26.4.1",
140
156
  "@typespec/compiler": "1.16.0",
141
157
  "@typespec/events": "0.86.0",
@@ -144,6 +160,8 @@
144
160
  "@typespec/openapi3": "1.16.0",
145
161
  "@typespec/sse": "0.86.0",
146
162
  "ajv": "8.20.0",
163
+ "oxlint": "^1.83.0",
164
+ "oxlint-tsgolint": "^7.0.2001",
147
165
  "typescript": "7.0.2",
148
166
  "zod": "4.5.4"
149
167
  }