@bluecopa/core 0.1.63 → 0.1.65
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.es.js +4 -27
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -12465,9 +12465,7 @@ class DocRefImpl {
|
|
|
12465
12465
|
return doc ? doc.toJSON() : null;
|
|
12466
12466
|
}
|
|
12467
12467
|
async update(data) {
|
|
12468
|
-
console.log("doxxxxx 12344");
|
|
12469
12468
|
const doc = await this.collection.findOne(this.id).exec();
|
|
12470
|
-
console.log("doxxxxx", doc);
|
|
12471
12469
|
if (!doc) {
|
|
12472
12470
|
throw new InputTableError(`Document "${this.id}" not found`, 404);
|
|
12473
12471
|
}
|
|
@@ -12475,7 +12473,6 @@ class DocRefImpl {
|
|
|
12475
12473
|
delete patch[this.primaryKeyField];
|
|
12476
12474
|
delete patch[CHECKPOINT_FIELD];
|
|
12477
12475
|
await doc.patch(patch);
|
|
12478
|
-
await doc.upsert(patch);
|
|
12479
12476
|
}
|
|
12480
12477
|
async delete() {
|
|
12481
12478
|
await apiClient.request({
|
|
@@ -12908,40 +12905,23 @@ function createReplication(collection, solutionId, tableName, primaryKeyField) {
|
|
|
12908
12905
|
async handler(changeRows) {
|
|
12909
12906
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
12910
12907
|
const conflicts = [];
|
|
12911
|
-
console.log(changeRows, "chnageRows");
|
|
12912
12908
|
for (const row of changeRows) {
|
|
12913
12909
|
const doc = row.newDocumentState;
|
|
12914
12910
|
try {
|
|
12915
|
-
debugger;
|
|
12916
|
-
let serverResponse;
|
|
12917
12911
|
if (row.assumedMasterState == null) {
|
|
12918
12912
|
const insertData = { ...doc };
|
|
12919
12913
|
delete insertData[CHECKPOINT_FIELD];
|
|
12920
12914
|
delete insertData._deleted;
|
|
12921
|
-
|
|
12922
|
-
headers: { Prefer: "return=representation" }
|
|
12923
|
-
});
|
|
12915
|
+
await apiClient.post(`/input-table-v2/${solutionId}/rows/${tableName}`, insertData);
|
|
12924
12916
|
} else {
|
|
12925
12917
|
const updateData = { ...doc };
|
|
12926
12918
|
delete updateData[primaryKeyField];
|
|
12927
12919
|
delete updateData[CHECKPOINT_FIELD];
|
|
12928
12920
|
delete updateData._deleted;
|
|
12929
|
-
|
|
12930
|
-
params: { [primaryKeyField]: `eq.${doc[primaryKeyField]}` }
|
|
12931
|
-
headers: { Prefer: "return=representation" }
|
|
12921
|
+
await apiClient.patch(`/input-table-v2/${solutionId}/rows/${tableName}`, updateData, {
|
|
12922
|
+
params: { [primaryKeyField]: `eq.${doc[primaryKeyField]}` }
|
|
12932
12923
|
});
|
|
12933
12924
|
}
|
|
12934
|
-
const serverRow = Array.isArray(serverResponse == null ? void 0 : serverResponse.data) ? serverResponse.data[0] : serverResponse == null ? void 0 : serverResponse.data;
|
|
12935
|
-
if (serverRow) {
|
|
12936
|
-
const cleaned = stripNullsAndCoercePk(serverRow, primaryKeyField);
|
|
12937
|
-
const localDoc = await collection.findOne(String(cleaned[primaryKeyField])).exec();
|
|
12938
|
-
if (localDoc) {
|
|
12939
|
-
const patch = { ...cleaned };
|
|
12940
|
-
delete patch[primaryKeyField];
|
|
12941
|
-
delete patch._deleted;
|
|
12942
|
-
await localDoc.patch(patch);
|
|
12943
|
-
}
|
|
12944
|
-
}
|
|
12945
12925
|
} catch (err) {
|
|
12946
12926
|
const status = (_a = err == null ? void 0 : err.response) == null ? void 0 : _a.status;
|
|
12947
12927
|
const pgCode = ((_c = (_b = err == null ? void 0 : err.response) == null ? void 0 : _b.data) == null ? void 0 : _c.code) ?? ((_f = (_e = (_d = err == null ? void 0 : err.response) == null ? void 0 : _d.data) == null ? void 0 : _e.data) == null ? void 0 : _f.code);
|
|
@@ -13066,10 +13046,7 @@ async function createCollectionInternal(key, solutionId, tableDef, workspaceId,
|
|
|
13066
13046
|
const collectionConfig = {
|
|
13067
13047
|
schema,
|
|
13068
13048
|
conflictHandler: {
|
|
13069
|
-
isEqual: (a, b) =>
|
|
13070
|
-
console.log("kywfvyiubwe", { CHECKPOINT_FIELD, a, b });
|
|
13071
|
-
return a[CHECKPOINT_FIELD] === b[CHECKPOINT_FIELD];
|
|
13072
|
-
},
|
|
13049
|
+
isEqual: (a, b) => JSON.stringify(a) === JSON.stringify(b),
|
|
13073
13050
|
resolve: (i) => i.realMasterState
|
|
13074
13051
|
// server wins
|
|
13075
13052
|
}
|