@aws-amplify/datastore 4.7.5 → 5.0.1-console-preview.4208d73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +4 -0
  2. package/lib/authModeStrategies/defaultAuthStrategy.js +3 -2
  3. package/lib/authModeStrategies/index.js +3 -3
  4. package/lib/authModeStrategies/multiAuthStrategy.js +81 -24
  5. package/lib/datastore/datastore.d.ts +3 -4
  6. package/lib/datastore/datastore.js +361 -227
  7. package/lib/index.d.ts +1 -1
  8. package/lib/index.js +25 -12
  9. package/lib/predicates/index.js +46 -12
  10. package/lib/predicates/next.d.ts +2 -2
  11. package/lib/predicates/next.js +172 -74
  12. package/lib/predicates/sort.js +3 -4
  13. package/lib/ssr/index.js +1 -1
  14. package/lib/storage/adapter/AsyncStorageAdapter.js +240 -128
  15. package/lib/storage/adapter/AsyncStorageDatabase.js +100 -39
  16. package/lib/storage/adapter/InMemoryStore.js +68 -17
  17. package/lib/storage/adapter/InMemoryStore.native.js +5 -3
  18. package/lib/storage/adapter/IndexedDBAdapter.js +355 -199
  19. package/lib/storage/adapter/StorageAdapterBase.js +154 -85
  20. package/lib/storage/adapter/getDefaultAdapter/index.js +8 -9
  21. package/lib/storage/adapter/getDefaultAdapter/index.native.js +4 -3
  22. package/lib/storage/adapter/index.js +0 -1
  23. package/lib/storage/relationship.js +31 -21
  24. package/lib/storage/storage.d.ts +3 -3
  25. package/lib/storage/storage.js +143 -61
  26. package/lib/sync/datastoreConnectivity.d.ts +1 -1
  27. package/lib/sync/datastoreConnectivity.js +57 -9
  28. package/lib/sync/datastoreReachability/index.js +3 -3
  29. package/lib/sync/datastoreReachability/index.native.js +7 -5
  30. package/lib/sync/index.d.ts +1 -1
  31. package/lib/sync/index.js +193 -125
  32. package/lib/sync/merger.js +81 -10
  33. package/lib/sync/outbox.js +101 -30
  34. package/lib/sync/processors/errorMaps.d.ts +1 -1
  35. package/lib/sync/processors/errorMaps.js +41 -6
  36. package/lib/sync/processors/mutation.d.ts +1 -1
  37. package/lib/sync/processors/mutation.js +192 -101
  38. package/lib/sync/processors/subscription.d.ts +4 -1
  39. package/lib/sync/processors/subscription.js +190 -178
  40. package/lib/sync/processors/sync.d.ts +1 -1
  41. package/lib/sync/processors/sync.js +113 -47
  42. package/lib/sync/utils.d.ts +4 -4
  43. package/lib/sync/utils.js +162 -81
  44. package/lib/tsconfig.tsbuildinfo +1 -0
  45. package/lib/types.d.ts +138 -140
  46. package/lib/types.js +40 -5
  47. package/lib/util.d.ts +9 -17
  48. package/lib/util.js +216 -100
  49. package/lib-esm/authModeStrategies/defaultAuthStrategy.js +0 -1
  50. package/lib-esm/authModeStrategies/index.js +0 -1
  51. package/lib-esm/authModeStrategies/multiAuthStrategy.js +76 -21
  52. package/lib-esm/datastore/datastore.d.ts +3 -4
  53. package/lib-esm/datastore/datastore.js +206 -77
  54. package/lib-esm/index.d.ts +1 -1
  55. package/lib-esm/index.js +0 -1
  56. package/lib-esm/predicates/index.js +40 -7
  57. package/lib-esm/predicates/next.d.ts +2 -2
  58. package/lib-esm/predicates/next.js +148 -52
  59. package/lib-esm/predicates/sort.js +2 -4
  60. package/lib-esm/ssr/index.js +0 -1
  61. package/lib-esm/storage/adapter/AsyncStorageAdapter.js +203 -95
  62. package/lib-esm/storage/adapter/AsyncStorageDatabase.js +66 -5
  63. package/lib-esm/storage/adapter/InMemoryStore.js +52 -2
  64. package/lib-esm/storage/adapter/InMemoryStore.native.js +0 -1
  65. package/lib-esm/storage/adapter/IndexedDBAdapter.js +271 -138
  66. package/lib-esm/storage/adapter/StorageAdapterBase.js +130 -62
  67. package/lib-esm/storage/adapter/getDefaultAdapter/index.js +2 -5
  68. package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js +0 -1
  69. package/lib-esm/storage/adapter/index.js +1 -1
  70. package/lib-esm/storage/relationship.js +27 -18
  71. package/lib-esm/storage/storage.d.ts +3 -3
  72. package/lib-esm/storage/storage.js +87 -9
  73. package/lib-esm/sync/datastoreConnectivity.d.ts +1 -1
  74. package/lib-esm/sync/datastoreConnectivity.js +48 -3
  75. package/lib-esm/sync/datastoreReachability/index.js +1 -2
  76. package/lib-esm/sync/datastoreReachability/index.native.js +1 -2
  77. package/lib-esm/sync/index.d.ts +1 -1
  78. package/lib-esm/sync/index.js +136 -72
  79. package/lib-esm/sync/merger.js +73 -3
  80. package/lib-esm/sync/outbox.js +75 -5
  81. package/lib-esm/sync/processors/errorMaps.d.ts +1 -1
  82. package/lib-esm/sync/processors/errorMaps.js +39 -5
  83. package/lib-esm/sync/processors/mutation.d.ts +1 -1
  84. package/lib-esm/sync/processors/mutation.js +130 -44
  85. package/lib-esm/sync/processors/subscription.d.ts +4 -1
  86. package/lib-esm/sync/processors/subscription.js +134 -126
  87. package/lib-esm/sync/processors/sync.d.ts +1 -1
  88. package/lib-esm/sync/processors/sync.js +74 -12
  89. package/lib-esm/sync/utils.d.ts +4 -4
  90. package/lib-esm/sync/utils.js +135 -55
  91. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  92. package/lib-esm/types.d.ts +138 -140
  93. package/lib-esm/types.js +36 -2
  94. package/lib-esm/util.d.ts +9 -17
  95. package/lib-esm/util.js +96 -16
  96. package/package.json +139 -132
  97. package/src/authModeStrategies/multiAuthStrategy.ts +11 -12
  98. package/src/datastore/datastore.ts +32 -25
  99. package/src/predicates/sort.ts +3 -1
  100. package/src/storage/adapter/InMemoryStore.ts +1 -1
  101. package/src/storage/adapter/IndexedDBAdapter.ts +1 -1
  102. package/src/storage/adapter/StorageAdapterBase.ts +1 -1
  103. package/src/storage/adapter/getDefaultAdapter/index.ts +2 -3
  104. package/src/storage/storage.ts +1 -1
  105. package/src/sync/datastoreConnectivity.ts +2 -2
  106. package/src/sync/datastoreReachability/index.native.ts +1 -1
  107. package/src/sync/datastoreReachability/index.ts +1 -1
  108. package/src/sync/index.ts +69 -78
  109. package/src/sync/processors/mutation.ts +16 -10
  110. package/src/sync/processors/subscription.ts +55 -127
  111. package/src/sync/processors/sync.ts +8 -4
  112. package/src/sync/utils.ts +7 -8
  113. package/src/types.ts +4 -8
  114. package/src/util.ts +5 -6
  115. package/lib/.tsbuildinfo +0 -3
  116. package/lib/authModeStrategies/defaultAuthStrategy.js.map +0 -1
  117. package/lib/authModeStrategies/index.js.map +0 -1
  118. package/lib/authModeStrategies/multiAuthStrategy.js.map +0 -1
  119. package/lib/datastore/datastore.js.map +0 -1
  120. package/lib/index.js.map +0 -1
  121. package/lib/predicates/index.js.map +0 -1
  122. package/lib/predicates/next.js.map +0 -1
  123. package/lib/predicates/sort.js.map +0 -1
  124. package/lib/ssr/index.js.map +0 -1
  125. package/lib/storage/adapter/AsyncStorageAdapter.js.map +0 -1
  126. package/lib/storage/adapter/AsyncStorageDatabase.js.map +0 -1
  127. package/lib/storage/adapter/InMemoryStore.js.map +0 -1
  128. package/lib/storage/adapter/InMemoryStore.native.js.map +0 -1
  129. package/lib/storage/adapter/IndexedDBAdapter.js.map +0 -1
  130. package/lib/storage/adapter/StorageAdapterBase.js.map +0 -1
  131. package/lib/storage/adapter/getDefaultAdapter/index.js.map +0 -1
  132. package/lib/storage/adapter/getDefaultAdapter/index.native.js.map +0 -1
  133. package/lib/storage/adapter/index.js.map +0 -1
  134. package/lib/storage/relationship.js.map +0 -1
  135. package/lib/storage/storage.js.map +0 -1
  136. package/lib/sync/datastoreConnectivity.js.map +0 -1
  137. package/lib/sync/datastoreReachability/index.js.map +0 -1
  138. package/lib/sync/datastoreReachability/index.native.js.map +0 -1
  139. package/lib/sync/index.js.map +0 -1
  140. package/lib/sync/merger.js.map +0 -1
  141. package/lib/sync/outbox.js.map +0 -1
  142. package/lib/sync/processors/errorMaps.js.map +0 -1
  143. package/lib/sync/processors/mutation.js.map +0 -1
  144. package/lib/sync/processors/subscription.js.map +0 -1
  145. package/lib/sync/processors/sync.js.map +0 -1
  146. package/lib/sync/utils.js.map +0 -1
  147. package/lib/types.js.map +0 -1
  148. package/lib/util.js.map +0 -1
  149. package/lib-esm/.tsbuildinfo +0 -3
  150. package/lib-esm/authModeStrategies/defaultAuthStrategy.js.map +0 -1
  151. package/lib-esm/authModeStrategies/index.js.map +0 -1
  152. package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +0 -1
  153. package/lib-esm/datastore/datastore.js.map +0 -1
  154. package/lib-esm/index.js.map +0 -1
  155. package/lib-esm/predicates/index.js.map +0 -1
  156. package/lib-esm/predicates/next.js.map +0 -1
  157. package/lib-esm/predicates/sort.js.map +0 -1
  158. package/lib-esm/ssr/index.js.map +0 -1
  159. package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +0 -1
  160. package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +0 -1
  161. package/lib-esm/storage/adapter/InMemoryStore.js.map +0 -1
  162. package/lib-esm/storage/adapter/InMemoryStore.native.js.map +0 -1
  163. package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +0 -1
  164. package/lib-esm/storage/adapter/StorageAdapterBase.js.map +0 -1
  165. package/lib-esm/storage/adapter/getDefaultAdapter/index.js.map +0 -1
  166. package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js.map +0 -1
  167. package/lib-esm/storage/adapter/index.js.map +0 -1
  168. package/lib-esm/storage/relationship.js.map +0 -1
  169. package/lib-esm/storage/storage.js.map +0 -1
  170. package/lib-esm/sync/datastoreConnectivity.js.map +0 -1
  171. package/lib-esm/sync/datastoreReachability/index.js.map +0 -1
  172. package/lib-esm/sync/datastoreReachability/index.native.js.map +0 -1
  173. package/lib-esm/sync/index.js.map +0 -1
  174. package/lib-esm/sync/merger.js.map +0 -1
  175. package/lib-esm/sync/outbox.js.map +0 -1
  176. package/lib-esm/sync/processors/errorMaps.js.map +0 -1
  177. package/lib-esm/sync/processors/mutation.js.map +0 -1
  178. package/lib-esm/sync/processors/subscription.js.map +0 -1
  179. package/lib-esm/sync/processors/sync.js.map +0 -1
  180. package/lib-esm/sync/utils.js.map +0 -1
  181. package/lib-esm/types.js.map +0 -1
  182. package/lib-esm/util.js.map +0 -1
