@gpc-cli/api 1.0.26 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -549,6 +549,31 @@ function enhanceApiError(status, body) {
549
549
  ].join("\n")
550
550
  };
551
551
  }
552
+ if ((status === 403 || status === 400) && (errorMsg.includes("changes not sent for review") || errorMsg.includes("changesnotsentforreview") || errorMsg.includes("review") && errorMsg.includes("rejected"))) {
553
+ return {
554
+ code: "API_CHANGES_NOT_SENT_FOR_REVIEW",
555
+ message: "This app has a rejected update. The API requires explicit acknowledgement before committing changes.",
556
+ suggestion: [
557
+ "Add --changes-not-sent-for-review to your command:",
558
+ " gpc releases upload app.aab --track internal --changes-not-sent-for-review",
559
+ "",
560
+ "This applies your changes without sending them for review.",
561
+ "You must manually send for review from the Google Play Console when ready."
562
+ ].join("\n")
563
+ };
564
+ }
565
+ if (status === 400 && (errorMsg.includes("changes_already_in_review") || errorMsg.includes("already in review"))) {
566
+ return {
567
+ code: "API_CHANGES_ALREADY_IN_REVIEW",
568
+ message: "Changes are already in review. Committing this edit would cancel the existing review.",
569
+ suggestion: [
570
+ "Wait for the current review to complete, or re-run without --error-if-in-review",
571
+ "to cancel the existing review and submit new changes.",
572
+ "",
573
+ "To prevent accidental review cancellation in CI, keep --error-if-in-review."
574
+ ].join("\n")
575
+ };
576
+ }
552
577
  return void 0;
553
578
  }
