@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,10 +1,123 @@
|
|
|
1
|
-
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
28
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
31
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
32
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
37
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
38
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
39
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
40
|
+
function step(op) {
|
|
41
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
42
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
43
|
+
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;
|
|
44
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
45
|
+
switch (op[0]) {
|
|
46
|
+
case 0: case 1: t = op; break;
|
|
47
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
48
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
49
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
50
|
+
default:
|
|
51
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
52
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
53
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
54
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
55
|
+
if (t[2]) _.ops.pop();
|
|
56
|
+
_.trys.pop(); continue;
|
|
57
|
+
}
|
|
58
|
+
op = body.call(thisArg, _);
|
|
59
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
60
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
64
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
65
|
+
var m = o[Symbol.asyncIterator], i;
|
|
66
|
+
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);
|
|
67
|
+
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); }); }; }
|
|
68
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
69
|
+
};
|
|
70
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
71
|
+
var t = {};
|
|
72
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
73
|
+
t[p] = s[p];
|
|
74
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
75
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
76
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
77
|
+
t[p[i]] = s[p[i]];
|
|
78
|
+
}
|
|
79
|
+
return t;
|
|
80
|
+
};
|
|
81
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
82
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
83
|
+
if (!m) return o;
|
|
84
|
+
var i = m.call(o), r, ar = [], e;
|
|
85
|
+
try {
|
|
86
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
87
|
+
}
|
|
88
|
+
catch (error) { e = { error: error }; }
|
|
89
|
+
finally {
|
|
90
|
+
try {
|
|
91
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
92
|
+
}
|
|
93
|
+
finally { if (e) throw e.error; }
|
|
94
|
+
}
|
|
95
|
+
return ar;
|
|
96
|
+
};
|
|
97
|
+
var __values = (this && this.__values) || function(o) {
|
|
98
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
99
|
+
if (m) return m.call(o);
|
|
100
|
+
if (o && typeof o.length === "number") return {
|
|
101
|
+
next: function () {
|
|
102
|
+
if (o && i >= o.length) o = void 0;
|
|
103
|
+
return { value: o && o[i++], done: !o };
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
107
|
+
};
|
|
108
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
109
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
110
|
+
if (ar || !(i in from)) {
|
|
111
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
112
|
+
ar[i] = from[i];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
116
|
+
};
|
|
2
117
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
118
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
119
|
import { InternalAPI } from '@aws-amplify/api/internals';
|
|
5
|
-
import {
|
|
6
|
-
import { Cache } from '@aws-amplify/cache';
|
|
7
|
-
import { Amplify, ConsoleLogger as Logger, Hub, browserOrNode, BackgroundProcessManager, } from '@aws-amplify/core';
|
|
120
|
+
import { Amplify, Hub, Cache } from '@aws-amplify/core';
|
|
8
121
|
import { immerable, produce, setAutoFreeze, enablePatches, } from 'immer';
|
|
9
122
|
import { v4 as uuid4 } from 'uuid';
|
|
10
123
|
import Observable from 'zen-observable-ts';
|
|
@@ -17,11 +130,11 @@ import { GraphQLScalarType, isGraphQLScalarType, isSchemaModelWithAttributes, Au
|
|
|
17
130
|
import { DATASTORE, errorMessages, establishRelationAndKeys, isModelConstructor, monotonicUlidFactory, STORAGE, SYNC, USER, isNullOrUndefined, registerNonModelClass, sortCompareFunction, DeferredCallbackResolver, inMemoryPagination, extractPrimaryKeyFieldNames, extractPrimaryKeysAndValues, isIdManaged, isIdOptionallyManaged, mergePatches, getTimestampFields, } from '../util';
|
|
18
131
|
import { recursivePredicateFor, predicateFor, internals, } from '../predicates/next';
|
|
19
132
|
import { getIdentifierValue } from '../sync/utils';
|
|
133
|
+
import { BackgroundProcessManager, Logger, } from '@aws-amplify/core/internals/utils';
|
|
20
134
|
setAutoFreeze(true);
|
|
21
135
|
enablePatches();
|
|
22
136
|
var logger = new Logger('DataStore');
|
|
23
137
|
var ulid = monotonicUlidFactory(Date.now());
|
|
24
|
-
var isNode = browserOrNode().isNode;
|
|
25
138
|
var SETTING_SCHEMA_VERSION = 'schemaVersion';
|
|
26
139
|
var schema;
|
|
27
140
|
var modelNamespaceMap = new WeakMap();
|
|
@@ -51,7 +164,7 @@ var isValidModelConstructor = function (obj) {
|
|
|
51
164
|
var namespaceResolver = function (modelConstructor) {
|
|
52
165
|
var resolver = modelNamespaceMap.get(modelConstructor);
|
|
53
166
|
if (!resolver) {
|
|
54
|
-
throw new Error("Namespace Resolver for '"
|
|
167
|
+
throw new Error("Namespace Resolver for '".concat(modelConstructor.name, "' not found! This is probably a bug in '@amplify-js/datastore'."));
|
|
55
168
|
}
|
|
56
169
|
return resolver;
|
|
57
170
|
};
|
|
@@ -215,7 +328,7 @@ var initSchema = function (userSchema) {
|
|
|
215
328
|
get: function () {
|
|
216
329
|
var relatedModelDefinition = getModelDefinition(relatedModel);
|
|
217
330
|
if (!relatedModelDefinition)
|
|
218
|
-
throw new Error("Could not find model definition for "
|
|
331
|
+
throw new Error("Could not find model definition for ".concat(relatedModel.name));
|
|
219
332
|
return {
|
|
220
333
|
builder: relatedModel,
|
|
221
334
|
schema: relatedModelDefinition,
|
|
@@ -255,7 +368,7 @@ var initSchema = function (userSchema) {
|
|
|
255
368
|
}
|
|
256
369
|
finally { if (e_2) throw e_2.error; }
|
|
257
370
|
}
|
|
258
|
-
model.allFields = __assign(__assign({}, Object.fromEntries(
|
|
371
|
+
model.allFields = __assign(__assign({}, Object.fromEntries(__spreadArray([], __read(indexFields.values()), false).map(function (name) { return [
|
|
259
372
|
name,
|
|
260
373
|
{
|
|
261
374
|
name: name,
|
|
@@ -340,10 +453,10 @@ var checkSchemaCodegenVersion = function (codegenVersion) {
|
|
|
340
453
|
isValid = Number(major) === majorVersion && Number(minor) >= minorVersion;
|
|
341
454
|
}
|
|
342
455
|
catch (err) {
|
|
343
|
-
console.log("Error parsing codegen version: "
|
|
456
|
+
console.log("Error parsing codegen version: ".concat(codegenVersion, "\n").concat(err));
|
|
344
457
|
}
|
|
345
458
|
if (!isValid) {
|
|
346
|
-
var message = "Models were generated with an unsupported version of codegen. Codegen artifacts are from "
|
|
459
|
+
var message = "Models were generated with an unsupported version of codegen. Codegen artifacts are from ".concat(codegenVersion || 'an unknown version', ", whereas ^").concat(majorVersion, ".").concat(minorVersion, ".0 is required. ") +
|
|
347
460
|
"Update to the latest CLI and run 'amplify codegen models'.";
|
|
348
461
|
logger.error(message);
|
|
349
462
|
throw new Error(message);
|
|
@@ -385,7 +498,7 @@ var validateModelFields = function (modelDefinition) { return function (k, v) {
|
|
|
385
498
|
if (((!isArray && isRequired_1) || (isArray && !isArrayNullable)) &&
|
|
386
499
|
!isTimestampField &&
|
|
387
500
|
(v === null || v === undefined)) {
|
|
388
|
-
throw new Error("Field "
|
|
501
|
+
throw new Error("Field ".concat(name_1, " is required"));
|
|
389
502
|
}
|
|
390
503
|
if (isSchemaModelWithAttributes(modelDefinition) &&
|
|
391
504
|
!isIdManaged(modelDefinition)) {
|
|
@@ -408,17 +521,17 @@ var validateModelFields = function (modelDefinition) { return function (k, v) {
|
|
|
408
521
|
return;
|
|
409
522
|
}
|
|
410
523
|
catch (error) {
|
|
411
|
-
throw new Error("Field "
|
|
524
|
+
throw new Error("Field ".concat(name_1, " is an invalid JSON object. ").concat(v));
|
|
412
525
|
}
|
|
413
526
|
}
|
|
414
527
|
}
|
|
415
528
|
if (isArray) {
|
|
416
529
|
var errorTypeText = jsType_1;
|
|
417
530
|
if (!isRequired_1) {
|
|
418
|
-
errorTypeText = jsType_1
|
|
531
|
+
errorTypeText = "".concat(jsType_1, " | null | undefined");
|
|
419
532
|
}
|
|
420
533
|
if (!Array.isArray(v) && !isArrayNullable) {
|
|
421
|
-
throw new Error("Field "
|
|
534
|
+
throw new Error("Field ".concat(name_1, " should be of type [").concat(errorTypeText, "], ").concat(typeof v, " received. ").concat(v));
|
|
422
535
|
}
|
|
423
536
|
if (!isNullOrUndefined(v) &&
|
|
424
537
|
v.some(function (e) {
|
|
@@ -427,7 +540,7 @@ var validateModelFields = function (modelDefinition) { return function (k, v) {
|
|
|
427
540
|
var elemTypes = v
|
|
428
541
|
.map(function (e) { return (e === null ? 'null' : typeof e); })
|
|
429
542
|
.join(',');
|
|
430
|
-
throw new Error("All elements in the "
|
|
543
|
+
throw new Error("All elements in the ".concat(name_1, " array should be of type ").concat(errorTypeText, ", [").concat(elemTypes, "] received. ").concat(v));
|
|
431
544
|
}
|
|
432
545
|
if (validateScalar_1 && !isNullOrUndefined(v)) {
|
|
433
546
|
var validationStatus = v.map(function (e) {
|
|
@@ -442,7 +555,7 @@ var validateModelFields = function (modelDefinition) { return function (k, v) {
|
|
|
442
555
|
}
|
|
443
556
|
});
|
|
444
557
|
if (!validationStatus.every(function (s) { return s; })) {
|
|
445
|
-
throw new Error("All elements in the "
|
|
558
|
+
throw new Error("All elements in the ".concat(name_1, " array should be of type ").concat(type_1, ", validation failed for one or more elements. ").concat(v));
|
|
446
559
|
}
|
|
447
560
|
}
|
|
448
561
|
}
|
|
@@ -450,13 +563,13 @@ var validateModelFields = function (modelDefinition) { return function (k, v) {
|
|
|
450
563
|
return;
|
|
451
564
|
}
|
|
452
565
|
else if (typeof v !== jsType_1 && v !== null) {
|
|
453
|
-
throw new Error("Field "
|
|
566
|
+
throw new Error("Field ".concat(name_1, " should be of type ").concat(jsType_1, ", ").concat(typeof v, " received. ").concat(v));
|
|
454
567
|
}
|
|
455
568
|
else if (!isNullOrUndefined(v) &&
|
|
456
569
|
validateScalar_1 &&
|
|
457
570
|
!validateScalar_1(v) // TODO: why never, TS ... why ...
|
|
458
571
|
) {
|
|
459
|
-
throw new Error("Field "
|
|
572
|
+
throw new Error("Field ".concat(name_1, " should be of type ").concat(type_1, ", validation failed. ").concat(v));
|
|
460
573
|
}
|
|
461
574
|
}
|
|
462
575
|
else if (isNonModelFieldType(type_1)) {
|
|
@@ -467,15 +580,15 @@ var validateModelFields = function (modelDefinition) { return function (k, v) {
|
|
|
467
580
|
if (isArray) {
|
|
468
581
|
var errorTypeText = type_1.nonModel;
|
|
469
582
|
if (!isRequired_1) {
|
|
470
|
-
errorTypeText = type_1.nonModel
|
|
583
|
+
errorTypeText = "".concat(type_1.nonModel, " | null | undefined");
|
|
471
584
|
}
|
|
472
585
|
if (!Array.isArray(v)) {
|
|
473
|
-
throw new Error("Field "
|
|
586
|
+
throw new Error("Field ".concat(name_1, " should be of type [").concat(errorTypeText, "], ").concat(typeof v, " received. ").concat(v));
|
|
474
587
|
}
|
|
475
588
|
v.forEach(function (item) {
|
|
476
589
|
if ((isNullOrUndefined(item) && isRequired_1) ||
|
|
477
590
|
(typeof item !== 'object' && typeof item !== 'undefined')) {
|
|
478
|
-
throw new Error("All elements in the "
|
|
591
|
+
throw new Error("All elements in the ".concat(name_1, " array should be of type ").concat(type_1.nonModel, ", [").concat(typeof item, "] received. ").concat(item));
|
|
479
592
|
}
|
|
480
593
|
if (!isNullOrUndefined(item)) {
|
|
481
594
|
Object.keys(subNonModelDefinition_1.fields).forEach(function (subKey) {
|
|
@@ -486,7 +599,7 @@ var validateModelFields = function (modelDefinition) { return function (k, v) {
|
|
|
486
599
|
}
|
|
487
600
|
else {
|
|
488
601
|
if (typeof v !== 'object') {
|
|
489
|
-
throw new Error("Field "
|
|
602
|
+
throw new Error("Field ".concat(name_1, " should be of type ").concat(type_1.nonModel, ", ").concat(typeof v, " recieved. ").concat(v));
|
|
490
603
|
}
|
|
491
604
|
Object.keys(subNonModelDefinition_1.fields).forEach(function (subKey) {
|
|
492
605
|
modelValidator_1(subKey, v[subKey]);
|
|
@@ -640,7 +753,7 @@ var createModelClass = function (modelDefinition) {
|
|
|
640
753
|
// Keys are immutable
|
|
641
754
|
keyNames.forEach(function (key) {
|
|
642
755
|
if (draft[key] !== source[key]) {
|
|
643
|
-
logger.warn("copyOf() does not update PK fields. The '"
|
|
756
|
+
logger.warn("copyOf() does not update PK fields. The '".concat(key, "' update is being ignored."), { source: source });
|
|
644
757
|
}
|
|
645
758
|
draft[key] = source[key];
|
|
646
759
|
});
|
|
@@ -718,13 +831,13 @@ var createModelClass = function (modelDefinition) {
|
|
|
718
831
|
var modelConstructor = Object.getPrototypeOf(model || {})
|
|
719
832
|
.constructor;
|
|
720
833
|
if (!isValidModelConstructor(modelConstructor)) {
|
|
721
|
-
var msg = "Value passed to "
|
|
834
|
+
var msg = "Value passed to ".concat(modelDefinition.name, ".").concat(field, " is not a valid instance of a model");
|
|
722
835
|
logger.error(msg, { model: model });
|
|
723
836
|
throw new Error(msg);
|
|
724
837
|
}
|
|
725
838
|
if (modelConstructor.name.toLowerCase() !==
|
|
726
839
|
relationship.remoteModelConstructor.name.toLowerCase()) {
|
|
727
|
-
var msg = "Value passed to "
|
|
840
|
+
var msg = "Value passed to ".concat(modelDefinition.name, ".").concat(field, " is not an instance of ").concat(relationship.remoteModelConstructor.name);
|
|
728
841
|
logger.error(msg, { model: model });
|
|
729
842
|
throw new Error(msg);
|
|
730
843
|
}
|
|
@@ -733,7 +846,8 @@ var createModelClass = function (modelDefinition) {
|
|
|
733
846
|
// if the relationship can be managed automagically, set the FK's
|
|
734
847
|
if (relationship.isComplete) {
|
|
735
848
|
for (var i = 0; i < relationship.localJoinFields.length; i++) {
|
|
736
|
-
this[relationship.localJoinFields[i]] =
|
|
849
|
+
this[relationship.localJoinFields[i]] =
|
|
850
|
+
model === null || model === void 0 ? void 0 : model[relationship.remoteJoinFields[i]];
|
|
737
851
|
}
|
|
738
852
|
var instanceMemos = modelInstanceAssociationsMap.has(this)
|
|
739
853
|
? modelInstanceAssociationsMap.get(this)
|
|
@@ -781,7 +895,7 @@ var createModelClass = function (modelDefinition) {
|
|
|
781
895
|
instanceMemos[field] = resultPromise.then(function (rows) {
|
|
782
896
|
if (rows.length > 1) {
|
|
783
897
|
// should never happen for a HAS_ONE or BELONGS_TO.
|
|
784
|
-
var err = new Error("\n\t\t\t\t\t\t\t\t\tData integrity error.\n\t\t\t\t\t\t\t\t\tToo many records found for a HAS_ONE/BELONGS_TO field '"
|
|
898
|
+
var err = new Error("\n\t\t\t\t\t\t\t\t\tData integrity error.\n\t\t\t\t\t\t\t\t\tToo many records found for a HAS_ONE/BELONGS_TO field '".concat(modelDefinition.name, ".").concat(field, "'\n\t\t\t\t\t\t\t\t"));
|
|
785
899
|
console.error(err);
|
|
786
900
|
throw err;
|
|
787
901
|
}
|
|
@@ -895,45 +1009,52 @@ var AsyncCollection = /** @class */ (function () {
|
|
|
895
1009
|
* ```
|
|
896
1010
|
*/
|
|
897
1011
|
AsyncCollection.prototype.toArray = function (_a) {
|
|
898
|
-
var _b
|
|
899
|
-
var
|
|
1012
|
+
var _b, e_6, _c, _d;
|
|
1013
|
+
var _e = _a === void 0 ? {} : _a, _f = _e.max, max = _f === void 0 ? Number.MAX_SAFE_INTEGER : _f;
|
|
900
1014
|
return __awaiter(this, void 0, void 0, function () {
|
|
901
|
-
var output, i,
|
|
902
|
-
return __generator(this, function (
|
|
903
|
-
switch (
|
|
1015
|
+
var output, i, _g, _h, _j, element, e_6_1;
|
|
1016
|
+
return __generator(this, function (_k) {
|
|
1017
|
+
switch (_k.label) {
|
|
904
1018
|
case 0:
|
|
905
1019
|
output = [];
|
|
906
1020
|
i = 0;
|
|
907
|
-
|
|
1021
|
+
_k.label = 1;
|
|
908
1022
|
case 1:
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
case 2: return [4 /*yield*/,
|
|
1023
|
+
_k.trys.push([1, 6, 7, 12]);
|
|
1024
|
+
_g = true, _h = __asyncValues(this);
|
|
1025
|
+
_k.label = 2;
|
|
1026
|
+
case 2: return [4 /*yield*/, _h.next()];
|
|
913
1027
|
case 3:
|
|
914
|
-
if (!(
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1028
|
+
if (!(_j = _k.sent(), _b = _j.done, !_b)) return [3 /*break*/, 5];
|
|
1029
|
+
_d = _j.value;
|
|
1030
|
+
_g = false;
|
|
1031
|
+
try {
|
|
1032
|
+
element = _d;
|
|
1033
|
+
if (i < max) {
|
|
1034
|
+
output.push(element);
|
|
1035
|
+
i++;
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
return [3 /*break*/, 5];
|
|
1039
|
+
}
|
|
919
1040
|
}
|
|
920
|
-
|
|
921
|
-
|
|
1041
|
+
finally {
|
|
1042
|
+
_g = true;
|
|
922
1043
|
}
|
|
923
|
-
|
|
1044
|
+
_k.label = 4;
|
|
924
1045
|
case 4: return [3 /*break*/, 2];
|
|
925
1046
|
case 5: return [3 /*break*/, 12];
|
|
926
1047
|
case 6:
|
|
927
|
-
e_6_1 =
|
|
1048
|
+
e_6_1 = _k.sent();
|
|
928
1049
|
e_6 = { error: e_6_1 };
|
|
929
1050
|
return [3 /*break*/, 12];
|
|
930
1051
|
case 7:
|
|
931
|
-
|
|
932
|
-
if (!(
|
|
933
|
-
return [4 /*yield*/, _c.call(
|
|
1052
|
+
_k.trys.push([7, , 10, 11]);
|
|
1053
|
+
if (!(!_g && !_b && (_c = _h.return))) return [3 /*break*/, 9];
|
|
1054
|
+
return [4 /*yield*/, _c.call(_h)];
|
|
934
1055
|
case 8:
|
|
935
|
-
|
|
936
|
-
|
|
1056
|
+
_k.sent();
|
|
1057
|
+
_k.label = 9;
|
|
937
1058
|
case 9: return [3 /*break*/, 11];
|
|
938
1059
|
case 10:
|
|
939
1060
|
if (e_6) throw e_6.error;
|
|
@@ -952,7 +1073,7 @@ var checkReadOnlyPropertyOnCreate = function (draft, modelDefinition) {
|
|
|
952
1073
|
var fields = modelDefinition.fields;
|
|
953
1074
|
modelKeys.forEach(function (key) {
|
|
954
1075
|
if (fields[key] && fields[key].isReadOnly) {
|
|
955
|
-
throw new Error(key
|
|
1076
|
+
throw new Error("".concat(key, " is read-only."));
|
|
956
1077
|
}
|
|
957
1078
|
});
|
|
958
1079
|
};
|
|
@@ -964,7 +1085,7 @@ var checkReadOnlyPropertyOnUpdate = function (patches, modelDefinition) {
|
|
|
964
1085
|
if (!val || !fields[key])
|
|
965
1086
|
return;
|
|
966
1087
|
if (fields[key].isReadOnly) {
|
|
967
|
-
throw new Error(key
|
|
1088
|
+
throw new Error("".concat(key, " is read-only."));
|
|
968
1089
|
}
|
|
969
1090
|
});
|
|
970
1091
|
};
|
|
@@ -1010,13 +1131,13 @@ function getModelConstructorByModelName(namespaceName, modelName) {
|
|
|
1010
1131
|
result = storageClasses[modelName];
|
|
1011
1132
|
break;
|
|
1012
1133
|
default:
|
|
1013
|
-
throw new Error("Invalid namespace: "
|
|
1134
|
+
throw new Error("Invalid namespace: ".concat(namespaceName));
|
|
1014
1135
|
}
|
|
1015
1136
|
if (isValidModelConstructor(result)) {
|
|
1016
1137
|
return result;
|
|
1017
1138
|
}
|
|
1018
1139
|
else {
|
|
1019
|
-
var msg = "Model name is not valid for namespace. modelName: "
|
|
1140
|
+
var msg = "Model name is not valid for namespace. modelName: ".concat(modelName, ", namespace: ").concat(namespaceName);
|
|
1020
1141
|
logger.error(msg);
|
|
1021
1142
|
throw new Error(msg);
|
|
1022
1143
|
}
|
|
@@ -1129,7 +1250,6 @@ var DataStore = /** @class */ (function () {
|
|
|
1129
1250
|
function DataStore() {
|
|
1130
1251
|
var _this = this;
|
|
1131
1252
|
// reference to configured category instances. Used for preserving SSR context
|
|
1132
|
-
this.Auth = Auth;
|
|
1133
1253
|
this.InternalAPI = InternalAPI;
|
|
1134
1254
|
this.Cache = Cache;
|
|
1135
1255
|
// Non-null assertions (bang operator) have been added to most of these properties
|
|
@@ -1142,9 +1262,7 @@ var DataStore = /** @class */ (function () {
|
|
|
1142
1262
|
this.syncPredicates = new WeakMap();
|
|
1143
1263
|
// object that gets passed to descendent classes. Allows us to pass these down by reference
|
|
1144
1264
|
this.amplifyContext = {
|
|
1145
|
-
Auth: this.Auth,
|
|
1146
1265
|
InternalAPI: this.InternalAPI,
|
|
1147
|
-
Cache: this.Cache,
|
|
1148
1266
|
};
|
|
1149
1267
|
/**
|
|
1150
1268
|
* **IMPORTANT!**
|
|
@@ -1237,11 +1355,8 @@ var DataStore = /** @class */ (function () {
|
|
|
1237
1355
|
.subscribe({
|
|
1238
1356
|
next: function (_a) {
|
|
1239
1357
|
var type = _a.type, data = _a.data;
|
|
1240
|
-
// In Node, we need to wait for queries to be synced to prevent returning empty arrays.
|
|
1241
1358
|
// In the Browser, we can begin returning data once subscriptions are in place.
|
|
1242
|
-
var readyType =
|
|
1243
|
-
? ControlMessage.SYNC_ENGINE_SYNC_QUERIES_READY
|
|
1244
|
-
: ControlMessage.SYNC_ENGINE_STORAGE_SUBSCRIBED;
|
|
1359
|
+
var readyType = ControlMessage.SYNC_ENGINE_STORAGE_SUBSCRIBED;
|
|
1245
1360
|
if (type === readyType) {
|
|
1246
1361
|
_this.initResolve();
|
|
1247
1362
|
}
|
|
@@ -1411,10 +1526,10 @@ var DataStore = /** @class */ (function () {
|
|
|
1411
1526
|
related = _c.sent();
|
|
1412
1527
|
if (related.length === 0) {
|
|
1413
1528
|
throw new Error([
|
|
1414
|
-
"Data integrity error. You tried to save a "
|
|
1415
|
-
"but the instance assigned to the \""
|
|
1529
|
+
"Data integrity error. You tried to save a ".concat(modelDefinition.name, " (").concat(JSON.stringify(model), ")"),
|
|
1530
|
+
"but the instance assigned to the \"".concat(relationship.field, "\" property"),
|
|
1416
1531
|
"does not exist in the local database. If you're trying to create the related",
|
|
1417
|
-
"\""
|
|
1532
|
+
"\"".concat((_b = relationship.remoteDefinition) === null || _b === void 0 ? void 0 : _b.name, "\", you must save it independently first."),
|
|
1418
1533
|
].join(' '));
|
|
1419
1534
|
}
|
|
1420
1535
|
_c.label = 4;
|
|
@@ -1851,7 +1966,7 @@ var DataStore = /** @class */ (function () {
|
|
|
1851
1966
|
var generateSnapshot = function () {
|
|
1852
1967
|
var _a, _b;
|
|
1853
1968
|
var isSynced = (_b = (_a = _this.sync) === null || _a === void 0 ? void 0 : _a.getModelSyncedStatus(model)) !== null && _b !== void 0 ? _b : false;
|
|
1854
|
-
var itemsArray =
|
|
1969
|
+
var itemsArray = __spreadArray(__spreadArray([], __read(Array.from(items.values())), false), __read(Array.from(itemsChanged.values())), false);
|
|
1855
1970
|
items.clear();
|
|
1856
1971
|
itemsArray.forEach(function (item) {
|
|
1857
1972
|
var itemModelDefinition = getModelDefinition(model);
|
|
@@ -1911,16 +2026,16 @@ var DataStore = /** @class */ (function () {
|
|
|
1911
2026
|
* @param payload The payload from the Hub event.
|
|
1912
2027
|
*/
|
|
1913
2028
|
var hubCallback = function (_a) {
|
|
1914
|
-
var payload = _a.payload;
|
|
1915
2029
|
var _b;
|
|
2030
|
+
var payload = _a.payload;
|
|
1916
2031
|
var event = payload.event, data = payload.data;
|
|
1917
2032
|
if (event === ControlMessage.SYNC_ENGINE_MODEL_SYNCED &&
|
|
1918
2033
|
((_b = data === null || data === void 0 ? void 0 : data.model) === null || _b === void 0 ? void 0 : _b.name) === model.name) {
|
|
1919
2034
|
generateAndEmitSnapshot();
|
|
1920
|
-
|
|
2035
|
+
hubRemove();
|
|
1921
2036
|
}
|
|
1922
2037
|
};
|
|
1923
|
-
Hub.listen('datastore', hubCallback);
|
|
2038
|
+
var hubRemove = Hub.listen('datastore', hubCallback);
|
|
1924
2039
|
return _this.runningProcesses.addCleaner(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1925
2040
|
return __generator(this, function (_a) {
|
|
1926
2041
|
if (handle) {
|
|
@@ -1932,12 +2047,22 @@ var DataStore = /** @class */ (function () {
|
|
|
1932
2047
|
});
|
|
1933
2048
|
};
|
|
1934
2049
|
this.configure = function (config) {
|
|
2050
|
+
var _a;
|
|
1935
2051
|
if (config === void 0) { config = {}; }
|
|
1936
|
-
_this.amplifyContext.Auth = _this.Auth;
|
|
1937
2052
|
_this.amplifyContext.InternalAPI = _this.InternalAPI;
|
|
1938
|
-
_this.amplifyContext.Cache = _this.Cache;
|
|
1939
2053
|
var configDataStore = config.DataStore, configAuthModeStrategyType = config.authModeStrategyType, configConflictHandler = config.conflictHandler, configErrorHandler = config.errorHandler, configMaxRecordsToSync = config.maxRecordsToSync, configSyncPageSize = config.syncPageSize, configFullSyncInterval = config.fullSyncInterval, configSyncExpressions = config.syncExpressions, configAuthProviders = config.authProviders, configStorageAdapter = config.storageAdapter, configFromAmplify = __rest(config, ["DataStore", "authModeStrategyType", "conflictHandler", "errorHandler", "maxRecordsToSync", "syncPageSize", "fullSyncInterval", "syncExpressions", "authProviders", "storageAdapter"]);
|
|
1940
|
-
|
|
2054
|
+
var apiKey = '';
|
|
2055
|
+
var currentAppSyncConfig = (_a = Amplify.getConfig().API) === null || _a === void 0 ? void 0 : _a.AppSync;
|
|
2056
|
+
if ((currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.defaultAuthMode.type) === 'apiKey') {
|
|
2057
|
+
apiKey = currentAppSyncConfig.defaultAuthMode.apiKey;
|
|
2058
|
+
}
|
|
2059
|
+
var appSyncConfig = {
|
|
2060
|
+
aws_appsync_graphqlEndpoint: currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.endpoint,
|
|
2061
|
+
aws_appsync_authenticationType: currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.defaultAuthMode.type,
|
|
2062
|
+
aws_appsync_region: currentAppSyncConfig === null || currentAppSyncConfig === void 0 ? void 0 : currentAppSyncConfig.region,
|
|
2063
|
+
aws_appsync_apiKey: apiKey,
|
|
2064
|
+
};
|
|
2065
|
+
_this.amplifyConfig = __assign(__assign(__assign({}, _this.amplifyConfig), configFromAmplify), (currentAppSyncConfig && appSyncConfig));
|
|
1941
2066
|
_this.conflictHandler = _this.setConflictHandler(config);
|
|
1942
2067
|
_this.errorHandler = _this.setErrorHandler(config);
|
|
1943
2068
|
var authModeStrategyType = (configDataStore && configDataStore.authModeStrategyType) ||
|
|
@@ -2009,7 +2134,7 @@ var DataStore = /** @class */ (function () {
|
|
|
2009
2134
|
var handler = function (err) {
|
|
2010
2135
|
if (err.message.startsWith('BackgroundManagerNotOpenError')) {
|
|
2011
2136
|
throw new Error([
|
|
2012
|
-
"DataStoreStateError: Tried to execute `"
|
|
2137
|
+
"DataStoreStateError: Tried to execute `".concat(operation, "` while DataStore was \"").concat(_this.state, "\"."),
|
|
2013
2138
|
"This can only be done while DataStore is \"Started\" or \"Stopped\". To remedy:",
|
|
2014
2139
|
'Ensure all calls to `stop()` and `clear()` have completed first.',
|
|
2015
2140
|
'If this is not possible, retry the operation until it succeeds.',
|
|
@@ -2218,7 +2343,7 @@ var DataStore = /** @class */ (function () {
|
|
|
2218
2343
|
var _b = __read(_a, 2), modelDefinition = _b[0], predicate = _b[1];
|
|
2219
2344
|
if (map.has(modelDefinition)) {
|
|
2220
2345
|
var name_2 = modelDefinition.name;
|
|
2221
|
-
logger.warn("You can only utilize one Sync Expression per model.\n Subsequent sync expressions for the "
|
|
2346
|
+
logger.warn("You can only utilize one Sync Expression per model.\n Subsequent sync expressions for the ".concat(name_2, " model will be ignored."));
|
|
2222
2347
|
return map;
|
|
2223
2348
|
}
|
|
2224
2349
|
if (predicate) {
|
|
@@ -2238,7 +2363,7 @@ var DataStore = /** @class */ (function () {
|
|
|
2238
2363
|
var aws_appsync_graphqlEndpoint = this.amplifyConfig.aws_appsync_graphqlEndpoint;
|
|
2239
2364
|
var appSyncUrl = aws_appsync_graphqlEndpoint.split('/')[2];
|
|
2240
2365
|
var _a = __read(appSyncUrl.split('.'), 1), appSyncId = _a[0];
|
|
2241
|
-
return sessionId
|
|
2366
|
+
return "".concat(sessionId, "-").concat(appSyncId);
|
|
2242
2367
|
}
|
|
2243
2368
|
}
|
|
2244
2369
|
catch (_b) { }
|
|
@@ -2247,6 +2372,10 @@ var DataStore = /** @class */ (function () {
|
|
|
2247
2372
|
return DataStore;
|
|
2248
2373
|
}());
|
|
2249
2374
|
var instance = new DataStore();
|
|
2250
|
-
|
|
2375
|
+
instance.configure({});
|
|
2376
|
+
Hub.listen('core', function (capsule) {
|
|
2377
|
+
if (capsule.payload.event === 'configure') {
|
|
2378
|
+
instance.configure({});
|
|
2379
|
+
}
|
|
2380
|
+
});
|
|
2251
2381
|
export { DataStore as DataStoreClass, initSchema, instance as DataStore };
|
|
2252
|
-
//# sourceMappingURL=datastore.js.map
|
package/lib-esm/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const utils: {
|
|
|
9
9
|
item: T;
|
|
10
10
|
instance: T;
|
|
11
11
|
}[];
|
|
12
|
-
validatePredicate: <T_2 extends Readonly<Record<string, any>>>(model: T_2, groupType:
|
|
12
|
+
validatePredicate: <T_2 extends Readonly<Record<string, any>>>(model: T_2, groupType: keyof import("./types").PredicateGroups<T_2>, predicatesOrGroups: (import("./types").PredicateObject<T_2> | import("./types").PredicatesGroup<T_2>)[]) => any;
|
|
13
13
|
isNonModelConstructor: (obj: any) => obj is import("./types").NonModelTypeConstructor<any>;
|
|
14
14
|
isModelConstructor: <T_3 extends Readonly<Record<string, any>>>(obj: any) => obj is import("./types").PersistentModelConstructor<T_3>;
|
|
15
15
|
};
|
package/lib-esm/index.js
CHANGED