The OperationStack class in TypeScript is a data structure that stores and manages a collection of operations using a Map object.

Implements

Constructors

Properties

operations: Map<
    string,
    {
        _id?: string;
        data?: Record<string, any>;
        delta?: Record<string, any>;
        eventTime?: number;
        method?: "POST" | "UPDATE" | "DELETE";
        operationId?: string;
        operationType?:
            | "node"
            | "structure"
            | "structure-child"
            | "relation"
            | "metadata"
            | "list"
            | "list-child";
        ref?: any;
    },
> = ...

The above code is declaring a class in TypeScript that has a property called "operations" which is a Map object. The Map object is used to store key-value pairs, where the keys are strings and the values are instances of the "Operation" class.

Accessors

  • get addOperation(): <T extends IOperation>(
        operation: T,
    ) => {
        _id?: string;
        data?: Record<string, any>;
        delta?: Record<string, any>;
        eventTime?: number;
        method?: "POST" | "UPDATE" | "DELETE";
        operationId?: string;
        operationType?:
            | "node"
            | "structure"
            | "structure-child"
            | "relation"
            | "metadata"
            | "list"
            | "list-child";
        ref?: any;
    }
  • The add(operation:IOperation):void; function is a method of the IOperationStack interface. It is used to add an operation to the stack of operations. The operation parameter is of type IOperation, which represents an operation that can be performed on a data structure. The function does not return anything (void).

    Returns <T extends IOperation>(
        operation: T,
    ) => {
        _id?: string;
        data?: Record<string, any>;
        delta?: Record<string, any>;
        eventTime?: number;
        method?: "POST" | "UPDATE" | "DELETE";
        operationId?: string;
        operationType?:
            | "node"
            | "structure"
            | "structure-child"
            | "relation"
            | "metadata"
            | "list"
            | "list-child";
        ref?: any;
    }

  • get deleteOperation(): (operationId: string) => boolean
  • The delete(operationId):void; function is a method of the IOperationStack interface. It is used to remove an operation from the stack of operations based on its ID. The operationId parameter is the ID of the operation to be deleted. The function does not return anything (void).

    Returns (operationId: string) => boolean

  • get getOperation(): (
        operationId: string,
    ) => {
        _id?: string;
        data?: Record<string, any>;
        delta?: Record<string, any>;
        eventTime?: number;
        method?: "POST" | "UPDATE" | "DELETE";
        operationId?: string;
        operationType?:
            | "node"
            | "structure"
            | "structure-child"
            | "relation"
            | "metadata"
            | "list"
            | "list-child";
        ref?: any;
    }
  • The get(operationId):void; function is a method of the IOperationStack interface. It is used to retrieve an operation from the stack of operations based on its ID. The operationId parameter is the ID of the operation to be retrieved. The function does not return anything (void).

    Returns (
        operationId: string,
    ) => {
        _id?: string;
        data?: Record<string, any>;
        delta?: Record<string, any>;
        eventTime?: number;
        method?: "POST" | "UPDATE" | "DELETE";
        operationId?: string;
        operationType?:
            | "node"
            | "structure"
            | "structure-child"
            | "relation"
            | "metadata"
            | "list"
            | "list-child";
        ref?: any;
    }

  • get jsonReady(): {
        _id?: string;
        data: Record<string, any>;
        delta?: Record<string, any>;
        eventTime?: number;
        method?: "POST" | "UPDATE" | "DELETE";
        operationId?: string;
        operationType?:
            | "node"
            | "structure"
            | "structure-child"
            | "relation"
            | "metadata"
            | "list"
            | "list-child";
        ref?: any;
    }[]
  • The function returns an array of values from a Map object.

    Returns {
        _id?: string;
        data: Record<string, any>;
        delta?: Record<string, any>;
        eventTime?: number;
        method?: "POST" | "UPDATE" | "DELETE";
        operationId?: string;
        operationType?:
            | "node"
            | "structure"
            | "structure-child"
            | "relation"
            | "metadata"
            | "list"
            | "list-child";
        ref?: any;
    }[]

    An array containing the values of the operations map.

  • get updateOperation(): (
        operation: {
            _id?: string;
            data?: Record<string, any>;
            delta?: Record<string, any>;
            eventTime?: number;
            method?: "POST" | "UPDATE" | "DELETE";
            operationId?: string;
            operationType?:
                | "node"
                | "structure"
                | "structure-child"
                | "relation"
                | "metadata"
                | "list"
                | "list-child";
            ref?: any;
        },
    ) => Map<
        string,
        {
            _id?: string;
            data?: Record<string, any>;
            delta?: Record<string, any>;
            eventTime?: number;
            method?: "POST" | "UPDATE" | "DELETE";
            operationId?: string;
            operationType?:
                | "node"
                | "structure"
                | "structure-child"
                | "relation"
                | "metadata"
                | "list"
                | "list-child";
            ref?: any;
        },
    >
  • The update(operationId):void; function is a method of the IOperationStack interface. It is used to update an operation in the stack of operations based on its ID. The operationId parameter is the ID of the operation to be updated. The function does not return anything (void).

    Returns (
        operation: {
            _id?: string;
            data?: Record<string, any>;
            delta?: Record<string, any>;
            eventTime?: number;
            method?: "POST" | "UPDATE" | "DELETE";
            operationId?: string;
            operationType?:
                | "node"
                | "structure"
                | "structure-child"
                | "relation"
                | "metadata"
                | "list"
                | "list-child";
            ref?: any;
        },
    ) => Map<
        string,
        {
            _id?: string;
            data?: Record<string, any>;
            delta?: Record<string, any>;
            eventTime?: number;
            method?: "POST" | "UPDATE" | "DELETE";
            operationId?: string;
            operationType?:
                | "node"
                | "structure"
                | "structure-child"
                | "relation"
                | "metadata"
                | "list"
                | "list-child";
            ref?: any;
        },
    >

Methods

  • Parameters

    • stackToCompare: Map<
          string,
          {
              _id?: string;
              data?: Record<string, any>;
              delta?: Record<string, any>;
              eventTime?: number;
              method?: "POST" | "UPDATE" | "DELETE";
              operationId?: string;
              operationType?:
                  | "node"
                  | "structure"
                  | "structure-child"
                  | "relation"
                  | "metadata"
                  | "list"
                  | "list-child";
              ref?: any;
          },
      >

    Returns {
        _id?: string;
        data?: Record<string, any>;
        delta?: Record<string, any>;
        eventTime?: number;
        method?: "POST" | "UPDATE" | "DELETE";
        operationId?: string;
        operationType?:
            | "node"
            | "structure"
            | "structure-child"
            | "relation"
            | "metadata"
            | "list"
            | "list-child";
        ref?: any;
    }[]

  • The above code is defining a function called getTransactions in TypeScript. This function retrieves transactions from a collection of operations.

    Returns any[]

  • The above code is defining a function called queryAllOperations in TypeScript. This function takes a query parameter and returns an array of operations that match the query.

    Parameters

    • query: any

    Returns any[]