Giter Site home page Giter Site logo

siemienik / xtoolset Goto Github PK

View Code? Open in Web Editor NEW
170.0 9.0 34.0 7.56 MB

Typed import, and export XLSX spreadsheet to JS / TS. Template-based create, render, and export data into excel files.

Home Page: https://siemienik.com/docs/xtoolset

License: MIT License

TypeScript 99.13% JavaScript 0.87%
hacktoberfest xlsx excel workbook worksheet import xlsx-import xlsx-parser xlsx-to-json javascript

xtoolset's Introduction

๐Ÿ‘‹ Siema, say hello to open source!

Hi, I'm Siemienik, a passionate software developer specialized in creating reusable tools, modules, and open-source components. I am currently open for job opportunities and available for B2B projects.

๐ŸŒŸ Featured Projects

๐ŸŒ Connect with me

๐Ÿš€ Open Source Support Group

I'm planning to create a group of people who will support the development of selected open-source projects. We'll communicate on Discord and you can support me on GitHub Sponsors. Feel free to join our community and contribute to the world of open-source software!

๐Ÿ’ผ Job Opportunities and B2B Projects

I am currently open for job opportunities and available for B2B projects. With extensive experience in software development, team leadership, and project management, I am well-versed in multiple programming languages, frameworks, and databases. For more information about my professional background, please refer to my CV below or check my LinkedIn profile.

๐Ÿ“„ View my CV


Metrics

xtoolset's People

Contributors

alinakul avatar dependabot[bot] avatar edmondop avatar fossabot avatar gitter-badger avatar jacekkoziol avatar lowkeypriority avatar machadolucasvp avatar maryiabydanova avatar metastasis avatar michalp4 avatar siemienik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xtoolset's Issues

Add isEmpty into mappers

Part of #21

TODO:

  1. Create file src/mappers/isEmpty.ts with function matches to type ValueMapper<boolean>. Which examine if input is empty
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  { inValue: '', expectedResult: true },
  { inValue: null, expectedResult: true },
  { inValue: ' ', expectedResult: false }, // it is quite problematic case, however it isn't empty
  { inValue: 'null', expectedResult: false },
  { inValue: 'a', expectedResult: false},
  { inValue: 'as d', expectedResult: false },
]

For making a reservation please open draft PR with this issue linked

[Proposal] The paginator

The paginator

I want to propose add possibility to paginate result into xlsx-import, I suppose that should improve performance for larger files. I have no idea how it should be done yet, but this issue is only a proposition. So any ideas are welcome ๐Ÿค—

Current:

Function getAllItems return all items from imported worksheet

https://github.com/Siemienik/xlsx-import/blob/4c74089/src/Importer.ts#L11-L17

After:

const importer = new PaginatedImporter(workbook);

 importer.getItems(cfg, 0, 100); // 1s "page": {offset:0, amount: 100}

 importer.getItems(cfg, 4*100, 100); // 5th "page": {offset:400, amount: 100}

Possible problems

Afaik, ExcelJS hasn't option to stop and resume function ws.eachRow. We use this function in verticalListStrategy. (probably resolved by: #80)

Add upperCaseMapper into mappers

Part of #21

TODO:

  1. Create file src/mappers/upperCaseMapper.ts with function matches to type (v: string): string. Which for any input try to return only upper case string.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test (create new one in tests/unit/mappers.test.ts)
  4. Describe it in Readme.md

test data provider:

const upperCaseDp = [
  { inValue: '', expectedResult: '' },
  { inValue: 'asd', expectedResult: 'ASD' },
  { inValue: 'Asd', expectedResult: 'ASD' },
  { inValue: 'ASD', expectedResult: 'ASD' },
  { inValue: 'asd ASD', expectedResult: 'ASD ASD' },
]

Add customisation for default response from jsonMapper

Actual

The jsonMapper described in #40 and implemented in #43 has fallback mechanism that return null if parsing json failed.

Expected

Default response should be customisable by calling jsonMapper.default<TDefaultResult>(defaultResult: TDefaultResult) which produce mapper with return type TJsonResult | TDefaultResult.

Example usage:

const statusMapper = jsonMapper.default<Stats>({views: 0, unique: 0, stars: 0})

// returns default = {views: 0, unique:0, starts:0} for invalide
const stats = statusMapper<Stats>('invalid');

// returns parsed = {views: 1234, unique:10, starts:40}
const stats2 = statusMapper<Stats>('{"views": 123, "unique":10, "starts":40}');

