mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 15:36:33 +00:00
9de8490176
The lines this branch adds used em and en dashes as sentence punctuation across comments, JSDoc, CSS comments and test titles. Each one is rewritten with a comma, a colon, parentheses or a second sentence, keeping what the sentence said. Only lines this branch adds are touched; everything that already exists on dev stays as it is. No logic, error code or logged message changes. The only string literals affected are describe and it titles, which now read "X: topic" like the rest of the provider tests.
29 lines
1011 B
TypeScript
29 lines
1011 B
TypeScript
import { Inject, Injectable } from '@nestjs/common';
|
|
import { DOCUMENT_PROVIDERS, type DocumentProvider } from './document-provider';
|
|
|
|
/**
|
|
* The one dispatch site for document providers.
|
|
*
|
|
* Same shape as PhotoProviderRegistry, and for the same reason: adding a
|
|
* backend is registering an adapter in the module, not editing a switch that
|
|
* exists in four places. Whether a registered provider is switched ON is a
|
|
* different question, answered by the `document_providers` table plus the
|
|
* `documents` addon. This only knows what the server can talk to at all.
|
|
*/
|
|
@Injectable()
|
|
export class DocumentProviderRegistry {
|
|
private readonly byId: Map<string, DocumentProvider>;
|
|
|
|
constructor(@Inject(DOCUMENT_PROVIDERS) providers: readonly DocumentProvider[]) {
|
|
this.byId = new Map(providers.map((p) => [p.id, p]));
|
|
}
|
|
|
|
get(id: string | null | undefined): DocumentProvider | undefined {
|
|
return id ? this.byId.get(id) : undefined;
|
|
}
|
|
|
|
ids(): string[] {
|
|
return [...this.byId.keys()];
|
|
}
|
|
}
|