@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,135 @@
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
+ /**
17
+ * Enum transformation utilities for JavaScript developers.
18
+ * These helpers make it easier to work with enums by providing:
19
+ * - Case-insensitive enum lookups
20
+ * - CamelCase to SNAKE_CASE conversion
21
+ * - Enum validation with helpful error messages
22
+ * - Support for prefix-aware transformations
23
+ */
24
+ /**
25
+ * Converts a string from various formats to the expected enum value format (SCREAMING_SNAKE_CASE)
26
+ *
27
+ * @param input - The input string in any case format
28
+ * @returns The normalized SCREAMING_SNAKE_CASE string
29
+ *
30
+ * @example
31
+ * normalizeEnumValue('buy') // 'BUY'
32
+ * normalizeEnumValue('marketOrder') // 'MARKET_ORDER'
33
+ * normalizeEnumValue('STOP_LIMIT') // 'STOP_LIMIT'
34
+ * normalizeEnumValue('Order_Type_Market') // 'ORDER_TYPE_MARKET'
35
+ */
36
+ export declare function normalizeEnumValue(input: string): string;
37
+ /**
38
+ * Safely gets an enum value by normalizing the input and checking if it exists
39
+ *
40
+ * @param enumObject - The enum object to search in
41
+ * @param input - The input value to normalize and find
42
+ * @param enumName - Optional enum name for better error messages
43
+ * @returns The matching enum value or undefined if not found
44
+ *
45
+ * @example
46
+ * import { OrderSide } from '../model/enums/OrderSide';
47
+ *
48
+ * getEnumValue(OrderSide, 'buy') // OrderSide.Buy
49
+ * getEnumValue(OrderSide, 'BUY') // OrderSide.Buy
50
+ * getEnumValue(OrderSide, 'invalid') // undefined
51
+ */
52
+ export declare function getEnumValue<T extends Record<string, string>>(enumObject: T, input: string, enumName?: string): T[keyof T] | undefined;
53
+ /**
54
+ * Gets an enum value with strict validation, throwing an error if not found
55
+ *
56
+ * @param enumObject - The enum object to search in
57
+ * @param input - The input value to normalize and find
58
+ * @param enumName - Optional enum name for better error messages
59
+ * @returns The matching enum value
60
+ * @throws Error if the enum value is not found
61
+ *
62
+ * @example
63
+ * import { OrderSide } from '../model/enums/OrderSide';
64
+ *
65
+ * requireEnumValue(OrderSide, 'buy') // OrderSide.Buy
66
+ * requireEnumValue(OrderSide, 'invalid') // throws Error
67
+ */
68
+ export declare function requireEnumValue<T extends Record<string, string>>(enumObject: T, input: string, enumName?: string): T[keyof T];
69
+ /**
70
+ * Checks if a string is a valid enum value (case-insensitive)
71
+ *
72
+ * @param enumObject - The enum object to check against
73
+ * @param input - The input value to validate
74
+ * @returns True if the input is a valid enum value
75
+ *
76
+ * @example
77
+ * import { OrderSide } from '../model/enums/OrderSide';
78
+ *
79
+ * isValidEnumValue(OrderSide, 'buy') // true
80
+ * isValidEnumValue(OrderSide, 'BUY') // true
81
+ * isValidEnumValue(OrderSide, 'invalid') // false
82
+ */
83
+ export declare function isValidEnumValue<T extends Record<string, string>>(enumObject: T, input: string): boolean;
84
+ /**
85
+ * Gets all possible enum values as an array
86
+ *
87
+ * @param enumObject - The enum object
88
+ * @returns Array of all enum values
89
+ *
90
+ * @example
91
+ * import { OrderSide } from '../model/enums/OrderSide';
92
+ *
93
+ * getEnumValues(OrderSide) // ['BUY', 'SELL']
94
+ */
95
+ export declare function getEnumValues<T extends Record<string, string>>(enumObject: T): T[keyof T][];
96
+ /**
97
+ * Gets all possible enum keys as an array
98
+ *
99
+ * @param enumObject - The enum object
100
+ * @returns Array of all enum keys
101
+ *
102
+ * @example
103
+ * import { OrderSide } from '../model/enums/OrderSide';
104
+ *
105
+ * getEnumKeys(OrderSide) // ['Buy', 'Sell']
106
+ */
107
+ export declare function getEnumKeys<T extends Record<string, string>>(enumObject: T): (keyof T)[];
108
+ /**
109
+ * Validates that a string has the correct prefix for enum values
110
+ * Useful for ensuring enum values follow expected patterns
111
+ *
112
+ * @param input - The enum value to check
113
+ * @param expectedPrefix - The expected prefix (e.g., 'ORDER_TYPE_', 'ACTIVITY_TYPE_')
114
+ * @param strict - If true, requires exact prefix match. If false, allows values without prefix
115
+ * @returns True if the prefix is correct
116
+ *
117
+ * @example
118
+ * validateEnumPrefix('ORDER_TYPE_MARKET', 'ORDER_TYPE_') // true
119
+ * validateEnumPrefix('MARKET', 'ORDER_TYPE_', false) // true (non-strict)
120
+ * validateEnumPrefix('MARKET', 'ORDER_TYPE_', true) // false (strict)
121
+ */
122
+ export declare function validateEnumPrefix(input: string, expectedPrefix: string, strict?: boolean): boolean;
123
+ /**
124
+ * Transforms enum input to the correct format, optionally adding a prefix
125
+ *
126
+ * @param input - The input string
127
+ * @param prefix - Optional prefix to add if not present
128
+ * @returns The transformed enum value
129
+ *
130
+ * @example
131
+ * transformEnumValue('market', 'ORDER_TYPE_') // 'ORDER_TYPE_MARKET'
132
+ * transformEnumValue('ORDER_TYPE_MARKET', 'ORDER_TYPE_') // 'ORDER_TYPE_MARKET'
133
+ * transformEnumValue('marketOrder') // 'MARKET_ORDER'
134
+ */
135
+ export declare function transformEnumValue(input: string, prefix?: string): string;
@@ -0,0 +1,74 @@
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
+ /**
17
+ * Registry for managing discovered enums and providing lookup capabilities
18
+ */
19
+ export declare class EnumRegistry {
20
+ private enums;
21
+ private enumsByValue;
22
+ private enumsByKey;
23
+ constructor();
24
+ /**
25
+ * Automatically discover and register all enums from the model/enums directory
26
+ */
27
+ private populateEnums;
28
+ /**
29
+ * Check if an object is a valid TypeScript enum
30
+ */
31
+ private isValidEnum;
32
+ /**
33
+ * Index enum values and keys for fast lookup
34
+ */
35
+ private indexEnumValues;
36
+ /**
37
+ * Get a specific enum by name
38
+ */
39
+ getEnum(enumName: string): Record<string, string> | null;
40
+ /**
41
+ * Get all registered enum names
42
+ */
43
+ getAllEnumNames(): string[];
44
+ /**
45
+ * Find enum by value (exact match)
46
+ */
47
+ findEnumByValue(value: string): {
48
+ enum: Record<string, string>;
49
+ name: string;
50
+ } | null;
51
+ /**
52
+ * Find enum by key (exact match)
53
+ */
54
+ findEnumByKey(key: string): {
55
+ enum: Record<string, string>;
56
+ name: string;
57
+ } | null;
58
+ /**
59
+ * Get statistics about discovered enums
60
+ */
61
+ getStats(): {
62
+ totalEnums: number;
63
+ totalValues: number;
64
+ totalKeys: number;
65
+ };
66
+ /**
67
+ * Get detailed information about all enums
68
+ */
69
+ getEnumDetails(): Record<string, {
70
+ values: string[];
71
+ keys: string[];
72
+ }>;
73
+ }
74
+ export declare const enumRegistry: EnumRegistry;
@@ -0,0 +1,68 @@
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
+ /**
17
+ * Error thrown when a request contains invalid enum values
18
+ */
19
+ export declare class DynamicEnumValidationError extends Error {
20
+ field: string;
21
+ value: string;
22
+ enumName: string;
23
+ validValues: string[];
24
+ validKeys?: string[] | undefined;
25
+ constructor(field: string, value: string, enumName: string, validValues: string[], validKeys?: string[] | undefined);
26
+ }
27
+ /**
28
+ * Configuration for dynamic validation behavior
29
+ */
30
+ export interface DynamicValidationConfig {
31
+ enabled: boolean;
32
+ strict: boolean;
33
+ autoNormalize: boolean;
34
+ logWarnings: boolean;
35
+ serviceName?: string;
36
+ }
37
+ /**
38
+ * Information about a field that contains enum values
39
+ */
40
+ export interface FieldTypeInfo {
41
+ fieldName: string;
42
+ enumName: string;
43
+ isOptional: boolean;
44
+ isArray: boolean;
45
+ }
46
+ /**
47
+ * Check if a value is valid for a specific enum (includes normalization)
48
+ */
49
+ export declare function isValueValidForEnum(value: string, enumObject: Record<string, string>): boolean;
50
+ /**
51
+ * Detects the enum type for a field based on field name patterns and value analysis
52
+ */
53
+ export declare function detectEnumType(fieldName: string, value: string, serviceName?: string): {
54
+ enum: Record<string, string>;
55
+ name: string;
56
+ } | null;
57
+ /**
58
+ * Analyzes a single field to determine if it's an enum
59
+ */
60
+ export declare function analyzeField(fieldName: string, value: any, serviceName?: string): FieldTypeInfo | null;
61
+ /**
62
+ * Validate and normalize a single enum value
63
+ */
64
+ export declare function validateEnumValue(value: string, enumObject: Record<string, string>, enumName: string, fieldName: string, config: DynamicValidationConfig): {
65
+ isValid: boolean;
66
+ normalizedValue?: string;
67
+ error?: string;
68
+ };
@@ -0,0 +1,117 @@
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
+ /**
17
+ * Convenient enum validators for common Prime API enums.
18
+ * These provide pre-configured validation for frequently used enum types.
19
+ *
20
+ * Note: Most users should use the dynamic validation system instead, which
21
+ * automatically handles all enums. These validators are useful for explicit
22
+ * control or when you need to validate individual enum values.
23
+ */
24
+ import { normalizeEnumValue } from './enumHelpers';
25
+ import { OrderType } from '../model/enums/OrderType';
26
+ import { OrderSide } from '../model/enums/OrderSide';
27
+ import { OrderStatus } from '../model/enums/OrderStatus';
28
+ import { TransactionType } from '../model/enums/TransactionType';
29
+ import { TimeInForceType } from '../model/enums/TimeInForceType';
30
+ /**
31
+ * Order-related enum helpers
32
+ */
33
+ export declare const OrderEnums: {
34
+ /**
35
+ * Validates and normalizes order type values
36
+ * Accepts: 'market', 'limit', 'twap', 'block', 'vwap', 'stopLimit', 'rfq' (case-insensitive)
37
+ */
38
+ getOrderType: (input: string) => OrderType | undefined;
39
+ requireOrderType: (input: string) => OrderType;
40
+ isValidOrderType: (input: string) => boolean;
41
+ /**
42
+ * Validates and normalizes order side values
43
+ * Accepts: 'buy', 'sell' (case-insensitive)
44
+ */
45
+ getOrderSide: (input: string) => OrderSide | undefined;
46
+ requireOrderSide: (input: string) => OrderSide;
47
+ isValidOrderSide: (input: string) => boolean;
48
+ /**
49
+ * Validates and normalizes order status values
50
+ * Accepts: 'open', 'filled', 'cancelled', 'expired', 'failed', 'pending' (case-insensitive)
51
+ */
52
+ getOrderStatus: (input: string) => OrderStatus | undefined;
53
+ requireOrderStatus: (input: string) => OrderStatus;
54
+ isValidOrderStatus: (input: string) => boolean;
55
+ /**
56
+ * Validates and normalizes time in force type values
57
+ * Accepts: 'good_until_cancelled', 'good_until_time', 'immediate_or_cancel', 'fill_or_kill' (case-insensitive)
58
+ */
59
+ getTimeInForceType: (input: string) => TimeInForceType | undefined;
60
+ requireTimeInForceType: (input: string) => TimeInForceType;
61
+ isValidTimeInForceType: (input: string) => boolean;
62
+ };
63
+ /**
64
+ * Transaction-related enum helpers
65
+ */
66
+ export declare const TransactionEnums: {
67
+ /**
68
+ * Validates and normalizes transaction type values
69
+ * Accepts various transaction types like 'deposit', 'withdrawal', 'internalDeposit', etc. (case-insensitive)
70
+ */
71
+ getTransactionType: (input: string) => TransactionType | undefined;
72
+ requireTransactionType: (input: string) => TransactionType;
73
+ isValidTransactionType: (input: string) => boolean;
74
+ };
75
+ /**
76
+ * Utility for creating custom enum validators for any enum type
77
+ *
78
+ * @param enumObject - The enum object to create validators for
79
+ * @param enumName - Name of the enum for error messages
80
+ * @returns Object with validation methods
81
+ *
82
+ * @example
83
+ * import { WalletType } from '../model/enums/WalletType';
84
+ *
85
+ * const WalletValidators = createEnumValidators(WalletType, 'WalletType');
86
+ * WalletValidators.get('trading'); // Gets WalletType value
87
+ * WalletValidators.require('custody'); // Gets WalletType value or throws
88
+ * WalletValidators.isValid('invalid'); // false
89
+ */
90
+ export declare function createEnumValidators<T extends Record<string, string>>(enumObject: T, enumName: string): {
91
+ get: (input: string) => T[keyof T] | undefined;
92
+ require: (input: string) => T[keyof T];
93
+ isValid: (input: string) => boolean;
94
+ values: string[];
95
+ keys: string[];
96
+ };
97
+ /**
98
+ * Convenience function to normalize any string to enum format
99
+ * Useful for debugging or preparing values for API calls
100
+ *
101
+ * @example
102
+ * toEnumFormat('marketOrder') // 'MARKET_ORDER'
103
+ * toEnumFormat('buy') // 'BUY'
104
+ * toEnumFormat('stop-limit') // 'STOP_LIMIT'
105
+ */
106
+ export { normalizeEnumValue as toEnumFormat };
107
+ /**
108
+ * @deprecated Use the dynamic validation system instead.
109
+ *
110
+ * Most users should prefer:
111
+ * ```javascript
112
+ * import { dynamicValidateRequest } from '@coinbase/prime-sdk';
113
+ * const validated = dynamicValidateRequest(request);
114
+ * ```
115
+ *
116
+ * This provides automatic validation for all enum fields without manual configuration.
117
+ */
@@ -0,0 +1,36 @@
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 { CoinbasePrimeCredentials } from '../credentials';
17
+ /**
18
+ * Shared utility function to create credentials from environment variables
19
+ * Used by both CoinbasePrimeClient and CoinbasePrimeClientWithServices
20
+ *
21
+ * Automatically attempts to load .env file if dotenv is available.
22
+ * If dotenv is not installed or .env file doesn't exist, falls back to
23
+ * using environment variables set directly.
24
+ *
25
+ * @advanced For custom scenarios. Most users should use Client.fromEnv() instead.
26
+ * @example
27
+ * ```typescript
28
+ * // Basic usage (recommended)
29
+ * const client = CoinbasePrimeClient.fromEnv();
30
+ *
31
+ * // Advanced usage (custom scenarios)
32
+ * const credentials = createCredentialsFromEnv();
33
+ * const client = new CoinbasePrimeClient(credentials, 'custom-url');
34
+ * ```
35
+ */
36
+ export declare function createCredentialsFromEnv(): CoinbasePrimeCredentials;
@@ -0,0 +1,35 @@
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
+ /**
17
+ * Generate field name variations for plural/singular matching
18
+ */
19
+ export declare function getFieldNameVariations(fieldName: string): string[];
20
+ /**
21
+ * Extract context clues from field names to resolve enum ambiguity
22
+ */
23
+ export declare function extractContextClues(fieldName: string): string[];
24
+ /**
25
+ * Find enum with context awareness to resolve collisions
26
+ */
27
+ export declare function findEnumWithContext(fieldName: string, allEnumNames: string[]): string | null;
28
+ /**
29
+ * Dynamically find enum name based on field name patterns
30
+ */
31
+ export declare function findEnumByFieldName(fieldName: string): string | null;
32
+ /**
33
+ * Get direct field-to-enum mapping with service context and fallback to essential mappings
34
+ */
35
+ export declare function getDirectEnumMapping(fieldName: string, serviceName?: string): string | null;
@@ -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 'src/client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { SortDirection } from '../model/enums/SortDirection';
19
18
  /**
20
19
  * Base type for paginated requests
@@ -118,5 +117,5 @@ export declare const ResponseExtractors: {
118
117
  /**
119
118
  * Get the default pagination options for a client
120
119
  */
