Hierarchy (view full)

Constructors

Properties

baseDocument: JsonDocumentLike
contributions: Map<string, JsonDocumentLike>
latestOutput: undefined | JsonDocumentLike
onDidRebuild: PlatformEvent<undefined>

Event that emits to announce that the document has been rebuilt and the output has been updated

options: DocumentCombinerOptions
settingTypeName: string

Name for type of setting to use in error messages

Methods

  • Add or update one of the contribution documents for the composition process

    Note: the order in which contribution documents are added can be considered indeterminate as it depends on the order in which Map.forEach iterates over the contributions. However, the order matters when merging two arrays into one. Also, when options.ignoreDuplicateProperties is is true, the order also matters when adding the same property to an object that is already provided previously. Please let us know if you have trouble because of indeterminate contribution ordering.

    Parameters

    • documentName: string

      Name of the contributed document to combine

    • document: JsonDocumentLike

      Content of the contributed document to combine

    Returns undefined | JsonDocumentLike

    Recalculated output document given the new or updated contribution and existing other documents

  • Delete all present contribution documents for the composition process and return to the base document

    Returns undefined | JsonDocumentLike

    Recalculated output document consisting only of the base document

  • Delete one of the contribution documents for the composition process

    Parameters

    • documentName: string

      Name of the contributed document to delete

    Returns undefined | JsonDocumentLike

    Recalculated output document given the remaining other documents

  • This method is intended to be layered over by a child class to expose the localized setting info.

    Get the current set of settings contribution info given all the input documents with all localized string keys localized properly.

    NOTE: If the input documents might have changed since the last time the settings contributions were retrieved, you can call rebuild to incorporate those document changes before calling this getter. For example, if one of the input document objects changed and addOrUpdateContribution wasn't called explicitly, those document changes will not be seen in the current set of settings contributions. If all the input documents are static, then there is no need to ever rebuild once all the documents have been contributed to this combiner.

    Returns Promise<undefined | {
        contributions: {};
        settings: {
            platform.commentsEnabled: undefined | {
                default: boolean;
                derivesFrom?: string;
                description?: string;
                label: string;
                platformType?: undefined;
                type?: undefined;
            };
            platform.interfaceLanguage: undefined | {
                default: string[];
                derivesFrom?: string;
                description?: string;
                label: string;
                platformType?: undefined;
                type?: undefined;
            };
            platform.paratextDataLastRegistryDataCachedTimes: undefined | {
                default: {};
                derivesFrom?: string;
                description?: string;
                label: string;
                platformType?: undefined;
                type?: undefined;
            };
            platform.ptxUtilsMementoData: undefined | {
                default: {};
                derivesFrom?: string;
                description?: string;
                label: string;
                platformType?: undefined;
                type?: undefined;
            };
            platform.verseRef: undefined | {
                default: {
                    bookNum: number;
                    chapterNum: number;
                    verseNum: number;
                };
                derivesFrom?: string;
                description?: string;
                label: string;
                platformType?: undefined;
                type?: undefined;
            };
        };
    }>

  • Validate the base and contribution documents against the JSON schema

    Parameters

    • document: JsonDocumentLike
    • docType: string

    Returns void

  • Run the document composition process given the starting document and all contributions. Throws if the output document fails to validate properly.

    Returns undefined | JsonDocumentLike

    Recalculated output document given the starting and contributed documents

  • Transform the starting document that is given to the combiner. This transformation occurs after validating the base document and before combining any contributions.

    WARNING: If you do not create the combiner with option copyDocuments: true or clone inside this method, this method will directly modify the baseDocument passed in.

    Parameters

    • baseDocument: JsonDocumentLike

      Initial input document. Already validated via validateBaseDocument

    Returns JsonDocumentLike

    Transformed base document

  • Transform the contributed document associated with documentName. This transformation occurs after validating the contributed document and before combining with other documents.

    WARNING: If you do not create the combiner with option copyDocuments: true or clone inside this method, this method will directly modify the contributed document passed in.

    Parameters

    • documentName: string

      Name of the contributed document to combine

    • document: JsonDocumentLike

      Content of the contributed document to combine. Already validated via validateContribution

    Returns JsonDocumentLike

    Transformed contributed document

  • Transform the document that is the composition of the base document and all contribution documents. This is the last step that will be run prior to validation via validateOutput before this.latestOutput is updated to the new output.

    Parameters

    • finalOutput: JsonDocumentLike

      Final output document that could potentially be returned to callers. "Final" means no further contribution documents will be merged.

    Returns JsonDocumentLike

  • Update the starting document for composition process

    Parameters

    • baseDocument: JsonDocumentLike

      Base JSON document/JS object that all other documents are added to

    Returns undefined | JsonDocumentLike

    Recalculated output document given the new starting state and existing other documents

  • Throw an error if the provided document is not a valid starting document.

    Parameters

    • baseDocument: JsonDocumentLike

      Base JSON document/JS object that all other documents are added to

    Returns void

  • Throw an error if the provided document is not a valid contribution document.

    Parameters

    • documentName: string

      Name of the contributed document to combine

    • document: JsonDocumentLike

      Content of the contributed document to combine

    Returns void

  • Throw an error if the provided output is not valid.

    Returns void