Pipelines used in the JSS code-first import process

Version: 22.x

The import process uses a series of pipelines in the javaScriptServices group that create templates, layouts, media, and content items based on the data in the JSS Manifest file.

Pipelines are configured in \App_Config\Sitecore\JavaScriptServices\Sitecore.JavaScriptServices.AppServices.config. To make any adjustments to the pipelines, use a configuration patch.

The following diagram shows the sequence of pipelines used in the import process:

Import process sequence of pipelines

The import process uses the following pipelines:

Pipeline

Description

import

The primary pipeline for the import process. It initializes the context for the import, creates template and layout items, and triggers the creation of content item pipelines.

create.item

Finds or creates a content item.

update.item

Populates or updates field values on a content item, triggers the update of item layout.

import.field

Imports the value of a field on a content item.

create.media

Creates a media item from an asset associated with the manifest.

import.layout

Populates the layout of an imported item.

create.renderingInstance

Creates a rendering instance for use in imported item layout.

Pipeline processors

Each pipeline leverages processors to perform tasks. Processors described as creating items first attempt to look for an existing item of the same name and, if it already exists, update it. All processors creating or writing items check item:create and item:write permissions appropriately and skip those actions if permissions do not allow them.

import

The namespace for this pipeline is Sitecore.JavaScriptServices.AppServices.Pipelines.Import.

This pipeline uses the datasourceStrategy value defined in the app configuration to determine the allowed datasource locations for any created renderings.

Processor

Description

EnableSecurity

Ensures that security permissions are enforced. Needed for execution within contexts where security is normally disabled, such as an update package post-step.

SwitchUser

Switches the user context to the configured import user.

SwitchSite

Sitecore content Workflow can be enabled on a per-site basis. This mock site ensures that content workflow executes during the import process.

SwitchDatabases

Switches the database context to the configured import database.

SwitchLanguage

Switches the language context to the configured import language.

SwitchBulkUpdateContext

If import indexing optimization is enabled, enters a BulkUpdateContext.

VerifyAppConfiguration

Ensures the app has all required attributes and that configured item paths on the app exist. Populates values on args.Items.

Deserialize

Deserializes import JSON into import data model classes.

WipePreviousImport

If full wipe mode is enabled, the process attempts to delete any existing items in the import paths configured on the app.

CreateTemplatesContainer

Creates the parent item for imported templates.

CreateRouteTemplate

Creates an app-specific template for route items.

CreateAppContainer

Creates the root item for app routes and data items. Grants the import user item:create access on the created item and assigns the generated route template as an insert option.

CreatePlaceholdersContainer

Creates the parent item for imported placeholder settings.

CreateRenderingsContainer

Creates the parent item for imported renderings. Assigns the JSS rendering types as insert options.

CreateMediaLibraryContainer

Creates the parent item for imported media items.

ProcessTemplates

Creates all templates in the manifest with their specified fields. It also creates their standard values and sets the configured workflow as the default workflow.

ProcessPlaceholders

Creates settings items for all placeholders in the manifest and the root placeholders in the app configuration.

ProcessRenderings

Creates rendering items for all renderings in the manifest. Uses the configured datasource strategy to set the appropriate datasource location(s) for the rendering with a datasource template. Configures rendering placeholders based on data in the manifest.

AddPlaceholderAllowedControls

If allowed controls analysis is enabled, all imported placeholder settings are updated with allowed controls based on rendering usage within the imported routes.

CreateLayout

Creates a main layout item for the app. Configures its placeholders based on the root placeholders in the app configuration.

SetRouteLayoutStandardValue

Populates the layout in the standard values of the generated route template with the generated layout item.

SetRouteTemplateInheritance

If the import manifest defines any custom route templates, it sets their base template to the app-specific route template generated above.

ProcessItems

Creates all route and nonroute items in the manifest using the create.item pipeline.

ProtectDeveloperItems

If developer item protection is enabled, the process applies the read-only/protected flag to imported template and layout/rendering items.

RefreshIndexes

If import indexing optimization is enabled, the process refreshes indexes on all the root/parent import items utilizing IndexCustodian.RefreshTree.

Note

All the Switch* processors set up IDisposable context switchers. All the IDisposable context switchers are disposed of outside the pipeline itself, in the ImportPipeline service.

create.item

