@brickkit/cli 0.0.0-stage → 0.1.3

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler2.js","names":["EMPTY_SERVICES","DEFAULT_REQUEST","isNonEmpty"],"sources":["../src/action-handler.ts","../src/compiler/ir.ts","../src/compiler/emit.ts","../src/compiler/runtime.ts","../src/compiler.ts"],"sourcesContent":["import { type Service, type Action, type Logger, type CompiledRoutePlan,\n ValidationError, ActionExecutionError, getCompiledCheck, buildErrorHelpers } from \"@brickkit/core\";\n\nlet _srvSeq = 0;\nconst EMPTY_SERVICES = Object.freeze({});\nconst DEFAULT_REQUEST = new Request(\"http://localhost\");\n\nfunction isNonEmpty(obj: any): boolean {\n if (obj == null) return false;\n for (const _ in obj) return true;\n return false;\n}\n\nexport function compileRoutePlan(\n service: Service,\n action: Action,\n routePath: string,\n method?: string\n): CompiledRoutePlan {\n const actionName = action.name;\n const serviceName = service.name;\n const isGetLike =\n method === \"GET\" ||\n actionName.startsWith(\"get\") ||\n actionName.endsWith(\".get\") ||\n actionName.startsWith(\"list\") ||\n actionName.endsWith(\".list\") ||\n actionName.startsWith(\"find\") ||\n actionName.startsWith(\"read\");\n\n const inputSchema = action.config?.input;\n const outputSchema = action.config?.output;\n const hasInput = Boolean(inputSchema);\n const inputChecker = inputSchema ? (getCompiledCheck(inputSchema) as any) : undefined;\n const hasOutputCheck = Boolean(outputSchema);\n const outputChecker = outputSchema ? (getCompiledCheck(outputSchema) as any) : undefined;\n\n let coercions: Array<{ key: string; isNumber: boolean; isBoolean: boolean }> | undefined;\n if (inputSchema && typeof (inputSchema as any).properties === \"object\") {\n const list: Array<{ key: string; isNumber: boolean; isBoolean: boolean }> = [];\n for (const [key, prop] of Object.entries((inputSchema as any).properties) as [string, any][]) {\n const type = prop?.type;\n if (type === \"number\" || type === \"integer\") {\n list.push({ key, isNumber: true, isBoolean: false });\n } else if (type === \"boolean\") {\n list.push({ key, isNumber: false, isBoolean: true });\n }\n }\n if (list.length > 0) coercions = list;\n }\n\n const contextHook = service.options?.context;\n const hasContextHook = typeof contextHook === \"function\";\n\n const authorize = action.config?.authorize;\n const hasAuthorize = typeof authorize === \"function\";\n\n const execute = action.config?.execute;\n\n const tag = `[${serviceName}:${actionName}]`;\n const logger: Logger = {\n info: (...args) => console.log(tag, ...args),\n warn: (...args) => console.warn(tag, ...args),\n error: (...args) => console.error(tag, ...args),\n debug: (...args) => console.debug(tag, ...args),\n };\n\n const errorBuilder = (action as any).errorHelpers ?? buildErrorHelpers(action.config?.errors);\n const cachedDb = service.getDb();\n\n return {\n service,\n action,\n actionName,\n serviceName,\n routePath,\n method,\n isGetLike,\n hasInput,\n hasContextHook,\n contextHook,\n hasAuthorize,\n authorize,\n execute,\n inputChecker,\n outputChecker,\n coercions,\n logger,\n errorBuilder,\n cachedDb,\n };\n}\n\nexport async function executeCompiledRoute(plan: CompiledRoutePlan, elysiaCtx: any) {\n const { params, body, query, headers, request, set } = elysiaCtx;\n const seq = (++_srvSeq).toString(36);\n const traceId = (headers && headers[\"x-trace-id\"]) || `tr_${seq}`;\n const requestId = (headers && headers[\"x-request-id\"]) || `req_${seq}`;\n\n if (set?.headers) {\n set.headers[\"x-trace-id\"] = traceId;\n set.headers[\"x-request-id\"] = requestId;\n }\n\n let input: any;\n if (plan.hasInput) {\n let coercedQuery = query;\n if (query && plan.coercions && plan.coercions.length > 0) {\n coercedQuery = { ...query };\n for (let i = 0; i < plan.coercions.length; i++) {\n const c = plan.coercions[i];\n const val = query[c.key];\n if (val !== undefined) {\n if (c.isNumber) {\n const num = Number(val);\n if (!isNaN(num)) coercedQuery[c.key] = num;\n } else if (c.isBoolean) {\n if (val === \"true\" || val === \"1\") coercedQuery[c.key] = true;\n else if (val === \"false\" || val === \"0\") coercedQuery[c.key] = false;\n }\n }\n }\n }\n\n const hasP = isNonEmpty(params);\n const hasB = isNonEmpty(body);\n const hasQ = isNonEmpty(coercedQuery);\n\n if (plan.isGetLike) {\n if (hasQ && !hasP && !hasB) {\n input = coercedQuery;\n } else if (hasP && !hasQ && !hasB) {\n input = params;\n } else if (hasB && !hasP && !hasQ) {\n input = body;\n } else if (hasQ || hasP || hasB) {\n input = Object.assign({}, coercedQuery, params, body);\n }\n } else {\n if (hasB && !hasP && !hasQ) {\n input = body;\n } else if (hasP && !hasB && !hasQ) {\n input = params;\n } else if (hasQ && !hasP && !hasB) {\n input = coercedQuery;\n } else if (hasP || hasB || hasQ) {\n input = Object.assign({}, params, body, coercedQuery);\n }\n }\n }\n\n const standardRequest = request instanceof Request ? request : DEFAULT_REQUEST;\n\n const ctx: any = {\n request: standardRequest,\n traceId,\n requestId,\n db: plan.cachedDb ?? plan.service.getDb(),\n logger: plan.logger,\n services: EMPTY_SERVICES,\n metadata: { headers },\n _resolved: true,\n };\n\n try {\n if (plan.hasContextHook) {\n const extra = plan.contextHook!(ctx);\n const resolved = extra instanceof Promise ? await extra : extra;\n if (resolved) {\n Object.assign(ctx, resolved);\n }\n }\n\n if (plan.hasInput && plan.inputChecker) {\n if (!plan.inputChecker.Check(input)) {\n const errors = Array.from(plan.inputChecker.Errors(input)).map((err: any) => ({\n path: err.path,\n message: err.message,\n value: err.value,\n }));\n throw new ValidationError(`Validation failed for action '${plan.actionName}' input`, errors);\n }\n }\n\n if (plan.hasAuthorize) {\n const authRes = plan.authorize!({\n ctx,\n input,\n user: ctx.user,\n });\n const isAuthorized = authRes instanceof Promise ? await authRes : authRes;\n if (!isAuthorized) {\n throw new ActionExecutionError(\"UNAUTHORIZED\", `Access denied for action '${plan.actionName}'`, 403);\n }\n }\n\n const execRes = plan.execute({ input, ctx, error: plan.errorBuilder });\n const result = execRes instanceof Promise ? await execRes : execRes;\n\n if (plan.outputChecker) {\n if (!plan.outputChecker.Check(result)) {\n const errors = Array.from(plan.outputChecker.Errors(result)).map((err: any) => ({\n path: err.path,\n message: err.message,\n value: err.value,\n }));\n throw new ValidationError(`Validation failed for action '${plan.actionName}' output`, errors, 500);\n }\n }\n\n return result;\n } catch (err: any) {\n if (err instanceof ValidationError || err instanceof ActionExecutionError) {\n set.status = err.status || 400;\n return err.toJSON();\n }\n set.status = 500;\n return {\n name: \"InternalServerError\",\n message: err.message || \"An unexpected error occurred\",\n status: 500,\n };\n }\n}\n\nexport function createActionHandler(\n service: Service,\n action: Action,\n routePath: string,\n method?: string\n) {\n const plan = compileRoutePlan(service, action, routePath, method);\n return (elysiaCtx: any) => executeCompiledRoute(plan, elysiaCtx);\n}\n","import { type Service, type Action, describeResourceReads, type ResourceReadQueries } from \"@brickkit/core\";\n\nexport type RouteMethod = \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\nexport interface RouteIR {\n readonly method: RouteMethod;\n readonly path: string;\n readonly service: string;\n readonly action: string;\n readonly kind: \"action\" | \"resource\";\n readonly input: boolean;\n readonly output: boolean;\n readonly context: boolean;\n readonly authorize: boolean;\n readonly inputPrecedence: readonly (\"query\" | \"params\" | \"body\")[];\n readonly coercions: readonly { readonly key: string; readonly type: \"number\" | \"boolean\" }[];\n /** JSON projection for inspection and stale-artifact detection, not runtime validation. */\n readonly inputSchema?: unknown;\n readonly outputSchema?: unknown;\n}\nexport interface BrickIR {\n readonly version: 1;\n readonly target: \"bun-elysia\";\n readonly prefix: string;\n readonly services: readonly string[];\n readonly routes: readonly RouteIR[];\n readonly reads: readonly ResourceReadQueries[];\n readonly diagnostics: readonly string[];\n}\nexport interface RouteBinding { readonly service: Service<any, any>; readonly action: Action<any, any, any, any>; }\n\nexport function freezeIR<T>(value: T): T {\n if (value && typeof value === \"object\" && !Object.isFrozen(value)) {\n for (const child of Object.values(value)) freezeIR(child);\n Object.freeze(value);\n }\n return value;\n}\n\nfunction schemaSnapshot(schema: unknown): unknown {\n return schema === undefined ? undefined : JSON.parse(JSON.stringify(schema));\n}\n\nexport function analyzeApplication(services: Service<any, any>[], prefix = \"/api\") {\n if (!prefix.startsWith(\"/\")) throw new Error(\"Brick compiler: prefix must start with '/'\");\n const names = new Set<string>();\n for (const service of services) {\n if (names.has(service.name)) throw new Error(`Brick compiler: duplicate service '${service.name}'`);\n names.add(service.name);\n service.build();\n }\n const routes: RouteIR[] = [];\n const bindings: RouteBinding[] = [];\n const registered = new Map<string, string>();\n const diagnostics: string[] = [];\n const add = (service: Service<any, any>, action: Action<any, any, any, any>, method: RouteMethod, path: string, kind: RouteIR[\"kind\"]) => {\n if (!path.startsWith(\"/\")) throw new Error(`Brick compiler: invalid route '${method} ${path}'`);\n const key = `${method} ${path}`;\n const previous = registered.get(key);\n if (previous) {\n diagnostics.push(`${key}: '${service.name}.${action.name}' shadowed by '${previous}' (first registration wins)`);\n return;\n }\n if (typeof action.config.execute !== \"function\") throw new Error(`Brick compiler: '${service.name}.${action.name}' has no execute handler`);\n registered.set(key, `${service.name}.${action.name}`);\n const readLike = method === \"GET\" || action.name.startsWith(\"get\") || action.name.endsWith(\".get\") || action.name.startsWith(\"list\") || action.name.endsWith(\".list\") || action.name.startsWith(\"find\") || action.name.startsWith(\"read\");\n const coercions: { key: string; type: \"number\" | \"boolean\" }[] = [];\n for (const [key, prop] of Object.entries(action.config.input?.properties ?? {}) as [string, any][]) {\n if (prop.type === \"number\" || prop.type === \"integer\") coercions.push({ key, type: \"number\" });\n else if (prop.type === \"boolean\") coercions.push({ key, type: \"boolean\" });\n }\n routes.push({ method, path, service: service.name, action: action.name, kind,\n input: Boolean(action.config.input), output: Boolean(action.config.output),\n context: typeof service.options.context === \"function\", authorize: typeof action.config.authorize === \"function\",\n inputPrecedence: readLike ? [\"query\", \"params\", \"body\"] : [\"params\", \"body\", \"query\"], coercions,\n inputSchema: schemaSnapshot(action.config.input), outputSchema: schemaSnapshot(action.config.output) });\n bindings.push({ service, action });\n };\n for (const service of services) {\n for (const resource of service.listResources()) {\n const collection = `${prefix}/${resource.name}`;\n const item = `${collection}/:id`;\n for (const [operation, method, path] of [\n [\"list\", \"GET\", collection], [\"create\", \"POST\", collection], [\"get\", \"GET\", item],\n [\"update\", \"PATCH\", item], [\"update\", \"PUT\", item], [\"delete\", \"DELETE\", item],\n ] as const) {\n const action = resource.actions[operation];\n if (action) add(service, action, method, path, \"resource\");\n }\n }\n for (const action of service.listActions()) {\n const path = `${prefix}/${service.name}/${action.name}`;\n add(service, action, \"POST\", path, \"action\");\n if (/^(get|list|find|read)/.test(action.name)) add(service, action, \"GET\", path, \"action\");\n if (action.config.path) {\n if (action.config.method) add(service, action, action.config.method, action.config.path, \"action\");\n else {\n add(service, action, \"GET\", action.config.path, \"action\");\n add(service, action, \"POST\", action.config.path, \"action\");\n }\n }\n }\n }\n const reads = services.flatMap(service => service.listResources().flatMap(resource => {\n const queries = describeResourceReads(service, resource);\n return queries ? [queries] : [];\n }));\n const ir: BrickIR = freezeIR({ version: 1, target: \"bun-elysia\", prefix, services: [...names], routes, reads, diagnostics });\n return { ir, bindings };\n}\n","import type { BrickIR, RouteIR } from \"./ir\";\n\n/** Emits framework code only. User callbacks remain closures bound separately. */\nexport function emitHandlerFactory(route: RouteIR): string {\n const name = JSON.stringify(route.action);\n const fields = route.input ? \"params, body, query, headers, request, set\" : \"headers, request, set\";\n const input: string[] = [\"let input;\"];\n if (route.input) {\n input.push(\"let coercedQuery = query;\");\n if (route.coercions.length) {\n input.push(\"if (query) {\", \"coercedQuery = { ...query };\");\n for (const [index, coercion] of route.coercions.entries()) {\n const key = JSON.stringify(coercion.key);\n input.push(`const v${index} = query[${key}];`);\n if (coercion.type === \"number\") input.push(`if (v${index} !== undefined) { const n${index} = Number(v${index}); if (!Number.isNaN(n${index})) coercedQuery[${key}] = n${index}; }`);\n else input.push(`if (v${index} === \"true\" || v${index} === \"1\") coercedQuery[${key}] = true; else if (v${index} === \"false\" || v${index} === \"0\") coercedQuery[${key}] = false;`);\n }\n input.push(\"}\");\n }\n input.push(`input = mergeInput(${route.inputPrecedence.map(source => source === \"query\" ? \"coercedQuery\" : source).join(\", \")});`);\n }\n const asyncStages = route.context || route.authorize;\n const context = route.context ? \"const extra = await contextHook(ctx); if (extra) Object.assign(ctx, extra);\" : \"\";\n const validation = route.input ? `validate(inputChecker, input, ${name}, \"input\");` : \"\";\n const authorization = route.authorize ? `if (!await authorize({ ctx, input, user: ctx.user })) deny(${name});` : \"\";\n const output = route.output ? `validate(outputChecker, result, ${name}, \"output\");` : \"\";\n const execute = asyncStages ? `const result = await execute({ input, ctx, error: errorBuilder });\\n${output}\\nreturn result;` : `const result = execute({ input, ctx, error: errorBuilder });\nif (isThenable(result)) return Promise.resolve(result).then(value => {\n ${route.output ? `validate(outputChecker, value, ${name}, \"output\");` : \"\"}\n return value;\n}).catch(err => mapError(err, set));\n${output}\nreturn result;`;\n return `function bindAction(binding, runtime) {\nconst { execute, contextHook, authorize, inputChecker, outputChecker, errorBuilder, logger, cachedDb, service } = binding;\nconst { nextSequence, defaultRequest, emptyServices, mergeInput, validate, deny, mapError, isThenable } = runtime;\nreturn ${asyncStages ? \"async \" : \"\"}function brickAction({ ${fields} }) {\nconst seq = nextSequence();\nconst traceId = (headers && headers[\"x-trace-id\"]) || \"tr_\" + seq;\nconst requestId = (headers && headers[\"x-request-id\"]) || \"req_\" + seq;\nif (set?.headers) { set.headers[\"x-trace-id\"] = traceId; set.headers[\"x-request-id\"] = requestId; }\n${input.join(\"\\n\")}\nconst ctx = { request: request instanceof Request ? request : defaultRequest, traceId, requestId,\n db: cachedDb ?? service.getDb(), logger, services: emptyServices, metadata: { headers }, _resolved: true };\ntry {\n${context}\n${validation}\n${authorization}\n${execute}\n} catch (err) { return mapError(err, set); }\n};\n}`;\n}\n\n/** An ES module of real JS functions; it never stringifies application callbacks. */\nexport function emitCompiledApplication(ir: BrickIR, runtimeImport = \"@brickkit/cli/compiler\"): string {\n return `// Generated by Brick compiler v1. Rebuild after changing application definitions.\\nimport { bindCompiledApplication } from ${JSON.stringify(runtimeImport)};\\nexport const ir = JSON.parse(${JSON.stringify(JSON.stringify(ir))});\\nconst factories = [\\n${ir.routes.map(emitHandlerFactory).join(\",\\n\")}\\n];\\nexport function bind(services) { return bindCompiledApplication(ir, services, factories); }\\n`;\n}\n","import { ValidationError, ActionExecutionError, type CompiledRoutePlan } from \"@brickkit/core\";\n\nexport type CompiledHandler = (context: any) => unknown | Promise<unknown>;\nexport type HandlerFactory = (binding: CompiledRoutePlan, runtime: typeof compilerRuntime) => CompiledHandler;\n\nconst EMPTY_SERVICES = Object.freeze({});\nconst DEFAULT_REQUEST = new Request(\"http://localhost\");\nlet sequence = 0;\n\nfunction isNonEmpty(value: any): boolean {\n if (value == null) return false;\n for (const _ in value) return true;\n return false;\n}\n\n/** Retains Brick's existing source precedence and treatment of empty bodies. */\nfunction mergeInput(first: any, second: any, third: any) {\n const a = isNonEmpty(first), b = isNonEmpty(second), c = isNonEmpty(third);\n if (a && !b && !c) return first;\n if (b && !a && !c) return second;\n if (c && !a && !b) return third;\n if (a || b || c) return Object.assign({}, first, second, third);\n return undefined;\n}\n\nfunction validate(check: NonNullable<CompiledRoutePlan[\"inputChecker\"]>, value: unknown, action: string, stage: \"input\" | \"output\") {\n if (check.Check(value)) return;\n const errors = Array.from(check.Errors(value)).map((err: any) => ({ path: err.path, message: err.message, value: err.value }));\n throw new ValidationError(`Validation failed for action '${action}' ${stage}`, errors, stage === \"output\" ? 500 : 400);\n}\n\nfunction mapError(err: any, set: any) {\n if (err instanceof ValidationError || err instanceof ActionExecutionError) {\n set.status = err.status || 400;\n return err.toJSON();\n }\n set.status = 500;\n return { name: \"InternalServerError\", message: err?.message || \"An unexpected error occurred\", status: 500 };\n}\n\nexport const compilerRuntime = Object.freeze({\n emptyServices: EMPTY_SERVICES, defaultRequest: DEFAULT_REQUEST,\n nextSequence: () => (++sequence).toString(36), mergeInput, validate, mapError,\n isThenable: (value: any): boolean => value != null && typeof value.then === \"function\",\n deny: (action: string): never => { throw new ActionExecutionError(\"UNAUTHORIZED\", `Access denied for action '${action}'`, 403); },\n});\n","import { type Service, prepareResourceReads, prepareResourceWrites } from \"@brickkit/core\";\nimport { compileRoutePlan, executeCompiledRoute } from \"./action-handler\";\nimport { analyzeApplication, freezeIR, type BrickIR, type RouteIR } from \"./compiler/ir\";\nimport { emitHandlerFactory } from \"./compiler/emit\";\nimport { compilerRuntime, type CompiledHandler, type HandlerFactory } from \"./compiler/runtime\";\n\nexport { emitCompiledApplication, emitHandlerFactory } from \"./compiler/emit\";\nexport type { BrickIR, RouteIR, RouteMethod } from \"./compiler/ir\";\nexport type { CompiledHandler, HandlerFactory } from \"./compiler/runtime\";\nexport interface CompiledRoute { readonly ir: RouteIR; readonly handler: CompiledHandler; }\nexport interface CompiledApplication { readonly ir: BrickIR; readonly routes: readonly CompiledRoute[]; }\n\nfunction bindAnalyzed(ir: BrickIR, bindings: ReturnType<typeof analyzeApplication>[\"bindings\"], factories: readonly HandlerFactory[]): CompiledApplication {\n if (factories.length !== ir.routes.length) throw new Error(\"Brick compiler: handler factory count does not match IR\");\n const routes = ir.routes.map((route, index) => {\n const { service, action } = bindings[index]!;\n const plan = Object.freeze(compileRoutePlan(service, action, route.path, route.method));\n const handler = factories[index]!(plan, compilerRuntime);\n return Object.freeze({ ir: route, handler });\n });\n return Object.freeze({ ir: freezeIR(ir), routes: Object.freeze(routes) });\n}\n\n/** Startup compiler: analyzes once, generates JS once, then binds live callbacks. */\nexport function compileBrickApplication(options: { services: Service<any, any>[]; prefix?: string; mode?: \"specialized\" | \"generic\" }): CompiledApplication {\n const { ir, bindings } = analyzeApplication(options.services, options.prefix);\n const factories: HandlerFactory[] = options.mode === \"generic\"\n ? ir.routes.map(() => (plan => context => executeCompiledRoute(plan, context)))\n : ir.routes.map(route => new Function(`return (${emitHandlerFactory(route)});`)() as HandlerFactory);\n if (options.mode !== \"generic\") for (const service of options.services) { prepareResourceReads(service); prepareResourceWrites(service); }\n return bindAnalyzed(ir, bindings, factories);\n}\n\n/** Build artifact binder: consumes emitted functions, with no runtime handler code generation. */\nexport function bindCompiledApplication(ir: BrickIR, services: Service<any, any>[], factories: readonly HandlerFactory[]): CompiledApplication {\n if (ir.version !== 1 || ir.target !== \"bun-elysia\") throw new Error(\"Brick compiler: unsupported IR version or target; rebuild the application\");\n const analyzed = analyzeApplication(services, ir.prefix);\n if (JSON.stringify(analyzed.ir) !== JSON.stringify(ir)) throw new Error(\"Brick compiler: application definitions differ from the compiled IR; rebuild the application\");\n for (const service of services) { prepareResourceReads(service); prepareResourceWrites(service); }\n return bindAnalyzed(ir, analyzed.bindings, factories);\n}\n"],"mappings":";;AAGA,IAAI,UAAU;AACd,MAAMA,mBAAiB,OAAO,OAAO,CAAC,CAAC;AACvC,MAAMC,oBAAkB,IAAI,QAAQ,kBAAkB;AAEtD,SAASC,aAAW,KAAmB;CACrC,IAAI,OAAO,MAAM,OAAO;CACxB,KAAK,MAAM,KAAK,KAAK,OAAO;CAC5B,OAAO;AACT;AAEA,SAAgB,iBACd,SACA,QACA,WACA,QACmB;CACnB,MAAM,aAAa,OAAO;CAC1B,MAAM,cAAc,QAAQ;CAC5B,MAAM,YACJ,WAAW,SACX,WAAW,WAAW,KAAK,KAC3B,WAAW,SAAS,MAAM,KAC1B,WAAW,WAAW,MAAM,KAC5B,WAAW,SAAS,OAAO,KAC3B,WAAW,WAAW,MAAM,KAC5B,WAAW,WAAW,MAAM;CAE9B,MAAM,cAAc,OAAO,QAAQ;CACnC,MAAM,eAAe,OAAO,QAAQ;CACpC,MAAM,WAAW,QAAQ,WAAW;CACpC,MAAM,eAAe,cAAe,iBAAiB,WAAW,IAAY,KAAA;CAE5E,MAAM,gBAAgB,eAAgB,iBAAiB,YAAY,IAAY,KAAA;CAE/E,IAAI;CACJ,IAAI,eAAe,OAAQ,YAAoB,eAAe,UAAU;EACtE,MAAM,OAAsE,CAAC;EAC7E,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAS,YAAoB,UAAU,GAAsB;GAC5F,MAAM,OAAO,MAAM;GACnB,IAAI,SAAS,YAAY,SAAS,WAChC,KAAK,KAAK;IAAE;IAAK,UAAU;IAA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I,UAAU,SAAS;AAC7C;;AAGA,SAAgB,wBAAwB,IAAa,UAA+B,WAA2D;CAC7I,IAAI,GAAG,YAAY,KAAK,GAAG,WAAW,cAAc,MAAM,IAAI,MAAM,2EAA2E;CAC/I,MAAM,WAAW,mBAAmB,UAAU,GAAG,MAAM;CACvD,IAAI,KAAK,UAAU,SAAS,EAAE,MAAM,KAAK,UAAU,EAAE,GAAG,MAAM,IAAI,MAAM,8FAA8F;CACtK,KAAK,MAAM,WAAW,UAAU;EAAE,qBAAqB,OAAO;EAAG,sBAAsB,OAAO;CAAG;CACjG,OAAO,aAAa,IAAI,SAAS,UAAU,SAAS;AACtD"}
@@ -0,0 +1,136 @@
1
+ import { a as emitCompiledApplication, i as compileBrickApplication, l as BrickIR, r as bindCompiledApplication, t as CompiledApplication, u as RouteIR } from "./compiler.js";
2
+ import { Elysia } from "elysia";
3
+ import { CompiledRoutePlan, DatabaseHandle, SecretSource, Service } from "@brickkit/core";
4
+ //#region src/request-logger.d.ts
5
+ interface RequestLoggingOptions {
6
+ enabled?: boolean;
7
+ logger?: (msg: string) => void;
8
+ }
9
+ /**
10
+ * Elysia plugin that logs each request as `METHOD path → status (elapsedms)`.
11
+ * Timing is tracked per-Request via a WeakMap. The onError hook only logs and
12
+ * returns undefined so existing error mapping is preserved. Logging only —
13
+ * no CORS headers are set here.
14
+ *
15
+ * Hooks are registered with `{ as: "global" }` so they propagate to the
16
+ * parent app when mounted via `app.use(...)` — Elysia scopes plain instance
17
+ * hooks to the plugin's own routes. Timing is captured in onBeforeHandle
18
+ * because onRequest offers no `as` option and is never propagated from a
19
+ * used instance. Unmatched routes (no beforeHandle) fall back to Date.now().
20
+ */
21
+ export declare function requestLoggingPlugin(opts?: RequestLoggingOptions): Elysia;
22
+ //#endregion
23
+ //#region src/docs.d.ts
24
+ interface ReferenceOptions {
25
+ path?: string;
26
+ title?: string;
27
+ specUrl?: string;
28
+ }
29
+ /** Renders the Scalar API reference page for the given OpenAPI URL. */
30
+ export declare function scalarDocsHTML(specUrl: string, title: string): string;
31
+ /** Standalone Elysia plugin serving GET <path> with the Scalar HTML page. */
32
+ export declare function referencePlugin(opts?: ReferenceOptions): Elysia;
33
+ /** Mounts the Scalar reference route onto an existing app. */
34
+ export declare function registerReferenceRoute(app: Elysia, opts?: ReferenceOptions): Elysia;
35
+ //#endregion
36
+ //#region src/endpoints.d.ts
37
+ type EndpointMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
38
+ /** Logger subset handed to endpoint handlers (mirrors action context loggers). */
39
+ interface EndpointLogger {
40
+ info: (...args: any[]) => void;
41
+ warn: (...args: any[]) => void;
42
+ error: (...args: any[]) => void;
43
+ debug: (...args: any[]) => void;
44
+ }
45
+ /** Context for raw endpoint handlers: Elysia route fields + Brick extras. */
46
+ interface EndpointContext {
47
+ params: Record<string, string>;
48
+ query: Record<string, string | undefined>;
49
+ body: unknown;
50
+ headers: Record<string, string>;
51
+ request: Request;
52
+ /** Elysia response setter (status/headers). Mutate like in `app.get`. */
53
+ set: {
54
+ status?: number;
55
+ headers: Record<string, string>;
56
+ };
57
+ /** Drizzle db from `service` (or first service with one); `undefined` when none. */
58
+ db: any;
59
+ logger: EndpointLogger;
60
+ traceId: string;
61
+ requestId: string;
62
+ }
63
+ interface EndpointDefinition {
64
+ method: EndpointMethod;
65
+ /** Elysia-style path, e.g. `/p/:slug`. */
66
+ path: string;
67
+ handler: (ctx: EndpointContext) => unknown | Promise<unknown>;
68
+ /** Db source: instance or registered service name. Defaults to first service with a db. */
69
+ service?: Service<any, any> | string;
70
+ /** Explicit database handle, independent of a service. */
71
+ database?: DatabaseHandle<unknown>;
72
+ summary?: string;
73
+ description?: string;
74
+ tags?: string[];
75
+ }
76
+ /** The app object returned by `createBrickServer`: Elysia plus `endpoint()`. */
77
+ type BrickApp = Elysia<any, any, any, any, any, any, any> & {
78
+ /** Register a raw endpoint (outside the JSON action mesh). */
79
+ endpoint(def: EndpointDefinition): void;
80
+ /** All endpoints registered via `endpoint()` (declaration order). */
81
+ listEndpoints(): EndpointDefinition[];
82
+ };
83
+ //#endregion
84
+ //#region src/server.d.ts
85
+ interface CreateServerOptions {
86
+ port?: number;
87
+ /** Generate specialized handlers once at startup (default true). */
88
+ compiler?: boolean;
89
+ /** Ahead-of-time handlers already bound to the supplied services. */
90
+ compilation?: CompiledApplication;
91
+ services?: Service<any, any>[];
92
+ prefix?: string;
93
+ title?: string;
94
+ version?: string;
95
+ description?: string;
96
+ docs?: boolean;
97
+ openApiPath?: string;
98
+ docsPath?: string;
99
+ swaggerPath?: string;
100
+ requestLogging?: boolean | RequestLoggingOptions;
101
+ reference?: boolean | ReferenceOptions;
102
+ secrets?: {
103
+ source?: SecretSource;
104
+ validate?: boolean;
105
+ };
106
+ /** Raw endpoints (outside the JSON action mesh), mounted at startup. */
107
+ endpoints?: EndpointDefinition[];
108
+ }
109
+ export declare function createBrickServer(options?: CreateServerOptions): BrickApp;
110
+ //#endregion
111
+ //#region src/runner.d.ts
112
+ interface DevServerOptions {
113
+ port?: number;
114
+ entry?: string;
115
+ prefix?: string;
116
+ }
117
+ export declare function startDevServer(options?: DevServerOptions): Promise<BrickApp>;
118
+ //#endregion
119
+ //#region src/build.d.ts
120
+ interface BuildApplicationOptions {
121
+ /** A module that registers services, without starting a server. */
122
+ entry: string;
123
+ outdir?: string;
124
+ prefix?: string;
125
+ port?: number;
126
+ requestLogging?: boolean;
127
+ }
128
+ /** Analyze definitions and bundle the emitted handlers with the user's callbacks. */
129
+ export declare function buildApplication(options: BuildApplicationOptions): Promise<{
130
+ outdir: string;
131
+ entry: string;
132
+ ir: BrickIR;
133
+ }>;
134
+ //#endregion
135
+ export { type BrickApp, type BrickIR, type BuildApplicationOptions, type CompiledApplication, type CreateServerOptions, type DevServerOptions, type EndpointContext, type EndpointDefinition, type EndpointLogger, type EndpointMethod, type ReferenceOptions, type RequestLoggingOptions, type RouteIR, bindCompiledApplication, compileBrickApplication, emitCompiledApplication };
136
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["_$__endpoints0.BrickApp","_$__compiler0.BrickIR"],"sources":["../src/request-logger.ts","../src/docs.ts","../src/endpoints.ts","../src/server.ts","../src/runner.ts","../src/build.ts"],"mappings":";;;;UAEiB;EACf;EACA,UAAU;;;;;;;;;;;;;;wBAoCI,qBACd,OAAM,wBACL;;;UCxCc;EACf;EACA;EACA;;;wBAIc,eAAe,iBAAiB;;wBAwBhC,gBAAgB,OAAM,mBAAwB;;wBAa9C,uBACd,KAAK,QACL,OAAM,mBACL;;;KC7CS;;UAGK;EACf,UAAU;EACV,UAAU;EACV,WAAW;EACX,WAAW;;;UAII;EACf,QAAQ;EACR,OAAO;EACP;EACA,SAAS;EACT,SAAS;;EAET;IAAO;IAAiB,SAAS;;;EAEjC;EACA,QAAQ;EACR;EACA;;UAGe;EACf,QAAQ;;EAER;EACA,UAAU,KAAK,8BAA8B;;EAE7C,UAAU;;EAEV,WAAW;EACX;EACA;EACA;;;KA2HU,WAAW;;EAErB,SAAS,KAAK;;EAEd,iBAAiB;;;;UC9IF;EACf;;EAEA;;EAEA,cAAc;EACd,WAAW;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,2BAA2B;EAC3B,sBAAsB;EACtB;IAAY,SAAS;IAAc;;;EAEnC,YAAY;;wBAKE,kBAAkB,UAAS,sBAA2B;;;UC7CrD;EACf;EACA;EACA;;wBAGoB,eAAe,UAAS,mBAAqB,QAArBA;;;UCL7B;;EAEf;EACA;EACA;EACA;EACA;;;wBAIoB,iBAAiB,SAAS,0BAAuB;;;MAAvBC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { n as compileBrickApplication, r as emitCompiledApplication, t as bindCompiledApplication } from "./compiler2.js";
2
+ import { a as registerReferenceRoute, i as referencePlugin, n as startDevServer, o as scalarDocsHTML, r as createBrickServer, s as requestLoggingPlugin, t as buildApplication } from "./build.js";
3
+ export { bindCompiledApplication, buildApplication, compileBrickApplication, createBrickServer, emitCompiledApplication, referencePlugin, registerReferenceRoute, requestLoggingPlugin, scalarDocsHTML, startDevServer };
package/package.json CHANGED
@@ -1,6 +1,48 @@
1
1
  {
2
2
  "name": "@brickkit/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.3",
4
+ "description": "CLI and server engine for Brick-TS",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "bin": {
10
+ "brick": "dist/bin.js"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ },
17
+ "./compiler": {
18
+ "import": "./dist/compiler.js",
19
+ "types": "./dist/compiler.d.ts"
20
+ }
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/Chandraprakash-Darji/brick.git",
31
+ "directory": "packages/cli"
32
+ },
33
+ "scripts": {
34
+ "build": "tsdown",
35
+ "prepublishOnly": "bun run build",
36
+ "typecheck": "tsc --noEmit -p tsconfig.build.json"
37
+ },
38
+ "dependencies": {
39
+ "@brickkit/core": "^0.1.3",
40
+ "@sinclair/typebox": "^0.34.0",
41
+ "elysia": "^1.2.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/bun": "latest",
45
+ "tsdown": "^0.23.0",
46
+ "typescript": "^5.7.0"
47
+ }
48
+ }