Type

Type

Represents a user-created Type

Constructor

new Type(berryfi, data)

Source:
Properties:
Name Type Attributes Description
berryfi Berryfi The Berryfi client instance. Circular reference.
entities Collection.<UIUID, Entity> A Collection of Entities that are derived from this Type
fields Collection.<UUID, Field> A Collection of Fields that belong to this Type
parentApp App The App this Type is a child of
name string The Fibery name of this type. 'some/name'
meta object The Fibery meta of this type
id string The ID of this tupe. If App, ID is the app's label.
flag number The flag value for this type
label string A readable name, often the one shown in Fibery's UI
fieldNames Set A set of Fibery field names this type has
readOnly Set A set of Fibery field names that are 'read only' and cannot be modified
type string <optional>
The Fibery type. Only present in Fields.
fields Array.<object> <optional>
The Fibery Fields array if this is a non-primitive Type.
Creates a new Type
Parameters:
Name Type Description
berryfi Berryfi The Berryfi client instance
data object The data to populate this type

Extends

Members

booleans :object

Source:
Overrides:
Returns an object of true/false booleans based on the flag value
Type:
  • object

collection :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/collection?' value
Type:
  • boolean

color :string

Source:
Overrides:
String - Returns 'fibery/meta' → 'ui/color' value
Type:
  • string

created :Date

Source:
Overrides:
Date - Returns the creation date, based on the ID (UUID v1)
Type:
  • Date

defaultValue :string

Source:
Overrides:
String|Object - Returns 'fibery/meta' → 'fibery/default-value' value
Type:
  • string

domain :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/domain?' value
Type:
  • boolean

entities :Collection.<UIUID, Entity>

Source:
A Collection of Entities that are derived from this Type
Type:

fields :Collection.<UUID, Field>

Source:
A Collection of Fields that belong to this Type
Type:

(abstract) flag :number

Source:
Overrides:
The flags value for this thing. Is set when loaded by Berryfi.pull()
Type:
  • number

hasModificationDate :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/modification-date?' value
Type:
  • boolean

icon :string

Source:
Overrides:
String - Returns 'fibery/meta' → 'ui/mixin-icon' value
Type:
  • string

isApp :boolean

Source:
Overrides:
Boolean - Check if this is a user created App
Type:
  • boolean

isAuxiliary :boolean

Source:
Overrides:
Boolean - Check if this is a Fibery helper type or field
Type:
  • boolean

isAuxiliaryField :boolean

Source:
Overrides:
Boolean - Check if this is a Fibery helper field
Type:
  • boolean

isAuxiliaryType :boolean

Source:
Overrides:
Boolean - Check if this is a Fibery helper type
Type:
  • boolean

isEntity :boolean

Source:
Overrides:
Boolean - Check if this is an entity
Type:
  • boolean

isField :boolean

Source:
Overrides:
Boolean - Check if this is a field inside a Type
Type:
  • boolean

isId :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/id?' value
Type:
  • boolean

isPrimitive :boolean

Source:
Overrides:
Boolean - Check if this is a primitive Fibery type
Type:
  • boolean

isPublicId :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/public-id?' value
Type:
  • boolean

isReadOnly :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/readonly?' value
Type:
  • boolean

isSecure :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/secure?' value
Type:
  • boolean

isType :boolean

Source:
Overrides:
Boolean - Check if this is a Type inside an App
Type:
  • boolean

isUserCreated :boolean

Source:
Overrides:
Boolean - Check if this type is directly created by a user
Type:
  • boolean

mixin :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'app/mixin?' value
Type:
  • boolean

mixinCreateRelation :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'app/mixin-create-relation?' value
Type:
  • boolean

mixins :object

Source:
Overrides:
Object - Returns 'fibery/meta' → 'app/mixins' value
Type:
  • object

objectEditorOrder :number

Source:
Overrides:
Number - Returns 'fibery/meta' → 'ui/object-editor-order' value
Type:
  • number

precision :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'ui/precision' value
Type:
  • boolean

primitive :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/primitive?' value
Type:
  • boolean

relation :string

Source:
Overrides:
String - Returns 'fibery/meta' → 'fibery/relation' value
Type:
  • string

required :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/required?' value
Type:
  • boolean

showInMenu :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'ui/show-in-menu?' value
Type:
  • boolean

title :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'ui/title?' value
Type:
  • boolean

unique :boolean

Source:
Overrides:
Boolean - Returns 'fibery/meta' → 'fibery/unique?' value
Type:
  • boolean

unit :string

Source:
Overrides:
String - Returns 'fibery/meta' → 'ui/number-unit' value
Type:
  • string

Methods

append(input) → {Type}

Source:
Registers a Field or Entity as a child of this Type, and this Type as their parent.
Parameters:
Name Type Description
input Field | Entity A Field or Entity to register in to this Type
Returns:
Type
Type

(async) insert(data, returnEntitiesopt) → {Array.<object>}

Source:
Direct insertion of data, useful if you know the scheme and how to do it. Performs a single or batch insert based on if you pass an array of entities or a single object. The entities returned from the API are also converted to Entities and stored in Type.entities collection behind the scenes, so you can access the resulted Entities from there as well.
Example
let res = await contactType.insert([{
	"My App/Name": "John Doe",
	"My App/User email": "john@doe.com"
}, {
	"My App/Name": "Ola Normann",
	"My App/User email": "ola@normann.no"
}]);
console.log(res) // [{success:true, result: [Object]}, {success:true, result: [Object]}]

// Return array of entity references instead of API result
let rob = await contactType.insert({
	"My App/Name": "Rob Robinson",
	"My App/User email": "rob@robinson.net"
}, true);
console.log(rob[0].constructor.name, rob[0].field["User email"]) // "Entity" "rob@robinson.net"
Parameters:
Name Type Attributes Default Description
data Array.<object> | object The raw data to pass in to a `fibery.entity/create`. If multiple, will be wrapped around by a batch.
returnEntities boolean <optional>
false If set to true, will return an array of created Entities (even if only 1) instead of array of API request results.
Returns:
Raw API response
Type
Array.<object>

makeEntity(data) → {Entity}

Source:
Creates a new entity and adds it to cache. By later passing `entity.validate()` you can check if you are using invalid fields.
Parameters:
Name Type Description
data object The data that makes up this new entity
Returns:
Type
Entity

toFibery() → {object}

Source:
Overrides:
Converts the data of this to a valid Fibery schema
Example
const data = primitive.toFibery();
console.log(data);
/*
{
	"fibery/name": "fibery/modification-date",
	"fibery/type": "fibery/date-time",
	"fibery/meta": {
	    "fibery/modification-date?": true,
	    "fibery/required?": true,
	    "fibery/readonly?": true,
	    "fibery/default-value": "$now",
	    "fibery/secured?": false
	},
	"fibery/id": "de64a8e4-a781-11ea-a8a7-539d334de305"
}
Returns:
Type
object