@aws-amplify/datastore 5.0.1-console-preview.5f040a2.0 → 5.0.1-console-preview.23dc225.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/lib/datastore/datastore.js +11 -10
- package/lib/sync/processors/subscription.js +1 -2
- package/lib/sync/utils.d.ts +4 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +3 -3
- package/lib/util.js +4 -4
- package/lib-esm/datastore/datastore.js +4 -3
- package/lib-esm/sync/processors/subscription.js +1 -2
- package/lib-esm/sync/utils.d.ts +4 -4
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types.d.ts +3 -3
- package/lib-esm/util.js +4 -4
- package/package.json +8 -10
- package/src/authModeStrategies/multiAuthStrategy.ts +2 -2
- package/src/datastore/datastore.ts +4 -3
- package/src/sync/processors/mutation.ts +2 -2
- package/src/sync/processors/subscription.ts +165 -170
- package/src/sync/processors/sync.ts +2 -2
- package/src/sync/utils.ts +5 -5
- package/src/types.ts +4 -4
- package/src/util.ts +4 -4
|
@@ -122,7 +122,7 @@ exports.DataStore = exports.initSchema = exports.DataStoreClass = exports.AsyncC
|
|
|
122
122
|
var internals_1 = require("@aws-amplify/api/internals");
|
|
123
123
|
var core_1 = require("@aws-amplify/core");
|
|
124
124
|
var immer_1 = require("immer");
|
|
125
|
-
var
|
|
125
|
+
var utils_1 = require("@aws-amplify/core/internals/utils");
|
|
126
126
|
var rxjs_1 = require("rxjs");
|
|
127
127
|
var authModeStrategies_1 = require("../authModeStrategies");
|
|
128
128
|
var predicates_1 = require("../predicates");
|
|
@@ -132,11 +132,11 @@ var sync_1 = require("../sync");
|
|
|
132
132
|
var types_1 = require("../types");
|
|
133
133
|
var util_1 = require("../util");
|
|
134
134
|
var next_1 = require("../predicates/next");
|
|
135
|
-
var
|
|
136
|
-
var
|
|
135
|
+
var utils_2 = require("../sync/utils");
|
|
136
|
+
var utils_3 = require("@aws-amplify/core/internals/utils");
|
|
137
137
|
(0, immer_1.setAutoFreeze)(true);
|
|
138
138
|
(0, immer_1.enablePatches)();
|
|
139
|
-
var logger = new
|
|
139
|
+
var logger = new utils_3.Logger('DataStore');
|
|
140
140
|
var ulid = (0, util_1.monotonicUlidFactory)(Date.now());
|
|
141
141
|
var SETTING_SCHEMA_VERSION = 'schemaVersion';
|
|
142
142
|
var schema;
|
|
@@ -714,13 +714,14 @@ var createModelClass = function (modelDefinition) {
|
|
|
714
714
|
var id = isInternalModel
|
|
715
715
|
? _id
|
|
716
716
|
: modelDefinition.syncable
|
|
717
|
-
? (0,
|
|
717
|
+
? (0, utils_1.amplifyUuid)()
|
|
718
718
|
: ulid();
|
|
719
719
|
draft.id = id;
|
|
720
720
|
}
|
|
721
721
|
else if ((0, util_1.isIdOptionallyManaged)(modelDefinition)) {
|
|
722
722
|
// only auto-populate if the id was not provided
|
|
723
|
-
draft.id =
|
|
723
|
+
draft.id =
|
|
724
|
+
draft.id || (0, utils_1.amplifyUuid)();
|
|
724
725
|
}
|
|
725
726
|
if (!isInternallyInitialized) {
|
|
726
727
|
checkReadOnlyPropertyOnCreate(draft, modelDefinition);
|
|
@@ -1299,7 +1300,7 @@ var DataStore = /** @class */ (function () {
|
|
|
1299
1300
|
*
|
|
1300
1301
|
* (Reasonable = *seconds*, not minutes.)
|
|
1301
1302
|
*/
|
|
1302
|
-
this.runningProcesses = new
|
|
1303
|
+
this.runningProcesses = new utils_3.BackgroundProcessManager();
|
|
1303
1304
|
/**
|
|
1304
1305
|
* Indicates what state DataStore is in.
|
|
1305
1306
|
*
|
|
@@ -1884,7 +1885,7 @@ var DataStore = /** @class */ (function () {
|
|
|
1884
1885
|
// first, query and return any locally-available records
|
|
1885
1886
|
(_a.sent()).forEach(function (item) {
|
|
1886
1887
|
var itemModelDefinition = getModelDefinition(model);
|
|
1887
|
-
var idOrPk = (0,
|
|
1888
|
+
var idOrPk = (0, utils_2.getIdentifierValue)(itemModelDefinition, item);
|
|
1888
1889
|
items.set(idOrPk, item);
|
|
1889
1890
|
});
|
|
1890
1891
|
// Observe the model and send a stream of updates (debounced).
|
|
@@ -1901,7 +1902,7 @@ var DataStore = /** @class */ (function () {
|
|
|
1901
1902
|
switch (_d.label) {
|
|
1902
1903
|
case 0:
|
|
1903
1904
|
itemModelDefinition = getModelDefinition(model);
|
|
1904
|
-
idOrPk = (0,
|
|
1905
|
+
idOrPk = (0, utils_2.getIdentifierValue)(itemModelDefinition, element);
|
|
1905
1906
|
_a = executivePredicate;
|
|
1906
1907
|
if (!_a) return [3 /*break*/, 2];
|
|
1907
1908
|
return [4 /*yield*/, executivePredicate.matches(element)];
|
|
@@ -1974,7 +1975,7 @@ var DataStore = /** @class */ (function () {
|
|
|
1974
1975
|
items.clear();
|
|
1975
1976
|
itemsArray.forEach(function (item) {
|
|
1976
1977
|
var itemModelDefinition = getModelDefinition(model);
|
|
1977
|
-
var idOrPk = (0,
|
|
1978
|
+
var idOrPk = (0, utils_2.getIdentifierValue)(itemModelDefinition, item);
|
|
1978
1979
|
items.set(idOrPk, item);
|
|
1979
1980
|
});
|
|
1980
1981
|
// remove deleted items from the final result set
|
|
@@ -303,8 +303,7 @@ var SubscriptionProcessor = /** @class */ (function () {
|
|
|
303
303
|
logger.debug("Attempting ".concat(operation, " subscription with authMode: ").concat(readAuthModes[operationAuthModeAttempts[operation]]));
|
|
304
304
|
queryObservable = this.amplifyContext.InternalAPI.graphql(__assign(__assign({ query: query, variables: variables }, { authMode: authMode }), { authToken: authToken }), undefined, customUserAgentDetails);
|
|
305
305
|
// TODO: consider onTerminate.then(() => API.cancel(...))
|
|
306
|
-
subscriptions[modelDefinition.name][transformerMutationType].push(queryObservable
|
|
307
|
-
.subscribe({
|
|
306
|
+
subscriptions[modelDefinition.name][transformerMutationType].push(queryObservable.subscribe({
|
|
308
307
|
next: function (result) {
|
|
309
308
|
var data = result.data, errors = result.errors;
|
|
310
309
|
if (Array.isArray(errors) && errors.length > 0) {
|
package/lib/sync/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLAuthError } from '@aws-amplify/api';
|
|
2
|
-
import {
|
|
2
|
+
import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';
|
|
3
3
|
import { ModelInstanceCreator } from '../datastore/datastore';
|
|
4
4
|
import { AuthorizationRule, GraphQLCondition, GraphQLFilter, ModelInstanceMetadata, OpType, PersistentModel, PersistentModelConstructor, PredicatesGroup, RelationshipType, SchemaModel, SchemaNamespace, SchemaNonModel, ModelOperation, InternalSchema, AuthModeStrategy } from '../types';
|
|
5
5
|
import { MutationEvent } from './';
|
|
@@ -93,14 +93,14 @@ export declare function getUserGroupsFromToken(token: {
|
|
|
93
93
|
}, rule: AuthorizationRule): string[];
|
|
94
94
|
export declare function getModelAuthModes({ authModeStrategy, defaultAuthMode, modelName, schema, }: {
|
|
95
95
|
authModeStrategy: AuthModeStrategy;
|
|
96
|
-
defaultAuthMode:
|
|
96
|
+
defaultAuthMode: GraphQLAuthMode;
|
|
97
97
|
modelName: string;
|
|
98
98
|
schema: InternalSchema;
|
|
99
99
|
}): Promise<{
|
|
100
|
-
[key in ModelOperation]:
|
|
100
|
+
[key in ModelOperation]: GraphQLAuthMode[];
|
|
101
101
|
}>;
|
|
102
102
|
export declare function getForbiddenError(error: any): any;
|
|
103
103
|
export declare function getClientSideAuthError(error: any): GraphQLAuthError;
|
|
104
|
-
export declare function getTokenForCustomAuth(authMode:
|
|
104
|
+
export declare function getTokenForCustomAuth(authMode: GraphQLAuthMode, amplifyConfig?: Record<string, any>): Promise<string | undefined>;
|
|
105
105
|
export declare function getIdentifierValue(modelDefinition: SchemaModel, model: ModelInstanceMetadata | PersistentModel): string;
|
|
106
106
|
export {};
|