entropic-bond 1.53.14 → 1.53.16
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 +257 -279
- 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/store/data-source.d.ts +4 -2
- package/package.json +11 -8
package/lib/entropic-bond.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class U {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
4
4
|
}
|
|
@@ -46,36 +46,36 @@ class I {
|
|
|
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 $(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
|
-
let
|
|
53
|
-
const
|
|
54
|
-
function
|
|
55
|
-
if (!
|
|
52
|
+
let D;
|
|
53
|
+
const T = new Uint8Array(16);
|
|
54
|
+
function x() {
|
|
55
|
+
if (!D) {
|
|
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
|
+
D = crypto.getRandomValues.bind(crypto);
|
|
59
59
|
}
|
|
60
|
-
return
|
|
60
|
+
return D(T);
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
function
|
|
64
|
-
var s;
|
|
65
|
-
if (V.randomUUID && !i)
|
|
66
|
-
return V.randomUUID();
|
|
62
|
+
const B = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), A = { randomUUID: B };
|
|
63
|
+
function W(i, e, t) {
|
|
67
64
|
i = i || {};
|
|
68
|
-
const r = i.random ??
|
|
65
|
+
const r = i.random ?? i.rng?.() ?? x();
|
|
69
66
|
if (r.length < 16)
|
|
70
67
|
throw new Error("Random bytes length must be >= 16");
|
|
71
|
-
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, $(r);
|
|
72
69
|
}
|
|
73
|
-
|
|
70
|
+
function Q(i, e, t) {
|
|
71
|
+
return A.randomUUID && !i ? A.randomUUID() : W(i);
|
|
72
|
+
}
|
|
73
|
+
var q = Object.defineProperty, Y = (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 && q(e, t, s), s;
|
|
77
|
+
}, l;
|
|
78
|
+
const k = (l = 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 B = (d = class {
|
|
|
136
136
|
* @see registerFactory
|
|
137
137
|
*/
|
|
138
138
|
static annotations(e) {
|
|
139
|
-
if (e instanceof
|
|
139
|
+
if (e instanceof l ? 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 = Q()) {
|
|
147
147
|
this._id = e;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
@@ -273,7 +273,7 @@ const B = (d = 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[l.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 B = (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(
|
|
@@ -302,7 +302,7 @@ const B = (d = 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 l)
|
|
306
306
|
return e.toObj(t);
|
|
307
307
|
if (typeof e == "object") {
|
|
308
308
|
const r = {};
|
|
@@ -318,15 +318,11 @@ const B = (d = class {
|
|
|
318
318
|
return typeof t.storeInCollection == "function" ? r = t.storeInCollection(e, t) : r = t.storeInCollection ?? e.className, r;
|
|
319
319
|
}
|
|
320
320
|
toReferenceObj(e, t) {
|
|
321
|
-
var s;
|
|
322
321
|
const r = this[e.name];
|
|
323
|
-
return Array.isArray(r) ? r.map((
|
|
324
|
-
var o;
|
|
325
|
-
return e.isPureReference || this.pushDocument(t, d.collectionPath(n, e), n), this.buildRefObject(n, d.collectionPath(n, e), (o = e.cachedPropsConfig) == null ? void 0 : o.cachedProps);
|
|
326
|
-
}) : (e.isPureReference || this.pushDocument(t, d.collectionPath(r, e), r), this.buildRefObject(r, d.collectionPath(r, e), (s = e.cachedPropsConfig) == null ? void 0 : s.cachedProps));
|
|
322
|
+
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.cachedPropsConfig?.cachedProps))) : (e.isPureReference || this.pushDocument(t, l.collectionPath(r, e), r), this.buildRefObject(r, l.collectionPath(r, e), e.cachedPropsConfig?.cachedProps));
|
|
327
323
|
}
|
|
328
324
|
buildRefObject(e, t, r) {
|
|
329
|
-
const s = r
|
|
325
|
+
const s = r?.reduce((n, o) => (e[o] !== void 0 && (n[o] = e[o]), n), {});
|
|
330
326
|
return {
|
|
331
327
|
id: e.id,
|
|
332
328
|
__className: e.className || e.__className,
|
|
@@ -346,14 +342,14 @@ const B = (d = class {
|
|
|
346
342
|
return e.name.slice(1);
|
|
347
343
|
}
|
|
348
344
|
static createReference(e) {
|
|
349
|
-
const t =
|
|
345
|
+
const t = l.createInstance(e);
|
|
350
346
|
return t.__documentReference = e.__documentReference || { storedInCollection: t.className }, t;
|
|
351
347
|
}
|
|
352
348
|
static createInstance(e) {
|
|
353
349
|
if (typeof e == "string")
|
|
354
|
-
return new (
|
|
350
|
+
return new (l.classFactory(e))();
|
|
355
351
|
try {
|
|
356
|
-
return new (
|
|
352
|
+
return new (l.classFactory(e.__className))().fromObject(e);
|
|
357
353
|
} catch (t) {
|
|
358
354
|
const r = Object.entries(e).filter(([s, n]) => n != null && typeof n != "function").map(([s, n]) => `${s}: ${n}`).join(`,
|
|
359
355
|
`);
|
|
@@ -366,46 +362,43 @@ const B = (d = class {
|
|
|
366
362
|
}
|
|
367
363
|
}
|
|
368
364
|
static propInfo(e, t) {
|
|
369
|
-
return
|
|
365
|
+
return l.createInstance(e).getPropInfo(t);
|
|
370
366
|
}
|
|
371
367
|
/**
|
|
372
368
|
* Retrieves a collection of references with the properties that are stored in the reference object
|
|
373
369
|
* @returns the references collection
|
|
374
370
|
*/
|
|
375
371
|
static getSystemRegisteredReferencesWithCachedProps() {
|
|
376
|
-
return
|
|
377
|
-
const o =
|
|
378
|
-
(
|
|
379
|
-
var h;
|
|
380
|
-
return (h = c.cachedPropsConfig) == null ? void 0 : h.cachedProps;
|
|
381
|
-
}
|
|
372
|
+
return l.registeredClassesAndLegacyNames().reduce((r, s) => {
|
|
373
|
+
const o = l.createInstance(s).getPersistentProperties().filter(
|
|
374
|
+
(a) => a.cachedPropsConfig?.cachedProps
|
|
382
375
|
);
|
|
383
376
|
return o.length > 0 && (r[s] = o), r;
|
|
384
377
|
}, {});
|
|
385
378
|
}
|
|
386
|
-
},
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
],
|
|
390
|
-
let
|
|
391
|
-
function
|
|
392
|
-
return
|
|
379
|
+
}, l._factoryMap = {}, l);
|
|
380
|
+
Y([
|
|
381
|
+
S
|
|
382
|
+
], k.prototype, "_id");
|
|
383
|
+
let u = k;
|
|
384
|
+
function S(i, e) {
|
|
385
|
+
return _()(i, e);
|
|
393
386
|
}
|
|
394
|
-
function
|
|
387
|
+
function te(i) {
|
|
395
388
|
return function(e, t) {
|
|
396
|
-
return
|
|
389
|
+
return _({
|
|
397
390
|
storeInCollection: i,
|
|
398
391
|
isReference: !0
|
|
399
392
|
})(e, t);
|
|
400
393
|
};
|
|
401
394
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
395
|
+
function re(i, e) {
|
|
396
|
+
return _({ isReference: !0 })(i, e);
|
|
404
397
|
}
|
|
405
|
-
function
|
|
398
|
+
function se(i, e, t) {
|
|
406
399
|
const r = Array.isArray(i) ? { cachedProps: i } : i;
|
|
407
400
|
return function(s, n) {
|
|
408
|
-
return
|
|
401
|
+
return _({
|
|
409
402
|
isReference: !0,
|
|
410
403
|
storeInCollection: e,
|
|
411
404
|
typeName: t,
|
|
@@ -413,13 +406,13 @@ function ce(i, e, t) {
|
|
|
413
406
|
})(s, n);
|
|
414
407
|
};
|
|
415
408
|
}
|
|
416
|
-
function
|
|
417
|
-
return
|
|
409
|
+
function ie(i, e, t) {
|
|
410
|
+
return _({ isReference: !0, isPureReference: !0, storeInCollection: t })(i, e);
|
|
418
411
|
}
|
|
419
|
-
function
|
|
412
|
+
function ne(i, e, t) {
|
|
420
413
|
return function(r, s) {
|
|
421
414
|
const n = Array.isArray(i) ? { cachedProps: i } : i;
|
|
422
|
-
return
|
|
415
|
+
return _({
|
|
423
416
|
isReference: !0,
|
|
424
417
|
isPureReference: !0,
|
|
425
418
|
storeInCollection: e,
|
|
@@ -428,7 +421,7 @@ function he(i, e, t) {
|
|
|
428
421
|
})(r, s);
|
|
429
422
|
};
|
|
430
423
|
}
|
|
431
|
-
function
|
|
424
|
+
function _(i) {
|
|
432
425
|
return function(e, t) {
|
|
433
426
|
Object.getOwnPropertyDescriptor(e, "_persistentProperties") || (e._persistentProperties ? e._persistentProperties = [...e._persistentProperties] : e._persistentProperties = []);
|
|
434
427
|
const r = e._persistentProperties.find((s) => s.name === t);
|
|
@@ -438,30 +431,30 @@ function y(i) {
|
|
|
438
431
|
});
|
|
439
432
|
};
|
|
440
433
|
}
|
|
441
|
-
function
|
|
434
|
+
function z(i, e) {
|
|
442
435
|
return (t) => {
|
|
443
|
-
|
|
436
|
+
u.registerFactory(i, t, e), t.prototype.__className = i;
|
|
444
437
|
};
|
|
445
438
|
}
|
|
446
|
-
function
|
|
439
|
+
function oe(i) {
|
|
447
440
|
return (e) => {
|
|
448
|
-
|
|
441
|
+
u.registerFactory(i, e, void 0, !0);
|
|
449
442
|
};
|
|
450
443
|
}
|
|
451
|
-
function
|
|
452
|
-
return
|
|
444
|
+
function ae(i, e) {
|
|
445
|
+
return _({ searchableArray: !0 })(i, e);
|
|
453
446
|
}
|
|
454
|
-
function
|
|
455
|
-
return
|
|
447
|
+
function ce(i, e) {
|
|
448
|
+
return _({ validator: (t) => t != null })(i, e);
|
|
456
449
|
}
|
|
457
|
-
function
|
|
450
|
+
function ue(i = (e) => e != null) {
|
|
458
451
|
return function(e, t) {
|
|
459
|
-
return
|
|
452
|
+
return _({ validator: i })(e, t);
|
|
460
453
|
};
|
|
461
454
|
}
|
|
462
|
-
class
|
|
455
|
+
class he extends u {
|
|
463
456
|
constructor() {
|
|
464
|
-
super(...arguments), this._onChange = new
|
|
457
|
+
super(...arguments), this._onChange = new U();
|
|
465
458
|
}
|
|
466
459
|
/**
|
|
467
460
|
* Subscribes a listener callback function. Every time a property is changed,
|
|
@@ -544,13 +537,13 @@ class me extends l {
|
|
|
544
537
|
return this.notify({ [e]: this[e] }), t;
|
|
545
538
|
}
|
|
546
539
|
}
|
|
547
|
-
const
|
|
540
|
+
const R = class R {
|
|
548
541
|
constructor(e, t, r) {
|
|
549
542
|
if (r) {
|
|
550
|
-
if (!(t instanceof
|
|
543
|
+
if (!(t instanceof u)) throw new Error(R.error.persistentNeedForSubCollection);
|
|
551
544
|
this.collectionName = `${t.className}/${t.id}/${r}`;
|
|
552
545
|
} else
|
|
553
|
-
this.collectionName = t instanceof
|
|
546
|
+
this.collectionName = t instanceof u ? t.className : t;
|
|
554
547
|
this._stream = e;
|
|
555
548
|
}
|
|
556
549
|
/**
|
|
@@ -565,7 +558,7 @@ const E = class E {
|
|
|
565
558
|
findById(e, t) {
|
|
566
559
|
return new Promise((r, s) => {
|
|
567
560
|
this._stream.findById(e, this.collectionName).then((n) => {
|
|
568
|
-
n ? (t ? t.fromObject(n) : t =
|
|
561
|
+
n ? (t ? t.fromObject(n) : t = u.createInstance(n), r(t)) : r(void 0);
|
|
569
562
|
}).catch((n) => s(n));
|
|
570
563
|
});
|
|
571
564
|
}
|
|
@@ -596,7 +589,7 @@ const E = class E {
|
|
|
596
589
|
* @returns a Query object
|
|
597
590
|
*/
|
|
598
591
|
find() {
|
|
599
|
-
return new
|
|
592
|
+
return new H(this);
|
|
600
593
|
}
|
|
601
594
|
/**
|
|
602
595
|
* Define the search conditions. You pass query operations and how the query
|
|
@@ -607,7 +600,7 @@ const E = class E {
|
|
|
607
600
|
*/
|
|
608
601
|
query(e = {}, t) {
|
|
609
602
|
if (t) {
|
|
610
|
-
const r = t instanceof
|
|
603
|
+
const r = t instanceof u ? t.className : t;
|
|
611
604
|
e.operations || (e.operations = []), e.operations.push(
|
|
612
605
|
{ property: "__className", operator: "==", value: r }
|
|
613
606
|
);
|
|
@@ -650,8 +643,8 @@ const E = class E {
|
|
|
650
643
|
toPersistentChangeObject(e) {
|
|
651
644
|
return {
|
|
652
645
|
...e,
|
|
653
|
-
before: e.before &&
|
|
654
|
-
after: e.after &&
|
|
646
|
+
before: e.before && u.createInstance(e.before),
|
|
647
|
+
after: e.after && u.createInstance(e.after)
|
|
655
648
|
};
|
|
656
649
|
}
|
|
657
650
|
// /**
|
|
@@ -666,7 +659,7 @@ const E = class E {
|
|
|
666
659
|
mapToInstance(e) {
|
|
667
660
|
return new Promise((t, r) => {
|
|
668
661
|
e().then((s) => t(
|
|
669
|
-
s.map((n) =>
|
|
662
|
+
s.map((n) => u.createInstance(n))
|
|
670
663
|
)).catch((s) => r(s));
|
|
671
664
|
});
|
|
672
665
|
}
|
|
@@ -679,34 +672,33 @@ const E = class E {
|
|
|
679
672
|
* @returns the normalized query object
|
|
680
673
|
*/
|
|
681
674
|
preprocessQueryObject(e) {
|
|
682
|
-
var r;
|
|
683
675
|
if (Object.values(e).length === 0) return e;
|
|
684
|
-
const t =
|
|
685
|
-
const
|
|
686
|
-
return
|
|
687
|
-
property:
|
|
688
|
-
operator:
|
|
689
|
-
value: Array.isArray(
|
|
690
|
-
aggregate:
|
|
676
|
+
const t = e.operations?.map((r) => {
|
|
677
|
+
const s = r.value[0] ?? r.value;
|
|
678
|
+
return w.isArrayOperator(r.operator) && s instanceof u ? {
|
|
679
|
+
property: u.searchableArrayNameFor(r.property),
|
|
680
|
+
operator: r.operator,
|
|
681
|
+
value: Array.isArray(r.value) ? r.value.map((n) => n.id) : s.id,
|
|
682
|
+
aggregate: r.aggregate
|
|
691
683
|
} : {
|
|
692
|
-
property:
|
|
693
|
-
operator:
|
|
694
|
-
value:
|
|
695
|
-
aggregate:
|
|
684
|
+
property: r.property,
|
|
685
|
+
operator: r.operator,
|
|
686
|
+
value: r.value instanceof u ? { id: r.value.id } : r.value,
|
|
687
|
+
aggregate: r.aggregate
|
|
696
688
|
};
|
|
697
|
-
})
|
|
689
|
+
}) ?? [];
|
|
698
690
|
return {
|
|
699
691
|
...e,
|
|
700
692
|
operations: t
|
|
701
693
|
};
|
|
702
694
|
}
|
|
703
695
|
};
|
|
704
|
-
|
|
696
|
+
R.error = {
|
|
705
697
|
persistentNeedForSubCollection: "The document parameter for a sub-collection should be a Persistent instace",
|
|
706
698
|
invalidQueryOrder: "Cannot add where calls after or calls"
|
|
707
699
|
};
|
|
708
|
-
let
|
|
709
|
-
class
|
|
700
|
+
let C = R;
|
|
701
|
+
class H {
|
|
710
702
|
constructor(e) {
|
|
711
703
|
this.queryObject = { operations: [] }, this.model = e;
|
|
712
704
|
}
|
|
@@ -730,9 +722,8 @@ class X {
|
|
|
730
722
|
* @see orDeepProp
|
|
731
723
|
*/
|
|
732
724
|
where(e, t, r, s) {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
return (c = this.queryObject.operations) == null || c.push({
|
|
725
|
+
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(C.error.invalidQueryOrder);
|
|
726
|
+
return this.queryObject.operations?.push({
|
|
736
727
|
property: e,
|
|
737
728
|
operator: t,
|
|
738
729
|
value: r,
|
|
@@ -764,16 +755,15 @@ class X {
|
|
|
764
755
|
* @see orDeepProp
|
|
765
756
|
*/
|
|
766
757
|
whereDeepProp(e, t, r, s) {
|
|
767
|
-
|
|
768
|
-
if ((a = (h = this.queryObject.operations) == null ? void 0 : h.at(-1)) != null && a.aggregate && !s) throw new Error(O.error.invalidQueryOrder);
|
|
758
|
+
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(C.error.invalidQueryOrder);
|
|
769
759
|
const n = e.split(".");
|
|
770
|
-
let o = {},
|
|
771
|
-
return n.slice(1).forEach((
|
|
772
|
-
o[
|
|
773
|
-
}),
|
|
760
|
+
let o = {}, a = n.length > 1 ? o : r;
|
|
761
|
+
return n.slice(1).forEach((c, h) => {
|
|
762
|
+
o[c] = h < n.length - 2 ? {} : r, o = o[c];
|
|
763
|
+
}), this.queryObject.operations?.push({
|
|
774
764
|
property: n[0],
|
|
775
765
|
operator: t,
|
|
776
|
-
value:
|
|
766
|
+
value: a,
|
|
777
767
|
aggregate: s
|
|
778
768
|
}), this;
|
|
779
769
|
}
|
|
@@ -859,9 +849,8 @@ class X {
|
|
|
859
849
|
* query.instanceOf( Person ).where( 'age', '>', 18 )
|
|
860
850
|
*/
|
|
861
851
|
instanceOf(e) {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
return (r = this.queryObject.operations) == null || r.push({
|
|
852
|
+
const t = e instanceof u ? e.className : e;
|
|
853
|
+
return this.queryObject.operations?.push({
|
|
865
854
|
property: "__className",
|
|
866
855
|
operator: "==",
|
|
867
856
|
value: t
|
|
@@ -930,7 +919,7 @@ class X {
|
|
|
930
919
|
return this.queryObject;
|
|
931
920
|
}
|
|
932
921
|
}
|
|
933
|
-
const
|
|
922
|
+
const y = class y {
|
|
934
923
|
constructor() {
|
|
935
924
|
}
|
|
936
925
|
/**
|
|
@@ -946,7 +935,7 @@ const P = class P {
|
|
|
946
935
|
* @returns the data source
|
|
947
936
|
*/
|
|
948
937
|
static get dataSource() {
|
|
949
|
-
return
|
|
938
|
+
return y._dataSource;
|
|
950
939
|
}
|
|
951
940
|
/**
|
|
952
941
|
* Retrieves a model for a collection
|
|
@@ -954,8 +943,8 @@ const P = class P {
|
|
|
954
943
|
* @returns the model for the collection
|
|
955
944
|
*/
|
|
956
945
|
static getModel(e) {
|
|
957
|
-
if (!
|
|
958
|
-
return new
|
|
946
|
+
if (!y._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
947
|
+
return new C(y._dataSource, e);
|
|
959
948
|
}
|
|
960
949
|
/**
|
|
961
950
|
* Retrieves a model for a subcollection
|
|
@@ -964,8 +953,8 @@ const P = class P {
|
|
|
964
953
|
* @returns the model for the subcollection
|
|
965
954
|
*/
|
|
966
955
|
static getModelForSubCollection(e, t) {
|
|
967
|
-
if (!
|
|
968
|
-
return new
|
|
956
|
+
if (!y._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
957
|
+
return new C(y._dataSource, e, t);
|
|
969
958
|
}
|
|
970
959
|
/**
|
|
971
960
|
* Populates property references with actual data from the store.
|
|
@@ -997,26 +986,26 @@ const P = class P {
|
|
|
997
986
|
) : e.__documentReference === void 0;
|
|
998
987
|
}
|
|
999
988
|
};
|
|
1000
|
-
|
|
1001
|
-
let
|
|
1002
|
-
class
|
|
989
|
+
y.error = { shouldBeRegistered: "You should register a data source before using the data Store." };
|
|
990
|
+
let E = y;
|
|
991
|
+
class w {
|
|
1003
992
|
installCachedPropsUpdaters(e = {}) {
|
|
1004
|
-
|
|
1005
|
-
const t =
|
|
993
|
+
w.onUpdate = e.onUpdate;
|
|
994
|
+
const t = u.getSystemRegisteredReferencesWithCachedProps(), r = {};
|
|
1006
995
|
Object.entries(t).forEach(([n, o]) => {
|
|
1007
|
-
o.forEach((
|
|
1008
|
-
const
|
|
1009
|
-
r[
|
|
1010
|
-
prop:
|
|
996
|
+
o.forEach((a) => {
|
|
997
|
+
const c = u.collectionPath(u.createInstance(n), a);
|
|
998
|
+
r[c] || (r[c] = []), r[c].push({
|
|
999
|
+
prop: a,
|
|
1011
1000
|
collectionPropOwner: n
|
|
1012
1001
|
});
|
|
1013
1002
|
});
|
|
1014
1003
|
});
|
|
1015
1004
|
const s = [];
|
|
1016
1005
|
return Object.entries(r).forEach(([n, o]) => {
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1019
|
-
s.push(
|
|
1006
|
+
const a = this.subscribeToDocumentChangeListerner(n, (c) => w.processDocumentChange(c, o));
|
|
1007
|
+
if (a)
|
|
1008
|
+
s.push(a);
|
|
1020
1009
|
else if (e.noThrowOnNonImplementedListener) throw new Error("The method documentChangeListerner has not been implemented in the concrete data source");
|
|
1021
1010
|
}), s;
|
|
1022
1011
|
}
|
|
@@ -1046,9 +1035,9 @@ class S {
|
|
|
1046
1035
|
*/
|
|
1047
1036
|
static toPropertyPathOperations(e) {
|
|
1048
1037
|
return e ? e.map((t) => {
|
|
1049
|
-
if (
|
|
1038
|
+
if (w.isArrayOperator(t.operator) && t.value[0] instanceof u)
|
|
1050
1039
|
return {
|
|
1051
|
-
property:
|
|
1040
|
+
property: u.searchableArrayNameFor(t.property),
|
|
1052
1041
|
operator: t.operator,
|
|
1053
1042
|
value: t.value.map((o) => o.id),
|
|
1054
1043
|
aggregate: t.aggregate
|
|
@@ -1075,29 +1064,25 @@ class S {
|
|
|
1075
1064
|
static async processDocumentChange(e, t) {
|
|
1076
1065
|
if (e.before)
|
|
1077
1066
|
return t.map(async (r) => {
|
|
1078
|
-
|
|
1079
|
-
const s = F.getModel(r.collectionPropOwner);
|
|
1067
|
+
const s = E.getModel(r.collectionPropOwner);
|
|
1080
1068
|
let n = s.find();
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
u !== g && (n = n.orDeepProp(`${r.prop.name}.${a}`, "==", u));
|
|
1069
|
+
r.prop.cachedPropsConfig?.cachedProps?.forEach((a) => {
|
|
1070
|
+
const c = e.before?.[a], h = e.after?.[a];
|
|
1071
|
+
c !== h && (n = n.orDeepProp(`${r.prop.name}.${a}`, "==", c));
|
|
1085
1072
|
});
|
|
1086
1073
|
const o = await n.get();
|
|
1087
1074
|
return Promise.all([
|
|
1088
1075
|
o.map(async (a) => {
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
const j = (k = e.before) == null ? void 0 : k[v], N = (L = e.after) == null ? void 0 : L[v];
|
|
1093
|
-
j !== N && (a[`_${r.prop.name}`][`_${v}`] = N, await s.save(a), (M = this.onUpdate) == null || M.call(this, a, r.prop));
|
|
1076
|
+
r.prop.cachedPropsConfig?.cachedProps?.forEach(async (c) => {
|
|
1077
|
+
const h = e.before?.[c], d = e.after?.[c];
|
|
1078
|
+
h !== d && (a[`_${r.prop.name}`][`_${c}`] = d, await s.save(a), this.onUpdate?.(a, r.prop));
|
|
1094
1079
|
});
|
|
1095
1080
|
})
|
|
1096
1081
|
]);
|
|
1097
1082
|
});
|
|
1098
1083
|
}
|
|
1099
1084
|
}
|
|
1100
|
-
class
|
|
1085
|
+
class le extends w {
|
|
1101
1086
|
/**
|
|
1102
1087
|
* @param jsonRawData the JSON object to be used as data store
|
|
1103
1088
|
*/
|
|
@@ -1121,32 +1106,28 @@ class ge extends S {
|
|
|
1121
1106
|
return this._simulateDelay = e, this;
|
|
1122
1107
|
}
|
|
1123
1108
|
findById(e, t) {
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
return this.resolveWithDelay((s = this._jsonRawData[t]) == null ? void 0 : s[e]);
|
|
1109
|
+
if (this._simulateError?.findById) throw new Error(this._simulateError.findById);
|
|
1110
|
+
return this.resolveWithDelay(this._jsonRawData[t]?.[e]);
|
|
1127
1111
|
}
|
|
1128
1112
|
save(e) {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
this._jsonRawData[r][n.id] = n, o && this.notifyChange(r, n, o);
|
|
1113
|
+
if (this._simulateError?.store) throw new Error(this._simulateError.store);
|
|
1114
|
+
return Object.entries(e).forEach(([t, r]) => {
|
|
1115
|
+
this._jsonRawData[t] || (this._jsonRawData[t] = {}), r?.forEach((s) => {
|
|
1116
|
+
const n = this._jsonRawData[t][s.id];
|
|
1117
|
+
this._jsonRawData[t][s.id] = s, n && this.notifyChange(t, s, n);
|
|
1135
1118
|
});
|
|
1136
1119
|
}), this.resolveWithDelay();
|
|
1137
1120
|
}
|
|
1138
1121
|
find(e, t) {
|
|
1139
|
-
|
|
1140
|
-
if ((s = this._simulateError) != null && s.find) throw new Error(this._simulateError.find);
|
|
1122
|
+
if (this._simulateError?.find) throw new Error(this._simulateError.find);
|
|
1141
1123
|
const r = Object.values(this._jsonRawData[t] || {});
|
|
1142
1124
|
return e ? (this._lastLimit = e.limit || 0, this._cursor = 0, this._lastMatchingDocs = Object.entries(e).reduce(
|
|
1143
|
-
(
|
|
1125
|
+
(s, [n, o]) => this.queryProcessor(s, n, o),
|
|
1144
1126
|
Object.values(r)
|
|
1145
1127
|
), this.resolveWithDelay(this._lastMatchingDocs.slice(0, e.limit))) : this.resolveWithDelay(r);
|
|
1146
1128
|
}
|
|
1147
1129
|
delete(e, t) {
|
|
1148
|
-
|
|
1149
|
-
if ((r = this._simulateError) != null && r.delete) throw new Error(this._simulateError.delete);
|
|
1130
|
+
if (this._simulateError?.delete) throw new Error(this._simulateError.delete);
|
|
1150
1131
|
return delete this._jsonRawData[t][e], this.resolveWithDelay();
|
|
1151
1132
|
}
|
|
1152
1133
|
next(e) {
|
|
@@ -1200,7 +1181,6 @@ class ge extends S {
|
|
|
1200
1181
|
};
|
|
1201
1182
|
}
|
|
1202
1183
|
notifyChange(e, t, r) {
|
|
1203
|
-
var n, o, c, h, a, u;
|
|
1204
1184
|
const s = {
|
|
1205
1185
|
before: r,
|
|
1206
1186
|
after: t,
|
|
@@ -1208,7 +1188,7 @@ class ge extends S {
|
|
|
1208
1188
|
params: {},
|
|
1209
1189
|
type: r ? "update" : "create"
|
|
1210
1190
|
};
|
|
1211
|
-
|
|
1191
|
+
this._serverCollectionListeners[e]?.(s), this._documentListeners[e]?.(s), this._collectionListeners[e]?.(s);
|
|
1212
1192
|
}
|
|
1213
1193
|
decCursor(e) {
|
|
1214
1194
|
return this._cursor -= e, this._cursor < 0 ? (this._cursor = 0, !0) : !1;
|
|
@@ -1218,13 +1198,13 @@ class ge extends S {
|
|
|
1218
1198
|
limit: (n) => e,
|
|
1219
1199
|
//.slice( 0, limit ),
|
|
1220
1200
|
operations: (n) => this.retrieveQueryDocs(e, n),
|
|
1221
|
-
sort: ({ order: n, propertyName: o }) => e.sort((
|
|
1201
|
+
sort: ({ order: n, propertyName: o }) => e.sort((a, c) => n === "asc" ? this.deepValue(a, o) > this.deepValue(c, o) ? 1 : -1 : this.deepValue(a, o) < this.deepValue(c, o) ? 1 : -1)
|
|
1222
1202
|
}[t](r);
|
|
1223
1203
|
}
|
|
1224
1204
|
retrieveQueryDocs(e, t) {
|
|
1225
1205
|
return t.reduce((r, s, n) => {
|
|
1226
1206
|
if (s.aggregate) {
|
|
1227
|
-
const o = e.filter((
|
|
1207
|
+
const o = e.filter((a) => this.isQueryMatched(a, s));
|
|
1228
1208
|
return n === 0 ? o : r.concat(o);
|
|
1229
1209
|
} else
|
|
1230
1210
|
return r.filter((o) => this.isQueryMatched(o, s));
|
|
@@ -1235,22 +1215,22 @@ class ge extends S {
|
|
|
1235
1215
|
}
|
|
1236
1216
|
isQueryMatched(e, t) {
|
|
1237
1217
|
const r = {
|
|
1238
|
-
"==": (
|
|
1239
|
-
"!=": (
|
|
1240
|
-
"<": (
|
|
1241
|
-
"<=": (
|
|
1242
|
-
">": (
|
|
1243
|
-
">=": (
|
|
1244
|
-
containsAny: (
|
|
1245
|
-
contains: (
|
|
1246
|
-
}, { property: s, value: n, operator: o } = t, [
|
|
1247
|
-
return r[o](
|
|
1218
|
+
"==": (h, d) => h === d,
|
|
1219
|
+
"!=": (h, d) => h !== d,
|
|
1220
|
+
"<": (h, d) => h < d,
|
|
1221
|
+
"<=": (h, d) => h <= d,
|
|
1222
|
+
">": (h, d) => h > d,
|
|
1223
|
+
">=": (h, d) => h >= d,
|
|
1224
|
+
containsAny: (h, d) => h?.some((V) => d?.includes(V)),
|
|
1225
|
+
contains: (h, d) => h?.includes(d)
|
|
1226
|
+
}, { property: s, value: n, operator: o } = t, [a, c] = this.retrieveValuesToCompare(e, s, n);
|
|
1227
|
+
return r[o](a, c);
|
|
1248
1228
|
}
|
|
1249
1229
|
retrieveValuesToCompare(e, t, r) {
|
|
1250
1230
|
const s = e[t];
|
|
1251
1231
|
if (s && typeof r == "object" && !Array.isArray(r)) {
|
|
1252
|
-
const
|
|
1253
|
-
var [n, o] = this.retrieveValuesToCompare(s,
|
|
1232
|
+
const a = Object.keys(r)[0];
|
|
1233
|
+
var [n, o] = this.retrieveValuesToCompare(s, a, r?.[a]);
|
|
1254
1234
|
}
|
|
1255
1235
|
return [n || s, o || r];
|
|
1256
1236
|
}
|
|
@@ -1267,12 +1247,12 @@ class ge extends S {
|
|
|
1267
1247
|
), t;
|
|
1268
1248
|
}
|
|
1269
1249
|
}
|
|
1270
|
-
const
|
|
1250
|
+
const v = class v {
|
|
1271
1251
|
static registerCloudStorage(e, t) {
|
|
1272
|
-
|
|
1252
|
+
v._cloudStorageFactoryMap[e] = t;
|
|
1273
1253
|
}
|
|
1274
1254
|
static createInstance(e) {
|
|
1275
|
-
const t =
|
|
1255
|
+
const t = v._cloudStorageFactoryMap[e];
|
|
1276
1256
|
if (!t)
|
|
1277
1257
|
throw new Error(`You should register the ${e} cloud storage provider prior to use it`);
|
|
1278
1258
|
return t();
|
|
@@ -1281,27 +1261,27 @@ const b = class b {
|
|
|
1281
1261
|
return this.__className;
|
|
1282
1262
|
}
|
|
1283
1263
|
static useCloudStorage(e) {
|
|
1284
|
-
|
|
1264
|
+
v._defaultCloudStorage = e;
|
|
1285
1265
|
}
|
|
1286
1266
|
static get defaultCloudStorage() {
|
|
1287
|
-
if (!
|
|
1267
|
+
if (!v._defaultCloudStorage)
|
|
1288
1268
|
throw new Error("You should define a default cloud storage provider prior to use it");
|
|
1289
|
-
return
|
|
1269
|
+
return v._defaultCloudStorage;
|
|
1290
1270
|
}
|
|
1291
1271
|
};
|
|
1292
|
-
|
|
1293
|
-
let
|
|
1294
|
-
function
|
|
1295
|
-
return
|
|
1272
|
+
v._cloudStorageFactoryMap = {};
|
|
1273
|
+
let P = v;
|
|
1274
|
+
function J(i, e) {
|
|
1275
|
+
return P.registerCloudStorage(i, e), (t) => {
|
|
1296
1276
|
t.prototype.__className = i;
|
|
1297
1277
|
};
|
|
1298
1278
|
}
|
|
1299
|
-
var
|
|
1300
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1279
|
+
var Z = Object.getOwnPropertyDescriptor, G = (i, e, t, r) => {
|
|
1280
|
+
for (var s = r > 1 ? void 0 : r ? Z(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
1301
1281
|
(o = i[n]) && (s = o(s) || s);
|
|
1302
1282
|
return s;
|
|
1303
1283
|
};
|
|
1304
|
-
let
|
|
1284
|
+
let j = class extends P {
|
|
1305
1285
|
constructor(i = "") {
|
|
1306
1286
|
super(), this._simulateDelay = 0, this._pendingPromises = [], this.mockFileSystem = {}, this._pathToMockFiles = i;
|
|
1307
1287
|
}
|
|
@@ -1349,21 +1329,21 @@ let A = class extends w {
|
|
|
1349
1329
|
return delete this.mockFileSystem[i], this.resolveWithDelay();
|
|
1350
1330
|
}
|
|
1351
1331
|
};
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
],
|
|
1355
|
-
var
|
|
1356
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1332
|
+
j = G([
|
|
1333
|
+
J("MockCloudStorage", () => new j())
|
|
1334
|
+
], j);
|
|
1335
|
+
var K = Object.defineProperty, X = Object.getOwnPropertyDescriptor, O = (i, e, t, r) => {
|
|
1336
|
+
for (var s = r > 1 ? void 0 : r ? X(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
1357
1337
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1358
|
-
return r && s &&
|
|
1359
|
-
},
|
|
1360
|
-
let
|
|
1338
|
+
return r && s && K(e, t, s), s;
|
|
1339
|
+
}, ee = /* @__PURE__ */ ((i) => (i[i.stored = 0] = "stored", i[i.pendingDataSet = 1] = "pendingDataSet", i[i.deleted = 2] = "deleted", i))(ee || {});
|
|
1340
|
+
let b = class extends u {
|
|
1361
1341
|
constructor() {
|
|
1362
|
-
super(...arguments), this._onChange = new
|
|
1342
|
+
super(...arguments), this._onChange = new U();
|
|
1363
1343
|
}
|
|
1364
1344
|
async save({ data: i, fileName: e, progress: t, cloudStorageProvider: r } = {}) {
|
|
1365
1345
|
const s = i || this._pendingData;
|
|
1366
|
-
s && (this._reference && await this.delete(), this.provider = r ||
|
|
1346
|
+
s && (this._reference && await this.delete(), this.provider = r || P.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 }));
|
|
1367
1347
|
}
|
|
1368
1348
|
uploadControl() {
|
|
1369
1349
|
return this.provider.uploadControl();
|
|
@@ -1378,9 +1358,9 @@ let C = class extends l {
|
|
|
1378
1358
|
get provider() {
|
|
1379
1359
|
if (!this._provider)
|
|
1380
1360
|
try {
|
|
1381
|
-
this._provider =
|
|
1361
|
+
this._provider = P.createInstance(this._cloudStorageProviderName);
|
|
1382
1362
|
} catch {
|
|
1383
|
-
this._provider =
|
|
1363
|
+
this._provider = P.defaultCloudStorage;
|
|
1384
1364
|
}
|
|
1385
1365
|
return this._provider;
|
|
1386
1366
|
}
|
|
@@ -1404,29 +1384,29 @@ let C = class extends l {
|
|
|
1404
1384
|
return this._onChange.subscribe(i);
|
|
1405
1385
|
}
|
|
1406
1386
|
};
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
],
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
],
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
],
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
],
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
],
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
],
|
|
1425
|
-
class
|
|
1387
|
+
O([
|
|
1388
|
+
S
|
|
1389
|
+
], b.prototype, "_reference", 2);
|
|
1390
|
+
O([
|
|
1391
|
+
S
|
|
1392
|
+
], b.prototype, "_url", 2);
|
|
1393
|
+
O([
|
|
1394
|
+
S
|
|
1395
|
+
], b.prototype, "_cloudStorageProviderName", 2);
|
|
1396
|
+
O([
|
|
1397
|
+
S
|
|
1398
|
+
], b.prototype, "_originalFileName", 2);
|
|
1399
|
+
O([
|
|
1400
|
+
S
|
|
1401
|
+
], b.prototype, "_mimeType", 2);
|
|
1402
|
+
b = O([
|
|
1403
|
+
z("StoredFile")
|
|
1404
|
+
], b);
|
|
1405
|
+
class L {
|
|
1426
1406
|
}
|
|
1427
|
-
const p = class p extends
|
|
1407
|
+
const p = class p extends L {
|
|
1428
1408
|
constructor() {
|
|
1429
|
-
if (super(), this._onAuthStateChange = new
|
|
1409
|
+
if (super(), this._onAuthStateChange = new U(), !p._authService) throw new Error(p.error.shouldBeRegistered);
|
|
1430
1410
|
p._authService.onAuthStateChange(
|
|
1431
1411
|
(e) => this.authStateChanged(e)
|
|
1432
1412
|
);
|
|
@@ -1550,15 +1530,14 @@ const p = class p extends W {
|
|
|
1550
1530
|
}
|
|
1551
1531
|
};
|
|
1552
1532
|
p.error = { shouldBeRegistered: "You should register an auth service before using Auth." }, p._instance = void 0;
|
|
1553
|
-
let
|
|
1554
|
-
class
|
|
1533
|
+
let F = p;
|
|
1534
|
+
class de extends L {
|
|
1555
1535
|
constructor() {
|
|
1556
1536
|
super(...arguments), this.pendingPromises = [], this._fakeRegisteredUsers = {};
|
|
1557
1537
|
}
|
|
1558
1538
|
signUp(e) {
|
|
1559
|
-
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (
|
|
1560
|
-
|
|
1561
|
-
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));
|
|
1539
|
+
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (a, c) => {
|
|
1540
|
+
n === "email" && (r || c({ code: "missingEmail", message: "missingEmail" }), s || c({ code: "missingPassword", message: "missingPassword" })), s !== "fail" && r !== "fail" ? (this._loggedUser = this.userCredentials(e), this._fakeRegisteredUsers[this._loggedUser.id] = this._loggedUser, a(this._loggedUser), this.notifyChange?.(this._loggedUser)) : (c({ code: "userNotFound", message: t || "Test auth error" }), this.notifyChange?.(void 0));
|
|
1562
1541
|
});
|
|
1563
1542
|
return this.pendingPromises.push(o), o;
|
|
1564
1543
|
}
|
|
@@ -1573,8 +1552,7 @@ class _e extends W {
|
|
|
1573
1552
|
}
|
|
1574
1553
|
async logout() {
|
|
1575
1554
|
const e = new Promise((t) => {
|
|
1576
|
-
|
|
1577
|
-
this._loggedUser = void 0, t(), (r = this.notifyChange) == null || r.call(this, void 0);
|
|
1555
|
+
this._loggedUser = void 0, t(), this.notifyChange?.(void 0);
|
|
1578
1556
|
});
|
|
1579
1557
|
return this.pendingPromises.push(e), e;
|
|
1580
1558
|
}
|
|
@@ -1624,21 +1602,21 @@ class _e extends W {
|
|
|
1624
1602
|
};
|
|
1625
1603
|
}
|
|
1626
1604
|
}
|
|
1627
|
-
const
|
|
1605
|
+
const g = class g {
|
|
1628
1606
|
constructor() {
|
|
1629
1607
|
}
|
|
1630
1608
|
static useCloudFunctionsService(e) {
|
|
1631
1609
|
this._cloudFunctionsService != e && (this._cloudFunctionsService = e);
|
|
1632
1610
|
}
|
|
1633
1611
|
static get instance() {
|
|
1634
|
-
if (!this._cloudFunctionsService) throw new Error(
|
|
1635
|
-
return
|
|
1612
|
+
if (!this._cloudFunctionsService) throw new Error(g.error.shouldBeRegistered);
|
|
1613
|
+
return g._instance || (g._instance = new g());
|
|
1636
1614
|
}
|
|
1637
1615
|
getRawFunction(e) {
|
|
1638
|
-
return
|
|
1616
|
+
return g._cloudFunctionsService.retrieveFunction(e);
|
|
1639
1617
|
}
|
|
1640
1618
|
getFunction(e) {
|
|
1641
|
-
const t =
|
|
1619
|
+
const t = g._cloudFunctionsService.callFunction, r = this.getRawFunction(e);
|
|
1642
1620
|
return async (s) => {
|
|
1643
1621
|
const n = await t(r, this.processParam(s));
|
|
1644
1622
|
return this.processResult(n);
|
|
@@ -1646,16 +1624,16 @@ const _ = class _ {
|
|
|
1646
1624
|
}
|
|
1647
1625
|
processParam(e) {
|
|
1648
1626
|
if (e != null)
|
|
1649
|
-
return e instanceof
|
|
1627
|
+
return e instanceof u ? 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;
|
|
1650
1628
|
}
|
|
1651
1629
|
processResult(e) {
|
|
1652
1630
|
if (e != null)
|
|
1653
|
-
return e.__className ?
|
|
1631
|
+
return e.__className ? u.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;
|
|
1654
1632
|
}
|
|
1655
1633
|
};
|
|
1656
|
-
|
|
1657
|
-
let
|
|
1658
|
-
class
|
|
1634
|
+
g.error = { shouldBeRegistered: "You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions." };
|
|
1635
|
+
let I = g;
|
|
1636
|
+
class fe {
|
|
1659
1637
|
constructor(e) {
|
|
1660
1638
|
this._registeredFunctions = e;
|
|
1661
1639
|
}
|
|
@@ -1668,9 +1646,9 @@ class ye {
|
|
|
1668
1646
|
return e(t);
|
|
1669
1647
|
}
|
|
1670
1648
|
}
|
|
1671
|
-
class
|
|
1649
|
+
class M {
|
|
1672
1650
|
}
|
|
1673
|
-
const m = class m extends
|
|
1651
|
+
const m = class m extends M {
|
|
1674
1652
|
constructor() {
|
|
1675
1653
|
super();
|
|
1676
1654
|
}
|
|
@@ -1695,8 +1673,8 @@ const m = class m extends Q {
|
|
|
1695
1673
|
}
|
|
1696
1674
|
};
|
|
1697
1675
|
m.error = { shouldBeRegistered: "You should register a Server Auth service before using the Server Auth." }, m._instance = void 0;
|
|
1698
|
-
let
|
|
1699
|
-
class
|
|
1676
|
+
let N = m;
|
|
1677
|
+
class pe extends M {
|
|
1700
1678
|
constructor(e) {
|
|
1701
1679
|
super(), this._userCredentials = e;
|
|
1702
1680
|
}
|
|
@@ -1722,62 +1700,62 @@ class ve extends Q {
|
|
|
1722
1700
|
return this._userCredentials;
|
|
1723
1701
|
}
|
|
1724
1702
|
}
|
|
1725
|
-
function
|
|
1703
|
+
function me(i, e) {
|
|
1726
1704
|
return i ? i.replace(/\${\s*(\w*)\s*}/g, function(t, r) {
|
|
1727
1705
|
return e[r] || "";
|
|
1728
1706
|
}) : "";
|
|
1729
1707
|
}
|
|
1730
|
-
function
|
|
1708
|
+
function ge(i) {
|
|
1731
1709
|
return i ? i.replace(
|
|
1732
1710
|
/([-_ ][\w])/g,
|
|
1733
1711
|
(e) => e.toUpperCase().replace("-", "").replace("_", "").replace(" ", "")
|
|
1734
1712
|
) : "";
|
|
1735
1713
|
}
|
|
1736
|
-
function
|
|
1714
|
+
function _e(i, e = "-") {
|
|
1737
1715
|
if (!i) return "";
|
|
1738
1716
|
const t = i.slice(1).replace(/( |[A-Z])/g, (r) => r === " " ? "-" : e + r[0].toLowerCase());
|
|
1739
1717
|
return i[0].toLocaleLowerCase() + t.replace(/--/g, "-");
|
|
1740
1718
|
}
|
|
1741
|
-
function
|
|
1719
|
+
function ye(i, e) {
|
|
1742
1720
|
return e.split(".").reduce((t, r) => t[r], i);
|
|
1743
1721
|
}
|
|
1744
1722
|
export {
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1723
|
+
F as Auth,
|
|
1724
|
+
de as AuthMock,
|
|
1725
|
+
L as AuthService,
|
|
1726
|
+
I as CloudFunctions,
|
|
1727
|
+
fe as CloudFunctionsMock,
|
|
1728
|
+
P as CloudStorage,
|
|
1729
|
+
w as DataSource,
|
|
1730
|
+
he as EntropicComponent,
|
|
1731
|
+
le as JsonDataSource,
|
|
1732
|
+
j as MockCloudStorage,
|
|
1733
|
+
C as Model,
|
|
1734
|
+
U as Observable,
|
|
1735
|
+
u as Persistent,
|
|
1736
|
+
H as Query,
|
|
1737
|
+
N as ServerAuth,
|
|
1738
|
+
pe as ServerAuthMock,
|
|
1739
|
+
M as ServerAuthService,
|
|
1740
|
+
E as Store,
|
|
1741
|
+
b as StoredFile,
|
|
1742
|
+
ee as StoredFileEvent,
|
|
1743
|
+
ge as camelCase,
|
|
1744
|
+
ye as getDeepValue,
|
|
1745
|
+
S as persistent,
|
|
1746
|
+
_ as persistentParser,
|
|
1747
|
+
ie as persistentPureReference,
|
|
1748
|
+
ne as persistentPureReferenceWithCachedProps,
|
|
1749
|
+
re as persistentReference,
|
|
1750
|
+
te as persistentReferenceAt,
|
|
1751
|
+
se as persistentReferenceWithCachedProps,
|
|
1752
|
+
J as registerCloudStorage,
|
|
1753
|
+
oe as registerLegacyClassName,
|
|
1754
|
+
z as registerPersistentClass,
|
|
1755
|
+
me as replaceValue,
|
|
1756
|
+
ce as required,
|
|
1757
|
+
ue as requiredWithValidator,
|
|
1758
|
+
ae as searchableArray,
|
|
1759
|
+
_e as snakeCase
|
|
1782
1760
|
};
|
|
1783
1761
|
//# sourceMappingURL=entropic-bond.js.map
|