nexabase-console 2.0.0 → 2.0.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.
- package/dist/firestore/Query.js +14 -10
- package/dist/firestore/batch.js +4 -0
- package/dist/firestore/writes.js +10 -0
- package/package.json +1 -1
package/dist/firestore/Query.js
CHANGED
|
@@ -120,11 +120,13 @@ const getDocs = async (queryOrCollection) => {
|
|
|
120
120
|
for (const d of docs) {
|
|
121
121
|
await db._setCache(`${collectionPath}/${d.id}`, d.fields);
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
if (constraints.length === 0) {
|
|
124
|
+
for (const cachePath of Object.keys(db._firestoreCache)) {
|
|
125
|
+
if (cachePath.startsWith(collectionPath + '/')) {
|
|
126
|
+
const docId = cachePath.split('/').pop();
|
|
127
|
+
if (docId && !serverIds.has(docId)) {
|
|
128
|
+
await db._deleteCache(cachePath);
|
|
129
|
+
}
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
}
|
|
@@ -141,11 +143,13 @@ const getDocs = async (queryOrCollection) => {
|
|
|
141
143
|
for (const d of docs) {
|
|
142
144
|
await db._setCache(`${collectionPath}/${d.id}`, d.fields);
|
|
143
145
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
if (constraints.length === 0) {
|
|
147
|
+
for (const cachePath of Object.keys(db._firestoreCache)) {
|
|
148
|
+
if (cachePath.startsWith(collectionPath + '/')) {
|
|
149
|
+
const docId = cachePath.split('/').pop();
|
|
150
|
+
if (docId && !serverIds.has(docId)) {
|
|
151
|
+
await db._deleteCache(cachePath);
|
|
152
|
+
}
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
155
|
}
|
package/dist/firestore/batch.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.writeBatch = void 0;
|
|
4
4
|
const helpers_1 = require("../utils/helpers");
|
|
5
|
+
const NexaError_1 = require("../errors/NexaError");
|
|
5
6
|
const writeBatch = (db) => {
|
|
6
7
|
const operations = [];
|
|
7
8
|
const batchObj = {
|
|
@@ -59,6 +60,9 @@ const writeBatch = (db) => {
|
|
|
59
60
|
return (await db.client.post(`/api/firestore/${db.projectId}/batch`, { operations, idempotencyKey }, { headers: { 'X-Idempotency-Key': idempotencyKey } })).data;
|
|
60
61
|
}
|
|
61
62
|
catch (error) {
|
|
63
|
+
if (error && error.response && error.response.status >= 400 && error.response.status < 500) {
|
|
64
|
+
throw (0, NexaError_1.toNexaError)(error);
|
|
65
|
+
}
|
|
62
66
|
for (const op of operations) {
|
|
63
67
|
await db._addOfflineJob({
|
|
64
68
|
id: Math.random().toString(36).substring(2, 9),
|
package/dist/firestore/writes.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteDoc = exports.updateDoc = exports.patchDoc = exports.setDoc = exports.FieldValue = void 0;
|
|
4
4
|
const helpers_1 = require("../utils/helpers");
|
|
5
|
+
const NexaError_1 = require("../errors/NexaError");
|
|
5
6
|
var FieldValue_1 = require("./FieldValue");
|
|
6
7
|
Object.defineProperty(exports, "FieldValue", { enumerable: true, get: function () { return FieldValue_1.FieldValue; } });
|
|
7
8
|
const setDoc = async (docRef, data, options) => {
|
|
@@ -35,6 +36,9 @@ const setDoc = async (docRef, data, options) => {
|
|
|
35
36
|
return res;
|
|
36
37
|
}
|
|
37
38
|
catch (error) {
|
|
39
|
+
if (error && error.response && error.response.status >= 400 && error.response.status < 500) {
|
|
40
|
+
throw (0, NexaError_1.toNexaError)(error);
|
|
41
|
+
}
|
|
38
42
|
await db._addOfflineJob({
|
|
39
43
|
id: jobId,
|
|
40
44
|
type: 'set',
|
|
@@ -82,6 +86,9 @@ const patchDoc = async (docRef, data, options) => {
|
|
|
82
86
|
return res;
|
|
83
87
|
}
|
|
84
88
|
catch (error) {
|
|
89
|
+
if (error && error.response && error.response.status >= 400 && error.response.status < 500) {
|
|
90
|
+
throw (0, NexaError_1.toNexaError)(error);
|
|
91
|
+
}
|
|
85
92
|
await db._addOfflineJob({
|
|
86
93
|
id: jobId,
|
|
87
94
|
type: 'patch',
|
|
@@ -129,6 +136,9 @@ const deleteDoc = async (docRef, options) => {
|
|
|
129
136
|
return res;
|
|
130
137
|
}
|
|
131
138
|
catch (error) {
|
|
139
|
+
if (error && error.response && error.response.status >= 400 && error.response.status < 500) {
|
|
140
|
+
throw (0, NexaError_1.toNexaError)(error);
|
|
141
|
+
}
|
|
132
142
|
await db._addOfflineJob({
|
|
133
143
|
id: jobId,
|
|
134
144
|
type: 'delete',
|
package/package.json
CHANGED