@appzung/react-native-code-push 11.0.0-rc3 → 11.0.0-rc5

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 (223) hide show
  1. package/README.md +7 -7
  2. package/android/app/src/main/java/com/appzung/codepush/react/CodePush.java +3 -0
  3. package/docs/advanced-usage.md +15 -0
  4. package/docs/api-js/README.md +5 -2
  5. package/docs/api-js/enumerations/CheckFrequency.md +1 -1
  6. package/docs/api-js/enumerations/DeploymentStatus.md +1 -1
  7. package/docs/api-js/enumerations/InstallMode.md +1 -1
  8. package/docs/api-js/enumerations/LogLevel.md +31 -0
  9. package/docs/api-js/enumerations/SyncStatus.md +1 -1
  10. package/docs/api-js/enumerations/UpdateState.md +1 -1
  11. package/docs/api-js/functions/allowRestart.md +1 -1
  12. package/docs/api-js/functions/checkForUpdate.md +1 -1
  13. package/docs/api-js/functions/clearUpdates.md +1 -1
  14. package/docs/api-js/functions/disallowRestart.md +1 -1
  15. package/docs/api-js/functions/getClientUniqueId.md +1 -1
  16. package/docs/api-js/functions/getLogLevel.md +13 -0
  17. package/docs/api-js/functions/getUpdateMetadata.md +1 -1
  18. package/docs/api-js/functions/notifyAppReady.md +1 -1
  19. package/docs/api-js/functions/resetClientUniqueId.md +1 -1
  20. package/docs/api-js/functions/restartApp.md +1 -1
  21. package/docs/api-js/functions/setLogLevel.md +19 -0
  22. package/docs/api-js/functions/sync.md +1 -1
  23. package/docs/api-js/functions/withCodePush.md +1 -1
  24. package/docs/api-js/interfaces/CodePushOptions.md +1 -1
  25. package/docs/api-js/interfaces/DownloadProgress.md +1 -1
  26. package/docs/api-js/interfaces/LocalPackage.md +1 -1
  27. package/docs/api-js/interfaces/Package.md +1 -1
  28. package/docs/api-js/interfaces/RemotePackage.md +1 -1
  29. package/docs/api-js/interfaces/RollbackRetryOptions.md +1 -1
  30. package/docs/api-js/interfaces/StatusReport.md +1 -1
  31. package/docs/api-js/interfaces/SyncOptions.md +1 -1
  32. package/docs/api-js/interfaces/UpdateDialog.md +1 -1
  33. package/docs/api-js/type-aliases/DownloadProgressCallback.md +1 -1
  34. package/docs/api-js/type-aliases/HandleBinaryVersionMismatchCallback.md +4 -2
  35. package/docs/api-js/type-aliases/SyncStatusChangedCallback.md +1 -1
  36. package/docs/api-js/variables/DEFAULT_UPDATE_DIALOG.md +1 -1
  37. package/docs/code-signing.md +2 -0
  38. package/docs/setup-android.md +0 -1
  39. package/ios/CodePush/CodePushConfig.m +4 -0
  40. package/lib/commonjs/CodePush.js +5 -0
  41. package/lib/commonjs/CodePush.js.map +1 -1
  42. package/lib/commonjs/checkForUpdates.js +25 -26
  43. package/lib/commonjs/checkForUpdates.js.map +1 -1
  44. package/lib/commonjs/enums/LogLevel.enum.js +14 -0
  45. package/lib/commonjs/enums/LogLevel.enum.js.map +1 -0
  46. package/lib/commonjs/index.js +30 -9
  47. package/lib/commonjs/index.js.map +1 -1
  48. package/lib/commonjs/internals/CodePushApiSdk.errors.js +26 -0
  49. package/lib/commonjs/internals/CodePushApiSdk.errors.js.map +1 -0
  50. package/lib/commonjs/internals/CodePushApiSdk.js +100 -0
  51. package/lib/commonjs/internals/CodePushApiSdk.js.map +1 -0
  52. package/lib/commonjs/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +3 -2
  53. package/lib/commonjs/internals/CodePushApiSdk.types.js.map +1 -0
  54. package/lib/commonjs/internals/RemotePackageImplementation.js +7 -5
  55. package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -1
  56. package/lib/commonjs/internals/shouldUpdateBeIgnored.js +6 -5
  57. package/lib/commonjs/internals/shouldUpdateBeIgnored.js.map +1 -1
  58. package/lib/commonjs/internals/utils/fetchRetry.js +59 -0
  59. package/lib/commonjs/internals/utils/fetchRetry.js.map +1 -0
  60. package/lib/commonjs/internals/utils/log.js +6 -1
  61. package/lib/commonjs/internals/utils/log.js.map +1 -1
  62. package/lib/commonjs/internals/utils/queryStringify.js +25 -0
  63. package/lib/commonjs/internals/utils/queryStringify.js.map +1 -0
  64. package/lib/commonjs/internals/utils/requestFetchAdapter.js +38 -0
  65. package/lib/commonjs/internals/utils/requestFetchAdapter.js.map +1 -0
  66. package/lib/commonjs/internals/version.js +1 -1
  67. package/lib/commonjs/logLevel.js +15 -0
  68. package/lib/commonjs/logLevel.js.map +1 -0
  69. package/lib/commonjs/notifyAppReady.js +22 -15
  70. package/lib/commonjs/notifyAppReady.js.map +1 -1
  71. package/lib/commonjs/sync.js +27 -24
  72. package/lib/commonjs/sync.js.map +1 -1
  73. package/lib/module/CodePush.js +5 -0
  74. package/lib/module/CodePush.js.map +1 -1
  75. package/lib/module/checkForUpdates.js +25 -26
  76. package/lib/module/checkForUpdates.js.map +1 -1
  77. package/lib/module/enums/LogLevel.enum.js +10 -0
  78. package/lib/module/enums/LogLevel.enum.js.map +1 -0
  79. package/lib/module/index.js +3 -1
  80. package/lib/module/index.js.map +1 -1
  81. package/lib/module/internals/CodePushApiSdk.errors.js +20 -0
  82. package/lib/module/internals/CodePushApiSdk.errors.js.map +1 -0
  83. package/lib/module/internals/CodePushApiSdk.js +96 -0
  84. package/lib/module/internals/CodePushApiSdk.js.map +1 -0
  85. package/lib/module/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +2 -1
  86. package/lib/module/internals/CodePushApiSdk.types.js.map +1 -0
  87. package/lib/module/internals/RemotePackageImplementation.js +7 -5
  88. package/lib/module/internals/RemotePackageImplementation.js.map +1 -1
  89. package/lib/module/internals/shouldUpdateBeIgnored.js +6 -5
  90. package/lib/module/internals/shouldUpdateBeIgnored.js.map +1 -1
  91. package/lib/module/internals/utils/fetchRetry.js +55 -0
  92. package/lib/module/internals/utils/fetchRetry.js.map +1 -0
  93. package/lib/module/internals/utils/log.js +7 -1
  94. package/lib/module/internals/utils/log.js.map +1 -1
  95. package/lib/module/internals/utils/queryStringify.js +21 -0
  96. package/lib/module/internals/utils/queryStringify.js.map +1 -0
  97. package/lib/module/internals/utils/requestFetchAdapter.js +34 -0
  98. package/lib/module/internals/utils/requestFetchAdapter.js.map +1 -0
  99. package/lib/module/internals/version.js +1 -1
  100. package/lib/module/logLevel.js +9 -0
  101. package/lib/module/logLevel.js.map +1 -0
  102. package/lib/module/notifyAppReady.js +22 -15
  103. package/lib/module/notifyAppReady.js.map +1 -1
  104. package/lib/module/sync.js +27 -24
  105. package/lib/module/sync.js.map +1 -1
  106. package/lib/typescript/commonjs/src/CodePush.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts +7 -0
  109. package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/src/index.d.ts +3 -1
  111. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts +13 -0
  113. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts.map +1 -0
  114. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts +9 -0
  115. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
  116. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts +101 -0
  117. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts +2 -2
  119. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -1
  120. package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/src/internals/types.d.ts +2 -2
  122. package/lib/typescript/commonjs/src/internals/types.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts +9 -0
  124. package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts.map +1 -0
  125. package/lib/typescript/commonjs/src/internals/utils/log.d.ts +2 -1
  126. package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts +4 -0
  128. package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts.map +1 -0
  129. package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts +3 -0
  130. package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
  131. package/lib/typescript/commonjs/src/internals/version.d.ts +1 -1
  132. package/lib/typescript/commonjs/src/logLevel.d.ts +4 -0
  133. package/lib/typescript/commonjs/src/logLevel.d.ts.map +1 -0
  134. package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -1
  135. package/lib/typescript/commonjs/src/sync.d.ts.map +1 -1
  136. package/lib/typescript/commonjs/src/types.d.ts +4 -3
  137. package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
  138. package/lib/typescript/module/src/CodePush.d.ts.map +1 -1
  139. package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -1
  140. package/lib/typescript/module/src/enums/LogLevel.enum.d.ts +7 -0
  141. package/lib/typescript/module/src/enums/LogLevel.enum.d.ts.map +1 -0
  142. package/lib/typescript/module/src/index.d.ts +3 -1
  143. package/lib/typescript/module/src/index.d.ts.map +1 -1
  144. package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts +13 -0
  145. package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts.map +1 -0
  146. package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts +9 -0
  147. package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
  148. package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts +101 -0
  149. package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
  150. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts +2 -2
  151. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -1
  152. package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
  153. package/lib/typescript/module/src/internals/types.d.ts +2 -2
  154. package/lib/typescript/module/src/internals/types.d.ts.map +1 -1
  155. package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts +9 -0
  156. package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts.map +1 -0
  157. package/lib/typescript/module/src/internals/utils/log.d.ts +2 -1
  158. package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -1
  159. package/lib/typescript/module/src/internals/utils/queryStringify.d.ts +4 -0
  160. package/lib/typescript/module/src/internals/utils/queryStringify.d.ts.map +1 -0
  161. package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts +3 -0
  162. package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
  163. package/lib/typescript/module/src/internals/version.d.ts +1 -1
  164. package/lib/typescript/module/src/logLevel.d.ts +4 -0
  165. package/lib/typescript/module/src/logLevel.d.ts.map +1 -0
  166. package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -1
  167. package/lib/typescript/module/src/sync.d.ts.map +1 -1
  168. package/lib/typescript/module/src/types.d.ts +4 -3
  169. package/lib/typescript/module/src/types.d.ts.map +1 -1
  170. package/package.json +3 -3
  171. package/src/CodePush.tsx +6 -0
  172. package/src/checkForUpdates.ts +26 -24
  173. package/src/enums/LogLevel.enum.ts +6 -0
  174. package/src/index.ts +3 -1
  175. package/src/internals/CodePushApiSdk.errors.ts +22 -0
  176. package/src/internals/CodePushApiSdk.ts +133 -0
  177. package/src/internals/CodePushApiSdk.types.ts +115 -0
  178. package/src/internals/RemotePackageImplementation.ts +9 -7
  179. package/src/internals/shouldUpdateBeIgnored.ts +6 -5
  180. package/src/internals/types.ts +2 -2
  181. package/src/internals/utils/fetchRetry.ts +72 -0
  182. package/src/internals/utils/log.ts +9 -1
  183. package/src/internals/utils/queryStringify.ts +22 -0
  184. package/src/internals/utils/requestFetchAdapter.ts +36 -0
  185. package/src/internals/version.ts +1 -1
  186. package/src/logLevel.ts +9 -0
  187. package/src/notifyAppReady.ts +25 -18
  188. package/src/sync.ts +33 -23
  189. package/src/types.ts +2 -3
  190. package/lib/commonjs/enums/DeploymentStatus.enum.js.map +0 -1
  191. package/lib/commonjs/internals/AcquisitionSdk.js +0 -9
  192. package/lib/commonjs/internals/AcquisitionSdk.js.map +0 -1
  193. package/lib/commonjs/internals/getPromisifiedSdk.js +0 -49
  194. package/lib/commonjs/internals/getPromisifiedSdk.js.map +0 -1
  195. package/lib/commonjs/internals/utils/request-fetch-adapter.js +0 -50
  196. package/lib/commonjs/internals/utils/request-fetch-adapter.js.map +0 -1
  197. package/lib/module/enums/DeploymentStatus.enum.js.map +0 -1
  198. package/lib/module/internals/AcquisitionSdk.js +0 -5
  199. package/lib/module/internals/AcquisitionSdk.js.map +0 -1
  200. package/lib/module/internals/getPromisifiedSdk.js +0 -45
  201. package/lib/module/internals/getPromisifiedSdk.js.map +0 -1
  202. package/lib/module/internals/utils/request-fetch-adapter.js +0 -46
  203. package/lib/module/internals/utils/request-fetch-adapter.js.map +0 -1
  204. package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts +0 -14
  205. package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
  206. package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts +0 -3
  207. package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts.map +0 -1
  208. package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts +0 -13
  209. package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts.map +0 -1
  210. package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts +0 -3
  211. package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
  212. package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts +0 -14
  213. package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
  214. package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts +0 -3
  215. package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts.map +0 -1
  216. package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts +0 -13
  217. package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts.map +0 -1
  218. package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts +0 -3
  219. package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
  220. package/src/enums/DeploymentStatus.enum.ts +0 -14
  221. package/src/internals/AcquisitionSdk.ts +0 -3
  222. package/src/internals/getPromisifiedSdk.ts +0 -72
  223. package/src/internals/utils/request-fetch-adapter.ts +0 -58
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,MAAM,CAAC;IAEtC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,QA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CAAC,EAAE,MAAM,CAAC;CACpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appzung/react-native-code-push",
3
- "version": "11.0.0-rc3",
3
+ "version": "11.0.0-rc5",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "author": "Louis Lagrange <lagrange.louis@gmail.com> (https://github.com/Minishlink)",
6
6
  "license": "MIT",
