|
126 | 126 | */ |
127 | 127 |
|
128 | 128 | /** |
129 | | - * @typedef {object} datasource |
| 129 | + * @typedef datasourceConfig |
| 130 | + * @property {import('./datasource').default} datasource |
130 | 131 | * @property {string} url - physical storage location: e.g. database url, file path |
131 | | - * @property {function()} adapterFactory - factory function to construct datasource adapter |
132 | | - * @property {string} baseClass - name of base class to extend |
| 132 | + * @property {function({DataSource}):DataSourcelw4l} adapterFactory - factory function to construct datasource adapter |
| 133 | + * @property {string} baseClass - name owkllllllllllllllf base class to extend |
133 | 134 | * @property {number} [cacheSize] - maxium number of cached instances before purging |
134 | 135 | * @property {number} [cacheSizeKb] - maximum size in kilobytes of cached instances before cache purge |
135 | 136 | * @property {boolean} [cachedWrite] - allow cached instances of an object to write to persistent storage |
136 | | - * @property {()=>[]} list |
137 | | - * @property {(id)=>{}} find |
138 | | - * @property {(id,data)=>data} save |
139 | | - * @property {import('.').ports} factory |
140 | 137 | */ |
141 | 138 |
|
142 | 139 | /** |
|
173 | 170 | * URL parameter or query of the auto-generated REST API |
174 | 171 | * @property {accessControlList} [accessControlList] - configure authorization |
175 | 172 | * @property {number} [start] - create `start` instances of the model |
176 | | - * @property {datasource} [datasource] - define custom datasource |
| 173 | + * @property {datasourceConfig} [datasource] - define custom datasource |
177 | 174 | * @property {Array<{ [method:string]: function(), path: string }>} [routes] - custom routes |
178 | 175 | */ |
179 | 176 |
|
@@ -431,6 +428,24 @@ export async function importRemoteCache (name) { |
431 | 428 | } |
432 | 429 | } |
433 | 430 |
|
| 431 | +/** |
| 432 | + * The total number of domains deployed to a host. |
| 433 | + * A domain consists of one or more models. |
| 434 | + * Each model represents a domain unless it specifies |
| 435 | + * the name of another model in `ModelSpecification.domain`, |
| 436 | + * in which case it is a subdomain within the bounded context |
| 437 | + * of that domain or simply a supporting entity. Such models |
| 438 | + * run in the same threadpool and share the same storage |
| 439 | + * namespace (e.g. collections or tables in the same database) |
| 440 | + * |
| 441 | + * |
| 442 | + * @returns {number} sum of domains deployed to host |
| 443 | + */ |
| 444 | +export const totalDomains = () => |
| 445 | + ModelFactory.getModelSpecs().filter( |
| 446 | + s => !s.isCached && (!s.domain || s.modelName === s.domain) |
| 447 | + ).length |
| 448 | + |
434 | 449 | export { UseCaseService } from './use-cases' |
435 | 450 |
|
436 | 451 | export { default as EventBrokerFactory } from './event-broker' |
|
0 commit comments