entropic-bond 1.55.0 → 1.55.2
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 +284 -282
- package/lib/entropic-bond.js.map +1 -1
- package/lib/entropic-bond.umd.cjs +2 -2
- package/lib/entropic-bond.umd.cjs.map +1 -1
- package/lib/persistent/persistent.d.ts +1 -0
- package/lib/store/cached-props-updater.d.ts +4 -2
- package/lib/store/data-source.d.ts +6 -3
- package/lib/store/json-data-source.d.ts +3 -1
- package/package.json +1 -1
package/lib/entropic-bond.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class T {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
4
4
|
}
|
|
@@ -46,36 +46,36 @@ class k {
|
|
|
46
46
|
const f = [];
|
|
47
47
|
for (let i = 0; i < 256; ++i)
|
|
48
48
|
f.push((i + 256).toString(16).slice(1));
|
|
49
|
-
function
|
|
49
|
+
function q(i, e = 0) {
|
|
50
50
|
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]]).toLowerCase();
|
|
51
51
|
}
|
|
52
52
|
let N;
|
|
53
|
-
const
|
|
54
|
-
function
|
|
53
|
+
const Y = new Uint8Array(16);
|
|
54
|
+
function z() {
|
|
55
55
|
if (!N) {
|
|
56
56
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
57
57
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
58
58
|
N = crypto.getRandomValues.bind(crypto);
|
|
59
59
|
}
|
|
60
|
-
return N(
|
|
60
|
+
return N(Y);
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
function
|
|
62
|
+
const H = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), I = { randomUUID: H };
|
|
63
|
+
function J(i, e, t) {
|
|
64
64
|
i = i || {};
|
|
65
|
-
const r = i.random ?? i.rng?.() ??
|
|
65
|
+
const r = i.random ?? i.rng?.() ?? z();
|
|
66
66
|
if (r.length < 16)
|
|
67
67
|
throw new Error("Random bytes length must be >= 16");
|
|
68
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128,
|
|
68
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, q(r);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
70
|
+
function Z(i, e, t) {
|
|
71
|
+
return I.randomUUID && !i ? I.randomUUID() : J(i);
|
|
72
72
|
}
|
|
73
|
-
var
|
|
73
|
+
var G = Object.defineProperty, K = (i, e, t, r) => {
|
|
74
74
|
for (var s = void 0, n = i.length - 1, o; n >= 0; n--)
|
|
75
75
|
(o = i[n]) && (s = o(e, t, s) || s);
|
|
76
|
-
return s &&
|
|
77
|
-
},
|
|
78
|
-
const
|
|
76
|
+
return s && G(e, t, s), s;
|
|
77
|
+
}, h;
|
|
78
|
+
const V = (h = class {
|
|
79
79
|
/**
|
|
80
80
|
* Registers a class to be used by the persistence engine.
|
|
81
81
|
* @param className the name of the class to be registered
|
|
@@ -136,14 +136,14 @@ const $ = (u = class {
|
|
|
136
136
|
* @see registerFactory
|
|
137
137
|
*/
|
|
138
138
|
static annotations(e) {
|
|
139
|
-
if (e instanceof
|
|
139
|
+
if (e instanceof h ? e = e.className : typeof e == "string" || (e = new e().className), !this._factoryMap[e]) throw new Error(`You should register class ${e} prior to use.`);
|
|
140
140
|
return this._factoryMap[e].annotation;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
143
|
* Returns a new instance of Persistent class.
|
|
144
144
|
* @param className the initial id of this instance. If not provided, a new id will be generated
|
|
145
145
|
*/
|
|
146
|
-
constructor(e =
|
|
146
|
+
constructor(e = Z()) {
|
|
147
147
|
this._id = e;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
@@ -273,7 +273,7 @@ const $ = (u = class {
|
|
|
273
273
|
if (!this.className) throw new Error(`You should register \`${this.constructor.name || this.toString() || "this"}\` class prior to streaming it.`);
|
|
274
274
|
return this._persistentProperties.forEach((r) => {
|
|
275
275
|
const s = this[r.name], n = this.removeUnderscore(r);
|
|
276
|
-
s != null && (r.isReference ? t[n] = this.toReferenceObj(r, e) : t[n] = this.toDeepObj(s, e), r.searchableArray && (t[
|
|
276
|
+
s != null && (r.isReference ? t[n] = this.toReferenceObj(r, e) : t[n] = this.toDeepObj(s, e), r.searchableArray && (t[h.searchableArrayNameFor(n)] = s.map((o) => o.id)));
|
|
277
277
|
}), t.__className = this.className, t;
|
|
278
278
|
}
|
|
279
279
|
static searchableArrayNameFor(e) {
|
|
@@ -284,11 +284,11 @@ const $ = (u = 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 = h.createInstance(t);
|
|
288
288
|
return r.__documentReference = e.__documentReference, r;
|
|
289
289
|
}
|
|
290
290
|
if (e.__className)
|
|
291
|
-
return
|
|
291
|
+
return h.createInstance(e);
|
|
292
292
|
if (typeof e == "object") {
|
|
293
293
|
const t = {};
|
|
294
294
|
return Object.entries(e).forEach(
|
|
@@ -302,7 +302,7 @@ const $ = (u = class {
|
|
|
302
302
|
if (Array.isArray(e))
|
|
303
303
|
return e.map((r) => this.toDeepObj(r, t));
|
|
304
304
|
if (e.__documentReference) return e;
|
|
305
|
-
if (e instanceof
|
|
305
|
+
if (e instanceof h)
|
|
306
306
|
return e.toObj(t);
|
|
307
307
|
if (typeof e == "object") {
|
|
308
308
|
const r = {};
|
|
@@ -319,7 +319,7 @@ const $ = (u = class {
|
|
|
319
319
|
}
|
|
320
320
|
toReferenceObj(e, t) {
|
|
321
321
|
const r = this[e.name];
|
|
322
|
-
return Array.isArray(r) ? r.map((s) => (e.isPureReference || this.pushDocument(t,
|
|
322
|
+
return Array.isArray(r) ? r.map((s) => (e.isPureReference || this.pushDocument(t, h.collectionPath(s, e), s), this.buildRefObject(s, h.collectionPath(s, e), e.cachedProps))) : (e.isPureReference || this.pushDocument(t, h.collectionPath(r, e), r), this.buildRefObject(r, h.collectionPath(r, e), e.cachedProps));
|
|
323
323
|
}
|
|
324
324
|
buildRefObject(e, t, r) {
|
|
325
325
|
const s = r?.reduce((n, o) => (e[o] !== void 0 && (n[o] = e[o]), n), {});
|
|
@@ -342,14 +342,14 @@ const $ = (u = class {
|
|
|
342
342
|
return e.name.slice(1);
|
|
343
343
|
}
|
|
344
344
|
static createReference(e) {
|
|
345
|
-
const t =
|
|
345
|
+
const t = h.createInstance(e);
|
|
346
346
|
return t.__documentReference = e.__documentReference || { storedInCollection: t.className }, t;
|
|
347
347
|
}
|
|
348
348
|
static createInstance(e) {
|
|
349
349
|
if (typeof e == "string")
|
|
350
|
-
return new (
|
|
350
|
+
return new (h.classFactory(e))();
|
|
351
351
|
try {
|
|
352
|
-
return new (
|
|
352
|
+
return new (h.classFactory(e.__className))().fromObject(e);
|
|
353
353
|
} catch (t) {
|
|
354
354
|
const r = Object.entries(e).filter(([s, n]) => n != null && typeof n != "function").map(([s, n]) => `${s}: ${n}`).join(`,
|
|
355
355
|
`);
|
|
@@ -362,7 +362,7 @@ const $ = (u = class {
|
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
static propInfo(e, t) {
|
|
365
|
-
return
|
|
365
|
+
return h.createInstance(e).getPropInfo(t);
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
368
368
|
* Return the type of a persistent property.
|
|
@@ -376,35 +376,35 @@ const $ = (u = class {
|
|
|
376
376
|
*/
|
|
377
377
|
static propType(e) {
|
|
378
378
|
if (e.typeName) return Array.isArray(e.typeName) ? "undefined[]" : e.typeName ?? "undefined";
|
|
379
|
-
const r =
|
|
379
|
+
const r = h.createInstance(e.ownerClassName())[e.name];
|
|
380
380
|
if (Array.isArray(r)) {
|
|
381
381
|
if (r.length === 0) return "undefined[]";
|
|
382
382
|
const s = r[0];
|
|
383
|
-
return s instanceof
|
|
383
|
+
return s instanceof h ? s.className + "[]" : typeof s + "[]";
|
|
384
384
|
} else
|
|
385
|
-
return r instanceof
|
|
385
|
+
return r instanceof h ? r.className : typeof r;
|
|
386
386
|
}
|
|
387
387
|
/**
|
|
388
388
|
* Retrieves a collection of references with the properties that are stored in the reference object
|
|
389
389
|
* @returns the references collection
|
|
390
390
|
*/
|
|
391
391
|
static getSystemRegisteredReferencesWithCachedProps() {
|
|
392
|
-
return
|
|
393
|
-
const o =
|
|
392
|
+
return h.registeredClasses().reduce((r, s) => {
|
|
393
|
+
const o = h.createInstance(s).getPersistentProperties().filter(
|
|
394
394
|
(a) => a.cachedProps
|
|
395
395
|
);
|
|
396
396
|
return o.length > 0 && (r[s] = o), r;
|
|
397
397
|
}, {});
|
|
398
398
|
}
|
|
399
|
-
},
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
],
|
|
403
|
-
let
|
|
404
|
-
function
|
|
399
|
+
}, h._factoryMap = {}, h);
|
|
400
|
+
K([
|
|
401
|
+
U
|
|
402
|
+
], V.prototype, "_id");
|
|
403
|
+
let l = V;
|
|
404
|
+
function U(i, e) {
|
|
405
405
|
return _()(i, e);
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function ae(i) {
|
|
408
408
|
return function(e, t) {
|
|
409
409
|
return _({
|
|
410
410
|
storeInCollection: i,
|
|
@@ -412,10 +412,10 @@ function ne(i) {
|
|
|
412
412
|
})(e, t);
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function ce(i, e) {
|
|
416
416
|
return _({ isReference: !0 })(i, e);
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function ue(i, e, t, r) {
|
|
419
419
|
return function(s, n) {
|
|
420
420
|
const o = {
|
|
421
421
|
isReference: !0,
|
|
@@ -427,10 +427,10 @@ function ae(i, e, t, r) {
|
|
|
427
427
|
return _(o)(s, n);
|
|
428
428
|
};
|
|
429
429
|
}
|
|
430
|
-
function
|
|
430
|
+
function he(i, e, t) {
|
|
431
431
|
return _({ isReference: !0, isPureReference: !0, storeInCollection: t })(i, e);
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function le(i, e, t, r) {
|
|
434
434
|
return function(s, n) {
|
|
435
435
|
return _({
|
|
436
436
|
isReference: !0,
|
|
@@ -453,36 +453,36 @@ function _(i) {
|
|
|
453
453
|
});
|
|
454
454
|
};
|
|
455
455
|
}
|
|
456
|
-
function
|
|
456
|
+
function X(i, e) {
|
|
457
457
|
return (t) => {
|
|
458
|
-
|
|
458
|
+
l.registerFactory(i, t, e), t.prototype.__className = i;
|
|
459
459
|
};
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function de(i) {
|
|
462
462
|
return (e) => {
|
|
463
|
-
|
|
463
|
+
l.registerFactory(i, e, void 0, !0);
|
|
464
464
|
};
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function fe(i, e) {
|
|
467
467
|
return _({ searchableArray: !0 })(i, e);
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function pe(i, e) {
|
|
470
470
|
return _({ validator: (t) => t != null })(i, e);
|
|
471
471
|
}
|
|
472
|
-
function
|
|
472
|
+
function me(i = (e) => e != null) {
|
|
473
473
|
return function(e, t) {
|
|
474
474
|
return _({ validator: i })(e, t);
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function ge(i) {
|
|
478
478
|
let e;
|
|
479
479
|
return typeof i == "function" ? e = new i().className : e = i, function(t, r) {
|
|
480
480
|
return _({ typeName: e })(t, r);
|
|
481
481
|
};
|
|
482
482
|
}
|
|
483
|
-
class
|
|
483
|
+
class _e extends l {
|
|
484
484
|
constructor() {
|
|
485
|
-
super(...arguments), this._onChange = new
|
|
485
|
+
super(...arguments), this._onChange = new T();
|
|
486
486
|
}
|
|
487
487
|
/**
|
|
488
488
|
* Subscribes a listener callback function. Every time a property is changed,
|
|
@@ -568,10 +568,10 @@ class pe extends h {
|
|
|
568
568
|
const E = class E {
|
|
569
569
|
constructor(e, t, r) {
|
|
570
570
|
if (r) {
|
|
571
|
-
if (!(t instanceof
|
|
571
|
+
if (!(t instanceof l)) throw new Error(E.error.persistentNeedForSubCollection);
|
|
572
572
|
this.collectionName = `${t.className}/${t.id}/${r}`;
|
|
573
573
|
} else
|
|
574
|
-
this.collectionName = t instanceof
|
|
574
|
+
this.collectionName = t instanceof l ? t.className : t;
|
|
575
575
|
this._stream = e;
|
|
576
576
|
}
|
|
577
577
|
/**
|
|
@@ -586,7 +586,7 @@ const E = class E {
|
|
|
586
586
|
findById(e, t) {
|
|
587
587
|
return new Promise((r, s) => {
|
|
588
588
|
this._stream.findById(e, this.collectionName).then((n) => {
|
|
589
|
-
n ? (t ? t.fromObject(n) : t =
|
|
589
|
+
n ? (t ? t.fromObject(n) : t = l.createInstance(n), r(t)) : r(void 0);
|
|
590
590
|
}).catch((n) => s(n));
|
|
591
591
|
});
|
|
592
592
|
}
|
|
@@ -617,7 +617,7 @@ const E = class E {
|
|
|
617
617
|
* @returns a Query object
|
|
618
618
|
*/
|
|
619
619
|
find() {
|
|
620
|
-
return new
|
|
620
|
+
return new ee(this);
|
|
621
621
|
}
|
|
622
622
|
/**
|
|
623
623
|
* Define the search conditions. You pass query operations and how the query
|
|
@@ -628,7 +628,7 @@ const E = class E {
|
|
|
628
628
|
*/
|
|
629
629
|
query(e = {}, t) {
|
|
630
630
|
if (t) {
|
|
631
|
-
const r = t instanceof
|
|
631
|
+
const r = t instanceof l ? t.className : t;
|
|
632
632
|
e.operations || (e.operations = []), e.operations.push(
|
|
633
633
|
{ property: "__className", operator: "==", value: r }
|
|
634
634
|
);
|
|
@@ -658,7 +658,7 @@ const E = class E {
|
|
|
658
658
|
return this._stream.onDocumentChange(
|
|
659
659
|
this.collectionName,
|
|
660
660
|
e,
|
|
661
|
-
(r) => t(
|
|
661
|
+
(r) => t(b.toPersistentDocumentChange(r))
|
|
662
662
|
);
|
|
663
663
|
}
|
|
664
664
|
onCollectionChange(e, t) {
|
|
@@ -666,7 +666,7 @@ const E = class E {
|
|
|
666
666
|
this.preprocessQueryObject(e.getQueryObject()),
|
|
667
667
|
this.collectionName,
|
|
668
668
|
(r) => t(r.map(
|
|
669
|
-
(s) =>
|
|
669
|
+
(s) => b.toPersistentDocumentChange(s)
|
|
670
670
|
))
|
|
671
671
|
);
|
|
672
672
|
}
|
|
@@ -682,7 +682,7 @@ const E = class E {
|
|
|
682
682
|
mapToInstance(e) {
|
|
683
683
|
return new Promise((t, r) => {
|
|
684
684
|
e().then((s) => t(
|
|
685
|
-
s.map((n) =>
|
|
685
|
+
s.map((n) => l.createInstance(n))
|
|
686
686
|
)).catch((s) => r(s));
|
|
687
687
|
});
|
|
688
688
|
}
|
|
@@ -698,15 +698,15 @@ const E = class E {
|
|
|
698
698
|
if (Object.values(e).length === 0) return e;
|
|
699
699
|
const t = e.operations?.map((r) => {
|
|
700
700
|
const s = r.value[0] ?? r.value;
|
|
701
|
-
return
|
|
702
|
-
property:
|
|
701
|
+
return b.isArrayOperator(r.operator) && s instanceof l ? {
|
|
702
|
+
property: l.searchableArrayNameFor(r.property),
|
|
703
703
|
operator: r.operator,
|
|
704
704
|
value: Array.isArray(r.value) ? r.value.map((n) => n.id) : s.id,
|
|
705
705
|
aggregate: r.aggregate
|
|
706
706
|
} : {
|
|
707
707
|
property: r.property,
|
|
708
708
|
operator: r.operator,
|
|
709
|
-
value: r.value instanceof
|
|
709
|
+
value: r.value instanceof l ? { id: r.value.id } : r.value,
|
|
710
710
|
aggregate: r.aggregate
|
|
711
711
|
};
|
|
712
712
|
}) ?? [];
|
|
@@ -720,8 +720,8 @@ E.error = {
|
|
|
720
720
|
persistentNeedForSubCollection: "The document parameter for a sub-collection should be a Persistent instace",
|
|
721
721
|
invalidQueryOrder: "Cannot add where calls after or calls"
|
|
722
722
|
};
|
|
723
|
-
let
|
|
724
|
-
class
|
|
723
|
+
let R = E;
|
|
724
|
+
class ee {
|
|
725
725
|
constructor(e) {
|
|
726
726
|
this.queryObject = { operations: [] }, this.model = e;
|
|
727
727
|
}
|
|
@@ -745,7 +745,7 @@ class K {
|
|
|
745
745
|
* @see orDeepProp
|
|
746
746
|
*/
|
|
747
747
|
where(e, t, r, s) {
|
|
748
|
-
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(
|
|
748
|
+
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(R.error.invalidQueryOrder);
|
|
749
749
|
return this.queryObject.operations?.push({
|
|
750
750
|
property: e,
|
|
751
751
|
operator: t,
|
|
@@ -778,11 +778,11 @@ class K {
|
|
|
778
778
|
* @see orDeepProp
|
|
779
779
|
*/
|
|
780
780
|
whereDeepProp(e, t, r, s) {
|
|
781
|
-
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(
|
|
781
|
+
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(R.error.invalidQueryOrder);
|
|
782
782
|
const n = e.split(".");
|
|
783
783
|
let o = {}, a = n.length > 1 ? o : r;
|
|
784
|
-
return n.slice(1).forEach((d,
|
|
785
|
-
o[d] =
|
|
784
|
+
return n.slice(1).forEach((d, c) => {
|
|
785
|
+
o[d] = c < n.length - 2 ? {} : r, o = o[d];
|
|
786
786
|
}), this.queryObject.operations?.push({
|
|
787
787
|
property: n[0],
|
|
788
788
|
operator: t,
|
|
@@ -872,7 +872,7 @@ class K {
|
|
|
872
872
|
* query.instanceOf( Person ).where( 'age', '>', 18 )
|
|
873
873
|
*/
|
|
874
874
|
instanceOf(e) {
|
|
875
|
-
const t = e instanceof
|
|
875
|
+
const t = e instanceof l ? e.className : e;
|
|
876
876
|
return this.queryObject.operations?.push({
|
|
877
877
|
property: "__className",
|
|
878
878
|
operator: "==",
|
|
@@ -942,7 +942,7 @@ class K {
|
|
|
942
942
|
return this.queryObject;
|
|
943
943
|
}
|
|
944
944
|
}
|
|
945
|
-
const
|
|
945
|
+
const w = class w {
|
|
946
946
|
constructor() {
|
|
947
947
|
}
|
|
948
948
|
/**
|
|
@@ -958,7 +958,7 @@ const P = class P {
|
|
|
958
958
|
* @returns the data source
|
|
959
959
|
*/
|
|
960
960
|
static get dataSource() {
|
|
961
|
-
return
|
|
961
|
+
return w._dataSource;
|
|
962
962
|
}
|
|
963
963
|
/**
|
|
964
964
|
* Retrieves a model for a collection
|
|
@@ -966,8 +966,8 @@ const P = class P {
|
|
|
966
966
|
* @returns the model for the collection
|
|
967
967
|
*/
|
|
968
968
|
static getModel(e) {
|
|
969
|
-
if (!
|
|
970
|
-
return new
|
|
969
|
+
if (!w._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
970
|
+
return new R(w._dataSource, e);
|
|
971
971
|
}
|
|
972
972
|
/**
|
|
973
973
|
* Retrieves a model for a subcollection
|
|
@@ -976,8 +976,8 @@ const P = class P {
|
|
|
976
976
|
* @returns the model for the subcollection
|
|
977
977
|
*/
|
|
978
978
|
static getModelForSubCollection(e, t) {
|
|
979
|
-
if (!
|
|
980
|
-
return new
|
|
979
|
+
if (!w._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
980
|
+
return new R(w._dataSource, e, t);
|
|
981
981
|
}
|
|
982
982
|
/**
|
|
983
983
|
* Populates property references with actual data from the store.
|
|
@@ -1009,31 +1009,33 @@ const P = class P {
|
|
|
1009
1009
|
) : e.__documentReference === void 0;
|
|
1010
1010
|
}
|
|
1011
1011
|
};
|
|
1012
|
-
|
|
1013
|
-
let
|
|
1014
|
-
class
|
|
1012
|
+
w.error = { shouldBeRegistered: "You should register a data source before using the data Store." };
|
|
1013
|
+
let M = w;
|
|
1014
|
+
class k {
|
|
1015
1015
|
constructor(e) {
|
|
1016
1016
|
this.handlers = [], this.subscribeToDocumentChangeListener = () => {
|
|
1017
1017
|
throw new Error("The method subscribeToDocumentChangeListener has not been implemented in the concrete data source");
|
|
1018
|
+
}, this.collectionsMatchingTemplate = () => {
|
|
1019
|
+
throw new Error("The method collectionsMatchingTemplate has not been implemented in the concrete data source");
|
|
1018
1020
|
}, e && (this.beforeUpdate = e.beforeUpdateDocument, this.afterUpdate = e.afterUpdateDocument, this.onAllPropsUpdatedCallback = e.onAllPropsUpdated);
|
|
1019
1021
|
}
|
|
1020
|
-
installUpdaters() {
|
|
1021
|
-
const e =
|
|
1022
|
+
async installUpdaters() {
|
|
1023
|
+
const e = l.getSystemRegisteredReferencesWithCachedProps(), t = {};
|
|
1022
1024
|
return Object.entries(e).forEach(([r, s]) => {
|
|
1023
1025
|
s.forEach((n) => {
|
|
1024
1026
|
if (!n.typeName) return;
|
|
1025
|
-
(Array.isArray(n.typeName) ? n.typeName : [n?.typeName ?? r]).map((a) =>
|
|
1027
|
+
(Array.isArray(n.typeName) ? n.typeName : [n?.typeName ?? r]).map((a) => l.collectionPath(l.createInstance(a), n)).forEach((a) => {
|
|
1026
1028
|
t[a] || (t[a] = []), t[a].push(n);
|
|
1027
1029
|
});
|
|
1028
1030
|
});
|
|
1029
|
-
}), this.handlers = [], Object.entries(t).
|
|
1030
|
-
const n = this.subscribeToDocumentChangeListener(
|
|
1031
|
+
}), this.handlers = [], await Promise.all(Object.entries(t).map(async ([r, s]) => {
|
|
1032
|
+
const n = await this.subscribeToDocumentChangeListener(
|
|
1031
1033
|
r,
|
|
1032
1034
|
(o) => this.onDocumentChange(o, s)
|
|
1033
1035
|
);
|
|
1034
1036
|
if (n) this.handlers.push(n);
|
|
1035
1037
|
else throw new Error("The method documentChangeListener has not been implemented in the concrete data source");
|
|
1036
|
-
}), this.handlers;
|
|
1038
|
+
})), this.handlers;
|
|
1037
1039
|
}
|
|
1038
1040
|
uninstallUpdaters() {
|
|
1039
1041
|
this.handlers.forEach((e) => e.uninstall()), this.handlers = [];
|
|
@@ -1050,44 +1052,38 @@ class I {
|
|
|
1050
1052
|
set documentChangeListenerSubscriber(e) {
|
|
1051
1053
|
this.subscribeToDocumentChangeListener = e;
|
|
1052
1054
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
// const snapshot = event[0]!
|
|
1057
|
-
// listener( snapshot )
|
|
1058
|
-
// })
|
|
1059
|
-
// return {
|
|
1060
|
-
// uninstall: handler,
|
|
1061
|
-
// nativeHandler: handler,
|
|
1062
|
-
// collectionPath: collectionPathToListen
|
|
1063
|
-
// }
|
|
1064
|
-
// }
|
|
1055
|
+
set collectionsMatchingTemplateFunction(e) {
|
|
1056
|
+
this.collectionsMatchingTemplate = e;
|
|
1057
|
+
}
|
|
1065
1058
|
async onDocumentChange(e, t) {
|
|
1066
|
-
const r =
|
|
1059
|
+
const r = b.toPersistentDocumentChange(e);
|
|
1067
1060
|
r.before && (await Promise.all(t.map(async (s) => {
|
|
1068
|
-
const n =
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
g
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1061
|
+
const n = k.ownerCollectionPath(l.createInstance(s.ownerClassName()), s, r.params), o = await this.collectionsMatchingTemplate(n);
|
|
1062
|
+
await Promise.all(o.map(async (a) => {
|
|
1063
|
+
const d = M.getModel(a);
|
|
1064
|
+
let c = d.find(), u = !1;
|
|
1065
|
+
s.cachedProps?.forEach((g) => {
|
|
1066
|
+
const O = r.before[g], P = r.after[g];
|
|
1067
|
+
O !== P && (u = !0);
|
|
1068
|
+
}), u && (s.searchableArray ? c = c.where(s.name, "contains", r.before) : c = c.where(s.name, "==", r.before));
|
|
1069
|
+
const C = await c.get();
|
|
1070
|
+
return Promise.all([
|
|
1071
|
+
C.map(async (g) => {
|
|
1072
|
+
let O = !1;
|
|
1073
|
+
if (s.cachedProps?.forEach((P) => {
|
|
1074
|
+
const A = r.before[P], Q = r.after[P];
|
|
1075
|
+
A !== Q && (O = !0);
|
|
1076
|
+
}), O) {
|
|
1077
|
+
if (s.searchableArray) {
|
|
1078
|
+
const P = g[s.name].findIndex((A) => A.id === r.before.id);
|
|
1079
|
+
g[s.name][P] = r.after;
|
|
1080
|
+
} else
|
|
1081
|
+
g[`_${s.name}`] = r.after;
|
|
1082
|
+
this.beforeUpdate?.(g, s), await d.save(g), this.afterUpdate?.(g, s);
|
|
1083
|
+
} else await Promise.resolve();
|
|
1084
|
+
})
|
|
1085
|
+
]);
|
|
1086
|
+
}));
|
|
1091
1087
|
})), this.onAllPropsUpdatedCallback?.());
|
|
1092
1088
|
}
|
|
1093
1089
|
static ownerCollectionPath(e, t, r) {
|
|
@@ -1095,37 +1091,12 @@ class I {
|
|
|
1095
1091
|
return typeof t.ownerCollection == "function" ? s = t.ownerCollection(e, t, r) : s = t.ownerCollection ?? e.className, s;
|
|
1096
1092
|
}
|
|
1097
1093
|
}
|
|
1098
|
-
class
|
|
1094
|
+
class b {
|
|
1099
1095
|
constructor() {
|
|
1100
1096
|
this._cachedPropsUpdater = void 0;
|
|
1101
1097
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
* Implement the required logic to install a listener that will be called
|
|
1105
|
-
* when a document is changed in your concrete the data source
|
|
1106
|
-
* @param collectionPathToListen the name of the collection to be watched
|
|
1107
|
-
* @param props the properties to be watched in the collection
|
|
1108
|
-
* @param listener the listener to be called when a document is changed
|
|
1109
|
-
* @returns a function that uninstalls the listener. If the returned value is undefined
|
|
1110
|
-
* the method documentChangeListener has not been implemented in the concrete data source
|
|
1111
|
-
*/
|
|
1112
|
-
subscribeToDocumentChangeListener(e, t) {
|
|
1113
|
-
const r = R.getModel(e), s = r.onCollectionChange(r.find(), (n) => {
|
|
1114
|
-
const o = n[0];
|
|
1115
|
-
t({
|
|
1116
|
-
...o,
|
|
1117
|
-
before: o.before?.toObject(),
|
|
1118
|
-
after: o.after?.toObject()
|
|
1119
|
-
});
|
|
1120
|
-
});
|
|
1121
|
-
return {
|
|
1122
|
-
uninstall: s,
|
|
1123
|
-
nativeHandler: s,
|
|
1124
|
-
collectionPath: e
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
installCachedPropsUpdater(e) {
|
|
1128
|
-
return this._cachedPropsUpdater = new I(e), this._cachedPropsUpdater.documentChangeListenerSubscriber = this.subscribeToDocumentChangeListener.bind(this), this._cachedPropsUpdater.installUpdaters();
|
|
1098
|
+
async installCachedPropsUpdater(e) {
|
|
1099
|
+
return this._cachedPropsUpdater = new k(e), this._cachedPropsUpdater.documentChangeListenerSubscriber = this.subscribeToDocumentChangeListener.bind(this), this._cachedPropsUpdater.collectionsMatchingTemplateFunction = this.collectionsMatchingTemplate.bind(this), this._cachedPropsUpdater.installUpdaters();
|
|
1129
1100
|
}
|
|
1130
1101
|
uninstallCachedPropsUpdater() {
|
|
1131
1102
|
this._cachedPropsUpdater?.uninstallUpdaters(), this._cachedPropsUpdater = void 0;
|
|
@@ -1147,9 +1118,9 @@ class w {
|
|
|
1147
1118
|
*/
|
|
1148
1119
|
static toPropertyPathOperations(e) {
|
|
1149
1120
|
return e ? e.map((t) => {
|
|
1150
|
-
if (
|
|
1121
|
+
if (b.isArrayOperator(t.operator) && t.value[0] instanceof l)
|
|
1151
1122
|
return {
|
|
1152
|
-
property:
|
|
1123
|
+
property: l.searchableArrayNameFor(t.property),
|
|
1153
1124
|
operator: t.operator,
|
|
1154
1125
|
value: t.value.map((o) => o.id),
|
|
1155
1126
|
aggregate: t.aggregate
|
|
@@ -1169,8 +1140,8 @@ class w {
|
|
|
1169
1140
|
static toPersistentDocumentChange(e) {
|
|
1170
1141
|
return {
|
|
1171
1142
|
...e,
|
|
1172
|
-
before: e.before &&
|
|
1173
|
-
after: e.after &&
|
|
1143
|
+
before: e.before && l.createInstance(e.before),
|
|
1144
|
+
after: e.after && l.createInstance(e.after)
|
|
1174
1145
|
};
|
|
1175
1146
|
}
|
|
1176
1147
|
static toPropertyPathValue(e) {
|
|
@@ -1180,8 +1151,18 @@ class w {
|
|
|
1180
1151
|
} else
|
|
1181
1152
|
return [void 0, e];
|
|
1182
1153
|
}
|
|
1154
|
+
static isStringMatchingTemplate(e, t) {
|
|
1155
|
+
const s = e.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&").replace(/\\\$\\\{[^}]+\\\}/g, "([^/]+)").replace(/\\\{[^}]+\\\}/g, "([^/]+)");
|
|
1156
|
+
return new RegExp("^" + s + "$").test(t);
|
|
1157
|
+
}
|
|
1158
|
+
static extractTemplateParams(e, t) {
|
|
1159
|
+
const r = [], n = t.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&").replace(/\\\{([^}]+)\\\}/g, (c, u) => (r.push(u), "([^/]+)")), o = new RegExp("^" + n + "$"), a = e.match(o), d = {};
|
|
1160
|
+
return a && r.forEach((c, u) => {
|
|
1161
|
+
d[c] = a[u + 1];
|
|
1162
|
+
}), d;
|
|
1163
|
+
}
|
|
1183
1164
|
}
|
|
1184
|
-
class
|
|
1165
|
+
class ye extends b {
|
|
1185
1166
|
/**
|
|
1186
1167
|
* @param jsonRawData the JSON object to be used as data store
|
|
1187
1168
|
*/
|
|
@@ -1244,10 +1225,10 @@ class ge extends w {
|
|
|
1244
1225
|
if (!a.after) return;
|
|
1245
1226
|
const d = [a.after];
|
|
1246
1227
|
a.before && d.push(a.before);
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1228
|
+
const u = this.retrieveQueryDocs(d, e.operations).filter((C, g, O) => g === O.findIndex((P) => P.id === C.id));
|
|
1229
|
+
u.length > 0 && r(u.map((C) => ({
|
|
1249
1230
|
before: a.before,
|
|
1250
|
-
after:
|
|
1231
|
+
after: C,
|
|
1251
1232
|
type: a.type,
|
|
1252
1233
|
params: a.params
|
|
1253
1234
|
})));
|
|
@@ -1286,15 +1267,31 @@ class ge extends w {
|
|
|
1286
1267
|
delete: e
|
|
1287
1268
|
} : this._simulateError = e, this);
|
|
1288
1269
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1270
|
+
async subscribeToDocumentChangeListener(e, t) {
|
|
1271
|
+
const r = await this.collectionsMatchingTemplate(e), s = Math.random().toString(36).substring(2, 9);
|
|
1272
|
+
return r.forEach((n) => {
|
|
1273
|
+
let o = this._serverCollectionListeners[n];
|
|
1274
|
+
o || (o = this._serverCollectionListeners[n] = {}), o[s] = (a) => {
|
|
1275
|
+
const d = b.extractTemplateParams(n, e);
|
|
1276
|
+
t({
|
|
1277
|
+
...a,
|
|
1278
|
+
before: a.before,
|
|
1279
|
+
after: a.after,
|
|
1280
|
+
collectionPath: n,
|
|
1281
|
+
params: {
|
|
1282
|
+
...a.params,
|
|
1283
|
+
...d
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
};
|
|
1287
|
+
}), {
|
|
1288
|
+
uninstall: () => {
|
|
1289
|
+
r.forEach((n) => delete this._serverCollectionListeners[n]?.[s]);
|
|
1290
|
+
},
|
|
1291
|
+
nativeHandler: void 0,
|
|
1292
|
+
collectionPath: e
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1298
1295
|
notifyChange(e, t, r) {
|
|
1299
1296
|
const s = {
|
|
1300
1297
|
before: r,
|
|
@@ -1303,7 +1300,7 @@ class ge extends w {
|
|
|
1303
1300
|
params: {},
|
|
1304
1301
|
type: r ? "update" : "create"
|
|
1305
1302
|
};
|
|
1306
|
-
this._serverCollectionListeners[e]
|
|
1303
|
+
Object.values(this._serverCollectionListeners[e] ?? {}).forEach((n) => n(s)), Object.values(this._documentListeners[e] ?? {}).forEach((n) => n(s)), Object.values(this._collectionListeners[e] ?? {}).forEach((n) => n(s));
|
|
1307
1304
|
}
|
|
1308
1305
|
decCursor(e) {
|
|
1309
1306
|
return this._cursor -= e, this._cursor < 0 ? (this._cursor = 0, !0) : !1;
|
|
@@ -1330,14 +1327,14 @@ class ge extends w {
|
|
|
1330
1327
|
}
|
|
1331
1328
|
isQueryMatched(e, t) {
|
|
1332
1329
|
const r = {
|
|
1333
|
-
"==": (
|
|
1334
|
-
"!=": (
|
|
1335
|
-
"<": (
|
|
1336
|
-
"<=": (
|
|
1337
|
-
">": (
|
|
1338
|
-
">=": (
|
|
1339
|
-
containsAny: (
|
|
1340
|
-
contains: (
|
|
1330
|
+
"==": (c, u) => c === u,
|
|
1331
|
+
"!=": (c, u) => c !== u,
|
|
1332
|
+
"<": (c, u) => c < u,
|
|
1333
|
+
"<=": (c, u) => c <= u,
|
|
1334
|
+
">": (c, u) => c > u,
|
|
1335
|
+
">=": (c, u) => c >= u,
|
|
1336
|
+
containsAny: (c, u) => c?.some((C) => u?.includes(C)),
|
|
1337
|
+
contains: (c, u) => c?.includes(u)
|
|
1341
1338
|
}, { property: s, value: n, operator: o } = t, [a, d] = this.retrieveValuesToCompare(e, s, n);
|
|
1342
1339
|
return r[o](a, d);
|
|
1343
1340
|
}
|
|
@@ -1361,6 +1358,11 @@ class ge extends w {
|
|
|
1361
1358
|
() => this._pendingPromises = this._pendingPromises.filter((r) => r === t)
|
|
1362
1359
|
), t;
|
|
1363
1360
|
}
|
|
1361
|
+
collectionsMatchingTemplate(e) {
|
|
1362
|
+
return Promise.resolve(
|
|
1363
|
+
Object.keys(this._jsonRawData).filter((t) => b.isStringMatchingTemplate(e, t))
|
|
1364
|
+
);
|
|
1365
|
+
}
|
|
1364
1366
|
}
|
|
1365
1367
|
const v = class v {
|
|
1366
1368
|
static registerCloudStorage(e, t) {
|
|
@@ -1385,18 +1387,18 @@ const v = class v {
|
|
|
1385
1387
|
}
|
|
1386
1388
|
};
|
|
1387
1389
|
v._cloudStorageFactoryMap = {};
|
|
1388
|
-
let
|
|
1389
|
-
function
|
|
1390
|
-
return
|
|
1390
|
+
let D = v;
|
|
1391
|
+
function te(i, e) {
|
|
1392
|
+
return D.registerCloudStorage(i, e), (t) => {
|
|
1391
1393
|
t.prototype.__className = i;
|
|
1392
1394
|
};
|
|
1393
1395
|
}
|
|
1394
|
-
var
|
|
1395
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1396
|
+
var re = Object.getOwnPropertyDescriptor, se = (i, e, t, r) => {
|
|
1397
|
+
for (var s = r > 1 ? void 0 : r ? re(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
1396
1398
|
(o = i[n]) && (s = o(s) || s);
|
|
1397
1399
|
return s;
|
|
1398
1400
|
};
|
|
1399
|
-
let F = class extends
|
|
1401
|
+
let F = class extends D {
|
|
1400
1402
|
constructor(i = "") {
|
|
1401
1403
|
super(), this._simulateDelay = 0, this._pendingPromises = [], this.mockFileSystem = {}, this._pathToMockFiles = i;
|
|
1402
1404
|
}
|
|
@@ -1444,21 +1446,21 @@ let F = class extends C {
|
|
|
1444
1446
|
return delete this.mockFileSystem[i], this.resolveWithDelay();
|
|
1445
1447
|
}
|
|
1446
1448
|
};
|
|
1447
|
-
F =
|
|
1448
|
-
|
|
1449
|
+
F = se([
|
|
1450
|
+
te("MockCloudStorage", () => new F())
|
|
1449
1451
|
], F);
|
|
1450
|
-
var
|
|
1451
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1452
|
+
var ie = Object.defineProperty, ne = Object.getOwnPropertyDescriptor, j = (i, e, t, r) => {
|
|
1453
|
+
for (var s = r > 1 ? void 0 : r ? ne(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
1452
1454
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1453
|
-
return r && s &&
|
|
1454
|
-
},
|
|
1455
|
-
let
|
|
1455
|
+
return r && s && ie(e, t, s), s;
|
|
1456
|
+
}, oe = /* @__PURE__ */ ((i) => (i[i.stored = 0] = "stored", i[i.pendingDataSet = 1] = "pendingDataSet", i[i.deleted = 2] = "deleted", i))(oe || {});
|
|
1457
|
+
let S = class extends l {
|
|
1456
1458
|
constructor() {
|
|
1457
|
-
super(...arguments), this._onChange = new
|
|
1459
|
+
super(...arguments), this._onChange = new T();
|
|
1458
1460
|
}
|
|
1459
1461
|
async save({ data: i, fileName: e, progress: t, cloudStorageProvider: r } = {}) {
|
|
1460
1462
|
const s = i || this._pendingData;
|
|
1461
|
-
s && (this._reference && await this.delete(), this.provider = r ||
|
|
1463
|
+
s && (this._reference && await this.delete(), this.provider = r || D.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 }));
|
|
1462
1464
|
}
|
|
1463
1465
|
uploadControl() {
|
|
1464
1466
|
return this.provider.uploadControl();
|
|
@@ -1473,9 +1475,9 @@ let D = class extends h {
|
|
|
1473
1475
|
get provider() {
|
|
1474
1476
|
if (!this._provider)
|
|
1475
1477
|
try {
|
|
1476
|
-
this._provider =
|
|
1478
|
+
this._provider = D.createInstance(this._cloudStorageProviderName);
|
|
1477
1479
|
} catch {
|
|
1478
|
-
this._provider =
|
|
1480
|
+
this._provider = D.defaultCloudStorage;
|
|
1479
1481
|
}
|
|
1480
1482
|
return this._provider;
|
|
1481
1483
|
}
|
|
@@ -1499,30 +1501,30 @@ let D = class extends h {
|
|
|
1499
1501
|
return this._onChange.subscribe(i);
|
|
1500
1502
|
}
|
|
1501
1503
|
};
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
],
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
],
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
],
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
],
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
],
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
],
|
|
1520
|
-
class
|
|
1504
|
+
j([
|
|
1505
|
+
U
|
|
1506
|
+
], S.prototype, "_reference", 2);
|
|
1507
|
+
j([
|
|
1508
|
+
U
|
|
1509
|
+
], S.prototype, "_url", 2);
|
|
1510
|
+
j([
|
|
1511
|
+
U
|
|
1512
|
+
], S.prototype, "_cloudStorageProviderName", 2);
|
|
1513
|
+
j([
|
|
1514
|
+
U
|
|
1515
|
+
], S.prototype, "_originalFileName", 2);
|
|
1516
|
+
j([
|
|
1517
|
+
U
|
|
1518
|
+
], S.prototype, "_mimeType", 2);
|
|
1519
|
+
S = j([
|
|
1520
|
+
X("StoredFile")
|
|
1521
|
+
], S);
|
|
1522
|
+
class W {
|
|
1521
1523
|
}
|
|
1522
|
-
const
|
|
1524
|
+
const p = class p extends W {
|
|
1523
1525
|
constructor() {
|
|
1524
|
-
if (super(), this._onAuthStateChange = new
|
|
1525
|
-
|
|
1526
|
+
if (super(), this._onAuthStateChange = new T(), !p._authService) throw new Error(p.error.shouldBeRegistered);
|
|
1527
|
+
p._authService.onAuthStateChange(
|
|
1526
1528
|
(e) => this.authStateChanged(e)
|
|
1527
1529
|
);
|
|
1528
1530
|
}
|
|
@@ -1532,7 +1534,7 @@ const m = class m extends x {
|
|
|
1532
1534
|
* @param authService the authentication service to be used by the Auth class
|
|
1533
1535
|
*/
|
|
1534
1536
|
static useAuthService(e) {
|
|
1535
|
-
|
|
1537
|
+
p._authService != e && (p._authService = e, this._instance = void 0);
|
|
1536
1538
|
}
|
|
1537
1539
|
/**
|
|
1538
1540
|
* The instance of the Auth class
|
|
@@ -1552,7 +1554,7 @@ const m = class m extends x {
|
|
|
1552
1554
|
* Auth.instance.signUp({ authProvider: 'google'})
|
|
1553
1555
|
*/
|
|
1554
1556
|
signUp(e) {
|
|
1555
|
-
return
|
|
1557
|
+
return p._authService.signUp(e);
|
|
1556
1558
|
}
|
|
1557
1559
|
/**
|
|
1558
1560
|
* Logs in an existing user
|
|
@@ -1565,14 +1567,14 @@ const m = class m extends x {
|
|
|
1565
1567
|
* Auth.instance.login({ authProvider: 'google'})
|
|
1566
1568
|
*/
|
|
1567
1569
|
login(e) {
|
|
1568
|
-
return
|
|
1570
|
+
return p._authService.login(e);
|
|
1569
1571
|
}
|
|
1570
1572
|
/**
|
|
1571
1573
|
* Logs out the current user
|
|
1572
1574
|
* @returns a promise that resolves when the user is logged out
|
|
1573
1575
|
*/
|
|
1574
1576
|
logout() {
|
|
1575
|
-
return
|
|
1577
|
+
return p._authService.logout();
|
|
1576
1578
|
}
|
|
1577
1579
|
/**
|
|
1578
1580
|
* Resets the password associated with the email.
|
|
@@ -1580,17 +1582,17 @@ const m = class m extends x {
|
|
|
1580
1582
|
* @returns a promise that resolves when the process is done
|
|
1581
1583
|
*/
|
|
1582
1584
|
resetEmailPassword(e) {
|
|
1583
|
-
return
|
|
1585
|
+
return p._authService.resetEmailPassword(e);
|
|
1584
1586
|
}
|
|
1585
1587
|
/**
|
|
1586
1588
|
* Resends the email verification to the user.
|
|
1587
1589
|
* @returns a promise that resolves when the process is done
|
|
1588
1590
|
*/
|
|
1589
1591
|
resendVerificationEmail(e, t, r) {
|
|
1590
|
-
return
|
|
1592
|
+
return p._authService.resendVerificationEmail(e, t, r);
|
|
1591
1593
|
}
|
|
1592
1594
|
refreshToken() {
|
|
1593
|
-
return
|
|
1595
|
+
return p._authService.refreshToken();
|
|
1594
1596
|
}
|
|
1595
1597
|
/**
|
|
1596
1598
|
* Adds a listener to be called when the authentication state changes.
|
|
@@ -1627,7 +1629,7 @@ const m = class m extends x {
|
|
|
1627
1629
|
* Auth.instance.linkAdditionalProvider({ authProvider: 'google' })
|
|
1628
1630
|
*/
|
|
1629
1631
|
linkAdditionalProvider(e) {
|
|
1630
|
-
return
|
|
1632
|
+
return p._authService.linkAdditionalProvider(e);
|
|
1631
1633
|
}
|
|
1632
1634
|
/**
|
|
1633
1635
|
* Unlinks an authentication provider from the authenticated user.
|
|
@@ -1638,15 +1640,15 @@ const m = class m extends x {
|
|
|
1638
1640
|
* Auth.instance.unlinkProvider({ authProvider: 'google' })
|
|
1639
1641
|
*/
|
|
1640
1642
|
unlinkProvider(e) {
|
|
1641
|
-
return
|
|
1643
|
+
return p._authService.unlinkProvider(e);
|
|
1642
1644
|
}
|
|
1643
1645
|
authStateChanged(e) {
|
|
1644
1646
|
this._onAuthStateChange.notify(e);
|
|
1645
1647
|
}
|
|
1646
1648
|
};
|
|
1647
|
-
|
|
1648
|
-
let
|
|
1649
|
-
class
|
|
1649
|
+
p.error = { shouldBeRegistered: "You should register an auth service before using Auth." }, p._instance = void 0;
|
|
1650
|
+
let L = p;
|
|
1651
|
+
class be extends W {
|
|
1650
1652
|
constructor() {
|
|
1651
1653
|
super(...arguments), this.pendingPromises = [], this._fakeRegisteredUsers = {};
|
|
1652
1654
|
}
|
|
@@ -1739,16 +1741,16 @@ const y = class y {
|
|
|
1739
1741
|
}
|
|
1740
1742
|
processParam(e) {
|
|
1741
1743
|
if (e != null)
|
|
1742
|
-
return e instanceof
|
|
1744
|
+
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;
|
|
1743
1745
|
}
|
|
1744
1746
|
processResult(e) {
|
|
1745
1747
|
if (e != null)
|
|
1746
|
-
return e.__className ?
|
|
1748
|
+
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;
|
|
1747
1749
|
}
|
|
1748
1750
|
};
|
|
1749
1751
|
y.error = { shouldBeRegistered: "You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions." };
|
|
1750
|
-
let
|
|
1751
|
-
class
|
|
1752
|
+
let x = y;
|
|
1753
|
+
class Pe {
|
|
1752
1754
|
constructor(e) {
|
|
1753
1755
|
this._registeredFunctions = e;
|
|
1754
1756
|
}
|
|
@@ -1761,35 +1763,35 @@ class ye {
|
|
|
1761
1763
|
return e(t);
|
|
1762
1764
|
}
|
|
1763
1765
|
}
|
|
1764
|
-
class
|
|
1766
|
+
class B {
|
|
1765
1767
|
}
|
|
1766
|
-
const
|
|
1768
|
+
const m = class m extends B {
|
|
1767
1769
|
constructor() {
|
|
1768
1770
|
super();
|
|
1769
1771
|
}
|
|
1770
1772
|
static useServerAuthService(e) {
|
|
1771
|
-
|
|
1773
|
+
m._authService != e && (m._authService = e, this._instance = void 0);
|
|
1772
1774
|
}
|
|
1773
1775
|
static get instance() {
|
|
1774
|
-
if (!
|
|
1775
|
-
return this._instance || (this._instance = new
|
|
1776
|
+
if (!m._authService) throw new Error(m.error.shouldBeRegistered);
|
|
1777
|
+
return this._instance || (this._instance = new m());
|
|
1776
1778
|
}
|
|
1777
1779
|
getUser(e) {
|
|
1778
|
-
return
|
|
1780
|
+
return m._authService.getUser(e);
|
|
1779
1781
|
}
|
|
1780
1782
|
updateUser(e, t) {
|
|
1781
|
-
return
|
|
1783
|
+
return m._authService.updateUser(e, t);
|
|
1782
1784
|
}
|
|
1783
1785
|
setCustomCredentials(e, t) {
|
|
1784
|
-
return
|
|
1786
|
+
return m._authService.setCustomCredentials(e, t);
|
|
1785
1787
|
}
|
|
1786
1788
|
deleteUser(e) {
|
|
1787
|
-
return
|
|
1789
|
+
return m._authService.deleteUser(e);
|
|
1788
1790
|
}
|
|
1789
1791
|
};
|
|
1790
|
-
|
|
1791
|
-
let
|
|
1792
|
-
class
|
|
1792
|
+
m.error = { shouldBeRegistered: "You should register a Server Auth service before using the Server Auth." }, m._instance = void 0;
|
|
1793
|
+
let $ = m;
|
|
1794
|
+
class we extends B {
|
|
1793
1795
|
constructor(e) {
|
|
1794
1796
|
super(), this._userCredentials = e;
|
|
1795
1797
|
}
|
|
@@ -1815,63 +1817,63 @@ class be extends W {
|
|
|
1815
1817
|
return this._userCredentials;
|
|
1816
1818
|
}
|
|
1817
1819
|
}
|
|
1818
|
-
function
|
|
1820
|
+
function ve(i, e) {
|
|
1819
1821
|
return i ? i.replace(/\${\s*(\w*)\s*}/g, function(t, r) {
|
|
1820
1822
|
return e[r] || "";
|
|
1821
1823
|
}) : "";
|
|
1822
1824
|
}
|
|
1823
|
-
function
|
|
1825
|
+
function Ce(i) {
|
|
1824
1826
|
return i ? i.replace(
|
|
1825
1827
|
/([-_ ][\w])/g,
|
|
1826
1828
|
(e) => e.toUpperCase().replace("-", "").replace("_", "").replace(" ", "")
|
|
1827
1829
|
) : "";
|
|
1828
1830
|
}
|
|
1829
|
-
function
|
|
1831
|
+
function De(i, e = "-") {
|
|
1830
1832
|
if (!i) return "";
|
|
1831
1833
|
const t = i.slice(1).replace(/( |[A-Z])/g, (r) => r === " " ? "-" : e + r[0].toLowerCase());
|
|
1832
1834
|
return i[0].toLocaleLowerCase() + t.replace(/--/g, "-");
|
|
1833
1835
|
}
|
|
1834
|
-
function
|
|
1836
|
+
function Se(i, e) {
|
|
1835
1837
|
return e.split(".").reduce((t, r) => t[r], i);
|
|
1836
1838
|
}
|
|
1837
1839
|
export {
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1840
|
+
L as Auth,
|
|
1841
|
+
be as AuthMock,
|
|
1842
|
+
W as AuthService,
|
|
1843
|
+
x as CloudFunctions,
|
|
1844
|
+
Pe as CloudFunctionsMock,
|
|
1845
|
+
D as CloudStorage,
|
|
1846
|
+
b as DataSource,
|
|
1847
|
+
_e as EntropicComponent,
|
|
1848
|
+
ye as JsonDataSource,
|
|
1847
1849
|
F as MockCloudStorage,
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1850
|
+
R as Model,
|
|
1851
|
+
T as Observable,
|
|
1852
|
+
l as Persistent,
|
|
1853
|
+
ee as Query,
|
|
1854
|
+
$ as ServerAuth,
|
|
1855
|
+
we as ServerAuthMock,
|
|
1856
|
+
B as ServerAuthService,
|
|
1857
|
+
M as Store,
|
|
1858
|
+
S as StoredFile,
|
|
1859
|
+
oe as StoredFileEvent,
|
|
1860
|
+
Ce as camelCase,
|
|
1861
|
+
Se as getDeepValue,
|
|
1862
|
+
U as persistent,
|
|
1861
1863
|
_ as persistentParser,
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1864
|
+
he as persistentPureReference,
|
|
1865
|
+
le as persistentPureReferenceWithCachedProps,
|
|
1866
|
+
ce as persistentReference,
|
|
1867
|
+
ae as persistentReferenceAt,
|
|
1868
|
+
ue as persistentReferenceWithCachedProps,
|
|
1869
|
+
te as registerCloudStorage,
|
|
1870
|
+
de as registerLegacyClassName,
|
|
1871
|
+
X as registerPersistentClass,
|
|
1872
|
+
ve as replaceValue,
|
|
1873
|
+
pe as required,
|
|
1874
|
+
me as requiredWithValidator,
|
|
1875
|
+
fe as searchableArray,
|
|
1876
|
+
De as snakeCase,
|
|
1877
|
+
ge as typeName
|
|
1876
1878
|
};
|
|
1877
1879
|
//# sourceMappingURL=entropic-bond.js.map
|