entropic-bond 1.57.1 → 1.58.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 +151 -113
- package/lib/entropic-bond.js.map +1 -1
- package/lib/entropic-bond.umd.cjs +2 -2
- package/lib/entropic-bond.umd.cjs.map +1 -1
- package/lib/persistent/persistent.d.ts +1 -1
- package/lib/store/data-source.d.ts +1 -0
- package/lib/store/json-data-source.d.ts +1 -1
- package/lib/store/model.d.ts +1 -0
- package/package.json +5 -5
package/lib/entropic-bond.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class L {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
4
4
|
}
|
|
@@ -59,7 +59,7 @@ function J() {
|
|
|
59
59
|
}
|
|
60
60
|
return F(z);
|
|
61
61
|
}
|
|
62
|
-
const H = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
|
|
62
|
+
const H = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), k = { randomUUID: H };
|
|
63
63
|
function Z(i, e, t) {
|
|
64
64
|
i = i || {};
|
|
65
65
|
const r = i.random ?? i.rng?.() ?? J();
|
|
@@ -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 k.randomUUID && !i ? k.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
77
|
}, l;
|
|
78
|
-
const
|
|
78
|
+
const x = (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
|
|
@@ -399,21 +399,21 @@ const W = (l = class {
|
|
|
399
399
|
}, l._factoryMap = {}, l);
|
|
400
400
|
X([
|
|
401
401
|
j
|
|
402
|
-
],
|
|
403
|
-
let d =
|
|
402
|
+
], x.prototype, "_id");
|
|
403
|
+
let d = x;
|
|
404
404
|
function j(i, e) {
|
|
405
|
-
return
|
|
405
|
+
return y()(i, e);
|
|
406
406
|
}
|
|
407
407
|
function ce(i) {
|
|
408
408
|
return function(e, t) {
|
|
409
|
-
return
|
|
409
|
+
return y({
|
|
410
410
|
storeInCollection: i,
|
|
411
411
|
isReference: !0
|
|
412
412
|
})(e, t);
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
415
|
function ue(i, e) {
|
|
416
|
-
return
|
|
416
|
+
return y({ isReference: !0 })(i, e);
|
|
417
417
|
}
|
|
418
418
|
function he(i, e, t, r) {
|
|
419
419
|
return function(s, n) {
|
|
@@ -424,15 +424,15 @@ function he(i, e, t, r) {
|
|
|
424
424
|
cachedProps: i,
|
|
425
425
|
ownerCollection: r ?? s.className
|
|
426
426
|
};
|
|
427
|
-
return
|
|
427
|
+
return y(o)(s, n);
|
|
428
428
|
};
|
|
429
429
|
}
|
|
430
430
|
function le(i, e, t) {
|
|
431
|
-
return
|
|
431
|
+
return y({ isReference: !0, isPureReference: !0, storeInCollection: t })(i, e);
|
|
432
432
|
}
|
|
433
433
|
function de(i, e, t, r) {
|
|
434
434
|
return function(s, n) {
|
|
435
|
-
return
|
|
435
|
+
return y({
|
|
436
436
|
isReference: !0,
|
|
437
437
|
isPureReference: !0,
|
|
438
438
|
storeInCollection: t,
|
|
@@ -442,7 +442,7 @@ function de(i, e, t, r) {
|
|
|
442
442
|
})(s, n);
|
|
443
443
|
};
|
|
444
444
|
}
|
|
445
|
-
function
|
|
445
|
+
function y(i) {
|
|
446
446
|
return function(e, t) {
|
|
447
447
|
Object.getOwnPropertyDescriptor(e, "_persistentProperties") || (e._persistentProperties ? e._persistentProperties = [...e._persistentProperties] : e._persistentProperties = []);
|
|
448
448
|
const r = e._persistentProperties.find((s) => s.name === t);
|
|
@@ -464,25 +464,25 @@ function fe(i) {
|
|
|
464
464
|
};
|
|
465
465
|
}
|
|
466
466
|
function me(i, e) {
|
|
467
|
-
return
|
|
467
|
+
return y({ searchableArray: !0 })(i, e);
|
|
468
468
|
}
|
|
469
469
|
function pe(i, e) {
|
|
470
|
-
return
|
|
470
|
+
return y({ validator: (t) => t != null })(i, e);
|
|
471
471
|
}
|
|
472
472
|
function ge(i = (e) => e != null) {
|
|
473
473
|
return function(e, t) {
|
|
474
|
-
return
|
|
474
|
+
return y({ validator: i })(e, t);
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
477
|
function _e(i) {
|
|
478
478
|
let e;
|
|
479
479
|
return typeof i == "function" ? e = new i().className : e = i, function(t, r) {
|
|
480
|
-
return
|
|
480
|
+
return y({ typeName: e })(t, r);
|
|
481
481
|
};
|
|
482
482
|
}
|
|
483
483
|
class ye extends d {
|
|
484
484
|
constructor() {
|
|
485
|
-
super(...arguments), this._onChange = new
|
|
485
|
+
super(...arguments), this._onChange = new L();
|
|
486
486
|
}
|
|
487
487
|
/**
|
|
488
488
|
* Subscribes a listener callback function. Every time a property is changed,
|
|
@@ -565,10 +565,10 @@ class ye extends d {
|
|
|
565
565
|
return this.notify({ [e]: this[e] }), t;
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
|
-
const
|
|
568
|
+
const A = class A {
|
|
569
569
|
constructor(e, t, r) {
|
|
570
570
|
if (r) {
|
|
571
|
-
if (!(t instanceof d)) throw new Error(
|
|
571
|
+
if (!(t instanceof d)) throw new Error(A.error.persistentNeedForSubCollection);
|
|
572
572
|
this.collectionName = `${t.className}/${t.id}/${r}`;
|
|
573
573
|
} else
|
|
574
574
|
this.collectionName = t instanceof d ? t.className : t;
|
|
@@ -658,7 +658,7 @@ const N = class N {
|
|
|
658
658
|
return this._stream.onDocumentChange(
|
|
659
659
|
this.collectionName,
|
|
660
660
|
e,
|
|
661
|
-
(r) => t(
|
|
661
|
+
(r) => t(_.toPersistentDocumentChange(r))
|
|
662
662
|
);
|
|
663
663
|
}
|
|
664
664
|
onCollectionChange(e, t) {
|
|
@@ -666,10 +666,16 @@ const N = class N {
|
|
|
666
666
|
this.preprocessQueryObject(e.getQueryObject()),
|
|
667
667
|
this.collectionName,
|
|
668
668
|
(r) => t(r.map(
|
|
669
|
-
(s) =>
|
|
669
|
+
(s) => _.toPersistentDocumentChange(s)
|
|
670
670
|
))
|
|
671
671
|
);
|
|
672
672
|
}
|
|
673
|
+
onCollectionTemplateChange(e, t) {
|
|
674
|
+
return this._stream.onDocumentTemplateChange(
|
|
675
|
+
e,
|
|
676
|
+
(r) => t(_.toPersistentDocumentChange(r))
|
|
677
|
+
);
|
|
678
|
+
}
|
|
673
679
|
// /**
|
|
674
680
|
// * Get the previous bunch of documents matching the last query
|
|
675
681
|
// * @param limit the max amount of documents to retrieve. If not set, uses the
|
|
@@ -698,7 +704,7 @@ const N = class N {
|
|
|
698
704
|
if (Object.values(e).length === 0) return e;
|
|
699
705
|
const t = e.operations?.map((r) => {
|
|
700
706
|
const s = r.value[0] ?? r.value;
|
|
701
|
-
return
|
|
707
|
+
return _.isArrayOperator(r.operator) && s instanceof d ? {
|
|
702
708
|
property: d.searchableArrayNameFor(r.property),
|
|
703
709
|
operator: r.operator,
|
|
704
710
|
value: Array.isArray(r.value) ? r.value.map((n) => n.id) : s.id,
|
|
@@ -716,11 +722,11 @@ const N = class N {
|
|
|
716
722
|
};
|
|
717
723
|
}
|
|
718
724
|
};
|
|
719
|
-
|
|
725
|
+
A.error = {
|
|
720
726
|
persistentNeedForSubCollection: "The document parameter for a sub-collection should be a Persistent instace",
|
|
721
727
|
invalidQueryOrder: "Cannot add where calls after or calls"
|
|
722
728
|
};
|
|
723
|
-
let R =
|
|
729
|
+
let R = A;
|
|
724
730
|
class te {
|
|
725
731
|
constructor(e) {
|
|
726
732
|
this.queryObject = { operations: [] }, this.model = e;
|
|
@@ -781,8 +787,8 @@ class te {
|
|
|
781
787
|
if (this.queryObject.operations?.at(-1)?.aggregate && !s) throw new Error(R.error.invalidQueryOrder);
|
|
782
788
|
const n = e.split(".");
|
|
783
789
|
let o = {}, a = n.length > 1 ? o : r;
|
|
784
|
-
return n.slice(1).forEach((
|
|
785
|
-
o[
|
|
790
|
+
return n.slice(1).forEach((c, h) => {
|
|
791
|
+
o[c] = h < n.length - 2 ? {} : r, o = o[c];
|
|
786
792
|
}), this.queryObject.operations?.push({
|
|
787
793
|
property: n[0],
|
|
788
794
|
operator: t,
|
|
@@ -945,7 +951,7 @@ class te {
|
|
|
945
951
|
return this.model;
|
|
946
952
|
}
|
|
947
953
|
}
|
|
948
|
-
const
|
|
954
|
+
const C = class C {
|
|
949
955
|
constructor() {
|
|
950
956
|
}
|
|
951
957
|
/**
|
|
@@ -961,7 +967,7 @@ const P = class P {
|
|
|
961
967
|
* @returns the data source
|
|
962
968
|
*/
|
|
963
969
|
static get dataSource() {
|
|
964
|
-
return
|
|
970
|
+
return C._dataSource;
|
|
965
971
|
}
|
|
966
972
|
/**
|
|
967
973
|
* Retrieves a model for a collection
|
|
@@ -969,8 +975,8 @@ const P = class P {
|
|
|
969
975
|
* @returns the model for the collection
|
|
970
976
|
*/
|
|
971
977
|
static getModel(e) {
|
|
972
|
-
if (!
|
|
973
|
-
return new R(
|
|
978
|
+
if (!C._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
979
|
+
return new R(C._dataSource, e);
|
|
974
980
|
}
|
|
975
981
|
/**
|
|
976
982
|
* Retrieves a model for a subcollection
|
|
@@ -979,8 +985,8 @@ const P = class P {
|
|
|
979
985
|
* @returns the model for the subcollection
|
|
980
986
|
*/
|
|
981
987
|
static getModelForSubCollection(e, t) {
|
|
982
|
-
if (!
|
|
983
|
-
return new R(
|
|
988
|
+
if (!C._dataSource) throw new Error(this.error.shouldBeRegistered);
|
|
989
|
+
return new R(C._dataSource, e, t);
|
|
984
990
|
}
|
|
985
991
|
/**
|
|
986
992
|
* Populates property references with actual data from the store.
|
|
@@ -1012,9 +1018,9 @@ const P = class P {
|
|
|
1012
1018
|
) : e.__documentReference === void 0;
|
|
1013
1019
|
}
|
|
1014
1020
|
};
|
|
1015
|
-
|
|
1016
|
-
let
|
|
1017
|
-
class
|
|
1021
|
+
C.error = { shouldBeRegistered: "You should register a data source before using the data Store." };
|
|
1022
|
+
let W = C;
|
|
1023
|
+
class M {
|
|
1018
1024
|
constructor(e) {
|
|
1019
1025
|
this._resolveCollectionPaths = () => {
|
|
1020
1026
|
throw new Error("The method collectionsMatchingTemplate has not been implemented in the concrete data source");
|
|
@@ -1026,7 +1032,7 @@ class L {
|
|
|
1026
1032
|
r.forEach((s) => {
|
|
1027
1033
|
if (!s.typeName) return;
|
|
1028
1034
|
(Array.isArray(s.typeName) ? s.typeName : [s?.typeName ?? t]).map((o) => d.collectionPath(d.createInstance(o), s)).forEach((o) => {
|
|
1029
|
-
this._collectionsToWatch[o] || (this._collectionsToWatch[o] = []), this._collectionsToWatch[o].find((
|
|
1035
|
+
this._collectionsToWatch[o] || (this._collectionsToWatch[o] = []), this._collectionsToWatch[o].find((c) => c.name === s.name && c.ownerClassName() === s.ownerClassName()) || this._collectionsToWatch[o].push(s);
|
|
1030
1036
|
});
|
|
1031
1037
|
});
|
|
1032
1038
|
});
|
|
@@ -1077,20 +1083,20 @@ class L {
|
|
|
1077
1083
|
return r ? this.onDocumentChange(t, r) : Promise.resolve();
|
|
1078
1084
|
}
|
|
1079
1085
|
async onDocumentChange(e, t) {
|
|
1080
|
-
const r =
|
|
1086
|
+
const r = _.toPersistentDocumentChange(e);
|
|
1081
1087
|
this._beforeDocumentChange?.(r, t);
|
|
1082
1088
|
const s = {};
|
|
1083
1089
|
e.type !== "update" || !r.before || r.after?.id && this._disabledChangeListeners.has(r.after?.id) || (await Promise.all(t.map(async (n) => {
|
|
1084
|
-
const o =
|
|
1085
|
-
await Promise.all(a.map(async (
|
|
1086
|
-
const h =
|
|
1087
|
-
let
|
|
1090
|
+
const o = M.ownerCollectionPath(d.createInstance(n.ownerClassName()), n, r.params), a = await this._resolveCollectionPaths(o);
|
|
1091
|
+
await Promise.all(a.map(async (c) => {
|
|
1092
|
+
const h = W.getModel(c);
|
|
1093
|
+
let u = h.find(), b = !1;
|
|
1088
1094
|
n.cachedProps?.forEach((f) => {
|
|
1089
1095
|
const S = r.before[f], O = r.after[f];
|
|
1090
1096
|
S !== O && (b = !0);
|
|
1091
|
-
}), b && (n.searchableArray ?
|
|
1092
|
-
const E = await
|
|
1093
|
-
return s[
|
|
1097
|
+
}), b && (n.searchableArray ? u = u.where(n.name, "contains", r.before) : u = u.where(n.name, "==", r.before)), u = this._beforeQueryOwnerCollection?.(u) ?? u;
|
|
1098
|
+
const E = await u.get();
|
|
1099
|
+
return s[c] = {
|
|
1094
1100
|
totalDocumentsToUpdate: E.length,
|
|
1095
1101
|
updatedDocuments: [],
|
|
1096
1102
|
documentsToUpdate: E.map((f) => f.name ?? f.id)
|
|
@@ -1098,15 +1104,15 @@ class L {
|
|
|
1098
1104
|
E.map(async (f) => {
|
|
1099
1105
|
let S = !1;
|
|
1100
1106
|
if (n.cachedProps?.forEach((O) => {
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1107
|
+
const N = r.before[O], q = r.after[O];
|
|
1108
|
+
N !== q && (S = !0);
|
|
1103
1109
|
}), S) {
|
|
1104
1110
|
if (n.searchableArray) {
|
|
1105
|
-
const O = f[n.name].findIndex((
|
|
1111
|
+
const O = f[n.name].findIndex((N) => N.id === r.before.id);
|
|
1106
1112
|
f[n.name][O] = r.after;
|
|
1107
1113
|
} else
|
|
1108
1114
|
f[`_${n.name}`] = r.after;
|
|
1109
|
-
this._beforeUpdate?.(f, n), this.disableChangeListener(f), await h.save(f), this.enableChangeListener(f), s[
|
|
1115
|
+
this._beforeUpdate?.(f, n), this.disableChangeListener(f), await h.save(f), this.enableChangeListener(f), s[c]?.updatedDocuments.push(f.id), this._afterUpdate?.(f, n);
|
|
1110
1116
|
} else return Promise.resolve();
|
|
1111
1117
|
})
|
|
1112
1118
|
]);
|
|
@@ -1124,12 +1130,12 @@ class L {
|
|
|
1124
1130
|
return typeof t.ownerCollection == "function" ? s = t.ownerCollection(e, t, r) : s = t.ownerCollection ?? e.className, s;
|
|
1125
1131
|
}
|
|
1126
1132
|
}
|
|
1127
|
-
class
|
|
1133
|
+
class _ {
|
|
1128
1134
|
constructor() {
|
|
1129
1135
|
this._cachedPropsUpdater = void 0;
|
|
1130
1136
|
}
|
|
1131
1137
|
installCachedPropsUpdater(e) {
|
|
1132
|
-
return this._cachedPropsUpdater = new
|
|
1138
|
+
return this._cachedPropsUpdater = new M(e), this._cachedPropsUpdater.resolveCollectionPaths = this.resolveCollectionPaths.bind(this), this._cachedPropsUpdater;
|
|
1133
1139
|
}
|
|
1134
1140
|
get cachedPropsUpdater() {
|
|
1135
1141
|
return this._cachedPropsUpdater;
|
|
@@ -1148,7 +1154,7 @@ class w {
|
|
|
1148
1154
|
*/
|
|
1149
1155
|
static toPropertyPathOperations(e) {
|
|
1150
1156
|
return e ? e.map((t) => {
|
|
1151
|
-
if (
|
|
1157
|
+
if (_.isArrayOperator(t.operator) && t.value[0] instanceof d)
|
|
1152
1158
|
return {
|
|
1153
1159
|
property: d.searchableArrayNameFor(t.property),
|
|
1154
1160
|
operator: t.operator,
|
|
@@ -1182,22 +1188,43 @@ class w {
|
|
|
1182
1188
|
return [void 0, e];
|
|
1183
1189
|
}
|
|
1184
1190
|
static isStringMatchingTemplate(e, t) {
|
|
1185
|
-
const
|
|
1186
|
-
|
|
1191
|
+
const r = e.split("/"), s = t.split("/");
|
|
1192
|
+
if (s.length > r.length) return !1;
|
|
1193
|
+
for (let n = 0; n < s.length; n++) {
|
|
1194
|
+
const o = r[n], a = s[n];
|
|
1195
|
+
if (!(o.startsWith("{") && o.endsWith("}") || o.startsWith("${") && o.endsWith("}")) && o !== a) return !1;
|
|
1196
|
+
}
|
|
1197
|
+
for (let n = s.length; n < r.length; n++) {
|
|
1198
|
+
const o = r[n];
|
|
1199
|
+
if (!(o.startsWith("{") && o.endsWith("}") || o.startsWith("${") && o.endsWith("}"))) return !1;
|
|
1200
|
+
}
|
|
1201
|
+
return !0;
|
|
1187
1202
|
}
|
|
1188
1203
|
static extractTemplateParams(e, t) {
|
|
1189
|
-
const r =
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1204
|
+
const r = t.split("/"), s = e.split("/"), n = {};
|
|
1205
|
+
if (s.length > r.length) return n;
|
|
1206
|
+
for (let o = 0; o < s.length; o++) {
|
|
1207
|
+
const a = r[o], c = s[o];
|
|
1208
|
+
if (a.startsWith("{") && a.endsWith("}"))
|
|
1209
|
+
n[a.slice(1, -1)] = c;
|
|
1210
|
+
else if (a.startsWith("${") && a.endsWith("}"))
|
|
1211
|
+
n[a.slice(2, -1)] = c;
|
|
1212
|
+
else if (a !== c)
|
|
1213
|
+
return {};
|
|
1214
|
+
}
|
|
1215
|
+
for (let o = s.length; o < r.length; o++) {
|
|
1216
|
+
const a = r[o];
|
|
1217
|
+
if (!(a.startsWith("{") && a.endsWith("}") || a.startsWith("${") && a.endsWith("}"))) return {};
|
|
1218
|
+
}
|
|
1219
|
+
return n;
|
|
1193
1220
|
}
|
|
1194
1221
|
}
|
|
1195
|
-
class
|
|
1222
|
+
class Pe extends _ {
|
|
1196
1223
|
/**
|
|
1197
1224
|
* @param jsonRawData the JSON object to be used as data store
|
|
1198
1225
|
*/
|
|
1199
1226
|
constructor(e) {
|
|
1200
|
-
super(), this._jsonRawData = {}, this._lastMatchingDocs = [], this._lastLimit = 0, this._cursor = 0, this._simulateDelay = 0, this._pendingPromises = [], this._documentListeners = {}, this._collectionListeners = {},
|
|
1227
|
+
super(), this._jsonRawData = {}, this._lastMatchingDocs = [], this._lastLimit = 0, this._cursor = 0, this._simulateDelay = 0, this._pendingPromises = [], this._documentListeners = {}, this._collectionListeners = {}, e && (this._jsonRawData = e);
|
|
1201
1228
|
}
|
|
1202
1229
|
/**
|
|
1203
1230
|
* Set the JSON object to initialize the data store. Use to set the it after
|
|
@@ -1253,10 +1280,10 @@ class be extends w {
|
|
|
1253
1280
|
s || (this._collectionListeners[t] = {}, s = this._collectionListeners[t]);
|
|
1254
1281
|
const n = (a) => {
|
|
1255
1282
|
if (!a.after) return;
|
|
1256
|
-
const
|
|
1257
|
-
a.before &&
|
|
1258
|
-
const
|
|
1259
|
-
|
|
1283
|
+
const c = [a.after];
|
|
1284
|
+
a.before && c.push(a.before);
|
|
1285
|
+
const u = this.retrieveQueryDocs(c, e.operations).filter((b, E, f) => E === f.findIndex((S) => S.id === b.id));
|
|
1286
|
+
u.length > 0 && r(u.map((b) => ({
|
|
1260
1287
|
before: a.before,
|
|
1261
1288
|
after: b,
|
|
1262
1289
|
type: a.type,
|
|
@@ -1273,6 +1300,17 @@ class be extends w {
|
|
|
1273
1300
|
}, o = Math.random().toString(36).substring(2, 9);
|
|
1274
1301
|
return s[o] = n, () => delete s[o];
|
|
1275
1302
|
}
|
|
1303
|
+
onDocumentTemplateChange(e, t) {
|
|
1304
|
+
const r = this.collectionsMatchingTemplate(e), s = [];
|
|
1305
|
+
return r.forEach((n) => {
|
|
1306
|
+
let o = this._documentListeners[n];
|
|
1307
|
+
o || (this._documentListeners[n] = {}, o = this._documentListeners[n]);
|
|
1308
|
+
const a = (h) => {
|
|
1309
|
+
h.params = _.extractTemplateParams(n, e), t(h);
|
|
1310
|
+
}, c = Math.random().toString(36).substring(2, 9);
|
|
1311
|
+
o[c] = a, s.push(() => delete o[c]);
|
|
1312
|
+
}), () => s.forEach((n) => n());
|
|
1313
|
+
}
|
|
1276
1314
|
/**
|
|
1277
1315
|
* @returns the raw data store data as a JSON object
|
|
1278
1316
|
*/
|
|
@@ -1305,7 +1343,7 @@ class be extends w {
|
|
|
1305
1343
|
params: {},
|
|
1306
1344
|
type: r ? "update" : "create"
|
|
1307
1345
|
};
|
|
1308
|
-
Object.values(this.
|
|
1346
|
+
Object.values(this._documentListeners[e] ?? {}).forEach((n) => n(s)), Object.values(this._collectionListeners[e] ?? {}).forEach((n) => n(s));
|
|
1309
1347
|
}
|
|
1310
1348
|
decCursor(e) {
|
|
1311
1349
|
return this._cursor -= e, this._cursor < 0 ? (this._cursor = 0, !0) : !1;
|
|
@@ -1315,7 +1353,7 @@ class be extends w {
|
|
|
1315
1353
|
limit: (n) => e,
|
|
1316
1354
|
//.slice( 0, limit ),
|
|
1317
1355
|
operations: (n) => this.retrieveQueryDocs(e, n),
|
|
1318
|
-
sort: ({ order: n, propertyName: o }) => e.sort((a,
|
|
1356
|
+
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)
|
|
1319
1357
|
}[t](r);
|
|
1320
1358
|
}
|
|
1321
1359
|
retrieveQueryDocs(e, t) {
|
|
@@ -1332,16 +1370,16 @@ class be extends w {
|
|
|
1332
1370
|
}
|
|
1333
1371
|
isQueryMatched(e, t) {
|
|
1334
1372
|
const r = {
|
|
1335
|
-
"==": (h,
|
|
1336
|
-
"!=": (h,
|
|
1337
|
-
"<": (h,
|
|
1338
|
-
"<=": (h,
|
|
1339
|
-
">": (h,
|
|
1340
|
-
">=": (h,
|
|
1341
|
-
containsAny: (h,
|
|
1342
|
-
contains: (h,
|
|
1343
|
-
}, { property: s, value: n, operator: o } = t, [a,
|
|
1344
|
-
return r[o](a,
|
|
1373
|
+
"==": (h, u) => h === u,
|
|
1374
|
+
"!=": (h, u) => h !== u,
|
|
1375
|
+
"<": (h, u) => h < u,
|
|
1376
|
+
"<=": (h, u) => h <= u,
|
|
1377
|
+
">": (h, u) => h > u,
|
|
1378
|
+
">=": (h, u) => h >= u,
|
|
1379
|
+
containsAny: (h, u) => h?.some((b) => u?.includes(b)),
|
|
1380
|
+
contains: (h, u) => h?.includes(u)
|
|
1381
|
+
}, { property: s, value: n, operator: o } = t, [a, c] = this.retrieveValuesToCompare(e, s, n);
|
|
1382
|
+
return r[o](a, c);
|
|
1345
1383
|
}
|
|
1346
1384
|
retrieveValuesToCompare(e, t, r) {
|
|
1347
1385
|
const s = e[t];
|
|
@@ -1367,7 +1405,7 @@ class be extends w {
|
|
|
1367
1405
|
return Promise.resolve(this.collectionsMatchingTemplate(e));
|
|
1368
1406
|
}
|
|
1369
1407
|
collectionsMatchingTemplate(e) {
|
|
1370
|
-
return Object.keys(this._jsonRawData).filter((t) =>
|
|
1408
|
+
return Object.keys(this._jsonRawData).filter((t) => _.isStringMatchingTemplate(e, t));
|
|
1371
1409
|
}
|
|
1372
1410
|
}
|
|
1373
1411
|
const v = class v {
|
|
@@ -1393,9 +1431,9 @@ const v = class v {
|
|
|
1393
1431
|
}
|
|
1394
1432
|
};
|
|
1395
1433
|
v._cloudStorageFactoryMap = {};
|
|
1396
|
-
let
|
|
1434
|
+
let w = v;
|
|
1397
1435
|
function re(i, e) {
|
|
1398
|
-
return
|
|
1436
|
+
return w.registerCloudStorage(i, e), (t) => {
|
|
1399
1437
|
t.prototype.__className = i;
|
|
1400
1438
|
};
|
|
1401
1439
|
}
|
|
@@ -1404,7 +1442,7 @@ var se = Object.getOwnPropertyDescriptor, ie = (i, e, t, r) => {
|
|
|
1404
1442
|
(o = i[n]) && (s = o(s) || s);
|
|
1405
1443
|
return s;
|
|
1406
1444
|
};
|
|
1407
|
-
let T = class extends
|
|
1445
|
+
let T = class extends w {
|
|
1408
1446
|
constructor(i = "") {
|
|
1409
1447
|
super(), this._simulateDelay = 0, this._pendingPromises = [], this.mockFileSystem = {}, this._pathToMockFiles = i;
|
|
1410
1448
|
}
|
|
@@ -1462,11 +1500,11 @@ var ne = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, U = (i, e,
|
|
|
1462
1500
|
}, ae = /* @__PURE__ */ ((i) => (i[i.stored = 0] = "stored", i[i.pendingDataSet = 1] = "pendingDataSet", i[i.deleted = 2] = "deleted", i))(ae || {});
|
|
1463
1501
|
let D = class extends d {
|
|
1464
1502
|
constructor() {
|
|
1465
|
-
super(...arguments), this._onChange = new
|
|
1503
|
+
super(...arguments), this._onChange = new L();
|
|
1466
1504
|
}
|
|
1467
1505
|
async save({ data: i, fileName: e, progress: t, cloudStorageProvider: r } = {}) {
|
|
1468
1506
|
const s = i || this._pendingData;
|
|
1469
|
-
s && (this._reference && await this.delete(), this.provider = r ||
|
|
1507
|
+
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 }));
|
|
1470
1508
|
}
|
|
1471
1509
|
uploadControl() {
|
|
1472
1510
|
return this.provider.uploadControl();
|
|
@@ -1481,9 +1519,9 @@ let D = class extends d {
|
|
|
1481
1519
|
get provider() {
|
|
1482
1520
|
if (!this._provider)
|
|
1483
1521
|
try {
|
|
1484
|
-
this._provider =
|
|
1522
|
+
this._provider = w.createInstance(this._cloudStorageProviderName);
|
|
1485
1523
|
} catch {
|
|
1486
|
-
this._provider =
|
|
1524
|
+
this._provider = w.defaultCloudStorage;
|
|
1487
1525
|
}
|
|
1488
1526
|
return this._provider;
|
|
1489
1527
|
}
|
|
@@ -1529,7 +1567,7 @@ class Q {
|
|
|
1529
1567
|
}
|
|
1530
1568
|
const p = class p extends Q {
|
|
1531
1569
|
constructor() {
|
|
1532
|
-
if (super(), this._onAuthStateChange = new
|
|
1570
|
+
if (super(), this._onAuthStateChange = new L(), !p._authService) throw new Error(p.error.shouldBeRegistered);
|
|
1533
1571
|
p._authService.onAuthStateChange(
|
|
1534
1572
|
(e) => this.authStateChanged(e)
|
|
1535
1573
|
);
|
|
@@ -1653,14 +1691,14 @@ const p = class p extends Q {
|
|
|
1653
1691
|
}
|
|
1654
1692
|
};
|
|
1655
1693
|
p.error = { shouldBeRegistered: "You should register an auth service before using Auth." }, p._instance = void 0;
|
|
1656
|
-
let
|
|
1657
|
-
class
|
|
1694
|
+
let I = p;
|
|
1695
|
+
class be extends Q {
|
|
1658
1696
|
constructor() {
|
|
1659
1697
|
super(...arguments), this.pendingPromises = [], this._fakeRegisteredUsers = {};
|
|
1660
1698
|
}
|
|
1661
1699
|
signUp(e) {
|
|
1662
|
-
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (a,
|
|
1663
|
-
n === "email" && (r ||
|
|
1700
|
+
const { verificationLink: t, email: r, password: s, authProvider: n } = e, o = new Promise(async (a, c) => {
|
|
1701
|
+
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));
|
|
1664
1702
|
});
|
|
1665
1703
|
return this.pendingPromises.push(o), o;
|
|
1666
1704
|
}
|
|
@@ -1725,21 +1763,21 @@ class Pe extends Q {
|
|
|
1725
1763
|
};
|
|
1726
1764
|
}
|
|
1727
1765
|
}
|
|
1728
|
-
const
|
|
1766
|
+
const P = class P {
|
|
1729
1767
|
constructor() {
|
|
1730
1768
|
}
|
|
1731
1769
|
static useCloudFunctionsService(e) {
|
|
1732
1770
|
this._cloudFunctionsService != e && (this._cloudFunctionsService = e);
|
|
1733
1771
|
}
|
|
1734
1772
|
static get instance() {
|
|
1735
|
-
if (!this._cloudFunctionsService) throw new Error(
|
|
1736
|
-
return
|
|
1773
|
+
if (!this._cloudFunctionsService) throw new Error(P.error.shouldBeRegistered);
|
|
1774
|
+
return P._instance || (P._instance = new P());
|
|
1737
1775
|
}
|
|
1738
1776
|
getRawFunction(e) {
|
|
1739
|
-
return
|
|
1777
|
+
return P._cloudFunctionsService.retrieveFunction(e);
|
|
1740
1778
|
}
|
|
1741
1779
|
getFunction(e) {
|
|
1742
|
-
const t =
|
|
1780
|
+
const t = P._cloudFunctionsService.callFunction, r = this.getRawFunction(e);
|
|
1743
1781
|
return async (s) => {
|
|
1744
1782
|
const n = await t(r, this.processParam(s));
|
|
1745
1783
|
return this.processResult(n);
|
|
@@ -1754,9 +1792,9 @@ const y = class y {
|
|
|
1754
1792
|
return e.__className ? d.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;
|
|
1755
1793
|
}
|
|
1756
1794
|
};
|
|
1757
|
-
|
|
1758
|
-
let
|
|
1759
|
-
class
|
|
1795
|
+
P.error = { shouldBeRegistered: "You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions." };
|
|
1796
|
+
let V = P;
|
|
1797
|
+
class Ce {
|
|
1760
1798
|
constructor(e) {
|
|
1761
1799
|
this._registeredFunctions = e;
|
|
1762
1800
|
}
|
|
@@ -1796,8 +1834,8 @@ const g = class g extends B {
|
|
|
1796
1834
|
}
|
|
1797
1835
|
};
|
|
1798
1836
|
g.error = { shouldBeRegistered: "You should register a Server Auth service before using the Server Auth." }, g._instance = void 0;
|
|
1799
|
-
let
|
|
1800
|
-
class
|
|
1837
|
+
let $ = g;
|
|
1838
|
+
class ve extends B {
|
|
1801
1839
|
constructor(e) {
|
|
1802
1840
|
super(), this._userCredentials = e;
|
|
1803
1841
|
}
|
|
@@ -1823,7 +1861,7 @@ class we extends B {
|
|
|
1823
1861
|
return this._userCredentials;
|
|
1824
1862
|
}
|
|
1825
1863
|
}
|
|
1826
|
-
function
|
|
1864
|
+
function we(i, e) {
|
|
1827
1865
|
return i ? i.replace(/\${\s*(\w*)\s*}/g, function(t, r) {
|
|
1828
1866
|
return e[r] || "";
|
|
1829
1867
|
}) : "";
|
|
@@ -1843,30 +1881,30 @@ function Oe(i, e) {
|
|
|
1843
1881
|
return e.split(".").reduce((t, r) => t[r], i);
|
|
1844
1882
|
}
|
|
1845
1883
|
export {
|
|
1846
|
-
|
|
1847
|
-
|
|
1884
|
+
I as Auth,
|
|
1885
|
+
be as AuthMock,
|
|
1848
1886
|
Q as AuthService,
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1887
|
+
V as CloudFunctions,
|
|
1888
|
+
Ce as CloudFunctionsMock,
|
|
1889
|
+
w as CloudStorage,
|
|
1890
|
+
_ as DataSource,
|
|
1853
1891
|
ye as EntropicComponent,
|
|
1854
|
-
|
|
1892
|
+
Pe as JsonDataSource,
|
|
1855
1893
|
T as MockCloudStorage,
|
|
1856
1894
|
R as Model,
|
|
1857
|
-
|
|
1895
|
+
L as Observable,
|
|
1858
1896
|
d as Persistent,
|
|
1859
1897
|
te as Query,
|
|
1860
|
-
|
|
1861
|
-
|
|
1898
|
+
$ as ServerAuth,
|
|
1899
|
+
ve as ServerAuthMock,
|
|
1862
1900
|
B as ServerAuthService,
|
|
1863
|
-
|
|
1901
|
+
W as Store,
|
|
1864
1902
|
D as StoredFile,
|
|
1865
1903
|
ae as StoredFileEvent,
|
|
1866
1904
|
De as camelCase,
|
|
1867
1905
|
Oe as getDeepValue,
|
|
1868
1906
|
j as persistent,
|
|
1869
|
-
|
|
1907
|
+
y as persistentParser,
|
|
1870
1908
|
le as persistentPureReference,
|
|
1871
1909
|
de as persistentPureReferenceWithCachedProps,
|
|
1872
1910
|
ue as persistentReference,
|
|
@@ -1875,7 +1913,7 @@ export {
|
|
|
1875
1913
|
re as registerCloudStorage,
|
|
1876
1914
|
fe as registerLegacyClassName,
|
|
1877
1915
|
ee as registerPersistentClass,
|
|
1878
|
-
|
|
1916
|
+
we as replaceValue,
|
|
1879
1917
|
pe as required,
|
|
1880
1918
|
ge as requiredWithValidator,
|
|
1881
1919
|
me as searchableArray,
|