entropic-bond 1.56.3 → 1.56.5
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/lib/entropic-bond.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class k {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
4
4
|
}
|
|
@@ -59,7 +59,7 @@ function H() {
|
|
|
59
59
|
}
|
|
60
60
|
return L(z);
|
|
61
61
|
}
|
|
62
|
-
const J = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
|
|
62
|
+
const J = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), T = { randomUUID: J };
|
|
63
63
|
function Z(i, e, t) {
|
|
64
64
|
i = i || {};
|
|
65
65
|
const r = i.random ?? i.rng?.() ?? H();
|
|
@@ -68,7 +68,7 @@ function Z(i, e, t) {
|
|
|
68
68
|
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Y(r);
|
|
69
69
|
}
|
|
70
70
|
function G(i, e, t) {
|
|
71
|
-
return
|
|
71
|
+
return T.randomUUID && !i ? T.randomUUID() : Z(i);
|
|
72
72
|
}
|
|
73
73
|
var K = Object.defineProperty, X = (i, e, t, r) => {
|
|
74
74
|
for (var s = void 0, n = i.length - 1, o; n >= 0; n--)
|
|
@@ -398,10 +398,10 @@ const Q = (l = class {
|
|
|
398
398
|
}
|
|
399
399
|
}, l._factoryMap = {}, l);
|
|
400
400
|
X([
|
|
401
|
-
|
|
401
|
+
j
|
|
402
402
|
], Q.prototype, "_id");
|
|
403
403
|
let d = Q;
|
|
404
|
-
function
|
|
404
|
+
function j(i, e) {
|
|
405
405
|
return _()(i, e);
|
|
406
406
|
}
|
|
407
407
|
function ce(i) {
|
|
@@ -482,7 +482,7 @@ function _e(i) {
|
|
|
482
482
|
}
|
|
483
483
|
class ye extends d {
|
|
484
484
|
constructor() {
|
|
485
|
-
super(...arguments), this._onChange = new
|
|
485
|
+
super(...arguments), this._onChange = new k();
|
|
486
486
|
}
|
|
487
487
|
/**
|
|
488
488
|
* Subscribes a listener callback function. Every time a property is changed,
|
|
@@ -945,7 +945,7 @@ class te {
|
|
|
945
945
|
return this.model;
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
|
-
const
|
|
948
|
+
const P = class P {
|
|
949
949
|
constructor() {
|
|
950
950
|
}
|
|
951
951
|
/**
|
|
@@ -961,7 +961,7 @@ const C = class C {
|
|
|
961
961
|
* @returns the data source
|
|
962
962
|
*/
|
|
963
963
|
static get dataSource() {
|
|
964
|
-
return
|
|
964
|
+
return P._dataSource;
|
|
965
965
|
}
|
|
966
966
|
/**
|
|
967
967
|
* Retrieves a model for a collection
|
|
@@ -969,8 +969,8 @@ const C = class C {
|
|
|
969
969
|
* @returns the model for the collection
|
|
970
970
|
*/
|
|
971
971
|
static getModel(e) {
|
|
972
|
-
if (!
|
|
973
|
-
return new R(
|
|
972
|
+
if (!P._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
973
|
+
return new R(P._dataSource, e);
|
|
974
974
|
}
|
|
975
975
|
/**
|
|
976
976
|
* Retrieves a model for a subcollection
|
|
@@ -979,8 +979,8 @@ const C = class C {
|
|
|
979
979
|
* @returns the model for the subcollection
|
|
980
980
|
*/
|
|
981
981
|
static getModelForSubCollection(e, t) {
|
|
982
|
-
if (!
|
|
983
|
-
return new R(
|
|
982
|
+
if (!P._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
983
|
+
return new R(P._dataSource, e, t);
|
|
984
984
|
}
|
|
985
985
|
/**
|
|
986
986
|
* Populates property references with actual data from the store.
|
|
@@ -1012,15 +1012,15 @@ const C = class C {
|
|
|
1012
1012
|
) : e.__documentReference === void 0;
|
|
1013
1013
|
}
|
|
1014
1014
|
};
|
|
1015
|
-
|
|
1016
|
-
let
|
|
1017
|
-
class
|
|
1015
|
+
P.error = { shouldBeRegistered: "You should register a data source before using the data Store." };
|
|
1016
|
+
let M = P;
|
|
1017
|
+
class I {
|
|
1018
1018
|
constructor(e) {
|
|
1019
|
-
this.handlers = [], this.
|
|
1019
|
+
this.handlers = [], this._subscribeToDocumentChangeListener = () => {
|
|
1020
1020
|
throw new Error("The method subscribeToDocumentChangeListener has not been implemented in the concrete data source");
|
|
1021
1021
|
}, this._resolveCollectionPaths = () => {
|
|
1022
1022
|
throw new Error("The method collectionsMatchingTemplate has not been implemented in the concrete data source");
|
|
1023
|
-
}, this._disabledChangeListeners = /* @__PURE__ */ new Set(), e && (this.
|
|
1023
|
+
}, this._disabledChangeListeners = /* @__PURE__ */ new Set(), e && (this._beforeUpdate = e.beforeUpdateDocument, this._afterUpdate = e.afterUpdateDocument, this._afterDocumentChange = e.afterDocumentChange, this._beforeDocumentChange = e.beforeDocumentChange, this._beforeQueryOwnerCollection = e.beforeQueryOwnerCollection);
|
|
1024
1024
|
}
|
|
1025
1025
|
installUpdaters() {
|
|
1026
1026
|
const e = d.getSystemRegisteredReferencesWithCachedProps(), t = {};
|
|
@@ -1032,7 +1032,7 @@ class T {
|
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
1034
1034
|
}), this.handlers = [], Object.entries(t).forEach(([r, s]) => {
|
|
1035
|
-
const n = this.
|
|
1035
|
+
const n = this._subscribeToDocumentChangeListener(
|
|
1036
1036
|
r,
|
|
1037
1037
|
(o) => this.onDocumentChange(o, s)
|
|
1038
1038
|
);
|
|
@@ -1044,17 +1044,44 @@ class T {
|
|
|
1044
1044
|
uninstallUpdaters() {
|
|
1045
1045
|
this.handlers.forEach((e) => e.uninstall()), this.handlers = [];
|
|
1046
1046
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1047
|
+
/**
|
|
1048
|
+
* Set a callback to be executed before updating each document that has a cached prop to update.
|
|
1049
|
+
* The callback receives the document to update and the prop that triggered the update as parameters.
|
|
1050
|
+
* @param callback The callback to be executed before updating each document that has a cached prop to update.
|
|
1051
|
+
*/
|
|
1052
|
+
set beforeDocumentChange(e) {
|
|
1053
|
+
this._beforeDocumentChange = e;
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Set a callback to be executed after updating each document that has a cached prop to update.
|
|
1057
|
+
* The callback receives the document that was updated and the prop that triggered the update as parameters.
|
|
1058
|
+
* @param callback The callback to be executed after updating each document that has a cached prop to update.
|
|
1059
|
+
*/
|
|
1060
|
+
set afterDocumentChange(e) {
|
|
1061
|
+
this._afterDocumentChange = e;
|
|
1049
1062
|
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Set a callback to be executed before updating each document that has a cached prop to update.
|
|
1065
|
+
* The callback receives the document to update and the prop that triggered the update as parameters.
|
|
1066
|
+
* @param callback The callback to be executed before updating each document that has a cached prop to update.
|
|
1067
|
+
*/
|
|
1050
1068
|
set beforeUpdateDocument(e) {
|
|
1051
|
-
this.
|
|
1069
|
+
this._beforeUpdate = e;
|
|
1052
1070
|
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Set a callback to be executed after updating each document that has a cached prop to update.
|
|
1073
|
+
* The callback receives the document that was updated and the prop that triggered the update as parameters.
|
|
1074
|
+
* @param callback The callback to be executed after updating each document that has a cached prop to update.
|
|
1075
|
+
*/
|
|
1053
1076
|
set afterUpdateDocument(e) {
|
|
1054
|
-
this.
|
|
1077
|
+
this._afterUpdate = e;
|
|
1055
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Set a subscriber for handling document change events.
|
|
1081
|
+
* @param subscriber The subscriber to be used for handling document change events.
|
|
1082
|
+
*/
|
|
1056
1083
|
set documentChangeListenerSubscriber(e) {
|
|
1057
|
-
this.
|
|
1084
|
+
this._subscribeToDocumentChangeListener = e;
|
|
1058
1085
|
}
|
|
1059
1086
|
set beforeQueryOwnerCollection(e) {
|
|
1060
1087
|
this._beforeQueryOwnerCollection = e;
|
|
@@ -1063,16 +1090,18 @@ class T {
|
|
|
1063
1090
|
this._resolveCollectionPaths = e;
|
|
1064
1091
|
}
|
|
1065
1092
|
async onDocumentChange(e, t) {
|
|
1066
|
-
const r = b.toPersistentDocumentChange(e)
|
|
1093
|
+
const r = b.toPersistentDocumentChange(e);
|
|
1094
|
+
this._beforeDocumentChange?.(r, t);
|
|
1095
|
+
const s = {};
|
|
1067
1096
|
r.before && (r.after?.id && this._disabledChangeListeners.has(r.after?.id) || (await Promise.all(t.map(async (n) => {
|
|
1068
|
-
const o =
|
|
1097
|
+
const o = I.ownerCollectionPath(d.createInstance(n.ownerClassName()), n, r.params), a = await this._resolveCollectionPaths(o);
|
|
1069
1098
|
await Promise.all(a.map(async (h) => {
|
|
1070
|
-
const u =
|
|
1071
|
-
let c = u.find(),
|
|
1099
|
+
const u = M.getModel(h);
|
|
1100
|
+
let c = u.find(), C = !1;
|
|
1072
1101
|
n.cachedProps?.forEach((f) => {
|
|
1073
1102
|
const S = r.before[f], O = r.after[f];
|
|
1074
|
-
S !== O && (
|
|
1075
|
-
}),
|
|
1103
|
+
S !== O && (C = !0);
|
|
1104
|
+
}), C && (n.searchableArray ? c = c.where(n.name, "contains", r.before) : c = c.where(n.name, "==", r.before)), c = this._beforeQueryOwnerCollection?.(c) ?? c;
|
|
1076
1105
|
const E = await c.get();
|
|
1077
1106
|
return s[h] = {
|
|
1078
1107
|
totalDocumentsToUpdate: E.length,
|
|
@@ -1090,12 +1119,12 @@ class T {
|
|
|
1090
1119
|
f[n.name][O] = r.after;
|
|
1091
1120
|
} else
|
|
1092
1121
|
f[`_${n.name}`] = r.after;
|
|
1093
|
-
this.
|
|
1122
|
+
this._beforeUpdate?.(f, n), this.disableChangeListener(f), await u.save(f), this.enableChangeListener(f), s[h]?.updatedDocuments.push(f.id), this._afterUpdate?.(f, n);
|
|
1094
1123
|
} else await Promise.resolve();
|
|
1095
1124
|
})
|
|
1096
1125
|
]);
|
|
1097
1126
|
}));
|
|
1098
|
-
})), this.
|
|
1127
|
+
})), this._afterDocumentChange?.(s, t)));
|
|
1099
1128
|
}
|
|
1100
1129
|
disableChangeListener(e) {
|
|
1101
1130
|
this._disabledChangeListeners.add(e.id);
|
|
@@ -1113,7 +1142,7 @@ class b {
|
|
|
1113
1142
|
this._cachedPropsUpdater = void 0;
|
|
1114
1143
|
}
|
|
1115
1144
|
installCachedPropsUpdater(e) {
|
|
1116
|
-
return this._cachedPropsUpdater = new
|
|
1145
|
+
return this._cachedPropsUpdater = new I(e), this._cachedPropsUpdater.documentChangeListenerSubscriber = this.subscribeToDocumentChangeListener.bind(this), this._cachedPropsUpdater.resolveCollectionPaths = this.resolveCollectionPaths.bind(this), this._cachedPropsUpdater.installUpdaters();
|
|
1117
1146
|
}
|
|
1118
1147
|
uninstallCachedPropsUpdater() {
|
|
1119
1148
|
this._cachedPropsUpdater?.uninstallUpdaters(), this._cachedPropsUpdater = void 0;
|
|
@@ -1242,10 +1271,10 @@ class be extends b {
|
|
|
1242
1271
|
if (!a.after) return;
|
|
1243
1272
|
const h = [a.after];
|
|
1244
1273
|
a.before && h.push(a.before);
|
|
1245
|
-
const c = this.retrieveQueryDocs(h, e.operations).filter((
|
|
1246
|
-
c.length > 0 && r(c.map((
|
|
1274
|
+
const c = this.retrieveQueryDocs(h, e.operations).filter((C, E, f) => E === f.findIndex((S) => S.id === C.id));
|
|
1275
|
+
c.length > 0 && r(c.map((C) => ({
|
|
1247
1276
|
before: a.before,
|
|
1248
|
-
after:
|
|
1277
|
+
after: C,
|
|
1249
1278
|
type: a.type,
|
|
1250
1279
|
params: a.params
|
|
1251
1280
|
})));
|
|
@@ -1350,7 +1379,7 @@ class be extends b {
|
|
|
1350
1379
|
"<=": (u, c) => u <= c,
|
|
1351
1380
|
">": (u, c) => u > c,
|
|
1352
1381
|
">=": (u, c) => u >= c,
|
|
1353
|
-
containsAny: (u, c) => u?.some((
|
|
1382
|
+
containsAny: (u, c) => u?.some((C) => c?.includes(C)),
|
|
1354
1383
|
contains: (u, c) => u?.includes(c)
|
|
1355
1384
|
}, { property: s, value: n, operator: o } = t, [a, h] = this.retrieveValuesToCompare(e, s, n);
|
|
1356
1385
|
return r[o](a, h);
|
|
@@ -1467,14 +1496,14 @@ let F = class extends w {
|
|
|
1467
1496
|
F = ie([
|
|
1468
1497
|
re("MockCloudStorage", () => new F())
|
|
1469
1498
|
], F);
|
|
1470
|
-
var ne = Object.defineProperty, oe = Object.getOwnPropertyDescriptor,
|
|
1499
|
+
var ne = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, U = (i, e, t, r) => {
|
|
1471
1500
|
for (var s = r > 1 ? void 0 : r ? oe(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
1472
1501
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1473
1502
|
return r && s && ne(e, t, s), s;
|
|
1474
1503
|
}, ae = /* @__PURE__ */ ((i) => (i[i.stored = 0] = "stored", i[i.pendingDataSet = 1] = "pendingDataSet", i[i.deleted = 2] = "deleted", i))(ae || {});
|
|
1475
1504
|
let D = class extends d {
|
|
1476
1505
|
constructor() {
|
|
1477
|
-
super(...arguments), this._onChange = new
|
|
1506
|
+
super(...arguments), this._onChange = new k();
|
|
1478
1507
|
}
|
|
1479
1508
|
async save({ data: i, fileName: e, progress: t, cloudStorageProvider: r } = {}) {
|
|
1480
1509
|
const s = i || this._pendingData;
|
|
@@ -1519,29 +1548,29 @@ let D = class extends d {
|
|
|
1519
1548
|
return this._onChange.subscribe(i);
|
|
1520
1549
|
}
|
|
1521
1550
|
};
|
|
1522
|
-
|
|
1523
|
-
|
|
1551
|
+
U([
|
|
1552
|
+
j
|
|
1524
1553
|
], D.prototype, "_reference", 2);
|
|
1525
|
-
|
|
1526
|
-
|
|
1554
|
+
U([
|
|
1555
|
+
j
|
|
1527
1556
|
], D.prototype, "_url", 2);
|
|
1528
|
-
|
|
1529
|
-
|
|
1557
|
+
U([
|
|
1558
|
+
j
|
|
1530
1559
|
], D.prototype, "_cloudStorageProviderName", 2);
|
|
1531
|
-
|
|
1532
|
-
|
|
1560
|
+
U([
|
|
1561
|
+
j
|
|
1533
1562
|
], D.prototype, "_originalFileName", 2);
|
|
1534
|
-
|
|
1535
|
-
|
|
1563
|
+
U([
|
|
1564
|
+
j
|
|
1536
1565
|
], D.prototype, "_mimeType", 2);
|
|
1537
|
-
D =
|
|
1566
|
+
D = U([
|
|
1538
1567
|
ee("StoredFile")
|
|
1539
1568
|
], D);
|
|
1540
1569
|
class W {
|
|
1541
1570
|
}
|
|
1542
1571
|
const p = class p extends W {
|
|
1543
1572
|
constructor() {
|
|
1544
|
-
if (super(), this._onAuthStateChange = new
|
|
1573
|
+
if (super(), this._onAuthStateChange = new k(), !p._authService) throw new Error(p.error.shouldBeRegistered);
|
|
1545
1574
|
p._authService.onAuthStateChange(
|
|
1546
1575
|
(e) => this.authStateChanged(e)
|
|
1547
1576
|
);
|
|
@@ -1666,7 +1695,7 @@ const p = class p extends W {
|
|
|
1666
1695
|
};
|
|
1667
1696
|
p.error = { shouldBeRegistered: "You should register an auth service before using Auth." }, p._instance = void 0;
|
|
1668
1697
|
let x = p;
|
|
1669
|
-
class
|
|
1698
|
+
class Ce extends W {
|
|
1670
1699
|
constructor() {
|
|
1671
1700
|
super(...arguments), this.pendingPromises = [], this._fakeRegisteredUsers = {};
|
|
1672
1701
|
}
|
|
@@ -1768,7 +1797,7 @@ const y = class y {
|
|
|
1768
1797
|
};
|
|
1769
1798
|
y.error = { shouldBeRegistered: "You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions." };
|
|
1770
1799
|
let $ = y;
|
|
1771
|
-
class
|
|
1800
|
+
class Pe {
|
|
1772
1801
|
constructor(e) {
|
|
1773
1802
|
this._registeredFunctions = e;
|
|
1774
1803
|
}
|
|
@@ -1856,28 +1885,28 @@ function Oe(i, e) {
|
|
|
1856
1885
|
}
|
|
1857
1886
|
export {
|
|
1858
1887
|
x as Auth,
|
|
1859
|
-
|
|
1888
|
+
Ce as AuthMock,
|
|
1860
1889
|
W as AuthService,
|
|
1861
1890
|
$ as CloudFunctions,
|
|
1862
|
-
|
|
1891
|
+
Pe as CloudFunctionsMock,
|
|
1863
1892
|
w as CloudStorage,
|
|
1864
1893
|
b as DataSource,
|
|
1865
1894
|
ye as EntropicComponent,
|
|
1866
1895
|
be as JsonDataSource,
|
|
1867
1896
|
F as MockCloudStorage,
|
|
1868
1897
|
R as Model,
|
|
1869
|
-
|
|
1898
|
+
k as Observable,
|
|
1870
1899
|
d as Persistent,
|
|
1871
1900
|
te as Query,
|
|
1872
1901
|
V as ServerAuth,
|
|
1873
1902
|
ve as ServerAuthMock,
|
|
1874
1903
|
B as ServerAuthService,
|
|
1875
|
-
|
|
1904
|
+
M as Store,
|
|
1876
1905
|
D as StoredFile,
|
|
1877
1906
|
ae as StoredFileEvent,
|
|
1878
1907
|
De as camelCase,
|
|
1879
1908
|
Oe as getDeepValue,
|
|
1880
|
-
|
|
1909
|
+
j as persistent,
|
|
1881
1910
|
_ as persistentParser,
|
|
1882
1911
|
le as persistentPureReference,
|
|
1883
1912
|
de as persistentPureReferenceWithCachedProps,
|