@gusto/baerly-storage 0.4.1 → 0.6.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 (104) hide show
  1. package/dist/API.md +3 -2
  2. package/dist/CHANGELOG.md +125 -0
  3. package/dist/THIRD-PARTY-LICENSES.txt +1 -1
  4. package/dist/auth.d.ts +1 -1
  5. package/dist/aws4fetch.esm-CXE5ZbAa.js +460 -0
  6. package/dist/aws4fetch.esm-CXE5ZbAa.js.map +1 -0
  7. package/dist/baerly.js +10 -10
  8. package/dist/baerly.spec.json +1 -1
  9. package/dist/client-react.d.ts +2 -2
  10. package/dist/{client-Fe8CwB73.d.ts → client-ypCm3zjt.d.ts} +2 -2
  11. package/dist/client.d.ts +2 -2
  12. package/dist/{cloudflare-DzKBrUlg.js → cloudflare-wrVYf4bb.js} +457 -56
  13. package/dist/cloudflare-wrVYf4bb.js.map +1 -0
  14. package/dist/cloudflare.d.ts +13 -10
  15. package/dist/cloudflare.js +6 -6
  16. package/dist/cloudflare.js.map +1 -1
  17. package/dist/{config-1tv0-Yzm.js → config-B6nTy8e2.js} +435 -33
  18. package/dist/config-B6nTy8e2.js.map +1 -0
  19. package/dist/constants-CfeMWQWk.js.map +1 -1
  20. package/dist/{cost-DSMIVqzL.js → cost-_SE_SVgZ.js} +4 -4
  21. package/dist/{cost-DSMIVqzL.js.map → cost-_SE_SVgZ.js.map} +1 -1
  22. package/dist/{db-DsPkOVEH.d.ts → db-DjjthkTi.d.ts} +2 -2
  23. package/dist/{deploy-DonTr-CV.js → deploy-Di_Q01qx.js} +5 -5
  24. package/dist/deploy-Di_Q01qx.js.map +1 -0
  25. package/dist/dev-vite.d.ts +31 -27
  26. package/dist/dev-vite.js +60 -30
  27. package/dist/dev-vite.js.map +1 -1
  28. package/dist/dev.d.ts +1 -1
  29. package/dist/doctor-RWVRpvat.js +102 -0
  30. package/dist/doctor-RWVRpvat.js.map +1 -0
  31. package/dist/{dump-Bh5k26VQ.js → dump-m2vEYDNY.js} +4 -4
  32. package/dist/{dump-Bh5k26VQ.js.map → dump-m2vEYDNY.js.map} +1 -1
  33. package/dist/{export-DtF5tDIM.js → export-DenKwEQu.js} +4 -4
  34. package/dist/{export-DtF5tDIM.js.map → export-DenKwEQu.js.map} +1 -1
  35. package/dist/{fsck-D_djMO5D.js → fsck-2Vq-7-e2.js} +5 -5
  36. package/dist/{fsck-D_djMO5D.js.map → fsck-2Vq-7-e2.js.map} +1 -1
  37. package/dist/gcs-admin-Bx6xSNJj.d.ts +123 -0
  38. package/dist/gcs.d.ts +18 -0
  39. package/dist/gcs.js +2 -0
  40. package/dist/goog4-signer-Z7KnJ1su.js +321 -0
  41. package/dist/goog4-signer-Z7KnJ1su.js.map +1 -0
  42. package/dist/{http-DxM9MflO.js → http-7zT29K3P.js} +4 -4
  43. package/dist/{http-DxM9MflO.js.map → http-7zT29K3P.js.map} +1 -1
  44. package/dist/{aws4fetch.esm-p7eEzLCs.js → http-transport-BTgVCY5r.js} +24 -476
  45. package/dist/http-transport-BTgVCY5r.js.map +1 -0
  46. package/dist/http.d.ts +2 -2
  47. package/dist/http.js +2 -2
  48. package/dist/{index-BNRh23K9.d.ts → index-BHz92Acj.d.ts} +2 -2
  49. package/dist/{index-BYk9oCNf.d.ts → index-CEZKQsKt.d.ts} +3 -2
  50. package/dist/{index-B6oexfOB.d.ts → index-DP3ClvcA.d.ts} +12 -10
  51. package/dist/{index-0rZcMBwy.d.ts → index-uE-w2dgj.d.ts} +2 -2
  52. package/dist/index.d.ts +3 -3
  53. package/dist/index.js +3 -3
  54. package/dist/{inspect-6WZ-pC7-.js → inspect-BpYbH1DM.js} +5 -5
  55. package/dist/{inspect-6WZ-pC7-.js.map → inspect-BpYbH1DM.js.map} +1 -1
  56. package/dist/{log-tail-D98U1JBo.js → log-tail-QWU4wlu-.js} +3 -11
  57. package/dist/log-tail-QWU4wlu-.js.map +1 -0
  58. package/dist/{maintenance-B_e0T99L.d.ts → maintenance-BGHGt2Yg.d.ts} +2 -2
  59. package/dist/{maintenance-B4Dki6Ig.js → maintenance-DULFcpd1.js} +4 -17
  60. package/dist/maintenance-DULFcpd1.js.map +1 -0
  61. package/dist/{maintenance-C7coQp4c.js → maintenance-fEi-UZ2o.js} +5 -11
  62. package/dist/maintenance-fEi-UZ2o.js.map +1 -0
  63. package/dist/maintenance.d.ts +1 -1
  64. package/dist/maintenance.js +1 -1
  65. package/dist/node.d.ts +22 -61
  66. package/dist/node.js +4 -3
  67. package/dist/{observability-wzs3-BL_.js → observability-Ch-VQJyE.js} +85 -27
  68. package/dist/{observability-wzs3-BL_.js.map → observability-Ch-VQJyE.js.map} +1 -1
  69. package/dist/observability.d.ts +2 -2
  70. package/dist/observability.js +1 -1
  71. package/dist/{plan-a7PJHBCy.js → plan-C4qgiXSg.js} +2 -2
  72. package/dist/{plan-a7PJHBCy.js.map → plan-C4qgiXSg.js.map} +1 -1
  73. package/dist/{query-rAtXNQQB.js → query-C43r-6ib.js} +2 -2
  74. package/dist/{query-rAtXNQQB.js.map → query-C43r-6ib.js.map} +1 -1
  75. package/dist/{rebuild-index-BVzQSZlm.js → rebuild-index-BH1dc1p6.js} +4 -4
  76. package/dist/{rebuild-index-BVzQSZlm.js.map → rebuild-index-BH1dc1p6.js.map} +1 -1
  77. package/dist/{restore-R-4rbciV.js → restore-D0VYWzfP.js} +5 -5
  78. package/dist/{restore-R-4rbciV.js.map → restore-D0VYWzfP.js.map} +1 -1
  79. package/dist/{runtime-spec-_GTdeSMo.js → runtime-spec--LykAdl1.js} +2 -2
  80. package/dist/{runtime-spec-_GTdeSMo.js.map → runtime-spec--LykAdl1.js.map} +1 -1
  81. package/dist/{s3-http-B-z8th6O.d.ts → s3-http-DD5gDc7t.d.ts} +6 -4
  82. package/dist/s3.d.ts +1 -1
  83. package/dist/s3.js +1 -1
  84. package/dist/sha256-CqcKTjw9.js +22 -0
  85. package/dist/sha256-CqcKTjw9.js.map +1 -0
  86. package/dist/{src-D__mHQmQ.js → src-BMFfDUI2.js} +69 -29
  87. package/dist/src-BMFfDUI2.js.map +1 -0
  88. package/dist/{src-CYHFDrKz.js → src-DvbTEya2.js} +3 -3
  89. package/dist/{src-CYHFDrKz.js.map → src-DvbTEya2.js.map} +1 -1
  90. package/dist/{subcommand-DoDA-K7d.js → subcommand-BV68pqwJ.js} +2 -2
  91. package/dist/{subcommand-DoDA-K7d.js.map → subcommand-BV68pqwJ.js.map} +1 -1
  92. package/dist/{usage-DBV1eQHC.js → usage-BMZR8o6U.js} +3 -3
  93. package/dist/{usage-DBV1eQHC.js.map → usage-BMZR8o6U.js.map} +1 -1
  94. package/package.json +12 -6
  95. package/dist/aws4fetch.esm-p7eEzLCs.js.map +0 -1
  96. package/dist/cloudflare-DzKBrUlg.js.map +0 -1
  97. package/dist/config-1tv0-Yzm.js.map +0 -1
  98. package/dist/deploy-DonTr-CV.js.map +0 -1
  99. package/dist/doctor-DSIyCDg_.js +0 -346
  100. package/dist/doctor-DSIyCDg_.js.map +0 -1
  101. package/dist/log-tail-D98U1JBo.js.map +0 -1
  102. package/dist/maintenance-B4Dki6Ig.js.map +0 -1
  103. package/dist/maintenance-C7coQp4c.js.map +0 -1
  104. package/dist/src-D__mHQmQ.js.map +0 -1
