πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
DemoInstallSign in
Socket

fms-api-client

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fms-api-client

A FileMaker Data API client designed to allow easier interaction with a FileMaker application from a web environment.

1.7.1
Source
npm
Version published
Weekly downloads
38
40.74%
Maintainers
1
Weekly downloads
Β 
Created
Source

fms-api-client

Build Status Known Vulnerabilities Coverage Status GitHub issues Github commits (since latest release) GitHub license

A FileMaker Data API client designed to allow easier interaction with a FileMaker application from a web environment. This client abstracts the FileMaker 17 Data API into class based methods. You can find detailed documentation on this project here:

fms-api-client documentation

Installation

npm install --save fms-api-client

Usage

Introduction

The fms-api-client is a wrapper around the FileMaker Data API. Much :heart: to FileMaker for their work on the Data API. The client attempts to follow the terminology used by FileMaker wherever possible. the client uses a lightweight datastore to hold Data API connections. The client contains methods which are modeled after the Data API Endpoints.

The client requires that you first connect to a datastore before creating or querying the FileMaker class. You can use the datastore to save a multitude of clients. Each client committed to the datastore will automatically handle Data API Sessions. Once saved to the data store a client's methods can be used to interact with a FileMaker Database without the need for additional authentication.

Each client will manage their own FileMaker Data API session, but the clients can manually open or close their FileMaker sessions by calling either the client.login() method or the client.logout() method. To remove a client from a datastore and log out a session call client.destroy().

The client supports the same parameter syntax as is found in the Data API Documentation. Where appropriate and useful the client also allows additional parameters. Any method that accepts script or portals in a query or body parameters will also accept the following script and portal parameters:

Script Array Syntax

The custom script parameter follows the following syntax:

{
  "scripts": [
    {
      "name": "At Mos Eisley",
      "phase": "presort",
      "param": "awesome bar"
    },
    {
      "name": "First Shot",
      "phase": "prerequest",
      "param": "Han"
    },
    {
      "name": "Moof Milker",
      "param": "Greedo"
    }
  ]
}

File ./examples/schema/scripts-array-schema.json

Portal Array Syntax

The custom portal parameter follows the following syntax:

{
  "portals": [
    { "name": "planets", "limit": 1, "offset": 1 },
    { "name": "vehicles", "limit": 2 }
  ]
}

File ./examples/schema/portals-array-schema.json

Note: The FileMaker script and portal syntax will override the alternative script and portal parameter syntax.

In addition to allowing an exanded syntax for invoking script or selecting portals the client will also automatically parse arrays, objects, and numbers to adhere to the requirements of the Data API. Arrays and objects are stringified before being inserted into field data. Also limits and offsets can be set as either a strings or a numbers.

The client will also automatically convert limit, find, and offset into their underscored conterparts as needed. Additionally, if a script result can be parsed as JSON it will be automatically parsed for you by the client.

All methods on the client return promises and each each method will reject with a message and code upon encountering an error. All messages and codes follow the FileMaker Data API where possible.

This project also provides utility modules to aid in working with FileMaker Data API Results. The provided utility modules are fieldData, recordId, and transform. These utilities will accept and return either an object or an an array objects. For more information on the utility modules see the utility section.

Datastore Connection

Connect must be called before the FileMaker class is used. This connect uses Marpat. Marpat is a fork of Camo. Thanks and love to Scott Robinson for his creation and maintenance of Camo. My fork of Camo - Marpat is designed to allow the use of multiple datastores with the focus on encrypted file storage and project flexibility.

For more information on marpat and the different types of supported storage visit marpat

const { connect } = require('marpat');
connect('nedb://memory')

Excerpt from ./examples/index.js

Client Creation

After connecting to a datastore you can import and create clients. A client is created using the create method on the Filemaker class. The FileMaker class accepts an object with the following properties:

PropertyTypeDescription
applicationStringrequired The FileMaker application / database to connect to
serverStringrequired The FileMaker server to use as the host. Note: Must be an http or https Domain.
userStringrequired The FileMaker user account to be used when authenticating into the Data API
passwordStringrequired The FileMaker user account's password.
nameStringoptional A name for the client.
usageBooleanoptional Track Data API usage for this client. Note: Default is true
timeoutNumberoptional The default timeout time for requests Note: Default is 0, (no timeout)
proxyObjectoptional settings for a proxy server
agentObjectoptional settings for a custom request agent

