diff --git a/circle.yml b/circle.yml index 33bc94bc8..8e4c76311 100644 --- a/circle.yml +++ b/circle.yml @@ -15,10 +15,10 @@ test: before: - greenkeeper-lockfile-update override: - - yarn test + - lerna run build_cjs && yarn test post: - - npm run build_cjs && npm run check_circular_dependencies - - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js + - npm run check_circular_dependencies + - cat ./packages/*/coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js - greenkeeper-lockfile-upload notify: diff --git a/package.json b/package.json index 14d2d34c3..a781a5f13 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "packages/*" ], "scripts": { + "check_circular_dependencies": "madge ./packages/*/dist/cjs --circular", "build_test": "rm -rf spec-js && tsc --project test", "test": "lerna run test && npm run build_test && tman --mocha spec-js/app.js" }, diff --git a/packages/teambition-sdk-core/package.json b/packages/teambition-sdk-core/package.json index 244f67350..5124e41d0 100644 --- a/packages/teambition-sdk-core/package.json +++ b/packages/teambition-sdk-core/package.json @@ -13,7 +13,6 @@ "build_mock_cjs": "rm -rf dist/mock-cjs && tsc mock/index.ts -m commonjs --outDir dist/mock-cjs --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom", "build_socket": "rm -rf dist/bundle/tbsdk.socket.js && tsc ./src/SocketApp.ts ./src/teambition.ts -m commonjs --outDir dist/socket --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom && ts-node ./tools/tasks/bundle.socket.ts", "build_test": "rm -rf spec-js && tsc --project test", - "check_circular_dependencies": "madge ./dist/cjs --circular", "copy_files": "cp README.md package.json ./dist/cjs/", "cover": "npm run build_test && rm -rf ./coverage && nyc --reporter=html --reporter=lcov --exclude=node_modules --exclude=spec-js/test --exclude=spec-js/mock --exclude=spec-js/src/sockets/SocketClient.js tman --mocha spec-js/test/app.js", "lint": "tslint ./src/**/*.ts ./mock/**/*.ts ./test/*.ts ./test/apis/**/*.ts ./test/mock/**/*.ts ./test/utils/**/*.ts", diff --git a/packages/teambition-sdk-core/src/schemas/TapChart.ts b/packages/teambition-sdk-core/src/schemas/TapChart.ts new file mode 100644 index 000000000..b047e409d --- /dev/null +++ b/packages/teambition-sdk-core/src/schemas/TapChart.ts @@ -0,0 +1,143 @@ +import { RDBType, Relationship, SchemaDef } from 'reactivedb/interface' +import { schemas } from '../SDK' + +import { + UserId, + TapChartId, + TapDashboardId, + ExecutorOrCreator, + TapGenericFilterRequest as FilterRequest, + TapGenericFilterResponse as FilterResponse +} from 'teambition-types' + +export type TapChartType = 'bar' | 'line' + +// tapGraph definition +export type TapGraphColType = 'type/DateTime' | 'type/Integer' | 'type/String' + +export interface TapGraphCol { + name: string + baseType: TapGraphColType +} + +export type TapGraphData = { + cols: TapGraphCol[], + rows: any[][] +} + +export type TapGraphLineDisplay = { + showPointMarker: boolean, + stack: false | 'stack' +} + +export type TapGraphBarDisplay = { + stack: false | 'stack' +} + +export type TapGraphVisualizationSettings = { + type: TapChartType + dimension: number // key of cols in data + display: TapGraphLineDisplay | TapGraphBarDisplay + axes: { + x: { + visible: boolean + label: string | null + scale: 'timeseries' | 'ordinal' + }, + y: { + visible: boolean + scale: 'linear' + label: string | null + range: 'auto' + } + } +} + +// tapChart definition +export interface TapChartSchema { + _id: TapChartId + + _creatorId: UserId + creator?: ExecutorOrCreator + + _tapdashboardId: TapDashboardId + tapdashboard?: { + _id: TapDashboardId, + name: string + } + + name: string + desc: string + + created: string + updated: string + + filter: T + filterList: FilterResponse + + graphData: TapGraphData + visualizationSettings: TapGraphVisualizationSettings +} + +const schema: SchemaDef> = { + _id: { + type: RDBType.STRING, + primaryKey: true + }, + + _creatorId: { + type: RDBType.STRING + }, + creator: { + type: Relationship.oneToOne, + virtual: { + name: 'Member', + where: (memberTable: any) => ({ + _creatorId: memberTable._id + }) + } + }, + + _tapdashboardId: { + type: RDBType.STRING + }, + tapdashboard: { + type: Relationship.oneToOne, + virtual: { + name: 'TapDashboard', + where: (dashboardTable: any) => ({ + _tapdashboardId: dashboardTable._id + }) + } + }, + + name: { + type: RDBType.STRING + }, + desc: { + type: RDBType.STRING + }, + + created: { + type: RDBType.DATE_TIME + }, + updated: { + type: RDBType.DATE_TIME + }, + + filter: { + type: RDBType.OBJECT + }, + filterList: { + type: RDBType.OBJECT + }, + + graphData: { + type: RDBType.OBJECT + }, + visualizationSettings: { + type: RDBType.OBJECT + } +} + +schemas.push({ schema, name: 'TapChart' }) diff --git a/packages/teambition-sdk-core/src/schemas/TapDashboard.ts b/packages/teambition-sdk-core/src/schemas/TapDashboard.ts new file mode 100644 index 000000000..a3ee97923 --- /dev/null +++ b/packages/teambition-sdk-core/src/schemas/TapDashboard.ts @@ -0,0 +1,77 @@ +import { RDBType, Relationship, SchemaDef } from 'reactivedb/interface' +import { schemas } from '../SDK' + +import { + UserId, + ProjectId, + TapDashboardId, + ExecutorOrCreator, + TapGenericFilterRequest as FilterRequest, + TapGenericFilterResponse as FilterResponse +} from 'teambition-types' + +import { + TapChartType, + TapChartSchema +} from './TapChart' + +export interface TapDashboardSchema { + _id: TapDashboardId + + _projectId: ProjectId + + _creatorId: UserId + creator?: ExecutorOrCreator + + name: string + cover: TapChartType + + filter: T + tapcharts: TapChartSchema[] +} + +const schema: SchemaDef> = { + _id: { + type: RDBType.STRING, + primaryKey: true + }, + + _projectId: { + type: RDBType.STRING + }, + + _creatorId: { + type: RDBType.STRING + }, + creator: { + type: Relationship.oneToOne, + virtual: { + name: 'Member', + where: (memberTable: any) => ({ + _creatorId: memberTable._id + }) + } + }, + + name: { + type: RDBType.STRING + }, + cover: { + type: RDBType.STRING + }, + + filter: { + type: RDBType.OBJECT + }, + tapcharts: { + type: Relationship.oneToMany, + virtual: { + name: 'TapChart', + where: (tapChartTable: any) => ({ + _id: tapChartTable._tapdashboardId + }) + } + } +} + +schemas.push({ schema, name: 'TapDashboard' }) diff --git a/packages/teambition-sdk-core/src/schemas/TapQuestion.ts b/packages/teambition-sdk-core/src/schemas/TapQuestion.ts new file mode 100644 index 000000000..2dec4e7ce --- /dev/null +++ b/packages/teambition-sdk-core/src/schemas/TapQuestion.ts @@ -0,0 +1,18 @@ +import { TapChartType } from './TapChart' +import { TapGenericFilterResponse } from 'teambition-types' + +export interface QuestionId extends String { + kind?: 'QuestionId' +} + +export interface QuestionSchema { + _id: QuestionId + type: TapChartType + + name: string + desc: string + + filter: TapGenericFilterResponse + + [index: string]: any +}