({
className,
parentClassName = 'Domain',
summary = [],
commands,
events,
runtimeByTsName,
enumConstants,
})
| 1119 | } |
| 1120 | |
| 1121 | function generateClass({ |
| 1122 | className, |
| 1123 | parentClassName = 'Domain', |
| 1124 | summary = [], |
| 1125 | commands, |
| 1126 | events, |
| 1127 | runtimeByTsName, |
| 1128 | enumConstants, |
| 1129 | }) { |
| 1130 | const lines = [] |
| 1131 | |
| 1132 | const doc = INTERNAL_API_DOC.split('\n') |
| 1133 | if (summary.length) doc.splice(1, 0, ...summary.map((line) => ` * ${line}`), ' *') |
| 1134 | lines.push(doc.join('\n')) |
| 1135 | lines.push(`export class ${className} extends ${parentClassName} {`) |
| 1136 | |
| 1137 | for (const evt of events) { |
| 1138 | lines.push('') |
| 1139 | lines.push(generateEventDescriptor(evt, runtimeByTsName)) |
| 1140 | } |
| 1141 | |
| 1142 | for (const { propertyName, values } of enumConstants) { |
| 1143 | lines.push('') |
| 1144 | lines.push(` static readonly ${propertyName} = ${generateEnumConstantLiteral(values)}`) |
| 1145 | } |
| 1146 | |
| 1147 | lines.push('') |
| 1148 | lines.push(` static async create(driver: unknown): Promise<${className}> {`) |
| 1149 | lines.push(` return new ${className}(await Domain.connect(driver), DOMAIN_TOKEN)`) |
| 1150 | lines.push(` }`) |
| 1151 | |
| 1152 | for (const cmd of commands) { |
| 1153 | lines.push('') |
| 1154 | lines.push(generateCommandMethod(cmd, runtimeByTsName)) |
| 1155 | } |
| 1156 | |
| 1157 | lines.push(`}`) |
| 1158 | return lines.join('\n') |
| 1159 | } |
| 1160 | |
| 1161 | // A static EventDescriptor<T> constant — no subscribe/dispatch method. Callers |
| 1162 | // reach events via the inherited addCallback(descriptor, handler), never a |
no test coverage detected