Node-RED FileMaker nodes. These nodes use fms-api-client to connect to FileMaker Server. Each node exposes an fms-api-client method or utility. Nodes connecting to FileMaker Server depend upon a configurable FileMaker Data API client.
The nodes in this project use fms-api-client to connect via the FileMaker Data API to FileMaker Server. The nodes that connect to FileMaker Server depend upon a configurable client node. The client node uses marpat to store and maintain FileMaker Data API session information in-memory, on the filesystem, or in a MongoDB cluster. Persistence is configured via Node-RED's settings file. For more information see the storage section. For security client configuration parameters are not exported with a flow.
Once configured a client node will automatically create and maintain a FileMaker Data API session as needed. You are not required to call the login or logout nodes in a flow.
Each node can be configured to use either static or dynamic parameters. Dynamic parameters may be
read from either the msg
property or the flow
and global
contexts. The default output of each node is msg.payload
. A node can also be configured to merge its output with any property on the msg
object.
:v: and :heart: - Lui de la Parra
These nodes can be installed from the command line by running the following command in your Node-RED directory:
npm install --save node-red-contrib-filemaker
These nodes can also be installed using the Node-RED palette manager.
The nodes in this project all depend on a configurable Data API client. By default the client is saved in-memory. When saved in-memory a client will not persist between restarts of the Node-RED runtime. This means that each restart of the Node-RED runtime will cause the client to open new Data API sessions.
To persist a client between Node-RED runtime restarts and allow active session monitoring and maintenance additional datastores can be configured. This project will accept a url property and an options property from a marpat object in the Node-RED settings.js file. Any datastore made available by marpat. The url property accepts the following formats:
mongodb://[username:password@]host[:port][/db-name]
nedb://[directory-path]
nedb://memory
Stroage Configuration Example:
module.exports = {
// the tcp port that the Node-RED web server is listening on
uiPort: process.env.PORT || 1880,
marpat: { url: process.env.DATASTORE, options: {} }
File ./red.dev.config.js
The status node will return the current state of the configured client. The status node will return the client's data usage, urls for all pending and queued requests, and currently open sessions.
The login node will open a FileMaker Data API session. This node will also save the resulting session token for future use by the configured client. You are not required to login before using any other node in a flow.
The logout node closes the currently open Data API session and removes the associated session token. You are not required to logout at the end of a flow.
The product info node gets server product info. This node gets metadata for the FileMaker server the client is configured to use.
The databases node gets all the scripts and script folders accesible to the client.
These nodes can be installed from the command line by running the following command in your Node-RED directory:
These nodes can also be installed using the Node-RED palette manager.
The database scripts node gets all the scripts and script folders accesible to the client.
The database layouts node gets all the layouts and layout folders accesible to the client.
The layout info node gets metadata information for fields and portals on the specified layout.
The create node creates a record in FileMaker. By default The create node will use the value in msg.payload.layout
as the layout context and msg.payload.data
for setting field and portal data.
The edit node edits a specific record in FileMaker. By default the edit node will use msg.payload.recordId
as the record id to target for editing, the data found in msg.payload.data
for editing field and portal data, and msg.payload.layout
as the layout context.
The delete node deletes a specific record in FileMaker. By default the delete node will use msg.payload.recordId
as the record id to target for deletion and msg.payload.layout
as the layout context.
The get node retrieves a specific FileMaker record. By default the get node will use msg.payload.layout
as the layout context, and msg.payload.recordId
as the record id to target.
The get node retrieves a specific FileMaker record. By default the get node will use msg.payload.layout
as the layout context, and msg.payload.recordId
as the record id to target.
The List node lists FileMaker records for a specified layout. By default the list node will use the value found in msg.payload.layout
as the layout context.
The find node performs a find in FileMaker. By Default the find node will user msg.payload.layout
as the layout context, and msg.payload.query
as query parameters for the find.
The script node will trigger a script in FileMaker. By default the script node will use msg.payload.layout
as the layout context, and msg.payload.script
as the script to run. An optional script parameter may also be passed using msg.payload.parameter
.
The upload node will transfer binary data to a FileMaker container. By default the upload node will use msg.payload.file
as either a string path or buffer object and msg.payload.layout
as the layout context.
The globals node will set global record field values for the current FileMaker session. The globals node will use msg.payload.data
to set global fields.
The field data node reduces the data found in msg.payload.data
to only include the modId
, recordId
, and fieldData
properties.
The record ids node reduces the data found in msg.payload.data
to only include the recordId
property.
The tranform node transforms data in msg.payload.data
. It reduces { table::field : value }
properties to { table: { field : value } }
properties.
The container node retrieves container data from msg.payload.data
. The container node requires a container
property, a filename
property, and a destination
property. Each property should be a dot notation
path to the required data, such as fieldData.container
and fieldData.fileName
. If the configured path does not exist it will be automatically created.
npm install
npm test
> node-red-contrib-filemaker@2.3.1 test node-red-contrib-filemaker
> snyk test && nyc _mocha --recursive "test/**/*_spec.js" --timeout=30000 --exit
Testing /node-red-contrib-filemaker...
Organization: luidog
Package manager: npm
Target file: package-lock.json
Open source: yes
Project path: /node-red-contrib-filemaker
Local Snyk policy: found
Licenses: enabled
✓ Tested 364 dependencies for known issues, no vulnerable paths found.
Client Node
Client Save
✓ should save on close
Reused Client Tests
✓ should be loaded
✓ should create a persistent client (152ms)
✓ should reuse a client (113ms)
✓ should allow a client's server configuration to be modified
✓ should allow a client's database configuration to be modified
✓ should allow a client's account user configuration to be modified
✓ should allow a client's account password configuration to be modified
✓ should allow multiple clients
✓ should create a client of one does not exist
✓ should reuse a client if it exists
✓ should handle datastore errors
New Client Tests
✓ should be loaded
✓ should create a persistent client (215ms)
✓ should reuse a client (113ms)
✓ should allow a client's server configuration to be modified
✓ should allow a client's database configuration to be modified
✓ should allow a client's account user configuration to be modified
✓ should allow a client's account password configuration to be modified
✓ should allow multiple clients
✓ should create a client of one does not exist
✓ should reuse a client if it exists
✓ should handle datastore errors
Container Data Node
✓ should be loaded
✓ should download an object with container data to a buffer (547ms)
✓ should download an array of objects with container data to a buffer (2579ms)
✓ should download an object with container data to the filesystem (1526ms)
✓ should download an array of objects with container data to the filesystem (1430ms)
✓ should throw an error with a message and a code when writing an object to a buffer and an error is triggered
✓ should throw an error with a message and a code when writing an array to a buffer an error is triggered
✓ should handle undefined data input when writing to a buffer
✓ should handle undefined data input when writing to a file
✓ should throw an error when writing data to the filesystem and an error is triggered
✓ should throw an error with a message and a code when writing to a buffer and an array is triggered
Create Record Node
✓ should be loaded
✓ should create a record (208ms)
✓ should allow the filemaker response to be merged to the message object (308ms)
✓ should use flow context to create a record. (217ms)
✓ should use global context to create a record. (209ms)
✓ should throw an error with a message and a code (264ms)
Databases Node
✓ should be loaded
✓ should return available databases (89ms)
✓ should reject with an error message and a code (115ms)
✓ should reject if a client can not be initialized
Delete Record Node
✓ should be loaded
✓ should delete a record (345ms)
✓ should throw an error with a message and a code (214ms)
✓ should handle client initilization errors
Duplicate Record Node
✓ should be loaded
✓ should duplicate a record (356ms)
✓ should reject with an error message and a code (206ms)
✓ should rehject with an error if the client cannot be initialized
Edit Record Node
✓ should be loaded
✓ should edit a record (357ms)
✓ should support merging data when editing a record (356ms)
✓ should throw an error with a message and a code (225ms)
✓ should reject with an error if a client cannot be initialized
FieldData Utility Node
✓ should be loaded
✓ should transform an array of objects (370ms)
✓ should transform a a single object (386ms)
✓ should reject with an error message and code
Find Records Node
✓ should be loaded
✓ should perform a find (352ms)
✓ should handle client connection errors
✓ should handle client initialization errors
✓ allows multiple clients
✓ will reuse previous clients
✓ should throw an error with a message and a code (158ms)
Get Record Node
✓ should be loaded
✓ should get a specific record (408ms)
✓ should throw an error with a message and a code (144ms)
✓ should handle client connection errors
Set Globals Node
✓ should be loaded
✓ should set globals (169ms)
✓ should throw an error with a message and a code (162ms)
✓ should reject with an error if the client cannot be initialized
Layout Info Node
✓ should be loaded
✓ should get layout information (168ms)
✓ should throw an error with a message and a code (172ms)
✓ should throw an error with a message and a code
Get Layouts Node
✓ should be loaded
✓ should return a list of layouts (168ms)
✓ should reject with an error message and a code
✓ should reject if a client cannot be initialized
List Records Node
✓ should be loaded
✓ should List records (405ms)
✓ should throw an error with a message and a code (164ms)
✓ should reject with an error if a client cannot be initialized
Login Node
✓ should be loaded
✓ should login to a Data API session (104ms)
✓ should throw an error with a message and a code (1437ms)
✓ should reject with an error if a client cannot be initialized
Logout Node
✓ should be loaded
✓ should close a Data API Session (656ms)
✓ should throw an error with a message and a code
✓ should throw an error if a client cannot be initialized
Product Info Node
✓ should be loaded
✓ should return Data API Server Info (93ms)
✓ should reject with an error message and a code (102ms)
✓ should reject with an error if the client cannot be initialized
Record Id Utility Node
✓ should be loaded
✓ should extract record ids from a single object (338ms)
✓ should extract record ids from an array of objects (258ms)
✓ should reject with an error message and a code
Trigger Script Node
✓ should be loaded
✓ should trigger a script (193ms)
✓ should parse a script result if it is valid json (165ms)
✓ should not parse a script result if it is not valid json (182ms)
✓ should throw an error with a message and a code (274ms)
✓ should throw an error if a client cannot be initialized
Get Scripts Node
✓ should be loaded
✓ should return a list of scripts (176ms)
✓ should reject with an error message and a code
✓ should throw an error if a client cannot be initialized
Utility Services
merge utility
✓ should merge data to the payload object
sanitize utility
✓ should discard unspecified properties
compact utility
✓ should accept an array of objects
✓ should remove null properties
✓ should remove null properties
✓ should remove empty strings
✓ should not remove false values
✓ should discard non json values
✓ should discard non json values
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
castBoolean Utility
✓ it should cast a true string as true boolean
✓ it should cast a false string as false boolean
✓ it should cast multiple string values as booleans
✓ it should only cast strings of true or false
Client Status Node
✓ should be loaded
✓ should return Data API Client Status
✓ should reject with an error if the client cannot be initialized
Transform Utility Node
✓ should be loaded
✓ should transform an array of objects (411ms)
✓ should transform a single object (270ms)
✓ should throw an error with a message and a code
Upload File Node
✓ should be loaded
✓ should upload to an existing record (436ms)
✓ should upload to a file to a new record (1455ms)
✓ should throw an error with a message and a code
✓ should throw an error if a client cannot be initialized
146 passing (1m)
-----------------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-----------------------|----------|----------|----------|----------|-------------------|
All files | 100 | 100 | 100 | 100 | |
client | 100 | 100 | 100 | 100 | |
client.js | 100 | 100 | 100 | 100 | |
nodes | 100 | 100 | 100 | 100 | |
containerData.js | 100 | 100 | 100 | 100 | |
create.js | 100 | 100 | 100 | 100 | |
databases.js | 100 | 100 | 100 | 100 | |
delete.js | 100 | 100 | 100 | 100 | |
duplicate.js | 100 | 100 | 100 | 100 | |
edit.js | 100 | 100 | 100 | 100 | |
fieldData.js | 100 | 100 | 100 | 100 | |
find.js | 100 | 100 | 100 | 100 | |
get.js | 100 | 100 | 100 | 100 | |
globals.js | 100 | 100 | 100 | 100 | |
layout.js | 100 | 100 | 100 | 100 | |
layouts.js | 100 | 100 | 100 | 100 | |
list.js | 100 | 100 | 100 | 100 | |
login.js | 100 | 100 | 100 | 100 | |
logout.js | 100 | 100 | 100 | 100 | |
productInfo.js | 100 | 100 | 100 | 100 | |
recordId.js | 100 | 100 | 100 | 100 | |
script.js | 100 | 100 | 100 | 100 | |
scripts.js | 100 | 100 | 100 | 100 | |
status.js | 100 | 100 | 100 | 100 | |
transform.js | 100 | 100 | 100 | 100 | |
upload.js | 100 | 100 | 100 | 100 | |
services | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
utilities.service.js | 100 | 100 | 100 | 100 | |
-----------------------|----------|----------|----------|----------|-------------------|
MIT © Lui de la Parra