Read-only mirror of github.com/smbcloudXYZ/smbcloud-ascapi.
Mirrored from https://github.com/smbcloudXYZ/smbcloud-ascapi.git
Synced Nov 25, 09:15 UTC
Add asc appgallery listings commands
asc appgallery app-id, listings list and listings update read and change per-language listing text through a new frontend module. Update checks the documented limits, supports --dry-run, and reads the language back to confirm the change. The app argument is a numeric app id or a package name, which is resolved through appid-list. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Seto Elkahfi committed
Oct 27, 2026 at 15:23 UTC
a58aae97b03ed044c79bf8aad135c3d9a83bed1c
9 files changed
+368
-7
.agents/AGENTS.md
+13
@@ -74,6 +74,19 @@ stale `AuthKey_<id>.p8` and fail with a 401, and `--auth-string` would put
74
the key in the process table. Upload is CLI-only, because a tool call that
75
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
+There are no MCP tools for it yet.
89
+
90
## Git branching workflow
91
92
Branches flow in one direction: `main` ← `development` ← feature branch.
Cargo.lock
+2
@@ -1791,6 +1791,7 @@ dependencies = [
1791
"flate2",
1792
"serde",
1793
"serde_json",
1794
+ "smbcloud-ascapi-appgallery",
1795
"smbcloud-ascapi-aso",
1796
"smbcloud-ascapi-core",
1797
"smbcloud-ascapi-frontend",
@@ -1822,6 +1823,7 @@ dependencies = [
1823
"serde",
1824
"serde_json",
1825
"sha2",
1826
+ "smbcloud-ascapi-appgallery",
1827
"smbcloud-ascapi-aso",
1828
"smbcloud-ascapi-core",
1829
"smbcloud-ascapi-play",
README.md
+20
-2
@@ -2,13 +2,14 @@
2
3
`smbcloud-ascapi` is the app stores coolest API.
4
5
-Eight crates, split by domain and layered so neither front end can drift
5
+Nine crates, split by domain and layered so neither front end can drift
6
from the other:
7
8
| Crate | What it is |
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` |
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 |
@@ -17,7 +18,7 @@ from the other:
18
| `smbcloud-ascapi-mcp` | The MCP contract and stdio server |
19
| `smbcloud-ascapi-cli` | The `asc` binary: clap command tree, plus `--mcp` |
20
20
-`aso`, `play`, `pricing`, `signing` and `reports` know nothing about each other, and neither knows
21
+`aso`, `play`, `appgallery`, `pricing`, `signing` and `reports` know nothing about each other, and neither knows
22
anything about the front ends. Each adds its calls to
23
`smbcloud_ascapi_core::Client` as **extension traits**, since Rust only
24
allows inherent impls in the crate that defines a type:
@@ -42,6 +43,23 @@ The CLI signs requests with an App Store Connect API key:
43
With `--mcp`, credentials are resolved on each tool call, so the server can
44
list its tools before they are configured.
45
46
+## AppGallery credentials
47
+
48
+`asc appgallery` uses an AppGallery Connect Service Account (developer-level,
49
+with a publishing role), not the App Store Connect key:
50
+
51
+| Flag | Environment variable | Notes |
52
+| --- | --- | --- |
53
+| `--service-account` | `APPGALLERY_SERVICE_ACCOUNT_JSON_PATH` | The `*private.json` file; or its contents in `APPGALLERY_SERVICE_ACCOUNT_JSON`. |
54
+| `--client-id` | `APPGALLERY_CLIENT_ID` | Optional `client_id` header. |
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
+```
62
+
63
## Copyright
64
65
© 2026 PT Sigit Mitra Bangun ([smbCloud](https://smbcloud.xyz)).
crates/appgallery/src/publish.rs
+4
-4
@@ -41,7 +41,7 @@ impl RetCode {
41
}
42
43
/// App basic information: the fields listing work reads.
44
-#[derive(Debug, Clone, Default, Deserialize)]
44
+#[derive(Debug, Clone, Default, Deserialize, Serialize)]
45
#[serde(rename_all = "camelCase")]
46
pub struct AppInfo {
47
/// 0 released, 1 rejected, 3 releasing, 4 reviewing, 7 draft, and so on.
@@ -66,7 +66,7 @@ pub struct LanguageInfo {
66
pub icon: Option<String>,
67
}
68
69
-#[derive(Debug, Clone, Deserialize)]
69
+#[derive(Debug, Clone, Deserialize, Serialize)]
70
#[serde(rename_all = "camelCase")]
71
pub struct AppInfoResponse {
72
pub app_info: Option<AppInfo>,
@@ -76,7 +76,7 @@ pub struct AppInfoResponse {
76
pub languages: Vec<LanguageInfo>,
77
}
78
79
-#[derive(Debug, Clone, Deserialize)]
79
+#[derive(Debug, Clone, Deserialize, Serialize)]
80
#[serde(rename_all = "camelCase")]
81
pub struct AuditInfo {
82
pub audit_opinion: Option<String>,
@@ -142,7 +142,7 @@ struct AppIdEnvelope {
142
appids: Vec<AppIdPair>,
143
}
144
145
-#[derive(Debug, Clone, Deserialize)]
145
+#[derive(Debug, Clone, Deserialize, Serialize)]
146
pub struct AppIdPair {
147
/// The app name.
148
pub key: String,
crates/cli/Cargo.toml
+1
@@ -22,6 +22,7 @@ serde = { workspace = true }
22
serde_json = { workspace = true }
23
smbcloud-ascapi-aso = { workspace = true }
24
smbcloud-ascapi-core = { workspace = true }
25
+smbcloud-ascapi-appgallery = { workspace = true }
26
smbcloud-ascapi-play = { workspace = true }
27
smbcloud-ascapi-pricing = { workspace = true }
28
smbcloud-ascapi-signing = { workspace = true }
crates/cli/src/main.rs
+152
-1
@@ -1,5 +1,6 @@
1
use anyhow::{Context, Result};
2
use clap::{Parser, Subcommand, ValueEnum};
3
+use smbcloud_ascapi_appgallery::LanguageFields as AppGalleryLanguageFields;
4
use smbcloud_ascapi_aso::app::AppUpdateAttributes;
5
use smbcloud_ascapi_aso::app_info_localization::{
6
AppInfoLocalizationCreateAttributes, AppInfoLocalizationUpdateAttributes,
@@ -95,6 +96,63 @@ enum PlayCommand {
96
},
97
}
98
99
+// `Listings` carries the nested update command with its many text flags; boxing
100
+// a clap subcommand field is not possible.
101
+#[allow(clippy::large_enum_variant)]
102
+#[derive(Subcommand)]
103
+enum AppGalleryCommand {
104
+ /// Localized listing text: name, description, brief and release notes.
105
+ Listings {
106
+ #[command(subcommand)]
107
+ command: AppGalleryListingsCommand,
108
+ },
109
+ /// Look up the AppGallery app id for a package name.
110
+ AppId { package: String },
111
+}
112
+
113
+#[derive(Subcommand)]
114
+enum AppGalleryListingsCommand {
115
+ /// App info and every language's text, or one language's. `APP` is the
116
+ /// numeric app id or the package name.
117
+ List {
118
+ app: String,
119
+ #[arg(long)]
120
+ lang: Option<String>,
121
+ },
122
+ /// Update one language's text (or add the language), then read it back.
123
+ /// With `--dry-run` nothing is sent.
124
+ Update {
125
+ app: String,
126
+ /// Language code such as en-US, zh-CN or id.
127
+ #[arg(long)]
128
+ lang: String,
129
+ /// App name, up to 64 characters (required for a new language).
130
+ #[arg(long, conflicts_with = "name_file")]
131
+ name: Option<String>,
132
+ #[arg(long)]
133
+ name_file: Option<PathBuf>,
134
+ /// Full description, up to 8000 characters.
135
+ #[arg(long, conflicts_with = "description_file")]
136
+ description: Option<String>,
137
+ /// Read the description from a UTF-8 file; one trailing newline is dropped.
138
+ #[arg(long)]
139
+ description_file: Option<PathBuf>,
140
+ /// Brief introduction, up to 80 characters.
141
+ #[arg(long, conflicts_with = "brief_file")]
142
+ brief: Option<String>,
143
+ #[arg(long)]
144
+ brief_file: Option<PathBuf>,
145
+ /// Release notes, up to 500 characters.
146
+ #[arg(long, conflicts_with = "release_notes_file")]
147
+ release_notes: Option<String>,
148
+ #[arg(long)]
149
+ release_notes_file: Option<PathBuf>,
150
+ /// 1 for the entire network (default) or 3 for a phased release.
151
+ #[arg(long, value_parser = clap::value_parser!(u8).range(1..=3))]
152
+ release_type: Option<u8>,
153
+ },
154
+}
155
+
156
#[derive(Subcommand)]
157
enum PlayListingsCommand {
158
/// Every localized listing of an app.
@@ -204,6 +262,22 @@ enum PlayTracksCommand {
262
263
#[derive(Subcommand)]
264
enum Command {
265
+ /// Huawei AppGallery listing text. Uses an AppGallery Connect Service
266
+ /// Account, not the App Store Connect key.
267
+ #[command(name = "appgallery")]
268
+ AppGallery {
269
+ /// Path to the Service Account credential file (`*private.json`).
270
+ /// Falls back to `APPGALLERY_SERVICE_ACCOUNT_JSON_PATH`, then to the
271
+ /// contents in `APPGALLERY_SERVICE_ACCOUNT_JSON`.
272
+ #[arg(long, global = true)]
273
+ service_account: Option<PathBuf>,
274
+ /// Sent as the `client_id` header when set. Falls back to
275
+ /// `APPGALLERY_CLIENT_ID`.
276
+ #[arg(long, global = true)]
277
+ client_id: Option<String>,
278
+ #[command(subcommand)]
279
+ command: AppGalleryCommand,
280
+ },
281
/// Google Play store listings: text, images, and release notes. Uses a
282
/// Play service account, not the App Store Connect key.
283
Play {
@@ -297,6 +371,66 @@ enum Command {
371
},
372
}
373
374
+async fn run_appgallery(
375
+ service_account: Option<&std::path::Path>,
376
+ client_id: Option<&str>,
377
+ command: AppGalleryCommand,
378
+ dry_run: bool,
379
+) -> Result<()> {
380
+ use smbcloud_ascapi_frontend::appgallery;
381
+ let client = appgallery::appgallery_client(service_account, client_id)
382
+ .map_err(|e| anyhow::anyhow!(e))?;
383
+ let fail = |e: String| anyhow::anyhow!(e);
384
+ match command {
385
+ AppGalleryCommand::AppId { package } => print_json(
386
+ &client
387
+ .app_ids_for_packages(&[package.as_str()])
388
+ .await
389
+ .map_err(|e| anyhow::anyhow!(e))?,
390
+ ),
391
+ AppGalleryCommand::Listings { command } => match command {
392
+ AppGalleryListingsCommand::List { app, lang } => print_json(
393
+ &appgallery::read_listings(&client, &app, lang.as_deref())
394
+ .await
395
+ .map_err(fail)?,
396
+ ),
397
+ AppGalleryListingsCommand::Update {
398
+ app,
399
+ lang,
400
+ name,
401
+ name_file,
402
+ description,
403
+ description_file,
404
+ brief,
405
+ brief_file,
406
+ release_notes,
407
+ release_notes_file,
408
+ release_type,
409
+ } => {
410
+ let fields = AppGalleryLanguageFields {
411
+ lang,
412
+ app_name: text_arg(name, name_file, "--name-file")?,
413
+ app_desc: text_arg(description, description_file, "--description-file")?,
414
+ brief_info: text_arg(brief, brief_file, "--brief-file")?,
415
+ new_features: text_arg(
416
+ release_notes,
417
+ release_notes_file,
418
+ "--release-notes-file",
419
+ )?,
420
+ };
421
+ let result =
422
+ appgallery::update_language(&client, &app, fields, release_type, dry_run)
423
+ .await
424
+ .map_err(fail)?;
425
+ if result.dry_run {
426
+ println!("# dry run: nothing was sent; body that would be sent:");
427
+ }
428
+ print_json(&result)
429
+ }
430
+ },
431
+ }
432
+}
433
+
434
async fn run_play(
435
service_account: Option<&std::path::Path>,
436
command: PlayCommand,
@@ -1482,6 +1616,21 @@ async fn main() -> Result<()> {
1616
return smbcloud_ascapi_mcp::serve().await;
1617
}
1618
1619
+ if let Some(Command::AppGallery {
1620
+ service_account,
1621
+ client_id,
1622
+ command,
1623
+ }) = cli.command
1624
+ {
1625
+ return run_appgallery(
1626
+ service_account.as_deref(),
1627
+ client_id.as_deref(),
1628
+ command,
1629
+ cli.dry_run,
1630
+ )
1631
+ .await;
1632
+ }
1633
+
1634
if let Some(Command::Play {
1635
play_service_account,
1636
command,
@@ -1521,7 +1670,9 @@ async fn main() -> Result<()> {
1670
};
1671
1672
match command {
1524
- Command::Play { .. } => unreachable!("handled before App Store Connect credentials"),
1673
+ Command::AppGallery { .. } | Command::Play { .. } => {
1674
+ unreachable!("handled before App Store Connect credentials")
1675
+ }
1676
Command::Apps { command } => run_apps(&client, &altool_auth, command, cli.dry_run).await,
1677
Command::BundleIds { command } => run_bundle_ids(&client, command, cli.dry_run).await,
1678
Command::AppStoreVersions { command } => {
crates/frontend/Cargo.toml
+1
@@ -17,6 +17,7 @@ schemars = { workspace = true }
17
serde = { workspace = true, features = ["derive"] }
18
serde_json = { workspace = true }
19
sha2 = "0.10"
20
+smbcloud-ascapi-appgallery = { workspace = true }
21
smbcloud-ascapi-aso = { workspace = true }
22
smbcloud-ascapi-core = { workspace = true }
23
smbcloud-ascapi-play = { workspace = true }
crates/frontend/src/appgallery.rs
new
+174
@@ -0,0 +1,174 @@
1
+//! Huawei AppGallery listing operations shared by `asc appgallery` and the
2
+//! MCP tools.
3
+
4
+use std::path::Path;
5
+
6
+use serde::Serialize;
7
+use smbcloud_ascapi_appgallery::{
8
+ AppGalleryClient, AppInfoResponse, LanguageFields, LanguageInfo, ServiceAccount,
9
+};
10
+
11
+/// Resolve the AppGallery client. `path` wins; then
12
+/// `APPGALLERY_SERVICE_ACCOUNT_JSON_PATH`; then the credential contents inline
13
+/// in `APPGALLERY_SERVICE_ACCOUNT_JSON`. `APPGALLERY_CLIENT_ID` (or
14
+/// `client_id`) adds the `client_id` header. Per call, so an unconfigured MCP
15
+/// server still lists its tools. The private key never appears in an error.
16
+pub fn appgallery_client(
17
+ path: Option<&Path>,
18
+ client_id: Option<&str>,
19
+) -> Result<AppGalleryClient, String> {
20
+ let account = if let Some(path) = path {
21
+ ServiceAccount::from_json_file(path)
22
+ } else if let Ok(path) = std::env::var("APPGALLERY_SERVICE_ACCOUNT_JSON_PATH") {
23
+ ServiceAccount::from_json_file(path)
24
+ } else if let Ok(json) = std::env::var("APPGALLERY_SERVICE_ACCOUNT_JSON") {
25
+ ServiceAccount::from_json(&json)
26
+ } else {
27
+ return Err("no AppGallery credentials: pass --service-account, or set \
28
+ APPGALLERY_SERVICE_ACCOUNT_JSON_PATH (or APPGALLERY_SERVICE_ACCOUNT_JSON)"
29
+ .to_string());
30
+ }
31
+ .map_err(|e| e.to_string())?;
32
+ let client = AppGalleryClient::new(account);
33
+ let client_id = client_id
34
+ .map(str::to_string)
35
+ .or_else(|| std::env::var("APPGALLERY_CLIENT_ID").ok());
36
+ Ok(match client_id {
37
+ Some(id) if !id.is_empty() => client.with_client_id(id),
38
+ _ => client,
39
+ })
40
+}
41
+
42
+fn err(error: impl std::fmt::Display) -> String {
43
+ error.to_string()
44
+}
45
+
46
+/// An app id is all digits; anything else is taken as a package name and
47
+/// looked up.
48
+pub async fn resolve_app_id(client: &AppGalleryClient, app: &str) -> Result<String, String> {
49
+ if !app.is_empty() && app.bytes().all(|b| b.is_ascii_digit()) {
50
+ return Ok(app.to_string());
51
+ }
52
+ let ids = client.app_ids_for_packages(&[app]).await.map_err(err)?;
53
+ match ids.as_slice() {
54
+ [one] => Ok(one.value.clone()),
55
+ [] => Err(format!("no AppGallery app found for package {app:?}")),
56
+ _ => Err(format!("more than one app matches package {app:?}")),
57
+ }
58
+}
59
+
60
+/// App info with every language's text, or one language's.
61
+pub async fn read_listings(
62
+ client: &AppGalleryClient,
63
+ app: &str,
64
+ lang: Option<&str>,
65
+) -> Result<AppInfoResponse, String> {
66
+ let app_id = resolve_app_id(client, app).await?;
67
+ client.app_info(&app_id, lang).await.map_err(err)
68
+}
69
+
70
+#[derive(Debug, Serialize)]
71
+pub struct LanguageUpdate {
72
+ pub dry_run: bool,
73
+ pub app_id: String,
74
+ pub sent: LanguageFields,
75
+ /// The language as it was before the change; `None` when it is new.
76
+ pub before: Option<LanguageInfo>,
77
+ /// Read back after the write; `None` on a dry run.
78
+ pub after: Option<LanguageInfo>,
79
+}
80
+
81
+fn differs(sent: &LanguageFields, stored: &LanguageInfo) -> Vec<&'static str> {
82
+ let mut wrong = Vec::new();
83
+ let mut check = |name: &'static str, want: &Option<String>, got: &Option<String>| {
84
+ if want.is_some() && want != got {
85
+ wrong.push(name);
86
+ }
87
+ };
88
+ check("appName", &sent.app_name, &stored.app_name);
89
+ check("appDesc", &sent.app_desc, &stored.app_desc);
90
+ check("briefInfo", &sent.brief_info, &stored.brief_info);
91
+ check("newFeatures", &sent.new_features, &stored.new_features);
92
+ wrong
93
+}
94
+
95
+/// Update (or add) one language's text, then read it back. With `dry_run`,
96
+/// nothing is sent: the result shows the body and the current text.
97
+pub async fn update_language(
98
+ client: &AppGalleryClient,
99
+ app: &str,
100
+ fields: LanguageFields,
101
+ release_type: Option<u8>,
102
+ dry_run: bool,
103
+) -> Result<LanguageUpdate, String> {
104
+ fields.validate().map_err(err)?;
105
+ if fields.app_name.is_none()
106
+ && fields.app_desc.is_none()
107
+ && fields.brief_info.is_none()
108
+ && fields.new_features.is_none()
109
+ {
110
+ return Err("nothing to update: pass at least one text field".to_string());
111
+ }
112
+ let app_id = resolve_app_id(client, app).await?;
113
+ let language_of = |info: AppInfoResponse| info.languages.into_iter().next();
114
+ let before = client
115
+ .app_info(&app_id, Some(&fields.lang))
116
+ .await
117
+ .ok()
118
+ .and_then(language_of);
119
+ if dry_run {
120
+ return Ok(LanguageUpdate {
121
+ dry_run,
122
+ app_id,
123
+ sent: fields,
124
+ before,
125
+ after: None,
126
+ });
127
+ }
128
+ client
129
+ .update_language_info(&app_id, &fields, release_type)
130
+ .await
131
+ .map_err(err)?;
132
+ let after = client
133
+ .app_info(&app_id, Some(&fields.lang))
134
+ .await
135
+ .map_err(err)?;
136
+ let stored = language_of(after)
137
+ .ok_or_else(|| "updated, but the language is missing on read-back".to_string())?;
138
+ let wrong = differs(&fields, &stored);
139
+ if !wrong.is_empty() {
140
+ return Err(format!(
141
+ "updated, but the read-back differs in: {}",
142
+ wrong.join(", ")
143
+ ));
144
+ }
145
+ Ok(LanguageUpdate {
146
+ dry_run,
147
+ app_id,
148
+ sent: fields,
149
+ before,
150
+ after: Some(stored),
151
+ })
152
+}
153
+
154
+#[cfg(test)]
155
+mod tests {
156
+ use super::*;
157
+
158
+ #[test]
159
+ fn differs_names_only_the_fields_that_were_sent_and_changed() {
160
+ let sent = LanguageFields {
161
+ lang: "en-US".into(),
162
+ app_name: Some("siGit".into()),
163
+ brief_info: Some("a".into()),
164
+ ..Default::default()
165
+ };
166
+ let stored = LanguageInfo {
167
+ app_name: Some("siGit".into()),
168
+ brief_info: Some("b".into()),
169
+ app_desc: Some("untouched".into()),
170
+ ..Default::default()
171
+ };
172
+ assert_eq!(differs(&sent, &stored), vec!["briefInfo"]);
173
+ }
174
+}
crates/frontend/src/lib.rs
+1
@@ -20,6 +20,7 @@
20
//! `profileContent`, and [`profiles::download_profile`] returns the path
21
//! it wrote instead.
22
23
+pub mod appgallery;
24
pub mod attach_build;
25
pub mod await_processing;
26
pub mod certificates;