@gala-chain/launchpad-sdk 3.5.2 → 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.
Files changed (50) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +23 -1
  3. package/dist/constants/endpoints.d.ts +38 -0
  4. package/dist/constants/endpoints.d.ts.map +1 -0
  5. package/dist/index.cjs.js +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.esm.js +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/schemas/files.d.ts +63 -0
  11. package/dist/schemas/files.d.ts.map +1 -0
  12. package/dist/schemas/index.d.ts +82 -0
  13. package/dist/schemas/index.d.ts.map +1 -0
  14. package/dist/schemas/launchpad.d.ts +188 -0
  15. package/dist/schemas/launchpad.d.ts.map +1 -0
  16. package/dist/schemas/pagination.d.ts +208 -0
  17. package/dist/schemas/pagination.d.ts.map +1 -0
  18. package/dist/schemas/primitives.d.ts +144 -0
  19. package/dist/schemas/primitives.d.ts.map +1 -0
  20. package/dist/schemas/trade.d.ts +192 -0
  21. package/dist/schemas/trade.d.ts.map +1 -0
  22. package/dist/schemas/user.d.ts +251 -0
  23. package/dist/schemas/user.d.ts.map +1 -0
  24. package/dist/schemas/validators.d.ts +243 -0
  25. package/dist/schemas/validators.d.ts.map +1 -0
  26. package/dist/services/CommentService.d.ts +71 -0
  27. package/dist/services/CommentService.d.ts.map +1 -0
  28. package/dist/services/FaucetService.d.ts +55 -0
  29. package/dist/services/FaucetService.d.ts.map +1 -0
  30. package/dist/services/ImageService.d.ts +81 -0
  31. package/dist/services/ImageService.d.ts.map +1 -0
  32. package/dist/services/LaunchpadService.d.ts +57 -298
  33. package/dist/services/LaunchpadService.d.ts.map +1 -1
  34. package/dist/services/PoolService.d.ts +114 -0
  35. package/dist/services/PoolService.d.ts.map +1 -0
  36. package/dist/services/TradeService.d.ts +55 -0
  37. package/dist/services/TradeService.d.ts.map +1 -0
  38. package/dist/services/UserService.d.ts +121 -0
  39. package/dist/services/UserService.d.ts.map +1 -0
  40. package/dist/types/launchpad.validation.d.ts +9 -6
  41. package/dist/types/launchpad.validation.d.ts.map +1 -1
  42. package/dist/utils/multipart.d.ts +4 -1
  43. package/dist/utils/multipart.d.ts.map +1 -1
  44. package/dist/utils/query-params.d.ts +98 -0
  45. package/dist/utils/query-params.d.ts.map +1 -0
  46. package/dist/utils/response-normalizers.d.ts +133 -0
  47. package/dist/utils/response-normalizers.d.ts.map +1 -0
  48. package/dist/utils/validation.d.ts +13 -10
  49. package/dist/utils/validation.d.ts.map +1 -1
  50. package/package.json +4 -2
@@ -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.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserService.d.ts","sourceRoot":"","sources":["../../src/services/UserService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EAEjB,yBAAyB,EAO1B,MAAM,mBAAmB,CAAC;AAO3B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;OAMG;IACG,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAmBlD;;;;;;;;;;;OAWG;IACG,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmD3D;;;;;;;OAOG;IACG,kBAAkB,CACtB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC;IAoElB;;;;;;OAMG;IACG,cAAc,CAClB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,mBAAmB,CAAC;IA4C/B;;;;;;OAMG;IACG,eAAe,CACnB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,mBAAmB,CAAC;IA2C/B;;;;;OAKG;IACG,kBAAkB,CACtB,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO,GACnF,OAAO,CAAC,mBAAmB,CAAC;IAsB/B;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAuCnC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IA0B9B;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAkBjC;;;;OAIG;IACH,OAAO,CAAC,iCAAiC;CAW1C"}
@@ -3,18 +3,21 @@
3
3
  *
4
4
  * These functions provide client-side validation to catch errors
5
5
  * before making API calls to the backend.
6
+ *
7
+ * MIGRATION NOTE: This file now uses Zod validators from schemas/validators.ts
8
+ * while maintaining backward-compatible API for legacy code.
6
9
  */
7
- import { LaunchTokenData } from './launchpad.dto';
10
+ import type { LaunchTokenData } from './launchpad.dto.js';
8
11
  /**
9
- * Validates token name format
12
+ * Validates token name format using Zod schema
10
13
  */
11
14
  export declare function isValidTokenName(name: string): boolean;
12
15
  /**
13
- * Validates token symbol format
16
+ * Validates token symbol format using Zod schema
14
17
  */
15
18
  export declare function isValidTokenSymbol(symbol: string): boolean;
16
19
  /**
17
- * Validates token description format
20
+ * Validates token description format using Zod schema
18
21
  */
19
22
  export declare function isValidTokenDescription(description: string): boolean;
20
23
  /**
@@ -26,11 +29,11 @@ export declare function isValidUrl(url: string): boolean;
26
29
  */
27
30
  export declare function hasAtLeastOneSocialUrl(data: LaunchTokenData): boolean;
28
31
  /**
29
- * Type guard to check if an object is valid LaunchTokenData
32
+ * Type guard to check if an object is valid LaunchTokenData using Zod schema
30
33
  */
31
34
  export declare function isValidLaunchTokenData(obj: any): obj is LaunchTokenData;
32
35
  /**
33
- * Generates detailed validation error messages for LaunchTokenData
36
+ * Generates detailed validation error messages for LaunchTokenData using Zod
34
37
  */