:warning: You should only use the agent parameter when absolutely necessary. The Data API was designed to be used on https. Deviating from the intended use should be done with caution.

    const client = Filemaker.create({
      name: process.env.CLIENT_NAME,
      application: process.env.APPLICATION,
      server: process.env.SERVER,
      user: process.env.USERNAME,
      password: process.env.PASSWORD,
      usage: process.env.CLIENT_USAGE_TRACKING,
      agent: { rejectUnauthorized: false }
    });

Excerpt from ./examples/index.js

Note: The server must be an http or https domain.

A client can be used directly after saving it. The client.save() method takes no arguments and will either reject with an error or resolve with a useable client. The client will automatically handle Data API session creation and expiration. Once a client is saved it will be stored on the datastore for reuse later.

    return client.save();
  })
  .then(client => authentication(client))
  .then(client => creates(client))
  .then(client => gets(client))
  .then(client => lists(client))
  .then(client => finds(client))
  .then(client => edits(client))
  .then(client => scripts(client))
  .then(client => globals(client))
  .then(client => deletes(client))
  .then(client => uploads(client))
  .then(client => utilities(client))

Excerpt from ./examples/index.js

A client can be removed using either the client.destroy() method, the Filemaker.deleteOne(query) method or the Filemaker.deleteMany(query) method.

Note Only the client.destroy() method will close a FileMaker session. Any client removed using the the Filemaker.deleteOne(query) method or the Filemaker.deleteMany(query) method will not log out before being destroyed.

Client Use

A client can be used after it is created and saved or recalled from the datastore. The Filemaker.find(query) or Filemaker.findOne(query) methods can be used to recall clients. The filemaker.findOne(query) method will return either an client or null. The filemaker.find(query) will return an array of clients. All public methods on the client are return promises.

const createManyRecords = client =>
  Promise.all([
    client.create('Heroes', { name: 'Anakin Skywalker' }, { merge: true }),
    client.create('Heroes', { name: 'Obi-Wan' }, { merge: true }),
    client.create('Heroes', { name: 'Yoda' }, { merge: true })
  ]).then(result => log('create-many-records-example', result));

Excerpt from ./examples/create.examples.js

Results:

[
  {
    "name": "Anakin Skywalker",
    "recordId": "746018",
    "modId": "0"
  },
  {
    "name": "Obi-Wan",
    "recordId": "746019",
    "modId": "0"
  },
  {
    "name": "Yoda",
    "recordId": "746022",
    "modId": "0"
  }
]

File ./examples/results/create-many-records-example.json

Data API Sessions

The client will automatically handle creating and closing Data API sessions. If required the client will authenticate and generate a new session token with each method call. The Data API session is also monitored, updated, and saved as the client interacts with the Data API. A client will always attempt to reuse a valid token whenever possible.

The client contains two methods related to Data API sessions.These methods are client.login() and client.logout(). The login method is used to start a Data API session and the logout method will end a Data API session.

Login Method

The client will automatically call the login method if it does not have a valid token. This method returns an object with a token property. This method will also save the token to the client's connection for future use.

client.login()

const login = client => client.login();

Excerpt from ./examples/authentication.examples.js

Logout Method

The logout method is used to end a Data API session. This method will also remove the current client's authentication token.

client.logout()

Note The logout method will change in an upcoming release. It will be modified to accept a session parameter.

const logout = client =>
  client.logout().then(result => log('client-logout-example', result));

Excerpt from ./examples/authentication.examples.js

Create Records

Using the client you can create filemaker records. To create a record specify the layout to use and the data to insert on creation. The client will automatically convert numbers, arrays, and objects into strings so they can be inserted into a filemaker field. The create method will automatically create a fieldData and add data to that property if there is no fieldData property present.

client.create(layout, data, parameters)

InputTypeDescription
layoutStringThe layout to use as context for creating the record
dataObjectThe data to use when creating a record.
parametersObjectThe parameters to use when creating a record.
const createRecord = client =>
  client
    .create('Heroes', {
      name: 'George Lucas'
    })
    .then(result => log('create-record-example', result));

Excerpt from ./examples/create.examples.js

Result:

{
  "recordId": "746017",
  "modId": "0"
}

File ./examples/results/create-record-example.json

Both the create method and the edit method accept a merge boolean in their options. If merge is true the data used to create or edit the filemaker record will be merged with

const mergeDataOnCreate = client =>
  client
    .create(
      'Heroes',
      {
        name: 'George Lucas'
      },
      { merge: true }
    )
    .then(result => log('create-record-merge-example', result));

Excerpt from ./examples/create.examples.js

Result:

{
  "name": "George Lucas",
  "recordId": "746021",
  "modId": "0"
}

File ./examples/results/create-record-merge-example.json

