@gusto/baerly-storage 0.3.0 → 0.4.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 (141) hide show
  1. package/README.md +157 -92
  2. package/dist/API.md +64 -32
  3. package/dist/CHANGELOG.md +295 -5
  4. package/dist/RECIPES.md +125 -0
  5. package/dist/THIRD-PARTY-LICENSES.txt +22 -96
  6. package/dist/{app-config-BIzyAKzy.d.ts → app-config-DyiFK3_k.d.ts} +43 -11
  7. package/dist/app-config.d.ts +1 -1
  8. package/dist/auth.d.ts +1 -1
  9. package/dist/auth.js +13 -13
  10. package/dist/auth.js.map +1 -1
  11. package/dist/aws4fetch.esm-p7eEzLCs.js +1702 -0
  12. package/dist/aws4fetch.esm-p7eEzLCs.js.map +1 -0
  13. package/dist/baerly.js +35 -15
  14. package/dist/baerly.js.map +1 -1
  15. package/dist/baerly.spec.json +342 -0
  16. package/dist/{client-BJXF3XJA.d.ts → client-Fe8CwB73.d.ts} +3 -3
  17. package/dist/client-react.d.ts +3 -3
  18. package/dist/client-react.js +4 -4
  19. package/dist/client-react.js.map +1 -1
  20. package/dist/client.d.ts +4 -4
  21. package/dist/client.js +3 -3
  22. package/dist/{cloudflare-Cn2ibODt.js → cloudflare-DzKBrUlg.js} +2 -2
  23. package/dist/{cloudflare-Cn2ibODt.js.map → cloudflare-DzKBrUlg.js.map} +1 -1
  24. package/dist/cloudflare.d.ts +49 -6
  25. package/dist/cloudflare.js +55 -21
  26. package/dist/cloudflare.js.map +1 -1
  27. package/dist/config-1tv0-Yzm.js +2693 -0
  28. package/dist/config-1tv0-Yzm.js.map +1 -0
  29. package/dist/constants-CfeMWQWk.js +222 -0
  30. package/dist/constants-CfeMWQWk.js.map +1 -0
  31. package/dist/{cost-BZ_MDBmn.js → cost-DSMIVqzL.js} +42 -43
  32. package/dist/cost-DSMIVqzL.js.map +1 -0
  33. package/dist/{current-json-DsN7FNY1.js → current-json-C6nhPOm1.js} +6 -204
  34. package/dist/current-json-C6nhPOm1.js.map +1 -0
  35. package/dist/{db-CCT6tDfY.d.ts → db-DsPkOVEH.d.ts} +3 -3
  36. package/dist/{deploy-BKKyGlSJ.js → deploy-DonTr-CV.js} +4 -4
  37. package/dist/{deploy-BKKyGlSJ.js.map → deploy-DonTr-CV.js.map} +1 -1
  38. package/dist/dev-vite.d.ts +9 -5
  39. package/dist/dev-vite.js +5 -4
  40. package/dist/dev-vite.js.map +1 -1
  41. package/dist/dev.d.ts +1 -1
  42. package/dist/dev.js +1 -1
  43. package/dist/{doctor-BVU4GNXN.js → doctor-DSIyCDg_.js} +5 -8
  44. package/dist/{doctor-BVU4GNXN.js.map → doctor-DSIyCDg_.js.map} +1 -1
  45. package/dist/{dump-DPEAKub6.js → dump-Bh5k26VQ.js} +9 -32
  46. package/dist/dump-Bh5k26VQ.js.map +1 -0
  47. package/dist/{errors-DOdL95kK.js → errors-Dfa3p78c.js} +25 -5
  48. package/dist/errors-Dfa3p78c.js.map +1 -0
  49. package/dist/{export-BcuCLFFe.js → export-DtF5tDIM.js} +9 -32
  50. package/dist/{export-BcuCLFFe.js.map → export-DtF5tDIM.js.map} +1 -1
  51. package/dist/{fsck-RXgLOaJG.js → fsck-D_djMO5D.js} +10 -33
  52. package/dist/fsck-D_djMO5D.js.map +1 -0
  53. package/dist/{http-Bd4byR4n.js → http-DxM9MflO.js} +123 -35
  54. package/dist/http-DxM9MflO.js.map +1 -0
  55. package/dist/http.d.ts +42 -26
  56. package/dist/http.js +3 -2
  57. package/dist/{index-DnBGSeuU.d.ts → index-0rZcMBwy.d.ts} +2 -2
  58. package/dist/{index-Cmsxx-ZN.d.ts → index-B6oexfOB.d.ts} +7 -7
  59. package/dist/{index-BDceQQi-.d.ts → index-BNRh23K9.d.ts} +4 -4
  60. package/dist/{index-DW7GT6M2.d.ts → index-BYk9oCNf.d.ts} +193 -163
  61. package/dist/index.d.ts +6 -6
  62. package/dist/index.js +4 -4
  63. package/dist/{indexes-Cx7uMXm0.d.ts → indexes-Dn9hbGQG.d.ts} +2 -2
  64. package/dist/{inspect-DhI49PSi.js → inspect-6WZ-pC7-.js} +10 -33
  65. package/dist/inspect-6WZ-pC7-.js.map +1 -0
  66. package/dist/key-Di6yyxFu.js +35 -0
  67. package/dist/key-Di6yyxFu.js.map +1 -0
  68. package/dist/{log-tail-DXeDkWEp.js → log-tail-D98U1JBo.js} +31 -7
  69. package/dist/log-tail-D98U1JBo.js.map +1 -0
  70. package/dist/{maintenance-CWBQpZ2y.js → maintenance-B4Dki6Ig.js} +77 -22
  71. package/dist/maintenance-B4Dki6Ig.js.map +1 -0
  72. package/dist/{maintenance-BkhUr72A.d.ts → maintenance-B_e0T99L.d.ts} +28 -5
  73. package/dist/{maintenance-C_KSkVjd.js → maintenance-C7coQp4c.js} +17 -16
  74. package/dist/maintenance-C7coQp4c.js.map +1 -0
  75. package/dist/maintenance.d.ts +3 -3
  76. package/dist/maintenance.js +3 -3
  77. package/dist/node.d.ts +168 -65
  78. package/dist/node.js +3 -2
  79. package/dist/{normalize-XWY25_sG.js → normalize-rjnZLwS4.js} +2 -2
  80. package/dist/normalize-rjnZLwS4.js.map +1 -0
  81. package/dist/{observability-BYd-RzEx.js → observability-wzs3-BL_.js} +233 -71
  82. package/dist/observability-wzs3-BL_.js.map +1 -0
  83. package/dist/observability.d.ts +2 -2
  84. package/dist/observability.js +1 -1
  85. package/dist/{plan-DIu_B6fy.js → plan-a7PJHBCy.js} +2 -2
  86. package/dist/{plan-DIu_B6fy.js.map → plan-a7PJHBCy.js.map} +1 -1
  87. package/dist/{query-sQNO5vU_.js → query-rAtXNQQB.js} +96 -207
  88. package/dist/query-rAtXNQQB.js.map +1 -0
  89. package/dist/{rebuild-index-DP4CqSSs.js → rebuild-index-BVzQSZlm.js} +9 -32
  90. package/dist/rebuild-index-BVzQSZlm.js.map +1 -0
  91. package/dist/{request-BEF_OvMh.js → request-u0M51mhJ.js} +3 -3
  92. package/dist/{request-BEF_OvMh.js.map → request-u0M51mhJ.js.map} +1 -1
  93. package/dist/{restore-DpQYef6r.js → restore-R-4rbciV.js} +73 -100
  94. package/dist/restore-R-4rbciV.js.map +1 -0
  95. package/dist/runtime-spec-qL3_lTTU.js +391 -0
  96. package/dist/runtime-spec-qL3_lTTU.js.map +1 -0
  97. package/dist/s3-http-B-z8th6O.d.ts +60 -0
  98. package/dist/s3.d.ts +47 -0
  99. package/dist/s3.js +45 -0
  100. package/dist/s3.js.map +1 -0
  101. package/dist/{shared-secret-BJdSwpgw.js → shared-secret-DgEicd3x.js} +13 -5
  102. package/dist/shared-secret-DgEicd3x.js.map +1 -0
  103. package/dist/src-BG20LZs7.js +2271 -0
  104. package/dist/src-BG20LZs7.js.map +1 -0
  105. package/dist/{src-Db4-qVtM.js → src-CYHFDrKz.js} +51 -8
  106. package/dist/src-CYHFDrKz.js.map +1 -0
  107. package/dist/{src-CWpkSbvJ.js → src-DYZ4H1aF.js} +6 -5
  108. package/dist/src-DYZ4H1aF.js.map +1 -0
  109. package/dist/{subcommand-CP9NY2J4.js → subcommand-DoDA-K7d.js} +44 -6
  110. package/dist/subcommand-DoDA-K7d.js.map +1 -0
  111. package/dist/time-DUqvFMHq.js +119 -0
  112. package/dist/time-DUqvFMHq.js.map +1 -0
  113. package/dist/{usage-CTfDq9HR.js → usage-DBV1eQHC.js} +7 -22
  114. package/dist/usage-DBV1eQHC.js.map +1 -0
  115. package/dist/wire-izfGZDvr.js.map +1 -1
  116. package/package.json +52 -28
  117. package/dist/config-CGyBopy3.js +0 -5326
  118. package/dist/config-CGyBopy3.js.map +0 -1
  119. package/dist/cost-BZ_MDBmn.js.map +0 -1
  120. package/dist/current-json-DsN7FNY1.js.map +0 -1
  121. package/dist/dump-DPEAKub6.js.map +0 -1
  122. package/dist/errors-DOdL95kK.js.map +0 -1
  123. package/dist/fsck-RXgLOaJG.js.map +0 -1
  124. package/dist/http-Bd4byR4n.js.map +0 -1
  125. package/dist/inspect-DhI49PSi.js.map +0 -1
  126. package/dist/log-tail-DXeDkWEp.js.map +0 -1
  127. package/dist/maintenance-CWBQpZ2y.js.map +0 -1
  128. package/dist/maintenance-C_KSkVjd.js.map +0 -1
  129. package/dist/normalize-XWY25_sG.js.map +0 -1
  130. package/dist/observability-BYd-RzEx.js.map +0 -1
  131. package/dist/query-sQNO5vU_.js.map +0 -1
  132. package/dist/rebuild-index-DP4CqSSs.js.map +0 -1
  133. package/dist/restore-DpQYef6r.js.map +0 -1
  134. package/dist/shared-secret-BJdSwpgw.js.map +0 -1
  135. package/dist/src-CWpkSbvJ.js.map +0 -1
  136. package/dist/src-D24wDpzR.js +0 -6247
  137. package/dist/src-D24wDpzR.js.map +0 -1
  138. package/dist/src-Db4-qVtM.js.map +0 -1
  139. package/dist/subcommand-CP9NY2J4.js.map +0 -1
  140. package/dist/usage-CTfDq9HR.js.map +0 -1
  141. /package/dist/{chunk-EAsCxrDo.js → rolldown-runtime-EAsCxrDo.js} +0 -0
