@proxyrequest/sdk 2.0.0 → 2.1.0

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/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ All notable changes to this project are documented here. The format follows [Kee
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ### Fixed
8
+
9
+ - Keep the exported `SDK_VERSION` synchronized with the package version and verify it in the package smoke test.
10
+
11
+ ## [2.1.0] - 2026-09-17
12
+
13
+ - Add atomic per-package data reset with typed requests, response metadata, and idempotent retries.
14
+ - Refresh the public API contract and document root balances versus child allocations.
15
+
7
16
  ## [2.0.0] - 2026-09-16
8
17
 
9
18
  ### Changed
package/README.md CHANGED
@@ -84,8 +84,8 @@ Never embed a Static API key or webhook secret in frontend JavaScript. Browser s
84
84
 
85
85
  ## Resource API
86
86
 
87
- The client exposes 79 supported operations through 17 resource groups. The pinned
88
- public schema contains 81 operations; the disabled `sessions_list` and
87
+ The client exposes 80 supported operations through 17 resource groups. The pinned
88
+ public schema contains 82 operations; the disabled `sessions_list` and
89
89
  `sessions_destroy` operations are intentionally excluded from the SDK. Sticky
90
90
  session options in proxy generation remain supported.
91
91
 
@@ -351,3 +351,19 @@ The repository also has a real Chromium smoke test via `npm run test:browser`.
351
351
  ## License
352
352
 
353
353
  [MIT](LICENSE)
354
+
355
+ ## Reset remaining data (SDK 2.1.0+)
356
+
357
+ ```typescript
358
+ const order = await client.users.resetData({
359
+ id: userId,
360
+ body: { package_id: packageId },
361
+ idempotencyKey: resetOperationId,
362
+ });
363
+ ```
364
+
365
+ Send only `package_id`, without `data`. A system administrator can reset any user; other accounts can reset only their direct children. The server atomically clears positive, zero, or negative remaining data for a finite package and returns the updated order. Unlimited packages are rejected. Root orders lose their remaining ledger balances; child orders lose their remaining quota without changing the parent pool. Usage history and invoices are preserved.
366
+
367
+ Persist one operation ID and reuse it when retrying the same reset, including after a process restart. This prevents a repeated request from clearing a later top-up. Use subtraction when an explicit amount should be removed from a child quota. The backend must support the reset endpoint before calling it.
368
+
369
+ Version 2.1 retains legacy user and invoice models from 2.0 for compatibility with older deployments. These compatibility types do not change the current public API contract.
package/dist/index.cjs CHANGED
@@ -924,11 +924,11 @@ var LocationsResource = class {
924
924
  this.#client = client;
925
925
  }
926
926
  /** List available autonomous systems */
927
- async listAsns(options = {}) {
927
+ async listAsns(options) {
928
928
  return (await this.listAsnsWithResponse(options)).data;
929
929
  }
930
930
  /** List available autonomous systems; include response metadata. */
931
- async listAsnsWithResponse(options = {}) {
931
+ async listAsnsWithResponse(options) {
932
932
  return this.#client._callWithResponse({
933
933
  operationId: "locations_asn_list",
934
934
  method: "GET",
@@ -950,11 +950,11 @@ var LocationsResource = class {
950
950
  });
951
951
  }
952
952
  /** List available cities */
953
- async listCities(options = {}) {
953
+ async listCities(options) {
954
954
  return (await this.listCitiesWithResponse(options)).data;
955
955
  }
956
956
  /** List available cities; include response metadata. */
957
- async listCitiesWithResponse(options = {}) {
957
+ async listCitiesWithResponse(options) {
958
958
  return this.#client._callWithResponse({
959
959
  operationId: "locations_cities_list",
960
960
  method: "GET",
@@ -987,16 +987,17 @@ var LocationsResource = class {
987
987
  path: "/locations/cities/{id}"
988
988
  }, {
989
989
  path: { id: options.id },
990
+ query: { package_id: options.packageId },
990
991
  headers: { "Accept-Language": options.acceptLanguage },
991
992
  ...options.request === void 0 ? {} : { request: options.request }
992
993
  });
993
994
  }
994
995
  /** List available continents */
995
- async listContinents(options = {}) {
996
+ async listContinents(options) {
996
997
  return (await this.listContinentsWithResponse(options)).data;
997
998
  }
998
999
  /** List available continents; include response metadata. */
999
- async listContinentsWithResponse(options = {}) {
1000
+ async listContinentsWithResponse(options) {
1000
1001
  return this.#client._callWithResponse({
1001
1002
  operationId: "locations_continents_list",
1002
1003
  method: "GET",
@@ -1027,16 +1028,17 @@ var LocationsResource = class {
1027
1028
  path: "/locations/continents/{id}"
1028
1029
  }, {
1029
1030
  path: { id: options.id },
1031
+ query: { package_id: options.packageId },
1030
1032
  headers: { "Accept-Language": options.acceptLanguage },
1031
1033
  ...options.request === void 0 ? {} : { request: options.request }
1032
1034
  });
1033
1035
  }
1034
1036
  /** List available countries */
1035
- async listCountries(options = {}) {
1037
+ async listCountries(options) {
1036
1038
  return (await this.listCountriesWithResponse(options)).data;
1037
1039
  }
1038
1040
  /** List available countries; include response metadata. */
1039
- async listCountriesWithResponse(options = {}) {
1041
+ async listCountriesWithResponse(options) {
1040
1042
  return this.#client._callWithResponse({
1041
1043
  operationId: "locations_countries_list",
1042
1044
  method: "GET",
@@ -1067,16 +1069,17 @@ var LocationsResource = class {
1067
1069
  path: "/locations/countries/{id}"
1068
1070
  }, {
1069
1071
  path: { id: options.id },
1072
+ query: { package_id: options.packageId },
1070
1073
  headers: { "Accept-Language": options.acceptLanguage },
1071
1074
  ...options.request === void 0 ? {} : { request: options.request }
1072
1075
  });
1073
1076
  }
1074
1077
  /** List available internet service providers */
1075
- async listIsps(options = {}) {
1078
+ async listIsps(options) {
1076
1079
  return (await this.listIspsWithResponse(options)).data;
1077
1080
  }
1078
1081
  /** List available internet service providers; include response metadata. */
1079
- async listIspsWithResponse(options = {}) {
1082
+ async listIspsWithResponse(options) {
1080
1083
  return this.#client._callWithResponse({
1081
1084
  operationId: "locations_isps_list",
1082
1085
  method: "GET",
@@ -1097,11 +1100,11 @@ var LocationsResource = class {
1097
1100
  });
1098
1101
  }
1099
1102
  /** List available regions */
1100
- async listRegions(options = {}) {
1103
+ async listRegions(options) {
1101
1104
  return (await this.listRegionsWithResponse(options)).data;
1102
1105
  }
1103
1106
  /** List available regions; include response metadata. */
1104
- async listRegionsWithResponse(options = {}) {
1107
+ async listRegionsWithResponse(options) {
1105
1108
  return this.#client._callWithResponse({
1106
1109
  operationId: "locations_regions_list",
1107
1110
  method: "GET",
@@ -1133,6 +1136,7 @@ var LocationsResource = class {
1133
1136
  path: "/locations/regions/{id}"
1134
1137
  }, {
1135
1138
  path: { id: options.id },
1139
+ query: { package_id: options.packageId },
1136
1140
  headers: { "Accept-Language": options.acceptLanguage },
1137
1141
  ...options.request === void 0 ? {} : { request: options.request }
1138
1142
  });
@@ -1645,11 +1649,11 @@ var UsersResource = class {
1645
1649
  ...options.request === void 0 ? {} : { request: options.request }
1646
1650
  });
1647
1651
  }
1648
- /** Create a sub-user */
1652
+ /** Create a customer account */
1649
1653
  async create(options) {
1650
1654
  return (await this.createWithResponse(options)).data;
1651
1655
  }
1652
- /** Create a sub-user; include response metadata. */
1656
+ /** Create a customer account; include response metadata. */
1653
1657
  async createWithResponse(options) {
1654
1658
  return this.#client._callWithResponse({
1655
1659
  operationId: "users_create",
@@ -1764,6 +1768,27 @@ var UsersResource = class {
1764
1768
  ...options.request === void 0 ? {} : { request: options.request }
1765
1769
  });
1766
1770
  }
1771
+ /** Reset a user's remaining data */
1772
+ async resetData(options) {
1773
+ return (await this.resetDataWithResponse(options)).data;
1774
+ }
1775
+ /** Reset a user's remaining data; include response metadata. */
1776
+ async resetDataWithResponse(options) {
1777
+ return this.#client._callWithResponse({
1778
+ operationId: "users_data_reset_create",
1779
+ method: "POST",
1780
+ path: "/users/{id}/data/reset",
1781
+ idempotent: true
1782
+ }, {
1783
+ path: { id: options.id },
1784
+ headers: {
1785
+ "Idempotency-Key": options.idempotencyKey,
1786
+ "Accept-Language": options.acceptLanguage
1787
+ },
1788
+ body: options.body,
1789
+ ...options.request === void 0 ? {} : { request: options.request }
1790
+ });
1791
+ }
1767
1792
  /** List a sub-user's orders */
1768
1793
  async listOrders(options) {
1769
1794
  return (await this.listOrdersWithResponse(options)).data;
@@ -1801,7 +1826,7 @@ var UsersResource = class {
1801
1826
  }, {
1802
1827
  path: { id: options.id },
1803
1828
  headers: { "Accept-Language": options.acceptLanguage },
1804
- ...options.body === void 0 ? {} : { body: options.body },
1829
+ body: options.body,
1805
1830
  ...options.request === void 0 ? {} : { request: options.request }
1806
1831
  });
1807
1832
  }
@@ -1948,7 +1973,7 @@ function offsetFromUrl(url) {
1948
1973
  //#endregion
1949
1974
  //#region src/client.ts
1950
1975
  const DEFAULT_BASE_URL = "https://api.proxyrequest.com/api/v1";
1951
- const SDK_VERSION = "1.0.0";
1976
+ const SDK_VERSION = "2.1.0";
1952
1977
  var ProxyRequestClient = class ProxyRequestClient {
1953
1978
  apiKeys;
1954
1979
  affiliates;