@aws-amplify/core 4.6.2-next.20 → 4.6.2-next.36

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 (215) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/lib/.tsbuildinfo +3 -0
  3. package/lib/Amplify.d.ts +0 -4
  4. package/lib/Amplify.js +0 -4
  5. package/lib/Amplify.js.map +1 -1
  6. package/lib/ClientDevice/android.js +1 -1
  7. package/lib/ClientDevice/browser.js +1 -1
  8. package/lib/ClientDevice/index.d.ts +0 -4
  9. package/lib/ClientDevice/index.js +1 -5
  10. package/lib/ClientDevice/index.js.map +1 -1
  11. package/lib/ClientDevice/ios.js +1 -1
  12. package/lib/ClientDevice/reactnative.d.ts +0 -7
  13. package/lib/ClientDevice/reactnative.js +1 -5
  14. package/lib/ClientDevice/reactnative.js.map +1 -1
  15. package/lib/Credentials.d.ts +1 -5
  16. package/lib/Credentials.js +1 -5
  17. package/lib/Credentials.js.map +1 -1
  18. package/lib/Errors.js +1 -1
  19. package/lib/Hub.d.ts +28 -4
  20. package/lib/Hub.js +34 -10
  21. package/lib/Hub.js.map +1 -1
  22. package/lib/I18n/I18n.js +1 -1
  23. package/lib/I18n/index.d.ts +0 -4
  24. package/lib/I18n/index.js +1 -5
  25. package/lib/I18n/index.js.map +1 -1
  26. package/lib/I18n/types.js +1 -1
  27. package/lib/JS.d.ts +0 -24
  28. package/lib/JS.js +3 -28
  29. package/lib/JS.js.map +1 -1
  30. package/lib/Logger/ConsoleLogger.js +1 -1
  31. package/lib/Logger/index.d.ts +1 -1
  32. package/lib/Logger/index.js +4 -3
  33. package/lib/Logger/index.js.map +1 -1
  34. package/lib/Logger/logger-interface.d.ts +0 -4
  35. package/lib/Logger/logger-interface.js +1 -1
  36. package/lib/OAuthHelper/FacebookOAuth.d.ts +0 -4
  37. package/lib/OAuthHelper/FacebookOAuth.js +1 -5
  38. package/lib/OAuthHelper/FacebookOAuth.js.map +1 -1
  39. package/lib/OAuthHelper/GoogleOAuth.d.ts +0 -4
  40. package/lib/OAuthHelper/GoogleOAuth.js +1 -5
  41. package/lib/OAuthHelper/GoogleOAuth.js.map +1 -1
  42. package/lib/OAuthHelper/index.js +1 -1
  43. package/lib/Platform/index.d.ts +0 -4
  44. package/lib/Platform/index.js +1 -5
  45. package/lib/Platform/index.js.map +1 -1
  46. package/lib/Platform/version.d.ts +1 -1
  47. package/lib/Platform/version.js +1 -1
  48. package/lib/Platform/version.js.map +1 -1
  49. package/lib/Providers/AWSCloudWatchProvider.js +3 -3
  50. package/lib/Providers/AWSCloudWatchProvider.js.map +1 -1
  51. package/lib/Providers/index.d.ts +1 -1
  52. package/lib/Providers/index.js +2 -2
  53. package/lib/Providers/index.js.map +1 -1
  54. package/lib/RNComponents/index.js +1 -1
  55. package/lib/RNComponents/reactnative.js +1 -1
  56. package/lib/ServiceWorker/ServiceWorker.d.ts +0 -4
  57. package/lib/ServiceWorker/ServiceWorker.js +0 -4
  58. package/lib/ServiceWorker/ServiceWorker.js.map +1 -1
  59. package/lib/Signer.d.ts +0 -4
  60. package/lib/Signer.js +1 -5
  61. package/lib/Signer.js.map +1 -1
  62. package/lib/StorageHelper/index.d.ts +0 -4
  63. package/lib/StorageHelper/index.js +1 -5
  64. package/lib/StorageHelper/index.js.map +1 -1
  65. package/lib/StorageHelper/reactnative.d.ts +0 -4
  66. package/lib/StorageHelper/reactnative.js +1 -5
  67. package/lib/StorageHelper/reactnative.js.map +1 -1
  68. package/lib/Util/BackgroundProcessManager.d.ts +204 -0
  69. package/lib/Util/BackgroundProcessManager.js +385 -0
  70. package/lib/Util/BackgroundProcessManager.js.map +1 -0
  71. package/lib/Util/Constants.js +1 -1
  72. package/lib/Util/Retry.d.ts +2 -2
  73. package/lib/Util/Retry.js +76 -34
  74. package/lib/Util/Retry.js.map +1 -1
  75. package/lib/Util/index.d.ts +5 -4
  76. package/lib/Util/index.js +23 -5
  77. package/lib/Util/index.js.map +1 -1
  78. package/lib/constants.js +1 -1
  79. package/lib/index.d.ts +8 -9
  80. package/lib/index.js +53 -12
  81. package/lib/index.js.map +1 -1
  82. package/lib/parseAWSExports.d.ts +2 -0
  83. package/lib/{Parser.js → parseAWSExports.js} +2 -16
  84. package/lib/parseAWSExports.js.map +1 -0
  85. package/lib-esm/.tsbuildinfo +3 -0
  86. package/lib-esm/Amplify.d.ts +0 -4
  87. package/lib-esm/Amplify.js +0 -4
  88. package/lib-esm/Amplify.js.map +1 -1
  89. package/lib-esm/ClientDevice/android.js +1 -1
  90. package/lib-esm/ClientDevice/browser.js +1 -1
  91. package/lib-esm/ClientDevice/index.d.ts +0 -4
  92. package/lib-esm/ClientDevice/index.js +1 -5
  93. package/lib-esm/ClientDevice/index.js.map +1 -1
  94. package/lib-esm/ClientDevice/ios.js +1 -1
  95. package/lib-esm/ClientDevice/reactnative.d.ts +0 -7
  96. package/lib-esm/ClientDevice/reactnative.js +1 -5
  97. package/lib-esm/ClientDevice/reactnative.js.map +1 -1
  98. package/lib-esm/Credentials.d.ts +1 -5
  99. package/lib-esm/Credentials.js +1 -5
  100. package/lib-esm/Credentials.js.map +1 -1
  101. package/lib-esm/Errors.js +1 -1
  102. package/lib-esm/Hub.d.ts +28 -4
  103. package/lib-esm/Hub.js +34 -10
  104. package/lib-esm/Hub.js.map +1 -1
  105. package/lib-esm/I18n/I18n.js +1 -1
  106. package/lib-esm/I18n/index.d.ts +0 -4
  107. package/lib-esm/I18n/index.js +1 -5
  108. package/lib-esm/I18n/index.js.map +1 -1
  109. package/lib-esm/I18n/types.js +1 -1
  110. package/lib-esm/JS.d.ts +0 -24
  111. package/lib-esm/JS.js +3 -28
  112. package/lib-esm/JS.js.map +1 -1
  113. package/lib-esm/Logger/ConsoleLogger.js +1 -1
  114. package/lib-esm/Logger/index.d.ts +1 -1
  115. package/lib-esm/Logger/index.js +2 -2
  116. package/lib-esm/Logger/index.js.map +1 -1
  117. package/lib-esm/Logger/logger-interface.d.ts +0 -4
  118. package/lib-esm/Logger/logger-interface.js +1 -1
  119. package/lib-esm/OAuthHelper/FacebookOAuth.d.ts +0 -4
  120. package/lib-esm/OAuthHelper/FacebookOAuth.js +1 -5
  121. package/lib-esm/OAuthHelper/FacebookOAuth.js.map +1 -1
  122. package/lib-esm/OAuthHelper/GoogleOAuth.d.ts +0 -4
  123. package/lib-esm/OAuthHelper/GoogleOAuth.js +1 -5
  124. package/lib-esm/OAuthHelper/GoogleOAuth.js.map +1 -1
  125. package/lib-esm/OAuthHelper/index.js +1 -1
  126. package/lib-esm/Platform/index.d.ts +0 -4
  127. package/lib-esm/Platform/index.js +1 -5
  128. package/lib-esm/Platform/index.js.map +1 -1
  129. package/lib-esm/Platform/version.d.ts +1 -1
  130. package/lib-esm/Platform/version.js +1 -1
  131. package/lib-esm/Platform/version.js.map +1 -1
  132. package/lib-esm/Providers/AWSCloudWatchProvider.js +3 -3
  133. package/lib-esm/Providers/AWSCloudWatchProvider.js.map +1 -1
  134. package/lib-esm/Providers/index.d.ts +1 -1
  135. package/lib-esm/Providers/index.js +1 -1
  136. package/lib-esm/Providers/index.js.map +1 -1
  137. package/lib-esm/RNComponents/index.js +1 -1
  138. package/lib-esm/RNComponents/reactnative.js +1 -1
  139. package/lib-esm/ServiceWorker/ServiceWorker.d.ts +0 -4
  140. package/lib-esm/ServiceWorker/ServiceWorker.js +0 -4
  141. package/lib-esm/ServiceWorker/ServiceWorker.js.map +1 -1
  142. package/lib-esm/Signer.d.ts +0 -4
  143. package/lib-esm/Signer.js +1 -5
  144. package/lib-esm/Signer.js.map +1 -1
  145. package/lib-esm/StorageHelper/index.d.ts +0 -4
  146. package/lib-esm/StorageHelper/index.js +1 -5
  147. package/lib-esm/StorageHelper/index.js.map +1 -1
  148. package/lib-esm/StorageHelper/reactnative.d.ts +0 -4
  149. package/lib-esm/StorageHelper/reactnative.js +1 -5
  150. package/lib-esm/StorageHelper/reactnative.js.map +1 -1
  151. package/lib-esm/Util/BackgroundProcessManager.d.ts +204 -0
  152. package/lib-esm/Util/BackgroundProcessManager.js +383 -0
  153. package/lib-esm/Util/BackgroundProcessManager.js.map +1 -0
  154. package/lib-esm/Util/Constants.js +1 -1
  155. package/lib-esm/Util/Retry.d.ts +2 -2
  156. package/lib-esm/Util/Retry.js +76 -34
  157. package/lib-esm/Util/Retry.js.map +1 -1
  158. package/lib-esm/Util/index.d.ts +5 -4
  159. package/lib-esm/Util/index.js +5 -4
  160. package/lib-esm/Util/index.js.map +1 -1
  161. package/lib-esm/constants.js +1 -1
  162. package/lib-esm/index.d.ts +8 -9
  163. package/lib-esm/index.js +9 -10
  164. package/lib-esm/index.js.map +1 -1
  165. package/lib-esm/parseAWSExports.d.ts +2 -0
  166. package/lib-esm/{Parser.js → parseAWSExports.js} +2 -16
  167. package/lib-esm/parseAWSExports.js.map +1 -0
  168. package/package.json +11 -4
  169. package/src/Amplify.ts +0 -5
  170. package/src/ClientDevice/android.ts +1 -1
  171. package/src/ClientDevice/browser.ts +1 -1
  172. package/src/ClientDevice/index.ts +1 -6
  173. package/src/ClientDevice/ios.ts +1 -1
  174. package/src/ClientDevice/reactnative.ts +1 -6
  175. package/src/Credentials.ts +13 -19
  176. package/src/Errors.ts +1 -1
  177. package/src/Hub.ts +39 -12
  178. package/src/I18n/I18n.ts +1 -1
  179. package/src/I18n/index.ts +1 -6
  180. package/src/I18n/types.ts +1 -1
  181. package/src/JS.ts +5 -26
  182. package/src/Logger/ConsoleLogger.ts +1 -1
  183. package/src/Logger/index.ts +2 -2
  184. package/src/Logger/logger-interface.ts +1 -6
  185. package/src/OAuthHelper/FacebookOAuth.ts +1 -6
  186. package/src/OAuthHelper/GoogleOAuth.ts +1 -6
  187. package/src/OAuthHelper/index.ts +1 -1
  188. package/src/Platform/index.ts +1 -6
  189. package/src/Platform/version.ts +1 -1
  190. package/src/Providers/AWSCloudWatchProvider.ts +3 -3
  191. package/src/Providers/index.ts +1 -1
  192. package/src/RNComponents/index.ts +1 -1
  193. package/src/RNComponents/reactnative.ts +1 -1
  194. package/src/ServiceWorker/ServiceWorker.ts +1 -6
  195. package/src/Signer.ts +1 -6
  196. package/src/StorageHelper/index.ts +1 -6
  197. package/src/StorageHelper/reactnative.ts +1 -6
  198. package/src/Util/BackgroundProcessManager.ts +449 -0
  199. package/src/Util/Constants.ts +1 -1
  200. package/src/Util/Retry.ts +66 -31
  201. package/src/Util/index.ts +23 -4
  202. package/src/constants.ts +1 -1
  203. package/src/index.ts +47 -10
  204. package/src/{Parser.ts → parseAWSExports.ts} +1 -13
  205. package/build.js +0 -5
  206. package/dist/aws-amplify-core.js +0 -39352
  207. package/dist/aws-amplify-core.js.map +0 -1
  208. package/dist/aws-amplify-core.min.js +0 -134
  209. package/dist/aws-amplify-core.min.js.map +0 -1
  210. package/index.js +0 -7
  211. package/lib/Parser.d.ts +0 -12
  212. package/lib/Parser.js.map +0 -1
  213. package/lib-esm/Parser.d.ts +0 -12
  214. package/lib-esm/Parser.js.map +0 -1
  215. package/webpack.config.dev.js +0 -6
