npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fm-data-api

v1.0.5

Published

FileMaker Data Api wrapper for Vue.js

Downloads

7

Readme

A Javascript wrapper based on "myFMApiLibrary for Javascript" by Lesterius (Claris) and using axios library to perform REST request to the FileMaker Data Api

Presentation

Description

This library is a rework of this very good library. The addition of this present library is to use axios in order to generate Promises. It is also available on npm

You will be able to use every functions like it's documented in your FileMaker server Data Api documentation (accessible via https://[your server domain]/fmi/data/apidoc). General Claris document on the Data API is available here

Installation

The recommended way to install it is with :

npm install fm-data-api

After installing, you can call this javascript library by adding:

import DataApi from 'fm-data-api'

In your Javascript application.

Usage

Prepare your FileMaker solution

  1. Enable the FileMaker Data API option on your FileMaker server admin console.
  2. Create a specific user in your FileMaker database with the 'fmrest' privilege
  3. Define records & layouts access for this user

Use the library

Login

Login with credentials:

let options = {
        'apiUrl': 'https://test.fmconnection.com/fmi/data',
        'databaseName' : 'MyDatabase',
        'login' : 'filemaker api user',
        'password' : 'filemaker api password'
    };

let api = new DataApi(options);

Login with oauth:

let options = {
        'apiUrl': 'https://test.fmconnection.com/fmi/data',
        'databaseName' : 'MyDatabase',
        'oAuthRequestId' : 'oAuthIdentifier',
        'oAuthIdentifier' : 'oAuthIdentifier'
    };

let api = new DataApi(options);

Use only generated token:

let options = {
        'apiUrl': 'https://test.fmconnection.com/fmi/data',
        'databaseName' : 'MyDatabase',
        'token' : 'generated token'
    };

let api = new DataApi(options);

To re generate a token, use 'login' function.

/!\ Not available with 'Login with token' method, use 'setApiToken' function.

Logout

dataApi.logout();

Validate Session

dataApi.validateSession();

Create record

let data = {
    'FirstName'         : 'John',
    'LastName'          : 'Doe',
    'email'             : '[email protected]'
};

let scripts = [
    {
        'name'  : 'ValidateUser',
        'param' : '[email protected]',
        'type'  : SCRIPT_PREREQUEST
    },
    {
        'name'  : 'SendEmail',
        'param' : '[email protected]',
        'type'  : SCRIPT_POSTREQUEST
    }
];

let portalData = {
  'portalName or OccurenceName' : [
      {
          "Occurence::PortalField 1" : "Value",
          "Occurence::PortalField 2" : "Value",
      }
  ]
 };

dataApi.createRecord('layout name', data, scripts, portalData).then((recordId) => {
    console.log(recordId)
    // display the recordId's new record.
});

Delete record

dataApi.deleteRecord('layout name', recordId, script);

Edit record

  dataApi.editRecord('layout name', recordId, data, lastModificationId, portalData, scripts).then((recordId) => {
    console.log(recordId)
    // display the recordId's edit record.
});

Duplicate record

  dataApi.duplicateRecord('layout name', recordId, scripts).then((recordId) => {
    console.log(recordId)
    // display the recordId's new record.
});

Get record

let portals = [
    {
        'name'  : 'Portal1',
        'limit' : 10
    },
    { 
        'name'   : 'Portal2',
        'offset' : 3
    }
];

dataApi.getRecord('layout name', recordId, portals, scripts).then((record) => {
    console.log(record)
    // display the wished record.
});

Get records


let sort = [
    {
        'fieldName' : 'FirstName',
        'sortOrder' : 'ascend'
    },
    {
        'fieldName' : 'City',
        'sortOrder' : 'descend'
    }
];

dataApi.getRecords('layout name', sort, offset, limit, portals, scripts).then((record) =>{
    console.log(record)
    // display the wished records.
});

Find records


let query1 = [
    {
        'fields'  : [
            { fieldname : 'd_firstName', fieldvalue : '==Jean'},
            { fieldname : 'd_lastName', fieldvalue : '==Dupond'},
            { fieldname : 'd_age', fieldvalue : '30'},
            { fieldname : 'd_height', fieldvalue : '160...180'},
            { fieldname : 'd_sex', fieldvalue : 'male'},
        ]
    }
];

