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

Release 2024-15 #5538

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1488174
Merge pull request #5537 from beyondessential/master
rohan-bes Mar 26, 2024
310b171
no-issue: Don’t render schema diffs by default (#5542)
jaskfla Mar 28, 2024
7cbc742
no-issue: Add 'output' and fix up config for conditions in viz-builde…
rohan-bes Mar 28, 2024
344c36a
MDEV-229: Add 'maintenance' entity type (#5546)
rohan-bes Apr 1, 2024
8665090
build(deps): bump express from 4.17.1 to 4.19.2 (#5545)
jaskfla Apr 2, 2024
97c8c06
ci: Add PR title check (#5548)
rohan-bes Apr 2, 2024
3a59b3a
fix(security): RN-1084: Remove refresh token from access token (#5547)
alexd-bes Apr 2, 2024
7fc05ab
feat(adminPanel): RN-1242: Export entity hierarchies (#5530)
alexd-bes Apr 3, 2024
f64998d
fix(vizBuilder): RN-1054: picks wrong date (#5447)
jaskfla Apr 4, 2024
b2c0d4b
tweak(centralServer): remove legacy `requestCountryAccess` endpoint (…
jaskfla Apr 4, 2024
7616b19
refactor: RN-1225: Update how env vars are handled (#5533)
alexd-bes Apr 4, 2024
9cb809e
deps: bump `vite` to 4.5.3
jaskfla Apr 4, 2024
cb316ed
Fix issue with mac/linux (#5562)
alexd-bes Apr 4, 2024
edf5ad1
repo: mark lockfile as generated (#5555)
jaskfla Apr 4, 2024
1287db2
deps: RN-1112: bump `knex` to 3.1.0 (#5483)
jaskfla Apr 4, 2024
56032fe
tweak(environment): RN-1225: Override with local env if exists (#5564)
alexd-bes Apr 4, 2024
998c820
fix(vizBuilder): vizBuilder crashes Admin Panel (#5565)
jaskfla Apr 4, 2024
0c15d3d
db(entityTypes): MDEV-230: Add larval_sample entity type (#5559)
rohan-bes Apr 4, 2024
63c6b59
refactor(permissions): Removed un-used 'Viz Builder User' permissions…
rohan-bes Apr 4, 2024
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
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
*.md linguist-documentation
*.pbxproj -text
packages/types/src/schemas/schemas.ts linguist-generated=true
packages/types/src/types/models.ts linguist-generated=true
yarn.lock linguist-generated=true
43 changes: 43 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,49 @@ your changes and provide feedback. If your pull request has been approved by a r
will then go through a round of internal testing. Once your changes have passed testing, they
can be merged into main and be included in an upcoming Tupaia release.

#### Pull request title rules

We use a squash-and-merge strategy when merging PRs into dev. This means the commit messages in dev will match the PR titles. We like to keep standardised commit messages as an easy way to track release changes and for record keeping purposes.

The title of pull requests must be in [Conventional Commit](https://beyond-essential.slab.com/posts/pr-titles-conventional-commits-avgsj3xb) format. This is used to generate
changelogs, and to provide a consistent format for commits landing in the main branch, as pull
requests are merged in “squash” mode.

```plain
type: <description>
type(scope): <description>
```

When a Linear card is applicable, the Linear card number should be included:

```plain
type: TEAM-123: <description>
type(scope): TEAM-123: <description>
```

The following types are conventional:

- `ci` for changes to the CI/CD workflows
- `db` for changes to the database schema, migrations, etc
- `deps` for changes to dependencies or dependency upgrades
- `doc` for documentation changes
- `env` for changes to the environment variables
- `feat` for new features
- `fix` for bug fixes
- `fmt` for automatic formatting changes
- `merge` for merging between branches (generally between `master` and `dev`)
- `refactor` for code refactoring
- `repo` for changes to the repository structure (e.g. `.gitignore`, `.editorconfig`, etc)
- `revert` for reverting a previous commit
- `style` for stylistic changes that do not affect the meaning of the code
- `test` for adding missing tests or correcting existing tests
- `tweak` for minor changes that do not fit into any other category

When merging, additional change lines may be added to the squashed commit message to provide further
context to be pulled into changelogs.

Using Conventional Commit format for actual commit messages within pull requests is not required.

### Note on Forking

While Tupaia is open-source, there is always the possibility for forking the repository, which
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/check-pr-title.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Check PR title

on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
check:
runs-on: ubuntu-latest
env:
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- id: release
name: Check for release PR format
if: startsWith(github.event.pull_request.title, 'Release')
shell: bash
run: |
if ! grep -qP '^Release [0-9]{4}-[0-9]{2}$' <<< "$PR_TITLE"; then
echo "::warning::Release PR title should be: 'Release <year>-<ISO week number>'"
exit 1
fi

- name: Check for Conventional Commit format
shell: bash
if: steps.release.conclusion == 'skipped'
run: |
if ! grep -qP '^\w+(\(\w+\))?:\s' <<< "$PR_TITLE"; then
echo "::warning::PR title should be in Conventional Commit style, e.g. 'feat: ...'"
exit 1
fi

- name: Check for conventional type allow-list
if: steps.release.conclusion == 'skipped'
shell: bash
run: |
if ! grep -qP '^(ci|db|deps|doc|env|feat|fix|fmt|merge|refactor|repo|revert|style|test|tweak)(\(\w+\))?:\s' <<< "$PR_TITLE"; then
echo "::warning::PR title Conventional Type is not on the list; refer to CONTRIBUTING.md"
exit 1
fi

- name: Check for Linear card number for feature branches
if: steps.release.conclusion == 'skipped' && startsWith(github.event.pull_request.title, 'feat')
shell: bash
run: |
if ! grep -qP '^\w+(\(\w+\))?:\s[A-Z]+-[0-9]+(:\s+\w+)?' <<< "$PR_TITLE"; then
echo "::warning::PR title should start with ticket number, e.g. 'feat(scope): ABC-123: ...'"
exit 1
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.env*
!*.env.example*
!*.env.*.example*
!*.env.encrypted*
.DS_Store
**/node_modules
Expand Down
1 change: 1 addition & 0 deletions env/aggregation.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AGGREGATION_URL_PREFIX=
7 changes: 7 additions & 0 deletions env/api-client.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
AUTH_API_URL=
DATA_TABLE_API_URL=
CENTRAL_API_URL=
ENTITY_API_URL=
REPORT_API_URL=
WEB_CONFIG_API_URL=
API_CLIENT_SALT=
3 changes: 3 additions & 0 deletions env/aws.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
4 changes: 4 additions & 0 deletions env/data-lake.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DATA_LAKE_DB_NAME=
DATA_LAKE_DB_PASSWORD=
DATA_LAKE_DB_URL=
DATA_LAKE_DB_USER=
1 change: 0 additions & 1 deletion packages/auth/.env.example → env/db.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
DB_DISABLE_SSL=
DB_NAME=
DB_PASSWORD=
DB_URL=
Expand Down
8 changes: 8 additions & 0 deletions env/dhis.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PALAU_DHIS_CLIENT_SECRET=
PALAU_DHIS_PASSWORD=
PALAU_DHIS_API_URL=
DHIS_CLIENT_ID=
DHIS_CLIENT_SECRET=
DHIS_PASSWORD=
DHIS_USERNAME=
IS_PRODUCTION_ENVIRONMENT=
15 changes: 15 additions & 0 deletions env/external-db-connections.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
EXT_DB_niwa_PORT=
EXT_DB_niwa_DATABASE=
EXT_DB_niwa_USER=
EXT_DB_niwa_PASSWORD=
EXT_DB_niwa_HOST=
EXT_DB_data_lake_HOST=
EXT_DB_data_lake_PORT=
EXT_DB_data_lake_DATABASE=
EXT_DB_data_lake_USER=
EXT_DB_data_lake_PASSWORD=
EXT_DB_msupply_scheduled_HOST=
EXT_DB_msupply_scheduled_PORT=
EXT_DB_msupply_scheduled_DATABASE=
EXT_DB_msupply_scheduled_USER=
EXT_DB_msupply_scheduled_PASSWORD=
5 changes: 5 additions & 0 deletions env/mail.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SITE_EMAIL_ADDRESS=
SMTP_HOST=
SMTP_PASSWORD=
SMTP_USER=
DEV_EMAIL_ADDRESS=
4 changes: 4 additions & 0 deletions env/pg.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DB_PG_USER=
DB_PG_PASSWORD=
# used in CI/CD, and for running analytics refresh via CLI
DB_ENABLE_SSL=
5 changes: 5 additions & 0 deletions env/servers.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

JWT_SECRET=
SESSION_COOKIE_SECRET=


3 changes: 3 additions & 0 deletions env/superset.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUPERSET_API_PROXY_URL=
SUPERSET_API_USERNAME=
SUPERSET_API_PASSWORD=
1 change: 1 addition & 0 deletions env/weatherbit.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WEATHERBIT_API_KEY=
2 changes: 1 addition & 1 deletion jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Tupaia
* Copyright (c) 2017 - 2020 Beyond Essential Systems Pty Ltd
* Copyright (c) 2017 - 2024 Beyond Essential Systems Pty Ltd
*/

/* eslint-env jest */
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"babel-preset-react-app": "^10.0.0",
"concurrently": "^5.2.0",
"cypress-dotenv": "^1.2.2",
"dotenv": "^16.0.3",
"dotenv": "16.4.5",
"eslint": "^7.9.0",
"eslint-import-resolver-babel-module": "^5.3.1",
"eslint-plugin-cypress": "^2.11.1",
Expand All @@ -87,7 +87,7 @@
"ts-jest": "^29.1.2",
"ts-node": "^10.7.0",
"typescript": "^5.2.2",
"vite": "^4.4.8",
"vite": "^4.5.3",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-ejs": "^1.6.4",
"yargs": "15.4.1"
Expand Down
14 changes: 1 addition & 13 deletions packages/admin-panel-server/.env.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
PORT=

API_CLIENT_NAME=
API_CLIENT_PASSWORD=
API_CLIENT_SALT=

DB_URL=
DB_NAME=
DB_PASSWORD=
DB_USER=

SESSION_COOKIE_SECRET=

CENTRAL_API_URL=
ENTITY_API_URL=
REPORT_API_URL=
API_CLIENT_PASSWORD=
7 changes: 4 additions & 3 deletions 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/server-utils": "workspace:*",
"@tupaia/types": "workspace:*",
"@tupaia/utils": "workspace:*",
"api-error-handler": "^1.0.0",
Expand All @@ -38,11 +39,11 @@
"case": "^1.6.3",
"client-sessions": "^0.8.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.16.2",
"express": "^4.19.2",
"lodash": "^4.17.4",
"multer": "^1.4.3",
"winston": "^3.3.3"
"winston": "^3.3.3",
"xlsx": "^0.10.9"
},
"devDependencies": {
"@types/multer": "^1.4.7"
Expand Down
6 changes: 6 additions & 0 deletions packages/admin-panel-server/src/app/createApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import {
FetchTransformSchemasRoute,
FetchDataTableBuiltInParamsRequest,
FetchDataTableBuiltInParamsRoute,
ExportEntityHierarchiesRequest,
ExportEntityHierarchiesRoute,
} from '../routes';
import { authHandlerProvider } from '../auth';

Expand Down Expand Up @@ -105,6 +107,10 @@ export async function createApp() {
'export/mapOverlayVisualisation/:mapOverlayVisualisationId',
handleWith(ExportMapOverlayVisualisationRoute),
)
.get<ExportEntityHierarchiesRequest>(
'export/hierarchies',
handleWith(ExportEntityHierarchiesRoute),
)
.post<ExportDashboardVisualisationRequest>(
'export/dashboardVisualisation',
handleWith(ExportDashboardVisualisationRoute),
Expand Down
1 change: 0 additions & 1 deletion packages/admin-panel-server/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@

export const BES_ADMIN_PERMISSION_GROUP = 'BES Admin';
export const TUPAIA_ADMIN_PANEL_PERMISSION_GROUP = 'Tupaia Admin Panel';
export const VIZ_BUILDER_USER_PERMISSION_GROUP = 'Viz Builder User';
11 changes: 9 additions & 2 deletions packages/admin-panel-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
*/

import http from 'http';
import * as dotenv from 'dotenv';
import path from 'path';

import winston from 'winston';
import { configureWinston } from '@tupaia/server-boilerplate';
import { configureDotEnv } from '@tupaia/server-utils';
import { createApp } from './app';

configureWinston();
dotenv.config(); // Load the environment variables into process.env

configureDotEnv([
path.resolve(__dirname, '../../../env/servers.env'),
path.resolve(__dirname, '../../../env/db.env'),
path.resolve(__dirname, '../../../env/api-client.env'),
path.resolve(__dirname, '../.env'),
]);

(async () => {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* Tupaia
* Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd
*/

import { Request } from 'express';
import xlsx from 'xlsx';
import { Route } from '@tupaia/server-boilerplate';

export type ExportEntityHierarchiesRequest = Request<
{ hierarchies: string },
{ contents: Buffer; filePath: string; type: string },
Record<string, never>,
Record<string, any>
>;

export class ExportEntityHierarchiesRoute extends Route<ExportEntityHierarchiesRequest> {
protected readonly type = 'download';

public async buildResponse() {
const { hierarchies } = this.req.query;
const { entity: entityApi } = this.req.ctx.services;

const hierarchiesArray = Array.isArray(hierarchies) ? hierarchies : [hierarchies];

const workbook = xlsx.utils.book_new();

for (const hierarchy of hierarchiesArray) {
const descendants = await entityApi.getDescendantsOfEntity(
hierarchy,
hierarchy,
{
fields: ['name', 'code', 'parent_code'],
},
false,
false,
);

const projectEntity = await entityApi.getEntity(hierarchy, hierarchy, {
fields: ['name'],
});

const sheetName = projectEntity?.name || hierarchy;
const sheet = xlsx.utils.json_to_sheet(descendants);
xlsx.utils.book_append_sheet(workbook, sheet, sheetName);
}

const buffer = xlsx.write(workbook, { type: 'buffer', bookType: 'xlsx' });

return {
contents: buffer,
filePath: `entity_hierarchies_export_${Date.now()}.xlsx`,
type: '.xlsx',
};
}
}
1 change: 1 addition & 0 deletions packages/admin-panel-server/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './FetchReportPreviewDataRoute';
export * from './FetchReportSchemasRoute';
export * from './UploadTestDataRoute';
export * from './UserRoute';
export * from './ExportEntityHierarchiesRoute';
19 changes: 0 additions & 19 deletions packages/admin-panel-server/src/utils/hasVizBuilderUserAccess.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/admin-panel-server/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
*/

export { hasTupaiaAdminPanelAccess } from './hasTupaiaAdminPanelAccess';
export { hasVizBuilderUserAccess } from './hasVizBuilderUserAccess';
export { readFileContent } from './readFileContent';
Loading
Loading