@logbrew/sdk 0.1.37 → 0.1.39

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 (103) hide show
  1. package/automatic-delivery.cjs +271 -0
  2. package/batch-sender.cjs +164 -0
  3. package/bounded-number.cjs +34 -0
  4. package/browser-breadcrumbs.cjs +346 -136
  5. package/capture-support.cjs +100 -0
  6. package/client-options.cjs +292 -0
  7. package/client-report.cjs +232 -0
  8. package/client.cjs +447 -0
  9. package/console-arguments.cjs +151 -0
  10. package/console-capture.cjs +194 -0
  11. package/core.cjs +35 -2984
  12. package/delivery-health.cjs +133 -0
  13. package/error-causes.cjs +130 -0
  14. package/error-details.cjs +124 -0
  15. package/error-issue.cjs +187 -0
  16. package/event-clone.cjs +55 -0
  17. package/event-metadata.cjs +40 -0
  18. package/event-pipeline.cjs +325 -0
  19. package/event-queue.cjs +306 -0
  20. package/event-store.cjs +237 -0
  21. package/event-validation.cjs +159 -0
  22. package/examples/agent-timeline.cjs +57 -46
  23. package/examples/agent-timeline.mjs +41 -35
  24. package/examples/index.mjs +122 -94
  25. package/examples/readme-example.cjs +36 -27
  26. package/examples/readme-example.mjs +21 -17
  27. package/examples/real-user-smoke.cjs +41 -32
  28. package/examples/real-user-smoke.mjs +26 -22
  29. package/exception-chain.cjs +205 -0
  30. package/index.d.ts +144 -1076
  31. package/index.js +1 -1
  32. package/issue-breadcrumbs.cjs +143 -0
  33. package/issue-diagnostics.cjs +94 -582
  34. package/issue-evidence.cjs +256 -0
  35. package/issue-exception.cjs +268 -0
  36. package/issue-stack-frames.cjs +220 -0
  37. package/issue-stack-text.cjs +101 -0
  38. package/issue-stack.cjs +188 -225
  39. package/issue-text.cjs +72 -0
  40. package/log-context.cjs +87 -67
  41. package/metric-validation.cjs +95 -0
  42. package/network-milestone.cjs +155 -0
  43. package/null-value.cjs +4 -0
  44. package/opentelemetry-bridge.cjs +330 -0
  45. package/opentelemetry-context.cjs +245 -0
  46. package/opentelemetry-exceptions.cjs +69 -0
  47. package/opentelemetry-keys.cjs +183 -0
  48. package/opentelemetry-span.cjs +286 -0
  49. package/opentelemetry-summary.cjs +213 -0
  50. package/opentelemetry-time.cjs +131 -0
  51. package/opentelemetry.cjs +99 -1068
  52. package/package.json +64 -1
  53. package/pino-destination.cjs +108 -0
  54. package/pino-record.cjs +237 -0
  55. package/product-action.cjs +163 -0
  56. package/provided-breadcrumbs.cjs +117 -0
  57. package/random-hex.cjs +29 -0
  58. package/react-native.js +1 -1
  59. package/recording-transport.cjs +68 -0
  60. package/release-artifacts-build.cjs +263 -84
  61. package/release-artifacts-common.js +347 -66
  62. package/release-artifacts-debug-id.js +178 -0
  63. package/release-artifacts-inspect.js +213 -0
  64. package/release-artifacts-issue-event.js +99 -0
  65. package/release-artifacts-manifest-artifact.js +107 -0
  66. package/release-artifacts-manifest.js +77 -0
  67. package/release-artifacts-mappings.js +265 -0
  68. package/release-artifacts-prepare.js +297 -0
  69. package/release-artifacts-source-context.js +210 -0
  70. package/release-artifacts-symbolication.js +272 -421
  71. package/release-artifacts-upload-files.js +122 -0
  72. package/release-artifacts-upload-request.js +246 -0
  73. package/release-artifacts-upload.js +155 -300
  74. package/release-artifacts-urls.js +49 -0
  75. package/release-artifacts.js +189 -662
  76. package/retry-delay.cjs +32 -0
  77. package/sdk-error.cjs +36 -0
  78. package/span-validation.cjs +191 -0
  79. package/stored-events.cjs +243 -0
  80. package/support-ticket.cjs +232 -122
  81. package/telemetry-context.cjs +343 -251
  82. package/trace-context.cjs +376 -179
  83. package/transport-error.cjs +23 -0
  84. package/types/client.d.ts +67 -0
  85. package/types/delivery.d.ts +125 -0
  86. package/types/issues.d.ts +249 -0
  87. package/types/logging.d.ts +175 -0
  88. package/types/opentelemetry.d.ts +205 -0
  89. package/types/product.d.ts +128 -0
  90. package/types/recording-transport.d.ts +15 -0
  91. package/types/sdk-error.d.ts +9 -0
  92. package/types/telemetry.d.ts +171 -0
  93. package/types/trace-context.d.ts +110 -0
  94. package/types/transport-error.d.ts +10 -0
  95. package/utf8.cjs +37 -0
  96. package/validation.cjs +327 -0
  97. package/vite-release-artifacts-config.cjs +120 -0
  98. package/vite-release-artifacts.cjs +199 -99
  99. package/vite-release-artifacts.d.cts +65 -40
  100. package/vite-release-artifacts.d.ts +65 -40
  101. package/vite-release-artifacts.js +2 -2
  102. package/winston-info.cjs +205 -0
  103. package/winston.cjs +189 -290
