@calmlens/sdk 0.12.0 → 0.13.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 (35) hide show
  1. package/README.md +14 -1
  2. package/cjs/CalmLensConnection-DzRDCMOP.js +233 -0
  3. package/cjs/CalmLensUtils-vX5H_vMn.js +699 -0
  4. package/cjs/{CalmLensError-CKwMKV0S.js → CalmLensVersion-DjhsJ1gj.js} +48 -0
  5. package/cjs/{CalmLensWebhooks-BTPxKvcD.js → CalmLensWebhooks-hVquX5L1.js} +9 -9
  6. package/cjs/{WebhookPayload-Cgb32aSH.d.ts → WebhookPayload-B7CgSmI5.d.ts} +4996 -3255
  7. package/cjs/app.d.ts +3 -3
  8. package/cjs/app.js +10 -10
  9. package/cjs/{index-BgmWj3KL.d.ts → index-BywTQbRq.d.ts} +3 -1
  10. package/cjs/index.d.ts +3 -3
  11. package/cjs/index.js +4 -5
  12. package/cjs/server.d.ts +12 -4
  13. package/cjs/server.js +31 -18
  14. package/cjs/testing.d.ts +6 -1
  15. package/cjs/testing.js +91 -73
  16. package/esm/CalmLensConnection-D8VsTdsA.js +192 -0
  17. package/esm/{CalmLensUtils-Cx32j2zt.js → CalmLensUtils-B4i3Z2He.js} +316 -2
  18. package/esm/{CalmLensError-CihGG26K.js → CalmLensVersion-DK4BMEST.js} +25 -1
  19. package/esm/{CalmLensWebhooks-DShmAal4.js → CalmLensWebhooks-DyCoEvpf.js} +2 -2
  20. package/esm/{WebhookPayload-Cgb32aSH.d.ts → WebhookPayload-B7CgSmI5.d.ts} +4996 -3255
  21. package/esm/app.d.ts +3 -3
  22. package/esm/app.js +4 -4
  23. package/esm/{index-BgmWj3KL.d.ts → index-BywTQbRq.d.ts} +3 -1
  24. package/esm/index.d.ts +3 -3
  25. package/esm/index.js +1 -3
  26. package/esm/server.d.ts +12 -4
  27. package/esm/server.js +20 -7
  28. package/esm/testing.d.ts +6 -1
  29. package/esm/testing.js +59 -41
  30. package/package.json +1 -1
  31. package/cjs/CalmLensConnection-CYtBP-vu.js +0 -516
  32. package/cjs/CalmLensUtils-Dg3s4loH.js +0 -367
  33. package/cjs/src-Dsc8Pn6v.js +0 -45
  34. package/esm/CalmLensConnection-wLNy0OIP.js +0 -475
  35. package/esm/src-CJhrILvM.js +0 -22
@@ -1,4 +1,4 @@
1
- import { a as invalidConfig, i as invalidArgument, n as CalmLensError, o as API_ERROR_CODES } from "./CalmLensError-CihGG26K.js";
1
+ import { c as invalidArgument, l as invalidConfig, n as getUserAgent, o as CalmLensError, r as isBrowserRuntime, s as SDK_ERROR_CODES, u as API_ERROR_CODES } from "./CalmLensVersion-DK4BMEST.js";
2
2
  const MAX_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 20971520)();
3
3
  const MIN_MULTIPART_IMAGE_UPLOAD_BYTES = /* @__PURE__ */ (() => 10485760)();
