entropic-bond 1.51.5 → 1.51.6
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
|
@@ -43,12 +43,12 @@ class F {
|
|
|
43
43
|
return this.subscribers.size;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
let
|
|
46
|
+
let R;
|
|
47
47
|
const x = new Uint8Array(16);
|
|
48
48
|
function L() {
|
|
49
|
-
if (!
|
|
49
|
+
if (!R && (R = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !R))
|
|
50
50
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
51
|
-
return
|
|
51
|
+
return R(x);
|
|
52
52
|
}
|
|
53
53
|
const f = [];
|
|
54
54
|
for (let i = 0; i < 256; ++i)
|
|
@@ -76,8 +76,8 @@ var q = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, z = (i, e, t
|
|
|
76
76
|
for (var s = r > 1 ? void 0 : r ? Y(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
77
77
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
78
78
|
return r && s && q(e, t, s), s;
|
|
79
|
-
},
|
|
80
|
-
const k = (
|
|
79
|
+
}, l;
|
|
80
|
+
const k = (l = class {
|
|
81
81
|
/**
|
|
82
82
|
* Registers a class to be used by the persistence engine.
|
|
83
83
|
* @param className the name of the class to be registered
|
|
@@ -131,7 +131,7 @@ const k = (d = class {
|
|
|
131
131
|
* @see registerFactory
|
|
132
132
|
*/
|
|
133
133
|
static annotations(e) {
|
|
134
|
-
if (e instanceof
|
|
134
|
+
if (e instanceof l ? e = e.className : typeof e == "string" || (e = new e().className), !this._factoryMap[e])
|
|
135
135
|
throw new Error(`You should register class ${e} prior to use.`);
|
|
136
136
|
return this._factoryMap[e].annotation;
|
|
137
137
|
}
|
|
@@ -272,7 +272,7 @@ const k = (d = class {
|
|
|
272
272
|
throw new Error("You should register this class prior to streaming it.");
|
|
273
273
|
return this._persistentProperties.forEach((r) => {
|
|
274
274
|
const s = this[r.name], n = this.removeUnderscore(r);
|
|
275
|
-
s != null && (r.isReference ? t[n] = this.toReferenceObj(r, e) : t[n] = this.toDeepObj(s, e), r.searchableArray && (t[
|
|
275
|
+
s != null && (r.isReference ? t[n] = this.toReferenceObj(r, e) : t[n] = this.toDeepObj(s, e), r.searchableArray && (t[l.searchableArrayNameFor(n)] = s.map((o) => o.id)));
|
|
276
276
|
}), t.__className = this.className, t;
|
|
277
277
|
}
|
|
278
278
|
static searchableArrayNameFor(e) {
|
|
@@ -284,11 +284,11 @@ const k = (d = class {
|
|
|
284
284
|
if (Array.isArray(e))
|
|
285
285
|
return e.map((t) => this.fromDeepObject(t));
|
|
286
286
|
if (e.__documentReference) {
|
|
287
|
-
const t = e, r =
|
|
287
|
+
const t = e, r = l.createInstance(t);
|
|
288
288
|
return r.__documentReference = e.__documentReference, r;
|
|
289
289
|
}
|
|
290
290
|
if (e.__className)
|
|
291
|
-
return
|
|
291
|
+
return l.createInstance(e);
|
|
292
292
|
if (typeof e == "object") {
|
|
293
293
|
const t = {};
|
|
294
294
|
return Object.entries(e).forEach(
|
|
@@ -303,7 +303,7 @@ const k = (d = class {
|
|
|
303
303
|
return e.map((r) => this.toDeepObj(r, t));
|
|
304
304
|
if (e.__documentReference)
|
|
305
305
|
return e;
|
|
306
|
-
if (e instanceof
|
|
306
|
+
if (e instanceof l)
|
|
307
307
|
return e.toObj(t);
|
|
308
308
|
if (typeof e == "object") {
|
|
309
309
|
const r = {};
|
|
@@ -320,7 +320,7 @@ const k = (d = class {
|
|
|
320
320
|
}
|
|
321
321
|
toReferenceObj(e, t) {
|
|
322
322
|
const r = this[e.name];
|
|
323
|
-
return Array.isArray(r) ? r.map((s) => (e.isPureReference || this.pushDocument(t,
|
|
323
|
+
return Array.isArray(r) ? r.map((s) => (e.isPureReference || this.pushDocument(t, l.collectionPath(s, e), s), this.buildRefObject(s, l.collectionPath(s, e), e.cachedProps))) : (e.isPureReference || this.pushDocument(t, l.collectionPath(r, e), r), this.buildRefObject(r, l.collectionPath(r, e), e.cachedProps));
|
|
324
324
|
}
|
|
325
325
|
buildRefObject(e, t, r) {
|
|
326
326
|
const s = r == null ? void 0 : r.reduce((n, o) => (e[o] !== void 0 && (n[o] = e[o]), n), {});
|
|
@@ -344,14 +344,14 @@ const k = (d = class {
|
|
|
344
344
|
return e.name.slice(1);
|
|
345
345
|
}
|
|
346
346
|
static createReference(e) {
|
|
347
|
-
const t =
|
|
347
|
+
const t = l.createInstance(e);
|
|
348
348
|
return t.__documentReference = e.__documentReference || { storedInCollection: t.className }, t;
|
|
349
349
|
}
|
|
350
350
|
static createInstance(e) {
|
|
351
351
|
if (typeof e == "string")
|
|
352
|
-
return new (
|
|
352
|
+
return new (l.classFactory(e))();
|
|
353
353
|
try {
|
|
354
|
-
return new (
|
|
354
|
+
return new (l.classFactory(e.__className))().fromObject(e);
|
|
355
355
|
} catch (t) {
|
|
356
356
|
const r = Object.entries(e).filter(([s, n]) => n != null && typeof n != "function").map(([s, n]) => `${s}: ${n}`).join(`,
|
|
357
357
|
`);
|
|
@@ -364,13 +364,25 @@ const k = (d = class {
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
static propInfo(e, t) {
|
|
367
|
-
return
|
|
367
|
+
return l.createInstance(e).getPropInfo(t);
|
|
368
368
|
}
|
|
369
|
-
|
|
369
|
+
/**
|
|
370
|
+
* Retrieves a collection of references with the properties that are stored in the reference object
|
|
371
|
+
* @returns the references collection
|
|
372
|
+
*/
|
|
373
|
+
static getSystemRegisteredReferencesWithCachedProps() {
|
|
374
|
+
return l.registeredClasses().reduce((r, s) => {
|
|
375
|
+
const o = l.createInstance(s).getPersistentProperties().filter(
|
|
376
|
+
(a) => a.cachedProps
|
|
377
|
+
);
|
|
378
|
+
return o.length > 0 && (r[s] = o), r;
|
|
379
|
+
}, {});
|
|
380
|
+
}
|
|
381
|
+
}, l._factoryMap = {}, l);
|
|
370
382
|
z([
|
|
371
383
|
S
|
|
372
384
|
], k.prototype, "_id", 2);
|
|
373
|
-
let
|
|
385
|
+
let d = k;
|
|
374
386
|
function S(i, e) {
|
|
375
387
|
return _()(i, e);
|
|
376
388
|
}
|
|
@@ -419,12 +431,12 @@ function _(i) {
|
|
|
419
431
|
}
|
|
420
432
|
function H(i, e) {
|
|
421
433
|
return (t) => {
|
|
422
|
-
|
|
434
|
+
d.registerFactory(i, t, e), t.prototype.__className = i;
|
|
423
435
|
};
|
|
424
436
|
}
|
|
425
437
|
function ce(i) {
|
|
426
438
|
return (e) => {
|
|
427
|
-
|
|
439
|
+
d.registerFactory(i, e);
|
|
428
440
|
};
|
|
429
441
|
}
|
|
430
442
|
function ue(i, e) {
|
|
@@ -438,7 +450,7 @@ function le(i = (e) => e != null) {
|
|
|
438
450
|
return _({ validator: i })(e, t);
|
|
439
451
|
};
|
|
440
452
|
}
|
|
441
|
-
class de extends
|
|
453
|
+
class de extends d {
|
|
442
454
|
constructor() {
|
|
443
455
|
super(...arguments), this._onChange = new F();
|
|
444
456
|
}
|
|
@@ -523,14 +535,14 @@ class de extends l {
|
|
|
523
535
|
return this.notify({ [e]: this[e] }), t;
|
|
524
536
|
}
|
|
525
537
|
}
|
|
526
|
-
const
|
|
538
|
+
const j = class j {
|
|
527
539
|
constructor(e, t, r) {
|
|
528
540
|
if (r) {
|
|
529
|
-
if (!(t instanceof
|
|
530
|
-
throw new Error(
|
|
541
|
+
if (!(t instanceof d))
|
|
542
|
+
throw new Error(j.error.persistentNeedForSubCollection);
|
|
531
543
|
this.collectionName = `${t.className}/${t.id}/${r}`;
|
|
532
544
|
} else
|
|
533
|
-
this.collectionName = t instanceof
|
|
545
|
+
this.collectionName = t instanceof d ? t.className : t;
|
|
534
546
|
this._stream = e;
|
|
535
547
|
}
|
|
536
548
|
/**
|
|
@@ -545,7 +557,7 @@ const E = class E {
|
|
|
545
557
|
findById(e, t) {
|
|
546
558
|
return new Promise((r, s) => {
|
|
547
559
|
this._stream.findById(e, this.collectionName).then((n) => {
|
|
548
|
-
n ? (t ? t.fromObject(n) : t =
|
|
560
|
+
n ? (t ? t.fromObject(n) : t = d.createInstance(n), r(t)) : r(void 0);
|
|
549
561
|
}).catch((n) => s(n));
|
|
550
562
|
});
|
|
551
563
|
}
|
|
@@ -587,7 +599,7 @@ const E = class E {
|
|
|
587
599
|
*/
|
|
588
600
|
query(e = {}, t) {
|
|
589
601
|
if (t) {
|
|
590
|
-
const r = t instanceof
|
|
602
|
+
const r = t instanceof d ? t.className : t;
|
|
591
603
|
e.operations || (e.operations = []), e.operations.push(
|
|
592
604
|
{ property: "__className", operator: "==", value: r }
|
|
593
605
|
);
|
|
@@ -625,7 +637,7 @@ const E = class E {
|
|
|
625
637
|
mapToInstance(e) {
|
|
626
638
|
return new Promise((t, r) => {
|
|
627
639
|
e().then((s) => t(
|
|
628
|
-
s.map((n) =>
|
|
640
|
+
s.map((n) => d.createInstance(n))
|
|
629
641
|
)).catch((s) => r(s));
|
|
630
642
|
});
|
|
631
643
|
}
|
|
@@ -643,15 +655,15 @@ const E = class E {
|
|
|
643
655
|
return e;
|
|
644
656
|
const t = ((r = e.operations) == null ? void 0 : r.map((s) => {
|
|
645
657
|
const n = s.value[0] ?? s.value;
|
|
646
|
-
return
|
|
647
|
-
property:
|
|
658
|
+
return E.isArrayOperator(s.operator) && n instanceof d ? {
|
|
659
|
+
property: d.searchableArrayNameFor(s.property),
|
|
648
660
|
operator: s.operator,
|
|
649
661
|
value: Array.isArray(s.value) ? s.value.map((o) => o.id) : n.id,
|
|
650
662
|
aggregate: s.aggregate
|
|
651
663
|
} : {
|
|
652
664
|
property: s.property,
|
|
653
665
|
operator: s.operator,
|
|
654
|
-
value: s.value instanceof
|
|
666
|
+
value: s.value instanceof d ? { id: s.value.id } : s.value,
|
|
655
667
|
aggregate: s.aggregate
|
|
656
668
|
};
|
|
657
669
|
})) ?? [];
|
|
@@ -661,11 +673,11 @@ const E = class E {
|
|
|
661
673
|
};
|
|
662
674
|
}
|
|
663
675
|
};
|
|
664
|
-
|
|
676
|
+
j.error = {
|
|
665
677
|
persistentNeedForSubCollection: "The document parameter for a sub-collection should be a Persistent instace",
|
|
666
678
|
invalidQueryOrder: "Cannot add where calls after or calls"
|
|
667
679
|
};
|
|
668
|
-
let C =
|
|
680
|
+
let C = j;
|
|
669
681
|
class J {
|
|
670
682
|
constructor(e) {
|
|
671
683
|
this.queryObject = { operations: [] }, this.model = e;
|
|
@@ -730,8 +742,8 @@ class J {
|
|
|
730
742
|
throw new Error(C.error.invalidQueryOrder);
|
|
731
743
|
const n = e.split(".");
|
|
732
744
|
let o = {}, a = n.length > 1 ? o : r;
|
|
733
|
-
return n.slice(1).forEach((P,
|
|
734
|
-
o[P] =
|
|
745
|
+
return n.slice(1).forEach((P, O) => {
|
|
746
|
+
o[P] = O < n.length - 2 ? {} : r, o = o[P];
|
|
735
747
|
}), (u = this.queryObject.operations) == null || u.push({
|
|
736
748
|
property: n[0],
|
|
737
749
|
operator: t,
|
|
@@ -822,7 +834,7 @@ class J {
|
|
|
822
834
|
*/
|
|
823
835
|
instanceOf(e) {
|
|
824
836
|
var r;
|
|
825
|
-
const t = e instanceof
|
|
837
|
+
const t = e instanceof d ? e.className : e;
|
|
826
838
|
return (r = this.queryObject.operations) == null || r.push({
|
|
827
839
|
property: "__className",
|
|
828
840
|
operator: "==",
|
|
@@ -962,10 +974,10 @@ const y = class y {
|
|
|
962
974
|
};
|
|
963
975
|
y.error = { shouldBeRegistered: "You should register a data source before using the data Store." };
|
|
964
976
|
let A = y;
|
|
965
|
-
class
|
|
977
|
+
class E {
|
|
966
978
|
installCachedPropsUpdaters(e = {}) {
|
|
967
979
|
this.onUpdate = e.onUpdate;
|
|
968
|
-
const t = [], r =
|
|
980
|
+
const t = [], r = d.getSystemRegisteredReferencesWithCachedProps();
|
|
969
981
|
return Object.entries(r).forEach(([s, n]) => {
|
|
970
982
|
n.forEach((o) => {
|
|
971
983
|
if (!o.storeInCollection)
|
|
@@ -1003,9 +1015,9 @@ class O {
|
|
|
1003
1015
|
*/
|
|
1004
1016
|
static toPropertyPathOperations(e) {
|
|
1005
1017
|
return e ? e.map((t) => {
|
|
1006
|
-
if (
|
|
1018
|
+
if (E.isArrayOperator(t.operator) && t.value[0] instanceof d)
|
|
1007
1019
|
return {
|
|
1008
|
-
property:
|
|
1020
|
+
property: d.searchableArrayNameFor(t.property),
|
|
1009
1021
|
operator: t.operator,
|
|
1010
1022
|
value: t.value.map((o) => o.id),
|
|
1011
1023
|
aggregate: t.aggregate
|
|
@@ -1043,23 +1055,15 @@ class O {
|
|
|
1043
1055
|
o.map(async (a) => {
|
|
1044
1056
|
var h;
|
|
1045
1057
|
(h = t.cachedProps) == null || h.forEach(async (c) => {
|
|
1046
|
-
var
|
|
1058
|
+
var O;
|
|
1047
1059
|
const u = e.before[c], P = e.after[c];
|
|
1048
|
-
u !== P && (a[`_${t.name}`][`_${c}`] = P, await s.save(a), (
|
|
1060
|
+
u !== P && (a[`_${t.name}`][`_${c}`] = P, await s.save(a), (O = this.onUpdate) == null || O.call(this, a, t, r));
|
|
1049
1061
|
});
|
|
1050
1062
|
})
|
|
1051
1063
|
]);
|
|
1052
1064
|
}
|
|
1053
|
-
static getSystemRegisteredReferencesWithStoredProps() {
|
|
1054
|
-
return l.registeredClasses().reduce((r, s) => {
|
|
1055
|
-
const o = l.createInstance(s).getPersistentProperties().filter(
|
|
1056
|
-
(a) => a.cachedProps
|
|
1057
|
-
);
|
|
1058
|
-
return o.length > 0 && (r[s] = o), r;
|
|
1059
|
-
}, {});
|
|
1060
|
-
}
|
|
1061
1065
|
}
|
|
1062
|
-
class fe extends
|
|
1066
|
+
class fe extends E {
|
|
1063
1067
|
/**
|
|
1064
1068
|
* @param jsonRawData the JSON object to be used as data store
|
|
1065
1069
|
*/
|
|
@@ -1148,7 +1152,7 @@ class fe extends O {
|
|
|
1148
1152
|
} : this._simulateError = e, this);
|
|
1149
1153
|
}
|
|
1150
1154
|
subscribeToDocumentChangeListerner(e, t) {
|
|
1151
|
-
const r =
|
|
1155
|
+
const r = d.collectionPath(void 0, e);
|
|
1152
1156
|
if (r)
|
|
1153
1157
|
return delete this._listener[r], this._listener[r] = t, {
|
|
1154
1158
|
uninstall: () => delete this._listener[r],
|
|
@@ -1312,7 +1316,7 @@ var ee = Object.defineProperty, te = Object.getOwnPropertyDescriptor, D = (i, e,
|
|
|
1312
1316
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1313
1317
|
return r && s && ee(e, t, s), s;
|
|
1314
1318
|
}, re = /* @__PURE__ */ ((i) => (i[i.stored = 0] = "stored", i[i.pendingDataSet = 1] = "pendingDataSet", i[i.deleted = 2] = "deleted", i))(re || {});
|
|
1315
|
-
let b = class extends
|
|
1319
|
+
let b = class extends d {
|
|
1316
1320
|
constructor() {
|
|
1317
1321
|
super(...arguments), this._onChange = new F();
|
|
1318
1322
|
}
|
|
@@ -1605,11 +1609,11 @@ const g = class g {
|
|
|
1605
1609
|
}
|
|
1606
1610
|
processParam(e) {
|
|
1607
1611
|
if (e != null)
|
|
1608
|
-
return e instanceof
|
|
1612
|
+
return e instanceof d ? e.toObject() : Array.isArray(e) ? e.map((t) => this.processParam(t)) : typeof e == "object" ? Object.entries(e).reduce((t, [r, s]) => (t[r] = this.processParam(s), t), {}) : e;
|
|
1609
1613
|
}
|
|
1610
1614
|
processResult(e) {
|
|
1611
1615
|
if (e != null)
|
|
1612
|
-
return e.__className ?
|
|
1616
|
+
return e.__className ? d.createInstance(e) : Array.isArray(e) ? e.map((t) => this.processResult(t)) : typeof e == "object" ? Object.entries(e).reduce((t, [r, s]) => (t[r] = this.processResult(s), t), {}) : e;
|
|
1613
1617
|
}
|
|
1614
1618
|
};
|
|
1615
1619
|
g.error = { shouldBeRegistered: "You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions." };
|
|
@@ -1711,13 +1715,13 @@ export {
|
|
|
1711
1715
|
V as CloudFunctions,
|
|
1712
1716
|
me as CloudFunctionsMock,
|
|
1713
1717
|
w as CloudStorage,
|
|
1714
|
-
|
|
1718
|
+
E as DataSource,
|
|
1715
1719
|
de as EntropicComponent,
|
|
1716
1720
|
fe as JsonDataSource,
|
|
1717
1721
|
U as MockCloudStorage,
|
|
1718
1722
|
C as Model,
|
|
1719
1723
|
F as Observable,
|
|
1720
|
-
|
|
1724
|
+
d as Persistent,
|
|
1721
1725
|
J as Query,
|
|
1722
1726
|
$ as ServerAuth,
|
|
1723
1727
|
ge as ServerAuthMock,
|