@@ -0,0 +1,204 @@
1
+ /**
2
+ * @private For internal Amplify use.
3
+ *
4
+ * Creates a new scope for promises, observables, and other types of work or
5
+ * processes that may be running in the background. This manager provides
6
+ * an singular entrypoint to request termination and await completion.
7
+ *
8
+ * As work completes on its own prior to close, the manager removes them
9
+ * from the registry to avoid holding references to completed jobs.
10
+ */
11
+ export declare class BackgroundProcessManager {
12
+ /**
13
+ * A string indicating whether the manager is accepting new work ("Open"),
14
+ * waiting for work to complete ("Closing"), or fully done with all
15
+ * submitted work and *not* accepting new jobs ("Closed").
16
+ */
17
+ private _state;
18
+ private _closingPromise;
19
+ /**
20
+ * The list of outstanding jobs we'll need to wait for upon `close()`
21
+ */
22
+ private jobs;
23
+ /**
24
+ * Creates a new manager for promises, observables, and other types
25
+ * of work that may be running in the background. This manager provides
26
+ * a centralized mechanism to request termination and await completion.
27
+ */
28
+ constructor();
29
+ /**
30
+ * Executes an async `job` function, passing the return value through to
31
+ * the caller, registering it as a running job in the manager. When the
32
+ * manager *closes*, it will `await` the job.
33
+ *
34
+ * @param job The function to execute.
35
+ * @param description Optional description to help identify pending jobs.
36
+ * @returns The return value from the given function.
37
+ */
38
+ add<T>(job: () => Promise<T>, description?: string): Promise<T>;
39
+ /**
40
+ * Executes an async `job` function, passing the return value through to
41
+ * the caller, registering it as a running job in the manager. When the
42
+ * manager *closes*, it will request termination by resolving the
43
+ * provided `onTerminate` promise. It will then `await` the job, so it is
44
+ * important that the job still `resolve()` or `reject()` when responding
45
+ * to a termination request.
46
+ *
47
+ * @param job The function to execute.
48
+ * @param description Optional description to help identify pending jobs.
49
+ * @returns The return value from the given function.
50
+ */
51
+ add<T>(job: (onTerminate: Promise<void>) => Promise<T>, description?: string): Promise<T>;
52
+ /**
53
+ * Create a no-op job, registers it with the manager, and returns hooks
54
+ * to the caller to signal the job's completion and respond to termination
55
+ * requests.
56
+ *
57
+ * When the manager closes, the no-op job will be `await`-ed, so its
58
+ * important to always `resolve()` or `reject()` when done responding to an
59
+ * `onTerminate` signal.
60
+ * @param description Optional description to help identify pending jobs.
61
+ * @returns Job promise hooks + onTerminate signaling promise
62
+ */
63
+ add(description?: string): {
64
+ resolve: (value?: unknown) => void;
65
+ reject: (reason?: any) => void;
66
+ onTerminate: Promise<void>;
67
+ };
68
+ /**
69
+ * Adds another job manager to await on at the time of closing. the inner
70
+ * manager's termination is signaled when this manager's `close()` is
71
+ * called for.
72
+ *
73
+ * @param job The inner job manager to await.
74
+ * @param description Optional description to help identify pending jobs.
75
+ */
76
+ add(job: BackgroundProcessManager, description?: string): any;
77
+ /**
78
+ * Adds a **cleaner** function that doesn't immediately get executed.
79
+ * Instead, the caller gets a **terminate** function back. The *cleaner* is
80
+ * invoked only once the mananger *closes* or the returned **terminate**
81
+ * function is called.
82
+ *
83
+ * @param clean The cleanup function.
84
+ * @param description Optional description to help identify pending jobs.
85
+ * @returns A terminate function.
86
+ */
87
+ addCleaner<T>(clean: () => Promise<T>, description?: string): () => Promise<void>;
88
+ private addFunction;
89
+ private addManager;
90
+ /**
91
+ * Creates and registers a fabricated job for processes that need to operate
92
+ * with callbacks/hooks. The returned `resolve` and `reject`
93
+ * functions can be used to signal the job is done successfully or not.
94
+ * The returned `onTerminate` is a promise that will resolve when the
95
+ * manager is requesting the termination of the job.
96
+ *
97
+ * @param description Optional description to help identify pending jobs.
98
+ * @returns `{ resolve, reject, onTerminate }`
99
+ */
100
+ private addHook;
101
+ /**
102
+ * Adds a Promise based job to the list of jobs for monitoring and listens
103
+ * for either a success or failure, upon which the job is considered "done"
104
+ * and removed from the registry.
105
+ *
106
+ * @param promise A promise that is on its way to being returned to a
107
+ * caller, which needs to be tracked as a background job.
108
+ * @param terminate The termination function to register, which can be
109
+ * invoked to request the job stop.
110
+ * @param description Optional description to help identify pending jobs.
111
+ */
112
+ private registerPromise;
113
+ /**
114
+ * The number of jobs being waited on.
115
+ *
116
+ * We don't use this for anything. It's just informational for the caller,
117
+ * and can be used in logging and testing.
118
+ *
119
+ * @returns the number of jobs.
120
+ */
121
+ get length(): number;
122
+ /**
123
+ * The execution state of the manager. One of:
124
+ *
125
+ * 1. "Open" -> Accepting new jobs
126
+ * 1. "Closing" -> Not accepting new work. Waiting for jobs to complete.
127
+ * 1. "Closed" -> Not accepting new work. All submitted jobs are complete.
128
+ */
129
+ get state(): BackgroundProcessManagerState;
130
+ /**
131
+ * The registered `description` of all still-pending jobs.
132
+ *
133
+ * @returns descriptions as an array.
134
+ */
135
+ get pending(): string[];
136
+ /**
137
+ * Whether the manager is accepting new jobs.
138
+ */
139
+ get isOpen(): boolean;
140
+ /**
141
+ * Whether the manager is rejecting new work, but still waiting for
142
+ * submitted work to complete.
143
+ */
144
+ get isClosing(): boolean;
145
+ /**
146
+ * Whether the manager is rejecting work and done waiting for submitted
147
+ * work to complete.
148
+ */
149
+ get isClosed(): boolean;
150
+ private closedFailure;
151
+ /**
152
+ * Signals jobs to stop (for those that accept interruptions) and waits
153
+ * for confirmation that jobs have stopped.
154
+ *
155
+ * This immediately puts the manager into a closing state and just begins
156
+ * to reject new work. After all work in the manager is complete, the
157
+ * manager goes into a `Completed` state and `close()` returns.
158
+ *
159
+ * This call is idempotent.
160
+ *
161
+ * If the manager is already closing or closed, `finalCleaup` is not executed.
162
+ *
163
+ * @param onClosed
164
+ * @returns The settled results of each still-running job's promise. If the
165
+ * manager is already closed, this will contain the results as of when the
166
+ * manager's `close()` was called in an `Open` state.
167
+ */
168
+ close(): Promise<any>;
169
+ /**
170
+ * Signals the manager to start accepting work (again) and returns once
171
+ * the manager is ready to do so.
172
+ *
173
+ * If the state is already `Open`, this call is a no-op.
174
+ *
175
+ * If the state is `Closed`, this call simply updates state and returns.
176
+ *
177
+ * If the state is `Closing`, this call waits for completion before it
178
+ * updates the state and returns.
179
+ */
180
+ open(): Promise<void>;
181
+ }
182
+ /**
183
+ *
184
+ */
185
+ export declare class BackgroundManagerNotOpenError extends Error {
186
+ constructor(message: string);
187
+ }
188
+ /**
189
+ * All possible states a `BackgroundProcessManager` instance can be in.
190
+ */
191
+ export declare enum BackgroundProcessManagerState {
192
+ /**
193
+ * Accepting new jobs.
194
+ */
195
+ Open = "Open",
196
+ /**
197
+ * Not accepting new jobs. Waiting for submitted jobs to complete.
198
+ */
199
+ Closing = "Closing",
200
+ /**
201
+ * Not accepting new jobs. All submitted jobs are complete.
202
+ */
203
+ Closed = "Closed"
204
+ }
@@ -0,0 +1,385 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ /**
5
+ * @private For internal Amplify use.
6
+ *
7
+ * Creates a new scope for promises, observables, and other types of work or
8
+ * processes that may be running in the background. This manager provides
9
+ * an singular entrypoint to request termination and await completion.
10
+ *
11
+ * As work completes on its own prior to close, the manager removes them
12
+ * from the registry to avoid holding references to completed jobs.
13
+ */
14
+ var BackgroundProcessManager = /** @class */ (function () {
15
+ /**
16
+ * Creates a new manager for promises, observables, and other types
17
+ * of work that may be running in the background. This manager provides
18
+ * a centralized mechanism to request termination and await completion.
19
+ */
20
+ function BackgroundProcessManager() {
21
+ /**
22
+ * A string indicating whether the manager is accepting new work ("Open"),
23
+ * waiting for work to complete ("Closing"), or fully done with all
24
+ * submitted work and *not* accepting new jobs ("Closed").
25
+ */
26
+ this._state = BackgroundProcessManagerState.Open;
27
+ /**
28
+ * The list of outstanding jobs we'll need to wait for upon `close()`
29
+ */
30
+ this.jobs = new Set();
31
+ }
32
+ BackgroundProcessManager.prototype.add = function (jobOrDescription, optionalDescription) {
33
+ var job;
34
+ var description;
35
+ if (typeof jobOrDescription === 'string') {
36
+ job = undefined;
37
+ description = jobOrDescription;
38
+ }
39
+ else {
40
+ job = jobOrDescription;
41
+ description = optionalDescription;
42
+ }
43
+ var error = this.closedFailure(description);
44
+ if (error)
45
+ return error;
46
+ if (job === undefined) {
47
+ return this.addHook(description);
48
+ }
49
+ else if (typeof job === 'function') {
50
+ return this.addFunction(job, description);
51
+ }
52
+ else if (job instanceof BackgroundProcessManager) {
53
+ return this.addManager(job, description);
54
+ }
55
+ else {
56
+ throw new Error('If `job` is provided, it must be an Observable, Function, or BackgroundProcessManager.');
57
+ }
58
+ };
59
+ /**
60
+ * Adds a **cleaner** function that doesn't immediately get executed.
61
+ * Instead, the caller gets a **terminate** function back. The *cleaner* is
62
+ * invoked only once the mananger *closes* or the returned **terminate**
63
+ * function is called.
64
+ *
65
+ * @param clean The cleanup function.
66
+ * @param description Optional description to help identify pending jobs.
67
+ * @returns A terminate function.
68
+ */
69
+ BackgroundProcessManager.prototype.addCleaner = function (clean, description) {
70
+ var _this = this;
71
+ var _a = this.addHook(description), resolve = _a.resolve, onTerminate = _a.onTerminate;
72
+ var proxy = function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
73
+ return tslib_1.__generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0: return [4 /*yield*/, clean()];
76
+ case 1:
77
+ _a.sent();
78
+ resolve();
79
+ return [2 /*return*/];
80
+ }
81
+ });
82
+ }); };
83
+ onTerminate.then(proxy);
84
+ return proxy;
85
+ };
86
+ BackgroundProcessManager.prototype.addFunction = function (job, description) {
87
+ // the function we call when we want to try to terminate this job.
88
+ var terminate;
89
+ // the promise the job can opt into listening to for termination.
90
+ var onTerminate = new Promise(function (resolve) {
91
+ terminate = resolve;
92
+ });
93
+ // finally! start the job.
94
+ var jobResult = job(onTerminate);
95
+ // depending on what the job gives back, register the result
96
+ // so we can monitor for completion.
97
+ if (typeof (jobResult === null || jobResult === void 0 ? void 0 : jobResult.then) === 'function') {
98
+ this.registerPromise(jobResult, terminate, description);
99
+ }
100
+ // At the end of the day, or you know, method call, it doesn't matter
101
+ // what the return value is at all; we just pass it through to the
102
+ // caller.
103
+ return jobResult;
104
+ };
105
+ BackgroundProcessManager.prototype.addManager = function (manager, description) {
106
+ var _this = this;
107
+ this.addCleaner(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
108
+ switch (_a.label) {
109
+ case 0: return [4 /*yield*/, manager.close()];
110
+ case 1: return [2 /*return*/, _a.sent()];
111
+ }
112
+ }); }); }, description);
113
+ };
114
+ /**
115
+ * Creates and registers a fabricated job for processes that need to operate
116
+ * with callbacks/hooks. The returned `resolve` and `reject`
117
+ * functions can be used to signal the job is done successfully or not.
118
+ * The returned `onTerminate` is a promise that will resolve when the
119
+ * manager is requesting the termination of the job.
120
+ *
121
+ * @param description Optional description to help identify pending jobs.
122
+ * @returns `{ resolve, reject, onTerminate }`
123
+ */
124
+ BackgroundProcessManager.prototype.addHook = function (description) {
125
+ // the resolve/reject functions we'll provide to the caller to signal
126
+ // the state of the job.
127
+ var resolve;
128
+ var reject;
129
+ // the underlying promise we'll use to manage it, pretty much like
130
+ // any other promise.
131
+ var promise = new Promise(function (res, rej) {
132
+ resolve = res;
133
+ reject = rej;
134
+ });
135
+ // the function we call when we want to try to terminate this job.
136
+ var terminate;
137
+ // the promise the job can opt into listening to for termination.
138
+ var onTerminate = new Promise(function (resolveTerminate) {
139
+ terminate = resolveTerminate;
140
+ });
141
+ this.registerPromise(promise, terminate, description);
142
+ return {
143
+ resolve: resolve,
144
+ reject: reject,
145
+ onTerminate: onTerminate,
146
+ };
147
+ };
148
+ /**
149
+ * Adds a Promise based job to the list of jobs for monitoring and listens
150
+ * for either a success or failure, upon which the job is considered "done"
151
+ * and removed from the registry.
152
+ *
153
+ * @param promise A promise that is on its way to being returned to a
154
+ * caller, which needs to be tracked as a background job.
155
+ * @param terminate The termination function to register, which can be
156
+ * invoked to request the job stop.
157
+ * @param description Optional description to help identify pending jobs.
158
+ */
159
+ BackgroundProcessManager.prototype.registerPromise = function (promise, terminate, description) {
160
+ var _this = this;
161
+ var jobEntry = { promise: promise, terminate: terminate, description: description };
162
+ this.jobs.add(jobEntry);
163
+ // in all of my testing, it is safe to multi-subscribe to a promise.
164
+ // so, rather than create another layer of promising, we're just going
165
+ // to hook into the promise we already have, and when it's done
166
+ // (successfully or not), we no longer need to wait for it upon close.
167
+ //
168
+ // sorry this is a bit hand-wavy:
169
+ //
170
+ // i believe we use `.then` and `.catch` instead of `.finally` because
171
+ // `.finally` is invoked in a different order in the sequence, and this
172
+ // breaks assumptions throughout and causes failures.
173
+ promise
174
+ .then(function () {
175
+ _this.jobs.delete(jobEntry);
176
+ })
177
+ .catch(function () {
178
+ _this.jobs.delete(jobEntry);
179
+ });
180
+ };
181
+ Object.defineProperty(BackgroundProcessManager.prototype, "length", {
182
+ /**
183
+ * The number of jobs being waited on.
184
+ *
185
+ * We don't use this for anything. It's just informational for the caller,
186
+ * and can be used in logging and testing.
187
+ *
188
+ * @returns the number of jobs.
189
+ */
190
+ get: function () {
191
+ return this.jobs.size;
192
+ },
193
+ enumerable: true,
194
+ configurable: true
195
+ });
196
+ Object.defineProperty(BackgroundProcessManager.prototype, "state", {
197
+ /**
198
+ * The execution state of the manager. One of:
199
+ *
200
+ * 1. "Open" -> Accepting new jobs
201
+ * 1. "Closing" -> Not accepting new work. Waiting for jobs to complete.
202
+ * 1. "Closed" -> Not accepting new work. All submitted jobs are complete.
203
+ */
204
+ get: function () {
205
+ return this._state;
206
+ },
207
+ enumerable: true,
208
+ configurable: true
209
+ });
210
+ Object.defineProperty(BackgroundProcessManager.prototype, "pending", {
211
+ /**
212
+ * The registered `description` of all still-pending jobs.
213
+ *
214
+ * @returns descriptions as an array.
215
+ */
216
+ get: function () {
217
+ return Array.from(this.jobs).map(function (job) { return job.description; });
218
+ },
219
+ enumerable: true,
220
+ configurable: true
221
+ });
222
+ Object.defineProperty(BackgroundProcessManager.prototype, "isOpen", {
223
+ /**
224
+ * Whether the manager is accepting new jobs.
225
+ */
226
+ get: function () {
227
+ return this._state === BackgroundProcessManagerState.Open;
228
+ },
229
+ enumerable: true,
230
+ configurable: true
231
+ });
232
+ Object.defineProperty(BackgroundProcessManager.prototype, "isClosing", {
233
+ /**
234
+ * Whether the manager is rejecting new work, but still waiting for
235
+ * submitted work to complete.
236
+ */
237
+ get: function () {
238
+ return this._state === BackgroundProcessManagerState.Closing;
239
+ },
240
+ enumerable: true,
241
+ configurable: true
242
+ });
243
+ Object.defineProperty(BackgroundProcessManager.prototype, "isClosed", {
244
+ /**
245
+ * Whether the manager is rejecting work and done waiting for submitted
246
+ * work to complete.
247
+ */
248
+ get: function () {
249
+ return this._state === BackgroundProcessManagerState.Closed;
250
+ },
251
+ enumerable: true,
252
+ configurable: true
253
+ });
254
+ BackgroundProcessManager.prototype.closedFailure = function (description) {
255
+ if (!this.isOpen) {
256
+ return Promise.reject(new BackgroundManagerNotOpenError([
257
+ "The manager is " + this.state + ".",
258
+ "You tried to add \"" + description + "\".",
259
+ "Pending jobs: [\n" + this.pending
260
+ .map(function (t) { return ' ' + t; })
261
+ .join(',\n') + "\n]",
262
+ ].join('\n')));
263
+ }
264
+ };
265
+ /**
266
+ * Signals jobs to stop (for those that accept interruptions) and waits
267
+ * for confirmation that jobs have stopped.
268
+ *
269
+ * This immediately puts the manager into a closing state and just begins
270
+ * to reject new work. After all work in the manager is complete, the
271
+ * manager goes into a `Completed` state and `close()` returns.
272
+ *
273
+ * This call is idempotent.
274
+ *
275
+ * If the manager is already closing or closed, `finalCleaup` is not executed.
276
+ *
277
+ * @param onClosed
278
+ * @returns The settled results of each still-running job's promise. If the
279
+ * manager is already closed, this will contain the results as of when the
280
+ * manager's `close()` was called in an `Open` state.
281
+ */
282
+ BackgroundProcessManager.prototype.close = function () {
283
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
284
+ var _a, _b, job;
285
+ var e_1, _c;
286
+ return tslib_1.__generator(this, function (_d) {
287
+ switch (_d.label) {
288
+ case 0:
289
+ if (!this.isOpen) return [3 /*break*/, 2];
290
+ this._state = BackgroundProcessManagerState.Closing;
291
+ try {
292
+ for (_a = tslib_1.__values(Array.from(this.jobs)), _b = _a.next(); !_b.done; _b = _a.next()) {
293
+ job = _b.value;
294
+ try {
295
+ job.terminate();
296
+ }
297
+ catch (error) {
298
+ // Due to potential races with a job's natural completion, it's
299
+ // reasonable to expect the termination call to fail. Hence,
300
+ // not logging as an error.
301
+ console.warn("Failed to send termination signal to job. Error: " + error.message, job);
302
+ }
303
+ }
304
+ }
305
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
306
+ finally {
307
+ try {
308
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
309
+ }
310
+ finally { if (e_1) throw e_1.error; }
311
+ }
312
+ // Use `allSettled()` because we want to wait for all to finish. We do
313
+ // not want to stop waiting if there is a failure.
314
+ this._closingPromise = Promise.allSettled(Array.from(this.jobs).map(function (j) { return j.promise; }));
315
+ return [4 /*yield*/, this._closingPromise];
316
+ case 1:
317
+ _d.sent();
318
+ this._state = BackgroundProcessManagerState.Closed;
319
+ _d.label = 2;
320
+ case 2: return [2 /*return*/, this._closingPromise];
321
+ }
322
+ });
323
+ });
324
+ };
325
+ /**
326
+ * Signals the manager to start accepting work (again) and returns once
327
+ * the manager is ready to do so.
328
+ *
329
+ * If the state is already `Open`, this call is a no-op.
330
+ *
331
+ * If the state is `Closed`, this call simply updates state and returns.
332
+ *
333
+ * If the state is `Closing`, this call waits for completion before it
334
+ * updates the state and returns.
335
+ */
336
+ BackgroundProcessManager.prototype.open = function () {
337
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
338
+ return tslib_1.__generator(this, function (_a) {
339
+ switch (_a.label) {
340
+ case 0:
341
+ if (!this.isClosing) return [3 /*break*/, 2];
342
+ return [4 /*yield*/, this.close()];
343
+ case 1:
344
+ _a.sent();
345
+ _a.label = 2;
346
+ case 2:
347
+ this._state = BackgroundProcessManagerState.Open;
348
+ return [2 /*return*/];
349
+ }
350
+ });
351
+ });
352
+ };
353
+ return BackgroundProcessManager;
354
+ }());
355
+ exports.BackgroundProcessManager = BackgroundProcessManager;
356
+ /**
357
+ *
358
+ */
359
+ var BackgroundManagerNotOpenError = /** @class */ (function (_super) {
360
+ tslib_1.__extends(BackgroundManagerNotOpenError, _super);
361
+ function BackgroundManagerNotOpenError(message) {
362
+ return _super.call(this, "BackgroundManagerNotOpenError: " + message) || this;
363
+ }
364
+ return BackgroundManagerNotOpenError;
365
+ }(Error));
366
+ exports.BackgroundManagerNotOpenError = BackgroundManagerNotOpenError;
367
+ /**
368
+ * All possible states a `BackgroundProcessManager` instance can be in.
369
+ */
370
+ var BackgroundProcessManagerState;
371
+ (function (BackgroundProcessManagerState) {
372
+ /**
373
+ * Accepting new jobs.
374
+ */
375
+ BackgroundProcessManagerState["Open"] = "Open";
376
+ /**
377
+ * Not accepting new jobs. Waiting for submitted jobs to complete.
378
+ */
379
+ BackgroundProcessManagerState["Closing"] = "Closing";
380
+ /**
381
+ * Not accepting new jobs. All submitted jobs are complete.
382
+ */
383
+ BackgroundProcessManagerState["Closed"] = "Closed";
384
+ })(BackgroundProcessManagerState = exports.BackgroundProcessManagerState || (exports.BackgroundProcessManagerState = {}));
385
+ //# sourceMappingURL=BackgroundProcessManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackgroundProcessManager.js","sourceRoot":"","sources":["../../src/Util/B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served.
3
+ * Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
4
  *
5
5
  * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
6
6
  * the License. A copy of the License is located at
@@ -8,7 +8,7 @@ export declare const isNonRetryableError: (obj: any) => obj is NonRetryableError
8
8
  * @private
9
9
  * Internal use of Amplify only
10
10
  */
11
- export declare function retry(functionToRetry: Function, args: any[], delayFn: DelayFunction, attempt?: number): any;
11
+ export declare function retry<T>(functionToRetry: (...args: any[]) => T, args: any[], delayFn: DelayFunction, onTerminate?: Promise<void>): Promise<T>;
12
12
  /**
13
13
  * @private
14
14
  * Internal use of Amplify only
@@ -18,4 +18,4 @@ export declare function jitteredBackoff(maxDelayMs?: number): DelayFunction;
18
18
  * @private
19
19
  * Internal use of Amplify only
20
20
  */
21
- export declare const jitteredExponentialRetry: (functionToRetry: Function, args: any[], maxDelayMs?: number) => any;
21
+ export declare const jitteredExponentialRetry: <T>(functionToRetry: (...args: any[]) => T, args: any[], maxDelayMs?: number, onTerminate?: Promise<void>) => Promise<T>;