Berryfi

Berryfi

The Berryfi client

Constructor

new Berryfi(config)

Source:
See:
Properties:
Name Type Description
workspace string The name of your workspace
useCache boolean Whether the client is going to try to use cache or not.
fibery object Last update from Fibery and its state
apps Collection.<App> A collection of apps cached. Key is App name.
types Collection.<Type> A collection of types cached. Key is type ID.
fields Collection.<Field> A collection of fields cached. Key is field ID.
entities Collection.<Entity> A collection of entities cached. Key is entity ID.
flags Flags An object of flags that can be used to check boolean values of data.
Creates a new Berryfi client
Example
const Berryfi = require("Berryfi");

const berryfi = new Berryfi({
	workspace: "somewhere",
	token: "a1a1a1a1a1.b2b2b2b2b2b2b2b2b2b2b2b2b2"
});

// If restarting a lot, debuggin, testing etc. you should check Schema caching.
const berryfi = new Berryfi({
	workspace: "somewhere",
	token: "a1a1a1a1a1.b2b2b2b2b2b2b2b2b2b2b2b2b2",
	cacheSchema: true,
	schemaPath: path.join(__dirname, "schemaCache.json")
});
Parameters:
Name Type Description
config object Configuration for the Berryfi client
Properties
Name Type Attributes Default Description
workspace string The name of your workspace. Can be found in url: https://{workspace name}.fibery.io/
token string Your Fibery token. Check Fibery API documentation on how to get your token.
cacheSchema boolean <optional>
false Meant for debugging and development. If true, caches the returned Fibery Schema in the config.schemaPath as a JSON file. Berryfi will try to check this location on creation, or Berryfi.pull(), and use the data there if found. If not, it will write it if connected to Fibery, and then from that point on read from that cache. The schema cache is never considered stale, so you either have to delete or rename the file to make Berryfi make a new updated one.
schemaPath string <optional>
Meant for debugging and development. An absolute path to the location where the Fibery schema overview will be saved. Berryfi fill try to read the file in this location on creation, or Berryfi.pull(), and use the data there if found.

Methods

(async) exec(command, endpointopt) → {Promise.<Array.<object>>}

Source:
Executs a HTTP request to Fibery, using your token and workspace as the base.
Example
let rawData = await berryfi.exec([{ command: "fibery.schema/query" }]);
Parameters:
Name Type Attributes Default Description
command Array.<object> The command to execute, which will be used as the body of the HTTP request
endpoint string <optional>
"commands" The part after `fibery.io/api` you want to connect to
Returns:
Type
Promise.<Array.<object>>

(async) pull()

Source:
Checks token validity, hostname, and connects client to Fibery, and will populate overview of your Workspace in to cache.
Example
await berryfi.pull();

stentenceCase(string) → {string}

Source:
Fibery fields force Sentence case on the labels, and there's inconsistencies with the API (e.g. 'name' in API, 'Name' in response). This method converts the first letter to uppercase, and leave rest as-is.
Example
console.log(berryfi.sentenceCase("hello there World!")) // "Hello there World!"
Parameters:
Name Type Description
string string The string input to apply uppercase to the first letter
Returns:
Type
string

toDate(uuid) → {Date}

Source:
Returns the date something was created by passing its UUID (Using UUID v1).
Example
let date = berryfi.toDate("750bb3e0-a851-11ea-9163-48203d178ac1");
console.log(date.getFullYear()) // 2020
Parameters:
Name Type Description
uuid string The UUID to get the creation date of
Returns:
Type
Date