@@ -1,21 +1,92 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __read = (this && this.__read) || function (o, n) {
50
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
51
+ if (!m) return o;
52
+ var i = m.call(o), r, ar = [], e;
53
+ try {
54
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
+ }
56
+ catch (error) { e = { error: error }; }
57
+ finally {
58
+ try {
59
+ if (r && !r.done && (m = i["return"])) m.call(i);
60
+ }
61
+ finally { if (e) throw e.error; }
62
+ }
63
+ return ar;
64
+ };
65
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
+ if (ar || !(i in from)) {
68
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
+ ar[i] = from[i];
70
+ }
71
+ }
72
+ return to.concat(ar || Array.prototype.slice.call(from));
73
+ };
74
+ var __importDefault = (this && this.__importDefault) || function (mod) {
75
+ return (mod && mod.__esModule) ? mod : { "default": mod };
76
+ };
2
77
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
- // SPDX-License-Identifier: Apache-2.0
6
- var api_1 = require("@aws-amplify/api");
78
+ exports.SubscriptionProcessor = exports.USER_CREDENTIALS = exports.CONTROL_MSG = void 0;
7
79
  var internals_1 = require("@aws-amplify/api/internals");
8
- var auth_1 = require("@aws-amplify/auth");
9
- var cache_1 = require("@aws-amplify/cache");
10
80
  var core_1 = require("@aws-amplify/core");