@@ -32,7 +32,7 @@ const errorEnvelope = (code, message, issues, resolution, retriable) => {
32
32
  } };
33
33
  };
34
34
  //#endregion
35
- //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/context.js
35
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/context.js
36
36
  /**
37
37
  * Internal symbol for storing category prefix in context.
38
38
  */
@@ -67,7 +67,7 @@ function getImplicitContextIfAny() {
67
67
  return result;
68
68
  }
69
69
  //#endregion
70
- //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/level.js
70
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/level.js
71
71
  const logLevels = [
72
72
  "trace",
73
73
  "debug",
@@ -92,7 +92,7 @@ function compareLogLevel(a, b) {
92
92
  return aIndex - bIndex;
93
93
  }
94
94
  //#endregion
95
- //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/logger.js
95
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/logger.js
96
96
  /**
97
97
  * Symbol to identify lazy values.
98
98
  */
@@ -1005,7 +1005,7 @@ function renderMessage(template, values) {
1005
1005
  return args;
1006
1006
  }
1007
1007
  //#endregion
1008
- //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/filter.js
1008
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/filter.js
1009
1009
  /**
1010
1010
  * Converts a {@link FilterLike} value to an actual {@link Filter}.
1011
1011
  *
@@ -1034,14 +1034,14 @@ function getLevelFilter(level) {
1034
1034
  throw new TypeError(`Invalid log level: ${level}.`);
1035
1035
  }
1036
1036
  //#endregion
1037
- //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/util.js
1037
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/util.js
1038
1038
  var util_exports = /* @__PURE__ */ __exportAll({ inspect: () => inspect$1 });
1039
1039
  function inspect$1(obj, options) {
1040
1040
  const indent = options?.compact === true ? void 0 : 2;
1041
1041
  return JSON.stringify(obj, null, indent);
1042
1042
  }
1043
1043
  //#endregion
1044
- //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/formatter.js
1044
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/formatter.js
1045
1045
  /**
1046
1046
  * The severity level abbreviations.
1047
1047
  */
@@ -1658,7 +1658,7 @@ function defaultConsoleFormatter(record) {
1658
1658
  ];
1659
1659
  }
