@fjell/registry 4.4.51 → 4.4.53

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 (51) hide show
  1. package/package.json +4 -4
  2. package/API.md +0 -62
  3. package/GETTING_STARTED.md +0 -69
  4. package/build.js +0 -38
  5. package/docs/README.md +0 -74
  6. package/docs/TIMING_NODE_OPTIMIZATION.md +0 -207
  7. package/docs/TIMING_README.md +0 -170
  8. package/docs/docs.config.ts +0 -114
  9. package/docs/index.html +0 -26
  10. package/docs/package-lock.json +0 -5129
  11. package/docs/package.json +0 -34
  12. package/docs/public/404.html +0 -53
  13. package/docs/public/GETTING_STARTED.md +0 -69
  14. package/docs/public/README.md +0 -623
  15. package/docs/public/TIMING_NODE_OPTIMIZATION.md +0 -207
  16. package/docs/public/api.md +0 -62
  17. package/docs/public/client-api-overview.md +0 -137
  18. package/docs/public/configuration.md +0 -759
  19. package/docs/public/error-handling/README.md +0 -356
  20. package/docs/public/error-handling/network-errors.md +0 -485
  21. package/docs/public/examples/coordinates-example.ts +0 -253
  22. package/docs/public/examples/multi-level-keys.ts +0 -374
  23. package/docs/public/examples/registry-hub-coordinates-example.ts +0 -370
  24. package/docs/public/examples/registry-hub-types.ts +0 -437
  25. package/docs/public/examples/simple-example.ts +0 -250
  26. package/docs/public/examples-README.md +0 -241
  27. package/docs/public/fjell-icon.svg +0 -1
  28. package/docs/public/icon.png +0 -0
  29. package/docs/public/icon2.png +0 -0
  30. package/docs/public/memory-overhead.svg +0 -120
  31. package/docs/public/memory.md +0 -430
  32. package/docs/public/operations/README.md +0 -121
  33. package/docs/public/operations/all.md +0 -325
  34. package/docs/public/operations/create.md +0 -415
  35. package/docs/public/operations/get.md +0 -389
  36. package/docs/public/package.json +0 -63
  37. package/docs/public/pano.png +0 -0
  38. package/docs/public/pano2.png +0 -0
  39. package/docs/public/timing-range.svg +0 -176
  40. package/docs/public/timing.md +0 -483
  41. package/docs/timing-range.svg +0 -174
  42. package/docs/vitest.config.ts +0 -14
  43. package/examples/README.md +0 -241
  44. package/examples/coordinates-example.ts +0 -253
  45. package/examples/multi-level-keys.ts +0 -382
  46. package/examples/registry-hub-coordinates-example.ts +0 -370
  47. package/examples/registry-hub-types.ts +0 -437
  48. package/examples/registry-statistics-example.ts +0 -264
  49. package/examples/simple-example.ts +0 -250
  50. package/tsconfig.docs.json +0 -28
  51. package/vitest.config.ts +0 -22
