Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common add expandReferences on parseCsv #308

Merged
merged 4 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/bigquery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-bigquery

## 2.0.1

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 2.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/bigquery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-bigquery",
"version": "2.0.0",
"version": "2.0.1",
"description": "A Google BigQuery language package for use with Open Function",
"main": "dist/index.cjs",
"scripts": {
Expand All @@ -21,7 +21,7 @@
],
"dependencies": {
"@google-cloud/bigquery": "^5.12.0",
"@openfn/language-common": "workspace:1.10.1",
"@openfn/language-common": "workspace:1.10.2",
"csv-parse": "^4.16.3",
"import": "0.0.6",
"json2csv": "^5.0.7",
Expand Down
8 changes: 8 additions & 0 deletions packages/commcare/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @openfn/language-commcare

## 1.6.5

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]
- @openfn/[email protected]

## 1.6.4

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/commcare/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-commcare",
"version": "1.6.4",
"version": "1.6.5",
"description": "Commcare Language Pack for OpenFn",
"homepage": "https://docs.openfn.org",
"repository": {
Expand All @@ -25,8 +25,8 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "workspace:1.10.1",
"@openfn/language-http": "workspace:^5.0.0",
"@openfn/language-common": "workspace:1.10.2",
"@openfn/language-http": "workspace:^5.0.1",
"JSONPath": "^0.10.0",
"form-data": "^4.0.0",
"js2xmlparser": "^1.0.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
v0.4.0

## 1.10.2

### Patch Changes

- 26a303e: add expandReferences for csvData and parsingOptions

## 1.10.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-common",
"version": "1.10.1",
"version": "1.10.2",
"description": "Common Expressions for OpenFn",
"homepage": "https://docs.openfn.org",
"repository": {
Expand Down
32 changes: 21 additions & 11 deletions packages/common/src/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import fromPairs from 'lodash/fp/fromPairs.js';
import { JSONPath } from 'jsonpath-plus';
import { parse } from 'csv-parse';

import { expandReferences as newExpandReferences } from './util';

export * as beta from './beta';
export * as http from './http';
export * as dateFns from './dateFns';
Expand Down Expand Up @@ -588,23 +590,31 @@ export function parseCsv(csvData, parsingOptions = {}, callback) {
skip_empty_lines: true,
};

const filteredOptions = Object.fromEntries(
Object.entries(parsingOptions).filter(([key]) => key in defaultOptions)
);
return async state => {
const [resolvedCsvData, resolvedParsingOptions] = newExpandReferences(
state,
csvData,
parsingOptions
);

const options = { ...defaultOptions, ...filteredOptions };
const filteredOptions = Object.fromEntries(
Object.entries(resolvedParsingOptions).filter(
([key]) => key in defaultOptions
)
);

if (options.chunkSize < 1) {
throw new Error('chunkSize must be at least 1');
}
const options = { ...defaultOptions, ...filteredOptions };

if (options.chunkSize < 1) {
throw new Error('chunkSize must be at least 1');
}

return async state => {
let buffer = [];

const parser =
typeof csvData === 'string'
? parse(csvData, options)
: csvData.pipe(parse(options));
typeof resolvedCsvData === 'string'
? parse(resolvedCsvData, options)
: resolvedCsvData.pipe(parse(options));

const flushBuffer = async currentState => {
const nextState = callback
Expand Down
7 changes: 7 additions & 0 deletions packages/dynamics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-dynamics

## 0.4.5

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 0.4.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/dynamics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-dynamics",
"version": "0.4.4",
"version": "0.4.5",
"description": "A Microsoft Dynamics Language Pack for OpenFn",
"main": "dist/index.cjs",
"scripts": {
Expand All @@ -20,7 +20,7 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "1.10.1",
"@openfn/language-common": "1.10.2",
"request": "^2.72.0"
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-http

## 5.0.1

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 5.0.0

### Major Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-http",
"version": "5.0.0",
"version": "5.0.1",
"description": "An HTTP request language package for use with Open Function",
"homepage": "https://docs.openfn.org",
"repository": {
Expand Down Expand Up @@ -33,7 +33,7 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "workspace:1.10.1",
"@openfn/language-common": "workspace:1.10.2",
"cheerio": "^1.0.0-rc.10",
"cheerio-tableparser": "^1.0.1",
"csv-parse": "^4.10.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/mssql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-mssql

## 4.1.5

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 4.1.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/mssql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-mssql",
"version": "4.1.4",
"version": "4.1.5",
"description": "A Microsoft SQL language pack for OpenFn",
"exports": {
".": {
Expand Down Expand Up @@ -31,7 +31,7 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "workspace:1.10.1",
"@openfn/language-common": "workspace:1.10.2",
"tedious": "15.1.0"
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/mysql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-mysql

## 1.4.5

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 1.4.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/mysql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-mysql",
"version": "1.4.4",
"version": "1.4.5",
"description": "A MySQL Language Pack for OpenFn",
"homepage": "https://docs.openfn.org",
"main": "dist/index.cjs",
Expand All @@ -25,7 +25,7 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "1.10.1",
"@openfn/language-common": "1.10.2",
"json-sql": "^0.3.10",
"mysql": "^2.13.0",
"squel": "^5.8.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/ocl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-ocl

## 1.1.3

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 1.1.2

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/ocl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-ocl",
"version": "1.1.2",
"version": "1.1.3",
"description": "An OCL language package for use with Open Function",
"main": "dist/index.cjs",
"scripts": {
Expand All @@ -20,7 +20,7 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "1.10.1"
"@openfn/language-common": "1.10.2"
},
"devDependencies": {
"@openfn/buildtools": "workspace:^1.0.2",
Expand Down
7 changes: 7 additions & 0 deletions packages/openfn/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-openfn

## 1.3.5

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 1.3.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/openfn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-openfn",
"version": "1.3.4",
"version": "1.3.5",
"description": "An (experimental) adaptor for accessing the OpenFn web API",
"homepage": "https://docs.openfn.org",
"repository": {
Expand All @@ -25,7 +25,7 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "1.10.1",
"@openfn/language-common": "1.10.2",
"axios": "^0.21.1"
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/openmrs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-openmrs

## 2.0.5

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 2.0.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/openmrs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-openmrs",
"version": "2.0.4",
"version": "2.0.5",
"description": "OpenMRS Language Pack for OpenFn",
"homepage": "https://docs.openfn.org",
"repository": {
Expand All @@ -25,7 +25,7 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "1.10.1",
"@openfn/language-common": "1.10.2",
"superagent": "^8.0.9"
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/postgresql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-postgresql

## 4.1.5

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 4.1.4

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/postgresql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-postgresql",
"version": "4.1.4",
"version": "4.1.5",
"description": "A PostgreSQL Language Pack for OpenFn",
"homepage": "https://docs.openfn.org",
"exports": {
Expand Down Expand Up @@ -31,7 +31,7 @@
"configuration-schema.json"
],
"dependencies": {
"@openfn/language-common": "1.10.1",
"@openfn/language-common": "1.10.2",
"pg": "^8.3.2",
"pg-format": "^1.0.4"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/primero/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @openfn/language-primero

## 2.11.5

### Patch Changes

- Updated dependencies [26a303e]
- @openfn/[email protected]

## 2.11.4

### Patch Changes
Expand Down
Loading