// in a config: (column definition for vertical list)
// {key:"stats", index:5, mapper: jsonMapper.default<Stats>({views: 0, unique: 0, stars: 0})} 

TODO:

  1. Introduce factory similar like in splitMapper:
    • define JsonMapper type
    • wrap mapper into factory function
    • implement setting default
    • produce and export default jsonMapper created by the factory
  2. prove that it works by covering new changes by unit tests
  3. describe jsonMapper api in a Readme.md

Add GH action for automatically markdown formatting + commit

As mention @lowkeypriority in #26. It will be nice to have pretty well formatted README. To keep high quality level without effort to contributor works I want to:

  1. Add workflow: Quality Assistance
  2. On pull_request push events format all *.md inside repo,
  3. Detected changes commit into PR ref branch with message "[QA] Markdown formatted automatically"
  4. If any of rules cannot be resolve automatically then fail workflow

As starting set of rules we may use proposed by @lowkeypriority in #26:

I'm suggesting to format README with markdown rules from markdownlint repo

Renderer command line interface

Introduction

Solving this issue should allow using xlsx-renderer from the command line.

Example:

image

proposed usages:

# Basic
sxr template.xlsx '{"jsonData":true"}' > output.xlsx
sxr -o output.xlsx  template.xlsx '{"jsonData":true"}'
cat vm.json | sxr template.xlsx > output.xlsx

# More advanced
sxr --model vm.json template.xlsx > output.xlsx
sxr --type json --model vm.json template.xlsx > output.xlsx
sxr --type xml --model vm.xml template.xlsx > output.xlsx
sxr --type xml template.xlsx '<someData></someData>'  > output.xlsx 
sxr --type xml --model vm.xml -o output.xlsx template.xlsx 


# Example how it will work with Xlsx-import-cli (sxi)
sxi -d books-def.json input.xlsx | sxr template.xlsx > beauty-books.xlsx

command body:

sxr [options] <template> [model]

Arguments

  • <template> indicate which file is used as the template
  • [model] view model as a json used to generate a spreadsheet,

Options

  • -o --output <filename> write to filename
  • -m --model <filename> read filename as a [model] (using both is denied)
  • -o --output <filename> write result into filename
  • Proposal: -t --type <type: json|xml> specify parser for a model, default it is a JSON.

Add isValue into mappers

Part of #21

TODO:

  1. Create file src/mappers/isValue.ts with function matches to type (...acceptedValues:string[]) => ValueMapper<boolean>. Which check value to be included in accepted values. Returns false if no accepted values provided.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  // without accepted values
  { inValue: '', inAcceptedValue:[], expectedResult: false },
  { inValue: 'TRUE', inAcceptedValue:[], expectedResult: false },
  { inValue: 'X', inAcceptedValue:[], expectedResult: false },
  { inValue: '1', inAcceptedValue:[], expectedResult: false },
  { inValue: 'FALSE', inAcceptedValue:[], expectedResult: false },
  { inValue: 'Lorem', inAcceptedValue:[], expectedResult: false },

  // with one accepted value
  { inValue: '', inAcceptedValue:['X'], expectedResult: false },
  { inValue: 'TRUE', inAcceptedValue:['X'], expectedResult: false },
  { inValue: 'X', inAcceptedValue:['X'], expectedResult: true },
  { inValue: '1', inAcceptedValue:['X'], expectedResult: false },
  { inValue: 'FALSE', inAcceptedValue:['X'], expectedResult: false },
  { inValue: 'Lorem', inAcceptedValue:['X'], expectedResult: false },

  // with more than one accepted value
  { inValue: '', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: false },
  { inValue: 'TRUE', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: true },
  { inValue: 'X', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: true },
  { inValue: '1', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: true },
  { inValue: 'FALSE', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: false },
  { inValue: 'Lorem', inAcceptedValue:['X', 'TRUE', '1'], expectedResult: false },

  // with different case
  { inValue: 'TRUE', inAcceptedValue:['true'], expectedResult: true },
  { inValue: 'X', inAcceptedValue:['x'], expectedResult: true },
];

For making a reservation please open draft PR with this issue linked

Import errors

Hi, I am using a default typescript config. And its telling me that it does not find your module. How do you import it?
I am trying import ImporterFactory from 'xlsx-import/ImporterFactory' but I tried several other ways as well.

Realease version 2.3.2

At 18/19th Oct. 2020.

Including: v2.3.1...master

TODO:

NICE TO HAVE:

  • #4 Checked browser support
  • #6 At least one frontend example - if works with frontend

for me it's amazing how much was recently done ๐Ÿค—

[Refactoring] Rename variable

[Q&A] How to handle multiple rows of headers?

Hi, how to read sheet with multiple rows of header? Is it possible at all? (For example, first row we have gender spanning two cells, second row we have male and female each in one cell, is it possible to preserve this data?) Thanks!

[Proposal] Config builder

The Config Builder - still DRAFT

Please do not start until it is a draft

Place of live

./src/configBuilder/

Sample usages

const cfg = ListCfgBuilder.createList()
  .worksheet('asd')
  .column('key', 1 ,integerMapper)
  .column('key2' 2, splitMapper.separator(':'))
  .toConfig(); // or .build() - or event better, put this cfg directly into getAllItems() 

// and
const cfg2 =ListCfgBuilder.from(cfg)
  .worksheet('second')
  .getConfig();


// json support
const asJson = CfgBuilder.from(cfg).toJson();

const fromJson = CfgBuilder.from(asJson, {type: 'json'}).toConfig();

TODO

  • ListVerticalConfigBuilder
  • SingleObjectConfigBuilder
  • Research required: ConfigBuilder for both
  • toJson/fromJson (ConfigWriter/ConfigReader)
    • string representation for mappers

Draft's todo:

  • analysis discriminator for reading config
  • become sure about APIs
  • create issues for each TODO Point
  • consider about moving ConfigWriter & Reader out of scope of this issue
  • write about motivations to add it into project

Common mappers implementation

The PR #20 refactor how the code is organised. Among others there was created new layer called mappers (src/mappers) and here I will describe how I plan to expand it.

Remark:

I marked this issue as good first issue because it contains list of simple and well described issues. Good practice is create one PR for one of these issues.

Actual

There is only file named index.ts with MAPPER_DEFAULT introduce in #19.

Expected

This should contains handy and the most popular mappers ready to use. The first mappers how I consider to do is:

  • #23 upperCaseMaper: Some Text => SOME TEXT
  • #22 lowerCaseMaper : Some Text => some text
  • #37 isEmpty - true if has no value
  • #39 isFilled - true if any value provided
  • #40 jsonMapper : '{prop:[1,2]}' (string) => {prop:[1,2]} (object with array)
  • #24 splitMapper: val1,val2,val3 => [val1,val2,val3]
  • #46 numberMapper : 123 (string) => 123 (number)
  • #48 integerMapper: Number.parseInt
  • #53 booleanMapper: 0 => false
  • #58 dateMapper: transform date string into Date, same as new Date
  • #59 isValue - true if value match
  • regexMapper - true if matches to regex EDIT: for further development
  • decimalMapper: has to define **EDIT: ** for further development`

For each mapper I'm going to create new issue.

Request for a mapper

This issue is great a place to propose mappers, so if you have any idea, write a comment.

Add booleanMapper into mappers

Part of #21

TODO:

  1. Create file src/mappers/booleanMapper.ts with function matches to type ValueMapper<boolean>. Which parse value string into boolean.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  { inValue: null, expectedResult: false },
  { inValue: '', expectedResult: false },
  { inValue: '  ', expectedResult: false },
  { inValue: '0', expectedResult: false },
  { inValue: '000', expectedResult: false },
  { inValue: 'true', expectedResult: false },
  { inValue: 'false', expectedResult: false },
  { inValue: 'a0.1', expectedResult: false},

  { inValue: '001', expectedResult: true },
  { inValue: '123', expectedResult: true },
  { inValue: '0.1', expectedResult: true},
  { inValue: '-1', expectedResult: true},
  { inValue: '   -1.2123asd', expectedResult: true}
];

tips:

  • I propose to use Boolean(Number())

For making a reservation please open draft PR with this issue linked

[Proposal]Wiki docs

It's a lot of documentation in source code, for example here:
https://github.com/Siemienik/xlsx-renderer/blob/release/v1/src/xls-renderer/cell/ForEachCell.js#L5

/**
 * Pattern: `#! FOR_EACH [TARGET] [FROM]`
 * Iterate through `vm[FROM]` and store current item in readonly `vm[TARGET]`.
 * `vm[TARGET]` has additional fields:
 *
 * * `__from` - keeps `FROM` parameter's value
 * * `__index` - current 1-based iteration index (`vm[TARGET]` is `vm[FROM][__index-1]`)
 * * `__start` - template foreach start cell
 * * `__end` - template loop's end cell, it is undefined before first `END_LOOP`
 * * `__iterated` - iteration has been finished
 * * `__insetRows` - second and next iterations have to insert new rows
 * * `__startOutput` - first output cell
 * * `__endOutput` - last output cell
 */

