@gala-chain/launchpad-sdk 3.5.3 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Trade Service
3
+ *
4
+ * Handles all trade-related operations including trade history queries.
5
+ *
6
+ * @category Services
7
+ * @since 3.6.0
8
+ */
9
+ import { HttpClient } from '../utils/http';
10
+ import { TradesResult } from '../types/trade.dto';
11
+ import { FetchTradesOptions } from '../types/options.dto';
12
+ /**
13
+ * Trade Service Class
14
+ *
15
+ * Provides methods for:
16
+ * - Fetching trade history with pagination
17
+ * - Filtering trades by token, user, type, date range
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const tradeService = new TradeService(httpClient);
22
+ *
23
+ * // Get first page of trades for a token
24
+ * const trades = await tradeService.fetchTrades({ tokenName: "dragnrkti" });
25
+ *
26
+ * // Get specific page with custom limit
27
+ * const moreTrades = await tradeService.fetchTrades({
28
+ * tokenName: "dragnrkti",
29
+ * page: 2,
30
+ * limit: 20
31
+ * });
32
+ * ```
33
+ */
34
+ export declare class TradeService {
35
+ private readonly http;
36
+ constructor(http: HttpClient);
37
+ /**
38
+ * Gets trades for a token by its tokenName with pagination
39
+ *
40
+ * This method provides a clean, intuitive API for fetching token trades
41
+ * using the token name. Follows the same pattern as CommentAPI.
42
+ *
43
+ * @param options Trade fetching options
44
+ * @returns Promise<TradesResult> Clean trades with full pagination
45
+ * @throws ValidationError if token name is invalid or not found
46
+ */
47
+ fetchTrades(options: FetchTradesOptions): Promise<TradesResult>;
48
+ /**
49
+ * Validates pagination parameters
50
+ *
51
+ * @private
52
+ */
53
+ private validateTradePagination;
54
+ }
55
+ //# sourceMappingURL=TradeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TradeService.d.ts","sourceRoot":"","sources":["../../src/services/TradeService.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAEL,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAwB,MAAM,sBAAsB,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;OASG;IACG,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IA2DrE;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;CAyBhC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * User Service
3
+ *
4
+ * Handles all user-related operations including profile management,
5
+ * token lists, and user data queries.
6
+ *
7
+ * @category Services
8
+ * @since 3.6.0
9
+ */
10
+ import { HttpClient } from '../utils/http';
11
+ import { GetTokenListOptions, UserTokenListResult, UpdateProfileData, UploadProfileImageOptions } from '../types/user.dto';
12
+ /**
13
+ * User Service Class
14
+ *
15
+ * Provides methods for:
16
+ * - Profile management (fetch, update)
17
+ * - Profile image uploads
18
+ * - Token list queries (created, held)
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const userService = new UserService(httpClient);
23
+ *
24
+ * // Get user profile
25
+ * const profile = await userService.fetchProfile();
26
+ *
27
+ * // Update profile
28
+ * await userService.updateProfile({
29
+ * profileImage: "https://example.com/avatar.jpg",
30
+ * fullName: "John Doe",
31
+ * address: "eth|1234..."
32
+ * });
33
+ * ```
34
+ */
35
+ export declare class UserService {
36
+ private readonly http;
37
+ constructor(http: HttpClient);
38
+ /**
39
+ * Fetches user profile information
40
+ *
41
+ * @param address Optional wallet address (defaults to SDK wallet address)
42
+ * @returns Promise<any> User profile information
43
+ * @throws ValidationError if input validation fails
44
+ */
45
+ fetchProfile(address?: string): Promise<any>;
46
+ /**
47
+ * Updates user profile information
48
+ *
49
+ * **Smart Image Preservation**: If profileImage is empty or not provided,
50
+ * the method automatically fetches and preserves the existing profile image
51
+ * to prevent accidental image loss.
52
+ *
53
+ * @param data Profile update data
54
+ * @returns Promise<void> No return data - throws on failure
55
+ * @throws ValidationError if input validation fails
56
+ * @throws Error if profile update fails
57
+ */
58
+ updateProfile(data: UpdateProfileData): Promise<void>;
59
+ /**
60
+ * Uploads a profile image and returns the image URL
61
+ *
62
+ * @param options Profile image upload options
63
+ * @returns Promise<string> Clean image URL
64
+ * @throws ValidationError if input validation fails
65
+ * @throws Error if upload fails
66
+ */
67
+ uploadProfileImage(options: UploadProfileImageOptions): Promise<string>;
68
+ /**
69
+ * Fetches user token list with optional filtering and pagination
70
+ *
71
+ * @param options Filtering and pagination options
72
+ * @returns Promise<UserTokenListResult> Clean token list with proper types
73
+ * @throws Error if request fails
74
+ */
75
+ fetchTokenList(options: GetTokenListOptions): Promise<UserTokenListResult>;
76
+ /**
77
+ * Fetches tokens held by user (balances)
78
+ *
79
+ * @param options Token held filtering options (address is optional)
80
+ * @returns Promise<UserTokenListResult> Clean tokens held with full pagination
81
+ * @throws ValidationError if input validation fails
82
+ */
83
+ fetchTokensHeld(options: GetTokenListOptions): Promise<UserTokenListResult>;
84
+ /**
85
+ * Fetches tokens created by user
86
+ *
87
+ * @param options Options including pagination
88
+ * @returns Promise<UserTokenListResult> Tokens created by the user
89
+ */
90
+ fetchTokensCreated(options?: {
91
+ page?: number;
92
+ limit?: number;
93
+ search?: string;
94
+ tokenName?: string;
95
+ }): Promise<UserTokenListResult>;
96
+ /**
97
+ * Validates get token list options
98
+ *
99
+ * @private
100
+ */
101
+ private validateGetTokenListOptions;
102
+ /**
103
+ * Validates user pagination parameters
104
+ *
105
+ * @private
106
+ */
107
+ private validateUserPagination;
108
+ /**
109
+ * Validates update profile data
110
+ *
111
+ * @private
112
+ */
113
+ private validateUpdateProfileData;
114
+ /**
115
+ * Validates upload profile image options
116
+ *
117
+ * @private
118
+ */
119
+ private validateUploadProfileImageOptions;
120
+ }
121
+ //# sourceMappingURL=UserService.d.ts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AAC,iCAAiC;CAW1C"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Query Parameter Building Utilities
3
+ *
4
+ * Unified utilities for building backend query parameters.
5
+ * Replaces multiple duplicate query building methods with a single,
6
+ * type-safe, reusable utility.
7
+ *
8
+ * @category Utilities
9
+ * @since 3.6.0
10
+ */
11
+ /**
12
+ * Configuration for field transformations
13
+ */
14
+ export interface QueryParamConfig<T> {
15
+ /** Fields that should be converted to strings */
16
+ stringifyFields?: (keyof T)[];
17
+ /** Fields that should be excluded if undefined/empty */
18
+ optionalFields?: (keyof T)[];
19
+ /** Custom field name mappings (source -> backend) */
20
+ fieldMappings?: Partial<Record<keyof T, string>>;
21
+ }
22
+ /**
23
+ * Builds backend query parameters from typed options object
24
+ *
25
+ * This utility consolidates the logic from multiple query building methods:
26
+ * - buildGetCommentsQueryParams
27
+ * - buildTradeQueryParams
28
+ * - buildTokenListQueryParams
29
+ * - buildTokenHoldQueryParams
30
+ *
31
+ * @template T The type of the input options object
32
+ * @param options Input options to convert to query parameters
33
+ * @param config Configuration for field transformations
34
+ * @returns Query parameters ready for backend API
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Simple pagination
39
+ * const params = buildBackendQueryParams(
40
+ * { page: 1, limit: 10 },
41
+ * { stringifyFields: ['page', 'limit'] }
42
+ * );
43
+ * // Result: { page: '1', limit: '10' }
44
+ *
45
+ * // With optional fields
46
+ * const params = buildBackendQueryParams(
47
+ * { page: 1, limit: 10, search: 'test', tokenName: undefined },
48
+ * {
49
+ * stringifyFields: ['page', 'limit'],
50
+ * optionalFields: ['search', 'tokenName']
51
+ * }
52
+ * );
53
+ * // Result: { page: '1', limit: '10', search: 'test' }
54
+ *
55
+ * // With field mappings
56
+ * const params = buildBackendQueryParams(
57
+ * { walletAddress: 'eth|123', amount: '100' },
58
+ * { fieldMappings: { walletAddress: 'userAddress' } }
59
+ * );
60
+ * // Result: { userAddress: 'eth|123', amount: '100' }
61
+ * ```
62
+ */
63
+ export declare function buildBackendQueryParams<T extends Record<string, any>>(options: T, config?: QueryParamConfig<T>): Record<string, any>;
64
+ /**
65
+ * Builds pagination query parameters (common pattern)
66
+ *
67
+ * Convenience function for the most common use case: pagination with page/limit.
68
+ *
69
+ * @param page Page number
70
+ * @param limit Items per page
71
+ * @returns Query parameters with stringified page and limit
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const params = buildPaginationParams(2, 20);
76
+ * // Result: { page: '2', limit: '20' }
77
+ * ```
78
+ */
79
+ export declare function buildPaginationParams(page: number, limit: number): Record<string, string>;
80
+ /**
81
+ * Builds token query parameters with pagination
82
+ *
83
+ * Common pattern for token-related endpoints that support
84
+ * pagination plus optional filters.
85
+ *
86
+ * @param tokenName Token name to query
87
+ * @param page Page number
88
+ * @param limit Items per page
89
+ * @returns Query parameters ready for backend API
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const params = buildTokenQueryParams('mytoken', 1, 10);
94
+ * // Result: { tokenName: 'mytoken', page: '1', limit: '10' }
95
+ * ```
96
+ */
97
+ export declare function buildTokenQueryParams(tokenName: string, page: number, limit: number): Record<string, any>;
98
+ //# sourceMappingURL=query-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../src/utils/query-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,iDAAiD;IACjD,eAAe,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAC9B,wDAAwD;IACxD,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAC7B,qDAAqD;IACrD,aAAa,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnE,OAAO,EAAE,CAAC,EACV,MAAM,GAAE,gBAAgB,CAAC,CAAC,CAAM,GAC/B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAyCrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKxB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAKrB"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Response Normalization Utilities
3
+ *
4
+ * Utilities for normalizing backend API responses into consistent formats.
5
+ * Handles the various response structure variations from the backend API,
6
+ * reducing complexity in service methods.
7
+ *
8
+ * @category Utilities
9
+ * @since 3.6.0
10
+ */
11
+ /**
12
+ * Normalizes pool response data into consistent array format
13
+ *
14
+ * The backend API returns pools in different formats depending on the query:
15
+ * - Single token: { tokens: {pool data} }
16
+ * - Multiple tokens: { tokens: [{pool data}] }
17
+ * - Legacy format: { pools: [{pool data}] }
18
+ *
19
+ * This normalizer ensures we always get an array of pools with proper Date objects.
20
+ *
21
+ * @param data Raw response data from backend
22
+ * @returns Normalized array of pools with Date objects
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Single token response
27
+ * const normalized = normalizePoolResponse({
28
+ * tokens: { id: 1, created_at: '2024-01-01' }
29
+ * });
30
+ * // Result: [{ id: 1, createdAt: Date('2024-01-01') }]
31
+ *
32
+ * // Multiple tokens response
33
+ * const normalized = normalizePoolResponse({
34
+ * tokens: [{ id: 1, created_at: '2024-01-01' }, { id: 2, created_at: '2024-01-02' }]
35
+ * });
36
+ * // Result: [{ id: 1, createdAt: Date('2024-01-01') }, { id: 2, createdAt: Date('2024-01-02') }]
37
+ * ```
38
+ */
39
+ export declare function normalizePoolResponse(data: any): any[];
40
+ /**
41
+ * Normalizes trade response data into consistent array format
42
+ *
43
+ * The backend API returns trades in different formats:
44
+ * - Direct array: [trade1, trade2]
45
+ * - Wrapped object: { trades: [trade1, trade2] }
46
+ *
47
+ * This normalizer ensures we always get an array of trades with proper Date objects.
48
+ *
49
+ * @param data Raw response data from backend
50
+ * @returns Normalized array of trades with Date objects
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const normalized = normalizeTradeResponse({
55
+ * trades: [
56
+ * { id: 1, createdAt: '2024-01-01', updatedAt: '2024-01-01' }
57
+ * ]
58
+ * });
59
+ * // Result: [{ id: 1, createdAt: Date(...), updatedAt: Date(...) }]
60
+ * ```
61
+ */
62
+ export declare function normalizeTradeResponse(data: any): any[];
63
+ /**
64
+ * Normalizes token list response data into consistent array format
65
+ *
66
+ * The backend API returns token lists in different formats:
67
+ * - Direct array: [token1, token2]
68
+ * - Wrapped object: { token: [token1, token2] }
69
+ *
70
+ * This normalizer ensures we always get an array of tokens with proper Date objects.
71
+ *
72
+ * @param data Raw response data from backend
73
+ * @returns Normalized array of tokens with Date objects
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const normalized = normalizeTokenListResponse({
78
+ * token: [
79
+ * { id: 1, createdAt: '2024-01-01', updatedAt: '2024-01-01' }
80
+ * ]
81
+ * });
82
+ * // Result: [{ id: 1, createdAt: Date(...), updatedAt: Date(...) }]
83
+ * ```
84
+ */
85
+ export declare function normalizeTokenListResponse(data: any): any[];
86
+ /**
87
+ * Extracts pagination metadata from backend response
88
+ *
89
+ * Safely extracts page, limit, and total from various response formats,
90
+ * providing defaults when fields are missing.
91
+ *
92
+ * @param response Raw backend response
93
+ * @param defaults Default values for page and limit
94
+ * @returns Normalized pagination metadata
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const pagination = extractPaginationMetadata(
99
+ * { page: '2', limit: '10', total: '100' },
100
+ * { page: 1, limit: 10 }
101
+ * );
102
+ * // Result: { page: 2, limit: 10, total: 100, totalPages: 10 }
103
+ * ```
104
+ */
105
+ export declare function extractPaginationMetadata(response: any, defaults: {
106
+ page: number;
107
+ limit: number;
108
+ }): {
109
+ page: number;
110
+ limit: number;
111
+ total: number;
112
+ totalPages: number;
113
+ };
114
+ /**
115
+ * Creates pagination helper flags
116
+ *
117
+ * Calculates hasNext and hasPrevious flags based on current page and total pages.
118
+ *
119
+ * @param page Current page number
120
+ * @param totalPages Total number of pages
121
+ * @returns Pagination navigation flags
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * const flags = createPaginationFlags(2, 5);
126
+ * // Result: { hasNext: true, hasPrevious: true }
127
+ * ```
128
+ */
129
+ export declare function createPaginationFlags(page: number, totalPages: number): {
130
+ hasNext: boolean;
131
+ hasPrevious: boolean;
132
+ };
133
+ //# sourceMappingURL=response-normalizers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-normalizers.d.ts","sourceRoot":"","sources":["../../src/utils/response-normalizers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,CAgCtD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,CAkBvD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,CAc3D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,GAAG,EACb,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACxC;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,CAOA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAKA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gala-chain/launchpad-sdk",
3
- "version": "3.5.3",
3
+ "version": "3.6.0",
4
4
  "description": "TypeScript SDK for Gala Launchpad Backend API - Production-ready DeFi token launchpad integration with wallet-based authentication, GalaChain trading, and comprehensive user operations. 100% tested (22/22 endpoints working).",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",