@brickkit/core 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","names":["BunSQLiteDatabase","_$__plugin0.ResourcePluginAPI","BunSQLiteDatabase"],"sources":["../../src/plugin.ts","../../src/db/sqlite.ts","../../src/secrets.ts","../../src/db/postgres.ts","../../src/db/define.ts","../../src/types.ts","../../src/client.ts"],"mappings":";;;;;;;;KAcY;KACA;KACA,aAAa,UAAU,mBAAmB,4BAElD,SAAS;EAAyB;EAAe,QAAQ;;KAExD,UAAU,KACb,UAAU,cAAc,SAAS,KAAK,YAAY,KAAK;UAExC,sBACf,UAAU,gBAAgB;EAE1B,QAAQ;EACR,OAAO;EACP;EACA,SAAS;EACT,SAAS;EACT;IAAO;IAAiB,SAAS;;EACjC,KAAK;;UAGU,qBACf,UAAU,gBAAgB,eAC1B,UAAU,mBAAmB;EAE7B,OACE,UAAU,iCACV,UAAU,iCACV,UAAU,eAAe,yBAAyB,eAEhD,wBAGF,QAAQ,0BAA0B,GAAG,GAAG,GAAG;IACzC;IACA,QAAQ;IACR,QAAQ;MAET,OAAO,GAAG,GAAG,GAAG;EACnB,OACE,UAAU,iCACV,UAAU,iCACV,UAAU,eAAe,yBAAyB,eAEhD,wBAGF,QAAQ,6BAA6B,GAAG,GAAG,GAAG;IAC5C;IACA,QAAQ;IACR,QAAQ;MAET,OAAO,GAAG,GAAG,GAAG;EACnB,SAAS;IACP;IACA;IACA,QAAQ;IACR,QAAQ;IACR,UAAU,SAAS,sBAAsB,iBAAiB;IAC1D;IACA;IACA;;;UAIa,qBACf,UAAU,oBAAoB;EAE9B,SAAS;EACT,QAAQ,qBAAqB,UAAU;;UAExB,sBACf,UAAU,oBAAoB,mBAC9B,UAAU,0BAA0B,cAAc,UAAU;EAE5D,SAAS;EACT,UAAU;EACV,QAAQ,qBAAqB,UAAU;;;UAIxB;WACN;WAC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Q,iBAAiB,IACzB,UAAU,qBACP,QAAQ,kBAAkB,OAE7B,OAAO,iBAAiB,IACxB,UAAU,qBACP,QAAQ,kBAAkB;;KAGzB,YAAY,KAAK,UACzB,mCACA,6BACA,kBAAkB,KAClB,eAAc,uBACZ,kBAAkB,KAClB,sBACK,WAAW,IAAI,YAAY,EAAE,SAChC;;;;;;iBAqSQ,kBAAkB,aAAa,qBAC7C,SAAS;EAAuB,UAAU;IACzC,YAAY;iBACC,kBAAkB,aAAa,qBAC7C,SAAS,qBACR,YAAY"}
1
+ {"version":3,"file":"client.d.ts","names":["BunSQLiteDatabase","_$__plugin0.ResourcePluginAPI","BunSQLiteDatabase"],"sources":["../../src/plugin.ts","../../src/db/sqlite.ts","../../src/secrets.ts","../../src/db/postgres.ts","../../src/db/define.ts","../../src/events/outbox.ts","../../src/events/types.ts","../../src/events/dispatcher.ts","../../src/events/hub.ts","../../src/types.ts","../../src/client.ts"],"mappings":";;;;;;;;KAcY;KACA;KACA,aAAa,UAAU,mBAAmB,4BAElD,SAAS;EAAyB;EAAe,QAAQ;;KAExD,UAAU,KACb,UAAU,cAAc,SAAS,KAAK,YAAY,KAAK;UAExC,sBACf,UAAU,gBAAgB;EAE1B,QAAQ;EACR,OAAO;EACP;EACA,SAAS;EACT,SAAS;EACT;IAAO;IAAiB,SAAS;;EACjC,KAAK;;UAGU,qBACf,UAAU,gBAAgB,eAC1B,UAAU,mBAAmB;EAE7B,OACE,UAAU,iCACV,UAAU,iCACV,UAAU,eAAe,yBAAyB,eAEhD,wBAGF,QAAQ,0BAA0B,GAAG,GAAG,GAAG;IACzC;IACA,QAAQ;IACR,QAAQ;MAET,OAAO,GAAG,GAAG,GAAG;EACnB,OACE,UAAU,iCACV,UAAU,iCACV,UAAU,eAAe,yBAAyB,eAEhD,wBAGF,QAAQ,6BAA6B,GAAG,GAAG,GAAG;IAC5C;IACA,QAAQ;IACR,QAAQ;MAET,OAAO,GAAG,GAAG,GAAG;EACnB,SAAS;IACP;IAC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C,iBAAiB,KAC3B,UAAU,wBAAwB,eAC9B,IACA;EACI;IAAU,cAAc,UAAU;;IAEpC,OAAO,KACP;EACI,QAAQ;IAAU,cAAc;IAAG;;IAErC,IACA;EAAY,IAAI,cAAc,GAAG;IAC/B,IACA,YAAW;EAAU,cAAc;EAAG;aACpC;;KAIF,kBAAkB,KAC5B,UAAU,6BAA6B,UACnC,IACA,eAAc,gBAAgB,cAAc,MAC1C,IACA;EAAY,QAAQ,cAAc,cAAc;IAC9C;;KAIE,sBAAsB,KAChC,UAAU,kCAAkC,KACxC,cAAc,aACd;EACI;IAAU,eAAe;;IAE3B,UAAU,eAAe,yBACvB,cAAc;;;;;;;;;;;;;KAgBZ,mBAAmB,KAAK;EAClC,MACI,sBAAsB;;;;;;KAchB,kBAAkB,uBACV,iBAAiB,MAE7B,QAAQ,iBAAiB,IACzB,UAAU,qBACP,QAAQ,kBAAkB,OAE7B,OAAO,iBAAiB,IACxB,UAAU,qBACP,QAAQ,kBAAkB;;KAGzB,YAAY,KAAK,UACzB,mCACA,6BACA,kBAAkB,KAClB,eAAc,uBACZ,kBAAkB,KAClB,sBACK,WAAW,IAAI,YAAY,EAAE,SAChC;;;;;;iBAuSQ,kBAAkB,aAAa,qBAC7C,SAAS;EAAuB,UAAU;IACzC,YAAY;iBACC,kBAAkB,aAAa,qBAC7C,SAAS,qBACR,YAAY"}
@@ -197,9 +197,10 @@ async function dispatch(resolved, path, target, input, callOptions) {
197
197
  if (timeoutMs !== void 0) timeoutSignal = AbortSignal.timeout(timeoutMs);
198
198
  const signals = [callOptions?.signal ?? resolved.signal, timeoutSignal].filter((value) => value !== void 0);
199
199
  const signal = signals.length > 1 ? AbortSignal.any(signals) : signals[0];
200
+ const send = resolved.fetch;
200
201
  let response;
201
202
  try {
202
- response = await resolved.fetch(url, {
203
+ response = await send(url, {
203
204
  method,
204
205
  headers,
205
206
  body: payload,
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../../src/types.ts","../../src/client.ts"],"sourcesContent":["import type { ServicePlugin, ResourcePlugin } from \"./plugin\";\nimport type { TSchema, Static } from \"@sinclair/typebox\";\nimport type { BunSQLiteDatabase } from \"./db/sqlite\";\nimport type { DatabaseHandle } from \"./db/define\";\n\n/**\n * The logger on action, tool, and endpoint contexts. While a dashboard is on\n * (`brick dev`, or `brick start` with the `dashboard` option) a line logged\n * during a traced request appears in the dashboard with that request, instead\n * of on the console (as does a plain `console.log`); anywhere else it prints\n * to the console.\n */\nexport interface Logger {\n info: (...args: any[]) => void;\n warn: (...args: any[]) => void;\n error: (...args: any[]) => void;\n debug: (...args: any[]) => void;\n}\n\n/**\n * Base framework context supplied to all service resolvers and action executions.\n */\nexport interface BaseContext<TDb = any> {\n request: Request;\n db: TDb;\n logger: Logger;\n traceId: string;\n requestId?: string;\n caller?: string;\n tenantId?: string;\n services?: Record<string, any>;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Default fallback service context for untyped or simple services.\n */\nexport interface DefaultServiceContext {\n user?: any;\n session?: any;\n [key: string]: any;\n}\n\n/**\n * The combined execution context: BaseContext & TServiceContext.\n */\nexport type ActionContext<\n TDb = any,\n TServiceContext = DefaultServiceContext,\n> = BaseContext<TDb> & TServiceContext;\n\n/**\n * Type utility that automatically narrows ctx.user from User | null to User\n * in execute() when authorize() is declared on the action.\n */\nexport type NarrowAuthorizedContext<TCtx> = TCtx extends { user: infer U }\n ? [U] extends [null | undefined]\n ? TCtx\n : Omit<TCtx, \"user\"> & { user: NonNullable<U> }\n : TCtx;\n\nexport interface ActionErrorDefinition {\n status?: number;\n message: string;\n}\n\nexport interface ValidationErrorItem {\n path: string;\n message: string;\n value?: unknown;\n type?: number;\n}\n\nexport class ValidationError extends Error {\n readonly code = \"VALIDATION_FAILED\";\n readonly status: number;\n readonly errors: ValidationErrorItem[];\n\n constructor(\n message: string,\n errors: ValidationErrorItem[] = [],\n status = 400,\n ) {\n super(message);\n this.name = \"ValidationError\";\n this.status = status;\n this.errors = errors;\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n errors: this.errors,\n };\n }\n}\n\nexport class ActionExecutionError extends Error {\n readonly code: string;\n readonly status: number;\n readonly details?: unknown;\n\n constructor(\n code: string,\n message: string,\n status = 400,\n details?: unknown,\n options?: ErrorOptions,\n ) {\n super(message, options);\n this.name = \"ActionExecutionError\";\n this.code = code;\n this.status = status;\n this.details = details;\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n details: this.details,\n };\n }\n}\n\nexport interface StandardErrorMap {\n BAD_REQUEST: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n UNAUTHORIZED: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n FORBIDDEN: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n NOT_FOUND: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n CONFLICT: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n INTERNAL_SERVER_ERROR: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n [key: string]:\n | ((\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never)\n | undefined;\n}\n\nexport type ErrorBuilder<\n TErrors extends Record<string, ActionErrorDefinition>,\n> = StandardErrorMap & {\n [K in keyof TErrors]: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n};\n\nexport interface BaseActionConfig<\n TInputSchema extends TSchema | undefined = undefined,\n TOutputSchema extends TSchema | undefined = undefined,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n> {\n name: string;\n description?: string;\n /** Effective HTTP path, including the prefix; replaces the default action path. */\n path?: string;\n /** Single HTTP method exposed for this action (default POST). */\n method?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n input?: TInputSchema;\n output?: TOutputSchema;\n errors?: TErrors;\n emits?: string[];\n tags?: string[];\n}\n\nexport interface ActionConfigWithAuthorize<\n TInputSchema extends TSchema | undefined = undefined,\n TOutputSchema extends TSchema | undefined = undefined,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n TContext extends ActionContext = ActionContext,\n> extends BaseActionConfig<TInputSchema, TOutputSchema, TErrors> {\n authorize: (params: {\n user?: TContext extends { user: infer U } ? U : any;\n input: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx: TContext;\n }) => boolean | Promise<boolean>;\n execute: (params: {\n input: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx: NarrowAuthorizedContext<TContext>;\n error: ErrorBuilder<TErrors>;\n }) =>\n | Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>\n | (TOutputSchema extends TSchema ? Static<TOutputSchema> : any);\n}\n\nexport interface ActionConfigWithoutAuthorize<\n TInputSchema extends TSchema | undefined = undefined,\n TOutputSchema extends TSchema | undefined = undefined,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n TContext extends ActionContext = ActionContext,\n> extends BaseActionConfig<TInputSchema, TOutputSchema, TErrors> {\n authorize?: undefined;\n execute: (params: {\n input: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx: TContext;\n error: ErrorBuilder<TErrors>;\n }) =>\n | Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>\n | (TOutputSchema extends TSchema ? Static<TOutputSchema> : any);\n}\n\nexport type ActionConfig<\n TInputSchema extends TSchema | undefined = any,\n TOutputSchema extends TSchema | undefined = any,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n TContext extends ActionContext = ActionContext,\n> =\n | ActionConfigWithAuthorize<TInputSchema, TOutputSchema, TErrors, TContext>\n | ActionConfigWithoutAuthorize<\n TInputSchema,\n TOutputSchema,\n TErrors,\n TContext\n >;\n\nexport interface Action<\n TInputSchema extends TSchema | undefined = any,\n TOutputSchema extends TSchema | undefined = any,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n TContext extends ActionContext = ActionContext,\n> {\n (params: {\n input?: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx?: Partial<TContext>;\n }): Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>;\n\n name: string;\n serviceName?: string;\n /** Owning plugin descriptor name for plugin actions (e.g. `@brickkit/crud`). */\n plugin?: string;\n /** Owning resource name for resource-plugin actions (e.g. `page`). */\n resource?: string;\n config: ActionConfig<TInputSchema, TOutputSchema, TErrors, TContext>;\n /**\n * Optional runtime-only output schema. When present, `validateOutput` and\n * HTTP output checking validate against it instead of `config.output`,\n * while `config.output` remains the published contract (client types,\n * OpenAPI). Lets projected/subset responses validate at runtime without\n * leaking optionality into the generated contract.\n */\n outputValidationSchema?: TSchema;\n run(\n input?: TInputSchema extends TSchema ? Static<TInputSchema> : any,\n ctx?: Partial<TContext>,\n ): Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>;\n execute(params: {\n input?: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx?: Partial<TContext>;\n }): Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>;\n executeResolved?(params: {\n input?: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx: TContext;\n }): Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>;\n validateInput(\n input: unknown,\n ):\n | { success: true; data: any }\n | { success: false; errors: ValidationErrorItem[] };\n validateOutput(\n output: unknown,\n ):\n | { success: true; data: any }\n | { success: false; errors: ValidationErrorItem[] };\n errorHelpers?: ErrorBuilder<TErrors>;\n}\n\n/** MCP tool metadata, kept with the executable definition. */\nexport interface ToolAnnotations {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n}\nexport interface ToolOptions {\n title?: string;\n annotations?: ToolAnnotations;\n /** Also register HTTP routes and OpenAPI. Defaults to false. */\n http?: boolean;\n}\nexport type ToolConfigWithAuthorize<\n I extends TSchema | undefined = undefined,\n O extends TSchema | undefined = undefined,\n E extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n C extends ActionContext = ActionContext,\n> = ActionConfigWithAuthorize<I, O, E, C> & ToolOptions;\nexport type ToolConfigWithoutAuthorize<\n I extends TSchema | undefined = undefined,\n O extends TSchema | undefined = undefined,\n E extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n C extends ActionContext = ActionContext,\n> = ActionConfigWithoutAuthorize<I, O, E, C> & ToolOptions;\nexport interface Tool<\n I extends TSchema | undefined = any,\n O extends TSchema | undefined = any,\n E extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n C extends ActionContext = ActionContext,\n> extends Action<I, O, E, C> {\n readonly kind: \"tool\";\n config:\n | ToolConfigWithAuthorize<I, O, E, C>\n | ToolConfigWithoutAuthorize<I, O, E, C>;\n}\n\n/** A resource declares identity and a table; plugins supply behavior. */\nexport interface ResourceConfig<TTable = any, _TCtx = any> {\n name: string;\n table: TTable;\n id?: import(\"drizzle-orm\").Column;\n}\n\nexport type InferTableRow<TTable> = TTable extends { $inferSelect: infer S }\n ? S\n : any;\nexport type InferTableInsert<TTable> = TTable extends { $inferInsert: infer S }\n ? S\n : any;\nexport type ResourceTypeOptions = Pick<ResourceConfig, \"name\" | \"id\">;\n\ntype PrimaryColumn<T> = T extends { _: { columns: infer C } }\n ? {\n [K in keyof C]: C[K] extends { _: { isPrimaryKey: true } } ? C[K] : never;\n }[keyof C]\n : import(\"drizzle-orm\").Column;\nexport type ResourceIdentity<T, O> = O & {\n id: O extends { id: infer I extends import(\"drizzle-orm\").Column }\n ? I\n : PrimaryColumn<T>;\n};\n\n/** Generic preparation declarations consumed by the application compiler. */\nexport interface PreparationContribution {\n readonly name: string;\n describe(): unknown;\n prepare(): void;\n}\n\nexport interface Resource<\n TTable = any,\n TCtx extends ActionContext = ActionContext,\n TOptions = {},\n> {\n use<\n P extends ResourcePlugin<\n Service<TCtx[\"db\"], Omit<TCtx, keyof BaseContext>>,\n this,\n any\n >,\n >(\n plugin: P,\n ): this & import(\"./plugin\").ResourcePluginAPI<P, TTable, TCtx, this>;\n readonly name: string;\n readonly serviceName: string;\n readonly table: TTable;\n readonly id: TOptions extends {\n id: infer I extends import(\"drizzle-orm\").Column;\n }\n ? I\n : import(\"drizzle-orm\").Column;\n readonly idField: string;\n readonly config: ResourceConfig<TTable, TCtx> & TOptions;\n}\n\nexport interface ServiceAuthOptions {\n requireAuth?: boolean;\n allowedRoles?: string[];\n policy?: (ctx: ActionContext) => boolean | Promise<boolean>;\n}\n\nexport interface RateLimitOptions {\n maxRequests: number;\n window: number | string;\n scope?: \"ip\" | \"user\" | \"tenant\";\n}\n\nexport interface CacheOptions {\n driver?: \"memory\" | \"redis\";\n defaultTtl?: number;\n}\n\nexport interface ResilienceOptions {\n timeoutMs?: number;\n retry?: {\n attempts: number;\n backoff: \"linear\" | \"exponential\";\n delayMs: number;\n };\n circuitBreaker?: {\n errorThresholdPercentage: number;\n resetTimeoutMs: number;\n };\n}\n\nexport interface TelemetryOptions {\n traceQueries?: boolean;\n auditLog?: boolean;\n tags?: Record<string, string>;\n}\n\nexport interface LifecycleOptions {\n onInit?: (ctx: { db?: any; logger?: Logger }) => Promise<void>;\n onDestroy?: () => Promise<void>;\n}\n\nexport interface ServiceOptions<\n TServiceContext extends Record<string, any> = Record<string, any>,\n TDb = any,\n> {\n database?: DatabaseHandle<TDb>;\n context?: (\n baseCtx: BaseContext<TDb> & { user?: unknown },\n ) => Promise<TServiceContext> | TServiceContext;\n auth?: ServiceAuthOptions;\n rateLimit?: RateLimitOptions;\n cache?: CacheOptions;\n resilience?: ResilienceOptions;\n telemetry?: TelemetryOptions;\n lifecycle?: LifecycleOptions;\n}\n\nexport type ActionAccessPolicy = \"public\" | \"authorized\" | \"scoped\";\n\nexport interface ActionSchema {\n name: string;\n /** Present only when this action has a registered HTTP route. */\n method?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path?: string;\n serviceName?: string;\n /** Owning plugin descriptor name for plugin actions (e.g. `@brickkit/crud`). */\n plugin?: string;\n /** Owning resource name for resource-plugin actions (e.g. `page`). */\n resource?: string;\n description?: string;\n inputSchema?: unknown;\n outputSchema?: unknown;\n hasAuthorize: boolean;\n hasScope?: boolean;\n accessPolicy?: ActionAccessPolicy;\n errors?: Record<string, ActionErrorDefinition>;\n emits?: string[];\n tags?: string[];\n}\n\nexport interface ServiceSchema {\n name: string;\n /** The service options as JSON: functions, such as `context` and hooks, are left out. */\n options: Record<string, unknown>;\n hasDatabase: boolean;\n databaseConfig?: {\n name?: string;\n engine: \"sqlite\" | \"postgres\";\n tables: string[];\n };\n actions: ActionSchema[];\n /** MCP tools. A tool with an HTTP route is also listed under `actions`. */\n tools?: { name: string }[];\n resources?: { name: string }[];\n}\n\nexport interface ArchitectureSchema {\n version: string;\n services: ServiceSchema[];\n}\n\nexport interface CompiledRoutePlan {\n service: Service<any, any>;\n action: Action<any, any, any, any>;\n actionName: string;\n serviceName: string;\n routePath: string;\n method?: string;\n isGetLike: boolean;\n hasInput: boolean;\n hasContextHook: boolean;\n contextHook?: (baseCtx: any) => Promise<any> | any;\n hasAuthorize: boolean;\n authorize?: (params: any) => boolean | Promise<boolean>;\n execute: (params: any) => Promise<any> | any;\n inputChecker?: {\n Check: (val: any) => boolean;\n Errors: (val: any) => Iterable<any>;\n };\n outputChecker?: {\n Check: (val: any) => boolean;\n Errors: (val: any) => Iterable<any>;\n };\n coercions?: Array<{\n key: string;\n isNumber: boolean;\n isBoolean: boolean;\n isArray?: boolean;\n }>;\n logger: Logger;\n errorBuilder: any;\n cachedDb: any;\n}\n\nexport interface Service<\n TDb = BunSQLiteDatabase<Record<string, unknown>>,\n TServiceContext extends Record<string, any> = Record<string, any>,\n> {\n readonly name: string;\n readonly options: ServiceOptions<TServiceContext, TDb>;\n readonly actions: Map<string, Action<any, any, any, any>>;\n readonly tools: Map<string, Tool<any, any, any, any>>;\n readonly tables: Map<string, any>;\n readonly resources: Map<\n string,\n Resource<any, BaseContext<TDb> & TServiceContext>\n >;\n readonly db?: TDb;\n readonly isBuilt?: boolean;\n\n use<A>(plugin: ServicePlugin<this, A>): A;\n\n build(): this;\n\n action<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n action: Action<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>,\n ): this;\n\n action<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n config: ActionConfigWithAuthorize<\n TIn,\n TOut,\n TErr,\n BaseContext<TDb> & TServiceContext\n >,\n ): Action<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>;\n\n action<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n config: ActionConfigWithoutAuthorize<\n TIn,\n TOut,\n TErr,\n BaseContext<TDb> & TServiceContext\n >,\n ): Action<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>;\n\n tool<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n action: Tool<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>,\n ): this;\n\n tool<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n config: ToolConfigWithAuthorize<\n TIn,\n TOut,\n TErr,\n BaseContext<TDb> & TServiceContext\n >,\n ): Tool<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>;\n\n tool<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n config: ToolConfigWithoutAuthorize<\n TIn,\n TOut,\n TErr,\n BaseContext<TDb> & TServiceContext\n >,\n ): Tool<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>;\n\n resource<\n TTable = any,\n const TOptions extends ResourceTypeOptions = ResourceTypeOptions,\n >(\n config: ResourceConfig<TTable, BaseContext<TDb> & TServiceContext> &\n TOptions &\n Record<Exclude<keyof TOptions, keyof ResourceConfig>, never>,\n ): Resource<\n TTable,\n BaseContext<TDb> & TServiceContext,\n ResourceIdentity<TTable, TOptions>\n >;\n\n readonly preparations: Map<string, PreparationContribution>;\n contributePreparation(contribution: PreparationContribution): void;\n listPreparations(): PreparationContribution[];\n prepareContributions(): void;\n registerTable(table: any): this;\n getAction(name: string): Action<any, any, any, any> | undefined;\n listActions(): Action<any, any, any, any>[];\n getTool(name: string): Tool<any, any, any, any> | undefined;\n listTools(): Tool<any, any, any, any>[];\n getResource(\n name: string,\n ): Resource<any, BaseContext<TDb> & TServiceContext> | undefined;\n listResources(): Resource<any, BaseContext<TDb> & TServiceContext>[];\n getDb(): TDb | undefined;\n setDb(database: DatabaseHandle<TDb>): void;\n resolveContext(\n callCtx?: Partial<BaseContext<TDb> & TServiceContext>,\n ): Promise<BaseContext<TDb> & TServiceContext>;\n introspect(): ServiceSchema;\n}\n\nexport interface ProxyOptions {\n isMonolith?: boolean;\n /** Name of the service creating this proxy. Populates ctx.caller on the target's envelope. */\n from?: string;\n context?: Partial<ActionContext>;\n}\n","import type { Static, TSchema } from \"@sinclair/typebox\";\nimport type { Action, ActionErrorDefinition } from \"./types\";\nimport { ActionExecutionError, ValidationError } from \"./types\";\n\n/**\n * Eden/tRPC-style typed HTTP client inferred from Brick-TS application contracts.\n *\n * The frontend imports only the contract *type* — never a backend implementation:\n *\n * ```ts\n * import { createBrickClient } from \"@brickkit/core/client\";\n * import type { AppServer } from \"./server\"; // `import type`: erased at build\n *\n * const api = createBrickClient<AppServer>({ baseUrl: \"http://localhost:4000\" });\n * const pages = await api.page.list({ limit: 10, sort: \"-createdAt\" });\n * const created = await api.page.create({ title: \"Hello\", content: \"World\" });\n * ```\n *\n * Build the contract from individually-typed actions (each `defineAction` call\n * preserves its input/output/error literal types):\n *\n * ```ts\n * // server.ts (backend)\n * export const listPages = pagesService.action({ name: \"page.list\", ... });\n * export const createPage = pagesService.action({ name: \"page.create\", ... });\n * export const contract = { page: { list: listPages, create: createPage } };\n * export type AppServer = typeof contract;\n * ```\n *\n * ## Result / error convention\n *\n * The client uses a throw-based convention that mirrors local `action.execute`\n * semantics, because TypeScript promises cannot encode thrown exception types:\n *\n * - Success → the promise resolves with the action output.\n * - Declared domain failures (your `errors: { SLUG_EXISTS: ... }`) and framework\n * guards (UNAUTHORIZED/FORBIDDEN/NOT_FOUND/...) → rejected with\n * {@link ActionExecutionError} carrying the declared `code`, `status`,\n * `message`, and `details`. Narrow with `instanceof` and read `err.code`.\n * - Input/output validation failures → rejected with {@link ValidationError},\n * exactly as local execution throws.\n * - Network failures, unparsable bodies, and non-OK responses outside the\n * declared contract → {@link BrickTransportError} (4xx) or\n * {@link BrickServerError} (5xx).\n * - Cancellation via `AbortSignal` → the native `AbortError` propagates\n * unwrapped so `err.name === \"AbortError\"` keeps working.\n *\n * ## URL mapping\n *\n * A client path is a namespace walk ending in an action call. The leaf segment\n * decides the route, matching the server compiler (`packages/cli/src/compiler`):\n *\n * | Client call | HTTP request |\n * |---|---|\n * Generated browser contracts carry each action's HTTP method and path,\n * including plugin routes and consumer overrides. Without runtime metadata,\n * callers use `POST /api/<service>/<action>` with dotted action names.\n * GET/DELETE input is serialized as a query string; other methods send JSON.\n\n */\n\nexport interface BrickClientOptions {\n /** Server origin, e.g. `\"http://localhost:4000\"`. No trailing slash required. */\n baseUrl: string;\n /**\n * Route prefix the server was mounted with (default `\"/api\"`).\n * Must match the `prefix` passed to `brick({ prefix })`.\n */\n prefix?: string;\n /**\n * Default headers sent with every call (e.g. an `Authorization` bearer).\n * A thunk is re-evaluated per call, so rotated tokens stay fresh.\n */\n headers?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n /** `fetch` implementation. Defaults to `globalThis.fetch`. */\n fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n /** Default signal applied to every call (per-call `signal` wins). */\n signal?: AbortSignal;\n /** Default per-call timeout in milliseconds (per-call `timeoutMs` wins). */\n timeoutMs?: number;\n /**\n * Browser-safe route metadata generated by the Brick Vite plugin.\n * Required for custom methods/paths and plugin routes. Without a contract,\n * calls use POST and service/action names inferred from namespace keys.\n */\n contract?: Record<string, any>;\n}\n\n/** Browser-safe action metadata generated by the Brick Vite plugin. */\nexport interface BrickClientAction<\n TInput = unknown,\n TOutput = unknown,\n TErrors = {},\n> {\n kind: \"action\";\n name: string;\n serviceName: string;\n /** Owning plugin descriptor name for plugin actions (e.g. `@brickkit/crud`). */\n plugin?: string;\n /** Owning resource name for resource-plugin actions (e.g. `page`). */\n resource?: string;\n config: { path: string; method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\" };\n /** Type information only; never emitted at runtime. */\n readonly __types?: { input: TInput; output: TOutput; errors: TErrors };\n}\n\nexport interface BrickCallOptions {\n /** Extra headers merged over the client defaults for this call only. */\n headers?: Record<string, string>;\n /** Abort signal for this call only. Never wrapped: aborts reject with `AbortError`. */\n signal?: AbortSignal;\n /** Per-call timeout in milliseconds. Implemented with `AbortSignal.timeout`. */\n timeoutMs?: number;\n}\n\n/**\n * The request never received a meaningful server answer: DNS / connection\n * failure, a malformed body, or a 4xx response outside the declared contract\n * (no `code` and no `ValidationError` shape).\n */\nexport class BrickTransportError extends Error {\n readonly kind = \"transport\" as const;\n readonly status?: number;\n readonly url: string;\n readonly body?: unknown;\n override readonly cause?: unknown;\n\n constructor(\n message: string,\n opts: { status?: number; url: string; body?: unknown; cause?: unknown },\n ) {\n super(message);\n this.name = \"BrickTransportError\";\n this.status = opts.status;\n this.url = opts.url;\n this.body = opts.body;\n this.cause = opts.cause;\n }\n}\n\n/**\n * The server answered 5xx without a declared `code` / `ValidationError` shape,\n * i.e. an unexpected failure rather than a modelled domain error.\n */\nexport class BrickServerError extends Error {\n readonly kind = \"server\" as const;\n readonly status: number;\n readonly url: string;\n readonly body: unknown;\n\n constructor(\n message: string,\n opts: { status: number; url: string; body: unknown },\n ) {\n super(message);\n this.name = \"BrickServerError\";\n this.status = opts.status;\n this.url = opts.url;\n this.body = opts.body;\n }\n}\n\n/**\n * Whether an error from the typed client is a `BrickTransportError`: the request\n * got no meaningful answer from the server (a network failure, a body that was\n * not JSON, or a 4xx outside the declared contract).\n *\n * @param err - What a client call threw.\n * @returns `true` for a transport error, narrowing its type.\n */\nexport function isBrickTransportError(\n err: unknown,\n): err is BrickTransportError {\n return err instanceof BrickTransportError;\n}\n\n/**\n * Whether an error from the typed client is a `BrickServerError`: the server\n * answered with a 5xx that is not one of the contract's declared errors, and the\n * error carries its `status`, `url`, and `body`.\n *\n * @param err - What a client call threw.\n * @returns `true` for a server error, narrowing its type.\n */\nexport function isBrickServerError(err: unknown): err is BrickServerError {\n return err instanceof BrickServerError;\n}\n\n/** Static input type from the schema, with a fallback for structural actions. */\nexport type InferActionInput<A> =\n A extends BrickClientAction<infer I, any, any>\n ? I\n : A extends {\n config: { input?: infer S extends TSchema };\n }\n ? Static<S>\n : A extends {\n execute(params: { input?: infer I; ctx?: any }): any;\n }\n ? I\n : A extends { run(input?: infer I, ctx?: any): any }\n ? I\n : A extends (params: { input?: infer I; ctx?: any }) => any\n ? I\n : unknown;\n\n/** Resolved output type of an action. */\nexport type InferActionOutput<A> =\n A extends BrickClientAction<any, infer O, any>\n ? O\n : A extends (...args: any[]) => Promise<infer O>\n ? O\n : A extends { execute(params: any): Promise<infer O> }\n ? O\n : unknown;\n\n/** Union of error `code`s declared in an action's `errors` map. */\nexport type InferActionErrorCodes<A> =\n A extends BrickClientAction<any, any, infer E>\n ? Extract<keyof E, string>\n : A extends {\n config: { errors?: infer E };\n }\n ? E extends Record<string, ActionErrorDefinition>\n ? Extract<keyof E, string>\n : never\n : never;\n\n/**\n * The declared failure shape of an action for `catch` narrowing:\n * ```ts\n * try { await api.page.create(input); }\n * catch (err) {\n * if (err instanceof ActionExecutionError) {\n * const code: InferActionErrorCodes<typeof createPage> | \"UNAUTHORIZED\" | ... = err.code;\n * }\n * }\n * ```\n * (Standard framework codes are always possible alongside declared ones.)\n */\nexport type InferActionFailure<A> = ActionExecutionError & {\n code:\n | InferActionErrorCodes<A>\n | \"BAD_REQUEST\"\n | \"UNAUTHORIZED\"\n | \"FORBIDDEN\"\n | \"NOT_FOUND\"\n | \"CONFLICT\"\n | \"INTERNAL_SERVER_ERROR\"\n | \"VALIDATION_FAILED\";\n};\n\n/**\n * Typed caller for one action. Required inputs stay required; actions whose\n * input includes `undefined` (no schema / all-optional) can be called bare.\n */\nexport type BrickActionCaller<A> =\n undefined extends InferActionInput<A>\n ? (\n input?: InferActionInput<A>,\n options?: BrickCallOptions,\n ) => Promise<InferActionOutput<A>>\n : (\n input: InferActionInput<A>,\n options?: BrickCallOptions,\n ) => Promise<InferActionOutput<A>>;\n\n/** Recursively maps action leaves and their namespaces to browser callers. */\nexport type BrickClient<T> = T extends\n | BrickClientAction<any, any, any>\n | Action<any, any, any, any>\n ? BrickActionCaller<T>\n : T extends (...args: any[]) => any\n ? BrickActionCaller<T>\n : T extends object\n ? { [K in keyof T]: BrickClient<T[K]> }\n : T;\n\ninterface ResolvedClientOptions {\n baseUrl: string;\n prefix: string;\n headers?: BrickClientOptions[\"headers\"];\n fetch: NonNullable<BrickClientOptions[\"fetch\"]>;\n signal?: AbortSignal;\n timeoutMs?: number;\n}\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n const trimmed = baseUrl.replace(/\\/+$/, \"\");\n if (!trimmed)\n throw new Error(\"[Brick-TS client] `baseUrl` must not be empty.\");\n return trimmed;\n}\n\nfunction normalizePrefix(prefix: string | undefined): string {\n if (!prefix) return \"/api\";\n const withLeading = prefix.startsWith(\"/\") ? prefix : `/${prefix}`;\n return withLeading.length > 1 ? withLeading.replace(/\\/+$/, \"\") : withLeading;\n}\n\nfunction toQueryString(input: unknown): string {\n if (input == null || typeof input !== \"object\") return \"\";\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(input as Record<string, unknown>)) {\n if (value === undefined || value === null) continue;\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item === undefined || item === null) continue;\n params.append(\n key,\n typeof item === \"object\" ? JSON.stringify(item) : String(item),\n );\n }\n } else if (typeof value === \"object\") {\n params.append(key, JSON.stringify(value));\n } else {\n params.append(key, String(value));\n }\n }\n const qs = params.toString();\n return qs ? `?${qs}` : \"\";\n}\n\ninterface PlannedRequest {\n method: string;\n url: string;\n body: unknown;\n hasBody: boolean;\n}\n\nfunction isActionValue(value: unknown): value is {\n serviceName?: unknown;\n name?: unknown;\n config: Action<any, any, any, any>[\"config\"];\n} & Function {\n return (\n typeof value === \"function\" &&\n !!(value as any).config &&\n typeof (value as any).config.execute === \"function\"\n );\n}\n\nfunction isClientAction(value: unknown): value is BrickClientAction {\n return (\n !!value &&\n typeof value === \"object\" &&\n (value as BrickClientAction).kind === \"action\"\n );\n}\n\nfunction planRequest(\n path: string[],\n /** Runtime contract value at `path`, when the `contract` option is set. */\n target: unknown,\n input: unknown,\n baseUrl: string,\n prefix: string,\n): PlannedRequest {\n if (path.length === 0) {\n throw new Error(\n \"[Brick-TS client] No action selected: call a leaf such as `api.page.list(input)`.\",\n );\n }\n const actionTarget =\n isActionValue(target) || isClientAction(target) ? target : undefined;\n const actionConfig = actionTarget?.config;\n if (path.length < 2) {\n throw new Error(\n `[Brick-TS client] Cannot address '${path.join(\".\")}': custom actions need a service segment, e.g. \\`api.${path[0]}.<action>(input)\\`.`,\n );\n }\n // Exact mode: the runtime contract reveals the bound service/action names,\n // so contract keys can differ from backend names.\n const service =\n typeof actionTarget?.serviceName === \"string\" && actionTarget.serviceName\n ? actionTarget.serviceName\n : path[0]!;\n const action =\n typeof actionTarget?.name === \"string\" && actionTarget.name\n ? actionTarget.name\n : path.slice(1).join(\".\");\n const method = actionConfig?.method ?? \"POST\";\n const configuredPath = actionConfig?.path;\n let actionPath =\n configuredPath ??\n `${prefix}/${encodeURIComponent(service)}/${action.split(\".\").map(encodeURIComponent).join(\".\")}`;\n let remaining = input;\n if (configuredPath !== undefined) {\n if (!configuredPath.startsWith(\"/\")) {\n throw new Error(\"[Brick-TS client] Action paths must start with '/'.\");\n }\n const source = { ...((input ?? {}) as Record<string, unknown>) };\n const record = { ...source };\n actionPath = actionPath.replace(/:([^/]+)/g, (_match, key: string) => {\n const value = Object.hasOwn(source, key) ? source[key] : undefined;\n if (value === undefined || value === null || value === \"\") {\n throw new Error(`[Brick-TS client] Missing path parameter '${key}'.`);\n }\n delete record[key];\n return encodeURIComponent(String(value));\n });\n remaining = input === undefined ? undefined : record;\n }\n const queryOnly = method === \"GET\" || method === \"DELETE\";\n return {\n method,\n url: `${baseUrl}${actionPath}${queryOnly ? toQueryString(remaining) : \"\"}`,\n body: queryOnly ? undefined : remaining,\n hasBody: !queryOnly && remaining !== undefined,\n };\n}\n\nfunction toActionError(status: number, body: unknown, url: string): Error {\n if (body !== null && typeof body === \"object\") {\n const record = body as Record<string, unknown>;\n if (record.name === \"ValidationError\") {\n return new ValidationError(\n typeof record.message === \"string\"\n ? record.message\n : \"Validation failed\",\n Array.isArray(record.errors) ? (record.errors as any) : [],\n typeof record.status === \"number\" ? record.status : status,\n );\n }\n if (typeof record.code === \"string\") {\n return new ActionExecutionError(\n record.code,\n typeof record.message === \"string\" ? record.message : record.code,\n typeof record.status === \"number\" ? record.status : status,\n (record.details ?? undefined) as unknown,\n );\n }\n }\n if (status >= 500) {\n return new BrickServerError(\n `Unexpected server error (status ${status}) for ${url}.`,\n {\n status,\n url,\n body,\n },\n );\n }\n return new BrickTransportError(\n `Request failed with status ${status} for ${url}.`,\n {\n status,\n url,\n body,\n },\n );\n}\n\nasync function dispatch(\n resolved: ResolvedClientOptions,\n path: string[],\n target: unknown,\n input: unknown,\n callOptions: BrickCallOptions | undefined,\n): Promise<unknown> {\n const { method, url, body, hasBody } = planRequest(\n path,\n target,\n input,\n resolved.baseUrl,\n resolved.prefix,\n );\n\n const staticHeaders =\n typeof resolved.headers === \"function\"\n ? await resolved.headers()\n : (resolved.headers ?? {});\n const headers: Record<string, string> = {\n accept: \"application/json\",\n ...staticHeaders,\n ...callOptions?.headers,\n };\n let payload: string | undefined;\n if (hasBody) {\n headers[\"content-type\"] = \"application/json\";\n payload = JSON.stringify(body ?? null);\n }\n\n const timeoutMs = callOptions?.timeoutMs ?? resolved.timeoutMs;\n let timeoutSignal: AbortSignal | undefined;\n if (timeoutMs !== undefined) timeoutSignal = AbortSignal.timeout(timeoutMs);\n const signals = [\n callOptions?.signal ?? resolved.signal,\n timeoutSignal,\n ].filter((value): value is AbortSignal => value !== undefined);\n const signal = signals.length > 1 ? AbortSignal.any(signals) : signals[0];\n\n let response: Response;\n try {\n response = await resolved.fetch(url, {\n method,\n headers,\n body: payload,\n signal,\n });\n } catch (err) {\n if (err instanceof Error && err.name === \"AbortError\") throw err;\n throw new BrickTransportError(\n `Network request failed for ${url}: ${err instanceof Error ? err.message : String(err)}`,\n { url, cause: err },\n );\n }\n\n let parsed: unknown;\n const text = await response.text();\n if (response.headers.get(\"content-type\")?.includes(\"text/plain\")) {\n parsed = text;\n } else if (text) {\n try {\n parsed = JSON.parse(text);\n } catch (err) {\n if (!response.headers.has(\"content-type\")) {\n parsed = text;\n } else {\n throw new BrickTransportError(`Unparsable response body for ${url}.`, {\n status: response.status,\n url,\n cause: err,\n });\n }\n }\n }\n\n if (response.ok) return parsed;\n throw toActionError(response.status, parsed, url);\n}\n\nfunction childNode(node: unknown, prop: string): unknown {\n if (\n node != null &&\n (typeof node === \"object\" || typeof node === \"function\")\n ) {\n return (node as Record<string, unknown>)[prop];\n }\n return undefined;\n}\n\nfunction createNamespace(\n resolved: ResolvedClientOptions,\n path: string[],\n node: unknown,\n): any {\n const callable = async (input?: unknown, options?: BrickCallOptions) =>\n dispatch(resolved, path, node, input, options);\n return new Proxy(callable, {\n get(target, prop, receiver) {\n if (typeof prop !== \"string\") return Reflect.get(target, prop, receiver);\n // Never masquerade as a thenable: awaiting a namespace must not dispatch.\n if (prop === \"then\" || prop === \"catch\" || prop === \"finally\")\n return undefined;\n return createNamespace(resolved, [...path, prop], childNode(node, prop));\n },\n apply(_target, _thisArg, args: unknown[]) {\n const [input, options] = args as [unknown, BrickCallOptions | undefined];\n return dispatch(resolved, path, node, input, options);\n },\n });\n}\n\n/**\n * Create an Eden/tRPC-style typed client for the application contract `TApp`.\n * `TApp` is a type-only parameter: `import type { AppServer }` keeps backend\n * implementations out of the frontend bundle.\n */\nexport function createBrickClient<TApp extends Record<string, any>>(\n options: BrickClientOptions & { contract: TApp },\n): BrickClient<TApp>;\nexport function createBrickClient<TApp extends Record<string, any>>(\n options: BrickClientOptions,\n): BrickClient<TApp>;\nexport function createBrickClient<TApp extends Record<string, any>>(\n options: BrickClientOptions,\n): BrickClient<TApp> {\n if (!options?.baseUrl)\n throw new Error(\n '[Brick-TS client] `baseUrl` is required, e.g. `{ baseUrl: \"http://localhost:4000\" }`.',\n );\n const fetchImpl = options.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") {\n throw new Error(\n \"[Brick-TS client] No `fetch` implementation available: pass `fetch` explicitly.\",\n );\n }\n const resolved: ResolvedClientOptions = {\n baseUrl: normalizeBaseUrl(options.baseUrl),\n prefix: normalizePrefix(options.prefix),\n headers: options.headers,\n fetch: fetchImpl,\n signal: options.signal,\n timeoutMs: options.timeoutMs,\n };\n return createNamespace(resolved, [], options.contract) as BrickClient<TApp>;\n}\n"],"mappings":";AAyEA,IAAa,kBAAb,cAAqC,MAAM;CACzC,OAAgB;CAChB;CACA;CAEA,YACE,SACA,SAAgC,CAAC,GACjC,SAAS,KACT;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,SAAS;CAChB;CAEA,SAAS;EACP,OAAO;GACL,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,QAAQ,KAAK;EACf;CACF;AACF;AAEA,IAAa,uBAAb,cAA0C,MAAM;CAC9C;CACA;CACA;CAEA,YACE,MACA,SACA,SAAS,KACT,SACA,SACA;EACA,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,UAAU;CACjB;CAEA,SAAS;EACP,OAAO;GACL,MAAM,KAAK;GACX,MAAM,KAAK;GACX,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,SAAS,KAAK;EAChB;CACF;AACF;;;;;;;;ACNA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,OAAgB;CAChB;CACA;CACA;CACA;CAEA,YACE,SACA,MACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS,KAAK;EACnB,KAAK,MAAM,KAAK;EAChB,KAAK,OAAO,KAAK;EACjB,KAAK,QAAQ,KAAK;CACpB;AACF;;;;;AAMA,IAAa,mBAAb,cAAsC,MAAM;CAC1C,OAAgB;CAChB;CACA;CACA;CAEA,YACE,SACA,MACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS,KAAK;EACnB,KAAK,MAAM,KAAK;EAChB,KAAK,OAAO,KAAK;CACnB;AACF;;;;;;;;;AAUA,SAAgB,sBACd,KAC4B;CAC5B,OAAO,eAAe;AACxB;;;;;;;;;AAUA,SAAgB,mBAAmB,KAAuC;CACxE,OAAO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,KAAA;GACT,OAAO,gBAAgB,UAAU,CAAC,GAAG,MAAM,IAAI,GAAG,UAAU,MAAM,IAAI,CAAC;EACzE;EACA,MAAM,SAAS,UAAU,MAAiB;GACxC,MAAM,CAAC,OAAO,WAAW;GACzB,OAAO,SAAS,UAAU,MAAM,MAAM,OAAO,OAAO;EACtD;CACF,CAAC;AACH;AAaA,SAAgB,kBACd,SACmB;CACnB,IAAI,CAAC,SAAS,SACZ,MAAM,IAAI,MACR,yFACF;CACF,MAAM,YAAY,QAAQ,SAAS,WAAW;CAC9C,IAAI,OAAO,cAAc,YACvB,MAAM,IAAI,MACR,iFACF;CAUF,OAAO,gBAAgB;EAPrB,SAAS,iBAAiB,QAAQ,OAAO;EACzC,QAAQ,gBAAgB,QAAQ,MAAM;EACtC,SAAS,QAAQ;EACjB,OAAO;EACP,QAAQ,QAAQ;EAChB,WAAW,QAAQ;CAES,GAAG,CAAC,GAAG,QAAQ,QAAQ;AACvD"}
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/types.ts","../../src/client.ts"],"sourcesContent":["import type { ServicePlugin, ResourcePlugin } from \"./plugin\";\nimport type { TSchema, Static } from \"@sinclair/typebox\";\nimport type { BunSQLiteDatabase } from \"./db/sqlite\";\nimport type { DatabaseHandle } from \"./db/define\";\nimport type { OutboxTable } from \"./events/outbox\";\nimport type { ServiceEvents } from \"./events/types\";\nimport type { EventsDefinition } from \"./events/hub\";\n\n/**\n * The logger on action, tool, and endpoint contexts. While a dashboard is on\n * (`brick dev`, or `brick start` with the `dashboard` option) a line logged\n * during a traced request appears in the dashboard with that request, instead\n * of on the console (as does a plain `console.log`); anywhere else it prints\n * to the console.\n */\nexport interface Logger {\n info: (...args: any[]) => void;\n warn: (...args: any[]) => void;\n error: (...args: any[]) => void;\n debug: (...args: any[]) => void;\n}\n\n/**\n * Base framework context supplied to all service resolvers and action executions.\n */\nexport interface BaseContext<TDb = any> {\n request: Request;\n db: TDb;\n logger: Logger;\n traceId: string;\n requestId?: string;\n caller?: string;\n tenantId?: string;\n services?: Record<string, any>;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Default fallback service context for untyped or simple services.\n */\nexport interface DefaultServiceContext {\n user?: any;\n session?: any;\n [key: string]: any;\n}\n\n/**\n * The combined execution context: BaseContext & TServiceContext.\n */\nexport type ActionContext<\n TDb = any,\n TServiceContext = DefaultServiceContext,\n> = BaseContext<TDb> & TServiceContext;\n\n/**\n * Type utility that automatically narrows ctx.user from User | null to User\n * in execute() when authorize() is declared on the action.\n */\nexport type NarrowAuthorizedContext<TCtx> = TCtx extends { user: infer U }\n ? [U] extends [null | undefined]\n ? TCtx\n : Omit<TCtx, \"user\"> & { user: NonNullable<U> }\n : TCtx;\n\nexport interface ActionErrorDefinition {\n status?: number;\n message: string;\n}\n\nexport interface ValidationErrorItem {\n path: string;\n message: string;\n value?: unknown;\n type?: number;\n}\n\nexport class ValidationError extends Error {\n readonly code = \"VALIDATION_FAILED\";\n readonly status: number;\n readonly errors: ValidationErrorItem[];\n\n constructor(\n message: string,\n errors: ValidationErrorItem[] = [],\n status = 400,\n ) {\n super(message);\n this.name = \"ValidationError\";\n this.status = status;\n this.errors = errors;\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n errors: this.errors,\n };\n }\n}\n\nexport class ActionExecutionError extends Error {\n readonly code: string;\n readonly status: number;\n readonly details?: unknown;\n\n constructor(\n code: string,\n message: string,\n status = 400,\n details?: unknown,\n options?: ErrorOptions,\n ) {\n super(message, options);\n this.name = \"ActionExecutionError\";\n this.code = code;\n this.status = status;\n this.details = details;\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n details: this.details,\n };\n }\n}\n\nexport interface StandardErrorMap {\n BAD_REQUEST: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n UNAUTHORIZED: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n FORBIDDEN: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n NOT_FOUND: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n CONFLICT: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n INTERNAL_SERVER_ERROR: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n [key: string]:\n | ((\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never)\n | undefined;\n}\n\nexport type ErrorBuilder<\n TErrors extends Record<string, ActionErrorDefinition>,\n> = StandardErrorMap & {\n [K in keyof TErrors]: (\n overrideMessage?: string,\n details?: unknown,\n options?: ErrorOptions,\n ) => never;\n};\n\nexport interface BaseActionConfig<\n TInputSchema extends TSchema | undefined = undefined,\n TOutputSchema extends TSchema | undefined = undefined,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n> {\n name: string;\n description?: string;\n /** Effective HTTP path, including the prefix; replaces the default action path. */\n path?: string;\n /** Single HTTP method exposed for this action (default POST). */\n method?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n input?: TInputSchema;\n output?: TOutputSchema;\n errors?: TErrors;\n emits?: string[];\n tags?: string[];\n}\n\nexport interface ActionConfigWithAuthorize<\n TInputSchema extends TSchema | undefined = undefined,\n TOutputSchema extends TSchema | undefined = undefined,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n TContext extends ActionContext = ActionContext,\n> extends BaseActionConfig<TInputSchema, TOutputSchema, TErrors> {\n authorize: (params: {\n user?: TContext extends { user: infer U } ? U : any;\n input: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx: TContext;\n }) => boolean | Promise<boolean>;\n execute: (params: {\n input: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx: NarrowAuthorizedContext<TContext>;\n error: ErrorBuilder<TErrors>;\n }) =>\n | Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>\n | (TOutputSchema extends TSchema ? Static<TOutputSchema> : any);\n}\n\nexport interface ActionConfigWithoutAuthorize<\n TInputSchema extends TSchema | undefined = undefined,\n TOutputSchema extends TSchema | undefined = undefined,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n TContext extends ActionContext = ActionContext,\n> extends BaseActionConfig<TInputSchema, TOutputSchema, TErrors> {\n authorize?: undefined;\n execute: (params: {\n input: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx: TContext;\n error: ErrorBuilder<TErrors>;\n }) =>\n | Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>\n | (TOutputSchema extends TSchema ? Static<TOutputSchema> : any);\n}\n\nexport type ActionConfig<\n TInputSchema extends TSchema | undefined = any,\n TOutputSchema extends TSchema | undefined = any,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n TContext extends ActionContext = ActionContext,\n> =\n | ActionConfigWithAuthorize<TInputSchema, TOutputSchema, TErrors, TContext>\n | ActionConfigWithoutAuthorize<\n TInputSchema,\n TOutputSchema,\n TErrors,\n TContext\n >;\n\nexport interface Action<\n TInputSchema extends TSchema | undefined = any,\n TOutputSchema extends TSchema | undefined = any,\n TErrors extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n TContext extends ActionContext = ActionContext,\n> {\n (params: {\n input?: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx?: Partial<TContext>;\n }): Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>;\n\n name: string;\n serviceName?: string;\n /** Owning plugin descriptor name for plugin actions (e.g. `@brickkit/crud`). */\n plugin?: string;\n /** Owning resource name for resource-plugin actions (e.g. `page`). */\n resource?: string;\n config: ActionConfig<TInputSchema, TOutputSchema, TErrors, TContext>;\n /**\n * Optional runtime-only output schema. When present, `validateOutput` and\n * HTTP output checking validate against it instead of `config.output`,\n * while `config.output` remains the published contract (client types,\n * OpenAPI). Lets projected/subset responses validate at runtime without\n * leaking optionality into the generated contract.\n */\n outputValidationSchema?: TSchema;\n run(\n input?: TInputSchema extends TSchema ? Static<TInputSchema> : any,\n ctx?: Partial<TContext>,\n ): Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>;\n execute(params: {\n input?: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx?: Partial<TContext>;\n }): Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>;\n executeResolved?(params: {\n input?: TInputSchema extends TSchema ? Static<TInputSchema> : any;\n ctx: TContext;\n }): Promise<TOutputSchema extends TSchema ? Static<TOutputSchema> : any>;\n validateInput(\n input: unknown,\n ):\n | { success: true; data: any }\n | { success: false; errors: ValidationErrorItem[] };\n validateOutput(\n output: unknown,\n ):\n | { success: true; data: any }\n | { success: false; errors: ValidationErrorItem[] };\n errorHelpers?: ErrorBuilder<TErrors>;\n}\n\n/** MCP tool metadata, kept with the executable definition. */\nexport interface ToolAnnotations {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n}\nexport interface ToolOptions {\n title?: string;\n annotations?: ToolAnnotations;\n /** Also register HTTP routes and OpenAPI. Defaults to false. */\n http?: boolean;\n}\nexport type ToolConfigWithAuthorize<\n I extends TSchema | undefined = undefined,\n O extends TSchema | undefined = undefined,\n E extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n C extends ActionContext = ActionContext,\n> = ActionConfigWithAuthorize<I, O, E, C> & ToolOptions;\nexport type ToolConfigWithoutAuthorize<\n I extends TSchema | undefined = undefined,\n O extends TSchema | undefined = undefined,\n E extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n C extends ActionContext = ActionContext,\n> = ActionConfigWithoutAuthorize<I, O, E, C> & ToolOptions;\nexport interface Tool<\n I extends TSchema | undefined = any,\n O extends TSchema | undefined = any,\n E extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n C extends ActionContext = ActionContext,\n> extends Action<I, O, E, C> {\n readonly kind: \"tool\";\n config:\n | ToolConfigWithAuthorize<I, O, E, C>\n | ToolConfigWithoutAuthorize<I, O, E, C>;\n}\n\n/** A resource declares identity and a table; plugins supply behavior. */\nexport interface ResourceConfig<TTable = any, _TCtx = any> {\n name: string;\n table: TTable;\n id?: import(\"drizzle-orm\").Column;\n}\n\nexport type InferTableRow<TTable> = TTable extends { $inferSelect: infer S }\n ? S\n : any;\nexport type InferTableInsert<TTable> = TTable extends { $inferInsert: infer S }\n ? S\n : any;\nexport type ResourceTypeOptions = Pick<ResourceConfig, \"name\" | \"id\">;\n\ntype PrimaryColumn<T> = T extends { _: { columns: infer C } }\n ? {\n [K in keyof C]: C[K] extends { _: { isPrimaryKey: true } } ? C[K] : never;\n }[keyof C]\n : import(\"drizzle-orm\").Column;\nexport type ResourceIdentity<T, O> = O & {\n id: O extends { id: infer I extends import(\"drizzle-orm\").Column }\n ? I\n : PrimaryColumn<T>;\n};\n\n/** Generic preparation declarations consumed by the application compiler. */\nexport interface PreparationContribution {\n readonly name: string;\n describe(): unknown;\n prepare(): void;\n}\n\nexport interface Resource<\n TTable = any,\n TCtx extends ActionContext = ActionContext,\n TOptions = {},\n> {\n use<\n P extends ResourcePlugin<\n Service<TCtx[\"db\"], Omit<TCtx, keyof BaseContext>>,\n this,\n any\n >,\n >(\n plugin: P,\n ): this & import(\"./plugin\").ResourcePluginAPI<P, TTable, TCtx, this>;\n readonly name: string;\n readonly serviceName: string;\n readonly table: TTable;\n readonly id: TOptions extends {\n id: infer I extends import(\"drizzle-orm\").Column;\n }\n ? I\n : import(\"drizzle-orm\").Column;\n readonly idField: string;\n readonly config: ResourceConfig<TTable, TCtx> & TOptions;\n}\n\nexport interface ServiceAuthOptions {\n requireAuth?: boolean;\n allowedRoles?: string[];\n policy?: (ctx: ActionContext) => boolean | Promise<boolean>;\n}\n\nexport interface RateLimitOptions {\n maxRequests: number;\n window: number | string;\n scope?: \"ip\" | \"user\" | \"tenant\";\n}\n\nexport interface CacheOptions {\n driver?: \"memory\" | \"redis\";\n defaultTtl?: number;\n}\n\nexport interface ResilienceOptions {\n timeoutMs?: number;\n retry?: {\n attempts: number;\n backoff: \"linear\" | \"exponential\";\n delayMs: number;\n };\n circuitBreaker?: {\n errorThresholdPercentage: number;\n resetTimeoutMs: number;\n };\n}\n\nexport interface TelemetryOptions {\n traceQueries?: boolean;\n auditLog?: boolean;\n tags?: Record<string, string>;\n}\n\nexport interface LifecycleOptions {\n onInit?: (ctx: { db?: any; logger?: Logger }) => Promise<void>;\n onDestroy?: () => Promise<void>;\n}\n\nexport interface ServiceOptions<\n TServiceContext extends Record<string, any> = Record<string, any>,\n TDb = any,\n> {\n database?: DatabaseHandle<TDb>;\n context?: (\n baseCtx: BaseContext<TDb> & { user?: unknown },\n ) => Promise<TServiceContext> | TServiceContext;\n auth?: ServiceAuthOptions;\n rateLimit?: RateLimitOptions;\n cache?: CacheOptions;\n resilience?: ResilienceOptions;\n telemetry?: TelemetryOptions;\n lifecycle?: LifecycleOptions;\n}\n\nexport type ActionAccessPolicy = \"public\" | \"authorized\" | \"scoped\";\n\nexport interface ActionSchema {\n name: string;\n /** Present only when this action has a registered HTTP route. */\n method?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n path?: string;\n serviceName?: string;\n /** Owning plugin descriptor name for plugin actions (e.g. `@brickkit/crud`). */\n plugin?: string;\n /** Owning resource name for resource-plugin actions (e.g. `page`). */\n resource?: string;\n description?: string;\n inputSchema?: unknown;\n outputSchema?: unknown;\n hasAuthorize: boolean;\n hasScope?: boolean;\n accessPolicy?: ActionAccessPolicy;\n errors?: Record<string, ActionErrorDefinition>;\n emits?: string[];\n tags?: string[];\n}\n\nexport interface ServiceSchema {\n name: string;\n /** The service options as JSON: functions, such as `context` and hooks, are left out. */\n options: Record<string, unknown>;\n hasDatabase: boolean;\n databaseConfig?: {\n name?: string;\n engine: \"sqlite\" | \"postgres\";\n tables: string[];\n };\n actions: ActionSchema[];\n /** MCP tools. A tool with an HTTP route is also listed under `actions`. */\n tools?: { name: string }[];\n resources?: { name: string }[];\n}\n\nexport interface ArchitectureSchema {\n version: string;\n services: ServiceSchema[];\n /** Present when the app has an `events` option. */\n events?: EventsDefinition;\n}\n\nexport interface CompiledRoutePlan {\n service: Service<any, any>;\n action: Action<any, any, any, any>;\n actionName: string;\n serviceName: string;\n routePath: string;\n method?: string;\n isGetLike: boolean;\n hasInput: boolean;\n hasContextHook: boolean;\n contextHook?: (baseCtx: any) => Promise<any> | any;\n hasAuthorize: boolean;\n authorize?: (params: any) => boolean | Promise<boolean>;\n execute: (params: any) => Promise<any> | any;\n inputChecker?: {\n Check: (val: any) => boolean;\n Errors: (val: any) => Iterable<any>;\n };\n outputChecker?: {\n Check: (val: any) => boolean;\n Errors: (val: any) => Iterable<any>;\n };\n coercions?: Array<{\n key: string;\n isNumber: boolean;\n isBoolean: boolean;\n isArray?: boolean;\n }>;\n logger: Logger;\n errorBuilder: any;\n cachedDb: any;\n}\n\nexport interface Service<\n TDb = BunSQLiteDatabase<Record<string, unknown>>,\n TServiceContext extends Record<string, any> = Record<string, any>,\n> {\n readonly name: string;\n readonly options: ServiceOptions<TServiceContext, TDb>;\n readonly actions: Map<string, Action<any, any, any, any>>;\n readonly tools: Map<string, Tool<any, any, any, any>>;\n readonly tables: Map<string, any>;\n readonly resources: Map<\n string,\n Resource<any, BaseContext<TDb> & TServiceContext>\n >;\n readonly db?: TDb;\n readonly isBuilt?: boolean;\n\n use<A>(plugin: ServicePlugin<this, A>): A;\n\n build(): this;\n\n action<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n action: Action<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>,\n ): this;\n\n action<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n config: ActionConfigWithAuthorize<\n TIn,\n TOut,\n TErr,\n BaseContext<TDb> & TServiceContext\n >,\n ): Action<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>;\n\n action<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n config: ActionConfigWithoutAuthorize<\n TIn,\n TOut,\n TErr,\n BaseContext<TDb> & TServiceContext\n >,\n ): Action<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>;\n\n tool<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n action: Tool<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>,\n ): this;\n\n tool<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n config: ToolConfigWithAuthorize<\n TIn,\n TOut,\n TErr,\n BaseContext<TDb> & TServiceContext\n >,\n ): Tool<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>;\n\n tool<\n TIn extends TSchema | undefined = undefined,\n TOut extends TSchema | undefined = undefined,\n TErr extends Record<string, ActionErrorDefinition> = Record<\n string,\n ActionErrorDefinition\n >,\n >(\n config: ToolConfigWithoutAuthorize<\n TIn,\n TOut,\n TErr,\n BaseContext<TDb> & TServiceContext\n >,\n ): Tool<TIn, TOut, TErr, BaseContext<TDb> & TServiceContext>;\n\n resource<\n TTable = any,\n const TOptions extends ResourceTypeOptions = ResourceTypeOptions,\n >(\n config: ResourceConfig<TTable, BaseContext<TDb> & TServiceContext> &\n TOptions &\n Record<Exclude<keyof TOptions, keyof ResourceConfig>, never>,\n ): Resource<\n TTable,\n BaseContext<TDb> & TServiceContext,\n ResourceIdentity<TTable, TOptions>\n >;\n\n readonly preparations: Map<string, PreparationContribution>;\n contributePreparation(contribution: PreparationContribution): void;\n listPreparations(): PreparationContribution[];\n prepareContributions(): void;\n registerTable(table: any): this;\n getAction(name: string): Action<any, any, any, any> | undefined;\n listActions(): Action<any, any, any, any>[];\n getTool(name: string): Tool<any, any, any, any> | undefined;\n listTools(): Tool<any, any, any, any>[];\n getResource(\n name: string,\n ): Resource<any, BaseContext<TDb> & TServiceContext> | undefined;\n listResources(): Resource<any, BaseContext<TDb> & TServiceContext>[];\n getDb(): TDb | undefined;\n setDb(database: DatabaseHandle<TDb>): void;\n /** The outbox table of this service's database, if it holds one (see `outboxTable`). */\n getOutbox?(): OutboxTable | undefined;\n /** What a write needs to record events. Set by `brick({ events })`; absent otherwise. */\n readonly events?: ServiceEvents;\n setEvents?(events: ServiceEvents | undefined): void;\n resolveContext(\n callCtx?: Partial<BaseContext<TDb> & TServiceContext>,\n ): Promise<BaseContext<TDb> & TServiceContext>;\n introspect(): ServiceSchema;\n}\n\nexport interface ProxyOptions {\n isMonolith?: boolean;\n /** Name of the service creating this proxy. Populates ctx.caller on the target's envelope. */\n from?: string;\n context?: Partial<ActionContext>;\n}\n","import type { Static, TSchema } from \"@sinclair/typebox\";\nimport type { Action, ActionErrorDefinition } from \"./types\";\nimport { ActionExecutionError, ValidationError } from \"./types\";\n\n/**\n * Eden/tRPC-style typed HTTP client inferred from Brick-TS application contracts.\n *\n * The frontend imports only the contract *type* — never a backend implementation:\n *\n * ```ts\n * import { createBrickClient } from \"@brickkit/core/client\";\n * import type { AppServer } from \"./server\"; // `import type`: erased at build\n *\n * const api = createBrickClient<AppServer>({ baseUrl: \"http://localhost:4000\" });\n * const pages = await api.page.list({ limit: 10, sort: \"-createdAt\" });\n * const created = await api.page.create({ title: \"Hello\", content: \"World\" });\n * ```\n *\n * Build the contract from individually-typed actions (each `defineAction` call\n * preserves its input/output/error literal types):\n *\n * ```ts\n * // server.ts (backend)\n * export const listPages = pagesService.action({ name: \"page.list\", ... });\n * export const createPage = pagesService.action({ name: \"page.create\", ... });\n * export const contract = { page: { list: listPages, create: createPage } };\n * export type AppServer = typeof contract;\n * ```\n *\n * ## Result / error convention\n *\n * The client uses a throw-based convention that mirrors local `action.execute`\n * semantics, because TypeScript promises cannot encode thrown exception types:\n *\n * - Success → the promise resolves with the action output.\n * - Declared domain failures (your `errors: { SLUG_EXISTS: ... }`) and framework\n * guards (UNAUTHORIZED/FORBIDDEN/NOT_FOUND/...) → rejected with\n * {@link ActionExecutionError} carrying the declared `code`, `status`,\n * `message`, and `details`. Narrow with `instanceof` and read `err.code`.\n * - Input/output validation failures → rejected with {@link ValidationError},\n * exactly as local execution throws.\n * - Network failures, unparsable bodies, and non-OK responses outside the\n * declared contract → {@link BrickTransportError} (4xx) or\n * {@link BrickServerError} (5xx).\n * - Cancellation via `AbortSignal` → the native `AbortError` propagates\n * unwrapped so `err.name === \"AbortError\"` keeps working.\n *\n * ## URL mapping\n *\n * A client path is a namespace walk ending in an action call. The leaf segment\n * decides the route, matching the server compiler (`packages/cli/src/compiler`):\n *\n * | Client call | HTTP request |\n * |---|---|\n * Generated browser contracts carry each action's HTTP method and path,\n * including plugin routes and consumer overrides. Without runtime metadata,\n * callers use `POST /api/<service>/<action>` with dotted action names.\n * GET/DELETE input is serialized as a query string; other methods send JSON.\n\n */\n\nexport interface BrickClientOptions {\n /** Server origin, e.g. `\"http://localhost:4000\"`. No trailing slash required. */\n baseUrl: string;\n /**\n * Route prefix the server was mounted with (default `\"/api\"`).\n * Must match the `prefix` passed to `brick({ prefix })`.\n */\n prefix?: string;\n /**\n * Default headers sent with every call (e.g. an `Authorization` bearer).\n * A thunk is re-evaluated per call, so rotated tokens stay fresh.\n */\n headers?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n /** `fetch` implementation. Defaults to `globalThis.fetch`. */\n fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;\n /** Default signal applied to every call (per-call `signal` wins). */\n signal?: AbortSignal;\n /** Default per-call timeout in milliseconds (per-call `timeoutMs` wins). */\n timeoutMs?: number;\n /**\n * Browser-safe route metadata generated by the Brick Vite plugin.\n * Required for custom methods/paths and plugin routes. Without a contract,\n * calls use POST and service/action names inferred from namespace keys.\n */\n contract?: Record<string, any>;\n}\n\n/** Browser-safe action metadata generated by the Brick Vite plugin. */\nexport interface BrickClientAction<\n TInput = unknown,\n TOutput = unknown,\n TErrors = {},\n> {\n kind: \"action\";\n name: string;\n serviceName: string;\n /** Owning plugin descriptor name for plugin actions (e.g. `@brickkit/crud`). */\n plugin?: string;\n /** Owning resource name for resource-plugin actions (e.g. `page`). */\n resource?: string;\n config: { path: string; method: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\" };\n /** Type information only; never emitted at runtime. */\n readonly __types?: { input: TInput; output: TOutput; errors: TErrors };\n}\n\nexport interface BrickCallOptions {\n /** Extra headers merged over the client defaults for this call only. */\n headers?: Record<string, string>;\n /** Abort signal for this call only. Never wrapped: aborts reject with `AbortError`. */\n signal?: AbortSignal;\n /** Per-call timeout in milliseconds. Implemented with `AbortSignal.timeout`. */\n timeoutMs?: number;\n}\n\n/**\n * The request never received a meaningful server answer: DNS / connection\n * failure, a malformed body, or a 4xx response outside the declared contract\n * (no `code` and no `ValidationError` shape).\n */\nexport class BrickTransportError extends Error {\n readonly kind = \"transport\" as const;\n readonly status?: number;\n readonly url: string;\n readonly body?: unknown;\n override readonly cause?: unknown;\n\n constructor(\n message: string,\n opts: { status?: number; url: string; body?: unknown; cause?: unknown },\n ) {\n super(message);\n this.name = \"BrickTransportError\";\n this.status = opts.status;\n this.url = opts.url;\n this.body = opts.body;\n this.cause = opts.cause;\n }\n}\n\n/**\n * The server answered 5xx without a declared `code` / `ValidationError` shape,\n * i.e. an unexpected failure rather than a modelled domain error.\n */\nexport class BrickServerError extends Error {\n readonly kind = \"server\" as const;\n readonly status: number;\n readonly url: string;\n readonly body: unknown;\n\n constructor(\n message: string,\n opts: { status: number; url: string; body: unknown },\n ) {\n super(message);\n this.name = \"BrickServerError\";\n this.status = opts.status;\n this.url = opts.url;\n this.body = opts.body;\n }\n}\n\n/**\n * Whether an error from the typed client is a `BrickTransportError`: the request\n * got no meaningful answer from the server (a network failure, a body that was\n * not JSON, or a 4xx outside the declared contract).\n *\n * @param err - What a client call threw.\n * @returns `true` for a transport error, narrowing its type.\n */\nexport function isBrickTransportError(\n err: unknown,\n): err is BrickTransportError {\n return err instanceof BrickTransportError;\n}\n\n/**\n * Whether an error from the typed client is a `BrickServerError`: the server\n * answered with a 5xx that is not one of the contract's declared errors, and the\n * error carries its `status`, `url`, and `body`.\n *\n * @param err - What a client call threw.\n * @returns `true` for a server error, narrowing its type.\n */\nexport function isBrickServerError(err: unknown): err is BrickServerError {\n return err instanceof BrickServerError;\n}\n\n/** Static input type from the schema, with a fallback for structural actions. */\nexport type InferActionInput<A> =\n A extends BrickClientAction<infer I, any, any>\n ? I\n : A extends {\n config: { input?: infer S extends TSchema };\n }\n ? Static<S>\n : A extends {\n execute(params: { input?: infer I; ctx?: any }): any;\n }\n ? I\n : A extends { run(input?: infer I, ctx?: any): any }\n ? I\n : A extends (params: { input?: infer I; ctx?: any }) => any\n ? I\n : unknown;\n\n/** Resolved output type of an action. */\nexport type InferActionOutput<A> =\n A extends BrickClientAction<any, infer O, any>\n ? O\n : A extends (...args: any[]) => Promise<infer O>\n ? O\n : A extends { execute(params: any): Promise<infer O> }\n ? O\n : unknown;\n\n/** Union of error `code`s declared in an action's `errors` map. */\nexport type InferActionErrorCodes<A> =\n A extends BrickClientAction<any, any, infer E>\n ? Extract<keyof E, string>\n : A extends {\n config: { errors?: infer E };\n }\n ? E extends Record<string, ActionErrorDefinition>\n ? Extract<keyof E, string>\n : never\n : never;\n\n/**\n * The declared failure shape of an action for `catch` narrowing:\n * ```ts\n * try { await api.page.create(input); }\n * catch (err) {\n * if (err instanceof ActionExecutionError) {\n * const code: InferActionErrorCodes<typeof createPage> | \"UNAUTHORIZED\" | ... = err.code;\n * }\n * }\n * ```\n * (Standard framework codes are always possible alongside declared ones.)\n */\nexport type InferActionFailure<A> = ActionExecutionError & {\n code:\n | InferActionErrorCodes<A>\n | \"BAD_REQUEST\"\n | \"UNAUTHORIZED\"\n | \"FORBIDDEN\"\n | \"NOT_FOUND\"\n | \"CONFLICT\"\n | \"INTERNAL_SERVER_ERROR\"\n | \"VALIDATION_FAILED\";\n};\n\n/**\n * Typed caller for one action. Required inputs stay required; actions whose\n * input includes `undefined` (no schema / all-optional) can be called bare.\n */\nexport type BrickActionCaller<A> =\n undefined extends InferActionInput<A>\n ? (\n input?: InferActionInput<A>,\n options?: BrickCallOptions,\n ) => Promise<InferActionOutput<A>>\n : (\n input: InferActionInput<A>,\n options?: BrickCallOptions,\n ) => Promise<InferActionOutput<A>>;\n\n/** Recursively maps action leaves and their namespaces to browser callers. */\nexport type BrickClient<T> = T extends\n | BrickClientAction<any, any, any>\n | Action<any, any, any, any>\n ? BrickActionCaller<T>\n : T extends (...args: any[]) => any\n ? BrickActionCaller<T>\n : T extends object\n ? { [K in keyof T]: BrickClient<T[K]> }\n : T;\n\ninterface ResolvedClientOptions {\n baseUrl: string;\n prefix: string;\n headers?: BrickClientOptions[\"headers\"];\n fetch: NonNullable<BrickClientOptions[\"fetch\"]>;\n signal?: AbortSignal;\n timeoutMs?: number;\n}\n\nfunction normalizeBaseUrl(baseUrl: string): string {\n const trimmed = baseUrl.replace(/\\/+$/, \"\");\n if (!trimmed)\n throw new Error(\"[Brick-TS client] `baseUrl` must not be empty.\");\n return trimmed;\n}\n\nfunction normalizePrefix(prefix: string | undefined): string {\n if (!prefix) return \"/api\";\n const withLeading = prefix.startsWith(\"/\") ? prefix : `/${prefix}`;\n return withLeading.length > 1 ? withLeading.replace(/\\/+$/, \"\") : withLeading;\n}\n\nfunction toQueryString(input: unknown): string {\n if (input == null || typeof input !== \"object\") return \"\";\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(input as Record<string, unknown>)) {\n if (value === undefined || value === null) continue;\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item === undefined || item === null) continue;\n params.append(\n key,\n typeof item === \"object\" ? JSON.stringify(item) : String(item),\n );\n }\n } else if (typeof value === \"object\") {\n params.append(key, JSON.stringify(value));\n } else {\n params.append(key, String(value));\n }\n }\n const qs = params.toString();\n return qs ? `?${qs}` : \"\";\n}\n\ninterface PlannedRequest {\n method: string;\n url: string;\n body: unknown;\n hasBody: boolean;\n}\n\nfunction isActionValue(value: unknown): value is {\n serviceName?: unknown;\n name?: unknown;\n config: Action<any, any, any, any>[\"config\"];\n} & Function {\n return (\n typeof value === \"function\" &&\n !!(value as any).config &&\n typeof (value as any).config.execute === \"function\"\n );\n}\n\nfunction isClientAction(value: unknown): value is BrickClientAction {\n return (\n !!value &&\n typeof value === \"object\" &&\n (value as BrickClientAction).kind === \"action\"\n );\n}\n\nfunction planRequest(\n path: string[],\n /** Runtime contract value at `path`, when the `contract` option is set. */\n target: unknown,\n input: unknown,\n baseUrl: string,\n prefix: string,\n): PlannedRequest {\n if (path.length === 0) {\n throw new Error(\n \"[Brick-TS client] No action selected: call a leaf such as `api.page.list(input)`.\",\n );\n }\n const actionTarget =\n isActionValue(target) || isClientAction(target) ? target : undefined;\n const actionConfig = actionTarget?.config;\n if (path.length < 2) {\n throw new Error(\n `[Brick-TS client] Cannot address '${path.join(\".\")}': custom actions need a service segment, e.g. \\`api.${path[0]}.<action>(input)\\`.`,\n );\n }\n // Exact mode: the runtime contract reveals the bound service/action names,\n // so contract keys can differ from backend names.\n const service =\n typeof actionTarget?.serviceName === \"string\" && actionTarget.serviceName\n ? actionTarget.serviceName\n : path[0]!;\n const action =\n typeof actionTarget?.name === \"string\" && actionTarget.name\n ? actionTarget.name\n : path.slice(1).join(\".\");\n const method = actionConfig?.method ?? \"POST\";\n const configuredPath = actionConfig?.path;\n let actionPath =\n configuredPath ??\n `${prefix}/${encodeURIComponent(service)}/${action.split(\".\").map(encodeURIComponent).join(\".\")}`;\n let remaining = input;\n if (configuredPath !== undefined) {\n if (!configuredPath.startsWith(\"/\")) {\n throw new Error(\"[Brick-TS client] Action paths must start with '/'.\");\n }\n const source = { ...((input ?? {}) as Record<string, unknown>) };\n const record = { ...source };\n actionPath = actionPath.replace(/:([^/]+)/g, (_match, key: string) => {\n const value = Object.hasOwn(source, key) ? source[key] : undefined;\n if (value === undefined || value === null || value === \"\") {\n throw new Error(`[Brick-TS client] Missing path parameter '${key}'.`);\n }\n delete record[key];\n return encodeURIComponent(String(value));\n });\n remaining = input === undefined ? undefined : record;\n }\n const queryOnly = method === \"GET\" || method === \"DELETE\";\n return {\n method,\n url: `${baseUrl}${actionPath}${queryOnly ? toQueryString(remaining) : \"\"}`,\n body: queryOnly ? undefined : remaining,\n hasBody: !queryOnly && remaining !== undefined,\n };\n}\n\nfunction toActionError(status: number, body: unknown, url: string): Error {\n if (body !== null && typeof body === \"object\") {\n const record = body as Record<string, unknown>;\n if (record.name === \"ValidationError\") {\n return new ValidationError(\n typeof record.message === \"string\"\n ? record.message\n : \"Validation failed\",\n Array.isArray(record.errors) ? (record.errors as any) : [],\n typeof record.status === \"number\" ? record.status : status,\n );\n }\n if (typeof record.code === \"string\") {\n return new ActionExecutionError(\n record.code,\n typeof record.message === \"string\" ? record.message : record.code,\n typeof record.status === \"number\" ? record.status : status,\n (record.details ?? undefined) as unknown,\n );\n }\n }\n if (status >= 500) {\n return new BrickServerError(\n `Unexpected server error (status ${status}) for ${url}.`,\n {\n status,\n url,\n body,\n },\n );\n }\n return new BrickTransportError(\n `Request failed with status ${status} for ${url}.`,\n {\n status,\n url,\n body,\n },\n );\n}\n\nasync function dispatch(\n resolved: ResolvedClientOptions,\n path: string[],\n target: unknown,\n input: unknown,\n callOptions: BrickCallOptions | undefined,\n): Promise<unknown> {\n const { method, url, body, hasBody } = planRequest(\n path,\n target,\n input,\n resolved.baseUrl,\n resolved.prefix,\n );\n\n const staticHeaders =\n typeof resolved.headers === \"function\"\n ? await resolved.headers()\n : (resolved.headers ?? {});\n const headers: Record<string, string> = {\n accept: \"application/json\",\n ...staticHeaders,\n ...callOptions?.headers,\n };\n let payload: string | undefined;\n if (hasBody) {\n headers[\"content-type\"] = \"application/json\";\n payload = JSON.stringify(body ?? null);\n }\n\n const timeoutMs = callOptions?.timeoutMs ?? resolved.timeoutMs;\n let timeoutSignal: AbortSignal | undefined;\n if (timeoutMs !== undefined) timeoutSignal = AbortSignal.timeout(timeoutMs);\n const signals = [\n callOptions?.signal ?? resolved.signal,\n timeoutSignal,\n ].filter((value): value is AbortSignal => value !== undefined);\n const signal = signals.length > 1 ? AbortSignal.any(signals) : signals[0];\n\n // Called detached: a browser's `fetch` throws \"Illegal invocation\" when `this` is not the window.\n const send = resolved.fetch;\n let response: Response;\n try {\n response = await send(url, {\n method,\n headers,\n body: payload,\n signal,\n });\n } catch (err) {\n if (err instanceof Error && err.name === \"AbortError\") throw err;\n throw new BrickTransportError(\n `Network request failed for ${url}: ${err instanceof Error ? err.message : String(err)}`,\n { url, cause: err },\n );\n }\n\n let parsed: unknown;\n const text = await response.text();\n if (response.headers.get(\"content-type\")?.includes(\"text/plain\")) {\n parsed = text;\n } else if (text) {\n try {\n parsed = JSON.parse(text);\n } catch (err) {\n if (!response.headers.has(\"content-type\")) {\n parsed = text;\n } else {\n throw new BrickTransportError(`Unparsable response body for ${url}.`, {\n status: response.status,\n url,\n cause: err,\n });\n }\n }\n }\n\n if (response.ok) return parsed;\n throw toActionError(response.status, parsed, url);\n}\n\nfunction childNode(node: unknown, prop: string): unknown {\n if (\n node != null &&\n (typeof node === \"object\" || typeof node === \"function\")\n ) {\n return (node as Record<string, unknown>)[prop];\n }\n return undefined;\n}\n\nfunction createNamespace(\n resolved: ResolvedClientOptions,\n path: string[],\n node: unknown,\n): any {\n const callable = async (input?: unknown, options?: BrickCallOptions) =>\n dispatch(resolved, path, node, input, options);\n return new Proxy(callable, {\n get(target, prop, receiver) {\n if (typeof prop !== \"string\") return Reflect.get(target, prop, receiver);\n // Never masquerade as a thenable: awaiting a namespace must not dispatch.\n if (prop === \"then\" || prop === \"catch\" || prop === \"finally\")\n return undefined;\n return createNamespace(resolved, [...path, prop], childNode(node, prop));\n },\n apply(_target, _thisArg, args: unknown[]) {\n const [input, options] = args as [unknown, BrickCallOptions | undefined];\n return dispatch(resolved, path, node, input, options);\n },\n });\n}\n\n/**\n * Create an Eden/tRPC-style typed client for the application contract `TApp`.\n * `TApp` is a type-only parameter: `import type { AppServer }` keeps backend\n * implementations out of the frontend bundle.\n */\nexport function createBrickClient<TApp extends Record<string, any>>(\n options: BrickClientOptions & { contract: TApp },\n): BrickClient<TApp>;\nexport function createBrickClient<TApp extends Record<string, any>>(\n options: BrickClientOptions,\n): BrickClient<TApp>;\nexport function createBrickClient<TApp extends Record<string, any>>(\n options: BrickClientOptions,\n): BrickClient<TApp> {\n if (!options?.baseUrl)\n throw new Error(\n '[Brick-TS client] `baseUrl` is required, e.g. `{ baseUrl: \"http://localhost:4000\" }`.',\n );\n const fetchImpl = options.fetch ?? globalThis.fetch;\n if (typeof fetchImpl !== \"function\") {\n throw new Error(\n \"[Brick-TS client] No `fetch` implementation available: pass `fetch` explicitly.\",\n );\n }\n const resolved: ResolvedClientOptions = {\n baseUrl: normalizeBaseUrl(options.baseUrl),\n prefix: normalizePrefix(options.prefix),\n headers: options.headers,\n fetch: fetchImpl,\n signal: options.signal,\n timeoutMs: options.timeoutMs,\n };\n return createNamespace(resolved, [], options.contract) as BrickClient<TApp>;\n}\n"],"mappings":";AA4EA,IAAa,kBAAb,cAAqC,MAAM;CACzC,OAAgB;CAChB;CACA;CAEA,YACE,SACA,SAAgC,CAAC,GACjC,SAAS,KACT;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,SAAS;CAChB;CAEA,SAAS;EACP,OA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SACmB;CACnB,IAAI,CAAC,SAAS,SACZ,MAAM,IAAI,MACR,yFACF;CACF,MAAM,YAAY,QAAQ,SAAS,WAAW;CAC9C,IAAI,OAAO,cAAc,YACvB,MAAM,IAAI,MACR,iFACF;CAUF,OAAO,gBAAgB;EAPrB,SAAS,iBAAiB,QAAQ,OAAO;EACzC,QAAQ,gBAAgB,QAAQ,MAAM;EACtC,SAAS,QAAQ;EACjB,OAAO;EACP,QAAQ,QAAQ;EAChB,WAAW,QAAQ;CAES,GAAG,CAAC,GAAG,QAAQ,QAAQ;AACvD"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as ToolConfigWithoutAuthorize, A as ErrorBuilder, At as index, B as Resource, Bt as PluginRouteScope, C as ActionSchema, Ct as secret, D as CacheOptions, Dt as blob, E as BaseContext, Et as SQLiteDatabaseConfig, F as NarrowAuthorizedContext, Ft as text, G as ServiceAuthOptions, Gt as ResourcePluginTypes, H as ResourceIdentity, Ht as ResourcePlugin, I as PreparationContribution, It as uniqueIndex, J as StandardErrorMap, Jt as defineResourcePlugin, K as ServiceOptions, Kt as ServicePlugin, L as ProxyOptions, Lt as PluginEndpointContext, M as InferTableRow, Mt as primaryKey, N as LifecycleOptions, Nt as real, O as CompiledRoutePlan, Ot as createSQLiteDatabase, P as Logger, Pt as sqliteTable, Q as ToolConfigWithAuthorize, R as RateLimitOptions, Rt as PluginRouteMethod, S as ActionExecutionError, St as resolveSecrets, T as BaseActionConfig, Tt as BunSQLiteDatabase, U as ResourceTypeOptions, Ut as ResourcePluginAPI, V as ResourceConfig, Vt as PluginRoutes, W as Service, Wt as ResourcePluginContext, X as Tool, Xt as getPluginActionRoute, Y as TelemetryOptions, Yt as defineServicePlugin, Z as ToolAnnotations, Zt as getPluginEndpoints, _ as ActionConfig, _t as envSource, a as BrickClientOptions, at as EnvInput, b as ActionContext, bt as overrideSecrets, c as InferActionErrorCodes, ct as defineDatabase, d as InferActionOutput, dt as PostgresDatabase, et as ToolOptions, f as createBrickClient, ft as PostgresDatabaseConfig, g as ActionAccessPolicy, gt as SecretSource, h as Action, ht as SecretRef, i as BrickClientAction, it as DatabaseHandle, j as InferTableInsert, jt as integer, k as DefaultServiceContext, kt as foreignKey, l as InferActionFailure, lt as isDatabaseHandle, m as isBrickTransportError, mt as SecretOptions, n as BrickCallOptions, nt as ValidationErrorItem, o as BrickServerError, ot as PostgresDefinition, p as isBrickServerError, pt as createPostgresDatabase, q as ServiceSchema, qt as ServicePluginContext, r as BrickClient, rt as DatabaseDefinition, s as BrickTransportError, st as SQLiteDefinition, t as BrickActionCaller, tt as ValidationError, u as InferActionInput, ut as DatabaseAdapter, v as ActionConfigWithAuthorize, vt as listSecrets, w as ArchitectureSchema, wt as BrickSQLiteDatabase, x as ActionErrorDefinition, xt as resetSecrets, y as ActionConfigWithoutAuthorize, yt as overrideSecret, z as ResilienceOptions, zt as PluginRouteRegistrar } from "./chunks/client.js";
1
+ import { $ as ToolConfigWithoutAuthorize, $t as index, A as ErrorBuilder, At as SQLiteDefinition, B as Resource, Bt as envSource, C as ActionSchema, Ct as SQLiteOutboxTable, D as CacheOptions, Dt as DatabaseHandle, E as BaseContext, Et as DatabaseDefinition, F as NarrowAuthorizedContext, Ft as PostgresDatabaseConfig, G as ServiceAuthOptions, Gt as resolveSecrets, H as ResourceIdentity, Ht as overrideSecret, I as PreparationContribution, It as createPostgresDatabase, J as StandardErrorMap, Jt as BunSQLiteDatabase, K as ServiceOptions, Kt as secret, L as ProxyOptions, Lt as SecretOptions, M as InferTableRow, Mt as isDatabaseHandle, N as LifecycleOptions, Nt as DatabaseAdapter, O as CompiledRoutePlan, Ot as EnvInput, P as Logger, Pt as PostgresDatabase, Q as ToolConfigWithAuthorize, Qt as foreignKey, R as RateLimitOptions, Rt as SecretRef, S as ActionExecutionError, St as PostgresOutboxTable, T as BaseActionConfig, Tt as outboxTable, U as ResourceTypeOptions, Ut as overrideSecrets, V as ResourceConfig, Vt as listSecrets, W as Service, Wt as resetSecrets, X as Tool, Xt as blob, Y as TelemetryOptions, Yt as SQLiteDatabaseConfig, Z as ToolAnnotations, Zt as createSQLiteDatabase, _ as ActionConfig, _n as defineResourcePlugin, _t as ServiceEvents, a as BrickClientOptions, an as uniqueIndex, at as stopAllEvents, b as ActionContext, bn as getPluginEndpoints, bt as OutboxStatus, c as InferActionErrorCodes, cn as PluginRouteRegistrar, ct as CrudEventPayload, d as InferActionOutput, dn as ResourcePlugin, dt as EventEnvelope, en as integer, et as ToolOptions, f as createBrickClient, fn as ResourcePluginAPI, ft as EventListener, g as ActionAccessPolicy, gn as ServicePluginContext, gt as EventsWorld, h as Action, hn as ServicePlugin, ht as EventsOptions, i as BrickClientAction, in as text, it as EventsHub, j as InferTableInsert, jt as defineDatabase, k as DefaultServiceContext, kt as PostgresDefinition, l as InferActionFailure, ln as PluginRouteScope, lt as DispatchOptions, m as isBrickTransportError, mn as ResourcePluginTypes, mt as EventWorkflow, n as BrickCallOptions, nn as real, nt as ValidationErrorItem, o as BrickServerError, on as PluginEndpointContext, ot as Dispatcher, p as isBrickServerError, pn as ResourcePluginContext, pt as EventRecorder, q as ServiceSchema, qt as BrickSQLiteDatabase, r as BrickClient, rn as sqliteTable, rt as EventsDefinition, s as BrickTransportError, sn as PluginRouteMethod, st as OutboxCounts, t as BrickActionCaller, tn as primaryKey, tt as ValidationError, u as InferActionInput, un as PluginRoutes, ut as EventDelivery, v as ActionConfigWithAuthorize, vn as defineServicePlugin, vt as WorkflowEvent, w as ArchitectureSchema, wt as isOutboxTable, x as ActionErrorDefinition, xt as OutboxTable, y as ActionConfigWithoutAuthorize, yn as getPluginActionRoute, yt as WorkflowsOptions, z as ResilienceOptions, zt as SecretSource } from "./chunks/client.js";
2
2
  import { SpanKind } from "@opentelemetry/api";
3
3
  import { Static, TSchema, TSchema as TSchema$1, Type } from "@sinclair/typebox";
4
4
  import { TypeCheck } from "@sinclair/typebox/compiler";
@@ -198,7 +198,15 @@ type BrickApp = Elysia<any, any, any, any, any, any, any> & {
198
198
  readonly documentation?: DocumentationOptions;
199
199
  /** What `brick start` serves for monitoring; its `auth` is not enumerable. */
200
200
  readonly dashboard?: DashboardOptions;
201
+ /** The listeners and settings of `events`, as plain data. */
202
+ readonly events?: EventsDefinition;
201
203
  };
204
+ /**
205
+ * The events of this app, when `events` is set: start and stop delivery, drain
206
+ * what is due, and see or retry what is parked. `brick dev` and `brick start`
207
+ * start it for you.
208
+ */
209
+ readonly events?: EventsHub;
202
210
  /** Register a raw endpoint (outside the JSON action mesh). */
203
211
  endpoint(def: EndpointDefinition): void;
204
212
  /**
@@ -361,6 +369,14 @@ interface CreateServerOptions {
361
369
  * `auth`. Setting it turns on `telemetry`. See `DashboardOptions`.
362
370
  */
363
371
  dashboard?: DashboardOptions;
372
+ /**
373
+ * Record events in the same database transaction as the writes that cause them,
374
+ * and deliver them to listeners after the commit. Generated CRUD writes emit
375
+ * `<resource>.create`, `<resource>.update` and `<resource>.delete`. A service
376
+ * records events once its database holds an `outboxTable()`. Reads emit nothing,
377
+ * and an app without this option behaves exactly as before. See `EventsOptions`.
378
+ */
379
+ events?: EventsOptions;
364
380
  }
365
381
  /**
366
382
  * Create the HTTP application: an Elysia app that serves every service's
@@ -541,6 +557,10 @@ export declare class ServiceImpl<TDb = BunSQLiteDatabase<Record<string, unknown>
541
557
  getAction(name: string): Action<any, any, any, any> | undefined;
542
558
  listActions(): Action<any, any, any, any>[];
543
559
  getDb(): TDb | undefined;
560
+ /** What a write needs to record events. Set by `brick({ events })`. */
561
+ events?: ServiceEvents;
562
+ getOutbox(): OutboxTable | undefined;
563
+ setEvents(events: ServiceEvents | undefined): void;
544
564
  setDb(database: DatabaseHandle<TDb>): void;
545
565
  /**
546
566
  * Resolves the complete service execution context once per incoming request.
@@ -711,10 +731,133 @@ export declare function defineResource<TTable = any, TCtx extends ActionContext
711
731
  */
712
732
  export declare function createServiceProxy<T extends Record<string, any>>(serviceName: string, options?: ProxyOptions): T;
713
733
  //#endregion
734
+ //#region src/events/listener.d.ts
735
+ type ListenerConfig<TPayload> = {
736
+ name: string;
737
+ on: string | readonly string[];
738
+ maxAttempts?: number;
739
+ } & ({
740
+ run: (delivery: EventDelivery<TPayload>) => void | Promise<void>;
741
+ workflow?: never;
742
+ } | {
743
+ workflow: EventWorkflow<TPayload>;
744
+ run?: never;
745
+ });
746
+ /**
747
+ * Define a listener: code that runs for each event it listens for, after the write
748
+ * that caused the event has been committed. Pass it to `brick({ events: {
749
+ * listeners } })`.
750
+ *
751
+ * It either runs a handler (`run`) in the process that delivers events, or starts
752
+ * a durable workflow (`workflow`) on the app's `events.world`. Delivery is at
753
+ * least once. A handler that throws is retried later with a growing delay, then
754
+ * parked as dead, so it can run again for the same event: use
755
+ * `delivery.deliveryId` to make its work idempotent. A workflow needs no such
756
+ * care: a delivery starts one run however often it is tried, and the workflow
757
+ * retries its own steps.
758
+ *
759
+ * @param config - `name` (unique; it is part of each delivery's id), `on` (an
760
+ * event name or a list of them; a trailing `*` matches a prefix, as in
761
+ * `user.*`), `run` or `workflow`, and optionally `maxAttempts`.
762
+ * @returns The listener.
763
+ * @throws When the name is empty or contains `:`, `on` is empty, or the listener
764
+ * has both or neither of `run` and `workflow`.
765
+ * @example
766
+ * import { brick, defineListener } from "@brickkit/core";
767
+ *
768
+ * const welcome = defineListener({
769
+ * name: "welcome-email",
770
+ * on: "user.create",
771
+ * run: async ({ payload, deliveryId }) => {
772
+ * await mailer.sendWelcome(payload.row.email, { idempotencyKey: deliveryId });
773
+ * },
774
+ * });
775
+ *
776
+ * export default brick({ services, events: { listeners: [welcome] } });
777
+ * @example
778
+ * // src/workflows/onboard.ts
779
+ * export async function onboard(event: WorkflowEvent<CrudEventPayload>) {
780
+ * "use workflow";
781
+ * await sendWelcome(event.payload.row.email);
782
+ * }
783
+ *
784
+ * defineListener({ name: "onboard", on: "user.create", workflow: onboard });
785
+ */
786
+ export declare function defineListener<TPayload = any>(config: ListenerConfig<TPayload>): EventListener<TPayload>;
787
+ //#endregion
788
+ //#region src/events/emit.d.ts
789
+ /**
790
+ * Record an event of your own from an action, a tool or a hook. Listeners get it
791
+ * as they get a generated CRUD event, with the payload you give.
792
+ *
793
+ * By default the event is committed in a transaction of its own. Pass the `tx`
794
+ * of a transaction you have open to commit it with your writes instead: then it
795
+ * is delivered at the dispatcher's next poll, because Brick does not see your
796
+ * commit. Nothing is recorded when no listener wants the event.
797
+ *
798
+ * @param ctx - The action context: its `db` finds the service's outbox, and its
799
+ * `traceId` follows the event to its listeners.
800
+ * @param name - The event name, such as `order.refunded`.
801
+ * @param payload - JSON data for the listeners.
802
+ * @param options - `tx`: an open transaction on the service's database. `source`:
803
+ * what emitted it, shown to listeners.
804
+ * @throws When the context's database has no outbox table, or the app has no
805
+ * `events`.
806
+ * @example
807
+ * refund: service.action({
808
+ * name: "refund",
809
+ * execute: async ({ ctx, input }) => {
810
+ * await ctx.db.update(orders).set({ status: "refunded" }).where(eq(orders.id, input.id));
811
+ * await emitEvent(ctx, "order.refunded", { id: input.id });
812
+ * },
813
+ * });
814
+ */
815
+ export declare function emitEvent(ctx: {
816
+ db?: unknown;
817
+ traceId?: string;
818
+ }, name: string, payload: unknown, options?: {
819
+ tx?: unknown;
820
+ source?: string;
821
+ }): Promise<void>;
822
+ //#endregion
823
+ //#region src/events/transaction.d.ts
824
+ /**
825
+ * Run `fn` in a database transaction: everything it writes through the `tx` it is
826
+ * given is committed together when it returns, or undone if it throws.
827
+ *
828
+ * Postgres uses a real transaction on one connection. SQLite has one connection
829
+ * and a synchronous driver, which Drizzle's own `transaction` cannot use with an
830
+ * async callback (it would commit before the callback finished). So transactions
831
+ * on one SQLite database take turns, each between `BEGIN IMMEDIATE` and `COMMIT`.
832
+ * A write made elsewhere in the process during that time, outside this helper,
833
+ * would join the transaction; use Postgres where that matters.
834
+ *
835
+ * @param db - A Drizzle database, from `service.getDb()`.
836
+ * @param fn - Receives the transaction handle to run queries on.
837
+ * @returns What `fn` returned.
838
+ * @throws What `fn` threw, after rolling back.
839
+ */
840
+ export declare function runInTransaction<T>(db: any, fn: (tx: any) => Promise<T>): Promise<T>;
841
+ //#endregion
842
+ //#region src/events/workflows.d.ts
843
+ /**
844
+ * Where the workflow bundle is read from, and the project it is built from.
845
+ *
846
+ * @param options - The `events.workflows` option.
847
+ * @returns Absolute `root` and `dir`. The bundle cannot live elsewhere: the
848
+ * builder finds the SDK from where it writes, and skips only this directory when it
849
+ * looks for workflows.
850
+ */
851
+ export declare function resolveWorkflowPaths(options?: WorkflowsOptions): {
852
+ root: string;
853
+ dir: string;
854
+ };
855
+ //#endregion
714
856
  //#region src/registry.d.ts
715
857
  interface ArchitectureApplication {
716
858
  services: readonly Service[];
717
859
  routes: readonly RouteIR[];
860
+ events?: EventsDefinition;
718
861
  }
719
862
  export declare class ServiceRegistry {
720
863
  private _revision;
@@ -899,5 +1042,5 @@ type ErrorContext = {
899
1042
  */
900
1043
  export declare function toErrorResponse(err: unknown, context: ErrorContext): ErrorEnvelope;
901
1044
  //#endregion
902
- export { Action, type ActionAccessInfo, ActionAccessPolicy, ActionConfig, ActionConfigWithAuthorize, ActionConfigWithoutAuthorize, ActionContext, ActionErrorDefinition, ActionExecutionError, ActionSchema, type ApiDocument, ArchitectureSchema, BaseActionConfig, BaseContext, type BrickActionCaller, type BrickApp, type BrickCallOptions, type BrickClient, type BrickClientAction, type BrickClientOptions, type BrickIR, BrickSQLiteDatabase, BrickServerError, BrickTransportError, type BunSQLiteDatabase, CacheOptions, type CompiledApplication, type CompiledHandler, type CompiledRoute, CompiledRoutePlan, type CreateServerOptions, type DashboardAuth, type DashboardOptions, DatabaseAdapter, DatabaseDefinition, DatabaseHandle, DefaultServiceContext, type DocumentationOptions, type EndpointContext, type EndpointDefinition, type EndpointLogger, type EndpointMethod, EnvInput, ErrorBuilder, type ErrorEnvelope, type HandlerFactory, type InferActionErrorCodes, type InferActionFailure, type InferActionInput, type InferActionOutput, InferTableInsert, InferTableRow, LifecycleOptions, Logger, type McpHandlerOptions, type McpRegistry, type McpRegistryOptions, type McpToolDefinition, NarrowAuthorizedContext, type OpenApiDocument, type OpenApiGeneratorOptions, type PluginEndpointContext, type PluginRouteMethod, type PluginRouteRegistrar, type PluginRouteScope, type PluginRoutes, PostgresDatabase, PostgresDatabaseConfig, PostgresDefinition, PreparationContribution, ProxyOptions, RateLimitOptions, type ReferenceDocument, type ReferenceOptions, type RequestLoggingOptions, ResilienceOptions, Resource, ResourceConfig, ResourceIdentity, type ResourcePlugin, type ResourcePluginAPI, type ResourcePluginContext, type ResourcePluginTypes, ResourceTypeOptions, type RouteIR, type RouteMethod, SQLiteDatabaseConfig, SQLiteDefinition, type SecretOptions, SecretRef, type SecretSource, Service, ServiceAuthOptions, ServiceOptions, type ServicePlugin, type ServicePluginContext, ServiceSchema, StandardErrorMap, type Static, type TSchema, Table, TelemetryOptions, Tool, ToolAnnotations, ToolConfigWithAuthorize, ToolConfigWithoutAuthorize, ToolOptions, Type, Type as t, ValidationError, ValidationErrorItem, and, asc, blob, createBrickClient, createPostgresDatabase, createSQLiteDatabase, defineDatabase, defineResourcePlugin, defineServicePlugin, desc, envSource, eq, foreignKey, getPluginActionRoute, getPluginEndpoints, getTableColumns, getTableName, gt, gte, ilike, inArray, index, integer, is, isBrickServerError, isBrickTransportError, isDatabaseHandle, isNotNull, isNull, like, listSecrets, lt, lte, ne, not, notInArray, or, overrideSecret, overrideSecrets, primaryKey, real, relations, resetSecrets, resolveSecrets, secret, sql, sqliteTable, text, uniqueIndex };
1045
+ export { Action, type ActionAccessInfo, ActionAccessPolicy, ActionConfig, ActionConfigWithAuthorize, ActionConfigWithoutAuthorize, ActionContext, ActionErrorDefinition, ActionExecutionError, ActionSchema, type ApiDocument, ArchitectureSchema, BaseActionConfig, BaseContext, type BrickActionCaller, type BrickApp, type BrickCallOptions, type BrickClient, type BrickClientAction, type BrickClientOptions, type BrickIR, BrickSQLiteDatabase, BrickServerError, BrickTransportError, type BunSQLiteDatabase, CacheOptions, type CompiledApplication, type CompiledHandler, type CompiledRoute, CompiledRoutePlan, type CreateServerOptions, type CrudEventPayload, type DashboardAuth, type DashboardOptions, DatabaseAdapter, DatabaseDefinition, DatabaseHandle, DefaultServiceContext, type DispatchOptions, Dispatcher, type DocumentationOptions, type EndpointContext, type EndpointDefinition, type EndpointLogger, type EndpointMethod, EnvInput, ErrorBuilder, type ErrorEnvelope, type EventDelivery, type EventEnvelope, type EventListener, type EventRecorder, type EventWorkflow, type EventsDefinition, EventsHub, type EventsOptions, type EventsWorld, type HandlerFactory, type InferActionErrorCodes, type InferActionFailure, type InferActionInput, type InferActionOutput, InferTableInsert, InferTableRow, LifecycleOptions, Logger, type McpHandlerOptions, type McpRegistry, type McpRegistryOptions, type McpToolDefinition, NarrowAuthorizedContext, type OpenApiDocument, type OpenApiGeneratorOptions, type OutboxCounts, type OutboxStatus, type OutboxTable, type PluginEndpointContext, type PluginRouteMethod, type PluginRouteRegistrar, type PluginRouteScope, type PluginRoutes, PostgresDatabase, PostgresDatabaseConfig, PostgresDefinition, type PostgresOutboxTable, PreparationContribution, ProxyOptions, RateLimitOptions, type ReferenceDocument, type ReferenceOptions, type RequestLoggingOptions, ResilienceOptions, Resource, ResourceConfig, ResourceIdentity, type ResourcePlugin, type ResourcePluginAPI, type ResourcePluginContext, type ResourcePluginTypes, ResourceTypeOptions, type RouteIR, type RouteMethod, SQLiteDatabaseConfig, SQLiteDefinition, type SQLiteOutboxTable, type SecretOptions, SecretRef, type SecretSource, Service, ServiceAuthOptions, type ServiceEvents, ServiceOptions, type ServicePlugin, type ServicePluginContext, ServiceSchema, StandardErrorMap, type Static, type TSchema, Table, TelemetryOptions, Tool, ToolAnnotations, ToolConfigWithAuthorize, ToolConfigWithoutAuthorize, ToolOptions, Type, Type as t, ValidationError, ValidationErrorItem, type WorkflowEvent, type WorkflowsOptions, and, asc, blob, createBrickClient, createPostgresDatabase, createSQLiteDatabase, defineDatabase, defineResourcePlugin, defineServicePlugin, desc, envSource, eq, foreignKey, getPluginActionRoute, getPluginEndpoints, getTableColumns, getTableName, gt, gte, ilike, inArray, index, integer, is, isBrickServerError, isBrickTransportError, isDatabaseHandle, isNotNull, isNull, isOutboxTable, like, listSecrets, lt, lte, ne, not, notInArray, or, outboxTable, overrideSecret, overrideSecrets, primaryKey, real, relations, resetSecrets, resolveSecrets, secret, sql, sqliteTable, stopAllEvents, text, uniqueIndex };
903
1046
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["_$__0.ErrorEnvelope","_$__endpoints0.BrickApp","TSchema","TSchema","TSchema"],"sources":["../src/compiler/ir.ts","../src/docs.ts","../src/dashboard.ts","../src/endpoints.ts","../src/compiler/runtime.ts","../src/compiler.ts","../src/request-logger.ts","../src/action-handler.ts","../src/server.ts","../src/app-entry.ts","../src/telemetry.ts","../src/compiler/emit.ts","../src/db/index.ts","../src/service.ts","../src/access.ts","../src/action.ts","../src/resource.ts","../src/rpc.ts","../src/registry.ts","../src/typebox.ts","../src/openapi.ts","../src/tool.ts","../src/mcp.ts","../src/error-response.ts"],"mappings":";;;;;;;KAGY;UACK;WACN,QAAQ;WACR;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;aACE;aACA;;;WAGF;WACA;;UAEM;WACN;WACA;WACA;WACA;WACA,iBAAiB;WACjB;IACP;IACA;IACA;;WAEO;;;;;KC/BC,kBAAkB;;UAGb;;EAEf;;EAEA,UACI,yBACO,kBAAkB,QAAQ;;;UAItB;EACf;EACA,UAAU;;;UAIK;;;;;EAKf;;;;;;;EAOA;;UAGe;;EAEf;EACA;EACA;;EAEA,YAAY;;;wBAIE,eAAe,iBAAiB;;wBAwBhC,gBAAgB,OAAM,mBAAwB;;wBAa9C,uBACd,KAAK,QACL,OAAM,mBACL;;wBAKa,gBAAgB,iBAAiB;;;;UC3FhC;;;;;;;;EAQf;;;;;;;;;;;;;EAaA,aACE,SAAS,sBACI,WAAW,kBAAkB;;;;;;;;;;;;UAa7B;;EAEf;;;;;;EAMA;EACA,O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ACxB,YAAA;;;wBAOE,kBAAkB,SAAS,qBAAqB;UAsC/C;EACf,UAAU;EACV;IAAc;IAAc;IAAiB;;;EAE7C;;;wBAcc,iBAAiB,SAAS,qBAKtC,SAAS,SACT,MAAM,QAAQ,mBACb,QAAQ;;;UC5FI;EACf;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;KAGN;EAAiB,QAAQ,KAAK;EAAkB;;;;;;;;;;;;;wBAgCrC,gBACd,cACA,SAAS,eACR"}
1
+ {"version":3,"file":"index.d.ts","names":["_$__0.ErrorEnvelope","_$__endpoints0.BrickApp","TSchema","TSchema","TSchema"],"sources":["../src/compiler/ir.ts","../src/docs.ts","../src/dashboard.ts","../src/endpoints.ts","../src/compiler/runtime.ts","../src/compiler.ts","../src/request-logger.ts","../src/action-handler.ts","../src/server.ts","../src/app-entry.ts","../src/telemetry.ts","../src/compiler/emit.ts","../src/db/index.ts","../src/service.ts","../src/access.ts","../src/action.ts","../src/resource.ts","../src/rpc.ts","../src/events/listener.ts","../src/events/emit.ts","../src/events/transaction.ts","../src/events/workflows.ts","../src/registry.ts","../src/typebox.ts","../src/openapi.ts","../src/tool.ts","../src/mcp.ts","../src/error-response.ts"],"mappings":";;;;;;;KAGY;UACK;WACN,QAAQ;WACR;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;aACE;aACA;;;WAGF;WACA;;UAEM;WACN;WACA;WACA;WACA;WACA,iBAAiB;WACjB;IACP;IACA;IACA;;WAEO;;;;;KC/BC,kBAAkB;;UAGb;;EAEf;;EAEA,UACI,yBACO,kBAAkB,QAAQ;;;UAItB;EACf;EACA,UAAU;;;UAIK;;;;;EAKf;;;;;;;EAOA;;UAGe;;EAEf;EACA;EACA;;EAEA,YAAY;;;wBAIE,eAAe,iBAAiB;;wBAwBhC,gBAAgB,OAAM,mBAAwB;;wBAa9C,uBACd,KAAK,QACL,OAAM,mBACL;;wBAKa,gBAAgB,iBAAiB;;;;UC3FhC;;;;;;;;EAQf;;;;;;;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