@coinbase-sample/prime-sdk-ts 0.6.1 → 0.6.3

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.
Files changed (64) hide show
  1. package/README.md +207 -67
  2. package/dist/activities/index.js +21 -39
  3. package/dist/addressBooks/index.js +18 -5
  4. package/dist/allocations/index.js +19 -18
  5. package/dist/balances/index.js +23 -17
  6. package/dist/client-manual.js +84 -0
  7. package/dist/client-modular.js +57 -0
  8. package/dist/client-only.js +31 -0
  9. package/dist/{client.js → clients/client.js} +12 -2
  10. package/dist/clients/clientWithServices.js +323 -0
  11. package/dist/{types/client.d.ts → clients/clientWithServicesTypes.js} +3 -6
  12. package/dist/clients/index.js +28 -0
  13. package/dist/clients/types.js +2 -0
  14. package/dist/constants.js +1 -1
  15. package/dist/financing/index.js +16 -3
  16. package/dist/futures/index.js +4 -4
  17. package/dist/index.js +27 -18
  18. package/dist/invoices/index.js +16 -12
  19. package/dist/onchainAddressBook/index.js +4 -4
  20. package/dist/orders/index.js +38 -58
  21. package/dist/positions/index.js +21 -6
  22. package/dist/products/index.js +16 -3
  23. package/dist/services.js +75 -0
  24. package/dist/shared/envUtils.js +66 -0
  25. package/dist/shared/paginatedResponse.js +3 -0
  26. package/dist/staking/index.js +5 -5
  27. package/dist/transactions/index.js +26 -17
  28. package/dist/types/activities/index.d.ts +2 -3
  29. package/dist/types/addressBooks/index.d.ts +2 -3
  30. package/dist/types/allocations/index.d.ts +2 -3
  31. package/dist/types/assets/index.d.ts +2 -3
  32. package/dist/types/balances/index.d.ts +2 -3
  33. package/dist/types/client-manual.d.ts +58 -0
  34. package/dist/types/client-modular.d.ts +39 -0
  35. package/dist/types/client-only.d.ts +18 -0
  36. package/dist/types/clients/client.d.ts +27 -0
  37. package/dist/types/clients/clientWithServices.d.ts +229 -0
  38. package/dist/types/clients/clientWithServicesTypes.d.ts +115 -0
  39. package/dist/types/clients/index.d.ts +19 -0
  40. package/dist/types/clients/types.d.ts +48 -0
  41. package/dist/types/commission/index.d.ts +2 -3
  42. package/dist/types/constants.d.ts +1 -1
  43. package/dist/types/financing/index.d.ts +2 -3
  44. package/dist/types/futures/index.d.ts +2 -3
  45. package/dist/types/index.d.ts +2 -1
  46. package/dist/types/invoices/index.d.ts +2 -3
  47. package/dist/types/onchainAddressBook/index.d.ts +2 -3
  48. package/dist/types/orders/index.d.ts +2 -3
  49. package/dist/types/paymentMethods/index.d.ts +2 -3
  50. package/dist/types/portfolios/index.d.ts +2 -3
  51. package/dist/types/positions/index.d.ts +2 -3
  52. package/dist/types/products/index.d.ts +2 -3
  53. package/dist/types/services.d.ts +39 -0
  54. package/dist/types/shared/envUtils.d.ts +36 -0
  55. package/dist/types/shared/paginatedResponse.d.ts +5 -4
  56. package/dist/types/staking/index.d.ts +2 -3
  57. package/dist/types/transactions/index.d.ts +2 -3
  58. package/dist/types/types.d.ts +37 -0
  59. package/dist/types/users/index.d.ts +2 -3
  60. package/dist/types/wallets/index.d.ts +2 -3
  61. package/dist/types.js +39 -0
  62. package/dist/users/index.js +21 -6
  63. package/dist/wallets/index.js +24 -12
  64. package/package.json +32 -1
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2025-present Coinbase Global, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.WalletsService = exports.UsersService = exports.TransactionsService = exports.StakingService = exports.ProductsService = exports.PositionsService = exports.PortfoliosService = exports.PaymentMethodsService = exports.OrdersService = exports.OnchainAddressBookService = exports.InvoicesService = exports.FuturesService = exports.FinancingService = exports.CommissionService = exports.BalancesService = exports.AssetsService = exports.AllocationService = exports.AddressBooksService = exports.ActivitiesService = exports.createCredentialsFromEnv = exports.CoinbasePrimeCredentials = exports.CoinbaseError = exports.CoinbaseClientException = exports.Method = exports.CoinbaseClient = exports.CoinbasePrimeClient = void 0;
33
+ // Manual client entry point - for users who prefer manual service instantiation
34
+ // with comprehensive type exports and full control over service lifecycle
35
+ var clients_1 = require("./clients");
36
+ Object.defineProperty(exports, "CoinbasePrimeClient", { enumerable: true, get: function () { return clients_1.CoinbasePrimeClient; } });
37
+ Object.defineProperty(exports, "CoinbaseClient", { enumerable: true, get: function () { return clients_1.CoinbaseClient; } });
38
+ Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return clients_1.Method; } });
39
+ Object.defineProperty(exports, "CoinbaseClientException", { enumerable: true, get: function () { return clients_1.CoinbaseClientException; } });
40
+ Object.defineProperty(exports, "CoinbaseError", { enumerable: true, get: function () { return clients_1.CoinbaseError; } });
41
+ var credentials_1 = require("./credentials");
42
+ Object.defineProperty(exports, "CoinbasePrimeCredentials", { enumerable: true, get: function () { return credentials_1.CoinbasePrimeCredentials; } });
43
+ var envUtils_1 = require("./shared/envUtils");
44
+ Object.defineProperty(exports, "createCredentialsFromEnv", { enumerable: true, get: function () { return envUtils_1.createCredentialsFromEnv; } });
45
+ // Export all individual services for manual instantiation
46
+ var activities_1 = require("./activities");
47
+ Object.defineProperty(exports, "ActivitiesService", { enumerable: true, get: function () { return activities_1.ActivitiesService; } });
48
+ var addressBooks_1 = require("./addressBooks");
49
+ Object.defineProperty(exports, "AddressBooksService", { enumerable: true, get: function () { return addressBooks_1.AddressBooksService; } });
50
+ var allocations_1 = require("./allocations");
51
+ Object.defineProperty(exports, "AllocationService", { enumerable: true, get: function () { return allocations_1.AllocationService; } });
52
+ var assets_1 = require("./assets");
53
+ Object.defineProperty(exports, "AssetsService", { enumerable: true, get: function () { return assets_1.AssetsService; } });
54
+ var balances_1 = require("./balances");
55
+ Object.defineProperty(exports, "BalancesService", { enumerable: true, get: function () { return balances_1.BalancesService; } });
56
+ var commission_1 = require("./commission");
57
+ Object.defineProperty(exports, "CommissionService", { enumerable: true, get: function () { return commission_1.CommissionService; } });
58
+ var financing_1 = require("./financing");
59
+ Object.defineProperty(exports, "FinancingService", { enumerable: true, get: function () { return financing_1.FinancingService; } });
60
+ var futures_1 = require("./futures");
61
+ Object.defineProperty(exports, "FuturesService", { enumerable: true, get: function () { return futures_1.FuturesService; } });
62
+ var invoices_1 = require("./invoices");
63
+ Object.defineProperty(exports, "InvoicesService", { enumerable: true, get: function () { return invoices_1.InvoicesService; } });
64
+ var onchainAddressBook_1 = require("./onchainAddressBook");
65
+ Object.defineProperty(exports, "OnchainAddressBookService", { enumerable: true, get: function () { return onchainAddressBook_1.OnchainAddressBookService; } });
66
+ var orders_1 = require("./orders");
67
+ Object.defineProperty(exports, "OrdersService", { enumerable: true, get: function () { return orders_1.OrdersService; } });
68
+ var paymentMethods_1 = require("./paymentMethods");
69
+ Object.defineProperty(exports, "PaymentMethodsService", { enumerable: true, get: function () { return paymentMethods_1.PaymentMethodsService; } });
70
+ var portfolios_1 = require("./portfolios");
71
+ Object.defineProperty(exports, "PortfoliosService", { enumerable: true, get: function () { return portfolios_1.PortfoliosService; } });
72
+ var positions_1 = require("./positions");
73
+ Object.defineProperty(exports, "PositionsService", { enumerable: true, get: function () { return positions_1.PositionsService; } });
74
+ var products_1 = require("./products");
75
+ Object.defineProperty(exports, "ProductsService", { enumerable: true, get: function () { return products_1.ProductsService; } });
76
+ var staking_1 = require("./staking");
77
+ Object.defineProperty(exports, "StakingService", { enumerable: true, get: function () { return staking_1.StakingService; } });
78
+ var transactions_1 = require("./transactions");
79
+ Object.defineProperty(exports, "TransactionsService", { enumerable: true, get: function () { return transactions_1.TransactionsService; } });
80
+ var users_1 = require("./users");
81
+ Object.defineProperty(exports, "UsersService", { enumerable: true, get: function () { return users_1.UsersService; } });
82
+ var wallets_1 = require("./wallets");
83
+ Object.defineProperty(exports, "WalletsService", { enumerable: true, get: function () { return wallets_1.WalletsService; } });
84
+ __exportStar(require("./model/enums/"), exports);
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2025-present Coinbase Global, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.createCredentialsFromEnv = exports.CoinbasePrimeCredentials = exports.CoinbaseError = exports.CoinbaseClientException = exports.Method = exports.CoinbaseClient = exports.CoinbasePrimeClientWithServices = void 0;
33
+ // Modular client entry point - for users who want optimized bundle sizes
34
+ // with lazy-loaded services and modular type imports
35
+ var clients_1 = require("./clients");
36
+ Object.defineProperty(exports, "CoinbasePrimeClientWithServices", { enumerable: true, get: function () { return clients_1.CoinbasePrimeClientWithServices; } });
37
+ Object.defineProperty(exports, "CoinbaseClient", { enumerable: true, get: function () { return clients_1.CoinbaseClient; } });
38
+ Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return clients_1.Method; } });
39
+ Object.defineProperty(exports, "CoinbaseClientException", { enumerable: true, get: function () { return clients_1.CoinbaseClientException; } });
40
+ Object.defineProperty(exports, "CoinbaseError", { enumerable: true, get: function () { return clients_1.CoinbaseError; } });
41
+ var credentials_1 = require("./credentials");
42
+ Object.defineProperty(exports, "CoinbasePrimeCredentials", { enumerable: true, get: function () { return credentials_1.CoinbasePrimeCredentials; } });
43
+ var envUtils_1 = require("./shared/envUtils");
44
+ Object.defineProperty(exports, "createCredentialsFromEnv", { enumerable: true, get: function () { return envUtils_1.createCredentialsFromEnv; } });
45
+ __exportStar(require("./model/enums/"), exports);
46
+ // NOTE: Service-specific request/response types are NOT exported here.
47
+ // For optimal tree-shaking, import them from their dedicated modules:
48
+ //
49
+ // import type { CreateOrderRequest } from '@coinbase-sample/prime-sdk-ts/orders';
50
+ // import type { ListWalletsRequest } from '@coinbase-sample/prime-sdk-ts/wallets';
51
+ // import type { GetActivityRequest } from '@coinbase-sample/prime-sdk-ts/activities';
52
+ //
53
+ // Or import all service types at once:
54
+ // import type * from '@coinbase-sample/prime-sdk-ts/types';
55
+ //
56
+ // This design ensures the modular client bundle stays minimal while
57
+ // still providing access to all service interfaces for TypeScript support.
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2025-present Coinbase Global, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.createCredentialsFromEnv = exports.CoinbasePrimeCredentials = exports.CoinbaseError = exports.CoinbaseClientException = exports.Method = exports.CoinbaseClient = exports.CoinbasePrimeClientWithServices = exports.CoinbasePrimeClient = void 0;
19
+ // Client-only entry point - for ultra-minimal bundles when using services separately
20
+ // Perfect for services-only approach where you want the smallest possible client bundle
21
+ var clients_1 = require("./clients");
22
+ Object.defineProperty(exports, "CoinbasePrimeClient", { enumerable: true, get: function () { return clients_1.CoinbasePrimeClient; } });
23
+ Object.defineProperty(exports, "CoinbasePrimeClientWithServices", { enumerable: true, get: function () { return clients_1.CoinbasePrimeClientWithServices; } });
24
+ Object.defineProperty(exports, "CoinbaseClient", { enumerable: true, get: function () { return clients_1.CoinbaseClient; } });
25
+ Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return clients_1.Method; } });
26
+ Object.defineProperty(exports, "CoinbaseClientException", { enumerable: true, get: function () { return clients_1.CoinbaseClientException; } });
27
+ Object.defineProperty(exports, "CoinbaseError", { enumerable: true, get: function () { return clients_1.CoinbaseError; } });
28
+ var credentials_1 = require("./credentials");
29
+ Object.defineProperty(exports, "CoinbasePrimeCredentials", { enumerable: true, get: function () { return credentials_1.CoinbasePrimeCredentials; } });
30
+ var envUtils_1 = require("./shared/envUtils");
31
+ Object.defineProperty(exports, "createCredentialsFromEnv", { enumerable: true, get: function () { return envUtils_1.createCredentialsFromEnv; } });
@@ -17,8 +17,9 @@ exports.CoinbasePrimeClient = void 0;
17
17
  * limitations under the License.
