entropic-bond 1.51.6 → 1.51.8
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,25 +43,25 @@ class F {
|
|
|
43
43
|
return this.subscribers.size;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
let
|
|
47
|
-
const
|
|
46
|
+
let O;
|
|
47
|
+
const B = new Uint8Array(16);
|
|
48
48
|
function L() {
|
|
49
|
-
if (!
|
|
49
|
+
if (!O && (O = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !O))
|
|
50
50
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
51
|
-
return
|
|
51
|
+
return O(B);
|
|
52
52
|
}
|
|
53
53
|
const f = [];
|
|
54
54
|
for (let i = 0; i < 256; ++i)
|
|
55
55
|
f.push((i + 256).toString(16).slice(1));
|
|
56
|
-
function
|
|
56
|
+
function W(i, e = 0) {
|
|
57
57
|
return f[i[e + 0]] + f[i[e + 1]] + f[i[e + 2]] + f[i[e + 3]] + "-" + f[i[e + 4]] + f[i[e + 5]] + "-" + f[i[e + 6]] + f[i[e + 7]] + "-" + f[i[e + 8]] + f[i[e + 9]] + "-" + f[i[e + 10]] + f[i[e + 11]] + f[i[e + 12]] + f[i[e + 13]] + f[i[e + 14]] + f[i[e + 15]];
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
randomUUID:
|
|
59
|
+
const Q = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), N = {
|
|
60
|
+
randomUUID: Q
|
|
61
61
|
};
|
|
62
|
-
function
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
62
|
+
function q(i, e, t) {
|
|
63
|
+
if (N.randomUUID && !e && !i)
|
|
64
|
+
return N.randomUUID();
|
|
65
65
|
i = i || {};
|
|
66
66
|
const r = i.random || (i.rng || L)();
|
|
67
67
|
if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, e) {
|
|
@@ -70,14 +70,14 @@ function Q(i, e, t) {
|
|
|
70
70
|
e[t + s] = r[s];
|
|
71
71
|
return e;
|
|
72
72
|
}
|
|
73
|
-
return
|
|
73
|
+
return W(r);
|
|
74
74
|
}
|
|
75
|
-
var
|
|
76
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
75
|
+
var Y = Object.defineProperty, z = Object.getOwnPropertyDescriptor, H = (i, e, t, r) => {
|
|
76
|
+
for (var s = r > 1 ? void 0 : r ? z(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
|
-
return r && s &&
|
|
79
|
-
},
|
|
80
|
-
const
|
|
78
|
+
return r && s && Y(e, t, s), s;
|
|
79
|
+
}, d;
|
|
80
|
+
const M = (d = 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 = (l = class {
|
|
|
131
131
|
* @see registerFactory
|
|
132
132
|
*/
|
|
133
133
|
static annotations(e) {
|
|
134
|
-
if (e instanceof
|
|
134
|
+
if (e instanceof d ? 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
|
}
|
|
@@ -139,7 +139,7 @@ const k = (l = class {
|
|
|
139
139
|
* Returns a new instance of Persistent class.
|
|
140
140
|
* @param className the initial id of this instance. If not provided, a new id will be generated
|
|
141
141
|
*/
|
|
142
|
-
constructor(e =
|
|
142
|
+
constructor(e = q()) {
|
|
143
143
|
this._id = e;
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
@@ -272,7 +272,7 @@ const k = (l = 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[d.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 = (l = 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 = d.createInstance(t);
|
|
288
288
|
return r.__documentReference = e.__documentReference, r;
|
|
289
289
|
}
|
|
290
290
|
if (e.__className)
|
|
291
|
-
return
|
|
291
|
+
return d.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 = (l = 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 d)
|
|
307
307
|
return e.toObj(t);
|
|
308
308
|
if (typeof e == "object") {
|
|
309
309
|
const r = {};
|
|
@@ -320,7 +320,7 @@ const k = (l = 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, d.collectionPath(s, e), s), this.buildRefObject(s, d.collectionPath(s, e), e.cachedProps))) : (e.isPureReference || this.pushDocument(t, d.collectionPath(r, e), r), this.buildRefObject(r, d.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 = (l = class {
|
|
|
344
344
|
return e.name.slice(1);
|
|
345
345
|
}
|
|
346
346
|
static createReference(e) {
|
|
347
|
-
const t =
|
|
347
|
+
const t = d.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 (d.classFactory(e))();
|
|
353
353
|
try {
|
|
354
|
-
return new (
|
|
354
|
+
return new (d.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,29 +364,29 @@ const k = (l = class {
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
static propInfo(e, t) {
|
|
367
|
-
return
|
|
367
|
+
return d.createInstance(e).getPropInfo(t);
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
370
370
|
* Retrieves a collection of references with the properties that are stored in the reference object
|
|
371
371
|
* @returns the references collection
|
|
372
372
|
*/
|
|
373
373
|
static getSystemRegisteredReferencesWithCachedProps() {
|
|
374
|
-
return
|
|
375
|
-
const o =
|
|
376
|
-
(
|
|
374
|
+
return d.registeredClasses().reduce((r, s) => {
|
|
375
|
+
const o = d.createInstance(s).getPersistentProperties().filter(
|
|
376
|
+
(c) => c.cachedProps
|
|
377
377
|
);
|
|
378
378
|
return o.length > 0 && (r[s] = o), r;
|
|
379
379
|
}, {});
|
|
380
380
|
}
|
|
381
|
-
},
|
|
382
|
-
|
|
381
|
+
}, d._factoryMap = {}, d);
|
|
382
|
+
H([
|
|
383
383
|
S
|
|
384
|
-
],
|
|
385
|
-
let
|
|
384
|
+
], M.prototype, "_id", 2);
|
|
385
|
+
let l = M;
|
|
386
386
|
function S(i, e) {
|
|
387
387
|
return _()(i, e);
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function ie(i) {
|
|
390
390
|
return function(e, t) {
|
|
391
391
|
return _({
|
|
392
392
|
storeInCollection: i,
|
|
@@ -394,10 +394,10 @@ function se(i) {
|
|
|
394
394
|
})(e, t);
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
|
-
function
|
|
397
|
+
function ne(i, e) {
|
|
398
398
|
return _({ isReference: !0 })(i, e);
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function oe(i, e) {
|
|
401
401
|
return function(t, r) {
|
|
402
402
|
return _({
|
|
403
403
|
isReference: !0,
|
|
@@ -406,10 +406,10 @@ function ne(i, e) {
|
|
|
406
406
|
})(t, r);
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function ae(i, e, t) {
|
|
410
410
|
return _({ isReference: !0, isPureReference: !0, storeInCollection: t })(i, e);
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function ce(i, e) {
|
|
413
413
|
return function(t, r) {
|
|
414
414
|
return _({
|
|
415
415
|
isReference: !0,
|
|
@@ -429,28 +429,28 @@ function _(i) {
|
|
|
429
429
|
});
|
|
430
430
|
};
|
|
431
431
|
}
|
|
432
|
-
function
|
|
432
|
+
function J(i, e) {
|
|
433
433
|
return (t) => {
|
|
434
|
-
|
|
434
|
+
l.registerFactory(i, t, e), t.prototype.__className = i;
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function ue(i) {
|
|
438
438
|
return (e) => {
|
|
439
|
-
|
|
439
|
+
l.registerFactory(i, e);
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function he(i, e) {
|
|
443
443
|
return _({ searchableArray: !0 })(i, e);
|
|
444
444
|
}
|
|
445
|
-
function
|
|
445
|
+
function le(i, e) {
|
|
446
446
|
return _({ validator: (t) => t != null })(i, e);
|
|
447
447
|
}
|
|
448
|
-
function
|
|
448
|
+
function de(i = (e) => e != null) {
|
|
449
449
|
return function(e, t) {
|
|
450
450
|
return _({ validator: i })(e, t);
|
|
451
451
|
};
|
|
452
452
|
}
|
|
453
|
-
class
|
|
453
|
+
class fe extends l {
|
|
454
454
|
constructor() {
|
|
455
455
|
super(...arguments), this._onChange = new F();
|
|
456
456
|
}
|
|
@@ -538,11 +538,11 @@ class de extends d {
|
|
|
538
538
|
const j = class j {
|
|
539
539
|
constructor(e, t, r) {
|
|
540
540
|
if (r) {
|
|
541
|
-
if (!(t instanceof
|
|
541
|
+
if (!(t instanceof l))
|
|
542
542
|
throw new Error(j.error.persistentNeedForSubCollection);
|
|
543
543
|
this.collectionName = `${t.className}/${t.id}/${r}`;
|
|
544
544
|
} else
|
|
545
|
-
this.collectionName = t instanceof
|
|
545
|
+
this.collectionName = t instanceof l ? t.className : t;
|
|
546
546
|
this._stream = e;
|
|
547
547
|
}
|
|
548
548
|
/**
|
|
@@ -557,7 +557,7 @@ const j = class j {
|
|
|
557
557
|
findById(e, t) {
|
|
558
558
|
return new Promise((r, s) => {
|
|
559
559
|
this._stream.findById(e, this.collectionName).then((n) => {
|
|
560
|
-
n ? (t ? t.fromObject(n) : t =
|
|
560
|
+
n ? (t ? t.fromObject(n) : t = l.createInstance(n), r(t)) : r(void 0);
|
|
561
561
|
}).catch((n) => s(n));
|
|
562
562
|
});
|
|
563
563
|
}
|
|
@@ -588,7 +588,7 @@ const j = class j {
|
|
|
588
588
|
* @returns a Query object
|
|
589
589
|
*/
|
|
590
590
|
find() {
|
|
591
|
-
return new
|
|
591
|
+
return new Z(this);
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
594
594
|
* Define the search conditions. You pass query operations and how the query
|
|
@@ -599,7 +599,7 @@ const j = class j {
|
|
|
599
599
|
*/
|
|
600
600
|
query(e = {}, t) {
|
|
601
601
|
if (t) {
|
|
602
|
-
const r = t instanceof
|
|
602
|
+
const r = t instanceof l ? t.className : t;
|
|
603
603
|
e.operations || (e.operations = []), e.operations.push(
|
|
604
604
|
{ property: "__className", operator: "==", value: r }
|
|
605
605
|
);
|
|
@@ -637,7 +637,7 @@ const j = class j {
|
|
|
637
637
|
mapToInstance(e) {
|
|
638
638
|
return new Promise((t, r) => {
|
|
639
639
|
e().then((s) => t(
|
|
640
|
-
s.map((n) =>
|
|
640
|
+
s.map((n) => l.createInstance(n))
|
|
641
641
|
)).catch((s) => r(s));
|
|
642
642
|
});
|
|
643
643
|
}
|
|
@@ -655,15 +655,15 @@ const j = class j {
|
|
|
655
655
|
return e;
|
|
656
656
|
const t = ((r = e.operations) == null ? void 0 : r.map((s) => {
|
|
657
657
|
const n = s.value[0] ?? s.value;
|
|
658
|
-
return E.isArrayOperator(s.operator) && n instanceof
|
|
659
|
-
property:
|
|
658
|
+
return E.isArrayOperator(s.operator) && n instanceof l ? {
|
|
659
|
+
property: l.searchableArrayNameFor(s.property),
|
|
660
660
|
operator: s.operator,
|
|
661
661
|
value: Array.isArray(s.value) ? s.value.map((o) => o.id) : n.id,
|
|
662
662
|
aggregate: s.aggregate
|
|
663
663
|
} : {
|
|
664
664
|
property: s.property,
|
|
665
665
|
operator: s.operator,
|
|
666
|
-
value: s.value instanceof
|
|
666
|
+
value: s.value instanceof l ? { id: s.value.id } : s.value,
|
|
667
667
|
aggregate: s.aggregate
|
|
668
668
|
};
|
|
669
669
|
})) ?? [];
|
|
@@ -678,7 +678,7 @@ j.error = {
|
|
|
678
678
|
invalidQueryOrder: "Cannot add where calls after or calls"
|
|
679
679
|
};
|
|
680
680
|
let C = j;
|
|
681
|
-
class
|
|
681
|
+
class Z {
|
|
682
682
|
constructor(e) {
|
|
683
683
|
this.queryObject = { operations: [] }, this.model = e;
|
|
684
684
|
}
|
|
@@ -702,10 +702,10 @@ class J {
|
|
|
702
702
|
* @see orDeepProp
|
|
703
703
|
*/
|
|
704
704
|
where(e, t, r, s) {
|
|
705
|
-
var n, o,
|
|
705
|
+
var n, o, c;
|
|
706
706
|
if ((o = (n = this.queryObject.operations) == null ? void 0 : n.at(-1)) != null && o.aggregate && !s)
|
|
707
707
|
throw new Error(C.error.invalidQueryOrder);
|
|
708
|
-
return (
|
|
708
|
+
return (c = this.queryObject.operations) == null || c.push({
|
|
709
709
|
property: e,
|
|
710
710
|
operator: t,
|
|
711
711
|
value: r,
|
|
@@ -737,17 +737,17 @@ class J {
|
|
|
737
737
|
* @see orDeepProp
|
|
738
738
|
*/
|
|
739
739
|
whereDeepProp(e, t, r, s) {
|
|
740
|
-
var h,
|
|
741
|
-
if ((
|
|
740
|
+
var h, a, u;
|
|
741
|
+
if ((a = (h = this.queryObject.operations) == null ? void 0 : h.at(-1)) != null && a.aggregate && !s)
|
|
742
742
|
throw new Error(C.error.invalidQueryOrder);
|
|
743
743
|
const n = e.split(".");
|
|
744
|
-
let o = {},
|
|
745
|
-
return n.slice(1).forEach((
|
|
746
|
-
o[
|
|
744
|
+
let o = {}, c = n.length > 1 ? o : r;
|
|
745
|
+
return n.slice(1).forEach((b, R) => {
|
|
746
|
+
o[b] = R < n.length - 2 ? {} : r, o = o[b];
|
|
747
747
|
}), (u = this.queryObject.operations) == null || u.push({
|
|
748
748
|
property: n[0],
|
|
749
749
|
operator: t,
|
|
750
|
-
value:
|
|
750
|
+
value: c,
|
|
751
751
|
aggregate: s
|
|
752
752
|
}), this;
|
|
753
753
|
}
|
|
@@ -834,7 +834,7 @@ class J {
|
|
|
834
834
|
*/
|
|
835
835
|
instanceOf(e) {
|
|
836
836
|
var r;
|
|
837
|
-
const t = e instanceof
|
|
837
|
+
const t = e instanceof l ? e.className : e;
|
|
838
838
|
return (r = this.queryObject.operations) == null || r.push({
|
|
839
839
|
property: "__className",
|
|
840
840
|
operator: "==",
|
|
@@ -977,24 +977,31 @@ let A = y;
|
|
|
977
977
|
class E {
|
|
978
978
|
installCachedPropsUpdaters(e = {}) {
|
|
979
979
|
this.onUpdate = e.onUpdate;
|
|
980
|
-
const t =
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
else if (e.noThrowOnNonImplementedListener)
|
|
989
|
-
throw new Error("The method documentChangeListerner has not been implemented in the concrete data source");
|
|
980
|
+
const t = l.getSystemRegisteredReferencesWithCachedProps(), r = {};
|
|
981
|
+
Object.entries(t).forEach(([n, o]) => {
|
|
982
|
+
o.forEach((c) => {
|
|
983
|
+
const h = l.collectionPath(l.createInstance(n), c);
|
|
984
|
+
r[h] || (r[h] = []), r[h].push({
|
|
985
|
+
prop: c,
|
|
986
|
+
collectionPropOwner: n
|
|
987
|
+
});
|
|
990
988
|
});
|
|
991
|
-
})
|
|
989
|
+
});
|
|
990
|
+
const s = [];
|
|
991
|
+
return Object.entries(r).forEach(([n, o]) => {
|
|
992
|
+
const c = this.subscribeToDocumentChangeListerner(n, (h) => this.onDocumentChange(h, o));
|
|
993
|
+
if (c)
|
|
994
|
+
s.push(c);
|
|
995
|
+
else if (e.noThrowOnNonImplementedListener)
|
|
996
|
+
throw new Error("The method documentChangeListerner has not been implemented in the concrete data source");
|
|
997
|
+
}), s;
|
|
992
998
|
}
|
|
993
999
|
/**
|
|
994
1000
|
* Installs a document change listener
|
|
995
1001
|
* Implement the required logic to install a listener that will be called
|
|
996
1002
|
* when a document is changed in your concrete the data source
|
|
997
|
-
* @param
|
|
1003
|
+
* @param collectionPathToListen the name of the collection to be watched
|
|
1004
|
+
* @param props the properties to be watched in the collection
|
|
998
1005
|
* @param listener the listener to be called when a document is changed
|
|
999
1006
|
* @returns a function that uninstalls the listener. If the returned value is undefined
|
|
1000
1007
|
* the method documentChangeListerner has not been implemented in the concrete data source
|
|
@@ -1015,9 +1022,9 @@ class E {
|
|
|
1015
1022
|
*/
|
|
1016
1023
|
static toPropertyPathOperations(e) {
|
|
1017
1024
|
return e ? e.map((t) => {
|
|
1018
|
-
if (E.isArrayOperator(t.operator) && t.value[0] instanceof
|
|
1025
|
+
if (E.isArrayOperator(t.operator) && t.value[0] instanceof l)
|
|
1019
1026
|
return {
|
|
1020
|
-
property:
|
|
1027
|
+
property: l.searchableArrayNameFor(t.property),
|
|
1021
1028
|
operator: t.operator,
|
|
1022
1029
|
value: t.value.map((o) => o.id),
|
|
1023
1030
|
aggregate: t.aggregate
|
|
@@ -1041,29 +1048,31 @@ class E {
|
|
|
1041
1048
|
} else
|
|
1042
1049
|
return [void 0, e];
|
|
1043
1050
|
}
|
|
1044
|
-
async onDocumentChange(e, t
|
|
1045
|
-
if (
|
|
1046
|
-
return
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
const o = await n.get();
|
|
1054
|
-
return Promise.all([
|
|
1055
|
-
o.map(async (a) => {
|
|
1056
|
-
var h;
|
|
1057
|
-
(h = t.cachedProps) == null || h.forEach(async (c) => {
|
|
1058
|
-
var O;
|
|
1059
|
-
const u = e.before[c], P = e.after[c];
|
|
1060
|
-
u !== P && (a[`_${t.name}`][`_${c}`] = P, await s.save(a), (O = this.onUpdate) == null || O.call(this, a, t, r));
|
|
1051
|
+
async onDocumentChange(e, t) {
|
|
1052
|
+
if (e.before)
|
|
1053
|
+
return t.map(async (r) => {
|
|
1054
|
+
var c;
|
|
1055
|
+
const s = A.getModel(r.collectionPropOwner);
|
|
1056
|
+
let n = s.find();
|
|
1057
|
+
(c = r.prop.cachedProps) == null || c.forEach((h) => {
|
|
1058
|
+
const a = e.before[h], u = e.after[h];
|
|
1059
|
+
a !== u && (n = n.orDeepProp(`${r.prop.name}.${h}`, "==", a));
|
|
1061
1060
|
});
|
|
1062
|
-
|
|
1063
|
-
|
|
1061
|
+
const o = await n.get();
|
|
1062
|
+
return Promise.all([
|
|
1063
|
+
o.map(async (h) => {
|
|
1064
|
+
var a;
|
|
1065
|
+
(a = r.prop.cachedProps) == null || a.forEach(async (u) => {
|
|
1066
|
+
var I;
|
|
1067
|
+
const b = e.before[u], R = e.after[u];
|
|
1068
|
+
b !== R && (h[`_${r.prop.name}`][`_${u}`] = R, await s.save(h), (I = this.onUpdate) == null || I.call(this, h, r.prop));
|
|
1069
|
+
});
|
|
1070
|
+
})
|
|
1071
|
+
]);
|
|
1072
|
+
});
|
|
1064
1073
|
}
|
|
1065
1074
|
}
|
|
1066
|
-
class
|
|
1075
|
+
class pe extends E {
|
|
1067
1076
|
/**
|
|
1068
1077
|
* @param jsonRawData the JSON object to be used as data store
|
|
1069
1078
|
*/
|
|
@@ -1099,7 +1108,7 @@ class fe extends E {
|
|
|
1099
1108
|
return Object.entries(e).forEach(([r, s]) => {
|
|
1100
1109
|
this._jsonRawData[r] || (this._jsonRawData[r] = {}), s == null || s.forEach((n) => {
|
|
1101
1110
|
const o = this._jsonRawData[r][n.id];
|
|
1102
|
-
this._jsonRawData[r][n.id] = n, this.notifyChange(r, n, o);
|
|
1111
|
+
this._jsonRawData[r][n.id] = n, o && this.notifyChange(r, l.createInstance(n), l.createInstance(o));
|
|
1103
1112
|
});
|
|
1104
1113
|
}), this.resolveWithDelay();
|
|
1105
1114
|
}
|
|
@@ -1109,7 +1118,7 @@ class fe extends E {
|
|
|
1109
1118
|
throw new Error(this._simulateError.find);
|
|
1110
1119
|
const r = Object.values(this._jsonRawData[t] || {});
|
|
1111
1120
|
return e ? (this._lastLimit = e.limit || 0, this._cursor = 0, this._lastMatchingDocs = Object.entries(e).reduce(
|
|
1112
|
-
(n, [o,
|
|
1121
|
+
(n, [o, c]) => this.queryProcessor(n, o, c),
|
|
1113
1122
|
Object.values(r)
|
|
1114
1123
|
), this.resolveWithDelay(this._lastMatchingDocs.slice(0, e.limit))) : this.resolveWithDelay(r);
|
|
1115
1124
|
}
|
|
@@ -1152,19 +1161,18 @@ class fe extends E {
|
|
|
1152
1161
|
} : this._simulateError = e, this);
|
|
1153
1162
|
}
|
|
1154
1163
|
subscribeToDocumentChangeListerner(e, t) {
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
collectionPath: r
|
|
1161
|
-
};
|
|
1164
|
+
return delete this._listener[e], this._listener[e] = t, {
|
|
1165
|
+
uninstall: () => delete this._listener[e],
|
|
1166
|
+
nativeHandler: t,
|
|
1167
|
+
collectionPath: e
|
|
1168
|
+
};
|
|
1162
1169
|
}
|
|
1163
1170
|
notifyChange(e, t, r) {
|
|
1164
1171
|
const s = this._listener[e];
|
|
1165
1172
|
s && s({
|
|
1166
1173
|
before: r,
|
|
1167
|
-
after: t
|
|
1174
|
+
after: t,
|
|
1175
|
+
collectionPath: e
|
|
1168
1176
|
});
|
|
1169
1177
|
}
|
|
1170
1178
|
decCursor(e) {
|
|
@@ -1175,13 +1183,13 @@ class fe extends E {
|
|
|
1175
1183
|
limit: (n) => e,
|
|
1176
1184
|
//.slice( 0, limit ),
|
|
1177
1185
|
operations: (n) => this.retrieveQueryDocs(e, n),
|
|
1178
|
-
sort: ({ order: n, propertyName: o }) => e.sort((
|
|
1186
|
+
sort: ({ order: n, propertyName: o }) => e.sort((c, h) => n === "asc" ? this.deepValue(c, o) > this.deepValue(h, o) ? 1 : -1 : this.deepValue(c, o) < this.deepValue(h, o) ? 1 : -1)
|
|
1179
1187
|
}[t](r);
|
|
1180
1188
|
}
|
|
1181
1189
|
retrieveQueryDocs(e, t) {
|
|
1182
1190
|
return t.reduce((r, s, n) => {
|
|
1183
1191
|
if (s.aggregate) {
|
|
1184
|
-
const o = e.filter((
|
|
1192
|
+
const o = e.filter((c) => this.isQueryMatched(c, s));
|
|
1185
1193
|
return n === 0 ? o : r.concat(o);
|
|
1186
1194
|
} else
|
|
1187
1195
|
return r.filter((o) => this.isQueryMatched(o, s));
|
|
@@ -1192,22 +1200,22 @@ class fe extends E {
|
|
|
1192
1200
|
}
|
|
1193
1201
|
isQueryMatched(e, t) {
|
|
1194
1202
|
const r = {
|
|
1195
|
-
"==": (
|
|
1196
|
-
"!=": (
|
|
1197
|
-
"<": (
|
|
1198
|
-
"<=": (
|
|
1199
|
-
">": (
|
|
1200
|
-
">=": (
|
|
1201
|
-
containsAny: (
|
|
1202
|
-
contains: (
|
|
1203
|
-
}, { property: s, value: n, operator: o } = t, [
|
|
1204
|
-
return r[o](
|
|
1203
|
+
"==": (a, u) => a === u,
|
|
1204
|
+
"!=": (a, u) => a !== u,
|
|
1205
|
+
"<": (a, u) => a < u,
|
|
1206
|
+
"<=": (a, u) => a <= u,
|
|
1207
|
+
">": (a, u) => a > u,
|
|
1208
|
+
">=": (a, u) => a >= u,
|
|
1209
|
+
containsAny: (a, u) => a == null ? void 0 : a.some((b) => u == null ? void 0 : u.includes(b)),
|
|
1210
|
+
contains: (a, u) => a == null ? void 0 : a.includes(u)
|
|
1211
|
+
}, { property: s, value: n, operator: o } = t, [c, h] = this.retrieveValuesToCompare(e, s, n);
|
|
1212
|
+
return r[o](c, h);
|
|
1205
1213
|
}
|
|
1206
1214
|
retrieveValuesToCompare(e, t, r) {
|
|
1207
1215
|
const s = e[t];
|
|
1208
1216
|
if (s && typeof r == "object" && !Array.isArray(r)) {
|
|
1209
|
-
const
|
|
1210
|
-
var [n, o] = this.retrieveValuesToCompare(s,
|
|
1217
|
+
const c = Object.keys(r)[0];
|
|
1218
|
+
var [n, o] = this.retrieveValuesToCompare(s, c, r == null ? void 0 : r[c]);
|
|
1211
1219
|
}
|
|
1212
1220
|
return [n || s, o || r];
|
|
1213
1221
|
}
|
|
@@ -1225,12 +1233,12 @@ class fe extends E {
|
|
|
1225
1233
|
), t;
|
|
1226
1234
|
}
|
|
1227
1235
|
}
|
|
1228
|
-
const
|
|
1236
|
+
const P = class P {
|
|
1229
1237
|
static registerCloudStorage(e, t) {
|
|
1230
|
-
|
|
1238
|
+
P._cloudStorageFactoryMap[e] = t;
|
|
1231
1239
|
}
|
|
1232
1240
|
static createInstance(e) {
|
|
1233
|
-
const t =
|
|
1241
|
+
const t = P._cloudStorageFactoryMap[e];
|
|
1234
1242
|
if (!t)
|
|
1235
1243
|
throw new Error(`You should register the ${e} cloud storage provider prior to use it`);
|
|
1236
1244
|
return t();
|
|
@@ -1239,27 +1247,27 @@ const v = class v {
|
|
|
1239
1247
|
return this.__className;
|
|
1240
1248
|
}
|
|
1241
1249
|
static useCloudStorage(e) {
|
|
1242
|
-
|
|
1250
|
+
P._defaultCloudStorage = e;
|
|
1243
1251
|
}
|
|
1244
1252
|
static get defaultCloudStorage() {
|
|
1245
|
-
if (!
|
|
1253
|
+
if (!P._defaultCloudStorage)
|
|
1246
1254
|
throw new Error("You should define a default cloud storage provider prior to use it");
|
|
1247
|
-
return
|
|
1255
|
+
return P._defaultCloudStorage;
|
|
1248
1256
|
}
|
|
1249
1257
|
};
|
|
1250
|
-
|
|
1251
|
-
let
|
|
1252
|
-
function
|
|
1253
|
-
return
|
|
1258
|
+
P._cloudStorageFactoryMap = {};
|
|
1259
|
+
let v = P;
|
|
1260
|
+
function G(i, e) {
|
|
1261
|
+
return v.registerCloudStorage(i, e), (t) => {
|
|
1254
1262
|
t.prototype.__className = i;
|
|
1255
1263
|
};
|
|
1256
1264
|
}
|
|
1257
|
-
var
|
|
1258
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1265
|
+
var K = Object.defineProperty, X = Object.getOwnPropertyDescriptor, ee = (i, e, t, r) => {
|
|
1266
|
+
for (var s = r > 1 ? void 0 : r ? X(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
1259
1267
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1260
|
-
return r && s &&
|
|
1268
|
+
return r && s && K(e, t, s), s;
|
|
1261
1269
|
};
|
|
1262
|
-
let U = class extends
|
|
1270
|
+
let U = class extends v {
|
|
1263
1271
|
constructor(i = "") {
|
|
1264
1272
|
super(), this._simulateDelay = 0, this._pendingPromises = [], this.mockFileSystem = {}, this._pathToMockFiles = i;
|
|
1265
1273
|
}
|
|
@@ -1308,21 +1316,21 @@ let U = class extends w {
|
|
|
1308
1316
|
return delete this.mockFileSystem[i], this.resolveWithDelay();
|
|
1309
1317
|
}
|
|
1310
1318
|
};
|
|
1311
|
-
U =
|
|
1312
|
-
|
|
1319
|
+
U = ee([
|
|
1320
|
+
G("MockCloudStorage", () => new U())
|
|
1313
1321
|
], U);
|
|
1314
|
-
var
|
|
1315
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1322
|
+
var te = Object.defineProperty, re = Object.getOwnPropertyDescriptor, D = (i, e, t, r) => {
|
|
1323
|
+
for (var s = r > 1 ? void 0 : r ? re(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
1316
1324
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1317
|
-
return r && s &&
|
|
1318
|
-
},
|
|
1319
|
-
let
|
|
1325
|
+
return r && s && te(e, t, s), s;
|
|
1326
|
+
}, se = /* @__PURE__ */ ((i) => (i[i.stored = 0] = "stored", i[i.pendingDataSet = 1] = "pendingDataSet", i[i.deleted = 2] = "deleted", i))(se || {});
|
|
1327
|
+
let w = class extends l {
|
|
1320
1328
|
constructor() {
|
|
1321
1329
|
super(...arguments), this._onChange = new F();
|
|
1322
1330
|
}
|
|
1323
1331
|
async save({ data: i, fileName: e, progress: t, cloudStorageProvider: r } = {}) {
|
|
1324
1332
|
const s = i || this._pendingData;
|
|
1325
|
-
s && (this._reference && await this.delete(), this.provider = r ||
|
|
1333
|
+
s && (this._reference && await this.delete(), this.provider = r || v.defaultCloudStorage, this._originalFileName = e || (s instanceof File ? s.name : void 0), this._reference = await this.provider.save(this.id, s, t), this._url = await this.provider.getUrl(this._reference), this._pendingData = void 0, this._onChange.notify({ event: 0, storedFile: this }));
|
|
1326
1334
|
}
|
|
1327
1335
|
uploadControl() {
|
|
1328
1336
|
return this.provider.uploadControl();
|
|
@@ -1338,9 +1346,9 @@ let b = class extends d {
|
|
|
1338
1346
|
get provider() {
|
|
1339
1347
|
if (!this._provider)
|
|
1340
1348
|
try {
|
|
1341
|
-
this._provider =
|
|
1349
|
+
this._provider = v.createInstance(this._cloudStorageProviderName);
|
|
1342
1350
|
} catch {
|
|
1343
|
-
this._provider =
|
|
1351
|
+
this._provider = v.defaultCloudStorage;
|
|
1344
1352
|
}
|
|
1345
1353
|
return this._provider;
|
|
1346
1354
|
}
|
|
@@ -1366,25 +1374,25 @@ let b = class extends d {
|
|
|
1366
1374
|
};
|
|
1367
1375
|
D([
|
|
1368
1376
|
S
|
|
1369
|
-
],
|
|
1377
|
+
], w.prototype, "_reference", 2);
|
|
1370
1378
|
D([
|
|
1371
1379
|
S
|
|
1372
|
-
],
|
|
1380
|
+
], w.prototype, "_url", 2);
|
|
1373
1381
|
D([
|
|
1374
1382
|
S
|
|
1375
|
-
],
|
|
1383
|
+
], w.prototype, "_cloudStorageProviderName", 2);
|
|
1376
1384
|
D([
|
|
1377
1385
|
S
|
|
1378
|
-
],
|
|
1386
|
+
], w.prototype, "_originalFileName", 2);
|
|
1379
1387
|
D([
|
|
1380
1388
|
S
|
|
1381
|
-
],
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
],
|
|
1385
|
-
class
|
|
1389
|
+
], w.prototype, "_mimeType", 2);
|
|
1390
|
+
w = D([
|
|
1391
|
+
J("StoredFile")
|
|
1392
|
+
], w);
|
|
1393
|
+
class T {
|
|
1386
1394
|
}
|
|
1387
|
-
const p = class p extends
|
|
1395
|
+
const p = class p extends T {
|
|
1388
1396
|
constructor() {
|
|
1389
1397
|
if (super(), this._onAuthStateChange = new F(), !p._authService)
|
|
1390
1398
|
throw new Error(p.error.shouldBeRegistered);
|
|
@@ -1511,15 +1519,15 @@ const p = class p extends M {
|
|
|
1511
1519
|
}
|
|
1512
1520
|
};
|
|
1513
1521
|
p.error = { shouldBeRegistered: "You should register an auth service before using Auth." }, p._instance = void 0;
|
|
1514
|
-
let
|
|
1515
|
-
class
|
|
1522
|
+
let V = p;
|
|
1523
|
+
class me extends T {
|
|
1516
1524
|
constructor() {
|
|
1517
1525
|
super(...arguments), this.pendingPromises = [], this._fakeRegisteredUsers = {};
|
|
1518
1526
|
}
|
|
1519
1527
|
signUp(e) {
|
|
1520
|
-
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (
|
|
1521
|
-
var
|
|
1522
|
-
n === "email" && (r || h({ code: "missingEmail", message: "missingEmail" }), s || h({ code: "missingPassword", message: "missingPassword" })), s !== "fail" && r !== "fail" ? (this._loggedUser = this.userCredentials(e), this._fakeRegisteredUsers[this._loggedUser.id] = this._loggedUser,
|
|
1528
|
+
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (c, h) => {
|
|
1529
|
+
var a, u;
|
|
1530
|
+
n === "email" && (r || h({ code: "missingEmail", message: "missingEmail" }), s || h({ code: "missingPassword", message: "missingPassword" })), s !== "fail" && r !== "fail" ? (this._loggedUser = this.userCredentials(e), this._fakeRegisteredUsers[this._loggedUser.id] = this._loggedUser, c(this._loggedUser), (a = this.notifyChange) == null || a.call(this, this._loggedUser)) : (h({ code: "userNotFound", message: t || "Test auth error" }), (u = this.notifyChange) == null || u.call(this, void 0));
|
|
1523
1531
|
});
|
|
1524
1532
|
return this.pendingPromises.push(o), o;
|
|
1525
1533
|
}
|
|
@@ -1609,16 +1617,16 @@ const g = class g {
|
|
|
1609
1617
|
}
|
|
1610
1618
|
processParam(e) {
|
|
1611
1619
|
if (e != null)
|
|
1612
|
-
return e instanceof
|
|
1620
|
+
return e instanceof l ? 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;
|
|
1613
1621
|
}
|
|
1614
1622
|
processResult(e) {
|
|
1615
1623
|
if (e != null)
|
|
1616
|
-
return e.__className ?
|
|
1624
|
+
return e.__className ? l.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;
|
|
1617
1625
|
}
|
|
1618
1626
|
};
|
|
1619
1627
|
g.error = { shouldBeRegistered: "You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions." };
|
|
1620
|
-
let
|
|
1621
|
-
class
|
|
1628
|
+
let $ = g;
|
|
1629
|
+
class ge {
|
|
1622
1630
|
constructor(e) {
|
|
1623
1631
|
this._registeredFunctions = e;
|
|
1624
1632
|
}
|
|
@@ -1632,9 +1640,9 @@ class me {
|
|
|
1632
1640
|
return e(t);
|
|
1633
1641
|
}
|
|
1634
1642
|
}
|
|
1635
|
-
class
|
|
1643
|
+
class x {
|
|
1636
1644
|
}
|
|
1637
|
-
const m = class m extends
|
|
1645
|
+
const m = class m extends x {
|
|
1638
1646
|
constructor() {
|
|
1639
1647
|
super();
|
|
1640
1648
|
}
|
|
@@ -1660,8 +1668,8 @@ const m = class m extends T {
|
|
|
1660
1668
|
}
|
|
1661
1669
|
};
|
|
1662
1670
|
m.error = { shouldBeRegistered: "You should register a Server Auth service before using the Server Auth." }, m._instance = void 0;
|
|
1663
|
-
let
|
|
1664
|
-
class
|
|
1671
|
+
let k = m;
|
|
1672
|
+
class _e extends x {
|
|
1665
1673
|
constructor(e) {
|
|
1666
1674
|
super(), this._userCredentials = e;
|
|
1667
1675
|
}
|
|
@@ -1688,12 +1696,12 @@ class ge extends T {
|
|
|
1688
1696
|
return this._userCredentials;
|
|
1689
1697
|
}
|
|
1690
1698
|
}
|
|
1691
|
-
function
|
|
1699
|
+
function ye(i, e) {
|
|
1692
1700
|
return i ? i.replace(/\${\s*(\w*)\s*}/g, function(t, r) {
|
|
1693
1701
|
return e[r] || "";
|
|
1694
1702
|
}) : "";
|
|
1695
1703
|
}
|
|
1696
|
-
function
|
|
1704
|
+
function Pe(i) {
|
|
1697
1705
|
return i ? i.replace(
|
|
1698
1706
|
/([-_ ][\w])/g,
|
|
1699
1707
|
(e) => e.toUpperCase().replace("-", "").replace("_", "").replace(" ", "")
|
|
@@ -1705,46 +1713,46 @@ function ve(i, e = "-") {
|
|
|
1705
1713
|
const t = i.slice(1).replace(/( |[A-Z])/g, (r) => r === " " ? "-" : e + r[0].toLowerCase());
|
|
1706
1714
|
return i[0].toLocaleLowerCase() + t.replace(/--/g, "-");
|
|
1707
1715
|
}
|
|
1708
|
-
function
|
|
1716
|
+
function we(i, e) {
|
|
1709
1717
|
return e.split(".").reduce((t, r) => t[r], i);
|
|
1710
1718
|
}
|
|
1711
1719
|
export {
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1720
|
+
V as Auth,
|
|
1721
|
+
me as AuthMock,
|
|
1722
|
+
T as AuthService,
|
|
1723
|
+
$ as CloudFunctions,
|
|
1724
|
+
ge as CloudFunctionsMock,
|
|
1725
|
+
v as CloudStorage,
|
|
1718
1726
|
E as DataSource,
|
|
1719
|
-
|
|
1720
|
-
|
|
1727
|
+
fe as EntropicComponent,
|
|
1728
|
+
pe as JsonDataSource,
|
|
1721
1729
|
U as MockCloudStorage,
|
|
1722
1730
|
C as Model,
|
|
1723
1731
|
F as Observable,
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1732
|
+
l as Persistent,
|
|
1733
|
+
Z as Query,
|
|
1734
|
+
k as ServerAuth,
|
|
1735
|
+
_e as ServerAuthMock,
|
|
1736
|
+
x as ServerAuthService,
|
|
1729
1737
|
A as Store,
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1738
|
+
w as StoredFile,
|
|
1739
|
+
se as StoredFileEvent,
|
|
1740
|
+
Pe as camelCase,
|
|
1741
|
+
we as getDeepValue,
|
|
1734
1742
|
S as persistent,
|
|
1735
1743
|
_ as persistentParser,
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1744
|
+
ae as persistentPureReference,
|
|
1745
|
+
ce as persistentPureReferenceWithCachedProps,
|
|
1746
|
+
ne as persistentReference,
|
|
1747
|
+
ie as persistentReferenceAt,
|
|
1748
|
+
oe as persistentReferenceWithCachedProps,
|
|
1749
|
+
G as registerCloudStorage,
|
|
1750
|
+
ue as registerLegacyClassName,
|
|
1751
|
+
J as registerPersistentClass,
|
|
1752
|
+
ye as replaceValue,
|
|
1753
|
+
le as required,
|
|
1754
|
+
de as requiredWithValidator,
|
|
1755
|
+
he as searchableArray,
|
|
1748
1756
|
ve as snakeCase
|
|
1749
1757
|
};
|
|
1750
1758
|
//# sourceMappingURL=entropic-bond.js.map
|