4
4
  const REJECTED_UPLOAD_MIME_TYPE_SET = /* @__PURE__ */ new Set([
@@ -97,6 +97,287 @@ const validateAssetPayload = (payload, options) => {
97
97
  return { ok: true };
98
98
  };
99
99
  //#endregion
100
+ //#region src/client/CalmLensTransport.ts
101
+ /** Retry delays grow from this base, doubling per attempt, with jitter. */
102
+ const RETRY_BASE_DELAY_MS = 500;
103
+ const RETRY_MAX_DELAY_MS = 8e3;
104
+ /** A `Retry-After` longer than this is returned to the caller instead of waited out. */
105
+ const RETRY_AFTER_MAX_MS = 6e4;
106
+ const RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
107
+ 429,
108
+ 502,
109
+ 503,
110
+ 504
111
+ ]);
112
+ const timeoutReason = () => {
113
+ const reason = /* @__PURE__ */ new Error("The operation timed out.");
114
+ reason.name = "TimeoutError";
115
+ return reason;
116
+ };
117
+ /**
118
+ * Links the callers' signals and a per-attempt deadline. `AbortSignal.any` holds its sources
119
+ * weakly, so a long-lived caller signal doesn't collect a listener per streamed response;
120
+ * runtimes without it get explicit listeners that `release` removes.
121
+ */
122
+ const createAttemptSignal = (signals, timeoutMs) => {
123
+ const callers = signals.filter((signal) => signal !== void 0);
124
+ const deadline = new AbortController();
125
+ let timedOut = false;
126
+ let signal;
127
+ let onAbort;
128
+ if (typeof AbortSignal.any === "function") signal = AbortSignal.any([...callers, deadline.signal]);
129
+ else {
130
+ const controller = new AbortController();
131
+ signal = controller.signal;
132
+ onAbort = (event) => controller.abort(event.target.reason);
133
+ for (const source of [...callers, deadline.signal]) if (source.aborted) controller.abort(source.reason);
134
+ else source.addEventListener("abort", onAbort, { once: true });
135
+ }
136
+ let timer = timeoutMs === void 0 ? void 0 : setTimeout(() => {
137
+ timedOut = true;
138
+ deadline.abort(timeoutReason());
139
+ }, timeoutMs);
140
+ return {
141
+ signal,
142
+ isTimedOut: () => timedOut,
143
+ isCancelled: () => callers.some((caller) => caller.aborted),
144
+ clearDeadline: () => {
145
+ if (timer !== void 0) clearTimeout(timer);
146
+ timer = void 0;
147
+ },
148
+ release: () => {
149
+ if (timer !== void 0) clearTimeout(timer);
150
+ timer = void 0;
151
+ if (onAbort) for (const caller of callers) caller.removeEventListener("abort", onAbort);
152
+ }
153
+ };
154
+ };
155
+ /**
156
+ * A redirect the SDK must not follow: it would send the API key to another origin. Browsers report
157
+ * a manual redirect as an opaque response; other runtimes return the 3xx with its Location.
158
+ */
159
+ const isRedirect = (response) => response.type === "opaqueredirect" || response.status >= 300 && response.status < 400 && response.headers.has("location");
160
+ /** Turns anything thrown while sending or reading a request into a `CalmLensError`. */
161
+ const toFailure = (cause, attempt) => {
162
+ if (CalmLensError.isCalmLensError(cause)) return cause;
163
+ if (attempt.isCancelled()) return new CalmLensError(SDK_ERROR_CODES.CANCELLED, {
164
+ message: "Request cancelled",
165
+ cause
166
+ });
167
+ if (attempt.isTimedOut()) return new CalmLensError(SDK_ERROR_CODES.TIMEOUT, {
168
+ message: "Request timed out",
169
+ cause
170
+ });
171
+ return new CalmLensError(SDK_ERROR_CODES.TRANSPORT_ERROR, {
172
+ message: "Request failed",
173
+ cause
174
+ });
175
+ };
176
+ const sleep = (ms, signal) => new Promise((resolve, reject) => {
177
+ if (signal?.aborted) {
178
+ reject(new CalmLensError(SDK_ERROR_CODES.CANCELLED, { message: "Request cancelled" }));
179
+ return;
180
+ }
181
+ const onAbort = () => {
182
+ clearTimeout(timer);
183
+ reject(new CalmLensError(SDK_ERROR_CODES.CANCELLED, { message: "Request cancelled" }));
184
+ };
185
+ const timer = setTimeout(() => {
186
+ signal?.removeEventListener("abort", onAbort);
187
+ resolve();
188
+ }, ms);
189
+ signal?.addEventListener("abort", onAbort, { once: true });
190
+ });
191
+ /** Exponential backoff with jitter: half the delay is fixed, the other half random. */
192
+ const getRetryDelayMs = (attempt, random = Math.random) => {
193
+ const delay = Math.min(RETRY_MAX_DELAY_MS, RETRY_BASE_DELAY_MS * 2 ** attempt);
194
+ return Math.round(delay / 2 + random() * (delay / 2));
195
+ };
196
+ /** Parses `Retry-After` as seconds or an HTTP date, in seconds from `now`. */
197
+ const parseRetryAfter = (value, now = Date.now()) => {
198
+ if (!value) return void 0;
199
+ const trimmed = value.trim();
200
+ if (/^\d+$/.test(trimmed)) return Number(trimmed);
201
+ const date = Date.parse(trimmed);
202
+ if (Number.isNaN(date)) return void 0;
203
+ return Math.max(0, Math.ceil((date - now) / 1e3));
204
+ };
205
+ /** Bodies that can be sent again unchanged. Streams are consumed by the first attempt. */
206
+ const isReplayableBody = (body) => body === void 0 || body === null || typeof body === "string" || body instanceof Blob || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || body instanceof URLSearchParams;
207
+ const isApiErrorPayload = (value) => !!value && typeof value === "object" && typeof value.code === "string";
208
+ /** Reads at most `limit` bytes of a body, failing with `sdk/response-too-large` beyond that. */
209
+ const readBody = async (response, limit) => {
210
+ const declared = Number(response.headers.get("content-length"));
211
+ const tooLarge = () => new CalmLensError(SDK_ERROR_CODES.RESPONSE_TOO_LARGE, {
212
+ message: `Response body exceeds ${limit} bytes`,
213
+ status: response.status,
214
+ requestId: response.headers.get("x-request-id") ?? void 0,
215
+ headers: response.headers
216
+ });
217
+ if (Number.isFinite(declared) && declared > limit) {
218
+ await response.body?.cancel().catch(() => {});
219
+ throw tooLarge();
220
+ }
221
+ if (!response.body) return /* @__PURE__ */ new Uint8Array(0);
222
+ const reader = response.body.getReader();
223
+ const chunks = [];
224
+ let total = 0;
225
+ for (;;) {
226
+ const { done, value } = await reader.read();
227
+ if (done) break;
228
+ total += value.byteLength;
229
+ if (total > limit) {
230
+ await reader.cancel().catch(() => {});
231
+ throw tooLarge();
232
+ }
233
+ chunks.push(value);
234
+ }
235
+ const bytes = new Uint8Array(total);
236
+ let offset = 0;
237
+ for (const chunk of chunks) {
238
+ bytes.set(chunk, offset);
239
+ offset += chunk.byteLength;
240
+ }
241
+ return bytes;
242
+ };
243
+ const responseInfo = (response) => ({
244
+ status: response.status,
245
+ requestId: response.headers.get("x-request-id") ?? void 0,
246
+ headers: response.headers,
247
+ retryAfter: parseRetryAfter(response.headers.get("retry-after"))
248
+ });
249
+ /** The `CalmLensError` for a non-2xx response whose body has been read. */
250
+ const toHttpError = (response, bytes) => {
251
+ let data;
252
+ try {
253
+ data = JSON.parse(new TextDecoder().decode(bytes));
254
+ } catch {}
255
+ if (isApiErrorPayload(data)) {
256
+ const { code, message, details, traceId } = data;
257
+ return new CalmLensError(code, {
258
+ message: message ?? code,
259
+ ...responseInfo(response),
260
+ details: details || traceId ? {
261
+ ...details,
262
+ ...traceId ? { traceId } : {}
263
+ } : void 0
264
+ });
265
+ }
266
+ return new CalmLensError(SDK_ERROR_CODES.HTTP_ERROR, {
267
+ message: `HTTP ${response.status}`,
268
+ ...responseInfo(response)
269
+ });
270
+ };
271
+ /** Sends requests with the client's credentials, deadlines, retries and response limits. */
272
+ var CalmLensTransport = class {
273
+ constructor(settings) {
274
+ this.settings = settings;
275
+ }
276
+ headersFor(request) {
277
+ const headers = new Headers(request.init?.headers);
278
+ for (const [name, value] of Object.entries(request.headers ?? {})) headers.set(name, value);
279
+ if (!headers.has("accept") && request.deadline === "body") headers.set("accept", "application/json");
280
+ if (this.settings.apiKey) headers.set("x-api-key", this.settings.apiKey);
281
+ if (!isBrowserRuntime()) headers.set("user-agent", getUserAgent());
282
+ if (request.idempotencyKey) headers.set("idempotency-key", request.idempotencyKey);
283
+ return Object.fromEntries(headers.entries());
284
+ }
285
+ canRetry(request) {
286
+ return this.settings.maxRetries > 0 && (request.method === "GET" || request.method === "HEAD" || !!request.idempotencyKey) && isReplayableBody(request.body);
287
+ }
288
+ /**
289
+ * Sends a request and returns the response, retrying transport failures, 429, 502–504 and
290
+ * `idempotency/request-in-progress` when the request is safe to repeat. Non-2xx responses
291
+ * throw unless `allowHttpErrors` is set. Call `release` once the body has been read.
292
+ */
293
+ async send(request, { allowHttpErrors = false } = {}) {
294
+ const fetchImpl = request.fetch ?? this.settings.fetch;
295
+ const retryable = this.canRetry(request);
296
+ const headers = this.headersFor(request);
297
+ for (let attemptNumber = 0;; attemptNumber++) {
298
+ const canRetryAgain = retryable && attemptNumber < this.settings.maxRetries;
299
+ const attempt = createAttemptSignal([this.settings.signal, request.init?.signal ?? void 0], request.timeoutMs);
300
+ let response;
301
+ try {
302
+ if (attempt.signal.aborted) throw attempt.signal.reason;
303
+ response = await fetchImpl(request.url, {
304
+ ...request.init,
305
+ method: request.method,
306
+ headers,
307
+ body: request.body,
308
+ redirect: "manual",
309
+ signal: attempt.signal,
310
+ duplex: "half"
311
+ });
312
+ if (isRedirect(response)) {
313
+ await response.body?.cancel().catch(() => {});
314
+ throw new CalmLensError(SDK_ERROR_CODES.TRANSPORT_ERROR, { message: `Unexpected redirect (HTTP ${response.status})` });
315
+ }
316
+ } catch (cause) {
317
+ attempt.release();
318
+ const failure = toFailure(cause, attempt);
319
+ if (canRetryAgain && failure.code === SDK_ERROR_CODES.TRANSPORT_ERROR) {
320
+ await sleep(getRetryDelayMs(attemptNumber), this.settings.signal);
321
+ continue;
322
+ }
323
+ throw failure;
324
+ }
325
+ if (request.deadline === "headers") attempt.clearDeadline();
326
+ if (response.ok) return {
327
+ response,
328
+ attempt
329
+ };
330
+ if (allowHttpErrors) {
331
+ const retryAfter = parseRetryAfter(response.headers.get("retry-after"));
332
+ const delayMs = retryAfter !== void 0 ? retryAfter * 1e3 : getRetryDelayMs(attemptNumber);
333
+ if (!canRetryAgain || !RETRYABLE_STATUSES.has(response.status) || delayMs > RETRY_AFTER_MAX_MS) return {
334
+ response,
335
+ attempt
336
+ };
337
+ attempt.release();
338
+ await response.body?.cancel().catch(() => {});
339
+ await sleep(delayMs, this.settings.signal);
340
+ continue;
341
+ }
342
+ let error;
343
+ try {
344
+ error = toHttpError(response, await readBody(response, this.settings.maxResponseBytes));
345
+ } catch (cause) {
346
+ error = toFailure(cause, attempt);
347
+ } finally {
348
+ attempt.release();
349
+ }
350
+ const retryDelayMs = error.retryAfter !== void 0 ? error.retryAfter * 1e3 : getRetryDelayMs(attemptNumber);
351
+ if (canRetryAgain && retryDelayMs <= RETRY_AFTER_MAX_MS && (error.status !== void 0 && RETRYABLE_STATUSES.has(error.status) || error.code === API_ERROR_CODES.IDEMPOTENT_REQUEST_IN_PROGRESS)) {
352
+ await sleep(retryDelayMs, this.settings.signal);
353
+ continue;
354
+ }
355
+ throw error;
356
+ }
357
+ }
358
+ /** Sends a request and parses its JSON response body. */
359
+ async json(request) {
360
+ const { response, attempt } = await this.send(request);
361
+ try {
362
+ const bytes = await readBody(response, this.settings.maxResponseBytes);
363
+ if (bytes.byteLength === 0 && (response.status === 204 || request.method === "DELETE")) return;
364
+ try {
365
+ return JSON.parse(new TextDecoder().decode(bytes));
366
+ } catch (cause) {
367
+ throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
368
+ message: `Invalid JSON response (HTTP ${response.status})`,
369
+ ...responseInfo(response),
370
+ cause
371
+ });
372
+ }
373
+ } catch (cause) {
374
+ throw toFailure(cause, attempt);
375
+ } finally {
376
+ attempt.release();
377
+ }
378
+ }
379
+ };
380
+ //#endregion
100
381
  //#region src/client/CalmLensUtils.ts