The namespace for this pipeline is Sitecore.JavaScriptServices.AppServices.Pipelines.CreateItem.

Processor

Description

ResolveItemName

Determines the name of the item to be found/created based on the itemNamer provided in the pipeline arguments.

CheckPermissions

Checks whether the item already exists based on the item name. If not, checks if permissions exist to create the item. If not, aborts the pipeline.

ResolveTemplate

Determines the template that is used to create a new item, if necessary.

AddItem

Creates the item if it does not already exist.

UpdateItemValues

Invokes the update.item pipeline to set item values.

CreateChildItems

Re-invokes the create.item pipeline again for each child of the item found in the manifest.

update.item

The namespace for this pipeline is Sitecore.JavaScriptServices.AppServices.Pipelines.UpdateItem.

Processor

Description

CheckPermissions

Checks whether permissions exist to write to the item. If not, aborts the pipeline.

SetDisplayName

Sets the item display name based on the display namer function/callback provided in the pipeline arguments.

SetFieldValues

Sets field values on the item by invoking the import.field pipeline for each field in the item manifest.

AssignInsertOptions

If indicated in pipeline args, sets the item's insert options to the item's own template.

ImportLayout

Invokes the import.layout pipeline to update the item's layout/presentation.

import.field

The namespace for this pipeline is Sitecore.JavaScriptServices.AppServices.Pipelines.ImportField.

Processor

Description

ResolveField

Finds the field on the item by the name specified in the JSON field model. Aborts the pipeline if not found.

LinkFieldValue

If the field is one of the configured link field types, it invokes the create.item pipeline to create the linked items, then populates the field with pipe-delimited IDs and aborts the pipeline.

MediaFieldValue

If the field is one of the configured image field types, it invokes the create.media pipeline to create the media item, it populates the field with the media ID and aborts the pipeline.

DefaultFieldValue

Populates the field with the raw/literal value from the JSON field model and aborts the pipeline.

create.media

The namespace for this pipeline is Sitecore.JavaScriptServices.AppServices.Pipelines.CreateMedia.

Processor

Description

CalculateItemPath

Determines the appropriate location in the media library based on the configured app media library path and the path of the asset in the import manifest.

CheckPermissions

Checks if the media item already exists and whether write permission is allowed on the item. If not, the existing item is returned, and the pipeline is aborted.

CalculateFilePath

Maps the filesystem path of the asset based on the path of the import package and the asset path in the manifest. If the file does not exist at the calculated path, the pipeline is aborted.

BuildMediaCreatorOptions

Creates the Sitecore.Resources.Media.MediaCreatorOptions object used for importing the media.

CreateFromFile

Invokes a Sitecore.Resources.Media.MediaCreator to import the media file into the media library.

import.layout

The namespace for this pipeline is Sitecore.JavaScriptServices.AppServices.Pipelines.ImportLayout.

Processor

Description

CheckForLayout

Checks if the imported item manifest has any renderings defined. Aborts the pipeline if not.

InitializeLayout

Creates a new LayoutDefinition and initializes the main layout on the configured device.

AddRenderings

Invokes the create.renderingInstance pipeline for each rendering defined in the item manifest and adds the renderings to the configured device.

SaveLayout

Sets the layout XML on the item's Shared Layout, using LayoutField to ensure that the layout delta calculation is performed. If the processor is configured to do so, resets/clears the Final Layout field on the item (ClearFinalLayout).

create.renderingInstance

The namespace for this pipeline is Sitecore.JavaScriptServices.AppServices.Pipelines.CreateRenderingInstance.

This pipeline uses the datasourceStrategy value defined in the app configuration to determine the allowed datasource locations for any created renderings.

Processor

Description

ResolveRenderingItem

Finds the imported rendering definition item for the rendering instance. Aborts the pipeline if not found.

CreateRenderingInstance

Creates a new RenderingDefinition and populates its rendering ID, placeholder, UID, rendering parameters, and other properties.

CheckForDatasourceFields

Checks whether the rendering manifest has any datasource fields. Aborts the pipeline if not.

CreateDatasourceItem

Uses the configured datasource strategy to create/determine the parent item for the rendering datasource, then invokes the create.item pipeline to create or find the datasource item. Updates the rendering with the datasource ID.

Do you have some feedback for us?

If you have suggestions for improving this article,