1660
1660
  //#endregion
1661
- //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/sink.js
1661
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/sink.js
1662
1662
  /**
1663
1663
  * A console sink factory that returns a sink that logs to the console.
1664
1664
  *
@@ -1742,7 +1742,7 @@ function getConsoleSink(options = {}) {
1742
1742
  return nonBlockingSink;
1743
1743
  }
1744
1744
  //#endregion
1745
- //#region node_modules/.pnpm/@logtape+logtape@2.2.2/node_modules/@logtape/logtape/dist/config.js
1745
+ //#region node_modules/.pnpm/@logtape+logtape@2.2.4/node_modules/@logtape/logtape/dist/config.js
1746
1746
  /**
1747
1747
  * The current configuration, if any. Otherwise, `null`.
1748
1748
  */
@@ -1769,6 +1769,7 @@ const asyncFilterDisposables = /* @__PURE__ */ new Set();
1769
1769
  * Async sink disposables to dispose when resetting the configuration.
1770
1770
  */
1771
1771
  const asyncSinkDisposables = /* @__PURE__ */ new Set();
1772
+ let unregisterDisposeHook;
1772
1773
  /**
1773
1774
  * Check if a config is for the meta logger.
1774
1775
  */
@@ -1777,19 +1778,35 @@ function isLoggerConfigMeta(cfg) {
1777
1778
  return category.length === 0 || category.length === 1 && category[0] === "logtape" || category.length === 2 && category[0] === "logtape" && category[1] === "meta";
1778
1779
  }
