entropic-bond 1.56.1 → 1.56.3
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 M {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
4
4
|
}
|
|
@@ -43,23 +43,23 @@ class L {
|
|
|
43
43
|
return this.subscribers.size;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
const
|
|
46
|
+
const m = [];
|
|
47
47
|
for (let i = 0; i < 256; ++i)
|
|
48
|
-
|
|
48
|
+
m.push((i + 256).toString(16).slice(1));
|
|
49
49
|
function Y(i, e = 0) {
|
|
50
|
-
return (
|
|
50
|
+
return (m[i[e + 0]] + m[i[e + 1]] + m[i[e + 2]] + m[i[e + 3]] + "-" + m[i[e + 4]] + m[i[e + 5]] + "-" + m[i[e + 6]] + m[i[e + 7]] + "-" + m[i[e + 8]] + m[i[e + 9]] + "-" + m[i[e + 10]] + m[i[e + 11]] + m[i[e + 12]] + m[i[e + 13]] + m[i[e + 14]] + m[i[e + 15]]).toLowerCase();
|
|
51
51
|
}
|
|
52
|
-
let
|
|
52
|
+
let L;
|
|
53
53
|
const z = new Uint8Array(16);
|
|
54
54
|
function H() {
|
|
55
|
-
if (!
|
|
55
|
+
if (!L) {
|
|
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
|
+
L = crypto.getRandomValues.bind(crypto);
|
|
59
59
|
}
|
|
60
|
-
return
|
|
60
|
+
return L(z);
|
|
61
61
|
}
|
|
62
|
-
const J = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
|
|
62
|
+
const J = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), I = { randomUUID: J };
|
|
63
63
|
function Z(i, e, t) {
|
|
64
64
|
i = i || {};
|
|
65
65
|
const r = i.random ?? i.rng?.() ?? H();
|
|
@@ -68,14 +68,14 @@ function Z(i, e, t) {
|
|
|
68
68
|
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Y(r);
|
|
69
69
|
}
|
|
70
70
|
function G(i, e, t) {
|
|
71
|
-
return
|
|
71
|
+
return I.randomUUID && !i ? I.randomUUID() : Z(i);
|
|
72
72
|
}
|
|
73
73
|
var K = Object.defineProperty, X = (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 && K(e, t, s), s;
|
|
77
|
-
},
|
|
78
|
-
const Q = (
|
|
77
|
+
}, l;
|
|
78
|
+
const Q = (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 Q = (h = 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
|
/**
|
|
@@ -273,7 +273,7 @@ const Q = (h = 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 Q = (h = 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 Q = (h = 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 = {};
|
|
@@ -319,7 +319,7 @@ const Q = (h = class {
|
|
|
319
319
|
}
|
|
320
320
|
toReferenceObj(e, t) {
|
|
321
321
|
const r = this[e.name];
|
|
322
|
-
return Array.isArray(r) ? r.map((s) => (e.isPureReference || this.pushDocument(t,
|
|
322
|
+
return Array.isArray(r) ? r.map((s) => (e.isPureReference || this.pushDocument(t, l.collectionPath(s, e), s), this.buildRefObject(s, l.collectionPath(s, e), e.cachedProps))) : (e.isPureReference || this.pushDocument(t, l.collectionPath(r, e), r), this.buildRefObject(r, l.collectionPath(r, e), e.cachedProps));
|
|
323
323
|
}
|
|
324
324
|
buildRefObject(e, t, r) {
|
|
325
325
|
const s = r?.reduce((n, o) => (e[o] !== void 0 && (n[o] = e[o]), n), {});
|
|
@@ -342,14 +342,14 @@ const Q = (h = class {
|
|
|
342
342
|
return e.name.slice(1);
|
|
343
343
|
}
|
|
344
344
|
static createReference(e) {
|
|
345
|
-
const t =
|
|
345
|
+
const t = l.createInstance(e);
|
|
346
346
|
return t.__documentReference = e.__documentReference || { storedInCollection: t.className }, t;
|
|
347
347
|
}
|
|
348
348
|
static createInstance(e) {
|
|
349
349
|
if (typeof e == "string")
|
|
350
|
-
return new (
|
|
350
|
+
return new (l.classFactory(e))();
|
|
351
351
|
try {
|
|
352
|
-
return new (
|
|
352
|
+
return new (l.classFactory(e.__className))().fromObject(e);
|
|
353
353
|
} catch (t) {
|
|
354
354
|
const r = Object.entries(e).filter(([s, n]) => n != null && typeof n != "function").map(([s, n]) => `${s}: ${n}`).join(`,
|
|
355
355
|
`);
|
|
@@ -362,7 +362,7 @@ const Q = (h = class {
|
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
static propInfo(e, t) {
|
|
365
|
-
return
|
|
365
|
+
return l.createInstance(e).getPropInfo(t);
|
|
366
366
|
}
|
|
367
367
|
/**
|
|
368
368
|
* Return the type of a persistent property.
|
|
@@ -376,27 +376,27 @@ const Q = (h = class {
|
|
|
376
376
|
*/
|
|
377
377
|
static propType(e) {
|
|
378
378
|
if (e.typeName) return Array.isArray(e.typeName) ? "undefined[]" : e.typeName ?? "undefined";
|
|
379
|
-
const r =
|
|
379
|
+
const r = l.createInstance(e.ownerClassName())[e.name];
|
|
380
380
|
if (Array.isArray(r)) {
|
|
381
381
|
if (r.length === 0) return "undefined[]";
|
|
382
382
|
const s = r[0];
|
|
383
|
-
return s instanceof
|
|
383
|
+
return s instanceof l ? s.className + "[]" : typeof s + "[]";
|
|
384
384
|
} else
|
|
385
|
-
return r instanceof
|
|
385
|
+
return r instanceof l ? r.className : typeof r;
|
|
386
386
|
}
|
|
387
387
|
/**
|
|
388
388
|
* Retrieves a collection of references with the properties that are stored in the reference object
|
|
389
389
|
* @returns the references collection
|
|
390
390
|
*/
|
|
391
391
|
static getSystemRegisteredReferencesWithCachedProps() {
|
|
392
|
-
return
|
|
393
|
-
const o =
|
|
392
|
+
return l.registeredClasses().reduce((r, s) => {
|
|
393
|
+
const o = l.createInstance(s).getPersistentProperties().filter(
|
|
394
394
|
(a) => a.cachedProps
|
|
395
395
|
);
|
|
396
396
|
return o.length > 0 && (r[s] = o), r;
|
|
397
397
|
}, {});
|
|
398
398
|
}
|
|
399
|
-
},
|
|
399
|
+
}, l._factoryMap = {}, l);
|
|
400
400
|
X([
|
|
401
401
|
U
|
|
402
402
|
], Q.prototype, "_id");
|
|
@@ -482,7 +482,7 @@ function _e(i) {
|
|
|
482
482
|
}
|
|
483
483
|
class ye extends d {
|
|
484
484
|
constructor() {
|
|
485
|
-
super(...arguments), this._onChange = new
|
|
485
|
+
super(...arguments), this._onChange = new M();
|
|
486
486
|
}
|
|
487
487
|
/**
|
|
488
488
|
* Subscribes a listener callback function. Every time a property is changed,
|
|
@@ -781,8 +781,8 @@ class te {
|
|
|
781
781
|
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(R.error.invalidQueryOrder);
|
|
782
782
|
const n = e.split(".");
|
|
783
783
|
let o = {}, a = n.length > 1 ? o : r;
|
|
784
|
-
return n.slice(1).forEach((
|
|
785
|
-
o[
|
|
784
|
+
return n.slice(1).forEach((h, u) => {
|
|
785
|
+
o[h] = u < n.length - 2 ? {} : r, o = o[h];
|
|
786
786
|
}), this.queryObject.operations?.push({
|
|
787
787
|
property: n[0],
|
|
788
788
|
operator: t,
|
|
@@ -945,7 +945,7 @@ class te {
|
|
|
945
945
|
return this.model;
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
|
-
const
|
|
948
|
+
const C = class C {
|
|
949
949
|
constructor() {
|
|
950
950
|
}
|
|
951
951
|
/**
|
|
@@ -961,7 +961,7 @@ const v = class v {
|
|
|
961
961
|
* @returns the data source
|
|
962
962
|
*/
|
|
963
963
|
static get dataSource() {
|
|
964
|
-
return
|
|
964
|
+
return C._dataSource;
|
|
965
965
|
}
|
|
966
966
|
/**
|
|
967
967
|
* Retrieves a model for a collection
|
|
@@ -969,8 +969,8 @@ const v = class v {
|
|
|
969
969
|
* @returns the model for the collection
|
|
970
970
|
*/
|
|
971
971
|
static getModel(e) {
|
|
972
|
-
if (!
|
|
973
|
-
return new R(
|
|
972
|
+
if (!C._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
973
|
+
return new R(C._dataSource, e);
|
|
974
974
|
}
|
|
975
975
|
/**
|
|
976
976
|
* Retrieves a model for a subcollection
|
|
@@ -979,8 +979,8 @@ const v = class v {
|
|
|
979
979
|
* @returns the model for the subcollection
|
|
980
980
|
*/
|
|
981
981
|
static getModelForSubCollection(e, t) {
|
|
982
|
-
if (!
|
|
983
|
-
return new R(
|
|
982
|
+
if (!C._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
983
|
+
return new R(C._dataSource, e, t);
|
|
984
984
|
}
|
|
985
985
|
/**
|
|
986
986
|
* Populates property references with actual data from the store.
|
|
@@ -1012,15 +1012,15 @@ const v = class v {
|
|
|
1012
1012
|
) : e.__documentReference === void 0;
|
|
1013
1013
|
}
|
|
1014
1014
|
};
|
|
1015
|
-
|
|
1016
|
-
let
|
|
1017
|
-
class
|
|
1015
|
+
C.error = { shouldBeRegistered: "You should register a data source before using the data Store." };
|
|
1016
|
+
let k = C;
|
|
1017
|
+
class T {
|
|
1018
1018
|
constructor(e) {
|
|
1019
1019
|
this.handlers = [], this.subscribeToDocumentChangeListener = () => {
|
|
1020
1020
|
throw new Error("The method subscribeToDocumentChangeListener has not been implemented in the concrete data source");
|
|
1021
1021
|
}, this._resolveCollectionPaths = () => {
|
|
1022
1022
|
throw new Error("The method collectionsMatchingTemplate has not been implemented in the concrete data source");
|
|
1023
|
-
}, e && (this.beforeUpdate = e.beforeUpdateDocument, this.afterUpdate = e.afterUpdateDocument, this.onAllPropsUpdatedCallback = e.onAllPropsUpdated, this._beforeQueryOwnerCollection = e.beforeQueryOwnerCollection);
|
|
1023
|
+
}, this._disabledChangeListeners = /* @__PURE__ */ new Set(), e && (this.beforeUpdate = e.beforeUpdateDocument, this.afterUpdate = e.afterUpdateDocument, this.onAllPropsUpdatedCallback = e.onAllPropsUpdated, this._beforeQueryOwnerCollection = e.beforeQueryOwnerCollection);
|
|
1024
1024
|
}
|
|
1025
1025
|
installUpdaters() {
|
|
1026
1026
|
const e = d.getSystemRegisteredReferencesWithCachedProps(), t = {};
|
|
@@ -1028,7 +1028,7 @@ class M {
|
|
|
1028
1028
|
s.forEach((n) => {
|
|
1029
1029
|
if (!n.typeName) return;
|
|
1030
1030
|
(Array.isArray(n.typeName) ? n.typeName : [n?.typeName ?? r]).map((a) => d.collectionPath(d.createInstance(a), n)).forEach((a) => {
|
|
1031
|
-
t[a] || (t[a] = []), t[a].push(n);
|
|
1031
|
+
t[a] || (t[a] = []), t[a].find((u) => u.name === n.name && u.ownerClassName() === n.ownerClassName()) || t[a].push(n);
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
1034
1034
|
}), this.handlers = [], Object.entries(t).forEach(([r, s]) => {
|
|
@@ -1036,8 +1036,9 @@ class M {
|
|
|
1036
1036
|
r,
|
|
1037
1037
|
(o) => this.onDocumentChange(o, s)
|
|
1038
1038
|
);
|
|
1039
|
-
if (n) this.handlers.push(n);
|
|
1040
|
-
else
|
|
1039
|
+
if (n) n.props = s, this.handlers.push(n);
|
|
1040
|
+
else
|
|
1041
|
+
throw new Error("The method documentChangeListener has not been implemented in the concrete data source");
|
|
1041
1042
|
}), this.handlers;
|
|
1042
1043
|
}
|
|
1043
1044
|
uninstallUpdaters() {
|
|
@@ -1063,38 +1064,44 @@ class M {
|
|
|
1063
1064
|
}
|
|
1064
1065
|
async onDocumentChange(e, t) {
|
|
1065
1066
|
const r = b.toPersistentDocumentChange(e), s = {};
|
|
1066
|
-
r.before && (await Promise.all(t.map(async (n) => {
|
|
1067
|
-
const o =
|
|
1068
|
-
await Promise.all(a.map(async (
|
|
1069
|
-
const u =
|
|
1067
|
+
r.before && (r.after?.id && this._disabledChangeListeners.has(r.after?.id) || (await Promise.all(t.map(async (n) => {
|
|
1068
|
+
const o = T.ownerCollectionPath(d.createInstance(n.ownerClassName()), n, r.params), a = await this._resolveCollectionPaths(o);
|
|
1069
|
+
await Promise.all(a.map(async (h) => {
|
|
1070
|
+
const u = k.getModel(h);
|
|
1070
1071
|
let c = u.find(), P = !1;
|
|
1071
|
-
n.cachedProps?.forEach((
|
|
1072
|
-
const S = r.before[
|
|
1072
|
+
n.cachedProps?.forEach((f) => {
|
|
1073
|
+
const S = r.before[f], O = r.after[f];
|
|
1073
1074
|
S !== O && (P = !0);
|
|
1074
1075
|
}), P && (n.searchableArray ? c = c.where(n.name, "contains", r.before) : c = c.where(n.name, "==", r.before)), c = this._beforeQueryOwnerCollection?.(c) ?? c;
|
|
1075
1076
|
const E = await c.get();
|
|
1076
|
-
return s[
|
|
1077
|
+
return s[h] = {
|
|
1077
1078
|
totalDocumentsToUpdate: E.length,
|
|
1078
1079
|
updatedDocuments: [],
|
|
1079
|
-
documentsToUpdate: E.map((
|
|
1080
|
+
documentsToUpdate: E.map((f) => f.name ?? f.id)
|
|
1080
1081
|
}, Promise.all([
|
|
1081
|
-
E.map(async (
|
|
1082
|
+
E.map(async (f) => {
|
|
1082
1083
|
let S = !1;
|
|
1083
1084
|
if (n.cachedProps?.forEach((O) => {
|
|
1084
1085
|
const N = r.before[O], q = r.after[O];
|
|
1085
1086
|
N !== q && (S = !0);
|
|
1086
1087
|
}), S) {
|
|
1087
1088
|
if (n.searchableArray) {
|
|
1088
|
-
const O =
|
|
1089
|
-
|
|
1089
|
+
const O = f[n.name].findIndex((N) => N.id === r.before.id);
|
|
1090
|
+
f[n.name][O] = r.after;
|
|
1090
1091
|
} else
|
|
1091
|
-
|
|
1092
|
-
this.beforeUpdate?.(
|
|
1092
|
+
f[`_${n.name}`] = r.after;
|
|
1093
|
+
this.beforeUpdate?.(f, n), this.disableChangeListener(f), await u.save(f), this.enableChangeListener(f), s[h]?.updatedDocuments.push(f.id), this.afterUpdate?.(f, n);
|
|
1093
1094
|
} else await Promise.resolve();
|
|
1094
1095
|
})
|
|
1095
1096
|
]);
|
|
1096
1097
|
}));
|
|
1097
|
-
})), this.onAllPropsUpdatedCallback?.(s, t));
|
|
1098
|
+
})), this.onAllPropsUpdatedCallback?.(s, t)));
|
|
1099
|
+
}
|
|
1100
|
+
disableChangeListener(e) {
|
|
1101
|
+
this._disabledChangeListeners.add(e.id);
|
|
1102
|
+
}
|
|
1103
|
+
enableChangeListener(e) {
|
|
1104
|
+
this._disabledChangeListeners.delete(e.id);
|
|
1098
1105
|
}
|
|
1099
1106
|
static ownerCollectionPath(e, t, r) {
|
|
1100
1107
|
let s;
|
|
@@ -1106,7 +1113,7 @@ class b {
|
|
|
1106
1113
|
this._cachedPropsUpdater = void 0;
|
|
1107
1114
|
}
|
|
1108
1115
|
installCachedPropsUpdater(e) {
|
|
1109
|
-
return this._cachedPropsUpdater = new
|
|
1116
|
+
return this._cachedPropsUpdater = new T(e), this._cachedPropsUpdater.documentChangeListenerSubscriber = this.subscribeToDocumentChangeListener.bind(this), this._cachedPropsUpdater.resolveCollectionPaths = this.resolveCollectionPaths.bind(this), this._cachedPropsUpdater.installUpdaters();
|
|
1110
1117
|
}
|
|
1111
1118
|
uninstallCachedPropsUpdater() {
|
|
1112
1119
|
this._cachedPropsUpdater?.uninstallUpdaters(), this._cachedPropsUpdater = void 0;
|
|
@@ -1166,10 +1173,10 @@ class b {
|
|
|
1166
1173
|
return new RegExp("^" + s + "$").test(t);
|
|
1167
1174
|
}
|
|
1168
1175
|
static extractTemplateParams(e, t) {
|
|
1169
|
-
const r = [], n = t.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&").replace(/\\\{([^}]+)\\\}/g, (u, c) => (r.push(c), "([^/]+)")), o = new RegExp("^" + n + "$"), a = e.match(o),
|
|
1176
|
+
const r = [], n = t.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&").replace(/\\\{([^}]+)\\\}/g, (u, c) => (r.push(c), "([^/]+)")), o = new RegExp("^" + n + "$"), a = e.match(o), h = {};
|
|
1170
1177
|
return a && r.forEach((u, c) => {
|
|
1171
|
-
|
|
1172
|
-
}),
|
|
1178
|
+
h[u] = a[c + 1];
|
|
1179
|
+
}), h;
|
|
1173
1180
|
}
|
|
1174
1181
|
}
|
|
1175
1182
|
class be extends b {
|
|
@@ -1233,9 +1240,9 @@ class be extends b {
|
|
|
1233
1240
|
s || (this._collectionListeners[t] = {}, s = this._collectionListeners[t]);
|
|
1234
1241
|
const n = (a) => {
|
|
1235
1242
|
if (!a.after) return;
|
|
1236
|
-
const
|
|
1237
|
-
a.before &&
|
|
1238
|
-
const c = this.retrieveQueryDocs(
|
|
1243
|
+
const h = [a.after];
|
|
1244
|
+
a.before && h.push(a.before);
|
|
1245
|
+
const c = this.retrieveQueryDocs(h, e.operations).filter((P, E, f) => E === f.findIndex((S) => S.id === P.id));
|
|
1239
1246
|
c.length > 0 && r(c.map((P) => ({
|
|
1240
1247
|
before: a.before,
|
|
1241
1248
|
after: P,
|
|
@@ -1282,7 +1289,7 @@ class be extends b {
|
|
|
1282
1289
|
return r.forEach((n) => {
|
|
1283
1290
|
let o = this._serverCollectionListeners[n];
|
|
1284
1291
|
o || (o = this._serverCollectionListeners[n] = {}), o[s] = (a) => {
|
|
1285
|
-
const
|
|
1292
|
+
const h = b.extractTemplateParams(n, e);
|
|
1286
1293
|
t({
|
|
1287
1294
|
...a,
|
|
1288
1295
|
before: a.before,
|
|
@@ -1290,7 +1297,7 @@ class be extends b {
|
|
|
1290
1297
|
collectionPath: n,
|
|
1291
1298
|
params: {
|
|
1292
1299
|
...a.params,
|
|
1293
|
-
...
|
|
1300
|
+
...h
|
|
1294
1301
|
}
|
|
1295
1302
|
});
|
|
1296
1303
|
};
|
|
@@ -1320,7 +1327,7 @@ class be extends b {
|
|
|
1320
1327
|
limit: (n) => e,
|
|
1321
1328
|
//.slice( 0, limit ),
|
|
1322
1329
|
operations: (n) => this.retrieveQueryDocs(e, n),
|
|
1323
|
-
sort: ({ order: n, propertyName: o }) => e.sort((a,
|
|
1330
|
+
sort: ({ order: n, propertyName: o }) => e.sort((a, h) => n === "asc" ? this.deepValue(a, o) > this.deepValue(h, o) ? 1 : -1 : this.deepValue(a, o) < this.deepValue(h, o) ? 1 : -1)
|
|
1324
1331
|
}[t](r);
|
|
1325
1332
|
}
|
|
1326
1333
|
retrieveQueryDocs(e, t) {
|
|
@@ -1345,8 +1352,8 @@ class be extends b {
|
|
|
1345
1352
|
">=": (u, c) => u >= c,
|
|
1346
1353
|
containsAny: (u, c) => u?.some((P) => c?.includes(P)),
|
|
1347
1354
|
contains: (u, c) => u?.includes(c)
|
|
1348
|
-
}, { property: s, value: n, operator: o } = t, [a,
|
|
1349
|
-
return r[o](a,
|
|
1355
|
+
}, { property: s, value: n, operator: o } = t, [a, h] = this.retrieveValuesToCompare(e, s, n);
|
|
1356
|
+
return r[o](a, h);
|
|
1350
1357
|
}
|
|
1351
1358
|
retrieveValuesToCompare(e, t, r) {
|
|
1352
1359
|
const s = e[t];
|
|
@@ -1375,12 +1382,12 @@ class be extends b {
|
|
|
1375
1382
|
return Object.keys(this._jsonRawData).filter((t) => b.isStringMatchingTemplate(e, t));
|
|
1376
1383
|
}
|
|
1377
1384
|
}
|
|
1378
|
-
const
|
|
1385
|
+
const v = class v {
|
|
1379
1386
|
static registerCloudStorage(e, t) {
|
|
1380
|
-
|
|
1387
|
+
v._cloudStorageFactoryMap[e] = t;
|
|
1381
1388
|
}
|
|
1382
1389
|
static createInstance(e) {
|
|
1383
|
-
const t =
|
|
1390
|
+
const t = v._cloudStorageFactoryMap[e];
|
|
1384
1391
|
if (!t)
|
|
1385
1392
|
throw new Error(`You should register the ${e} cloud storage provider prior to use it`);
|
|
1386
1393
|
return t();
|
|
@@ -1389,18 +1396,18 @@ const w = class w {
|
|
|
1389
1396
|
return this.__className;
|
|
1390
1397
|
}
|
|
1391
1398
|
static useCloudStorage(e) {
|
|
1392
|
-
|
|
1399
|
+
v._defaultCloudStorage = e;
|
|
1393
1400
|
}
|
|
1394
1401
|
static get defaultCloudStorage() {
|
|
1395
|
-
if (!
|
|
1402
|
+
if (!v._defaultCloudStorage)
|
|
1396
1403
|
throw new Error("You should define a default cloud storage provider prior to use it");
|
|
1397
|
-
return
|
|
1404
|
+
return v._defaultCloudStorage;
|
|
1398
1405
|
}
|
|
1399
1406
|
};
|
|
1400
|
-
|
|
1401
|
-
let
|
|
1407
|
+
v._cloudStorageFactoryMap = {};
|
|
1408
|
+
let w = v;
|
|
1402
1409
|
function re(i, e) {
|
|
1403
|
-
return
|
|
1410
|
+
return w.registerCloudStorage(i, e), (t) => {
|
|
1404
1411
|
t.prototype.__className = i;
|
|
1405
1412
|
};
|
|
1406
1413
|
}
|
|
@@ -1409,7 +1416,7 @@ var se = Object.getOwnPropertyDescriptor, ie = (i, e, t, r) => {
|
|
|
1409
1416
|
(o = i[n]) && (s = o(s) || s);
|
|
1410
1417
|
return s;
|
|
1411
1418
|
};
|
|
1412
|
-
let
|
|
1419
|
+
let F = class extends w {
|
|
1413
1420
|
constructor(i = "") {
|
|
1414
1421
|
super(), this._simulateDelay = 0, this._pendingPromises = [], this.mockFileSystem = {}, this._pathToMockFiles = i;
|
|
1415
1422
|
}
|
|
@@ -1457,9 +1464,9 @@ let k = class extends C {
|
|
|
1457
1464
|
return delete this.mockFileSystem[i], this.resolveWithDelay();
|
|
1458
1465
|
}
|
|
1459
1466
|
};
|
|
1460
|
-
|
|
1461
|
-
re("MockCloudStorage", () => new
|
|
1462
|
-
],
|
|
1467
|
+
F = ie([
|
|
1468
|
+
re("MockCloudStorage", () => new F())
|
|
1469
|
+
], F);
|
|
1463
1470
|
var ne = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, j = (i, e, t, r) => {
|
|
1464
1471
|
for (var s = r > 1 ? void 0 : r ? oe(e, t) : e, n = i.length - 1, o; n >= 0; n--)
|
|
1465
1472
|
(o = i[n]) && (s = (r ? o(e, t, s) : o(s)) || s);
|
|
@@ -1467,11 +1474,11 @@ var ne = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, j = (i, e,
|
|
|
1467
1474
|
}, ae = /* @__PURE__ */ ((i) => (i[i.stored = 0] = "stored", i[i.pendingDataSet = 1] = "pendingDataSet", i[i.deleted = 2] = "deleted", i))(ae || {});
|
|
1468
1475
|
let D = class extends d {
|
|
1469
1476
|
constructor() {
|
|
1470
|
-
super(...arguments), this._onChange = new
|
|
1477
|
+
super(...arguments), this._onChange = new M();
|
|
1471
1478
|
}
|
|
1472
1479
|
async save({ data: i, fileName: e, progress: t, cloudStorageProvider: r } = {}) {
|
|
1473
1480
|
const s = i || this._pendingData;
|
|
1474
|
-
s && (this._reference && await this.delete(), this.provider = r ||
|
|
1481
|
+
s && (this._reference && await this.delete(), this.provider = r || w.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 }));
|
|
1475
1482
|
}
|
|
1476
1483
|
uploadControl() {
|
|
1477
1484
|
return this.provider.uploadControl();
|
|
@@ -1486,9 +1493,9 @@ let D = class extends d {
|
|
|
1486
1493
|
get provider() {
|
|
1487
1494
|
if (!this._provider)
|
|
1488
1495
|
try {
|
|
1489
|
-
this._provider =
|
|
1496
|
+
this._provider = w.createInstance(this._cloudStorageProviderName);
|
|
1490
1497
|
} catch {
|
|
1491
|
-
this._provider =
|
|
1498
|
+
this._provider = w.defaultCloudStorage;
|
|
1492
1499
|
}
|
|
1493
1500
|
return this._provider;
|
|
1494
1501
|
}
|
|
@@ -1532,10 +1539,10 @@ D = j([
|
|
|
1532
1539
|
], D);
|
|
1533
1540
|
class W {
|
|
1534
1541
|
}
|
|
1535
|
-
const
|
|
1542
|
+
const p = class p extends W {
|
|
1536
1543
|
constructor() {
|
|
1537
|
-
if (super(), this._onAuthStateChange = new
|
|
1538
|
-
|
|
1544
|
+
if (super(), this._onAuthStateChange = new M(), !p._authService) throw new Error(p.error.shouldBeRegistered);
|
|
1545
|
+
p._authService.onAuthStateChange(
|
|
1539
1546
|
(e) => this.authStateChanged(e)
|
|
1540
1547
|
);
|
|
1541
1548
|
}
|
|
@@ -1545,7 +1552,7 @@ const m = class m extends W {
|
|
|
1545
1552
|
* @param authService the authentication service to be used by the Auth class
|
|
1546
1553
|
*/
|
|
1547
1554
|
static useAuthService(e) {
|
|
1548
|
-
|
|
1555
|
+
p._authService != e && (p._authService = e, this._instance = void 0);
|
|
1549
1556
|
}
|
|
1550
1557
|
/**
|
|
1551
1558
|
* The instance of the Auth class
|
|
@@ -1565,7 +1572,7 @@ const m = class m extends W {
|
|
|
1565
1572
|
* Auth.instance.signUp({ authProvider: 'google'})
|
|
1566
1573
|
*/
|
|
1567
1574
|
signUp(e) {
|
|
1568
|
-
return
|
|
1575
|
+
return p._authService.signUp(e);
|
|
1569
1576
|
}
|
|
1570
1577
|
/**
|
|
1571
1578
|
* Logs in an existing user
|
|
@@ -1578,14 +1585,14 @@ const m = class m extends W {
|
|
|
1578
1585
|
* Auth.instance.login({ authProvider: 'google'})
|
|
1579
1586
|
*/
|
|
1580
1587
|
login(e) {
|
|
1581
|
-
return
|
|
1588
|
+
return p._authService.login(e);
|
|
1582
1589
|
}
|
|
1583
1590
|
/**
|
|
1584
1591
|
* Logs out the current user
|
|
1585
1592
|
* @returns a promise that resolves when the user is logged out
|
|
1586
1593
|
*/
|
|
1587
1594
|
logout() {
|
|
1588
|
-
return
|
|
1595
|
+
return p._authService.logout();
|
|
1589
1596
|
}
|
|
1590
1597
|
/**
|
|
1591
1598
|
* Resets the password associated with the email.
|
|
@@ -1593,17 +1600,17 @@ const m = class m extends W {
|
|
|
1593
1600
|
* @returns a promise that resolves when the process is done
|
|
1594
1601
|
*/
|
|
1595
1602
|
resetEmailPassword(e) {
|
|
1596
|
-
return
|
|
1603
|
+
return p._authService.resetEmailPassword(e);
|
|
1597
1604
|
}
|
|
1598
1605
|
/**
|
|
1599
1606
|
* Resends the email verification to the user.
|
|
1600
1607
|
* @returns a promise that resolves when the process is done
|
|
1601
1608
|
*/
|
|
1602
1609
|
resendVerificationEmail(e, t, r) {
|
|
1603
|
-
return
|
|
1610
|
+
return p._authService.resendVerificationEmail(e, t, r);
|
|
1604
1611
|
}
|
|
1605
1612
|
refreshToken() {
|
|
1606
|
-
return
|
|
1613
|
+
return p._authService.refreshToken();
|
|
1607
1614
|
}
|
|
1608
1615
|
/**
|
|
1609
1616
|
* Adds a listener to be called when the authentication state changes.
|
|
@@ -1640,7 +1647,7 @@ const m = class m extends W {
|
|
|
1640
1647
|
* Auth.instance.linkAdditionalProvider({ authProvider: 'google' })
|
|
1641
1648
|
*/
|
|
1642
1649
|
linkAdditionalProvider(e) {
|
|
1643
|
-
return
|
|
1650
|
+
return p._authService.linkAdditionalProvider(e);
|
|
1644
1651
|
}
|
|
1645
1652
|
/**
|
|
1646
1653
|
* Unlinks an authentication provider from the authenticated user.
|
|
@@ -1651,21 +1658,21 @@ const m = class m extends W {
|
|
|
1651
1658
|
* Auth.instance.unlinkProvider({ authProvider: 'google' })
|
|
1652
1659
|
*/
|
|
1653
1660
|
unlinkProvider(e) {
|
|
1654
|
-
return
|
|
1661
|
+
return p._authService.unlinkProvider(e);
|
|
1655
1662
|
}
|
|
1656
1663
|
authStateChanged(e) {
|
|
1657
1664
|
this._onAuthStateChange.notify(e);
|
|
1658
1665
|
}
|
|
1659
1666
|
};
|
|
1660
|
-
|
|
1661
|
-
let x =
|
|
1667
|
+
p.error = { shouldBeRegistered: "You should register an auth service before using Auth." }, p._instance = void 0;
|
|
1668
|
+
let x = p;
|
|
1662
1669
|
class Pe extends W {
|
|
1663
1670
|
constructor() {
|
|
1664
1671
|
super(...arguments), this.pendingPromises = [], this._fakeRegisteredUsers = {};
|
|
1665
1672
|
}
|
|
1666
1673
|
signUp(e) {
|
|
1667
|
-
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (a,
|
|
1668
|
-
n === "email" && (r ||
|
|
1674
|
+
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (a, h) => {
|
|
1675
|
+
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, a(this._loggedUser), this.notifyChange?.(this._loggedUser)) : (h({ code: "userNotFound", message: t || "Test auth error" }), this.notifyChange?.(void 0));
|
|
1669
1676
|
});
|
|
1670
1677
|
return this.pendingPromises.push(o), o;
|
|
1671
1678
|
}
|
|
@@ -1761,7 +1768,7 @@ const y = class y {
|
|
|
1761
1768
|
};
|
|
1762
1769
|
y.error = { shouldBeRegistered: "You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions." };
|
|
1763
1770
|
let $ = y;
|
|
1764
|
-
class
|
|
1771
|
+
class Ce {
|
|
1765
1772
|
constructor(e) {
|
|
1766
1773
|
this._registeredFunctions = e;
|
|
1767
1774
|
}
|
|
@@ -1802,7 +1809,7 @@ const g = class g extends B {
|
|
|
1802
1809
|
};
|
|
1803
1810
|
g.error = { shouldBeRegistered: "You should register a Server Auth service before using the Server Auth." }, g._instance = void 0;
|
|
1804
1811
|
let V = g;
|
|
1805
|
-
class
|
|
1812
|
+
class ve extends B {
|
|
1806
1813
|
constructor(e) {
|
|
1807
1814
|
super(), this._userCredentials = e;
|
|
1808
1815
|
}
|
|
@@ -1828,7 +1835,7 @@ class we extends B {
|
|
|
1828
1835
|
return this._userCredentials;
|
|
1829
1836
|
}
|
|
1830
1837
|
}
|
|
1831
|
-
function
|
|
1838
|
+
function we(i, e) {
|
|
1832
1839
|
return i ? i.replace(/\${\s*(\w*)\s*}/g, function(t, r) {
|
|
1833
1840
|
return e[r] || "";
|
|
1834
1841
|
}) : "";
|
|
@@ -1852,20 +1859,20 @@ export {
|
|
|
1852
1859
|
Pe as AuthMock,
|
|
1853
1860
|
W as AuthService,
|
|
1854
1861
|
$ as CloudFunctions,
|
|
1855
|
-
|
|
1856
|
-
|
|
1862
|
+
Ce as CloudFunctionsMock,
|
|
1863
|
+
w as CloudStorage,
|
|
1857
1864
|
b as DataSource,
|
|
1858
1865
|
ye as EntropicComponent,
|
|
1859
1866
|
be as JsonDataSource,
|
|
1860
|
-
|
|
1867
|
+
F as MockCloudStorage,
|
|
1861
1868
|
R as Model,
|
|
1862
|
-
|
|
1869
|
+
M as Observable,
|
|
1863
1870
|
d as Persistent,
|
|
1864
1871
|
te as Query,
|
|
1865
1872
|
V as ServerAuth,
|
|
1866
|
-
|
|
1873
|
+
ve as ServerAuthMock,
|
|
1867
1874
|
B as ServerAuthService,
|
|
1868
|
-
|
|
1875
|
+
k as Store,
|
|
1869
1876
|
D as StoredFile,
|
|
1870
1877
|
ae as StoredFileEvent,
|
|
1871
1878
|
De as camelCase,
|
|
@@ -1880,7 +1887,7 @@ export {
|
|
|
1880
1887
|
re as registerCloudStorage,
|
|
1881
1888
|
fe as registerLegacyClassName,
|
|
1882
1889
|
ee as registerPersistentClass,
|
|
1883
|
-
|
|
1890
|
+
we as replaceValue,
|
|
1884
1891
|
pe as required,
|
|
1885
1892
|
ge as requiredWithValidator,
|
|
1886
1893
|
me as searchableArray,
|