@gala-chain/launchpad-sdk 3.5.3 → 3.6.1

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 (33) 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.esm.js +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/schemas/validators.d.ts +130 -32
  9. package/dist/schemas/validators.d.ts.map +1 -1
  10. package/dist/services/BundleService.d.ts.map +1 -1
  11. package/dist/services/CommentService.d.ts +71 -0
  12. package/dist/services/CommentService.d.ts.map +1 -0
  13. package/dist/services/FaucetService.d.ts +55 -0
  14. package/dist/services/FaucetService.d.ts.map +1 -0
  15. package/dist/services/ImageService.d.ts +81 -0
  16. package/dist/services/ImageService.d.ts.map +1 -0
  17. package/dist/services/LaunchpadService.d.ts +57 -298
  18. package/dist/services/LaunchpadService.d.ts.map +1 -1
  19. package/dist/services/PoolService.d.ts +114 -0
  20. package/dist/services/PoolService.d.ts.map +1 -0
  21. package/dist/services/TradeService.d.ts +55 -0
  22. package/dist/services/TradeService.d.ts.map +1 -0
  23. package/dist/services/UserService.d.ts +121 -0
  24. package/dist/services/UserService.d.ts.map +1 -0
  25. package/dist/utils/error-factories.d.ts +95 -0
  26. package/dist/utils/error-factories.d.ts.map +1 -0
  27. package/dist/utils/query-params.d.ts +98 -0
  28. package/dist/utils/query-params.d.ts.map +1 -0
  29. package/dist/utils/response-handlers.d.ts +96 -0
  30. package/dist/utils/response-handlers.d.ts.map +1 -0
  31. package/dist/utils/response-normalizers.d.ts +133 -0
  32. package/dist/utils/response-normalizers.d.ts.map +1 -0
  33. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,76 @@ All notable changes to the Gala Launchpad SDK will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.6.0] - 2025-10-02
8
+
9
+ ### Changed
10
+ - **Major architectural refactoring** - LaunchpadService decomposed into specialized services
11
+ - Extracted PoolService (~400 lines) - Pool queries, distribution, badges, volume data
12
+ - Extracted TradeService (~150 lines) - Trade history and queries
13
+ - Extracted CommentService (~200 lines) - Comments with vault resolution
14
+ - Extracted UserService (~400 lines) - Profile management and token lists
15
+ - Extracted ImageService (~150 lines) - Image upload operations
16
+ - Extracted FaucetService (~100 lines) - Faucet transfer operations
17
+ - Rewrote LaunchpadService as facade pattern (1,657 → 384 lines, 76.8% reduction)
18
+ - All public methods maintained for 100% backward compatibility
19
+
20
+ ### Added
21
+ - **Centralized constants** - `constants/endpoints.ts` eliminates magic strings
22
+ - 14 API endpoint URLs now defined in single location
23
+ - Type-safe via `as const` assertion
24
+ - Easier to maintain and update
25
+ - **Unified query builder** - `utils/query-params.ts` consolidates 4 duplicate methods
26
+ - `buildBackendQueryParams()` - Generic query parameter builder
27
+ - `buildPaginationParams()` - Common pagination pattern
28
+ - `buildTokenQueryParams()` - Token-specific queries
29
+ - Configurable field transformations (stringification, mappings, optional fields)
30
+ - Reduced from 81 lines (4 methods) to 30 lines (1 generic utility)
31
+ - **Response normalizers** - `utils/response-normalizers.ts` for consistent data handling
32
+ - `normalizePoolResponse()` - Handles multiple backend pool formats
33
+ - `normalizeTradeResponse()` - Standardizes trade data
34
+ - `normalizeTokenListResponse()` - Unifies token list formats
35
+ - `normalizeCommentResponse()` - Comment data transformation
36
+ - `extractPaginationMetadata()` - Pagination info extraction
37
+ - `createPaginationFlags()` - hasNext/hasPrevious flag generation
38
+
39
+ ### Removed
40
+ - **Eliminated code duplication** - 163 lines of inline validation removed
41
+ - All validation now uses centralized utilities
42
+ - No functionality lost, just consolidated
43
+ - **Deprecated query builders** - 4 nearly-identical methods replaced
44
+ - `buildGetCommentsQueryParams` → `buildBackendQueryParams`
45
+ - `buildTradeQueryParams` → `buildBackendQueryParams`
46
+ - `buildTokenListQueryParams` → `buildBackendQueryParams`
47
+ - `buildTokenHoldQueryParams` → `buildBackendQueryParams`
48
+
49
+ ### Fixed
50
+ - **TypeScript strict mode compliance** - Fixed exactOptionalPropertyTypes issues
51
+ - Conditional property assignment pattern for optional fields
52
+ - Type-safe field mapping in query builder
53
+ - All compilation errors resolved
54
+
55
+ ### Benefits
56
+ - ✅ **76.8% reduction** in main service file (1,657 → 384 lines)
57
+ - ✅ **100% backward compatible** - All public methods unchanged
58
+ - ✅ **Single Responsibility Principle** - Each service has one clear purpose
59
+ - ✅ **Improved maintainability** - Easier to locate and modify functionality
60
+ - ✅ **Reduced duplication** - 244 lines eliminated (163 validation + 81 query builders)
61
+ - ✅ **Better testability** - Services can be tested in isolation
62
+ - ✅ **Modern patterns** - Template literals, optional chaining, nullish coalescing
63
+ - ✅ **All tests passing** - 53/53 tests verified
64
+
65
+ ### Architecture
66
+ New service structure (facade pattern):
67
+ ```
68
+ LaunchpadService (facade)
69
+ ├── PoolService - Pool operations
70
+ ├── TradeService - Trade history
71
+ ├── CommentService - Social features
72
+ ├── UserService - Profile & token lists
73
+ ├── ImageService - Image uploads
74
+ └── FaucetService - Faucet transfers
75
+ ```
76
+
7
77
  ## [3.5.2] - 2025-10-02
