@aws-amplify/datastore 3.10.1-unstable.7 → 3.10.1-unstable.8

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.
Files changed (48) hide show
  1. package/dist/aws-amplify-datastore.js +350 -109
  2. package/dist/aws-amplify-datastore.js.map +1 -1
  3. package/dist/aws-amplify-datastore.min.js +6 -6
  4. package/dist/aws-amplify-datastore.min.js.map +1 -1
  5. package/lib/datastore/datastore.js.map +1 -1
  6. package/lib/sync/index.js +3 -3
  7. package/lib/sync/index.js.map +1 -1
  8. package/lib/sync/processors/mutation.d.ts +2 -2
  9. package/lib/sync/processors/mutation.js +12 -5
  10. package/lib/sync/processors/mutation.js.map +1 -1
  11. package/lib/sync/processors/subscription.d.ts +3 -2
  12. package/lib/sync/processors/subscription.js +73 -32
  13. package/lib/sync/processors/subscription.js.map +1 -1
  14. package/lib/sync/processors/sync.d.ts +5 -2
  15. package/lib/sync/processors/sync.js +61 -26
  16. package/lib/sync/processors/sync.js.map +1 -1
  17. package/lib/sync/utils.d.ts +11 -1
  18. package/lib/sync/utils.js +59 -0
  19. package/lib/sync/utils.js.map +1 -1
  20. package/lib/types.d.ts +18 -8
  21. package/lib/types.js +6 -0
  22. package/lib/types.js.map +1 -1
  23. package/lib-esm/datastore/datastore.js.map +1 -1
  24. package/lib-esm/sync/index.js +3 -3
  25. package/lib-esm/sync/index.js.map +1 -1
  26. package/lib-esm/sync/processors/mutation.d.ts +2 -2
  27. package/lib-esm/sync/processors/mutation.js +14 -7
  28. package/lib-esm/sync/processors/mutation.js.map +1 -1
  29. package/lib-esm/sync/processors/subscription.d.ts +3 -2
  30. package/lib-esm/sync/processors/subscription.js +74 -33
  31. package/lib-esm/sync/processors/subscription.js.map +1 -1
  32. package/lib-esm/sync/processors/sync.d.ts +5 -2
  33. package/lib-esm/sync/processors/sync.js +62 -27
  34. package/lib-esm/sync/processors/sync.js.map +1 -1
  35. package/lib-esm/sync/utils.d.ts +11 -1
  36. package/lib-esm/sync/utils.js +58 -0
  37. package/lib-esm/sync/utils.js.map +1 -1
  38. package/lib-esm/types.d.ts +18 -8
  39. package/lib-esm/types.js +6 -0
  40. package/lib-esm/types.js.map +1 -1
  41. package/package.json +7 -7
  42. package/src/datastore/datastore.ts +2 -2
  43. package/src/sync/index.ts +6 -4
  44. package/src/sync/processors/mutation.ts +17 -8
  45. package/src/sync/processors/subscription.ts +39 -4
  46. package/src/sync/processors/sync.ts +33 -4
  47. package/src/sync/utils.ts +22 -0
  48. package/src/types.ts +25 -8
@@ -83543,7 +83543,7 @@ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Amplify"].register(instance);
83543
83543
  /*!**************************!*\
83544
83544
  !*** ./lib-esm/index.js ***!
83545
83545
  \**************************/
83546
- /*! exports provided: DataStore, DataStoreClass, initSchema, Predicates, ModelPredicateCreator, ModelSortPredicateCreator, utils, isSchemaModel, isAssociatedWith, isTargetNameAssociation, isModelAttributeAuth, isModelAttributeKey, isModelAttributePrimaryKey, isModelAttributeCompositeKey, ModelAttributeAuthAllow, ModelAttributeAuthProvider, GraphQLScalarType, isGraphQLScalarType, isModelFieldType, isNonModelFieldType, isEnumFieldType, OpType, isPredicateObj, isPredicateGroup, QueryOne, SortDirection, AuthModeStrategyType, ModelOperation, syncExpression, DISCARD, LimitTimerRaceResolvedValues */
83546
+ /*! exports provided: DataStore, DataStoreClass, initSchema, Predicates, ModelPredicateCreator, ModelSortPredicateCreator, utils, isSchemaModel, isAssociatedWith, isTargetNameAssociation, isModelAttributeAuth, isModelAttributeKey, isModelAttributePrimaryKey, isModelAttributeCompositeKey, ModelAttributeAuthAllow, ModelAttributeAuthProvider, GraphQLScalarType, isGraphQLScalarType, isModelFieldType, isNonModelFieldType, isEnumFieldType, OpType, isPredicateObj, isPredicateGroup, QueryOne, SortDirection, AuthModeStrategyType, ModelOperation, syncExpression, ProcessName, DISCARD, LimitTimerRaceResolvedValues */
83547
83547
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
83548
83548
 
83549
83549
  "use strict";
@@ -83609,6 +83609,8 @@ __webpack_require__.r(__webpack_exports__);
83609
83609
 
83610
83610
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "syncExpression", function() { return _types__WEBPACK_IMPORTED_MODULE_3__["syncExpression"]; });
83611
83611
 
83612
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProcessName", function() { return _types__WEBPACK_IMPORTED_MODULE_3__["ProcessName"]; });
83613
+
83612
83614
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DISCARD", function() { return _types__WEBPACK_IMPORTED_MODULE_3__["DISCARD"]; });
83613
83615
 
