entropic-bond 1.53.24 → 1.54.0
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
|
@@ -74,8 +74,8 @@ var H = Object.defineProperty, J = (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
76
|
return s && H(e, t, s), s;
|
|
77
|
-
},
|
|
78
|
-
const
|
|
77
|
+
}, l;
|
|
78
|
+
const L = (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,7 +136,7 @@ const N = (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
|
/**
|
|
@@ -150,7 +150,7 @@ const N = (d = class {
|
|
|
150
150
|
* Gets the class name of this instance.
|
|
151
151
|
*/
|
|
152
152
|
get className() {
|
|
153
|
-
return this.__className;
|
|
153
|
+
return this.__className ?? this.constructor.name;
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* Sets the id of this instance.
|
|
@@ -186,7 +186,8 @@ const N = (d = class {
|
|
|
186
186
|
getPersistentProperties() {
|
|
187
187
|
return this._persistentProperties ? this._persistentProperties.map((e) => ({
|
|
188
188
|
...e,
|
|
189
|
-
name: e.name.slice(1)
|
|
189
|
+
name: e.name.slice(1),
|
|
190
|
+
ownerClassName: e._target.className === "_Persistent" ? "Persistent" : e._target.className
|
|
190
191
|
})) : [];
|
|
191
192
|
}
|
|
192
193
|
/**
|
|
@@ -270,10 +271,10 @@ const N = (d = class {
|
|
|
270
271
|
if (!this._persistentProperties) return {};
|
|
271
272
|
this.beforeSerialize();
|
|
272
273
|
const t = {};
|
|
273
|
-
if (!this.className) throw new Error(`You should register \`${this.constructor.name || this.toString() || "this"}\` class prior to streaming it.`);
|
|
274
|
+
if (!this.className || !l.registeredClasses().includes(this.className)) throw new Error(`You should register \`${this.constructor.name || this.toString() || "this"}\` class prior to streaming it.`);
|
|
274
275
|
return this._persistentProperties.forEach((r) => {
|
|
275
276
|
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[
|
|
277
|
+
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
278
|
}), t.__className = this.className, t;
|
|
278
279
|
}
|
|
279
280
|
static searchableArrayNameFor(e) {
|
|
@@ -284,11 +285,11 @@ const N = (d = class {
|
|
|
284
285
|
if (Array.isArray(e))
|
|
285
286
|
return e.map((t) => this.fromDeepObject(t));
|
|
286
287
|
if (e.__documentReference) {
|
|
287
|
-
const t = e, r =
|
|
288
|
+
const t = e, r = l.createInstance(t);
|
|
288
289
|
return r.__documentReference = e.__documentReference, r;
|
|
289
290
|
}
|
|
290
291
|
if (e.__className)
|
|
291
|
-
return
|
|
292
|
+
return l.createInstance(e);
|
|
292
293
|
if (typeof e == "object") {
|
|
293
294
|
const t = {};
|
|
294
295
|
return Object.entries(e).forEach(
|
|
@@ -302,7 +303,7 @@ const N = (d = class {
|
|
|
302
303
|
if (Array.isArray(e))
|
|
303
304
|
return e.map((r) => this.toDeepObj(r, t));
|
|
304
305
|
if (e.__documentReference) return e;
|
|
305
|
-
if (e instanceof
|
|
306
|
+
if (e instanceof l)
|
|
306
307
|
return e.toObj(t);
|
|
307
308
|
if (typeof e == "object") {
|
|
308
309
|
const r = {};
|
|
@@ -315,11 +316,11 @@ const N = (d = class {
|
|
|
315
316
|
}
|
|
316
317
|
static collectionPath(e, t) {
|
|
317
318
|
let r;
|
|
318
|
-
return
|
|
319
|
+
return t = t || e._target, typeof e.storeInCollection == "function" ? r = e.storeInCollection(t, e) : r = e.storeInCollection ?? t.className, r;
|
|
319
320
|
}
|
|
320
321
|
toReferenceObj(e, t) {
|
|
321
322
|
const r = this[e.name];
|
|
322
|
-
return Array.isArray(r) ? r.map((s) => (e.isPureReference || this.pushDocument(t,
|
|
323
|
+
return Array.isArray(r) ? r.map((s) => (e.isPureReference || this.pushDocument(t, l.collectionPath(e, s), s), this.buildRefObject(s, l.collectionPath(e, s), e.cachedPropsConfig?.cachedProps))) : (e.isPureReference || this.pushDocument(t, l.collectionPath(e, r), r), this.buildRefObject(r, l.collectionPath(e, r), e.cachedPropsConfig?.cachedProps));
|
|
323
324
|
}
|
|
324
325
|
buildRefObject(e, t, r) {
|
|
325
326
|
const s = r?.reduce((n, o) => (e[o] !== void 0 && (n[o] = e[o]), n), {});
|
|
@@ -342,14 +343,14 @@ const N = (d = class {
|
|
|
342
343
|
return e.name.slice(1);
|
|
343
344
|
}
|
|
344
345
|
static createReference(e) {
|
|
345
|
-
const t =
|
|
346
|
+
const t = l.createInstance(e);
|
|
346
347
|
return t.__documentReference = e.__documentReference || { storedInCollection: t.className }, t;
|
|
347
348
|
}
|
|
348
349
|
static createInstance(e) {
|
|
349
350
|
if (typeof e == "string")
|
|
350
|
-
return new (
|
|
351
|
+
return new (l.classFactory(e))();
|
|
351
352
|
try {
|
|
352
|
-
return new (
|
|
353
|
+
return new (l.classFactory(e.__className))().fromObject(e);
|
|
353
354
|
} catch (t) {
|
|
354
355
|
const r = Object.entries(e).filter(([s, n]) => n != null && typeof n != "function").map(([s, n]) => `${s}: ${n}`).join(`,
|
|
355
356
|
`);
|
|
@@ -362,25 +363,25 @@ const N = (d = class {
|
|
|
362
363
|
}
|
|
363
364
|
}
|
|
364
365
|
static propInfo(e, t) {
|
|
365
|
-
return
|
|
366
|
+
return l.createInstance(e).getPropInfo(t);
|
|
366
367
|
}
|
|
367
368
|
/**
|
|
368
369
|
* Retrieves a collection of references with the properties that are stored in the reference object
|
|
369
370
|
* @returns the references collection
|
|
370
371
|
*/
|
|
371
372
|
static getSystemRegisteredReferencesWithCachedProps() {
|
|
372
|
-
return
|
|
373
|
-
const o =
|
|
373
|
+
return l.registeredClassesAndLegacyNames().reduce((r, s) => {
|
|
374
|
+
const o = l.createInstance(s).getPersistentProperties().filter(
|
|
374
375
|
(a) => a.cachedPropsConfig?.cachedProps
|
|
375
376
|
);
|
|
376
377
|
return o.length > 0 && (r[s] = o), r;
|
|
377
378
|
}, {});
|
|
378
379
|
}
|
|
379
|
-
},
|
|
380
|
+
}, l._factoryMap = {}, l);
|
|
380
381
|
J([
|
|
381
382
|
S
|
|
382
|
-
],
|
|
383
|
-
let u =
|
|
383
|
+
], L.prototype, "_id");
|
|
384
|
+
let u = L;
|
|
384
385
|
function S(i, e) {
|
|
385
386
|
return _()(i, e);
|
|
386
387
|
}
|
|
@@ -427,13 +428,14 @@ function _(i) {
|
|
|
427
428
|
const r = e._persistentProperties.find((s) => s.name === t);
|
|
428
429
|
r ? Object.assign(r, i) : e._persistentProperties.push({
|
|
429
430
|
name: t,
|
|
431
|
+
_target: e,
|
|
430
432
|
...i
|
|
431
433
|
});
|
|
432
434
|
};
|
|
433
435
|
}
|
|
434
436
|
function Z(i, e) {
|
|
435
437
|
return (t) => {
|
|
436
|
-
u.registerFactory(i, t, e), t.prototype.__className = i;
|
|
438
|
+
i || (i = t.name), u.registerFactory(i, t, e), t.prototype.__className = i;
|
|
437
439
|
};
|
|
438
440
|
}
|
|
439
441
|
function ue(i) {
|
|
@@ -999,7 +1001,7 @@ class w {
|
|
|
999
1001
|
const t = u.getSystemRegisteredReferencesWithCachedProps(), r = {};
|
|
1000
1002
|
Object.entries(t).forEach(([n, o]) => {
|
|
1001
1003
|
o.forEach((a) => {
|
|
1002
|
-
const c = u.collectionPath(u.createInstance(n)
|
|
1004
|
+
const c = u.collectionPath(a, u.createInstance(n));
|
|
1003
1005
|
r[c] || (r[c] = []), r[c].push({
|
|
1004
1006
|
prop: a,
|
|
1005
1007
|
collectionPropOwner: n
|
|
@@ -1079,8 +1081,8 @@ class w {
|
|
|
1079
1081
|
return Promise.all([
|
|
1080
1082
|
o.map(async (a) => {
|
|
1081
1083
|
r.prop.cachedPropsConfig?.cachedProps?.forEach(async (c) => {
|
|
1082
|
-
const h = e.before?.[c],
|
|
1083
|
-
h !==
|
|
1084
|
+
const h = e.before?.[c], d = e.after?.[c];
|
|
1085
|
+
h !== d && (a[`_${r.prop.name}`][`_${c}`] = d, await s.save(a), this.onUpdate?.(a, r.prop));
|
|
1084
1086
|
});
|
|
1085
1087
|
})
|
|
1086
1088
|
]);
|
|
@@ -1150,8 +1152,8 @@ class pe extends w {
|
|
|
1150
1152
|
if (!a.after) return;
|
|
1151
1153
|
const c = [a.after];
|
|
1152
1154
|
a.before && c.push(a.before);
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
+
const d = this.retrieveQueryDocs(c, e.operations).filter((D, $, T) => $ === T.findIndex((x) => x.id === D.id));
|
|
1156
|
+
d.length > 0 && r(d.map((D) => ({
|
|
1155
1157
|
before: void 0,
|
|
1156
1158
|
after: D,
|
|
1157
1159
|
type: a.type,
|
|
@@ -1234,14 +1236,14 @@ class pe extends w {
|
|
|
1234
1236
|
}
|
|
1235
1237
|
isQueryMatched(e, t) {
|
|
1236
1238
|
const r = {
|
|
1237
|
-
"==": (h,
|
|
1238
|
-
"!=": (h,
|
|
1239
|
-
"<": (h,
|
|
1240
|
-
"<=": (h,
|
|
1241
|
-
">": (h,
|
|
1242
|
-
">=": (h,
|
|
1243
|
-
containsAny: (h,
|
|
1244
|
-
contains: (h,
|
|
1239
|
+
"==": (h, d) => h === d,
|
|
1240
|
+
"!=": (h, d) => h !== d,
|
|
1241
|
+
"<": (h, d) => h < d,
|
|
1242
|
+
"<=": (h, d) => h <= d,
|
|
1243
|
+
">": (h, d) => h > d,
|
|
1244
|
+
">=": (h, d) => h >= d,
|
|
1245
|
+
containsAny: (h, d) => h?.some((D) => d?.includes(D)),
|
|
1246
|
+
contains: (h, d) => h?.includes(d)
|
|
1245
1247
|
}, { property: s, value: n, operator: o } = t, [a, c] = this.retrieveValuesToCompare(e, s, n);
|
|
1246
1248
|
return r[o](a, c);
|
|
1247
1249
|
}
|
|
@@ -1651,7 +1653,7 @@ const g = class g {
|
|
|
1651
1653
|
}
|
|
1652
1654
|
};
|
|
1653
1655
|
g.error = { shouldBeRegistered: "You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions." };
|
|
1654
|
-
let
|
|
1656
|
+
let N = g;
|
|
1655
1657
|
class ge {
|
|
1656
1658
|
constructor(e) {
|
|
1657
1659
|
this._registeredFunctions = e;
|
|
@@ -1692,7 +1694,7 @@ const m = class m extends V {
|
|
|
1692
1694
|
}
|
|
1693
1695
|
};
|
|
1694
1696
|
m.error = { shouldBeRegistered: "You should register a Server Auth service before using the Server Auth." }, m._instance = void 0;
|
|
1695
|
-
let
|
|
1697
|
+
let k = m;
|
|
1696
1698
|
class _e extends V {
|
|
1697
1699
|
constructor(e) {
|
|
1698
1700
|
super(), this._userCredentials = e;
|
|
@@ -1742,7 +1744,7 @@ export {
|
|
|
1742
1744
|
I as Auth,
|
|
1743
1745
|
me as AuthMock,
|
|
1744
1746
|
M as AuthService,
|
|
1745
|
-
|
|
1747
|
+
N as CloudFunctions,
|
|
1746
1748
|
ge as CloudFunctionsMock,
|
|
1747
1749
|
P as CloudStorage,
|
|
1748
1750
|
w as DataSource,
|
|
@@ -1753,7 +1755,7 @@ export {
|
|
|
1753
1755
|
A as Observable,
|
|
1754
1756
|
u as Persistent,
|
|
1755
1757
|
G as Query,
|
|
1756
|
-
|
|
1758
|
+
k as ServerAuth,
|
|
1757
1759
|
_e as ServerAuthMock,
|
|
1758
1760
|
V as ServerAuthService,
|
|
1759
1761
|
U as Store,
|