The create method also allows you to trigger scripts when creating a record. Notice the scripts property in the following example. You can specify scripts to run using either FileMaker's script.key syntax or specify an array of scripts with a name, phase, and script parameter.

const triggerScriptsOnCreate = client =>
  client
    .create(
      'Heroes',
      { name: 'Anakin Skywalker' },
      {
        merge: true,
        scripts: [
          { name: 'Create Droids', param: { droids: ['C3-PO', 'R2-D2'] } }
        ]
      }
    )
    .then(result => log('trigger-scripts-on-create-example', result));

Excerpt from ./examples/create.examples.js

Result:

{
  "name": "Anakin Skywalker",
  "scriptError": "0",
  "recordId": "746020",
  "modId": "0"
}

File ./examples/results/trigger-scripts-on-create-example.json

Get Record Details

The Get method will return a specific FileMaker record based on the recordId passed to it. The recordId can be a string or a number.

client.get(layout, recordId, parameters)

InputTypeDescription
layoutStringThe layout to use as context for creating the record.
recordIdStringNumber
parametersObjectThe parameters to use when getting a record a record.
      client
        .get('Heroes', response.data[0].recordId)
        .then(result => log('get-record-example', result))

Excerpt from ./examples/get.examples.js

Result:

{
  "data": [
    {
      "fieldData": {
        "name": "yoda",
        "image(1)": "https://some-server.com/Streaming_SSL/MainDB/E8ADD6FFD6AE5AC1F43014030280FAE36E79E5AD03FF4C52BF31649D3798644A?RCType=EmbeddedRCFileProcessor",
        "object": "",
        "array": "",
        "height": "",
        "id": "3FFF23CF-EE1E-2C4D-8599-95F2744AFD3C",
        "imageName": "placeholder.md",
        "faceDescriptor": ""
      },
      "portalData": {
        "Planets": [],
        "Vehicles": []
      },
      "recordId": "733117",
      "modId": "2"
    }
  ]
}

File ./examples/results/get-record-example.json

List Records

You can use the client to list filemaker records. The list method accepts a layout and parameter variable. The client will automatically santize the limit, offset, and sort keys to correspond with the DAPI's requirements.

client.list(layout, parameters)

InputTypeDescription
layoutStringThe layout to use as context for listing records.
parametersObjectThe parameters to use when listing records.
const listHeroes = client =>
  client
    .list('Heroes', { limit: 2 })
    .then(result => log('list-records-example', result));

Excerpt from ./examples/list.examples.js

Result:

{
  "data": [
    {
      "fieldData": {
        "name": "George Lucas",
        "image(1)": "https://some-server.com/Streaming_SSL/MainDB/D97A1B6810CB39522D4438F85CE8D6857425923B542F3F89B46E96FB387D0A73?RCType=EmbeddedRCFileProcessor",
        "object": "",
        "array": "",
        "height": "",
        "id": "0E6DF26C-761E-7947-9A3C-C312C285EE55",
        "imageName": "placeholder.md",
        "faceDescriptor": ""
      },
      "portalData": {
        "Planets": [],
        "Vehicles": [
          {
            "recordId": "3",
            "Vehicles::name": "test",
            "Vehicles::type": "",
            "modId": "0"
          }
        ]
      },
      "recordId": "732765",
      "modId": "7"
    },
    {
      "fieldData": {
        "name": "George Lucas",
        "image(1)": "",
        "object": "",
        "array": "",
        "height": "",
        "id": "0F628510-432C-0E47-8D03-BA90AAF2EA17",
        "imageName": "",
        "faceDescriptor": ""
      },
      "portalData": {
        "Planets": [],
        "Vehicles": []
      },
      "recordId": "732766",
      "modId": "1"
    }
  ]
}

File ./examples/results/list-records-example.json

Find Records

The client's find method will accept either a single object as find parameters or an array. The find method will also santize the limit, sort, and offset parameters to conform with the Data API's requirements.

client.find(layout, query, parameters)

InputTypeDescription
layoutStringThe layout to use when performing a find.
queryObjectArray
parametersObjectThe parameters to use when listing records.
const findRecords = client =>
  client
    .find('Heroes', [{ name: 'Anakin Skywalker' }], { limit: 1 })
    .then(result => log('find-records-example', result));

Excerpt from ./examples/find.examples.js

Result:

{
  "data": [
    {
      "fieldData": {
        "name": "Anakin Skywalker",
        "image(1)": "",
        "object": "",
        "array": "",
        "height": "",
        "id": "F3B3D737-FD2F-8945-BE95-B49CB617ED5B",
        "imageName": "",
        "faceDescriptor": ""
      },
      "portalData": {
        "Planets": [],
        "Vehicles": []
      },
      "recordId": "736984",
      "modId": "1"
    }
  ]
}

