Skip to main content
Pentaho Documentation

spec

pentaho.type.spec

The type.spec namespace contains specification interfaces and type definitions.

Source: doc-js/pentaho/type/spec/_namespace.jsdoc, line 17

Interfaces

Name Summary
IApplication

The spec.IApplication interface describes an application instance in object form.

IComplex

The spec.IComplex interface describes a complex instance in object form.

IComplexProto

The spec.IComplexProto interface represents the specification of the prototype of a complex type's instance class.

IComplexTypeProto

The spec.IComplexTypeProto interface represents the specification of a complex type.

IDate

The spec.IDate interface describes a date value in object form.

IFunction

The spec.IFunction interface describes a function value in object form.

IInstance

The spec.IInstance interface describes an instance using a generic, object form.

IInstanceProto

The spec.IInstanceProto interface describes the extensible/configurable members of the prototype of instance classes.

IList

The spec.IList interface describes a list value in object form.

IListProto

The spec.IListProto interface represents the specification of the prototype of a list type's instance class.

IListTypeProto

The spec.IListTypeProto interface represents the specification of a list type.

IModel

The spec.IModel interface describes a model instance in object form.

IPropertyTypeProto

The spec.IPropertyTypeProto interface represents the information used to define a property of a complex type.

IRefinementTypeProto

The spec.IRefinementTypeProto interface represents the specification of a refinement type.

ISimple

The spec.ISimple interface describes a simple value in object form.

ISimpleProto

The spec.ISimpleProto interface represents the specification of the prototype of a simple type's instance class.

ISimpleTypeProto

The spec.ISimpleTypeProto interface represents the specification of a simple type.

ITypeProto

The spec.ITypeProto interface represents the specification of a type.

IValue

The spec.IValue interface describes a value instance using a generic, object form.

IValueProto

The spec.IValueProto interface represents the specification of the prototype of a value type's instance class.

IValueTypeProto

The spec.IValueTypeProto interface represents the specification of a value type.

Type Definitions

UComplex: pentaho.type.spec.IComplex | Array.<pentaho.type.spec.UInstance> | Nully

A spec.UComplex represents the union of JS types that can be used to describe a complex value, or the absence of one.

Like with all other value types, complex values can be described using the general object form. The object form conforms to pentaho.type.spec.IComplex.

Complex values support an additional form of value specification, the array form: an array of pentaho.type.spec.UInstance, each the specification of the value of one of a complex's properties, in property definition order, according to Property.Type#index.

Take the following object form example:

{
  product: "boeing-737",
  price:   1500
}

Assuming that the two properties were defined in the order "product" then "price", it could be written in array form, like this:

["boeing-737", 1500]

However, note that array form can only be used if the inline type property can, in fact, be omitted.

When a complex value is absent, it can be described with a Nully JavaScript value:

null

Source: doc-js/pentaho/type/spec/UComplex.jsdoc, line 17

UContextPropFilter: Nully | any | Array.<any>

A spec.UContextPropFilter represents the union of JS types that can be used to filter the value of a context property, in the select attribute of a type configuration rule.

A Nully filter is equivalent to not filtering a variable. When unfiltered, any context variable value is matched.

An array filter matches a context variable if any of the values in the array are the same exact value of the context variable.

Any other value is assumed to be a single value, and matches the context variable if it is the same value.

Source: doc-js/pentaho/type/spec/UContextPropFilter.jsdoc, line 17

UInstance: pentaho.type.spec.IInstance | pentaho.type.spec.UValue | Nully

A spec.UInstance represents the union of JS types that can be used to describe an instance, or the absence of one.

When an instance is described using object form, its specification is of type spec.IInstance.

To describe an absent instance, use a Nully JavaScript value.

Source: doc-js/pentaho/type/spec/UInstance.jsdoc, line 17

UList: pentaho.type.spec.IList | Array.<pentaho.type.spec.UInstance> | Nully

A spec.UList represents the union of JS types that can be used to describe a list value, or the absence of one.

Like with all other value types, list values can be described using the general object form. The object form conforms to pentaho.type.spec.IList.

List values support an additional form of value specification, the array form: an array of pentaho.type.spec.UInstance, each the specification of the corresponding element of the list.

Take the following example of a number list in object form:

{
  _: {base: "list", of: "number"},
  d: [1, 2, 3]
}

In array form, if we assume the type of the list is implied, the same list could be written simply as:

[1, 2, 3]

However, note that array form can only be used if the inline type property can, in fact, be omitted.

A list of complex values can be written in array form, and its complex elements be written in array form, as well. For example:

[
  ["boeing-737",  1500],
  ["airbus-A320", 1000]
]

When a list value is absent or empty, it can be described with a Nully JavaScript value:

null

Source: doc-js/pentaho/type/spec/UList.jsdoc, line 17

UPropertyTypeProto: string | pentaho.type.spec.IPropertyTypeProto

A spec.UPropertyTypeProto represents the union of JS types that can be used to define a property of a complex type.

When the value is a string, it's taken to represent a property whose pentaho.type.spec.IPropertyTypeProto#name is that string and whose pentaho.type.spec.IPropertyTypeProto#type is pentaho.type.String.

Source: doc-js/pentaho/type/spec/UPropertyTypeProto.jsdoc, line 17

USimple: pentaho.type.spec.ISimple | pentaho.type.Simple | any

A spec.USimple represents the union of JS types that can be used to describe a simple value, or the absence of one.

Like with all other value types, simple values can be described using the general object form. The object form conforms to pentaho.type.spec.ISimple.

The following is an example of an object form specification:

