@kuckit/db 2.0.3 → 2.0.5

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.
@@ -6,11 +6,8 @@ import { createRequire as createRequire$1 } from "module";
6
6
  import { existsSync as existsSync$1 } from "node:fs";
7
7
  import { dirname as dirname$1, resolve as resolve$1 } from "node:path";
8
8
 
9
- //#region ../sdk/dist/chunk-B1JASekH.js
9
+ //#region ../sdk/dist/loader-BJ2ClBV6.js
10
10
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
11
-
12
- //#endregion
13
- //#region ../sdk/dist/loader-DKhFYG5d.js
14
11
  const CONFIG_FILES = [
15
12
  "kuckit.config.ts",
16
13
  "kuckit.config.js",
@@ -1 +1 @@
1
- {"version":3,"file":"schema-discovery.js","names":["dirname","resolve","existsSync","createRequire"],"sources":["../../sdk/dist/chunk-B1JASekH.js","../../sdk/dist/loader-DKhFYG5d.js","../src/schema-discovery.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\n//#region rolldown:runtime\nvar __require = /* @__PURE__ */ createRequire(import.meta.url);\n\n//#endregion\nexport { __require as t };","import { t as __require } from \"./chunk-B1JASekH.js\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\n//#region src/config/loader.ts\nconst CONFIG_FILES = [\n\t\"kuckit.config.ts\",\n\t\"kuckit.config.js\",\n\t\"kuckit.config.mjs\"\n];\n/**\n* Find the config file path by searching from cwd upward\n*/\nfunction findConfigFile(cwd = process.cwd()) {\n\tlet dir = cwd;\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)) return configPath;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\tfor (const file of CONFIG_FILES) {\n\t\tconst configPath = resolve(dir, file);\n\t\tif (existsSync(configPath)) return configPath;\n\t}\n\treturn null;\n}\n/**\n* Check if a unified config file exists\n*/\nfunction hasUnifiedConfig(cwd = process.cwd()) {\n\treturn findConfigFile(cwd) !== null;\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*/\nasync function loadKuckitConfig(cwd = process.cwd()) {\n\tconst configPath = findConfigFile(cwd);\n\tif (!configPath) throw new Error(`No Kuckit config file found. Create a kuckit.config.ts at your project root.\\nSearched from: ${cwd}`);\n\tlet config;\n\tif (configPath.endsWith(\".ts\")) {\n\t\tconst { createJiti } = await import(\"jiti\");\n\t\tconst loaded = await createJiti(cwd, { interopDefault: true }).import(configPath);\n\t\tconfig = loaded.default ?? loaded;\n\t} else {\n\t\tconst loaded = await import(configPath);\n\t\tconfig = loaded.default ?? loaded;\n\t}\n\tif (!config || typeof config !== \"object\") throw new Error(`Invalid Kuckit config at ${configPath}: expected an object`);\n\tif (!Array.isArray(config.modules)) throw new Error(`Invalid Kuckit config at ${configPath}: 'modules' must be an array`);\n\treturn {\n\t\t...config,\n\t\t_configPath: configPath\n\t};\n}\n/**\n* Synchronously load config (for non-async contexts like drizzle.config.ts)\n* Uses jiti synchronously to load TypeScript config\n*/\nfunction loadKuckitConfigSync(cwd = process.cwd()) {\n\tconst configPath = findConfigFile(cwd);\n\tif (!configPath) return null;\n\ttry {\n\t\tconst { createJiti } = __require(\"jiti\");\n\t\tconst loaded = createJiti(cwd, { interopDefault: true })(configPath);\n\t\tconst config = loaded.default ?? loaded;\n\t\tif (!config || typeof config !== \"object\" || !Array.isArray(config.modules)) return null;\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* Try to load config, returning null if not found\n*/\nasync function tryLoadKuckitConfig(cwd = process.cwd()) {\n\ttry {\n\t\treturn await loadKuckitConfig(cwd);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n//#endregion\nexport { tryLoadKuckitConfig as a, loadKuckitConfigSync as i, hasUnifiedConfig as n, loadKuckitConfig as r, findConfigFile as t };\n//# sourceMappingURL=loader-DKhFYG5d.js.map","import { existsSync } from 'fs'\nimport { resolve, dirname } from 'path'\nimport { fileURLToPath } from 'url'\nimport { createRequire } from 'module'\nimport { loadKuckitConfigSync, type KuckitModuleConfig } from '@kuckit/sdk/config'\n\nconst currentDirPath = dirname(fileURLToPath(import.meta.url))\nconst require = createRequire(import.meta.url)\n\n/**\n * Resolve a module's package root directory using require.resolve.\n * Works for packages in node_modules, packages/, apps/, or any location.\n *\n * @param packageName - NPM package name (e.g., '@kuckit/users-module')\n * @returns Absolute path to package root, or null if not found\n */\nfunction resolvePackageRoot(packageName: string): string | null {\n\ttry {\n\t\t// Try to resolve the package's package.json\n\t\tconst packageJsonPath = require.resolve(`${packageName}/package.json`)\n\t\treturn dirname(packageJsonPath)\n\t} catch {\n\t\t// Package not installed or doesn't have package.json exports\n\t\ttry {\n\t\t\t// Fallback: resolve main entry and walk up to find package.json\n\t\t\tconst mainPath = require.resolve(packageName)\n\t\t\tlet dir = dirname(mainPath)\n\t\t\t// Walk up until we find package.json (max 10 levels to prevent infinite loop)\n\t\t\tfor (let i = 0; i < 10; i++) {\n\t\t\t\tif (existsSync(resolve(dir, 'package.json'))) {\n\t\t\t\t\treturn dir\n\t\t\t\t}\n\t\t\t\tconst parent = dirname(dir)\n\t\t\t\tif (parent === dir) break // Reached filesystem root\n\t\t\t\tdir = parent\n\t\t\t}\n\t\t} catch {\n\t\t\t// Package not resolvable at all\n\t\t}\n\t\treturn null\n\t}\n}\n\n/**\n * Get schema paths for Drizzle configuration.\n * Derives paths from kuckit.config.ts (single source of truth).\n *\n * Uses require.resolve to dynamically locate packages, supporting:\n * - Modules in packages/ directory\n * - Modules in apps/ directory\n * - External modules in node_modules\n * - Nested package directories\n *\n * @returns Array of absolute paths to schema directories, starting with core schema\n */\nexport function getModuleSchemaPaths(): string[] {\n\tconst coreSchema = resolve(currentDirPath, './schema')\n\n\t// Load config using the SDK's pure config loader (no side effects)\n\tconst config = loadKuckitConfigSync()\n\tif (!config) {\n\t\t// Fall back to just core schema if no config found\n\t\treturn [coreSchema]\n\t}\n\n\tconst modulePaths = config.modules\n\t\t.filter((m: KuckitModuleConfig) => m.enabled !== false)\n\t\t.map((m: KuckitModuleConfig) => {\n\t\t\tconst packageRoot = resolvePackageRoot(m.package)\n\t\t\tif (!packageRoot) return null\n\n\t\t\tconst schemaDir = m.schemaDir ?? 'src/server/schema'\n\t\t\treturn resolve(packageRoot, schemaDir)\n\t\t})\n\t\t.filter((p): p is string => p !== null && existsSync(p))\n\n\treturn [coreSchema, ...modulePaths]\n}\n"],"mappings":";;;;;;;;;AAGA,IAAI,YAA4B,8BAAc,OAAO,KAAK,IAAI;;;;ACE9D,MAAM,eAAe;CACpB;CACA;CACA;CACA;;;;AAID,SAAS,eAAe,MAAM,QAAQ,KAAK,EAAE;CAC5C,IAAI,MAAM;AACV,QAAO,QAAQA,UAAQ,IAAI,EAAE;AAC5B,OAAK,MAAM,QAAQ,cAAc;GAChC,MAAM,aAAaC,UAAQ,KAAK,KAAK;AACrC,OAAIC,aAAW,WAAW,CAAE,QAAO;;AAEpC,QAAMF,UAAQ,IAAI;;AAEnB,MAAK,MAAM,QAAQ,cAAc;EAChC,MAAM,aAAaC,UAAQ,KAAK,KAAK;AACrC,MAAIC,aAAW,WAAW,CAAE,QAAO;;AAEpC,QAAO;;;;;;AAwCR,SAAS,qBAAqB,MAAM,QAAQ,KAAK,EAAE;CAClD,MAAM,aAAa,eAAe,IAAI;AACtC,KAAI,CAAC,WAAY,QAAO;AACxB,KAAI;EACH,MAAM,EAAE,eAAe,UAAU,OAAO;EACxC,MAAM,SAAS,WAAW,KAAK,EAAE,gBAAgB,MAAM,CAAC,CAAC,WAAW;EACpE,MAAM,SAAS,OAAO,WAAW;AACjC,MAAI,CAAC,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,QAAQ,CAAE,QAAO;AACpF,SAAO;GACN,GAAG;GACH,aAAa;GACb;SACM;AACP,SAAO;;;;;;ACzET,MAAM,iBAAiB,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAC9D,MAAM,UAAUC,gBAAc,OAAO,KAAK,IAAI;;;;;;;;AAS9C,SAAS,mBAAmB,aAAoC;AAC/D,KAAI;AAGH,SAAO,QADiB,QAAQ,QAAQ,GAAG,YAAY,eAAe,CACvC;SACxB;AAEP,MAAI;GAGH,IAAI,MAAM,QADO,QAAQ,QAAQ,YAAY,CAClB;AAE3B,QAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;AAC5B,QAAI,WAAW,QAAQ,KAAK,eAAe,CAAC,CAC3C,QAAO;IAER,MAAM,SAAS,QAAQ,IAAI;AAC3B,QAAI,WAAW,IAAK;AACpB,UAAM;;UAEA;AAGR,SAAO;;;;;;;;;;;;;;;AAgBT,SAAgB,uBAAiC;CAChD,MAAM,aAAa,QAAQ,gBAAgB,WAAW;CAGtD,MAAM,SAAS,sBAAsB;AACrC,KAAI,CAAC,OAEJ,QAAO,CAAC,WAAW;AAcpB,QAAO,CAAC,YAAY,GAXA,OAAO,QACzB,QAAQ,MAA0B,EAAE,YAAY,MAAM,CACtD,KAAK,MAA0B;EAC/B,MAAM,cAAc,mBAAmB,EAAE,QAAQ;AACjD,MAAI,CAAC,YAAa,QAAO;AAGzB,SAAO,QAAQ,aADG,EAAE,aAAa,oBACK;GACrC,CACD,QAAQ,MAAmB,MAAM,QAAQ,WAAW,EAAE,CAAC,CAEtB"}
1
+ {"version":3,"file":"schema-discovery.js","names":["dirname","resolve","existsSync","createRequire"],"sources":["../../sdk/dist/loader-BJ2ClBV6.js","../src/schema-discovery.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { existsSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\n\n//#region rolldown:runtime\nvar __require = /* @__PURE__ */ createRequire(import.meta.url);\n\n//#endregion\n//#region src/config/loader.ts\nconst CONFIG_FILES = [\n\t\"kuckit.config.ts\",\n\t\"kuckit.config.js\",\n\t\"kuckit.config.mjs\"\n];\n/**\n* Find the config file path by searching from cwd upward\n*/\nfunction findConfigFile(cwd = process.cwd()) {\n\tlet dir = cwd;\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)) return configPath;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\tfor (const file of CONFIG_FILES) {\n\t\tconst configPath = resolve(dir, file);\n\t\tif (existsSync(configPath)) return configPath;\n\t}\n\treturn null;\n}\n/**\n* Check if a unified config file exists\n*/\nfunction hasUnifiedConfig(cwd = process.cwd()) {\n\treturn findConfigFile(cwd) !== null;\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*/\nasync function loadKuckitConfig(cwd = process.cwd()) {\n\tconst configPath = findConfigFile(cwd);\n\tif (!configPath) throw new Error(`No Kuckit config file found. Create a kuckit.config.ts at your project root.\\nSearched from: ${cwd}`);\n\tlet config;\n\tif (configPath.endsWith(\".ts\")) {\n\t\tconst { createJiti } = await import(\"jiti\");\n\t\tconst loaded = await createJiti(cwd, { interopDefault: true }).import(configPath);\n\t\tconfig = loaded.default ?? loaded;\n\t} else {\n\t\tconst loaded = await import(configPath);\n\t\tconfig = loaded.default ?? loaded;\n\t}\n\tif (!config || typeof config !== \"object\") throw new Error(`Invalid Kuckit config at ${configPath}: expected an object`);\n\tif (!Array.isArray(config.modules)) throw new Error(`Invalid Kuckit config at ${configPath}: 'modules' must be an array`);\n\treturn {\n\t\t...config,\n\t\t_configPath: configPath\n\t};\n}\n/**\n* Synchronously load config (for non-async contexts like drizzle.config.ts)\n* Uses jiti synchronously to load TypeScript config\n*/\nfunction loadKuckitConfigSync(cwd = process.cwd()) {\n\tconst configPath = findConfigFile(cwd);\n\tif (!configPath) return null;\n\ttry {\n\t\tconst { createJiti } = __require(\"jiti\");\n\t\tconst loaded = createJiti(cwd, { interopDefault: true })(configPath);\n\t\tconst config = loaded.default ?? loaded;\n\t\tif (!config || typeof config !== \"object\" || !Array.isArray(config.modules)) return null;\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* Try to load config, returning null if not found\n*/\nasync function tryLoadKuckitConfig(cwd = process.cwd()) {\n\ttry {\n\t\treturn await loadKuckitConfig(cwd);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n//#endregion\nexport { tryLoadKuckitConfig as a, loadKuckitConfigSync as i, hasUnifiedConfig as n, loadKuckitConfig as r, findConfigFile as t };\n//# sourceMappingURL=loader-BJ2ClBV6.js.map","import { existsSync } from 'fs'\nimport { resolve, dirname } from 'path'\nimport { fileURLToPath } from 'url'\nimport { createRequire } from 'module'\nimport { loadKuckitConfigSync, type KuckitModuleConfig } from '@kuckit/sdk/config'\n\nconst currentDirPath = dirname(fileURLToPath(import.meta.url))\nconst require = createRequire(import.meta.url)\n\n/**\n * Resolve a module's package root directory using require.resolve.\n * Works for packages in node_modules, packages/, apps/, or any location.\n *\n * @param packageName - NPM package name (e.g., '@kuckit/users-module')\n * @returns Absolute path to package root, or null if not found\n */\nfunction resolvePackageRoot(packageName: string): string | null {\n\ttry {\n\t\t// Try to resolve the package's package.json\n\t\tconst packageJsonPath = require.resolve(`${packageName}/package.json`)\n\t\treturn dirname(packageJsonPath)\n\t} catch {\n\t\t// Package not installed or doesn't have package.json exports\n\t\ttry {\n\t\t\t// Fallback: resolve main entry and walk up to find package.json\n\t\t\tconst mainPath = require.resolve(packageName)\n\t\t\tlet dir = dirname(mainPath)\n\t\t\t// Walk up until we find package.json (max 10 levels to prevent infinite loop)\n\t\t\tfor (let i = 0; i < 10; i++) {\n\t\t\t\tif (existsSync(resolve(dir, 'package.json'))) {\n\t\t\t\t\treturn dir\n\t\t\t\t}\n\t\t\t\tconst parent = dirname(dir)\n\t\t\t\tif (parent === dir) break // Reached filesystem root\n\t\t\t\tdir = parent\n\t\t\t}\n\t\t} catch {\n\t\t\t// Package not resolvable at all\n\t\t}\n\t\treturn null\n\t}\n}\n\n/**\n * Get schema paths for Drizzle configuration.\n * Derives paths from kuckit.config.ts (single source of truth).\n *\n * Uses require.resolve to dynamically locate packages, supporting:\n * - Modules in packages/ directory\n * - Modules in apps/ directory\n * - External modules in node_modules\n * - Nested package directories\n *\n * @returns Array of absolute paths to schema directories, starting with core schema\n */\nexport function getModuleSchemaPaths(): string[] {\n\tconst coreSchema = resolve(currentDirPath, './schema')\n\n\t// Load config using the SDK's pure config loader (no side effects)\n\tconst config = loadKuckitConfigSync()\n\tif (!config) {\n\t\t// Fall back to just core schema if no config found\n\t\treturn [coreSchema]\n\t}\n\n\tconst modulePaths = config.modules\n\t\t.filter((m: KuckitModuleConfig) => m.enabled !== false)\n\t\t.map((m: KuckitModuleConfig) => {\n\t\t\tconst packageRoot = resolvePackageRoot(m.package)\n\t\t\tif (!packageRoot) return null\n\n\t\t\tconst schemaDir = m.schemaDir ?? 'src/server/schema'\n\t\t\treturn resolve(packageRoot, schemaDir)\n\t\t})\n\t\t.filter((p): p is string => p !== null && existsSync(p))\n\n\treturn [coreSchema, ...modulePaths]\n}\n"],"mappings":";;;;;;;;;AAKA,IAAI,YAA4B,8BAAc,OAAO,KAAK,IAAI;AAI9D,MAAM,eAAe;CACpB;CACA;CACA;CACA;;;;AAID,SAAS,eAAe,MAAM,QAAQ,KAAK,EAAE;CAC5C,IAAI,MAAM;AACV,QAAO,QAAQA,UAAQ,IAAI,EAAE;AAC5B,OAAK,MAAM,QAAQ,cAAc;GAChC,MAAM,aAAaC,UAAQ,KAAK,KAAK;AACrC,OAAIC,aAAW,WAAW,CAAE,QAAO;;AAEpC,QAAMF,UAAQ,IAAI;;AA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