@@ -51,7 +51,6 @@
51
51
  "url": "https://github.com/appzung/react-native-code-push"
52
52
  },
53
53
  "dependencies": {
54
- "code-push": "^4.2.3",
55
54
  "hoist-non-react-statics": "^3.3.2"
56
55
  },
57
56
  "devDependencies": {
@@ -118,5 +117,6 @@
118
117
  "expo-updates",
119
118
  "expo-ota",
120
119
  "appcenter"
121
- ]
120
+ ],
121
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
122
122
  }
package/src/CodePush.tsx CHANGED
@@ -2,6 +2,8 @@ import hoistStatics from 'hoist-non-react-statics';
2
2
  import React from 'react';
3
3
  import { AppState } from 'react-native';
4
4
  import { CheckFrequency } from './enums/CheckFrequency.enum';
5
+ import { LogLevel } from './enums/LogLevel.enum';
6
+ import { log } from './internals/utils/log';
5
7
  import { notifyAppReady } from './notifyAppReady';
6
8
  import { sync } from './sync';
7
9
  import type {
@@ -54,6 +56,8 @@ export function withCodePush<P extends object>(optionsOrComponent: CodePushOptio
54
56
  }
55
57
 
56
58
  componentDidMount() {
59
+ log(LogLevel.DEBUG, `withCodePush ${JSON.stringify(options)}`);
60
+
57
61
  if (options.checkFrequency === CheckFrequency.MANUAL) {
58
62
  notifyAppReady();
59
63
  } else {
@@ -75,11 +79,13 @@ export function withCodePush<P extends object>(optionsOrComponent: CodePushOptio
75
79
  rootComponentInstance.codePushOnBinaryVersionMismatch.bind(rootComponentInstance);
76
80
  }
77
81
 
82
+ log(LogLevel.DEBUG, `sync on mount`);
78
83
  sync(options, syncStatusCallback, downloadProgressCallback, handleBinaryVersionMismatchCallback);
79
84
 
80
85
  if (options.checkFrequency === CheckFrequency.ON_APP_RESUME) {
81
86
  AppState.addEventListener('change', (newState: string) => {
82
87
  if (newState === 'active') {
88
+ log(LogLevel.DEBUG, `sync on active appState`);
83
89
  sync(options, syncStatusCallback, downloadProgressCallback);
84
90
  }
85
91
  });
@@ -1,12 +1,14 @@
1
1
  import { Platform } from 'react-native';
2
+ import { LogLevel } from './enums/LogLevel.enum';
3
+ import { CodePushApiSdk } from './internals/CodePushApiSdk';
4
+ import type { ApiSdkQueryUpdatePackageInfo } from './internals/CodePushApiSdk.types';
2
5
  import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
3
6
  import { RemotePackageImpl } from './internals/RemotePackageImplementation';
4
7
  import { getConfiguration } from './internals/getConfiguration';
5
8
  import { getCurrentPackage } from './internals/getCurrentPackage';
6
- import { type PromisifiedSdkQueryPackage, getPromisifiedSdk } from './internals/getPromisifiedSdk';
7
9
  import type { Configuration } from './internals/types';
8
10
  import { log } from './internals/utils/log';
9
- import { requestFetchAdapter } from './internals/utils/request-fetch-adapter';
11
+ import { requestFetchAdapter } from './internals/utils/requestFetchAdapter';
10
12
  import type { HandleBinaryVersionMismatchCallback, RemotePackage } from './types';
11
13
 
12
14
  /**
@@ -36,10 +38,8 @@ export async function checkForUpdate(
36
38
  * dynamically "redirecting" end-users at different
37
39
  * release channels (e.g. an early access release channel for insiders).
38
40
  */
39
- const config: Configuration = releaseChannelPublicId
40
- ? { ...nativeConfig, ...{ releaseChannelPublicId } }
41
- : nativeConfig;
42
- const sdk = getPromisifiedSdk(requestFetchAdapter, config);
41
+ const config: Configuration = releaseChannelPublicId ? { ...nativeConfig, releaseChannelPublicId } : nativeConfig;
42
+ const sdk = new CodePushApiSdk(requestFetchAdapter, config);
43
43
 
44
44
  const localPackage = await getCurrentPackage();
45
45
 
@@ -51,15 +51,10 @@ export async function checkForUpdate(
51
51
  * to send the app version to the server, since we are interested
52
52
  * in any updates for current binary version, regardless of hash.
53
53
  */
54
- let queryPackage: PromisifiedSdkQueryPackage;
55
- if (localPackage) {
56
- queryPackage = localPackage;
57
- } else {
58
- queryPackage = { appVersion: config.appVersion };
59
- if (Platform.OS === 'ios' && config.packageHash) {
60
- queryPackage.packageHash = config.packageHash;
61
- }
62
- }
54
+ const queryPackage: ApiSdkQueryUpdatePackageInfo = localPackage ?? {
55
+ appVersion: config.appVersion,
56
+ ...(Platform.OS === 'ios' && config.packageHash ? { packageHash: config.packageHash } : {}),
57
+ };
63
58
 
64
59
  const update = await sdk.queryUpdateWithCurrentPackage(queryPackage);
65
60
 
@@ -85,25 +80,32 @@ export async function checkForUpdate(
85
80
  return null;
86
81
  }
87
82
 
88
- if ('updateAppVersion' in update && update.updateAppVersion) {
89
- log('An update is available but it is not targeting the binary version of your app.');
83
+ if ('updateAppVersion' in update) {
84
+ if (!update.updateAppVersion) {
85
+ throw new Error('updateAppVersion should never be false');
86
+ }
87
+
88
+ log(LogLevel.INFO, 'An update is available but it is not targeting the binary version of your app.');
90
89
  handleBinaryVersionMismatchCallback?.(update);
91
90
 
92
91
  return null;
93
92
  }
94
93
 
95
94
  if (
96
- (localPackage && 'packageHash' in update && update.packageHash === localPackage.packageHash) ||
95
+ (localPackage && update.packageHash === localPackage.packageHash) ||
97
96
  ((!localPackage || ('_isDebugOnly' in localPackage && localPackage._isDebugOnly)) &&
98
- 'packageHash' in update &&
99
97
  config.packageHash === update.packageHash)
100
98
  ) {
101
99
  return null;
102
100
  }
103
101
 
104
- // @ts-expect-error sdk typing is wrong
105
- const remotePackage = new RemotePackageImpl(update, sdk.reportStatusDownload);
106
- remotePackage.failedInstall = await NativeRNAppZungCodePushModule.isFailedUpdate(remotePackage.packageHash);
107
- remotePackage.releaseChannelPublicId = releaseChannelPublicId || nativeConfig.releaseChannelPublicId;
108
- return remotePackage;
102
+ const remotePackageData: Omit<RemotePackage, 'download'> = {
103
+ ...update,
104
+ releaseChannelPublicId: releaseChannelPublicId || nativeConfig.releaseChannelPublicId,
105
+ failedInstall: await NativeRNAppZungCodePushModule.isFailedUpdate(update.packageHash),
106
+ isFirstRun: false,
107
+ isPending: false,
108
+ };
109
+
110
+ return new RemotePackageImpl(remotePackageData, (packageInfo) => sdk.reportStatusDownload(packageInfo));
109
111
  }
@@ -0,0 +1,6 @@
1
+ export enum LogLevel {
2
+ DEBUG,
3
+ INFO,
4
+ WARN,
5
+ ERROR,
6
+ }
package/src/index.ts CHANGED
@@ -10,11 +10,13 @@ export * from './restartApp';
10
10
  export * from './sync';
11
11
  export * from './getClientUniqueId';
12
12
  export * from './resetClientUniqueId';
13
+ export * from './logLevel';
13
14
 
14
15
  export * from './types';
15
16
 
16
17
  export * from './enums/SyncStatus.enum';
17
18
  export * from './enums/InstallMode.enum';
18
19
  export * from './enums/UpdateState.enum';
19
- export * from './enums/DeploymentStatus.enum';
20
+ export { DeploymentStatus } from './internals/CodePushApiSdk.types';
20
21
  export * from './enums/CheckFrequency.enum';
22
+ export * from './enums/LogLevel.enum';
@@ -0,0 +1,22 @@
1
+ export class CodePushError extends Error {
2
+ constructor(message: string) {
3
+ super(message);
4
+ this.name = 'CodePushError';
5
+ }
6
+ }
7
+
8
+ export class CodePushHttpError extends CodePushError {
9
+ constructor(
10
+ readonly url: string,
11
+ readonly statusCode: number,
12
+ message: string,
13
+ ) {
14
+ super(message);
15
+
16
+ if (statusCode === 0) {
17
+ this.message = `Couldn't send request to ${url}, xhr.statusCode = 0 was returned. One of the possible reasons for that might be connection problems. Please, check your internet connection.`;
18
+ }
19
+
20
+ this.name = 'CodePushHttpError';
21
+ }
22
+ }
@@ -0,0 +1,133 @@
1
+ import { CodePushError, CodePushHttpError } from './CodePushApiSdk.errors';
2
+ import {
3
+ type ApiSdkConfiguration,
4
+ type ApiSdkDeployReportPackageInfo,
5
+ type ApiSdkDownloadReportPackageInfo,
6
+ type ApiSdkNativeUpdateNotification,
7
+ type ApiSdkQueryUpdatePackageInfo,
8
+ type ApiSdkRemotePackage,
9
+ type CheckUpdateRequestInput,
10
+ type CheckUpdateResponse,
11
+ DeploymentStatus,
12
+ type Http,
13
+ type ReportDeployInput,
14
+ type ReportDownloadInput,
15
+ } from './CodePushApiSdk.types';
16
+ import { queryStringify } from './utils/queryStringify';
17
+
18
+ // TODO move this to @appzung/code-push-api-sdk
19
+
20
+ export class CodePushApiSdk {
21
+ private configuration: ApiSdkConfiguration;
22
+
23
+ constructor(
24
+ private readonly httpRequester: Http.Requester,
25
+ configuration: ApiSdkConfiguration,
26
+ ) {
27
+ this.configuration = { ...configuration };
28
+ if (this.configuration.serverUrl.slice(-1) !== '/') {
29
+ this.configuration.serverUrl += '/';
30
+ }
31
+ this.configuration.serverUrl += 'v0.1/public/codepush';
32
+ }
33
+
34
+ async queryUpdateWithCurrentPackage(
35
+ currentPackageInfo: ApiSdkQueryUpdatePackageInfo,
36
+ ): Promise<ApiSdkRemotePackage | ApiSdkNativeUpdateNotification | null> {
37
+ const query: CheckUpdateRequestInput = {
38
+ deployment_key: this.configuration.releaseChannelPublicId,
39
+ app_version: currentPackageInfo.appVersion,
40
+ package_hash: currentPackageInfo.packageHash,
41
+ is_companion: this.configuration.ignoreAppVersion,
42
+ label: currentPackageInfo.label,
43
+ client_unique_id: this.configuration.clientUniqueId,
44
+ };
45
+
46
+ const url = `${this.configuration.serverUrl}/update_check?${queryStringify(query)}`;
47
+
48
+ const response = await this.httpRequester.request('GET', url);
49
+
50
+ if (response.statusCode < 200 || response.statusCode >= 300) {
51
+ throw new CodePushHttpError(url, response.statusCode, response.body || 'No body');
52
+ }
53
+
54
+ const responseObject: CheckUpdateResponse | Record<string, never> = JSON.parse(response.body || '{}');
55
+ if (!responseObject.update_info) {
56
+ throw new CodePushError('Missing update info in response');
57
+ }
58
+
59
+ const { update_info: updateInfo } = responseObject;
60
+
61
+ if (updateInfo.update_app_version) {
62
+ return {
63
+ updateAppVersion: true,
64
+ appVersion: responseObject.update_info.target_binary_range,
65
+ };
66
+ }
67
+
68
+ if (!updateInfo.is_available) {
69
+ return null;
70
+ }
71
+
72
+ return {
73
+ releaseChannelPublicId: this.configuration.releaseChannelPublicId,
74
+ description: updateInfo.description,
75
+ label: updateInfo.label,
76
+ appVersion: updateInfo.target_binary_range,
77
+ isMandatory: updateInfo.is_mandatory,
78
+ packageHash: updateInfo.package_hash,
79
+ packageSize: updateInfo.package_size,
80
+ downloadUrl: updateInfo.download_url,
81
+ };
82
+ }
83
+
84
+ async reportStatusDeploy(
85
+ deployedPackageInfo: { package: ApiSdkDeployReportPackageInfo; status: DeploymentStatus } | null,
86
+ previousLabelOrAppVersion: string | null,
87
+ previousDeploymentKey: string | null,
88
+ ): Promise<void> {
89
+ const requestBody: ReportDeployInput = {
90
+ app_version: this.configuration.appVersion,
91
+ deployment_key: this.configuration.releaseChannelPublicId,
92
+ client_unique_id: this.configuration.clientUniqueId,
93
+ };
94
+
95
+ if (deployedPackageInfo) {
96
+ requestBody.label = deployedPackageInfo.package.label;
97
+ requestBody.app_version = deployedPackageInfo.package.appVersion;
98
+ requestBody.status = deployedPackageInfo.status;
99
+ }
100
+
101
+ if (previousLabelOrAppVersion) {
102
+ requestBody.previous_label_or_app_version = previousLabelOrAppVersion;
103
+ }
104
+
105
+ if (previousDeploymentKey) {
106
+ requestBody.previous_deployment_key = previousDeploymentKey;
107
+ }
108
+
109
+ const url = `${this.configuration.serverUrl}/report_status/deploy`;
110
+
111
+ const response = await this.httpRequester.request('POST', url, JSON.stringify(requestBody));
112
+
113
+ if (response.statusCode < 200 || response.statusCode >= 300) {
114
+ throw new CodePushHttpError(url, response.statusCode, response.body || 'No body');
115
+ }
116
+ }
117
+
118
+ async reportStatusDownload(downloadedPackage: ApiSdkDownloadReportPackageInfo): Promise<void> {
119
+ const requestBody: ReportDownloadInput = {
120
+ client_unique_id: this.configuration.clientUniqueId,
121
+ deployment_key: this.configuration.releaseChannelPublicId,
122
+ label: downloadedPackage.label,
123
+ };
124
+
125
+ const url = `${this.configuration.serverUrl}/report_status/download`;
126
+
127
+ const response = await this.httpRequester.request('POST', url, JSON.stringify(requestBody));
128
+
129
+ if (response.statusCode < 200 || response.statusCode >= 300) {
130
+ throw new CodePushHttpError(url, response.statusCode, response.body || 'No body');
131
+ }
132
+ }
133
+ }
@@ -0,0 +1,115 @@
1
+ export interface ApiSdkQueryUpdatePackageInfo {
2
+ appVersion: string;
3
+ label?: string;
4
+ packageHash?: string;
5
+ }
6
+
7
+ export interface ApiSdkDeployReportPackageInfo {
8
+ label: string;
9
+ appVersion: string;
10
+ }
11
+
12
+ export interface ApiSdkDownloadReportPackageInfo {
13
+ label: string;
14
+ }
15
+
16
+ export interface ApiSdkRemotePackage {
17
+ releaseChannelPublicId: string;
18
+ label: string;
19
+ appVersion: string;
20
+ description: string;
21
+ isMandatory: boolean;
22
+ packageSize: number;
23
+ packageHash: string;
24
+ downloadUrl: string;
25
+ }
26
+
27
+ export interface ApiSdkNativeUpdateNotification {
28
+ updateAppVersion: true;
29
+ appVersion: string;
30
+ }
31
+
32
+ export namespace Http {
33
+ export interface Response {
34
+ statusCode: number;
35
+ body?: string;
36
+ }
37
+
38
+ export interface Requester {
39
+ request(verb: 'GET' | 'POST', url: string, requestBody?: string | object | null): Promise<Response>;
40
+ }
41
+ }
42
+
43
+ export interface ApiSdkConfiguration {
44
+ appVersion: string;
45
+ clientUniqueId: string;
46
+ releaseChannelPublicId: string;
47
+ serverUrl: string;
48
+ ignoreAppVersion?: boolean;
49
+ }
50
+
51
+ /**
52
+ * Indicates the status of a deployment (after installing and restarting).
53
+ */
54
+ export enum DeploymentStatus {
55
+ /**
56
+ * The deployment failed (and was rolled back).
57
+ */
58
+ FAILED = 'DeploymentFailed',
59
+
60
+ /**
61
+ * The deployment succeeded.
62
+ */
63
+ SUCCEEDED = 'DeploymentSucceeded',
64
+ }
65
+
66
+ export interface ReportDeployInput {
67
+ deployment_key: string;
68
+ app_version: string;
69
+ status?: DeploymentStatus;
70
+ label?: string;
71
+ client_unique_id?: string;
72
+ previous_label_or_app_version?: string;
73
+ previous_deployment_key?: string;
74
+ }
75
+
76
+ export interface ReportDownloadInput {
77
+ deployment_key: string;
78
+ label: string;
79
+ client_unique_id?: string;
80
+ }
81
+
82
+ export interface CheckUpdateRequestInput {
83
+ deployment_key: string;
84
+ app_version: string;
85
+ package_hash?: string;
86
+ label?: string;
87
+ client_unique_id?: string;
88
+ is_companion?: boolean;
89
+ previous_label_or_app_version?: string;
90
+ previous_deployment_key?: string;
91
+ }
92
+
93
+ export interface CheckUpdateResponse {
94
+ update_info:
95
+ | {
96
+ is_available: true;
97
+ target_binary_range: string;
98
+ description: string;
99
+ is_disabled: boolean;
100
+ is_mandatory: boolean;
101
+ rollout: number;
102
+ download_url: string;
103
+ package_size: number;
104
+ package_hash: string;
105
+ label: string;
106
+ should_run_binary_version: boolean;
107
+ update_app_version: boolean;
108
+ }
109
+ | {
110
+ is_available: false;
111
+ should_run_binary_version: boolean;
112
+ target_binary_range: string;
113
+ update_app_version?: boolean;
114
+ };
115
+ }
@@ -1,6 +1,7 @@
1
- import type { Package } from 'code-push/script/acquisition-sdk';
2
1
  import { NativeEventEmitter } from 'react-native';
2
+ import { LogLevel } from '../enums/LogLevel.enum';
3
3
  import type { DownloadProgressCallback, LocalPackage, RemotePackage } from '../types';
4
+ import type { ApiSdkDownloadReportPackageInfo } from './CodePushApiSdk.types';
4
5
  import { LocalPackageImplementation } from './LocalPackageImplementation';
5
6
  import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
6
7
  import { log } from './utils/log';
@@ -8,7 +9,7 @@ import { log } from './utils/log';
8
9
  export class RemotePackageImpl implements RemotePackage {
9
10
  constructor(
10
11
  remotePackageData: Omit<RemotePackage, 'download'>,
11
- reportStatusDownload?: (downloadedPackage: Package) => Promise<void>,
12
+ reportStatusDownload: (downloadedPackage: ApiSdkDownloadReportPackageInfo) => Promise<void>,
12
13
  ) {
13
14
  Object.assign(this, remotePackageData);
14
15
 
@@ -38,12 +39,13 @@ export class RemotePackageImpl implements RemotePackage {
38
39
  );
39
40
 
40
41
  if (reportStatusDownload) {
41
- reportStatusDownload({
42
- ...this,
43
- deploymentKey: this.releaseChannelPublicId,
44
- }).catch((err) => {
45
- log(`Report download status failed: ${err}`);
42
+ const timeoutPromise = new Promise<void>((resolve) => setTimeout(resolve, 250));
43
+ const reportPromise = reportStatusDownload({
44
+ label: this.label,
45
+ }).catch((error) => {
46
+ log(LogLevel.ERROR, `Report download status failed: ${error}`);
46
47
  });
48
+ await Promise.race([timeoutPromise, reportPromise]);
47
49
  }
48
50
 
49
51
  return new LocalPackageImplementation(downloadedPackage);
@@ -1,3 +1,4 @@
1
+ import { LogLevel } from '../enums/LogLevel.enum';
1
2
  import type { RemotePackage, RollbackRetryOptions, SyncOptions } from '../types';
2
3
  import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
3
4
  import type { LatestRollbackInfo } from './types';
@@ -20,17 +21,17 @@ function validateLatestRollbackInfo(latestRollbackInfo: LatestRollbackInfo, pack
20
21
 
21
22
  function validateRollbackRetryOptions(rollbackRetryOptions: RollbackRetryOptions) {
22
23
  if (typeof rollbackRetryOptions.delayInHours !== 'number') {
23
- log("The 'delayInHours' rollback retry parameter must be a number.");
24
+ log(LogLevel.ERROR, "The 'delayInHours' rollback retry parameter must be a number.");
24
25
  return false;
25
26
  }
26
27
 
27
28
  if (typeof rollbackRetryOptions.maxRetryAttempts !== 'number') {
28
- log("The 'maxRetryAttempts' rollback retry parameter must be a number.");
29
+ log(LogLevel.ERROR, "The 'maxRetryAttempts' rollback retry parameter must be a number.");
29
30
  return false;
30
31
  }
31
32
 
32
33
  if (rollbackRetryOptions.maxRetryAttempts < 1) {
33
- log("The 'maxRetryAttempts' rollback retry parameter cannot be less then 1.");
34
+ log(LogLevel.ERROR, "The 'maxRetryAttempts' rollback retry parameter cannot be less then 1.");
34
35
  return false;
35
36
  }
36
37
 
@@ -61,14 +62,14 @@ export async function shouldUpdateBeIgnored(remotePackage: RemotePackage | null
61
62
 
62
63
  const latestRollbackInfo = await NativeRNAppZungCodePushModule.getLatestRollbackInfo();
63
64
  if (!validateLatestRollbackInfo(latestRollbackInfo, remotePackage.packageHash)) {
64
- log('The latest rollback info is not valid.');
65
+ log(LogLevel.ERROR, 'The latest rollback info is not valid.');
65
66
  return true;
66
67
  }
67
68
 
68
69
  const { delayInHours, maxRetryAttempts } = rollbackRetryOptions;
69
70
  const hoursSinceLatestRollback = (Date.now() - latestRollbackInfo.time) / (1000 * 60 * 60);
70
71
  if (hoursSinceLatestRollback >= delayInHours && maxRetryAttempts >= latestRollbackInfo.count) {
71
- log('Previous rollback should be ignored due to rollback retry options.');
72
+ log(LogLevel.INFO, 'Previous rollback should be ignored due to rollback retry options.');
72
73
  return false;
73
74
  }
74
75
 
@@ -1,6 +1,6 @@
1
- import type { Configuration as BaseConfiguration } from 'code-push/script/acquisition-sdk';
1
+ import type { ApiSdkConfiguration } from './CodePushApiSdk.types';
2
2
 
3
- export interface Configuration extends BaseConfiguration {
3
+ export interface Configuration extends ApiSdkConfiguration {
4
4
  releaseChannelPublicId: string;
5
5
  packageHash?: string;
6
6
  }
@@ -0,0 +1,72 @@
1
+ export async function fetchRetry(url: string, options: FetchRetryOptions = {}, attempt = 0): Promise<Response> {
2
+ const {
3
+ maxRetries = 3,
4
+ initialBackoff = 1000,
5
+ backoffMultiplier = 2,
6
+ maxRetryDelay = 30000,
7
+ ...fetchOptions
8
+ } = options;
9
+
10
+ try {
11
+ const response = await fetch(url, fetchOptions);
12
+ if (response.ok || !(response.status === 429 || response.status >= 500)) {
13
+ return response;
14
+ }
15
+
16
+ if (attempt >= maxRetries) {
17
+ return response;
18
+ }
19
+
20
+ const retryAfter = parseRetryAfterHeader(response);
21
+ if (retryAfter && retryAfter > maxRetryDelay) {
22
+ return response;
23
+ }
24
+
25
+ const delay = retryAfter ?? addJitter(initialBackoff * Math.pow(backoffMultiplier, attempt));
26
+
27
+ await new Promise((resolve) => setTimeout(resolve, delay));
28
+
29
+ return fetchRetry(url, options, attempt + 1);
30
+ } catch (error) {
31
+ if (attempt >= maxRetries) {
32
+ throw error;
33
+ }
34
+
35
+ const delay = addJitter(initialBackoff * Math.pow(backoffMultiplier, attempt));
36
+
37
+ await new Promise((resolve) => setTimeout(resolve, delay));
38
+
39
+ return fetchRetry(url, options, attempt + 1);
40
+ }
41
+ }
42
+
43
+ interface FetchRetryOptions extends RequestInit {
44
+ maxRetries?: number;
45
+ initialBackoff?: number;
46
+ backoffMultiplier?: number;
47
+ maxRetryDelay?: number;
48
+ }
49
+
50
+ function parseRetryAfterHeader(response: Response): number | null {
51
+ const retryAfter = response.headers.get('Retry-After');
52
+ if (!retryAfter) {
53
+ return null;
54
+ }
55
+
56
+ if (!isNaN(Number(retryAfter))) {
57
+ return parseInt(retryAfter, 10) * 1000;
58
+ }
59
+
60
+ try {
61
+ const retryDate = new Date(retryAfter).getTime();
62
+ const now = Date.now();
63
+ return retryDate > now ? retryDate - now : 0;
64
+ } catch (e) {
65
+ return null;
66
+ }
67
+ }
68
+
69
+ function addJitter(delay: number): number {
70
+ const jitterFactor = 0.5 + Math.random() * 0.5;
71
+ return Math.floor(delay * jitterFactor);
72
+ }
@@ -1,4 +1,12 @@
1
+ import type { LogLevel } from '../../enums/LogLevel.enum';
2
+ import { getLogLevel } from '../../logLevel';
3
+
1
4
  /* Logs messages to console with the [CodePush] prefix */
2
- export function log(message: string): void {
5
+ export function log(level: LogLevel, message: string): void {
6
+ const currentLogLevel = getLogLevel();
7
+ if (level < currentLogLevel) {
8
+ return;
9
+ }
10
+
3
11
  console.log(`[CodePush] ${message}`);
4
12
  }
@@ -0,0 +1,22 @@
1
+ export function queryStringify(object: { [key: string]: any }): string {
2
+ let queryString = '';
3
+ let isFirst = true;
4
+
5
+ for (const property in object) {
6
+ if (object.hasOwnProperty(property)) {
7
+ const value = object[property];
8
+ if (value !== null && typeof value !== 'undefined') {
9
+ if (!isFirst) {
10
+ queryString += '&';
11
+ }
12
+
13
+ queryString += encodeURIComponent(property) + '=';
14
+ queryString += encodeURIComponent(value);
15
+ }
16
+
17
+ isFirst = false;
18
+ }
19
+ }
20
+
21
+ return queryString;
22
+ }