{v: 1, f: "1.0"}

If the formatted is not defined, it can be written more concisely as:

{v: 1}

or, simply, as:

1

Note that, when the underlying JavaScript value is a plain object, it must always be described using the generic object form, spec.ISimple, as in:

{v: {}}

When a simple value is absent, it can be described with a Nully JavaScript value:

null

Note, also, that a simple value cannot have a Nully as its underlying JavaScript value, and, as such, the following example would not be valid:

{v: null} // throws if given to a Simple, derived constructor

A Simple instance can also be used as a simple value specification, in which case it is used as a source of its value and formatted properties.

To know, exactly, which types of JavaScript values are accepted as specifications of a specific pentaho.type.spec.ISimple subtype, see the subtype's documentation.

Source: doc-js/pentaho/type/spec/USimple.jsdoc, line 17

UTypeReference: nonEmptyString | pentaho.type.Factory.<pentaho.type.Instance> | pentaho.type.Type | Class.<pentaho.type.Instance> | Array.<pentaho.type.spec.UTypeReference> | pentaho.type.spec.ITypeProto

The spec.UTypeReference union represents the set of JS types that can be used to reference a type.

It can be one of the following:

A type id string

A type's permanent id — the identifier of a defined module in the AMD module system —, or a temporary, serialization-only identifier.

When an identifier is permanent and does not contain any "/" character, it is considered a standard type and is taken relative to Pentaho's "pentaho/type" module.

Note that relative AMD module identifiers, such as "./foo", are not supported.

Example absolute, permanent identifier:

"pentaho/type/string"

Example temporary identifier:

"_:1"
An instance constructor function

A reference to an instance constructor, like Complex.

Usually, a reference to an instance constructor is obtained from a context object (and not used to obtain one...) by providing the type's identifier. Nevertheless, it is sometimes useful to be able to use it to identify a type.

Example:

require(["pentaho/type/Context"], function(Context) {
  var context = new Context();
  var Complex = context.get("pentaho/type/complex");
  // ...
});
A type factory function

The functions that create instance constructors of value types, each time they are called, for a given context. They have the signature pentaho.type.Factory.<pentaho.type.Instance>.

The AMD module under the identifier of a value type must return a type factory function. A type factory can thus be obtained by requiring the AMD module that has the type's identifier:

require(["pentaho/type/Context", "pentaho/type/string"], function(Context, stringFactory) {
  var context = new Context();
  var PentahoString = context.get(stringFactory);

  // ...
});

In practice, a type factory reference is seldom needed, and is only used for obtaining the base type of a type being defined:

// In a file accessible through module id "my/derived/type"

define(["my/base/type"], function(baseTypeFactory) {

  // Return the derived type's factory function
  return function(context) {

    // Obtain the base type's instance constructor in this context
    var MyBaseType = context.get(baseTypeFactory);

    // Derive and return the derived type constructor
    return MyBaseType.extend({
       type: {
         id: "my/derived/type"
         // ...
       }
       // ...
    });
  };

});
A type object

A type's singleton object, like Number.type, where Number is Number.

Example:

require(["pentaho/type/Context"], function(Context) {
  var context = new Context();

  var PentahoNumber = context.get("pentaho/type/number");
  var numberType = PentahoNumber.type;

  // Get a number list type
  var NumberList = context.get([numberType]);

  var numbers = new NumberList([1, 2, 3]);

  // ...
});
A generic type specification object

A plain Object specification used to generically describe a type. Satisfies the interface spec.ITypeProto.

The special base attribute allows specifying the base type and defaults to "pentaho/type/complex", on a global context, or to the type of the base property, when overriding it. Any additional attributes are determined and processed by each type's pentaho.type.Type.extend method.

Example:

require(["pentaho/type/Context"], function(Context) {
  var context = new Context();

  // Obtain an anonymous, derived complex type from the context
  var MyProduct = context.get({
        base: "complex" // optional
        props: [
          {name: "id",    label: "Id",    type: "string"},
          {name: "name",  label: "Name",  type: "string"},
          {name: "price", label: "Price", type: "number"}
        ]
      });

  var productA = new MyProduct({id: "mabc", name: "Principia Mathematica", price: 1200});

  // ...
});
A list type shorthand specification array

A shorter specification syntax to reference the List type, or derived list types of varied element types.

Example:

require(["pentaho/type/Context"], function(Context) {
  var context = new Context();

  // Obtain the List type instance constructor

  // Using the id
  var ListA = context.get("list");

  // Obtain a derived List type instance constructor
  // with Number as the element type

  // Using the generic type specification syntax
  var NumberListA = context.get({base: "list", of: "number"});

  // Using the shorthand syntax
  var NumberListB = context.get(["number"]);

  // ...

  // Assuming the type MyProduct from a previous example

  var ProductList = context.get([MyProduct]);

  var productList = new ProductList([
        {id: "mpma", name: "Principia Mathematica", price: 1200},
        {id: "flot", name: "The Laws of Thought",   price:  500}
      ]);

  alert("Product count: " + productList.count);
});

Source: doc-js/pentaho/type/spec/UTypeReference.jsdoc, line 17

UValue: pentaho.type.spec.IValue | pentaho.type.spec.UComplex | pentaho.type.spec.USimple | pentaho.type.spec.UList | Nully

A spec.UValue represents the union of JS types that can be used to describe a value instance, or the absence of one.

When a value instance is described using object form, its specification is of type spec.IValue.

To describe an absent instance, use a Nully JavaScript value.

Source: doc-js/pentaho/type/spec/UValue.jsdoc, line 17