@aws-amplify/datastore 4.7.5 → 5.0.1-console-preview.4208d73.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/README.md +4 -0
- package/lib/authModeStrategies/defaultAuthStrategy.js +3 -2
- package/lib/authModeStrategies/index.js +3 -3
- package/lib/authModeStrategies/multiAuthStrategy.js +81 -24
- package/lib/datastore/datastore.d.ts +3 -4
- package/lib/datastore/datastore.js +361 -227
- package/lib/index.d.ts +1 -1
- package/lib/index.js +25 -12
- package/lib/predicates/index.js +46 -12
- package/lib/predicates/next.d.ts +2 -2
- package/lib/predicates/next.js +172 -74
- package/lib/predicates/sort.js +3 -4
- package/lib/ssr/index.js +1 -1
- package/lib/storage/adapter/AsyncStorageAdapter.js +240 -128
- package/lib/storage/adapter/AsyncStorageDatabase.js +100 -39
- package/lib/storage/adapter/InMemoryStore.js +68 -17
- package/lib/storage/adapter/InMemoryStore.native.js +5 -3
- package/lib/storage/adapter/IndexedDBAdapter.js +355 -199
- package/lib/storage/adapter/StorageAdapterBase.js +154 -85
- package/lib/storage/adapter/getDefaultAdapter/index.js +8 -9
- package/lib/storage/adapter/getDefaultAdapter/index.native.js +4 -3
- package/lib/storage/adapter/index.js +0 -1
- package/lib/storage/relationship.js +31 -21
- package/lib/storage/storage.d.ts +3 -3
- package/lib/storage/storage.js +143 -61
- package/lib/sync/datastoreConnectivity.d.ts +1 -1
- package/lib/sync/datastoreConnectivity.js +57 -9
- package/lib/sync/datastoreReachability/index.js +3 -3
- package/lib/sync/datastoreReachability/index.native.js +7 -5
- package/lib/sync/index.d.ts +1 -1
- package/lib/sync/index.js +193 -125
- package/lib/sync/merger.js +81 -10
- package/lib/sync/outbox.js +101 -30
- package/lib/sync/processors/errorMaps.d.ts +1 -1
- package/lib/sync/processors/errorMaps.js +41 -6
- package/lib/sync/processors/mutation.d.ts +1 -1
- package/lib/sync/processors/mutation.js +192 -101
- package/lib/sync/processors/subscription.d.ts +4 -1
- package/lib/sync/processors/subscription.js +190 -178
- package/lib/sync/processors/sync.d.ts +1 -1
- package/lib/sync/processors/sync.js +113 -47
- package/lib/sync/utils.d.ts +4 -4
- package/lib/sync/utils.js +162 -81
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types.d.ts +138 -140
- package/lib/types.js +40 -5
- package/lib/util.d.ts +9 -17
- package/lib/util.js +216 -100
- package/lib-esm/authModeStrategies/defaultAuthStrategy.js +0 -1
- package/lib-esm/authModeStrategies/index.js +0 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +76 -21
- package/lib-esm/datastore/datastore.d.ts +3 -4
- package/lib-esm/datastore/datastore.js +206 -77
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +0 -1
- package/lib-esm/predicates/index.js +40 -7
- package/lib-esm/predicates/next.d.ts +2 -2
- package/lib-esm/predicates/next.js +148 -52
- package/lib-esm/predicates/sort.js +2 -4
- package/lib-esm/ssr/index.js +0 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js +203 -95
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js +66 -5
- package/lib-esm/storage/adapter/InMemoryStore.js +52 -2
- package/lib-esm/storage/adapter/InMemoryStore.native.js +0 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +271 -138
- package/lib-esm/storage/adapter/StorageAdapterBase.js +130 -62
- package/lib-esm/storage/adapter/getDefaultAdapter/index.js +2 -5
- package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js +0 -1
- package/lib-esm/storage/adapter/index.js +1 -1
- package/lib-esm/storage/relationship.js +27 -18
- package/lib-esm/storage/storage.d.ts +3 -3
- package/lib-esm/storage/storage.js +87 -9
- package/lib-esm/sync/datastoreConnectivity.d.ts +1 -1
- package/lib-esm/sync/datastoreConnectivity.js +48 -3
- package/lib-esm/sync/datastoreReachability/index.js +1 -2
- package/lib-esm/sync/datastoreReachability/index.native.js +1 -2
- package/lib-esm/sync/index.d.ts +1 -1
- package/lib-esm/sync/index.js +136 -72
- package/lib-esm/sync/merger.js +73 -3
- package/lib-esm/sync/outbox.js +75 -5
- package/lib-esm/sync/processors/errorMaps.d.ts +1 -1
- package/lib-esm/sync/processors/errorMaps.js +39 -5
- package/lib-esm/sync/processors/mutation.d.ts +1 -1
- package/lib-esm/sync/processors/mutation.js +130 -44
- package/lib-esm/sync/processors/subscription.d.ts +4 -1
- package/lib-esm/sync/processors/subscription.js +134 -126
- package/lib-esm/sync/processors/sync.d.ts +1 -1
- package/lib-esm/sync/processors/sync.js +74 -12
- package/lib-esm/sync/utils.d.ts +4 -4
- package/lib-esm/sync/utils.js +135 -55
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types.d.ts +138 -140
- package/lib-esm/types.js +36 -2
- package/lib-esm/util.d.ts +9 -17
- package/lib-esm/util.js +96 -16
- package/package.json +139 -132
- package/src/authModeStrategies/multiAuthStrategy.ts +11 -12
- package/src/datastore/datastore.ts +32 -25
- package/src/predicates/sort.ts +3 -1
- package/src/storage/adapter/InMemoryStore.ts +1 -1
- package/src/storage/adapter/IndexedDBAdapter.ts +1 -1
- package/src/storage/adapter/StorageAdapterBase.ts +1 -1
- package/src/storage/adapter/getDefaultAdapter/index.ts +2 -3
- package/src/storage/storage.ts +1 -1
- package/src/sync/datastoreConnectivity.ts +2 -2
- package/src/sync/datastoreReachability/index.native.ts +1 -1
- package/src/sync/datastoreReachability/index.ts +1 -1
- package/src/sync/index.ts +69 -78
- package/src/sync/processors/mutation.ts +16 -10
- package/src/sync/processors/subscription.ts +55 -127
- package/src/sync/processors/sync.ts +8 -4
- package/src/sync/utils.ts +7 -8
- package/src/types.ts +4 -8
- package/src/util.ts +5 -6
- package/lib/.tsbuildinfo +0 -3
- package/lib/authModeStrategies/defaultAuthStrategy.js.map +0 -1
- package/lib/authModeStrategies/index.js.map +0 -1
- package/lib/authModeStrategies/multiAuthStrategy.js.map +0 -1
- package/lib/datastore/datastore.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/predicates/index.js.map +0 -1
- package/lib/predicates/next.js.map +0 -1
- package/lib/predicates/sort.js.map +0 -1
- package/lib/ssr/index.js.map +0 -1
- package/lib/storage/adapter/AsyncStorageAdapter.js.map +0 -1
- package/lib/storage/adapter/AsyncStorageDatabase.js.map +0 -1
- package/lib/storage/adapter/InMemoryStore.js.map +0 -1
- package/lib/storage/adapter/InMemoryStore.native.js.map +0 -1
- package/lib/storage/adapter/IndexedDBAdapter.js.map +0 -1
- package/lib/storage/adapter/StorageAdapterBase.js.map +0 -1
- package/lib/storage/adapter/getDefaultAdapter/index.js.map +0 -1
- package/lib/storage/adapter/getDefaultAdapter/index.native.js.map +0 -1
- package/lib/storage/adapter/index.js.map +0 -1
- package/lib/storage/relationship.js.map +0 -1
- package/lib/storage/storage.js.map +0 -1
- package/lib/sync/datastoreConnectivity.js.map +0 -1
- package/lib/sync/datastoreReachability/index.js.map +0 -1
- package/lib/sync/datastoreReachability/index.native.js.map +0 -1
- package/lib/sync/index.js.map +0 -1
- package/lib/sync/merger.js.map +0 -1
- package/lib/sync/outbox.js.map +0 -1
- package/lib/sync/processors/errorMaps.js.map +0 -1
- package/lib/sync/processors/mutation.js.map +0 -1
- package/lib/sync/processors/subscription.js.map +0 -1
- package/lib/sync/processors/sync.js.map +0 -1
- package/lib/sync/utils.js.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/util.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/authModeStrategies/defaultAuthStrategy.js.map +0 -1
- package/lib-esm/authModeStrategies/index.js.map +0 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +0 -1
- package/lib-esm/datastore/datastore.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/predicates/index.js.map +0 -1
- package/lib-esm/predicates/next.js.map +0 -1
- package/lib-esm/predicates/sort.js.map +0 -1
- package/lib-esm/ssr/index.js.map +0 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +0 -1
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +0 -1
- package/lib-esm/storage/adapter/InMemoryStore.js.map +0 -1
- package/lib-esm/storage/adapter/InMemoryStore.native.js.map +0 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +0 -1
- package/lib-esm/storage/adapter/StorageAdapterBase.js.map +0 -1
- package/lib-esm/storage/adapter/getDefaultAdapter/index.js.map +0 -1
- package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js.map +0 -1
- package/lib-esm/storage/adapter/index.js.map +0 -1
- package/lib-esm/storage/relationship.js.map +0 -1
- package/lib-esm/storage/storage.js.map +0 -1
- package/lib-esm/sync/datastoreConnectivity.js.map +0 -1
- package/lib-esm/sync/datastoreReachability/index.js.map +0 -1
- package/lib-esm/sync/datastoreReachability/index.native.js.map +0 -1
- package/lib-esm/sync/index.js.map +0 -1
- package/lib-esm/sync/merger.js.map +0 -1
- package/lib-esm/sync/outbox.js.map +0 -1
- package/lib-esm/sync/processors/errorMaps.js.map +0 -1
- package/lib-esm/sync/processors/mutation.js.map +0 -1
- package/lib-esm/sync/processors/subscription.js.map +0 -1
- package/lib-esm/sync/processors/sync.js.map +0 -1
- package/lib-esm/sync/utils.js.map +0 -1
- package/lib-esm/types.js.map +0 -1
- package/lib-esm/util.js.map +0 -1
|
@@ -1,4 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
+
if (ar || !(i in from)) {
|
|
31
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
+
ar[i] = from[i];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
+
};
|
|
2
37
|
import { extractPrimaryKeyFieldNames, extractPrimaryKeyValues } from '../util';
|
|
3
38
|
export { ModelSortPredicateCreator } from './sort';
|
|
4
39
|
var predicatesAllSet = new WeakSet();
|
|
@@ -23,7 +58,7 @@ var groupKeys = new Set(['and', 'or', 'not']);
|
|
|
23
58
|
* @param o The object to test.
|
|
24
59
|
*/
|
|
25
60
|
var isGroup = function (o) {
|
|
26
|
-
var keys =
|
|
61
|
+
var keys = __spreadArray([], __read(Object.keys(o)), false);
|
|
27
62
|
return keys.length === 1 && groupKeys.has(keys[0]);
|
|
28
63
|
};
|
|
29
64
|
/**
|
|
@@ -58,7 +93,7 @@ export var comparisonKeys = new Set([
|
|
|
58
93
|
* @param o The object to test.
|
|
59
94
|
*/
|
|
60
95
|
var isComparison = function (o) {
|
|
61
|
-
var keys =
|
|
96
|
+
var keys = __spreadArray([], __read(Object.keys(o)), false);
|
|
62
97
|
return !Array.isArray(o) && keys.length === 1 && comparisonKeys.has(keys[0]);
|
|
63
98
|
};
|
|
64
99
|
/**
|
|
@@ -85,13 +120,13 @@ var Predicates = /** @class */ (function () {
|
|
|
85
120
|
predicatesAllSet.add(predicate);
|
|
86
121
|
return predicate;
|
|
87
122
|
},
|
|
88
|
-
enumerable:
|
|
123
|
+
enumerable: false,
|
|
89
124
|
configurable: true
|
|
90
125
|
});
|
|
91
126
|
return Predicates;
|
|
92
127
|
}());
|
|
93
128
|
export { Predicates };
|
|
94
|
-
var ModelPredicateCreator = /** @class */ (function () {
|
|
129
|
+
export var ModelPredicateCreator = /** @class */ (function () {
|
|
95
130
|
function ModelPredicateCreator() {
|
|
96
131
|
}
|
|
97
132
|
/**
|
|
@@ -250,5 +285,3 @@ var ModelPredicateCreator = /** @class */ (function () {
|
|
|
250
285
|
ModelPredicateCreator.predicateGroupsMap = new WeakMap();
|
|
251
286
|
return ModelPredicateCreator;
|
|
252
287
|
}());
|
|
253
|
-
export { ModelPredicateCreator };
|
|
254
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PersistentModel, ModelMeta, ModelPredicate as StoragePredicate, PredicateInternalsKey, V5ModelPredicate as ModelPredicate, RecursiveModelPredicate } from '../types';
|
|
2
2
|
import { ExclusiveStorage as StorageAdapter } from '../storage/storage';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
type GroupOperator = 'and' | 'or' | 'not';
|
|
4
|
+
type UntypedCondition = {
|
|
5
5
|
fetch: (storage: StorageAdapter) => Promise<Record<string, any>[]>;
|
|
6
6
|
matches: (item: Record<string, any>) => Promise<boolean>;
|
|
7
7
|
copy(extract?: GroupCondition): [UntypedCondition, GroupCondition | undefined];
|
|
@@ -1,11 +1,100 @@
|
|
|
1
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
49
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
50
|
+
var m = o[Symbol.asyncIterator], i;
|
|
51
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
52
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
53
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
54
|
+
};
|
|
55
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
56
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
57
|
+
if (!m) return o;
|
|
58
|
+
var i = m.call(o), r, ar = [], e;
|
|
59
|
+
try {
|
|
60
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
61
|
+
}
|
|
62
|
+
catch (error) { e = { error: error }; }
|
|
63
|
+
finally {
|
|
64
|
+
try {
|
|
65
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
66
|
+
}
|
|
67
|
+
finally { if (e) throw e.error; }
|
|
68
|
+
}
|
|
69
|
+
return ar;
|
|
70
|
+
};
|
|
71
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
72
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
73
|
+
if (ar || !(i in from)) {
|
|
74
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
75
|
+
ar[i] = from[i];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
79
|
+
};
|
|
80
|
+
var __values = (this && this.__values) || function(o) {
|
|
81
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
82
|
+
if (m) return m.call(o);
|
|
83
|
+
if (o && typeof o.length === "number") return {
|
|
84
|
+
next: function () {
|
|
85
|
+
if (o && i >= o.length) o = void 0;
|
|
86
|
+
return { value: o && o[i++], done: !o };
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
90
|
+
};
|
|
2
91
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
92
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
93
|
import { PredicateInternalsKey, } from '../types';
|
|
5
94
|
import { ModelPredicateCreator as FlatModelPredicateCreator, comparisonKeys, } from './index';
|
|
6
95
|
import { ModelRelationship } from '../storage/relationship';
|
|
7
96
|
import { asyncSome, asyncEvery } from '../util';
|
|
8
|
-
var ops =
|
|
97
|
+
var ops = __spreadArray([], __read(comparisonKeys), false);
|
|
9
98
|
/**
|
|
10
99
|
* A map from keys (exposed to customers) to the internal predicate data
|
|
11
100
|
* structures invoking code should not muck with.
|
|
@@ -79,7 +168,7 @@ var FieldCondition = /** @class */ (function () {
|
|
|
79
168
|
*/
|
|
80
169
|
FieldCondition.prototype.copy = function (extract) {
|
|
81
170
|
return [
|
|
82
|
-
new FieldCondition(this.field, this.operator,
|
|
171
|
+
new FieldCondition(this.field, this.operator, __spreadArray([], __read(this.operands), false)),
|
|
83
172
|
undefined,
|
|
84
173
|
];
|
|
85
174
|
};
|
|
@@ -186,7 +275,7 @@ var FieldCondition = /** @class */ (function () {
|
|
|
186
275
|
return [2 /*return*/, result];
|
|
187
276
|
}
|
|
188
277
|
else {
|
|
189
|
-
throw new Error("Invalid operator given: "
|
|
278
|
+
throw new Error("Invalid operator given: ".concat(this.operator));
|
|
190
279
|
}
|
|
191
280
|
return [2 /*return*/];
|
|
192
281
|
});
|
|
@@ -206,7 +295,7 @@ var FieldCondition = /** @class */ (function () {
|
|
|
206
295
|
var argsClause = count === 1 ? 'argument is' : 'arguments are';
|
|
207
296
|
return function () {
|
|
208
297
|
if (_this.operands.length !== count) {
|
|
209
|
-
return "Exactly "
|
|
298
|
+
return "Exactly ".concat(count, " ").concat(argsClause, " required.");
|
|
210
299
|
}
|
|
211
300
|
};
|
|
212
301
|
};
|
|
@@ -234,10 +323,10 @@ var FieldCondition = /** @class */ (function () {
|
|
|
234
323
|
if (validate) {
|
|
235
324
|
var e = validate();
|
|
236
325
|
if (typeof e === 'string')
|
|
237
|
-
throw new Error("Incorrect usage of `"
|
|
326
|
+
throw new Error("Incorrect usage of `".concat(this.operator, "()`: ").concat(e));
|
|
238
327
|
}
|
|
239
328
|
else {
|
|
240
|
-
throw new Error("Non-existent operator: `"
|
|
329
|
+
throw new Error("Non-existent operator: `".concat(this.operator, "()`"));
|
|
241
330
|
}
|
|
242
331
|
};
|
|
243
332
|
return FieldCondition;
|
|
@@ -250,7 +339,7 @@ export { FieldCondition };
|
|
|
250
339
|
*/
|
|
251
340
|
var getGroupId = (function () {
|
|
252
341
|
var seed = 1;
|
|
253
|
-
return function () { return "group_"
|
|
342
|
+
return function () { return "group_".concat(seed++); };
|
|
254
343
|
})();
|
|
255
344
|
/**
|
|
256
345
|
* A set of sub-conditions to operate against a model, optionally scoped to
|
|
@@ -454,7 +543,7 @@ var GroupCondition = /** @class */ (function () {
|
|
|
454
543
|
case 2:
|
|
455
544
|
if (!!groups_1_1.done) return [3 /*break*/, 9];
|
|
456
545
|
g = groups_1_1.value;
|
|
457
|
-
return [4 /*yield*/, g.fetch(storage,
|
|
546
|
+
return [4 /*yield*/, g.fetch(storage, __spreadArray(__spreadArray([], __read(breadcrumb), false), [this.groupId], false), negateChildren)];
|
|
458
547
|
case 3:
|
|
459
548
|
relatives = _r.sent();
|
|
460
549
|
// no relatives -> no need to attempt to perform a "join" query for
|
|
@@ -643,23 +732,23 @@ var GroupCondition = /** @class */ (function () {
|
|
|
643
732
|
* @returns A boolean (promise): `true` if matched, `false` otherwise.
|
|
644
733
|
*/
|
|
645
734
|
GroupCondition.prototype.matches = function (item, ignoreFieldName) {
|
|
735
|
+
var _a, e_7, _b, _c;
|
|
646
736
|
if (ignoreFieldName === void 0) { ignoreFieldName = false; }
|
|
647
|
-
var e_7, _a;
|
|
648
737
|
return __awaiter(this, void 0, void 0, function () {
|
|
649
|
-
var itemToCheck,
|
|
650
|
-
return __generator(this, function (
|
|
651
|
-
switch (
|
|
738
|
+
var itemToCheck, _d, _e, itemToCheck_1, itemToCheck_1_1, singleItem, e_7_1;
|
|
739
|
+
return __generator(this, function (_f) {
|
|
740
|
+
switch (_f.label) {
|
|
652
741
|
case 0:
|
|
653
742
|
if (!(this.field && !ignoreFieldName)) return [3 /*break*/, 2];
|
|
654
743
|
return [4 /*yield*/, item[this.field]];
|
|
655
744
|
case 1:
|
|
656
|
-
|
|
745
|
+
_d = _f.sent();
|
|
657
746
|
return [3 /*break*/, 3];
|
|
658
747
|
case 2:
|
|
659
|
-
|
|
660
|
-
|
|
748
|
+
_d = item;
|
|
749
|
+
_f.label = 3;
|
|
661
750
|
case 3:
|
|
662
|
-
itemToCheck =
|
|
751
|
+
itemToCheck = _d;
|
|
663
752
|
// if there is no item to check, we can stop recursing immediately.
|
|
664
753
|
// a condition cannot match against an item that does not exist. this
|
|
665
754
|
// can occur when `item.field` is optional in the schema.
|
|
@@ -667,55 +756,63 @@ var GroupCondition = /** @class */ (function () {
|
|
|
667
756
|
return [2 /*return*/, false];
|
|
668
757
|
}
|
|
669
758
|
if (!(this.relationshipType === 'HAS_MANY' &&
|
|
670
|
-
typeof itemToCheck[Symbol.asyncIterator] === 'function')) return [3 /*break*/,
|
|
671
|
-
|
|
759
|
+
typeof itemToCheck[Symbol.asyncIterator] === 'function')) return [3 /*break*/, 19];
|
|
760
|
+
_f.label = 4;
|
|
672
761
|
case 4:
|
|
673
|
-
|
|
674
|
-
itemToCheck_1 = __asyncValues(itemToCheck);
|
|
675
|
-
|
|
762
|
+
_f.trys.push([4, 12, 13, 18]);
|
|
763
|
+
_e = true, itemToCheck_1 = __asyncValues(itemToCheck);
|
|
764
|
+
_f.label = 5;
|
|
676
765
|
case 5: return [4 /*yield*/, itemToCheck_1.next()];
|
|
677
766
|
case 6:
|
|
678
|
-
if (!(itemToCheck_1_1 =
|
|
679
|
-
|
|
680
|
-
|
|
767
|
+
if (!(itemToCheck_1_1 = _f.sent(), _a = itemToCheck_1_1.done, !_a)) return [3 /*break*/, 11];
|
|
768
|
+
_c = itemToCheck_1_1.value;
|
|
769
|
+
_e = false;
|
|
770
|
+
_f.label = 7;
|
|
681
771
|
case 7:
|
|
682
|
-
|
|
772
|
+
_f.trys.push([7, , 9, 10]);
|
|
773
|
+
singleItem = _c;
|
|
774
|
+
return [4 /*yield*/, this.matches(singleItem, true)];
|
|
775
|
+
case 8:
|
|
776
|
+
if (_f.sent()) {
|
|
683
777
|
return [2 /*return*/, true];
|
|
684
778
|
}
|
|
685
|
-
|
|
686
|
-
case
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
return [3 /*break*/, 16];
|
|
692
|
-
case 11:
|
|
693
|
-
_c.trys.push([11, , 14, 15]);
|
|
694
|
-
if (!(itemToCheck_1_1 && !itemToCheck_1_1.done && (_a = itemToCheck_1.return))) return [3 /*break*/, 13];
|
|
695
|
-
return [4 /*yield*/, _a.call(itemToCheck_1)];
|
|
779
|
+
return [3 /*break*/, 10];
|
|
780
|
+
case 9:
|
|
781
|
+
_e = true;
|
|
782
|
+
return [7 /*endfinally*/];
|
|
783
|
+
case 10: return [3 /*break*/, 5];
|
|
784
|
+
case 11: return [3 /*break*/, 18];
|
|
696
785
|
case 12:
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
786
|
+
e_7_1 = _f.sent();
|
|
787
|
+
e_7 = { error: e_7_1 };
|
|
788
|
+
return [3 /*break*/, 18];
|
|
789
|
+
case 13:
|
|
790
|
+
_f.trys.push([13, , 16, 17]);
|
|
791
|
+
if (!(!_e && !_a && (_b = itemToCheck_1.return))) return [3 /*break*/, 15];
|
|
792
|
+
return [4 /*yield*/, _b.call(itemToCheck_1)];
|
|
700
793
|
case 14:
|
|
794
|
+
_f.sent();
|
|
795
|
+
_f.label = 15;
|
|
796
|
+
case 15: return [3 /*break*/, 17];
|
|
797
|
+
case 16:
|
|
701
798
|
if (e_7) throw e_7.error;
|
|
702
799
|
return [7 /*endfinally*/];
|
|
703
|
-
case
|
|
704
|
-
case
|
|
705
|
-
case
|
|
706
|
-
if (!(this.operator === 'or')) return [3 /*break*/,
|
|
800
|
+
case 17: return [7 /*endfinally*/];
|
|
801
|
+
case 18: return [2 /*return*/, false];
|
|
802
|
+
case 19:
|
|
803
|
+
if (!(this.operator === 'or')) return [3 /*break*/, 20];
|
|
707
804
|
return [2 /*return*/, asyncSome(this.operands, function (c) { return c.matches(itemToCheck); })];
|
|
708
|
-
case
|
|
709
|
-
if (!(this.operator === 'and')) return [3 /*break*/,
|
|
805
|
+
case 20:
|
|
806
|
+
if (!(this.operator === 'and')) return [3 /*break*/, 21];
|
|
710
807
|
return [2 /*return*/, asyncEvery(this.operands, function (c) { return c.matches(itemToCheck); })];
|
|
711
|
-
case
|
|
712
|
-
if (!(this.operator === 'not')) return [3 /*break*/,
|
|
808
|
+
case 21:
|
|
809
|
+
if (!(this.operator === 'not')) return [3 /*break*/, 23];
|
|
713
810
|
if (this.operands.length !== 1) {
|
|
714
811
|
throw new Error('Invalid arguments! `not()` accepts exactly one predicate expression.');
|
|
715
812
|
}
|
|
716
813
|
return [4 /*yield*/, this.operands[0].matches(itemToCheck)];
|
|
717
|
-
case
|
|
718
|
-
case
|
|
814
|
+
case 22: return [2 /*return*/, !(_f.sent())];
|
|
815
|
+
case 23: throw new Error('Invalid group operator!');
|
|
719
816
|
}
|
|
720
817
|
});
|
|
721
818
|
});
|
|
@@ -800,7 +897,7 @@ export function recursivePredicateFor(ModelType, allowRecursion, field, query, t
|
|
|
800
897
|
var _a = copyLink(), query = _a.query, newTail = _a.newTail;
|
|
801
898
|
var childConditions = builder(recursivePredicateFor(ModelType, allowRecursion));
|
|
802
899
|
if (!Array.isArray(childConditions)) {
|
|
803
|
-
throw new Error("Invalid predicate. `"
|
|
900
|
+
throw new Error("Invalid predicate. `".concat(op, "` groups must return an array of child conditions."));
|
|
804
901
|
}
|
|
805
902
|
// the customer will supply a child predicate, which apply to the `model.field`
|
|
806
903
|
// of the tail GroupCondition.
|
|
@@ -905,4 +1002,3 @@ export function predicateFor(ModelType) {
|
|
|
905
1002
|
// the recursive type.
|
|
906
1003
|
return recursivePredicateFor(ModelType, false);
|
|
907
1004
|
}
|
|
908
|
-
//# sourceMappingURL=next.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ModelSortPredicateCreator = /** @class */ (function () {
|
|
1
|
+
export var ModelSortPredicateCreator = /** @class */ (function () {
|
|
2
2
|
function ModelSortPredicateCreator() {
|
|
3
3
|
}
|
|
4
4
|
ModelSortPredicateCreator.createPredicateBuilder = function (modelDefinition) {
|
|
@@ -9,7 +9,7 @@ var ModelSortPredicateCreator = /** @class */ (function () {
|
|
|
9
9
|
get: function (_target, propertyKey, receiver) {
|
|
10
10
|
var field = propertyKey;
|
|
11
11
|
if (!fieldNames.has(field)) {
|
|
12
|
-
throw new Error("Invalid field for model. field: "
|
|
12
|
+
throw new Error("Invalid field for model. field: ".concat(String(field), ", model: ").concat(modelName));
|
|
13
13
|
}
|
|
14
14
|
var result = function (sortDirection) {
|
|
15
15
|
var _a;
|
|
@@ -50,5 +50,3 @@ var ModelSortPredicateCreator = /** @class */ (function () {
|
|
|
50
50
|
ModelSortPredicateCreator.sortPredicateGroupsMap = new WeakMap();
|
|
51
51
|
return ModelSortPredicateCreator;
|
|
52
52
|
}());
|
|
53
|
-
export { ModelSortPredicateCreator };
|
|
54
|
-
//# sourceMappingURL=sort.js.map
|
package/lib-esm/ssr/index.js
CHANGED