entropic-bond 1.53.13 → 1.53.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/entropic-bond.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class U {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
4
4
|
}
|
|
@@ -46,44 +46,44 @@ 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 ($.randomUUID && !i)
|
|
66
|
-
return $.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
|
|
82
82
|
* @param factory the constructor of the registered class
|
|
83
83
|
* @param annotation an annotation associated with the class
|
|
84
84
|
*/
|
|
85
|
-
static registerFactory(e, t, r) {
|
|
86
|
-
this._factoryMap[e] = { factory: t, annotation: r };
|
|
85
|
+
static registerFactory(e, t, r, s = !1) {
|
|
86
|
+
this._factoryMap[e] = { factory: t, annotation: r, isLegacy: s };
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Returns the constructor of a registered class
|
|
@@ -107,6 +107,15 @@ const B = (d = class {
|
|
|
107
107
|
* @see classFactory
|
|
108
108
|
*/
|
|
109
109
|
static registeredClasses() {
|
|
110
|
+
return Object.entries(this._factoryMap).filter(([, e]) => !e.isLegacy).map(([e]) => e);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns the names of all registered classes, including legacy names
|
|
114
|
+
* @returns the names of all registered classes, including legacy names
|
|
115
|
+
* @see registerFactory
|
|
116
|
+
* @see classFactory
|
|
117
|
+
*/
|
|
118
|
+
static registeredClassesAndLegacyNames() {
|
|
110
119
|
return Object.keys(this._factoryMap);
|
|
111
120
|
}
|
|
112
121
|
/**
|
|
@@ -117,7 +126,7 @@ const B = (d = class {
|
|
|
117
126
|
* @see classFactory
|
|
118
127
|
*/
|
|
119
128
|
static classesExtending(e) {
|
|
120
|
-
return Object.entries(this._factoryMap).filter(([, t]) => new t.factory() instanceof e).map(([t]) => t);
|
|
129
|
+
return Object.entries(this._factoryMap).filter(([, t]) => new t.factory() instanceof e && !t.isLegacy).map(([t]) => t);
|
|
121
130
|
}
|
|
122
131
|
/**
|
|
123
132
|
* Returns the annotation associated with a registered class
|
|
@@ -127,14 +136,14 @@ const B = (d = class {
|
|
|
127
136
|
* @see registerFactory
|
|
128
137
|
*/
|
|
129
138
|
static annotations(e) {
|
|
130
|
-
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.`);
|
|
131
140
|
return this._factoryMap[e].annotation;
|
|
132
141
|
}
|
|
133
142
|
/**
|
|
134
143
|
* Returns a new instance of Persistent class.
|
|
135
144
|
* @param className the initial id of this instance. If not provided, a new id will be generated
|
|
136
145
|
*/
|
|
137
|
-
constructor(e =
|
|
146
|
+
constructor(e = Q()) {
|
|
138
147
|
this._id = e;
|
|
139
148
|
}
|
|
140
149
|
/**
|
|
@@ -264,7 +273,7 @@ const B = (d = class {
|
|
|
264
273
|
if (!this.className) throw new Error(`You should register \`${this.constructor.name || this.toString() || "this"}\` class prior to streaming it.`);
|
|
265
274
|
return this._persistentProperties.forEach((r) => {
|
|
266
275
|
const s = this[r.name], n = this.removeUnderscore(r);
|
|
267
|
-
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)));
|
|
268
277
|
}), t.__className = this.className, t;
|
|
269
278
|
}
|
|
270
279
|
static searchableArrayNameFor(e) {
|
|
@@ -275,11 +284,11 @@ const B = (d = class {
|
|
|
275
284
|
if (Array.isArray(e))
|
|
276
285
|
return e.map((t) => this.fromDeepObject(t));
|
|
277
286
|
if (e.__documentReference) {
|
|
278
|
-
const t = e, r =
|
|
287
|
+
const t = e, r = l.createInstance(t);
|
|
279
288
|
return r.__documentReference = e.__documentReference, r;
|
|
280
289
|
}
|
|
281
290
|
if (e.__className)
|
|
282
|
-
return
|
|
291
|
+
return l.createInstance(e);
|
|
283
292
|
if (typeof e == "object") {
|
|
284
293
|
const t = {};
|
|
285
294
|
return Object.entries(e).forEach(
|
|
@@ -293,7 +302,7 @@ const B = (d = class {
|
|
|
293
302
|
if (Array.isArray(e))
|
|
294
303
|
return e.map((r) => this.toDeepObj(r, t));
|
|
295
304
|
if (e.__documentReference) return e;
|
|
296
|
-
if (e instanceof
|
|
305
|
+
if (e instanceof l)
|
|
297
306
|
return e.toObj(t);
|
|
298
307
|
if (typeof e == "object") {
|
|
299
308
|
const r = {};
|
|
@@ -309,15 +318,11 @@ const B = (d = class {
|
|
|
309
318
|
return typeof t.storeInCollection == "function" ? r = t.storeInCollection(e, t) : r = t.storeInCollection ?? e.className, r;
|
|
310
319
|
}
|
|
311
320
|
toReferenceObj(e, t) {
|
|
312
|
-
var s;
|
|
313
321
|
const r = this[e.name];
|
|
314
|
-
return Array.isArray(r) ? r.map((
|
|
315
|
-
var o;
|
|
316
|
-
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);
|
|
317
|
-
}) : (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));
|
|
318
323
|
}
|
|
319
324
|
buildRefObject(e, t, r) {
|
|
320
|
-
const s = r
|
|
325
|
+
const s = r?.reduce((n, o) => (e[o] !== void 0 && (n[o] = e[o]), n), {});
|
|
321
326
|
return {
|
|
322
327
|
id: e.id,
|
|
323
328
|
__className: e.className || e.__className,
|
|
@@ -337,14 +342,14 @@ const B = (d = class {
|
|
|
337
342
|
return e.name.slice(1);
|
|
338
343
|
}
|
|
339
344
|
static createReference(e) {
|
|
340
|
-
const t =
|
|
345
|
+
const t = l.createInstance(e);
|
|
341
346
|
return t.__documentReference = e.__documentReference || { storedInCollection: t.className }, t;
|
|
342
347
|
}
|
|
343
348
|
static createInstance(e) {
|
|
344
349
|
if (typeof e == "string")
|
|
345
|
-
return new (
|
|
350
|
+
return new (l.classFactory(e))();
|
|
346
351
|
try {
|
|
347
|
-
return new (
|
|
352
|
+
return new (l.classFactory(e.__className))().fromObject(e);
|
|
348
353
|
} catch (t) {
|
|
349
354
|
const r = Object.entries(e).filter(([s, n]) => n != null && typeof n != "function").map(([s, n]) => `${s}: ${n}`).join(`,
|
|
350
355
|
`);
|
|
@@ -357,46 +362,43 @@ const B = (d = class {
|
|
|
357
362
|
}
|
|
358
363
|
}
|
|
359
364
|
static propInfo(e, t) {
|
|
360
|
-
return
|
|
365
|
+
return l.createInstance(e).getPropInfo(t);
|
|
361
366
|
}
|
|
362
367
|
/**
|
|
363
368
|
* Retrieves a collection of references with the properties that are stored in the reference object
|
|
364
369
|
* @returns the references collection
|
|
365
370
|
*/
|
|
366
371
|
static getSystemRegisteredReferencesWithCachedProps() {
|
|
367
|
-
return
|
|
368
|
-
const o =
|
|
369
|
-
(
|
|
370
|
-
var h;
|
|
371
|
-
return (h = c.cachedPropsConfig) == null ? void 0 : h.cachedProps;
|
|
372
|
-
}
|
|
372
|
+
return l.registeredClassesAndLegacyNames().reduce((r, s) => {
|
|
373
|
+
const o = l.createInstance(s).getPersistentProperties().filter(
|
|
374
|
+
(a) => a.cachedPropsConfig?.cachedProps
|
|
373
375
|
);
|
|
374
376
|
return o.length > 0 && (r[s] = o), r;
|
|
375
377
|
}, {});
|
|
376
378
|
}
|
|
377
|
-
},
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
],
|
|
381
|
-
let
|
|
382
|
-
function
|
|
383
|
-
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);
|
|
384
386
|
}
|
|
385
|
-
function
|
|
387
|
+
function te(i) {
|
|
386
388
|
return function(e, t) {
|
|
387
|
-
return
|
|
389
|
+
return _({
|
|
388
390
|
storeInCollection: i,
|
|
389
391
|
isReference: !0
|
|
390
392
|
})(e, t);
|
|
391
393
|
};
|
|
392
394
|
}
|
|
393
|
-
function
|
|
394
|
-
return
|
|
395
|
+
function re(i, e) {
|
|
396
|
+
return _({ isReference: !0 })(i, e);
|
|
395
397
|
}
|
|
396
|
-
function
|
|
398
|
+
function se(i, e, t) {
|
|
397
399
|
const r = Array.isArray(i) ? { cachedProps: i } : i;
|
|
398
400
|
return function(s, n) {
|
|
399
|
-
return
|
|
401
|
+
return _({
|
|
400
402
|
isReference: !0,
|
|
401
403
|
storeInCollection: e,
|
|
402
404
|
typeName: t,
|
|
@@ -404,13 +406,13 @@ function ce(i, e, t) {
|
|
|
404
406
|
})(s, n);
|
|
405
407
|
};
|
|
406
408
|
}
|
|
407
|
-
function
|
|
408
|
-
return
|
|
409
|
+
function ie(i, e, t) {
|
|
410
|
+
return _({ isReference: !0, isPureReference: !0, storeInCollection: t })(i, e);
|
|
409
411
|
}
|
|
410
|
-
function
|
|
412
|
+
function ne(i, e, t) {
|
|
411
413
|
return function(r, s) {
|
|
412
414
|
const n = Array.isArray(i) ? { cachedProps: i } : i;
|
|
413
|
-
return
|
|
415
|
+
return _({
|
|
414
416
|
isReference: !0,
|
|
415
417
|
isPureReference: !0,
|
|
416
418
|
storeInCollection: e,
|
|
@@ -419,7 +421,7 @@ function he(i, e, t) {
|
|
|
419
421
|
})(r, s);
|
|
420
422
|
};
|
|
421
423
|
}
|
|
422
|
-
function
|
|
424
|
+
function _(i) {
|
|
423
425
|
return function(e, t) {
|
|
424
426
|
Object.getOwnPropertyDescriptor(e, "_persistentProperties") || (e._persistentProperties ? e._persistentProperties = [...e._persistentProperties] : e._persistentProperties = []);
|
|
425
427
|
const r = e._persistentProperties.find((s) => s.name === t);
|
|
@@ -429,30 +431,30 @@ function y(i) {
|
|
|
429
431
|
});
|
|
430
432
|
};
|
|
431
433
|
}
|
|
432
|
-
function
|
|
434
|
+
function z(i, e) {
|
|
433
435
|
return (t) => {
|
|
434
|
-
|
|
436
|
+
u.registerFactory(i, t, e), t.prototype.__className = i;
|
|
435
437
|
};
|
|
436
438
|
}
|
|
437
|
-
function
|
|
439
|
+
function oe(i) {
|
|
438
440
|
return (e) => {
|
|
439
|
-
|
|
441
|
+
u.registerFactory(i, e, void 0, !0);
|
|
440
442
|
};
|
|
441
443
|
}
|
|
442
|
-
function
|
|
443
|
-
return
|
|
444
|
+
function ae(i, e) {
|
|
445
|
+
return _({ searchableArray: !0 })(i, e);
|
|
444
446
|
}
|
|
445
|
-
function
|
|
446
|
-
return
|
|
447
|
+
function ce(i, e) {
|
|
448
|
+
return _({ validator: (t) => t != null })(i, e);
|
|
447
449
|
}
|
|
448
|
-
function
|
|
450
|
+
function ue(i = (e) => e != null) {
|
|
449
451
|
return function(e, t) {
|
|
450
|
-
return
|
|
452
|
+
return _({ validator: i })(e, t);
|
|
451
453
|
};
|
|
452
454
|
}
|
|
453
|
-
class
|
|
455
|
+
class he extends u {
|
|
454
456
|
constructor() {
|
|
455
|
-
super(...arguments), this._onChange = new
|
|
457
|
+
super(...arguments), this._onChange = new U();
|
|
456
458
|
}
|
|
457
459
|
/**
|
|
458
460
|
* Subscribes a listener callback function. Every time a property is changed,
|
|
@@ -535,13 +537,13 @@ class me extends l {
|
|
|
535
537
|
return this.notify({ [e]: this[e] }), t;
|
|
536
538
|
}
|
|
537
539
|
}
|
|
538
|
-
const
|
|
540
|
+
const R = class R {
|
|
539
541
|
constructor(e, t, r) {
|
|
540
542
|
if (r) {
|
|
541
|
-
if (!(t instanceof
|
|
543
|
+
if (!(t instanceof u)) throw new Error(R.error.persistentNeedForSubCollection);
|
|
542
544
|
this.collectionName = `${t.className}/${t.id}/${r}`;
|
|
543
545
|
} else
|
|
544
|
-
this.collectionName = t instanceof
|
|
546
|
+
this.collectionName = t instanceof u ? t.className : t;
|
|
545
547
|
this._stream = e;
|
|
546
548
|
}
|
|
547
549
|
/**
|
|
@@ -556,7 +558,7 @@ const E = class E {
|
|
|
556
558
|
findById(e, t) {
|
|
557
559
|
return new Promise((r, s) => {
|
|
558
560
|
this._stream.findById(e, this.collectionName).then((n) => {
|
|
559
|
-
n ? (t ? t.fromObject(n) : t =
|
|
561
|
+
n ? (t ? t.fromObject(n) : t = u.createInstance(n), r(t)) : r(void 0);
|
|
560
562
|
}).catch((n) => s(n));
|
|
561
563
|
});
|
|
562
564
|
}
|
|
@@ -587,7 +589,7 @@ const E = class E {
|
|
|
587
589
|
* @returns a Query object
|
|
588
590
|
*/
|
|
589
591
|
find() {
|
|
590
|
-
return new
|
|
592
|
+
return new H(this);
|
|
591
593
|
}
|
|
592
594
|
/**
|
|
593
595
|
* Define the search conditions. You pass query operations and how the query
|
|
@@ -598,7 +600,7 @@ const E = class E {
|
|
|
598
600
|
*/
|
|
599
601
|
query(e = {}, t) {
|
|
600
602
|
if (t) {
|
|
601
|
-
const r = t instanceof
|
|
603
|
+
const r = t instanceof u ? t.className : t;
|
|
602
604
|
e.operations || (e.operations = []), e.operations.push(
|
|
603
605
|
{ property: "__className", operator: "==", value: r }
|
|
604
606
|
);
|
|
@@ -641,8 +643,8 @@ const E = class E {
|
|
|
641
643
|
toPersistentChangeObject(e) {
|
|
642
644
|
return {
|
|
643
645
|
...e,
|
|
644
|
-
before: e.before &&
|
|
645
|
-
after: e.after &&
|
|
646
|
+
before: e.before && u.createInstance(e.before),
|
|
647
|
+
after: e.after && u.createInstance(e.after)
|
|
646
648
|
};
|
|
647
649
|
}
|
|
648
650
|
// /**
|
|
@@ -657,7 +659,7 @@ const E = class E {
|
|
|
657
659
|
mapToInstance(e) {
|
|
658
660
|
return new Promise((t, r) => {
|
|
659
661
|
e().then((s) => t(
|
|
660
|
-
s.map((n) =>
|
|
662
|
+
s.map((n) => u.createInstance(n))
|
|
661
663
|
)).catch((s) => r(s));
|
|
662
664
|
});
|
|
663
665
|
}
|
|
@@ -670,34 +672,33 @@ const E = class E {
|
|
|
670
672
|
* @returns the normalized query object
|
|
671
673
|
*/
|
|
672
674
|
preprocessQueryObject(e) {
|
|
673
|
-
var r;
|
|
674
675
|
if (Object.values(e).length === 0) return e;
|
|
675
|
-
const t =
|
|
676
|
-
const
|
|
677
|
-
return
|
|
678
|
-
property:
|
|
679
|
-
operator:
|
|
680
|
-
value: Array.isArray(
|
|
681
|
-
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
|
|
682
683
|
} : {
|
|
683
|
-
property:
|
|
684
|
-
operator:
|
|
685
|
-
value:
|
|
686
|
-
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
|
|
687
688
|
};
|
|
688
|
-
})
|
|
689
|
+
}) ?? [];
|
|
689
690
|
return {
|
|
690
691
|
...e,
|
|
691
692
|
operations: t
|
|
692
693
|
};
|
|
693
694
|
}
|
|
694
695
|
};
|
|
695
|
-
|
|
696
|
+
R.error = {
|
|
696
697
|
persistentNeedForSubCollection: "The document parameter for a sub-collection should be a Persistent instace",
|
|
697
698
|
invalidQueryOrder: "Cannot add where calls after or calls"
|
|
698
699
|
};
|
|
699
|
-
let
|
|
700
|
-
class
|
|
700
|
+
let C = R;
|
|
701
|
+
class H {
|
|
701
702
|
constructor(e) {
|
|
702
703
|
this.queryObject = { operations: [] }, this.model = e;
|
|
703
704
|
}
|
|
@@ -721,9 +722,8 @@ class X {
|
|
|
721
722
|
* @see orDeepProp
|
|
722
723
|
*/
|
|
723
724
|
where(e, t, r, s) {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
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({
|
|
727
727
|
property: e,
|
|
728
728
|
operator: t,
|
|
729
729
|
value: r,
|
|
@@ -755,16 +755,15 @@ class X {
|
|
|
755
755
|
* @see orDeepProp
|
|
756
756
|
*/
|
|
757
757
|
whereDeepProp(e, t, r, s) {
|
|
758
|
-
|
|
759
|
-
if ((a = (h = this.queryObject.operations) == null ? void 0 : h.at(-1)) != null && a.aggregate && !s) throw new Error(R.error.invalidQueryOrder);
|
|
758
|
+
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(C.error.invalidQueryOrder);
|
|
760
759
|
const n = e.split(".");
|
|
761
|
-
let o = {},
|
|
762
|
-
return n.slice(1).forEach((
|
|
763
|
-
o[
|
|
764
|
-
}),
|
|
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({
|
|
765
764
|
property: n[0],
|
|
766
765
|
operator: t,
|
|
767
|
-
value:
|
|
766
|
+
value: a,
|
|
768
767
|
aggregate: s
|
|
769
768
|
}), this;
|
|
770
769
|
}
|
|
@@ -850,9 +849,8 @@ class X {
|
|
|
850
849
|
* query.instanceOf( Person ).where( 'age', '>', 18 )
|
|
851
850
|
*/
|
|
852
851
|
instanceOf(e) {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
return (r = this.queryObject.operations) == null || r.push({
|
|
852
|
+
const t = e instanceof u ? e.className : e;
|
|
853
|
+
return this.queryObject.operations?.push({
|
|
856
854
|
property: "__className",
|
|
857
855
|
operator: "==",
|
|
858
856
|
value: t
|
|
@@ -921,7 +919,7 @@ class X {
|
|
|
921
919
|
return this.queryObject;
|
|
922
920
|
}
|
|
923
921
|
}
|
|
924
|
-
const
|
|
922
|
+
const y = class y {
|
|
925
923
|
constructor() {
|
|
926
924
|
}
|
|
927
925
|
/**
|
|
@@ -937,7 +935,7 @@ const P = class P {
|
|
|
937
935
|
* @returns the data source
|
|
938
936
|
*/
|
|
939
937
|
static get dataSource() {
|
|
940
|
-
return
|
|
938
|
+
return y._dataSource;
|
|
941
939
|
}
|
|
942
940
|
/**
|
|
943
941
|
* Retrieves a model for a collection
|
|
@@ -945,8 +943,8 @@ const P = class P {
|
|
|
945
943
|
* @returns the model for the collection
|
|
946
944
|
*/
|
|
947
945
|
static getModel(e) {
|
|
948
|
-
if (!
|
|
949
|
-
return new
|
|
946
|
+
if (!y._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
947
|
+
return new C(y._dataSource, e);
|
|
950
948
|
}
|
|
951
949
|
/**
|
|
952
950
|
* Retrieves a model for a subcollection
|
|
@@ -955,8 +953,8 @@ const P = class P {
|
|
|
955
953
|
* @returns the model for the subcollection
|
|
956
954
|
*/
|
|
957
955
|
static getModelForSubCollection(e, t) {
|
|
958
|
-
if (!
|
|
959
|
-
return new
|
|
956
|
+
if (!y._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
957
|
+
return new C(y._dataSource, e, t);
|
|
960
958
|
}
|
|
961
959
|
/**
|
|
962
960
|
* Populates property references with actual data from the store.
|
|
@@ -988,26 +986,26 @@ const P = class P {
|
|
|
988
986
|
) : e.__documentReference === void 0;
|
|
989
987
|
}
|
|
990
988
|
};
|
|
991
|
-
|
|
992
|
-
let
|
|
993
|
-
class
|
|
989
|
+
y.error = { shouldBeRegistered: "You should register a data source before using the data Store." };
|
|
990
|
+
let E = y;
|
|
991
|
+
class w {
|
|
994
992
|
installCachedPropsUpdaters(e = {}) {
|
|
995
|
-
|
|
996
|
-
const t =
|
|
993
|
+
w.onUpdate = e.onUpdate;
|
|
994
|
+
const t = u.getSystemRegisteredReferencesWithCachedProps(), r = {};
|
|
997
995
|
Object.entries(t).forEach(([n, o]) => {
|
|
998
|
-
o.forEach((
|
|
999
|
-
const
|
|
1000
|
-
r[
|
|
1001
|
-
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,
|
|
1002
1000
|
collectionPropOwner: n
|
|
1003
1001
|
});
|
|
1004
1002
|
});
|
|
1005
1003
|
});
|
|
1006
1004
|
const s = [];
|
|
1007
1005
|
return Object.entries(r).forEach(([n, o]) => {
|
|
1008
|
-
const
|
|
1009
|
-
if (
|
|
1010
|
-
s.push(
|
|
1006
|
+
const a = this.subscribeToDocumentChangeListerner(n, (c) => w.processDocumentChange(c, o));
|
|
1007
|
+
if (a)
|
|
1008
|
+
s.push(a);
|
|
1011
1009
|
else if (e.noThrowOnNonImplementedListener) throw new Error("The method documentChangeListerner has not been implemented in the concrete data source");
|
|
1012
1010
|
}), s;
|
|
1013
1011
|
}
|
|
@@ -1037,9 +1035,9 @@ class S {
|
|
|
1037
1035
|
*/
|
|
1038
1036
|
static toPropertyPathOperations(e) {
|
|
1039
1037
|
return e ? e.map((t) => {
|
|
1040
|
-
if (
|
|
1038
|
+
if (w.isArrayOperator(t.operator) && t.value[0] instanceof u)
|
|
1041
1039
|
return {
|
|
1042
|
-
property:
|
|
1040
|
+
property: u.searchableArrayNameFor(t.property),
|
|
1043
1041
|
operator: t.operator,
|
|
1044
1042
|
value: t.value.map((o) => o.id),
|
|
1045
1043
|
aggregate: t.aggregate
|
|
@@ -1066,29 +1064,25 @@ class S {
|
|
|
1066
1064
|
static async processDocumentChange(e, t) {
|
|
1067
1065
|
if (e.before)
|
|
1068
1066
|
return t.map(async (r) => {
|
|
1069
|
-
|
|
1070
|
-
const s = F.getModel(r.collectionPropOwner);
|
|
1067
|
+
const s = E.getModel(r.collectionPropOwner);
|
|
1071
1068
|
let n = s.find();
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
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));
|
|
1076
1072
|
});
|
|
1077
1073
|
const o = await n.get();
|
|
1078
1074
|
return Promise.all([
|
|
1079
1075
|
o.map(async (a) => {
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
const j = (N = e.before) == null ? void 0 : N[v], k = (M = e.after) == null ? void 0 : M[v];
|
|
1084
|
-
j !== k && (a[`_${r.prop.name}`][`_${v}`] = k, await s.save(a), (V = this.onUpdate) == null || V.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));
|
|
1085
1079
|
});
|
|
1086
1080
|
})
|
|
1087
1081
|
]);
|
|
1088
1082
|
});
|
|
1089
1083
|
}
|
|
1090
1084
|
}
|
|
1091
|
-
class
|
|
1085
|
+
class le extends w {
|
|
1092
1086
|
/**
|
|
1093
1087
|
* @param jsonRawData the JSON object to be used as data store
|
|
1094
1088
|
*/
|
|
@@ -1112,32 +1106,28 @@ class ge extends S {
|
|
|
1112
1106
|
return this._simulateDelay = e, this;
|
|
1113
1107
|
}
|
|
1114
1108
|
findById(e, t) {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
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]);
|
|
1118
1111
|
}
|
|
1119
1112
|
save(e) {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
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);
|
|
1126
1118
|
});
|
|
1127
1119
|
}), this.resolveWithDelay();
|
|
1128
1120
|
}
|
|
1129
1121
|
find(e, t) {
|
|
1130
|
-
|
|
1131
|
-
if ((s = this._simulateError) != null && s.find) throw new Error(this._simulateError.find);
|
|
1122
|
+
if (this._simulateError?.find) throw new Error(this._simulateError.find);
|
|
1132
1123
|
const r = Object.values(this._jsonRawData[t] || {});
|
|
1133
1124
|
return e ? (this._lastLimit = e.limit || 0, this._cursor = 0, this._lastMatchingDocs = Object.entries(e).reduce(
|
|
1134
|
-
(
|
|
1125
|
+
(s, [n, o]) => this.queryProcessor(s, n, o),
|
|
1135
1126
|
Object.values(r)
|
|
1136
1127
|
), this.resolveWithDelay(this._lastMatchingDocs.slice(0, e.limit))) : this.resolveWithDelay(r);
|
|
1137
1128
|
}
|
|
1138
1129
|
delete(e, t) {
|
|
1139
|
-
|
|
1140
|
-
if ((r = this._simulateError) != null && r.delete) throw new Error(this._simulateError.delete);
|
|
1130
|
+
if (this._simulateError?.delete) throw new Error(this._simulateError.delete);
|
|
1141
1131
|
return delete this._jsonRawData[t][e], this.resolveWithDelay();
|
|
1142
1132
|
}
|
|
1143
1133
|
next(e) {
|
|
@@ -1191,7 +1181,6 @@ class ge extends S {
|
|
|
1191
1181
|
};
|
|
1192
1182
|
}
|
|
1193
1183
|
notifyChange(e, t, r) {
|
|
1194
|
-
var n, o, c, h, a, u;
|
|
1195
1184
|
const s = {
|
|
1196
1185
|
before: r,
|
|
1197
1186
|
after: t,
|
|
@@ -1199,7 +1188,7 @@ class ge extends S {
|
|
|
1199
1188
|
params: {},
|
|
1200
1189
|
type: r ? "update" : "create"
|
|
1201
1190
|
};
|
|
1202
|
-
|
|
1191
|
+
this._serverCollectionListeners[e]?.(s), this._documentListeners[e]?.(s), this._collectionListeners[e]?.(s);
|
|
1203
1192
|
}
|
|
1204
1193
|
decCursor(e) {
|
|
1205
1194
|
return this._cursor -= e, this._cursor < 0 ? (this._cursor = 0, !0) : !1;
|
|
@@ -1209,13 +1198,13 @@ class ge extends S {
|
|
|
1209
1198
|
limit: (n) => e,
|
|
1210
1199
|
//.slice( 0, limit ),
|
|
1211
1200
|
operations: (n) => this.retrieveQueryDocs(e, n),
|
|
1212
|
-
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)
|
|
1213
1202
|
}[t](r);
|
|
1214
1203
|
}
|
|
1215
1204
|
retrieveQueryDocs(e, t) {
|
|
1216
1205
|
return t.reduce((r, s, n) => {
|
|
1217
1206
|
if (s.aggregate) {
|
|
1218
|
-
const o = e.filter((
|
|
1207
|
+
const o = e.filter((a) => this.isQueryMatched(a, s));
|
|
1219
1208
|
return n === 0 ? o : r.concat(o);
|
|
1220
1209
|
} else
|
|
1221
1210
|
return r.filter((o) => this.isQueryMatched(o, s));
|
|
@@ -1226,22 +1215,22 @@ class ge extends S {
|
|
|
1226
1215
|
}
|
|
1227
1216
|
isQueryMatched(e, t) {
|
|
1228
1217
|
const r = {
|
|
1229
|
-
"==": (
|
|
1230
|
-
"!=": (
|
|
1231
|
-
"<": (
|
|
1232
|
-
"<=": (
|
|
1233
|
-
">": (
|
|
1234
|
-
">=": (
|
|
1235
|
-
containsAny: (
|
|
1236
|
-
contains: (
|
|
1237
|
-
}, { property: s, value: n, operator: o } = t, [
|
|
1238
|
-
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);
|
|
1239
1228
|
}
|
|
1240
1229
|
retrieveValuesToCompare(e, t, r) {
|
|
1241
1230
|
const s = e[t];
|
|
1242
1231
|
if (s && typeof r == "object" && !Array.isArray(r)) {
|
|
1243
|
-
const
|
|
1244
|
-
var [n, o] = this.retrieveValuesToCompare(s,
|
|
1232
|
+
const a = Object.keys(r)[0];
|
|
1233
|
+
var [n, o] = this.retrieveValuesToCompare(s, a, r?.[a]);
|
|
1245
1234
|
}
|
|
1246
1235
|
return [n || s, o || r];
|
|
1247
1236
|
}
|
|
@@ -1258,12 +1247,12 @@ class ge extends S {
|
|
|
1258
1247
|
), t;
|
|
1259
1248
|
}
|
|
1260
1249
|
}
|
|
1261
|
-
const
|
|
1250
|
+
const v = class v {
|
|
1262
1251
|
static registerCloudStorage(e, t) {
|
|
1263
|
-
|
|
1252
|
+
v._cloudStorageFactoryMap[e] = t;
|
|
1264
1253
|
}
|
|
1265
1254
|
static createInstance(e) {
|
|
1266
|
-
const t =
|
|
1255
|
+
const t = v._cloudStorageFactoryMap[e];
|
|
1267
1256
|
if (!t)
|
|
1268
1257
|
throw new Error(`You should register the ${e} cloud storage provider prior to use it`);
|
|
1269
1258
|
return t();
|
|
@@ -1272,27 +1261,27 @@ const b = class b {
|
|
|
1272
1261
|
return this.__className;
|
|
1273
1262
|
}
|
|
1274
1263
|
static useCloudStorage(e) {
|
|
1275
|
-
|
|
1264
|
+
v._defaultCloudStorage = e;
|
|
1276
1265
|
}
|
|
1277
1266
|
static get defaultCloudStorage() {
|
|
1278
|
-
if (!
|
|
1267
|
+
if (!v._defaultCloudStorage)
|
|
1279
1268
|
throw new Error("You should define a default cloud storage provider prior to use it");
|
|
1280
|
-
return
|
|
1269
|
+
return v._defaultCloudStorage;
|
|
1281
1270
|
}
|
|
1282
1271
|
};
|
|
1283
|
-
|
|
1284
|
-
let
|
|
1285
|
-
function
|
|
1286
|
-
return
|
|
1272
|
+
v._cloudStorageFactoryMap = {};
|
|
1273
|
+
let P = v;
|
|
1274
|
+
function J(i, e) {
|
|
1275
|
+
return P.registerCloudStorage(i, e), (t) => {
|
|
1287
1276
|
t.prototype.__className = i;
|
|
1288
1277
|
};
|
|
1289
1278
|
}
|
|
1290
|
-
var
|
|
1291
|
-
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--)
|
|
1292
1281
|
(o = i[n]) && (s = o(s) || s);
|
|
1293
1282
|
return s;
|
|
1294
1283
|
};
|
|
1295
|
-
let
|
|
1284
|
+
let j = class extends P {
|
|
1296
1285
|
constructor(i = "") {
|
|
1297
1286
|
super(), this._simulateDelay = 0, this._pendingPromises = [], this.mockFileSystem = {}, this._pathToMockFiles = i;
|
|
1298
1287
|
}
|
|
@@ -1340,21 +1329,21 @@ let A = class extends w {
|
|
|
1340
1329
|
return delete this.mockFileSystem[i], this.resolveWithDelay();
|
|
1341
1330
|
}
|
|
1342
1331
|
};
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
],
|
|
1346
|
-
var
|
|
1347
|
-
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--)
|
|
1348
1337
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
1349
|
-
return r && s &&
|
|
1350
|
-
},
|
|
1351
|
-
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 {
|
|
1352
1341
|
constructor() {
|
|
1353
|
-
super(...arguments), this._onChange = new
|
|
1342
|
+
super(...arguments), this._onChange = new U();
|
|
1354
1343
|
}
|
|
1355
1344
|
async save({ data: i, fileName: e, progress: t, cloudStorageProvider: r } = {}) {
|
|
1356
1345
|
const s = i || this._pendingData;
|
|
1357
|
-
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 }));
|
|
1358
1347
|
}
|
|
1359
1348
|
uploadControl() {
|
|
1360
1349
|
return this.provider.uploadControl();
|
|
@@ -1369,9 +1358,9 @@ let C = class extends l {
|
|
|
1369
1358
|
get provider() {
|
|
1370
1359
|
if (!this._provider)
|
|
1371
1360
|
try {
|
|
1372
|
-
this._provider =
|
|
1361
|
+
this._provider = P.createInstance(this._cloudStorageProviderName);
|
|
1373
1362
|
} catch {
|
|
1374
|
-
this._provider =
|
|
1363
|
+
this._provider = P.defaultCloudStorage;
|
|
1375
1364
|
}
|
|
1376
1365
|
return this._provider;
|
|
1377
1366
|
}
|
|
@@ -1396,28 +1385,28 @@ let C = class extends l {
|
|
|
1396
1385
|
}
|
|
1397
1386
|
};
|
|
1398
1387
|
O([
|
|
1399
|
-
|
|
1400
|
-
],
|
|
1388
|
+
S
|
|
1389
|
+
], b.prototype, "_reference", 2);
|
|
1401
1390
|
O([
|
|
1402
|
-
|
|
1403
|
-
],
|
|
1391
|
+
S
|
|
1392
|
+
], b.prototype, "_url", 2);
|
|
1404
1393
|
O([
|
|
1405
|
-
|
|
1406
|
-
],
|
|
1394
|
+
S
|
|
1395
|
+
], b.prototype, "_cloudStorageProviderName", 2);
|
|
1407
1396
|
O([
|
|
1408
|
-
|
|
1409
|
-
],
|
|
1397
|
+
S
|
|
1398
|
+
], b.prototype, "_originalFileName", 2);
|
|
1410
1399
|
O([
|
|
1411
|
-
|
|
1412
|
-
],
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
],
|
|
1416
|
-
class
|
|
1400
|
+
S
|
|
1401
|
+
], b.prototype, "_mimeType", 2);
|
|
1402
|
+
b = O([
|
|
1403
|
+
z("StoredFile")
|
|
1404
|
+
], b);
|
|
1405
|
+
class L {
|
|
1417
1406
|
}
|
|
1418
|
-
const p = class p extends
|
|
1407
|
+
const p = class p extends L {
|
|
1419
1408
|
constructor() {
|
|
1420
|
-
if (super(), this._onAuthStateChange = new
|
|
1409
|
+
if (super(), this._onAuthStateChange = new U(), !p._authService) throw new Error(p.error.shouldBeRegistered);
|
|
1421
1410
|
p._authService.onAuthStateChange(
|
|
1422
1411
|
(e) => this.authStateChanged(e)
|
|
1423
1412
|
);
|
|
@@ -1541,15 +1530,14 @@ const p = class p extends W {
|
|
|
1541
1530
|
}
|
|
1542
1531
|
};
|
|
1543
1532
|
p.error = { shouldBeRegistered: "You should register an auth service before using Auth." }, p._instance = void 0;
|
|
1544
|
-
let
|
|
1545
|
-
class
|
|
1533
|
+
let F = p;
|
|
1534
|
+
class de extends L {
|
|
1546
1535
|
constructor() {
|
|
1547
1536
|
super(...arguments), this.pendingPromises = [], this._fakeRegisteredUsers = {};
|
|
1548
1537
|
}
|
|
1549
1538
|
signUp(e) {
|
|
1550
|
-
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (
|
|
1551
|
-
|
|
1552
|
-
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));
|
|
1553
1541
|
});
|
|
1554
1542
|
return this.pendingPromises.push(o), o;
|
|
1555
1543
|
}
|
|
@@ -1564,8 +1552,7 @@ class _e extends W {
|
|
|
1564
1552
|
}
|
|
1565
1553
|
async logout() {
|
|
1566
1554
|
const e = new Promise((t) => {
|
|
1567
|
-
|
|
1568
|
-
this._loggedUser = void 0, t(), (r = this.notifyChange) == null || r.call(this, void 0);
|
|
1555
|
+
this._loggedUser = void 0, t(), this.notifyChange?.(void 0);
|
|
1569
1556
|
});
|
|
1570
1557
|
return this.pendingPromises.push(e), e;
|
|
1571
1558
|
}
|
|
@@ -1615,21 +1602,21 @@ class _e extends W {
|
|
|
1615
1602
|
};
|
|
1616
1603
|
}
|
|
1617
1604
|
}
|
|
1618
|
-
const
|
|
1605
|
+
const g = class g {
|
|
1619
1606
|
constructor() {
|
|
1620
1607
|
}
|
|
1621
1608
|
static useCloudFunctionsService(e) {
|
|
1622
1609
|
this._cloudFunctionsService != e && (this._cloudFunctionsService = e);
|
|
1623
1610
|
}
|
|
1624
1611
|
static get instance() {
|
|
1625
|
-
if (!this._cloudFunctionsService) throw new Error(
|
|
1626
|
-
return
|
|
1612
|
+
if (!this._cloudFunctionsService) throw new Error(g.error.shouldBeRegistered);
|
|
1613
|
+
return g._instance || (g._instance = new g());
|
|
1627
1614
|
}
|
|
1628
1615
|
getRawFunction(e) {
|
|
1629
|
-
return
|
|
1616
|
+
return g._cloudFunctionsService.retrieveFunction(e);
|
|
1630
1617
|
}
|
|
1631
1618
|
getFunction(e) {
|
|
1632
|
-
const t =
|
|
1619
|
+
const t = g._cloudFunctionsService.callFunction, r = this.getRawFunction(e);
|
|
1633
1620
|
return async (s) => {
|
|
1634
1621
|
const n = await t(r, this.processParam(s));
|
|
1635
1622
|
return this.processResult(n);
|
|
@@ -1637,16 +1624,16 @@ const _ = class _ {
|
|
|
1637
1624
|
}
|
|
1638
1625
|
processParam(e) {
|
|
1639
1626
|
if (e != null)
|
|
1640
|
-
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;
|
|
1641
1628
|
}
|
|
1642
1629
|
processResult(e) {
|
|
1643
1630
|
if (e != null)
|
|
1644
|
-
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;
|
|
1645
1632
|
}
|
|
1646
1633
|
};
|
|
1647
|
-
|
|
1648
|
-
let
|
|
1649
|
-
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 {
|
|
1650
1637
|
constructor(e) {
|
|
1651
1638
|
this._registeredFunctions = e;
|
|
1652
1639
|
}
|
|
@@ -1659,9 +1646,9 @@ class ye {
|
|
|
1659
1646
|
return e(t);
|
|
1660
1647
|
}
|
|
1661
1648
|
}
|
|
1662
|
-
class
|
|
1649
|
+
class M {
|
|
1663
1650
|
}
|
|
1664
|
-
const m = class m extends
|
|
1651
|
+
const m = class m extends M {
|
|
1665
1652
|
constructor() {
|
|
1666
1653
|
super();
|
|
1667
1654
|
}
|
|
@@ -1686,8 +1673,8 @@ const m = class m extends Q {
|
|
|
1686
1673
|
}
|
|
1687
1674
|
};
|
|
1688
1675
|
m.error = { shouldBeRegistered: "You should register a Server Auth service before using the Server Auth." }, m._instance = void 0;
|
|
1689
|
-
let
|
|
1690
|
-
class
|
|
1676
|
+
let N = m;
|
|
1677
|
+
class pe extends M {
|
|
1691
1678
|
constructor(e) {
|
|
1692
1679
|
super(), this._userCredentials = e;
|
|
1693
1680
|
}
|
|
@@ -1713,62 +1700,62 @@ class ve extends Q {
|
|
|
1713
1700
|
return this._userCredentials;
|
|
1714
1701
|
}
|
|
1715
1702
|
}
|
|
1716
|
-
function
|
|
1703
|
+
function me(i, e) {
|
|
1717
1704
|
return i ? i.replace(/\${\s*(\w*)\s*}/g, function(t, r) {
|
|
1718
1705
|
return e[r] || "";
|
|
1719
1706
|
}) : "";
|
|
1720
1707
|
}
|
|
1721
|
-
function
|
|
1708
|
+
function ge(i) {
|
|
1722
1709
|
return i ? i.replace(
|
|
1723
1710
|
/([-_ ][\w])/g,
|
|
1724
1711
|
(e) => e.toUpperCase().replace("-", "").replace("_", "").replace(" ", "")
|
|
1725
1712
|
) : "";
|
|
1726
1713
|
}
|
|
1727
|
-
function
|
|
1714
|
+
function _e(i, e = "-") {
|
|
1728
1715
|
if (!i) return "";
|
|
1729
1716
|
const t = i.slice(1).replace(/( |[A-Z])/g, (r) => r === " " ? "-" : e + r[0].toLowerCase());
|
|
1730
1717
|
return i[0].toLocaleLowerCase() + t.replace(/--/g, "-");
|
|
1731
1718
|
}
|
|
1732
|
-
function
|
|
1719
|
+
function ye(i, e) {
|
|
1733
1720
|
return e.split(".").reduce((t, r) => t[r], i);
|
|
1734
1721
|
}
|
|
1735
1722
|
export {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
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
|
-
|
|
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
|
|
1773
1760
|
};
|
|
1774
1761
|
//# sourceMappingURL=entropic-bond.js.map
|