import type { CollectionSchemaBase, SchemaBase } from './dsl.js'; import type { FrontAppSchema, ProjectApiSchema } from './project.js'; import type { DtoMessage } from './dto.js'; import type { ExceptionSchema } from './exception.js'; import type { FlowSchema } from './flow.js'; /** A backend service serving one frontend app (1:1 module), or a * platform-shared domain service (app unset — shared across modules). */ export interface ServiceSchema extends CollectionSchemaBase { type: 'service'; /** The backend api module this service belongs to (shared instance from * project.config.ts apis). Services are always backend-side, so storage is * service_schema/{api.name}/{app.name}/service/ — app unset = the api-level * common domain layer, stored at service_schema/{api.name}/common/service/. */ api: ProjectApiSchema; /** The frontend app this service serves (shared instance from project.config). * Unset = api-level common domain service shared by all modules of the api. */ app?: FrontAppSchema; /** Methods keyed by name — the map key is written back as the method name. */ methods: Record; } /** Method input for defineService: type/schema/name are set by the builder. */ export type ServiceMethodDef = Omit; export declare function defineService(options: { name: string; api: ProjectApiSchema; app?: FrontAppSchema; methods: Record; description?: string; }): ServiceSchema; /** A method exposed by a business service — the contract with the calling * frontend. Third-party integration methods are a separate contract * (ThirdServiceMethodSchema): they can never bind a flow. */ export interface ServiceMethodSchema extends SchemaBase { type: 'method'; schema: ServiceSchema; args: DtoMessage; results: DtoMessage; /** Exceptions this method may throw (e.g. IOException, CodeException). */ throws?: ExceptionSchema[]; /** Implementation flow — the method's logic graph. The method carries the * contract (args/results/throws), the flow carries the structure. */ flow?: FlowSchema; }