@microsoft/1ds-post-js 3.1.9 → 3.2.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 (60) hide show
  1. package/README.md +124 -5
  2. package/bundle/{ms.post-3.1.9.gbl.js → ms.post-3.2.0.gbl.js} +1706 -825
  3. package/bundle/ms.post-3.2.0.gbl.js.map +1 -0
  4. package/bundle/ms.post-3.2.0.gbl.min.js +7 -0
  5. package/bundle/ms.post-3.2.0.gbl.min.js.map +1 -0
  6. package/bundle/ms.post-3.2.0.integrity.json +46 -0
  7. package/bundle/{ms.post-3.1.9.js → ms.post-3.2.0.js} +1706 -825
  8. package/bundle/ms.post-3.2.0.js.map +1 -0
  9. package/bundle/ms.post-3.2.0.min.js +7 -0
  10. package/bundle/ms.post-3.2.0.min.js.map +1 -0
  11. package/bundle/ms.post.gbl.js +1705 -824
  12. package/bundle/ms.post.gbl.js.map +1 -1
  13. package/bundle/ms.post.gbl.min.js +2 -2
  14. package/bundle/ms.post.gbl.min.js.map +1 -1
  15. package/bundle/ms.post.integrity.json +17 -17
  16. package/bundle/ms.post.js +1705 -824
  17. package/bundle/ms.post.js.map +1 -1
  18. package/bundle/ms.post.min.js +2 -2
  19. package/bundle/ms.post.min.js.map +1 -1
  20. package/dist/ms.post.js +395 -212
  21. package/dist/ms.post.js.map +1 -1
  22. package/dist/ms.post.min.js +2 -2
  23. package/dist/ms.post.min.js.map +1 -1
  24. package/dist-esm/src/BatchNotificationActions.js +1 -1
  25. package/dist-esm/src/ClockSkewManager.js +1 -1
  26. package/dist-esm/src/Constants.d.ts +25 -0
  27. package/dist-esm/src/Constants.js +31 -0
  28. package/dist-esm/src/Constants.js.map +1 -0
  29. package/dist-esm/src/DataModels.d.ts +55 -0
  30. package/dist-esm/src/DataModels.js +1 -1
  31. package/dist-esm/src/EventBatch.d.ts +5 -2
  32. package/dist-esm/src/EventBatch.js +35 -15
  33. package/dist-esm/src/EventBatch.js.map +1 -1
  34. package/dist-esm/src/HttpManager.d.ts +2 -2
  35. package/dist-esm/src/HttpManager.js +186 -94
  36. package/dist-esm/src/HttpManager.js.map +1 -1
  37. package/dist-esm/src/Index.js +1 -1
  38. package/dist-esm/src/KillSwitch.js +1 -1
  39. package/dist-esm/src/PostChannel.d.ts +0 -4
  40. package/dist-esm/src/PostChannel.js +175 -107
  41. package/dist-esm/src/PostChannel.js.map +1 -1
  42. package/dist-esm/src/RetryPolicy.d.ts +20 -25
  43. package/dist-esm/src/RetryPolicy.js +35 -44
  44. package/dist-esm/src/RetryPolicy.js.map +1 -1
  45. package/dist-esm/src/Serializer.js +1 -1
  46. package/dist-esm/src/typings/XDomainRequest.js +1 -1
  47. package/package.json +3 -3
  48. package/src/Constants.ts +28 -0
  49. package/src/DataModels.ts +68 -0
  50. package/src/EventBatch.ts +47 -14
  51. package/src/HttpManager.ts +216 -98
  52. package/src/PostChannel.ts +207 -130
  53. package/src/RetryPolicy.ts +33 -38
  54. package/bundle/ms.post-3.1.9.gbl.js.map +0 -1
  55. package/bundle/ms.post-3.1.9.gbl.min.js +0 -7
  56. package/bundle/ms.post-3.1.9.gbl.min.js.map +0 -1
  57. package/bundle/ms.post-3.1.9.integrity.json +0 -46
  58. package/bundle/ms.post-3.1.9.js.map +0 -1
  59. package/bundle/ms.post-3.1.9.min.js +0 -7
  60. package/bundle/ms.post-3.1.9.min.js.map +0 -1