It's nice to have it on Wiki ๐Ÿฅ‡

Add isFilled into mappers

Part of #21

It is the opposite of #37 isEmpty mapper.

TODO:

  1. Create file src/mappers/isFilled.ts with function matches to type ValueMapper<boolean>. Which examine if input is not empty
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  { inValue: '', expectedResult: false },
  { inValue: null, expectedResult: false },
  { inValue: ' ', expectedResult: true }, // it is quite problematic case, however it isn't empty
  { inValue: 'null', expectedResult: true },
  { inValue: 'a', expectedResult: true},
  { inValue: 'as d', expectedResult: true },
]

For making a reservation please open draft PR with this issue linked

[Proposal] Dynamic columns

Sometimes happens that the columns are in a different order. It should match column headers and set property index for each column

Add numberMapper into mappers

Part of #21

TODO:

  1. Create file src/mappers/numberMapper.ts with function matches to type ValueMapper<number>. Which parse value string into number.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  { inValue: '', expectedResult: NaN },
  { inValue: null, expectedResult: NaN },
  { inValue: '  ', expectedResult: NaN },
  { inValue: '0', expectedResult: 0 },
  { inValue: '000', expectedResult: 0 },
  { inValue: '001', expectedResult: 1 },
  { inValue: '123', expectedResult: 123 },
  { inValue: '123s', expectedResult: 123 },
  { inValue: '0.1', expectedResult: 0.1},
  { inValue: 'a0.1', expectedResult: NaN},
  { inValue: '-1', expectedResult: -1},
  { inValue: '   -1.2123asd', expectedResult: -1.2123}
];

tips:

  • I propose to use Number.parseFloat
  • For asserting NaN values may be useful isNaN function

For making a reservation please open draft PR with this issue linked

Imports path

Actual

As it can be seen in samples/nodejs/importer.js:

https://github.com/Siemienik/xlsx-import/blob/ba224a5d0572c6f63a7bb27cee4833da80fb3ef9/samples/nodejs/importer.js#L1

It is required to use long path. It is absolutely unwanted.

Expected

const { ImporterFactory, Importer } = require('xlsx-import');
const { MAPPER_DEFAULT } = require('xlsx-import/mappers');

it means that the default package dir shoul be set as ./lib.

KEEP backward compatibility: It needs an investigate how to keep backward capability for some time before the change is finally committed and old paths stop working.

Add lowerCaseMapper into mappers

Part of #21

TODO:

  1. Create file src/mappers/lowerCaseMapper.ts with function matches to type (v: string): string. Which for any input try to return only lower case string.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test (create new one in tests/unit/mappers.test.ts)
  4. Describe it in Readme.md (Mappers section doesn't exists, please to add)

test data provider:

const lowerCaseDp = [
  { inValue: '', expectedResult: '' },
  { inValue: 'asd', expectedResult: 'asd' },
  { inValue: 'Asd', expectedResult: 'asd' },
  { inValue: 'ASD', expectedResult: 'asd' },
  { inValue: 'asd ASD', expectedResult: 'asd asd' },
]

The xlsx-import Command Line Interface

The xlsx-import-cli package

We have cli for renderer, now we should add cli for the import. I blocked this issue earlier, because I was doubts about setting mappers in json config file - however it isn't a problem if we use js files.

Usage:

# basic
cat invoice.xlsx > sxi config.js > result.json
sxi config.js invoice.xlsx > result.json
sxi -o result.json config.js invoice.xlsx 

#more advanced (todo)
cat invoice.xlsx > sxi config.js | sxr template.xlsx > refreshed-invoice.xlsx

Requirements

  • Added into ./packages/xlsx-import-cli
  • NPM package name: sxi (reserved on npm)
  • The interface: sxi [-o <output-file.json>] <import-config.js> [input-file.xlsx]. The input-file.xlsx isnt required if comes in sdtin.
  • Should be able to pipe with sxr (xlsx-renderer-cli).
  • Please add into main Readme.md
  • Please to make documentation

Additional info:

  • May been inspired by xlsx-renderer-cli
  • It will be nice to able cover it in 100% percent.

After

Add dateMapper into mappers

Part of #21

TODO:

  1. Create file src/mappers/dateMapper.ts with function matches to type ValueMapper<Date>. Which parse value string into Date.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test (some present dates, some future, some past & some invalid)
  4. Describe it in Readme.md

tips:

  • ExcelJS used inside xlsx-import return Date strings created by new Date().toString()
    fi. Thu Oct 08 2020 02:00:00 GMT+0200 (Central European Summer Time)

For making a reservation please open draft PR with this issue linked

Add integerMapper into Mappers

Part of #21

TODO:

  1. Create file src/mappers/integerMapper.ts with function matches to type ValueMapper<number>. Which parse value string into integer.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  { inValue: '', expectedResult: NaN },
  { inValue: null, expectedResult: NaN },
  { inValue: '  ', expectedResult: NaN },
  { inValue: '0', expectedResult: 0 },
  { inValue: '000', expectedResult: 0 },
  { inValue: '001', expectedResult: 1 },
  { inValue: '123', expectedResult: 123 },
  { inValue: '123.456', expectedResult: 123 },
  { inValue: '123s', expectedResult: 123 },
  { inValue: '0.1', expectedResult: 0},
  { inValue: 'a0.1', expectedResult: NaN},
  { inValue: '-1', expectedResult: -1},
  { inValue: '   -1.2123asd', expectedResult: -1}
];