18
18
  */
19
19
  const core_ts_1 = require("@coinbase-sample/core-ts");
20
- const constants_1 = require("./constants");
21
- const toCamelCase_1 = require("./shared/toCamelCase");
20
+ const constants_1 = require("../constants");
21
+ const toCamelCase_1 = require("../shared/toCamelCase");
22
+ const envUtils_1 = require("../shared/envUtils");
22
23
  class CoinbasePrimeClient extends core_ts_1.CoinbaseClient {
23
24
  constructor(credentials, apiBasePath, options) {
24
25
  const defaultClientOptions = Object.assign({ defaultLimit: constants_1.DEFAULT_PAGINATION_LIMIT, maxPages: constants_1.DEFAULT_MAX_PAGES, maxItems: constants_1.DEFAULT_MAX_ITEMS }, options);
@@ -32,5 +33,14 @@ class CoinbasePrimeClient extends core_ts_1.CoinbaseClient {
32
33
  return Object.assign(Object.assign({}, response), { data: (0, toCamelCase_1.toCamelCase)(response.data) });
33
34
  });
34
35
  }
36
+ /**
37
+ * Create a client from environment variables
38
+ * Requires PRIME_CREDENTIALS environment variable with JSON containing:
39
+ * { "AccessKey": "...", "SecretKey": "...", "Passphrase": "..." }
40
+ */
41
+ static fromEnv(apiBaseUrl, options) {
42
+ const credentials = (0, envUtils_1.createCredentialsFromEnv)();
43
+ return new CoinbasePrimeClient(credentials, apiBaseUrl, options);
44
+ }
35
45
  }