@@ -9,43 +9,38 @@ const BaseBackoff = 3000;
9
9
  const MaxBackoff = 600000;
10
10
 
11
11
  /**
12
- * Class for retry policy.
13
- */
14
- export default class RetryPolicy {
15
- /**
16
- * Determine if the request should be retried for the given status code.
17
- * The below expression reads that we should only retry for:
18
- * - HttpStatusCodes that are smaller than 300.
19
- * - HttpStatusCodes greater or equal to 500 (except for 501-NotImplement
20
- * and 505-HttpVersionNotSupport).
21
- * - HttpStatusCode 408-RequestTimeout.
22
- * - HttpStatusCode 429.
23
- * This is based on Microsoft.WindowsAzure.Storage.RetryPolicies.ExponentialRetry class
24
- * @param httpStatusCode - The status code returned for the request.
25
- * @returns True if request should be retried, false otherwise.
26
- */
27
- public static shouldRetryForStatus(httpStatusCode: number): boolean {
28
- /* tslint:disable:triple-equals */
29
- // Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value
30
- return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 408 && httpStatusCode != 429)
31
- || (httpStatusCode == 501)
32
- || (httpStatusCode == 505));
33
- /* tslint:enable:triple-equals */
34
- }
12
+ * Determine if the request should be retried for the given status code.
13
+ * The below expression reads that we should only retry for:
14
+ * - HttpStatusCodes that are smaller than 300.
15
+ * - HttpStatusCodes greater or equal to 500 (except for 501-NotImplement
16
+ * and 505-HttpVersionNotSupport).
17
+ * - HttpStatusCode 408-RequestTimeout.
18
+ * - HttpStatusCode 429.
19
+ * This is based on Microsoft.WindowsAzure.Storage.RetryPolicies.ExponentialRetry class
20
+ * @param httpStatusCode - The status code returned for the request.
21
+ * @returns True if request should be retried, false otherwise.
22
+ */
23
+ export function retryPolicyShouldRetryForStatus(httpStatusCode: number): boolean {
24
+ /* tslint:disable:triple-equals */
25
+ // Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value
26
+ return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 408 && httpStatusCode != 429)
27
+ || (httpStatusCode == 501)
28
+ || (httpStatusCode == 505));
29
+ /* tslint:enable:triple-equals */
30
+ }
35
31
 
36
- /**
37
- * Gets the number of milliseconds to back off before retrying the request. The
38
- * back off duration is exponentially scaled based on the number of retries already
39
- * done for the request.
40
- * @param retriesSoFar - The number of times the request has already been retried.
41
- * @returns The back off duration for the request before it can be retried.
42
- */
43
- public static getMillisToBackoffForRetry(retriesSoFar: number): number {
44
- let waitDuration = 0;
45
- let minBackoff = BaseBackoff * RandomizationLowerThreshold;
46
- let maxBackoff = BaseBackoff * RandomizationUpperThreshold;
47
- let randomBackoff = Math.floor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
48
- waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;
49
- return Math.min(waitDuration, MaxBackoff);
50
- }
32
+ /**
33
+ * Gets the number of milliseconds to back off before retrying the request. The
34
+ * back off duration is exponentially scaled based on the number of retries already
35
+ * done for the request.
36
+ * @param retriesSoFar - The number of times the request has already been retried.
37
+ * @returns The back off duration for the request before it can be retried.
38
+ */
39
+ export function retryPolicyGetMillisToBackoffForRetry(retriesSoFar: number): number {
40
+ let waitDuration = 0;
41
+ let minBackoff = BaseBackoff * RandomizationLowerThreshold;
42
+ let maxBackoff = BaseBackoff * RandomizationUpperThreshold;
43
+ let randomBackoff = Math.floor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
44
+ waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;
45
+ return Math.min(waitDuration, MaxBackoff);
51
46
  }