121
- export declare function getDefaultPaginationOptions(client: CoinbasePrimeClient, options: CoinbaseCallOptions | undefined): CoinbaseCallOptions;
122
- export declare function getQueryParams(client: CoinbasePrimeClient, request: BasePaginatedRequest): Record<string, string | number | string[]>;
120
+ export declare function getDefaultPaginationOptions(client: IPrimeApiClient, options: CoinbaseCallOptions | undefined): CoinbaseCallOptions;
121
+ export declare function getQueryParams(client: IPrimeApiClient, request: BasePaginatedRequest): Record<string, string | number | string[]>;
@@ -0,0 +1,46 @@
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
+ /**
17
+ * Service context for enhanced enum field detection
18
+ */
19
+ /**
20
+ * Service-specific enum mappings to resolve ambiguous field names
21
+ */
22
+ export interface ServiceEnumContext {
23
+ serviceName: string;
24
+ fieldMappings: Record<string, string>;
25
+ description?: string;
26
+ }
27
+ /**
28
+ * Registry of service contexts for accurate enum detection
29
+ */
30
+ export declare const SERVICE_CONTEXTS: Record<string, ServiceEnumContext>;
31
+ /**
32
+ * Get service context by service name
33
+ */
34
+ export declare function getServiceContext(serviceName: string): ServiceEnumContext | null;
35
+ /**
36
+ * Resolve field to enum using service context
37
+ */
38
+ export declare function resolveFieldWithServiceContext(fieldName: string, serviceName?: string): string | null;
39
+ /**
40
+ * Get all available service contexts
41
+ */
42
+ export declare function getAllServiceContexts(): Record<string, ServiceEnumContext>;
43
+ /**
44
+ * Check if a service has context defined
45
+ */
46
+ export declare function hasServiceContext(serviceName: string): boolean;
@@ -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 { CreateStakeRequest, CreateStakeResponse, CreateUnstakeRequest, CreateUnstakeResponse, CreatePortfolioStakeRequest, CreatePortfolioStakeResponse, CreatePortfolioUnstakeRequest, CreatePortfolioUnstakeResponse } from './types';
19
18
  export interface IStakingService {
20
19
  createStake(request: CreateStakeRequest, options?: CoinbaseCallOptions): Promise<CreateStakeResponse>;
@@ -24,7 +23,7 @@ export interface IStakingService {
24
23
  }
25
24
  export declare class StakingService implements IStakingService {
26
25
  private client;
27
- constructor(client: CoinbasePrimeClient);
26
+ constructor(client: IPrimeApiClient);
28
27
  createStake(request: CreateStakeRequest, options?: CoinbaseCallOptions): Promise<CreateStakeResponse>;
29
28
  createUnstake(request: CreateUnstakeRequest, options?: CoinbaseCallOptions): Promise<CreateUnstakeResponse>;
30
29
  createPortfolioStake(request: CreatePortfolioStakeRequest, options?: CoinbaseCallOptions): Promise<CreatePortfolioStakeResponse>;
@@ -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 { CreateConversionRequest, CreateConversionResponse, CreateOnchainTransactionRequest, CreateOnchainTransactionResponse, CreateTransferRequest, CreateTransferResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, GetTransactionRequest, GetTransactionResponse, ListPortfolioTransactionsRequest, ListPortfolioTransactionsResponse, ListWalletTransactionsRequest, ListWalletTransactionsResponse } from './types';
19
18
  export interface ITransactionsService {
20
19
  getTransaction(request: GetTransactionRequest, options?: CoinbaseCallOptions): Promise<GetTransactionResponse>;
@@ -27,7 +26,7 @@ export interface ITransactionsService {
27
26
  }
28
27
  export declare class TransactionsService implements ITransactionsService {
29
28
  private client;
30
- constructor(client: CoinbasePrimeClient);
29
+ constructor(client: IPrimeApiClient);
31
30
  getTransaction(request: GetTransactionRequest, options?: CoinbaseCallOptions): Promise<GetTransactionResponse>;
32
31
  listPortfolioTransactions(request: ListPortfolioTransactionsRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioTransactionsResponse>;
33
32
  listWalletTransactions(request: ListWalletTransactionsRequest, options?: CoinbaseCallOptions): Promise<ListWalletTransactionsResponse>;
@@ -0,0 +1,37 @@
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 type * from './model/';
17
+ export * from './model/enums/';
18
+ export type { IActivitiesService } from './activities';
19
+ export type { IAddressBooksService } from './addressBooks';
20
+ export type { IAllocationService } from './allocations';
21
+ export type { IAssetsService } from './assets';
22
+ export type { IBalancesService } from './balances';
23
+ export type { ICommissionService } from './commission';
24
+ export type { IFinancingService } from './financing';
25
+ export type { IFuturesService } from './futures';
26
+ export type { IInvoicesService } from './invoices';
27
+ export type { OnchainAddressBookService } from './onchainAddressBook';
28
+ export type { IOrdersService } from './orders';
29
+ export type { IPaymentMethodsService } from './paymentMethods';
30
+ export type { IPortfoliosService } from './portfolios';
31
+ export type { IPositionsService } from './positions';
32
+ export type { IProductsService } from './products';
33
+ export type { IStakingService } from './staking';
34
+ export type { ITransactionsService } from './transactions';
35
+ export type { IUsersService } from './users';
36
+ export type { IWalletsService } from './wallets';
37
+ export { IPrimeApiClient, CoinbasePrimeClientConfig, CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from './clients';
@@ -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 { ListPortfolioUsersRequest, ListPortfolioUsersResponse, ListUsersRequest, ListUsersResponse } from './types';
19
18
  export interface IUsersService {
20
19
  listUsers(request: ListUsersRequest, options?: CoinbaseCallOptions): Promise<ListUsersResponse>;
@@ -22,7 +21,7 @@ export interface IUsersService {
22
21
  }
23
22
  export declare class UsersService implements IUsersService {
24
23
  private client;
25
- constructor(client: CoinbasePrimeClient);
24
+ constructor(client: IPrimeApiClient);
26
25
  listUsers(request: ListUsersRequest, options?: CoinbaseCallOptions): Promise<ListUsersResponse>;
27
26
  listPortfolioUsers(request: ListPortfolioUsersRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioUsersResponse>;
28
27
  }
@@ -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 { ListWalletsRequest, ListWalletsResponse, GetWalletRequest, GetWalletResponse, GetWalletDepositInstructionsRequest, GetWalletDepositInstructionsResponse, ListWalletAddressesRequest, ListWalletAddressesResponse, CreateWalletRequest, CreateWalletResponse, CreateWalletDepositAddressRequest, CreateWalletDepositAddressResponse } from './types';
19
18
  export interface IWalletsService {
20
19
  listWallets(request: ListWalletsRequest, options?: CoinbaseCallOptions): Promise<ListWalletsResponse>;
@@ -26,7 +25,7 @@ export interface IWalletsService {
26
25
  }
27
26
  export declare class WalletsService implements IWalletsService {
28
27
  private client;
29
- constructor(client: CoinbasePrimeClient);
28
+ constructor(client: IPrimeApiClient);
30
29
  listWallets(request: ListWalletsRequest, options?: CoinbaseCallOptions): Promise<ListWalletsResponse>;
31
30
  getWallet(request: GetWalletRequest, options?: CoinbaseCallOptions): Promise<GetWalletResponse>;
32
31
  getWalletDepositInstructions(request: GetWalletDepositInstructionsRequest, options?: CoinbaseCallOptions): Promise<GetWalletDepositInstructionsResponse>;