@0xpolygonid/js-sdk 1.27.2 → 1.27.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/dist/browser/esm/index.js +74 -34
- package/dist/browser/esm/index.js.map +1 -1
- package/dist/browser/umd/index.js +73 -33
- package/dist/browser/umd/index.js.map +1 -1
- package/dist/node/cjs/storage/filters/jsonQuery.js +74 -34
- package/dist/node/esm/storage/filters/jsonQuery.js +73 -33
- package/dist/types/storage/filters/jsonQuery.d.ts +12 -0
- package/package.json +1 -1
|
@@ -57037,6 +57037,19 @@ var PolygonIdSdk = (function (exports) {
|
|
|
57037
57037
|
SearchError["NotDefinedQueryKey"] = "not defined query key";
|
|
57038
57038
|
SearchError["NotDefinedComparator"] = "not defined comparator";
|
|
57039
57039
|
})(exports.SearchError || (exports.SearchError = {}));
|
|
57040
|
+
/**
|
|
57041
|
+
* supported data formats
|
|
57042
|
+
*
|
|
57043
|
+
* @enum {number}
|
|
57044
|
+
*/
|
|
57045
|
+
exports.SupportedDataFormat = void 0;
|
|
57046
|
+
(function (SupportedDataFormat) {
|
|
57047
|
+
SupportedDataFormat[SupportedDataFormat["BigInt"] = 0] = "BigInt";
|
|
57048
|
+
SupportedDataFormat[SupportedDataFormat["Boolean"] = 1] = "Boolean";
|
|
57049
|
+
SupportedDataFormat[SupportedDataFormat["Double"] = 2] = "Double";
|
|
57050
|
+
SupportedDataFormat[SupportedDataFormat["DateTime"] = 3] = "DateTime";
|
|
57051
|
+
SupportedDataFormat[SupportedDataFormat["String"] = 4] = "String";
|
|
57052
|
+
})(exports.SupportedDataFormat || (exports.SupportedDataFormat = {}));
|
|
57040
57053
|
const truthyValues = [true, 1, 'true'];
|
|
57041
57054
|
const falsyValues = [false, 0, 'false'];
|
|
57042
57055
|
const equalsComparator = (a, b) => {
|
|
@@ -57060,40 +57073,38 @@ var PolygonIdSdk = (function (exports) {
|
|
|
57060
57073
|
return a === b;
|
|
57061
57074
|
};
|
|
57062
57075
|
const greaterThan = (a, b) => {
|
|
57063
|
-
|
|
57064
|
-
|
|
57065
|
-
|
|
57066
|
-
|
|
57067
|
-
|
|
57068
|
-
|
|
57069
|
-
|
|
57070
|
-
|
|
57071
|
-
|
|
57072
|
-
|
|
57076
|
+
const predicate = (a, b) => {
|
|
57077
|
+
const dataFormat = detectDataFormat(a.toString());
|
|
57078
|
+
switch (dataFormat) {
|
|
57079
|
+
case exports.SupportedDataFormat.BigInt:
|
|
57080
|
+
case exports.SupportedDataFormat.Boolean:
|
|
57081
|
+
return BigInt(a) > BigInt(b);
|
|
57082
|
+
case exports.SupportedDataFormat.DateTime:
|
|
57083
|
+
return Date.parse(a.toString()) > Date.parse(b.toString()); /// nanoseconds won't be compared.
|
|
57084
|
+
case exports.SupportedDataFormat.Double:
|
|
57085
|
+
case exports.SupportedDataFormat.String:
|
|
57086
|
+
default:
|
|
57087
|
+
return a > b;
|
|
57088
|
+
}
|
|
57089
|
+
};
|
|
57090
|
+
return operatorIndependentCheck(a, b, predicate);
|
|
57073
57091
|
};
|
|
57074
57092
|
const greaterThanOrEqual = (a, b) => {
|
|
57075
|
-
|
|
57076
|
-
|
|
57077
|
-
|
|
57078
|
-
|
|
57079
|
-
|
|
57080
|
-
|
|
57081
|
-
|
|
57082
|
-
|
|
57083
|
-
|
|
57084
|
-
|
|
57085
|
-
|
|
57086
|
-
|
|
57087
|
-
|
|
57088
|
-
|
|
57089
|
-
|
|
57090
|
-
if (!Array.isArray(a) && Array.isArray(b)) {
|
|
57091
|
-
return b.every((val) => a <= val);
|
|
57092
|
-
}
|
|
57093
|
-
if (Array.isArray(a) && !Array.isArray(b)) {
|
|
57094
|
-
return a.every((val) => val <= b);
|
|
57095
|
-
}
|
|
57096
|
-
return a <= b;
|
|
57093
|
+
const predicate = (a, b) => {
|
|
57094
|
+
const dataFormat = detectDataFormat(a.toString());
|
|
57095
|
+
switch (dataFormat) {
|
|
57096
|
+
case exports.SupportedDataFormat.BigInt:
|
|
57097
|
+
case exports.SupportedDataFormat.Boolean:
|
|
57098
|
+
return BigInt(a) >= BigInt(b);
|
|
57099
|
+
case exports.SupportedDataFormat.DateTime:
|
|
57100
|
+
return Date.parse(a.toString()) >= Date.parse(b.toString()); /// nanoseconds won't be compared.
|
|
57101
|
+
case exports.SupportedDataFormat.Double:
|
|
57102
|
+
case exports.SupportedDataFormat.String:
|
|
57103
|
+
default:
|
|
57104
|
+
return a >= b;
|
|
57105
|
+
}
|
|
57106
|
+
};
|
|
57107
|
+
return operatorIndependentCheck(a, b, predicate);
|
|
57097
57108
|
};
|
|
57098
57109
|
// a - field value
|
|
57099
57110
|
// b - true / false (exists operator values)
|
|
@@ -57142,7 +57153,7 @@ var PolygonIdSdk = (function (exports) {
|
|
|
57142
57153
|
$lt: (a, b) => !greaterThanOrEqual(a, b),
|
|
57143
57154
|
$ne: (a, b) => !equalsComparator(a, b),
|
|
57144
57155
|
$gte: (a, b) => greaterThanOrEqual(a, b),
|
|
57145
|
-
$lte: (a, b) =>
|
|
57156
|
+
$lte: (a, b) => !greaterThan(a, b),
|
|
57146
57157
|
$between: (a, b) => betweenOperator(a, b),
|
|
57147
57158
|
$nonbetween: (a, b) => !betweenOperator(a, b)
|
|
57148
57159
|
};
|
|
@@ -57256,6 +57267,35 @@ var PolygonIdSdk = (function (exports) {
|
|
|
57256
57267
|
}
|
|
57257
57268
|
}, []);
|
|
57258
57269
|
};
|
|
57270
|
+
const operatorIndependentCheck = (a, b, predicate) => {
|
|
57271
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
57272
|
+
return a.every((val, index) => predicate(val, b[index]));
|
|
57273
|
+
}
|
|
57274
|
+
if (!Array.isArray(a) && Array.isArray(b)) {
|
|
57275
|
+
return b.every((val) => predicate(a, val));
|
|
57276
|
+
}
|
|
57277
|
+
if (Array.isArray(a) && !Array.isArray(b)) {
|
|
57278
|
+
return a.every((val) => predicate(val, b));
|
|
57279
|
+
}
|
|
57280
|
+
// in this case a and b are not arrays
|
|
57281
|
+
return predicate(a, b);
|
|
57282
|
+
};
|
|
57283
|
+
const regExBigInt = /^[+-]?\d+$/;
|
|
57284
|
+
const regExDouble = /^(-?)(0|([1-9][0-9]*))(\\.[0-9]+)?$/;
|
|
57285
|
+
const regExDateTimeRFC3339Nano =
|
|
57286
|
+
/* eslint-disable-next-line */
|
|
57287
|
+
/^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$/;
|
|
57288
|
+
const regExBoolean = /^(true)|(false)$/;
|
|
57289
|
+
const regExDateTimeYYYYMMDD = /^\d{4}-\d{2}-\d{2}$/;
|
|
57290
|
+
const detectDataFormat = (s) => regExBigInt.test(s)
|
|
57291
|
+
? exports.SupportedDataFormat.BigInt
|
|
57292
|
+
: regExDouble.test(s)
|
|
57293
|
+
? exports.SupportedDataFormat.Double
|
|
57294
|
+
: regExDateTimeRFC3339Nano.test(s) || regExDateTimeYYYYMMDD.test(s)
|
|
57295
|
+
? exports.SupportedDataFormat.DateTime
|
|
57296
|
+
: regExBoolean.test(s)
|
|
57297
|
+
? exports.SupportedDataFormat.Boolean
|
|
57298
|
+
: exports.SupportedDataFormat.String;
|
|
57259
57299
|
|
|
57260
57300
|
const MERKLE_TREE_TYPES = [
|
|
57261
57301
|
exports.MerkleTreeType.Claims,
|