36
46
  exports.CoinbasePrimeClient = CoinbasePrimeClient;
@@ -0,0 +1,323 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoinbasePrimeClientWithServices = void 0;
4
+ /**
5
+ * Copyright 2025-present Coinbase Global, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const core_ts_1 = require("@coinbase-sample/core-ts");
20
+ const constants_1 = require("../constants");
21
+ const toCamelCase_1 = require("../shared/toCamelCase");
22
+ const envUtils_1 = require("../shared/envUtils");
23
+ /**
24
+ * Enhanced Coinbase Prime Client with lazy-loaded service getters.
25
+ * Services are only instantiated when first accessed, improving tree-shaking
26
+ * and reducing initial bundle size.
27
+ */
28
+ class CoinbasePrimeClientWithServices extends core_ts_1.CoinbaseClient {
29
+ constructor(credentials, apiBasePath, options) {
30
+ const defaultClientOptions = Object.assign({ defaultLimit: constants_1.DEFAULT_PAGINATION_LIMIT, maxPages: constants_1.DEFAULT_MAX_PAGES, maxItems: constants_1.DEFAULT_MAX_ITEMS }, options);
31
+ let basePath = constants_1.API_BASE_PATH;
32
+ if (apiBasePath && apiBasePath.length > 0) {
33
+ basePath = apiBasePath;
34
+ }
35
+ super(basePath, credentials, constants_1.USER_AGENT, defaultClientOptions);
36
+ // transform the response data to camelCase
37
+ this.addTransformResponse((response) => {
38
+ return Object.assign(Object.assign({}, response), { data: (0, toCamelCase_1.toCamelCase)(response.data) });
39
+ });
40
+ }
41
+ /**
42
+ * Create a client from environment variables
43
+ * Requires PRIME_CREDENTIALS environment variable with JSON containing:
44
+ * { "AccessKey": "...", "SecretKey": "...", "Passphrase": "..." }
45
+ */
46
+ static fromEnv(baseUrl, options) {
47
+ const credentials = (0, envUtils_1.createCredentialsFromEnv)();
48
+ return new CoinbasePrimeClientWithServices(credentials, baseUrl, options);
49
+ }
50
+ /**
51
+ * Lazy getter for ActivitiesService
52
+ * @example
53
+ * ```typescript
54
+ * const activities = await client.activities.listPortfolioActivities({ portfolioId });
55
+ * ```
56
+ */
57
+ get activities() {
58
+ if (!this._activitiesService) {
59
+ const { ActivitiesService } = require('../activities');
60
+ this._activitiesService = new ActivitiesService(this);
61
+ }
62
+ return this._activitiesService;
63
+ }
64
+ /**
65
+ * Lazy getter for AddressBooksService
66
+ * @example
67
+ * ```typescript
68
+ * const addressBooks = await client.addressBooks.listAddressBooks({ portfolioId });
69
+ * ```
70
+ */
71
+ get addressBooks() {
72
+ if (!this._addressBooksService) {
73
+ const { AddressBooksService } = require('../addressBooks');
74
+ this._addressBooksService = new AddressBooksService(this);
75
+ }
76
+ return this._addressBooksService;
77
+ }
78
+ /**
79
+ * Lazy getter for AllocationService
80
+ * @example
81
+ * ```typescript
82
+ * const allocation = await client.allocations.createAllocation({ portfolioId, ... });
83
+ * ```
84
+ */
85
+ get allocations() {
86
+ if (!this._allocationService) {
87
+ const { AllocationService } = require('../allocations');
88
+ this._allocationService = new AllocationService(this);
89
+ }
90
+ return this._allocationService;
91
+ }
92
+ /**
93
+ * Lazy getter for AssetsService
94
+ * @example
95
+ * ```typescript
96
+ * const assets = await client.assets.listAssets({ entityId });
97
+ * ```
98
+ */
99
+ get assets() {
100
+ if (!this._assetsService) {
101
+ const { AssetsService } = require('../assets');
102
+ this._assetsService = new AssetsService(this);
103
+ }
104
+ return this._assetsService;
105
+ }
106
+ /**
107
+ * Lazy getter for BalancesService
108
+ * @example
109
+ * ```typescript
110
+ * const balance = await client.balances.getWalletBalance({ portfolioId, walletId });
111
+ * ```
112
+ */
113
+ get balances() {
114
+ if (!this._balancesService) {
115
+ const { BalancesService } = require('../balances');
116
+ this._balancesService = new BalancesService(this);
117
+ }
118
+ return this._balancesService;
119
+ }
120
+ /**
121
+ * Lazy getter for CommissionService
122
+ * @example
123
+ * ```typescript
124
+ * const commission = await client.commission.getPortfolioCommission({ portfolioId });
125
+ * ```
126
+ */
127
+ get commission() {
128
+ if (!this._commissionService) {
129
+ const { CommissionService } = require('../commission');
130
+ this._commissionService = new CommissionService(this);
131
+ }
132
+ return this._commissionService;
133
+ }
134
+ /**
135
+ * Lazy getter for FinancingService
136
+ * @example
137
+ * ```typescript
138
+ * const buyingPower = await client.financing.getPortfolioBuyingPower({ portfolioId });
139
+ * ```
140
+ */
141
+ get financing() {
142
+ if (!this._financingService) {
143
+ const { FinancingService } = require('../financing');
144
+ this._financingService = new FinancingService(this);
145
+ }
146
+ return this._financingService;
147
+ }
148
+ /**
149
+ * Lazy getter for FuturesService
150
+ * @example
151
+ * ```typescript
152
+ * const positions = await client.futures.getEntityFuturesPositions({ entityId });
153
+ * ```
154
+ */
155
+ get futures() {
156
+ if (!this._futuresService) {
157
+ const { FuturesService } = require('../futures');
158
+ this._futuresService = new FuturesService(this);
159
+ }
160
+ return this._futuresService;
161
+ }
162
+ /**
163
+ * Lazy getter for InvoicesService
164
+ * @example
165
+ * ```typescript
166
+ * const invoices = await client.invoices.listInvoices({ entityId });
167
+ * ```
168
+ */
169
+ get invoices() {
170
+ if (!this._invoicesService) {
171
+ const { InvoicesService } = require('../invoices');
172
+ this._invoicesService = new InvoicesService(this);
173
+ }
174
+ return this._invoicesService;
175
+ }
176
+ /**
177
+ * Lazy getter for OnchainAddressBookService
178
+ * @example
179
+ * ```typescript
180
+ * const addressBook = await client.onchainAddressBook.listOnchainAddressBook({ portfolioId });
181
+ * ```
182
+ */
183
+ get onchainAddressBook() {
184
+ if (!this._onchainAddressBookService) {
185
+ const { OnchainAddressBookService } = require('../onchainAddressBook');
186
+ this._onchainAddressBookService = new OnchainAddressBookService(this);
187
+ }
188
+ return this._onchainAddressBookService;
189
+ }
190
+ /**
191
+ * Lazy getter for OrdersService
192
+ * @example
193
+ * ```typescript
194
+ * const order = await client.orders.createOrder({
195
+ * portfolioId: "123",
196
+ * side: "BUY",
197
+ * productId: "BTC-USD",
198
+ * type: "MARKET",
199
+ * baseQuantity: "0.001"
200
+ * });
201
+ * ```
202
+ */
203
+ get orders() {
204
+ if (!this._ordersService) {
205
+ const { OrdersService } = require('../orders');
206
+ this._ordersService = new OrdersService(this);
207
+ }
208
+ return this._ordersService;
209
+ }
210
+ /**
211
+ * Lazy getter for PaymentMethodsService
212
+ * @example
213
+ * ```typescript
214
+ * const paymentMethods = await client.paymentMethods.listEntityPaymentMethods({ entityId });
215
+ * ```
216
+ */
217
+ get paymentMethods() {
218
+ if (!this._paymentMethodsService) {
219
+ const { PaymentMethodsService } = require('../paymentMethods');
220
+ this._paymentMethodsService = new PaymentMethodsService(this);
221
+ }
222
+ return this._paymentMethodsService;
223
+ }
224
+ /**
225
+ * Lazy getter for PortfoliosService
226
+ * @example
227
+ * ```typescript
228
+ * const portfolios = await client.portfolios.listPortfolios();
229
+ * ```
230
+ */
231
+ get portfolios() {
232
+ if (!this._portfoliosService) {
233
+ const { PortfoliosService } = require('../portfolios');
234
+ this._portfoliosService = new PortfoliosService(this);
235
+ }
236
+ return this._portfoliosService;
237
+ }
238
+ /**
239
+ * Lazy getter for PositionsService
240
+ * @example
241
+ * ```typescript
242
+ * const positions = await client.positions.listAggregateEntityPositions({ entityId });
243
+ * ```
244
+ */
245
+ get positions() {
246
+ if (!this._positionsService) {
247
+ const { PositionsService } = require('../positions');
248
+ this._positionsService = new PositionsService(this);
249
+ }
250
+ return this._positionsService;
251
+ }
252
+ /**
253
+ * Lazy getter for ProductsService
254
+ * @example
255
+ * ```typescript
256
+ * const products = await client.products.listProducts({ portfolioId });
257
+ * ```
258
+ */
259
+ get products() {
260
+ if (!this._productsService) {
261
+ const { ProductsService } = require('../products');
262
+ this._productsService = new ProductsService(this);
263
+ }
264
+ return this._productsService;
265
+ }
266
+ /**
267
+ * Lazy getter for StakingService
268
+ * @example
269
+ * ```typescript
270
+ * const stake = await client.staking.createStake({ walletId, assetId, amount });
271
+ * ```
272
+ */
273
+ get staking() {
274
+ if (!this._stakingService) {
275
+ const { StakingService } = require('../staking');
276
+ this._stakingService = new StakingService(this);
277
+ }
278
+ return this._stakingService;
279
+ }
280
+ /**
281
+ * Lazy getter for TransactionsService
282
+ * @example
283
+ * ```typescript
284
+ * const transaction = await client.transactions.getTransaction({ portfolioId, transactionId });
285
+ * ```
286
+ */
287
+ get transactions() {
288
+ if (!this._transactionsService) {
289
+ const { TransactionsService } = require('../transactions');
290
+ this._transactionsService = new TransactionsService(this);
291
+ }
292
+ return this._transactionsService;
293
+ }
294
+ /**
295
+ * Lazy getter for UsersService
296
+ * @example
297
+ * ```typescript
298
+ * const users = await client.users.listUsers({ entityId });
299
+ * ```
300
+ */
301
+ get users() {
302
+ if (!this._usersService) {
303
+ const { UsersService } = require('../users');
304
+ this._usersService = new UsersService(this);
305
+ }
306
+ return this._usersService;
307
+ }
308
+ /**
309
+ * Lazy getter for WalletsService
310
+ * @example
311
+ * ```typescript
312
+ * const wallets = await client.wallets.listWallets({ portfolioId });
313
+ * ```
314
+ */
315
+ get wallets() {
316
+ if (!this._walletsService) {
317
+ const { WalletsService } = require('../wallets');
318
+ this._walletsService = new WalletsService(this);
319
+ }
320
+ return this._walletsService;
321
+ }
322
+ }
323
+ exports.CoinbasePrimeClientWithServices = CoinbasePrimeClientWithServices;
@@ -1,5 +1,6 @@
1
+ "use strict";
1
2
  /**
2
- * Copyright 2024-present Coinbase Global, Inc.
3
+ * Copyright 2025-present Coinbase Global, Inc.
3
4
  *
4
5
  * Licensed under the Apache License, Version 2.0 (the "License");
5
6
  * you may not use this file except in compliance with the License.
@@ -13,8 +14,4 @@
13
14
  * See the License for the specific language governing permissions and
14
15
  * limitations under the License.
15
16
  */