83614
83616
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LimitTimerRaceResolvedValues", function() { return _types__WEBPACK_IMPORTED_MODULE_3__["LimitTimerRaceResolvedValues"]; });
@@ -90228,9 +90230,9 @@ function () {
90228
90230
  var MutationEvent = this.modelClasses['MutationEvent'];
90229
90231
  this.outbox = new _outbox__WEBPACK_IMPORTED_MODULE_8__["MutationEventOutbox"](this.schema, MutationEvent, modelInstanceCreator, ownSymbol);
90230
90232
  this.modelMerger = new _merger__WEBPACK_IMPORTED_MODULE_7__["ModelMerger"](this.outbox, ownSymbol);
90231
- this.syncQueriesProcessor = new _processors_sync__WEBPACK_IMPORTED_MODULE_11__["SyncProcessor"](this.schema, this.syncPredicates, this.amplifyConfig, this.authModeStrategy);
90232
- this.subscriptionsProcessor = new _processors_subscription__WEBPACK_IMPORTED_MODULE_10__["SubscriptionProcessor"](this.schema, this.syncPredicates, this.amplifyConfig, this.authModeStrategy);
90233
- this.mutationsProcessor = new _processors_mutation__WEBPACK_IMPORTED_MODULE_9__["MutationProcessor"](this.schema, this.storage, this.userModelClasses, this.outbox, this.modelInstanceCreator, MutationEvent, this.amplifyConfig, this.authModeStrategy, conflictHandler, errorHandler);
90233
+ this.syncQueriesProcessor = new _processors_sync__WEBPACK_IMPORTED_MODULE_11__["SyncProcessor"](this.schema, this.syncPredicates, this.amplifyConfig, this.authModeStrategy, errorHandler);
90234
+ this.subscriptionsProcessor = new _processors_subscription__WEBPACK_IMPORTED_MODULE_10__["SubscriptionProcessor"](this.schema, this.syncPredicates, this.amplifyConfig, this.authModeStrategy, errorHandler);
90235
+ this.mutationsProcessor = new _processors_mutation__WEBPACK_IMPORTED_MODULE_9__["MutationProcessor"](this.schema, this.storage, this.userModelClasses, this.outbox, this.modelInstanceCreator, MutationEvent, this.amplifyConfig, this.authModeStrategy, errorHandler, conflictHandler);
90234
90236
  this.datastoreConnectivity = new _datastoreConnectivity__WEBPACK_IMPORTED_MODULE_6__["default"]();
90235
90237
  }
90236
90238
 
