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

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 (170) 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 +2 -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/SyncStatus.md +1 -1
  9. package/docs/api-js/enumerations/UpdateState.md +1 -1
  10. package/docs/api-js/functions/allowRestart.md +1 -1
  11. package/docs/api-js/functions/checkForUpdate.md +1 -1
  12. package/docs/api-js/functions/clearUpdates.md +1 -1
  13. package/docs/api-js/functions/disallowRestart.md +1 -1
  14. package/docs/api-js/functions/getClientUniqueId.md +1 -1
  15. package/docs/api-js/functions/getUpdateMetadata.md +1 -1
  16. package/docs/api-js/functions/notifyAppReady.md +1 -1
  17. package/docs/api-js/functions/resetClientUniqueId.md +1 -1
  18. package/docs/api-js/functions/restartApp.md +1 -1
  19. package/docs/api-js/functions/sync.md +1 -1
  20. package/docs/api-js/functions/withCodePush.md +1 -1
  21. package/docs/api-js/interfaces/CodePushOptions.md +1 -1
  22. package/docs/api-js/interfaces/DownloadProgress.md +1 -1
  23. package/docs/api-js/interfaces/LocalPackage.md +1 -1
  24. package/docs/api-js/interfaces/Package.md +1 -1
  25. package/docs/api-js/interfaces/RemotePackage.md +1 -1
  26. package/docs/api-js/interfaces/RollbackRetryOptions.md +1 -1
  27. package/docs/api-js/interfaces/StatusReport.md +1 -1
  28. package/docs/api-js/interfaces/SyncOptions.md +1 -1
  29. package/docs/api-js/interfaces/UpdateDialog.md +1 -1
  30. package/docs/api-js/type-aliases/DownloadProgressCallback.md +1 -1
  31. package/docs/api-js/type-aliases/HandleBinaryVersionMismatchCallback.md +4 -2
  32. package/docs/api-js/type-aliases/SyncStatusChangedCallback.md +1 -1
  33. package/docs/api-js/variables/DEFAULT_UPDATE_DIALOG.md +1 -1
  34. package/docs/code-signing.md +2 -0
  35. package/docs/setup-android.md +0 -1
  36. package/ios/CodePush/CodePushConfig.m +4 -0
  37. package/lib/commonjs/checkForUpdates.js +23 -25
  38. package/lib/commonjs/checkForUpdates.js.map +1 -1
  39. package/lib/commonjs/index.js +10 -13
  40. package/lib/commonjs/index.js.map +1 -1
  41. package/lib/commonjs/internals/CodePushApiSdk.errors.js +26 -0
  42. package/lib/commonjs/internals/CodePushApiSdk.errors.js.map +1 -0
  43. package/lib/commonjs/internals/CodePushApiSdk.js +100 -0
  44. package/lib/commonjs/internals/CodePushApiSdk.js.map +1 -0
  45. package/lib/commonjs/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +3 -2
  46. package/lib/commonjs/internals/CodePushApiSdk.types.js.map +1 -0
  47. package/lib/commonjs/internals/RemotePackageImplementation.js +6 -5
  48. package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -1
  49. package/lib/commonjs/internals/utils/fetchRetry.js +59 -0
  50. package/lib/commonjs/internals/utils/fetchRetry.js.map +1 -0
  51. package/lib/commonjs/internals/utils/queryStringify.js +25 -0
  52. package/lib/commonjs/internals/utils/queryStringify.js.map +1 -0
  53. package/lib/commonjs/internals/utils/requestFetchAdapter.js +33 -0
  54. package/lib/commonjs/internals/utils/requestFetchAdapter.js.map +1 -0
  55. package/lib/commonjs/internals/version.js +1 -1
  56. package/lib/commonjs/notifyAppReady.js +9 -9
  57. package/lib/commonjs/notifyAppReady.js.map +1 -1
  58. package/lib/module/checkForUpdates.js +23 -25
  59. package/lib/module/checkForUpdates.js.map +1 -1
  60. package/lib/module/index.js +1 -1
  61. package/lib/module/index.js.map +1 -1
  62. package/lib/module/internals/CodePushApiSdk.errors.js +20 -0
  63. package/lib/module/internals/CodePushApiSdk.errors.js.map +1 -0
  64. package/lib/module/internals/CodePushApiSdk.js +96 -0
  65. package/lib/module/internals/CodePushApiSdk.js.map +1 -0
  66. package/lib/module/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +2 -1
  67. package/lib/module/internals/CodePushApiSdk.types.js.map +1 -0
  68. package/lib/module/internals/RemotePackageImplementation.js +6 -5
  69. package/lib/module/internals/RemotePackageImplementation.js.map +1 -1
  70. package/lib/module/internals/utils/fetchRetry.js +55 -0
  71. package/lib/module/internals/utils/fetchRetry.js.map +1 -0
  72. package/lib/module/internals/utils/queryStringify.js +21 -0
  73. package/lib/module/internals/utils/queryStringify.js.map +1 -0
  74. package/lib/module/internals/utils/requestFetchAdapter.js +29 -0
  75. package/lib/module/internals/utils/requestFetchAdapter.js.map +1 -0
  76. package/lib/module/internals/version.js +1 -1
  77. package/lib/module/notifyAppReady.js +9 -9
  78. package/lib/module/notifyAppReady.js.map +1 -1
  79. package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/src/index.d.ts +1 -1
  81. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts +13 -0
  83. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts +9 -0
  85. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts +101 -0
  87. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts +2 -2
  89. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/src/internals/types.d.ts +2 -2
  91. package/lib/typescript/commonjs/src/internals/types.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts +9 -0
  93. package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts +4 -0
  95. package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts +3 -0
  97. package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/internals/version.d.ts +1 -1
  99. package/lib/typescript/commonjs/src/types.d.ts +4 -3
  100. package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
  101. package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -1
  102. package/lib/typescript/module/src/index.d.ts +1 -1
  103. package/lib/typescript/module/src/index.d.ts.map +1 -1
  104. package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts +13 -0
  105. package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts.map +1 -0
  106. package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts +9 -0
  107. package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
  108. package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts +101 -0
  109. package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
  110. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts +2 -2
  111. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -1
  112. package/lib/typescript/module/src/internals/types.d.ts +2 -2
  113. package/lib/typescript/module/src/internals/types.d.ts.map +1 -1
  114. package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts +9 -0
  115. package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts.map +1 -0
  116. package/lib/typescript/module/src/internals/utils/queryStringify.d.ts +4 -0
  117. package/lib/typescript/module/src/internals/utils/queryStringify.d.ts.map +1 -0
  118. package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts +3 -0
  119. package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
  120. package/lib/typescript/module/src/internals/version.d.ts +1 -1
  121. package/lib/typescript/module/src/types.d.ts +4 -3
  122. package/lib/typescript/module/src/types.d.ts.map +1 -1
  123. package/package.json +3 -3
  124. package/src/checkForUpdates.ts +24 -23
  125. package/src/index.ts +1 -1
  126. package/src/internals/CodePushApiSdk.errors.ts +22 -0
  127. package/src/internals/CodePushApiSdk.ts +133 -0
  128. package/src/internals/CodePushApiSdk.types.ts +115 -0
  129. package/src/internals/RemotePackageImplementation.ts +8 -7
  130. package/src/internals/types.ts +2 -2
  131. package/src/internals/utils/fetchRetry.ts +72 -0
  132. package/src/internals/utils/queryStringify.ts +22 -0
  133. package/src/internals/utils/requestFetchAdapter.ts +28 -0
  134. package/src/internals/version.ts +1 -1
  135. package/src/notifyAppReady.ts +10 -13
  136. package/src/types.ts +2 -3
  137. package/lib/commonjs/enums/DeploymentStatus.enum.js.map +0 -1
  138. package/lib/commonjs/internals/AcquisitionSdk.js +0 -9
  139. package/lib/commonjs/internals/AcquisitionSdk.js.map +0 -1
  140. package/lib/commonjs/internals/getPromisifiedSdk.js +0 -49
  141. package/lib/commonjs/internals/getPromisifiedSdk.js.map +0 -1
  142. package/lib/commonjs/internals/utils/request-fetch-adapter.js +0 -50
  143. package/lib/commonjs/internals/utils/request-fetch-adapter.js.map +0 -1
  144. package/lib/module/enums/DeploymentStatus.enum.js.map +0 -1
  145. package/lib/module/internals/AcquisitionSdk.js +0 -5
  146. package/lib/module/internals/AcquisitionSdk.js.map +0 -1
  147. package/lib/module/internals/getPromisifiedSdk.js +0 -45
  148. package/lib/module/internals/getPromisifiedSdk.js.map +0 -1
  149. package/lib/module/internals/utils/request-fetch-adapter.js +0 -46
  150. package/lib/module/internals/utils/request-fetch-adapter.js.map +0 -1
  151. package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts +0 -14
  152. package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
  153. package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts +0 -3
  154. package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts.map +0 -1
  155. package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts +0 -13
  156. package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts.map +0 -1
  157. package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts +0 -3
  158. package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
  159. package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts +0 -14
  160. package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
  161. package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts +0 -3
  162. package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts.map +0 -1
  163. package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts +0 -13
  164. package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts.map +0 -1
  165. package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts +0 -3
  166. package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
  167. package/src/enums/DeploymentStatus.enum.ts +0 -14
  168. package/src/internals/AcquisitionSdk.ts +0 -3
  169. package/src/internals/getPromisifiedSdk.ts +0 -72
  170. package/src/internals/utils/request-fetch-adapter.ts +0 -58
