@sudobility/types 1.9.55 → 1.9.56

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 (112) hide show
  1. package/README.md +44 -280
  2. package/dist/index.js +28 -201
  3. package/dist/index.js.map +1 -1
  4. package/dist/types/blockchain/common.js +9 -16
  5. package/dist/types/blockchain/common.js.map +1 -1
  6. package/dist/types/blockchain/index.js +3 -17
  7. package/dist/types/blockchain/index.js.map +1 -1
  8. package/dist/types/blockchain/validation.js +6 -12
  9. package/dist/types/blockchain/validation.js.map +1 -1
  10. package/dist/types/business/enums.js +46 -49
  11. package/dist/types/business/enums.js.map +1 -1
  12. package/dist/types/business/wallet-status.js +10 -16
  13. package/dist/types/business/wallet-status.js.map +1 -1
  14. package/dist/types/common.js +1 -2
  15. package/dist/types/common.js.map +1 -1
  16. package/dist/types/config/app-config.js +1 -2
  17. package/dist/types/config/app-config.js.map +1 -1
  18. package/dist/types/config/environment.js +2 -5
  19. package/dist/types/config/environment.js.map +1 -1
  20. package/dist/types/consumables/index.js +1 -2
  21. package/dist/types/consumables/index.js.map +1 -1
  22. package/dist/types/entity/entity.js +6 -9
  23. package/dist/types/entity/entity.js.map +1 -1
  24. package/dist/types/entity/permissions.js +12 -17
  25. package/dist/types/entity/permissions.js.map +1 -1
  26. package/dist/types/entity/requests.js +1 -2
  27. package/dist/types/entity/requests.js.map +1 -1
  28. package/dist/types/entity/responses.js +1 -2
  29. package/dist/types/entity/responses.js.map +1 -1
  30. package/dist/types/infrastructure/analytics.js +3 -7
  31. package/dist/types/infrastructure/analytics.js.map +1 -1
  32. package/dist/types/infrastructure/api.js +5 -9
  33. package/dist/types/infrastructure/api.js.map +1 -1
  34. package/dist/types/infrastructure/firebase-user.js +1 -2
  35. package/dist/types/infrastructure/firebase-user.js.map +1 -1
  36. package/dist/types/infrastructure/navigation.js +1 -2
  37. package/dist/types/infrastructure/network.js +1 -4
  38. package/dist/types/infrastructure/network.js.map +1 -1
  39. package/dist/types/infrastructure/wallet.js +2 -5
  40. package/dist/types/infrastructure/wallet.js.map +1 -1
  41. package/dist/types/subscription/entitlements.js +1 -4
  42. package/dist/types/subscription/entitlements.js.map +1 -1
  43. package/dist/types/subscription/period.js +2 -5
  44. package/dist/types/subscription/period.js.map +1 -1
  45. package/dist/types/subscription/rate-limits.js +2 -5
  46. package/dist/types/subscription/rate-limits.js.map +1 -1
  47. package/dist/utils/async-helpers.js +7 -16
  48. package/dist/utils/async-helpers.js.map +1 -1
  49. package/dist/utils/auth/admin-emails.js +3 -8
  50. package/dist/utils/auth/admin-emails.js.map +1 -1
  51. package/dist/utils/auth/auth.js +14 -24
  52. package/dist/utils/auth/auth.js.map +1 -1
  53. package/dist/utils/blockchain/address.js +20 -31
  54. package/dist/utils/blockchain/address.js.map +1 -1
  55. package/dist/utils/blockchain/event-helpers.js +9 -20
  56. package/dist/utils/blockchain/event-helpers.js.map +1 -1
  57. package/dist/utils/constants/application.js +2 -20
  58. package/dist/utils/constants/application.js.map +1 -1
  59. package/dist/utils/constants/status-values.js +1 -4
  60. package/dist/utils/constants/status-values.js.map +1 -1
  61. package/dist/utils/formatting/currency.js +6 -11
  62. package/dist/utils/formatting/currency.js.map +1 -1
  63. package/dist/utils/formatting/date.js +7 -16
  64. package/dist/utils/formatting/date.js.map +1 -1
  65. package/dist/utils/formatting/string.js +16 -34
  66. package/dist/utils/formatting/string.js.map +1 -1
  67. package/dist/utils/logging/logger.js +2 -10
  68. package/dist/utils/logging/logger.js.map +1 -1
  69. package/dist/utils/url/url-params.js +1 -6
  70. package/dist/utils/url/url-params.js.map +1 -1
  71. package/dist/utils/validation/type-validation.js +27 -48
  72. package/dist/utils/validation/type-validation.js.map +1 -1
  73. package/dist/utils/validation/web3-username-validator.js +6 -10
  74. package/dist/utils/validation/web3-username-validator.js.map +1 -1
  75. package/package.json +3 -11
  76. package/dist/index.cjs +0 -243
  77. package/dist/types/blockchain/common.cjs +0 -127
  78. package/dist/types/blockchain/index.cjs +0 -30
  79. package/dist/types/blockchain/validation.cjs +0 -144
  80. package/dist/types/business/enums.cjs +0 -367
  81. package/dist/types/business/wallet-status.cjs +0 -38
  82. package/dist/types/common.cjs +0 -12
  83. package/dist/types/config/app-config.cjs +0 -6
  84. package/dist/types/config/environment.cjs +0 -24
  85. package/dist/types/consumables/index.cjs +0 -8
  86. package/dist/types/entity/entity.cjs +0 -51
  87. package/dist/types/entity/permissions.cjs +0 -93
  88. package/dist/types/entity/requests.cjs +0 -7
  89. package/dist/types/entity/responses.cjs +0 -7
  90. package/dist/types/infrastructure/analytics.cjs +0 -212
  91. package/dist/types/infrastructure/api.cjs +0 -43
  92. package/dist/types/infrastructure/firebase-user.cjs +0 -10
  93. package/dist/types/infrastructure/navigation.cjs +0 -3
  94. package/dist/types/infrastructure/network.cjs +0 -18
  95. package/dist/types/infrastructure/wallet.cjs +0 -37
  96. package/dist/types/subscription/entitlements.cjs +0 -14
  97. package/dist/types/subscription/period.cjs +0 -29
  98. package/dist/types/subscription/rate-limits.cjs +0 -20
  99. package/dist/utils/async-helpers.cjs +0 -244
  100. package/dist/utils/auth/admin-emails.cjs +0 -79
  101. package/dist/utils/auth/auth.cjs +0 -99
  102. package/dist/utils/blockchain/address.cjs +0 -225
  103. package/dist/utils/blockchain/event-helpers.cjs +0 -143
  104. package/dist/utils/constants/application.cjs +0 -152
  105. package/dist/utils/constants/status-values.cjs +0 -14
  106. package/dist/utils/formatting/currency.cjs +0 -39
  107. package/dist/utils/formatting/date.cjs +0 -197
  108. package/dist/utils/formatting/string.cjs +0 -326
  109. package/dist/utils/logging/logger.cjs +0 -92
  110. package/dist/utils/url/url-params.cjs +0 -128
  111. package/dist/utils/validation/type-validation.cjs +0 -250
  112. package/dist/utils/validation/web3-username-validator.cjs +0 -132
