Skip to content

Commit

Permalink
Merge pull request #5535 from beyondessential/release-2024-13
Browse files Browse the repository at this point in the history
Release 2024-13
  • Loading branch information
rohan-bes authored Mar 26, 2024
2 parents 2f1050d + 273644f commit 4f302f5
Show file tree
Hide file tree
Showing 552 changed files with 40,966 additions and 26,187 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
# Only run if Tupaia CI passed
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ap-southeast-2
role-to-assume: arn:aws:iam::843218180240:role/Tupaia_GHA
Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ jobs:
name: Validate branch name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Validate branch name
run: packages/devops/scripts/ci/validateBranchName.sh

validate_migration:
name: Validate new migrations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Validate new migration
run: packages/devops/scripts/ci/validateNewMigrations.sh

validate_tests:
name: Validate tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.20.2
node-version-file: '.nvmrc'
cache: yarn
- run: yarn set version 3.2.1
- run: corepack enable yarn
- run: SKIP_BUILD_INTERNAL_DEPENDENCIES=true yarn install
- run: yarn workspace @tupaia/utils build # /scripts/node/validateTests.js uses utils package
- name: Validate unit tests
Expand Down Expand Up @@ -71,12 +71,12 @@ jobs:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.20.2
node-version-file: '.nvmrc'
cache: yarn
- run: yarn set version 3.2.1
- run: corepack enable yarn
- run: SKIP_BUILD_INTERNAL_DEPENDENCIES=true yarn install
- run: yarn build:internal-dependencies
- run: ./packages/devops/scripts/ci/validateTypesAndDbSchemaInSync.sh
Expand Down Expand Up @@ -165,12 +165,12 @@ jobs:
- 5432:5432

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.20.2
node-version-file: '.nvmrc'
cache: yarn
- run: yarn set version 3.2.1
- run: corepack enable yarn
- run: SKIP_BUILD_INTERNAL_DEPENDENCIES=true yarn install
- run: yarn build:internal-dependencies
- run: yarn workspace @tupaia/${{ matrix.package }} setup-test || echo "No setup needed"
Expand All @@ -182,12 +182,12 @@ jobs:
env:
CI: false # react-scripts build treats warnings as errors if this is true
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.20.2
node-version-file: '.nvmrc'
cache: yarn
- run: yarn set version 3.2.1
- run: corepack enable yarn
- run: SKIP_BUILD_INTERNAL_DEPENDENCIES=true yarn install --immutable
- run: yarn build

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
TERM: xterm # workaround for issue where cypress fails to upload to cypress.io
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.20.2
node-version-file: '.nvmrc'
cache: yarn
- run: yarn set version 3.2.1
- run: corepack enable yarn
- run: SKIP_BUILD_INTERNAL_DEPENDENCIES=true yarn install
- run: yarn workspace @tupaia/utils build
- run: yarn workspace "@tupaia/e2e" test-e2e --ciBuildId $GITHUB_RUN_ID
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.20.2
20.11.1
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"package:build:lib": "cd $INIT_CWD && babel src --out-dir lib --source-maps --config-file \"../../babel.config.json\" --copy-files --no-copy-ignored --ignore \"**/__tests__\",\"**/__mocks__\"",
"package:lint": "cd $INIT_CWD && eslint .",
"package:test": "cd $INIT_CWD && jest --maxWorkers=50%",
"package:test:withdb": "cd $INIT_CWD && yarn workspace @tupaia/database check-test-database-exists && DB_NAME=tupaia_test jest --runInBand",
"package:test:withdb": "cd $INIT_CWD && yarn workspace @tupaia/database check-test-database-exists && DB_NAME=tupaia_test jest --runInBand",
"package:start:backend-start-dev": "cd $INIT_CWD && LOG_LEVEL=debug ../../scripts/bash/backendStartDev.sh",
"package:start:vite": "cd $INIT_CWD && vite --config \"../../vite.config.js\"",
"package:start-stack": "scripts/bash/pm2startInline.sh"
Expand All @@ -68,7 +68,7 @@
"@beyondessential/eslint-config-ts": "^2.0.0",
"@vitejs/plugin-react": "^4.0.4",
"babel-eslint": "^10.1.0",
"babel-jest": "^27.0.6",
"babel-jest": "^29.7.0",
"babel-preset-react-app": "^10.0.0",
"concurrently": "^5.2.0",
"cypress-dotenv": "^1.2.2",
Expand All @@ -77,13 +77,14 @@
"eslint-import-resolver-babel-module": "^5.3.1",
"eslint-plugin-cypress": "^2.11.1",
"eslint-plugin-module-resolver": "^1.5.0",
"jest": "^27.0.6",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-extended": "^0.11.5",
"jest-when": "^3.6.0",
"nodemon": "^2.0.4",
"npm-package-json-lint": "5.1.0",
"pm2": "^5.3.0",
"ts-jest": "^27.1.3",
"ts-jest": "^29.1.2",
"ts-node": "^10.7.0",
"typescript": "^5.2.2",
"vite": "^4.4.8",
Expand All @@ -92,7 +93,7 @@
"yargs": "15.4.1"
},
"engines": {
"node": "^16.20.2"
"node": "^20.11.1"
},
"packageManager": "yarn@3.2.1"
}
2 changes: 1 addition & 1 deletion packages/admin-panel-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@tupaia/api-client": "workspace:*",
"@tupaia/database": "workspace:*",
"@tupaia/server-boilerplate": "workspace:*",
"@tupaia/types": "workspace:*",
"@tupaia/utils": "workspace:*",
"api-error-handler": "^1.0.0",
"body-parser": "^1.18.3",
Expand All @@ -44,7 +45,6 @@
"winston": "^3.3.3"
},
"devDependencies": {
"@tupaia/types": "workspace:*",
"@types/multer": "^1.4.7"
}
}
4 changes: 2 additions & 2 deletions packages/admin-panel-server/src/@types/express/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import { AccessPolicy } from '@tupaia/access-policy';
import { TupaiaApiClient } from '@tupaia/api-client';