554
579
  function mapStatusToError(status, body) {
@@ -1004,6 +1029,11 @@ function createRateLimiter(buckets) {
1004
1029
  }
1005
1030
 
1006
1031
  // src/client.ts
1032
+ var DEFAULT_REGIONS_VERSION = "2022/02";
1033
+ function applyMutationOptions(params, options) {
1034
+ if (options?.allowMissing) params["allowMissing"] = "true";
1035
+ if (options?.latencyTolerance) params["latencyTolerance"] = options.latencyTolerance;
1036
+ }
1007
1037
  async function autoRateLimit(limiter, path) {
1008
1038
  if (!limiter) return;
1009
1039
  const bucket = resolveBucket(path);
@@ -1050,8 +1080,15 @@ function createApiClient(options) {
1050
1080
  const { data } = await http.post(`/${packageName}/edits/${editId}:validate`);
1051
1081
  return data;
1052
1082
  },
1053
- async commit(packageName, editId) {
1054
- const { data } = await http.post(`/${packageName}/edits/${editId}:commit`);
1083
+ async commit(packageName, editId, options2) {
1084
+ let path = `/${packageName}/edits/${editId}:commit`;
1085
+ if (options2?.changesNotSentForReview || options2?.changesInReviewBehavior) {
1086
+ const params = new URLSearchParams();
1087
+ if (options2.changesNotSentForReview) params.set("changesNotSentForReview", "true");
1088
+ if (options2.changesInReviewBehavior) params.set("changesInReviewBehavior", options2.changesInReviewBehavior);
1089
+ path += `?${params.toString()}`;
1090
+ }
1091
+ const { data } = await http.post(path);
1055
1092
  return data;
1056
1093
  },
1057
1094
  async delete(packageName, editId) {
@@ -1085,9 +1122,13 @@ function createApiClient(options) {
1085
1122
  );
1086
1123
  return data.bundles;
1087
1124
  },
1088
- async upload(packageName, editId, filePath, uploadOptions) {
1125
+ async upload(packageName, editId, filePath, uploadOptions, deviceTierConfigId) {
1126
+ let bundlePath = `/${packageName}/edits/${editId}/bundles`;
1127
+ if (deviceTierConfigId) {
1128
+ bundlePath += `?${new URLSearchParams({ deviceTierConfigId }).toString()}`;
1129
+ }
1089
1130
  const { data } = await http.uploadResumable(
1090
- `/${packageName}/edits/${editId}/bundles`,
1131
+ bundlePath,
1091
1132
  filePath,
1092
1133
  "application/octet-stream",
1093
1134
  uploadOptions
@@ -1244,6 +1285,44 @@ function createApiClient(options) {
1244
1285
  return data.deleted || [];
1245
1286
  }
1246
1287
  },
1288
+ expansionFiles: {
1289
+ async get(packageName, editId, apkVersionCode, expansionFileType) {
1290
+ const { data } = await http.get(
1291
+ `/${packageName}/edits/${editId}/apks/${apkVersionCode}/expansionFiles/${expansionFileType}`
1292
+ );
1293
+ return data;
1294
+ },
1295
+ async update(packageName, editId, apkVersionCode, expansionFileType, body) {
1296
+ const { data } = await http.put(
1297
+ `/${packageName}/edits/${editId}/apks/${apkVersionCode}/expansionFiles/${expansionFileType}`,
1298
+ body
1299
+ );
1300
+ return data;
1301
+ },
1302
+ async patch(packageName, editId, apkVersionCode, expansionFileType, body) {
1303
+ const { data } = await http.patch(
1304
+ `/${packageName}/edits/${editId}/apks/${apkVersionCode}/expansionFiles/${expansionFileType}`,
1305
+ body
1306
+ );
1307
+ return data;
1308
+ },
1309
+ async upload(packageName, editId, apkVersionCode, expansionFileType, filePath) {
1310
+ const { data } = await http.upload(
1311
+ `/${packageName}/edits/${editId}/apks/${apkVersionCode}/expansionFiles/${expansionFileType}`,
1312
+ filePath,
1313
+ "application/octet-stream"
1314
+ );
1315
+ if (!data.expansionFile) {
1316
+ throw new PlayApiError(
1317
+ "Upload succeeded but no expansion file data returned",
1318
+ "API_EMPTY_RESPONSE",
1319
+ 200,
1320
+ "This is unexpected. Retry the upload or contact Google Play support if the issue persists."
1321
+ );
1322
+ }
1323
+ return data.expansionFile;
1324
+ }
1325
+ },
1247
1326
  countryAvailability: {
1248
1327
  async get(packageName, editId, track) {
1249
1328
  const { data } = await http.get(
@@ -1267,6 +1346,7 @@ function createApiClient(options) {
1267
1346
  const params = {};
1268
1347
  if (options2?.token) params["token"] = options2.token;
1269
1348
  if (options2?.maxResults) params["maxResults"] = String(options2.maxResults);
1349
+ if (options2?.startIndex !== void 0) params["startIndex"] = String(options2.startIndex);
1270
1350
  if (options2?.translationLanguage)
1271
1351
  params["translationLanguage"] = options2.translationLanguage;
1272
1352
  const hasParams = Object.keys(params).length > 0;
@@ -1311,18 +1391,19 @@ function createApiClient(options) {
1311
1391
  const { data } = await http.get(`/${packageName}/subscriptions/${productId}`);
1312
1392
  return data;
1313
1393
  },
1314
- async create(packageName, body, productId) {
1394
+ async create(packageName, body, productId, regionsVersion) {
1315
1395
  const params = {};
1316
1396
  if (productId) params["productId"] = productId;
1317
- params["regionsVersion.version"] = "2022/02";
1397
+ params["regionsVersion.version"] = regionsVersion || DEFAULT_REGIONS_VERSION;
1318
1398
  const path = `/${packageName}/subscriptions?${new URLSearchParams(params).toString()}`;
1319
1399
  const { data } = await http.post(path, body);
1320
1400
  return data;
1321
1401
  },
1322
- async update(packageName, productId, body, updateMask, regionsVersion) {
1402
+ async update(packageName, productId, body, updateMask, regionsVersion, options2) {
1323
1403
  const params = {};
1324
1404
  if (updateMask) params["updateMask"] = updateMask;
1325
- params["regionsVersion.version"] = regionsVersion || "2022/02";
1405
+ params["regionsVersion.version"] = regionsVersion || DEFAULT_REGIONS_VERSION;
1406
+ applyMutationOptions(params, options2);
1326
1407
  const path = `/${packageName}/subscriptions/${productId}?${new URLSearchParams(params).toString()}`;
1327
1408
  const { data } = await http.patch(path, body);
1328
1409
  return data;
@@ -1378,18 +1459,19 @@ function createApiClient(options) {
1378
1459
  );
1379
1460
  return data;
1380
1461
  },
1381
- async createOffer(packageName, productId, basePlanId, body, offerId) {
1462
+ async createOffer(packageName, productId, basePlanId, body, offerId, regionsVersion) {
1382
1463
  const params = {};
1383
1464
  if (offerId) params["offerId"] = offerId;
1384
- params["regionsVersion.version"] = "2022/02";
1465
+ params["regionsVersion.version"] = regionsVersion || DEFAULT_REGIONS_VERSION;
1385
1466
  const path = `/${packageName}/subscriptions/${productId}/basePlans/${basePlanId}/offers?${new URLSearchParams(params).toString()}`;
1386
1467
  const { data } = await http.post(path, body);
1387
1468
  return data;
1388
1469
  },
1389
- async updateOffer(packageName, productId, basePlanId, offerId, body, updateMask, regionsVersion) {
1470
+ async updateOffer(packageName, productId, basePlanId, offerId, body, updateMask, regionsVersion, options2) {
1390
1471
  const params = {};
1391
1472
  if (updateMask) params["updateMask"] = updateMask;
1392
- params["regionsVersion.version"] = regionsVersion || "2022/02";
1473
+ params["regionsVersion.version"] = regionsVersion || DEFAULT_REGIONS_VERSION;
1474
+ applyMutationOptions(params, options2);
1393
1475
  const path = `/${packageName}/subscriptions/${productId}/basePlans/${basePlanId}/offers/${offerId}?${new URLSearchParams(params).toString()}`;
1394
1476
  const { data } = await http.patch(path, body);
1395
1477
  return data;
@@ -1645,9 +1727,10 @@ function createApiClient(options) {
1645
1727
  }
1646
1728
  },
1647
1729
  deobfuscation: {
1648
- async upload(packageName, editId, versionCode, filePath) {
1730
+ async upload(packageName, editId, versionCode, filePath, fileType) {
1731
+ const deobType = fileType || "proguard";
1649
1732
  const { data } = await http.upload(
1650
- `/${packageName}/edits/${editId}/apks/${versionCode}/deobfuscationFiles/proguard`,
1733
+ `/${packageName}/edits/${editId}/apks/${versionCode}/deobfuscationFiles/${deobType}`,
1651
1734
  filePath,
1652
1735
  "application/octet-stream"
1653
1736
  );
@@ -1738,9 +1821,14 @@ function createApiClient(options) {
1738
1821
  }
1739
1822
  },
1740
1823
  oneTimeProducts: {
1741
- async list(packageName) {
1824
+ async list(packageName, options2) {
1825
+ const params = {};
1826
+ if (options2?.pageToken) params["pageToken"] = options2.pageToken;
1827
+ if (options2?.pageSize) params["pageSize"] = String(options2.pageSize);
1828
+ const hasParams = Object.keys(params).length > 0;
1742
1829
  const { data } = await http.get(
1743
- `/${packageName}/oneTimeProducts`
1830
+ `/${packageName}/oneTimeProducts`,
1831
+ hasParams ? params : void 0
1744
1832
  );
1745
1833
  return data;
1746
1834
  },
@@ -1750,18 +1838,19 @@ function createApiClient(options) {
1750
1838
  );
1751
1839
  return data;
1752
1840
  },
1753
- async create(packageName, body) {
1754
- const params = new URLSearchParams({ "regionsVersion.version": "2022/02" });
1841
+ async create(packageName, body, regionsVersion) {
1842
+ const params = new URLSearchParams({ "regionsVersion.version": regionsVersion || DEFAULT_REGIONS_VERSION });
1755
1843
  const { data } = await http.post(
1756
1844
  `/${packageName}/oneTimeProducts?${params.toString()}`,
1757
1845
  body
1758
1846
  );
1759
1847
  return data;
1760
1848
  },
1761
- async update(packageName, productId, body, updateMask, regionsVersion) {
1849
+ async update(packageName, productId, body, updateMask, regionsVersion, options2) {
1762
1850
  const params = {};
1763
1851
  if (updateMask) params["updateMask"] = updateMask;
1764
- params["regionsVersion.version"] = regionsVersion || "2022/02";
1852
+ params["regionsVersion.version"] = regionsVersion || DEFAULT_REGIONS_VERSION;
1853
+ applyMutationOptions(params, options2);
1765
1854
  const path = `/${packageName}/oneTimeProducts/${productId}?${new URLSearchParams(params).toString()}`;
1766
1855
  const { data } = await http.patch(path, body);
1767
1856
  return data;
@@ -1781,17 +1870,19 @@ function createApiClient(options) {
1781
1870
  );
1782
1871
  return data;
1783
1872
  },
1784
- async createOffer(packageName, productId, body) {
1873
+ async createOffer(packageName, productId, body, regionsVersion) {
1874
+ const params = new URLSearchParams({ "regionsVersion.version": regionsVersion || DEFAULT_REGIONS_VERSION });
1785
1875
  const { data } = await http.post(
1786
- `/${packageName}/oneTimeProducts/${productId}/offers`,
1876
+ `/${packageName}/oneTimeProducts/${productId}/offers?${params.toString()}`,
1787
1877
  body
1788
1878
  );
1789
1879
  return data;
1790
1880
  },
1791
- async updateOffer(packageName, productId, offerId, body, updateMask, regionsVersion) {
1881
+ async updateOffer(packageName, productId, offerId, body, updateMask, regionsVersion, options2) {
1792
1882
  const params = {};
1793
1883
  if (updateMask) params["updateMask"] = updateMask;
1794
- params["regionsVersion.version"] = regionsVersion || "2022/02";
1884
+ params["regionsVersion.version"] = regionsVersion || DEFAULT_REGIONS_VERSION;
1885
+ applyMutationOptions(params, options2);
1795
1886
  const path = `/${packageName}/oneTimeProducts/${productId}/offers/${offerId}?${new URLSearchParams(params).toString()}`;
1796
1887
  const { data } = await http.patch(path, body);
1797
1888
  return data;