@pooflabs/core 0.0.29 → 0.0.30

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
@@ -3188,7 +3188,7 @@ async function refreshAuthSessionOnce(appId, isServer) {
3188
3188
  return refreshPromise;
3189
3189
  }
3190
3190
  async function makeApiRequest(method, urlPath, data, _overrides) {
3191
- var _a, _b, _c, _d, _e, _f;
3191
+ var _a, _b, _c, _d;
3192
3192
  const config = await getConfig();
3193
3193
  let hasRetriedAfterServerSessionReset = false;
3194
3194
  const clearServerSession = async () => {
@@ -3248,8 +3248,14 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
3248
3248
  if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) == 404) {
3249
3249
  return { data: null, status: 404 };
3250
3250
  }
3251
- if ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message) {
3252
- throw new Error((_f = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.message);
3251
+ if ((_c = error.response) === null || _c === void 0 ? void 0 : _c.data) {
3252
+ const responseData = typeof error.response.data === 'object'
3253
+ ? error.response.data
3254
+ : { message: String(error.response.data) };
3255
+ const apiError = new Error(responseData.message || error.message || 'Request failed');
3256
+ Object.assign(apiError, responseData);
3257
+ apiError.statusCode = (_d = error.response) === null || _d === void 0 ? void 0 : _d.status;
3258
+ throw apiError;
3253
3259
  }
3254
3260
  throw error;
3255
3261
  }
@@ -3314,6 +3320,40 @@ async function getConfig() {
3314
3320
  return clientConfig;
3315
3321
  }
3316
3322
 
3323
+ /******************************************************************************
3324
+ Copyright (c) Microsoft Corporation.
3325
+
3326
+ Permission to use, copy, modify, and/or distribute this software for any
3327
+ purpose with or without fee is hereby granted.
3328
+
3329
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3330
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3331
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3332
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3333
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3334
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3335
+ PERFORMANCE OF THIS SOFTWARE.
3336
+ ***************************************************************************** */
3337
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
3338
+
3339
+
3340
+ function __rest(s, e) {
3341
+ var t = {};
3342
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3343
+ t[p] = s[p];
3344
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
3345
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3346
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3347
+ t[p[i]] = s[p[i]];
3348
+ }
3349
+ return t;
3350
+ }
3351
+
3352
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
3353
+ var e = new Error(message);
3354
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3355
+ };
3356
+
3317
3357
  // Cache for get responses
3318
3358
  const getCache = {};
3319
3359
  // Track in-flight requests to coalesce multiple identical requests
@@ -3411,11 +3451,11 @@ function cleanupExpiredCache() {
3411
3451
  });
3412
3452
  lastCacheCleanup = now;
3413
3453
  }
3414
- async function runQuery(absolutePath, queryName, queryArgs) {
3415
- const result = await runQueryMany([{ absolutePath, queryName, queryArgs }]);
3454
+ async function runQuery(absolutePath, queryName, queryArgs, opts) {
3455
+ const result = await runQueryMany([{ absolutePath, queryName, queryArgs }], opts);
3416
3456
  return result[0];
3417
3457
  }
3418
- async function runQueryMany(many) {
3458
+ async function runQueryMany(many, opts) {
3419
3459
  try {
3420
3460
  let queries = [];
3421
3461
  for (const { absolutePath, queryName, queryArgs } of many) {
@@ -3426,7 +3466,7 @@ async function runQueryMany(many) {
3426
3466
  }
3427
3467
  queries.push({ path: normalizedPath, queryName, queryArgs });
3428
3468
  }
3429
- const response = await makeApiRequest('POST', 'queries', { queries }, undefined);
3469
+ const response = await makeApiRequest('POST', 'queries', { queries }, opts === null || opts === void 0 ? void 0 : opts._overrides);
3430
3470
  return response.data.queries.map((result) => result.result);
3431
3471
  }
3432
3472
  catch (error) {
@@ -3543,6 +3583,12 @@ async function setMany(many, options) {
3543
3583
  if (setResponse.data === true) {
3544
3584
  return Object.assign(Object.assign({}, documents.map(d => d.document)), { transactionId: null });
3545
3585
  }
3586
+ else if (setResponse.data &&
3587
+ typeof setResponse.data === 'object' &&
3588
+ setResponse.data.success === true) {
3589
+ const _a = setResponse.data, { success: _success } = _a, rest = __rest(_a, ["success"]);
3590
+ return Object.assign(Object.assign(Object.assign({}, documents.map(d => d.document)), rest), { transactionId: null });
3591
+ }
3546
3592
  else {
3547
3593
  return Object.assign(Object.assign({}, setResponse.data), { transactionId: null });
3548
3594
  }