fms-api-client 
A FileMaker Data API client designed to allow interaction with a FileMaker application from a web environment.
For in depth documentation: https://luidog.github.io/fms-api-client/Filemaker.html
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
const { connect } = require('marpat');
const { Filemaker } = require('fms-api-client');
const environment = require('dotenv');
const varium = require('varium');
environment.config({ path: './tests/.env' });
varium(process.env, './tests/env.manifest');
connect('nedb://memory').then(db => {
const client = Filemaker.create({
application: process.env.APPLICATION,
server: process.env.SERVER,
_username: process.env.USERNAME,
_password: process.env.PASSWORD,
_layout: process.env.LAYOUT
});
client
.save()
.then(filemaker => {
filemaker
.list('Heroes', { range: 1 })
.then(response => filemaker.fieldData(response.data))
.then(response => console.log('A Long Time Ago', response))
.catch(error => console.log('That is no moon...', error));
filemaker
.create('Heroes', { name: 'Anakin Skywalker' })
.then(response =>
console.log('Jedi business, go back to your drinks!', response)
)
.catch(error => console.log('That is no moon...', error));
filemaker
.globals({ ship: 'Millenium Falcon' })
.then(response =>
console.log(
'Made the Kessel Run in less than twelve parsecs.',
response
)
)
.catch(error => console.log('That is no moon...', error));
return filemaker;
})
.then(filemaker => {
filemaker
.find('Heroes', [{ name: 'Anakin Skywalker' }], { range: '1' })
.then(response => filemaker.recordId(response.data))
.then(recordIds =>
filemaker.edit('Heroes', recordIds[0], { name: 'Darth Vader' })
)
.then(response =>
console.log('I find your lack of faith disturbing', response)
)
.catch(error => console.log('That is no moon...', error));
return filemaker;
})
.then(filemaker => {
filemaker
.find('Heroes', [{ name: 'Anakin Skywalker' }], { range: '1' })
.then(response => filemaker.recordId(response.data[0]))
.then(response => {
console.log(response);
return response;
})
.then(recordId => filemaker.delete('Heroes', recordId))
.then(response => console.log('Fin.', response))
.catch(error => console.log('That is no moon...', error));
});
});
Tests
npm install
npm test
> fms-api-client@0.0.3 test /Users/luidelaparra/Documents/Development/fms-api-client
> mocha --recursive ./tests
FileMaker Data API Client
✓ should allow an instance to be saved.
✓ should get an authentication token. (165ms)
✓ should create FileMaker records. (152ms)
✓ should edit FileMaker records.
✓ should delete FileMaker records.
✓ should get a FileMaker specific record.
✓ should allow you to modify the FileMaker List response (188ms)
✓ should allow you to find FileMaker records (175ms)
✓ should allow you to set FileMaker globals (159ms)
9 passing (877ms)
Dependencies
- lodash: Lodash modular utilities.
- marpat: A class-based ES6 ODM for Mongo-like databases.
- 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.
- 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