@@ -1,19 +1,38 @@
1
- import { n as __exportAll } from "./chunk-EAsCxrDo.js";
2
- import { t as BaerlyError } from "./errors-DOdL95kK.js";
1
+ import { n as __exportAll } from "./rolldown-runtime-EAsCxrDo.js";
2
+ import { n as isRetriableCode, t as BaerlyError } from "./errors-Dfa3p78c.js";
3
3
  import { i as noopMetricsRecorder, n as getCurrentContext, r as runWithContext, t as createObservabilityContext } from "./context-DRZ3tZ5l.js";
4
+ //#region packages/protocol/src/code-resolution.ts
5
+ /** Canonical per-code corrective action; `errorEnvelope` falls back to this and it crosses the wire as `resolution`. Actionable codes only — context-sensitive codes use throw-site overrides. */
6
+ const CODE_RESOLUTIONS = {
7
+ PayloadTooLarge: "Reduce the request body below the server's body-size cap (1 MiB default).",
8
+ Unauthorized: "Send a valid Authorization header for the server's configured auth method.",
9
+ AccessDenied: "These credentials are denied for this tenant prefix or bucket policy.",
10
+ NotFound: "No row matches this id; create it first or treat this as a miss."
11
+ };
12
+ /** Resolution for a malformed `?where=` / `?order=` query value. */
13
+ const WHERE_ORDER_JSON_RESOLUTION = "Pass a URL-encoded JSON object as the ?where= / ?order= value.";
14
+ /** Resolution for an empty / malformed / unwrapped write body. */
15
+ const WRITE_BODY_SHAPE_RESOLUTION = "Send a JSON body shaped { \"doc\": { ... } } for POST/PUT, or { \"patch\": { ... } } for PATCH.";
16
+ //#endregion
4
17
  //#region packages/server/src/contract.ts