package/index.js CHANGED
@@ -36,4 +36,4 @@ export const {
36
36
  TransportError
37
37
  } = sdk;
38
38
 
39
- export default sdk;
39
+ export { default } from "./index.cjs";
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ const { SdkError } = require("./sdk-error.cjs");
4
+ const { boundedText, optionalText, requireMachineName } = require("./issue-text.cjs");
5
+ const { optionalEntry, rejectUnknownKeys, requireObject, requireTimestamp } = require("./validation.cjs");
6
+
7
+ /**
8
+ * @import { IssueBreadcrumb, IssueBreadcrumbDataValue, IssueBreadcrumbLevel } from "./index.cjs"
9
+ */
10
+
11
+ const MAX_ISSUE_BREADCRUMBS = 64;
12
+ const MIN_ISSUE_BREADCRUMBS = 1;
13
+ const MAX_BREADCRUMB_MESSAGE_LENGTH = 512;
14
+ const MAX_BREADCRUMB_DATA_FIELDS = 8;
15
+ const MAX_BREADCRUMB_DATA_STRING_LENGTH = 256;
16
+ const DATA_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u;
17
+ const BREADCRUMB_KEYS = new Set(["timestamp", "type", "category", "level", "message", "data"]);
18
+ /** @type {ReadonlyMap<string, IssueBreadcrumbLevel>} */
19
+ const BREADCRUMB_LEVEL_ALIASES = new Map([
20
+ ["trace", "debug"],
21
+ ["debug", "debug"],
22
+ ["info", "info"],
23
+ ["log", "info"],
24
+ ["warn", "warning"],
25
+ ["warning", "warning"],
26
+ ["error", "error"],
27
+ ["fatal", "critical"],
28
+ ["critical", "critical"]
29
+ ]);
30
+
31
+ /**
32
+ * @param {unknown} value
33
+ * @returns {IssueBreadcrumbLevel | undefined}
34
+ */
35
+ function optionalBreadcrumbLevel(value) {
36
+ if (value === undefined) {
37
+ return undefined;
38
+ }
39
+ const normalized = typeof value === "string" ? BREADCRUMB_LEVEL_ALIASES.get(value) : undefined;
40
+ if (normalized === undefined) {
41
+ throw new SdkError(
42
+ "validation_error",
43
+ `issue breadcrumb level must be one of: ${[...BREADCRUMB_LEVEL_ALIASES.keys()].join(", ")}`
44
+ );
45
+ }
46
+ return normalized;
47
+ }
48
+
49
+ /**
50
+ * @param {string} key
51
+ * @returns {string}
52
+ */
53
+ function requireDataKey(key) {
54
+ if (!DATA_KEY_PATTERN.test(key)) {
55
+ throw new SdkError("validation_error", `issue breadcrumb data key must match ${DATA_KEY_PATTERN}`);
56
+ }
57
+ return key;
58
+ }
59
+
60
+ /**
61
+ * @param {string} key
62
+ * @param {unknown} value
63
+ * @returns {IssueBreadcrumbDataValue}
64
+ */
65
+ function breadcrumbDataValue(key, value) {
66
+ if (typeof value === "string") {
67
+ return boundedText(`issue breadcrumb data value for ${key}`, value, MAX_BREADCRUMB_DATA_STRING_LENGTH);
68
+ }
69
+ if (typeof value === "number") {
70
+ if (!Number.isFinite(value)) {
71
+ throw new SdkError("validation_error", `issue breadcrumb data value for ${key} must be finite`);
72
+ }
73
+ return value;
74
+ }
75
+ if (typeof value === "boolean" || value === null) {
76
+ return value;
77
+ }
78
+ throw new SdkError(
79
+ "validation_error",
80
+ `issue breadcrumb data value for ${key} must be a string, number, boolean, or null`
81
+ );
82
+ }
83
+
84
+ /**
85
+ * @param {unknown} data
86
+ * @returns {Record<string, IssueBreadcrumbDataValue> | undefined}
87
+ */
88
+ function validateBreadcrumbData(data) {
89
+ if (data === undefined) {
90
+ return undefined;
91
+ }
92
+ /** @type {readonly (readonly [string, unknown])[]} */
93
+ const entries = Object.entries(requireObject("issue breadcrumb data", data));
94
+ if (entries.length > MAX_BREADCRUMB_DATA_FIELDS) {
95
+ throw new SdkError(
96
+ "validation_error",
97
+ `issue breadcrumb data must contain at most ${MAX_BREADCRUMB_DATA_FIELDS} fields`
98
+ );
99
+ }
100
+ return Object.fromEntries(entries.map(([key, value]) => [requireDataKey(key), breadcrumbDataValue(key, value)]));
101
+ }
102
+
103
+ /**
104
+ * @param {unknown} breadcrumb
105
+ * @param {unknown} [defaultTimestamp]
106
+ * @returns {IssueBreadcrumb}
107
+ */
108
+ function validateIssueBreadcrumb(breadcrumb, defaultTimestamp) {
109
+ const source = requireObject("issue breadcrumb", breadcrumb);
110
+ rejectUnknownKeys("issue breadcrumb", source, BREADCRUMB_KEYS);
111
+ const timestamp = requireTimestamp(source["timestamp"] ?? defaultTimestamp);
112
+ const category = requireMachineName("issue breadcrumb category", source["category"]);
113
+ const type = source["type"] === undefined ? undefined : requireMachineName("issue breadcrumb type", source["type"]);
114
+ const level = optionalBreadcrumbLevel(source["level"]);
115
+ const message = optionalText("issue breadcrumb message", source["message"], MAX_BREADCRUMB_MESSAGE_LENGTH);
116
+ const data = validateBreadcrumbData(source["data"]);
117
+ return {
118
+ timestamp,
119
+ ...optionalEntry("type", type),
120
+ category,
121
+ ...optionalEntry("level", level),
122
+ ...optionalEntry("message", message),
123
+ ...optionalEntry("data", data)
124
+ };
125
+ }
126
+
127
+ /**
128
+ * @param {unknown} breadcrumbs
129
+ * @returns {IssueBreadcrumb[] | undefined}
130
+ */
131
+ function validateIssueBreadcrumbs(breadcrumbs) {
132
+ if (breadcrumbs === undefined) {
133
+ return undefined;
134
+ }
135
+ if (!Array.isArray(breadcrumbs) || breadcrumbs.length < MIN_ISSUE_BREADCRUMBS || breadcrumbs.length > MAX_ISSUE_BREADCRUMBS) {
136
+ throw new SdkError("validation_error", `issue breadcrumbs must contain 1-${MAX_ISSUE_BREADCRUMBS} entries`);
137
+ }
138
+ /** @type {readonly unknown[]} */
139
+ const list = breadcrumbs;
140
+ return list.map((breadcrumb) => validateIssueBreadcrumb(breadcrumb));
141
+ }
142
+
143
+ module.exports = { MAX_ISSUE_BREADCRUMBS, validateIssueBreadcrumb, validateIssueBreadcrumbs };