Skip Navigation

Using Workflow Extensions

This is a full guide on how to create, register and run an action for a specific extension point. This sample demonstrates only basic features, it does not show the full power of workflow extensions.

1. Create an implementation of interfaces.

a) SampleExtPointBeforeEndCmd implements BeforeEndCommandExtension. It contains only one method onPnrEndBeforeEndCommand. The logic created here is very simple: based on whether or not the PnrLocator is present, the Flow continues or is aborted.

image

Example implementation of SampleExtPointBeforeEndCmd.ts:

/**
 * This class demonstrates using a web extension point. Extension Point -
 * dynamo.pnr.end:beforeEndCommand.
 */
export class SampleExtPointBeforeEndCmd extends BeforeEndCommandExtension { (1)

    static SERVICE_NAME = 'com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointBeforeEndCmd';

    /**
     * Add sample remark to PNR. Flow is continue.
     *
     * @param rq request object.
     */
    async onPnrEndBeforeEndCommand(rq: CommandMessageEndReservationRq | null): Promise<ExtPointResult> { (2)
        console.log('THIS WEB REDAPP beforeEndCommand');

        await getService(ICommandMessageService).send('5TESTBEFOREFWEBREDAPP');

        return {
            Status: 'CONTINUE'
        }; (3)
    }
}
  1. Implement BeforeEndCommandExtension. It is the interface for the dynamo.pnr.end:beforeEndCommand extension point.

  2. Create a body for the method.

  3. The method has to return ExtPointResult which contains the status. The status informs whether to continue or abort the flow.

b) SampleAfterEndCmd implements AfterEndCommandExtension. It contains only one method - onPnrEndAfterEndCommand.

image

Example implementation of SampleExtPointAfterEndCmd.ts:

/**
 * These class demonstrate how to use the web extension point. Extension Point -
 * dynamo.pnr.end:beforeEndCommand.
 */
export class SampleExtPointAfterEndCmd extends AfterEndCommandExtension { (1)

    static SERVICE_NAME = 'com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointAfterEndCmd';

    /**
     * Add sample remark to session. It doesn't add remark to PNR. Flow is continue.
     *
     * @param rq input.
     */
    async onPnrEndAfterEndCommand(rs: CommandMessageEndReservationRs | null): Promise<ExtPointResult> { (2)
        console.log('THIS WEB REDAPP afterEndCommand');

        await getService(ICommandMessageService).send('5TESTAFTERWEBREDAPP');

        return {
            Status: 'CONTINUE'
        }; (3)
    }
}
  1. Implement AfterEndCommandExtension interface. It is the interface for the dynamo.pnr.end:afterEndCommand extension point.

  2. Create a body for the method.

  3. The method has to return ExtPointResult which contains the status. The status informs whether to continue or abort the flow.

Important
Value of SERVICE_NAME variable defined in the service must match the pattern: web-module-name-service-name

2. Register services.

image

To invoke services you need to register it in the Main class:

export class Main extends Module {

    init(): void {
        super.init();
        registerService(SampleExtPointAfterEndCmd);
        registerService(SampleExtPointBeforeEndCmd);
    }
}

3. Metadata in manifest.json.

image

In the manifest.json file you need to add extension points and services name (binds to specific extension points):

"extensions": { (1)
  "dynamo.pnr.end:beforeEndCommand": [ (2)
    {
      "service": "com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointBeforeEndCmd" (3)
    }
  ],
  "dynamo.pnr.end:afterEndCommand": [
    {
      "service": "com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointAfterEndCmd"
    }
  ]
}
  1. List of extension points. It contains the extension point name and services name.

  2. Extension Point Id.

  3. Service name.

4. Result.

Processing of the above workflow extensions sample is invisible to the user. During services execution remarks have been added to the PNR and the session.

In the beforeEndCommand extension point a remark has been added to the PNR.

image

In the afterEndCommand extension point remark has been added to the session, not to the PNR.

image

Multiple extension points implementations

There is a possibility to define multiple implementations of the same extension point.

For this purpose, in accordance with the above instruction, create and register another service you are interested in. Then add it as a separate object in manifest.json.

"extensions": {
  "dynamo.pnr.end:beforeEndCommand": [
    {
      "service": "com-sabre-redapp-example3-web-wf-extension-web-module-SampleExtPointBeforeEndCmd"
    },
    {
      "service": "com-sabre-redapp-example3-web-wf-extension-web-module-SecondSampleExtPointBeforeEndCmd"
    }
  ]
}

The order in which the services are launched depends on the order of their declarations in the manifest.json file.