@@ -92501,12 +92503,18 @@ var __values = undefined && undefined.__values || function (o) {
92501
92503
 
92502
92504
 
92503
92505
  var MAX_ATTEMPTS = 10;
92504
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('DataStore');
92506
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('DataStore'); // TODO: add additional error maps
92507
+
92508
+ var errorMap = {
92509
+ BadRecord: function BadRecord(error) {
92510
+ return /^Cannot return \w+ for [\w-_]+ type/.test(error.message);
92511
+ }
92512
+ };
92505
92513
 
92506
92514
  var MutationProcessor =
92507
92515
  /** @class */
92508
92516
  function () {
92509
- function MutationProcessor(schema, storage, userClasses, outbox, modelInstanceCreator, MutationEvent, amplifyConfig, authModeStrategy, conflictHandler, errorHandler) {
92517
+ function MutationProcessor(schema, storage, userClasses, outbox, modelInstanceCreator, MutationEvent, amplifyConfig, authModeStrategy, errorHandler, conflictHandler) {
92510
92518
  if (amplifyConfig === void 0) {
92511
92519
  amplifyConfig = {};
92512
92520
  }
@@ -92519,8 +92527,8 @@ function () {
92519
92527
  this.MutationEvent = MutationEvent;
92520
92528
  this.amplifyConfig = amplifyConfig;
92521
92529
  this.authModeStrategy = authModeStrategy;
92522
- this.conflictHandler = conflictHandler;
92523
92530
  this.errorHandler = errorHandler;
92531
+ this.conflictHandler = conflictHandler;
92524
92532
  this.typeQuery = new WeakMap();
92525
92533
  this.processing = false;
92526
92534
  this.generateQueries();
@@ -92971,11 +92979,14 @@ function () {
92971
92979
  return [4
92972
92980
  /*yield*/
92973
92981
  , this.errorHandler({
92974
- localModel: this.modelInstanceCreator(modelConstructor, variables.input),
92982
+ recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',
92983
+ localModel: variables.input,
92975
92984
  message: error.message,
92976
92985
  operation: operation,
92977
- errorType: error.errorType,
92986
+ errorType: Object(_utils__WEBPACK_IMPORTED_MODULE_5__["mapErrorToType"])(errorMap, error),
92978
92987
  errorInfo: error.errorInfo,
92988
+ process: _types__WEBPACK_IMPORTED_MODULE_3__["ProcessName"].mutate,
92989
+ cause: error,
92979
92990
  remoteModel: error.data ? this.modelInstanceCreator(modelConstructor, error.data) : null
92980
92991
  })];
92981
92992
 
@@ -92988,7 +92999,7 @@ function () {
92988
92999
 
92989
93000
  case 15:
92990
93001
  err_3 = _h.sent();
92991
- logger.warn('failed to execute errorHandler', err_3);
93002
+ logger.warn('Mutation error handler failed with:', err_3);
92992
93003
  return [3
92993
93004
  /*break*/
92994
93005
  , 17];
@@ -93221,9 +93232,10 @@ __webpack_require__.r(__webpack_exports__);
93221
93232
  /* harmony import */ var _aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @aws-amplify/pubsub */ "@aws-amplify/pubsub");
93222
93233
  /* harmony import */ var _aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__);
93223
93234
  /* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
93224
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils */ "./lib-esm/sync/utils.js");
93225
- /* harmony import */ var _predicates__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../predicates */ "./lib-esm/predicates/index.js");
93226
- /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../util */ "./lib-esm/util.js");
93235
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../types */ "./lib-esm/types.js");
93236
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils */ "./lib-esm/sync/utils.js");
93237
+ /* harmony import */ var _predicates__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../predicates */ "./lib-esm/predicates/index.js");
93238
+ /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../util */ "./lib-esm/util.js");
93227
93239
  var __assign = undefined && undefined.__assign || function () {
93228
93240
  __assign = Object.assign || function (t) {
93229
93241
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -93427,7 +93439,23 @@ var __spread = undefined && undefined.__spread || function () {
93427
93439
 
93428
93440
 
93429
93441
 
93430
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('DataStore');
93442
+
93443
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('DataStore'); // TODO: add additional error maps
93444
+
93445
+ var errorMap = {
93446
+ Unauthorized: function Unauthorized(givenError) {
93447
+ var _a = givenError.error,
93448
+ _b = __read((_a === void 0 ? {
93449
+ errors: []
93450
+ } : _a).errors, 1),
93451
+ _c = _b[0],
93452
+ _d = (_c === void 0 ? {} : _c).message,
93453
+ message = _d === void 0 ? '' : _d;
93454
+
93455
+ var regex = /Connection failed.+Unauthorized/;
93456
+ return regex.test(message);
93457
+ }
93458
+ };
93431
93459
  var CONTROL_MSG;
93432
93460
 
93433
93461
  (function (CONTROL_MSG) {
@@ -93445,7 +93473,7 @@ var USER_CREDENTIALS;
93445
93473
  var SubscriptionProcessor =
93446
93474
  /** @class */
93447
93475
  function () {
93448
- function SubscriptionProcessor(schema, syncPredicates, amplifyConfig, authModeStrategy) {
93476
+ function SubscriptionProcessor(schema, syncPredicates, amplifyConfig, authModeStrategy, errorHandler) {
93449
93477
  if (amplifyConfig === void 0) {
93450
93478
  amplifyConfig = {};
93451
93479
  }
@@ -93454,6 +93482,7 @@ function () {
93454
93482
  this.syncPredicates = syncPredicates;
93455
93483
  this.amplifyConfig = amplifyConfig;
93456
93484
  this.authModeStrategy = authModeStrategy;
93485
+ this.errorHandler = errorHandler;
93457
93486
  this.typeQuery = new WeakMap();
93458
93487
  this.buffer = [];
93459
93488
  }
@@ -93466,7 +93495,7 @@ function () {
93466
93495
  ownerField = _a.ownerField,
93467
93496
  ownerValue = _a.ownerValue;
93468
93497
 
93469
- var _b = __read(Object(_utils__WEBPACK_IMPORTED_MODULE_6__["buildSubscriptionGraphQLOperation"])(namespace, model, transformerMutationType, isOwner, ownerField), 3),
93498
+ var _b = __read(Object(_utils__WEBPACK_IMPORTED_MODULE_7__["buildSubscriptionGraphQLOperation"])(namespace, model, transformerMutationType, isOwner, ownerField), 3),
93470
93499
  opType = _b[0],
93471
93500
  opName = _b[1],
93472
93501
  query = _b[2];
@@ -93491,7 +93520,7 @@ function () {
93491
93520
  oidcTokenPayload = {};
93492
93521
  }
93493
93522
 
93494
- var rules = Object(_utils__WEBPACK_IMPORTED_MODULE_6__["getAuthorizationRules"])(model); // Return null if user doesn't have proper credentials for private API with IAM auth
93523
+ var rules = Object(_utils__WEBPACK_IMPORTED_MODULE_7__["getAuthorizationRules"])(model); // Return null if user doesn't have proper credentials for private API with IAM auth
93495
93524
 
93496
93525
  var iamPrivateAuth = authMode === _aws_amplify_api__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"].AWS_IAM && rules.find(function (rule) {
93497
93526
  return rule.authStrategy === 'private' && rule.provider === 'iam';
@@ -93510,8 +93539,8 @@ function () {
93510
93539
  });
93511
93540
  var validGroup = (authMode === _aws_amplify_api__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"].AMAZON_COGNITO_USER_POOLS || authMode === _aws_amplify_api__WEBPACK_IMPORTED_MODULE_0__["GRAPHQL_AUTH_MODE"].OPENID_CONNECT) && groupAuthRules.find(function (groupAuthRule) {
93512
93541
  // validate token against groupClaim
93513
- var cognitoUserGroups = Object(_utils__WEBPACK_IMPORTED_MODULE_6__["getUserGroupsFromToken"])(cognitoTokenPayload, groupAuthRule);
93514
- var oidcUserGroups = Object(_utils__WEBPACK_IMPORTED_MODULE_6__["getUserGroupsFromToken"])(oidcTokenPayload, groupAuthRule);
93542
+ var cognitoUserGroups = Object(_utils__WEBPACK_IMPORTED_MODULE_7__["getUserGroupsFromToken"])(cognitoTokenPayload, groupAuthRule);
93543
+ var oidcUserGroups = Object(_utils__WEBPACK_IMPORTED_MODULE_7__["getUserGroupsFromToken"])(oidcTokenPayload, groupAuthRule);
93515
93544
  return __spread(cognitoUserGroups, oidcUserGroups).find(function (userGroup) {
93516
93545
  return groupAuthRule.groups.find(function (group) {
93517
93546
  return group === userGroup;
@@ -93720,7 +93749,7 @@ function () {
93720
93749
  case 0:
93721
93750
  return [4
93722
93751
  /*yield*/
93723
- , Object(_utils__WEBPACK_IMPORTED_MODULE_6__["getModelAuthModes"])({
93752
+ , Object(_utils__WEBPACK_IMPORTED_MODULE_7__["getModelAuthModes"])({
93724
93753
  authModeStrategy: this.authModeStrategy,
93725
93754
  defaultAuthMode: this.amplifyConfig.aws_appsync_authenticationType,
93726
93755
  modelName: modelDefinition.name,
@@ -93730,9 +93759,9 @@ function () {
93730
93759
  case 1:
93731
93760
  modelAuthModes = _d.sent();
93732
93761
  readAuthModes = modelAuthModes.READ;
93733
- subscriptions = __assign(__assign({}, subscriptions), (_a = {}, _a[modelDefinition.name] = (_b = {}, _b[_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].CREATE] = [], _b[_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].UPDATE] = [], _b[_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].DELETE] = [], _b), _a));
93734
- operations = [_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].CREATE, _utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].UPDATE, _utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].DELETE];
93735
- operationAuthModeAttempts = (_c = {}, _c[_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].CREATE] = 0, _c[_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].UPDATE] = 0, _c[_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].DELETE] = 0, _c);
93762
+ subscriptions = __assign(__assign({}, subscriptions), (_a = {}, _a[modelDefinition.name] = (_b = {}, _b[_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].CREATE] = [], _b[_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].UPDATE] = [], _b[_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].DELETE] = [], _b), _a));
93763
+ operations = [_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].CREATE, _utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].UPDATE, _utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].DELETE];
93764
+ operationAuthModeAttempts = (_c = {}, _c[_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].CREATE] = 0, _c[_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].UPDATE] = 0, _c[_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].DELETE] = 0, _c);
93736
93765
 
93737
93766
  _authModeRetry = function authModeRetry(operation) {
93738
93767
  return __awaiter(_this, void 0, void 0, function () {
@@ -93746,7 +93775,7 @@ function () {
93746
93775
  _a = this.buildSubscription(namespace, modelDefinition, operation, userCredentials, cognitoTokenPayload, oidcTokenPayload, readAuthModes[operationAuthModeAttempts[operation]]), transformerMutationType = _a.opType, opName = _a.opName, query = _a.query, isOwner = _a.isOwner, ownerField = _a.ownerField, ownerValue = _a.ownerValue, authMode = _a.authMode;
93747
93776
  return [4
93748
93777
  /*yield*/
93749
- , Object(_utils__WEBPACK_IMPORTED_MODULE_6__["getTokenForCustomAuth"])(authMode, this.amplifyConfig)];
93778
+ , Object(_utils__WEBPACK_IMPORTED_MODULE_7__["getTokenForCustomAuth"])(authMode, this.amplifyConfig)];
93750
93779
 
93751
93780
  case 1:
93752
93781
  authToken = _b.sent();
@@ -93792,7 +93821,7 @@ function () {
93792
93821
  return;
93793
93822
  }
93794
93823
 
93795
- var predicatesGroup = _predicates__WEBPACK_IMPORTED_MODULE_7__["ModelPredicateCreator"].getPredicates(_this.syncPredicates.get(modelDefinition), false);
93824
+ var predicatesGroup = _predicates__WEBPACK_IMPORTED_MODULE_8__["ModelPredicateCreator"].getPredicates(_this.syncPredicates.get(modelDefinition), false);
93796
93825
  var _b = data,
93797
93826
  _c = opName,
93798
93827
  record = _b[_c]; // checking incoming subscription against syncPredicate.
@@ -93807,46 +93836,93 @@ function () {
93807
93836
  _this.drainBuffer();
93808
93837
  },
93809
93838
  error: function error(subscriptionError) {
93810
- var _a = subscriptionError.error,
93811
- _b = __read((_a === void 0 ? {
93812
- errors: []
93813
- } : _a).errors, 1),
93814
- _c = _b[0],
93815
- _d = (_c === void 0 ? {} : _c).message,
93816
- message = _d === void 0 ? '' : _d;
93817
-
93818
- if (message.includes(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR) || message.includes(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__["CONTROL_MSG"].CONNECTION_FAILED)) {
93819
- // Unsubscribe and clear subscription array for model/operation
93820
- subscriptions[modelDefinition.name][transformerMutationType].forEach(function (subscription) {
93821
- return subscription.unsubscribe();
93822
- });
93823
- subscriptions[modelDefinition.name][transformerMutationType] = [];
93824
- operationAuthModeAttempts[operation]++;
93825
-
93826
- if (operationAuthModeAttempts[operation] >= readAuthModes.length) {
93827
- logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1]);
93828
- logger.warn('subscriptionError', message);
93829
- return;
93830
- } else {
93831
- logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1] + ". Retrying with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
93832
-
93833
- _authModeRetry(operation);
93834
-
93835
- return;
93836
- }
93837
- }
93839
+ return __awaiter(_this, void 0, void 0, function () {
93840
+ var _a, _b, _c, _d, message, e_1;
93841
+
93842
+ return __generator(this, function (_e) {
93843
+ switch (_e.label) {
93844
+ case 0:
93845
+ _a = subscriptionError.error, _b = __read((_a === void 0 ? {
93846
+ errors: []
93847
+ } : _a).errors, 1), _c = _b[0], _d = (_c === void 0 ? {} : _c).message, message = _d === void 0 ? '' : _d;
93848
+ _e.label = 1;
93849
+
93850
+ case 1:
93851
+ _e.trys.push([1, 3,, 4]);
93852
+
93853
+ return [4
93854
+ /*yield*/
93855
+ , this.errorHandler({
93856
+ recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',
93857
+ localModel: null,
93858
+ message: message,
93859
+ model: modelDefinition.name,
93860
+ operation: operation,
93861
+ errorType: Object(_utils__WEBPACK_IMPORTED_MODULE_7__["mapErrorToType"])(errorMap, subscriptionError),
93862
+ process: _types__WEBPACK_IMPORTED_MODULE_6__["ProcessName"].subscribe,
93863
+ remoteModel: null,
93864
+ cause: subscriptionError
93865
+ })];
93866
+
93867
+ case 2:
93868
+ _e.sent();
93869
+
93870
+ return [3
93871
+ /*break*/
93872
+ , 4];
93873
+
93874
+ case 3:
93875
+ e_1 = _e.sent();
93876
+ logger.error('Sync error handler failed with:', e_1);
93877
+ return [3
93878
+ /*break*/
93879
+ , 4];
93880
+
93881
+ case 4:
93882
+ if (message.includes(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR) || message.includes(_aws_amplify_pubsub__WEBPACK_IMPORTED_MODULE_4__["CONTROL_MSG"].CONNECTION_FAILED)) {
93883
+ // Unsubscribe and clear subscription array for model/operation
93884
+ subscriptions[modelDefinition.name][transformerMutationType].forEach(function (subscription) {
93885
+ return subscription.unsubscribe();
93886
+ });
93887
+ subscriptions[modelDefinition.name][transformerMutationType] = [];
93888
+ operationAuthModeAttempts[operation]++;
93889
+
93890
+ if (operationAuthModeAttempts[operation] >= readAuthModes.length) {
93891
+ logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1]);
93892
+ logger.warn('subscriptionError', message);
93893
+ return [2
93894
+ /*return*/
93895
+ ];
93896
+ } else {
93897
+ logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1] + ". Retrying with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
93898
+
93899
+ _authModeRetry(operation);
93900
+
93901
+ return [2
93902
+ /*return*/
93903
+ ];
93904
+ }
93905
+ }
93838
93906
 
93839
- logger.warn('subscriptionError', message);
93907
+ logger.warn('subscriptionError', message);
93840
93908
 
93841
- if (typeof subscriptionReadyCallback === 'function') {
93842
- subscriptionReadyCallback();
93843
- }
93909
+ if (typeof subscriptionReadyCallback === 'function') {
93910
+ subscriptionReadyCallback();
93911
+ }
93844
93912
 
93845
- if (message.includes('"errorType":"Unauthorized"') || message.includes('"errorType":"OperationDisabled"')) {
93846
- return;
93847
- }
93913
+ if (message.includes('"errorType":"Unauthorized"') || message.includes('"errorType":"OperationDisabled"')) {
93914
+ return [2
93915
+ /*return*/
93916
+ ];
93917
+ }
93848
93918
 
93849
- observer.error(message);
93919
+ observer.error(message);
93920
+ return [2
93921
+ /*return*/
93922
+ ];
93923
+ }
93924
+ });
93925
+ });
93850
93926
  }
