@cranberry-money/shared-services 8.1.0 โ†’ 8.1.2

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @cranberry-money/shared-services v3.0.0
2
2
 
3
- **Functional Architecture Shared Services** with pure functions, dependency injection, and comprehensive TypeScript support for the MyPortfolio platform.
3
+ **Functional Architecture Shared Services** with pure functions, dependency injection, and comprehensive TypeScript support for the Blueberry platform.
4
4
 
5
5
  [![npm version](https://badge.fury.io/js/%40cranberry-money%2Fshared-services.svg)](https://badge.fury.io/js/%40cranberry-money%2Fshared-services)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)
@@ -9,7 +9,7 @@
9
9
  ## ๐ŸŽ‰ What's New in v3.0.0
10
10
 
11
11
  - **Pure Functional Architecture**: Complete migration to functional programming patterns
12
- - **Service Factory Pattern**: Type-safe service creation with dependency injection
12
+ - **Service Factory Pattern**: Type-safe service creation with dependency injection
13
13
  - **React Context Authentication**: Modern authentication with hooks and context
14
14
  - **Migration Framework**: Feature flags and tools for gradual migration from v2.x
15
15
  - **Performance Improvements**: 10-15% faster API calls, 15-20% less memory usage
@@ -25,9 +25,9 @@ npm install @cranberry-money/shared-services@^3.0.0
25
25
  ### Basic Setup
26
26
 
27
27
  ```typescript
28
- import {
29
- createWebServiceFactory,
30
- initializeFeatureFlags
28
+ import {
29
+ createWebServiceFactory,
30
+ initializeFeatureFlags
31
31
  } from '@cranberry-money/shared-services';
32
32
 
33
33
  // 1. Initialize feature flags (optional but recommended)
@@ -92,10 +92,10 @@ const result = await signin(credentials, authDeps);
92
92
  ### React Context Integration
93
93
 
94
94
  ```typescript
95
- import {
96
- useFunctionalAuthState,
95
+ import {
96
+ useFunctionalAuthState,
97
97
  useFunctionalAuthActions,
98
- FunctionalAuthGuard
98
+ FunctionalAuthGuard
99
99
  } from '@cranberry-money/shared-services';
100
100
 
101
101
  function Dashboard() {
@@ -168,7 +168,7 @@ const result = await apiClient.post('/api/items', { name: 'Item' });
168
168
  import { createFunctionalWebApiClient } from '@cranberry-money/shared-services';
169
169
  const webClient = createFunctionalWebApiClient('https://api.example.com');
170
170
 
171
- // Mobile-optimized client
171
+ // Mobile-optimized client
172
172
  import { createFunctionalMobileApiClient } from '@cranberry-money/shared-services';
173
173
  const mobileClient = createFunctionalMobileApiClient('https://api.example.com');
174
174
  ```
@@ -261,10 +261,7 @@ if (!validation.isValid) {
261
261
  ### Built-in Benchmarking
262
262
 
263
263
  ```typescript
264
- import {
265
- runQuickPerformanceCheck,
266
- runComprehensivePerformanceAnalysis
267
- } from '@cranberry-money/shared-services';
264
+ import { runQuickPerformanceCheck, runComprehensivePerformanceAnalysis } from '@cranberry-money/shared-services';
268
265
 
269
266
  // Quick performance check
270
267
  const quickReport = await runQuickPerformanceCheck();
@@ -281,10 +278,8 @@ console.log(detailedReport);
281
278
  import { monitorMigrationPerformance } from '@cranberry-money/shared-services';
282
279
 
283
280
  // Wrap functions for automatic performance tracking
284
- const monitored = monitorMigrationPerformance(
285
- 'api.getPortfolios',
286
- 'functional',
287
- () => services.portfolio.getPortfolios()
281
+ const monitored = monitorMigrationPerformance('api.getPortfolios', 'functional', () =>
282
+ services.portfolio.getPortfolios()
288
283
  );
289
284
 
290
285
  const result = await monitored();
@@ -313,10 +308,7 @@ describe('Authentication', () => {
313
308
  tokenStorage: createMemoryTokenStorage(),
314
309
  };
315
310
 
316
- const result = await signin(
317
- { email: 'test@example.com', password: 'password' },
318
- deps
319
- );
311
+ const result = await signin({ email: 'test@example.com', password: 'password' }, deps);
320
312
 
321
313
  expect(result.user.email).toBe('test@example.com');
322
314
  expect(mockApiClient.post).toHaveBeenCalledWith('/api/signin/', {
@@ -336,7 +328,7 @@ import { createMemoryTokenStorage } from '@cranberry-money/shared-services';
336
328
  const TestAuthProvider = ({ children }) => {
337
329
  const services = createWebServiceFactory('http://test-api.com');
338
330
  const AuthProvider = services.auth.createAuthProvider();
339
-
331
+
340
332
  return <AuthProvider>{children}</AuthProvider>;
341
333
  };
342
334
 
@@ -346,7 +338,7 @@ test('should display user name when authenticated', () => {
346
338
  <Dashboard />
347
339
  </TestAuthProvider>
348
340
  );
349
-
341
+
350
342
  // Test auth-dependent component
351
343
  });
352
344
  ```
@@ -358,13 +350,10 @@ test('should display user name when authenticated', () => {
358
350
  ```typescript
359
351
  import { createWebServiceFactory } from '@cranberry-money/shared-services';
360
352
 
361
- const services = createWebServiceFactory(
362
- process.env.REACT_APP_API_URL,
363
- {
364
- apiTimeout: 15000,
365
- enableCredentials: true,
366
- }
367
- );
353
+ const services = createWebServiceFactory(process.env.REACT_APP_API_URL, {
354
+ apiTimeout: 15000,
355
+ enableCredentials: true,
356
+ });
368
357
 
369
358
  export { services };
370
359
  ```
@@ -375,13 +364,9 @@ export { services };
375
364
  import { createMobileServiceFactory } from '@cranberry-money/shared-services';
376
365
  import * as SecureStore from 'expo-secure-store';
377
366
 
378
- const services = createMobileServiceFactory(
379
- process.env.EXPO_PUBLIC_API_URL,
380
- SecureStore,
381
- {
382
- apiTimeout: 20000,
383
- }
384
- );
367
+ const services = createMobileServiceFactory(process.env.EXPO_PUBLIC_API_URL, SecureStore, {
368
+ apiTimeout: 20000,
369
+ });
385
370
 
386
371
  export { services };
387
372
  ```
@@ -446,20 +431,21 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
446
431
  function usePortfolios() {
447
432
  return useQuery({
448
433
  queryKey: ['portfolios'],
449
- queryFn: () => services.portfolio.getPortfolios({
450
- isActive: true,
451
- sortBy: 'totalValue',
452
- sortOrder: 'desc',
453
- }),
434
+ queryFn: () =>
435
+ services.portfolio.getPortfolios({
436
+ isActive: true,
437
+ sortBy: 'totalValue',
438
+ sortOrder: 'desc',
439
+ }),
454
440
  staleTime: 5 * 60 * 1000, // 5 minutes
455
441
  });
456
442
  }
457
443
 
458
444
  function useCreatePortfolio() {
459
445
  const queryClient = useQueryClient();
460
-
446
+
461
447
  return useMutation({
462
- mutationFn: (data) => services.portfolio.createPortfolio(data),
448
+ mutationFn: data => services.portfolio.createPortfolio(data),
463
449
  onSuccess: () => {
464
450
  queryClient.invalidateQueries({ queryKey: ['portfolios'] });
465
451
  },
@@ -525,11 +511,13 @@ src/
525
511
  ## ๐Ÿ”— Dependencies
526
512
 
527
513
  ### Required
514
+
528
515
  - `axios` - HTTP client library
529
516
  - `react` >=18.0.0 - React framework (peer dependency)
530
517
  - `typescript` >=4.5.0 - TypeScript support (peer dependency)
531
518
 
532
519
  ### Optional
520
+
533
521
  - `@tanstack/react-query` - For optimized data fetching
534
522
  - `expo-secure-store` - For mobile secure storage
535
523
 
@@ -553,10 +541,10 @@ MIT License - see the [LICENSE](LICENSE) file for details.
553
541
 
554
542
  ## ๐Ÿ™ Acknowledgments
555
543
 
556
- - Built for the MyPortfolio platform
544
+ - Built for the Blueberry platform
557
545
  - Inspired by functional programming principles
558
546
  - Designed for maximum type safety and developer experience
559
547
 
560
548
  ---
561
549
 
562
- **Need help migrating from v2.x?** Check out our [comprehensive migration guide](../../docs/MIGRATION-V3.md) with step-by-step instructions and examples.
550
+ **Need help migrating from v2.x?** Check out our [comprehensive migration guide](../../docs/MIGRATION-V3.md) with step-by-step instructions and examples.
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  // Placeholder for package
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,2BAA2B"}
package/package.json CHANGED
@@ -1,57 +1,49 @@
1
1
  {
2
2
  "name": "@cranberry-money/shared-services",
3
- "version": "8.1.0",
4
- "description": "Functional architecture shared services with pure functions, dependency injection, and comprehensive TypeScript support for the MyPortfolio platform",
3
+ "version": "8.1.2",
4
+ "description": "Functional architecture shared services with pure functions, dependency injection, and comprehensive TypeScript support for the Blueberry platform",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "require": "./dist/index.cjs"
11
+ "import": "./dist/index.js"
13
12
  }
14
13
  },
15
14
  "files": [
16
- "dist",
17
- "README.md",
18
- "CHANGELOG.md",
19
- "docs"
15
+ "dist"
20
16
  ],
21
17
  "scripts": {
22
- "build": "tsc",
23
- "clean": "rm -rf dist",
18
+ "build": "tsc --build",
19
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
20
+ "test": "jest --passWithNoTests",
21
+ "test:watch": "jest --watch",
22
+ "test:coverage": "jest --coverage",
24
23
  "typecheck": "tsc --noEmit",
25
24
  "dev": "tsc --watch",
26
25
  "lint": "eslint src",
27
- "lint:fix": "eslint src --fix"
26
+ "lint:fix": "eslint src --fix",
27
+ "format": "prettier --write 'src/**/*.{ts,tsx}'",
28
+ "format:check": "prettier --check 'src/**/*.{ts,tsx}'",
29
+ "prepublishOnly": "npm run clean && npm run typecheck && npm run build"
28
30
  },
29
31
  "dependencies": {
30
- "axios": "^1.7.0"
32
+ "axios": "^1.9.0"
31
33
  },
32
34
  "peerDependencies": {
33
- "react": ">=18.0.0",
34
- "typescript": ">=4.5.0"
35
- },
36
- "peerDependenciesMeta": {
37
- "react": {
38
- "optional": false
39
- }
35
+ "typescript": ">=5.0.0"
40
36
  },
41
37
  "devDependencies": {
38
+ "@types/jest": "^30.0.0",
42
39
  "@types/node": "^20.0.0",
43
- "@types/react": "^18.0.0",
44
- "@typescript-eslint/eslint-plugin": "^6.0.0",
45
- "@typescript-eslint/parser": "^6.0.0",
46
- "eslint": "^8.0.0",
47
- "react": "^18.0.0",
48
- "tsx": "^4.0.0",
40
+ "jest": "^30.0.5",
41
+ "ts-jest": "^29.4.1",
49
42
  "typescript": "^5.0.0"
50
43
  },
51
44
  "keywords": [
52
45
  "functional-programming",
53
46
  "dependency-injection",
54
- "react",
55
47
  "typescript",
56
48
  "api-client",
57
49
  "authentication",
@@ -59,23 +51,10 @@
59
51
  "services",
60
52
  "pure-functions"
61
53
  ],
62
- "author": "MyPortfolio Team",
54
+ "author": "Blueberry Team",
63
55
  "license": "MIT",
64
56
  "publishConfig": {
65
57
  "access": "public",
66
58
  "registry": "https://registry.npmjs.org/"
67
- },
68
- "repository": {
69
- "type": "git",
70
- "url": "git+https://github.com/your-org/cranberry.git",
71
- "directory": "packages/shared-services"
72
- },
73
- "bugs": {
74
- "url": "https://github.com/your-org/cranberry/issues"
75
- },
76
- "homepage": "https://github.com/your-org/cranberry/tree/main/packages/shared-services#readme",
77
- "engines": {
78
- "node": ">=16.0.0",
79
- "npm": ">=8.0.0"
80
59
  }
81
60
  }
package/CHANGELOG.md DELETED
@@ -1,240 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [3.0.0] - 2025-08-15
9
-
10
- ### ๐ŸŽ‰ Major Features
11
-
12
- #### Pure Functional Architecture
13
- - **Complete migration** from mixed OOP/functional patterns to pure functional programming
14
- - **Explicit dependency injection** throughout the entire codebase
15
- - **Immutable state management** with functional state transitions
16
- - **Zero global mutable state** - all dependencies passed explicitly
17
-
18
- #### Service Factory Pattern
19
- - **Platform-specific service creation** with `createWebServiceFactory()` and `createMobileServiceFactory()`
20
- - **Type-safe service composition** with full TypeScript support
21
- - **Dependency injection** with explicit configuration and validation
22
- - **Modular architecture** allowing easy extension and testing
23
-
24
- #### Enhanced Authentication System
25
- - **React Context-based authentication** replacing class-based AuthManager
26
- - **Pure functional auth operations** (signin, signout, signup, token refresh)
27
- - **Platform-specific token storage** (web localStorage, mobile secure storage, in-memory for testing)
28
- - **Automatic token refresh** with error handling and fallback
29
- - **React hooks integration** (`useFunctionalAuthState`, `useFunctionalAuthActions`)
30
-
31
- #### Migration Framework
32
- - **Feature flag system** for gradual migration from v2.x to v3.0.0
33
- - **Performance benchmarking tools** to compare functional vs legacy implementations
34
- - **Migration validation utilities** to ensure readiness before switching
35
- - **Compatibility layers** for smooth transition during migration
36
- - **Domain-specific migration adapters** for reference data services
37
-
38
- ### ๐Ÿ’ฅ Breaking Changes
39
-
40
- #### Removed Global Singleton API Client
41
- ```typescript
42
- // โŒ REMOVED - Global singleton pattern
43
- import { webApiClient } from '@cranberry/shared-services';
44
- const data = await webApiClient.get('/api/data');
45
-
46
- // โœ… NEW - Factory pattern with dependency injection
47
- import { createWebServiceFactory } from '@cranberry/shared-services';
48
- const services = createWebServiceFactory('https://api.example.com');
49
- const apiClient = services.auth.createAuthDependencies().apiClient;
50
- const data = await apiClient.get('/api/data');
51
- ```
52
-
53
- #### Deprecated AuthManager Class
54
- ```typescript
55
- // โŒ DEPRECATED - Class-based authentication
56
- import { AuthManager } from '@cranberry/shared-services';
57
- const authManager = new AuthManager(config);
58
- const user = authManager.getCurrentUser();
59
-
60
- // โœ… NEW - React Context with functional hooks
61
- import { FunctionalAuthProvider, useFunctionalAuthState } from '@cranberry/shared-services';
62
- const AuthProvider = services.auth.createAuthProvider();
63
- // Use in React components with hooks
64
- const authState = useFunctionalAuthState();
65
- ```
66
-
67
- #### Changed Service Access Pattern
68
- ```typescript
69
- // โŒ OLD - Direct service imports
70
- import * as PortfoliosService from '@cranberry/shared-services';
71
- const portfolios = await PortfoliosService.getPortfolios();
72
-
73
- // โœ… NEW - Service factory pattern
74
- const services = createWebServiceFactory(apiUrl);
75
- const portfolios = await services.portfolio.getPortfolios();
76
- ```
77
-
78
- #### Updated Export Names for Clarity
79
- ```typescript
80
- // โŒ OLD - Potential naming conflicts
81
- import { AuthState, ApiClient, TokenStorage } from '@cranberry/shared-services';
82
-
83
- // โœ… NEW - Prefixed exports to avoid conflicts
84
- import {
85
- FunctionalAuthState,
86
- FunctionalApiClient,
87
- FunctionalTokenStorage
88
- } from '@cranberry/shared-services';
89
- ```
90
-
91
- #### Standardized Error Handling
92
- ```typescript
93
- // โŒ OLD - Inconsistent error formats
94
- catch (error) {
95
- const message = error.message || error.detail || 'Unknown error';
96
- }
97
-
98
- // โœ… NEW - Standardized API error handling
99
- import { isFunctionalApiError } from '@cranberry/shared-services';
100
- catch (error) {
101
- if (isFunctionalApiError(error)) {
102
- console.error(`API Error (${error.status}): ${error.message}`);
103
- if (error.details) console.error('Details:', error.details);
104
- }
105
- }
106
- ```
107
-
108
- ### โœจ New Features
109
-
110
- #### Feature Flag System
111
- - **Gradual migration support** with feature flags for each domain
112
- - **Environment-based configuration** (development, staging, production)
113
- - **Persistent storage** with automatic configuration loading
114
- - **Performance monitoring** integration during migration
115
- - **Rollback capabilities** for safe migration
116
-
117
- #### Migration Utilities
118
- - **Migration helpers** with compatibility layers between v2.x and v3.0.0
119
- - **Validation tools** to check migration readiness
120
- - **Progress tracking** with detailed metrics and reporting
121
- - **Performance comparison** tools for functional vs legacy implementations
122
-
123
- #### Reference Data Services
124
- - **Complete functional implementation** for countries, industries, sectors, stock exchanges
125
- - **Feature flag integration** for gradual migration
126
- - **Backward compatibility** during transition period
127
- - **Performance optimizations** with caching and filtering
128
-
129
- #### Platform-Specific Token Storage
130
- - **Web token storage** using localStorage with automatic cleanup
131
- - **Mobile secure storage** integration (Expo SecureStore, iOS Keychain, Android Keystore)
132
- - **In-memory storage** for testing environments
133
- - **Migration utilities** for converting from legacy token storage
134
-
135
- #### Performance Improvements
136
- - **10-15% faster API calls** due to reduced abstraction layers
137
- - **15-20% reduction in memory usage** through immutable state management
138
- - **5-10% smaller bundle size** by eliminating unnecessary OOP abstractions
139
- - **Built-in performance monitoring** with automatic benchmarking
140
-
141
- ### ๐Ÿ› Bug Fixes
142
-
143
- - **Fixed memory leaks** in global state management by eliminating mutable global state
144
- - **Fixed inconsistent error handling** across services with standardized error formats
145
- - **Fixed TypeScript strict mode compatibility** issues with improved type definitions
146
- - **Fixed race conditions** in authentication flow with pure functional state management
147
- - **Fixed token refresh edge cases** with proper error handling and fallback mechanisms
148
-
149
- ### ๐Ÿ“š Documentation
150
-
151
- #### Comprehensive Migration Guide
152
- - **Step-by-step migration instructions** from v2.x to v3.0.0
153
- - **Code examples** for all breaking changes
154
- - **Gradual migration strategy** with feature flag usage
155
- - **Rollback procedures** for emergency situations
156
- - **Performance validation** guidelines
157
-
158
- #### Integration Examples
159
- - **Blueberry dashboard integration** example with complete setup
160
- - **React Query integration** patterns and best practices
161
- - **Testing examples** for pure functions and React components
162
- - **Error handling** patterns and utilities
163
-
164
- #### API Documentation
165
- - **Complete TypeScript definitions** for all new APIs
166
- - **Usage examples** for every major feature
167
- - **Performance benchmarking** guides and tools
168
- - **Troubleshooting** guides for common migration issues
169
-
170
- ### ๐Ÿงช Testing
171
-
172
- - **100% test coverage** for all new functional components
173
- - **Migration validation tests** to ensure compatibility
174
- - **Performance regression tests** to maintain performance standards
175
- - **Integration test examples** for React components and hooks
176
- - **Pure function testing** utilities and patterns
177
-
178
- ### ๐Ÿ›  Developer Experience
179
-
180
- - **Improved TypeScript support** with strict mode compatibility
181
- - **Self-documenting pure functions** with explicit dependencies
182
- - **Better error messages** with detailed debugging information
183
- - **Comprehensive examples** for all use cases
184
- - **Migration tooling** for smooth transition
185
-
186
- ### ๐Ÿ“ฆ Dependencies
187
-
188
- #### Added
189
- - Enhanced TypeScript support (>=4.5.0)
190
- - React 18+ support for new context APIs
191
- - Improved axios integration for HTTP client
192
-
193
- #### Removed
194
- - Legacy OOP class dependencies
195
- - Global state management libraries
196
- - Unused abstraction layers
197
-
198
- ### ๐Ÿ”„ Migration Support
199
-
200
- #### Automatic Migration Tools
201
- - **Feature flag management** for gradual rollout
202
- - **Performance comparison** between old and new implementations
203
- - **Validation utilities** to check migration readiness
204
- - **Compatibility layers** to ease transition
205
-
206
- #### Support Timeline
207
- - **v3.0.x**: Active development and support
208
- - **v2.x**: Security fixes and critical bug fixes for 6 months
209
- - **v1.x**: End of life
210
-
211
- ---
212
-
213
- ## [2.x.x] - Previous Versions
214
-
215
- For changes in v2.x and earlier, please see the [legacy changelog](./CHANGELOG-v2.md).
216
-
217
- ---
218
-
219
- ## Migration Guide
220
-
221
- **Migrating from v2.x?**
222
-
223
- ๐Ÿ“– **[Complete Migration Guide](./docs/improvements/v3-migration-guide.md)** - Step-by-step instructions with examples
224
-
225
- ๐Ÿ”ง **[Migration Checklist](./docs/improvements/migration-checklist.md)** - Systematic approach to migration
226
-
227
- โšก **[Performance Guide](./docs/improvements/v3-release-preparation.md)** - Performance improvements and monitoring
228
-
229
- ๐Ÿš€ **[Quick Start](./README.md#quick-start)** - Get up and running with v3.0.0
230
-
231
- ## Support
232
-
233
- - **GitHub Issues**: [Report bugs and request features](https://github.com/your-org/cranberry/issues)
234
- - **Documentation**: [Complete documentation](./docs/)
235
- - **Examples**: [Integration examples](./src/integration/)
236
- - **Migration Help**: See migration guides above
237
-
238
- ---
239
-
240
- *This release represents a significant architectural advancement that improves code quality, performance, and developer experience across all applications using Cranberry shared services.*