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

flotiq-excel-migrator

v1.0.15

Published

Migrator of of Flotiq data to and from MS Excel

Downloads

255

Readme

Flotiq-Excel migrator

This module migrates Flotiq data to and from an xlsx file. It was made solely for flotiq-cli. However, you can use it independently.

Setup

Add this module to your project and import functions from flotiq-xlsx-migrate.js.

Run yarn to install packages.

Export

exportXlsx is the module's function for exporting Flotiq CTD and CO to the xlsx file.

Usage

Call function exportXlsx with options object as an attribute, for example:

let flotiqXlsx = require("flotiq-excel-migrator")
let exportOptions = { 
    apiKey: "[Flotiq API Key]",
    ctdName: "[CTD API Name]"
}
const exportFromFlotiq = async () => {
    let result = await flotiqXlsx.exportXlsx(exportOptions);
    console.log(result);
}
exportFromFlotiq();

Function returns the following information:

  • FilePath
  • Number of Content Objects for export
  • Number of Content Objects successfully exported
  • errors data

Options parameters

Options object accepts the following parameters:

  • apiKey - API key to your Flotiq account,
  • ctdName - API name of Content Type Definition you wish to export,
  • filePath (optional) - the directory to which the xlsx file is to be saved, the current directory by default,
  • limit (optional) - Number of Content Objects you wish to export, exports up to 10 000 Content Objects by default,
  • saveFile (optional) - boolean value determining whether to save the xlsx file in the directory, true by default. If the value is false, the function will return the parameter data with data from Flotiq converted for MS Excel,
  • logResults (optional) - boolean value determining whether to type out results into the console, true by default.

Notes

  • Exported CTD is saved as plain text of properties id's. No metadata is being exported.
  • Max string length for all values is set to 30.000 because MS Excel has trouble handling text with length > 30 000 in one cell.

Result example

{
  directoryPath: '[_dirname]//test.xlsx',
  errors: null,
  coTotal: 3,
  co_success: 3
}

Import

importXlsx is the module's function for importing an xlsx file to Flotiq.

Usage

Call function exportXlsx with options object as an attribute, for example:

let flotiqXlsx = require("flotiq-excel-migrator")
let importOptions = { 
    apiKey: "[Flotiq API Key]",
    ctdName: "[CTD API Name]",
    filePath: "[path to xlsx file]"
}
const importToFlotiq = async () => {
    let result = await flotiqXlsx.importXlsx(importOptions);
    console.log(result);
}
importToFlotiq();

Function returns the following promise: For every sheet in the workbook:

  • Number of Content Objects successfully imported
  • Number of errors in Content Object import
  • errors data (object)

If options validation error occurs, the function will not return the number of errors and CO exported; instead, it will return information about the invalid options parameter.

Options parameters

Options object accepts the following parameters:

  • apiKey - API key to your Flotiq account,
  • ctdName - API name of Content Type Definition you wish to export,
  • filePath - the directory to the xlsx file you wish to import data from,
  • limit (optional) - number of Content Objects you wish to import, imports up to 10 000 Content Objects by default,
  • logResults (optional) - boolean value determining whether to type out results into the console, true by default.
  • updateExisting (optional) - boolean value determining whether to update existing Content Objects, true by default.
  • batchLimit (optional) - number of Content Objects imported per batch call, 100 by default.

Notes

  • valid XLSX file looks just like the one that exportXlsx saves. The first row on the sheet (header) should have the names of CTD's properties. Every following row is a separate Content Object, for example:

| id | name | age | |--|--|--| | person-1 | John | 30 | | person-2 | Alex | 20 |

  • importXlsx allows you to import many sheets from the same workbook. However, these sheets must be dedicated to the same CTD and have this CTD's properties in the header.
  • Parameter LIMIT limits the number of Content Objects you will import from XLSX works individually for every sheet in the workbook.

Result example

Notice that the import function gives different results for every sheet from your xlsx file, so to read result errors result.[excel sheet name].sheetErrors.

{
  Sheet1: {
    sheetImportedCoCount: 98,
    sheetErrorsCount: 2,
    sheetErrors: [ [Object] ]
  }
  Sheet2: {
    sheetImportedCoCount: 100,
    sheetErrorsCount: 0,
    sheetErrors: []
    }
}

Data mapping

The form in which Flotiq data is exported to / imported from xlsx varies on property type:

| Flotiq field property | Form in which data is exported to xlsx | |--|--| | Text | Text | | Textarea | Text | | Markdown | Text (with markdown syntax) | | Rich text | Text (with HTML tags) | | Email | Text | | Number | Number (with ms excel's default decimal separator) | | Radio | Text | | Checkbox | TRUE / FALSE | | Select | Text | | Relation | API Url's in the form of text, separated with commas, for example: /api/v1/content/[ctdName]/[coName1],/api/v1/content/[ctdName]/[coName2] | | List | JSON | | Geo | JSON | | Media | API Url in form of text, separated with commas, for example: /api/v1/content/_media/[mediaId1],/api/v1/content/_media/[mediaId2] | | Date time | Date | | Block | JSON |

Notes

  • Max string length for all values is set to 30.000 because MS Excel has trouble handling text with length > 30 000 in one cell.