1779
1780
  function registerDisposeHook(allowAsync) {
1781
+ unregisterDisposeHook?.();
1782
+ unregisterDisposeHook = void 0;
1780
1783
  const handler = allowAsync ? dispose : disposeSync;
1781
1784
  if (typeof globalThis.EdgeRuntime !== "string" && "process" in globalThis && !("Deno" in globalThis)) {
1782
1785
  const proc = globalThis.process;
1783
1786
  const onMethod = proc?.["on"];
1784
1787
  if (typeof onMethod === "function") {
1785
1788
  onMethod.call(proc, "exit", handler);
1789
+ unregisterDisposeHook = () => {
1790
+ const offMethod = proc?.["off"] ?? proc?.["removeListener"];
1791
+ if (typeof offMethod === "function") offMethod.call(proc, "exit", handler);
1792
+ };
1786
1793
  return;
1787
1794
  }
1788
1795
  }
1789
1796
  const addEventListenerMethod = globalThis.addEventListener;
1790
1797
  if (typeof addEventListenerMethod !== "function") return;
1791
- if ("Deno" in globalThis) addEventListenerMethod.call(globalThis, "unload", handler);
1792
- else addEventListenerMethod.call(globalThis, "pagehide", handler);
1798
+ const removeEventListenerMethod = globalThis.removeEventListener;
1799
+ if ("Deno" in globalThis) {
1800
+ addEventListenerMethod.call(globalThis, "unload", handler);
1801
+ if (typeof removeEventListenerMethod === "function") unregisterDisposeHook = () => {
1802
+ removeEventListenerMethod.call(globalThis, "unload", handler);
1803
+ };
1804
+ } else {
1805
+ addEventListenerMethod.call(globalThis, "pagehide", handler);
1806
+ if (typeof removeEventListenerMethod === "function") unregisterDisposeHook = () => {
1807
+ removeEventListenerMethod.call(globalThis, "pagehide", handler);
1808
+ };
1809
+ }
1793
1810
  }
1794
1811
  /**
1795
1812
  * Configure the loggers with the specified configuration.
@@ -1891,6 +1908,13 @@ function configureInternal(config, allowAsync) {
1891
1908
  });
1892
1909
  }
1893
1910
  /**
1911
+ * Get the current configuration, if any. Otherwise, `null`.
1912
+ * @returns The current configuration, if any. Otherwise, `null`.
1913
+ */
1914
+ function getConfig() {
1915
+ return currentConfig;
1916
+ }
1917
+ /**
1894
1918
  * Reset the configuration. Mostly for testing purposes.
1895
1919
  */