tips:

  • I propose to use Number.parseInt
  • For asserting NaN values may be useful isNaN function
  • Probably more sense make extract NaN results into another dataProvider - I suppose that may simplify tests code.

For making a reservation please open draft PR with this issue linked

Replace current lint:fix and format by single lint:fix powered by eslint

Actual

Currently keeping code formatted and linted requires to use two commands:

  • yarn lint:fix (or npm run lint:fix)
  • yarn format (or npm run format)

Both of that are proceed by another tool.

Expected

  • yarn lint:fix (or npm run lint:fix) should get same result like current solution.
  • Migrate into eslint

Packages:

This issues should be performed in all packages:

  • xlsx-import
  • xlsx-renderer
  • xlsx-renderer-cli

Further (do not resolve it):

  • add [QA] Auto lint:fix

Docs: Add description for config fields according to SINGLE-OBJECT

sibling of #62

Actual

Described only shared cfg fields.

Expected

Following link: https://github.com/Siemienik/xlsx-import#fields-or-columns

Should be added section Single object depended fields with information: "Aliases: single, object, singleton".
The section should contains fields description (from IObjectSourceConfig and ISourceConfig): https://github.com/Siemienik/xlsx-import/blob/0db404b6be0117f3f81ede01879b1bbed3a4a3d8/src/config/IObjectSourceConfig.ts#L4-L6

Adding more sources types into ImportFactor.from

As @Metastasis mentioned in #4 (comment). Current factory has possibility only for reading workbook from local file system, what can't works under browser because security purposes.

Actual

The ImportFactory.from accept only filePath which is a string:

https://github.com/Siemienik/xlsx-import/blob/90c2b76564bd87433de19a9e8f55b9e064d14e09/src/ImporterFactory.ts#L6-L11

Expected

ImportFactory should recognise type of argument and knowing this choose how to handle it.

Type What is Should do
string File path If node: read file from localsystem
string Data url Get ArrayBuffer
string Buffer representation * Transform to ArrayBuffer
Buffer|ArrayBuffer Buffer Read indirectly from buffer
none of above unknown I haven't idea yet, probably should throw an error

I realized that string can also be a buffer so probably my implementation is broken (string can represent buffer as well as file path).

Please keep in mind, that samples Readme link into this issue - should be updated when issue become done.

Further (if requested)

Please do not it now

Type What is Should do
string File url Download from url and read file as ArrayBuffer

Test examples on each push event

Examples

The existence of examples has two reasons:

  1. Show others how to use our pretty lib
  2. Prove that this lib works with different envs&technologies

The situation when one of the examples stop works, and we don't know about it is unacceptable. So has to add a job which will test all of them automatically for each push event.

