@aws-amplify/datastore 4.7.6-api-v6-models.b3abc9b.0 → 5.0.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 +38 -53
- package/lib/datastore/datastore.d.ts +4 -5
- package/lib/datastore/datastore.js +929 -1284
- package/lib/index.d.ts +1 -1
- package/lib/index.js +26 -13
- package/lib/predicates/index.js +54 -69
- package/lib/predicates/next.d.ts +2 -2
- package/lib/predicates/next.js +313 -462
- package/lib/predicates/sort.js +24 -28
- package/lib/ssr/index.js +2 -2
- package/lib/storage/adapter/AsyncStorageAdapter.js +120 -342
- package/lib/storage/adapter/AsyncStorageDatabase.js +217 -421
- package/lib/storage/adapter/InMemoryStore.js +28 -51
- package/lib/storage/adapter/InMemoryStore.native.js +5 -3
- package/lib/storage/adapter/IndexedDBAdapter.js +466 -871
- package/lib/storage/adapter/StorageAdapterBase.js +180 -330
- package/lib/storage/adapter/getDefaultAdapter/index.js +8 -10
- package/lib/storage/adapter/getDefaultAdapter/index.native.js +5 -4
- package/lib/storage/adapter/index.js +0 -1
- package/lib/storage/relationship.js +177 -253
- package/lib/storage/storage.d.ts +4 -4
- package/lib/storage/storage.js +255 -433
- package/lib/sync/datastoreConnectivity.d.ts +2 -2
- package/lib/sync/datastoreConnectivity.js +29 -39
- package/lib/sync/datastoreReachability/index.d.ts +1 -3
- package/lib/sync/datastoreReachability/index.js +3 -3
- package/lib/sync/datastoreReachability/index.native.d.ts +1 -3
- package/lib/sync/datastoreReachability/index.native.js +4 -5
- package/lib/sync/index.d.ts +2 -2
- package/lib/sync/index.js +522 -827
- package/lib/sync/merger.js +31 -63
- package/lib/sync/outbox.js +148 -232
- package/lib/sync/processors/errorMaps.d.ts +1 -1
- package/lib/sync/processors/errorMaps.js +30 -47
- package/lib/sync/processors/mutation.d.ts +2 -2
- package/lib/sync/processors/mutation.js +343 -502
- package/lib/sync/processors/subscription.d.ts +5 -2
- package/lib/sync/processors/subscription.js +283 -437
- package/lib/sync/processors/sync.d.ts +2 -2
- package/lib/sync/processors/sync.js +279 -404
- package/lib/sync/utils.d.ts +5 -4
- package/lib/sync/utils.js +267 -320
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types.d.ts +138 -140
- package/lib/types.js +17 -24
- package/lib/util.d.ts +9 -17
- package/lib/util.js +387 -511
- package/lib-esm/authModeStrategies/defaultAuthStrategy.js +1 -2
- package/lib-esm/authModeStrategies/index.js +0 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +35 -52
- package/lib-esm/datastore/datastore.d.ts +4 -5
- package/lib-esm/datastore/datastore.js +888 -1247
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +6 -7
- package/lib-esm/predicates/index.js +53 -70
- package/lib-esm/predicates/next.d.ts +2 -2
- package/lib-esm/predicates/next.js +306 -459
- package/lib-esm/predicates/sort.js +23 -28
- package/lib-esm/ssr/index.js +1 -2
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js +111 -338
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js +212 -416
- package/lib-esm/storage/adapter/InMemoryStore.js +27 -52
- package/lib-esm/storage/adapter/InMemoryStore.native.js +0 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +438 -866
- package/lib-esm/storage/adapter/StorageAdapterBase.js +173 -325
- package/lib-esm/storage/adapter/getDefaultAdapter/index.js +2 -6
- package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js +1 -2
- package/lib-esm/storage/adapter/index.js +1 -1
- package/lib-esm/storage/relationship.js +173 -251
- package/lib-esm/storage/storage.d.ts +4 -4
- package/lib-esm/storage/storage.js +242 -424
- package/lib-esm/sync/datastoreConnectivity.d.ts +2 -2
- package/lib-esm/sync/datastoreConnectivity.js +28 -39
- package/lib-esm/sync/datastoreReachability/index.d.ts +1 -3
- package/lib-esm/sync/datastoreReachability/index.js +2 -3
- package/lib-esm/sync/datastoreReachability/index.native.d.ts +1 -3
- package/lib-esm/sync/datastoreReachability/index.native.js +3 -4
- package/lib-esm/sync/index.d.ts +2 -2
- package/lib-esm/sync/index.js +502 -812
- package/lib-esm/sync/merger.js +28 -61
- package/lib-esm/sync/outbox.js +143 -228
- package/lib-esm/sync/processors/errorMaps.d.ts +1 -1
- package/lib-esm/sync/processors/errorMaps.js +32 -50
- package/lib-esm/sync/processors/mutation.d.ts +2 -2
- package/lib-esm/sync/processors/mutation.js +329 -490
- package/lib-esm/sync/processors/subscription.d.ts +5 -2
- package/lib-esm/sync/processors/subscription.js +266 -421
- package/lib-esm/sync/processors/sync.d.ts +2 -2
- package/lib-esm/sync/processors/sync.js +271 -397
- package/lib-esm/sync/utils.d.ts +5 -4
- package/lib-esm/sync/utils.js +252 -307
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types.d.ts +138 -140
- package/lib-esm/types.js +16 -25
- package/lib-esm/util.d.ts +9 -17
- package/lib-esm/util.js +335 -497
- package/package.json +31 -26
- package/src/authModeStrategies/multiAuthStrategy.ts +15 -12
- package/src/datastore/datastore.ts +36 -35
- package/src/predicates/sort.ts +3 -1
- package/src/storage/adapter/InMemoryStore.ts +1 -1
- package/src/storage/adapter/IndexedDBAdapter.ts +2 -2
- package/src/storage/adapter/StorageAdapterBase.ts +2 -2
- package/src/storage/adapter/getDefaultAdapter/index.ts +1 -4
- package/src/storage/storage.ts +29 -24
- package/src/sync/datastoreConnectivity.ts +6 -6
- package/src/sync/datastoreReachability/index.native.ts +5 -3
- package/src/sync/datastoreReachability/index.ts +1 -1
- package/src/sync/index.ts +79 -89
- package/src/sync/processors/errorMaps.ts +7 -7
- package/src/sync/processors/mutation.ts +19 -13
- package/src/sync/processors/subscription.ts +221 -295
- package/src/sync/processors/sync.ts +11 -8
- package/src/sync/utils.ts +30 -15
- package/src/types.ts +4 -8
- package/src/util.ts +46 -9
- 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,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
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
|
+
const util_1 = require("./util");
|
|
5
5
|
function isSchemaModel(obj) {
|
|
6
6
|
return obj && obj.pluralName !== undefined;
|
|
7
7
|
}
|
|
@@ -15,12 +15,11 @@ function isAssociatedWith(obj) {
|
|
|
15
15
|
}
|
|
16
16
|
exports.isAssociatedWith = isAssociatedWith;
|
|
17
17
|
function isTargetNameAssociation(obj) {
|
|
18
|
-
return
|
|
18
|
+
return obj?.targetName || obj?.targetNames;
|
|
19
19
|
}
|
|
20
20
|
exports.isTargetNameAssociation = isTargetNameAssociation;
|
|
21
21
|
function isFieldAssociation(obj, fieldName) {
|
|
22
|
-
|
|
23
|
-
return (_b = (_a = obj === null || obj === void 0 ? void 0 : obj.fields[fieldName]) === null || _a === void 0 ? void 0 : _a.association) === null || _b === void 0 ? void 0 : _b.connectionType;
|
|
22
|
+
return obj?.fields[fieldName]?.association?.connectionType;
|
|
24
23
|
}
|
|
25
24
|
exports.isFieldAssociation = isFieldAssociation;
|
|
26
25
|
function isModelAttributeAuth(attr) {
|
|
@@ -137,29 +136,29 @@ function isGraphQLScalarType(obj) {
|
|
|
137
136
|
}
|
|
138
137
|
exports.isGraphQLScalarType = isGraphQLScalarType;
|
|
139
138
|
function isModelFieldType(obj) {
|
|
140
|
-
|
|
139
|
+
const modelField = 'model';
|
|
141
140
|
if (obj && obj[modelField])
|
|
142
141
|
return true;
|
|
143
142
|
return false;
|
|
144
143
|
}
|
|
145
144
|
exports.isModelFieldType = isModelFieldType;
|
|
146
145
|
function isNonModelFieldType(obj) {
|
|
147
|
-
|
|
146
|
+
const typeField = 'nonModel';
|
|
148
147
|
if (obj && obj[typeField])
|
|
149
148
|
return true;
|
|
150
149
|
return false;
|
|
151
150
|
}
|
|
152
151
|
exports.isNonModelFieldType = isNonModelFieldType;
|
|
153
152
|
function isEnumFieldType(obj) {
|
|
154
|
-
|
|
153
|
+
const modelField = 'enum';
|
|
155
154
|
if (obj && obj[modelField])
|
|
156
155
|
return true;
|
|
157
156
|
return false;
|
|
158
157
|
}
|
|
159
158
|
exports.isEnumFieldType = isEnumFieldType;
|
|
160
159
|
function isIdentifierObject(obj, modelDefinition) {
|
|
161
|
-
|
|
162
|
-
return (typeof obj === 'object' && obj && keys.every(
|
|
160
|
+
const keys = (0, util_1.extractPrimaryKeyFieldNames)(modelDefinition);
|
|
161
|
+
return (typeof obj === 'object' && obj && keys.every(k => obj[k] !== undefined));
|
|
163
162
|
}
|
|
164
163
|
exports.isIdentifierObject = isIdentifierObject;
|
|
165
164
|
//#endregion
|
|
@@ -200,15 +199,11 @@ var ModelOperation;
|
|
|
200
199
|
ModelOperation["UPDATE"] = "UPDATE";
|
|
201
200
|
ModelOperation["DELETE"] = "DELETE";
|
|
202
201
|
})(ModelOperation = exports.ModelOperation || (exports.ModelOperation = {}));
|
|
203
|
-
function syncExpression(modelConstructor, conditionProducer) {
|
|
204
|
-
return
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
conditionProducer: conditionProducer,
|
|
209
|
-
}];
|
|
210
|
-
});
|
|
211
|
-
});
|
|
202
|
+
async function syncExpression(modelConstructor, conditionProducer) {
|
|
203
|
+
return {
|
|
204
|
+
modelConstructor,
|
|
205
|
+
conditionProducer,
|
|
206
|
+
};
|
|
212
207
|
}
|
|
213
208
|
exports.syncExpression = syncExpression;
|
|
214
209
|
var ProcessName;
|
|
@@ -227,12 +222,10 @@ var LimitTimerRaceResolvedValues;
|
|
|
227
222
|
* A pointer used by DataStore internally to lookup predicate details
|
|
228
223
|
* that should not be exposed on public customer interfaces.
|
|
229
224
|
*/
|
|
230
|
-
|
|
231
|
-
|
|
225
|
+
class PredicateInternalsKey {
|
|
226
|
+
constructor() {
|
|
232
227
|
this.__isPredicateInternalsKeySentinel = true;
|
|
233
228
|
}
|
|
234
|
-
|
|
235
|
-
}());
|
|
229
|
+
}
|
|
236
230
|
exports.PredicateInternalsKey = PredicateInternalsKey;
|
|
237
231
|
// #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[];
|