@smbcloud / smbcloud-ascapi Mirror · read-only / commits / 17164ed
Fork 0

Read-only mirror of github.com/smbcloudXYZ/smbcloud-ascapi.

Mirrored from https://github.com/smbcloudXYZ/smbcloud-ascapi.git

Synced Nov 25, 09:15 UTC

Cover the rest of the AppGallery Publishing API

asc appgallery now reaches every Android Publishing API call a CLI can use: - listings delete - info update with every basic-info field (category, countries, price, device types and the flags) - files upload for all 17 file types, including the APK - packages list and status - gms, submit, phased-release and release-time listings list keeps the fields it doesn't type in a flattened map, so it returns everything the API sends. files upload reads the language's text before binding and writes it back if the bind cleared it. Every write takes --dry-run. MCP gets three read-only tools: appgallery_app_info_get, appgallery_package_list and appgallery_package_status. The download-mode submit and package calls are left out, since they need a public package URL and a callback server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Seto Elkahfi committed Oct 27, 2026 at 15:48 UTC 17164ed085e456b6659787c7be0a737a390f0222
12 files changed +1745 -166
.agents/AGENTS.md
+24 -16
@@ -76,22 +76,30 @@ blocks for minutes and publishes a build doesn't belong in MCP.
76
77 ## AppGallery (CLI)
78
79 -`asc appgallery` talks to the AppGallery Connect Publishing API through
80 -`crates/appgallery`; the shared operations are in
81 -`crates/frontend/src/appgallery.rs`. Auth is a PS256 JWT signed locally from
82 -the Service Account file and sent as the bearer token, no token exchange.
83 -Endpoints sit under `https://connect-api.cloud.huawei.com/api`: `appid-list`,
84 -`app-info` and `app-language-info`. A 200 reply with a non-zero `ret.code` is
85 -an error. The update limits (name 64, description 8000, brief 80, release
86 -notes 500) come from the update reference; the query reference documents 60
87 -and 1000 for brief and release notes, so the server has the last word.
88 -Images and packages go through `GET upload-url/for-obs`, a `PUT` of the bytes
89 -to the pre-signed URL (our JWT is not sent there), then `PUT app-file-info` to
90 -bind the object id. Observed 2026-10-27: binding an icon with `lang` reset
91 -that language's name, description, brief and release notes to empty, so upload
92 -images first and write the text last, then read it back. `PUT app-info`
93 -needs `privacyPolicy` every time. Service Account mode needs no `client_id`
94 -header. There are no MCP tools for it yet.
79 +`asc appgallery` covers the Android Publishing API through `crates/appgallery`
80 +(`publish.rs` app info and listings, `upload.rs` files, `release.rs` submit,
81 +phased release, release time, GMS flag, packages); the shared operations are
82 +in `crates/frontend/src/appgallery.rs`. Endpoints sit under
83 +`https://connect-api.cloud.huawei.com/api/publish/v2/`.
84 +
85 +- Auth is a PS256 JWT signed locally from the Service Account file and sent as
86 + the bearer token; no token exchange and no `client_id` header (confirmed
87 + live 2026-10-27).
88 +- A 200 reply with a non-zero `ret.code` is an error.
89 +- `AppInfo` and `LanguageInfo` type the common fields and keep the rest in a
90 + flattened `other`, so `listings list` returns everything the API sends.
91 +- Files: `GET upload-url/for-obs`, `PUT` the bytes to the pre-signed URL (our
92 + JWT is not sent there), then `PUT app-file-info`. Binding an image for a
93 + language reset that language's text (seen 2026-10-27), so `upload_files`
94 + reads the text first and writes it back if it went missing.
95 +- `PUT app-info` needs `privacyPolicy` on every call.
96 +- Update limits (name 64, description 8000, brief 80, release notes 500) come
97 + from the update reference; the query reference says 60 and 1000 for brief
98 + and release notes.
99 +- MCP is read-only (`appgallery_app_info_get`, `appgallery_package_list`,
100 + `appgallery_package_status`); writes, and above all `submit`, stay on the CLI.
101 +- Not implemented: `app-submit-with-file` and `add-packageurl` (download mode)
102 + and the callback they report to; they need a public URL and a server.
103
104 ## Git branching workflow
105
README.md
+23 -7
@@ -9,7 +9,7 @@ from the other:
9 | --- | --- |
10 | `smbcloud-ascapi-core` | Shared transport: JWT auth, the HTTP client, JSON:API envelopes, error types |
11 | `smbcloud-ascapi-play` | Google Play (Edits v3): store listings, listing images, track release notes; service-account auth, independent of `core` |
12 -| `smbcloud-ascapi-appgallery` | Huawei AppGallery Connect Publishing API: listing text (app info, per-language name, description, brief, release notes); Service Account auth (PS256 JWT), independent of `core` |
12 +| `smbcloud-ascapi-appgallery` | Huawei AppGallery Connect Publishing API (Android): app info and listings, file and package upload, submit, phased release, release time, GMS flag, package list and status; Service Account auth (PS256 JWT), independent of `core` |
13 | `smbcloud-ascapi-aso` | App Metadata: apps, app infos, versions, builds, pre-release versions, review submissions, bundle IDs, localizations, screenshots |
14 | `smbcloud-ascapi-pricing` | Pricing: app price schedules, and the per-territory prices joined with their price points and currencies |
15 | `smbcloud-ascapi-signing` | Code signing: certificates and provisioning profiles, plus local RSA key pair and CSR generation |
@@ -55,14 +55,30 @@ with a publishing role), not the App Store Connect key:
55
56 ```sh
57 asc appgallery app-id xyz.smbcloud.SiGit
58 -asc appgallery listings list xyz.smbcloud.SiGit --lang en-US
59 -asc appgallery listings update xyz.smbcloud.SiGit --lang en-US \
60 - --brief "Git client and code agent" --release-notes-file notes.txt --dry-run
61 -asc appgallery info update xyz.smbcloud.SiGit --privacy-policy https://example.com/privacy
62 -asc appgallery images upload <APP_ID> --lang en-US --kind icon icon-216.png
58 +asc appgallery listings list <APP> [--lang en-US] # every field the API returns
59 +asc appgallery listings update <APP> --lang en-US --brief "..." --release-notes-file notes.txt
60 +asc appgallery listings delete <APP> --lang id
61 +asc appgallery info update <APP> --privacy-policy URL [--category ID --category-tag ID]
62 + [--publish-country CODES] [--developer-website URL] [--device-types JSON] ...
63 +asc appgallery files upload <APP> --type icon --lang en-US icon-216.png
64 +asc appgallery files upload <APP> --type screenshots --orientation portrait --lang en-US 1.png 2.png
65 +asc appgallery files upload <APP> --type package siGit.apk # chineseMainlandFlag=0 unless --chinese-mainland
66 +asc appgallery packages list <APP>
67 +asc appgallery packages status <APP> <PKG_ID>...
68 +asc appgallery gms <APP> --needs-gms false
69 +asc appgallery submit <APP> [--release-time T] [--remark TEXT] [--phased-start T --phased-end T --phased-percent P --phased-description D]
70 +asc appgallery phased-release <APP> (--to-full | --state SUSPEND|RELEASE | --phased-percent P ...)
71 +asc appgallery release-time <APP> (--immediately | --at T)
72 ```
73
65 -Upload images before writing text: binding an image resets that language's text.
74 +`<APP>` is the numeric app id or the package name. Every write takes
75 +`--dry-run`. Binding an image or video for a language clears that language's
76 +text; `files upload` reads the text first and writes it back if it went
77 +missing. MCP has three read-only tools: `appgallery_app_info_get`,
78 +`appgallery_package_list` and `appgallery_package_status`.
79 +
80 +Not covered: the "download mode" submit and package calls, which need a
81 +public package URL and a callback server for Huawei to report to.
82
83 ## Copyright
84
crates/appgallery/src/error.rs
+3
@@ -37,6 +37,9 @@ pub enum Error {
37 max: usize,
38 },
39
40 + #[error("{field}: {detail}")]
41 + Invalid { field: &'static str, detail: String },
42 +
43 #[error("{0} is required")]
44 Missing(&'static str),
45
crates/appgallery/src/lib.rs
+8 -2
@@ -5,12 +5,15 @@
5 //! [`AppGalleryClient`] holds the account and the HTTP client the Publishing
6 //! API calls are built on. [`publish`] has the Publishing API calls for
7 //! listing text: resolve an app id from a package name, read app info, and
8 -//! update per-language text and release notes.
8 +//! update per-language text and release notes. [`upload`] sends images,
9 +//! videos and packages; [`release`] submits for review and manages phased
10 +//! release, the release time, the GMS flag and the package list.
11
12 pub mod auth;
13 pub mod client;
14 pub mod error;
15 pub mod publish;
16 +pub mod release;
17 pub mod upload;
18
19 pub use auth::ServiceAccount;
@@ -20,4 +23,7 @@ pub use publish::{
23 AppIdPair, AppInfo, AppInfoFields, AppInfoResponse, LanguageFields, LanguageInfo, RetCode,
24 APP_DESC_MAX_LEN, APP_NAME_MAX_LEN, BRIEF_INFO_MAX_LEN, LANG_MAX_LEN, NEW_FEATURES_MAX_LEN,
25 };
23 -pub use upload::{FileType, ImageOrientation, UploadUrl};
26 +pub use release::{
27 + PackageInfo, PackageList, PackageState, PhasedRelease, ReleaseTimeChange, Submit,
28 +};
29 +pub use upload::{FileBind, FileType, ImageOrientation, UploadUrl};
crates/appgallery/src/publish.rs
+171 -5
@@ -40,7 +40,9 @@ impl RetCode {
40 }
41 }
42
43 -/// App basic information: the fields listing work reads.
43 +/// App basic information. The commonly used fields are typed; every other
44 +/// field the API returns (categories, prices, device types, ...) is kept in
45 +/// `other`, so nothing is dropped on the way to the caller.
46 #[derive(Debug, Clone, Default, Deserialize, Serialize)]
47 #[serde(rename_all = "camelCase")]
48 pub struct AppInfo {
@@ -52,9 +54,12 @@ pub struct AppInfo {
54 pub version_code: Option<i64>,
55 pub on_shelf_version_number: Option<String>,
56 pub publish_country: Option<String>,
57 + #[serde(flatten)]
58 + pub other: serde_json::Map<String, serde_json::Value>,
59 }
60
57 -/// One language's listing text.
61 +/// One language's listing: text typed, visual assets (screenshots, videos,
62 +/// device materials) kept in `other`.
63 #[derive(Debug, Clone, Default, Deserialize, Serialize)]
64 #[serde(rename_all = "camelCase")]
65 pub struct LanguageInfo {
@@ -64,6 +69,8 @@ pub struct LanguageInfo {
69 pub brief_info: Option<String>,
70 pub new_features: Option<String>,
71 pub icon: Option<String>,
72 + #[serde(flatten)]
73 + pub other: serde_json::Map<String, serde_json::Value>,
74 }
75
76 #[derive(Debug, Clone, Deserialize, Serialize)]
@@ -74,6 +81,8 @@ pub struct AppInfoResponse {
81 pub audit_info: Option<AuditInfo>,
82 #[serde(default)]
83 pub languages: Vec<LanguageInfo>,
84 + /// Present while a phased release is configured.
85 + pub phased_release_info: Option<serde_json::Value>,
86 }
87
88 #[derive(Debug, Clone, Deserialize, Serialize)]
@@ -124,17 +133,73 @@ impl LanguageFields {
133 }
134
135 /// The body of `PUT app-info`: basic information. Unset fields are left as
127 -/// they are, except `privacy_policy`, which the API always requires.
136 +/// they are, except `privacy_policy`, which the API requires on every call.
137 +/// Integer flags follow the reference: 0 no, 1 yes unless noted.
138 #[derive(Debug, Clone, Default, Serialize)]
139 #[serde(rename_all = "camelCase")]
140 pub struct AppInfoFields {
141 pub privacy_policy: String,
142 #[serde(skip_serializing_if = "Option::is_none")]
143 + pub default_lang: Option<String>,
144 + /// Level-2 category id (App/Game Categories appendix).
145 + #[serde(skip_serializing_if = "Option::is_none")]
146 + pub child_type: Option<u32>,
147 + /// Level-3 category (tag) id.
148 + #[serde(skip_serializing_if = "Option::is_none")]
149 + pub grand_child_type: Option<u32>,
150 + /// Games only: 1 standalone, 2 online.
151 + #[serde(skip_serializing_if = "Option::is_none")]
152 + pub app_net_type: Option<u8>,
153 + /// 1 free, 0 paid. Cannot change after release.
154 + #[serde(skip_serializing_if = "Option::is_none")]
155 + pub is_free: Option<u8>,
156 + /// `{"countryCode":"price"}`; required when `is_free` is 0.
157 + #[serde(skip_serializing_if = "Option::is_none")]
158 + pub price: Option<String>,
159 + /// JSON array of `{country, currency, price}`; required when `is_free` is 0.
160 + #[serde(skip_serializing_if = "Option::is_none")]
161 + pub price_detail: Option<String>,
162 + /// Comma-separated country/region codes. `CN` is the Chinese mainland.
163 + #[serde(skip_serializing_if = "Option::is_none")]
164 + pub publish_country: Option<String>,
165 + #[serde(skip_serializing_if = "Option::is_none")]
166 + pub is_app_forced_update: Option<u8>,
167 + /// Let AppGallery fetch the package from the Internet.
168 + #[serde(skip_serializing_if = "Option::is_none")]
169 + pub hispace_auto_down: Option<u8>,
170 + /// Comma-separated in-app purchase types (1 activation ... 8 membership).
171 + #[serde(skip_serializing_if = "Option::is_none")]
172 + pub app_tariff_type: Option<String>,
173 + /// Games only.
174 + #[serde(skip_serializing_if = "Option::is_none")]
175 + pub publication_number: Option<String>,
176 + /// Games only, China only.
177 + #[serde(skip_serializing_if = "Option::is_none")]
178 + pub culture_record_number: Option<String>,
179 + /// Trustlisted developers only.
180 + #[serde(skip_serializing_if = "Option::is_none")]
181 + pub developer_name_cn: Option<String>,
182 + /// Trustlisted developers only.
183 + #[serde(skip_serializing_if = "Option::is_none")]
184 + pub developer_name_en: Option<String>,
185 + #[serde(skip_serializing_if = "Option::is_none")]
186 pub developer_website: Option<String>,
187 #[serde(skip_serializing_if = "Option::is_none")]
188 + pub family_share_tag: Option<u8>,
189 + /// `[{"deviceType":4,"appAdapters":"4,5"}]`; required when the device
190 + /// type changes.
191 + #[serde(skip_serializing_if = "Option::is_none")]
192 + pub device_types: Option<serde_json::Value>,
193 + #[serde(skip_serializing_if = "Option::is_none")]
194 + pub web_game_flag: Option<u8>,
195 + /// Where users view, change and delete their personal data.
196 + #[serde(skip_serializing_if = "Option::is_none")]
197 pub privacy_rights_url: Option<String>,
198 #[serde(skip_serializing_if = "Option::is_none")]
199 pub user_agreement_url: Option<String>,
200 + /// Encrypt the package; the API defaults to 1.
201 + #[serde(skip_serializing_if = "Option::is_none")]
202 + pub encrypted: Option<u8>,
203 }
204
205 pub const PRIVACY_POLICY_MAX_LEN: usize = 255;
@@ -142,16 +207,36 @@ pub const DEVELOPER_WEBSITE_MAX_LEN: usize = 255;
207 pub const PRIVACY_RIGHTS_URL_MAX_LEN: usize = 256;
208 pub const USER_AGREEMENT_URL_MAX_LEN: usize = 512;
209
210 +fn check_flag(field: &'static str, value: Option<u8>, allowed: &[u8]) -> Result<()> {
211 + match value {
212 + Some(v) if !allowed.contains(&v) => Err(Error::Invalid {
213 + field,
214 + detail: format!("{v} is not one of {allowed:?}"),
215 + }),
216 + _ => Ok(()),
217 + }
218 +}
219 +
220 impl AppInfoFields {
221 pub fn validate(&self) -> Result<()> {
222 if self.privacy_policy.is_empty() {
223 return Err(Error::Missing("privacyPolicy"));
224 }
225 + let text = |v: &str| Some(v.to_string());
226 check_len(
227 "privacyPolicy",
152 - &Some(self.privacy_policy.clone()),
228 + &text(&self.privacy_policy),
229 PRIVACY_POLICY_MAX_LEN,
230 )?;
231 + check_len("defaultLang", &self.default_lang, LANG_MAX_LEN)?;
232 + check_len("price", &self.price, 256)?;
233 + check_len("priceDetail", &self.price_detail, 8192)?;
234 + check_len("publishCountry", &self.publish_country, 2048)?;
235 + check_len("appTariffType", &self.app_tariff_type, 16)?;
236 + check_len("publicationNumber", &self.publication_number, 50)?;
237 + check_len("cultureRecordNumber", &self.culture_record_number, 50)?;
238 + check_len("developerNameCn", &self.developer_name_cn, 64)?;
239 + check_len("developerNameEn", &self.developer_name_en, 64)?;
240 check_len(
241 "developerWebsite",
242 &self.developer_website,
@@ -166,7 +251,29 @@ impl AppInfoFields {
251 "userAgreementUrl",
252 &self.user_agreement_url,
253 USER_AGREEMENT_URL_MAX_LEN,
169 - )
254 + )?;
255 + check_flag("appNetType", self.app_net_type, &[1, 2])?;
256 + check_flag("isFree", self.is_free, &[0, 1])?;
257 + check_flag("isAppForcedUpdate", self.is_app_forced_update, &[0, 1])?;
258 + check_flag("hispaceAutoDown", self.hispace_auto_down, &[0, 1])?;
259 + check_flag("familyShareTag", self.family_share_tag, &[0, 1])?;
260 + check_flag("webGameFlag", self.web_game_flag, &[0, 1])?;
261 + check_flag("encrypted", self.encrypted, &[0, 1])?;
262 + if self.is_free == Some(0) && (self.price.is_none() || self.price_detail.is_none()) {
263 + return Err(Error::Invalid {
264 + field: "isFree",
265 + detail: "a paid app (0) needs price and priceDetail".to_string(),
266 + });
267 + }
268 + if let Some(countries) = &self.publish_country {
269 + if countries.split(',').all(|c| c.trim() == "OTHER") {
270 + return Err(Error::Invalid {
271 + field: "publishCountry",
272 + detail: "cannot contain only OTHER".to_string(),
273 + });
274 + }
275 + }
276 + Ok(())
277 }
278 }
279
@@ -252,6 +359,28 @@ impl AppGalleryClient {
359 parse_ret(&bytes)
360 }
361
362 + /// Delete one language's listing. The default language cannot be deleted.
363 + pub async fn delete_language_info(
364 + &self,
365 + app_id: &str,
366 + lang: &str,
367 + release_type: Option<u8>,
368 + ) -> Result<()> {
369 + if lang.is_empty() {
370 + return Err(Error::EmptyLang);
371 + }
372 + let mut path = format!("/publish/v2/app-language-info?appId={app_id}&lang={lang}");
373 + if let Some(release_type) = release_type {
374 + path.push_str(&format!("&releaseType={release_type}"));
375 + }
376 + let bytes = self
377 + .send(Method::DELETE, &path, None)
378 + .await?
379 + .bytes()
380 + .await?;
381 + parse_ret(&bytes)
382 + }
383 +
384 /// Update one language's text, or add the language when it is new.
385 /// `release_type` is 1 (entire network, the default) or 3 (by phase).
386 pub async fn update_language_info(
@@ -343,6 +472,25 @@ mod tests {
472 assert_eq!(info.version_code, Some(2026102700));
473 assert_eq!(parsed.languages.len(), 1);
474 assert_eq!(parsed.languages[0].app_name.as_deref(), Some("siGit"));
475 + assert_eq!(
476 + parsed.languages[0].other.get("icon"),
477 + None,
478 + "typed fields are not duplicated into other"
479 + );
480 + }
481 +
482 + #[test]
483 + fn untyped_fields_survive_in_other() {
484 + let json = br#"{"ret":{"code":0,"msg":"ok"},
485 + "appInfo":{"parentType":13,"childType":10000000,"deviceTypes":[{"deviceType":4}]},
486 + "languages":[{"lang":"en-US","introPic":"a,b","deviceMaterials":[{"deviceType":4}]}],
487 + "phasedReleaseInfo":{"state":"DRAFT"}}"#;
488 + let parsed = parse_app_info(json).unwrap();
489 + let info = parsed.app_info.unwrap();
490 + assert_eq!(info.other["childType"], 10000000);
491 + assert!(info.other.contains_key("deviceTypes"));
492 + assert_eq!(parsed.languages[0].other["introPic"], "a,b");
493 + assert_eq!(parsed.phased_release_info.unwrap()["state"], "DRAFT");
494 }
495
496 #[test]
@@ -364,6 +512,24 @@ mod tests {
512 ..Default::default()
513 };
514 assert!(fields.validate().is_ok());
515 + assert!(AppInfoFields {
516 + is_free: Some(0),
517 + ..fields.clone()
518 + }
519 + .validate()
520 + .is_err());
521 + assert!(AppInfoFields {
522 + publish_country: Some("OTHER".into()),
523 + ..fields.clone()
524 + }
525 + .validate()
526 + .is_err());
527 + assert!(AppInfoFields {
528 + app_net_type: Some(3),
529 + ..fields.clone()
530 + }
531 + .validate()
532 + .is_err());
533 assert_eq!(
534 serde_json::to_value(&fields).unwrap(),
535 serde_json::json!({"privacyPolicy":"https://sigit.si/privacy","developerWebsite":"https://sigit.si"})
crates/appgallery/src/release.rs new
+449
@@ -0,0 +1,449 @@
1 +//! Release calls: submit for review, phased release, the release time, the
2 +//! GMS dependency flag, and the package list and its compile status.
3 +//!
4 +//! The "download mode" submit and package calls are not here: Huawei fetches
5 +//! the package from a public URL and reports back to a callback server, which
6 +//! a CLI does not have.
7 +
8 +use reqwest::Method;
9 +use serde::{Deserialize, Serialize};
10 +
11 +use crate::client::AppGalleryClient;
12 +use crate::error::{Error, Result};
13 +use crate::publish::{parse_ret, RetCode};
14 +
15 +/// Phased-release settings. Times are `yyyy-MM-ddTHH:mm:ssZZ`, e.g.
16 +/// `2026-11-01T09:00:00+0100`; the percentage is `0.00`-`100.00` with no `%`.
17 +#[derive(Debug, Clone, Default, Serialize)]
18 +#[serde(rename_all = "camelCase")]
19 +pub struct PhasedRelease {
20 + /// `SUSPEND` or `RELEASE` when updating a running phased release.
21 + #[serde(skip_serializing_if = "Option::is_none")]
22 + pub state: Option<String>,
23 + #[serde(skip_serializing_if = "Option::is_none")]
24 + pub phased_release_start_time: Option<String>,
25 + #[serde(skip_serializing_if = "Option::is_none")]
26 + pub phased_release_end_time: Option<String>,
27 + #[serde(skip_serializing_if = "Option::is_none")]
28 + pub phased_release_percent: Option<String>,
29 + #[serde(skip_serializing_if = "Option::is_none")]
30 + pub phased_release_description: Option<String>,
31 +}
32 +
33 +/// `HH:mm:ss` plus a `±HHMM` offset after a `yyyy-MM-ddT` date.
34 +pub fn is_release_time(value: &str) -> bool {
35 + let b = value.as_bytes();
36 + let digits = |r: std::ops::Range<usize>| r.into_iter().all(|i| b[i].is_ascii_digit());
37 + b.len() == 24
38 + && digits(0..4)
39 + && b[4] == b'-'
40 + && digits(5..7)
41 + && b[7] == b'-'
42 + && digits(8..10)
43 + && b[10] == b'T'
44 + && digits(11..13)
45 + && b[13] == b':'
46 + && digits(14..16)
47 + && b[16] == b':'
48 + && digits(17..19)
49 + && (b[19] == b'+' || b[19] == b'-')
50 + && digits(20..24)
51 +}
52 +
53 +/// `0.00`-`100.00`, at most two decimals, no `%`.
54 +pub fn is_percent(value: &str) -> bool {
55 + let (whole, frac) = value.split_once('.').unwrap_or((value, ""));
56 + if whole.is_empty() || !whole.bytes().all(|b| b.is_ascii_digit()) || frac.len() > 2 {
57 + return false;
58 + }
59 + if !frac.bytes().all(|b| b.is_ascii_digit()) {
60 + return false;
61 + }
62 + value
63 + .parse::<f64>()
64 + .map(|v| (0.0..=100.0).contains(&v))
65 + .unwrap_or(false)
66 +}
67 +
68 +impl PhasedRelease {
69 + pub fn validate(&self) -> Result<()> {
70 + for (field, value) in [
71 + ("phasedReleaseStartTime", &self.phased_release_start_time),
72 + ("phasedReleaseEndTime", &self.phased_release_end_time),
73 + ] {
74 + if let Some(v) = value {
75 + if !is_release_time(v) {
76 + return Err(Error::Invalid {
77 + field,
78 + detail: format!("{v:?} is not yyyy-MM-ddTHH:mm:ss+HHMM"),
79 + });
80 + }
81 + }
82 + }
83 + if let Some(p) = &self.phased_release_percent {
84 + if !is_percent(p) {
85 + return Err(Error::Invalid {
86 + field: "phasedReleasePercent",
87 + detail: format!("{p:?} is not 0.00-100.00"),
88 + });
89 + }
90 + }
91 + if let Some(state) = &self.state {
92 + if state != "SUSPEND" && state != "RELEASE" {
93 + return Err(Error::Invalid {
94 + field: "state",
95 + detail: "use SUSPEND or RELEASE".to_string(),
96 + });
97 + }
98 + }
99 + if let Some(d) = &self.phased_release_description {
100 + if d.chars().count() > 500 {
101 + return Err(Error::TooLong {
102 + field: "phasedReleaseDescription",
103 + len: d.chars().count(),
104 + max: 500,
105 + });
106 + }
107 + }
108 + Ok(())
109 + }
110 +}
111 +
112 +/// Options for `POST app-submit`.
113 +#[derive(Debug, Clone, Default)]
114 +pub struct Submit {
115 + /// Release at this time after approval; immediately when unset.
116 + pub release_time: Option<String>,
117 + /// 10-300 characters when set.
118 + pub remark: Option<String>,
119 + /// A phased release (`releaseType=3`); needs a version already released.
120 + pub phased: Option<PhasedRelease>,
121 +}
122 +
123 +impl Submit {
124 + pub fn validate(&self) -> Result<()> {
125 + if let Some(t) = &self.release_time {
126 + if !is_release_time(t) {
127 + return Err(Error::Invalid {
128 + field: "releaseTime",
129 + detail: format!("{t:?} is not yyyy-MM-ddTHH:mm:ss+HHMM"),
130 + });
131 + }
132 + }
133 + if let Some(r) = &self.remark {
134 + let n = r.chars().count();
135 + if !(10..=300).contains(&n) {
136 + return Err(Error::Invalid {
137 + field: "remark",
138 + detail: format!("{n} characters; it must be 10-300"),
139 + });
140 + }
141 + }
142 + if let Some(p) = &self.phased {
143 + p.validate()?;
144 + if p.phased_release_start_time.is_none()
145 + || p.phased_release_end_time.is_none()
146 + || p.phased_release_percent.is_none()
147 + || p.phased_release_description.is_none()
148 + {
149 + return Err(Error::Invalid {
150 + field: "phased",
151 + detail: "a phased submit needs start, end, percent and description".into(),
152 + });
153 + }
154 + }
155 + Ok(())
156 + }
157 +}
158 +
159 +/// When a version in Releasing state goes live.
160 +#[derive(Debug, Clone)]
161 +pub enum ReleaseTimeChange {
162 + /// From a scheduled time to now (`changeType` 2).
163 + Immediately,
164 + /// To a new scheduled time (`changeType` 3).
165 + At(String),
166 +}
167 +
168 +#[derive(Debug, Clone, Deserialize, Serialize)]
169 +#[serde(rename_all = "camelCase")]
170 +pub struct PackageInfo {
171 + /// The package id other calls take as `pkgIds`.
172 + pub pkg_version: String,
173 + pub file_name: Option<String>,
174 + pub version_code: Option<i64>,
175 + pub version_name: Option<String>,
176 + pub package_size: Option<i64>,
177 + pub upload_time: Option<serde_json::Value>,
178 + pub sha_code: Option<String>,
179 + #[serde(flatten)]
180 + pub other: serde_json::Map<String, serde_json::Value>,
181 +}
182 +
183 +#[derive(Debug, Clone, Deserialize, Serialize)]
184 +#[serde(rename_all = "camelCase")]
185 +pub struct PackageList {
186 + #[serde(default)]
187 + pub ret_count: i64,
188 + #[serde(default)]
189 + pub total_count: i64,
190 + #[serde(default)]
191 + pub pkg_list: Vec<PackageInfo>,
192 +}
193 +
194 +#[derive(Debug, Clone, Deserialize, Serialize)]
195 +#[serde(rename_all = "camelCase")]
196 +pub struct PackageState {
197 + pub pkg_id: String,
198 + /// 0 normal, 1 parsing, 2 failed (the package is unusable).
199 + pub success_status: Option<i64>,
200 + /// Deprecated by Huawei in favour of `success_status`.
201 + pub aab_compile_status: Option<i64>,
202 + pub fail_reason: Option<i64>,
203 +}
204 +
205 +#[derive(Deserialize)]
206 +#[serde(rename_all = "camelCase")]
207 +struct PackageListEnvelope {
208 + ret: RetCode,
209 + #[serde(flatten)]
210 + body: PackageList,
211 +}
212 +
213 +#[derive(Deserialize)]
214 +#[serde(rename_all = "camelCase")]
215 +struct PackageStateEnvelope {
216 + ret: RetCode,
217 + #[serde(default)]
218 + pkg_state_list: Vec<PackageState>,
219 +}
220 +
221 +fn parse_package_list(bytes: &[u8]) -> Result<PackageList> {
222 + let envelope: PackageListEnvelope = serde_json::from_slice(bytes)?;
223 + envelope.ret.check()?;
224 + Ok(envelope.body)
225 +}
226 +
227 +fn parse_package_states(bytes: &[u8]) -> Result<Vec<PackageState>> {
228 + let envelope: PackageStateEnvelope = serde_json::from_slice(bytes)?;
229 + envelope.ret.check()?;
230 + Ok(envelope.pkg_state_list)
231 +}
232 +
233 +impl AppGalleryClient {
234 + /// `POST app-submit`: send the app for review. This publishes once
235 + /// approved; call it only on purpose.
236 + pub async fn submit(&self, app_id: &str, options: &Submit) -> Result<()> {
237 + options.validate()?;
238 + let mut path = format!("/publish/v2/app-submit?appId={app_id}");
239 + if let Some(t) = &options.release_time {
240 + path.push_str(&format!("&releaseTime={}", crate::upload::encode(t)));
241 + }
242 + if let Some(r) = &options.remark {
243 + path.push_str(&format!("&remark={}", crate::upload::encode(r)));
244 + }
245 + let body = match &options.phased {
246 + Some(phased) => {
247 + path.push_str("&releaseType=3");
248 + Some(serde_json::to_value(phased)?)
249 + }
250 + None => None,
251 + };
252 + let bytes = self
253 + .send(Method::POST, &path, body.as_ref())
254 + .await?
255 + .bytes()
256 + .await?;
257 + parse_ret(&bytes)
258 + }
259 +
260 + /// `PUT phased-release`: update a phased release, or with `to_full`
261 + /// switch it to a release on the entire network.
262 + pub async fn update_phased_release(
263 + &self,
264 + app_id: &str,
265 + phased: &PhasedRelease,
266 + to_full: bool,
267 + ) -> Result<()> {
268 + let (path, body) = if to_full {
269 + (
270 + format!("/publish/v2/phased-release?appId={app_id}&releaseType=1"),
271 + serde_json::json!({}),
272 + )
273 + } else {
274 + phased.validate()?;
275 + (
276 + format!("/publish/v2/phased-release?appId={app_id}&releaseType=3"),
277 + serde_json::to_value(phased)?,
278 + )
279 + };
280 + let bytes = self
281 + .send(Method::PUT, &path, Some(&body))
282 + .await?
283 + .bytes()
284 + .await?;
285 + parse_ret(&bytes)
286 + }
287 +
288 + /// `PUT properties/gms`: report whether the app depends on Google Mobile
289 + /// Services.
290 + pub async fn set_gms_dependency(&self, app_id: &str, needs_gms: bool) -> Result<()> {
291 + let body = serde_json::json!({ "needGms": u8::from(needs_gms) });
292 + let path = format!("/publish/v2/properties/gms?appId={app_id}");
293 + let bytes = self
294 + .send(Method::PUT, &path, Some(&body))
295 + .await?
296 + .bytes()
297 + .await?;
298 + parse_ret(&bytes)
299 + }
300 +
301 + /// `PUT on-shelf-time`: change when a version in Releasing state goes live.
302 + pub async fn update_release_time(
303 + &self,
304 + app_id: &str,
305 + change: &ReleaseTimeChange,
306 + ) -> Result<()> {
307 + let body = match change {
308 + ReleaseTimeChange::Immediately => {
309 + serde_json::json!({ "changeType": 2, "releaseTime": "", "releaseType": 1 })
310 + }
311 + ReleaseTimeChange::At(time) => {
312 + if !is_release_time(time) {
313 + return Err(Error::Invalid {
314 + field: "releaseTime",
315 + detail: format!("{time:?} is not yyyy-MM-ddTHH:mm:ss+HHMM"),
316 + });
317 + }
318 + serde_json::json!({ "changeType": 3, "releaseTime": time, "releaseType": 1 })
319 + }
320 + };
321 + let path = format!("/publish/v2/on-shelf-time?appId={app_id}");
322 + let bytes = self
323 + .send(Method::PUT, &path, Some(&body))
324 + .await?
325 + .bytes()
326 + .await?;
327 + parse_ret(&bytes)
328 + }
329 +
330 + /// `GET package-list`: packages uploaded for the app, `max` up to 100.
331 + pub async fn package_list(
332 + &self,
333 + app_id: &str,
334 + from: Option<u32>,
335 + max: Option<u32>,
336 + ) -> Result<PackageList> {
337 + let mut path = format!("/publish/v2/package-list?appId={app_id}");
338 + if let Some(from) = from {
339 + path.push_str(&format!("&fromRecCount={from}"));
340 + }
341 + if let Some(max) = max {
342 + path.push_str(&format!("&maxReqCount={}", max.min(100)));
343 + }
344 + let bytes = self.send(Method::GET, &path, None).await?.bytes().await?;
345 + parse_package_list(&bytes)
346 + }
347 +
348 + /// `GET package/compile/status`: whether uploaded packages parsed.
349 + pub async fn package_status(
350 + &self,
351 + app_id: &str,
352 + pkg_ids: &[&str],
353 + ) -> Result<Vec<PackageState>> {
354 + if pkg_ids.is_empty() {
355 + return Err(Error::Missing("pkgIds"));
356 + }
357 + let path = format!(
358 + "/publish/v2/package/compile/status?appId={app_id}&pkgIds={}",
359 + pkg_ids.join(",")
360 + );
361 + let bytes = self.send(Method::GET, &path, None).await?.bytes().await?;
362 + parse_package_states(&bytes)
363 + }
364 +}
365 +
366 +#[cfg(test)]
367 +mod tests {
368 + use super::*;
369 +
370 + #[test]
371 + fn release_times_follow_the_documented_format() {
372 + assert!(is_release_time("2026-11-01T09:00:00+0100"));
373 + assert!(is_release_time("2015-01-01T01:01:01-0500"));
374 + assert!(!is_release_time("2026-11-01 09:00:00+0100"));
375 + assert!(!is_release_time("2026-11-01T09:00:00Z"));
376 + assert!(!is_release_time("2026-11-01T09:00:00+01:00"));
377 + }
378 +
379 + #[test]
380 + fn percentages_have_at_most_two_decimals_and_stay_in_range() {
381 + for ok in ["0", "50", "50.5", "50.00", "100.00"] {
382 + assert!(is_percent(ok), "{ok}");
383 + }
384 + for bad in ["", "50%", "100.01", "-1", "1.234", ".5", "abc"] {
385 + assert!(!is_percent(bad), "{bad}");
386 + }
387 + }
388 +
389 + #[test]
390 + fn a_phased_submit_needs_every_window_field() {
391 + let mut submit = Submit {
392 + phased: Some(PhasedRelease {
393 + phased_release_start_time: Some("2026-11-01T09:00:00+0100".into()),
394 + phased_release_end_time: Some("2026-11-08T09:00:00+0100".into()),
395 + phased_release_percent: Some("10.00".into()),
396 + ..Default::default()
397 + }),
398 + ..Default::default()
399 + };
400 + assert!(submit.validate().is_err());
401 + submit.phased.as_mut().unwrap().phased_release_description = Some("10% first".into());
402 + assert!(submit.validate().is_ok());
403 + }
404 +
405 + #[test]
406 + fn remarks_are_ten_to_three_hundred_characters() {
407 + let short = Submit {
408 + remark: Some("too short".into()),
409 + ..Default::default()
410 + };
411 + assert!(short.validate().is_err());
412 + let fine = Submit {
413 + remark: Some("Sign in with the demo account in the notes.".into()),
414 + ..Default::default()
415 + };
416 + assert!(fine.validate().is_ok());
417 + }
418 +
419 + #[test]
420 + fn the_phased_body_uses_the_documented_names() {
421 + let body = serde_json::to_value(PhasedRelease {
422 + state: Some("SUSPEND".into()),
423 + phased_release_percent: Some("50.00".into()),
424 + ..Default::default()
425 + })
426 + .unwrap();
427 + assert_eq!(
428 + body,
429 + serde_json::json!({"state":"SUSPEND","phasedReleasePercent":"50.00"})
430 + );
431 + }
432 +
433 + #[test]
434 + fn package_list_and_states_parse() {
435 + let list = parse_package_list(
436 + br#"{"ret":{"code":0,"msg":"ok"},"retCount":1,"totalCount":1,
437 + "pkgList":[{"pkgVersion":"10004151","fileName":"siGit.apk","versionCode":2026102700,
438 + "packageSize":1,"uploadTime":1,"packageType":1}]}"#,
439 + )
440 + .unwrap();
441 + assert_eq!(list.pkg_list[0].pkg_version, "10004151");
442 + assert_eq!(list.pkg_list[0].other["packageType"], 1);
443 + let states = parse_package_states(
444 + br#"{"ret":{"code":0,"msg":"ok"},"pkgStateList":[{"pkgId":"1","successStatus":1}]}"#,
445 + )
446 + .unwrap();
447 + assert_eq!(states[0].success_status, Some(1));
448 + }
449 +}
crates/appgallery/src/upload.rs
+153 -25
@@ -9,24 +9,82 @@ use sha2::{Digest, Sha256};
9
10 use crate::client::AppGalleryClient;
11 use crate::error::{Error, Result};
12 -use crate::publish::parse_ret;
12
14 -/// `fileType` in `PUT app-file-info`; only the kinds this crate uploads.
13 +/// `fileType` in `PUT app-file-info`.
14 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
15 pub enum FileType {
16 + /// 0
17 Icon,
18 + /// 1: up to three introduction videos, each followed by its poster.
19 + IntroVideo,
20 + /// 2
21 Screenshots,
19 - /// An APK, AAB or RPK.
22 + /// 3: a promotion video followed by its poster.
23 + PromoVideo,
24 + /// 4
25 + PromoImage,
26 + /// 5: an APK, AAB or RPK.
27 Package,
28 + /// 6: agent certificate or agent copyright image.
29 + AgentCertificate,
30 + /// 7: electronic certificate PDF, up to 5 MB.
31 + ElectronicCertificate,
32 + /// 8: Internet culture operation license screenshot (China only).
33 + CultureLicenseScreenshot,
34 + /// 9: Internet culture operation license image or PDF (games only).
35 + CultureLicense,
36 + /// 10
37 + VrCover,
38 + /// 11
39 + VrScreenshots,
40 + /// 12
41 + VrPromoImage,
42 + /// 13
43 + VrCoverLayered,
44 + /// 14
45 + VrPromo4x3,
46 + /// 15
47 + VrPromo1x1,
48 + /// 16
49 + VrPanorama,
50 }
51
52 impl FileType {
53 + pub const ALL: [FileType; 17] = [
54 + Self::Icon,
55 + Self::IntroVideo,
56 + Self::Screenshots,
57 + Self::PromoVideo,
58 + Self::PromoImage,
59 + Self::Package,
60 + Self::AgentCertificate,
61 + Self::ElectronicCertificate,
62 + Self::CultureLicenseScreenshot,
63 + Self::CultureLicense,
64 + Self::VrCover,
65 + Self::VrScreenshots,
66 + Self::VrPromoImage,
67 + Self::VrCoverLayered,
68 + Self::VrPromo4x3,
69 + Self::VrPromo1x1,
70 + Self::VrPanorama,
71 + ];
72 +
73 pub fn code(self) -> u8 {
25 - match self {
26 - Self::Icon => 0,
27 - Self::Screenshots => 2,
28 - Self::Package => 5,
29 - }
74 + Self::ALL.iter().position(|t| *t == self).unwrap_or(0) as u8
75 + }
76 +
77 + /// Images and videos belong to a language; packages and certificates
78 + /// do not.
79 + pub fn needs_lang(self) -> bool {
80 + !matches!(
81 + self,
82 + Self::Package
83 + | Self::AgentCertificate
84 + | Self::ElectronicCertificate
85 + | Self::CultureLicenseScreenshot
86 + | Self::CultureLicense
87 + )
88 }
89 }
90
@@ -92,9 +150,47 @@ struct FileInfoBody<'a> {
150 lang: Option<&'a str>,
151 #[serde(skip_serializing_if = "Option::is_none")]
152 img_show_type: Option<u8>,
153 + #[serde(skip_serializing_if = "Option::is_none")]
154 + video_show_type: Option<u8>,
155 + #[serde(skip_serializing_if = "Option::is_none")]
156 + sensitive_permission_desc: Option<&'a str>,
157 + #[serde(skip_serializing_if = "Option::is_none")]
158 + device_type: Option<u8>,
159 files: Vec<FileEntry<'a>>,
160 }
161
162 +/// What `PUT app-file-info` binds. `files` pairs an optional file name
163 +/// (packages need it) with the object id from [`UploadUrl`], in order.
164 +#[derive(Debug, Clone)]
165 +pub struct FileBind<'a> {
166 + pub file_type: FileType,
167 + /// Required for images and videos.
168 + pub lang: Option<&'a str>,
169 + /// Required for screenshots.
170 + pub image_orientation: Option<ImageOrientation>,
171 + /// Required for videos.
172 + pub video_orientation: Option<ImageOrientation>,
173 + pub sensitive_permission_desc: Option<&'a str>,
174 + /// Needed for visual assets when the app supports several device types
175 + /// (4 phone, 6 VR, 7 watch, 8 Vision, 9 router, 10 car).
176 + pub device_type: Option<u8>,
177 + pub files: Vec<(Option<&'a str>, &'a str)>,
178 +}
179 +
180 +#[derive(Deserialize)]
181 +#[serde(rename_all = "camelCase")]
182 +struct BindEnvelope {
183 + ret: crate::publish::RetCode,
184 + #[serde(default)]
185 + pkg_version: Vec<String>,
186 +}
187 +
188 +fn parse_bind(bytes: &[u8]) -> Result<Vec<String>> {
189 + let envelope: BindEnvelope = serde_json::from_slice(bytes)?;
190 + envelope.ret.check()?;
191 + Ok(envelope.pkg_version)
192 +}
193 +
194 impl AppGalleryClient {
195 /// `GET upload-url/for-obs`. `chinese_mainland` is sent as
196 /// `chineseMainlandFlag`; the API makes it mandatory when the developer
@@ -142,22 +238,37 @@ impl AppGalleryClient {
238 }
239 }
240
145 - /// `PUT app-file-info`: bind uploaded objects to the app. `lang` is
146 - /// required for images; `orientation` for screenshots. `files` pairs an
147 - /// optional file name (packages need it) with the object id.
148 - pub async fn bind_files(
149 - &self,
150 - app_id: &str,
151 - file_type: FileType,
152 - lang: Option<&str>,
153 - orientation: Option<ImageOrientation>,
154 - files: &[(Option<&str>, &str)],
155 - ) -> Result<()> {
241 + /// `PUT app-file-info`: bind uploaded objects to the app. Returns the
242 + /// package id (`pkgVersion`) when a package was added. Binding an image
243 + /// or video for a language resets that language's text (seen
244 + /// 2026-10-27), so write text after images.
245 + pub async fn bind_files(&self, app_id: &str, bind: &FileBind<'_>) -> Result<Vec<String>> {
246 + if bind.files.is_empty() {
247 + return Err(Error::Missing("files"));
248 + }
249 + if bind.file_type.needs_lang() && bind.lang.is_none() {
250 + return Err(Error::Missing("lang"));
251 + }
252 + if bind.file_type == FileType::Screenshots && bind.image_orientation.is_none() {
253 + return Err(Error::Missing("imgShowType"));
254 + }
255 + if matches!(bind.file_type, FileType::IntroVideo | FileType::PromoVideo)
256 + && bind.video_orientation.is_none()
257 + {
258 + return Err(Error::Missing("videoShowType"));
259 + }
260 + if bind.file_type == FileType::Package && bind.files.iter().any(|(n, _)| n.is_none()) {
261 + return Err(Error::Missing("fileName"));
262 + }
263 let body = serde_json::to_value(FileInfoBody {
157 - file_type: file_type.code(),
158 - lang,
159 - img_show_type: orientation.map(ImageOrientation::code),
160 - files: files
264 + file_type: bind.file_type.code(),
265 + lang: bind.lang,
266 + img_show_type: bind.image_orientation.map(ImageOrientation::code),
267 + video_show_type: bind.video_orientation.map(ImageOrientation::code),
268 + sensitive_permission_desc: bind.sensitive_permission_desc,
269 + device_type: bind.device_type,
270 + files: bind
271 + .files
272 .iter()
273 .map(|(name, object)| FileEntry {
274 file_name: *name,
@@ -171,12 +282,12 @@ impl AppGalleryClient {
282 .await?
283 .bytes()
284 .await?;
174 - parse_ret(&bytes)
285 + parse_bind(&bytes)
286 }
287 }
288
289 /// Percent-encode a file name for a query string.
179 -fn encode(value: &str) -> String {
290 +pub(crate) fn encode(value: &str) -> String {
291 let mut out = String::new();
292 for b in value.bytes() {
293 match b {
@@ -198,10 +309,24 @@ mod tests {
309 assert_eq!(FileType::Icon.code(), 0);
310 assert_eq!(FileType::Screenshots.code(), 2);
311 assert_eq!(FileType::Package.code(), 5);
312 + assert_eq!(FileType::IntroVideo.code(), 1);
313 + assert_eq!(FileType::VrPanorama.code(), 16);
314 + assert!(!FileType::Package.needs_lang());
315 + assert!(FileType::PromoImage.needs_lang());
316 assert_eq!(ImageOrientation::Portrait.code(), 0);
317 assert_eq!(ImageOrientation::Landscape.code(), 1);
318 }
319
320 + #[test]
321 + fn a_package_bind_returns_its_package_id() {
322 + let ids =
323 + parse_bind(br#"{"ret":{"code":0,"msg":"ok"},"pkgVersion":["10004151"]}"#).unwrap();
324 + assert_eq!(ids, vec!["10004151"]);
325 + assert!(parse_bind(br#"{"ret":{"code":0,"msg":"ok"}}"#)
326 + .unwrap()
327 + .is_empty());
328 + }
329 +
330 #[test]
331 fn sha256_hex_is_lowercase_hex() {
332 assert_eq!(
@@ -234,6 +359,9 @@ mod tests {
359 file_type: 2,
360 lang: Some("en-US"),
361 img_show_type: Some(0),
362 + video_show_type: None,
363 + sensitive_permission_desc: None,
364 + device_type: None,
365 files: vec![FileEntry {
366 file_name: None,
367 file_dest_url: "obj1",
crates/cli/src/main.rs
+399 -47
@@ -3,6 +3,8 @@ use clap::{Parser, Subcommand, ValueEnum};
3 use smbcloud_ascapi_appgallery::{
4 AppInfoFields as AppGalleryInfoFields, FileType as AppGalleryFileType,
5 ImageOrientation as AppGalleryOrientation, LanguageFields as AppGalleryLanguageFields,
6 + PhasedRelease as AppGalleryPhasedRelease, ReleaseTimeChange as AppGalleryReleaseTimeChange,
7 + Submit as AppGallerySubmit,
8 };
9 use smbcloud_ascapi_aso::app::AppUpdateAttributes;
10 use smbcloud_ascapi_aso::app_info_localization::{
@@ -99,53 +101,237 @@ enum PlayCommand {
101 },
102 }
103
102 -// `Listings` carries the nested update command with its many text flags; boxing
103 -// a clap subcommand field is not possible.
104 +// The update commands carry many flags; boxing a clap subcommand field is not
105 +// possible.
106 #[allow(clippy::large_enum_variant)]
107 #[derive(Subcommand)]
108 enum AppGalleryCommand {
109 + /// Look up the AppGallery app id for a package name.
110 + AppId { package: String },
111 /// Localized listing text: name, description, brief and release notes.
112 Listings {
113 #[command(subcommand)]
114 command: AppGalleryListingsCommand,
115 },
112 - /// Look up the AppGallery app id for a package name.
113 - AppId { package: String },
114 - /// Basic information: privacy policy link and similar.
116 + /// Basic information: privacy links, category, countries, price and flags.
117 Info {
118 #[command(subcommand)]
119 command: AppGalleryInfoCommand,
120 },
119 - /// Icon and screenshots for one language.
120 - Images {
121 + /// Upload and bind files: icon, screenshots, videos, promo images,
122 + /// certificates, VR assets, or the APK/AAB/RPK.
123 + #[command(alias = "images")]
124 + Files {
125 + #[command(subcommand)]
126 + command: AppGalleryFilesCommand,
127 + },
128 + /// Uploaded packages and whether they parsed.
129 + Packages {
130 #[command(subcommand)]
122 - command: AppGalleryImagesCommand,
131 + command: AppGalleryPackagesCommand,
132 + },
133 + /// Report whether the app depends on Google Mobile Services.
134 + Gms {
135 + app: String,
136 + /// true if the app needs GMS, false if it runs without it.
137 + #[arg(long, action = clap::ArgAction::Set)]
138 + needs_gms: bool,
139 + },
140 + /// Submit the app for review. Once approved it goes live (at
141 + /// --release-time if given). Check everything with --dry-run first.
142 + Submit {
143 + app: String,
144 + /// yyyy-MM-ddTHH:mm:ss+HHMM; released right after approval when unset.
145 + #[arg(long)]
146 + release_time: Option<String>,
147 + /// Note for the reviewer, 10-300 characters.
148 + #[arg(long, conflicts_with = "remark_file")]
149 + remark: Option<String>,
150 + #[arg(long)]
151 + remark_file: Option<PathBuf>,
152 + #[command(flatten)]
153 + phased: PhasedArgs,
154 + },
155 + /// Change a running phased release, or turn it into a full release.
156 + PhasedRelease {
157 + app: String,
158 + /// Release to the entire network instead; ignores the other flags.
159 + #[arg(long)]
160 + to_full: bool,
161 + /// SUSPEND or RELEASE.
162 + #[arg(long)]
163 + state: Option<String>,
164 + #[command(flatten)]
165 + phased: PhasedArgs,
166 + },
167 + /// Change when a version in Releasing state goes live.
168 + ReleaseTime {
169 + app: String,
170 + #[arg(long, conflicts_with = "at", required_unless_present = "at")]
171 + immediately: bool,
172 + /// yyyy-MM-ddTHH:mm:ss+HHMM
173 + #[arg(long)]
174 + at: Option<String>,
175 },
176 }
177
178 +/// The phased-release window. Setting any of these on `submit` makes it a
179 +/// phased release, which needs a version already released.
180 +#[derive(clap::Args)]
181 +struct PhasedArgs {
182 + /// yyyy-MM-ddTHH:mm:ss+HHMM
183 + #[arg(long)]
184 + phased_start: Option<String>,
185 + /// yyyy-MM-ddTHH:mm:ss+HHMM
186 + #[arg(long)]
187 + phased_end: Option<String>,
188 + /// 0.00-100.00, no percent sign.
189 + #[arg(long)]
190 + phased_percent: Option<String>,
191 + /// Up to 500 characters.
192 + #[arg(long)]
193 + phased_description: Option<String>,
194 +}
195 +
196 +impl PhasedArgs {
197 + fn into_release(self, state: Option<String>) -> Option<AppGalleryPhasedRelease> {
198 + let any = self.phased_start.is_some()
199 + || self.phased_end.is_some()
200 + || self.phased_percent.is_some()
201 + || self.phased_description.is_some()
202 + || state.is_some();
203 + any.then_some(AppGalleryPhasedRelease {
204 + state,
205 + phased_release_start_time: self.phased_start,
206 + phased_release_end_time: self.phased_end,
207 + phased_release_percent: self.phased_percent,
208 + phased_release_description: self.phased_description,
209 + })
210 + }
211 +}
212 +
213 #[derive(Subcommand)]
214 enum AppGalleryInfoCommand {
128 - /// Set the privacy policy link (required by the API) and, optionally,
129 - /// the developer website and the privacy-rights and user-agreement URLs.
130 - /// Reads the privacy link back. With `--dry-run` nothing is sent.
215 + /// Update basic information. The API needs --privacy-policy on every
216 + /// call; every other flag is left unchanged when omitted. Reads the
217 + /// privacy link back. With `--dry-run` nothing is sent.
218 Update {
219 app: String,
220 #[arg(long)]
221 privacy_policy: String,
222 + /// Default language, e.g. en-US.
223 + #[arg(long)]
224 + default_lang: Option<String>,
225 + /// Level-2 category id, e.g. 10000000 (Tools).
226 + #[arg(long)]
227 + category: Option<u32>,
228 + /// Level-3 category (tag) id, e.g. 15000005.
229 + #[arg(long)]
230 + category_tag: Option<u32>,
231 + /// Comma-separated country/region codes. Leave CN out to keep the
232 + /// app off the Chinese mainland.
233 + #[arg(long)]
234 + publish_country: Option<String>,
235 + /// 1 free, 0 paid (needs --price and --price-detail). Fixed after release.
236 + #[arg(long)]
237 + is_free: Option<u8>,
238 + /// {"countryCode":"price"}
239 + #[arg(long)]
240 + price: Option<String>,
241 + /// JSON array of {country, currency, price}.
242 + #[arg(long)]
243 + price_detail: Option<String>,
244 + /// Comma-separated in-app purchase types (1 activation ... 8 membership).
245 + #[arg(long)]
246 + tariff_type: Option<String>,
247 #[arg(long)]
248 developer_website: Option<String>,
137 - /// URL where users can view, change and delete their personal data.
249 + /// URL where users view, change and delete their personal data.
250 #[arg(long)]
251 privacy_rights_url: Option<String>,
252 #[arg(long)]
253 user_agreement_url: Option<String>,
254 + /// JSON, e.g. [{"deviceType":4,"appAdapters":"4,5"}] (4 phone, 5 tablet).
255 + #[arg(long)]
256 + device_types: Option<String>,
257 + /// 0 or 1.
258 + #[arg(long)]
259 + forced_update: Option<u8>,
260 + /// 0 or 1: let AppGallery fetch the package from the Internet.
261 + #[arg(long)]
262 + auto_download: Option<u8>,
263 + /// 0 or 1.
264 + #[arg(long)]
265 + family_share: Option<u8>,
266 + /// 0 or 1; the API defaults to 1.
267 + #[arg(long)]
268 + encrypted: Option<u8>,
269 + /// Games: 1 standalone, 2 online.
270 + #[arg(long)]
271 + net_type: Option<u8>,
272 + /// Games: 0 or 1.
273 + #[arg(long)]
274 + web_game: Option<u8>,
275 + /// Games: publication approval number.
276 + #[arg(long)]
277 + publication_number: Option<String>,
278 + /// Games, China only: Internet culture operation license number.
279 + #[arg(long)]
280 + culture_record_number: Option<String>,
281 + /// Trustlisted developers only.
282 + #[arg(long)]
283 + developer_name_cn: Option<String>,
284 + /// Trustlisted developers only.
285 + #[arg(long)]
286 + developer_name_en: Option<String>,
287 },
288 }
289
290 #[derive(Clone, Copy, ValueEnum)]
146 -enum CliAppGalleryImageKind {
291 +enum CliAppGalleryFileType {
292 Icon,
293 Screenshots,
294 + IntroVideo,
295 + PromoVideo,
296 + PromoImage,
297 + Package,
298 + AgentCertificate,
299 + ElectronicCertificate,
300 + CultureLicenseScreenshot,
301 + CultureLicense,
302 + VrCover,
303 + VrScreenshots,
304 + VrPromoImage,
305 + VrCoverLayered,
306 + #[value(name = "vr-promo-4x3")]
307 + VrPromo4x3,
308 + #[value(name = "vr-promo-1x1")]
309 + VrPromo1x1,
310 + VrPanorama,
311 +}
312 +
313 +impl From<CliAppGalleryFileType> for AppGalleryFileType {
314 + fn from(value: CliAppGalleryFileType) -> Self {
315 + match value {
316 + CliAppGalleryFileType::Icon => Self::Icon,
317 + CliAppGalleryFileType::Screenshots => Self::Screenshots,
318 + CliAppGalleryFileType::IntroVideo => Self::IntroVideo,
319 + CliAppGalleryFileType::PromoVideo => Self::PromoVideo,
320 + CliAppGalleryFileType::PromoImage => Self::PromoImage,
321 + CliAppGalleryFileType::Package => Self::Package,
322 + CliAppGalleryFileType::AgentCertificate => Self::AgentCertificate,
323 + CliAppGalleryFileType::ElectronicCertificate => Self::ElectronicCertificate,
324 + CliAppGalleryFileType::CultureLicenseScreenshot => Self::CultureLicenseScreenshot,
325 + CliAppGalleryFileType::CultureLicense => Self::CultureLicense,
326 + CliAppGalleryFileType::VrCover => Self::VrCover,
327 + CliAppGalleryFileType::VrScreenshots => Self::VrScreenshots,
328 + CliAppGalleryFileType::VrPromoImage => Self::VrPromoImage,
329 + CliAppGalleryFileType::VrCoverLayered => Self::VrCoverLayered,
330 + CliAppGalleryFileType::VrPromo4x3 => Self::VrPromo4x3,
331 + CliAppGalleryFileType::VrPromo1x1 => Self::VrPromo1x1,
332 + CliAppGalleryFileType::VrPanorama => Self::VrPanorama,
333 + }
334 + }
335 }
336
337 #[derive(Clone, Copy, ValueEnum)]
@@ -154,30 +340,73 @@ enum CliAppGalleryOrientation {
340 Landscape,
341 }
342
343 +impl From<CliAppGalleryOrientation> for AppGalleryOrientation {
344 + fn from(value: CliAppGalleryOrientation) -> Self {
345 + match value {
346 + CliAppGalleryOrientation::Portrait => Self::Portrait,
347 + CliAppGalleryOrientation::Landscape => Self::Landscape,
348 + }
349 + }
350 +}
351 +
352 #[derive(Subcommand)]
158 -enum AppGalleryImagesCommand {
159 - /// Upload an icon (one file) or screenshots (in display order) and bind
160 - /// them to a language. Sent with chineseMainlandFlag=0. With `--dry-run`
161 - /// it lists each file's size and SHA-256 and sends nothing.
353 +enum AppGalleryFilesCommand {
354 + /// Upload files of one type, in display order, and bind them. Images
355 + /// and videos need --lang; that language's text is checked and written
356 + /// back if binding cleared it. With `--dry-run` it lists each file's size
357 + /// and SHA-256 and sends nothing.
358 Upload {
359 app: String,
360 + #[arg(long = "type", alias = "kind", value_enum)]
361 + file_type: CliAppGalleryFileType,
362 #[arg(long)]
165 - lang: String,
166 - #[arg(long, value_enum)]
167 - kind: CliAppGalleryImageKind,
168 - /// Required for screenshots.
363 + lang: Option<String>,
364 + /// Screenshots: portrait or landscape.
365 #[arg(long, value_enum)]
366 orientation: Option<CliAppGalleryOrientation>,
171 - /// PNG or JPEG files.
367 + /// Videos: portrait or landscape.
368 + #[arg(long, value_enum)]
369 + video_orientation: Option<CliAppGalleryOrientation>,
370 + /// Packages: sensitive permission description.
371 + #[arg(long)]
372 + sensitive_permission_desc: Option<String>,
373 + /// Device type for visual assets on a multi-device app (4 phone).
374 + #[arg(long)]
375 + device_type: Option<u8>,
376 + /// Distribute the package to the Chinese mainland. Off by default.
377 + #[arg(long)]
378 + chinese_mainland: bool,
379 + /// The files. Videos alternate with their posters: video, poster, ...
380 #[arg(required = true)]
381 files: Vec<PathBuf>,
382 },
383 }
384
385 +#[derive(Subcommand)]
386 +enum AppGalleryPackagesCommand {
387 + /// Packages uploaded for the app, newest first.
388 + List {
389 + app: String,
390 + /// First record, from 1.
391 + #[arg(long)]
392 + from: Option<u32>,
393 + /// Up to 100 (the API's default is 10).
394 + #[arg(long)]
395 + max: Option<u32>,
396 + },
397 + /// Parse status of packages: 0 normal, 1 parsing, 2 failed.
398 + Status {
399 + app: String,
400 + /// Package ids (pkgVersion from `packages list` or the upload).
401 + #[arg(required = true)]
402 + pkg_ids: Vec<String>,
403 + },
404 +}
405 +
406 #[derive(Subcommand)]
407 enum AppGalleryListingsCommand {
179 - /// App info and every language's text, or one language's. `APP` is the
180 - /// numeric app id or the package name.
408 + /// App info and every language's text and assets, or one language's.
409 + /// `APP` is the numeric app id or the package name.
410 List {
411 app: String,
412 #[arg(long)]
@@ -215,6 +444,12 @@ enum AppGalleryListingsCommand {
444 #[arg(long, value_parser = clap::value_parser!(u8).range(1..=3))]
445 release_type: Option<u8>,
446 },
447 + /// Delete one language's listing. The default language cannot be deleted.
448 + Delete {
449 + app: String,
450 + #[arg(long)]
451 + lang: String,
452 + },
453 }
454
455 #[derive(Subcommand)]
@@ -445,6 +680,11 @@ async fn run_appgallery(
680 let client = appgallery::appgallery_client(service_account, client_id)
681 .map_err(|e| anyhow::anyhow!(e))?;
682 let fail = |e: String| anyhow::anyhow!(e);
683 + let flag = |label: &str, dry: bool| {
684 + if dry {
685 + println!("# dry run: nothing was sent; {label}:");
686 + }
687 + };
688 match command {
689 AppGalleryCommand::AppId { package } => print_json(
690 &client
@@ -456,58 +696,166 @@ async fn run_appgallery(
696 AppGalleryInfoCommand::Update {
697 app,
698 privacy_policy,
699 + default_lang,
700 + category,
701 + category_tag,
702 + publish_country,
703 + is_free,
704 + price,
705 + price_detail,
706 + tariff_type,
707 developer_website,
708 privacy_rights_url,
709 user_agreement_url,
710 + device_types,
711 + forced_update,
712 + auto_download,
713 + family_share,
714 + encrypted,
715 + net_type,
716 + web_game,
717 + publication_number,
718 + culture_record_number,
719 + developer_name_cn,
720 + developer_name_en,
721 } => {
722 + let device_types = device_types
723 + .map(|json| serde_json::from_str(&json))
724 + .transpose()
725 + .context("--device-types must be JSON")?;
726 let fields = AppGalleryInfoFields {
727 privacy_policy,
728 + default_lang,
729 + child_type: category,
730 + grand_child_type: category_tag,
731 + app_net_type: net_type,
732 + is_free,
733 + price,
734 + price_detail,
735 + publish_country,
736 + is_app_forced_update: forced_update,
737 + hispace_auto_down: auto_download,
738 + app_tariff_type: tariff_type,
739 + publication_number,
740 + culture_record_number,
741 + developer_name_cn,
742 + developer_name_en,
743 developer_website,
744 + family_share_tag: family_share,
745 + device_types,
746 + web_game_flag: web_game,
747 privacy_rights_url,
748 user_agreement_url,
749 + encrypted,
750 };
751 let result = appgallery::update_basic_info(&client, &app, fields, None, dry_run)
752 .await
753 .map_err(fail)?;
472 - if result.dry_run {
473 - println!("# dry run: nothing was sent; body that would be sent:");
474 - }
754 + flag("body that would be sent", result.dry_run);
755 print_json(&result)
756 }
757 },
478 - AppGalleryCommand::Images { command } => match command {
479 - AppGalleryImagesCommand::Upload {
758 + AppGalleryCommand::Files { command } => match command {
759 + AppGalleryFilesCommand::Upload {
760 app,
761 + file_type,
762 lang,
482 - kind,
763 orientation,
764 + video_orientation,
765 + sensitive_permission_desc,
766 + device_type,
767 + chinese_mainland,
768 files,
769 } => {
486 - let kind = match kind {
487 - CliAppGalleryImageKind::Icon => AppGalleryFileType::Icon,
488 - CliAppGalleryImageKind::Screenshots => AppGalleryFileType::Screenshots,
770 + let options = appgallery::UploadOptions {
771 + lang,
772 + image_orientation: orientation.map(Into::into),
773 + video_orientation: video_orientation.map(Into::into),
774 + sensitive_permission_desc,
775 + device_type,
776 + chinese_mainland,
777 };
490 - let orientation = orientation.map(|o| match o {
491 - CliAppGalleryOrientation::Portrait => AppGalleryOrientation::Portrait,
492 - CliAppGalleryOrientation::Landscape => AppGalleryOrientation::Landscape,
493 - });
494 - let result = appgallery::upload_images(
778 + let result = appgallery::upload_files(
779 &client,
780 &app,
497 - &lang,
498 - kind,
499 - orientation,
781 + file_type.into(),
782 &files,
783 + &options,
784 dry_run,
785 )
786 .await
787 .map_err(fail)?;
505 - if result.dry_run {
506 - println!("# dry run: nothing was uploaded; files that would be sent:");
507 - }
788 + flag("files that would be uploaded", result.dry_run);
789 print_json(&result)
790 }
791 },
792 + AppGalleryCommand::Packages { command } => match command {
793 + AppGalleryPackagesCommand::List { app, from, max } => print_json(
794 + &appgallery::package_list(&client, &app, from, max)
795 + .await
796 + .map_err(fail)?,
797 + ),
798 + AppGalleryPackagesCommand::Status { app, pkg_ids } => print_json(
799 + &appgallery::package_status(&client, &app, &pkg_ids)
800 + .await
801 + .map_err(fail)?,
802 + ),
803 + },
804 + AppGalleryCommand::Gms { app, needs_gms } => {
805 + let result = appgallery::set_gms_dependency(&client, &app, needs_gms, dry_run)
806 + .await
807 + .map_err(fail)?;
808 + flag("body that would be sent", result.dry_run);
809 + print_json(&result)
810 + }
811 + AppGalleryCommand::Submit {
812 + app,
813 + release_time,
814 + remark,
815 + remark_file,
816 + phased,
817 + } => {
818 + let options = AppGallerySubmit {
819 + release_time,
820 + remark: text_arg(remark, remark_file, "--remark-file")?,
821 + phased: phased.into_release(None),
822 + };
823 + let result = appgallery::submit(&client, &app, options, dry_run)
824 + .await
825 + .map_err(fail)?;
826 + flag("submission that would be sent", result.dry_run);
827 + print_json(&result)
828 + }
829 + AppGalleryCommand::PhasedRelease {
830 + app,
831 + to_full,
832 + state,
833 + phased,
834 + } => {
835 + let release = phased.into_release(state).unwrap_or_default();
836 + let result =
837 + appgallery::update_phased_release(&client, &app, release, to_full, dry_run)
838 + .await
839 + .map_err(fail)?;
840 + flag("body that would be sent", result.dry_run);
841 + print_json(&result)
842 + }
843 + AppGalleryCommand::ReleaseTime {
844 + app,
845 + immediately,
846 + at,
847 + } => {
848 + let change = match (immediately, at) {
849 + (true, _) => AppGalleryReleaseTimeChange::Immediately,
850 + (false, Some(at)) => AppGalleryReleaseTimeChange::At(at),
851 + (false, None) => anyhow::bail!("pass --immediately or --at"),
852 + };
853 + let result = appgallery::update_release_time(&client, &app, change, dry_run)
854 + .await
855 + .map_err(fail)?;
856 + flag("body that would be sent", result.dry_run);
857 + print_json(&result)
858 + }
859 AppGalleryCommand::Listings { command } => match command {
860 AppGalleryListingsCommand::List { app, lang } => print_json(
861 &appgallery::read_listings(&client, &app, lang.as_deref())
@@ -542,9 +890,13 @@ async fn run_appgallery(
890 appgallery::update_language(&client, &app, fields, release_type, dry_run)
891 .await
892 .map_err(fail)?;
545 - if result.dry_run {
546 - println!("# dry run: nothing was sent; body that would be sent:");
547 - }
893 + flag("body that would be sent", result.dry_run);
894 + print_json(&result)
895 + }
896 + AppGalleryListingsCommand::Delete { app, lang } => {
897 + let result = appgallery::delete_language(&client, &app, &lang, dry_run)
898 + .await
899 + .map_err(fail)?;
900 print_json(&result)
901 }
902 },
crates/frontend/src/appgallery.rs
+408 -61
@@ -6,8 +6,9 @@ use std::path::Path;
6 use serde::Serialize;
7 use smbcloud_ascapi_appgallery::upload::sha256_hex;
8 use smbcloud_ascapi_appgallery::{
9 - AppGalleryClient, AppInfo, AppInfoFields, AppInfoResponse, FileType, ImageOrientation,
10 - LanguageFields, LanguageInfo, ServiceAccount,
9 + AppGalleryClient, AppInfo, AppInfoFields, AppInfoResponse, FileBind, FileType,
10 + ImageOrientation, LanguageFields, LanguageInfo, PackageList, PackageState, PhasedRelease,
11 + ReleaseTimeChange, ServiceAccount, Submit,
12 };
13
14 /// Resolve the AppGallery client. `path` wins; then
@@ -215,67 +216,172 @@ pub struct PlannedFile {
216 }
217
218 #[derive(Debug, Serialize)]
218 -pub struct ImageUpload {
219 +pub struct FileUpload {
220 pub dry_run: bool,
221 pub app_id: String,
221 - pub kind: &'static str,
222 - pub lang: String,
222 + pub file_type: &'static str,
223 + pub lang: Option<String>,
224 pub files: Vec<PlannedFile>,
225 + /// Package ids, when a package was added.
226 + pub pkg_version: Vec<String>,
227 + /// True when binding cleared the language's text and it was written back.
228 + pub restored_text: bool,
229 }
230
226 -fn is_image(path: &Path) -> bool {
227 - path.extension()
228 - .and_then(|e| e.to_str())
229 - .map(|e| matches!(e.to_ascii_lowercase().as_str(), "png" | "jpg" | "jpeg"))
230 - .unwrap_or(false)
231 +/// Options for [`upload_files`] beyond the files themselves.
232 +#[derive(Debug, Clone, Default)]
233 +pub struct UploadOptions {
234 + pub lang: Option<String>,
235 + pub image_orientation: Option<ImageOrientation>,
236 + pub video_orientation: Option<ImageOrientation>,
237 + pub sensitive_permission_desc: Option<String>,
238 + pub device_type: Option<u8>,
239 + /// Sent as `chineseMainlandFlag`; false matches siGit's "not in the
240 + /// Chinese mainland" choice. Mandatory for developers registered
241 + /// outside the mainland.
242 + pub chinese_mainland: bool,
243 }
244
233 -/// Upload an icon (exactly one file) or screenshots (in display order) and
234 -/// bind them to one language. With `dry_run` nothing is sent: the plan lists
235 -/// each file's size and hash. Uploads are sent with `chineseMainlandFlag=0`,
236 -/// matching the "not available in the Chinese mainland" decision.
237 -pub async fn upload_images(
238 - client: &AppGalleryClient,
239 - app: &str,
240 - lang: &str,
241 - kind: FileType,
242 - orientation: Option<ImageOrientation>,
243 - paths: &[std::path::PathBuf],
244 - dry_run: bool,
245 -) -> Result<ImageUpload, String> {
246 - let kind_name = match kind {
245 +/// The CLI name of a file type.
246 +pub fn file_type_name(kind: FileType) -> &'static str {
247 + match kind {
248 FileType::Icon => "icon",
249 + FileType::IntroVideo => "intro-video",
250 FileType::Screenshots => "screenshots",
249 - FileType::Package => return Err("use the package upload for APKs".to_string()),
250 - };
251 - if lang.is_empty() {
252 - return Err("lang must not be empty".to_string());
251 + FileType::PromoVideo => "promo-video",
252 + FileType::PromoImage => "promo-image",
253 + FileType::Package => "package",
254 + FileType::AgentCertificate => "agent-certificate",
255 + FileType::ElectronicCertificate => "electronic-certificate",
256 + FileType::CultureLicenseScreenshot => "culture-license-screenshot",
257 + FileType::CultureLicense => "culture-license",
258 + FileType::VrCover => "vr-cover",
259 + FileType::VrScreenshots => "vr-screenshots",
260 + FileType::VrPromoImage => "vr-promo-image",
261 + FileType::VrCoverLayered => "vr-cover-layered",
262 + FileType::VrPromo4x3 => "vr-promo-4x3",
263 + FileType::VrPromo1x1 => "vr-promo-1x1",
264 + FileType::VrPanorama => "vr-panorama",
265 }
266 +}
267 +
268 +fn extension(path: &Path) -> String {
269 + path.extension()
270 + .and_then(|e| e.to_str())
271 + .map(str::to_ascii_lowercase)
272 + .unwrap_or_default()
273 +}
274 +
275 +fn is_image(path: &Path) -> bool {
276 + matches!(extension(path).as_str(), "png" | "jpg" | "jpeg")
277 +}
278 +
279 +/// Check the files suit the type before anything is read or sent.
280 +fn check_files(kind: FileType, paths: &[std::path::PathBuf]) -> Result<(), String> {
281 if paths.is_empty() {
255 - return Err("pass at least one image file".to_string());
256 - }
257 - if kind == FileType::Icon && paths.len() != 1 {
258 - return Err("an icon is exactly one file".to_string());
282 + return Err("pass at least one file".to_string());
283 }
260 - if kind == FileType::Screenshots {
261 - if paths.len() > MAX_SCREENSHOTS {
284 + let one = |what: &str| {
285 + if paths.len() == 1 {
286 + Ok(())
287 + } else {
288 + Err(format!("{what} is exactly one file"))
289 + }
290 + };
291 + match kind {
292 + FileType::Icon => one("an icon")?,
293 + FileType::Package => one("a package")?,
294 + FileType::Screenshots | FileType::VrScreenshots if paths.len() > MAX_SCREENSHOTS => {
295 return Err(format!(
296 "at most {MAX_SCREENSHOTS} screenshots per language"
264 - ));
297 + ))
298 }
266 - if orientation.is_none() {
267 - return Err("screenshots need --orientation portrait or landscape".to_string());
299 + FileType::IntroVideo if !paths.len().is_multiple_of(2) || paths.len() > 6 => {
300 + return Err("intro videos go as video, poster pairs, up to three pairs".to_string())
301 }
302 + FileType::PromoVideo if paths.len() != 2 => {
303 + return Err("a promo video is one video then its poster".to_string())
304 + }
305 + _ => {}
306 }
270 - let mut loaded = Vec::new();
307 for path in paths {
272 - if !is_image(path) {
273 - return Err(format!("{} is not a PNG or JPEG file", path.display()));
308 + let ext = extension(path);
309 + let ok = match kind {
310 + FileType::Package => matches!(ext.as_str(), "apk" | "aab" | "rpk"),
311 + FileType::ElectronicCertificate => ext == "pdf",
312 + FileType::CultureLicense => is_image(path) || ext == "pdf",
313 + // Videos alternate with poster images.
314 + FileType::IntroVideo | FileType::PromoVideo => {
315 + is_image(path) || matches!(ext.as_str(), "mp4" | "mov")
316 + }
317 + _ => is_image(path),
318 + };
319 + if !ok {
320 + return Err(format!(
321 + "{} does not fit {}",
322 + path.display(),
323 + file_type_name(kind)
324 + ));
325 }
326 + }
327 + Ok(())
328 +}
329 +
330 +fn text_of(info: &LanguageInfo) -> LanguageFields {
331 + LanguageFields {
332 + lang: info.lang.clone().unwrap_or_default(),
333 + app_name: info.app_name.clone().filter(|v| !v.is_empty()),
334 + app_desc: info.app_desc.clone().filter(|v| !v.is_empty()),
335 + brief_info: info.brief_info.clone().filter(|v| !v.is_empty()),
336 + new_features: info.new_features.clone().filter(|v| !v.is_empty()),
337 + }
338 +}
339 +
340 +/// Text that was set before and is empty now.
341 +fn lost_text(before: &LanguageFields, after: &LanguageInfo) -> bool {
342 + let gone = |was: &Option<String>, now: &Option<String>| {
343 + was.is_some() && now.as_deref().unwrap_or_default().is_empty()
344 + };
345 + gone(&before.app_desc, &after.app_desc)
346 + || gone(&before.brief_info, &after.brief_info)
347 + || gone(&before.new_features, &after.new_features)
348 + || gone(&before.app_name, &after.app_name)
349 +}
350 +
351 +/// Upload files of one type and bind them to the app, in order. With
352 +/// `dry_run` nothing is sent: the plan lists each file's size and hash.
353 +///
354 +/// Binding a file for a language clears that language's text, so the text is
355 +/// read first and written back if it went missing.
356 +pub async fn upload_files(
357 + client: &AppGalleryClient,
358 + app: &str,
359 + kind: FileType,
360 + paths: &[std::path::PathBuf],
361 + options: &UploadOptions,
362 + dry_run: bool,
363 +) -> Result<FileUpload, String> {
364 + check_files(kind, paths)?;
365 + if kind.needs_lang() && options.lang.as_deref().unwrap_or_default().is_empty() {
366 + return Err(format!("{} needs --lang", file_type_name(kind)));
367 + }
368 + if matches!(kind, FileType::Screenshots | FileType::VrScreenshots)
369 + && options.image_orientation.is_none()
370 + {
371 + return Err("screenshots need --orientation portrait or landscape".to_string());
372 + }
373 + if matches!(kind, FileType::IntroVideo | FileType::PromoVideo)
374 + && options.video_orientation.is_none()
375 + {
376 + return Err("videos need --video-orientation portrait or landscape".to_string());
377 + }
378 + let mut loaded = Vec::new();
379 + for path in paths {
380 let bytes = std::fs::read(path).map_err(|e| format!("reading {}: {e}", path.display()))?;
381 loaded.push((path, bytes));
382 }
383 let app_id = resolve_app_id(client, app).await?;
384 + let lang = options.lang.clone().filter(|_| kind.needs_lang());
385 let mut files: Vec<PlannedFile> = loaded
386 .iter()
387 .map(|(path, bytes)| PlannedFile {
@@ -285,48 +391,289 @@ pub async fn upload_images(
391 object_id: None,
392 })
393 .collect();
394 + let mut result = FileUpload {
395 + dry_run,
396 + app_id: app_id.clone(),
397 + file_type: file_type_name(kind),
398 + lang: lang.clone(),
399 + files: Vec::new(),
400 + pkg_version: Vec::new(),
401 + restored_text: false,
402 + };
403 if dry_run {
289 - return Ok(ImageUpload {
290 - dry_run,
291 - app_id,
292 - kind: kind_name,
293 - lang: lang.to_string(),
294 - files,
295 - });
404 + result.files = files;
405 + return Ok(result);
406 }
407 +
408 + let text_before = match &lang {
409 + Some(lang) => client
410 + .app_info(&app_id, Some(lang))
411 + .await
412 + .map_err(err)?
413 + .languages
414 + .into_iter()
415 + .next()
416 + .map(|info| text_of(&info)),
417 + None => None,
418 + };
419 +
420 + let mut names = Vec::new();
421 for ((path, bytes), planned) in loaded.into_iter().zip(files.iter_mut()) {
422 let name = path
423 .file_name()
424 .and_then(|n| n.to_str())
301 - .ok_or_else(|| format!("{} has no file name", path.display()))?;
425 + .ok_or_else(|| format!("{} has no file name", path.display()))?
426 + .to_string();
427 let target = client
303 - .upload_url(&app_id, name, &bytes, Some(false))
428 + .upload_url(&app_id, &name, &bytes, Some(options.chinese_mainland))
429 .await
430 .map_err(err)?;
431 client.put_upload(&target, bytes).await.map_err(err)?;
432 planned.object_id = Some(target.object_id);
433 + names.push(name);
434 }
309 - let objects: Vec<(Option<&str>, &str)> = files
310 - .iter()
311 - .map(|f| (None, f.object_id.as_deref().unwrap_or_default()))
312 - .collect();
313 - client
314 - .bind_files(&app_id, kind, Some(lang), orientation, &objects)
315 - .await
316 - .map_err(err)?;
317 - Ok(ImageUpload {
435 + let bind = FileBind {
436 + file_type: kind,
437 + lang: lang.as_deref(),
438 + image_orientation: options.image_orientation,
439 + video_orientation: options.video_orientation,
440 + sensitive_permission_desc: options.sensitive_permission_desc.as_deref(),
441 + device_type: options.device_type,
442 + files: files
443 + .iter()
444 + .zip(&names)
445 + .map(|(f, name)| {
446 + (
447 + (kind == FileType::Package).then_some(name.as_str()),
448 + f.object_id.as_deref().unwrap_or_default(),
449 + )
450 + })
451 + .collect(),
452 + };
453 + result.pkg_version = client.bind_files(&app_id, &bind).await.map_err(err)?;
454 +
455 + if let (Some(lang), Some(before)) = (&lang, text_before) {
456 + let after = client
457 + .app_info(&app_id, Some(lang))
458 + .await
459 + .map_err(err)?
460 + .languages
461 + .into_iter()
462 + .next()
463 + .unwrap_or_default();
464 + if lost_text(&before, &after) {
465 + client
466 + .update_language_info(&app_id, &before, None)
467 + .await
468 + .map_err(|e| format!("files bound, but restoring the {lang} text failed: {e}"))?;
469 + result.restored_text = true;
470 + }
471 + }
472 + result.files = files;
473 + Ok(result)
474 +}
475 +
476 +/// Delete one language's listing (not the default language).
477 +pub async fn delete_language(
478 + client: &AppGalleryClient,
479 + app: &str,
480 + lang: &str,
481 + dry_run: bool,
482 +) -> Result<serde_json::Value, String> {
483 + let app_id = resolve_app_id(client, app).await?;
484 + if !dry_run {
485 + client
486 + .delete_language_info(&app_id, lang, None)
487 + .await
488 + .map_err(err)?;
489 + }
490 + Ok(serde_json::json!({ "dry_run": dry_run, "app_id": app_id, "deleted_lang": lang }))
491 +}
492 +
493 +#[derive(Debug, Serialize)]
494 +pub struct ReleaseAction {
495 + pub dry_run: bool,
496 + pub app_id: String,
497 + pub action: &'static str,
498 + /// What was (or would be) sent.
499 + pub detail: serde_json::Value,
500 +}
501 +
502 +/// Submit for review. Approved apps go live (at `release_time` if set).
503 +pub async fn submit(
504 + client: &AppGalleryClient,
505 + app: &str,
506 + options: Submit,
507 + dry_run: bool,
508 +) -> Result<ReleaseAction, String> {
509 + options.validate().map_err(err)?;
510 + let app_id = resolve_app_id(client, app).await?;
511 + let detail = serde_json::json!({
512 + "releaseTime": options.release_time,
513 + "remark": options.remark,
514 + "phased": options.phased,
515 + });
516 + if !dry_run {
517 + client.submit(&app_id, &options).await.map_err(err)?;
518 + }
519 + Ok(ReleaseAction {
520 dry_run,
521 app_id,
320 - kind: kind_name,
321 - lang: lang.to_string(),
322 - files,
522 + action: "submit",
523 + detail,
524 })
525 }
526
527 +/// Update a phased release, or with `to_full` turn it into a full release.
528 +pub async fn update_phased_release(
529 + client: &AppGalleryClient,
530 + app: &str,
531 + phased: PhasedRelease,
532 + to_full: bool,
533 + dry_run: bool,
534 +) -> Result<ReleaseAction, String> {
535 + if !to_full {
536 + phased.validate().map_err(err)?;
537 + }
538 + let app_id = resolve_app_id(client, app).await?;
539 + if !dry_run {
540 + client
541 + .update_phased_release(&app_id, &phased, to_full)
542 + .await
543 + .map_err(err)?;
544 + }
545 + Ok(ReleaseAction {
546 + dry_run,
547 + app_id,
548 + action: if to_full {
549 + "phased-release-to-full"
550 + } else {
551 + "phased-release-update"
552 + },
553 + detail: if to_full {
554 + serde_json::json!({})
555 + } else {
556 + serde_json::to_value(&phased).map_err(err)?
557 + },
558 + })
559 +}
560 +
561 +/// Report whether the app depends on Google Mobile Services.
562 +pub async fn set_gms_dependency(
563 + client: &AppGalleryClient,
564 + app: &str,
565 + needs_gms: bool,
566 + dry_run: bool,
567 +) -> Result<ReleaseAction, String> {
568 + let app_id = resolve_app_id(client, app).await?;
569 + if !dry_run {
570 + client
571 + .set_gms_dependency(&app_id, needs_gms)
572 + .await
573 + .map_err(err)?;
574 + }
575 + Ok(ReleaseAction {
576 + dry_run,
577 + app_id,
578 + action: "gms",
579 + detail: serde_json::json!({ "needGms": u8::from(needs_gms) }),
580 + })
581 +}
582 +
583 +/// Change when a version in Releasing state goes live.
584 +pub async fn update_release_time(
585 + client: &AppGalleryClient,
586 + app: &str,
587 + change: ReleaseTimeChange,
588 + dry_run: bool,
589 +) -> Result<ReleaseAction, String> {
590 + let app_id = resolve_app_id(client, app).await?;
591 + let detail = match &change {
592 + ReleaseTimeChange::Immediately => serde_json::json!({ "changeType": 2 }),
593 + ReleaseTimeChange::At(t) => serde_json::json!({ "changeType": 3, "releaseTime": t }),
594 + };
595 + if !dry_run {
596 + client
597 + .update_release_time(&app_id, &change)
598 + .await
599 + .map_err(err)?;
600 + }
601 + Ok(ReleaseAction {
602 + dry_run,
603 + app_id,
604 + action: "release-time",
605 + detail,
606 + })
607 +}
608 +
609 +/// Packages uploaded for the app.
610 +pub async fn package_list(
611 + client: &AppGalleryClient,
612 + app: &str,
613 + from: Option<u32>,
614 + max: Option<u32>,
615 +) -> Result<PackageList, String> {
616 + let app_id = resolve_app_id(client, app).await?;
617 + client.package_list(&app_id, from, max).await.map_err(err)
618 +}
619 +
620 +/// Parse status of uploaded packages (0 normal, 1 parsing, 2 failed).
621 +pub async fn package_status(
622 + client: &AppGalleryClient,
623 + app: &str,
624 + pkg_ids: &[String],
625 +) -> Result<Vec<PackageState>, String> {
626 + let app_id = resolve_app_id(client, app).await?;
627 + let ids: Vec<&str> = pkg_ids.iter().map(String::as_str).collect();
628 + client.package_status(&app_id, &ids).await.map_err(err)
629 +}
630 +
631 #[cfg(test)]
632 mod tests {
633 use super::*;
634
635 + #[test]
636 + fn file_checks_follow_the_type() {
637 + use std::path::PathBuf;
638 + let p = |names: &[&str]| names.iter().map(PathBuf::from).collect::<Vec<_>>();
639 + assert!(check_files(FileType::Icon, &p(&["a.png"])).is_ok());
640 + assert!(check_files(FileType::Icon, &p(&["a.png", "b.png"])).is_err());
641 + assert!(check_files(FileType::Package, &p(&["siGit.apk"])).is_ok());
642 + assert!(check_files(FileType::Package, &p(&["siGit.png"])).is_err());
643 + assert!(check_files(FileType::PromoVideo, &p(&["v.mp4", "poster.png"])).is_ok());
644 + assert!(check_files(FileType::IntroVideo, &p(&["v.mp4"])).is_err());
645 + assert!(check_files(FileType::ElectronicCertificate, &p(&["c.pdf"])).is_ok());
646 + let eleven: Vec<String> = (0..11).map(|i| format!("{i}.png")).collect();
647 + let eleven: Vec<&str> = eleven.iter().map(String::as_str).collect();
648 + assert!(check_files(FileType::Screenshots, &p(&eleven)).is_err());
649 + }
650 +
651 + #[test]
652 + fn lost_text_spots_fields_that_were_cleared() {
653 + let before = LanguageFields {
654 + lang: "en-US".into(),
655 + app_desc: Some("d".into()),
656 + ..Default::default()
657 + };
658 + let cleared = LanguageInfo {
659 + app_desc: Some(String::new()),
660 + ..Default::default()
661 + };
662 + let kept = LanguageInfo {
663 + app_desc: Some("d".into()),
664 + ..Default::default()
665 + };
666 + assert!(lost_text(&before, &cleared));
667 + assert!(!lost_text(&before, &kept));
668 + }
669 +
670 + #[test]
671 + fn every_file_type_has_a_distinct_name() {
672 + let names: std::collections::HashSet<_> =
673 + FileType::ALL.iter().map(|t| file_type_name(*t)).collect();
674 + assert_eq!(names.len(), FileType::ALL.len());
675 + }
676 +
677 #[test]
678 fn only_png_and_jpeg_count_as_images() {
679 assert!(is_image(Path::new("a/icon.PNG")));
crates/mcp/src/lib.rs
+70 -1
@@ -72,7 +72,10 @@ macro_rules! ascapi_mcp_tools {
72 $beta_app_review_detail_get_name:literal,
73 $play_listing_list_name:literal,
74 $play_images_list_name:literal,
75 - $play_track_get_name:literal
75 + $play_track_get_name:literal,
76 + $appgallery_app_info_get_name:literal,
77 + $appgallery_package_list_name:literal,
78 + $appgallery_package_status_name:literal
79 ) => {
80 #[::rmcp::tool_router(router = ascapi_tool_router, vis = "pub(crate)")]
81 impl $server {
@@ -1041,6 +1044,72 @@ macro_rules! ascapi_mcp_tools {
1044 ::rmcp::model::ContentBlock::json(&value)?,
1045 ]))
1046 }
1047 +
1048 + #[::rmcp::tool(
1049 + name = $appgallery_app_info_get_name,
1050 + title = "Get AppGallery app info",
1051 + annotations(title = "Get AppGallery app info", read_only_hint = true, idempotent_hint = true),
1052 + description = "Purpose: read a Huawei AppGallery app's basic information (release state, default language, privacy link, countries, categories and more), its per-language listing text and assets, the reviewer's comment and any phased release. When to use vs siblings: use this for the listing; appgallery_package_list lists uploaded packages and appgallery_package_status says whether they parsed. Behavior: GET app-info, nothing changes. The app is a numeric app id or a package name, which is resolved through appid-list (a package is only known after its first APK upload). Prerequisites: an AppGallery Connect Service Account credential file (developer-level, with a role that may publish) at APPGALLERY_SERVICE_ACCOUNT_JSON_PATH or its contents in APPGALLERY_SERVICE_ACCOUNT_JSON; APPGALLERY_CLIENT_ID is optional. Failure modes: missing credentials return an invalid-request error naming what is absent; a non-zero AppGallery result code or HTTP error is returned verbatim. Limitations: read-only; changes go through the asc appgallery listings, info and files commands."
1053 + )]
1054 + async fn appgallery_app_info_get(
1055 + &self,
1056 + parameters: ::rmcp::handler::server::wrapper::Parameters<$crate::AppGalleryAppInfoRequest>,
1057 + ) -> ::std::result::Result<::rmcp::model::CallToolResult, ::rmcp::model::ErrorData> {
1058 + use ::smbcloud_ascapi_frontend::appgallery;
1059 + let client = appgallery::appgallery_client(None, None)
1060 + .map_err(|error| ::rmcp::model::ErrorData::invalid_request(error, None))?;
1061 + let request = parameters.0;
1062 + let value = appgallery::read_listings(&client, &request.app, request.lang.as_deref())
1063 + .await
1064 + .map_err(|error| ::rmcp::model::ErrorData::internal_error(error, None))?;
1065 + Ok(::rmcp::model::CallToolResult::success(vec![
1066 + ::rmcp::model::ContentBlock::json(&value)?,
1067 + ]))
1068 + }
1069 +
1070 + #[::rmcp::tool(
1071 + name = $appgallery_package_list_name,
1072 + title = "List AppGallery packages",
1073 + annotations(title = "List AppGallery packages", read_only_hint = true, idempotent_hint = true),
1074 + description = "Purpose: list the packages (APKs) uploaded for a Huawei AppGallery app with their package id, version code and name, size, upload time and SHA-256. When to use vs siblings: use this to find a package id for appgallery_package_status; appgallery_app_info_get reads the listing. Behavior: GET package-list, nothing changes; max is capped at 100. Prerequisites: an AppGallery Connect Service Account credential file (developer-level, with a role that may publish) at APPGALLERY_SERVICE_ACCOUNT_JSON_PATH or its contents in APPGALLERY_SERVICE_ACCOUNT_JSON; APPGALLERY_CLIENT_ID is optional. Failure modes: missing credentials return an invalid-request error naming what is absent; a non-zero AppGallery result code or HTTP error is returned verbatim. Limitations: read-only; uploading goes through asc appgallery files upload --type package."
1075 + )]
1076 + async fn appgallery_package_list(
1077 + &self,
1078 + parameters: ::rmcp::handler::server::wrapper::Parameters<$crate::AppGalleryPackageListRequest>,
1079 + ) -> ::std::result::Result<::rmcp::model::CallToolResult, ::rmcp::model::ErrorData> {
1080 + use ::smbcloud_ascapi_frontend::appgallery;
1081 + let client = appgallery::appgallery_client(None, None)
1082 + .map_err(|error| ::rmcp::model::ErrorData::invalid_request(error, None))?;
1083 + let request = parameters.0;
1084 + let value = appgallery::package_list(&client, &request.app, request.from, request.max)
1085 + .await
1086 + .map_err(|error| ::rmcp::model::ErrorData::internal_error(error, None))?;
1087 + Ok(::rmcp::model::CallToolResult::success(vec![
1088 + ::rmcp::model::ContentBlock::json(&value)?,
1089 + ]))
1090 + }
1091 +
1092 + #[::rmcp::tool(
1093 + name = $appgallery_package_status_name,
1094 + title = "Get AppGallery package status",
1095 + annotations(title = "Get AppGallery package status", read_only_hint = true, idempotent_hint = true),
1096 + description = "Purpose: say whether uploaded Huawei AppGallery packages parsed: successStatus 0 normal, 1 parsing, 2 failed (unusable). When to use vs siblings: call after an upload and before submitting; appgallery_package_list supplies the package ids. Behavior: GET package/compile/status, nothing changes. Prerequisites: an AppGallery Connect Service Account credential file (developer-level, with a role that may publish) at APPGALLERY_SERVICE_ACCOUNT_JSON_PATH or its contents in APPGALLERY_SERVICE_ACCOUNT_JSON; APPGALLERY_CLIENT_ID is optional. Failure modes: missing credentials return an invalid-request error naming what is absent; a non-zero AppGallery result code or HTTP error is returned verbatim. Limitations: read-only; packages parse asynchronously, so wait about two minutes after an upload."
1097 + )]
1098 + async fn appgallery_package_status(
1099 + &self,
1100 + parameters: ::rmcp::handler::server::wrapper::Parameters<$crate::AppGalleryPackageStatusRequest>,
1101 + ) -> ::std::result::Result<::rmcp::model::CallToolResult, ::rmcp::model::ErrorData> {
1102 + use ::smbcloud_ascapi_frontend::appgallery;
1103 + let client = appgallery::appgallery_client(None, None)
1104 + .map_err(|error| ::rmcp::model::ErrorData::invalid_request(error, None))?;
1105 + let request = parameters.0;
1106 + let value = appgallery::package_status(&client, &request.app, &request.pkg_ids)
1107 + .await
1108 + .map_err(|error| ::rmcp::model::ErrorData::internal_error(error, None))?;
1109 + Ok(::rmcp::model::CallToolResult::success(vec![
1110 + ::rmcp::model::ContentBlock::json(&value)?,
1111 + ]))
1112 + }
1113 }
1114 };
1115 }
crates/mcp/src/requests.rs
+29
@@ -300,3 +300,32 @@ pub struct PlayTrackGetRequest {
300 /// Track name: internal, alpha, beta or production.
301 pub track: String,
302 }
303 +
304 +#[derive(Debug, Clone, Deserialize, schemars::JsonSchema)]
305 +pub struct AppGalleryAppInfoRequest {
306 + /// AppGallery app id (digits) or Android package name.
307 + pub app: String,
308 + /// Language code such as en-US; every language when omitted.
309 + #[serde(default)]
310 + pub lang: Option<String>,
311 +}
312 +
313 +#[derive(Debug, Clone, Deserialize, schemars::JsonSchema)]
314 +pub struct AppGalleryPackageListRequest {
315 + /// AppGallery app id (digits) or Android package name.
316 + pub app: String,
317 + /// First record, from 1.
318 + #[serde(default)]
319 + pub from: Option<u32>,
320 + /// Number of packages, up to 100 (default 10).
321 + #[serde(default)]
322 + pub max: Option<u32>,
323 +}
324 +
325 +#[derive(Debug, Clone, Deserialize, schemars::JsonSchema)]
326 +pub struct AppGalleryPackageStatusRequest {
327 + /// AppGallery app id (digits) or Android package name.
328 + pub app: String,
329 + /// Package ids (pkgVersion) from appgallery_package_list.
330 + pub pkg_ids: Vec<String>,
331 +}
crates/mcp/src/server.rs
+8 -2
@@ -62,7 +62,10 @@ ascapi_mcp_tools!(
62 "beta_app_review_detail_get",
63 "play_listing_list",
64 "play_images_list",
65 - "play_track_get"
65 + "play_track_get",
66 + "appgallery_app_info_get",
67 + "appgallery_package_list",
68 + "appgallery_package_status"
69 );
70
71 #[rmcp::tool_handler(router = Self::ascapi_tool_router())]
@@ -111,7 +114,7 @@ mod tests {
114 /// The canonical tool names. Adding or renaming one is a
115 /// public-contract change, and this list is what makes that
116 /// deliberate rather than accidental.
114 - const CANONICAL_TOOL_NAMES: [&str; 34] = [
117 + const CANONICAL_TOOL_NAMES: [&str; 37] = [
118 "app_list",
119 "app_get",
120 "app_update",
@@ -146,6 +149,9 @@ mod tests {
149 "play_listing_list",
150 "play_images_list",
151 "play_track_get",
152 + "appgallery_app_info_get",
153 + "appgallery_package_list",
154 + "appgallery_package_status",
155 ];
156
157 /// Never a tool, at any point, for any caller.