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

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