@kuckit/sdk 2.0.3 → 2.0.6
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/dist/config/define-config.d.ts +2 -2
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.js +2 -2
- package/dist/config/loader.d.ts +2 -2
- package/dist/config/loader.js +1 -1
- package/dist/config/types.d.ts +1 -1
- package/dist/{container-Ct2UXGF_.js → container-CGi8iyd_.js} +2 -2
- package/dist/container-CGi8iyd_.js.map +1 -0
- package/dist/{container-BQ8Ow2Ot.d.ts → container-Cmi4qYsl.d.ts} +3 -32
- package/dist/core/container.d.ts +3 -3
- package/dist/core/container.js +2 -2
- package/dist/core/core.module.d.ts +2 -3
- package/dist/core/core.module.js +1 -1
- package/dist/{core.module-D8vH8AcY.d.ts → core.module-C0NHfRv9.d.ts} +3 -4
- package/dist/{core.module-47w_x8z-.js → core.module-DcvMkqV-.js} +2 -7
- package/dist/core.module-DcvMkqV-.js.map +1 -0
- package/dist/{define-config-D-gChhM6.d.ts → define-config-BHESZAiB.d.ts} +2 -2
- package/dist/{define-module-CDZ2Cnss.d.ts → define-module-DpWBcWhT.d.ts} +2 -2
- package/dist/express-AjKhnJGy.d.ts +28 -0
- package/dist/express.d.ts +2 -0
- package/dist/express.js +1 -0
- package/dist/index-CoTYpOht.d.ts +2 -0
- package/dist/index.d.ts +15 -14
- package/dist/index.js +4 -4
- package/dist/{loader-DKhFYG5d.js → loader-BJ2ClBV6.js} +6 -2
- package/dist/{loader-DKhFYG5d.js.map → loader-BJ2ClBV6.js.map} +1 -1
- package/dist/{loader-0s9nW_Uz.d.ts → loader-Cp4MZU8V.d.ts} +2 -2
- package/dist/{loader-Do1M_26D.d.ts → loader-D9yDVSnv.d.ts} +3 -3
- package/dist/modules/define-module.d.ts +3 -3
- package/dist/modules/index.d.ts +5 -5
- package/dist/modules/loader.d.ts +3 -3
- package/dist/modules/registry.d.ts +3 -3
- package/dist/modules/types.d.ts +2 -2
- package/dist/registry-B62Oueqd.js.map +1 -1
- package/dist/{registry-BwUbpLWo.d.ts → registry-CduEY_YF.d.ts} +5 -5
- package/dist/{registry-9FKJPjuY.d.ts → registry-DH-CkOzJ.d.ts} +2 -2
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/registry.d.ts +1 -1
- package/dist/{types-Ceg8XQY6.d.ts → types-C7uI1y_q.d.ts} +1 -1
- package/dist/{types-TrXzdvrM.d.ts → types-CZzFfAW4.d.ts} +4 -5
- package/dist/{types-TWbGQRnv.d.ts → types-D8uMMVx5.d.ts} +23 -3
- package/dist/types.d.ts +2 -2
- package/package.json +17 -10
- package/dist/chunk-B1JASekH.js +0 -7
- package/dist/container-Ct2UXGF_.js.map +0 -1
- package/dist/core.module-47w_x8z-.js.map +0 -1
- package/dist/index-BLsEv2uZ.d.ts +0 -2
- /package/dist/{config-Dwl_qu6x.js → config-BeiJJZGf.js} +0 -0
- /package/dist/{index-C9nY9t1j.d.ts → index-CDDzqahH.d.ts} +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import { t as defineConfig } from "../define-config-
|
|
1
|
+
import "../types-C7uI1y_q.js";
|
|
2
|
+
import { t as defineConfig } from "../define-config-BHESZAiB.js";
|
|
3
3
|
export { defineConfig };
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as KuckitServerConfig, i as KuckitModuleConfig, n as KuckitConfig, o as LoadedKuckitConfig, r as KuckitDiscoveryConfig, t as KuckitClientConfig } from "../types-
|
|
2
|
-
import { t as defineConfig } from "../define-config-
|
|
3
|
-
import { a as tryLoadKuckitConfig, i as loadKuckitConfigSync, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "../loader-
|
|
4
|
-
import "../index-
|
|
1
|
+
import { a as KuckitServerConfig, i as KuckitModuleConfig, n as KuckitConfig, o as LoadedKuckitConfig, r as KuckitDiscoveryConfig, t as KuckitClientConfig } from "../types-C7uI1y_q.js";
|
|
2
|
+
import { t as defineConfig } from "../define-config-BHESZAiB.js";
|
|
3
|
+
import { a as tryLoadKuckitConfig, i as loadKuckitConfigSync, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "../loader-Cp4MZU8V.js";
|
|
4
|
+
import "../index-CDDzqahH.js";
|
|
5
5
|
export { KuckitClientConfig, KuckitConfig, KuckitDiscoveryConfig, KuckitModuleConfig, KuckitServerConfig, LoadedKuckitConfig, defineConfig, findConfigFile, hasUnifiedConfig, loadKuckitConfig, loadKuckitConfigSync, tryLoadKuckitConfig };
|
package/dist/config/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { a as tryLoadKuckitConfig, i as loadKuckitConfigSync, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "../loader-BJ2ClBV6.js";
|
|
1
2
|
import { t as defineConfig } from "../define-config-fjqcYWfl.js";
|
|
2
|
-
import
|
|
3
|
-
import "../config-Dwl_qu6x.js";
|
|
3
|
+
import "../config-BeiJJZGf.js";
|
|
4
4
|
|
|
5
5
|
export { defineConfig, findConfigFile, hasUnifiedConfig, loadKuckitConfig, loadKuckitConfigSync, tryLoadKuckitConfig };
|
package/dist/config/loader.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import { a as tryLoadKuckitConfig, i as loadKuckitConfigSync, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "../loader-
|
|
1
|
+
import "../types-C7uI1y_q.js";
|
|
2
|
+
import { a as tryLoadKuckitConfig, i as loadKuckitConfigSync, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "../loader-Cp4MZU8V.js";
|
|
3
3
|
export { findConfigFile, hasUnifiedConfig, loadKuckitConfig, loadKuckitConfigSync, tryLoadKuckitConfig };
|
package/dist/config/loader.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as tryLoadKuckitConfig, i as loadKuckitConfigSync, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "../loader-
|
|
1
|
+
import { a as tryLoadKuckitConfig, i as loadKuckitConfigSync, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "../loader-BJ2ClBV6.js";
|
|
2
2
|
|
|
3
3
|
export { findConfigFile, hasUnifiedConfig, loadKuckitConfig, loadKuckitConfigSync, tryLoadKuckitConfig };
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as KuckitServerConfig, i as KuckitModuleConfig, n as KuckitConfig, o as LoadedKuckitConfig, r as KuckitDiscoveryConfig, t as KuckitClientConfig } from "../types-
|
|
1
|
+
import { a as KuckitServerConfig, i as KuckitModuleConfig, n as KuckitConfig, o as LoadedKuckitConfig, r as KuckitDiscoveryConfig, t as KuckitClientConfig } from "../types-C7uI1y_q.js";
|
|
2
2
|
export { KuckitClientConfig, KuckitConfig, KuckitDiscoveryConfig, KuckitModuleConfig, KuckitServerConfig, LoadedKuckitConfig };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as registerCoreModule } from "./core.module-
|
|
1
|
+
import { t as registerCoreModule } from "./core.module-DcvMkqV-.js";
|
|
2
2
|
import { InjectionMode, asValue, createContainer } from "awilix";
|
|
3
3
|
|
|
4
4
|
//#region src/core/container.ts
|
|
@@ -47,4 +47,4 @@ const disposeContainer = async (container) => {
|
|
|
47
47
|
|
|
48
48
|
//#endregion
|
|
49
49
|
export { disposeContainer as n, createKuckitContainer as t };
|
|
50
|
-
//# sourceMappingURL=container-
|
|
50
|
+
//# sourceMappingURL=container-CGi8iyd_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-CGi8iyd_.js","names":[],"sources":["../src/core/container.ts"],"sourcesContent":["import { createContainer, asValue, InjectionMode } from 'awilix'\nimport type { CoreContainer, CoreCradle, CoreConfig, PrebuiltDependencies } from '../types'\nimport { registerCoreModule } from './core.module'\n\nexport interface CreateKuckitOptions {\n\t/**\n\t * Core configuration for the SDK\n\t */\n\tconfig: CoreConfig\n\n\t/**\n\t * Pre-built dependencies to inject instead of creating internally.\n\t * Use this in composition root (apps/server) to control instantiation.\n\t */\n\tprebuilt?: PrebuiltDependencies\n\n\t/**\n\t * Optional callback to register additional services after core registration\n\t */\n\textraRegistrations?: (container: CoreContainer) => void | Promise<void>\n}\n\n/**\n * Factory function to create a Kuckit DI container\n *\n * This is the primary entry point for applications using the SDK.\n * It creates an Awilix container with core infrastructure services pre-registered.\n *\n * @example\n * ```ts\n * const container = await createKuckitContainer({\n * config: {\n * databaseUrl: process.env.DATABASE_URL!,\n * enableFileLogging: true,\n * logDir: './logs',\n * logLevel: 'INFO',\n * env: 'production',\n * },\n * extraRegistrations: (container) => {\n * // Register your custom services\n * container.register({\n * myService: asClass(MyService).singleton(),\n * })\n * },\n * })\n * ```\n */\nexport const createKuckitContainer = async (opts: CreateKuckitOptions): Promise<CoreContainer> => {\n\tconst container = createContainer<CoreCradle>({\n\t\tinjectionMode: InjectionMode.PROXY,\n\t})\n\n\t// Register config first (required by other registrations)\n\tcontainer.register({\n\t\tconfig: asValue(opts.config),\n\t})\n\n\t// Register core infrastructure (passing prebuilt dependencies if provided)\n\tregisterCoreModule(container, opts.prebuilt)\n\n\t// Allow custom registrations\n\tif (opts.extraRegistrations) {\n\t\tawait opts.extraRegistrations(container)\n\t}\n\n\treturn container\n}\n\n/**\n * Cleanup container resources gracefully\n *\n * Call this when shutting down your application to close database connections\n * and other resources.\n */\nexport const disposeContainer = async (container: CoreContainer): Promise<void> => {\n\tconst { dbPool } = container.cradle\n\t// Handle unknown dbPool type - check for end method\n\tif (\n\t\tdbPool &&\n\t\ttypeof dbPool === 'object' &&\n\t\t'end' in dbPool &&\n\t\ttypeof (dbPool as { end: unknown }).end === 'function'\n\t) {\n\t\tawait (dbPool as { end: () => Promise<void> }).end()\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,wBAAwB,OAAO,SAAsD;CACjG,MAAM,YAAY,gBAA4B,EAC7C,eAAe,cAAc,OAC7B,CAAC;AAGF,WAAU,SAAS,EAClB,QAAQ,QAAQ,KAAK,OAAO,EAC5B,CAAC;AAGF,oBAAmB,WAAW,KAAK,SAAS;AAG5C,KAAI,KAAK,mBACR,OAAM,KAAK,mBAAmB,UAAU;AAGzC,QAAO;;;;;;;;AASR,MAAa,mBAAmB,OAAO,cAA4C;CAClF,MAAM,EAAE,WAAW,UAAU;AAE7B,KACC,UACA,OAAO,WAAW,YAClB,SAAS,UACT,OAAQ,OAA4B,QAAQ,WAE5C,OAAO,OAAwC,KAAK"}
|
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
import { n as CoreContainer, t as CoreConfig } from "./types-
|
|
2
|
-
import { Auth } from "@kuckit/auth";
|
|
3
|
-
import { Pool } from "pg";
|
|
1
|
+
import { n as CoreContainer, o as PrebuiltDependencies, t as CoreConfig } from "./types-D8uMMVx5.js";
|
|
4
2
|
|
|
5
3
|
//#region src/core/container.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Pre-built dependencies that can be passed to createKuckitContainer.
|
|
9
|
-
* When provided, these skip the internal factory creation.
|
|
10
|
-
*/
|
|
11
|
-
interface PrebuiltDependencies {
|
|
12
|
-
/**
|
|
13
|
-
* Pre-built PostgreSQL connection pool
|
|
14
|
-
* If provided, skips createDbPool() in core.module
|
|
15
|
-
*/
|
|
16
|
-
dbPool?: Pool;
|
|
17
|
-
/**
|
|
18
|
-
* Pre-built Drizzle database instance
|
|
19
|
-
* If provided, skips createDb() in core.module
|
|
20
|
-
*/
|
|
21
|
-
db?: unknown;
|
|
22
|
-
/**
|
|
23
|
-
* Pre-built Better-Auth instance
|
|
24
|
-
* If provided, skips createAuth() in core.module
|
|
25
|
-
*/
|
|
26
|
-
auth?: Auth;
|
|
27
|
-
/**
|
|
28
|
-
* Pre-built AI provider (e.g., google('gemini-2.5-flash'))
|
|
29
|
-
* If provided, skips aiProvider creation in core.module
|
|
30
|
-
*/
|
|
31
|
-
aiProvider?: unknown;
|
|
32
|
-
}
|
|
33
4
|
interface CreateKuckitOptions {
|
|
34
5
|
/**
|
|
35
6
|
* Core configuration for the SDK
|
|
@@ -79,5 +50,5 @@ declare const createKuckitContainer: (opts: CreateKuckitOptions) => Promise<Core
|
|
|
79
50
|
*/
|
|
80
51
|
declare const disposeContainer: (container: CoreContainer) => Promise<void>;
|
|
81
52
|
//#endregion
|
|
82
|
-
export {
|
|
83
|
-
//# sourceMappingURL=container-
|
|
53
|
+
export { createKuckitContainer as n, disposeContainer as r, CreateKuckitOptions as t };
|
|
54
|
+
//# sourceMappingURL=container-Cmi4qYsl.d.ts.map
|
package/dist/core/container.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import {
|
|
3
|
-
export { CreateKuckitOptions,
|
|
1
|
+
import "../types-D8uMMVx5.js";
|
|
2
|
+
import { n as createKuckitContainer, r as disposeContainer, t as CreateKuckitOptions } from "../container-Cmi4qYsl.js";
|
|
3
|
+
export { CreateKuckitOptions, createKuckitContainer, disposeContainer };
|
package/dist/core/container.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../core.module-
|
|
2
|
-
import { n as disposeContainer, t as createKuckitContainer } from "../container-
|
|
1
|
+
import "../core.module-DcvMkqV-.js";
|
|
2
|
+
import { n as disposeContainer, t as createKuckitContainer } from "../container-CGi8iyd_.js";
|
|
3
3
|
|
|
4
4
|
export { createKuckitContainer, disposeContainer };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import "../
|
|
3
|
-
import { t as registerCoreModule } from "../core.module-D8vH8AcY.js";
|
|
1
|
+
import "../types-D8uMMVx5.js";
|
|
2
|
+
import { t as registerCoreModule } from "../core.module-C0NHfRv9.js";
|
|
4
3
|
export { registerCoreModule };
|
package/dist/core/core.module.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { n as CoreContainer } from "./types-
|
|
2
|
-
import { n as PrebuiltDependencies } from "./container-BQ8Ow2Ot.js";
|
|
1
|
+
import { n as CoreContainer, o as PrebuiltDependencies } from "./types-D8uMMVx5.js";
|
|
3
2
|
|
|
4
3
|
//#region src/core/core.module.d.ts
|
|
5
4
|
|
|
@@ -10,7 +9,7 @@ import { n as PrebuiltDependencies } from "./container-BQ8Ow2Ot.js";
|
|
|
10
9
|
* - Database pool and connection
|
|
11
10
|
* - Clock
|
|
12
11
|
* - Logger (structured, Loki/Prometheus compatible)
|
|
13
|
-
|
|
12
|
+
|
|
14
13
|
* - Auth
|
|
15
14
|
* - Event bus
|
|
16
15
|
* - Cache store
|
|
@@ -23,4 +22,4 @@ import { n as PrebuiltDependencies } from "./container-BQ8Ow2Ot.js";
|
|
|
23
22
|
declare const registerCoreModule: (container: CoreContainer, prebuilt?: PrebuiltDependencies) => void;
|
|
24
23
|
//#endregion
|
|
25
24
|
export { registerCoreModule as t };
|
|
26
|
-
//# sourceMappingURL=core.module-
|
|
25
|
+
//# sourceMappingURL=core.module-C0NHfRv9.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { t as __require } from "./chunk-B1JASekH.js";
|
|
2
1
|
import { asFunction, asValue } from "awilix";
|
|
3
2
|
import { SystemClock } from "@kuckit/domain";
|
|
4
3
|
import { createAuth } from "@kuckit/auth";
|
|
@@ -12,7 +11,7 @@ import { InMemoryEventBus, createDb, createDbPool, makeErrorHandler, makeInMemor
|
|
|
12
11
|
* - Database pool and connection
|
|
13
12
|
* - Clock
|
|
14
13
|
* - Logger (structured, Loki/Prometheus compatible)
|
|
15
|
-
|
|
14
|
+
|
|
16
15
|
* - Auth
|
|
17
16
|
* - Event bus
|
|
18
17
|
* - Cache store
|
|
@@ -34,10 +33,6 @@ const registerCoreModule = (container, prebuilt) => {
|
|
|
34
33
|
})).singleton(),
|
|
35
34
|
errorHandler: asFunction(({ logger }) => makeErrorHandler(logger)).singleton(),
|
|
36
35
|
auth: prebuilt?.auth ? asValue(prebuilt.auth) : asFunction(({ db }) => createAuth({ db })).singleton(),
|
|
37
|
-
aiProvider: prebuilt?.aiProvider ? asValue(prebuilt.aiProvider) : asFunction(() => {
|
|
38
|
-
const { google } = __require("@ai-sdk/google");
|
|
39
|
-
return google("gemini-2.5-flash");
|
|
40
|
-
}).singleton(),
|
|
41
36
|
eventBus: asFunction(({ logger }) => new InMemoryEventBus(logger)).singleton(),
|
|
42
37
|
cacheStore: asFunction(() => makeInMemoryCacheStore()).singleton(),
|
|
43
38
|
rateLimiterStore: asFunction(() => makeInMemoryRateLimiterStore()).singleton(),
|
|
@@ -51,4 +46,4 @@ const registerCoreModule = (container, prebuilt) => {
|
|
|
51
46
|
|
|
52
47
|
//#endregion
|
|
53
48
|
export { registerCoreModule as t };
|
|
54
|
-
//# sourceMappingURL=core.module-
|
|
49
|
+
//# sourceMappingURL=core.module-DcvMkqV-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.module-DcvMkqV-.js","names":[],"sources":["../src/core/core.module.ts"],"sourcesContent":["import { asFunction, asValue } from 'awilix'\nimport { SystemClock } from '@kuckit/domain'\nimport { createAuth } from '@kuckit/auth'\nimport {\n\tcreateDbPool,\n\tcreateDb,\n\tmakeStructuredLogger,\n\tmakeRequestLogger,\n\tmakeErrorHandler,\n\tInMemoryEventBus,\n\tmakeInMemoryCacheStore,\n\tmakeInMemoryRateLimiterStore,\n} from '@kuckit/infrastructure'\nimport type { CoreContainer, PrebuiltDependencies } from '../types'\n\n/**\n * Register core infrastructure services into the container\n *\n * This registers:\n * - Database pool and connection\n * - Clock\n * - Logger (structured, Loki/Prometheus compatible)\n\n * - Auth\n * - Event bus\n * - Cache store\n * - Rate limiter store\n * - Request-scoped logger\n *\n * @param container - The Awilix container to register services into\n * @param prebuilt - Optional pre-built dependencies to use instead of creating internally\n */\nexport const registerCoreModule = (\n\tcontainer: CoreContainer,\n\tprebuilt?: PrebuiltDependencies\n): void => {\n\tcontainer.register({\n\t\t// Database - use prebuilt if provided, otherwise create from config\n\t\tdbPool: prebuilt?.dbPool\n\t\t\t? asValue(prebuilt.dbPool)\n\t\t\t: asFunction(({ config }) => createDbPool(config.databaseUrl)).singleton(),\n\n\t\tdb: prebuilt?.db\n\t\t\t? asValue(prebuilt.db)\n\t\t\t: asFunction(({ dbPool }) => createDb(dbPool)).singleton(),\n\n\t\t// Core services\n\t\tclock: asValue(new SystemClock()),\n\n\t\tlogger: asFunction(({ config }) =>\n\t\t\tmakeStructuredLogger({\n\t\t\t\tenableFile: config.enableFileLogging,\n\t\t\t\tlogDir: config.logDir,\n\t\t\t\tminLevel: config.logLevel,\n\t\t\t})\n\t\t).singleton(),\n\n\t\terrorHandler: asFunction(({ logger }) => makeErrorHandler(logger)).singleton(),\n\n\t\t// Auth - use prebuilt if provided, otherwise create from db\n\t\tauth: prebuilt?.auth\n\t\t\t? asValue(prebuilt.auth)\n\t\t\t: asFunction(({ db }) => createAuth({ db })).singleton(),\n\n\t\t// Event bus\n\t\teventBus: asFunction(({ logger }) => new InMemoryEventBus(logger)).singleton(),\n\n\t\t// Stores - use factory functions that start cleanup timers\n\t\tcacheStore: asFunction(() => makeInMemoryCacheStore()).singleton(),\n\t\trateLimiterStore: asFunction(() => makeInMemoryRateLimiterStore()).singleton(),\n\n\t\t// Request-scoped logger (enriched with requestId and userId)\n\t\trequestLogger: asFunction(({ logger, requestId, session }) =>\n\t\t\tmakeRequestLogger({\n\t\t\t\trequestId,\n\t\t\t\tuserId: session?.user?.id,\n\t\t\t\tbaseLogger: logger,\n\t\t\t})\n\t\t).scoped(),\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,sBACZ,WACA,aACU;AACV,WAAU,SAAS;EAElB,QAAQ,UAAU,SACf,QAAQ,SAAS,OAAO,GACxB,YAAY,EAAE,aAAa,aAAa,OAAO,YAAY,CAAC,CAAC,WAAW;EAE3E,IAAI,UAAU,KACX,QAAQ,SAAS,GAAG,GACpB,YAAY,EAAE,aAAa,SAAS,OAAO,CAAC,CAAC,WAAW;EAG3D,OAAO,QAAQ,IAAI,aAAa,CAAC;EAEjC,QAAQ,YAAY,EAAE,aACrB,qBAAqB;GACpB,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,CAAC,CACF,CAAC,WAAW;EAEb,cAAc,YAAY,EAAE,aAAa,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,MAAM,UAAU,OACb,QAAQ,SAAS,KAAK,GACtB,YAAY,EAAE,SAAS,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW;EAGzD,UAAU,YAAY,EAAE,aAAa,IAAI,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,YAAY,iBAAiB,wBAAwB,CAAC,CAAC,WAAW;EAClE,kBAAkB,iBAAiB,8BAA8B,CAAC,CAAC,WAAW;EAG9E,eAAe,YAAY,EAAE,QAAQ,WAAW,cAC/C,kBAAkB;GACjB;GACA,QAAQ,SAAS,MAAM;GACvB,YAAY;GACZ,CAAC,CACF,CAAC,QAAQ;EACV,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as KuckitConfig } from "./types-
|
|
1
|
+
import { n as KuckitConfig } from "./types-C7uI1y_q.js";
|
|
2
2
|
|
|
3
3
|
//#region src/config/define-config.d.ts
|
|
4
4
|
|
|
@@ -31,4 +31,4 @@ import { n as KuckitConfig } from "./types-Ceg8XQY6.js";
|
|
|
31
31
|
declare function defineConfig(config: KuckitConfig): KuckitConfig;
|
|
32
32
|
//#endregion
|
|
33
33
|
export { defineConfig as t };
|
|
34
|
-
//# sourceMappingURL=define-config-
|
|
34
|
+
//# sourceMappingURL=define-config-BHESZAiB.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as KuckitModuleDefinition } from "./types-
|
|
1
|
+
import { i as KuckitModuleDefinition } from "./types-CZzFfAW4.js";
|
|
2
2
|
|
|
3
3
|
//#region src/modules/define-module.d.ts
|
|
4
4
|
|
|
@@ -53,4 +53,4 @@ import { i as KuckitModuleDefinition } from "./types-TrXzdvrM.js";
|
|
|
53
53
|
declare const defineKuckitModule: <TConfig = unknown>(mod: KuckitModuleDefinition<TConfig>) => KuckitModuleDefinition<TConfig>;
|
|
54
54
|
//#endregion
|
|
55
55
|
export { defineKuckitModule as t };
|
|
56
|
-
//# sourceMappingURL=define-module-
|
|
56
|
+
//# sourceMappingURL=define-module-DpWBcWhT.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AwilixContainer } from "awilix";
|
|
2
|
+
import { Request } from "express";
|
|
3
|
+
|
|
4
|
+
//#region src/express.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Express Request with Awilix scoped container.
|
|
8
|
+
* Use this type in module REST routers that need access to DI scope.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import type { ScopedRequest } from '@kuckit/sdk'
|
|
13
|
+
*
|
|
14
|
+
* interface MyCradle {
|
|
15
|
+
* myService: MyService
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* router.post('/endpoint', (req: Request, res) => {
|
|
19
|
+
* const { myService } = (req as ScopedRequest<MyCradle>).scope.cradle
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
interface ScopedRequest<TCradle extends object = object> extends Request {
|
|
24
|
+
scope: AwilixContainer<TCradle>;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ScopedRequest as t };
|
|
28
|
+
//# sourceMappingURL=express-AjKhnJGy.d.ts.map
|
package/dist/express.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { a as KuckitServerConfig, i as KuckitModuleConfig, n as KuckitConfig, o as LoadedKuckitConfig, r as KuckitDiscoveryConfig, t as KuckitClientConfig } from "./types-
|
|
2
|
-
import { t as defineConfig } from "./define-config-
|
|
3
|
-
import { a as tryLoadKuckitConfig, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "./loader-
|
|
4
|
-
import "./index-
|
|
5
|
-
import { n as CoreContainer, r as CoreCradle, t as CoreConfig } from "./types-
|
|
6
|
-
import {
|
|
7
|
-
import { t as registerCoreModule } from "./core.module-
|
|
8
|
-
import {
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { a as KuckitServerConfig, i as KuckitModuleConfig, n as KuckitConfig, o as LoadedKuckitConfig, r as KuckitDiscoveryConfig, t as KuckitClientConfig } from "./types-C7uI1y_q.js";
|
|
2
|
+
import { t as defineConfig } from "./define-config-BHESZAiB.js";
|
|
3
|
+
import { a as tryLoadKuckitConfig, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "./loader-Cp4MZU8V.js";
|
|
4
|
+
import "./index-CDDzqahH.js";
|
|
5
|
+
import { n as CoreContainer, o as PrebuiltDependencies, r as CoreCradle, t as CoreConfig } from "./types-D8uMMVx5.js";
|
|
6
|
+
import { n as createKuckitContainer, r as disposeContainer, t as CreateKuckitOptions } from "./container-Cmi4qYsl.js";
|
|
7
|
+
import { t as registerCoreModule } from "./core.module-C0NHfRv9.js";
|
|
8
|
+
import { t as ScopedRequest } from "./express-AjKhnJGy.js";
|
|
9
|
+
import { a as KuckitModuleHooks, c as ModuleCapability, i as KuckitModuleDefinition, l as ModuleSpec, n as BuiltInCapability, o as KuckitModuleMeta, r as KuckitModuleContext, t as ApiRegistration } from "./types-CZzFfAW4.js";
|
|
10
|
+
import { t as defineKuckitModule } from "./define-module-DpWBcWhT.js";
|
|
11
|
+
import { n as createModuleShutdownHandler, r as loadKuckitModules, t as LoadModulesOptions } from "./loader-D9yDVSnv.js";
|
|
12
|
+
import { a as resetModuleRegistry, i as getModulesWithCapability, n as ModuleRegistry, r as getModuleRegistry, t as LoadedModuleInfo } from "./registry-DH-CkOzJ.js";
|
|
12
13
|
import "./index-E7Wvm5uX.js";
|
|
13
|
-
import { i as resetSchemaRegistry, n as SchemaRegistry, r as getSchemaRegistry, t as SchemaEntry } from "./registry-
|
|
14
|
-
import { t as PgTable } from "./index-
|
|
14
|
+
import { i as resetSchemaRegistry, n as SchemaRegistry, r as getSchemaRegistry, t as SchemaEntry } from "./registry-CduEY_YF.js";
|
|
15
|
+
import { t as PgTable } from "./index-CoTYpOht.js";
|
|
15
16
|
import { AwilixContainer, Resolver, asClass, asFunction, asValue } from "awilix";
|
|
16
17
|
import * as Domain from "@kuckit/domain";
|
|
17
18
|
import * as Application from "@kuckit/application";
|
|
18
19
|
import * as Contracts from "@kuckit/contracts";
|
|
19
|
-
export { type ApiRegistration, Application, type AwilixContainer, type BuiltInCapability, Contracts, type CoreConfig, type CoreContainer, type CoreCradle, type CreateKuckitOptions, Domain, type KuckitClientConfig, type KuckitConfig, type KuckitDiscoveryConfig, type KuckitModuleConfig, type KuckitModuleContext, type KuckitModuleDefinition, type KuckitModuleHooks, type KuckitModuleMeta, type KuckitServerConfig, type LoadModulesOptions, type LoadedKuckitConfig, type LoadedModuleInfo, type ModuleCapability, ModuleRegistry, type ModuleSpec, type PgTable, type PrebuiltDependencies, type Resolver, type SchemaEntry, SchemaRegistry, asClass, asFunction, asValue, createKuckitContainer, createModuleShutdownHandler, defineConfig, defineKuckitModule, disposeContainer, findConfigFile, getModuleRegistry, getModulesWithCapability, getSchemaRegistry, hasUnifiedConfig, loadKuckitConfig, loadKuckitModules, registerCoreModule, resetModuleRegistry, resetSchemaRegistry, tryLoadKuckitConfig };
|
|
20
|
+
export { type ApiRegistration, Application, type AwilixContainer, type BuiltInCapability, Contracts, type CoreConfig, type CoreContainer, type CoreCradle, type CreateKuckitOptions, Domain, type KuckitClientConfig, type KuckitConfig, type KuckitDiscoveryConfig, type KuckitModuleConfig, type KuckitModuleContext, type KuckitModuleDefinition, type KuckitModuleHooks, type KuckitModuleMeta, type KuckitServerConfig, type LoadModulesOptions, type LoadedKuckitConfig, type LoadedModuleInfo, type ModuleCapability, ModuleRegistry, type ModuleSpec, type PgTable, type PrebuiltDependencies, type Resolver, type SchemaEntry, SchemaRegistry, type ScopedRequest, asClass, asFunction, asValue, createKuckitContainer, createModuleShutdownHandler, defineConfig, defineKuckitModule, disposeContainer, findConfigFile, getModuleRegistry, getModulesWithCapability, getSchemaRegistry, hasUnifiedConfig, loadKuckitConfig, loadKuckitModules, registerCoreModule, resetModuleRegistry, resetSchemaRegistry, tryLoadKuckitConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
1
|
+
import { a as tryLoadKuckitConfig, n as hasUnifiedConfig, r as loadKuckitConfig, t as findConfigFile } from "./loader-BJ2ClBV6.js";
|
|
2
|
+
import { t as registerCoreModule } from "./core.module-DcvMkqV-.js";
|
|
3
|
+
import { n as disposeContainer, t as createKuckitContainer } from "./container-CGi8iyd_.js";
|
|
3
4
|
import { t as defineKuckitModule } from "./define-module-CzsWcVHH.js";
|
|
4
5
|
import { i as resetModuleRegistry, n as getModuleRegistry, r as getModulesWithCapability, t as ModuleRegistry } from "./registry-DMY4gCiz.js";
|
|
5
6
|
import { n as getSchemaRegistry, r as resetSchemaRegistry, t as SchemaRegistry } from "./registry-B62Oueqd.js";
|
|
@@ -7,8 +8,7 @@ import "./schema-C94Ei_S4.js";
|
|
|
7
8
|
import { n as loadKuckitModules, t as createModuleShutdownHandler } from "./loader-BZuTuluL.js";
|
|
8
9
|
import "./modules-CQFGHC4e.js";
|
|
9
10
|
import { t as defineConfig } from "./define-config-fjqcYWfl.js";
|
|
10
|
-
import
|
|
11
|
-
import "./config-Dwl_qu6x.js";
|
|
11
|
+
import "./config-BeiJJZGf.js";
|
|
12
12
|
import { asClass, asFunction, asValue } from "awilix";
|
|
13
13
|
import * as Domain from "@kuckit/domain";
|
|
14
14
|
import * as Application from "@kuckit/application";
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
4
|
|
|
5
|
+
//#region rolldown:runtime
|
|
6
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
5
9
|
//#region src/config/loader.ts
|
|
6
10
|
const CONFIG_FILES = [
|
|
7
11
|
"kuckit.config.ts",
|
|
@@ -93,4 +97,4 @@ async function tryLoadKuckitConfig(cwd = process.cwd()) {
|
|
|
93
97
|
|
|
94
98
|
//#endregion
|
|
95
99
|
export { tryLoadKuckitConfig as a, loadKuckitConfigSync as i, hasUnifiedConfig as n, loadKuckitConfig as r, findConfigFile as t };
|
|
96
|
-
//# sourceMappingURL=loader-
|
|
100
|
+
//# sourceMappingURL=loader-BJ2ClBV6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-
|
|
1
|
+
{"version":3,"file":"loader-BJ2ClBV6.js","names":["config: KuckitConfig"],"sources":["../src/config/loader.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { resolve, dirname } from 'node:path'\nimport type { KuckitConfig, LoadedKuckitConfig } from './types'\n\nconst CONFIG_FILES = ['kuckit.config.ts', 'kuckit.config.js', 'kuckit.config.mjs']\n\n/**\n * Find the config file path by searching from cwd upward\n */\nexport function findConfigFile(cwd: string = process.cwd()): string | null {\n\tlet dir = cwd\n\n\twhile (dir !== dirname(dir)) {\n\t\tfor (const file of CONFIG_FILES) {\n\t\t\tconst configPath = resolve(dir, file)\n\t\t\tif (existsSync(configPath)) {\n\t\t\t\treturn configPath\n\t\t\t}\n\t\t}\n\t\tdir = dirname(dir)\n\t}\n\n\t// Check root directory\n\tfor (const file of CONFIG_FILES) {\n\t\tconst configPath = resolve(dir, file)\n\t\tif (existsSync(configPath)) {\n\t\t\treturn configPath\n\t\t}\n\t}\n\n\treturn null\n}\n\n/**\n * Check if a unified config file exists\n */\nexport function hasUnifiedConfig(cwd: string = process.cwd()): boolean {\n\treturn findConfigFile(cwd) !== null\n}\n\n/**\n * Load Kuckit configuration from file\n *\n * Uses jiti for TypeScript support at runtime.\n * Falls back to dynamic import for JS/MJS files.\n *\n * @param cwd - Directory to start searching from (default: process.cwd())\n * @throws Error if config file not found or invalid\n */\nexport async function loadKuckitConfig(cwd: string = process.cwd()): Promise<LoadedKuckitConfig> {\n\tconst configPath = findConfigFile(cwd)\n\n\tif (!configPath) {\n\t\tthrow new Error(\n\t\t\t`No Kuckit config file found. Create a kuckit.config.ts at your project root.\\n` +\n\t\t\t\t`Searched from: ${cwd}`\n\t\t)\n\t}\n\n\tlet config: KuckitConfig\n\n\tif (configPath.endsWith('.ts')) {\n\t\t// Use jiti for TypeScript files\n\t\tconst { createJiti } = await import('jiti')\n\t\tconst jiti = createJiti(cwd, {\n\t\t\tinteropDefault: true,\n\t\t})\n\t\tconst loaded = await jiti.import(configPath)\n\t\tconfig = (loaded as { default?: KuckitConfig }).default ?? (loaded as KuckitConfig)\n\t} else {\n\t\t// Use dynamic import for JS/MJS\n\t\tconst loaded = await import(configPath)\n\t\tconfig = loaded.default ?? loaded\n\t}\n\n\t// Validate config\n\tif (!config || typeof config !== 'object') {\n\t\tthrow new Error(`Invalid Kuckit config at ${configPath}: expected an object`)\n\t}\n\n\tif (!Array.isArray(config.modules)) {\n\t\tthrow new Error(`Invalid Kuckit config at ${configPath}: 'modules' must be an array`)\n\t}\n\n\treturn {\n\t\t...config,\n\t\t_configPath: configPath,\n\t}\n}\n\n/**\n * Synchronously load config (for non-async contexts like drizzle.config.ts)\n * Uses jiti synchronously to load TypeScript config\n */\nexport function loadKuckitConfigSync(cwd: string = process.cwd()): LoadedKuckitConfig | null {\n\tconst configPath = findConfigFile(cwd)\n\n\tif (!configPath) {\n\t\treturn null\n\t}\n\n\ttry {\n\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\tconst { createJiti } = require('jiti')\n\t\tconst jiti = createJiti(cwd, {\n\t\t\tinteropDefault: true,\n\t\t})\n\t\tconst loaded = jiti(configPath)\n\t\tconst config: KuckitConfig = loaded.default ?? loaded\n\n\t\tif (!config || typeof config !== 'object' || !Array.isArray(config.modules)) {\n\t\t\treturn null\n\t\t}\n\n\t\treturn {\n\t\t\t...config,\n\t\t\t_configPath: configPath,\n\t\t}\n\t} catch {\n\t\treturn null\n\t}\n}\n\n/**\n * Try to load config, returning null if not found\n */\nexport async function tryLoadKuckitConfig(\n\tcwd: string = process.cwd()\n): Promise<LoadedKuckitConfig | null> {\n\ttry {\n\t\treturn await loadKuckitConfig(cwd)\n\t} catch {\n\t\treturn null\n\t}\n}\n"],"mappings":";;;;;;;;;AAIA,MAAM,eAAe;CAAC;CAAoB;CAAoB;CAAoB;;;;AAKlF,SAAgB,eAAe,MAAc,QAAQ,KAAK,EAAiB;CAC1E,IAAI,MAAM;AAEV,QAAO,QAAQ,QAAQ,IAAI,EAAE;AAC5B,OAAK,MAAM,QAAQ,cAAc;GAChC,MAAM,aAAa,QAAQ,KAAK,KAAK;AACrC,OAAI,WAAW,WAAW,CACzB,QAAO;;AAGT,QAAM,QAAQ,IAAI;;AAInB,MAAK,MAAM,QAAQ,cAAc;EAChC,MAAM,aAAa,QAAQ,KAAK,KAAK;AACrC,MAAI,WAAW,WAAW,CACzB,QAAO;;AAIT,QAAO;;;;;AAMR,SAAgB,iBAAiB,MAAc,QAAQ,KAAK,EAAW;AACtE,QAAO,eAAe,IAAI,KAAK;;;;;;;;;;;AAYhC,eAAsB,iBAAiB,MAAc,QAAQ,KAAK,EAA+B;CAChG,MAAM,aAAa,eAAe,IAAI;AAEtC,KAAI,CAAC,WACJ,OAAM,IAAI,MACT,gGACmB,MACnB;CAGF,IAAIA;AAEJ,KAAI,WAAW,SAAS,MAAM,EAAE;EAE/B,MAAM,EAAE,eAAe,MAAM,OAAO;EAIpC,MAAM,SAAS,MAHF,WAAW,KAAK,EAC5B,gBAAgB,MAChB,CAAC,CACwB,OAAO,WAAW;AAC5C,WAAU,OAAsC,WAAY;QACtD;EAEN,MAAM,SAAS,MAAM,OAAO;AAC5B,WAAS,OAAO,WAAW;;AAI5B,KAAI,CAAC,UAAU,OAAO,WAAW,SAChC,OAAM,IAAI,MAAM,4BAA4B,WAAW,sBAAsB;AAG9E,KAAI,CAAC,MAAM,QAAQ,OAAO,QAAQ,CACjC,OAAM,IAAI,MAAM,4BAA4B,WAAW,8BAA8B;AAGtF,QAAO;EACN,GAAG;EACH,aAAa;EACb;;;;;;AAOF,SAAgB,qBAAqB,MAAc,QAAQ,KAAK,EAA6B;CAC5F,MAAM,aAAa,eAAe,IAAI;AAEtC,KAAI,CAAC,WACJ,QAAO;AAGR,KAAI;EAEH,MAAM,EAAE,yBAAuB,OAAO;EAItC,MAAM,SAHO,WAAW,KAAK,EAC5B,gBAAgB,MAChB,CAAC,CACkB,WAAW;EAC/B,MAAMA,SAAuB,OAAO,WAAW;AAE/C,MAAI,CAAC,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,QAAQ,CAC1E,QAAO;AAGR,SAAO;GACN,GAAG;GACH,aAAa;GACb;SACM;AACP,SAAO;;;;;;AAOT,eAAsB,oBACrB,MAAc,QAAQ,KAAK,EACU;AACrC,KAAI;AACH,SAAO,MAAM,iBAAiB,IAAI;SAC3B;AACP,SAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as LoadedKuckitConfig } from "./types-
|
|
1
|
+
import { o as LoadedKuckitConfig } from "./types-C7uI1y_q.js";
|
|
2
2
|
|
|
3
3
|
//#region src/config/loader.d.ts
|
|
4
4
|
|
|
@@ -31,4 +31,4 @@ declare function loadKuckitConfigSync(cwd?: string): LoadedKuckitConfig | null;
|
|
|
31
31
|
declare function tryLoadKuckitConfig(cwd?: string): Promise<LoadedKuckitConfig | null>;
|
|
32
32
|
//#endregion
|
|
33
33
|
export { tryLoadKuckitConfig as a, loadKuckitConfigSync as i, hasUnifiedConfig as n, loadKuckitConfig as r, findConfigFile as t };
|
|
34
|
-
//# sourceMappingURL=loader-
|
|
34
|
+
//# sourceMappingURL=loader-Cp4MZU8V.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as CoreContainer } from "./types-
|
|
2
|
-
import { i as KuckitModuleDefinition, l as ModuleSpec, t as ApiRegistration } from "./types-
|
|
1
|
+
import { n as CoreContainer } from "./types-D8uMMVx5.js";
|
|
2
|
+
import { i as KuckitModuleDefinition, l as ModuleSpec, t as ApiRegistration } from "./types-CZzFfAW4.js";
|
|
3
3
|
|
|
4
4
|
//#region src/modules/loader.d.ts
|
|
5
5
|
interface LoadModulesOptions {
|
|
@@ -70,4 +70,4 @@ declare const loadKuckitModules: (opts: LoadModulesOptions) => Promise<void>;
|
|
|
70
70
|
declare const createModuleShutdownHandler: (modules: KuckitModuleDefinition[], container: CoreContainer, env: string) => (() => Promise<void>);
|
|
71
71
|
//#endregion
|
|
72
72
|
export { createModuleShutdownHandler as n, loadKuckitModules as r, LoadModulesOptions as t };
|
|
73
|
-
//# sourceMappingURL=loader-
|
|
73
|
+
//# sourceMappingURL=loader-D9yDVSnv.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import "../types-
|
|
3
|
-
import { t as defineKuckitModule } from "../define-module-
|
|
1
|
+
import "../types-D8uMMVx5.js";
|
|
2
|
+
import "../types-CZzFfAW4.js";
|
|
3
|
+
import { t as defineKuckitModule } from "../define-module-DpWBcWhT.js";
|
|
4
4
|
export { defineKuckitModule };
|
package/dist/modules/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import { a as KuckitModuleHooks, c as ModuleCapability, i as KuckitModuleDefinition, l as ModuleSpec, n as BuiltInCapability, o as KuckitModuleMeta, r as KuckitModuleContext, t as ApiRegistration } from "../types-
|
|
3
|
-
import { t as defineKuckitModule } from "../define-module-
|
|
4
|
-
import { n as createModuleShutdownHandler, r as loadKuckitModules, t as LoadModulesOptions } from "../loader-
|
|
5
|
-
import { a as resetModuleRegistry, i as getModulesWithCapability, n as ModuleRegistry, r as getModuleRegistry, t as LoadedModuleInfo } from "../registry-
|
|
1
|
+
import "../types-D8uMMVx5.js";
|
|
2
|
+
import { a as KuckitModuleHooks, c as ModuleCapability, i as KuckitModuleDefinition, l as ModuleSpec, n as BuiltInCapability, o as KuckitModuleMeta, r as KuckitModuleContext, t as ApiRegistration } from "../types-CZzFfAW4.js";
|
|
3
|
+
import { t as defineKuckitModule } from "../define-module-DpWBcWhT.js";
|
|
4
|
+
import { n as createModuleShutdownHandler, r as loadKuckitModules, t as LoadModulesOptions } from "../loader-D9yDVSnv.js";
|
|
5
|
+
import { a as resetModuleRegistry, i as getModulesWithCapability, n as ModuleRegistry, r as getModuleRegistry, t as LoadedModuleInfo } from "../registry-DH-CkOzJ.js";
|
|
6
6
|
import "../index-E7Wvm5uX.js";
|
|
7
7
|
export { ApiRegistration, BuiltInCapability, KuckitModuleContext, KuckitModuleDefinition, KuckitModuleHooks, KuckitModuleMeta, LoadModulesOptions, LoadedModuleInfo, ModuleCapability, ModuleRegistry, ModuleSpec, createModuleShutdownHandler, defineKuckitModule, getModuleRegistry, getModulesWithCapability, loadKuckitModules, resetModuleRegistry };
|
package/dist/modules/loader.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import "../types-
|
|
3
|
-
import { n as createModuleShutdownHandler, r as loadKuckitModules, t as LoadModulesOptions } from "../loader-
|
|
1
|
+
import "../types-D8uMMVx5.js";
|
|
2
|
+
import "../types-CZzFfAW4.js";
|
|
3
|
+
import { n as createModuleShutdownHandler, r as loadKuckitModules, t as LoadModulesOptions } from "../loader-D9yDVSnv.js";
|
|
4
4
|
export { LoadModulesOptions, createModuleShutdownHandler, loadKuckitModules };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import "../types-
|
|
3
|
-
import { a as resetModuleRegistry, i as getModulesWithCapability, n as ModuleRegistry, r as getModuleRegistry, t as LoadedModuleInfo } from "../registry-
|
|
1
|
+
import "../types-D8uMMVx5.js";
|
|
2
|
+
import "../types-CZzFfAW4.js";
|
|
3
|
+
import { a as resetModuleRegistry, i as getModulesWithCapability, n as ModuleRegistry, r as getModuleRegistry, t as LoadedModuleInfo } from "../registry-DH-CkOzJ.js";
|
|
4
4
|
export { LoadedModuleInfo, ModuleRegistry, getModuleRegistry, getModulesWithCapability, resetModuleRegistry };
|
package/dist/modules/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "../types-
|
|
2
|
-
import { a as KuckitModuleHooks, c as ModuleCapability, i as KuckitModuleDefinition, l as ModuleSpec, n as BuiltInCapability, o as KuckitModuleMeta, r as KuckitModuleContext, s as LoadedModule, t as ApiRegistration } from "../types-
|
|
1
|
+
import "../types-D8uMMVx5.js";
|
|
2
|
+
import { a as KuckitModuleHooks, c as ModuleCapability, i as KuckitModuleDefinition, l as ModuleSpec, n as BuiltInCapability, o as KuckitModuleMeta, r as KuckitModuleContext, s as LoadedModule, t as ApiRegistration } from "../types-CZzFfAW4.js";
|
|
3
3
|
export { ApiRegistration, BuiltInCapability, KuckitModuleContext, KuckitModuleDefinition, KuckitModuleHooks, KuckitModuleMeta, LoadedModule, ModuleCapability, ModuleSpec };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-B62Oueqd.js","names":["result: Record<string,
|
|
1
|
+
{"version":3,"file":"registry-B62Oueqd.js","names":["result: Record<string, AnyPgTable>","globalSchemaRegistry: SchemaRegistry | null"],"sources":["../src/schema/registry.ts"],"sourcesContent":["import type { AnyPgTable } from 'drizzle-orm/pg-core'\n\n/**\n * Entry for a registered schema\n */\nexport interface SchemaEntry {\n\t/** Module that owns this schema */\n\tmoduleId: string\n\t/** Table name identifier */\n\ttableName: string\n\t/** Drizzle table schema */\n\tschema: AnyPgTable\n}\n\n/**\n * Registry for module-owned database schemas\n *\n * Allows modules to register their Drizzle schemas during the register() hook.\n * The CLI uses this registry to aggregate schemas for drizzle-kit operations.\n */\nexport class SchemaRegistry {\n\tprivate schemas = new Map<string, SchemaEntry>()\n\n\t/**\n\t * Register a schema from a module\n\t * @param moduleId - Module identifier (e.g., 'acme.billing')\n\t * @param tableName - Table name identifier (e.g., 'invoices')\n\t * @param schema - Drizzle PgTable schema\n\t */\n\tregister(moduleId: string, tableName: string, schema: AnyPgTable): void {\n\t\tconst key = `${moduleId}:${tableName}`\n\t\tif (this.schemas.has(key)) {\n\t\t\tthrow new Error(`Schema \"${tableName}\" already registered by module \"${moduleId}\"`)\n\t\t}\n\t\tthis.schemas.set(key, { moduleId, tableName, schema })\n\t}\n\n\t/**\n\t * Get all registered schemas\n\t */\n\tgetAll(): Map<string, SchemaEntry> {\n\t\treturn new Map(this.schemas)\n\t}\n\n\t/**\n\t * Get schemas registered by a specific module\n\t */\n\tgetByModule(moduleId: string): SchemaEntry[] {\n\t\treturn Array.from(this.schemas.values()).filter((entry) => entry.moduleId === moduleId)\n\t}\n\n\t/**\n\t * Get all schemas as a flat object for drizzle-kit\n\t * Keys are table names, values are PgTable schemas\n\t */\n\tgetAllSchemas(): Record<string, AnyPgTable> {\n\t\tconst result: Record<string, AnyPgTable> = {}\n\t\tfor (const entry of this.schemas.values()) {\n\t\t\tresult[entry.tableName] = entry.schema\n\t\t}\n\t\treturn result\n\t}\n\n\t/**\n\t * Check if any schemas are registered\n\t */\n\thasSchemas(): boolean {\n\t\treturn this.schemas.size > 0\n\t}\n\n\t/**\n\t * Get the count of registered schemas\n\t */\n\tget size(): number {\n\t\treturn this.schemas.size\n\t}\n\n\t/**\n\t * Clear all schemas (mainly for testing)\n\t */\n\tclear(): void {\n\t\tthis.schemas.clear()\n\t}\n}\n\n// Global schema registry instance\nlet globalSchemaRegistry: SchemaRegistry | null = null\n\n/**\n * Get the global schema registry\n * Creates one if it doesn't exist\n */\nexport function getSchemaRegistry(): SchemaRegistry {\n\tif (!globalSchemaRegistry) {\n\t\tglobalSchemaRegistry = new SchemaRegistry()\n\t}\n\treturn globalSchemaRegistry\n}\n\n/**\n * Reset the global schema registry (mainly for testing)\n */\nexport function resetSchemaRegistry(): void {\n\tglobalSchemaRegistry = null\n}\n"],"mappings":";;;;;;;AAoBA,IAAa,iBAAb,MAA4B;CAC3B,AAAQ,0BAAU,IAAI,KAA0B;;;;;;;CAQhD,SAAS,UAAkB,WAAmB,QAA0B;EACvE,MAAM,MAAM,GAAG,SAAS,GAAG;AAC3B,MAAI,KAAK,QAAQ,IAAI,IAAI,CACxB,OAAM,IAAI,MAAM,WAAW,UAAU,kCAAkC,SAAS,GAAG;AAEpF,OAAK,QAAQ,IAAI,KAAK;GAAE;GAAU;GAAW;GAAQ,CAAC;;;;;CAMvD,SAAmC;AAClC,SAAO,IAAI,IAAI,KAAK,QAAQ;;;;;CAM7B,YAAY,UAAiC;AAC5C,SAAO,MAAM,KAAK,KAAK,QAAQ,QAAQ,CAAC,CAAC,QAAQ,UAAU,MAAM,aAAa,SAAS;;;;;;CAOxF,gBAA4C;EAC3C,MAAMA,SAAqC,EAAE;AAC7C,OAAK,MAAM,SAAS,KAAK,QAAQ,QAAQ,CACxC,QAAO,MAAM,aAAa,MAAM;AAEjC,SAAO;;;;;CAMR,aAAsB;AACrB,SAAO,KAAK,QAAQ,OAAO;;;;;CAM5B,IAAI,OAAe;AAClB,SAAO,KAAK,QAAQ;;;;;CAMrB,QAAc;AACb,OAAK,QAAQ,OAAO;;;AAKtB,IAAIC,uBAA8C;;;;;AAMlD,SAAgB,oBAAoC;AACnD,KAAI,CAAC,qBACJ,wBAAuB,IAAI,gBAAgB;AAE5C,QAAO;;;;;AAMR,SAAgB,sBAA4B;AAC3C,wBAAuB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyPgTable } from "drizzle-orm/pg-core";
|
|
2
2
|
|
|
3
3
|
//#region src/schema/registry.d.ts
|
|
4
4
|
|
|
@@ -11,7 +11,7 @@ interface SchemaEntry {
|
|
|
11
11
|
/** Table name identifier */
|
|
12
12
|
tableName: string;
|
|
13
13
|
/** Drizzle table schema */
|
|
14
|
-
schema:
|
|
14
|
+
schema: AnyPgTable;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Registry for module-owned database schemas
|
|
@@ -27,7 +27,7 @@ declare class SchemaRegistry {
|
|
|
27
27
|
* @param tableName - Table name identifier (e.g., 'invoices')
|
|
28
28
|
* @param schema - Drizzle PgTable schema
|
|
29
29
|
*/
|
|
30
|
-
register(moduleId: string, tableName: string, schema:
|
|
30
|
+
register(moduleId: string, tableName: string, schema: AnyPgTable): void;
|
|
31
31
|
/**
|
|
32
32
|
* Get all registered schemas
|
|
33
33
|
*/
|
|
@@ -40,7 +40,7 @@ declare class SchemaRegistry {
|
|
|
40
40
|
* Get all schemas as a flat object for drizzle-kit
|
|
41
41
|
* Keys are table names, values are PgTable schemas
|
|
42
42
|
*/
|
|
43
|
-
getAllSchemas(): Record<string,
|
|
43
|
+
getAllSchemas(): Record<string, AnyPgTable>;
|
|
44
44
|
/**
|
|
45
45
|
* Check if any schemas are registered
|
|
46
46
|
*/
|
|
@@ -65,4 +65,4 @@ declare function getSchemaRegistry(): SchemaRegistry;
|
|
|
65
65
|
declare function resetSchemaRegistry(): void;
|
|
66
66
|
//#endregion
|
|
67
67
|
export { resetSchemaRegistry as i, SchemaRegistry as n, getSchemaRegistry as r, SchemaEntry as t };
|
|
68
|
-
//# sourceMappingURL=registry-
|
|
68
|
+
//# sourceMappingURL=registry-CduEY_YF.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as ModuleCapability, i as KuckitModuleDefinition } from "./types-
|
|
1
|
+
import { c as ModuleCapability, i as KuckitModuleDefinition } from "./types-CZzFfAW4.js";
|
|
2
2
|
|
|
3
3
|
//#region src/modules/registry.d.ts
|
|
4
4
|
|
|
@@ -87,4 +87,4 @@ declare function getModulesWithCapability(capability: ModuleCapability): LoadedM
|
|
|
87
87
|
declare function resetModuleRegistry(): void;
|
|
88
88
|
//#endregion
|
|
89
89
|
export { resetModuleRegistry as a, getModulesWithCapability as i, ModuleRegistry as n, getModuleRegistry as r, LoadedModuleInfo as t };
|
|
90
|
-
//# sourceMappingURL=registry-
|
|
90
|
+
//# sourceMappingURL=registry-DH-CkOzJ.d.ts.map
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as resetSchemaRegistry, n as SchemaRegistry, r as getSchemaRegistry, t as SchemaEntry } from "../registry-
|
|
2
|
-
import { t as PgTable } from "../index-
|
|
1
|
+
import { i as resetSchemaRegistry, n as SchemaRegistry, r as getSchemaRegistry, t as SchemaEntry } from "../registry-CduEY_YF.js";
|
|
2
|
+
import { t as PgTable } from "../index-CoTYpOht.js";
|
|
3
3
|
export { PgTable, SchemaEntry, SchemaRegistry, getSchemaRegistry, resetSchemaRegistry };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as resetSchemaRegistry, n as SchemaRegistry, r as getSchemaRegistry, t as SchemaEntry } from "../registry-
|
|
1
|
+
import { i as resetSchemaRegistry, n as SchemaRegistry, r as getSchemaRegistry, t as SchemaEntry } from "../registry-CduEY_YF.js";
|
|
2
2
|
export { SchemaEntry, SchemaRegistry, getSchemaRegistry, resetSchemaRegistry };
|
|
@@ -91,4 +91,4 @@ interface LoadedKuckitConfig extends KuckitConfig {
|
|
|
91
91
|
}
|
|
92
92
|
//#endregion
|
|
93
93
|
export { KuckitServerConfig as a, KuckitModuleConfig as i, KuckitConfig as n, LoadedKuckitConfig as o, KuckitDiscoveryConfig as r, KuckitClientConfig as t };
|
|
94
|
-
//# sourceMappingURL=types-
|
|
94
|
+
//# sourceMappingURL=types-C7uI1y_q.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { n as CoreContainer } from "./types-
|
|
2
|
-
import { PgTable } from "drizzle-orm/pg-core";
|
|
1
|
+
import { n as CoreContainer } from "./types-D8uMMVx5.js";
|
|
3
2
|
|
|
4
3
|
//#region src/modules/types.d.ts
|
|
5
4
|
|
|
@@ -37,8 +36,8 @@ interface KuckitModuleContext<TConfig = unknown> {
|
|
|
37
36
|
env: string;
|
|
38
37
|
/** Module-specific configuration */
|
|
39
38
|
config: TConfig;
|
|
40
|
-
/** Register a Drizzle schema for this module */
|
|
41
|
-
registerSchema: (tableName: string, schema:
|
|
39
|
+
/** Register a Drizzle schema for this module (accepts any PgTable) */
|
|
40
|
+
registerSchema: (tableName: string, schema: unknown) => void;
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
44
43
|
* API registration for oRPC routers or other API handlers
|
|
@@ -109,4 +108,4 @@ interface LoadedModule<TConfig = unknown> extends KuckitModuleDefinition<TConfig
|
|
|
109
108
|
}
|
|
110
109
|
//#endregion
|
|
111
110
|
export { KuckitModuleHooks as a, ModuleCapability as c, KuckitModuleDefinition as i, ModuleSpec as l, BuiltInCapability as n, KuckitModuleMeta as o, KuckitModuleContext as r, LoadedModule as s, ApiRegistration as t };
|
|
112
|
-
//# sourceMappingURL=types-
|
|
111
|
+
//# sourceMappingURL=types-CZzFfAW4.d.ts.map
|
|
@@ -36,7 +36,6 @@ interface CoreCradle {
|
|
|
36
36
|
logger: Logger;
|
|
37
37
|
errorHandler: unknown;
|
|
38
38
|
auth: Auth;
|
|
39
|
-
aiProvider: unknown;
|
|
40
39
|
eventBus: EventBus;
|
|
41
40
|
cacheStore: CacheStore;
|
|
42
41
|
rateLimiterStore: RateLimiterStore;
|
|
@@ -53,6 +52,27 @@ interface CoreCradle {
|
|
|
53
52
|
* Core container type with CoreCradle
|
|
54
53
|
*/
|
|
55
54
|
type CoreContainer = AwilixContainer<CoreCradle>;
|
|
55
|
+
/**
|
|
56
|
+
* Pre-built dependencies that can be passed to createKuckitContainer.
|
|
57
|
+
* When provided, these skip the internal factory creation.
|
|
58
|
+
*/
|
|
59
|
+
interface PrebuiltDependencies {
|
|
60
|
+
/**
|
|
61
|
+
* Pre-built PostgreSQL connection pool
|
|
62
|
+
* If provided, skips createDbPool() in core.module
|
|
63
|
+
*/
|
|
64
|
+
dbPool?: Pool;
|
|
65
|
+
/**
|
|
66
|
+
* Pre-built Drizzle database instance
|
|
67
|
+
* If provided, skips createDb() in core.module
|
|
68
|
+
*/
|
|
69
|
+
db?: unknown;
|
|
70
|
+
/**
|
|
71
|
+
* Pre-built Better-Auth instance
|
|
72
|
+
* If provided, skips createAuth() in core.module
|
|
73
|
+
*/
|
|
74
|
+
auth?: Auth;
|
|
75
|
+
}
|
|
56
76
|
//#endregion
|
|
57
|
-
export { DrizzleDb as a, DbPool as i, CoreContainer as n, CoreCradle as r, CoreConfig as t };
|
|
58
|
-
//# sourceMappingURL=types-
|
|
77
|
+
export { DrizzleDb as a, DbPool as i, CoreContainer as n, PrebuiltDependencies as o, CoreCradle as r, CoreConfig as t };
|
|
78
|
+
//# sourceMappingURL=types-D8uMMVx5.d.ts.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as DrizzleDb, i as DbPool, n as CoreContainer, r as CoreCradle, t as CoreConfig } from "./types-
|
|
2
|
-
export { CoreConfig, CoreContainer, CoreCradle, DbPool, DrizzleDb };
|
|
1
|
+
import { a as DrizzleDb, i as DbPool, n as CoreContainer, o as PrebuiltDependencies, r as CoreCradle, t as CoreConfig } from "./types-D8uMMVx5.js";
|
|
2
|
+
export { CoreConfig, CoreContainer, CoreCradle, DbPool, DrizzleDb, PrebuiltDependencies };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kuckit/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,22 +26,29 @@
|
|
|
26
26
|
"prepublishOnly": "npm run build && node ../../scripts/resolve-workspace-protocols.cjs && node ../../scripts/check-no-workspace-protocol.cjs"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@kuckit/domain": "^2.0.
|
|
30
|
-
"@kuckit/application": "^2.0.
|
|
31
|
-
"@kuckit/infrastructure": "^2.0.
|
|
32
|
-
"@kuckit/api": "^2.0.
|
|
33
|
-
"@kuckit/contracts": "^2.0.
|
|
34
|
-
"@kuckit/auth": "^2.0.
|
|
35
|
-
"@kuckit/db": "^2.0.
|
|
29
|
+
"@kuckit/domain": "^2.0.6",
|
|
30
|
+
"@kuckit/application": "^2.0.6",
|
|
31
|
+
"@kuckit/infrastructure": "^2.0.6",
|
|
32
|
+
"@kuckit/api": "^2.0.6",
|
|
33
|
+
"@kuckit/contracts": "^2.0.6",
|
|
34
|
+
"@kuckit/auth": "^2.0.6",
|
|
35
|
+
"@kuckit/db": "^2.0.6",
|
|
36
36
|
"awilix": "^12.0.5",
|
|
37
37
|
"jiti": "^2.4.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"tsdown": "catalog:"
|
|
40
|
+
"tsdown": "catalog:",
|
|
41
|
+
"@types/pg": "^8.10.9"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"typescript": "^5",
|
|
44
45
|
"@ai-sdk/google": "^2.0.0",
|
|
45
|
-
"drizzle-orm": "^0.
|
|
46
|
+
"drizzle-orm": "^0.44.2",
|
|
47
|
+
"express": "^4 || ^5"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"express": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
}
|
package/dist/chunk-B1JASekH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"container-Ct2UXGF_.js","names":[],"sources":["../src/core/container.ts"],"sourcesContent":["import { createContainer, asValue, InjectionMode } from 'awilix'\nimport type { Pool } from 'pg'\nimport type { Auth } from '@kuckit/auth'\nimport type { CoreContainer, CoreCradle, CoreConfig } from '../types'\nimport { registerCoreModule } from './core.module'\n\n/**\n * Pre-built dependencies that can be passed to createKuckitContainer.\n * When provided, these skip the internal factory creation.\n */\nexport interface PrebuiltDependencies {\n\t/**\n\t * Pre-built PostgreSQL connection pool\n\t * If provided, skips createDbPool() in core.module\n\t */\n\tdbPool?: Pool\n\n\t/**\n\t * Pre-built Drizzle database instance\n\t * If provided, skips createDb() in core.module\n\t */\n\tdb?: unknown\n\n\t/**\n\t * Pre-built Better-Auth instance\n\t * If provided, skips createAuth() in core.module\n\t */\n\tauth?: Auth\n\n\t/**\n\t * Pre-built AI provider (e.g., google('gemini-2.5-flash'))\n\t * If provided, skips aiProvider creation in core.module\n\t */\n\taiProvider?: unknown\n}\n\nexport interface CreateKuckitOptions {\n\t/**\n\t * Core configuration for the SDK\n\t */\n\tconfig: CoreConfig\n\n\t/**\n\t * Pre-built dependencies to inject instead of creating internally.\n\t * Use this in composition root (apps/server) to control instantiation.\n\t */\n\tprebuilt?: PrebuiltDependencies\n\n\t/**\n\t * Optional callback to register additional services after core registration\n\t */\n\textraRegistrations?: (container: CoreContainer) => void | Promise<void>\n}\n\n/**\n * Factory function to create a Kuckit DI container\n *\n * This is the primary entry point for applications using the SDK.\n * It creates an Awilix container with core infrastructure services pre-registered.\n *\n * @example\n * ```ts\n * const container = await createKuckitContainer({\n * config: {\n * databaseUrl: process.env.DATABASE_URL!,\n * enableFileLogging: true,\n * logDir: './logs',\n * logLevel: 'INFO',\n * env: 'production',\n * },\n * extraRegistrations: (container) => {\n * // Register your custom services\n * container.register({\n * myService: asClass(MyService).singleton(),\n * })\n * },\n * })\n * ```\n */\nexport const createKuckitContainer = async (opts: CreateKuckitOptions): Promise<CoreContainer> => {\n\tconst container = createContainer<CoreCradle>({\n\t\tinjectionMode: InjectionMode.PROXY,\n\t})\n\n\t// Register config first (required by other registrations)\n\tcontainer.register({\n\t\tconfig: asValue(opts.config),\n\t})\n\n\t// Register core infrastructure (passing prebuilt dependencies if provided)\n\tregisterCoreModule(container, opts.prebuilt)\n\n\t// Allow custom registrations\n\tif (opts.extraRegistrations) {\n\t\tawait opts.extraRegistrations(container)\n\t}\n\n\treturn container\n}\n\n/**\n * Cleanup container resources gracefully\n *\n * Call this when shutting down your application to close database connections\n * and other resources.\n */\nexport const disposeContainer = async (container: CoreContainer): Promise<void> => {\n\tconst { dbPool } = container.cradle\n\t// Handle unknown dbPool type - check for end method\n\tif (\n\t\tdbPool &&\n\t\ttypeof dbPool === 'object' &&\n\t\t'end' in dbPool &&\n\t\ttypeof (dbPool as { end: unknown }).end === 'function'\n\t) {\n\t\tawait (dbPool as { end: () => Promise<void> }).end()\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,MAAa,wBAAwB,OAAO,SAAsD;CACjG,MAAM,YAAY,gBAA4B,EAC7C,eAAe,cAAc,OAC7B,CAAC;AAGF,WAAU,SAAS,EAClB,QAAQ,QAAQ,KAAK,OAAO,EAC5B,CAAC;AAGF,oBAAmB,WAAW,KAAK,SAAS;AAG5C,KAAI,KAAK,mBACR,OAAM,KAAK,mBAAmB,UAAU;AAGzC,QAAO;;;;;;;;AASR,MAAa,mBAAmB,OAAO,cAA4C;CAClF,MAAM,EAAE,WAAW,UAAU;AAE7B,KACC,UACA,OAAO,WAAW,YAClB,SAAS,UACT,OAAQ,OAA4B,QAAQ,WAE5C,OAAO,OAAwC,KAAK"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.module-47w_x8z-.js","names":[],"sources":["../src/core/core.module.ts"],"sourcesContent":["import { asFunction, asValue } from 'awilix'\nimport { SystemClock } from '@kuckit/domain'\nimport { createAuth } from '@kuckit/auth'\nimport {\n\tcreateDbPool,\n\tcreateDb,\n\tmakeStructuredLogger,\n\tmakeRequestLogger,\n\tmakeErrorHandler,\n\tInMemoryEventBus,\n\tmakeInMemoryCacheStore,\n\tmakeInMemoryRateLimiterStore,\n} from '@kuckit/infrastructure'\nimport type { CoreContainer } from '../types'\nimport type { PrebuiltDependencies } from './container'\n\n/**\n * Register core infrastructure services into the container\n *\n * This registers:\n * - Database pool and connection\n * - Clock\n * - Logger (structured, Loki/Prometheus compatible)\n * - AI provider (optional - only if provided or API key available)\n * - Auth\n * - Event bus\n * - Cache store\n * - Rate limiter store\n * - Request-scoped logger\n *\n * @param container - The Awilix container to register services into\n * @param prebuilt - Optional pre-built dependencies to use instead of creating internally\n */\nexport const registerCoreModule = (\n\tcontainer: CoreContainer,\n\tprebuilt?: PrebuiltDependencies\n): void => {\n\tcontainer.register({\n\t\t// Database - use prebuilt if provided, otherwise create from config\n\t\tdbPool: prebuilt?.dbPool\n\t\t\t? asValue(prebuilt.dbPool)\n\t\t\t: asFunction(({ config }) => createDbPool(config.databaseUrl)).singleton(),\n\n\t\tdb: prebuilt?.db\n\t\t\t? asValue(prebuilt.db)\n\t\t\t: asFunction(({ dbPool }) => createDb(dbPool)).singleton(),\n\n\t\t// Core services\n\t\tclock: asValue(new SystemClock()),\n\n\t\tlogger: asFunction(({ config }) =>\n\t\t\tmakeStructuredLogger({\n\t\t\t\tenableFile: config.enableFileLogging,\n\t\t\t\tlogDir: config.logDir,\n\t\t\t\tminLevel: config.logLevel,\n\t\t\t})\n\t\t).singleton(),\n\n\t\terrorHandler: asFunction(({ logger }) => makeErrorHandler(logger)).singleton(),\n\n\t\t// Auth - use prebuilt if provided, otherwise create from db\n\t\tauth: prebuilt?.auth\n\t\t\t? asValue(prebuilt.auth)\n\t\t\t: asFunction(({ db }) => createAuth({ db })).singleton(),\n\n\t\t// AI provider - use prebuilt if provided, otherwise lazy-load\n\t\taiProvider: prebuilt?.aiProvider\n\t\t\t? asValue(prebuilt.aiProvider)\n\t\t\t: asFunction(() => {\n\t\t\t\t\t// Lazy import to avoid loading @ai-sdk/google at module load time\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-require-imports\n\t\t\t\t\tconst { google } = require('@ai-sdk/google')\n\t\t\t\t\treturn google('gemini-2.5-flash')\n\t\t\t\t}).singleton(),\n\n\t\t// Event bus\n\t\teventBus: asFunction(({ logger }) => new InMemoryEventBus(logger)).singleton(),\n\n\t\t// Stores - use factory functions that start cleanup timers\n\t\tcacheStore: asFunction(() => makeInMemoryCacheStore()).singleton(),\n\t\trateLimiterStore: asFunction(() => makeInMemoryRateLimiterStore()).singleton(),\n\n\t\t// Request-scoped logger (enriched with requestId and userId)\n\t\trequestLogger: asFunction(({ logger, requestId, session }) =>\n\t\t\tmakeRequestLogger({\n\t\t\t\trequestId,\n\t\t\t\tuserId: session?.user?.id,\n\t\t\t\tbaseLogger: logger,\n\t\t\t})\n\t\t).scoped(),\n\t})\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,sBACZ,WACA,aACU;AACV,WAAU,SAAS;EAElB,QAAQ,UAAU,SACf,QAAQ,SAAS,OAAO,GACxB,YAAY,EAAE,aAAa,aAAa,OAAO,YAAY,CAAC,CAAC,WAAW;EAE3E,IAAI,UAAU,KACX,QAAQ,SAAS,GAAG,GACpB,YAAY,EAAE,aAAa,SAAS,OAAO,CAAC,CAAC,WAAW;EAG3D,OAAO,QAAQ,IAAI,aAAa,CAAC;EAEjC,QAAQ,YAAY,EAAE,aACrB,qBAAqB;GACpB,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,CAAC,CACF,CAAC,WAAW;EAEb,cAAc,YAAY,EAAE,aAAa,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,MAAM,UAAU,OACb,QAAQ,SAAS,KAAK,GACtB,YAAY,EAAE,SAAS,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW;EAGzD,YAAY,UAAU,aACnB,QAAQ,SAAS,WAAW,GAC5B,iBAAiB;GAGjB,MAAM,EAAE,qBAAmB,iBAAiB;AAC5C,UAAO,OAAO,mBAAmB;IAChC,CAAC,WAAW;EAGhB,UAAU,YAAY,EAAE,aAAa,IAAI,iBAAiB,OAAO,CAAC,CAAC,WAAW;EAG9E,YAAY,iBAAiB,wBAAwB,CAAC,CAAC,WAAW;EAClE,kBAAkB,iBAAiB,8BAA8B,CAAC,CAAC,WAAW;EAG9E,eAAe,YAAY,EAAE,QAAQ,WAAW,cAC/C,kBAAkB;GACjB;GACA,QAAQ,SAAS,MAAM;GACvB,YAAY;GACZ,CAAC,CACF,CAAC,QAAQ;EACV,CAAC"}
|
package/dist/index-BLsEv2uZ.d.ts
DELETED
|
File without changes
|
|
File without changes
|