16
- import { CoinbaseClient, CoinbaseHttpClientRetryOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeCredentials } from './credentials';
18
- export declare class CoinbasePrimeClient extends CoinbaseClient {
19
- constructor(credentials?: CoinbasePrimeCredentials, apiBasePath?: string, options?: CoinbaseHttpClientRetryOptions);
20
- }
17
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright 2025-present Coinbase Global, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CoinbaseError = exports.CoinbaseClientException = exports.Method = exports.CoinbaseClient = exports.CoinbasePrimeClientWithServices = exports.CoinbasePrimeClient = void 0;
19
+ var client_1 = require("./client");
20
+ Object.defineProperty(exports, "CoinbasePrimeClient", { enumerable: true, get: function () { return client_1.CoinbasePrimeClient; } });
21
+ var clientWithServices_1 = require("./clientWithServices");
22
+ Object.defineProperty(exports, "CoinbasePrimeClientWithServices", { enumerable: true, get: function () { return clientWithServices_1.CoinbasePrimeClientWithServices; } });
23
+ // Re-export core-ts objects for central control of service's usage of core-ts
24
+ var core_ts_1 = require("@coinbase-sample/core-ts");
25
+ Object.defineProperty(exports, "CoinbaseClient", { enumerable: true, get: function () { return core_ts_1.CoinbaseClient; } });
26
+ Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return core_ts_1.Method; } });
27
+ Object.defineProperty(exports, "CoinbaseClientException", { enumerable: true, get: function () { return core_ts_1.CoinbaseClientException; } });
28
+ Object.defineProperty(exports, "CoinbaseError", { enumerable: true, get: function () { return core_ts_1.CoinbaseError; } });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/constants.js CHANGED
@@ -16,7 +16,7 @@ exports.DEFAULT_MAX_ITEMS = exports.DEFAULT_MAX_PAGES = exports.DEFAULT_PAGINATI
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- exports.VERSION = '0.6.1';
19
+ exports.VERSION = '0.6.3';
20
20
  exports.API_BASE_PATH = 'https://api.prime.coinbase.com/v1/';
