@superdurable/connector-bmob 0.1.0 → 0.1.1

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.
@@ -4,7 +4,7 @@
4
4
  "package": {
5
5
  "ecosystem": "npm",
6
6
  "name": "@superdurable/connector-bmob",
7
- "version": "0.1.0"
7
+ "version": "0.1.1"
8
8
  },
9
9
  "factories": [
10
10
  {
package/dist/index.js CHANGED
@@ -164,7 +164,8 @@ var BmobClient = class {
164
164
  signal: call.context.cancellationSignal
165
165
  };
166
166
  try {
167
- return { response: await this.send(request) };
167
+ const response = await this.send(request);
168
+ return { response, tooLarge: response.body.length > this.maxResponseBytes };
168
169
  } catch (error) {
169
170
  if (error instanceof BodyTooLargeError && error.status !== void 0)
170
171
  return { response: { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() }, tooLarge: true };
@@ -199,7 +200,7 @@ var CountClassObjectsOperation = class {
199
200
  }
200
201
  let value;
201
202
  try {
202
- value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body));
203
+ value = decodeProviderJSON(response.body);
203
204
  } catch {
204
205
  return terminal("invalidResponse", "PROTOCOL", "Bmob returned an invalid count response");
205
206
  }
@@ -226,6 +227,17 @@ function retryDelay(response) {
226
227
  const value = Object.entries(response.headers).find(([name]) => name.toLowerCase() === "retry-after")?.[1];
227
228
  return parseRetryAfter(Array.isArray(value) ? value[0] ?? "" : value ?? "") || 0;
228
229
  }
230
+ function decodeProviderJSON(body) {
231
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(body), (_key, value, context) => {
232
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) return Object.fromEntries(Object.entries(value).map(([key, field]) => [key.toLowerCase(), field]));
233
+ if (typeof value !== "number") return value;
234
+ const raw = context?.source ?? "";
235
+ if (raw.length > 20 || !/^-?\d+$/.test(raw)) return NaN;
236
+ if (Number.isSafeInteger(value)) return value;
237
+ const integer = BigInt(raw);
238
+ return integer >= -(1n << 63n) && integer < 1n << 63n ? value : NaN;
239
+ });
240
+ }
229
241
 
230
242
  // src/project.ts
231
243
  function newProjectConnection2(project, connectionName, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-bmob",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Bmob connector for Dex TypeScript applications",
5
5
  "repository": {
6
6
  "type": "git",