Implements

Helper

  • Add custom parameter to the query.

    E.g. usage

    apiParams
    // To add `foo=bar` to the query.
    .addCustomParam({foo: 'bar'})
    // To add `foo[bar]=baz` to the query.
    .addCustomParam({ foo: {bar: 'baz'}})
    // To add `bar[0]=a&bar[1]=b&bar[2]=c` to the query.
    .addCustomParam({ bar: ['a', 'b', 'c']})

    Parameters

    • input: ParamBag<any>

      The parameter object

    Returns DrupalJsonApiParams

  • Get query string.

    Parameters

    • Optionaloptions: object

      Options to be passed to qs library during parsing.

    Returns string

Init

  • Initialize with a previously stored query string.

    Parameters

    • input: string

      The Query string to use for initializing.

    • Optionaloptions: object

      Options to be passed to qs library during parsing.

    Returns DrupalJsonApiParams

JSON:API Query

  • Add JSON:API field.

    The name of this method might be miss leading. Use this to explicitely request for specific fields on an entity.

    Parameters

    • type: string

      Resource type

    • fields: string[]

      Array of field names in the given resource type

    Returns this

  • Add JSON:API sort.

    Used to return the list of items in specific order.

    Read more about Sort in Drupal.org Documentation

    Parameters

    • path: string

      A 'path' identifies a field on a resource

    • Optionaldirection: string

      Sort direction ASC or DESC

    Returns this

  • Add JSON:API page limit.

    Use to restrict max amount of items returned in the listing. Using this for pagination is tricky, and make sure you read the following document on Drupal.org to implement it correctly.

    Read more about Pagination in Drupal.org Documentation

    Parameters

    • limit: number

      Number of items to limit to

    Returns this

  • Add JSON:API page offset.

    Use to skip some items from the start of the listing. Using this for pagination is tricky, and make sure you read the following document on Drupal.org to implement it correctly.

    Read more about Pagination in Drupal.org Documentation

    Parameters

    • offset: number

      Number of items to skip from the begining.

    Returns this

  • Add JSON:API group.

    Parameters

    • name: string

      Name of the group

    • conjunction: string = 'OR'

      All groups have conjunctions and a conjunction is either AND or OR.

    • OptionalmemberOf: string

      Name of the group, this group belongs to

    Returns this

  • Add JSON:API filter.

    Following values can be used for the operator. If none is provided, it assumes "=" by default.

      '=', '<>',
    '>', '>=', '<', '<=',
    'STARTS_WITH', 'CONTAINS', 'ENDS_WITH',
    'IN', 'NOT IN',
    'BETWEEN', 'NOT BETWEEN',
    'IS NULL', 'IS NOT NULL'

    NOTE: Make sure you match the value supplied based on the operators used as per the table below

    Value Type Operator Comment
    string =, <>, >, >=, <, <=, STARTS_WITH, CONTAINS, ENDS_WITH
    string[] IN, NOT IN
    string[] size 2 BETWEEN, NOT BETWEEN The first item is used for min (start of the range), and the second item is used for max (end of the range).
    null IS NULL, IS NOT NULL Must use null

    Read more about filter in Drupal.org Documentation

    Parameters

    • path: string

      A 'path' identifies a field on a resource

    • value: null | string | string[]

      string[] | null` | A 'value' is the thing you compare against. For operators like "IN" which supports multiple parameters, you can supply an array.

    • operator: string = '='

      An 'operator' is a method of comparison

    • OptionalmemberOf: string

      Name of the group, the filter belongs to

    • Optionalkey: string

    Returns this

Other

qsOptions: object = {}
  • Generate a unique key name for the given object.

    Parameters

    • obj: any

      The object to generate a key name for.

    • proposedKey: string

      The proposed key name.

    • OptionalenforceKeyName: boolean

      Whether to enforce the key name.

    Returns string

    The generated key name.

  • Generate a unique key name for the given object.

    Parameters

    • obj: any

      The object to generate a key name for.

    • proposedKey: string

      The proposed key name.

    • enforceKeyName: boolean = false

      Whether to enforce the key name.

    Returns string

    The generated key name.