@logbrew/sdk 0.1.14 → 0.1.15
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/core.cjs +18 -9
- package/issue-diagnostics.cjs +6 -5
- package/package.json +1 -1
package/core.cjs
CHANGED
|
@@ -75,6 +75,7 @@ const PINO_SENSITIVE_CONTEXT_FIELDS = new Set([
|
|
|
75
75
|
const TRACEPARENT_PATTERN = /^([0-9a-fA-F]{2})-([0-9a-fA-F]{32})-([0-9a-fA-F]{16})-([0-9a-fA-F]{2})$/u;
|
|
76
76
|
const ZERO_TRACE_ID = "00000000000000000000000000000000";
|
|
77
77
|
const ZERO_SPAN_ID = "0000000000000000";
|
|
78
|
+
const RFC3339_TIMESTAMP_PATTERN = /^(\d{4})-(\d{2})-(\d{2})T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d{1,9})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/u;
|
|
78
79
|
const DEFAULT_MAX_QUEUE_SIZE = 1000;
|
|
79
80
|
const DEFAULT_MAX_QUEUE_BYTES = 4 * 1024 * 1024;
|
|
80
81
|
const DEFAULT_MAX_BATCH_EVENTS = 100;
|
|
@@ -2199,17 +2200,25 @@ function requireTraceFlags(traceFlags) {
|
|
|
2199
2200
|
|
|
2200
2201
|
function requireTimestamp(timestamp) {
|
|
2201
2202
|
requireNonEmpty("timestamp", timestamp);
|
|
2202
|
-
if (timestamp.endsWith("Z")) {
|
|
2203
|
-
return;
|
|
2204
|
-
}
|
|
2205
2203
|
const timePortion = timestamp.split("T")[1];
|
|
2206
|
-
if (
|
|
2207
|
-
|
|
2204
|
+
if (!timestamp.endsWith("Z")
|
|
2205
|
+
&& !(timePortion && (timePortion.includes("+") || /.+-.+/.test(timePortion)))) {
|
|
2206
|
+
throw new SdkError(
|
|
2207
|
+
"validation_error",
|
|
2208
|
+
`timestamp must include a timezone offset: ${timestamp}`
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
const match = timestamp.match(RFC3339_TIMESTAMP_PATTERN);
|
|
2212
|
+
const calendar = new Date(0);
|
|
2213
|
+
calendar.setUTCHours(0, 0, 0, 0);
|
|
2214
|
+
calendar.setUTCFullYear(Number(match?.[1]), Number(match?.[2]) - 1, Number(match?.[3]));
|
|
2215
|
+
if (!match
|
|
2216
|
+
|| Number(match[1]) === 0
|
|
2217
|
+
|| calendar.getUTCFullYear() !== Number(match[1])
|
|
2218
|
+
|| calendar.getUTCMonth() !== Number(match[2]) - 1
|
|
2219
|
+
|| calendar.getUTCDate() !== Number(match[3])) {
|
|
2220
|
+
throw new SdkError("validation_error", `invalid timestamp: ${timestamp}`);
|
|
2208
2221
|
}
|
|
2209
|
-
throw new SdkError(
|
|
2210
|
-
"validation_error",
|
|
2211
|
-
`timestamp must include a timezone offset: ${timestamp}`
|
|
2212
|
-
);
|
|
2213
2222
|
}
|
|
2214
2223
|
|
|
2215
2224
|
function cloneMetadata(metadata) {
|
package/issue-diagnostics.cjs
CHANGED
|
@@ -545,17 +545,18 @@ function buildIssueDiagnosticsHelpers({ SdkError, requireTimestamp, validateIssu
|
|
|
545
545
|
}
|
|
546
546
|
|
|
547
547
|
function boundedText(label, value, maxLength, { rejectLocationText = false } = {}) {
|
|
548
|
-
|
|
548
|
+
const normalized = typeof value === "string" ? value.trim() : "";
|
|
549
|
+
if (normalized === "") {
|
|
549
550
|
throw validationError(`${label} must be non-empty`);
|
|
550
551
|
}
|
|
551
552
|
if (
|
|
552
|
-
Array.from(
|
|
553
|
-
|| hasControlCharacter(
|
|
554
|
-
|| (rejectLocationText && /[?#]/u.test(
|
|
553
|
+
Array.from(normalized).length > maxLength
|
|
554
|
+
|| hasControlCharacter(normalized)
|
|
555
|
+
|| (rejectLocationText && /[?#]/u.test(normalized))
|
|
555
556
|
) {
|
|
556
557
|
throw validationError(`${label} is invalid or exceeds ${maxLength} characters`);
|
|
557
558
|
}
|
|
558
|
-
return
|
|
559
|
+
return normalized;
|
|
559
560
|
}
|
|
560
561
|
|
|
561
562
|
function requireObject(label, value) {
|