dataApi.findRecords('layout name', query1, sort, offset, limit, portals, scripts, dataInfo, responseLayout).then((record) => {
    console.log(record)
    // display the wished record.
});

let query2 = [
    {
        'fields'  : [
            { fieldname : 'd_firstName', fieldvalue : '==Jean'},
            { fieldname : 'd_lastName', fieldvalue : '==Dupond'},
            { fieldname : 'd_age', fieldvalue : '30'},
            { fieldname : 'd_height', fieldvalue : '160...180'},
            { fieldname : 'd_sex', fieldvalue : 'male'},
            { omit : true }
        ]
    }
];

dataApi.findRecords('layout name', query2, sort, offset, limit, portals, scripts, dataInfo, responseLayout).then((record) => {
    console.log(record)
    // display the wished record.
});

let query3 = [
    {
        'fields'  : [
            { fieldname : 'd_firstName', fieldvalue : '==Marie'},
            { fieldname : 'd_age', fieldvalue : '20...30'},
        ]
    },
    {
        'fields'  : [
            { fieldname : 'd_firstName', fieldvalue : '==Ernest'},
            { fieldname : 'd_height', fieldvalue : '150...180'},
            { fieldname : 'd_sex', fieldvalue : 'male'},
        ]
    }
];

dataApi.findRecords('layout name', query3, sort, offset, limit, portals, scripts, dataInfo, responseLayout).then((record) => {
    console.log(record)
    // display the wished record.
});

In this example of request query1 will find people named Jean Dupond AND who are 30 years old AND with an height between 160 and 180 cm AND who are male.

query2 will find all the people who don't match these criteria

query3 will find people named Marie AND who are between 20 and 30 years old, OR people named Ernest AND with an height between 150 and 180 cm AND who are male.

The dataInfo option is by default on false, on true it will provide the records on this form :

{
    "response": {
        "dataInfo": {
            "database": "XXXXX",
            "layout": "XXXXX",
            "table": "XXXXX",
            "totalRecordCount": 29,
            "foundCount": 29,
            "returnedCount": 9
        },
        "data": [{
            "fieldData": {
                "d_descriptif": "zzzzz",
                "d_prix": "zzzzz",
                .
                .
                .
            },
            "portalData": {},
            "recordId": "35",
            "modId": "0"
        }, {
            "fieldData": {
                "d_descriptif": "zzzzz",
                "d_prix": "zzzzz",
                .
                .
                .
            },
            "portalData": {},
            "recordId": "32",
            "modId": "2"
        },
        .
        .
        .
        ]
    },
    "messages": [{
        "code": "0",
        "message": "OK"
    }]
}

which bring the data foundCount, for example. By default the data form is :

[
        {
            "fieldData": {
                "d_descriptif": "zzzzz",
                "d_prix": "zzzzz",
                .
                .
                .
            },
            "portalData": {},
            "recordId": "35",
            "modId": "0"
        }, {
            "fieldData": {
                "d_descriptif": "zzzzz",
                "d_prix": "zzzzz",
                .
                .
                .
            },
            "portalData": {},
            "recordId": "32",
            "modId": "2"
        },
        .
        .
        .
]

Set global fields


let data = {
  'FieldName1'	: 'value',
  'FieldName2'	: 'value'
};

dataApi.setGlobalFields('layout name', data);

Execute script

dataApi.executeScript('script name', scriptsParams).then((result) => {
    console.log(result)
    // display the script result.
});

Upload file to container

dataApi.uploadToContainer('layout name', recordId, containerFieldName, containerFieldRepetition, file);

Metadata Info

Product Info

dataApi.getProductInfo();

Database Names

/!\ Not available with 'Login with token' method

dataApi.getDatabaseNames();

Layout Names

dataApi.getLayoutNames();

Script Names

dataApi.getScriptNames();

Layout Metadata

dataApi.getLayoutMetadata('layout name', recordId);