import { AdminPanelSessionType } from '../../models';
import { AdminPanelSessionRecord } from '../../models';

declare global {
namespace Express {
export interface Request {
accessPolicy: AccessPolicy;
session: AdminPanelSessionType;
session: AdminPanelSessionRecord;
ctx: {
services: TupaiaApiClient;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ describe('DashboardVisualisationExtractor', () => {
config: {
transform: [],
},
latestDataParameters: {},
});
});

Expand All @@ -99,6 +100,7 @@ describe('DashboardVisualisationExtractor', () => {
config: {
customReport: 'custom',
},
latestDataParameters: {},
});
});
});
Expand Down Expand Up @@ -300,6 +302,7 @@ describe('DashboardVisualisationExtractor', () => {
},
},
permissionGroup: 'Admin',
latestDataParameters: {},
});
});

Expand Down Expand Up @@ -339,6 +342,7 @@ describe('DashboardVisualisationExtractor', () => {
},
},
permissionGroup: 'Admin',
latestDataParameters: {},
});
});

Expand Down Expand Up @@ -376,6 +380,7 @@ describe('DashboardVisualisationExtractor', () => {
},
},
permissionGroup: 'Admin',
latestDataParameters: {},
});
});
});
Expand All @@ -385,13 +390,13 @@ describe('DashboardVisualisationExtractor', () => {
const extractor = new DashboardVisualisationExtractor(
{
code: 'viz',
name: 'My Viz',
data: {
transform: ['keyValueByDataElementName'],
},
presentation: {
type: 'chart',
chartType: 'bar',
name: 'My Viz',
output: {
type: 'bar',
},
Expand Down Expand Up @@ -422,13 +427,13 @@ describe('DashboardVisualisationExtractor', () => {
const extractor = new DashboardVisualisationExtractor(
{
code: 'viz',
name: 'My Viz',
data: {
transform: ['keyValueByDataElementName'],
},
presentation: {
type: 'chart',
chartType: 'bar',
name: 'My Viz',
output: {
type: 'bar',
},
Expand All @@ -451,6 +456,7 @@ describe('DashboardVisualisationExtractor', () => {
},
},
permission_group: 'Admin',
latest_data_parameters: {},
},
dashboardItem: {
code: 'viz',
Expand Down
10 changes: 5 additions & 5 deletions packages/admin-panel-server/src/models/AdminPanelSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
* Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd
*/

import { SessionType, SessionModel } from '@tupaia/server-boilerplate';
import { SessionRecord, SessionModel } from '@tupaia/server-boilerplate';

export class AdminPanelSessionType extends SessionType {
public static databaseType = 'admin_panel_session';
export class AdminPanelSessionRecord extends SessionRecord {
public static databaseRecord = 'admin_panel_session';
}

export class AdminPanelSessionModel extends SessionModel {
public get DatabaseTypeClass() {
return AdminPanelSessionType;
public get DatabaseRecordClass() {
return AdminPanelSessionRecord;
}
}
2 changes: 1 addition & 1 deletion packages/admin-panel-server/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd
*/

export { AdminPanelSessionType, AdminPanelSessionModel } from './AdminPanelSession';
export { AdminPanelSessionRecord, AdminPanelSessionModel } from './AdminPanelSession';
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export type FetchHierarchyEntitiesRequest = Request<
{ hierarchyName: string; entityCode: string },
Record<string, unknown>[],
Record<string, never>,
{ fields?: string; search?: string }
{ fields?: string; search?: string; pageSize?: string }
>;

export class FetchHierarchyEntitiesRoute extends Route<FetchHierarchyEntitiesRequest> {
public async buildResponse() {
const { entity: entityApi } = this.req.ctx.services;
const { hierarchyName, entityCode } = this.req.params;
const { fields, search } = this.req.query;
const { fields, search, pageSize } = this.req.query;
const queryParams: {
fields?: string[];
filter?: Record<string, { comparator: string; comparisonValue: unknown }>;
Expand All @@ -35,12 +35,21 @@ export class FetchHierarchyEntitiesRoute extends Route<FetchHierarchyEntitiesReq
},
};
}

const projectEntity = await entityApi.getEntities(hierarchyName, [entityCode], queryParams);
const descendants = await entityApi.getDescendantsOfEntity(
hierarchyName,
entityCode,
queryParams,
false,
false,
);
return projectEntity.concat(descendants);
const flattenedDescendants = projectEntity.concat(descendants);

// If pageSize is provided, return only the first n entities
if (pageSize) {
return flattenedDescendants.slice(0, parseInt(pageSize, 10));
}
return flattenedDescendants;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {

export type ExportDashboardVisualisationRequest = Request<
{ dashboardVisualisationId?: string },
{ contents: DashboardViz; filePath: string; type: string },
{ contents: Omit<DashboardViz, 'latestDataParameters'>; filePath: string; type: string },
{ visualisation: DashboardViz },
Record<string, any>
>;
Expand All @@ -40,14 +40,14 @@ export class ExportDashboardVisualisationRoute extends Route<ExportDashboardVisu
builtVisualisation || (await this.buildDashboardItemVisualisation(dashboardItem));
const fileBaseName = visualisation.code || 'new_dashboard_visualisation';

const { id, ...visualisationWithoutId } = visualisation;
const { id, latestDataParameters, ...visualisationWithoutIdAndLatestParams } = visualisation;
const { dashboards, dashboardRelations } = await this.buildDashboardsAndRelations(
dashboardItem,
);

return {
contents: {
...visualisationWithoutId,
...visualisationWithoutIdAndLatestParams,
dashboards,
dashboardRelations,
},
Expand Down
Loading

0 comments on commit 4f302f5

Please sign in to comment.