/** * Utility type to convert SNAKE_CASE to PascalCase. */ type SnakeToPascalCase = S extends `${infer Head}_${infer Tail}` ? `${Capitalize>}${SnakeToPascalCase}` : Capitalize>; /** * A contract that defines the fields and methods of a context service. */ export type DeriveContextServiceContract, TParams extends Partial> = TFields> = TFields & UpdateContextMethods; /** * Generates update methods based on fields. * Each field will have an update method with the name update{FieldName} and a single parameter of the field type. */ export type UpdateContextMethods> = T> = { [K in keyof T as K extends string ? `update${SnakeToPascalCase}` : never]: (value: TParams[K]) => void; }; export {};