21
21
  exports.USER_AGENT = 'coinbase-prime-ts/' + exports.VERSION;
22
22
  exports.CB_ACCESS_KEY_HEADER = 'X-CB-ACCESS-KEY';
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  Object.defineProperty(exports, "__esModule", { value: true });
12
23
  exports.FinancingService = void 0;
13
24
  class FinancingService {
@@ -16,8 +27,10 @@ class FinancingService {
16
27
  }
17
28
  listExistingLocates(request, options) {
18
29
  return __awaiter(this, void 0, void 0, function* () {
30
+ const { portfolioId } = request, queryParams = __rest(request, ["portfolioId"]);
19
31
  const response = yield this.client.request({
20
- url: `portfolios/${request.portfolioId}/locates`,
32
+ url: `portfolios/${portfolioId}/locates`,
33
+ queryParams,
21
34
  callOptions: options,
22
35
  });
23
36
  return response.data;
@@ -25,9 +38,9 @@ class FinancingService {
25
38
  }
26
39
  listInterestAccruals(request, options) {
27
40
  return __awaiter(this, void 0, void 0, function* () {
28
- const queryParams = Object.assign(Object.assign({}, request), { entityId: undefined });
41
+ const { entityId } = request, queryParams = __rest(request, ["entityId"]);
29
42
  const response = yield this.client.request({
30
- url: `entities/${request.entityId}/accruals`,
43
+ url: `entities/${entityId}/accruals`,
31
44
  callOptions: options,
32
45
  queryParams,
33
46
  });
@@ -25,7 +25,7 @@ exports.FuturesService = void 0;
25
25
  * See the License for the specific language governing permissions and
26
26
  * limitations under the License.
27
27
  */
28
- const core_ts_1 = require("@coinbase-sample/core-ts");
28
+ const clients_1 = require("../clients");
29
29
  class FuturesService {
30
30
  constructor(client) {
31
31
  this.client = client;
@@ -63,7 +63,7 @@ class FuturesService {
63
63
  return __awaiter(this, void 0, void 0, function* () {
64
64
  const response = yield this.client.request({
65
65
  url: `entities/${request.entityId}/futures/sweeps`,
66
- method: core_ts_1.Method.POST,
66
+ method: clients_1.Method.POST,
67
67
  bodyParams: Object.assign(Object.assign({}, request), { entityId: undefined }),
68
68
  callOptions: options,
69
69
  });
@@ -74,7 +74,7 @@ class FuturesService {
74
74
  return __awaiter(this, void 0, void 0, function* () {
75
75
  const response = yield this.client.request({
76
76
  url: `entities/${request.entityId}/futures/auto_sweep`,
77
- method: core_ts_1.Method.POST,
77
+ method: clients_1.Method.POST,
78
78
  bodyParams: Object.assign(Object.assign({}, request), { entityId: undefined }),
79
79
  callOptions: options,
80
80
  });
@@ -85,7 +85,7 @@ class FuturesService {
85
85
  return __awaiter(this, void 0, void 0, function* () {
86
86
  const response = yield this.client.request({
87
87
  url: `entities/${request.entityId}/futures/sweeps`,
88
- method: core_ts_1.Method.DELETE,
88
+ method: clients_1.Method.DELETE,
89
89
  callOptions: options,
90
90
  });
91
91
  return response.data;