Skip to content

Commit

Permalink
feat(types): add types via flow - EUBFR-72 (#45)
Browse files Browse the repository at this point in the history
* Add flow

* Add Project type

* Add eslint plugin for flow

* Type alias being modular

* Describe project's basic fields

* Include flow in the pipeline

* Easier call to flow bin
  • Loading branch information
kalinchernev authored Nov 28, 2017
1 parent e1fcee5 commit a290858
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ pipeline:
commands:
- yarn test:lint

test-flow:
image: node:8.5
group: test
commands:
- yarn test:flow

test-integration:
image: node:8.5
group: test
Expand Down
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
---
root: true
parser: babel-eslint
extends:
- airbnb-base
- prettier
- prettier/react
- plugin:jest/recommended
- plugin:react/recommended
- plugin:flowtype/recommended
plugins:
- jest
- prettier
- react
- flowtype
rules:
no-underscore-dangle:
- error
Expand Down
14 changes: 14 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[ignore]
.*/__tests__/.*
.*/node_modules/.*
.*\.ignore\.js

[include]

[libs]

[lints]

[options]

[strict]
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"bootstrap": "lerna bootstrap",
"deploy": "./scripts/deploy.sh",
"deploy-demo": "./scripts/deploy-demo.sh",
"flow": "flow",
"lint": "eslint .",
"precommit": "lint-staged",
"test:integration": "lerna run --parallel test:integration",
"test:unit": "lerna run --parallel test:unit",
"test:lint": "npm run lint",
"test:flow": "npm run flow",
"test": "npm-run-all -p test:* -cn",
"test-write": "jest --watch"
},
Expand All @@ -17,13 +19,16 @@
},
"devDependencies": {
"babel-core": "6.26.0",
"babel-eslint": "8.0.2",
"eslint": "4.9.0",
"eslint-config-airbnb-base": "12.1.0",
"eslint-config-prettier": "2.6.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jest": "21.2.0",
"eslint-plugin-prettier": "2.3.1",
"eslint-plugin-react": "7.4.0",
"flow-bin": "0.59.0",
"husky": "0.14.3",
"lerna": "2.4.0",
"lint-staged": "4.3.0",
Expand Down
1 change: 1 addition & 0 deletions services/ingestion/etl/budg/csv/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"presets": [
"flow",
[
"env",
{
Expand Down
1 change: 1 addition & 0 deletions services/ingestion/etl/budg/csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-preset-env": "1.6.1",
"babel-preset-flow": "6.23.0",
"jest": "21.2.1",
"serverless": "1.23.0",
"serverless-webpack": "3.1.2",
Expand Down
6 changes: 5 additions & 1 deletion services/ingestion/etl/budg/csv/src/lib/transform.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// @flow

/*
* Transform message (BUDG CSV)
*/

import type { Project } from '../../../../types/Project';

/*
* Map fields
*/
export default record => {
export default (record: Object): Project => {
// Preprocess budget
const budgetObject = {
total_cost: null,
Expand Down
68 changes: 68 additions & 0 deletions services/ingestion/etl/types/Project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// @flow

// Project model is discussed in EUBFR-4 EUBFR-5 and EUBFR-70

type Result = {
result: string,
};

type Geolocation = {
lat: string,
lon: string,
};

type Location = {
country_name?: string,
country_code: string,
geolocation: Geolocation,
};

type Timeframe = {
from: string | null,
to: string | null,
};

type Coordinator = {
name: string,
type?: string,
address?: string,
region?: string,
country?: string,
website?: string,
phone?: string,
email?: string,
};

type Partner = {
name: string,
type?: string,
address?: string,
region?: string,
country?: string,
website?: string,
};

type Budget = {
eu_contrib: number,
total_cost?: string | null,
private_fund?: string | null,
public_fund?: string | null,
other_contrib?: string | null,
funding_area?: string | null,
};

export type Project = {
project_id: string,
title: string,
description: string,
cover_image: string,
programme_name: string,
project_website: string,
budget: Budget,
results: Result,
timeframe: Timeframe,
ec_priorities: Array<string>,
coordinators: Array<Coordinator>,
partners: Array<Partner>,
project_locations: Array<Location>,
};
87 changes: 85 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,58 @@
# yarn lockfile v1


"@babel/code-frame@7.0.0-beta.32", "@babel/code-frame@^7.0.0-beta.31":
version "7.0.0-beta.32"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.32.tgz#04f231b8ec70370df830d9926ce0f5add074ec4c"
dependencies:
chalk "^2.0.0"
esutils "^2.0.2"
js-tokens "^3.0.0"

"@babel/helper-function-name@7.0.0-beta.32":
version "7.0.0-beta.32"
resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.32.tgz#6161af4419f1b4e3ed2d28c0c79c160e218be1f3"
dependencies:
"@babel/helper-get-function-arity" "7.0.0-beta.32"
"@babel/template" "7.0.0-beta.32"
"@babel/types" "7.0.0-beta.32"

"@babel/helper-get-function-arity@7.0.0-beta.32":
version "7.0.0-beta.32"
resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.32.tgz#93721a99db3757de575a83bab7c453299abca568"
dependencies:
"@babel/types" "7.0.0-beta.32"

"@babel/template@7.0.0-beta.32":
version "7.0.0-beta.32"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.32.tgz#e1d9fdbd2a7bcf128f2f920744a67dab18072495"
dependencies:
"@babel/code-frame" "7.0.0-beta.32"
"@babel/types" "7.0.0-beta.32"
babylon "7.0.0-beta.32"
lodash "^4.2.0"

"@babel/traverse@^7.0.0-beta.31":
version "7.0.0-beta.32"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.32.tgz#b78b754c6e1af3360626183738e4c7a05951bc99"
dependencies:
"@babel/code-frame" "7.0.0-beta.32"
"@babel/helper-function-name" "7.0.0-beta.32"
"@babel/types" "7.0.0-beta.32"
babylon "7.0.0-beta.32"
debug "^3.0.1"
globals "^10.0.0"
invariant "^2.2.0"
lodash "^4.2.0"

"@babel/types@7.0.0-beta.32", "@babel/types@^7.0.0-beta.31":
version "7.0.0-beta.32"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.32.tgz#c317d0ecc89297b80bbcb2f50608e31f6452a5ff"
dependencies:
esutils "^2.0.2"
lodash "^4.2.0"
to-fast-properties "^2.0.0"

"@serverless/fdk@^0.5.1":
version "0.5.1"
resolved "https://registry.yarnpkg.com/@serverless/fdk/-/fdk-0.5.1.tgz#9d420568bfb291d73f8a8a9b35ba68a974f7d0b7"
Expand Down Expand Up @@ -582,6 +634,15 @@ babel-eslint@7.2.3:
babel-types "^6.23.0"
babylon "^6.17.0"

babel-eslint@8.0.2:
version "8.0.2"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.0.2.tgz#e44fb9a037d749486071d52d65312f5c20aa7530"
dependencies:
"@babel/code-frame" "^7.0.0-beta.31"
"@babel/traverse" "^7.0.0-beta.31"
"@babel/types" "^7.0.0-beta.31"
babylon "^7.0.0-beta.31"

babel-generator@^6.18.0, babel-generator@^6.25.0, babel-generator@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.0.tgz#ac1ae20070b79f6e3ca1d3269613053774f20dc5"
Expand Down Expand Up @@ -1133,7 +1194,7 @@ babel-preset-env@1.6.1:
invariant "^2.2.2"
semver "^5.3.0"

babel-preset-flow@^6.23.0:
babel-preset-flow@6.23.0, babel-preset-flow@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-preset-flow/-/babel-preset-flow-6.23.0.tgz#e71218887085ae9a24b5be4169affb599816c49d"
dependencies:
Expand Down Expand Up @@ -1232,6 +1293,10 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24
lodash "^4.17.4"
to-fast-properties "^1.0.3"

babylon@7.0.0-beta.32, babylon@^7.0.0-beta.31:
version "7.0.0-beta.32"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.32.tgz#e9033cb077f64d6895f4125968b37dc0a8c3bc6e"

babylon@^6.17.0, babylon@^6.17.2, babylon@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"
Expand Down Expand Up @@ -2968,6 +3033,12 @@ eslint-plugin-flowtype@2.35.0:
dependencies:
lodash "^4.15.0"

eslint-plugin-flowtype@2.39.1:
version "2.39.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.39.1.tgz#b5624622a0388bcd969f4351131232dcb9649cd5"
dependencies:
lodash "^4.15.0"

eslint-plugin-import@2.7.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.7.0.tgz#21de33380b9efb55f5ef6d2e210ec0e07e7fa69f"
Expand Down Expand Up @@ -3552,6 +3623,10 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"

flow-bin@0.59.0:
version "0.59.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.59.0.tgz#8c151ee7f09f1deed9bf0b9d1f2e8ab9d470f1bb"

for-in@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
Expand Down Expand Up @@ -3841,6 +3916,10 @@ global-prefix@^1.0.1:
is-windows "^1.0.1"
which "^1.2.14"

globals@^10.0.0:
version "10.4.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-10.4.0.tgz#5c477388b128a9e4c5c5d01c7a2aca68c68b2da7"

globals@^9.17.0, globals@^9.18.0:
version "9.18.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"
Expand Down Expand Up @@ -4385,7 +4464,7 @@ interpret@^1.0.0:
version "1.0.4"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.4.tgz#820cdd588b868ffb191a809506d6c9c8f212b1b0"

invariant@^2.2.1, invariant@^2.2.2:
invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360"
dependencies:
Expand Down Expand Up @@ -8541,6 +8620,10 @@ to-fast-properties@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"

to-fast-properties@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"

tomlify-j0.4@^2.0.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/tomlify-j0.4/-/tomlify-j0.4-2.2.1.tgz#60c4e7dd2066b2e917dd9a0de5fd676c0a6d7c7b"
Expand Down

0 comments on commit a290858

Please sign in to comment.