However, we have two situations when tests should work a little bit different.

  1. The first one, if code inside ./sample changed: should install xlsx-import version from ./sample/*/package-lock.js and then run tests
  2. The second situation if this lib code was changed (./src), then should install xlsx-import version by commit hash using git+https protocol.

TODO list:

general

  1. Add job 'Prepare samples list':
    1. read samples/* dir names as json array and set into output
  2. Add job if src and samples were both changed
  3. Investigate how to get a table of supported browsers & versions for Vue and React sample

situation 1:

  1. Add job 'Samples (npm)'
    • Set strategy.samples with names of samples (fromJson)
    • For each:
      • install dependencies
      • run npm test

situation 2:

  1. Add job 'Samples (master) '
    • Set strategy.samples with names of samples (fromJson)
    • For each:
      • install dependencies
      • install xlsx-import from current repo/branch (ref)
      • run npm test

samples/xlsx-import+express

  1. Mock npm test
  2. Add npm test script which checks API response
  3. Add info about testing into Readme

samples/xlsx-import+react

  1. Add info about testing into Readme

samples/xlsx-import+vue

  1. Add info about testing into Readme

samples/xlsx-import+nodejs

  1. Add npm test script which checks API response DONE in: #74
  2. Add info about testing into Readme DONE in: #74

samples/xlsx-import+nodets

  1. Add npm test script which checks API response DONE in: #74
  2. Add info about testing into Readme DONE in: #74

samples/xlsx-import-cli

  1. Mock npm test
  2. Add npm test script which checks examples
  3. Add info about testing into Readme

Add jsonMapper into mappers

Part of #21

TODO:

  1. Create file src/mappers/jsonMapper.ts with generic function matches to type EDIT: ValueMapper<TJsonResult> ValueMapper<any> . Which parse json string into TJsonResult and return default null when failure.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test
  4. Describe it in Readme.md

proposed test data provider:

const dataProvider = [
  { inValue: '', expectedResult: null },
  { inValue: null, expectedResult: null },
  { inValue: ' ', expectedResult: null },
  { inValue: 'asd', expectedResult: null },
  { inValue: 'null', expectedResult: null },
  { inValue: 'false', expectedResult: false },
  { inValue: 'true', expectedResult: true },
  { inValue: '0', expectedResult: 0},
  { inValue: '1', expectedResult: 1},
  { inValue: '"string"', expectedResult: 'string'},
  { inValue: '\'string\'', expectedResult: null},
  { inValue: '{"a":1}', expectedResult: {a:1}},
  { inValue: '{"a":[1]}', expectedResult: {a:[1]}},
]

For making a reservation please open draft PR with this issue linked

Add `Import.getFirst(cfg)` function

Function getFirst

Current:

const author = importer.getAllItems<Person>(config.owner)[0];

After:

const author = importer.getFirst<Person>(config.owner);

Todo:

  • Add getFirst function into IImporter interface (not in IImporterLegacy)
  • Implement getFist in a Importer class (not in ImporterLegacy)
  • Update sample in Readme (use getFist)
  • Update/Add at least one test which check it.

For making a reservation please open draft PR with this issue linked

Docs: Add description for config fields according to LIST-VERTICAL

Actual

Described only shared cfg fields.

Expected

Following link: https://github.com/Siemienik/xlsx-import#fields-or-columns

Should be added section List depended fields with information: "Aliases: list, vertical, list-vertical".
The section should contains fields description (from IListSourceConfig and ISourceConfig): https://github.com/Siemienik/xlsx-import/blob/0db404b6be0117f3f81ede01879b1bbed3a4a3d8/src/config/IListSourceConfig.ts#L4-L7

Add splitMapper into mappers

Part of #21

TODO:

  1. Create file src/mappers/splitMapper.ts with function matches to type (v: string): string[]. Which for any input try to return only lower case string.
  2. reexport it in src/mappers/index.ts
  3. Prove that it works in unit test (create new one in tests/unit/mappers.test.ts)
  4. Describe it in Readme.md

test data provider:

const lowerCaseDp = [
  { inValue: '', expectedResult: [] },
  { inValue: 'asd', expectedResult: ['asd'] },
  { inValue: 'asd,', expectedResult: ['asd',''] },
  { inValue: 'asd,asd2', expectedResult: ['asd','asd2'] },
  { inValue: 'true,1, expectedResult: ['true','1'] },
]

Further (not in scope of this issue)

  • setting for separator
  • setting for itemMapper

Insights / Contribution issue

@Metastasis @Gontrum, both of You done a lot great works for this library but you aren appear on Contributor page... ๐Ÿ˜ž

image

I did a little research, I suppose that you have set different emails for commits than used in Github. To fix it please go to Settings/Emails ( https://github.com/settings/emails ) and add the following: (I get these mails from git log)

@Metastasis met*******@*****mail.ch
@Gontrum dav**.*******@*****vate.de

After verification was done, GH will recalculate the Contributions page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.