Skip to content

Commit

Permalink
Chore/deprecate PSV/TSV extractors (#226)
Browse files Browse the repository at this point in the history
* Deprecate PSV/TSV extractors

* Use specific version

* chore: changeset

* feat: remove pipe & tab delimiters & add messages

* Update good-bobcats-tease.md

* chore: update package-lock.json

* fix: return listener that console.logs deprecation message
  • Loading branch information
carlbrugger authored Sep 19, 2023
1 parent 5ce6306 commit cbf391e
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 58 deletions.
7 changes: 7 additions & 0 deletions .changeset/good-bobcats-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@flatfile/plugin-delimiter-extractor': minor
'@flatfile/plugin-psv-extractor': minor
'@flatfile/plugin-tsv-extractor': minor
---

Deprecate PSV/TSV extractors since PSV/TSV files are now natively supported by the Flatfile Platform.
6 changes: 2 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions plugins/delimiter-extractor/ref/test-basic.pound
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"Code*"#"Details"#"BranchName"#"Tenant"
"Personal Care"#"Personal Care"#"Department"#"notdata"
Hospital#Hospital#Department
Home Nursing#Home Nursing#Department#false
4 changes: 0 additions & 4 deletions plugins/delimiter-extractor/ref/test-basic.psv

This file was deleted.

13 changes: 13 additions & 0 deletions plugins/delimiter-extractor/ref/test-complex.pound
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@



hello



"Code*"#"Details"#"BranchName"#"Tenant"
"Personal Care"#"Personal Care"#"Department"#"notdata"


Hospital#Hospital#Department
Home Nursing#Home Nursing#Department#false
13 changes: 0 additions & 13 deletions plugins/delimiter-extractor/ref/test-complex.psv

This file was deleted.

2 changes: 0 additions & 2 deletions plugins/delimiter-extractor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { Extractor } from '@flatfile/util-extractor'
import { parseBuffer } from './parser'

const delimiterMap = {
'\t': 'tsv',
'|': 'pipe',
',': 'csv',
';': 'ssv',
':': 'dsv',
Expand Down
38 changes: 19 additions & 19 deletions plugins/delimiter-extractor/src/parser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { parseBuffer } from './parser'
import * as path from 'path'
import * as fs from 'fs'
import * as path from 'path'
import { parseBuffer } from './parser'

describe('parser', () => {
const psvBasicBuffer: Buffer = fs.readFileSync(
path.join(__dirname, '../ref/test-basic.psv')
const colonBasicBuffer: Buffer = fs.readFileSync(
path.join(__dirname, '../ref/test-basic.pound')
)

const psvComplexBuffer: Buffer = fs.readFileSync(
path.join(__dirname, '../ref/test-complex.psv')
const colonComplexBuffer: Buffer = fs.readFileSync(
path.join(__dirname, '../ref/test-complex.pound')
)

test('PSV to WorkbookCapture', () => {
expect(parseBuffer(psvBasicBuffer, { delimiter: '|' })).toEqual({
test('colon to WorkbookCapture', () => {
expect(parseBuffer(colonBasicBuffer, { delimiter: '#' })).toEqual({
Sheet1: {
headers: ['Code', 'Details', 'BranchName', 'Tenant'],
required: {
Expand Down Expand Up @@ -44,13 +44,13 @@ describe('parser', () => {
})
})
it('has headers', () => {
const headers = parseBuffer(psvBasicBuffer, { delimiter: '|' }).Sheet1
const headers = parseBuffer(colonBasicBuffer, { delimiter: '#' }).Sheet1
.headers
expect(headers).toEqual(['Code', 'Details', 'BranchName', 'Tenant'])
})
test('transform', () => {
const data = parseBuffer(psvBasicBuffer, {
delimiter: '|',
const data = parseBuffer(colonBasicBuffer, {
delimiter: '#',
transform: (v: string) => {
return v.toUpperCase()
},
Expand All @@ -76,8 +76,8 @@ describe('parser', () => {
])
})
test('dynamicTyping', () => {
const data = parseBuffer(psvBasicBuffer, {
delimiter: '|',
const data = parseBuffer(colonBasicBuffer, {
delimiter: '#',
dynamicTyping: true,
}).Sheet1.data
expect(data).toEqual([
Expand All @@ -101,8 +101,8 @@ describe('parser', () => {
])
})
test('skipEmptyLines', () => {
const data = parseBuffer(psvBasicBuffer, {
delimiter: '|',
const data = parseBuffer(colonBasicBuffer, {
delimiter: '#',
skipEmptyLines: true,
}).Sheet1.data
expect(data).toEqual([
Expand All @@ -128,13 +128,13 @@ describe('parser', () => {
test('empty buffer', () => {
const emptyBuffer = Buffer.from('', 'utf8')
const logSpy = jest.spyOn(global.console, 'log')
parseBuffer(emptyBuffer, { delimiter: '|' })
parseBuffer(emptyBuffer, { delimiter: '#' })
expect(logSpy).toHaveBeenCalledWith('No data found in the file')
expect(parseBuffer(emptyBuffer, { delimiter: '|' })).toEqual({})
expect(parseBuffer(emptyBuffer, { delimiter: '#' })).toEqual({})
})
test('parsing of basic equals parsing of complex', () => {
expect(parseBuffer(psvComplexBuffer, { delimiter: '|' })).toEqual(
parseBuffer(psvBasicBuffer, { delimiter: '|' })
expect(parseBuffer(colonComplexBuffer, { delimiter: '#' })).toEqual(
parseBuffer(colonBasicBuffer, { delimiter: '#' })
)
})
})
8 changes: 1 addition & 7 deletions plugins/psv-extractor/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# @flatfile/plugin-psv-extractor

This plugin parses a PSV file and extracts it into Flatfile.

`npm i @flatfile/plugin-psv-extractor`

## Get Started

Follow [this guide](https://flatfile.com/docs/plugins/extractors/psv-extractor) to learn how to use the plugin.
This plugin has been deprecated. PSV extraction is now natively supported by the Flatfile Platform.
3 changes: 1 addition & 2 deletions plugins/psv-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
},
"license": "ISC",
"dependencies": {
"@flatfile/api": "^1.5.13",
"@flatfile/plugin-delimiter-extractor": "^0.6.0"
"@flatfile/api": "^1.5.13"
}
}
13 changes: 10 additions & 3 deletions plugins/psv-extractor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Flatfile } from '@flatfile/api'
import { DelimiterExtractor } from '@flatfile/plugin-delimiter-extractor'
import { FlatfileListener } from '@flatfile/listener'

/*
* @deprecated
*/
export const PSVExtractor = (options?: {
dynamicTyping?: boolean
skipEmptyLines?: boolean | 'greedy'
Expand All @@ -9,10 +12,14 @@ export const PSVExtractor = (options?: {
parallel?: number
debug?: boolean
}) => {
return DelimiterExtractor('.psv', { delimiter: '|', ...options })
return (listener: FlatfileListener) => {
console.log(
'The PSVExtractor plugin is deprecated. PSV extraction is now natively supported by the Flatfile Platform.'
)
}
}

/*
* @deprecated use `PSVExtractor` instead
* @deprecated
*/
export const psvExtractorPlugin = PSVExtractor
3 changes: 3 additions & 0 deletions plugins/tsv-extractor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @flatfile/plugin-tsv-extractor

This plugin has been deprecated. TSV extraction is now natively supported by the Flatfile Platform.
3 changes: 1 addition & 2 deletions plugins/tsv-extractor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
},
"license": "ISC",
"dependencies": {
"@flatfile/api": "^1.5.13",
"@flatfile/plugin-delimiter-extractor": "^0.6.0"
"@flatfile/api": "^1.5.13"
}
}
11 changes: 9 additions & 2 deletions plugins/tsv-extractor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Flatfile } from '@flatfile/api'
import { DelimiterExtractor } from '@flatfile/plugin-delimiter-extractor'
import { FlatfileListener } from '@flatfile/listener'

/*
* @deprecated
*/
export const TSVExtractor = (options?: {
dynamicTyping?: boolean
skipEmptyLines?: boolean | 'greedy'
Expand All @@ -9,5 +12,9 @@ export const TSVExtractor = (options?: {
parallel?: number
debug?: boolean
}) => {
return DelimiterExtractor('.tsv', { delimiter: '\t', ...options })
return (listener: FlatfileListener) => {
console.log(
'The TSVExtractor plugin is deprecated. TSV extraction is now natively supported by the Flatfile Platform.'
)
}
}

0 comments on commit cbf391e

Please sign in to comment.