File ./examples/results/find-records-example.json

Edit Records

The client's edit method requires a layout, recordId, and object to use for updating the record.

client.edit(layout, recordId, data, parameters)

InputTypeDescription
layoutStringThe layout to use when editing the record.
recordIdStringNumber
dataObjectThe data to use to edit the record.
parametersObjectThe parameters to use when editing a record.
const editRecord = client =>
  client
    .find('Heroes', [{ name: 'Anakin Skywalker' }], { limit: 1 })
    .then(response => response.data[0].recordId)
    .then(recordId => client.edit('Heroes', recordId, { name: 'Darth Vader' }))
    .then(result => log('edit-record-example', result));

Excerpt from ./examples/edit.examples.js

Result:

{
  "modId": "2"
}

File ./examples/results/edit-record-example.json

Delete Records

The client's delete method requires a layout and a record id. The recordId can be a number or a string.

client.delete(layout, recordId, parameters)

InputTypeDescription
layoutStringThe layout to use when deleting the record.
recordIdStringNumber
parametersObjectThe parameters to use when deleting a record.
const deleteRecords = client =>
  client
    .find('Heroes', [{ name: 'yoda' }], { limit: 1 })
    .then(response => response.data[0].recordId)
    .then(recordId => client.delete('Heroes', recordId))
    .then(result => log('delete-record-example', result));

Excerpt from ./examples/delete.examples.js

Result:

{}

File ./examples/results/delete-record-example.json

Trigger Script

The client's script method will trigger a script. You can also trigger scripts with the create, edit, list, find, and delete methods. This method performs a list with a limit of one on the specified layout before triggering the script. this is the most lightweight request possible while still being able to trigger a script.

client.script(layout, script, param, parameters)

InputTypeDescription
layoutStringThe layout to use when triggering the script.
scriptStringThe script to trigger.
paramAnyThe parameter to send to the script
parametersObjectThe parameters to use making the request.
const triggerScript = client =>
  client
    .script('Heroes', 'FMS Triggered Script', { name: 'Han' })
    .then(result => log('script-trigger-example', result));

Excerpt from ./examples/script.examples.js

Result:

{
  "result": {
    "answer": "Han shot first"
  }
}

File ./examples/results/script-trigger-example.json

Upload Files

The upload method will upload binary data to a container. The file parameter should be either a path to a file or a buffer. If you need to set a field repetition, you can set that in parameters. If recordId is 0 or undefined a new record will be created.

client.upload(file, layout, container, recordId, parameters)

InputTypeDescription
fileObjectString
layoutStringThe layout to use when uploading a file.
containerStringThe container field name to upload into.
recordIdStringNumber
parametersObjectThe parameters to use making the request.
const uploadImage = client =>
  client
    .upload('./assets/placeholder.md', 'Heroes', 'image')
    .then(result => log('upload-image-example', result));

Excerpt from ./examples/upload.examples.js

Result:

{
  "modId": "1",
  "recordId": "746024"
}

File ./examples/results/upload-image-example.json

You can also provide a record Id to the upload method and the file will be uploaded to that record.

          client
            .upload('./assets/placeholder.md', 'Heroes', 'image', recordId)
            .then(result => log('upload-specific-record-example', result)),

Excerpt from ./examples/upload.examples.js

Result:

{
  "modId": "2",
  "recordId": "733119"
}

File ./examples/results/upload-specific-record-example.json

Set Session Globals

The globals method will set global fields for the current session.

client.globals(data, parameters)

InputTypeDescription
dataObjectThe global fields to set for the session
const setGlobals = client =>
  client
    .globals({ 'Globals::ship': 'Millenium Falcon' })
    .then(result => log('set-globals-example', result));

Excerpt from ./examples/globals.examples.js

Result:

{}

File ./examples/results/set-globals-example.json

Utility Methods

The client also provides utility methods to aid in parsing and manipulating FileMaker Data. The client exports the recordId(data), fieldData(data), and transform(data, options) to aid in transforming Data API response data into other formats. Each utility method is capable of recieving either an object or a array.

recordId Method

The recordId method retrieves the recordId properties for a response. This method will return either a single string or an array of strings.

recordId(data)

InputTypeDescription
dataArrayObject
const extractRecordId = client =>
  client
    .find('Heroes', { name: 'yoda' }, { limit: 2 })
    .then(response => recordId(response.data))
    .then(result => log('recordid-utility-example', result));

Excerpt from ./examples/utility.examples.js

