@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-esm/types.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
2
1
|
import { isAWSDate, isAWSTime, isAWSDateTime, isAWSTimestamp, isAWSEmail, isAWSJSON, isAWSURL, isAWSPhone, isAWSIPAddress, extractPrimaryKeyFieldNames, } from './util';
|
|
3
2
|
export function isSchemaModel(obj) {
|
|
4
3
|
return obj && obj.pluralName !== undefined;
|
|
@@ -10,11 +9,10 @@ export function isAssociatedWith(obj) {
|
|
|
10
9
|
return obj && obj.associatedWith;
|
|
11
10
|
}
|
|
12
11
|
export function isTargetNameAssociation(obj) {
|
|
13
|
-
return
|
|
12
|
+
return obj?.targetName || obj?.targetNames;
|
|
14
13
|
}
|
|
15
14
|
export function isFieldAssociation(obj, fieldName) {
|
|
16
|
-
|
|
17
|
-
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;
|
|
15
|
+
return obj?.fields[fieldName]?.association?.connectionType;
|
|
18
16
|
}
|
|
19
17
|
export function isModelAttributeAuth(attr) {
|
|
20
18
|
return (attr.type === 'auth' &&
|
|
@@ -125,26 +123,26 @@ export function isGraphQLScalarType(obj) {
|
|
|
125
123
|
return obj && GraphQLScalarType[obj] !== undefined;
|
|
126
124
|
}
|
|
127
125
|
export function isModelFieldType(obj) {
|
|
128
|
-
|
|
126
|
+
const modelField = 'model';
|
|
129
127
|
if (obj && obj[modelField])
|
|
130
128
|
return true;
|
|
131
129
|
return false;
|
|
132
130
|
}
|
|
133
131
|
export function isNonModelFieldType(obj) {
|
|
134
|
-
|
|
132
|
+
const typeField = 'nonModel';
|
|
135
133
|
if (obj && obj[typeField])
|
|
136
134
|
return true;
|
|
137
135
|
return false;
|
|
138
136
|
}
|
|
139
137
|
export function isEnumFieldType(obj) {
|
|
140
|
-
|
|
138
|
+
const modelField = 'enum';
|
|
141
139
|
if (obj && obj[modelField])
|
|
142
140
|
return true;
|
|
143
141
|
return false;
|
|
144
142
|
}
|
|
145
143
|
export function isIdentifierObject(obj, modelDefinition) {
|
|
146
|
-
|
|
147
|
-
return (typeof obj === 'object' && obj && keys.every(
|
|
144
|
+
const keys = extractPrimaryKeyFieldNames(modelDefinition);
|
|
145
|
+
return (typeof obj === 'object' && obj && keys.every(k => obj[k] !== undefined));
|
|
148
146
|
}
|
|
149
147
|
//#endregion
|
|
150
148
|
//#region Subscription messages
|
|
@@ -182,15 +180,11 @@ export var ModelOperation;
|
|
|
182
180
|
ModelOperation["UPDATE"] = "UPDATE";
|
|
183
181
|
ModelOperation["DELETE"] = "DELETE";
|
|
184
182
|
})(ModelOperation || (ModelOperation = {}));
|
|
185
|
-
export function syncExpression(modelConstructor, conditionProducer) {
|
|
186
|
-
return
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
conditionProducer: conditionProducer,
|
|
191
|
-
}];
|
|
192
|
-
});
|
|
193
|
-
});
|
|
183
|
+
export async function syncExpression(modelConstructor, conditionProducer) {
|
|
184
|
+
return {
|
|
185
|
+
modelConstructor,
|
|
186
|
+
conditionProducer,
|
|
187
|
+
};
|
|
194
188
|
}
|
|
195
189
|
export var ProcessName;
|
|
196
190
|
(function (ProcessName) {
|
|
@@ -198,7 +192,7 @@ export var ProcessName;
|
|
|
198
192
|
ProcessName["mutate"] = "mutate";
|
|
199
193
|
ProcessName["subscribe"] = "subscribe";
|
|
200
194
|
})(ProcessName || (ProcessName = {}));
|
|
201
|
-
export
|
|
195
|
+
export const DISCARD = Symbol('DISCARD');
|
|
202
196
|
export var LimitTimerRaceResolvedValues;
|
|
203
197
|
(function (LimitTimerRaceResolvedValues) {
|
|
204
198
|
LimitTimerRaceResolvedValues["LIMIT"] = "LIMIT";
|
|
@@ -208,12 +202,9 @@ export var LimitTimerRaceResolvedValues;
|
|
|
208
202
|
* A pointer used by DataStore internally to lookup predicate details
|
|
209
203
|
* that should not be exposed on public customer interfaces.
|
|
210
204
|
*/
|
|
211
|
-
|
|
212
|
-
|
|
205
|
+
export class PredicateInternalsKey {
|
|
206
|
+
constructor() {
|
|
213
207
|
this.__isPredicateInternalsKeySentinel = true;
|
|
214
208
|
}
|
|
215
|
-
|
|
216
|
-
}());
|
|
217
|
-
export { PredicateInternalsKey };
|
|
209
|
+
}
|
|
218
210
|
// #endregion
|
|
219
|
-
//# sourceMappingURL=types.js.map
|
package/lib-esm/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[];
|