sessionAnnotation

sessionAnnotation

Contains constants and functions for a Session Annotation Object.

The structure for a Session Annotation Object is as follows:

{
  payload: <object>,
  namespace: <string>,
  uuid: <string>,
}
Source:

Members

(static, constant) group

A grouping for this object

Source:

(static, constant) label

A label that can be used when describing this object

Source:

(static, constant) parentDepth

Describes the number of parents this object has based off schema references. When checking for matches for example, we want to use a schema that is more specific over a more generic schema

Source:

(static, constant) path :string

Paths for the keys on a Session Annotation Object

Properties:
Name Type Description
payload string

An object with custom data describing the annotation.
Path is payload.

namespace string

This is to scope annotations and prevent overwrites from other plugins. The type is usually deteremined by the plugin writing the annotation.
Path is namespace.

uuid string

Uniquely identifies each annotation.
Path is uuid.

Source:

(static, constant) publicKey :string

List of keys that are used in the public namespaces

Properties:
Name Type Description
clearSessionTS string

Key used in session to mark a session as cleared before this timestamp

Source:

(static, constant) publicNamespace :string

List of namespaces that are available to all plugins

Properties:
Name Type Description
visibility string

Namespace for annotations that effect event visibility

Source:

Methods

(static) get(alias, data) → {*}

Retrieves a value from the object. You can provide either a path or an alias.

Parameters:
Name Type Description
alias string

Path or alias

data *

Data to search

Source:

(static) getNamespace(source) → {string}

Returns the namespace from the Session Annotation Object. This is the this is to scope annotations and prevent overwrites from other plugins. The type is usually deteremined by the plugin writing the annotation.

Path is namespace.

Parameters:
Name Type Description
source object

The Session Annotation Object instance

Source:

(static) getPayload(source) → {object}

Returns the payload from the Session Annotation Object. This is the an object with custom data describing the annotation.

Path is payload.

Parameters:
Name Type Description
source object

The Session Annotation Object instance

Source:

(static) getPayloadKey(…path, source) → {*}

Returns the data using the specified path from the payload of the Session Annotation Object.

Parameters:
Name Type Attributes Description
path string <repeatable>

key in object

source object

The Session Annotation Object instance

Source:

(static) getUuid(source) → {string}

Returns the uuid from the Session Annotation Object. This is the uniquely identifies each annotation.

Path is uuid.

Parameters:
Name Type Description
source object

The Session Annotation Object instance

Source:

(static) make(…input) → {object}

Generates a Session Annotation Object with the const values set. Can be useful in testing. Can provide additional data by providing a flat object of paths and values.

Parameters:
Name Type Attributes Description
input function <repeatable>

Overrides

Source:

(static) makeNamespacePath(namespace, keyopt) → {string}

Returns a path using the provided namespace. If the optional key is provided, it will return that key from the payload.

Parameters:
Name Type Attributes Description
namespace string

The namespace to reference

key string <optional>

Key inside payload

Example
import { kit, session, sessionAnnotation } from '@adobe/griffon-toolkit';
const publicPath = sessionAnnotation.makeNamespacePath('shared', 'pubic');

const session = session.mock({
  annotations: [
    annotation.mock({
      [sessionAnnotation.path.namespace]: 'shared',
      [sessionAnnotation.path.payload]: { pubic: true }
    })
  ]
});

console.log(kit.search(publicPath, session))); // [true]
Source:

(static) mock(…input) → {object}

Generates a Session Annotation Object with some default values set. Can be useful in testing. Can override defaults and provide additional data by providing a flat object of paths and values.

Parameters:
Name Type Attributes Description
input function <repeatable>

Overrides

Source:

(static) search(namespace, keyopt, data) → {string}

Returns a the value of the path using the provided namespace and key.

Parameters:
Name Type Attributes Description
namespace string

The namespace to reference

key string <optional>

Key inside payload

data *

Data to search

Example
import { kit, session, sessionAnnotation } from '@adobe/griffon-toolkit';
const isPublic = sessionAnnotation.search('shared', 'pubic');

const session = session.mock({
  annotations: [
    annotation.mock({
      [sessionAnnotation.path.namespace]: 'shared',
      [sessionAnnotation.path.payload]: { pubic: true }
    })
  ]
});

console.log(isPublic(session)); // true
Source: