Extending Umbraco Deploy in v17

Heya :waving_hand:
I am reading the docs for extending deploy over here

But when trying the ITransferEntityService.RegisterTransferEntityType() method it seems that it has changed and been made simpler, to only give it the alias of the UDI/entity type string and the options, but it no longer has the other parameters that seem to help tie the entity to a given tree.

So in V17 how do we do this now?

Current Docs

// Snippet from docs article above 
_transferEntityService.RegisterTransferEntityType(
    "mypackage-example",
    "Examples",
    new DeployRegisteredEntityTypeDetailOptions
    {
        SupportsQueueForTransfer = true,
        SupportsQueueForTransferOfDescendents = true,
        SupportsRestore = true,
        PermittedToRestore = true,
        SupportsPartialRestore = true,
    },
    false,
    "exampleTreeAlias",
    (string routePath, HttpContext httpContext) => true,
    (string nodeId, HttpContext httpContext) => true,
    (string nodeId, HttpContext httpContext, out Guid entityId) => Guid.TryParse(nodeId, out entityId),
    new DeployRegisteredEntityTypeDetail.RemoteTreeDetail(FormsTreeHelper.GetExampleTree, "example", "externalExampleTree"),
    entitiesGetter: () => _exampleDataService.Get());

Current method

transferEntityService.RegisterTransferEntityType("mypackage-example", new DeployRegisteredEntityTypeDetailOptions
{
    SupportsQueueForTransfer = true,
    SupportsQueueForTransferOfDescendents = true,
    SupportsRestore = true,
    PermittedToRestore = true,
    SupportsPartialRestore = true,
    SupportsImportExport = true,
});

Question

So how does Umbraco Deploy know about the tree item to add the UI options to?

After some digging about and looking at an Umbraco Cloud site that lists out Umbraco Forms Deploy extensions in the Extensions Insights section of the backoffice, in conjuction with my little utility package Manifest Peek I am able to see the shape of the JSON for these manifests.

Example

import { SEOTOOLKIT_ROBOTSTXT_ENTITY } from "../Constants";

export const Manifests = [
    {
        name: "SeoToolkit Deploy Queue Entity Action Registrar",
        alias: "SeoToolkit.Deploy.Queue.Registrar",
        type: "deployEntityActionRegistrar",
        actionAlias: "Deploy.EntityAction.Queue",
        forEntityTypes: [
            {
                entityTypes: [SEOTOOLKIT_ROBOTSTXT_ENTITY],
            },
        ],
    },
    {
        name: "SeoToolkit Deploy Partial Restore Entity Action Registrar",
        alias: "SeoToolkit.Deploy.PartialRestore.Registrar",
        type: "deployEntityActionRegistrar",
        actionAlias: "Deploy.EntityAction.PartialRestore",
        forEntityTypes: [
            {
                entityTypes: [SEOTOOLKIT_ROBOTSTXT_ENTITY],
            },
        ],
    },
    {
        name: "SeoToolkit Deploy Partial Restore Entity Action Registrar",
        alias: "SeoToolkit.Deploy.PartialRestore.Registrar",
        type: "deployEntityActionRegistrar",
        actionAlias: "Deploy.EntityAction.TreeRestore",
        forEntityTypes: [
            {
                entityTypes: [SEOTOOLKIT_ROBOTSTXT_ENTITY],
            },
        ],
    }
];

Solution

  • Register a deployEntityActionRegistrar manifest
  • For ActionAlias property use one of these values:
    • Deploy.EntityAction.Queue
    • Deploy.EntityAction.PartialRestore
    • Forms.Deploy.TreeRestore.Registrar
  • Unfortunately no TypeScript type definitions published to NPM atm
  • Set one or more items in the forEntityTypes array
    • This is the same string for the entity type used in a manifest for a treeItem

Hi Warren! Deploy has moved quite a few things from server-side registrations to client-side manifests in recent versions. This allowed us to clean up some of the server-side registration methods, so you basically only have to register the entity-type as schema using IDiskEntityService.RegisterDiskEntityType(string entityType)or as content usingITransferEntityService.RegisterTransferEntityType(string entityType, DeployRegisteredEntityTypeDetailOptions options, TryParseUdiRangeFromNodeIdDelegate? tryParseUdiRangeFromNodeId = null, DeployTransferRegisteredEntityTypeDetail.RemoteTreeDetail? remoteTree = null), besides implementing theIServiceConnector(as per documentation).

This registration however doesn’t automatically show the Deploy operations in custom entity trees (assuming you use entity-actions). For this, you can use thedeployEntityActionRegistrarmanifest. In cases where the entity type differs between the client and server, you can usedeployEntityTypeMappingto map them. Have a look at the Umbraco.Commerce.Deploy code (Umbraco.Commerce.Deploy/src/Umbraco.Commerce.Deploy/wwwroot/umbraco-commerce-deploy.js at main · umbraco/Umbraco.Commerce.Deploy · GitHub) and Umbraco.Forms.Deploy (https://nuget.info/packages/Umbraco.Forms.Deploy/17.0.0) for inspiration!

1 Like