Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ContentGraph

Utility to assist parsing and generating Content Item graphs.

Hierarchy

  • ContentGraph

Index

Methods

Static deepCopy

  • deepCopy(ids: string[], contentItemProvider: (id: string) => Promise<ContentItem>, contentItemPicker: (original: ContentItem, body: any) => Promise<ContentItem>): Promise<any>
  • Utility to help deeply copy a content graph. Each content item and its dependencies are visited using the contentItemProvider function to load the source item. The contentItemPicker is invoked for every Content Item giving your application an opportunity to either save the item to a new location (copy) or return the original (reference).

    The JSON body provided to the contentItemPicker function will have had any Content Links remapped to the newly saved Content Item.

    const targetRepository = await client.contentRepositories.get('5b32377b4cedfd01c4503691');
    const contentIds = ['a87fd535-fb25-44ee-b687-0db72bbab721'];
    
    const idMap = await ContentGraph.deepCopy(
     contentIds,
     client.contentItems.get,
     function(item:ContentItem, body:any) {
         return targetRepository.related.contentItems.create(new ContentItem({
           label: item.label,
           body: body
         }));
       }
    );

    Parameters

    • ids: string[]

      Ids of the root content items to copy

    • contentItemProvider: (id: string) => Promise<ContentItem>

      Function that loads content items by id

    • contentItemPicker: (original: ContentItem, body: any) => Promise<ContentItem>

      Function that creates or returns an existing content item that should be used in place of the original

    Returns Promise<any>

    Mapping of old content item ids to the newly created ids

Static extractLinks

Generated using TypeDoc