Configurable Operations

Configurable Operations

LocalizedStringArray

An array of string values in a given LanguageCode, used to define human-readable string values.

Example

const title: LocalizedStringArray = [
  { languageCode: LanguageCode.en, value: 'English Title' },
  { languageCode: LanguageCode.de, value: 'German Title' },
  { languageCode: LanguageCode.zh, value: 'Chinese Title' },
]

Signature

type LocalizedStringArray = Array<Omit<LocalizedString, '__typename'>>

ConfigArgs

A object which defines the configurable arguments which may be passed to functions in those classes which implement the ConfigurableOperationDef interface.

Example

{
  operator: {
    type: 'string',
    config: {
      options: [
        { value: 'startsWith' },
        { value: 'endsWith' },
        { value: 'contains' },
        { value: 'doesNotContain' },
      ],
    },
  },
  term: { type: 'string' },
}

Signature

type ConfigArgs<T extends ConfigArgType> = {
  [name: string]: ConfigArgDef<T>;
}

Members

[index]

property
type:
ConfigArgDef<T>

ConfigurableOperationDefOptions

Common configuration options used when creating a new instance of a ConfigurableOperationDef.

Signature

interface ConfigurableOperationDefOptions<T extends ConfigArgs<ConfigArgType>> extends InjectableStrategy {
  code: string;
  args: T;
  description: LocalizedStringArray;
}

Extends

Members

code

property
type:
string
A unique code used to identify this operation.

args

property
type:
T

Optional provider-specific arguments which, when specified, are editable in the admin-ui. For example, args could be used to store an API key for a payment provider service.

Example

args: {
  apiKey: { type: 'string' },
}

See ConfigArgs for available configuration options.

description

property
A human-readable description for the operation method.

ConfigurableOperationDef

Defines a ConfigurableOperation, which is a method which can be configured by the Administrator via the Admin API.

Signature

class ConfigurableOperationDef<T extends ConfigArgs<ConfigArgType>> {
  code: string
  args: T
  description: LocalizedStringArray
  constructor(options: ConfigurableOperationDefOptions<T>)
  async init(injector: Injector) => ;
  async destroy() => ;
}

Members

code

property
type:
string

args

property
type:
T

description

property

constructor

method
type:
(options: ConfigurableOperationDefOptions<T>) => ConfigurableOperationDef

init

async method
type:
(injector: Injector) =>

destroy

async method
type:
() =>

ConfigArgType

Certain entities (those which implement ConfigurableOperationDef) allow arbitrary configuration arguments to be specified which can then be set in the admin-ui and used in the business logic of the app. These are the valid data types of such arguments. The data type influences:

  1. How the argument form field is rendered in the admin-ui
  2. The JavaScript type into which the value is coerced before being passed to the business logic.

Signature

type ConfigArgType = 'string' | 'int' | 'float' | 'boolean' | 'datetime' | 'facetValueIds'