dexie-cloud-sdk 0.1.1 → 0.1.2
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.js +14 -2
- package/dist/index.mjs +14 -2
- package/package.json +16 -17
package/dist/index.js
CHANGED
|
@@ -663,6 +663,12 @@ function isInlineBlob(val) {
|
|
|
663
663
|
function isBlobRef(val) {
|
|
664
664
|
return val !== null && typeof val === "object" && typeof val._bt === "string" && typeof val.ref === "string" && val.v === void 0;
|
|
665
665
|
}
|
|
666
|
+
function _containsBlobRef(val) {
|
|
667
|
+
if (val === null || typeof val !== "object") return false;
|
|
668
|
+
if (isBlobRef(val)) return true;
|
|
669
|
+
if (Array.isArray(val)) return val.some(_containsBlobRef);
|
|
670
|
+
return Object.values(val).some(_containsBlobRef);
|
|
671
|
+
}
|
|
666
672
|
function base64ToUint8Array(b64) {
|
|
667
673
|
if (typeof Buffer !== "undefined") {
|
|
668
674
|
return new Uint8Array(Buffer.from(b64, "base64"));
|
|
@@ -759,7 +765,11 @@ var BlobManager = class {
|
|
|
759
765
|
*/
|
|
760
766
|
async processForUpload(obj, token) {
|
|
761
767
|
if (this.mode !== "auto") return obj;
|
|
762
|
-
|
|
768
|
+
const result = await this._walkForUpload(obj, token);
|
|
769
|
+
if (result !== obj && result !== null && typeof result === "object" && !Array.isArray(result) && _containsBlobRef(result)) {
|
|
770
|
+
result._hasBlobRefs = 1;
|
|
771
|
+
}
|
|
772
|
+
return result;
|
|
763
773
|
}
|
|
764
774
|
/**
|
|
765
775
|
* Process an object after reading: find BlobRefs, download them,
|
|
@@ -795,7 +805,9 @@ var BlobManager = class {
|
|
|
795
805
|
}
|
|
796
806
|
if (val !== null && typeof val === "object") {
|
|
797
807
|
const entries = await Promise.all(
|
|
798
|
-
Object.entries(val).map(
|
|
808
|
+
Object.entries(val).map(
|
|
809
|
+
async ([k, v]) => [k, await this._walkForUpload(v, token)]
|
|
810
|
+
)
|
|
799
811
|
);
|
|
800
812
|
return Object.fromEntries(entries);
|
|
801
813
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -615,6 +615,12 @@ function isInlineBlob(val) {
|
|
|
615
615
|
function isBlobRef(val) {
|
|
616
616
|
return val !== null && typeof val === "object" && typeof val._bt === "string" && typeof val.ref === "string" && val.v === void 0;
|
|
617
617
|
}
|
|
618
|
+
function _containsBlobRef(val) {
|
|
619
|
+
if (val === null || typeof val !== "object") return false;
|
|
620
|
+
if (isBlobRef(val)) return true;
|
|
621
|
+
if (Array.isArray(val)) return val.some(_containsBlobRef);
|
|
622
|
+
return Object.values(val).some(_containsBlobRef);
|
|
623
|
+
}
|
|
618
624
|
function base64ToUint8Array(b64) {
|
|
619
625
|
if (typeof Buffer !== "undefined") {
|
|
620
626
|
return new Uint8Array(Buffer.from(b64, "base64"));
|
|
@@ -711,7 +717,11 @@ var BlobManager = class {
|
|
|
711
717
|
*/
|
|
712
718
|
async processForUpload(obj, token) {
|
|
713
719
|
if (this.mode !== "auto") return obj;
|
|
714
|
-
|
|
720
|
+
const result = await this._walkForUpload(obj, token);
|
|
721
|
+
if (result !== obj && result !== null && typeof result === "object" && !Array.isArray(result) && _containsBlobRef(result)) {
|
|
722
|
+
result._hasBlobRefs = 1;
|
|
723
|
+
}
|
|
724
|
+
return result;
|
|
715
725
|
}
|
|
716
726
|
/**
|
|
717
727
|
* Process an object after reading: find BlobRefs, download them,
|
|
@@ -747,7 +757,9 @@ var BlobManager = class {
|
|
|
747
757
|
}
|
|
748
758
|
if (val !== null && typeof val === "object") {
|
|
749
759
|
const entries = await Promise.all(
|
|
750
|
-
Object.entries(val).map(
|
|
760
|
+
Object.entries(val).map(
|
|
761
|
+
async ([k, v]) => [k, await this._walkForUpload(v, token)]
|
|
762
|
+
)
|
|
751
763
|
);
|
|
752
764
|
return Object.fromEntries(entries);
|
|
753
765
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dexie-cloud-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Official JavaScript SDK for Dexie Cloud - Local-first database with sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -17,21 +17,6 @@
|
|
|
17
17
|
"README.md",
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --clean --external node-fetch",
|
|
22
|
-
"build:watch": "npm run build -- --watch",
|
|
23
|
-
"test": "vitest run",
|
|
24
|
-
"test:watch": "vitest",
|
|
25
|
-
"test:ui": "vitest --ui",
|
|
26
|
-
"test:coverage": "vitest run --coverage",
|
|
27
|
-
"lint": "eslint src --ext .ts,.js",
|
|
28
|
-
"lint:fix": "eslint src --ext .ts,.js --fix",
|
|
29
|
-
"typecheck": "tsc --noEmit",
|
|
30
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --external node-fetch",
|
|
31
|
-
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
32
|
-
"test:e2e:docker": "docker compose -f docker-compose.test.yml up -d && pnpm run test:e2e; docker compose -f docker-compose.test.yml down -v",
|
|
33
|
-
"prepublishOnly": "npm run build && npm run test && npm run lint"
|
|
34
|
-
},
|
|
35
20
|
"keywords": [
|
|
36
21
|
"dexie",
|
|
37
22
|
"dexie-cloud",
|
|
@@ -75,5 +60,19 @@
|
|
|
75
60
|
"optionalDependencies": {
|
|
76
61
|
"@types/node-fetch": "^2.6.13",
|
|
77
62
|
"node-fetch": "^3.3.2"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean --external node-fetch",
|
|
66
|
+
"build:watch": "npm run build -- --watch",
|
|
67
|
+
"test": "vitest run",
|
|
68
|
+
"test:watch": "vitest",
|
|
69
|
+
"test:ui": "vitest --ui",
|
|
70
|
+
"test:coverage": "vitest run --coverage",
|
|
71
|
+
"lint": "eslint src --ext .ts,.js",
|
|
72
|
+
"lint:fix": "eslint src --ext .ts,.js --fix",
|
|
73
|
+
"typecheck": "tsc --noEmit",
|
|
74
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --external node-fetch",
|
|
75
|
+
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
76
|
+
"test:e2e:docker": "docker compose -f docker-compose.test.yml up -d && pnpm run test:e2e; docker compose -f docker-compose.test.yml down -v"
|
|
78
77
|
}
|
|
79
|
-
}
|
|
78
|
+
}
|