@coinbase-sample/prime-sdk-ts 0.6.2 → 0.6.4

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 (77) hide show
  1. package/README.md +207 -67
  2. package/dist/addressBooks/index.js +2 -2
  3. package/dist/allocations/index.js +3 -3
  4. package/dist/client-manual.js +84 -0
  5. package/dist/client-modular.js +57 -0
  6. package/dist/client-only.js +31 -0
  7. package/dist/{client.js → clients/client.js} +12 -2
  8. package/dist/clients/clientWithServices.js +323 -0
  9. package/dist/{types/client.d.ts → clients/clientWithServicesTypes.js} +3 -6
  10. package/dist/clients/index.js +28 -0
  11. package/dist/clients/types.js +2 -0
  12. package/dist/constants.js +1 -1
  13. package/dist/futures/index.js +4 -4
  14. package/dist/index.js +27 -18
  15. package/dist/model/enumPrefixes.js +330 -0
  16. package/dist/onchainAddressBook/index.js +4 -4
  17. package/dist/orders/index.js +6 -6
  18. package/dist/paymentMethods/index.js +2 -1
  19. package/dist/services.js +75 -0
  20. package/dist/shared/dynamicEnumValidation.js +184 -0
  21. package/dist/shared/dynamicEnumValidation.old.js +746 -0
  22. package/dist/shared/enumHelpers.js +219 -0
  23. package/dist/shared/enumRegistry.js +153 -0
  24. package/dist/shared/enumValidationCore.js +194 -0
  25. package/dist/shared/enumValidators.js +115 -0
  26. package/dist/shared/envUtils.js +66 -0
  27. package/dist/shared/fieldMapping.js +242 -0
  28. package/dist/shared/serviceContext.js +157 -0
  29. package/dist/staking/index.js +5 -5
  30. package/dist/transactions/index.js +5 -5
  31. package/dist/types/activities/index.d.ts +2 -3
  32. package/dist/types/addressBooks/index.d.ts +2 -3
  33. package/dist/types/allocations/index.d.ts +2 -3
  34. package/dist/types/assets/index.d.ts +2 -3
  35. package/dist/types/balances/index.d.ts +2 -3
  36. package/dist/types/balances/types.d.ts +1 -1
  37. package/dist/types/client-manual.d.ts +58 -0
  38. package/dist/types/client-modular.d.ts +39 -0
  39. package/dist/types/client-only.d.ts +18 -0
  40. package/dist/types/clients/client.d.ts +27 -0
  41. package/dist/types/clients/clientWithServices.d.ts +229 -0
  42. package/dist/types/clients/clientWithServicesTypes.d.ts +115 -0
  43. package/dist/types/clients/index.d.ts +19 -0
  44. package/dist/types/clients/types.d.ts +48 -0
  45. package/dist/types/commission/index.d.ts +2 -3
  46. package/dist/types/constants.d.ts +1 -1
  47. package/dist/types/financing/index.d.ts +2 -3
  48. package/dist/types/futures/index.d.ts +2 -3
  49. package/dist/types/index.d.ts +2 -1
  50. package/dist/types/invoices/index.d.ts +2 -3
  51. package/dist/types/model/enumPrefixes.d.ts +206 -0
  52. package/dist/types/onchainAddressBook/index.d.ts +2 -3
  53. package/dist/types/orders/index.d.ts +2 -3
  54. package/dist/types/paymentMethods/index.d.ts +2 -3
  55. package/dist/types/paymentMethods/types.d.ts +1 -0
  56. package/dist/types/portfolios/index.d.ts +2 -3
  57. package/dist/types/positions/index.d.ts +2 -3
  58. package/dist/types/products/index.d.ts +2 -3
  59. package/dist/types/services.d.ts +39 -0
  60. package/dist/types/shared/dynamicEnumValidation.d.ts +48 -0
  61. package/dist/types/shared/dynamicEnumValidation.old.d.ts +143 -0
  62. package/dist/types/shared/enumHelpers.d.ts +135 -0
  63. package/dist/types/shared/enumRegistry.d.ts +74 -0
  64. package/dist/types/shared/enumValidationCore.d.ts +68 -0
  65. package/dist/types/shared/enumValidators.d.ts +117 -0
  66. package/dist/types/shared/envUtils.d.ts +36 -0
  67. package/dist/types/shared/fieldMapping.d.ts +35 -0
  68. package/dist/types/shared/paginatedResponse.d.ts +3 -4
  69. package/dist/types/shared/serviceContext.d.ts +46 -0
  70. package/dist/types/staking/index.d.ts +2 -3
  71. package/dist/types/transactions/index.d.ts +2 -3
  72. package/dist/types/types.d.ts +37 -0
  73. package/dist/types/users/index.d.ts +2 -3
  74. package/dist/types/wallets/index.d.ts +2 -3
  75. package/dist/types.js +39 -0
  76. package/dist/wallets/index.js +3 -3
  77. package/package.json +33 -2
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { IPrimeApiClient, CoinbasePrimeClient, CoinbasePrimeClientConfig, CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from './clients';
17
+ export { CoinbasePrimeCredentials } from './credentials';
18
+ export { createCredentialsFromEnv } from './shared/envUtils';
19
+ export { ActivitiesService, IActivitiesService } from './activities';
20
+ export { AddressBooksService, IAddressBooksService } from './addressBooks';
21
+ export { AllocationService, IAllocationService } from './allocations';
22
+ export { AssetsService, IAssetsService } from './assets';
23
+ export { BalancesService, IBalancesService } from './balances';
24
+ export { CommissionService, ICommissionService } from './commission';
25
+ export { FinancingService, IFinancingService } from './financing';
26
+ export { FuturesService, IFuturesService } from './futures';
27
+ export { InvoicesService, IInvoicesService } from './invoices';
28
+ export { OnchainAddressBookService } from './onchainAddressBook';
29
+ export { OrdersService, IOrdersService } from './orders';
30
+ export { PaymentMethodsService, IPaymentMethodsService, } from './paymentMethods';
31
+ export { PortfoliosService, IPortfoliosService } from './portfolios';
32
+ export { PositionsService, IPositionsService } from './positions';
33
+ export { ProductsService, IProductsService } from './products';
34
+ export { StakingService, IStakingService } from './staking';
35
+ export { TransactionsService, ITransactionsService } from './transactions';
36
+ export { UsersService, IUsersService } from './users';
37
+ export { WalletsService, IWalletsService } from './wallets';
38
+ export type * from './model/';
39
+ export * from './model/enums/';
40
+ export type { GetActivityRequest, GetActivityResponse, GetPortfolioActivitiesRequest, GetPortfolioActivityResponse, ListEntityActivitiesRequest, ListEntityActivitiesResponse, ListPortfolioActivitiesRequest, ListPortfolioActivitiesResponse, } from './activities/types';
41
+ export type { CreateAddressBookRequest, CreateAddressBookResponse, ListAddressBooksRequest, ListAddressBooksResponse, } from './addressBooks/types';
42
+ export type { CreateAllocationRequest, CreateAllocationResponse, CreateNetAllocationRequest, CreateNetAllocationResponse, ListNetAllocationsRequest, ListNetAllocationsResponse, ListPortfolioAllocationsRequest, ListPortfolioAllocationsResponse, GetAllocationRequest, GetAllocationResponse, } from './allocations/types';
43
+ export type { ListAssetsRequest, ListAssetsResponse } from './assets/types';
44
+ export type { GetWalletBalanceRequest, GetWalletBalanceResponse, ListOnchainWalletBalancesRequest, ListOnchainWalletBalancesResponse, ListPortfolioBalancesRequest, ListPortfolioBalancesResponse, ListEntityBalancesRequest, ListEntityBalancesResponse, } from './balances/types';
45
+ export type { GetPortfolioCommissionRequest, GetPortfolioCommissionResponse, } from './commission/types';
46
+ export type { AcceptQuoteRequest, AcceptQuoteResponse, CancelOrderRequest, CancelOrderResponse, CreateOrderPreviewRequest, CreateOrderPreviewResponse, CreateOrderRequest, CreateOrderResponse, CreateQuoteRequest, CreateQuoteResponse, GetOrderRequest, GetOrderResponse, GetOrderEditHistoryRequest, GetOrderEditHistoryResponse, ListOpenOrdersRequest, ListOpenOrdersResponse, ListOrderFillsRequest, ListOrderFillsResponse, ListPortfolioFillsRequest, ListPortfolioFillsResponse, ListPortfolioOrdersRequest, ListPortfolioOrdersResponse, } from './orders/types';
47
+ export type { ListExistingLocatesRequest, ListExistingLocatesResponse, ListInterestAccrualsRequest, ListInterestAccrualsResponse, ListPortfolioInterestAccrualsRequest, ListPortfolioInterestAccrualsResponse, ListMarginCallSummariesRequest, ListMarginCallSummariesResponse, ListMarginConversionsRequest, ListMarginConversionsResponse, GetEntityLocateAvailabilitiesRequest, GetEntityLocateAvailabilitiesResponse, GetMarginInformationRequest, GetMarginInformationResponse, GetPortfolioBuyingPowerRequest, GetPortfolioBuyingPowerResponse, GetPortfolioCreditInformationRequest, GetPortfolioCreditInformationResponse, GetPortfolioWithdrawalPowerRequest, GetPortfolioWithdrawalPowerResponse, GetFcmMarginCallDetailsRequest, GetFcmMarginCallDetailsResponse, GetFcmRiskLimitsRequest, GetFcmRiskLimitsResponse, GetTieredPricingFeesRequest, GetTieredPricingFeesResponse, CreateNewLocatesRequest, CreateNewLocatesResponse, } from './financing/types';
48
+ export type { CancelEntitySweepRequest, CancelEntitySweepResponse, GetEntityFuturesBalanceRequest, GetEntityFuturesBalanceResponse, GetEntityFuturesPositionsRequest, GetEntityFuturesPositionsResponse, ListEntityFuturesSweepsRequest, ListEntityFuturesSweepsResponse, ScheduleEntityFuturesSweepRequest, ScheduleEntityFuturesSweepResponse, UpdateEntityFuturesAutoSweepRequest, UpdateEntityFuturesAutoSweepResponse, } from './futures/types';
49
+ export type { ListInvoicesRequest, ListInvoicesResponse, } from './invoices/types';
50
+ export type { CreateOnchainAddressBookEntryRequest, CreateOnchainAddressBookEntryResponse, DeleteOnchainAddressBookEntryRequest, DeleteOnchainAddressBookEntryResponse, ListOnchainAddressBookRequest, ListOnchainAddressBookResponse, UpdateOnchainAddressBookEntryRequest, UpdateOnchainAddressBookEntryResponse, } from './onchainAddressBook/types';
51
+ export type { GetPaymentMethodRequest, GetPaymentMethodResponse, ListEntityPaymentMethodsRequest, ListEntityPaymentMethodsResponse, } from './paymentMethods/types';
52
+ export type { ListPortfoliosRequest, ListPortfoliosResponse, GetPortfolioCreditRequest, GetPortfolioCreditResponse, GetPortfolioRequest, GetPortfolioResponse, GetCounterpartyIdRequest, GetCounterpartyIdResponse, } from './portfolios/types';
53
+ export type { ListAggregateEntityPositionsRequest, ListAggregateEntityPositionsResponse, ListEntityPositionsRequest, ListEntityPositionsResponse, } from './positions/types';
54
+ export type { ListProductsRequest, ListProductsResponse, } from './products/types';
55
+ export type { CreateStakeRequest, CreateStakeResponse, CreateUnstakeRequest, CreateUnstakeResponse, CreatePortfolioStakeRequest, CreatePortfolioStakeResponse, CreatePortfolioUnstakeRequest, CreatePortfolioUnstakeResponse, } from './staking/types';
56
+ export type { CreateConversionRequest, CreateConversionResponse, CreateOnchainTransactionRequest, CreateOnchainTransactionResponse, CreateTransferRequest, CreateTransferResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, GetTransactionRequest, GetTransactionResponse, ListPortfolioTransactionsRequest, ListPortfolioTransactionsResponse, ListWalletTransactionsRequest, ListWalletTransactionsResponse, } from './transactions/types';
57
+ export type { ListPortfolioUsersRequest, ListPortfolioUsersResponse, ListUsersRequest, ListUsersResponse, } from './users/types';
58
+ export type { CreateWalletRequest, CreateWalletResponse, CreateWalletDepositAddressRequest, CreateWalletDepositAddressResponse, GetWalletDepositInstructionsRequest, GetWalletDepositInstructionsResponse, GetWalletRequest, GetWalletResponse, ListWalletAddressesRequest, ListWalletAddressesResponse, ListWalletsRequest, ListWalletsResponse, } from './wallets/types';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { IPrimeApiClient, CoinbasePrimeClientWithServices, CoinbasePrimeClientConfig, CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from './clients';
17
+ export { CoinbasePrimeCredentials } from './credentials';
18
+ export { createCredentialsFromEnv } from './shared/envUtils';
19
+ export type * from './model/';
20
+ export * from './model/enums/';
21
+ export type { IActivitiesService } from './activities';
22
+ export type { IAddressBooksService } from './addressBooks';
23
+ export type { IAllocationService } from './allocations';
24
+ export type { IAssetsService } from './assets';
25
+ export type { IBalancesService } from './balances';
26
+ export type { ICommissionService } from './commission';
27
+ export type { IFinancingService } from './financing';
28
+ export type { IFuturesService } from './futures';
29
+ export type { IInvoicesService } from './invoices';
30
+ export type { OnchainAddressBookService } from './onchainAddressBook';
31
+ export type { IOrdersService } from './orders';
32
+ export type { IPaymentMethodsService } from './paymentMethods';
33
+ export type { IPortfoliosService } from './portfolios';
34
+ export type { IPositionsService } from './positions';
35
+ export type { IProductsService } from './products';
36
+ export type { IStakingService } from './staking';
37
+ export type { ITransactionsService } from './transactions';
38
+ export type { IUsersService } from './users';
39
+ export type { IWalletsService } from './wallets';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { CoinbasePrimeClient, CoinbasePrimeClientWithServices, CoinbasePrimeClientConfig, IPrimeApiClient, CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from './clients';
17
+ export { CoinbasePrimeCredentials } from './credentials';
18
+ export { createCredentialsFromEnv } from './shared/envUtils';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright 2024-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { CoinbaseClient } from '@coinbase-sample/core-ts';
17
+ import { CoinbasePrimeCredentials } from '../credentials';
18
+ import type { CoinbasePrimeClientConfig, IPrimeApiClient } from './types';
19
+ export declare class CoinbasePrimeClient extends CoinbaseClient implements IPrimeApiClient {
20
+ constructor(credentials?: CoinbasePrimeCredentials, apiBasePath?: string, options?: CoinbasePrimeClientConfig);
21
+ /**
22
+ * Create a client from environment variables
23
+ * Requires PRIME_CREDENTIALS environment variable with JSON containing:
24
+ * { "AccessKey": "...", "SecretKey": "...", "Passphrase": "..." }
25
+ */
26
+ static fromEnv(apiBaseUrl?: string, options?: CoinbasePrimeClientConfig): CoinbasePrimeClient;
27
+ }
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { CoinbaseClient } from '@coinbase-sample/core-ts';
17
+ import { CoinbasePrimeCredentials } from '../credentials';
18
+ import type { CoinbasePrimeClientConfig, IPrimeApiClient } from './types';
19
+ import { LazyServiceGetters } from './clientWithServicesTypes';
20
+ import type { IActivitiesService } from '../activities';
21
+ import type { IAddressBooksService } from '../addressBooks';
22
+ import type { IAllocationService } from '../allocations';
23
+ import type { IAssetsService } from '../assets';
24
+ import type { IBalancesService } from '../balances';
25
+ import type { ICommissionService } from '../commission';
26
+ import type { IFinancingService } from '../financing';
27
+ import type { IFuturesService } from '../futures';
28
+ import type { IInvoicesService } from '../invoices';
29
+ import type { OnchainAddressBookService } from '../onchainAddressBook';
30
+ import type { IOrdersService } from '../orders';
31
+ import type { IPaymentMethodsService } from '../paymentMethods';
32
+ import type { IPortfoliosService } from '../portfolios';
33
+ import type { IPositionsService } from '../positions';
34
+ import type { IProductsService } from '../products';
35
+ import type { IStakingService } from '../staking';
36
+ import type { ITransactionsService } from '../transactions';
37
+ import type { IUsersService } from '../users';
38
+ import type { IWalletsService } from '../wallets';
39
+ /**
40
+ * Enhanced Coinbase Prime Client with lazy-loaded service getters.
41
+ * Services are only instantiated when first accessed, improving tree-shaking
42
+ * and reducing initial bundle size.
43
+ */
44
+ export declare class CoinbasePrimeClientWithServices extends CoinbaseClient implements LazyServiceGetters, IPrimeApiClient {
45
+ private _activitiesService?;
46
+ private _addressBooksService?;
47
+ private _allocationService?;
48
+ private _assetsService?;
49
+ private _balancesService?;
50
+ private _commissionService?;
51
+ private _financingService?;
52
+ private _futuresService?;
53
+ private _invoicesService?;
54
+ private _onchainAddressBookService?;
55
+ private _ordersService?;
56
+ private _paymentMethodsService?;
57
+ private _portfoliosService?;
58
+ private _positionsService?;
59
+ private _productsService?;
60
+ private _stakingService?;
61
+ private _transactionsService?;
62
+ private _usersService?;
63
+ private _walletsService?;
64
+ constructor(credentials?: CoinbasePrimeCredentials, apiBasePath?: string, options?: CoinbasePrimeClientConfig);
65
+ /**
66
+ * Create a client from environment variables
67
+ * Requires PRIME_CREDENTIALS environment variable with JSON containing:
68
+ * { "AccessKey": "...", "SecretKey": "...", "Passphrase": "..." }
69
+ */
70
+ static fromEnv(baseUrl?: string, options?: CoinbasePrimeClientConfig): CoinbasePrimeClientWithServices;
71
+ /**
72
+ * Lazy getter for ActivitiesService
73
+ * @example
74
+ * ```typescript
75
+ * const activities = await client.activities.listPortfolioActivities({ portfolioId });
76
+ * ```
77
+ */
78
+ get activities(): IActivitiesService;
79
+ /**
80
+ * Lazy getter for AddressBooksService
81
+ * @example
82
+ * ```typescript
83
+ * const addressBooks = await client.addressBooks.listAddressBooks({ portfolioId });
84
+ * ```
85
+ */
86
+ get addressBooks(): IAddressBooksService;
87
+ /**
88
+ * Lazy getter for AllocationService
89
+ * @example
90
+ * ```typescript
91
+ * const allocation = await client.allocations.createAllocation({ portfolioId, ... });
92
+ * ```
93
+ */
94
+ get allocations(): IAllocationService;
95
+ /**
96
+ * Lazy getter for AssetsService
97
+ * @example
98
+ * ```typescript
99
+ * const assets = await client.assets.listAssets({ entityId });
100
+ * ```
101
+ */
102
+ get assets(): IAssetsService;
103
+ /**
104
+ * Lazy getter for BalancesService
105
+ * @example
106
+ * ```typescript
107
+ * const balance = await client.balances.getWalletBalance({ portfolioId, walletId });
108
+ * ```
109
+ */
110
+ get balances(): IBalancesService;
111
+ /**
112
+ * Lazy getter for CommissionService
113
+ * @example
114
+ * ```typescript
115
+ * const commission = await client.commission.getPortfolioCommission({ portfolioId });
116
+ * ```
117
+ */
118
+ get commission(): ICommissionService;
119
+ /**
120
+ * Lazy getter for FinancingService
121
+ * @example
122
+ * ```typescript
123
+ * const buyingPower = await client.financing.getPortfolioBuyingPower({ portfolioId });
124
+ * ```
125
+ */
126
+ get financing(): IFinancingService;
127
+ /**
128
+ * Lazy getter for FuturesService
129
+ * @example
130
+ * ```typescript
131
+ * const positions = await client.futures.getEntityFuturesPositions({ entityId });
132
+ * ```
133
+ */
134
+ get futures(): IFuturesService;
135
+ /**
136
+ * Lazy getter for InvoicesService
137
+ * @example
138
+ * ```typescript
139
+ * const invoices = await client.invoices.listInvoices({ entityId });
140
+ * ```
141
+ */
142
+ get invoices(): IInvoicesService;
143
+ /**
144
+ * Lazy getter for OnchainAddressBookService
145
+ * @example
146
+ * ```typescript
147
+ * const addressBook = await client.onchainAddressBook.listOnchainAddressBook({ portfolioId });
148
+ * ```
149
+ */
150
+ get onchainAddressBook(): OnchainAddressBookService;
151
+ /**
152
+ * Lazy getter for OrdersService
153
+ * @example
154
+ * ```typescript
155
+ * const order = await client.orders.createOrder({
156
+ * portfolioId: "123",
157
+ * side: "BUY",
158
+ * productId: "BTC-USD",
159
+ * type: "MARKET",
160
+ * baseQuantity: "0.001"
161
+ * });
162
+ * ```
163
+ */
164
+ get orders(): IOrdersService;
165
+ /**
166
+ * Lazy getter for PaymentMethodsService
167
+ * @example
168
+ * ```typescript
169
+ * const paymentMethods = await client.paymentMethods.listEntityPaymentMethods({ entityId });
170
+ * ```
171
+ */
172
+ get paymentMethods(): IPaymentMethodsService;
173
+ /**
174
+ * Lazy getter for PortfoliosService
175
+ * @example
176
+ * ```typescript
177
+ * const portfolios = await client.portfolios.listPortfolios();
178
+ * ```
179
+ */
180
+ get portfolios(): IPortfoliosService;
181
+ /**
182
+ * Lazy getter for PositionsService
183
+ * @example
184
+ * ```typescript
185
+ * const positions = await client.positions.listAggregateEntityPositions({ entityId });
186
+ * ```
187
+ */
188
+ get positions(): IPositionsService;
189
+ /**
190
+ * Lazy getter for ProductsService
191
+ * @example
192
+ * ```typescript
193
+ * const products = await client.products.listProducts({ portfolioId });
194
+ * ```
195
+ */
196
+ get products(): IProductsService;
197
+ /**
198
+ * Lazy getter for StakingService
199
+ * @example
200
+ * ```typescript
201
+ * const stake = await client.staking.createStake({ walletId, assetId, amount });
202
+ * ```
203
+ */
204
+ get staking(): IStakingService;
205
+ /**
206
+ * Lazy getter for TransactionsService
207
+ * @example
208
+ * ```typescript
209
+ * const transaction = await client.transactions.getTransaction({ portfolioId, transactionId });
210
+ * ```
211
+ */
212
+ get transactions(): ITransactionsService;
213
+ /**
214
+ * Lazy getter for UsersService
215
+ * @example
216
+ * ```typescript
217
+ * const users = await client.users.listUsers({ entityId });
218
+ * ```
219
+ */
220
+ get users(): IUsersService;
221
+ /**
222
+ * Lazy getter for WalletsService
223
+ * @example
224
+ * ```typescript
225
+ * const wallets = await client.wallets.listWallets({ portfolioId });
226
+ * ```
227
+ */
228
+ get wallets(): IWalletsService;
229
+ }
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IActivitiesService } from '../activities';
17
+ import type { IAddressBooksService } from '../addressBooks';
18
+ import type { IAllocationService } from '../allocations';
19
+ import type { IAssetsService } from '../assets';
20
+ import type { IBalancesService } from '../balances';
21
+ import type { ICommissionService } from '../commission';
22
+ import type { IFinancingService } from '../financing';
23
+ import type { IFuturesService } from '../futures';
24
+ import type { IInvoicesService } from '../invoices';
25
+ import type { OnchainAddressBookService } from '../onchainAddressBook';
26
+ import type { IOrdersService } from '../orders';
27
+ import type { IPaymentMethodsService } from '../paymentMethods';
28
+ import type { IPortfoliosService } from '../portfolios';
29
+ import type { IPositionsService } from '../positions';
30
+ import type { IProductsService } from '../products';
31
+ import type { IStakingService } from '../staking';
32
+ import type { ITransactionsService } from '../transactions';
33
+ import type { IUsersService } from '../users';
34
+ import type { IWalletsService } from '../wallets';
35
+ /**
36
+ * Interface defining all lazy service getters for the modular client
37
+ */
38
+ export interface LazyServiceGetters {
39
+ /**
40
+ * Activities service for managing portfolio and entity activities
41
+ */
42
+ readonly activities: IActivitiesService;
43
+ /**
44
+ * Address books service for managing portfolio address books
45
+ */
46
+ readonly addressBooks: IAddressBooksService;
47
+ /**
48
+ * Allocations service for managing portfolio allocations
49
+ */
50
+ readonly allocations: IAllocationService;
51
+ /**
52
+ * Assets service for managing entity assets
53
+ */
54
+ readonly assets: IAssetsService;
55
+ /**
56
+ * Balances service for managing wallet and portfolio balances
57
+ */
58
+ readonly balances: IBalancesService;
59
+ /**
60
+ * Commission service for retrieving commission information
61
+ */
62
+ readonly commission: ICommissionService;
63
+ /**
64
+ * Financing service for margin, buying power, and FCM operations
65
+ */
66
+ readonly financing: IFinancingService;
67
+ /**
68
+ * Futures service for managing futures positions and sweeps
69
+ */
70
+ readonly futures: IFuturesService;
71
+ /**
72
+ * Invoices service for managing entity invoices
73
+ */
74
+ readonly invoices: IInvoicesService;
75
+ /**
76
+ * Onchain address book service for managing blockchain addresses
77
+ */
78
+ readonly onchainAddressBook: OnchainAddressBookService;
79
+ /**
80
+ * Orders service for creating and managing trading orders
81
+ */
82
+ readonly orders: IOrdersService;
83
+ /**
84
+ * Payment methods service for managing entity payment methods
85
+ */
86
+ readonly paymentMethods: IPaymentMethodsService;
87
+ /**
88
+ * Portfolios service for managing portfolio information
89
+ */
90
+ readonly portfolios: IPortfoliosService;
91
+ /**
92
+ * Positions service for managing trading positions
93
+ */
94
+ readonly positions: IPositionsService;
95
+ /**
96
+ * Products service for retrieving available trading products
97
+ */
98
+ readonly products: IProductsService;
99
+ /**
100
+ * Staking service for managing staking operations
101
+ */
102
+ readonly staking: IStakingService;
103
+ /**
104
+ * Transactions service for managing transaction history
105
+ */
106
+ readonly transactions: ITransactionsService;
107
+ /**
108
+ * Users service for managing entity and portfolio users
109
+ */
110
+ readonly users: IUsersService;
111
+ /**
112
+ * Wallets service for managing portfolio wallets
113
+ */
114
+ readonly wallets: IWalletsService;
115
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { CoinbasePrimeClient } from './client';
17
+ export { CoinbasePrimeClientWithServices } from './clientWithServices';
18
+ export { CoinbasePrimeClientConfig, IPrimeApiClient, LazyService, } from './types';
19
+ export { CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from '@coinbase-sample/core-ts';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { CoinbaseHttpClientRetryOptions, CoinbaseHttpRequestOptions, CoinbaseResponse } from '@coinbase-sample/core-ts';
17
+ /**
18
+ * Configuration options for Prime SDK clients.
19
+ *
20
+ * This unified interface is used by:
21
+ * - CoinbasePrimeClient (traditional client)
22
+ * - CoinbasePrimeClientWithServices (enhanced client)
23
+ *
24
+ * Note: We use Omit<> to cleanly override pagination properties that may
25
+ * have different type constraints between core-ts and Prime SDK.
26
+ */
27
+ export interface CoinbasePrimeClientConfig extends Omit<CoinbaseHttpClientRetryOptions, 'defaultLimit' | 'maxPages' | 'maxItems'> {
28
+ defaultLimit?: number;
29
+ maxPages?: number;
30
+ maxItems?: number;
31
+ }
32
+ export interface IPrimeApiClient {
33
+ request(options: CoinbaseHttpRequestOptions): Promise<CoinbaseResponse>;
34
+ getDefaultPaginationLimit(): number;
35
+ getMaxPages(): number;
36
+ getMaxItems(): number;
37
+ }
38
+ /**
39
+ * Factory function type for creating service instances
40
+ */
41
+ export type ServiceFactory<T> = () => T;
42
+ /**
43
+ * Type helper for lazy service initialization
44
+ */
45
+ export type LazyService<T> = {
46
+ instance?: T;
47
+ factory: ServiceFactory<T>;
48
+ };
@@ -13,14 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { GetPortfolioCommissionRequest, GetPortfolioCommissionResponse } from './types';
19
18
  export interface ICommissionService {
20
19
  getPortfolioCommission(request: GetPortfolioCommissionRequest, options?: CoinbaseCallOptions): Promise<GetPortfolioCommissionResponse>;
21
20
  }
22
21
  export declare class CommissionService implements ICommissionService {
23
22
  private client;
24
- constructor(client: CoinbasePrimeClient);
23
+ constructor(client: IPrimeApiClient);
25
24
  getPortfolioCommission(request: GetPortfolioCommissionRequest, options?: CoinbaseCallOptions): Promise<GetPortfolioCommissionResponse>;
26
25
  }
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const VERSION = "0.6.2";
16
+ export declare const VERSION = "0.6.4";
17
17
  export declare const API_BASE_PATH = "https://api.prime.coinbase.com/v1/";
18
18
  export declare const USER_AGENT: string;
19
19
  export declare const CB_ACCESS_KEY_HEADER = "X-CB-ACCESS-KEY";
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { ListExistingLocatesRequest, ListExistingLocatesResponse, ListInterestAccrualsRequest, ListInterestAccrualsResponse, ListPortfolioInterestAccrualsRequest, ListPortfolioInterestAccrualsResponse, ListMarginCallSummariesRequest, ListMarginCallSummariesResponse, ListMarginConversionsRequest, ListMarginConversionsResponse, GetEntityLocateAvailabilitiesRequest, GetEntityLocateAvailabilitiesResponse, GetMarginInformationRequest, GetMarginInformationResponse, GetPortfolioBuyingPowerRequest, GetPortfolioBuyingPowerResponse, GetPortfolioCreditInformationRequest, GetPortfolioCreditInformationResponse, GetPortfolioWithdrawalPowerRequest, GetPortfolioWithdrawalPowerResponse, GetTieredPricingFeesRequest, GetTieredPricingFeesResponse, GetFcmMarginCallDetailsRequest, GetFcmMarginCallDetailsResponse, GetFcmRiskLimitsRequest, GetFcmRiskLimitsResponse, CreateNewLocatesRequest, CreateNewLocatesResponse } from './types';
19
18
  export interface IFinancingService {
20
19
  listExistingLocates(request: ListExistingLocatesRequest, options?: CoinbaseCallOptions): Promise<ListExistingLocatesResponse>;
@@ -34,7 +33,7 @@ export interface IFinancingService {
34
33
  }
35
34
  export declare class FinancingService implements IFinancingService {
36
35
  private client;
37
- constructor(client: CoinbasePrimeClient);
36
+ constructor(client: IPrimeApiClient);
38
37
  listExistingLocates(request: ListExistingLocatesRequest, options?: CoinbaseCallOptions): Promise<ListExistingLocatesResponse>;
39
38
  listInterestAccruals(request: ListInterestAccrualsRequest, options?: CoinbaseCallOptions): Promise<ListInterestAccrualsResponse>;
40
39
  listPortfolioInterestAccruals(request: ListPortfolioInterestAccrualsRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioInterestAccrualsResponse>;
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { ListEntityFuturesSweepsRequest, ListEntityFuturesSweepsResponse, GetEntityFuturesBalanceRequest, GetEntityFuturesBalanceResponse, GetEntityFuturesPositionsRequest, GetEntityFuturesPositionsResponse, ScheduleEntityFuturesSweepRequest, ScheduleEntityFuturesSweepResponse, UpdateEntityFuturesAutoSweepRequest, UpdateEntityFuturesAutoSweepResponse, CancelEntitySweepRequest, CancelEntitySweepResponse } from './types';
19
18
  export interface IFuturesService {
20
19
  listEntitySweeps(request: ListEntityFuturesSweepsRequest, options?: CoinbaseCallOptions): Promise<ListEntityFuturesSweepsResponse>;
@@ -26,7 +25,7 @@ export interface IFuturesService {
26
25
  }
27
26
  export declare class FuturesService implements IFuturesService {
28
27
  private client;
29
- constructor(client: CoinbasePrimeClient);
28
+ constructor(client: IPrimeApiClient);
30
29
  listEntitySweeps(request: ListEntityFuturesSweepsRequest, options?: CoinbaseCallOptions): Promise<ListEntityFuturesSweepsResponse>;
31
30
  getEntityBalance(request: GetEntityFuturesBalanceRequest, options?: CoinbaseCallOptions): Promise<GetEntityFuturesBalanceResponse>;
32
31
  getEntityPositions(request: GetEntityFuturesPositionsRequest, options?: CoinbaseCallOptions): Promise<GetEntityFuturesPositionsResponse>;
@@ -13,8 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { CoinbasePrimeClient } from './client';
16
+ export { CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, CoinbasePrimeClientWithServices, CoinbasePrimeClientConfig, CoinbasePrimeClient, IPrimeApiClient, } from './clients';
17
17
  export { CoinbasePrimeCredentials } from './credentials';
18
+ export { createCredentialsFromEnv } from './shared/envUtils';
18
19
  export { ActivitiesService, IActivitiesService } from './activities';
19
20
  export { AddressBooksService, IAddressBooksService } from './addressBooks';
20
21
  export { AllocationService, IAllocationService } from './allocations';