fms-api-client 
A FileMaker Data API client designed to allow interaction with a FileMaker application from a web environment.
Installation
This is a Node.js module available through the
npm registry. It can be installed using the
npm
or
yarn
command line tools.
npm install fms-api-client --save
Usage
'use strict';
const environment = require('dotenv');
const varium = require('varium');
const colors = require('colors');
const { connect } = require('marpat');
const { Filemaker } = require('./filemaker');
environment.config({ path: './tests/.env' });
varium(process.env, './tests/env.manifest');
connect('nedb://data').then(db => {
const client = Filemaker.create({
application: process.env.APPLICATION,
server: process.env.SERVER,
user: process.env.USERNAME,
password: process.env.PASSWORD,
layout: process.env.LAYOUT
});
client
.save()
.then(client => {
return Promise.all([
client.create('Heroes', { name: 'Anakin Skywalker' }),
client.create('Heroes', { name: 'Obi-Wan' }),
client.create('Heroes', { name: 'Yoda' })
]).then(response => {
console.group();
console.log('A Long Time Ago...'.rainbow);
console.log(response);
console.groupEnd();
return client;
});
})
.then(client => {
client
.list('Heroes', { range: 5 })
.then(response => client.fieldData(response.data))
.then(response => {
console.group();
console.log(
' For my ally is the Force, and a powerful ally it is.'.underline
.green
);
console.log(response);
console.groupEnd();
})
.catch(error => {
console.group();
console.log('That is no moon...'.red);
console.log(error);
console.groupEnd();
});
client
.globals({ ship: 'Millenium Falcon' })
.then(response => {
console.group();
console.log(
'Made the Kessel Run in less than twelve parsecs.'.underline.blue
);
console.log(response);
console.groupEnd();
})
.catch(error => {
console.group();
console.log('That is no moon...'.red);
console.log(error);
console.groupEnd();
});
return client;
})
.then(client =>
client
.find('Heroes', [{ name: 'Anakin Skywalker' }], { range: 1 })
.then(response => client.recordId(response.data))
.then(recordIds =>
client.edit('Heroes', recordIds[0], { name: 'Darth Vader' })
)
.then(response => {
console.group();
console.log('I find your lack of faith disturbing'.underline.red);
console.log(response);
console.groupEnd();
})
.catch(error => {
console.group();
console.log('That is no moon...'.red);
console.log(error);
console.groupEnd();
})
);
});
const rewind = () => {
Filemaker.findOne().then(client => {
client
.find('Heroes', [{ id: '*' }], { range: 150 })
.then(response => client.recordId(response.data))
.then(response => {
console.group();
console.log('Be Kind.... Rewind.....'.rainbow);
console.log(response);
console.groupEnd();
return response;
})
.then(recordIds =>
recordIds.forEach(id => {
client.delete('Heroes', id).catch(error => {
console.group();
console.log('That is no moon...'.red);
console.log(error);
console.groupEnd();
});
})
);
});
};
setTimeout(function() {
rewind();
}, 10000);
Tests
npm install
npm test
> fms-api-client@0.0.4 test /Users/luidelaparra/Documents/Development/fms-api-client
> mocha --recursive ./tests
FileMaker Data API Client
β should allow an instance to be saved.
β should authenticate into FileMaker. (165ms)
β should create FileMaker records. (243ms)
β should update FileMaker records.
β should delete FileMaker records.
β should get a FileMaker specific record.
β should allow you to list FileMaker records (419ms)
β should allow you to modify the FileMaker list response (403ms)
β should allow allow a list response to be set with numbers (332ms)
β should allow you to find FileMaker records (245ms)
β should allow you to set FileMaker globals (264ms)
11 passing (2s)
Dependencies
- lodash: Lodash modular utilities.
- moment: Parse, validate, manipulate, and display dates
- request: Simplified HTTP request client.
- request-promise: The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
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
- 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
- jsdocs: jsdocs
- minami: Clean and minimal JSDoc 3 Template / Theme
- mocha: simple, flexible, fun test framework
- package-json-to-readme: Generate a README.md from package.json contents
- prettier: Prettier is an opinionated code formatter
- varium: A strict parser and validator of environment config variables
License
MIT