supastash 0.2.7 → 0.2.8

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.
@@ -1,3 +1,3 @@
1
1
  export declare function stringifyComplexFields(record: any): any;
2
- export declare function stringifyValue(value: any): any;
2
+ export declare function stringifyValue(value: unknown): any;
3
3
  //# sourceMappingURL=stringifyFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stringifyFields.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/sync/pullFromRemote/stringifyFields.ts"],"names":[],"mappings":"AAIA,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,GAAG,OAcjD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,OAMxC"}
1
+ {"version":3,"file":"stringifyFields.d.ts","sourceRoot":"","sources":["../../../../../src/shared/utils/sync/pullFromRemote/stringifyFields.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,GAAG,OAMjD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAsBlD"}
@@ -1,26 +1,25 @@
1
- import { getSupastashConfig } from "../../../core/config";
2
- let isNitro = null;
3
1
  export function stringifyComplexFields(record) {
4
- if (isNitro === null) {
5
- isNitro = getSupastashConfig().sqliteClientType === "rn-nitro";
6
- }
7
2
  const result = {};
8
3
  for (const key in record) {
9
- const value = record[key];
10
- if (typeof value === "object" && value !== null) {
11
- result[key] = JSON.stringify(value);
12
- }
13
- else {
14
- result[key] = value;
15
- }
4
+ result[key] = stringifyValue(record[key]);
16
5
  }
17
6
  return result;
18
7
  }
19
8
  export function stringifyValue(value) {
20
- if (typeof value === "object" && value !== null) {
21
- return JSON.stringify(value);
9
+ if (value == null || value === undefined) {
10
+ return null;
11
+ }
12
+ if (typeof value === "number") {
13
+ return Number.isFinite(value) ? value : null;
22
14
  }
23
- else {
15
+ if (typeof value === "string" || typeof value === "boolean") {
24
16
  return value;
25
17
  }
18
+ if (value instanceof Date) {
19
+ return value.toISOString();
20
+ }
21
+ if (typeof value === "object") {
22
+ return JSON.stringify(value);
23
+ }
24
+ return null;
26
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supastash",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "repository": {
73
73
  "type": "git",
74
- "url": "https://github.com/0xZekeA/supastash"
74
+ "url": "git+https://github.com/0xZekeA/supastash.git"
75
75
  },
76
76
  "author": "Ezekiel Akpan",
77
77
  "license": "MIT",