Result:

[
  "733119",
  "733125"
]

File ./examples/results/recordid-utility-example.json

fieldData Method

The fieldData method retrieves the fieldData, recordId, and modId properties from a Data API response. The fieldData method will merge the recordId and modId properties into fielData properties. This method will not convert table::field properties.

fieldData(data)

InputTypeDescription
dataArrayObject
const extractFieldData = client =>
  client
    .find('Heroes', { name: 'yoda' }, { limit: 2 })
    .then(response => fieldData(response.data))
    .then(result => log('fielddata-utility-example', result));

Excerpt from ./examples/utility.examples.js

Result:

[
  {
    "name": "Yoda",
    "image(1)": "https://some-server.com/Streaming_SSL/MainDB/9947AD35A5CE2FF5BF085088D09F70AA9C9E8426C65C573872CA015DA76D863C?RCType=EmbeddedRCFileProcessor",
    "object": "",
    "array": "",
    "height": "",
    "id": "300AF47D-13DC-9146-97F6-71AD02DE425D",
    "imageName": "placeholder.md",
    "faceDescriptor": "",
    "recordId": "733119",
    "modId": "2"
  },
  {
    "name": "yoda",
    "image(1)": "",
    "object": "",
    "array": "",
    "height": "",
    "id": "53A5A6BE-D8CB-E145-BF60-9FFBA763D59E",
    "imageName": "",
    "faceDescriptor": "",
    "recordId": "733125",
    "modId": "1"
  }
]

File ./examples/results/fielddata-utility-example.json

Transform Method

The transform method converts Data API response data by converting table::field properties to objects. This method will transverse the response data and converting { table::field : value} properties to { table:{ field : value } }. The transform method will also convert portalData into arrays of objects.

The transform method accepts three option properties. The three option properties are all booleans and true by default. The three option properties are convert,fieldData,portalData. The convert property controls the transfomation of table::field properties. The fieldData property controls the merging of fieldData to the result. The portalData property controls the merging of portalData to the result. Setting any propery to false its transformation off.

transform(data, parameters)

InputTypeDescription
dataArrayObject
parametersObjectThe parameters to use when converting the data.
const transformData = client =>
  client
    .find('Transform', { name: 'Han Solo' }, { limit: 1 })
    .then(result => transform(result.data))
    .then(result => log('transform-utility-example', result));

Excerpt from ./examples/utility.examples.js

Result:

[
  {
    "starships": "",
    "vehicles": "",
    "species": "",
    "biography": "",
    "birthYear": "",
    "id": "193B8CEE-00CE-D942-92F0-FEEF4DA87967",
    "name": "Han Solo",
    "Planets": [
      {
        "recordId": "2",
        "name": "Coriella",
        "modId": "2"
      }
    ],
    "Vehicles": [
      {
        "recordId": "1",
        "name": "Millenium Falcon",
        "type": "Starship",
        "modId": "2"
      }
    ],
    "recordId": "732824",
    "modId": "3"
  }
]

File ./examples/results/transform-utility-example.json

Custom Request Agents, Custom Request Parameters and Proxies

The client has the ability to create custom agents and modify requests parameters or use a proxy. Agents, request parameters, and proxies can be configured either when the client is created or when a request is being made.

Custom Request Agents

A client can have a custom Agent. Using a custom request agent will allow you to configure an agent designed for your specific needs. A request agent can be configured to not reject unauthorized request such as those with invalid SSLs, keep the connection alive, or limit the number of sockets to a host. There is no need to create an agent unless theses options are needed.

Note If you are using a custom agent you are responsible for destroying that agent with client.destroy once the agent is no longer used.

Custom Request Parameters

All client methods except client.login() and client.logout() accept request parameters. These parameters are request.proxy and request.timeout, request.agent. These properties will apply only to the current request.

Proxies

The client can be configured to use a proxy. The proxy can be configured either for every request by specifying the proxy during the creation of the client, or just for a particular request by specifying the proxy in the request parameters.

Tests

npm install
npm test
> fms-api-client@1.0.0 test /Users/luidelaparra/Documents/Development/fms-api-client
> nyc _mocha --recursive  ./tests --timeout=30000 --exit



  Agent Configuration Capabilities
