({
className,
parentClassName = 'Domain',
summary = [],
commands,
events,
runtimeByTsName,
enumConstants,
})
| 1189 | } |
| 1190 | |
| 1191 | function generateClass({ |
| 1192 | className, |
| 1193 | parentClassName = 'Domain', |
| 1194 | summary = [], |
| 1195 | commands, |
| 1196 | events, |
| 1197 | runtimeByTsName, |
| 1198 | enumConstants, |
| 1199 | }) { |
| 1200 | const lines = [] |
| 1201 | |
| 1202 | const doc = INTERNAL_API_DOC.split('\n') |
| 1203 | if (summary.length) doc.splice(1, 0, ...summary.map((line) => ` * ${line}`), ' *') |
| 1204 | lines.push(doc.join('\n')) |
| 1205 | lines.push(`export class ${className} extends ${parentClassName} {`) |
| 1206 | |
| 1207 | for (const evt of events) { |
| 1208 | lines.push('') |
| 1209 | lines.push(generateEventDescriptor(evt, runtimeByTsName)) |
| 1210 | } |
| 1211 | |
| 1212 | for (const { propertyName, values } of enumConstants) { |
| 1213 | lines.push('') |
| 1214 | lines.push(` static readonly ${propertyName} = ${generateEnumConstantLiteral(values)}`) |
| 1215 | } |
| 1216 | |
| 1217 | lines.push('') |
| 1218 | lines.push(` static async create(driver: unknown): Promise<${className}> {`) |
| 1219 | lines.push(` return new ${className}(await Domain.connect(driver), DOMAIN_TOKEN)`) |
| 1220 | lines.push(` }`) |
| 1221 | |
| 1222 | for (const cmd of commands) { |
| 1223 | lines.push('') |
| 1224 | lines.push(generateCommandMethod(cmd, runtimeByTsName)) |
| 1225 | } |
| 1226 | |
| 1227 | lines.push(`}`) |
| 1228 | return lines.join('\n') |
| 1229 | } |
| 1230 | |
| 1231 | // A static EventDescriptor<T> constant — no subscribe/dispatch method. Callers |
| 1232 | // reach events via the inherited addCallback(descriptor, handler), never a |
no test coverage detected