@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
package/lib/types.js
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
39
|
+
exports.PredicateInternalsKey = exports.LimitTimerRaceResolvedValues = exports.DISCARD = exports.ProcessName = exports.syncExpression = exports.ModelOperation = exports.AuthModeStrategyType = exports.SortDirection = exports.QueryOne = exports.isPredicateGroup = exports.isPredicateObj = exports.OpType = exports.isIdentifierObject = exports.isEnumFieldType = exports.isNonModelFieldType = exports.isModelFieldType = exports.isGraphQLScalarType = exports.GraphQLScalarType = exports.ModelAttributeAuthProvider = exports.ModelAttributeAuthAllow = exports.isModelAttributeCompositeKey = exports.isModelAttributePrimaryKey = exports.isModelAttributeKey = exports.isModelAttributeAuth = exports.isFieldAssociation = exports.isTargetNameAssociation = exports.isAssociatedWith = exports.isSchemaModelWithAttributes = exports.isSchemaModel = void 0;
|
|
4
40
|
var util_1 = require("./util");
|
|
5
41
|
function isSchemaModel(obj) {
|
|
6
42
|
return obj && obj.pluralName !== undefined;
|
|
@@ -158,7 +194,7 @@ function isEnumFieldType(obj) {
|
|
|
158
194
|
}
|
|
159
195
|
exports.isEnumFieldType = isEnumFieldType;
|
|
160
196
|
function isIdentifierObject(obj, modelDefinition) {
|
|
161
|
-
var keys = util_1.extractPrimaryKeyFieldNames(modelDefinition);
|
|
197
|
+
var keys = (0, util_1.extractPrimaryKeyFieldNames)(modelDefinition);
|
|
162
198
|
return (typeof obj === 'object' && obj && keys.every(function (k) { return obj[k] !== undefined; }));
|
|
163
199
|
}
|
|
164
200
|
exports.isIdentifierObject = isIdentifierObject;
|
|
@@ -201,8 +237,8 @@ var ModelOperation;
|
|
|
201
237
|
ModelOperation["DELETE"] = "DELETE";
|
|
202
238
|
})(ModelOperation = exports.ModelOperation || (exports.ModelOperation = {}));
|
|
203
239
|
function syncExpression(modelConstructor, conditionProducer) {
|
|
204
|
-
return
|
|
205
|
-
return
|
|
240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
return __generator(this, function (_a) {
|
|
206
242
|
return [2 /*return*/, {
|
|
207
243
|
modelConstructor: modelConstructor,
|
|
208
244
|
conditionProducer: conditionProducer,
|
|
@@ -235,4 +271,3 @@ var PredicateInternalsKey = /** @class */ (function () {
|
|
|
235
271
|
}());
|
|
236
272
|
exports.PredicateInternalsKey = PredicateInternalsKey;
|
|
237
273
|
// #endregion
|
|
238
|
-
//# sourceMappingURL=types.js.map
|
package/lib/util.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ULID } from 'ulid';
|
|
2
2
|
import { Patch } from 'immer';
|
|
3
|
-
import {
|
|
3
|
+
import { ModelInstanceCreator } from './datastore/datastore';
|
|
4
|
+
import { AllOperators, PersistentModel, PersistentModelConstructor, PredicateGroups, PredicateObject, PredicatesGroup, RelationshipType, RelationType, ModelKeys, ModelAttributes, SchemaNamespace, SortPredicatesGroup, NonModelTypeConstructor, PaginationInput, DeferredCallbackResolverOptions, SchemaModel, ModelAttribute, IndexesType, ModelAssociation } from './types';
|
|
4
5
|
export declare const ID = "id";
|
|
5
6
|
/**
|
|
6
7
|
* Used by the Async Storage Adapter to concatenate key values
|
|
@@ -35,12 +36,12 @@ declare const STORAGE = NAMESPACES.STORAGE;
|
|
|
35
36
|
export { USER, SYNC, STORAGE, DATASTORE };
|
|
36
37
|
export declare const exhaustiveCheck: (obj: never, throwOnError?: boolean) => void;
|
|
37
38
|
export declare const isNullOrUndefined: (val: any) => boolean;
|
|
38
|
-
export declare const validatePredicate: <T extends Readonly<Record<string, any>>>(model: T, groupType:
|
|
39
|
-
export declare const validatePredicateField: <T>(value: T, operator:
|
|
39
|
+
export declare const validatePredicate: <T extends Readonly<Record<string, any>>>(model: T, groupType: keyof PredicateGroups<T>, predicatesOrGroups: (PredicateObject<T> | PredicatesGroup<T>)[]) => any;
|
|
40
|
+
export declare const validatePredicateField: <T>(value: T, operator: keyof AllOperators, operand: T | [T, T]) => boolean;
|
|
40
41
|
export declare const isModelConstructor: <T extends Readonly<Record<string, any>>>(obj: any) => obj is PersistentModelConstructor<T>;
|
|
41
42
|
export declare function registerNonModelClass(clazz: NonModelTypeConstructor<any>): void;
|
|
42
43
|
export declare const isNonModelConstructor: (obj: any) => obj is NonModelTypeConstructor<any>;
|
|
43
|
-
export declare const traverseModel: <T extends Readonly<Record<string, any>>>(srcModelName: string, instance: T, namespace: SchemaNamespace, modelInstanceCreator:
|
|
44
|
+
export declare const traverseModel: <T extends Readonly<Record<string, any>>>(srcModelName: string, instance: T, namespace: SchemaNamespace, modelInstanceCreator: ModelInstanceCreator, getModelConstructorByModelName: (namsespaceName: NAMESPACES, modelName: string) => PersistentModelConstructor<any>) => {
|
|
44
45
|
modelName: string;
|
|
45
46
|
item: T;
|
|
46
47
|
instance: T;
|
|
@@ -157,15 +158,15 @@ export declare class DeferredCallbackResolver {
|
|
|
157
158
|
export declare function mergePatches<T>(originalSource: T, oldPatches: Patch[], newPatches: Patch[]): Patch[];
|
|
158
159
|
export declare const getStorename: (namespace: string, modelName: string) => string;
|
|
159
160
|
export declare const processCompositeKeys: (attributes: ModelAttributes) => Set<string>[];
|
|
160
|
-
export declare const extractKeyIfExists: (modelDefinition: SchemaModel) => ModelAttribute;
|
|
161
|
+
export declare const extractKeyIfExists: (modelDefinition: SchemaModel) => ModelAttribute | undefined;
|
|
161
162
|
export declare const extractPrimaryKeyFieldNames: (modelDefinition: SchemaModel) => string[];
|
|
162
163
|
export declare const extractPrimaryKeyValues: <T extends Readonly<Record<string, any>>>(model: T, keyFields: string[]) => string[];
|
|
163
164
|
export declare const extractPrimaryKeysAndValues: <T extends Readonly<Record<string, any>>>(model: T, keyFields: string[]) => any;
|
|
164
165
|
export declare const isIdManaged: (modelDefinition: SchemaModel) => boolean;
|
|
165
166
|
export declare const isIdOptionallyManaged: (modelDefinition: SchemaModel) => boolean;
|
|
166
167
|
export declare const establishRelationAndKeys: (namespace: SchemaNamespace) => [RelationshipType, ModelKeys];
|
|
167
|
-
export declare const getIndex: (rel: RelationType[], src: string) => string;
|
|
168
|
-
export declare const getIndexFromAssociation: (indexes: IndexesType, src: string | string[]) => string;
|
|
168
|
+
export declare const getIndex: (rel: RelationType[], src: string) => string | undefined;
|
|
169
|
+
export declare const getIndexFromAssociation: (indexes: IndexesType, src: string | string[]) => string | undefined;
|
|
169
170
|
/**
|
|
170
171
|
* Backwards-compatability for schema generated prior to custom primary key support:
|
|
171
172
|
the single field `targetName` has been replaced with an array of `targetNames`.
|
|
@@ -173,16 +174,7 @@ the single field `targetName` has been replaced with an array of `targetNames`.
|
|
|
173
174
|
* @param src {RelationType | ModelAssociation | undefined}
|
|
174
175
|
* @returns array of targetNames, or `undefined`
|
|
175
176
|
*/
|
|
176
|
-
export declare const extractTargetNamesFromSrc: (src:
|
|
177
|
-
connectionType: "HAS_MANY" | "HAS_ONE";
|
|
178
|
-
associatedWith: string | string[];
|
|
179
|
-
targetName?: string;
|
|
180
|
-
targetNames?: string[];
|
|
181
|
-
} | {
|
|
182
|
-
connectionType: "BELONGS_TO";
|
|
183
|
-
targetName?: string;
|
|
184
|
-
targetNames?: string[];
|
|
185
|
-
} | RelationType) => string[];
|
|
177
|
+
export declare const extractTargetNamesFromSrc: (src: RelationType | ModelAssociation | undefined) => string[] | undefined;
|
|
186
178
|
export declare const indexNameFromKeys: (keys: string[]) => string;
|
|
187
179
|
export declare const keysEqual: (keysA: any, keysB: any) => boolean;
|
|
188
180
|
export declare const getIndexKeys: (namespace: SchemaNamespace, modelName: string) => string[];
|