1896
1920
  async function reset() {
@@ -1898,6 +1922,8 @@ async function reset() {
1898
1922
  resetInternal();
1899
1923
  }
1900
1924
  function resetInternal() {
1925
+ unregisterDisposeHook?.();
1926
+ unregisterDisposeHook = void 0;
1901
1927
  const rootLogger = LoggerImpl.getLogger([]);
1902
1928
  rootLogger.resetDescendants();
1903
1929
  delete rootLogger.contextLocalStorage;
@@ -2045,12 +2071,14 @@ var ConfigError = class extends Error {
2045
2071
  * the rest of the project's vocabulary; we translate at the
2046
2072
  * configure boundary.
2047
2073
  *
2048
- * ## Idempotency
2074
+ * ## Idempotency & host-config coexistence
2049
2075
  *
2050
- * `configureObservability` is safe to call multiple times. LogTape's
2051
- * own `configure` will reject re-configuration without `reset: true`;
2052
- * we always pass `reset: true` so the last call wins and operators
2053
- * can hot-swap config in dev without restarting.
2076
+ * Safe to call repeatedly: over baerly's own config (or none) we
2077
+ * reconfigure with `reset: true` so the last call wins. But baerly is
2078
+ * a library — an embedding app may own LogTape. To avoid clobbering a
2079
+ * host config, we skip (with one meta-logger notice) when {@link
2080
+ * getConfig} shows a config we didn't install. Embedders opt out fully
2081
+ * via the adapter's `observability: false`.
2054
2082
  */
2055
2083
  /**
2056
2084
  * Canonical category names. Use these instead of bare strings.
@@ -2067,29 +2095,56 @@ const CATEGORY = {
2067
2095
  storage: ["baerly", "storage"]
2068
2096
  };
2069
2097
  /**
2098
+ * Sink id baerly registers under. Doubles as our config-ownership
2099
+ * marker: a LogTape config carrying a sink under this key is one we
2100
+ * installed, so re-running {@link configureObservability} may safely
2101
+ * reset it. A config *without* this key belongs to the host app and
2102
+ * we must not clobber it.
2103
+ *
2104
+ * Deliberately namespaced rather than a bare `"baerly"`: this key
2105
+ * gates a destructive `reset`, so a host must never be able to trip it
2106
+ * by coincidentally naming one of its own sinks the same thing. The id
2107
+ * is internal (never surfaced on the wire) and depends only on
2108
+ * LogTape's documented `Config.sinks` shape.
2109
+ */
2110
+ const BAERLY_SINK_ID = "@gusto/baerly-storage";
2111
+ /**
2070
2112
  * Wire LogTape's global config.
2071
2113
  *
2072
- * Idempotent — call as many times as you like. The adapter boot
2073
- * path calls it once at init; tests call it once per
2074
- * `beforeEach`.
2114
+ * Idempotent over baerly's own config — call as many times as you
2115
+ * like and the last call wins. The adapter boot path calls it once at
2116
+ * init; tests call it once per `beforeEach`. When LogTape is already
2117
+ * configured by the host application (see the module doc), this is a
2118
+ * no-op apart from a one-line meta-logger notice.
2075
2119
  */
2076
2120
  const configureObservability = async (config = {}) => {
2121
+ const existing = getConfig();
2122
+ if (existing !== null && !isBaerlyOwnedConfig(existing)) {
2123
+ getLogger$1(["logtape", "meta"]).warn("LogTape already configured by the host; baerly left it intact. Add a [\"baerly\"] logger to route baerly logs, or pass observability:false.");
2124
+ return;
2125
+ }
2077
2126
  const level = resolveLevel(config.level);
2127
+ const sink = resolveSink(config.sink);
2078
2128
  await configure({
2079
2129
  reset: true,
2080
- sinks: { primary: resolveSink(config.sink) },
2130
+ sinks: { [BAERLY_SINK_ID]: sink },
2081
2131
  loggers: [{
2082
2132
  category: "baerly",
2083
- sinks: ["primary"],
2133
+ sinks: [BAERLY_SINK_ID],
2084
2134
  lowestLevel: level
2085
2135
  }, {
2086
2136
  category: ["logtape", "meta"],
2087
- sinks: ["primary"],
2137
+ sinks: [BAERLY_SINK_ID],
2088
2138
  lowestLevel: "error"
2089
2139
  }]
2090
2140
  });
2091
2141
  };
2092
2142
  /**
2143
+ * Is this LogTape config one baerly installed? Detected by the marker
2144
+ * sink id — see {@link BAERLY_SINK_ID}.
2145
+ */
2146
+ const isBaerlyOwnedConfig = (cfg) => Object.prototype.hasOwnProperty.call(cfg.sinks, BAERLY_SINK_ID);
2147
+ /**
2093
2148
  * Thin re-export. Identical shape to `@logtape/logtape`'s `getLogger`.
2094
2149
  * Constants in {@link CATEGORY} are the canonical inputs; bare
2095
2150
  * strings still work for ad-hoc instrumentation.
@@ -2149,11 +2204,14 @@ const deriveOutcome = (method, status, error) => {
2149
2204
  * Every HTTP request emits a line; level is computed from
2150
2205
  * status/error.
2151
2206
  *
2152
- * Level mapping at emit time:
2207
+ * Level mapping at emit time (wire status is authoritative):
2153
2208
  *
2154
- * - `error` present → `error`
2155
2209
  * - `status >= 500` → `error`
2156
- * - `status >= 400` → `warn`
2210
+ * - `status >= 400` → `warn` (client error — a 4xx is the caller's
2211
+ * fault, not a server fault; an attached structured error, including
2212
+ * a 409 Conflict, does NOT escalate it)
2213
+ * - `status` 2xx/3xx with an attached `error` → `error` (anomalous)
2214
+ * - no `status`, `error` present → `error`
2157
2215
  * - otherwise → `info`
2158
2216
  */
2159
2217
  /**
@@ -2277,12 +2335,12 @@ const flushUnauthorizedAndRespond = (obsCtx, req) => {
2277
2335
  });
2278
2336
  };
2279
2337
  const pickLevel = (opts) => {
2280
- if (opts.error !== void 0) return "error";
2281
2338
  if (opts.status !== void 0) {
2282
2339
  if (opts.status >= 500) return "error";
2283
2340
  if (opts.status >= 400) return "warn";
2341
+ return opts.error !== void 0 ? "error" : "info";
2284
2342
  }
2285
- return "info";
2343
+ return opts.error !== void 0 ? "error" : "info";
2286
2344
  };
2287
2345
  const buildProperties = (ctx, recorder, opts, level) => {
2288
2346
  const duration_ms = Math.max(0, performance.now() - ctx.started_at);
@@ -2500,4 +2558,4 @@ const observableStorage = (inner) => {
2500
2558
  //#endregion
2501
2559
  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 };
2502
2560
 
2503
- //# sourceMappingURL=observability-wzs3-BL_.js.map
2561
+ //# sourceMappingURL=observability-Ch-VQJyE.js.map