Skip to content

Commit dbcac54

Browse files
authored
Feature: Upload external datasets (#112)
* add endpoint for uploading external datasets * chunk segments into payload sizes less than Jetty size limit * cleanup after dataset creation failure * fix codeql errors (squashable) * return external dataset upload errors to client
1 parent 31ce057 commit dbcac54

File tree

18 files changed

+657
-35
lines changed

18 files changed

+657
-35
lines changed

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"altair-express-middleware": "^5.2.11",
3131
"cookie-parser": "^1.4.6",
3232
"cors": "^2.8.5",
33+
"csv-parse": "^5.5.6",
3334
"express": "^4.18.2",
3435
"express-rate-limit": "^6.7.0",
3536
"helmet": "^7.0.0",

src/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Algorithm } from 'jsonwebtoken';
2-
import { GroupRoleMapping } from './packages/auth/types';
2+
import { GroupRoleMapping } from './types/auth';
33

44
export type Env = {
55
ALLOWED_ROLES: string[];

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import initHealthRoutes from './packages/health/health.js';
1212
import initPlanRoutes from './packages/plan/plan.js';
1313
import initSwaggerRoutes from './packages/swagger/swagger.js';
1414
import cookieParser from 'cookie-parser';
15-
import { AuthAdapter } from './packages/auth/types.js';
15+
import { AuthAdapter } from './types/auth.js';
1616
import { NoAuthAdapter } from './packages/auth/adapters/NoAuthAdapter.js';
1717
import { CAMAuthAdapter } from './packages/auth/adapters/CAMAuthAdapter.js';
1818
import { validateGroupRoleMappings } from './packages/auth/functions.js';

src/packages/auth/adapters/CAMAuthAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getEnv } from '../../../env.js';
22
import { authGroupMappingsExist, generateJwt, getUserRoles, mapGroupsToRoles, syncRolesToDB } from '../functions.js';
33
import fetch from 'node-fetch';
4-
import type { AuthAdapter, AuthResponse, ValidateResponse } from '../types.js';
4+
import type { AuthAdapter, AuthResponse, ValidateResponse } from '../../../types/auth.js';
55

66
import { Request } from 'express';
77

src/packages/auth/adapters/NoAuthAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AuthAdapter, ValidateResponse } from '../types.js';
1+
import type { AuthAdapter, ValidateResponse } from '../../../types/auth.js';
22

33
export const NoAuthAdapter: AuthAdapter = {
44
logout: async (): Promise<boolean> => true,

src/packages/auth/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
JwtSecret,
1313
SessionResponse,
1414
UserRoles,
15-
} from './types.js';
15+
} from '../../types/auth.js';
1616
import { loginSSO } from './adapters/CAMAuthAdapter.js';
1717

1818
const logger = getLogger('packages/auth/functions');

src/packages/auth/routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Express } from 'express';
22
import rateLimit from 'express-rate-limit';
33
import { getEnv } from '../../env.js';
44
import { login, session } from './functions.js';
5-
import { AuthAdapter } from './types.js';
5+
import { AuthAdapter } from '../../types/auth.js';
66

77
export default (app: Express, auth: AuthAdapter) => {
88
const { RATE_LIMITER_LOGIN_MAX } = getEnv();

src/packages/plan/gql.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
export default {
2+
ADD_EXTERNAL_DATASET: `#graphql
3+
mutation AddExternalDataset(
4+
$planId: Int!,
5+
$simulationDatasetId: Int,
6+
$datasetStart: String!,
7+
$profileSet: ProfileSet!) {
8+
addExternalDataset(
9+
planId: $planId,
10+
simulationDatasetId: $simulationDatasetId,
11+
datasetStart: $datasetStart,
12+
profileSet: $profileSet) {
13+
datasetId
14+
}
15+
}
16+
`,
217
CREATE_ACTIVITY_DIRECTIVES: `#graphql
318
mutation CreateActivityDirectives($activityDirectivesInsertInput: [activity_directive_insert_input!]!) {
419
insert_activity_directive(objects: $activityDirectivesInsertInput) {
@@ -50,6 +65,13 @@ export default {
5065
}
5166
}
5267
`,
68+
DELETE_EXTERNAL_DATASET: `#graphql
69+
mutation DeleteExternalDataset($id: Int!) {
70+
delete_dataset_by_pk(id: $id) {
71+
id
72+
}
73+
}
74+
`,
5375
DELETE_PLAN: `#graphql
5476
mutation DeletePlan($id: Int!) {
5577
deletePlan: delete_plan_by_pk(id: $id) {
@@ -68,6 +90,13 @@ export default {
6890
}
6991
}
7092
`,
93+
EXTEND_EXTERNAL_DATASET: `#graphql
94+
mutation ExtendExternalDataset($datasetId: Int!, $profileSet: ProfileSet!) {
95+
extendExternalDataset(datasetId: $datasetId, profileSet: $profileSet) {
96+
datasetId
97+
}
98+
}
99+
`,
71100
GET_TAGS: `#graphql
72101
query GetTags {
73102
tags(order_by: { name: desc }) {

0 commit comments

Comments
 (0)