@oddington/sdk 0.1.10 → 0.1.11
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/browser.js +58 -57
- package/dist/index.js +71 -72
- package/dist/types/packages/sdk/src/public.d.ts +1 -1
- package/dist/types/shared/data-contract.d.ts +22 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -726,22 +726,41 @@ function historyProperties(value) {
|
|
|
726
726
|
let descriptors = Object.getOwnPropertyDescriptors(value);
|
|
727
727
|
return Reflect.ownKeys(value).some((key) => typeof key != "string" || !descriptors[key]?.enumerable || !Object.hasOwn(descriptors[key], "value")) ? invalid() : descriptors;
|
|
728
728
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
if (
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
729
|
+
var historyCollection = (value) => typeof value == "string" && value.length <= 512 && /^[_a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(value), historyCursor = (value) => typeof value == "string" && value.length <= 128 * 1024 && /^history-cursor-v1\.[A-Za-z0-9_-]{1,64}\.[A-Za-z0-9_-]{16}\.[A-Za-z0-9_-]+$/.test(value);
|
|
730
|
+
function historyArray(value) {
|
|
731
|
+
if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype) return invalid();
|
|
732
|
+
let descriptors = Object.getOwnPropertyDescriptors(value);
|
|
733
|
+
if (Reflect.ownKeys(value).length !== value.length + 1) return invalid();
|
|
734
|
+
let result2 = [];
|
|
735
|
+
for (let i = 0; i < value.length; i++) {
|
|
736
|
+
let descriptor2 = descriptors[i];
|
|
737
|
+
if (!descriptor2?.enumerable || !Object.hasOwn(descriptor2, "value")) return invalid();
|
|
738
|
+
result2.push(descriptor2.value);
|
|
737
739
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
740
|
+
return result2;
|
|
741
|
+
}
|
|
742
|
+
function captureOptions(value, changes) {
|
|
743
|
+
if (value === void 0) return {};
|
|
744
|
+
let descriptors = historyProperties(value), result2 = {}, allowed = changes ? ["collections", "refs", "from", "through", "limit", "after"] : ["limit", "before"];
|
|
745
|
+
if (Object.keys(descriptors).some((key) => !allowed.includes(key))) return invalid();
|
|
746
|
+
for (let key of allowed) {
|
|
747
|
+
if (!Object.hasOwn(descriptors, key)) continue;
|
|
748
|
+
let scalar = descriptors[key].value;
|
|
749
|
+
if (key === "collections" || key === "refs") {
|
|
750
|
+
let values = historyArray(scalar);
|
|
751
|
+
if (!values.length || values.length > (key === "collections" ? 16 : 100) || !values.every(key === "collections" ? historyCollection : validRecordRef) || new Set(values).size !== values.length) return invalid();
|
|
752
|
+
result2[key] = values;
|
|
753
|
+
} else if (key === "limit") {
|
|
754
|
+
if (!Number.isInteger(scalar) || scalar < 1 || scalar > (changes ? 500 : 100)) return invalid();
|
|
755
|
+
result2.limit = scalar;
|
|
756
|
+
} else {
|
|
757
|
+
if (!(key === "after" ? historyCursor(scalar) : historyVersion(scalar))) return invalid();
|
|
758
|
+
result2[key] = scalar;
|
|
759
|
+
}
|
|
742
760
|
}
|
|
743
761
|
return result2;
|
|
744
762
|
}
|
|
763
|
+
var captureHistoryListOptions = (value) => captureOptions(value, !1), captureHistoryChangesOptions = (value) => captureOptions(value, !0);
|
|
745
764
|
function captureHistoryInstant(value) {
|
|
746
765
|
if (!historyText(value) || value.length > 1024) return invalid();
|
|
747
766
|
let match = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?([Zz]|([+-])(\d{2}):(\d{2}))$/.exec(value);
|
|
@@ -785,7 +804,11 @@ var DATA_REQUEST_LIMIT = 256 * 1024, invalidChange = () => {
|
|
|
785
804
|
throw new DataOperationError("invalid_change", !1, "unapplied");
|
|
786
805
|
};
|
|
787
806
|
function mapping(value) {
|
|
788
|
-
|
|
807
|
+
try {
|
|
808
|
+
return historyProperties(value), value;
|
|
809
|
+
} catch {
|
|
810
|
+
return invalidChange();
|
|
811
|
+
}
|
|
789
812
|
}
|
|
790
813
|
function captureValue(value, ancestors = /* @__PURE__ */ new Set(), depth = 0) {
|
|
791
814
|
if (value === null || typeof value == "string" || typeof value == "boolean" || typeof value == "number" && Number.isFinite(value)) return value;
|
|
@@ -805,13 +828,18 @@ function captureDataUpdate(record2, set) {
|
|
|
805
828
|
let identity = captureDataDelete(record2), fields3 = mapping(set);
|
|
806
829
|
return !Object.keys(fields3).length || Object.keys(fields3).some((key) => key.startsWith("$") || ["id", "type"].includes(key)) ? invalidChange() : { ...identity, set: captureValue(fields3) };
|
|
807
830
|
}
|
|
808
|
-
function
|
|
831
|
+
function captureIdentities(value, update, allowEmpty = !0) {
|
|
809
832
|
if (!Array.isArray(value) || !allowEmpty && !value.length || value.length > 1e4) return invalidChange();
|
|
810
|
-
let
|
|
833
|
+
let captured = value.map((item) => {
|
|
811
834
|
let row = mapping(item);
|
|
812
|
-
|
|
835
|
+
if (Object.keys(row).sort().join(",") !== (update ? "expectedVersion,ref,set" : "expectedVersion,ref")) return invalidChange();
|
|
836
|
+
let identity = { $ref: row.ref, $version: row.expectedVersion };
|
|
837
|
+
return update ? captureDataUpdate(identity, row.set) : captureDataDelete(identity);
|
|
813
838
|
});
|
|
814
|
-
return new Set(
|
|
839
|
+
return new Set(captured.map((item) => item.ref)).size !== captured.length ? invalidChange() : captured;
|
|
840
|
+
}
|
|
841
|
+
function captureDataUpdates(value, allowEmpty = !1) {
|
|
842
|
+
return captureIdentities(value, !0, allowEmpty);
|
|
815
843
|
}
|
|
816
844
|
function captureDataCreate(value) {
|
|
817
845
|
let row = mapping(value);
|
|
@@ -834,12 +862,7 @@ function captureDataChanges(updatesValue, createsValue = [], deletesValue = [])
|
|
|
834
862
|
if (Object.keys(row).some((key) => !["ref", "fields", "filing"].includes(key)) || !Object.hasOwn(row, "ref") || !Object.hasOwn(row, "fields")) return invalidChange();
|
|
835
863
|
let fields3 = mapping(row.fields);
|
|
836
864
|
return Object.keys(fields3).some((key) => key.startsWith("$")) ? invalidChange() : captureDataCreate({ ...fields3, $ref: row.ref, ...Object.hasOwn(row, "filing") ? { $filing: row.filing } : {} });
|
|
837
|
-
});
|
|
838
|
-
if (!Array.isArray(deletesValue) || deletesValue.length > 1e4) return invalidChange();
|
|
839
|
-
let deletes = deletesValue.map((item) => {
|
|
840
|
-
let row = mapping(item);
|
|
841
|
-
return Object.keys(row).sort().join(",") !== "expectedVersion,ref" ? invalidChange() : captureDataDelete({ $ref: row.ref, $version: row.expectedVersion });
|
|
842
|
-
}), refs = [...updates, ...creates, ...deletes].map((item) => item.ref);
|
|
865
|
+
}), deletes = captureIdentities(deletesValue, !1), refs = [...updates, ...creates, ...deletes].map((item) => item.ref);
|
|
843
866
|
return !refs.length || refs.length > 1e4 || new Set(refs).size !== refs.length ? invalidChange() : { updates, creates, deletes };
|
|
844
867
|
}
|
|
845
868
|
function checkDataRequestSize(input) {
|
|
@@ -1053,15 +1076,14 @@ var data = {
|
|
|
1053
1076
|
},
|
|
1054
1077
|
history: {
|
|
1055
1078
|
list: async (options) => send2({ operation: "history.list", options: captureHistoryListOptions(options) }),
|
|
1056
|
-
at: async (instant) => send2({ operation: "history.at", instant: captureHistoryInstant(instant) })
|
|
1079
|
+
at: async (instant) => send2({ operation: "history.at", instant: captureHistoryInstant(instant) }),
|
|
1080
|
+
changes: async (options) => send2({ operation: "history.changes", options: captureHistoryChangesOptions(options) })
|
|
1057
1081
|
},
|
|
1058
1082
|
changes() {
|
|
1059
|
-
let updates = [], creates = [], deletes = [], publicationId, pending, confirmed,
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
...captured.deletes.length ? { deletes: captured.deletes } : {}
|
|
1064
|
-
};
|
|
1083
|
+
let updates = [], creates = [], deletes = [], publicationId, pending, confirmed, assertMutable = () => {
|
|
1084
|
+
if (publicationId) throw new DataOperationError("invalid_change", !1, "unapplied");
|
|
1085
|
+
}, snapshot = (nextUpdates = updates, nextCreates = creates, nextDeletes = deletes) => {
|
|
1086
|
+
let { updates: updates2, creates: creates2, deletes: deletes2 } = captureDataChanges(nextUpdates, nextCreates, nextDeletes), input = { updates: updates2, ...creates2.length ? { creates: creates2 } : {}, ...deletes2.length ? { deletes: deletes2 } : {} };
|
|
1065
1087
|
return checkDataRequestSize({
|
|
1066
1088
|
repository,
|
|
1067
1089
|
operation: "changes.publish",
|
|
@@ -1071,40 +1093,19 @@ var data = {
|
|
|
1071
1093
|
};
|
|
1072
1094
|
return {
|
|
1073
1095
|
create(record2) {
|
|
1074
|
-
|
|
1096
|
+
assertMutable();
|
|
1075
1097
|
let next = [...creates, captureDataCreate(record2)];
|
|
1076
|
-
|
|
1077
|
-
repository,
|
|
1078
|
-
operation: "changes.publish",
|
|
1079
|
-
updates,
|
|
1080
|
-
creates: next,
|
|
1081
|
-
...deletes.length ? { deletes } : {},
|
|
1082
|
-
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
1083
|
-
}), creates = next;
|
|
1098
|
+
snapshot(updates, next, deletes), creates = next;
|
|
1084
1099
|
},
|
|
1085
1100
|
update(record2, set) {
|
|
1086
|
-
|
|
1101
|
+
assertMutable();
|
|
1087
1102
|
let next = [...updates, captureDataUpdate(record2, set)];
|
|
1088
|
-
|
|
1089
|
-
repository,
|
|
1090
|
-
operation: "changes.publish",
|
|
1091
|
-
updates: next,
|
|
1092
|
-
...creates.length ? { creates } : {},
|
|
1093
|
-
...deletes.length ? { deletes } : {},
|
|
1094
|
-
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
1095
|
-
}), updates = next;
|
|
1103
|
+
snapshot(next, creates, deletes), updates = next;
|
|
1096
1104
|
},
|
|
1097
1105
|
delete(record2) {
|
|
1098
|
-
|
|
1106
|
+
assertMutable();
|
|
1099
1107
|
let next = [...deletes, captureDataDelete(record2)];
|
|
1100
|
-
|
|
1101
|
-
repository,
|
|
1102
|
-
operation: "changes.publish",
|
|
1103
|
-
updates,
|
|
1104
|
-
deletes: next,
|
|
1105
|
-
...creates.length ? { creates } : {},
|
|
1106
|
-
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
1107
|
-
}), deletes = next;
|
|
1108
|
+
snapshot(updates, creates, next), deletes = next;
|
|
1108
1109
|
},
|
|
1109
1110
|
async validate() {
|
|
1110
1111
|
await send2({ operation: "changes.validate", ...snapshot() });
|
package/dist/index.js
CHANGED
|
@@ -21725,26 +21725,53 @@ function historyProperties(value) {
|
|
|
21725
21725
|
return invalid();
|
|
21726
21726
|
return descriptors;
|
|
21727
21727
|
}
|
|
21728
|
-
|
|
21728
|
+
var historyCollection = (value) => typeof value === "string" && value.length <= 512 && /^[_a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(value);
|
|
21729
|
+
var historyCursor = (value) => typeof value === "string" && value.length <= 128 * 1024 && /^history-cursor-v1\.[A-Za-z0-9_-]{1,64}\.[A-Za-z0-9_-]{16}\.[A-Za-z0-9_-]+$/.test(value);
|
|
21730
|
+
function historyArray(value) {
|
|
21731
|
+
if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype)
|
|
21732
|
+
return invalid();
|
|
21733
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
21734
|
+
if (Reflect.ownKeys(value).length !== value.length + 1)
|
|
21735
|
+
return invalid();
|
|
21736
|
+
const result = [];
|
|
21737
|
+
for (let i = 0;i < value.length; i++) {
|
|
21738
|
+
const descriptor = descriptors[i];
|
|
21739
|
+
if (!descriptor?.enumerable || !Object.hasOwn(descriptor, "value"))
|
|
21740
|
+
return invalid();
|
|
21741
|
+
result.push(descriptor.value);
|
|
21742
|
+
}
|
|
21743
|
+
return result;
|
|
21744
|
+
}
|
|
21745
|
+
function captureOptions(value, changes) {
|
|
21729
21746
|
if (value === undefined)
|
|
21730
21747
|
return {};
|
|
21731
21748
|
const descriptors = historyProperties(value), result = {};
|
|
21732
|
-
|
|
21749
|
+
const allowed = changes ? ["collections", "refs", "from", "through", "limit", "after"] : ["limit", "before"];
|
|
21750
|
+
if (Object.keys(descriptors).some((key) => !allowed.includes(key)))
|
|
21733
21751
|
return invalid();
|
|
21734
|
-
|
|
21735
|
-
|
|
21736
|
-
|
|
21737
|
-
|
|
21738
|
-
|
|
21739
|
-
|
|
21740
|
-
|
|
21741
|
-
|
|
21742
|
-
|
|
21743
|
-
|
|
21744
|
-
|
|
21752
|
+
for (const key of allowed) {
|
|
21753
|
+
if (!Object.hasOwn(descriptors, key))
|
|
21754
|
+
continue;
|
|
21755
|
+
const scalar = descriptors[key].value;
|
|
21756
|
+
if (key === "collections" || key === "refs") {
|
|
21757
|
+
const values = historyArray(scalar);
|
|
21758
|
+
if (!values.length || values.length > (key === "collections" ? 16 : 100) || !values.every(key === "collections" ? historyCollection : validRecordRef) || new Set(values).size !== values.length)
|
|
21759
|
+
return invalid();
|
|
21760
|
+
result[key] = values;
|
|
21761
|
+
} else if (key === "limit") {
|
|
21762
|
+
if (!Number.isInteger(scalar) || scalar < 1 || scalar > (changes ? 500 : 100))
|
|
21763
|
+
return invalid();
|
|
21764
|
+
result.limit = scalar;
|
|
21765
|
+
} else {
|
|
21766
|
+
if (!(key === "after" ? historyCursor(scalar) : historyVersion(scalar)))
|
|
21767
|
+
return invalid();
|
|
21768
|
+
result[key] = scalar;
|
|
21769
|
+
}
|
|
21745
21770
|
}
|
|
21746
21771
|
return result;
|
|
21747
21772
|
}
|
|
21773
|
+
var captureHistoryListOptions = (value) => captureOptions(value, false);
|
|
21774
|
+
var captureHistoryChangesOptions = (value) => captureOptions(value, true);
|
|
21748
21775
|
function captureHistoryInstant(value) {
|
|
21749
21776
|
if (!historyText(value) || value.length > 1024)
|
|
21750
21777
|
return invalid();
|
|
@@ -21805,11 +21832,12 @@ var invalidChange = () => {
|
|
|
21805
21832
|
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
21806
21833
|
};
|
|
21807
21834
|
function mapping(value) {
|
|
21808
|
-
|
|
21809
|
-
|
|
21810
|
-
|
|
21835
|
+
try {
|
|
21836
|
+
historyProperties(value);
|
|
21837
|
+
return value;
|
|
21838
|
+
} catch {
|
|
21811
21839
|
return invalidChange();
|
|
21812
|
-
|
|
21840
|
+
}
|
|
21813
21841
|
}
|
|
21814
21842
|
function captureValue(value, ancestors = new Set, depth = 0) {
|
|
21815
21843
|
if (value === null || typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value))
|
|
@@ -21844,18 +21872,22 @@ function captureDataUpdate(record2, set) {
|
|
|
21844
21872
|
return invalidChange();
|
|
21845
21873
|
return { ...identity, set: captureValue(fields3) };
|
|
21846
21874
|
}
|
|
21847
|
-
function
|
|
21875
|
+
function captureIdentities(value, update, allowEmpty = true) {
|
|
21848
21876
|
if (!Array.isArray(value) || !allowEmpty && !value.length || value.length > 1e4)
|
|
21849
21877
|
return invalidChange();
|
|
21850
|
-
const
|
|
21878
|
+
const captured = value.map((item) => {
|
|
21851
21879
|
const row = mapping(item);
|
|
21852
|
-
if (Object.keys(row).sort().join(",") !== "expectedVersion,ref,set")
|
|
21880
|
+
if (Object.keys(row).sort().join(",") !== (update ? "expectedVersion,ref,set" : "expectedVersion,ref"))
|
|
21853
21881
|
return invalidChange();
|
|
21854
|
-
|
|
21882
|
+
const identity = { $ref: row.ref, $version: row.expectedVersion };
|
|
21883
|
+
return update ? captureDataUpdate(identity, row.set) : captureDataDelete(identity);
|
|
21855
21884
|
});
|
|
21856
|
-
if (new Set(
|
|
21885
|
+
if (new Set(captured.map((item) => item.ref)).size !== captured.length)
|
|
21857
21886
|
return invalidChange();
|
|
21858
|
-
return
|
|
21887
|
+
return captured;
|
|
21888
|
+
}
|
|
21889
|
+
function captureDataUpdates(value, allowEmpty = false) {
|
|
21890
|
+
return captureIdentities(value, true, allowEmpty);
|
|
21859
21891
|
}
|
|
21860
21892
|
function captureDataCreate(value) {
|
|
21861
21893
|
const row = mapping(value);
|
|
@@ -21884,14 +21916,7 @@ function captureDataChanges(updatesValue, createsValue = [], deletesValue = [])
|
|
|
21884
21916
|
return invalidChange();
|
|
21885
21917
|
return captureDataCreate({ ...fields3, $ref: row.ref, ...Object.hasOwn(row, "filing") ? { $filing: row.filing } : {} });
|
|
21886
21918
|
});
|
|
21887
|
-
|
|
21888
|
-
return invalidChange();
|
|
21889
|
-
const deletes = deletesValue.map((item) => {
|
|
21890
|
-
const row = mapping(item);
|
|
21891
|
-
if (Object.keys(row).sort().join(",") !== "expectedVersion,ref")
|
|
21892
|
-
return invalidChange();
|
|
21893
|
-
return captureDataDelete({ $ref: row.ref, $version: row.expectedVersion });
|
|
21894
|
-
});
|
|
21919
|
+
const deletes = captureIdentities(deletesValue, false);
|
|
21895
21920
|
const refs = [...updates, ...creates, ...deletes].map((item) => item.ref);
|
|
21896
21921
|
if (!refs.length || refs.length > 1e4 || new Set(refs).size !== refs.length)
|
|
21897
21922
|
return invalidChange();
|
|
@@ -22512,18 +22537,19 @@ var data = {
|
|
|
22512
22537
|
},
|
|
22513
22538
|
history: {
|
|
22514
22539
|
list: async (options) => send({ operation: "history.list", options: captureHistoryListOptions(options) }),
|
|
22515
|
-
at: async (instant) => send({ operation: "history.at", instant: captureHistoryInstant(instant) })
|
|
22540
|
+
at: async (instant) => send({ operation: "history.at", instant: captureHistoryInstant(instant) }),
|
|
22541
|
+
changes: async (options) => send({ operation: "history.changes", options: captureHistoryChangesOptions(options) })
|
|
22516
22542
|
},
|
|
22517
22543
|
changes() {
|
|
22518
22544
|
let updates = [], creates = [], deletes = [], publicationId;
|
|
22519
22545
|
let pending, confirmed;
|
|
22520
|
-
const
|
|
22521
|
-
|
|
22522
|
-
|
|
22523
|
-
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
};
|
|
22546
|
+
const assertMutable = () => {
|
|
22547
|
+
if (publicationId)
|
|
22548
|
+
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
22549
|
+
};
|
|
22550
|
+
const snapshot = (nextUpdates = updates, nextCreates = creates, nextDeletes = deletes) => {
|
|
22551
|
+
const { updates: updates2, creates: creates2, deletes: deletes2 } = captureDataChanges(nextUpdates, nextCreates, nextDeletes);
|
|
22552
|
+
const input = { updates: updates2, ...creates2.length ? { creates: creates2 } : {}, ...deletes2.length ? { deletes: deletes2 } : {} };
|
|
22527
22553
|
checkDataRequestSize({
|
|
22528
22554
|
repository,
|
|
22529
22555
|
operation: "changes.publish",
|
|
@@ -22534,48 +22560,21 @@ var data = {
|
|
|
22534
22560
|
};
|
|
22535
22561
|
return {
|
|
22536
22562
|
create(record2) {
|
|
22537
|
-
|
|
22538
|
-
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
22563
|
+
assertMutable();
|
|
22539
22564
|
const next = [...creates, captureDataCreate(record2)];
|
|
22540
|
-
|
|
22541
|
-
checkDataRequestSize({
|
|
22542
|
-
repository,
|
|
22543
|
-
operation: "changes.publish",
|
|
22544
|
-
updates,
|
|
22545
|
-
creates: next,
|
|
22546
|
-
...deletes.length ? { deletes } : {},
|
|
22547
|
-
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
22548
|
-
});
|
|
22565
|
+
snapshot(updates, next, deletes);
|
|
22549
22566
|
creates = next;
|
|
22550
22567
|
},
|
|
22551
22568
|
update(record2, set) {
|
|
22552
|
-
|
|
22553
|
-
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
22569
|
+
assertMutable();
|
|
22554
22570
|
const next = [...updates, captureDataUpdate(record2, set)];
|
|
22555
|
-
|
|
22556
|
-
checkDataRequestSize({
|
|
22557
|
-
repository,
|
|
22558
|
-
operation: "changes.publish",
|
|
22559
|
-
updates: next,
|
|
22560
|
-
...creates.length ? { creates } : {},
|
|
22561
|
-
...deletes.length ? { deletes } : {},
|
|
22562
|
-
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
22563
|
-
});
|
|
22571
|
+
snapshot(next, creates, deletes);
|
|
22564
22572
|
updates = next;
|
|
22565
22573
|
},
|
|
22566
22574
|
delete(record2) {
|
|
22567
|
-
|
|
22568
|
-
throw new DataOperationError("invalid_change", false, "unapplied");
|
|
22575
|
+
assertMutable();
|
|
22569
22576
|
const next = [...deletes, captureDataDelete(record2)];
|
|
22570
|
-
|
|
22571
|
-
checkDataRequestSize({
|
|
22572
|
-
repository,
|
|
22573
|
-
operation: "changes.publish",
|
|
22574
|
-
updates,
|
|
22575
|
-
deletes: next,
|
|
22576
|
-
...creates.length ? { creates } : {},
|
|
22577
|
-
publicationId: "00000000-0000-4000-8000-000000000000"
|
|
22578
|
-
});
|
|
22577
|
+
snapshot(updates, creates, next);
|
|
22579
22578
|
deletes = next;
|
|
22580
22579
|
},
|
|
22581
22580
|
async validate() {
|
|
@@ -13,7 +13,7 @@ export { AirtableOperationError } from '../../../shared/airtable-contract.js';
|
|
|
13
13
|
export type { AirtableField, AirtableTable, AirtableRecord, AirtableListInput, AirtableGetInput, AirtableCreateInput, AirtableUpdateInput, AirtableDeleteInput, AirtableReceipt, AirtableWriteResult, AirtableClient, Connections } from '../../../shared/airtable-contract.js';
|
|
14
14
|
export declare const connections: import('../../../shared/airtable-contract.js').Connections;
|
|
15
15
|
export { DataOperationError } from '../../../shared/data-contract.js';
|
|
16
|
-
export type { DataRepository, DataErrorCode, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, RecordsResult, RecordsSearchOptions, RecordsSearchResult, HistoryListOptions, HistoryEntry, RecordIdentity, RecordCreation, RecordUpdateSet, DataPublication, DataChangeSet, DataEffect } from '../../../shared/data-contract.js';
|
|
16
|
+
export type { DataRepository, DataErrorCode, PublicValueDefinition, PublicField, CollectionSummary, CollectionSchema, QueryScalar, SelectionOptions, RecordSelection, RecordsQuery, DataValue, SelectedRecord, SelectionMetadata, RecordsResult, RecordsSearchOptions, RecordsSearchResult, HistoryListOptions, HistoryEntry, HistoryChangesOptions, HistoryChange, HistoryChangesResult, RecordIdentity, RecordCreation, RecordUpdateSet, DataPublication, DataChangeSet, DataEffect } from '../../../shared/data-contract.js';
|
|
17
17
|
export declare const data: {
|
|
18
18
|
repository(name: string): import('../../../shared/data-contract.js').DataRepository;
|
|
19
19
|
};
|
|
@@ -138,6 +138,14 @@ export type HistoryListOptions = {
|
|
|
138
138
|
limit?: number;
|
|
139
139
|
before?: string;
|
|
140
140
|
};
|
|
141
|
+
export type HistoryChangesOptions = {
|
|
142
|
+
collections?: string[];
|
|
143
|
+
refs?: string[];
|
|
144
|
+
from?: string;
|
|
145
|
+
through?: string;
|
|
146
|
+
limit?: number;
|
|
147
|
+
after?: string;
|
|
148
|
+
};
|
|
141
149
|
export type HistoryEntry = {
|
|
142
150
|
version: string;
|
|
143
151
|
publishedAt: string;
|
|
@@ -156,6 +164,19 @@ export type HistoryEntry = {
|
|
|
156
164
|
updated: string[];
|
|
157
165
|
deleted: string[];
|
|
158
166
|
};
|
|
167
|
+
export type HistoryChange = Omit<HistoryEntry, 'created' | 'updated' | 'deleted'> & {
|
|
168
|
+
$ref: string;
|
|
169
|
+
change: 'created' | 'updated' | 'deleted';
|
|
170
|
+
before: SelectedRecord | null;
|
|
171
|
+
after: SelectedRecord | null;
|
|
172
|
+
};
|
|
173
|
+
export type HistoryChangesResult = {
|
|
174
|
+
$meta: {
|
|
175
|
+
through: string;
|
|
176
|
+
next?: string;
|
|
177
|
+
};
|
|
178
|
+
changes: HistoryChange[];
|
|
179
|
+
};
|
|
159
180
|
export interface DataChangeSet {
|
|
160
181
|
create(record: RecordCreation): void;
|
|
161
182
|
update(record: RecordIdentity, set: RecordUpdateSet): void;
|
|
@@ -175,6 +196,7 @@ export interface DataRepository {
|
|
|
175
196
|
history: {
|
|
176
197
|
list(options?: HistoryListOptions): Promise<HistoryEntry[]>;
|
|
177
198
|
at(instant: string): Promise<HistoryEntry | null>;
|
|
199
|
+
changes(options?: HistoryChangesOptions): Promise<HistoryChangesResult>;
|
|
178
200
|
};
|
|
179
201
|
changes(): DataChangeSet;
|
|
180
202
|
}
|