5
18
  /**
6
19
  * Single drift surface for the {@link HttpErrorEnvelope} shape. The
7
20
  * router and both adapters call this — adding or renaming a field on
8
- * the wire is a one-edit change here.
21
+ * the wire is a one-edit change here. `retriable` is additive (always
22
+ * present, defaulted from `code`); older clients ignore it.
9
23
  */
10
- const errorEnvelope = (code, message, issues) => ({ error: {
11
- code,
12
- message,
13
- ...issues !== void 0 && issues.length > 0 ? { issues } : {}
14
- } });
24
+ const errorEnvelope = (code, message, issues, resolution, retriable) => {
25
+ const resolved = resolution ?? CODE_RESOLUTIONS[code];
26
+ return { error: {
27
+ code,
28
+ message,
29
+ retriable: retriable ?? isRetriableCode(code),
30
+ ...issues !== void 0 && issues.length > 0 ? { issues } : {},
31
+ ...resolved !== void 0 ? { resolution: resolved } : {}
32
+ } };
33
+ };
15
34
  //#endregion
16
- //#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/context.js
35
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/context.js
17
36
  /**
18
37
  * Internal symbol for storing category prefix in context.
19
38
  */
@@ -30,20 +49,25 @@ function getCategoryPrefix() {
30
49
  return Array.isArray(prefix) ? prefix : [];
31
50
  }