35
38
  export declare function getLaunchTokenDataValidationErrors(obj: any): string[];
36
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"launchpad.validation.d.ts","sourceRoot":"","sources":["../../src/types/launchpad.validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAyB,MAAM,iBAAiB,CAAC;AAMzE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAa1D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAQpE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAM/C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAarE;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,eAAe,CAmDvE;AAMD;;GAEG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,CA4DrE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,IAAI,IAAI,eAAe,CAQjC"}
1
+ {"version":3,"file":"launchpad.validation.d.ts","sourceRoot":"","sources":["../../src/types/launchpad.validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAM1D;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGtD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAG1D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAGpE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO/C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CASrE;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,eAAe,CAGvE;AAMD;;GAEG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,CAQrE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,GAAG,GACR,OAAO,CAAC,IAAI,IAAI,eAAe,CAQjC"}
@@ -3,6 +3,9 @@
3
3
  *
4
4
  * This module provides cross-platform file upload support for both
5
5
  * browser and Node.js environments.
6
+ *
7
+ * MIGRATION NOTE: This file now uses Zod schemas for validation while maintaining
8
+ * backward-compatible API through FileValidationError throwing functions.
6
9
  */
7
10
  /**
8
11
  * Error thrown when file validation fails
@@ -13,7 +16,7 @@ export declare class FileValidationError extends Error {
13
16
  constructor(message: string, filename?: string | undefined, mimeType?: string | undefined);
14
17
  }
15
18
  /**
16
- * Validates a file against upload constraints
19
+ * Validates a file against upload constraints using Zod schemas
17
20
  *
18
21
  * @param file File or Buffer to validate
19
22
  * @param filename Original filename (required for Buffer validation)
@@ -1 +1 @@
1
- {"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../src/utils/multipart.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAGnC,QAAQ,CAAC,EAAE,MAAM;IACjB,QAAQ,CAAC,EAAE,MAAM;gBAFxB,OAAO,EAAE,MAAM,EACR,QAAQ,CAAC,EAAE,MAAM,YAAA,EACjB,QAAQ,CAAC,EAAE,MAAM,YAAA;CAK3B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,GAAG,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,CAAC,E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AAc,CAC5B,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACzB,QAAQ,CAiBV;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACzB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CA0CnD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAuB9C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAM3C"}
@@ -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"}
@@ -1,11 +1,14 @@
1
1
  /**
2
2
  * Validation utilities for Launchpad API operations
3
3
  *
4
- * This module provides input validation to catch issues before making API calls,
4
+ * This module provides input validation using Zod schemas to catch issues before making API calls,
5
5
  * improving error messages and reducing unnecessary network requests.
6
+ *
7
+ * MIGRATION NOTE: This file now uses Zod schemas for validation while maintaining
8
+ * backward-compatible API through ValidationError throwing functions.
6
9
  */
7
- import { TokenUrls, CheckPoolOptions, FetchPoolOptions, GetAmountOptions, GetGraphOptions } from '../types/launchpad.dto';
8
- import { AddressFormat } from '../types/common';
10
+ import { FetchPoolOptions, GetAmountOptions, GetGraphOptions, CheckPoolOptions, TokenUrls } from '../types/launchpad.dto.js';
11
+ import { AddressFormat } from '../types/common.js';
9
12
  /**
10
13
  * Error thrown when validation fails
11
14
  */
@@ -71,6 +74,13 @@ export declare function validateGetGraphOptions(options: GetGraphOptions): void;
71
74
  * @throws ValidationError if validation fails
72
75
  */
73
76
  export declare function validateCreatePoolData(data: any): void;
77
+ /**
78
+ * Validates launch token data (for bundle backend)
79
+ *
80
+ * @param data Token launch data to validate
81
+ * @throws ValidationError if validation fails
82
+ */
83
+ export declare function validateLaunchTokenData(data: any): void;
74
84
  /**
75
85
  * Converts Ethereum address to backend format
76
86
  *
@@ -101,13 +111,6 @@ export declare function fromBackendAddressFormat(backendAddress: string): string
101
111
  * ```
102
112
  */
103
113
  export declare function normalizeAddressInput(address: string | undefined): AddressFormat | undefined;
104
- /**
105
- * Validates launch token data (for bundle backend)
106
- *
107
- * @param data Token launch data to validate
108
- * @throws ValidationError if validation fails
109
- */
110
- export declare function validateLaunchTokenData(data: any): void;
111
114
  export declare function isValidEthereumAddress(address: string): boolean;
112
115
  export declare function isValidAddressFormat(address: string): address is AddressFormat;
113
116
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAIL,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAG/B,KAAK,CAAC,EAAE,MAAM;IACd,IAAI,CAAC,EAAE,MAAM;gBAFpB,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,MAAM,YAAA,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAgCzD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,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AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAKvD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,MAAM,GAAG,aAAa,CAU7E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAoBvE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,aAAa,GAAG,SAAS,CAe3B;AAGD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GACd,OAAO,IAAI,aAAa,CAQ1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,MAAM,CAuBR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,GACnB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkBxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gala-chain/launchpad-sdk",
3
- "version": "3.5.2",
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",
@@ -133,7 +133,9 @@
133
133
  "dotenv": "^17.2.3",
134
134
  "ethers": "^6.15.0",
135
135
  "socket.io-client": "^4.8.1",
136
- "uuid": "^13.0.0"
136
+ "uuid": "^13.0.0",
137
+ "zod": "^3.25.76",
138
+ "zod-to-json-schema": "^3.24.6"
137
139
  },
138
140
  "size-limit": [
139
141
  {