8
78
 
9
79
  ### Changed
package/README.md CHANGED
@@ -687,7 +687,29 @@ import {
687
687
 
688
688
  ### Service Responsibilities
689
689
 
690
- **LaunchpadService** - Launchpad Backend Operations
690
+ **LaunchpadService** - Launchpad Backend Operations (Facade)
691
+
692
+ LaunchpadService uses a **facade pattern** internally, delegating to specialized sub-services:
693
+
694
+ ```typescript
695
+ // Internal architecture (v3.6.0+)
696
+ LaunchpadService (facade)
697
+ ├── PoolService - Pool queries, distribution, badges, volume data
698
+ ├── TradeService - Trade history and queries
699
+ ├── CommentService - Comments with vault resolution
700
+ ├── UserService - Profile management and token lists
701
+ ├── ImageService - Image upload operations
702
+ └── FaucetService - Faucet transfer operations
703
+ ```
704
+
705
+ **Facade Benefits:**
706
+ - ✅ Single responsibility: Each sub-service has one clear purpose
707
+ - ✅ Maintainability: 76.8% reduction in main service file (1,657 → 384 lines)
708
+ - ✅ Code reuse: Shared utilities for query building and response normalization
709
+ - ✅ Backward compatibility: All public methods unchanged
710
+ - ✅ Testability: Sub-services can be tested independently
711
+
712
+ **Public API (unchanged):**
691
713
  - Pool management (fetch, create, check)
692
714
  - Trade history
693
715
  - Comments (post, fetch)
@@ -0,0 +1,38 @@
1
+ /**
2
+ * API Endpoint Constants
3
+ *
4
+ * Centralized definition of all launchpad-backend API endpoints.
5
+ * This prevents magic strings scattered throughout the codebase and
6
+ * makes it easier to update endpoints when the backend API changes.
7
+ *
8
+ * @category Constants
9
+ * @since 3.6.0
10
+ */
11
+ /**
12
+ * Launchpad Backend API Endpoints
13
+ */
14
+ export declare const ENDPOINTS: {
15
+ readonly UPLOAD_IMAGE: "/launchpad/upload-image";
16
+ readonly FETCH_POOLS: "/launchpad/fetch-pool";
17
+ readonly CHECK_POOL: "/launchpad/check-pool";
18
+ readonly GET_GRAPH_DATA: "/launchpad/get-graph-data";
19
+ readonly GET_TOKEN_DISTRIBUTION: "/holders";
20
+ readonly GET_TOKEN_BADGES: "/launchpad/get-badge/";
21
+ readonly GET_TRADES: "/trade/";
22
+ readonly GET_COMMENTS: "/token/commment";
23
+ readonly POST_COMMENT: "/token/commment";
24
+ readonly GET_PROFILE: "/user/profile";
25
+ readonly UPDATE_PROFILE: "/user/profile";
26
+ readonly GET_TOKEN_LIST: "/user/token-list";
27
+ readonly GET_TOKENS_HELD: "/user/token-hold";
28
+ readonly TRANSFER_FAUCETS: "/user/transfer-faucets";
29
+ };
30
+ /**
31
+ * Type-safe endpoint keys
32
+ */
33
+ export type EndpointKey = keyof typeof ENDPOINTS;
34
+ /**
35
+ * Type-safe endpoint values
36
+ */
37
+ export type EndpointValue = typeof ENDPOINTS[EndpointKey];
38
+ //# sourceMappingURL=endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../src/constants/endpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;CA8BZ,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,SAAS,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,SAAS,CAAC,WAAW,CAAC,CAAC"}