32
51
  /**
33
- * Gets the current implicit context from context local storage, excluding
34
- * internal symbol keys (like category prefix).
35
- * @returns The current implicit context without internal symbol keys.
36
- * @since 1.3.0
52
+ * Gets the current implicit context only when user-visible context keys exist.
53
+ *
54
+ * This is intentionally not exported from the public entry point. Hot logging
55
+ * paths use it to avoid allocating a fresh `{}` when no implicit context is
56
+ * active, while `getImplicitContext()` keeps its public return contract.
57
+ * @returns The current implicit context without internal symbol keys, or
58
+ * `undefined` if there is no user-visible implicit context.
37
59
  */
38
- function getImplicitContext() {
60
+ function getImplicitContextIfAny() {
39
61
  const store = LoggerImpl.getLogger().contextLocalStorage?.getStore();
40
- if (store == null) return {};
62
+ if (store == null) return void 0;
63
+ const keys = Object.keys(store);
64
+ if (keys.length < 1) return void 0;
41
65
  const result = {};
42
- for (const key of Object.keys(store)) result[key] = store[key];
66
+ for (const key of keys) result[key] = store[key];
43
67
  return result;
44
68
  }
45
69
  //#endregion
46
- //#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/level.js
70
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/level.js
47
71
  const logLevels = [
48
72
  "trace",
49
73
  "debug",
@@ -68,12 +92,15 @@ function compareLogLevel(a, b) {
68
92
  return aIndex - bIndex;
69
93
  }
70
94
  //#endregion
71
- //#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/logger.js
95
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/logger.js
72
96
  /**
73
97
  * Symbol to identify lazy values.
74
98
  */
75
99
  const lazySymbol = Symbol.for("logtape.lazy");
76
100
  const throttlingSummaryRecordSymbol = Symbol.for("LogTape.throttlingSummaryRecord");
101
+ const immediateSinkSymbol = Symbol.for("LogTape.sinkSnapshotPolicy.immediate");
102
+ const internalStringLogRecords = /* @__PURE__ */ new WeakSet();
103
+ const resolvedStringLogRecords = /* @__PURE__ */ new WeakSet();
77
104
  /**
78
105
  * Checks if a value is a lazy value.
79
106
  *
@@ -122,7 +149,18 @@ function logStringMessage(logger, level, message, props) {
122
149
  logger.log(level, message, result);
123
150
  }
124
151
  function snapshotLogRecordProperties(record) {
152
+ if (resolvedStringLogRecords.has(record)) return record;
125
153
  const properties = resolveProperties(record.properties);
154
+ if (internalStringLogRecords.has(record)) return {
155
+ category: record.category,
156
+ level: record.level,
157
+ get message() {
158
+ return record.message;
159
+ },
160
+ rawMessage: record.rawMessage,
161
+ timestamp: record.timestamp,
162
+ properties
163
+ };
126
164
  const descriptors = Object.getOwnPropertyDescriptors(record);
127
165
  descriptors.properties = {
128
166
  value: properties,
@@ -131,6 +169,13 @@ function snapshotLogRecordProperties(record) {
131
169
  };
132
170
  return Object.defineProperties({}, descriptors);
133
171
  }
172
+ function hasEnumerableProperties(properties) {
173
+ if (properties == null || typeof properties !== "object") return false;
174
+ return Object.keys(properties).length > 0 || Object.prototype.propertyIsEnumerable.call(properties, throttlingSummaryRecordSymbol);
175
+ }
176
+ function shouldSnapshotForSink(sink) {
177
+ return sink[immediateSinkSymbol] !== true;
178
+ }
134
179
  /**
135
180
  * Get a logger with the given category.
136
181
  *
@@ -151,7 +196,7 @@ function getLogger$1(category = []) {
151
196
  */
152
197
  const globalRootLoggerSymbol = Symbol.for("logtape.rootLogger");
153
198
  function isMetaLoggerCategory(category) {
154
- return category.length === 2 && category[0] === "logtape" && category[1] === "meta";
199
+ return category.length >= 2 && category[0] === "logtape" && category[1] === "meta";
155
200
  }
156
201
  /**
157
202
  * A logger implementation. Do not use this directly; use {@link getLogger}
@@ -162,10 +207,11 @@ var LoggerImpl = class LoggerImpl {
162
207
  children;
163
208
  category;
164
209
  sinks;
165
- parentSinks = "inherit";
166
210
  filters;
167
- lowestLevel = "trace";
168
211
  contextLocalStorage;
212
+ #parentSinks = "inherit";
213
+ #lowestLevel = "trace";
214
+ #sinkPlanCache = {};
169
215
  static getLogger(category = []) {
170
216
  let rootLogger = globalRootLoggerSymbol in globalThis ? globalThis[globalRootLoggerSymbol] ?? null : null;
171
217
  if (rootLogger == null) {
@@ -193,6 +239,20 @@ var LoggerImpl = class LoggerImpl {
193
239
  this.sinks = [];
194
240
  this.filters = [];
195
241
  }
242
+ get parentSinks() {
243
+ return this.#parentSinks;
244
+ }
245
+ set parentSinks(value) {
246
+ if (this.#parentSinks === value) return;
247
+ this.#parentSinks = value;
248
+ }
249
+ get lowestLevel() {
250
+ return this.#lowestLevel;
251
+ }
252
+ set lowestLevel(value) {
253
+ if (this.#lowestLevel === value) return;
254
+ this.#lowestLevel = value;
255
+ }
196
256
  getChild(subcategory) {
197
257
  const name = typeof subcategory === "string" ? subcategory : subcategory[0];
198
258
  const childRef = this.children[name];
@@ -233,23 +293,88 @@ var LoggerImpl = class LoggerImpl {
233
293
  return true;
234
294
  }
235
295
  *getSinks(level) {
236
- if (this.lowestLevel === null || compareLogLevel(level, this.lowestLevel) < 0) return;
237
- if (this.parent != null && this.parentSinks === "inherit") for (const sink of this.parent.getSinks(level)) yield sink;
238
- for (const sink of this.sinks) yield sink;
296
+ const plan = this.getSinkDispatchPlan(level);
297
+ switch (plan.kind) {
298
+ case "none": return;
299
+ case "one":
300
+ yield plan.sink;
301
+ return;
302
+ case "many":
303
+ yield* plan.sinks;
304
+ return;
305
+ }
306
+ }
307
+ getSinkDispatchPlan(level) {
308
+ const cached = this.#sinkPlanCache[level];
309
+ if (cached != null && this.isSinkDispatchPlanFresh(level, cached)) return cached;
310
+ const parentPlan = this.parent != null && this.parentSinks === "inherit" ? this.parent.getSinkDispatchPlan(level) : void 0;
311
+ const plan = this.createSinkDispatchPlan(level, parentPlan);
312
+ this.#sinkPlanCache[level] = plan;
313
+ return plan;
314
+ }
315
+ isSinkDispatchPlanFresh(level, plan) {
316
+ if (plan.lowestLevel !== this.lowestLevel || plan.parentSinks !== this.parentSinks || plan.localSinks.length !== this.sinks.length) return false;
317
+ for (let i = 0; i < plan.localSinks.length; i++) if (plan.localSinks[i] !== this.sinks[i]) return false;
318
+ const parentPlan = this.parent != null && this.parentSinks === "inherit" ? this.parent.getSinkDispatchPlan(level) : void 0;
319
+ return plan.parentPlan === parentPlan;
320
+ }
321
+ createSinkDispatchPlan(level, parentPlan) {
322
+ const state = {
323
+ localSinks: [...this.sinks],
324
+ parentSinks: this.parentSinks,
325
+ lowestLevel: this.lowestLevel,
326
+ parentPlan
327
+ };
328
+ if (state.lowestLevel === null) return {
329
+ ...state,
330
+ kind: "none"
331
+ };
332
+ if (compareLogLevel(level, state.lowestLevel) < 0) return {
333
+ ...state,
334
+ kind: "none"
335
+ };
336
+ let firstSink;
337
+ let sinks;
338
+ const appendSink = (sink) => {
339
+ if (sinks != null) sinks.push(sink);
340
+ else if (firstSink == null) firstSink = sink;
341
+ else sinks = [firstSink, sink];
342
+ };
343
+ if (parentPlan != null) {
344
+ if (parentPlan.kind === "one") firstSink = parentPlan.sink;
345
+ else if (parentPlan.kind === "many") sinks = [...parentPlan.sinks];
346
+ }
347
+ for (const sink of state.localSinks) appendSink(sink);
348
+ if (sinks != null) return {
349
+ ...state,
350
+ kind: "many",
351
+ sinks
352
+ };
353
+ if (firstSink != null) return {
354
+ ...state,
355
+ kind: "one",
356
+ sink: firstSink
357
+ };
358
+ return {
359
+ ...state,
360
+ kind: "none"
361
+ };
239
362
  }
240
363
  isEnabledFor(level) {
241
364
  const categoryPrefix = isMetaLoggerCategory(this.category) ? [] : getCategoryPrefix();
242
365
  return (categoryPrefix.length > 0 ? LoggerImpl.getNearestExistingLogger([...categoryPrefix, ...this.category]) : this).isEnabledForResolved(level);
243
366
  }
244
367
  isEnabledForResolved(level) {
245
- if (this.lowestLevel === null || compareLogLevel(level, this.lowestLevel) < 0) return false;
246
- for (const _ of this.getSinks(level)) return true;
247
- return false;
368
+ return this.getSinkDispatchPlan(level).kind !== "none";
248
369
  }
249
370
  emit(record, bypassSinks) {
250
371
  const baseCategory = "category" in record ? record.category : this.category;
251
372
  const categoryPrefix = isMetaLoggerCategory(baseCategory) ? [] : getCategoryPrefix();
252
373
  const fullCategory = categoryPrefix.length > 0 ? [...categoryPrefix, ...baseCategory] : baseCategory;
374
+ if (categoryPrefix.length < 1 && Object.prototype.hasOwnProperty.call(record, "category")) {
375
+ this.emitResolved(record, bypassSinks);
376
+ return;
377
+ }
253
378
  const descriptors = Object.getOwnPropertyDescriptors(record);
254
379
  descriptors.category = {
255
380
  value: fullCategory,
@@ -261,14 +386,36 @@ var LoggerImpl = class LoggerImpl {
261
386
  }
262
387
  emitResolved(record, bypassSinks) {
263
388
  if (this.lowestLevel === null || compareLogLevel(record.level, this.lowestLevel) < 0 || !this.filter(record)) return;
264
- const sinks = [...this.getSinks(record.level)];
265
- if (sinks.length < 1) return;
389
+ const plan = this.getSinkDispatchPlan(record.level);
390
+ if (plan.kind === "none") return;
266
391
  let snapshot;
267
392
  let snapshotFailed = false;
268
- for (const sink of sinks) {
393
+ if (plan.kind === "one") {
394
+ const sink = plan.sink;
395
+ if (bypassSinks?.has(sink)) return;
396
+ try {
397
+ if (shouldSnapshotForSink(sink)) try {
398
+ snapshot = snapshotLogRecordProperties(record);
399
+ } catch {
400
+ snapshotFailed = true;
401
+ snapshot = record;
402
+ }
403
+ sink(snapshot ?? record);
404
+ } catch (error) {
405
+ const bypassSinks2 = new Set(bypassSinks);
406
+ bypassSinks2.add(sink);
407
+ metaLogger.log("fatal", "Failed to emit a log record to sink {sink}: {error}", {
408
+ sink,
409
+ error,
410
+ record
411
+ }, bypassSinks2);
412
+ }
413
+ return;
414
+ }
415
+ for (const sink of plan.sinks) {
269
416
  if (bypassSinks?.has(sink)) continue;
270
417
  try {
271
- if (snapshot == null && !snapshotFailed) try {
418
+ if (snapshot == null && !snapshotFailed && shouldSnapshotForSink(sink)) try {
272
419
  snapshot = snapshotLogRecordProperties(record);
273
420
  } catch {
274
421
  snapshotFailed = true;
@@ -287,7 +434,20 @@ var LoggerImpl = class LoggerImpl {
287
434
  }
288
435
  }
289
436
  log(level, rawMessage, properties, bypassSinks) {
290
- const implicitContext = getImplicitContext();
437
+ const implicitContext = getImplicitContextIfAny();
438
+ if (typeof properties !== "function" && implicitContext == null && !rawMessage.includes("{") && !hasEnumerableProperties(properties)) {
439
+ const record$1 = {
440
+ category: this.category,
441
+ level,
442
+ message: [rawMessage],
443
+ rawMessage,
444
+ timestamp: Date.now(),
445
+ properties: {}
446
+ };
447
+ resolvedStringLogRecords.add(record$1);
448
+ this.emit(record$1, bypassSinks);
449
+ return;
450
+ }
291
451
  let cachedProps = void 0;
292
452
  let cachedMessage = void 0;
293
453
  const record = typeof properties === "function" ? {
@@ -301,7 +461,7 @@ var LoggerImpl = class LoggerImpl {
301
461
  rawMessage,
302
462
  get properties() {
303
463
  if (cachedProps == null) cachedProps = resolveProperties({
304
- ...implicitContext,
464
+ ...implicitContext ?? {},
305
465
  ...properties()
306
466
  });
307
467
  return cachedProps;
@@ -317,16 +477,17 @@ var LoggerImpl = class LoggerImpl {
317
477
  rawMessage,
318
478
  get properties() {
319
479
  if (cachedProps == null) cachedProps = resolveProperties({
320
- ...implicitContext,
480
+ ...implicitContext ?? {},
321
481
  ...properties
322
482
  });
323
483
  return cachedProps;
324
484
  }
325
485
  };
486
+ internalStringLogRecords.add(record);
326
487
  this.emit(record, bypassSinks);
327
488
  }
328
489
  logLazily(level, callback, properties = {}) {
329
- const implicitContext = getImplicitContext();
490
+ const implicitContext = getImplicitContextIfAny();
330
491
  let rawMessage = void 0;
331
492
  let msg = void 0;
332
493
  function realizeMessage() {
@@ -350,13 +511,13 @@ var LoggerImpl = class LoggerImpl {
350
511
  },
351
512
  timestamp: Date.now(),
352
513
  properties: {
353
- ...implicitContext,
514
+ ...implicitContext ?? {},
354
515
  ...properties
355
516
  }
356
517
  });
357
518
  }
358
519
  logTemplate(level, messageTemplate, values, properties = {}) {
359
- const implicitContext = getImplicitContext();
520
+ const implicitContext = getImplicitContextIfAny();
360
521
  this.emit({
361
522
  category: this.category,
362
523
  level,
@@ -364,7 +525,7 @@ var LoggerImpl = class LoggerImpl {
364
525
  rawMessage: messageTemplate,
365
526
  timestamp: Date.now(),
366
527
  properties: {
367
- ...implicitContext,
528
+ ...implicitContext ?? {},
368
529
  ...properties
369
530
  }
370
531
  });
@@ -844,7 +1005,7 @@ function renderMessage(template, values) {
844
1005
  return args;
845
1006
  }
846
1007
  //#endregion
847
- //#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/filter.js
1008
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/filter.js
848
1009
  /**
849
1010
  * Converts a {@link FilterLike} value to an actual {@link Filter}.
850
1011
  *
@@ -873,14 +1034,14 @@ function getLevelFilter(level) {
873
1034
  throw new TypeError(`Invalid log level: ${level}.`);
874
1035
  }
875
1036
  //#endregion
876
- //#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/util.js
1037
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/util.js
877
1038
  var util_exports = /* @__PURE__ */ __exportAll({ inspect: () => inspect$1 });
878
1039
  function inspect$1(obj, options) {
879
1040
  const indent = options?.compact === true ? void 0 : 2;
880
1041
  return JSON.stringify(obj, null, indent);
881
1042
  }
882
1043
  //#endregion
883
- //#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/formatter.js
1044
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/formatter.js
884
1045
  /**
885
1046
  * The severity level abbreviations.
886
1047
  */
@@ -1124,6 +1285,31 @@ function jsonReplacer(_key, value) {
1124
1285
  for (const key of Object.keys(value)) if (!(key in serialized)) serialized[key] = value[key];
1125
1286
  return serialized;
1126
1287
  }
1288
+ function renderDefaultJsonLinesMessage(message) {
1289
+ const messageLength = message.length;
1290
+ if (messageLength === 1) return message[0];
1291
+ if (messageLength === 3) return message[0] + JSON.stringify(message[1]) + message[2];
1292
+ let rendered = message[0];
1293
+ for (let i = 1; i < messageLength; i++) rendered += i & 1 ? JSON.stringify(message[i]) : message[i];
1294
+ return rendered;
1295
+ }
1296
+ function stringifyJsonLinesField(key, value) {
1297
+ if (value != null && (typeof value === "object" || typeof value === "function" || typeof value === "bigint")) {
1298
+ const toJSON = value.toJSON;
1299
+ if (typeof toJSON === "function") value = toJSON.call(value, key);
1300
+ }
1301
+ return JSON.stringify(jsonReplacer(key, value), jsonReplacer);
1302
+ }
1303
+ function formatDefaultJsonLinesRecord(record, lineEnding) {
1304
+ const level = record.level === "warning" ? "WARN" : record.level.toUpperCase();
1305
+ const messageJson = stringifyJsonLinesField("message", renderDefaultJsonLinesMessage(record.message));
1306
+ const propertiesJson = stringifyJsonLinesField("properties", record.properties);
1307
+ let line = `{"@timestamp":${JSON.stringify(new Date(record.timestamp).toISOString())},"level":${JSON.stringify(level)}`;
1308
+ if (messageJson !== void 0) line += `,"message":${messageJson}`;
1309
+ line += `,"logger":${JSON.stringify(record.category.join("."))}`;
1310
+ if (propertiesJson !== void 0) line += `,"properties":${propertiesJson}`;
1311
+ return `${line}}${lineEnding}`;
1312
+ }
1127
1313
  /**
1128
1314
  * Get a text formatter with the specified options. Although it's flexible
1129
1315
  * enough to create a custom formatter, if you want more control, you can
@@ -1260,31 +1446,7 @@ getAnsiColorFormatter();
1260
1446
  */
1261
1447
  function getJsonLinesFormatter(options = {}) {
1262
1448
  const lineEnding = getLineEndingValue(options.lineEnding);
1263
- if (!options.categorySeparator && !options.message && !options.properties) return (record) => {
1264
- if (record.message.length === 3) return JSON.stringify({
1265
- "@timestamp": new Date(record.timestamp).toISOString(),
1266
- level: record.level === "warning" ? "WARN" : record.level.toUpperCase(),
1267
- message: record.message[0] + JSON.stringify(record.message[1]) + record.message[2],
1268
- logger: record.category.join("."),
1269
- properties: record.properties
1270
- }, jsonReplacer) + lineEnding;
1271
- if (record.message.length === 1) return JSON.stringify({
1272
- "@timestamp": new Date(record.timestamp).toISOString(),
1273
- level: record.level === "warning" ? "WARN" : record.level.toUpperCase(),
1274
- message: record.message[0],
1275
- logger: record.category.join("."),
1276
- properties: record.properties
1277
- }, jsonReplacer) + lineEnding;
1278
- let msg = record.message[0];
1279
- for (let i = 1; i < record.message.length; i++) msg += i & 1 ? JSON.stringify(record.message[i]) : record.message[i];
1280
- return JSON.stringify({
1281
- "@timestamp": new Date(record.timestamp).toISOString(),
1282
- level: record.level === "warning" ? "WARN" : record.level.toUpperCase(),
1283
- message: msg,
1284
- logger: record.category.join("."),
1285
- properties: record.properties
1286
- }, jsonReplacer) + lineEnding;
1287
- };
1449
+ if (!options.categorySeparator && !options.message && !options.properties) return (record) => formatDefaultJsonLinesRecord(record, lineEnding);
1288
1450
  const isTemplateMessage = options.message === "template";
1289
1451
  const propertiesOption = options.properties ?? "nest:properties";
1290
1452
  let joinCategory;
@@ -1496,7 +1658,7 @@ function defaultConsoleFormatter(record) {
1496
1658
  ];
1497
1659
  }
1498
1660
  //#endregion
1499
- //#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/sink.js
1661
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/sink.js
1500
1662
  /**
1501
1663
  * A console sink factory that returns a sink that logs to the console.
1502
1664
  *
@@ -1580,7 +1742,7 @@ function getConsoleSink(options = {}) {
1580
1742
  return nonBlockingSink;
1581
1743
  }
1582
1744
  //#endregion
1583
- //#region node_modules/.pnpm/@logtape+logtape@2.1.3/node_modules/@logtape/logtape/dist/config.js
1745
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/config.js
1584
1746
  /**
1585
1747
  * The current configuration, if any. Otherwise, `null`.
1586
1748
  */
@@ -2219,7 +2381,7 @@ const serializeError = (err, includeStack = false) => {
2219
2381
  * pay the formatting cost in production where the level is
2220
2382
  * `info` or higher. (LogTape provides `isEnabledFor` since 2.0.0.)
2221
2383
  */
2222
- const CLASS_A_OPS = new Set([
2384
+ const CLASS_A_OPS = /* @__PURE__ */ new Set([
2223
2385
  "put",
2224
2386
  "delete",
2225
2387
  "list"
@@ -2336,6 +2498,6 @@ const observableStorage = (inner) => {
2336
2498
  };
2337
2499
  };
2338
2500
  //#endregion
2339
- export { withHttpObservability as a, configureObservability as c, serializeError as i, getLogger as l, flushCanonicalLine as n, deriveOutcome as o, flushUnauthorizedAndRespond as r, CATEGORY as s, observableStorage as t, errorEnvelope as u };
2501
+ export { withHttpObservability as a, configureObservability as c, WHERE_ORDER_JSON_RESOLUTION as d, WRITE_BODY_SHAPE_RESOLUTION as f, serializeError as i, getLogger as l, flushCanonicalLine as n, deriveOutcome as o, flushUnauthorizedAndRespond as r, CATEGORY as s, observableStorage as t, errorEnvelope as u };
2340
2502
 
2341
- //# sourceMappingURL=observability-BYd-RzEx.js.map
2503
+ //# sourceMappingURL=observability-wzs3-BL_.js.map