Share via


@azure/api-management-custom-widgets-tools package

Interfaces

EditorData

JSON object with all the data you'll receive from the Dev Portal

PortalData

Information about the widget instance received from the Dev Portal

Type Aliases

DeployConfig

Optional options object for configuring the deployment function.

Environment

All possible runtime environments

OnChange

Type of the onChange function.

Secrets

Secrets needed for communication with Dev Portal back-end and other runtime data

ServiceInformation

resourceId - resource ID of API Management service "subscriptions/[subscription-id]/resourceGroups/[resource-group-name]/providers/Microsoft.ApiManagement/service/[service-name]" managementApiEndpoint - URL with protocol (e.g. https://management.azure.com) apiVersion - optional to override default (e.g. "2019-01-01") tokenOverride - optional, provides token to use for auth, instead of 'az login' approach

TargetModule

Possible target modules "app" for main application which is embedded in your Dev Portal "editor" for form in admin panel

ValuesCommon

Base of a values obj

Functions

askForSecrets(TargetModule)

Request secrets - token & userId, from the Dev portal parent window.

buildBlobConfigPath(string)

Generate relative path for widgets' config on the blob storage

buildBlobDataPath(string)

Generate relative path for widgets' data on the blob storage

buildOnChange<Values>()

Build onChange function, which you can use, to send changed data from the editor.

deployNodeJS(ServiceInformation, string, string, DeployConfig)

Deploys everything from /dist folder to the API Management DevPortals' blob storage.

getEditorValues<Values>()

Function to get values you've set in the admin editor window.

getValues<Values>(Values)

Function to get values you've set in the admin editor window. Undefined/empty values are replaced with default values.

getWidgetData<Values>()

Function to get all data related to the widget including technical values not expected to be needed in most cases. Intended mostly for internal use, API might change. Consider using getValues or getEditorValues instead.

onChangeWithOrigin<Values>(string, string, Values)

The onChange function itself with 'origin' provided as a param.

Function Details

askForSecrets(TargetModule)

Request secrets - token & userId, from the Dev portal parent window.

function askForSecrets(targetModule: TargetModule): Promise<Secrets>

Parameters

targetModule
TargetModule

is the function invoke from the main "app" window or the admin "editor"?

Returns

Promise<Secrets>

buildBlobConfigPath(string)

Generate relative path for widgets' config on the blob storage

function buildBlobConfigPath(name: string): string

Parameters

name

string

name of the widget

Returns

string

buildBlobDataPath(string)

Generate relative path for widgets' data on the blob storage

function buildBlobDataPath(name: string): string

Parameters

name

string

name of the widget

Returns

string

buildOnChange<Values>()

Build onChange function, which you can use, to send changed data from the editor.

function buildOnChange<Values>(): OnChange<Values>

Returns

OnChange<Values>

deployNodeJS(ServiceInformation, string, string, DeployConfig)

Deploys everything from /dist folder to the API Management DevPortals' blob storage.

function deployNodeJS(serviceInformation: ServiceInformation, name: string, fallbackConfigPath?: string, config?: DeployConfig): Promise<void>

Parameters

serviceInformation
ServiceInformation

service information for deployment

name

string

name of the widget to be deployed

fallbackConfigPath

string

local path to the config file (by default "./static/config.msapim.json")

config
DeployConfig

optional config object

Returns

Promise<void>

getEditorValues<Values>()

Function to get values you've set in the admin editor window.

function getEditorValues<Values>(): Partial<Values>

Returns

Partial<Values>

getValues<Values>(Values)

Function to get values you've set in the admin editor window. Undefined/empty values are replaced with default values.

function getValues<Values>(valuesDefault: Values): Values

Parameters

valuesDefault

Values

object with your default values to use, just import valuesDefault object from values.ts folder

Returns

Values

getWidgetData<Values>()

Function to get all data related to the widget including technical values not expected to be needed in most cases. Intended mostly for internal use, API might change. Consider using getValues or getEditorValues instead.

function getWidgetData<Values>(): EditorData<Values>

Returns

EditorData<Values>

onChangeWithOrigin<Values>(string, string, Values)

The onChange function itself with 'origin' provided as a param.

function onChangeWithOrigin<Values>(origin: string, instanceId: string, values: Values)

Parameters

origin

string

web content's origin (URL) of your Dev Portal to send changes to

instanceId

string

ID of this particular instance of the widget

values

Values

values that changed