@bounded-sh/core 0.0.13 → 0.0.14

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/dist/index.mjs CHANGED
@@ -4751,39 +4751,8 @@ async function get(path, opts = {}) {
4751
4751
  }
4752
4752
  // Create a new request promise and store it
4753
4753
  const requestPromise = (async () => {
4754
- var _a;
4755
4754
  try {
4756
- // For realtime chains, prefer WebSocket reads (lower latency, already connected)
4757
- const config = await getConfig();
4758
4755
  const pathIsDocument = normalizedPath.split("/").length % 2 === 0;
4759
- if (((_a = config.chain) === null || _a === void 0 ? void 0 : _a.startsWith('realtime_')) && !config.isServer && !opts.prompt && !opts.shape && !opts.cursor && !opts.includeSubPaths && !opts.filter && !opts.sort) {
4760
- try {
4761
- const { wsGet, wsQuery, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
4762
- if (hasActiveConnection()) {
4763
- if (pathIsDocument) {
4764
- const wsResult = await wsGet(normalizedPath);
4765
- const responseData = normalizeReadResult(wsResult, true);
4766
- if (!opts.bypassCache) {
4767
- getCache[cacheKey] = { data: responseData, expiresAt: now + GET_CACHE_TTL };
4768
- }
4769
- return responseData;
4770
- }
4771
- else if (!opts.limit) {
4772
- const wsResult = await wsQuery(normalizedPath, {
4773
- filter: undefined,
4774
- sort: undefined,
4775
- includeSubPaths: opts.includeSubPaths,
4776
- });
4777
- const responseData = normalizeReadResult(wsResult, false);
4778
- if (!opts.bypassCache) {
4779
- getCache[cacheKey] = { data: responseData, expiresAt: now + GET_CACHE_TTL };
4780
- }
4781
- return responseData;
4782
- }
4783
- }
4784
- }
4785
- catch ( /* fall through to HTTP */_b) { /* fall through to HTTP */ }
4786
- }
4787
4756
  // Cache miss or bypass - proceed with HTTP API request
4788
4757
  let response;
4789
4758
  // Build common query params
@@ -5036,7 +5005,7 @@ async function set(path, document, options) {
5036
5005
  return result;
5037
5006
  }
5038
5007
  async function setMany(many, options) {
5039
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
5008
+ var _a, _b, _c, _d, _e, _f, _g;
5040
5009
  // Returns the data that was set, or undefined if the document was already set.
5041
5010
  try {
5042
5011
  const config = await getConfig();
@@ -5073,40 +5042,13 @@ async function setMany(many, options) {
5073
5042
  }
5074
5043
  let setResponse;
5075
5044
  try {
5076
- // For realtime chains, prefer WebSocket if a connection is active (lower latency)
5077
- const useWs = ((_c = config.chain) === null || _c === void 0 ? void 0 : _c.startsWith('realtime_')) && !config.isServer;
5078
- if (useWs) {
5079
- try {
5080
- const { wsSet, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
5081
- if (hasActiveConnection()) {
5082
- // Connection is active — send via WS. If this throws, the write
5083
- // may have been applied server-side (ack lost). Do NOT fall through
5084
- // to HTTP, as that would double-apply non-idempotent ops (Increment).
5085
- const wsResult = await wsSet(documents);
5086
- setResponse = { data: wsResult, status: 200 };
5087
- }
5088
- }
5089
- catch (wsError) {
5090
- // Only fall through to HTTP if the request was never sent (connection not available).
5091
- // If the request was sent and ack was lost (timeout), the server may have
5092
- // applied it — re-sending via HTTP risks double-write for non-idempotent ops.
5093
- const msg = (_d = wsError === null || wsError === void 0 ? void 0 : wsError.message) !== null && _d !== void 0 ? _d : '';
5094
- const neverSent = msg.includes('not available') || msg.includes('connection timeout');
5095
- if (!neverSent) {
5096
- throw wsError;
5097
- }
5098
- // Safe to retry via HTTP — request was never sent
5099
- }
5100
- }
5101
- if (!setResponse) {
5102
- setResponse = await makeApiRequest('PUT', `items`, { documents }, options === null || options === void 0 ? void 0 : options._overrides);
5103
- }
5045
+ setResponse = await makeApiRequest('PUT', `items`, { documents }, options === null || options === void 0 ? void 0 : options._overrides);
5104
5046
  }
5105
5047
  catch (error) {
5106
5048
  if ((error === null || error === void 0 ? void 0 : error.statusCode) === 402 && (error === null || error === void 0 ? void 0 : error.error) === 'INSUFFICIENT_BALANCE') {
5107
- const deficitLamports = Number((_e = error.deficitLamports) !== null && _e !== void 0 ? _e : 0);
5108
- const deficitSol = Number((_f = error.deficitSol) !== null && _f !== void 0 ? _f : deficitLamports / 1000000000);
5109
- throw new InsufficientBalanceError(String((_g = error.address) !== null && _g !== void 0 ? _g : ''), Number((_h = error.balanceLamports) !== null && _h !== void 0 ? _h : 0), Number((_j = error.estimatedCostLamports) !== null && _j !== void 0 ? _j : 0), deficitLamports, deficitSol);
5049
+ const deficitLamports = Number((_c = error.deficitLamports) !== null && _c !== void 0 ? _c : 0);
5050
+ const deficitSol = Number((_d = error.deficitSol) !== null && _d !== void 0 ? _d : deficitLamports / 1000000000);
5051
+ throw new InsufficientBalanceError(String((_e = error.address) !== null && _e !== void 0 ? _e : ''), Number((_f = error.balanceLamports) !== null && _f !== void 0 ? _f : 0), Number((_g = error.estimatedCostLamports) !== null && _g !== void 0 ? _g : 0), deficitLamports, deficitSol);
5110
5052
  }
5111
5053
  throw error;
5112
5054
  }
@@ -5153,7 +5095,7 @@ async function setMany(many, options) {
5153
5095
  else if (setResponse.data &&
5154
5096
  typeof setResponse.data === 'object' &&
5155
5097
  setResponse.data.success === true) {
5156
- const _k = setResponse.data, { success: _success } = _k, rest = __rest$1(_k, ["success"]);
5098
+ const _h = setResponse.data, { success: _success } = _h, rest = __rest$1(_h, ["success"]);
5157
5099
  return Object.assign(Object.assign(Object.assign({}, documents.map(d => d.document)), rest), { transactionId: null });
5158
5100
  }
5159
5101
  else {
@@ -6681,23 +6623,6 @@ async function wsGetMany(paths) {
6681
6623
  }));
6682
6624
  }
6683
6625
 
6684
- var subscriptionV2 = /*#__PURE__*/Object.freeze({
6685
- __proto__: null,
6686
- clearCacheV2: clearCacheV2,
6687
- closeAllSubscriptionsV2: closeAllSubscriptionsV2,
6688
- getCachedDataV2: getCachedDataV2,
6689
- hasActiveConnection: hasActiveConnection,
6690
- reconnectWithNewAuthV2: reconnectWithNewAuthV2,
6691
- subscribeV2: subscribeV2,
6692
- wsDelete: wsDelete,
6693
- wsGet: wsGet,
6694
- wsGetMany: wsGetMany,
6695
- wsIntent: wsIntent,
6696
- wsIntentReliable: wsIntentReliable,
6697
- wsQuery: wsQuery,
6698
- wsSet: wsSet
6699
- });
6700
-
6701
6626
  /**
6702
6627
  * WebSocket Subscription Module
6703
6628
  *