@gpc-cli/api 1.0.27 → 1.0.29
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/README.md +72 -248
- package/dist/index.d.ts +129 -33
- package/dist/index.js +149 -63
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -91,7 +91,11 @@ async function resumableUpload(uploadUrl, filePath, contentType, ctx, options) {
|
|
|
91
91
|
try {
|
|
92
92
|
const serverOffset = await queryProgress(sessionUri, totalBytes, ctx);
|
|
93
93
|
if (serverOffset >= totalBytes) {
|
|
94
|
-
const completionResult = await fetchCompletionResponse(
|
|
94
|
+
const completionResult = await fetchCompletionResponse(
|
|
95
|
+
sessionUri,
|
|
96
|
+
totalBytes,
|
|
97
|
+
ctx
|
|
98
|
+
);
|
|
95
99
|
if (completionResult) {
|
|
96
100
|
result = completionResult;
|
|
97
101
|
break;
|
|
@@ -411,7 +415,7 @@ function resolveOption(explicit, envName, fallback) {
|
|
|
411
415
|
return explicit ?? envInt2(envName) ?? fallback;
|
|
412
416
|
}
|
|
413
417
|
function enhanceApiError(status, body) {
|
|
414
|
-
let errorMsg
|
|
418
|
+
let errorMsg;
|
|
415
419
|
try {
|
|
416
420
|
const parsed = JSON.parse(body);
|
|
417
421
|
errorMsg = parsed?.error?.message?.toLowerCase() ?? "";
|
|
@@ -974,15 +978,22 @@ var RATE_LIMIT_BUCKETS = {
|
|
|
974
978
|
purchases: { name: "purchases", maxTokens: 3e3, refillRate: 3e3, refillIntervalMs: 6e4 },
|
|
975
979
|
reviews: { name: "reviews", maxTokens: 3e3, refillRate: 3e3, refillIntervalMs: 6e4 },
|
|
976
980
|
reporting: { name: "reporting", maxTokens: 3e3, refillRate: 3e3, refillIntervalMs: 6e4 },
|
|
977
|
-
monetization: {
|
|
981
|
+
monetization: {
|
|
982
|
+
name: "monetization",
|
|
983
|
+
maxTokens: 3e3,
|
|
984
|
+
refillRate: 3e3,
|
|
985
|
+
refillIntervalMs: 6e4
|
|
986
|
+
},
|
|
978
987
|
default: { name: "default", maxTokens: 3e3, refillRate: 3e3, refillIntervalMs: 6e4 }
|
|
979
988
|
};
|
|
980
989
|
function resolveBucket(path) {
|
|
981
990
|
if (path.includes("/edits/") || path.includes("/edits:")) return "edits";
|
|
982
991
|
if (path.includes("/purchases/") || path.includes("/orders")) return "purchases";
|
|
983
992
|
if (path.includes("/reviews")) return "reviews";
|
|
984
|
-
if (path.includes("playdeveloperreporting") || path.includes("MetricSet") || path.includes("anomalies"))
|
|
985
|
-
|
|
993
|
+
if (path.includes("playdeveloperreporting") || path.includes("MetricSet") || path.includes("anomalies"))
|
|
994
|
+
return "reporting";
|
|
995
|
+
if (path.includes("/inappproducts") || path.includes("/oneTimeProducts") || path.includes("/subscriptions") || path.includes("/monetization"))
|
|
996
|
+
return "monetization";
|
|
986
997
|
return "default";
|
|
987
998
|
}
|
|
988
999
|
function createRateLimiter(buckets) {
|
|
@@ -1085,7 +1096,8 @@ function createApiClient(options) {
|
|
|
1085
1096
|
if (options2?.changesNotSentForReview || options2?.changesInReviewBehavior) {
|
|
1086
1097
|
const params = new URLSearchParams();
|
|
1087
1098
|
if (options2.changesNotSentForReview) params.set("changesNotSentForReview", "true");
|
|
1088
|
-
if (options2.changesInReviewBehavior)
|
|
1099
|
+
if (options2.changesInReviewBehavior)
|
|
1100
|
+
params.set("changesInReviewBehavior", options2.changesInReviewBehavior);
|
|
1089
1101
|
path += `?${params.toString()}`;
|
|
1090
1102
|
}
|
|
1091
1103
|
const { data } = await http.post(path);
|
|
@@ -1169,10 +1181,13 @@ function createApiClient(options) {
|
|
|
1169
1181
|
return data;
|
|
1170
1182
|
},
|
|
1171
1183
|
async patch(packageName, editId, track, release) {
|
|
1172
|
-
const { data } = await http.patch(
|
|
1173
|
-
track
|
|
1174
|
-
|
|
1175
|
-
|
|
1184
|
+
const { data } = await http.patch(
|
|
1185
|
+
`/${packageName}/edits/${editId}/tracks/${track}`,
|
|
1186
|
+
{
|
|
1187
|
+
track,
|
|
1188
|
+
releases: [release]
|
|
1189
|
+
}
|
|
1190
|
+
);
|
|
1176
1191
|
return data;
|
|
1177
1192
|
}
|
|
1178
1193
|
},
|
|
@@ -1186,9 +1201,7 @@ function createApiClient(options) {
|
|
|
1186
1201
|
},
|
|
1187
1202
|
apks: {
|
|
1188
1203
|
async list(packageName, editId) {
|
|
1189
|
-
const { data } = await http.get(
|
|
1190
|
-
`/${packageName}/edits/${editId}/apks`
|
|
1191
|
-
);
|
|
1204
|
+
const { data } = await http.get(`/${packageName}/edits/${editId}/apks`);
|
|
1192
1205
|
return data.apks || [];
|
|
1193
1206
|
},
|
|
1194
1207
|
async upload(packageName, editId, filePath, uploadOptions) {
|
|
@@ -1312,6 +1325,14 @@ function createApiClient(options) {
|
|
|
1312
1325
|
filePath,
|
|
1313
1326
|
"application/octet-stream"
|
|
1314
1327
|
);
|
|
1328
|
+
if (!data.expansionFile) {
|
|
1329
|
+
throw new PlayApiError(
|
|
1330
|
+
"Upload succeeded but no expansion file data returned",
|
|
1331
|
+
"API_EMPTY_RESPONSE",
|
|
1332
|
+
200,
|
|
1333
|
+
"This is unexpected. Retry the upload or contact Google Play support if the issue persists."
|
|
1334
|
+
);
|
|
1335
|
+
}
|
|
1315
1336
|
return data.expansionFile;
|
|
1316
1337
|
}
|
|
1317
1338
|
},
|
|
@@ -1439,6 +1460,13 @@ function createApiClient(options) {
|
|
|
1439
1460
|
);
|
|
1440
1461
|
return data;
|
|
1441
1462
|
},
|
|
1463
|
+
async batchMigratePrices(packageName, productId, body) {
|
|
1464
|
+
const { data } = await http.post(
|
|
1465
|
+
`/${packageName}/subscriptions/${productId}/basePlans:batchMigratePrices`,
|
|
1466
|
+
body
|
|
1467
|
+
);
|
|
1468
|
+
return data;
|
|
1469
|
+
},
|
|
1442
1470
|
async listOffers(packageName, productId, basePlanId) {
|
|
1443
1471
|
const { data } = await http.get(
|
|
1444
1472
|
`/${packageName}/subscriptions/${productId}/basePlans/${basePlanId}/offers`
|
|
@@ -1546,6 +1574,15 @@ function createApiClient(options) {
|
|
|
1546
1574
|
const { data } = await http.put(path, body);
|
|
1547
1575
|
return data;
|
|
1548
1576
|
},
|
|
1577
|
+
async patch(packageName, sku, body, options2) {
|
|
1578
|
+
const params = {};
|
|
1579
|
+
if (options2?.autoConvertMissingPrices) params["autoConvertMissingPrices"] = "true";
|
|
1580
|
+
if (options2?.latencyTolerance) params["latencyTolerance"] = options2.latencyTolerance;
|
|
1581
|
+
const hasParams = Object.keys(params).length > 0;
|
|
1582
|
+
const path = hasParams ? `/${packageName}/inappproducts/${sku}?${new URLSearchParams(params).toString()}` : `/${packageName}/inappproducts/${sku}`;
|
|
1583
|
+
const { data } = await http.patch(path, body);
|
|
1584
|
+
return data;
|
|
1585
|
+
},
|
|
1549
1586
|
async delete(packageName, sku) {
|
|
1550
1587
|
await http.delete(`/${packageName}/inappproducts/${sku}`);
|
|
1551
1588
|
},
|
|
@@ -1568,10 +1605,9 @@ function createApiClient(options) {
|
|
|
1568
1605
|
return data.inappproduct || [];
|
|
1569
1606
|
},
|
|
1570
1607
|
async batchDelete(packageName, skus) {
|
|
1571
|
-
await http.post(
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
);
|
|
1608
|
+
await http.post(`/${packageName}/inappproducts:batchDelete`, {
|
|
1609
|
+
requests: skus.map((sku) => ({ packageName, sku }))
|
|
1610
|
+
});
|
|
1575
1611
|
}
|
|
1576
1612
|
},
|
|
1577
1613
|
purchases: {
|
|
@@ -1629,14 +1665,8 @@ function createApiClient(options) {
|
|
|
1629
1665
|
async revokeSubscriptionV2(packageName, token) {
|
|
1630
1666
|
await http.post(`/${packageName}/purchases/subscriptionsv2/tokens/${token}:revoke`);
|
|
1631
1667
|
},
|
|
1632
|
-
async refundSubscriptionV2(packageName, token) {
|
|
1633
|
-
await http.post(`/${packageName}/purchases/subscriptionsv2/tokens/${token}:refund`);
|
|
1634
|
-
},
|
|
1635
1668
|
async cancelSubscriptionV2(packageName, token, body) {
|
|
1636
|
-
await http.post(
|
|
1637
|
-
`/${packageName}/purchases/subscriptionsv2/tokens/${token}:cancel`,
|
|
1638
|
-
body
|
|
1639
|
-
);
|
|
1669
|
+
await http.post(`/${packageName}/purchases/subscriptionsv2/tokens/${token}:cancel`, body);
|
|
1640
1670
|
},
|
|
1641
1671
|
async deferSubscriptionV2(packageName, token, body) {
|
|
1642
1672
|
const { data } = await http.post(
|
|
@@ -1656,7 +1686,8 @@ function createApiClient(options) {
|
|
|
1656
1686
|
if (options2?.startTime) params["startTime"] = options2.startTime;
|
|
1657
1687
|
if (options2?.endTime) params["endTime"] = options2.endTime;
|
|
1658
1688
|
if (options2?.type !== void 0) params["type"] = String(options2.type);
|
|
1659
|
-
if (options2?.includeQuantityBasedPartialRefund)
|
|
1689
|
+
if (options2?.includeQuantityBasedPartialRefund)
|
|
1690
|
+
params["includeQuantityBasedPartialRefund"] = "true";
|
|
1660
1691
|
if (options2?.maxResults) params["maxResults"] = String(options2.maxResults);
|
|
1661
1692
|
if (options2?.token) params["token"] = options2.token;
|
|
1662
1693
|
const hasParams = Object.keys(params).length > 0;
|
|
@@ -1669,9 +1700,7 @@ function createApiClient(options) {
|
|
|
1669
1700
|
},
|
|
1670
1701
|
orders: {
|
|
1671
1702
|
async get(packageName, orderId) {
|
|
1672
|
-
const { data } = await http.get(
|
|
1673
|
-
`/${packageName}/orders/${orderId}`
|
|
1674
|
-
);
|
|
1703
|
+
const { data } = await http.get(`/${packageName}/orders/${orderId}`);
|
|
1675
1704
|
return data;
|
|
1676
1705
|
},
|
|
1677
1706
|
async batchGet(packageName, orderIds) {
|
|
@@ -1716,6 +1745,13 @@ function createApiClient(options) {
|
|
|
1716
1745
|
testersData
|
|
1717
1746
|
);
|
|
1718
1747
|
return data;
|
|
1748
|
+
},
|
|
1749
|
+
async patch(packageName, editId, track, testersData) {
|
|
1750
|
+
const { data } = await http.patch(
|
|
1751
|
+
`/${packageName}/edits/${editId}/testers/${track}`,
|
|
1752
|
+
testersData
|
|
1753
|
+
);
|
|
1754
|
+
return data;
|
|
1719
1755
|
}
|
|
1720
1756
|
},
|
|
1721
1757
|
deobfuscation: {
|
|
@@ -1831,9 +1867,14 @@ function createApiClient(options) {
|
|
|
1831
1867
|
return data;
|
|
1832
1868
|
},
|
|
1833
1869
|
async create(packageName, body, regionsVersion) {
|
|
1834
|
-
const
|
|
1835
|
-
|
|
1836
|
-
|
|
1870
|
+
const productId = body.productId;
|
|
1871
|
+
if (!productId) throw new Error("productId is required to create a one-time product");
|
|
1872
|
+
const params = new URLSearchParams({
|
|
1873
|
+
"regionsVersion.version": regionsVersion || DEFAULT_REGIONS_VERSION,
|
|
1874
|
+
allowMissing: "true"
|
|
1875
|
+
});
|
|
1876
|
+
const { data } = await http.patch(
|
|
1877
|
+
`/${packageName}/oneTimeProducts/${productId}?${params.toString()}`,
|
|
1837
1878
|
body
|
|
1838
1879
|
);
|
|
1839
1880
|
return data;
|
|
@@ -1850,37 +1891,41 @@ function createApiClient(options) {
|
|
|
1850
1891
|
async delete(packageName, productId) {
|
|
1851
1892
|
await http.delete(`/${packageName}/oneTimeProducts/${productId}`);
|
|
1852
1893
|
},
|
|
1853
|
-
async listOffers(packageName, productId) {
|
|
1894
|
+
async listOffers(packageName, productId, purchaseOptionId = "-") {
|
|
1854
1895
|
const { data } = await http.get(
|
|
1855
|
-
`/${packageName}/oneTimeProducts/${productId}/offers`
|
|
1896
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers`
|
|
1856
1897
|
);
|
|
1857
1898
|
return data;
|
|
1858
1899
|
},
|
|
1859
|
-
async getOffer(packageName, productId, offerId) {
|
|
1900
|
+
async getOffer(packageName, productId, purchaseOptionId, offerId) {
|
|
1860
1901
|
const { data } = await http.get(
|
|
1861
|
-
`/${packageName}/oneTimeProducts/${productId}/offers/${offerId}`
|
|
1902
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers/${offerId}`
|
|
1862
1903
|
);
|
|
1863
1904
|
return data;
|
|
1864
1905
|
},
|
|
1865
|
-
async createOffer(packageName, productId, body, regionsVersion) {
|
|
1866
|
-
const params = new URLSearchParams({
|
|
1906
|
+
async createOffer(packageName, productId, purchaseOptionId, body, regionsVersion) {
|
|
1907
|
+
const params = new URLSearchParams({
|
|
1908
|
+
"regionsVersion.version": regionsVersion || DEFAULT_REGIONS_VERSION
|
|
1909
|
+
});
|
|
1867
1910
|
const { data } = await http.post(
|
|
1868
|
-
`/${packageName}/oneTimeProducts/${productId}/offers?${params.toString()}`,
|
|
1911
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers?${params.toString()}`,
|
|
1869
1912
|
body
|
|
1870
1913
|
);
|
|
1871
1914
|
return data;
|
|
1872
1915
|
},
|
|
1873
|
-
async updateOffer(packageName, productId, offerId, body, updateMask, regionsVersion, options2) {
|
|
1916
|
+
async updateOffer(packageName, productId, purchaseOptionId, offerId, body, updateMask, regionsVersion, options2) {
|
|
1874
1917
|
const params = {};
|
|
1875
1918
|
if (updateMask) params["updateMask"] = updateMask;
|
|
1876
1919
|
params["regionsVersion.version"] = regionsVersion || DEFAULT_REGIONS_VERSION;
|
|
1877
1920
|
applyMutationOptions(params, options2);
|
|
1878
|
-
const path = `/${packageName}/oneTimeProducts/${productId}/offers/${offerId}?${new URLSearchParams(params).toString()}`;
|
|
1921
|
+
const path = `/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers/${offerId}?${new URLSearchParams(params).toString()}`;
|
|
1879
1922
|
const { data } = await http.patch(path, body);
|
|
1880
1923
|
return data;
|
|
1881
1924
|
},
|
|
1882
|
-
async deleteOffer(packageName, productId, offerId) {
|
|
1883
|
-
await http.delete(
|
|
1925
|
+
async deleteOffer(packageName, productId, purchaseOptionId, offerId) {
|
|
1926
|
+
await http.delete(
|
|
1927
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers/${offerId}`
|
|
1928
|
+
);
|
|
1884
1929
|
},
|
|
1885
1930
|
async batchGet(packageName, productIds) {
|
|
1886
1931
|
const params = productIds.map((id) => `productIds=${encodeURIComponent(id)}`).join("&");
|
|
@@ -1897,40 +1942,59 @@ function createApiClient(options) {
|
|
|
1897
1942
|
return data;
|
|
1898
1943
|
},
|
|
1899
1944
|
async batchDelete(packageName, productIds) {
|
|
1945
|
+
await http.post(`/${packageName}/oneTimeProducts:batchDelete`, {
|
|
1946
|
+
requests: productIds.map((id) => ({ productId: id }))
|
|
1947
|
+
});
|
|
1948
|
+
},
|
|
1949
|
+
// Purchase option batch operations
|
|
1950
|
+
async batchDeletePurchaseOptions(packageName, productId, requests) {
|
|
1900
1951
|
await http.post(
|
|
1901
|
-
`/${packageName}/oneTimeProducts:batchDelete`,
|
|
1902
|
-
{ requests
|
|
1952
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions:batchDelete`,
|
|
1953
|
+
{ requests }
|
|
1903
1954
|
);
|
|
1904
|
-
}
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
`/${packageName}/purchaseOptions`
|
|
1955
|
+
},
|
|
1956
|
+
async batchUpdatePurchaseOptionStates(packageName, productId, requests) {
|
|
1957
|
+
const { data } = await http.post(
|
|
1958
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions:batchUpdateStates`,
|
|
1959
|
+
{ requests }
|
|
1910
1960
|
);
|
|
1911
1961
|
return data;
|
|
1912
1962
|
},
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1963
|
+
// Offer batch operations
|
|
1964
|
+
async cancelOffer(packageName, productId, purchaseOptionId, offerId, latencyTolerance) {
|
|
1965
|
+
const body = latencyTolerance ? { latencyTolerance } : {};
|
|
1966
|
+
const { data } = await http.post(
|
|
1967
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers/${offerId}:cancel`,
|
|
1968
|
+
body
|
|
1916
1969
|
);
|
|
1917
1970
|
return data;
|
|
1918
1971
|
},
|
|
1919
|
-
async
|
|
1920
|
-
const { data } = await http.post(
|
|
1972
|
+
async batchGetOffers(packageName, productId, purchaseOptionId, requests) {
|
|
1973
|
+
const { data } = await http.post(
|
|
1974
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers:batchGet`,
|
|
1975
|
+
{ requests }
|
|
1976
|
+
);
|
|
1921
1977
|
return data;
|
|
1922
1978
|
},
|
|
1923
|
-
async
|
|
1979
|
+
async batchUpdateOffers(packageName, productId, purchaseOptionId, requests) {
|
|
1924
1980
|
const { data } = await http.post(
|
|
1925
|
-
`/${packageName}/purchaseOptions/${purchaseOptionId}:
|
|
1981
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers:batchUpdate`,
|
|
1982
|
+
{ requests }
|
|
1926
1983
|
);
|
|
1927
1984
|
return data;
|
|
1928
1985
|
},
|
|
1929
|
-
async
|
|
1986
|
+
async batchUpdateOfferStates(packageName, productId, purchaseOptionId, requests) {
|
|
1930
1987
|
const { data } = await http.post(
|
|
1931
|
-
`/${packageName}/purchaseOptions/${purchaseOptionId}:
|
|
1988
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers:batchUpdateStates`,
|
|
1989
|
+
{ requests }
|
|
1932
1990
|
);
|
|
1933
1991
|
return data;
|
|
1992
|
+
},
|
|
1993
|
+
async batchDeleteOffers(packageName, productId, purchaseOptionId, requests) {
|
|
1994
|
+
await http.post(
|
|
1995
|
+
`/${packageName}/oneTimeProducts/${productId}/purchaseOptions/${purchaseOptionId}/offers:batchDelete`,
|
|
1996
|
+
{ requests }
|
|
1997
|
+
);
|
|
1934
1998
|
}
|
|
1935
1999
|
},
|
|
1936
2000
|
internalAppSharing: {
|
|
@@ -1961,6 +2025,32 @@ function createApiClient(options) {
|
|
|
1961
2025
|
async download(packageName, versionCode, id) {
|
|
1962
2026
|
return http.download(`/${packageName}/generatedApks/${versionCode}/download/${id}`);
|
|
1963
2027
|
}
|
|
2028
|
+
},
|
|
2029
|
+
systemApks: {
|
|
2030
|
+
async create(packageName, versionCode, variant) {
|
|
2031
|
+
const { data } = await http.post(
|
|
2032
|
+
`/${packageName}/systemApks/${versionCode}/variants`,
|
|
2033
|
+
variant
|
|
2034
|
+
);
|
|
2035
|
+
return data;
|
|
2036
|
+
},
|
|
2037
|
+
async list(packageName, versionCode) {
|
|
2038
|
+
const { data } = await http.get(
|
|
2039
|
+
`/${packageName}/systemApks/${versionCode}/variants`
|
|
2040
|
+
);
|
|
2041
|
+
return data;
|
|
2042
|
+
},
|
|
2043
|
+
async get(packageName, versionCode, variantId) {
|
|
2044
|
+
const { data } = await http.get(
|
|
2045
|
+
`/${packageName}/systemApks/${versionCode}/variants/${variantId}`
|
|
2046
|
+
);
|
|
2047
|
+
return data;
|
|
2048
|
+
},
|
|
2049
|
+
async download(packageName, versionCode, variantId) {
|
|
2050
|
+
return http.download(
|
|
2051
|
+
`/${packageName}/systemApks/${versionCode}/variants/${variantId}:download`
|
|
2052
|
+
);
|
|
2053
|
+
}
|
|
1964
2054
|
}
|
|
1965
2055
|
};
|
|
1966
2056
|
}
|
|
@@ -2027,10 +2117,6 @@ function createUsersClient(options) {
|
|
|
2027
2117
|
);
|
|
2028
2118
|
return data;
|
|
2029
2119
|
},
|
|
2030
|
-
async get(developerId, userId) {
|
|
2031
|
-
const { data } = await http.get(`/${developerId}/users/${userId}`);
|
|
2032
|
-
return data;
|
|
2033
|
-
},
|
|
2034
2120
|
async create(developerId, user) {
|
|
2035
2121
|
const { data } = await http.post(`/${developerId}/users`, user);
|
|
2036
2122
|
return data;
|