@@ -1,241 +0,0 @@
1
- # Registry Examples
2
-
3
- This directory contains examples demonstrating how to use the Registry with different key patterns and configurations.
4
-
5
- ## Examples
6
-
7
- ### 1. `simple-example.ts` ⭐ **Start Here!**
8
- **Perfect for beginners!** Demonstrates the simplest possible way to use the Registry:
9
- - **No RegistryHub required** - just call `createRegistry()`
10
- - **No scopes needed** - pass empty array `[]` or omit entirely
11
- - **Basic dependency injection** - register and retrieve services
12
- - **Service dependencies** - shows how services can depend on each other
13
-
14
- Great for simple applications that just need basic dependency injection without complexity.
15
-
16
- ### 2. `multi-level-keys.ts`
17
- **Advanced usage with scopes and multi-level keys!** Demonstrates how Registry supports hierarchical key type arrays:
18
- - **Single level**: `['user']`, `['task']` - SQL vs NoSQL implementations
19
- - **Two levels**: `['user', 'profile']` - S3 vs Local storage implementations
20
- - **Three levels**: `['user', 'profile', 'preference']` - Redis implementation
21
- - **Real scopes**: Production vs development environments
22
- - **Multiple implementations**: Same interface, different backends
23
-
24
- Shows how each key path maps to different implementations via scopes using the real library.
25
-
26
- ### 3. `registry-hub-types.ts` 🏗️ **Enterprise Architecture**
27
- **Large-scale application with service organization!** Demonstrates how RegistryHub manages multiple registries for different service types:
28
- - **Service Categories**: Business logic, data access, infrastructure, communication
29
- - **Type-based Organization**: Services organized by purpose and responsibility
30
- - **Cross-Registry Workflows**: Services from different registries working together
31
- - **Environment Configuration**: Production vs development implementations
32
- - **Centralized Discovery**: Single hub for all service types
33
-
34
- Perfect for enterprise applications that need clean separation of concerns and organized service architecture.
35
-
36
- ### 4. `registry-statistics-example.ts` 📊 **Usage Analytics**
37
- **Track and monitor registry usage patterns with scope-aware analytics!** Demonstrates advanced statistics tracking:
38
- - **Scope-Aware Tracking**: Separate statistics for each kta + scopes combination
39
- - **Total Call Monitoring**: Track overall `get()` method usage
40
- - **Detailed Coordinate Records**: Individual tracking for each service/scope pair
41
- - **Environment Analysis**: Aggregate statistics by environment (prod/dev)
42
- - **Most/Least Used Services**: Identify usage patterns and bottlenecks
43
- - **Immutable Statistics**: Safe access to tracking data without affecting internal state
44
- - **Normalized Scope Handling**: Consistent tracking regardless of scope order
45
-
46
- Perfect for monitoring, optimization, understanding service usage patterns, and analyzing environment-specific behavior in production applications.
47
-
48
- ## Key Concepts Demonstrated
49
-
50
- ### Simple Usage (simple-example.ts)
51
- ```typescript
52
- // Import the real registry functionality
53
- import { createRegistry, createInstance } from '../src/Registry';
54
-
55
- // Create a registry - no RegistryHub needed!
56
- const registry = createRegistry('app');
57
-
58
- // Register a service - no scopes needed!
59
- registry.createInstance(['logger'], [], (coordinate, context) => {
60
- const service = new LoggerService();
61
- const instance = createInstance(context.registry, coordinate);
62
- (instance as any).log = service.log.bind(service);
63
- return instance;
64
- });
65
-
66
- // Get the service - no scopes needed!
67
- const logger = registry.get(['logger']);
68
- logger.log('Hello from the registry!');
69
- ```
70
-
71
- ### Multi-Level Key Arrays
72
- ```typescript
73
- // Different key path levels
74
- ['user'] // → UserService implementation
75
- ['user', 'profile'] // → UserProfileService implementation
76
- ['user', 'profile', 'preference'] // → UserPreferenceService implementation
77
- ['task'] // → TaskService implementation
78
- ```
79
-
80
- ### RegistryHub Usage (registry-hub-types.ts)
81
- ```typescript
82
- // Import RegistryHub functionality
83
- import { createRegistryHub } from '../src/RegistryHub';
84
- import { createRegistry } from '../src/Registry';
85
-
86
- // Create a hub to manage multiple registries
87
- const hub = createRegistryHub();
88
-
89
- // Create specialized registries for different service types
90
- const servicesRegistry = createRegistry('services'); // Business logic
91
- const dataRegistry = createRegistry('data'); // Data access
92
- const infraRegistry = createRegistry('infrastructure'); // Infrastructure
93
- const commRegistry = createRegistry('communication'); // External services
94
-
95
- // Register all registries in the hub
96
- hub.registerRegistry(servicesRegistry);
97
- hub.registerRegistry(dataRegistry);
98
- hub.registerRegistry(infraRegistry);
99
- hub.registerRegistry(commRegistry);
100
-
101
- // Register services by type and scope
102
- servicesRegistry.createInstance(['auth'], ['prod'], (coordinate, context) => {
103
- // JWT implementation for production
104
- });
105
-
106
- dataRegistry.createInstance(['user'], ['sql'], (coordinate, context) => {
107
- // PostgreSQL implementation
108
- });
109
-
110
- // Retrieve services by type and scope through the hub
111
- const prodAuth = hub.get('services', ['auth'], { scopes: ['prod'] });
112
- const sqlUser = hub.get('data', ['user'], { scopes: ['sql'] });
113
- const cache = hub.get('infrastructure', ['cache'], { scopes: ['dev'] });
114
- const email = hub.get('communication', ['email'], { scopes: ['prod'] });
115
- ```
116
-
117
- ### Scope-Based Implementation Selection
118
- - Multiple implementations per key path
119
- - Runtime selection via scopes
120
- - Environment-based switching (prod/dev/test)
121
- - Feature flags and A/B testing support
122
-
123
- ### Real-World Use Cases
124
- - **Database Abstraction**: Different implementations for PostgreSQL, MongoDB, etc.
125
- - **Environment Selection**: Different implementations for prod/dev
126
- - **Testing**: Mock implementations with 'test' scope
127
- - **Microservices**: Each key path represents a different service
128
- - **Multi-Region**: Different implementations across regions
129
-
130
- ## Using the Registry
131
-
132
- The registry provides a centralized way to manage instances in your application. Here are the main operations you can perform:
133
-
134
- ### Getting All Coordinates
135
-
136
- You can retrieve a list of all coordinates currently registered in the registry:
137
-
138
- ```typescript
139
- import { createRegistry } from '@fjell/registry';
140
-
141
- const registry = createRegistry('myRegistry');
142
-
143
- // Register some instances...
144
- registry.createInstance(['service'], ['production'], factory1);
145
- registry.createInstance(['cache', 'redis'], ['development'], factory2);
146
-
147
- // Get all coordinates
148
- const coordinates = registry.getCoordinates();
149
- console.log(`Found ${coordinates.length} registered coordinates:`);
150
- coordinates.forEach(coord => {
151
- console.log(`- ${coord.toString()}`);
152
- });
153
- ```
154
-
155
- This is useful for debugging, monitoring, or implementing discovery mechanisms in your application.
156
-
157
- ### Basic Instance Management
158
-
159
- ## Running Examples
160
-
161
- ```bash
162
- # Start with the simple example (recommended)
163
- npx tsx examples/simple-example.ts
164
-
165
- # Run the multi-level keys example
166
- npx tsx examples/multi-level-keys.ts
167
-
168
- # Run the RegistryHub with service types example
169
- npx tsx examples/registry-hub-types.ts
170
-
171
- # Run the coordinate discovery and introspection example
172
- npx tsx examples/coordinates-example.ts
173
-
174
- # Run the RegistryHub cross-registry coordinate discovery example
175
- npx tsx examples/registry-hub-coordinates-example.ts
176
-
177
- # Run the registry statistics tracking example
178
- npx tsx examples/registry-statistics-example.ts
179
-
180
- # Or in Node.js
181
- node -r esbuild-register examples/simple-example.ts
182
- node -r esbuild-register examples/multi-level-keys.ts
183
- node -r esbuild-register examples/registry-hub-types.ts
184
- node -r esbuild-register examples/coordinates-example.ts
185
- node -r esbuild-register examples/registry-hub-coordinates-example.ts
186
- node -r esbuild-register examples/registry-statistics-example.ts
187
- ```
188
-
189
- ## Integration with Real Fjell Registry
190
-
191
- Both examples now use the real library! In actual usage with the built package:
192
-
193
- ```typescript
194
- import { createRegistry, createInstance } from '@fjell/registry';
195
-
196
- // Simple usage - no RegistryHub, no scopes
197
- const registry = createRegistry('app');
198
-
199
- registry.createInstance(['user'], [], (coordinate, context) => {
200
- const service = new UserService();
201
- const instance = createInstance(context.registry, coordinate);
202
- (instance as any).save = service.save.bind(service);
203
- return instance;
204
- });
205
-
206
- const user = registry.get(['user']);
207
-
208
- // Advanced usage - with scopes for multiple implementations
209
- registry.createInstance(['user'], ['sql', 'prod'], (coordinate, context) => {
210
- const service = new SqlUserService();
211
- const instance = createInstance(context.registry, coordinate);
212
- (instance as any).save = service.save.bind(service);
213
- return instance;
214
- });
215
-
216
- const prodUser = registry.get(['user'], { scopes: ['prod'] });
217
- ```
218
-
219
- ## When to Use What
220
-
221
- **Use `simple-example.ts` approach when:**
222
- - You're just getting started
223
- - You have a simple application
224
- - You don't need multiple implementations per service
225
- - You want basic dependency injection
226
-
227
- **Use `multi-level-keys.ts` approach when:**
228
- - You need multiple implementations (prod/dev/test)
229
- - You have complex service hierarchies
230
- - You need environment-based switching
231
- - You're building a large, complex application
232
-
233
- **Use `registry-hub-types.ts` approach when:**
234
- - You're building enterprise-scale applications
235
- - You need to organize services by type/category
236
- - You have multiple teams working on different service layers
237
- - You want clean separation between business logic, data, and infrastructure
238
- - You need centralized service discovery across service types
239
- - You're implementing microservices or modular architecture
240
-
241
- This approach provides the foundation for the Fjell library's architecture pattern with swappable implementations and enterprise-scale service organization.
@@ -1 +0,0 @@
1
-
Binary file
Binary file
@@ -1,120 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg width="1200" height="800" xmlns="http://www.w3.org/2000/svg">
3
- <style>
4
- .axis { stroke: #333; stroke-width: 1; }
5
- .grid { stroke: #ddd; stroke-width: 0.5; }
6
- .label { font-family: Arial, sans-serif; font-size: 14px; fill: #333; }
7
- .title { font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; fill: #333; }
8
- .subtitle { font-family: Arial, sans-serif; font-size: 12px; fill: #666; }
9
- .per-instance { stroke: #3498db; stroke-width: 3; fill: none; }
10
- .per-instance-dot { fill: #3498db; }
11
- .legend { font-family: Arial, sans-serif; font-size: 12px; fill: #333; }
12
- .axis-title { font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; fill: #333; }
13
- .metadata-section { font-family: Arial, sans-serif; font-size: 14px; font-weight: bold; fill: #444; }
14
- .metadata-label { font-family: Arial, sans-serif; font-size: 10px; fill: #666; }
15
- .metadata-value { font-family: Arial, sans-serif; font-size: 10px; fill: #333; }
16
- </style>
17
-
18
- <!-- Background -->
19
- <rect width="1200" height="800" fill="white"/>
20
-
21
- <!-- Title -->
22
- <text x="600" y="25" text-anchor="middle" class="title">Memory Efficiency Per Instance</text>
23
- <text x="600" y="45" text-anchor="middle" class="subtitle">Average memory overhead per registry instance across different scale sizes</text>
24
-
25
- <!-- Plot area -->
26
- <g transform="translate(110,60)">
27
-
28
- <!-- Grid lines (Y-axis - memory in KB) -->
29
- <line x1="0" y1="355.57592837740003" x2="990" y2="355.57592837740003" class="grid"/>
30
- <text x="-10" y="359.57592837740003" text-anchor="end" class="label">2KB</text>
31
- <line x1="0" y1="153.13821696732998" x2="990" y2="153.13821696732998" class="grid"/>
32
- <text x="-10" y="157.13821696732998" text-anchor="end" class="label">5KB</text>
33
- <line x1="0" y1="0" x2="990" y2="0" class="grid"/>
34
- <text x="-10" y="4" text-anchor="end" class="label">10KB</text>
35
- <line x1="0" y1="0" x2="0" y2="460" class="grid"/>
36
- <text x="0" y="480" text-anchor="middle" class="label">10</text>
37
- <line x1="99.33989856911381" y1="0" x2="99.33989856911381" y2="460" class="grid"/>
38
- <text x="99.33989856911381" y="480" text-anchor="middle" class="label">20</text>
39
- <line x1="230.6601014308862" y1="0" x2="230.6601014308862" y2="460" class="grid"/>
40
- <text x="230.6601014308862" y="480" text-anchor="middle" class="label">50</text>
41
- <line x1="330" y1="0" x2="330" y2="460" class="grid"/>
42
- <text x="330" y="480" text-anchor="middle" class="label">100</text>
43
- <line x1="429.3398985691138" y1="0" x2="429.3398985691138" y2="460" class="grid"/>
44
- <text x="429.3398985691138" y="480" text-anchor="middle" class="label">200</text>
45
- <line x1="560.6601014308862" y1="0" x2="560.6601014308862" y2="460" class="grid"/>
46
- <text x="560.6601014308862" y="480" text-anchor="middle" class="label">500</text>
47
- <line x1="660" y1="0" x2="660" y2="460" class="grid"/>
48
- <text x="660" y="480" text-anchor="middle" class="label">1k</text>
49
- <line x1="759.3398985691139" y1="0" x2="759.3398985691139" y2="460" class="grid"/>
50
- <text x="759.3398985691139" y="480" text-anchor="middle" class="label">2k</text>
51
- <line x1="890.6601014308862" y1="0" x2="890.6601014308862" y2="460" class="grid"/>
52
- <text x="890.6601014308862" y="480" text-anchor="middle" class="label">5k</text>
53
- <line x1="990" y1="0" x2="990" y2="460" class="grid"/>
54
- <text x="990" y="480" text-anchor="middle" class="label">10k</text>
55
- <!-- Y-axis -->
56
- <line x1="0" y1="0" x2="0" y2="460" class="axis"/>
57
-
58
- <!-- X-axis -->
59
- <line x1="0" y1="460" x2="990" y2="460" class="axis"/>
60
-
61
- <!-- Axis labels -->
62
- <text x="495" y="510" text-anchor="middle" class="axis-title">Instance Count - Log Scale</text>
63
- <text transform="rotate(-90,-70,230)" x="-70" y="230" text-anchor="middle" class="axis-title">Memory Usage (KB)</text>
64
- <path d="M 0 240.70120928043835 L 99.33989856911381 282.22270579627764 L 230.6601014308862 327.2110056876071 L 330 354.03530806378257 L 429.3398985691138 346.21437843228813 L 560.6601014308862 360.1862852477646 L 660 352.43697251573866 L 759.3398985691139 365.33853358657484 L 890.6601014308862 349.28769665195966 L 990 410.70050555725993" class="per-instance"/>
65
- <circle cx="0" cy="240.70120928043835" r="4" class="per-instance-dot"/>
66
- <circle cx="99.33989856911381" cy="282.22270579627764" r="4" class="per-instance-dot"/>
67
- <circle cx="230.6601014308862" cy="327.2110056876071" r="4" class="per-instance-dot"/>
68
- <circle cx="330" cy="354.03530806378257" r="4" class="per-instance-dot"/>
69
- <circle cx="429.3398985691138" cy="346.21437843228813" r="4" class="per-instance-dot"/>
70
- <circle cx="560.6601014308862" cy="360.1862852477646" r="4" class="per-instance-dot"/>
71
- <circle cx="660" cy="352.43697251573866" r="4" class="per-instance-dot"/>
72
- <circle cx="759.3398985691139" cy="365.33853358657484" r="4" class="per-instance-dot"/>
73
- <circle cx="890.6601014308862" cy="349.28769665195966" r="4" class="per-instance-dot"/>
74
- <circle cx="990" cy="410.70050555725993" r="4" class="per-instance-dot"/>
75
- <!-- Legend -->
76
- <g transform="translate(20, 20)">
77
- <rect x="0" y="0" width="190" height="60" fill="white" stroke="#ccc" stroke-width="1"/>
78
-
79
- <!-- Memory Per Instance Legend -->
80
- <text x="10" y="20" class="legend" font-weight="bold">Memory Per Instance</text>
81
- <line x1="10" y1="30" x2="40" y2="30" class="per-instance"/>
82
- <circle cx="25" cy="30" r="3" class="per-instance-dot"/>
83
- <text x="45" y="34" class="legend">Average Performance</text>
84
- </g>
85
-
86
- </g>
87
-
88
- <!-- Test Metadata Section - match timing chart layout exactly -->
89
- <g transform="translate(50, 620)">
90
- <!-- Left Column: System Information -->
91
- <g transform="translate(20, 20)">
92
- <text x="0" y="0" class="metadata-section">System Information</text>
93
-
94
- <text x="0" y="25" class="metadata-label">Test Date:</text>
95
- <text x="150" y="25" class="metadata-value">2025-07-21</text>
96
-
97
- <text x="0" y="45" class="metadata-label">Package Version:</text>
98
- <text x="150" y="45" class="metadata-value">@fjell/registry v4.4.7</text>
99
-
100
- <text x="0" y="65" class="metadata-label">Node.js Version:</text>
101
- <text x="150" y="65" class="metadata-value">v22.0.0 (darwin arm64)</text>
102
-
103
- <text x="0" y="85" class="metadata-label">Platform:</text>
104
- <text x="150" y="85" class="metadata-value">darwin arm64</text>
105
-
106
- <text x="0" y="105" class="metadata-label">Compiler:</text>
107
- <text x="150" y="105" class="metadata-value">TypeScript + Vite</text>
108
- </g>
109
-
110
- <!-- Right Column: Test Notes -->
111
- <g transform="translate(400, 20)">
112
- <text x="0" y="0" class="metadata-section">Test Notes</text>
113
- <text x="0" y="25" class="metadata-label">• Memory measurements use Node.js process.memoryUsage() with heap precision</text>
114
- <text x="0" y="42" class="metadata-label">• Each test includes garbage collection to minimize measurement variance</text>
115
- <text x="0" y="59" class="metadata-label">• Logging is mocked during memory tests to eliminate overhead</text>
116
- <text x="0" y="76" class="metadata-label">• Tests verify memory efficiency and consistency across instance counts</text>
117
- <text x="0" y="93" class="metadata-label">• Statistical analysis ensures reliable performance measurements</text>
118
- </g>
119
- </g>
120
- </svg>