(node:17697) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    βœ“ should accept no agent configuration
    βœ“ should not create an agent unless one is defined (239ms)
    βœ“ adjusts the request protocol according to the server
    βœ“ should create a https agent
    βœ“ should use a created request agent
    βœ“ should destory the agent when the client is deleted
    βœ“ should create a http agent
    βœ“ should accept a timeout property
    βœ“ should use a timeout if one is set
    βœ“ should use a proxy if one is set (226ms)
    βœ“ should automatically recreate an agent if one is deleted (212ms)

  Authentication Capabilities
    βœ“ should authenticate into FileMaker. (101ms)
    βœ“ should automatically request an authentication token (175ms)
    βœ“ should reuse a saved authentication token (183ms)
    βœ“ should log out of the filemaker. (184ms)
    βœ“ should not attempt a logout if there is no valid token.
    βœ“ should reject if the logout request fails (177ms)
    βœ“ should reject if the authentication request fails (1429ms)
    βœ“ should attempt to log out before being removed (175ms)
    βœ“ should catch the log out error before being removed if the login is not valid

  Create Capabilities
    βœ“ should create FileMaker records without fieldData (170ms)
    βœ“ should allow you to specify a timeout
    βœ“ should create FileMaker records using fieldData (80ms)
    βœ“ should create FileMaker records with portalData (90ms)
    βœ“ should allow portalData to be an object or number (85ms)
    βœ“ should reject bad data with an error (84ms)
    βœ“ should create records with mixed types (84ms)
    βœ“ should substitute an empty object if data is not provided (84ms)
    βœ“ should return an object with merged data properties (84ms)
    βœ“ should allow you to run a script when creating a record with a merge response (90ms)
    βœ“ should allow you to specify scripts as an array (96ms)
    βœ“ should allow you to specify scripts as an array with a merge response (92ms)
    βœ“ should sanitize parameters when creating a new record (91ms)
    βœ“ should accept both the default script parameters and a scripts array (95ms)
    βœ“ should remove an expired token (85ms)

  Delete Capabilities
    βœ“ should delete FileMaker records. (268ms)
    βœ“ should allow you to specify a timeout (100ms)
    βœ“ should trigger scripts via an array when deleting records. (164ms)
    βœ“ should trigger scripts via parameters when deleting records. (165ms)
    βœ“ should allow you to mix script parameters and scripts array when deleting records. (166ms)
    βœ“ should stringify script parameters. (175ms)
    βœ“ should reject deletions that do not specify a recordId (81ms)
    βœ“ should reject deletions that do not specify an invalid recordId (75ms)
    βœ“ should remove an expired token (85ms)

  Edit Capabilities
    βœ“ should edit FileMaker records without fieldData
    βœ“ should allow you to specify a timeout (212ms)
    βœ“ should edit FileMaker records using fieldData
    βœ“ should edit FileMaker records with portalData
    βœ“ should edit FileMaker records with portalData and allow portalData to be an array.
    βœ“ should reject bad data with an error (165ms)
    βœ“ should return an object with merged filemaker and data properties
    βœ“ should allow you to run a script when editing a record (176ms)
    βœ“ should allow you to run a script via a scripts array when editing a record (174ms)
    βœ“ should allow you to specify scripts as an array (174ms)
    βœ“ should allow you to specify scripts as an array with a merge response (180ms)
    βœ“ should sanitize parameters when creating a editing record (182ms)
    βœ“ should accept both the default script parameters and a scripts array (180ms)
    βœ“ should remove an expired token (169ms)

  FieldData Capabilities
    βœ“ it should extract field data while maintaining the array (273ms)
    βœ“ it should extract field data while maintaining the object (167ms)

  Find Capabilities
    βœ“ should perform a find request (309ms)
    βœ“ should allow you to use an object instead of an array for a find (208ms)
    βœ“ should specify omit Criterea (137ms)
    βœ“ should allow additional parameters to manipulate the results (81ms)
    βœ“ should allow you to limit the number of portal records to return (88ms)
    βœ“ should allow you to use numbers in the find query parameters (85ms)
    βœ“ should allow you to sort the results (627ms)
    βœ“ should return an empty array if the find does not return results (88ms)
    βœ“ should allow you run a pre request script (96ms)
    βœ“ should return a response even if a script fails (99ms)
    βœ“ should allow you to send a parameter to the pre request script (92ms)
    βœ“ should allow you run script after the find and before the sort (294ms)
    βœ“ should allow you to pass a parameter to a script after the find and before the sort (291ms)
    βœ“ should reject of there is an issue with the find request (87ms)
    βœ“ should remove an expired token (81ms)

  Get Capabilities
    βœ“ should get specific FileMaker records. (280ms)
    βœ“ should allow you to specify a timeout (97ms)
    βœ“ should reject get requests that do not specify a recordId (171ms)
    βœ“ should allow you to limit the number of portal records to return (172ms)
    βœ“ should accept namespaced portal limit and offset parameters (167ms)
    βœ“ should remove an expired token (80ms)

  Global Capabilities
    βœ“ should allow you to set session globals (173ms)
    βœ“ should allow you to specify a timeout
    βœ“ should reject with a message and code if it fails to set a global (78ms)
    βœ“ should remove an expired token (79ms)

  Request Interceptor Capabilities
    βœ“ should reject if the server errors (124ms)
    βœ“ should handle non JSON responses by rejecting with a json error (117ms)
    βœ“ should reject non http requests to the server with a json error
    βœ“ should reject non https requests to the server with a json error (129ms)

  List Capabilities
    βœ“ should allow you to list records (300ms)
    βœ“ should allow you to specify a timeout
    βœ“ should allow you use parameters to modify the list response (82ms)
    βœ“ should should allow you to use numbers in parameters (87ms)
    βœ“ should should allow you to provide an array of portals in parameters (88ms)
    βœ“ should should remove non used properties from a portal object (81ms)
    βœ“ should modify requests to comply with DAPI name reservations (84ms)
    βœ“ should allow strings while complying with DAPI name reservations (79ms)
    βœ“ should allow you to offset the list response (80ms)
    βœ“ should santize parameters that would cause unexpected parameters (83ms)
    βœ“ should allow you to limit the number of portal records to return (83ms)
    βœ“ should accept namespaced portal limit and offset parameters (82ms)
    βœ“ should reject invalid parameters (81ms)
    βœ“ should remove an expired token (81ms)

  RecordId Capabilities
    βœ“ it should extract the recordId while maintaining the array (253ms)
    βœ“ it should extract recordId while maintaining the object (166ms)

  Script Capabilities
    βœ“ should allow you to trigger a script (189ms)
    βœ“ should allow you to specify a timeout
    βœ“ should allow you to trigger a script specifying a string as a parameter (88ms)
    βœ“ should allow you to trigger a script specifying a number as a parameter (87ms)
    βœ“ should allow you to trigger a script specifying an object as a parameter (86ms)
    βœ“ should allow you to trigger a script in a find (222ms)
    βœ“ should allow you to trigger a script in a list (97ms)
    βœ“ should reject a script that does not exist (85ms)
    βœ“ should allow return a result even if a script returns an error (92ms)
    βœ“ should parse script results if the results are json (86ms)
    βœ“ should not parse script results if the results are not json (90ms)
    βœ“ should parse an array of scripts (88ms)
    βœ“ should trigger scripts on all three script phases (91ms)
    βœ“ should remove an expired token (80ms)

  Storage
    βœ“ should allow an instance to be created
    βœ“ should allow an instance to be saved.
    βœ“ should reject if a client can not be validated
    βœ“ should allow an instance to be recalled
    βœ“ should allow instances to be listed
    βœ“ should allow you to remove an instance

  Transform Capabilities
    βœ“ should merge portal data and field data from an array (309ms)
    βœ“ should merge portal data and field data from an object (117ms)
    βœ“ should optionally not convert table::field keys from an array (116ms)
    βœ“ should optionally not convert table::field keys from an object (116ms)
    βœ“ should allow you to remove field data from an array (127ms)
    βœ“ should allow you to remove field data from an object (123ms)
    βœ“ should allow you to remove portal data from an array (170ms)
    βœ“ should allow you to remove portal data from an object (122ms)
    βœ“ should merge portal data and portal data from an array (128ms)

  File Upload Capabilities
    βœ“ should allow you to specify a timeout (193ms)
    βœ“ should allow you to upload a file to a new record (1267ms)
    βœ“ should allow you to upload a buffer to a new record (1342ms)
    βœ“ should allow you to upload a file to a specific container repetition (1270ms)
    βœ“ should allow you to upload a buffer to a specific container repetition (1288ms)
    βœ“ should reject with a message if it can not find the file to upload
    βœ“ should allow you to upload a file to a specific record (1266ms)
    βœ“ should allow you to upload a file to a specific record (1265ms)
    βœ“ should allow you to upload a file to a specific record container repetition (1265ms)
    βœ“ should allow you to upload a buffer to a specific record container repetition (1296ms)
    βœ“ should reject of the request is invalid (232ms)
    βœ“ should remove an expired token (83ms)

  Data Usage 
    Tracks Data Usage
      βœ“ should track API usage data. (181ms)
      βœ“ should allow you to reset usage data. (83ms)
    Does Not Track Data Usage
      βœ“ should not track data usage in (177ms)
      βœ“ should not track data usage out (81ms)

  Utility Capabilities
    Omit Utility
      βœ“ it should remove properties while maintaing the array
      βœ“ it should remove properties while maintaing the object
    Parse Utility
      βœ“ it should return a string when given a string
      βœ“ it should return an object when given a stringified object
    isJson Utility
      βœ“ it should return true for an object
      βœ“ it should return true for an empty object
      βœ“ it should return true for a stringified object
      βœ“ it should return false for a number
      βœ“ it should return false for undefined
      βœ“ it should return false for a string
      βœ“ it should return false for null


  161 passing (28s)

