This package provides wrapper for FluidCMS RestAPI. The aim of the package is to provide Javascript interface and manage RestAPI itself.
- Typescript support
- Promise based API
- Consistent Interface
- Caching
-
Blackstone Photo gallery
Install from npm
npm install fluidcms-api
or
yarn add fluidcms-api
Initalize by calling FluidCMS function. Provide ready only full access token in the arguments.
import FluidCMS from "fluidcms-api"
const api = FluidCMS("<PROJECT_TOKEN>");
let records = await api.getModel("article")
You can start by getting model records, or creating new records.
import FluidCMS from "fluidcms-api"
const api = FluidCMS("<PROJECT_TOKEN>");
async function getProducts() {
return await api.getAllRecords('product');
}
async function createProduct({ name, tag }) {
let productId = await api.createRecord('article',{
title:"A morning on Mars",
tags:"mars, planets",
});
return productId;
}
- createField
- createModel
- createRecord
- deleteField
- deleteModel
- deleteMultipleRecords
- deleteRecord
- getAllRecords
- getField
- getMedia
- getModel
- getModels
- getRecord
- updateField
- updateModel
- updateRecord
- uploadRecordImage
• new FluidCMS(token
)
Name | Type |
---|---|
token |
string |
• token: string
▸ createField(modelIdentifier
, fieldsData
): Promise
<IModelField
>
Name | Type |
---|---|
modelIdentifier |
string |
fieldsData |
Omit <IModelField , "uid" > |
Promise
<IModelField
>
▸ createModel(fieldsData
): Promise
<string
>
Name | Type |
---|---|
fieldsData |
Omit <IModel , "uid" | "fields" > |
Promise
<string
>
▸ createRecord(modelIdentifier
, fieldsData
): Promise
<string
>
Name | Type |
---|---|
modelIdentifier |
string |
fieldsData |
{ fieldIdentifier : string ; value : any }[] |
Promise
<string
>
▸ deleteField(fieldIdentifier
, modelIdentifier
): Promise
<boolean
>
Name | Type |
---|---|
fieldIdentifier |
string |
modelIdentifier |
string |
Promise
<boolean
>
▸ deleteModel(modelIdentifier
): Promise
<boolean
>
Name | Type |
---|---|
modelIdentifier |
string |
Promise
<boolean
>
▸ deleteMultipleRecords(recordUID
): Promise
<boolean
>
Name | Type |
---|---|
recordUID |
string [] |
Promise
<boolean
>
▸ deleteRecord(recordUID
): Promise
<boolean
>
Name | Type |
---|---|
recordUID |
string |
Promise
<boolean
>
▸ getAllRecords(modelIdentifier
): Promise
<IRecord
[]>
Name | Type |
---|---|
modelIdentifier |
string |
Promise
<IRecord
[]>
▸ getField(fieldIdentifier
, modelIdentifier
): Promise
<IModelField
>
Name | Type |
---|---|
fieldIdentifier |
string |
modelIdentifier |
string |
Promise
<IModelField
>
▸ getMedia(mediaID
): Promise
<Object
>
Name | Type |
---|---|
mediaID |
string |
Promise
<Object
>
▸ getModel(modelIdentifier
): Promise
<IModel
>
Get a model by ID
Name | Type |
---|---|
modelIdentifier |
string |
Promise
<IModel
>
Promise whic resolve to IModel or rejected with APIResponseError
▸ getModels(): Promise
<IModel
[]>
Promise
<IModel
[]>
▸ getRecord(recordUID
): Promise
<IRecord
>
Name | Type |
---|---|
recordUID |
string |
Promise
<IRecord
>
▸ updateField(fieldIdentifier
, modelIdentifier
, fieldsData
): Promise
<boolean
>
Name | Type |
---|---|
fieldIdentifier |
string |
modelIdentifier |
string |
fieldsData |
Partial <Omit <IModelField , "uid" >> |
Promise
<boolean
>
▸ updateModel(modelIdentifier
, fieldsData
): Promise
<boolean
>
Name | Type |
---|---|
modelIdentifier |
string |
fieldsData |
Partial <Omit <IModel , "uid" | "fields" >> |
Promise
<boolean
>
▸ updateRecord(recordUID
, fieldsData
): Promise
<boolean
>
Name | Type |
---|---|
recordUID |
string |
fieldsData |
{ fieldIdentifier : string ; value : any }[] |
Promise
<boolean
>
▸ uploadRecordImage(image
): Promise
<Object
>
Name | Type |
---|---|
image |
File |
Promise
<Object
>