11
- var pubsub_1 = require("@aws-amplify/pubsub");
12
- var zen_observable_ts_1 = tslib_1.__importDefault(require("zen-observable-ts"));
81
+ var utils_1 = require("@aws-amplify/core/internals/utils");
82
+ var zen_observable_ts_1 = __importDefault(require("zen-observable-ts"));
13
83
  var types_1 = require("../../types");
14
- var utils_1 = require("../utils");
84
+ var utils_2 = require("../utils");
15
85
  var predicates_1 = require("../../predicates");
16
86
  var util_1 = require("../../util");
17
87
  var errorMaps_1 = require("./errorMaps");
18
- var logger = new core_1.ConsoleLogger('DataStore');
88
+ var api_graphql_1 = require("@aws-amplify/api-graphql");
89
+ var logger = new utils_1.Logger('DataStore');
19
90
  var CONTROL_MSG;
20
91
  (function (CONTROL_MSG) {
21
92
  CONTROL_MSG["CONNECTED"] = "CONNECTED";
@@ -30,9 +101,7 @@ var SubscriptionProcessor = /** @class */ (function () {
30
101
  function SubscriptionProcessor(schema, syncPredicates, amplifyConfig, authModeStrategy, errorHandler, amplifyContext) {
31
102
  if (amplifyConfig === void 0) { amplifyConfig = {}; }
32
103
  if (amplifyContext === void 0) { amplifyContext = {
33
- Auth: auth_1.Auth,
34
104
  InternalAPI: internals_1.InternalAPI,
35
- Cache: cache_1.Cache,
36
105
  }; }
37
106
  this.schema = schema;
38
107
  this.syncPredicates = syncPredicates;
@@ -42,21 +111,19 @@ var SubscriptionProcessor = /** @class */ (function () {
42
111
  this.amplifyContext = amplifyContext;
43
112
  this.typeQuery = new WeakMap();
44
113
  this.buffer = [];
45
- this.runningProcesses = new core_1.BackgroundProcessManager();
114
+ this.runningProcesses = new utils_1.BackgroundProcessManager();
46
115
  }
47
- SubscriptionProcessor.prototype.buildSubscription = function (namespace, model, transformerMutationType, userCredentials, cognitoTokenPayload, oidcTokenPayload, authMode, filterArg) {
116
+ SubscriptionProcessor.prototype.buildSubscription = function (namespace, model, transformerMutationType, userCredentials, oidcTokenPayload, authMode, filterArg) {
48
117
  if (filterArg === void 0) { filterArg = false; }
49
118
  var aws_appsync_authenticationType = this.amplifyConfig.aws_appsync_authenticationType;
50
- var _a = this.getAuthorizationInfo(model, userCredentials, aws_appsync_authenticationType, cognitoTokenPayload, oidcTokenPayload, authMode) || {}, isOwner = _a.isOwner, ownerField = _a.ownerField, ownerValue = _a.ownerValue;
51
- var _b = tslib_1.__read(utils_1.buildSubscriptionGraphQLOperation(namespace, model, transformerMutationType, isOwner, ownerField, filterArg), 3), opType = _b[0], opName = _b[1], query = _b[2];
119
+ var _a = this.getAuthorizationInfo(model, userCredentials, aws_appsync_authenticationType, oidcTokenPayload, authMode) || {}, isOwner = _a.isOwner, ownerField = _a.ownerField, ownerValue = _a.ownerValue;
120
+ var _b = __read((0, utils_2.buildSubscriptionGraphQLOperation)(namespace, model, transformerMutationType, isOwner, ownerField, filterArg), 3), opType = _b[0], opName = _b[1], query = _b[2];
52
121
  return { authMode: authMode, opType: opType, opName: opName, query: query, isOwner: isOwner, ownerField: ownerField, ownerValue: ownerValue };
53
122
  };
54
- SubscriptionProcessor.prototype.getAuthorizationInfo = function (model, userCredentials, defaultAuthType, cognitoTokenPayload, oidcTokenPayload, authMode) {
55
- if (cognitoTokenPayload === void 0) { cognitoTokenPayload = {}; }
56
- if (oidcTokenPayload === void 0) { oidcTokenPayload = {}; }
57
- var rules = utils_1.getAuthorizationRules(model);
123
+ SubscriptionProcessor.prototype.getAuthorizationInfo = function (model, userCredentials, defaultAuthType, oidcTokenPayload, authMode) {
124
+ var rules = (0, utils_2.getAuthorizationRules)(model);
58
125
  // Return null if user doesn't have proper credentials for private API with IAM auth
59
- var iamPrivateAuth = authMode === api_1.GRAPHQL_AUTH_MODE.AWS_IAM &&
126
+ var iamPrivateAuth = authMode === 'iam' &&
60
127
  rules.find(function (rule) { return rule.authStrategy === 'private' && rule.provider === 'iam'; });
61
128
  if (iamPrivateAuth && userCredentials === USER_CREDENTIALS.unauth) {
62
129
  return null;
@@ -69,15 +136,15 @@ var SubscriptionProcessor = /** @class */ (function () {
69
136
  return rule.authStrategy === 'groups' &&
70
137
  ['userPools', 'oidc'].includes(rule.provider);
71
138
  });
72
- var validGroup = (authMode === api_1.GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS ||
73
- authMode === api_1.GRAPHQL_AUTH_MODE.OPENID_CONNECT) &&
139
+ var validGroup = authMode === 'jwt' &&
74
140
  groupAuthRules.find(function (groupAuthRule) {
75
141
  // validate token against groupClaim
76
- var cognitoUserGroups = utils_1.getUserGroupsFromToken(cognitoTokenPayload, groupAuthRule);
77
- var oidcUserGroups = utils_1.getUserGroupsFromToken(oidcTokenPayload, groupAuthRule);
78
- return tslib_1.__spread(cognitoUserGroups, oidcUserGroups).find(function (userGroup) {
79
- return groupAuthRule.groups.find(function (group) { return group === userGroup; });
80
- });
142
+ if (oidcTokenPayload) {
143
+ var oidcUserGroups = (0, utils_2.getUserGroupsFromToken)(oidcTokenPayload, groupAuthRule);
144
+ return __spreadArray([], __read(oidcUserGroups), false).find(function (userGroup) {
145
+ return groupAuthRule.groups.find(function (group) { return group === userGroup; });
146
+ });
147
+ }
81
148
  });
82
149
  if (validGroup) {
83
150
  return {
@@ -85,40 +152,18 @@ var SubscriptionProcessor = /** @class */ (function () {
85
152
  isOwner: false,
86
153
  };
87
154
  }
88
- // Owner auth needs additional values to be returned in order to create the subscription with
89
- // the correct parameters so we are getting the owner value from the Cognito token via the
90
- // identityClaim from the auth rule.
91
- var cognitoOwnerAuthRules = authMode === api_1.GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS
92
- ? rules.filter(function (rule) {
93
- return rule.authStrategy === 'owner' && rule.provider === 'userPools';
94
- })
95
- : [];
96
155
  var ownerAuthInfo;
97
- cognitoOwnerAuthRules.forEach(function (ownerAuthRule) {
98
- var _a;
99
- var ownerValue = cognitoTokenPayload[ownerAuthRule.identityClaim];
100
- // AuthZ for "list of owners" is handled dynamically in the subscription auth request
101
- // resolver. It doesn't rely on a subscription arg.
102
- // Only pass a subscription arg for single owner auth
103
- var singleOwner = ((_a = model.fields[ownerAuthRule.ownerField]) === null || _a === void 0 ? void 0 : _a.isArray) !== true;
104
- var isOwnerArgRequired = singleOwner && !ownerAuthRule.areSubscriptionsPublic;
105
- if (ownerValue) {
106
- ownerAuthInfo = {
107
- authMode: api_1.GRAPHQL_AUTH_MODE.AMAZON_COGNITO_USER_POOLS,
108
- isOwner: isOwnerArgRequired,
109
- ownerField: ownerAuthRule.ownerField,
110
- ownerValue: ownerValue,
111
- };
112
- }
113
- });
114
156
  if (ownerAuthInfo) {
115
157
  return ownerAuthInfo;
116
158
  }
117
159
  // Owner auth needs additional values to be returned in order to create the subscription with
118
160
  // the correct parameters so we are getting the owner value from the OIDC token via the
119
161
  // identityClaim from the auth rule.
120
- var oidcOwnerAuthRules = authMode === api_1.GRAPHQL_AUTH_MODE.OPENID_CONNECT
121
- ? rules.filter(function (rule) { return rule.authStrategy === 'owner' && rule.provider === 'oidc'; })
162
+ var oidcOwnerAuthRules = authMode === 'jwt'
163
+ ? rules.filter(function (rule) {
164
+ return rule.authStrategy === 'owner' &&
165
+ (rule.provider === 'oidc' || rule.provider === 'userPools');
166
+ })
122
167
  : [];
123
168
  oidcOwnerAuthRules.forEach(function (ownerAuthRule) {
124
169
  var _a;
@@ -127,10 +172,10 @@ var SubscriptionProcessor = /** @class */ (function () {
127
172
  var isOwnerArgRequired = singleOwner && !ownerAuthRule.areSubscriptionsPublic;
128
173
  if (ownerValue) {
129
174
  ownerAuthInfo = {
130
- authMode: api_1.GRAPHQL_AUTH_MODE.OPENID_CONNECT,
175
+ authMode: 'jwt',
131
176
  isOwner: isOwnerArgRequired,
132
177
  ownerField: ownerAuthRule.ownerField,
133
- ownerValue: ownerValue,
178
+ ownerValue: String(ownerValue),
134
179
  };
135
180
  }
136
181
  });
@@ -145,79 +190,51 @@ var SubscriptionProcessor = /** @class */ (function () {
145
190
  };
146
191
  SubscriptionProcessor.prototype.hubQueryCompletionListener = function (completed, capsule) {
147
192
  var event = capsule.payload.event;
148
- if (event === pubsub_1.CONTROL_MSG.SUBSCRIPTION_ACK) {
193
+ if (event === api_graphql_1.CONTROL_MSG.SUBSCRIPTION_ACK) {
149
194
  completed();
150
195
  }
151
196
  };
152
197
  SubscriptionProcessor.prototype.start = function () {
153
198
  var _this = this;
154
199
  this.runningProcesses =
155
- this.runningProcesses || new core_1.BackgroundProcessManager();
200
+ this.runningProcesses || new utils_1.BackgroundProcessManager();
156
201
  var ctlObservable = new zen_observable_ts_1.default(function (observer) {
157
202
  var promises = [];
158
203
  // Creating subs for each model/operation combo so they can be unsubscribed
159
204
  // independently, since the auth retry behavior is asynchronous.
160
205
  var subscriptions = {};
161
- var cognitoTokenPayload, oidcTokenPayload;
206
+ var oidcTokenPayload;
162
207
  var userCredentials = USER_CREDENTIALS.none;
163
- _this.runningProcesses.add(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
164
- var credentials, err_1, session, err_2, _a, aws_cognito_region, AuthConfig, token, federatedInfo, currentUser, payload, err_3;
208
+ _this.runningProcesses.add(function () { return __awaiter(_this, void 0, void 0, function () {
209
+ var credentials, err_1, session, err_2;
165
210
  var _this = this;
166
- return tslib_1.__generator(this, function (_b) {
167
- switch (_b.label) {
211
+ var _a, _b, _c;
212
+ return __generator(this, function (_d) {
213
+ switch (_d.label) {
168
214
  case 0:
169
- _b.trys.push([0, 2, , 3]);
170
- return [4 /*yield*/, this.amplifyContext.Auth.currentCredentials()];
215
+ _d.trys.push([0, 2, , 3]);
216
+ return [4 /*yield*/, (0, core_1.fetchAuthSession)()];
171
217
  case 1:
172
- credentials = _b.sent();
173
- userCredentials = credentials.authenticated
218
+ credentials = (_a = (_d.sent()).tokens) === null || _a === void 0 ? void 0 : _a.accessToken;
219
+ userCredentials = credentials
174
220
  ? USER_CREDENTIALS.auth
175
221
  : USER_CREDENTIALS.unauth;
176
222
  return [3 /*break*/, 3];
177
223
  case 2:
178
- err_1 = _b.sent();
224
+ err_1 = _d.sent();
179
225
  return [3 /*break*/, 3];
180
226
  case 3:
181
- _b.trys.push([3, 5, , 6]);
182
- return [4 /*yield*/, this.amplifyContext.Auth.currentSession()];
183
- case 4:
184
- session = _b.sent();
185
- cognitoTokenPayload = session.getIdToken().decodePayload();
186
- return [3 /*break*/, 6];
227
+ _d.trys.push([3, 6, , 7]);
228
+ return [4 /*yield*/, (0, core_1.fetchAuthSession)()];
229
+ case 4: return [4 /*yield*/, _d.sent()];
187
230
  case 5:
188
- err_2 = _b.sent();
189
- return [3 /*break*/, 6];
231
+ session = _d.sent();
232
+ oidcTokenPayload = (_c = (_b = session.tokens) === null || _b === void 0 ? void 0 : _b.idToken) === null || _c === void 0 ? void 0 : _c.payload;
233
+ return [3 /*break*/, 7];
190
234
  case 6:
191
- _b.trys.push([6, 11, , 12]);
192
- _a = this.amplifyConfig, aws_cognito_region = _a.aws_cognito_region, AuthConfig = _a.Auth;
193
- if (!aws_cognito_region || (AuthConfig && !AuthConfig.region)) {
194
- throw 'Auth is not configured';
195
- }
196
- token = void 0;
197
- return [4 /*yield*/, this.amplifyContext.Cache.getItem('federatedInfo')];
235
+ err_2 = _d.sent();
236
+ return [3 /*break*/, 7];
198
237
  case 7:
199
- federatedInfo = _b.sent();
200
- if (!federatedInfo) return [3 /*break*/, 8];
201
- token = federatedInfo.token;
202
- return [3 /*break*/, 10];
203
- case 8: return [4 /*yield*/, this.amplifyContext.Auth.currentAuthenticatedUser()];
204
- case 9:
205
- currentUser = _b.sent();
206
- if (currentUser) {
207
- token = currentUser.token;
208
- }
209
- _b.label = 10;
210
- case 10:
211
- if (token) {
212
- payload = token.split('.')[1];
213
- oidcTokenPayload = JSON.parse(Buffer.from(payload, 'base64').toString('utf8'));
214
- }
215
- return [3 /*break*/, 12];
216
- case 11:
217
- err_3 = _b.sent();
218
- logger.debug('error getting OIDC JWT', err_3);
219
- return [3 /*break*/, 12];
220
- case 12:
221
238
  Object.values(this.schema.namespaces).forEach(function (namespace) {
222
239
  Object.values(namespace.models)
223
240
  .filter(function (_a) {
@@ -226,13 +243,13 @@ var SubscriptionProcessor = /** @class */ (function () {
226
243
  })
227
244
  .forEach(function (modelDefinition) {
228
245
  return _this.runningProcesses.isOpen &&
229
- _this.runningProcesses.add(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
246
+ _this.runningProcesses.add(function () { return __awaiter(_this, void 0, void 0, function () {
230
247
  var modelAuthModes, readAuthModes, operations, operationAuthModeAttempts, predicatesGroup, addFilterArg, subscriptionRetry;
231
248
  var _a, _b, _c;
232
249
  var _this = this;
233
- return tslib_1.__generator(this, function (_d) {
250
+ return __generator(this, function (_d) {
234
251
  switch (_d.label) {
235
- case 0: return [4 /*yield*/, utils_1.getModelAuthModes({
252
+ case 0: return [4 /*yield*/, (0, utils_2.getModelAuthModes)({
236
253
  authModeStrategy: this.authModeStrategy,
237
254
  defaultAuthMode: this.amplifyConfig.aws_appsync_authenticationType,
238
255
  modelName: modelDefinition.name,
@@ -241,43 +258,43 @@ var SubscriptionProcessor = /** @class */ (function () {
241
258
  case 1:
242
259
  modelAuthModes = _d.sent();
243
260
  readAuthModes = modelAuthModes.READ;
244
- subscriptions = tslib_1.__assign(tslib_1.__assign({}, subscriptions), (_a = {}, _a[modelDefinition.name] = (_b = {},
245
- _b[utils_1.TransformerMutationType.CREATE] = [],
246
- _b[utils_1.TransformerMutationType.UPDATE] = [],
247
- _b[utils_1.TransformerMutationType.DELETE] = [],
261
+ subscriptions = __assign(__assign({}, subscriptions), (_a = {}, _a[modelDefinition.name] = (_b = {},
262
+ _b[utils_2.TransformerMutationType.CREATE] = [],
263
+ _b[utils_2.TransformerMutationType.UPDATE] = [],
264
+ _b[utils_2.TransformerMutationType.DELETE] = [],
248
265
  _b), _a));
249
266
  operations = [
250
- utils_1.TransformerMutationType.CREATE,
251
- utils_1.TransformerMutationType.UPDATE,
252
- utils_1.TransformerMutationType.DELETE,
267
+ utils_2.TransformerMutationType.CREATE,
268
+ utils_2.TransformerMutationType.UPDATE,
269
+ utils_2.TransformerMutationType.DELETE,
253
270
  ];
254
271
  operationAuthModeAttempts = (_c = {},
255
- _c[utils_1.TransformerMutationType.CREATE] = 0,
256
- _c[utils_1.TransformerMutationType.UPDATE] = 0,
257
- _c[utils_1.TransformerMutationType.DELETE] = 0,
272
+ _c[utils_2.TransformerMutationType.CREATE] = 0,
273
+ _c[utils_2.TransformerMutationType.UPDATE] = 0,
274
+ _c[utils_2.TransformerMutationType.DELETE] = 0,
258
275
  _c);
259
276
  predicatesGroup = predicates_1.ModelPredicateCreator.getPredicates(this.syncPredicates.get(modelDefinition), false);
260
277
  addFilterArg = predicatesGroup !== undefined;
261
278
  subscriptionRetry = function (operation, addFilter) {
262
279
  if (addFilter === void 0) { addFilter = addFilterArg; }
263
- return tslib_1.__awaiter(_this, void 0, void 0, function () {
280
+ return __awaiter(_this, void 0, void 0, function () {
264
281
  var _a, transformerMutationType, opName, query, isOwner, ownerField, ownerValue, authMode, authToken, variables, customUserAgentDetails, queryObservable, subscriptionReadyCallback;
265
282
  var _this = this;
266
- return tslib_1.__generator(this, function (_b) {
283
+ return __generator(this, function (_b) {
267
284
  switch (_b.label) {
268
285
  case 0:
269
- _a = this.buildSubscription(namespace, modelDefinition, operation, userCredentials, cognitoTokenPayload, oidcTokenPayload, readAuthModes[operationAuthModeAttempts[operation]], addFilter), transformerMutationType = _a.opType, opName = _a.opName, query = _a.query, isOwner = _a.isOwner, ownerField = _a.ownerField, ownerValue = _a.ownerValue, authMode = _a.authMode;
270
- return [4 /*yield*/, utils_1.getTokenForCustomAuth(authMode, this.amplifyConfig)];
286
+ _a = this.buildSubscription(namespace, modelDefinition, operation, userCredentials, oidcTokenPayload, readAuthModes[operationAuthModeAttempts[operation]], addFilter), transformerMutationType = _a.opType, opName = _a.opName, query = _a.query, isOwner = _a.isOwner, ownerField = _a.ownerField, ownerValue = _a.ownerValue, authMode = _a.authMode;
287
+ return [4 /*yield*/, (0, utils_2.getTokenForCustomAuth)(authMode, this.amplifyConfig)];
271
288
  case 1:
272
289
  authToken = _b.sent();
273
290
  variables = {};
274
291
  customUserAgentDetails = {
275
- category: core_1.Category.DataStore,
276
- action: core_1.DataStoreAction.Subscribe,
292
+ category: utils_1.Category.DataStore,
293
+ action: utils_1.DataStoreAction.Subscribe,
277
294
  };
278
295
  if (addFilter && predicatesGroup) {
279
296
  variables['filter'] =
280
- utils_1.predicateToGraphQLFilter(predicatesGroup);
297
+ (0, utils_2.predicateToGraphQLFilter)(predicatesGroup);
281
298
  }
282
299
  if (isOwner) {
283
300
  if (!ownerValue) {
@@ -286,30 +303,26 @@ var SubscriptionProcessor = /** @class */ (function () {
286
303
  }
287
304
  variables[ownerField] = ownerValue;
288
305
  }
289
- logger.debug("Attempting " + operation + " subscription with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
290
- queryObservable = this.amplifyContext.InternalAPI.graphql(tslib_1.__assign(tslib_1.__assign({ query: query,
291
- variables: variables }, { authMode: authMode }), { authToken: authToken }), undefined, customUserAgentDetails);
306
+ logger.debug("Attempting ".concat(operation, " subscription with authMode: ").concat(readAuthModes[operationAuthModeAttempts[operation]]));
307
+ queryObservable = this.amplifyContext.InternalAPI.graphql(__assign(__assign({ query: query, variables: variables }, { authMode: authMode }), { authToken: authToken }), undefined, customUserAgentDetails);
292
308
  // TODO: consider onTerminate.then(() => API.cancel(...))
293
309
  subscriptions[modelDefinition.name][transformerMutationType].push(queryObservable
294
- .map(function (_a) {
295
- var value = _a.value;
296
- return value;
297
- })
310
+ .filter(function () { return true; }) // to make change more readable
298
311
  .subscribe({
299
- next: function (_a) {
300
- var data = _a.data, errors = _a.errors;
312
+ next: function (result) {
313
+ var data = result.data, errors = result.errors;
301
314
  if (Array.isArray(errors) && errors.length > 0) {
302
315
  var messages = errors.map(function (_a) {
303
316
  var message = _a.message;
304
317
  return message;
305
318
  });
306
- logger.warn("Skipping incoming subscription. Messages: " + messages.join('\n'));
319
+ logger.warn("Skipping incoming subscription. Messages: ".concat(messages.join('\n')));
307
320
  _this.drainBuffer();
308
321
  return;
309
322
  }
310
323
  var predicatesGroup = predicates_1.ModelPredicateCreator.getPredicates(_this.syncPredicates.get(modelDefinition), false);
311
324
  // @ts-ignore
312
- var _b = data, _c = opName, record = _b[_c];
325
+ var _a = data, _b = opName, record = _a[_b];
313
326
  // checking incoming subscription against syncPredicate.
314
327
  // once AppSync implements filters on subscriptions, we'll be
315
328
  // able to set these when establishing the subscription instead.
@@ -319,14 +332,14 @@ var SubscriptionProcessor = /** @class */ (function () {
319
332
  }
320
333
  _this.drainBuffer();
321
334
  },
322
- error: function (subscriptionError) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
323
- var _a, _b, _c, _d, message, isRTFError, e_1;
324
- return tslib_1.__generator(this, function (_e) {
325
- switch (_e.label) {
335
+ error: function (subscriptionError) { return __awaiter(_this, void 0, void 0, function () {
336
+ var _a, _b, _c, _d, _e, _f, message, isRTFError, e_1;
337
+ return __generator(this, function (_g) {
338
+ switch (_g.label) {
326
339
  case 0:
327
- _a = subscriptionError.error, _b = tslib_1.__read((_a === void 0 ? {
340
+ _a = subscriptionError.error, _b = _a === void 0 ? {
328
341
  errors: [],
329
- } : _a).errors, 1), _c = _b[0], _d = (_c === void 0 ? {} : _c).message, message = _d === void 0 ? '' : _d;
342
+ } : _a, _c = __read(_b.errors, 1), _d = _c[0], _e = _d === void 0 ? {} : _d, _f = _e.message, message = _f === void 0 ? '' : _f;
330
343
  isRTFError =
331
344
  // only attempt catch if a filter variable was added to the subscription query
332
345
  addFilter &&
@@ -342,8 +355,8 @@ var SubscriptionProcessor = /** @class */ (function () {
342
355
  subscriptionRetry(operation, false);
343
356
  return [2 /*return*/];
344
357
  }
345
- if (message.includes(pubsub_1.CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR) ||
346
- message.includes(pubsub_1.CONTROL_MSG.CONNECTION_FAILED)) {
358
+ if (message.includes(api_graphql_1.CONTROL_MSG.REALTIME_SUBSCRIPTION_INIT_ERROR) ||
359
+ message.includes(api_graphql_1.CONTROL_MSG.CONNECTION_FAILED)) {
347
360
  // Unsubscribe and clear subscription array for model/operation
348
361
  subscriptions[modelDefinition.name][transformerMutationType].forEach(function (subscription) {
349
362
  return subscription.unsubscribe();
@@ -353,36 +366,36 @@ var SubscriptionProcessor = /** @class */ (function () {
353
366
  if (operationAuthModeAttempts[operation] >=
354
367
  readAuthModes.length) {
355
368
  // last auth mode retry. Continue with error
356
- logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1]);
369
+ logger.debug("".concat(operation, " subscription failed with authMode: ").concat(readAuthModes[operationAuthModeAttempts[operation] - 1]));
357
370
  }
358
371
  else {
359
372
  // retry with different auth mode. Do not trigger
360
373
  // observer error or error handler
361
- logger.debug(operation + " subscription failed with authMode: " + readAuthModes[operationAuthModeAttempts[operation] - 1] + ". Retrying with authMode: " + readAuthModes[operationAuthModeAttempts[operation]]);
374
+ logger.debug("".concat(operation, " subscription failed with authMode: ").concat(readAuthModes[operationAuthModeAttempts[operation] - 1], ". Retrying with authMode: ").concat(readAuthModes[operationAuthModeAttempts[operation]]));
362
375
  subscriptionRetry(operation);
363
376
  return [2 /*return*/];
364
377
  }
365
378
  }
366
379
  logger.warn('subscriptionError', message);
367
- _e.label = 1;
380
+ _g.label = 1;
368
381
  case 1:
369
- _e.trys.push([1, 3, , 4]);
382
+ _g.trys.push([1, 3, , 4]);
370
383
  return [4 /*yield*/, this.errorHandler({
371
384
  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',
372
385
  localModel: null,
373
386
  message: message,
374
387
  model: modelDefinition.name,
375
388
  operation: operation,
376
- errorType: errorMaps_1.getSubscriptionErrorType(subscriptionError),
389
+ errorType: (0, errorMaps_1.getSubscriptionErrorType)(subscriptionError),
377
390
  process: types_1.ProcessName.subscribe,
378
391
  remoteModel: null,
379
392
  cause: subscriptionError,
380
393
  })];
381
394
  case 2:
382
- _e.sent();
395
+ _g.sent();
383
396
  return [3 /*break*/, 4];
384
397
  case 3:
385
- e_1 = _e.sent();
398
+ e_1 = _g.sent();
386
399
  logger.error('Subscription error handler failed with:', e_1);
387
400
  return [3 /*break*/, 4];
388
401
  case 4:
@@ -399,19 +412,19 @@ var SubscriptionProcessor = /** @class */ (function () {
399
412
  });
400
413
  }); },
401
414
  }));
402
- promises.push((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
403
- var boundFunction;
415
+ promises.push((function () { return __awaiter(_this, void 0, void 0, function () {
416
+ var boundFunction, removeBoundFunctionListener;
404
417
  var _this = this;
405
- return tslib_1.__generator(this, function (_a) {
418
+ return __generator(this, function (_a) {
406
419
  switch (_a.label) {
407
420
  case 0: return [4 /*yield*/, new Promise(function (res) {
408
421
  subscriptionReadyCallback = res;
409
422
  boundFunction = _this.hubQueryCompletionListener.bind(_this, res);
410
- core_1.Hub.listen('api', boundFunction);
423
+ removeBoundFunctionListener = core_1.Hub.listen('api', boundFunction);
411
424
  })];
412
425
  case 1:
413
426
  _a.sent();
414
- core_1.Hub.remove('api', boundFunction);
427
+ removeBoundFunctionListener();
415
428
  return [2 /*return*/];
416
429
  }
417
430
  });
@@ -438,12 +451,12 @@ var SubscriptionProcessor = /** @class */ (function () {
438
451
  }
439
452
  });
440
453
  }); }, 'subscription processor new subscriber');
441
- return _this.runningProcesses.addCleaner(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
442
- return tslib_1.__generator(this, function (_a) {
454
+ return _this.runningProcesses.addCleaner(function () { return __awaiter(_this, void 0, void 0, function () {
455
+ return __generator(this, function (_a) {
443
456
  Object.keys(subscriptions).forEach(function (modelName) {
444
- subscriptions[modelName][utils_1.TransformerMutationType.CREATE].forEach(function (subscription) { return subscription.unsubscribe(); });
445
- subscriptions[modelName][utils_1.TransformerMutationType.UPDATE].forEach(function (subscription) { return subscription.unsubscribe(); });
446
- subscriptions[modelName][utils_1.TransformerMutationType.DELETE].forEach(function (subscription) { return subscription.unsubscribe(); });
457
+ subscriptions[modelName][utils_2.TransformerMutationType.CREATE].forEach(function (subscription) { return subscription.unsubscribe(); });
458
+ subscriptions[modelName][utils_2.TransformerMutationType.UPDATE].forEach(function (subscription) { return subscription.unsubscribe(); });
459
+ subscriptions[modelName][utils_2.TransformerMutationType.DELETE].forEach(function (subscription) { return subscription.unsubscribe(); });
447
460
  });
448
461
  return [2 /*return*/];
449
462
  });
@@ -452,8 +465,8 @@ var SubscriptionProcessor = /** @class */ (function () {
452
465
  var dataObservable = new zen_observable_ts_1.default(function (observer) {
453
466
  _this.dataObserver = observer;
454
467
  _this.drainBuffer();
455
- return _this.runningProcesses.addCleaner(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
456
- return tslib_1.__generator(this, function (_a) {
468
+ return _this.runningProcesses.addCleaner(function () { return __awaiter(_this, void 0, void 0, function () {
469
+ return __generator(this, function (_a) {
457
470
  this.dataObserver = null;
458
471
  return [2 /*return*/];
459
472
  });
@@ -462,8 +475,8 @@ var SubscriptionProcessor = /** @class */ (function () {
462
475
  return [ctlObservable, dataObservable];
463
476
  };
464
477
  SubscriptionProcessor.prototype.stop = function () {
465
- return tslib_1.__awaiter(this, void 0, void 0, function () {
466
- return tslib_1.__generator(this, function (_a) {
478
+ return __awaiter(this, void 0, void 0, function () {
479
+ return __generator(this, function (_a) {
467
480
  switch (_a.label) {
468
481
  case 0: return [4 /*yield*/, this.runningProcesses.close()];
469
482
  case 1:
@@ -481,7 +494,7 @@ var SubscriptionProcessor = /** @class */ (function () {
481
494
  return true;
482
495
  }
483
496
  var predicates = predicatesGroup.predicates, type = predicatesGroup.type;
484
- return util_1.validatePredicate(record, type, predicates);
497
+ return (0, util_1.validatePredicate)(record, type, predicates);
485
498
  };
486
499
  SubscriptionProcessor.prototype.pushToBuffer = function (transformerMutationType, modelDefinition, data) {
487
500
  this.buffer.push([transformerMutationType, modelDefinition, data]);
@@ -502,20 +515,20 @@ var SubscriptionProcessor = /** @class */ (function () {
502
515
  var header = 'Backend subscriptions filtering error.\n' +
503
516
  'Subscriptions filtering will be applied clientside.\n';
504
517
  var messageErrorTypeMap = {
505
- 'UnknownArgument: Unknown field argument filter': utils_1.RTFError.UnknownField,
506
- 'Filters exceed maximum attributes limit': utils_1.RTFError.MaxAttributes,
507
- 'Filters combination exceed maximum limit': utils_1.RTFError.MaxCombinations,
508
- 'filter uses same fieldName multiple time': utils_1.RTFError.RepeatedFieldname,
509
- "The variables input contains a field name 'not'": utils_1.RTFError.NotGroup,
510
- 'The variables input contains a field that is not defined for input object type': utils_1.RTFError.FieldNotInType,
518
+ 'UnknownArgument: Unknown field argument filter': utils_2.RTFError.UnknownField,
519
+ 'Filters exceed maximum attributes limit': utils_2.RTFError.MaxAttributes,
520
+ 'Filters combination exceed maximum limit': utils_2.RTFError.MaxCombinations,
521
+ 'filter uses same fieldName multiple time': utils_2.RTFError.RepeatedFieldname,
522
+ "The variables input contains a field name 'not'": utils_2.RTFError.NotGroup,
523
+ 'The variables input contains a field that is not defined for input object type': utils_2.RTFError.FieldNotInType,
511
524
  };
512
- var _a = tslib_1.__read(Object.entries(messageErrorTypeMap).find(function (_a) {
513
- var _b = tslib_1.__read(_a, 1), errorMsg = _b[0];
525
+ var _a = __read(Object.entries(messageErrorTypeMap).find(function (_a) {
526
+ var _b = __read(_a, 1), errorMsg = _b[0];
514
527
  return message.includes(errorMsg);
515
528
  }) || [], 2), _errorMsg = _a[0], errorType = _a[1];
516
529
  if (errorType !== undefined) {
517
- var remediationMessage = utils_1.generateRTFRemediation(errorType, modelDefinition, predicatesGroup);
518
- logger.warn(header + "\n" + message + "\n" + remediationMessage);
530
+ var remediationMessage = (0, utils_2.generateRTFRemediation)(errorType, modelDefinition, predicatesGroup);
531
+ logger.warn("".concat(header, "\n").concat(message, "\n").concat(remediationMessage));
519
532
  return true;
520
533
  }
521
534
  return false;
@@ -523,4 +536,3 @@ var SubscriptionProcessor = /** @class */ (function () {
523
536
  return SubscriptionProcessor;
524
537
  }());
525
538
  exports.SubscriptionProcessor = SubscriptionProcessor;
526
- //# sourceMappingURL=subscription.js.map