Module: nmodule/export/rc/Transformer

API Status: Development

Transform one object into another type.


<abstract> new (require("nmodule/export/rc/Transformer"))()

Methods


getDefaultConfig(transformedObject)

When invoking a transform operation using the Export Dialog, options can
be provided by the user to configure how the transform is performed.

If this transformer should provide user-configurable options, override
this function to provide them in the form of a Component. This
Component will be shown to the user in a Property Sheet for
configuration.

Parameters:
Name Type Description
transformedObject *

the transform object can be used to help
decide values on default config.

See:
Returns:
Type
baja.Component | Promise.<(baja.Component|undefined)> | undefined
Example

Provide a config option for 'prettyPrint' that uses a custom display name.

getDefaultConfig() {
  var comp = baja.$('baja:Component');
  comp.add({
    slot: 'prettyPrint',
    value: true,
    cx: { displayName: 'Pretty Print' }
  });
  return comp;
}

<abstract> getDisplayName()

Returns:

the display name of this transformer

Type
string

getExportContextObject(config)

When the user invokes the transform, the Component as edited by the
user will need to be converted to a context object to be used in the
transform() method. This function provides a hook to perform extra
processing during that conversion.

By default, will return a simple mapping of the Component's slot names
to their values.

Parameters:
Name Type Description
config baja.Component | object

the config component as edited by the user

Returns:

the context object

Type
object | Promise.<object>

<abstract> getFileExtension()

Returns:

the default file extension to use when saving the data produced by this transformer

Type
string

<abstract> getIcon()

Returns:

the icon for this transformer

Type
string

<abstract> getMimeType()

Returns:

the mime type for the data produced by this transformer

Type
string

isSupplier()

By default, all Transformers supply data to an ExportDestinationType.

If there is nothing to supply to a destination, then return false and
this will instruct the UI to show no ExportDestinationTypes.

See:
Returns:
Type
boolean

<abstract> transform(object [, cx])

Transform an object into another type of data.

Parameters:
Name Type Argument Description
object *

the object to be transformed

cx object <optional>

transform context containing options as configured by the user

Returns:

to be resolved with the transformed data

Type
Promise.<*> | *