@@ -0,0 +1,101 @@
1
+ export interface ApiSdkQueryUpdatePackageInfo {
2
+ appVersion: string;
3
+ label?: string;
4
+ packageHash?: string;
5
+ }
6
+ export interface ApiSdkDeployReportPackageInfo {
7
+ label: string;
8
+ appVersion: string;
9
+ }
10
+ export interface ApiSdkDownloadReportPackageInfo {
11
+ label: string;
12
+ }
13
+ export interface ApiSdkRemotePackage {
14
+ releaseChannelPublicId: string;
15
+ label: string;
16
+ appVersion: string;
17
+ description: string;
18
+ isMandatory: boolean;
19
+ packageSize: number;
20
+ packageHash: string;
21
+ downloadUrl: string;
22
+ }
23
+ export interface ApiSdkNativeUpdateNotification {
24
+ updateAppVersion: true;
25
+ appVersion: string;
26
+ }
27
+ export declare namespace Http {
28
+ interface Response {
29
+ statusCode: number;
30
+ body?: string;
31
+ }
32
+ interface Requester {
33
+ request(verb: 'GET' | 'POST', url: string, requestBody?: string | object | null): Promise<Response>;
34
+ }
35
+ }
36
+ export interface ApiSdkConfiguration {
37
+ appVersion: string;
38
+ clientUniqueId: string;
39
+ releaseChannelPublicId: string;
40
+ serverUrl: string;
41
+ ignoreAppVersion?: boolean;
42
+ }
43
+ /**
44
+ * Indicates the status of a deployment (after installing and restarting).
45
+ */
46
+ export declare enum DeploymentStatus {
47
+ /**
48
+ * The deployment failed (and was rolled back).
49
+ */
50
+ FAILED = "DeploymentFailed",
51
+ /**
52
+ * The deployment succeeded.
53
+ */
54
+ SUCCEEDED = "DeploymentSucceeded"
55
+ }
56
+ export interface ReportDeployInput {
57
+ deployment_key: string;
58
+ app_version: string;
59
+ status?: DeploymentStatus;
60
+ label?: string;
61
+ client_unique_id?: string;
62
+ previous_label_or_app_version?: string;
63
+ previous_deployment_key?: string;
64
+ }
65
+ export interface ReportDownloadInput {
66
+ deployment_key: string;
67
+ label: string;
68
+ client_unique_id?: string;
69
+ }
70
+ export interface CheckUpdateRequestInput {
71
+ deployment_key: string;
72
+ app_version: string;
73
+ package_hash?: string;
74
+ label?: string;
75
+ client_unique_id?: string;
76
+ is_companion?: boolean;
77
+ previous_label_or_app_version?: string;
78
+ previous_deployment_key?: string;
79
+ }
80
+ export interface CheckUpdateResponse {
81
+ update_info: {
82
+ is_available: true;
83
+ target_binary_range: string;
84
+ description: string;
85
+ is_disabled: boolean;
86
+ is_mandatory: boolean;
87
+ rollout: number;
88
+ download_url: string;
89
+ package_size: number;
90
+ package_hash: string;
91
+ label: string;
92
+ should_run_binary_version: boolean;
93
+ update_app_version: boolean;
94
+ } | {
95
+ is_available: false;
96
+ should_run_binary_version: boolean;
97
+ target_binary_range: string;
98
+ update_app_version?: boolean;
99
+ };
100
+ }
101
+ //# sourceMappingURL=CodePushApiSdk.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodePushApiSdk.types.d.ts","sourceRoot":"","sources":["../../../../../src/internals/CodePushApiSdk.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,8BAA8B;IAC7C,gBAAgB,EAAE,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,yBAAiB,IAAI,CAAC;IACpB,UAAiB,QAAQ;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,SAAS;QACxB,OAAO,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;KACrG;CACF;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,c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,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,yBAAyB,EAAE,OAAO,CAAC;QACnC,kBAAkB,EAAE,OAAO,CAAC;KAC7B,GACD;QACE,YAAY,EAAE,KAAK,CAAC;QACpB,yBAAyB,EAAE,OAAO,CAAC;QACnC,mBAAmB,EAAE,MAAM,CAAC;QAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;KAC9B,CAAC;CACP"}
@@ -1,7 +1,7 @@
1
- import type { Package } from 'code-push/script/acquisition-sdk';
2
1
  import type { DownloadProgressCallback, LocalPackage, RemotePackage } from '../types';
2
+ import type { ApiSdkDownloadReportPackageInfo } from './CodePushApiSdk.types';
3
3
  export declare class RemotePackageImpl implements RemotePackage {
4
- constructor(remotePackageData: Omit<RemotePackage, 'download'>, reportStatusDownload?: (downloadedPackage: Package) => Promise<void>);
4
+ constructor(remotePackageData: Omit<RemotePackage, 'download'>, reportStatusDownload: (downloadedPackage: ApiSdkDownloadReportPackageInfo) => Promise<void>);
5
5
  download: (downloadProgressCallback?: DownloadProgressCallback) => Promise<LocalPackage>;
6
6
  appVersion: string;
7
7
  description: string;
@@ -1 +1 @@
1
- {"version":3,"file":"RemotePackageImplementation.d.ts","sourceRoot":"","sources":["../../../../../src/internals/RemotePackageImplementation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKtF,qBAAa,iBAAkB,YAAW,aAAa;gBAEnD,iBAAiB,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,EAClD,oBAAoB,CAAC,EAAE,CAAC,iBAAiB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC;IA6CtE,QAAQ,EAAE,CAAC,wBAAwB,CAAC,EAAE,wBAAwB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzF,UAAU,EAAG,MAAM,CAAC;IACpB,WAAW,EAAG,MAAM,CAAC;IACrB,WAAW,EAAG,MAAM,CAAC;IACrB,aAAa,EAAG,OAAO,CAAC;IACxB,UAAU,EAAG,OAAO,CAAC;IACrB,WAAW,EAAG,OAAO,CAAC;IACtB,SAAS,UAAS;IAClB,KAAK,EAAG,MAAM,CAAC;IACf,WAAW,EAAG,MAAM,CAAC;IACrB,WAAW,EAAG,MAAM,CAAC;IACrB,sBAAsB,EAAG,MAAM,CAAC;CACjC"}
1
+ {"version":3,"file":"RemotePackageImplementation.d.ts","sourceRoot":"","sources":["../../../../../src/internals/RemotePackageImplementation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACtF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAC;AAK9E,qBAAa,iBAAkB,YAAW,aAAa;gBAEnD,iBAAiB,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,EAClD,oBAAoB,EAAE,CAAC,iBAAiB,EAAE,+BAA+B,KAAK,OAAO,CAAC,IAAI,CAAC;IA8C7F,QAAQ,EAAE,CAAC,wBAAwB,CAAC,EAAE,wBAAwB,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzF,UAAU,EAAG,MAAM,CAAC;IACpB,WAAW,EAAG,MAAM,CAAC;IACrB,WAAW,EAAG,MAAM,CAAC;IACrB,aAAa,EAAG,OAAO,CAAC;IACxB,UAAU,EAAG,OAAO,CAAC;IACrB,WAAW,EAAG,OAAO,CAAC;IACtB,SAAS,UAAS;IAClB,KAAK,EAAG,MAAM,CAAC;IACf,WAAW,EAAG,MAAM,CAAC;IACrB,WAAW,EAAG,MAAM,CAAC;IACrB,sBAAsB,EAAG,MAAM,CAAC;CACjC"}
@@ -1,5 +1,5 @@
1
- import type { Configuration as BaseConfiguration } from 'code-push/script/acquisition-sdk';
2
- export interface Configuration extends BaseConfiguration {
1
+ import type { ApiSdkConfiguration } from './CodePushApiSdk.types';
2
+ export interface Configuration extends ApiSdkConfiguration {
3
3
  releaseChannelPublicId: string;
4
4
  packageHash?: string;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/internals/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE3F,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,qBAAqB,CAAC,CAAC,IAAI;KAC7B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,GAAG,KAAK;CAClD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,IAAI,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/internals/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACxD,sBAAsB,EAAE,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,qBAAqB,CAAC,CAAC,IAAI;KAC7B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,GAAG,KAAK;CAClD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,IAAI,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare function fetchRetry(url: string, options?: FetchRetryOptions, attempt?: number): Promise<Response>;
2
+ interface FetchRetryOptions extends RequestInit {
3
+ maxRetries?: number;
4
+ initialBackoff?: number;
5
+ backoffMultiplier?: number;
6
+ maxRetryDelay?: number;
7
+ }
8
+ export {};
9
+ //# sourceMappingURL=fetchRetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchRetry.d.ts","sourceRoot":"","sources":["../../../../../../src/internals/utils/fetchRetry.ts"],"names":[],"mappings":"AAAA,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,EAAE,OAAO,SAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwC7G;AAED,UAAU,iBAAkB,SAAQ,WAAW;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,4 @@
1
+ export declare function queryStringify(object: {
2
+ [key: string]: any;
3
+ }): string;
4
+ //# sourceMappingURL=queryStringify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryStringify.d.ts","sourceRoot":"","sources":["../../../../../../src/internals/utils/queryStringify.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,MAAM,CAqBrE"}
@@ -0,0 +1,3 @@
1
+ import type { Http } from '../CodePushApiSdk.types';
2
+ export declare const requestFetchAdapter: Http.Requester;
3
+ //# sourceMappingURL=requestFetchAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestFetchAdapter.d.ts","sourceRoot":"","sources":["../../../../../../src/internals/utils/requestFetchAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAIpD,eAAO,MAAM,mBAAmB,EAAE,IAAI,CAAC,SAuBtC,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "11.0.0-rc3";
1
+ export declare const version = "11.0.0-rc4";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,6 @@
1
- import type { NativeUpdateNotification } from 'code-push/script/acquisition-sdk';
2
- import type { DeploymentStatus } from './enums/DeploymentStatus.enum';
3
1
  import type { InstallMode } from './enums/InstallMode.enum';
4
2
  import type { SyncStatus } from './enums/SyncStatus.enum';
3
+ import { DeploymentStatus } from './internals/CodePushApiSdk.types';
5
4
  export interface UpdateDialog {
6
5
  /**
7
6
  * Indicates whether you would like to append the description of an available release to the
@@ -67,7 +66,9 @@ export type SyncStatusChangedCallback = (status: SyncStatus) => void;
67
66
  /**
68
67
  * Called when there are any binary update available.
69
68
  */
70
- export type HandleBinaryVersionMismatchCallback = (update: NativeUpdateNotification) => void;
69
+ export type HandleBinaryVersionMismatchCallback = (update: {
70
+ appVersion: string;
71
+ }) => void;
71
72
  export interface DownloadProgress {
72
73
  /**
73
74
  * The total number of bytes expected to be received for this update.
@@ -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,KAA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C;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAEnC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAEnD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;IAEzB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAC;IAExC;;OAEG;IACH,yBAAyB,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-rc4",
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
  }
@@ -1,12 +1,13 @@
1
1
  import { Platform } from 'react-native';
2
+ import { CodePushApiSdk } from './internals/CodePushApiSdk';
3
+ import type { ApiSdkQueryUpdatePackageInfo } from './internals/CodePushApiSdk.types';
2
4
  import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
3
5
  import { RemotePackageImpl } from './internals/RemotePackageImplementation';
4
6
  import { getConfiguration } from './internals/getConfiguration';
5
7
  import { getCurrentPackage } from './internals/getCurrentPackage';
6
- import { type PromisifiedSdkQueryPackage, getPromisifiedSdk } from './internals/getPromisifiedSdk';
7
8
  import type { Configuration } from './internals/types';
8
9
  import { log } from './internals/utils/log';
9
- import { requestFetchAdapter } from './internals/utils/request-fetch-adapter';
10
+ import { requestFetchAdapter } from './internals/utils/requestFetchAdapter';
10
11
  import type { HandleBinaryVersionMismatchCallback, RemotePackage } from './types';
11
12
 
12
13
  /**
@@ -36,10 +37,8 @@ export async function checkForUpdate(
36
37
  * dynamically "redirecting" end-users at different
37
38
  * release channels (e.g. an early access release channel for insiders).
38
39
  */
39
- const config: Configuration = releaseChannelPublicId
40
- ? { ...nativeConfig, ...{ releaseChannelPublicId } }
41
- : nativeConfig;
42
- const sdk = getPromisifiedSdk(requestFetchAdapter, config);
40
+ const config: Configuration = releaseChannelPublicId ? { ...nativeConfig, releaseChannelPublicId } : nativeConfig;
41
+ const sdk = new CodePushApiSdk(requestFetchAdapter, config);
43
42
 
44
43
  const localPackage = await getCurrentPackage();
45
44
 
@@ -51,15 +50,10 @@ export async function checkForUpdate(
51
50
  * to send the app version to the server, since we are interested
52
51
  * in any updates for current binary version, regardless of hash.
53
52
  */
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
- }
53
+ const queryPackage: ApiSdkQueryUpdatePackageInfo = localPackage ?? {
54
+ appVersion: config.appVersion,
55
+ ...(Platform.OS === 'ios' && config.packageHash ? { packageHash: config.packageHash } : {}),
56
+ };
63
57
 
64
58
  const update = await sdk.queryUpdateWithCurrentPackage(queryPackage);
65
59
 
@@ -85,7 +79,11 @@ export async function checkForUpdate(
85
79
  return null;
86
80
  }
87
81
 
88
- if ('updateAppVersion' in update && update.updateAppVersion) {
82
+ if ('updateAppVersion' in update) {
83
+ if (!update.updateAppVersion) {
84
+ throw new Error('updateAppVersion should never be false');
85
+ }
86
+
89
87
  log('An update is available but it is not targeting the binary version of your app.');
90
88
  handleBinaryVersionMismatchCallback?.(update);
91
89
 
@@ -93,17 +91,20 @@ export async function checkForUpdate(
93
91
  }
94
92
 
95
93
  if (
96
- (localPackage && 'packageHash' in update && update.packageHash === localPackage.packageHash) ||
94
+ (localPackage && update.packageHash === localPackage.packageHash) ||
97
95
  ((!localPackage || ('_isDebugOnly' in localPackage && localPackage._isDebugOnly)) &&
98
- 'packageHash' in update &&
99
96
  config.packageHash === update.packageHash)
100
97
  ) {
101
98
  return null;
102
99
  }
103
100
 
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;
101
+ const remotePackageData: Omit<RemotePackage, 'download'> = {
102
+ ...update,
103
+ releaseChannelPublicId: releaseChannelPublicId || nativeConfig.releaseChannelPublicId,
104
+ failedInstall: await NativeRNAppZungCodePushModule.isFailedUpdate(update.packageHash),
105
+ isFirstRun: false,
106
+ isPending: false,
107
+ };
108
+
109
+ return new RemotePackageImpl(remotePackageData, (packageInfo) => sdk.reportStatusDownload(packageInfo));
109
110
  }
package/src/index.ts CHANGED
@@ -16,5 +16,5 @@ export * from './types';
16
16
  export * from './enums/SyncStatus.enum';
17
17
  export * from './enums/InstallMode.enum';
18
18
  export * from './enums/UpdateState.enum';
19
- export * from './enums/DeploymentStatus.enum';
19
+ export { DeploymentStatus } from './internals/CodePushApiSdk.types';
20
20
  export * from './enums/CheckFrequency.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,6 @@
1
- import type { Package } from 'code-push/script/acquisition-sdk';
2
1
  import { NativeEventEmitter } from 'react-native';
3
2
  import type { DownloadProgressCallback, LocalPackage, RemotePackage } from '../types';
3
+ import type { ApiSdkDownloadReportPackageInfo } from './CodePushApiSdk.types';
4
4
  import { LocalPackageImplementation } from './LocalPackageImplementation';
5
5
  import { NativeRNAppZungCodePushModule } from './NativeRNAppZungCodePushModule';
6
6
  import { log } from './utils/log';
@@ -8,7 +8,7 @@ import { log } from './utils/log';
8
8
  export class RemotePackageImpl implements RemotePackage {
9
9
  constructor(
10
10
  remotePackageData: Omit<RemotePackage, 'download'>,
11
- reportStatusDownload?: (downloadedPackage: Package) => Promise<void>,
11
+ reportStatusDownload: (downloadedPackage: ApiSdkDownloadReportPackageInfo) => Promise<void>,
12
12
  ) {
13
13
  Object.assign(this, remotePackageData);
14
14
 
@@ -38,12 +38,13 @@ export class RemotePackageImpl implements RemotePackage {
38
38
  );
39
39
 
40
40
  if (reportStatusDownload) {
41
- reportStatusDownload({
42
- ...this,
43
- deploymentKey: this.releaseChannelPublicId,
44
- }).catch((err) => {
45
- log(`Report download status failed: ${err}`);
41
+ const timeoutPromise = new Promise<void>((resolve) => setTimeout(resolve, 250));
42
+ const reportPromise = reportStatusDownload({
43
+ label: this.label,
44
+ }).catch((error) => {
45
+ log(`Report download status failed: ${error}`);
46
46
  });
47
+ await Promise.race([timeoutPromise, reportPromise]);
47
48
  }
48
49
 
49
50
  return new LocalPackageImplementation(downloadedPackage);
@@ -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
  }