package/README.md CHANGED
@@ -1,310 +1,74 @@
1
- # @johnqh/types
1
+ # @sudobility/types
2
2
 
3
- [![npm version](https://badge.fury.io/js/@johnqh%2Ftypes.svg)](https://badge.fury.io/js/@johnqh%2Ftypes)
4
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ Comprehensive TypeScript type definitions and utilities for Web3 email applications. Zero runtime dependencies, dual module support (ESM + CommonJS).
6
4
 
7
- **Comprehensive TypeScript type definitions and utilities for Web3 email applications.**
8
-
9
- ## 🚀 Overview
10
-
11
- This package provides a complete type-safe foundation for Web3 email applications, featuring:
12
-
13
- - **267 comprehensive tests** ensuring type reliability
14
- - **Zero runtime dependencies** for optimal performance
15
- - **Dual module support** (ESM + CommonJS)
16
- - **Complete TypeScript coverage** with strict type checking
17
- - **AI-friendly documentation** for enhanced development experience
18
-
19
- ## 📦 Features
20
-
21
- ### Core Type System
22
- - **Business Logic Types**: Email, User, WalletData, MailBox interfaces
23
- - **Blockchain Types**: Multi-chain support (Ethereum, Solana, Polygon, etc.)
24
- - **API Types**: Complete request/response type definitions
25
- - **Infrastructure Types**: Analytics, navigation, network client abstractions
26
- - **Utility Types**: `Optional<T>`, `Result<T, E>`, `ValidationResult<T>`
27
-
28
- ### Utilities & Helpers
29
- - **Address Validation**: EVM, Solana, ENS, SNS address validation
30
- - **Blockchain Utilities**: Network configuration, chain detection, event helpers
31
- - **Formatting**: Date, currency, string formatting utilities
32
- - **Validation**: Type guards, schema validation, Web3 username validation
33
- - **URL Management**: Type-safe URL parameter handling
34
-
35
- ### Development Features
36
- - **Tree Shakeable**: Import only what you need
37
- - **Framework Agnostic**: Works with React, Vue, Node.js, React Native
38
- - **Zero Config**: Ready to use out of the box
39
- - **Type-Safe**: Complete IntelliSense support
40
-
41
- ## 🛠 Installation
5
+ ## Installation
42
6
 
43
7
  ```bash
44
- npm install @johnqh/types
8
+ bun install @sudobility/types
45
9
  ```
46
10
 
47
- ## 📖 Usage Examples
48
-
49
- ### Basic Types
50
- ```typescript
51
- import {
52
- Email,
53
- User,
54
- WalletUserData,
55
- AuthStatus,
56
- ChainType,
57
- Optional
58
- } from '@johnqh/types';
59
-
60
- // Email handling
61
- const email: Email = {
62
- from: 'sender@example.com',
63
- to: 'recipient@example.com',
64
- subject: 'Web3 Email',
65
- body: 'Hello from the blockchain!',
66
- id: 'msg_123',
67
- timestamp: Date.now(),
68
- read: false
69
- };
11
+ No peer dependencies required.
70
12
 
71
- // User management with optional fields
72
- const user: WalletUserData = {
73
- walletAddress: '0x742d35Cc6634C0532925a3b8D2C36B7f12345678',
74
- chainType: ChainType.EVM,
75
- emails: [email],
76
- folders: []
77
- };
13
+ ## Usage
78
14
 
79
- // Optional type usage
80
- const maybeUser: Optional<User> = null; // T | undefined | null
81
- ```
15
+ ### Core Utility Types
82
16
 
83
- ### Blockchain Integration
84
17
  ```typescript
85
- import {
86
- Message,
87
- TransactionResult,
88
- MessageType,
89
- isEvmAddress,
90
- isSolanaAddress
91
- } from '@johnqh/types';
18
+ import { Optional, Result, ValidationResult, BaseResponse, PaginatedResponse } from '@sudobility/types';
92
19
 
93
- // Multi-chain message
94
- const message: Message = {
95
- from: '0x742d35Cc6634C0532925a3b8D2C36B7f12345678',
96
- to: '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
97
- subject: 'Cross-chain message',
98
- body: 'EVM to Solana communication',
99
- timestamp: Date.now(),
100
- txHash: '0x123abc...',
101
- messageType: MessageType.PRIORITY
102
- };
20
+ const maybeUser: Optional<User> = null; // T | undefined | null
103
21
 
104
- // Address validation
105
- const evmValid = isEvmAddress('0x742d35Cc6634C0532925a3b8D2C36B7f12345678'); // true
106
- const solanaValid = isSolanaAddress('9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM'); // true
22
+ function doWork(): Result<Data> {
23
+ if (ok) return { success: true, data: result };
24
+ return { success: false, error: { type: 'ValidationError', message: '...' } };
25
+ }
107
26
  ```
108
27
 
109
- ### API Integration
110
- ```typescript
111
- import {
112
- ApiResponse,
113
- ValidationResult,
114
- IndexerApiResponse,
115
- Result
116
- } from '@johnqh/types';
117
-
118
- // Type-safe API responses
119
- const apiResponse: ApiResponse<User> = {
120
- success: true,
121
- data: user,
122
- timestamp: new Date().toISOString()
123
- };
124
-
125
- // Result pattern for error handling
126
- const validateUser = (data: unknown): Result<User> => {
127
- // Validation logic...
128
- return { success: true, data: user as User };
129
- };
130
- ```
28
+ ### Blockchain Types
131
29
 
132
- ### Utilities
133
30
  ```typescript
134
- import {
135
- formatWalletAddress,
136
- parseEmailAddress,
137
- createMultiChainId,
138
- Web3UsernameValidator
139
- } from '@johnqh/types';
140
-
141
- // Address formatting
142
- const formatted = formatWalletAddress('0x742d35Cc6634C0532925a3b8D2C36B7f12345678');
143
- // Result: "0x742d...5678"
144
-
145
- // Email parsing
146
- const parsed = parseEmailAddress('user@domain.eth');
147
- // Result: { address: 'user', domain: 'domain.eth', type: AddressType.ENSName }
148
-
149
- // Multi-chain ID generation
150
- const id = createMultiChainId(1, '0x123...', 0);
151
- // Result: "1-0x123...-0"
152
-
153
- // Web3 username validation
154
- const validation = Web3UsernameValidator.validate('vitalik.eth');
155
- // Result: { name: 'vitalik.eth', address: null, chainType: ChainType.EVM }
156
- ```
157
-
158
- ## 🏗 Project Structure
159
-
160
- ```
161
- src/
162
- ├── types/ # Type definitions by domain
163
- │ ├── indexer/ # Indexer API request/response types
164
- │ ├── blockchain/ # Web3 and blockchain types
165
- │ ├── business/ # Core business logic types
166
- │ ├── common.ts # Shared utility types (Optional<T>, Result<T>)
167
- │ ├── config/ # Configuration types
168
- │ └── infrastructure/ # Infrastructure abstractions
169
- ├── utils/ # Pure utility functions
170
- │ ├── auth/ # Authentication utilities
171
- │ ├── blockchain/ # Blockchain utilities
172
- │ ├── constants/ # Shared constants
173
- │ ├── formatting/ # Formatting utilities
174
- │ ├── logging/ # Logging utilities
175
- │ ├── url/ # URL utilities
176
- │ └── validation/ # Validation utilities
177
- ├── wildduck-requests.ts # WildDuck email server types
178
- └── index.ts # Main exports
179
- ```
180
-
181
- ## 🧪 Development
182
-
183
- ### Available Scripts
184
- ```bash
185
- # Development
186
- npm run build # Build both ESM and CommonJS
187
- npm run dev # Watch mode development
188
- npm test # Run all 267 tests
189
- npm run test:watch # Watch mode testing
190
- npm run test:coverage # Generate coverage report
31
+ import { isEvmAddress, isSolanaAddress, formatWalletAddress, ChainType } from '@sudobility/types';
191
32
 
192
- # Quality Assurance
193
- npm run lint # ESLint checking
194
- npm run lint:fix # Fix linting issues
195
- npm run format # Format with Prettier
196
- npm run typecheck # TypeScript type checking
197
- npm run verify # Complete verification pipeline
198
-
199
- # AI Development Tools
200
- npm run ai:analyze # Analyze type structure
201
- npm run ai:validate # Validate exports
202
- npm run ai:docs # Generate AI documentation
33
+ isEvmAddress('0x742d35Cc6634C0532925a3b8D2C36B7f12345678'); // true
34
+ isSolanaAddress('9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM'); // true
35
+ formatWalletAddress('0x742d35Cc6634C0532925a3b8D2C36B7f12345678'); // "0x742d...5678"
203
36
  ```
204
37
 
205
- ### Quality Standards
206
- - **100% TypeScript**: Strict mode enabled with comprehensive coverage
207
- - **267 Tests**: Complete test suite with Vitest
208
- - **Zero Lint Errors**: ESLint v9 with flat config
209
- - **Perfect Formatting**: Prettier integration
210
- - **Dual Module Support**: ESM + CommonJS builds
211
-
212
- ## 🤖 AI Development Optimization
213
-
214
- This project is optimized for AI-assisted development with:
215
-
216
- ### Enhanced Documentation
217
- - **Comprehensive JSDoc comments** on all public APIs
218
- - **Usage examples** for common patterns
219
- - **Type relationships** clearly documented
220
- - **Change logs** with migration guides
221
-
222
- ### AI-Friendly Patterns
223
- - **Consistent naming conventions** across all types
224
- - **Semantic type organization** by domain
225
- - **Clear export patterns** with barrel exports
226
- - **Utility type composition** for complex scenarios
227
-
228
- ### Development Support
229
- - **CLAUDE.md** with project-specific instructions
230
- - **TYPE_CHANGES.md** documenting all type evolution
231
- - **AI analysis scripts** for type validation
232
- - **Comprehensive test coverage** for validation
233
-
234
- ## 📚 Key Type Categories
235
-
236
- ### Core Business Types
237
- - `Email`, `User`, `WalletUserData` - Core application entities
238
- - `MailBox`, `Folder` - Email organization structures
239
- - `AuthStatus`, `ConnectionState` - Authentication states
240
-
241
- ### Blockchain Types
242
- - `Message`, `PreparedMessage` - Multi-chain messaging
243
- - `TransactionResult`, `TransactionStatus` - Transaction handling
244
- - `NetworkConfig`, `DeploymentAddresses` - Network configuration
245
-
246
- ### Utility Types
247
- - `Optional<T>` - Null/undefined safe typing
248
- - `Result<T, E>` - Error handling patterns
249
- - `ValidationResult<T>` - Validation patterns
250
- - `PaginatedResponse<T>` - API pagination
38
+ ### Enums
251
39
 
252
- ### Infrastructure Types
253
- - `AnalyticsService` - Analytics abstraction
254
- - `NetworkClient` - HTTP client interface
255
- - `UINavigationService` - Navigation abstraction
40
+ Key enums: `AuthStatus`, `Chain` (60+ chains), `ChainType`, `ConnectionState`, `Theme`, `EmailAction`, `RequestStatus`, `WalletType`, `EntityType`, `EntityRole`, and more.
256
41
 
257
- ## 🔧 Configuration
42
+ ### Import Paths
258
43
 
259
- ### TypeScript Config
260
- The package is built with strict TypeScript settings:
261
- ```json
262
- {
263
- "compilerOptions": {
264
- "strict": true,
265
- "noUncheckedIndexedAccess": true,
266
- "exactOptionalPropertyTypes": true
267
- }
268
- }
269
- ```
270
-
271
- ### Import Patterns
272
44
  ```typescript
273
- // Main exports
274
- import { Email, User, Optional } from '@johnqh/types';
275
-
276
- // Specific modules (tree-shakeable)
277
- import { ChainType } from '@johnqh/types/enums';
278
- import { ValidationResponse } from '@johnqh/types/indexer';
279
-
280
- // Utilities
281
- import { formatWalletAddress } from '@johnqh/types/utils';
45
+ import { ... } from '@sudobility/types'; // Full library
46
+ import { ... } from '@sudobility/types/api'; // Indexer response types
47
+ import { ... } from '@sudobility/types/enums'; // Business enums only
282
48
  ```
283
49
 
284
- ## 🔄 Recent Updates (v1.6.2)
50
+ ## Development
285
51
 
286
- - ✅ **Optional<T> Consistency**: Standardized optional type usage
287
- - ✅ **Enhanced Type Safety**: Replaced `any` with `unknown` throughout
288
- - **Improved Documentation**: Comprehensive JSDoc coverage
289
- - **Better AI Support**: Enhanced for AI-assisted development
290
- - **Performance**: Zero runtime dependencies maintained
291
-
292
- ## 🤝 Contributing
293
-
294
- This project follows strict quality standards:
295
-
296
- 1. **All types must have JSDoc documentation**
297
- 2. **Comprehensive tests required for utilities**
298
- 3. **Zero external runtime dependencies**
299
- 4. **Backward compatibility maintained**
300
- 5. **AI-friendly code patterns**
301
-
302
- ## 📄 License
52
+ ```bash
53
+ bun install
54
+ bun run build # Build dual ESM + CJS output
55
+ bun run dev # Watch mode
56
+ bun test # Run tests (Vitest)
57
+ bun run typecheck # TypeScript check
58
+ bun run lint # ESLint (flat config)
59
+ bun run format # Prettier
60
+ bun run verify # Full pipeline: typecheck + lint + test + build
61
+ ```
303
62
 
304
- MIT © Sudobility
63
+ ## Key Exports
305
64
 
306
- ---
65
+ - **Types**: `Optional<T>`, `Result<T,E>`, `ValidationResult<T>`, `BaseResponse<T>`, `PaginatedResponse<T>`, `UnifiedError`
66
+ - **Enums**: `AuthStatus`, `Chain`, `ChainType`, `ConnectionState`, `Theme`, `EmailAction`, `WalletType`, `EntityType`, `EntityRole`, and more
67
+ - **Validators**: `isEvmAddress`, `isSolanaAddress`, `isENSName`, `isSNSName`, `Web3UsernameValidator`, `validateAddress`, `validateAmount`, type guards
68
+ - **Formatters**: `formatWalletAddress`, `formatUSDC`, `formatEmailDate`, `formatRelativeTime`, `formatBytes`, `truncate`, `capitalize`, and more
69
+ - **Async Helpers**: `safeAsync`, `withLoadingState`, `safeParallel`, `withTimeout`, `withCache`, `debounceAsync`
70
+ - **Infrastructure**: `NetworkClient`, `AnalyticsService`, `UINavigationService`
307
71
 
308
- **Built with ❤️ for the Web3 email revolution**
72
+ ## License
309
73
 
310
- *This package powers the type-safe foundation for Web3-native email platforms.*
74
+ BUSL-1.1