------------------------------|----------|----------|----------|----------|-------------------|
File                          |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
------------------------------|----------|----------|----------|----------|-------------------|
All files                     |      100 |      100 |      100 |      100 |                   |
 fms-api-client               |      100 |      100 |      100 |      100 |                   |
  index.js                    |      100 |      100 |      100 |      100 |                   |
 fms-api-client/src           |      100 |      100 |      100 |      100 |                   |
  index.js                    |      100 |      100 |      100 |      100 |                   |
 fms-api-client/src/models    |      100 |      100 |      100 |      100 |                   |
  agent.model.js              |      100 |      100 |      100 |      100 |                   |
  client.model.js             |      100 |      100 |      100 |      100 |                   |
  connection.model.js         |      100 |      100 |      100 |      100 |                   |
  credentials.model.js        |      100 |      100 |      100 |      100 |                   |
  data.model.js               |      100 |      100 |      100 |      100 |                   |
  index.js                    |      100 |      100 |      100 |      100 |                   |
 fms-api-client/src/services  |      100 |      100 |      100 |      100 |                   |
  index.js                    |      100 |      100 |      100 |      100 |                   |
  transform.service.js        |      100 |      100 |      100 |      100 |                   |
 fms-api-client/src/utilities |      100 |      100 |      100 |      100 |                   |
  conversion.utilities.js     |      100 |      100 |      100 |      100 |                   |
  filemaker.utilities.js      |      100 |      100 |      100 |      100 |                   |
  index.js                    |      100 |      100 |      100 |      100 |                   |
  request.utilities.js        |      100 |      100 |      100 |      100 |                   |
 fms-api-client/tests         |      100 |      100 |      100 |      100 |                   |
  transform.tests.js          |      100 |      100 |      100 |      100 |                   |