93851
93927
  }));
93852
93928
  promises.push(function () {
@@ -93909,13 +93985,13 @@ function () {
93909
93985
 
93910
93986
  return function () {
93911
93987
  Object.keys(subscriptions).forEach(function (modelName) {
93912
- subscriptions[modelName][_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].CREATE].forEach(function (subscription) {
93988
+ subscriptions[modelName][_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].CREATE].forEach(function (subscription) {
93913
93989
  return subscription.unsubscribe();
93914
93990
  });
93915
- subscriptions[modelName][_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].UPDATE].forEach(function (subscription) {
93991
+ subscriptions[modelName][_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].UPDATE].forEach(function (subscription) {
93916
93992
  return subscription.unsubscribe();
93917
93993
  });
93918
- subscriptions[modelName][_utils__WEBPACK_IMPORTED_MODULE_6__["TransformerMutationType"].DELETE].forEach(function (subscription) {
93994
+ subscriptions[modelName][_utils__WEBPACK_IMPORTED_MODULE_7__["TransformerMutationType"].DELETE].forEach(function (subscription) {
93919
93995
  return subscription.unsubscribe();
93920
93996
  });
93921
93997
  });
@@ -93940,7 +94016,7 @@ function () {
93940
94016
 
93941
94017
  var predicates = predicatesGroup.predicates,
93942
94018
  type = predicatesGroup.type;
93943
- return Object(_util__WEBPACK_IMPORTED_MODULE_8__["validatePredicate"])(record, type, predicates);
94019
+ return Object(_util__WEBPACK_IMPORTED_MODULE_9__["validatePredicate"])(record, type, predicates);
93944
94020
  };
93945
94021
 
93946
94022
  SubscriptionProcessor.prototype.pushToBuffer = function (transformerMutationType, modelDefinition, data) {
@@ -93978,9 +94054,10 @@ __webpack_require__.r(__webpack_exports__);
93978
94054
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SyncProcessor", function() { return SyncProcessor; });
93979
94055
  /* harmony import */ var _aws_amplify_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/api */ "../api/lib-esm/index.js");
93980
94056
  /* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
93981
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils */ "./lib-esm/sync/utils.js");
93982
- /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @aws-amplify/core */ "../core/lib-esm/index.js");
93983
- /* harmony import */ var _predicates__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../predicates */ "./lib-esm/predicates/index.js");
94057
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../types */ "./lib-esm/types.js");
94058
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils */ "./lib-esm/sync/utils.js");
94059
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @aws-amplify/core */ "../core/lib-esm/index.js");
94060
+ /* harmony import */ var _predicates__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../predicates */ "./lib-esm/predicates/index.js");
93984
94061
  var __assign = undefined && undefined.__assign || function () {
93985
94062
  __assign = Object.assign || function (t) {
93986
94063
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -94189,17 +94266,24 @@ var __values = undefined && undefined.__values || function (o) {
94189
94266
 
94190
94267
 
94191
94268
 
94269
+
94192
94270
  var opResultDefaults = {
94193
94271
  items: [],
94194
94272
  nextToken: null,
94195
94273
  startedAt: null
94196
94274
  };
94197
- var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('DataStore');
94275
+ var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["ConsoleLogger"]('DataStore'); // TODO: add additional error maps
94276
+
94277
+ var errorMap = {
94278
+ BadRecord: function BadRecord(error) {
94279
+ return /^Cannot return \w+ for [\w-_]+ type/.test(error.message);
94280
+ }
94281
+ };
94198
94282
 
94199
94283
  var SyncProcessor =
94200
94284
  /** @class */
94201
94285
  function () {
94202
- function SyncProcessor(schema, syncPredicates, amplifyConfig, authModeStrategy) {
94286
+ function SyncProcessor(schema, syncPredicates, amplifyConfig, authModeStrategy, errorHandler, modelInstanceCreator) {
94203
94287
  if (amplifyConfig === void 0) {
94204
94288
  amplifyConfig = {};
94205
94289
  }
@@ -94208,6 +94292,8 @@ function () {
94208
94292
  this.syncPredicates = syncPredicates;
94209
94293
  this.amplifyConfig = amplifyConfig;
94210
94294
  this.authModeStrategy = authModeStrategy;
94295
+ this.errorHandler = errorHandler;
94296
+ this.modelInstanceCreator = modelInstanceCreator;
94211
94297
  this.typeQuery = new WeakMap();
94212
94298
  this.generateQueries();
94213
94299
  }
@@ -94220,7 +94306,7 @@ function () {
94220
94306
  var syncable = _a.syncable;
94221
94307
  return syncable;
94222
94308
  }).forEach(function (model) {
94223
- var _a = __read(Object(_utils__WEBPACK_IMPORTED_MODULE_2__["buildGraphQLOperation"])(namespace, model, 'LIST'), 1),
94309
+ var _a = __read(Object(_utils__WEBPACK_IMPORTED_MODULE_3__["buildGraphQLOperation"])(namespace, model, 'LIST'), 1),
94224
94310
  _b = __read(_a[0]),
94225
94311
  opNameQuery = _b.slice(1);
94226
94312
 
@@ -94234,13 +94320,13 @@ function () {
94234
94320
  return null;
94235
94321
  }
94236
94322
 
94237
- var predicatesGroup = _predicates__WEBPACK_IMPORTED_MODULE_4__["ModelPredicateCreator"].getPredicates(this.syncPredicates.get(model), false);
94323
+ var predicatesGroup = _predicates__WEBPACK_IMPORTED_MODULE_5__["ModelPredicateCreator"].getPredicates(this.syncPredicates.get(model), false);
94238
94324
 
94239
94325
  if (!predicatesGroup) {
94240
94326
  return null;
94241
94327
  }
94242
94328
 
94243
- return Object(_utils__WEBPACK_IMPORTED_MODULE_2__["predicateToGraphQLFilter"])(predicatesGroup);
94329
+ return Object(_utils__WEBPACK_IMPORTED_MODULE_3__["predicateToGraphQLFilter"])(predicatesGroup);
94244
94330
  };
94245
94331
 
94246
94332
  SyncProcessor.prototype.retrievePage = function (modelDefinition, lastSync, nextToken, limit, filter) {
@@ -94265,7 +94351,7 @@ function () {
94265
94351
  };
94266
94352
  return [4
94267
94353
  /*yield*/
94268
- , Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getModelAuthModes"])({
94354
+ , Object(_utils__WEBPACK_IMPORTED_MODULE_3__["getModelAuthModes"])({
94269
94355
  authModeStrategy: this.authModeStrategy,
94270
94356
  defaultAuthMode: this.amplifyConfig.aws_appsync_authenticationType,
94271
94357
  modelName: modelDefinition.name,
@@ -94314,7 +94400,7 @@ function () {
94314
94400
  authMode = readAuthModes[authModeAttempts - 1];
94315
94401
  logger.debug("Sync failed with authMode: " + authMode, error_1);
94316
94402
 
94317
- if (Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getClientSideAuthError"])(error_1) || Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getForbiddenError"])(error_1)) {
94403
+ if (Object(_utils__WEBPACK_IMPORTED_MODULE_3__["getClientSideAuthError"])(error_1) || Object(_utils__WEBPACK_IMPORTED_MODULE_3__["getForbiddenError"])(error_1)) {
94318
94404
  // return empty list of data so DataStore will continue to sync other models
94319
94405
  logger.warn("User is unauthorized to query " + opName + " with auth mode " + authMode + ". No data could be returned.");
94320
94406
  return [2
@@ -94390,17 +94476,20 @@ function () {
94390
94476
  case 0:
94391
94477
  return [4
94392
94478
  /*yield*/
94393
- , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["jitteredExponentialRetry"])(function (query, variables) {
94479
+ , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["jitteredExponentialRetry"])(function (query, variables) {
94394
94480
  return __awaiter(_this, void 0, void 0, function () {
94395
94481
  var authToken, error_2, clientOrForbiddenErrorMessage, hasItems, result, unauthorized, result;
94482
+
94483
+ var _this = this;
94484
+
94396
94485
  return __generator(this, function (_a) {
94397
94486
  switch (_a.label) {
94398
94487
  case 0:
94399
- _a.trys.push([0, 3,, 4]);
94488
+ _a.trys.push([0, 3,, 8]);
94400
94489
 
94401
94490
  return [4
94402
94491
  /*yield*/
94403
- , Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getTokenForCustomAuth"])(authMode, this.amplifyConfig)];
94492
+ , Object(_utils__WEBPACK_IMPORTED_MODULE_3__["getTokenForCustomAuth"])(authMode, this.amplifyConfig)];
94404
94493
 
94405
94494
  case 1:
94406
94495
  authToken = _a.sent();
@@ -94420,39 +94509,94 @@ function () {
94420
94509
 
94421
94510
  case 3:
94422
94511
  error_2 = _a.sent();
94423
- clientOrForbiddenErrorMessage = Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getClientSideAuthError"])(error_2) || Object(_utils__WEBPACK_IMPORTED_MODULE_2__["getForbiddenError"])(error_2);
94512
+ clientOrForbiddenErrorMessage = Object(_utils__WEBPACK_IMPORTED_MODULE_3__["getClientSideAuthError"])(error_2) || Object(_utils__WEBPACK_IMPORTED_MODULE_3__["getForbiddenError"])(error_2);
94424
94513
 
94425
94514
  if (clientOrForbiddenErrorMessage) {
94426
- throw new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["NonRetryableError"](clientOrForbiddenErrorMessage);
94515
+ throw new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["NonRetryableError"](clientOrForbiddenErrorMessage);
94427
94516
  }
94428
94517
 
94429
94518
  hasItems = Boolean(error_2 && error_2.data && error_2.data[opName] && error_2.data[opName].items);
94519
+ if (!this.partialDataFeatureFlagEnabled()) return [3
94520
+ /*break*/
94521
+ , 7];
94522
+ if (!hasItems) return [3
94523
+ /*break*/
94524
+ , 6];
94525
+ result = error_2;
94526
+ result.data[opName].items = result.data[opName].items.filter(function (item) {
94527
+ return item !== null;
94528
+ });
94529
+ if (!error_2.errors) return [3
94530
+ /*break*/
94531
+ , 5];
94532
+ return [4
94533
+ /*yield*/
94534
+ , Promise.all(error_2.errors.map(function (err) {
94535
+ return __awaiter(_this, void 0, void 0, function () {
94536
+ var e_1;
94537
+ return __generator(this, function (_a) {
94538
+ switch (_a.label) {
94539
+ case 0:
94540
+ _a.trys.push([0, 2,, 3]);
94430
94541
 
94431
- if (this.partialDataFeatureFlagEnabled()) {
94432
- if (hasItems) {
94433
- result = error_2;
94434
- result.data[opName].items = result.data[opName].items.filter(function (item) {
94435
- return item !== null;
94542
+ return [4
94543
+ /*yield*/
94544
+ , this.errorHandler({
94545
+ recoverySuggestion: 'Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues',
94546
+ localModel: null,
94547
+ message: err.message,
94548
+ model: modelDefinition.name,
94549
+ operation: opName,
94550
+ errorType: Object(_utils__WEBPACK_IMPORTED_MODULE_3__["mapErrorToType"])(errorMap, err),
94551
+ process: _types__WEBPACK_IMPORTED_MODULE_2__["ProcessName"].sync,
94552
+ remoteModel: null,
94553
+ cause: err
94554
+ })];
94555
+
94556
+ case 1:
94557
+ _a.sent();
94558
+
94559
+ return [3
94560
+ /*break*/
94561
+ , 3];
94562
+
94563
+ case 2:
94564
+ e_1 = _a.sent();
94565
+ logger.error('Sync error handler failed with:', e_1);
94566
+ return [3
94567
+ /*break*/
94568
+ , 3];
94569
+
94570
+ case 3:
94571
+ return [2
94572
+ /*return*/
94573
+ ];
94574
+ }
94436
94575
  });
94576
+ });
94577
+ }))];
94437
94578
 
94438
- if (error_2.errors) {
94439
- _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["Hub"].dispatch('datastore', {
94440
- event: 'syncQueriesPartialSyncError',
94441
- data: {
94442
- errors: error_2.errors,
94443
- modelName: modelDefinition.name
94444
- }
94445
- });
94446
- }
94579
+ case 4:
94580
+ _a.sent();
94447
94581
 
94448
- return [2
94449
- /*return*/
94450
- , result];
94451
- } else {
94452
- throw error_2;
94582
+ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["Hub"].dispatch('datastore', {
94583
+ event: 'syncQueriesPartialSyncError',
94584
+ data: {
94585
+ errors: error_2.errors,
94586
+ modelName: modelDefinition.name
94453
94587
  }
94454
- }
94588
+ });
94589
+ _a.label = 5;
94590
+
94591
+ case 5:
94592
+ return [2
94593
+ /*return*/
94594
+ , result];
94455
94595
 
94596
+ case 6:
94597
+ throw error_2;
94598
+
94599
+ case 7:
94456
94600
  unauthorized = error_2 && error_2.errors && error_2.errors.some(function (err) {
94457
94601
  return err.errorType === 'Unauthorized';
94458
94602
  });
@@ -94478,9 +94622,9 @@ function () {
94478
94622
 
94479
94623
  return [3
94480
94624
  /*break*/
94481
- , 4];
94625
+ , 8];
94482
94626
 
94483
- case 4:
94627
+ case 8:
94484
94628
  return [2
94485
94629
  /*return*/
94486
94630
  ];
@@ -94508,7 +94652,7 @@ function () {
94508
94652
  var parentPromises = new Map();
94509
94653
  var observable = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_1__["default"](function (observer) {
94510
94654
  var sortedTypesLastSyncs = Object.values(_this.schema.namespaces).reduce(function (map, namespace) {
94511
- var e_1, _a;
94655
+ var e_2, _a;
94512
94656
 
94513
94657
  try {
94514
94658
  for (var _b = __values(Array.from(namespace.modelTopologicalOrdering.keys())), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -94516,15 +94660,15 @@ function () {
94516
94660
  var typeLastSync = typesLastSync.get(namespace.models[modelName]);
94517
94661
  map.set(namespace.models[modelName], typeLastSync);
94518
94662
  }
94519
- } catch (e_1_1) {
94520
- e_1 = {
94521
- error: e_1_1
94663
+ } catch (e_2_1) {
94664
+ e_2 = {
94665
+ error: e_2_1
94522
94666
  };
94523
94667
  } finally {
94524
94668
  try {
94525
94669
  if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
94526
94670
  } finally {
94527
- if (e_1) throw e_1.error;
94671
+ if (e_2) throw e_2.error;
94528
94672
  }
94529
94673
  }
94530
94674
 
@@ -94655,11 +94799,12 @@ function () {
94655
94799
  /*!*******************************!*\
94656
94800
  !*** ./lib-esm/sync/utils.js ***!
94657
94801
  \*******************************/
94658
- /*! exports provided: TransformerMutationType, getMetadataFields, generateSelectionSet, getAuthorizationRules, buildSubscriptionGraphQLOperation, buildGraphQLOperation, createMutationInstanceFromModelOperation, predicateToGraphQLCondition, predicateToGraphQLFilter, getUserGroupsFromToken, getModelAuthModes, getForbiddenError, getClientSideAuthError, getTokenForCustomAuth */
94802
+ /*! exports provided: mapErrorToType, TransformerMutationType, getMetadataFields, generateSelectionSet, getAuthorizationRules, buildSubscriptionGraphQLOperation, buildGraphQLOperation, createMutationInstanceFromModelOperation, predicateToGraphQLCondition, predicateToGraphQLFilter, getUserGroupsFromToken, getModelAuthModes, getForbiddenError, getClientSideAuthError, getTokenForCustomAuth */
94659
94803
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
94660
94804
 
94661
94805
  "use strict";
94662
94806
  __webpack_require__.r(__webpack_exports__);
94807
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mapErrorToType", function() { return mapErrorToType; });
94663
94808
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformerMutationType", function() { return TransformerMutationType; });
94664
94809
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMetadataFields", function() { return getMetadataFields; });
94665
94810
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateSelectionSet", function() { return generateSelectionSet; });
@@ -94848,6 +94993,58 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
94848
94993
  }
94849
94994
  };
94850
94995
 
94996
+ var __read = undefined && undefined.__read || function (o, n) {
94997
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
94998
+ if (!m) return o;
94999
+ var i = m.call(o),
95000
+ r,
95001
+ ar = [],
95002
+ e;
95003
+
95004
+ try {
95005
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
95006
+ ar.push(r.value);
95007
+ }
95008
+ } catch (error) {
95009
+ e = {
95010
+ error: error
95011
+ };
95012
+ } finally {
95013
+ try {
95014
+ if (r && !r.done && (m = i["return"])) m.call(i);
95015
+ } finally {
95016
+ if (e) throw e.error;
95017
+ }
95018
+ }
95019
+
95020
+ return ar;
95021
+ };
95022
+
95023
+ var __spread = undefined && undefined.__spread || function () {
95024
+ for (var ar = [], i = 0; i < arguments.length; i++) {
95025
+ ar = ar.concat(__read(arguments[i]));
95026
+ }
95027
+
95028
+ return ar;
95029
+ };
95030
+
95031
+ var __values = undefined && undefined.__values || function (o) {
95032
+ var s = typeof Symbol === "function" && Symbol.iterator,
95033
+ m = s && o[s],
95034
+ i = 0;
95035
+ if (m) return m.call(o);
95036
+ if (o && typeof o.length === "number") return {
95037
+ next: function next() {
95038
+ if (o && i >= o.length) o = void 0;
95039
+ return {
95040
+ value: o && o[i++],
95041
+ done: !o
95042
+ };
95043
+ }
95044
+ };
95045
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
95046
+ };
95047
+
94851
95048
 
94852
95049
 
94853
95050
 
@@ -94863,7 +95060,42 @@ var GraphQLOperationType;
94863
95060
  GraphQLOperationType["DELETE"] = "mutation";
94864
95061
  GraphQLOperationType["GET"] = "query";
94865
95062
  })(GraphQLOperationType || (GraphQLOperationType = {}));
95063
+ /**
95064
+ * Categorizes an error with a broad error type, intended to make
95065
+ * customer error handling code simpler.
95066
+ * @param errorMap Error names and a list of patterns that indicate them (each pattern as a regex or function)
95067
+ * @param error The underying error to categorize.
95068
+ */
95069
+
95070
+
95071
+ function mapErrorToType(errorMap, error) {
95072
+ var e_1, _a;
94866
95073
 
95074
+ var errorTypes = __spread(Object.keys(errorMap));
95075
+
95076
+ try {
95077
+ for (var errorTypes_1 = __values(errorTypes), errorTypes_1_1 = errorTypes_1.next(); !errorTypes_1_1.done; errorTypes_1_1 = errorTypes_1.next()) {
95078
+ var errorType = errorTypes_1_1.value;
95079
+ var matcher = errorMap[errorType];
95080
+
95081
+ if (matcher(error)) {
95082
+ return errorType;
95083
+ }
95084
+ }
95085
+ } catch (e_1_1) {
95086
+ e_1 = {
95087
+ error: e_1_1
95088
+ };
95089
+ } finally {
95090
+ try {
95091
+ if (errorTypes_1_1 && !errorTypes_1_1.done && (_a = errorTypes_1["return"])) _a.call(errorTypes_1);
95092
+ } finally {
95093
+ if (e_1) throw e_1.error;
95094
+ }
95095
+ }
95096
+
95097
+ return 'Unknown';
95098
+ }
94867
95099
  var TransformerMutationType;
94868
95100
 
94869
95101
  (function (TransformerMutationType) {
@@ -95428,7 +95660,7 @@ function getTokenForCustomAuth(authMode, amplifyConfig) {
95428
95660
  /*!**************************!*\
95429
95661
  !*** ./lib-esm/types.js ***!
95430
95662
  \**************************/
95431
- /*! exports provided: isSchemaModel, isAssociatedWith, isTargetNameAssociation, isModelAttributeAuth, isModelAttributeKey, isModelAttributePrimaryKey, isModelAttributeCompositeKey, ModelAttributeAuthAllow, ModelAttributeAuthProvider, GraphQLScalarType, isGraphQLScalarType, isModelFieldType, isNonModelFieldType, isEnumFieldType, OpType, isPredicateObj, isPredicateGroup, QueryOne, SortDirection, AuthModeStrategyType, ModelOperation, syncExpression, DISCARD, LimitTimerRaceResolvedValues */
95663
+ /*! exports provided: isSchemaModel, isAssociatedWith, isTargetNameAssociation, isModelAttributeAuth, isModelAttributeKey, isModelAttributePrimaryKey, isModelAttributeCompositeKey, ModelAttributeAuthAllow, ModelAttributeAuthProvider, GraphQLScalarType, isGraphQLScalarType, isModelFieldType, isNonModelFieldType, isEnumFieldType, OpType, isPredicateObj, isPredicateGroup, QueryOne, SortDirection, AuthModeStrategyType, ModelOperation, syncExpression, ProcessName, DISCARD, LimitTimerRaceResolvedValues */
95432
95664
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
95433
95665
 
95434
95666
  "use strict";
@@ -95455,6 +95687,7 @@ __webpack_require__.r(__webpack_exports__);
95455
95687
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AuthModeStrategyType", function() { return AuthModeStrategyType; });
95456
95688
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelOperation", function() { return ModelOperation; });
95457
95689
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "syncExpression", function() { return syncExpression; });
95690
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProcessName", function() { return ProcessName; });
95458
95691
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DISCARD", function() { return DISCARD; });
95459
95692
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LimitTimerRaceResolvedValues", function() { return LimitTimerRaceResolvedValues; });
95460
95693
  /* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ "./lib-esm/util.js");
@@ -95807,6 +96040,14 @@ function syncExpression(modelConstructor, conditionProducer) {
95807
96040
  });
95808
96041
  });
95809
96042
  }
96043
+ var ProcessName;
96044
+
96045
+ (function (ProcessName) {
96046
+ ProcessName["sync"] = "sync";
96047
+ ProcessName["mutate"] = "mutate";
96048
+ ProcessName["subscribe"] = "subscribe";
96049
+ })(ProcessName || (ProcessName = {}));
96050
+
95810
96051
  var DISCARD = Symbol('DISCARD');
95811
96052
  var LimitTimerRaceResolvedValues;
95812
96053