file-system-engine-host-base.d.ts 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.dev/license
  7. */
  8. import { BaseException } from '@angular-devkit/core';
  9. import { Observable } from 'rxjs';
  10. import { Url } from 'url';
  11. import { RuleFactory, Source, TaskExecutor, TaskExecutorFactory } from '../src';
  12. import { FileSystemCollectionDesc, FileSystemEngineHost, FileSystemSchematicContext, FileSystemSchematicDesc, FileSystemSchematicDescription } from './description';
  13. export declare type OptionTransform<T extends object | null, R extends object> = (schematic: FileSystemSchematicDescription, options: T, context?: FileSystemSchematicContext) => Observable<R> | PromiseLike<R> | R;
  14. export declare type ContextTransform = (context: FileSystemSchematicContext) => FileSystemSchematicContext;
  15. export declare class CollectionCannotBeResolvedException extends BaseException {
  16. constructor(name: string);
  17. }
  18. export declare class InvalidCollectionJsonException extends BaseException {
  19. constructor(_name: string, path: string, jsonException?: Error);
  20. }
  21. export declare class SchematicMissingFactoryException extends BaseException {
  22. constructor(name: string);
  23. }
  24. export declare class FactoryCannotBeResolvedException extends BaseException {
  25. constructor(name: string);
  26. }
  27. export declare class CollectionMissingSchematicsMapException extends BaseException {
  28. constructor(name: string);
  29. }
  30. export declare class CollectionMissingFieldsException extends BaseException {
  31. constructor(name: string);
  32. }
  33. export declare class SchematicMissingFieldsException extends BaseException {
  34. constructor(name: string);
  35. }
  36. export declare class SchematicMissingDescriptionException extends BaseException {
  37. constructor(name: string);
  38. }
  39. export declare class SchematicNameCollisionException extends BaseException {
  40. constructor(name: string);
  41. }
  42. /**
  43. * A EngineHost base class that uses the file system to resolve collections. This is the base of
  44. * all other EngineHost provided by the tooling part of the Schematics library.
  45. */
  46. export declare abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
  47. protected abstract _resolveCollectionPath(name: string, requester?: string): string;
  48. protected abstract _resolveReferenceString(name: string, parentPath: string, collectionDescription: FileSystemCollectionDesc): {
  49. ref: RuleFactory<{}>;
  50. path: string;
  51. } | null;
  52. protected abstract _transformCollectionDescription(name: string, desc: Partial<FileSystemCollectionDesc>): FileSystemCollectionDesc;
  53. protected abstract _transformSchematicDescription(name: string, collection: FileSystemCollectionDesc, desc: Partial<FileSystemSchematicDesc>): FileSystemSchematicDesc;
  54. private _transforms;
  55. private _contextTransforms;
  56. private _taskFactories;
  57. listSchematicNames(collection: FileSystemCollectionDesc, includeHidden?: boolean): string[];
  58. registerOptionsTransform<T extends object | null, R extends object>(t: OptionTransform<T, R>): void;
  59. registerContextTransform(t: ContextTransform): void;
  60. /**
  61. *
  62. * @param name
  63. * @return {{path: string}}
  64. */
  65. createCollectionDescription(name: string, requester?: FileSystemCollectionDesc): FileSystemCollectionDesc;
  66. createSchematicDescription(name: string, collection: FileSystemCollectionDesc): FileSystemSchematicDesc | null;
  67. createSourceFromUrl(url: Url): Source | null;
  68. transformOptions<OptionT extends object, ResultT extends object>(schematic: FileSystemSchematicDesc, options: OptionT, context?: FileSystemSchematicContext): Observable<ResultT>;
  69. transformContext(context: FileSystemSchematicContext): FileSystemSchematicContext;
  70. getSchematicRuleFactory<OptionT extends object>(schematic: FileSystemSchematicDesc, _collection: FileSystemCollectionDesc): RuleFactory<OptionT>;
  71. registerTaskExecutor<T>(factory: TaskExecutorFactory<T>, options?: T): void;
  72. createTaskExecutor(name: string): Observable<TaskExecutor>;
  73. hasTaskExecutor(name: string): boolean;
  74. }