------------------------------|----------|----------|----------|----------|-------------------|

Dependencies

  • axios: Promise based HTTP client for the browser and node.js
  • form-data: A library to create readable "multipart/form-data" streams. Can be used to submit forms and file uploads to other web applications.
  • into-stream: Convert a string/promise/array/iterable/buffer/typedarray/arraybuffer/object into a stream
  • lodash: Lodash modular utilities.
  • marpat: A class-based ES6 ODM for Mongo-like databases.
  • moment: Parse, validate, manipulate, and display dates
  • object-sizeof: Sizeof of a JavaScript object in Bytes
  • prettysize: Convert bytes to other sizes for prettier logging
  • uuid: RFC4122 (v1, v4, and v5) UUIDs

Dev Dependencies

  • chai: BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
  • chai-as-promised: Extends Chai with assertions about promises.
  • colors: get colors in your node.js console
  • coveralls: takes json-cov output into stdin and POSTs to coveralls.io
  • deep-map: Transforms nested values of complex objects
  • dotenv: Loads environment variables from .env file
  • eslint: An AST-based pattern checker for JavaScript.
  • eslint-config-google: ESLint shareable config for the Google style
  • eslint-config-prettier: Turns off all rules that are unnecessary or might conflict with Prettier.
  • eslint-plugin-prettier: Runs prettier as an eslint rule
  • fs-extra: fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.
  • http-proxy: HTTP proxying for the masses
  • jsdoc: An API documentation generator for JavaScript.
  • minami: Clean and minimal JSDoc 3 Template / Theme
  • mocha: simple, flexible, fun test framework
  • mocha-lcov-reporter: LCOV reporter for Mocha
  • mos: A pluggable module that injects content into your markdown files via hidden JavaScript snippets
  • mos-plugin-dependencies: A mos plugin that creates dependencies sections
  • mos-plugin-execute: Mos plugin to inline a process output
  • mos-plugin-installation: A mos plugin for creating installation section
  • mos-plugin-license: A mos plugin for generating a license section
  • mos-plugin-snippet: A mos plugin for embedding snippets from files
  • nyc: the Istanbul command line interface
  • prettier: Prettier is an opinionated code formatter
  • varium: A strict parser and validator of environment config variables

License

MIT Β© Lui de la Parra

Keywords

FileMaker

FAQs

Package last updated on 19 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts