@appzung/react-native-code-push 10.1.0 → 10.1.2
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.
- package/android/app/src/main/java/com/appzung/codepush/react/CodePush.java +3 -0
- package/ios/CodePush/CodePushConfig.m +4 -0
- package/lib/commonjs/CodePush.js +5 -0
- package/lib/commonjs/CodePush.js.map +1 -1
- package/lib/commonjs/checkForUpdates.js +25 -26
- package/lib/commonjs/checkForUpdates.js.map +1 -1
- package/lib/commonjs/enums/LogLevel.enum.js +14 -0
- package/lib/commonjs/enums/LogLevel.enum.js.map +1 -0
- package/lib/commonjs/index.js +30 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internals/CodePushApiSdk.errors.js +26 -0
- package/lib/commonjs/internals/CodePushApiSdk.errors.js.map +1 -0
- package/lib/commonjs/internals/CodePushApiSdk.js +100 -0
- package/lib/commonjs/internals/CodePushApiSdk.js.map +1 -0
- package/lib/commonjs/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +3 -2
- package/lib/commonjs/internals/CodePushApiSdk.types.js.map +1 -0
- package/lib/commonjs/internals/RemotePackageImplementation.js +7 -5
- package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -1
- package/lib/commonjs/internals/shouldUpdateBeIgnored.js +6 -5
- package/lib/commonjs/internals/shouldUpdateBeIgnored.js.map +1 -1
- package/lib/commonjs/internals/utils/fetchRetry.js +59 -0
- package/lib/commonjs/internals/utils/fetchRetry.js.map +1 -0
- package/lib/commonjs/internals/utils/log.js +6 -1
- package/lib/commonjs/internals/utils/log.js.map +1 -1
- package/lib/commonjs/internals/utils/queryStringify.js +25 -0
- package/lib/commonjs/internals/utils/queryStringify.js.map +1 -0
- package/lib/commonjs/internals/utils/requestFetchAdapter.js +38 -0
- package/lib/commonjs/internals/utils/requestFetchAdapter.js.map +1 -0
- package/lib/commonjs/internals/version.js +1 -1
- package/lib/commonjs/logLevel.js +15 -0
- package/lib/commonjs/logLevel.js.map +1 -0
- package/lib/commonjs/notifyAppReady.js +22 -15
- package/lib/commonjs/notifyAppReady.js.map +1 -1
- package/lib/commonjs/sync.js +27 -24
- package/lib/commonjs/sync.js.map +1 -1
- package/lib/module/CodePush.js +5 -0
- package/lib/module/CodePush.js.map +1 -1
- package/lib/module/checkForUpdates.js +25 -26
- package/lib/module/checkForUpdates.js.map +1 -1
- package/lib/module/enums/LogLevel.enum.js +10 -0
- package/lib/module/enums/LogLevel.enum.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internals/CodePushApiSdk.errors.js +20 -0
- package/lib/module/internals/CodePushApiSdk.errors.js.map +1 -0
- package/lib/module/internals/CodePushApiSdk.js +96 -0
- package/lib/module/internals/CodePushApiSdk.js.map +1 -0
- package/lib/module/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +2 -1
- package/lib/module/internals/CodePushApiSdk.types.js.map +1 -0
- package/lib/module/internals/RemotePackageImplementation.js +7 -5
- package/lib/module/internals/RemotePackageImplementation.js.map +1 -1
- package/lib/module/internals/shouldUpdateBeIgnored.js +6 -5
- package/lib/module/internals/shouldUpdateBeIgnored.js.map +1 -1
- package/lib/module/internals/utils/fetchRetry.js +55 -0
- package/lib/module/internals/utils/fetchRetry.js.map +1 -0
- package/lib/module/internals/utils/log.js +7 -1
- package/lib/module/internals/utils/log.js.map +1 -1
- package/lib/module/internals/utils/queryStringify.js +21 -0
- package/lib/module/internals/utils/queryStringify.js.map +1 -0
- package/lib/module/internals/utils/requestFetchAdapter.js +34 -0
- package/lib/module/internals/utils/requestFetchAdapter.js.map +1 -0
- package/lib/module/internals/version.js +1 -1
- package/lib/module/logLevel.js +9 -0
- package/lib/module/logLevel.js.map +1 -0
- package/lib/module/notifyAppReady.js +22 -15
- package/lib/module/notifyAppReady.js.map +1 -1
- package/lib/module/sync.js +27 -24
- package/lib/module/sync.js.map +1 -1
- package/lib/typescript/commonjs/src/CodePush.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts +7 -0
- package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +3 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts +13 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts +9 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts +101 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts +2 -2
- package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/types.d.ts +2 -2
- package/lib/typescript/commonjs/src/internals/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts +9 -0
- package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts +2 -1
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts +4 -0
- package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/version.d.ts +1 -1
- package/lib/typescript/commonjs/src/logLevel.d.ts +4 -0
- package/lib/typescript/commonjs/src/logLevel.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/sync.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +4 -3
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/CodePush.d.ts.map +1 -1
- package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -1
- package/lib/typescript/module/src/enums/LogLevel.enum.d.ts +7 -0
- package/lib/typescript/module/src/enums/LogLevel.enum.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +3 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts +13 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts +9 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts +101 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts +2 -2
- package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/types.d.ts +2 -2
- package/lib/typescript/module/src/internals/types.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts +9 -0
- package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/log.d.ts +2 -1
- package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/utils/queryStringify.d.ts +4 -0
- package/lib/typescript/module/src/internals/utils/queryStringify.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts +3 -0
- package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/version.d.ts +1 -1
- package/lib/typescript/module/src/logLevel.d.ts +4 -0
- package/lib/typescript/module/src/logLevel.d.ts.map +1 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -1
- package/lib/typescript/module/src/sync.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +4 -3
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/CodePush.tsx +6 -0
- package/src/checkForUpdates.ts +26 -24
- package/src/enums/LogLevel.enum.ts +6 -0
- package/src/index.ts +3 -1
- package/src/internals/CodePushApiSdk.errors.ts +22 -0
- package/src/internals/CodePushApiSdk.ts +133 -0
- package/src/internals/CodePushApiSdk.types.ts +115 -0
- package/src/internals/RemotePackageImplementation.ts +9 -7
- package/src/internals/shouldUpdateBeIgnored.ts +6 -5
- package/src/internals/types.ts +2 -2
- package/src/internals/utils/fetchRetry.ts +72 -0
- package/src/internals/utils/log.ts +9 -1
- package/src/internals/utils/queryStringify.ts +22 -0
- package/src/internals/utils/requestFetchAdapter.ts +36 -0
- package/src/internals/version.ts +1 -1
- package/src/logLevel.ts +9 -0
- package/src/notifyAppReady.ts +25 -18
- package/src/sync.ts +33 -23
- package/src/types.ts +2 -3
- package/lib/commonjs/enums/DeploymentStatus.enum.js.map +0 -1
- package/lib/commonjs/internals/AcquisitionSdk.js +0 -9
- package/lib/commonjs/internals/AcquisitionSdk.js.map +0 -1
- package/lib/commonjs/internals/getPromisifiedSdk.js +0 -49
- package/lib/commonjs/internals/getPromisifiedSdk.js.map +0 -1
- package/lib/commonjs/internals/utils/request-fetch-adapter.js +0 -50
- package/lib/commonjs/internals/utils/request-fetch-adapter.js.map +0 -1
- package/lib/module/enums/DeploymentStatus.enum.js.map +0 -1
- package/lib/module/internals/AcquisitionSdk.js +0 -5
- package/lib/module/internals/AcquisitionSdk.js.map +0 -1
- package/lib/module/internals/getPromisifiedSdk.js +0 -45
- package/lib/module/internals/getPromisifiedSdk.js.map +0 -1
- package/lib/module/internals/utils/request-fetch-adapter.js +0 -46
- package/lib/module/internals/utils/request-fetch-adapter.js.map +0 -1
- package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts +0 -14
- package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts +0 -3
- package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts +0 -13
- package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts +0 -3
- package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
- package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts +0 -14
- package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts +0 -3
- package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts +0 -13
- package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts +0 -3
- package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
- package/src/enums/DeploymentStatus.enum.ts +0 -14
- package/src/internals/AcquisitionSdk.ts +0 -3
- package/src/internals/getPromisifiedSdk.ts +0 -72
- 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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;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
|
|
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":"
|
|
1
|
+
{"version":3,"file":"RemotePackageImplementation.d.ts","sourceRoot":"","sources":["../../../../../src/internals/RemotePackageImplementation.ts"],"names":[],"mappings":"AAEA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shouldUpdateBeIgnored.d.ts","sourceRoot":"","sources":["../../../../../src/internals/shouldUpdateBeIgnored.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shouldUpdateBeIgnored.d.ts","sourceRoot":"","sources":["../../../../../src/internals/shouldUpdateBeIgnored.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAwB,WAAW,EAAE,MAAM,UAAU,CAAC;AAuCjF,wBAAsB,qBAAqB,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,EAAE,WAAW,EAAE,WAAW,oBAoCpH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface Configuration extends
|
|
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,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../../../src/internals/utils/log.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../../../src/internals/utils/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAI1D,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAO1D"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"requestFetchAdapter.d.ts","sourceRoot":"","sources":["../../../../../../src/internals/utils/requestFetchAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAKpD,eAAO,MAAM,mBAAmB,EAAE,IAAI,CAAC,SA6BtC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "10.1.
|
|
1
|
+
export declare const version = "10.1.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logLevel.d.ts","sourceRoot":"","sources":["../../../../src/logLevel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIjD,eAAO,MAAM,WAAW,UAAW,QAAQ,SAE1C,CAAC;AAEF,eAAO,MAAM,WAAW,gBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyAppReady.d.ts","sourceRoot":"","sources":["../../../../src/notifyAppReady.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifyAppReady.d.ts","sourceRoot":"","sources":["../../../../src/notifyAppReady.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,cAAc,oCAYvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/sync.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrD,OAAO,KAAK,EACV,wBAAwB,EACxB,mCAAmC,EACnC,WAAW,EACX,yBAAyB,EACzB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,YASnC,CAAC;AAqLF;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,aAUH,WAAW,8BACO,yBAAyB,6BAC1B,wBAAwB,wCACb,mCAAmC,KACxE,OAAO,CAAC,UAAU,CAgDnB,CAAC"}
|
|
@@ -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:
|
|
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,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,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,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,CAAC,MAAM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1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,WAAW,CAAC;IAEnC;;;;;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": "10.1.
|
|
3
|
+
"version": "10.1.2",
|
|
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
|
});
|
package/src/checkForUpdates.ts
CHANGED
|
@@ -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/
|
|
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
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
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
|
|
89
|
-
|
|
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 &&
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
}
|
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
|
|
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
|
+
}
|