0.0.9 • Published 6 years ago

@deepest-lore/fs-import v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@deepest-lore/fs-import Travis License FOSSA Status Renovate enabled npm npm type definitions

Imports deepest-lore schemas and data from JSON and CSV files on disk.

Example

import fsImport from "@deepest-lore/fs-import"

async function importData() {
  const imported = await fsImport(`base-path`)
  console.log(imported) // { schema: ..., data: { entityTypes: ..., mappings: ... } }
}

File structure

All files are expected to be UTF-8 encoded.

{base directory}/schema.json

The schema, as defined in @deepest-lore/data-model.

{base directory}/entities/{entity type identifier}.csv

Each row defines a single entity instance while the first row defines the columns. The following patterns are supported:

PatternMeaning
$The column defines the entity instance's unique identifier.
col_idThe column defines the value of unlocalized entity type column col_id.
col_id:loc_idThe column defines the value of localized entity type column col_id for localization loc_id.

Example

$,name__:en_gb_,name__:fr_fr_,catgry,weapon,food__,salqty,weight
grpfrt,Grapefruit,Pamplemousse,fruit_,❌,✔️,1,5
lemon_,Lemon,Citron,fruit_,TRUE,Yes,4,2
pebble,Pebble,Caillou,rock__,FALSE,No,50,1
$name_:en_gbname_:fr_frcatgryweaponfood__salqtyweight
grpfrtGrapefruitPamplemoussefruit_✔️15
lemon_LemonCitronfruit_TRUEYes42
pebblePebbleCaillourock__FALSENo501

{base directory}/mappings/{mapping identifier}.csv

Similarly to entity type files, each row defines a single mapping while the first row defines the columns. The following patterns are supported:

PatternMeaning
$key_idThe column defines the mapping key key_id.
col_idThe column defines the value of unlocalized entity type column col_id.
col_id:loc_idThe column defines the value of localized entity type column col_id for localization loc_id.

Example

$item__,$vendor,price_
lemon_,grngcr,0.8
pebble,grngcr,0.5
grpfrt,grngcr,2.4
pebble,rocrus,0.4
$item__$vendorprice_
lemon_grngcr0.8
pebblegrngcr0.5
grpfrtgrngcr2.4
pebblerocrus0.4

License

FOSSA Status

0.0.9

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago