@kuckit/sdk 1.0.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.
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # @kuckit/sdk
2
+
3
+ The Kuckit SDK provides the foundation for building modular applications with dependency injection, lifecycle management, and a plugin-style module system.
4
+
5
+ ## Features
6
+
7
+ - **DI Container** - Awilix-based dependency injection with scoped lifetimes
8
+ - **Module Loader** - Plugin system with lifecycle hooks for registering services and APIs
9
+ - **Core Services** - Pre-configured logger, event bus, cache, rate limiter, and database pool
10
+ - **Type Safety** - Full TypeScript support with typed container resolution
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Using bun
16
+ bun add @kuckit/sdk
17
+
18
+ # Using npm
19
+ npm install @kuckit/sdk
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ### 1. Create a Container
25
+
26
+ ```ts
27
+ import { createKuckitContainer, loadKuckitModules } from '@kuckit/sdk'
28
+
29
+ const container = await createKuckitContainer({
30
+ config: {
31
+ databaseUrl: process.env.DATABASE_URL!,
32
+ enableFileLogging: false,
33
+ logDir: './logs',
34
+ logLevel: 'INFO',
35
+ env: 'development',
36
+ },
37
+ })
38
+ ```
39
+
40
+ ### 2. Load Modules
41
+
42
+ ```ts
43
+ import { kuckitModule as usersModule } from '@kuckit/users-module'
44
+
45
+ await loadKuckitModules({
46
+ container,
47
+ env: 'development',
48
+ modules: [
49
+ { module: usersModule, config: { enableCaching: true } },
50
+ { package: '@acme/billing-module' }, // npm package
51
+ ],
52
+ onApiRegistrations: (registrations) => {
53
+ // Wire API routes to your framework (Express, Hono, etc.)
54
+ },
55
+ })
56
+ ```
57
+
58
+ ### 3. Resolve Services
59
+
60
+ ```ts
61
+ const logger = container.resolve('logger')
62
+ const userRepository = container.resolve('userRepository')
63
+
64
+ logger.info('Application started')
65
+ ```
66
+
67
+ ## Core Services
68
+
69
+ After `createKuckitContainer()`, these services are available:
70
+
71
+ | Token | Type | Description |
72
+ | ------------------ | ------------------ | ------------------------------ |
73
+ | `config` | `CoreConfig` | Application configuration |
74
+ | `db` | Drizzle instance | Database query builder |
75
+ | `dbPool` | `Pool` | Raw PostgreSQL connection pool |
76
+ | `logger` | `Logger` | Structured logging |
77
+ | `eventBus` | `EventBus` | Pub/sub event system |
78
+ | `clock` | `Clock` | Time abstraction (testable) |
79
+ | `cacheStore` | `CacheStore` | Key-value cache |
80
+ | `rateLimiterStore` | `RateLimiterStore` | Rate limiting |
81
+ | `auth` | Auth utilities | Authentication helpers |
82
+
83
+ ## Building Modules
84
+
85
+ See [Module Development Guide](./docs/MODULE_DEVELOPMENT.md) for a complete guide on creating third-party modules.
86
+
87
+ ```ts
88
+ import { defineKuckitModule, asClass } from '@kuckit/sdk'
89
+
90
+ export const kuckitModule = defineKuckitModule({
91
+ id: 'acme.billing',
92
+ displayName: 'Billing',
93
+
94
+ register(ctx) {
95
+ ctx.container.register({
96
+ invoiceRepository: asClass(InvoiceRepository).scoped(),
97
+ })
98
+ },
99
+ })
100
+ ```
101
+
102
+ ## API Reference
103
+
104
+ ### `createKuckitContainer(options)`
105
+
106
+ Creates a DI container with core services registered.
107
+
108
+ ### `loadKuckitModules(options)`
109
+
110
+ Loads and initializes modules through their lifecycle hooks.
111
+
112
+ ### `defineKuckitModule(definition)`
113
+
114
+ Type-safe helper to define a module with metadata and hooks.
115
+
116
+ ### `disposeContainer(container)`
117
+
118
+ Gracefully closes database connections and cleans up resources.
119
+
120
+ ## Re-exports
121
+
122
+ The SDK re-exports useful utilities:
123
+
124
+ ```ts
125
+ // Awilix helpers
126
+ import { asClass, asFunction, asValue } from '@kuckit/sdk'
127
+
128
+ // Core packages (for advanced use)
129
+ import { Domain, Application, Contracts } from '@kuckit/sdk'
130
+ ```
131
+
132
+ ## License
133
+
134
+ MIT