101
382
  const assertHttpUrl = (name, value) => {
102
383
  if (value === void 0) return;
@@ -256,5 +537,38 @@ const stringifyQuery = (query) => {
256
537
  for (const [key, value] of Object.entries(query)) appendQueryValue(parts, key, value);
257
538
  return parts.join("&");
258
539
  };
540
+ /** Statuses that are a moderation decision; `assets.waitForDecision` returns at the first. */
541
+ const DECIDED_ASSET_STATUSES = [
542
+ "approved",
543
+ "rejected",
544
+ "error"
545
+ ];
546
+ const DECISION_POLL_FIRST_DELAY_MS = 500;
547
+ const DECISION_POLL_MAX_DELAY_MS = 5e3;
548
+ const DEFAULT_DECISION_TIMEOUT_MS = 6e4;
549
+ /**
550
+ * Retrieves an asset until it has a decision, waiting 0.5s between checks and 1.5 times longer
551
+ * each time, up to 5s. Rejects with `sdk/timeout` once `timeoutMs` passes without one.
552
+ */
553
+ const pollForDecision = async (retrieve, { timeoutMs = DEFAULT_DECISION_TIMEOUT_MS, signal }, sleep, now = Date.now) => {
554
+ if (!Number.isFinite(timeoutMs) || timeoutMs < 0) throw invalidArgument("timeoutMs must be a non-negative number");
555
+ const deadline = now() + timeoutMs;
556
+ let delay = DECISION_POLL_FIRST_DELAY_MS;
557
+ for (;;) {
558
+ if (signal?.aborted) throw new CalmLensError(SDK_ERROR_CODES.CANCELLED, { message: "Request cancelled" });
559
+ const asset = await retrieve();
560
+ if (DECIDED_ASSET_STATUSES.includes(asset.status)) return asset;
561
+ const remaining = deadline - now();
562
+ if (remaining <= 0) throw new CalmLensError(SDK_ERROR_CODES.TIMEOUT, {
563
+ message: `Asset ${asset.id} had no moderation decision after ${timeoutMs}ms (status ${asset.status})`,
564
+ details: {
565
+ assetId: asset.id,
566
+ status: asset.status
567
+ }
568
+ });
569
+ await sleep(Math.min(delay, remaining), signal);
570
+ delay = Math.min(DECISION_POLL_MAX_DELAY_MS, delay * 1.5);
571
+ }
572
+ };
259
573
  //#endregion
260
- export { getRejectedUploadMimeTypeError as _, toTextAssetOptions as a, validateRequestOptions as c, assetToData as d, getAssetPayloadByteLength as f, MIN_MULTIPART_IMAGE_UPLOAD_BYTES as g, MAX_IMAGE_UPLOAD_BYTES as h, stringifyQuery as i, validateServerClientOptions as l, DOMAIN as m, encodePathSegment as n, transformSelector as o, validateAssetPayload as p, randomUuid as r, validateAppClientOptions as s, appendCdnSelector as t, assetDataToUint8Array as u, isRejectedUploadMimeType as v };
574
+ export { DOMAIN as _, stringifyQuery as a, getRejectedUploadMimeTypeError as b, validateAppClientOptions as c, CalmLensTransport as d, sleep as f, validateAssetPayload as g, getAssetPayloadByteLength as h, randomUuid as i, validateRequestOptions as l, assetToData as m, encodePathSegment as n, toTextAssetOptions as o, assetDataToUint8Array as p, pollForDecision as r, transformSelector as s, appendCdnSelector as t, validateServerClientOptions as u, MAX_IMAGE_UPLOAD_BYTES as v, isRejectedUploadMimeType as x, MIN_MULTIPART_IMAGE_UPLOAD_BYTES as y };
@@ -11,6 +11,7 @@ const API_ERROR_CODES = {
11
11
  MULTIPART_IMAGE_TOO_LARGE: "upload/multipart-image-too-large",
12
12
  IMAGE_EXCEEDED_MAX_DIMENSIONS: "upload/image-exceeded-max-dimensions",
13
13
  UPLOAD_LIMIT_EXCEEDED: "upload/limit-exceeded",
14
+ SPEND_LIMIT_REACHED: "upload/spend-limit-reached",
14
15
  INVALID_UPLOAD_MIME_TYPE: "upload/invalid-mime-type",
15
16
  INVALID_EVENT_CURSOR: "events/invalid-cursor",
16
17
  INVALID_UPLOAD_PAYLOAD: "upload/invalid-payload",
@@ -89,6 +90,10 @@ const API_ERROR_DEFINITIONS = {
89
90
  status: 403,
90
91
  message: "Upload limit exceeded. You have used all your free uploads. Please upgrade to Plus or Pro for unlimited uploads."
91
92
  },
93
+ "upload/spend-limit-reached": {
94
+ status: 402,
95
+ message: "The project owner's spend limit for this billing period has been reached. Raise the limit in Billing to resume uploads."
96
+ },
92
97
  "upload/invalid-mime-type": {
93
98
  status: 400,
94
99
  message: "Upload file type is not supported. Uploads must use a concrete file MIME type that CalmLens can store and process, such as image/png, image/jpeg, application/pdf, or text/plain."
@@ -318,4 +323,23 @@ const invalidArgument = (message, details) => new CalmLensError(SDK_ERROR_CODES.
318
323
  });
319
324
  const invalidConfig = (message) => new CalmLensError(SDK_ERROR_CODES.INVALID_CONFIG, { message });
320
325
  //#endregion
321
- export { invalidConfig as a, invalidArgument as i, CalmLensError as n, API_ERROR_CODES as o, SDK_ERROR_CODES as r, API_ERROR_DEFINITIONS as s, CALMLENS_ERROR_CODES as t };
326
+ //#region src/client/CalmLensVersion.ts
327
+ /** This SDK's version, from its package.json. */
328
+ const SDK_VERSION = "0.13.0";
329
+ const runtimeName = () => {
330
+ const runtime = globalThis;
331
+ if (isReactNativeRuntime()) return "react-native";
332
+ if (runtime.Bun?.version) return `bun/${runtime.Bun.version}`;
333
+ if (runtime.Deno?.version?.deno) return `deno/${runtime.Deno.version.deno}`;
334
+ if (runtime.navigator?.userAgent === "Cloudflare-Workers") return "workerd";
335
+ if (runtime.process?.versions?.node) return `node/${runtime.process.versions.node}`;
336
+ return "unknown";
337
+ };
338
+ /** The `User-Agent` the SDK sends from server runtimes, e.g. `calmlens-js/0.10.0 (node/22.12.0)`. */
339
+ const getUserAgent = () => `calmlens-js/${SDK_VERSION} (${runtimeName()})`;
340
+ /** True in a web page, where API keys would be visible to every visitor. */
341
+ const isBrowserRuntime = () => typeof globalThis.window !== "undefined" && typeof globalThis.document !== "undefined";
342
+ /** True in a React Native app, where an API key ships inside the app for anyone to extract. */
343
+ const isReactNativeRuntime = () => globalThis.navigator?.product === "ReactNative";
344
+ //#endregion
345
+ export { CALMLENS_ERROR_CODES as a, invalidArgument as c, API_ERROR_DEFINITIONS as d, isReactNativeRuntime as i, invalidConfig as l, getUserAgent as n, CalmLensError as o, isBrowserRuntime as r, SDK_ERROR_CODES as s, SDK_VERSION as t, API_ERROR_CODES as u };
@@ -1,5 +1,5 @@
1
- import { i as invalidArgument, n as CalmLensError, r as SDK_ERROR_CODES } from "./CalmLensError-CihGG26K.js";
2
- import { n as encodePathSegment } from "./CalmLensUtils-Cx32j2zt.js";
1
+ import { c as invalidArgument, o as CalmLensError, s as SDK_ERROR_CODES } from "./CalmLensVersion-DK4BMEST.js";
2
+ import { n as encodePathSegment } from "./CalmLensUtils-B4i3Z2He.js";
3
3
  //#region ../shared/src/JsonUtils.ts
4
4
  const stringifyJsonCanonical = (value) => JSON.stringify(value, (_key, nestedValue) => {
5
5
  if (!nestedValue || typeof nestedValue !== "object" || Array.isArray(nestedValue)) return nestedValue;