Skip to content

Commit

Permalink
Merge pull request #649 from bcgov/dev
Browse files Browse the repository at this point in the history
Dev to Main merge 19 March 2024
  • Loading branch information
nikhila-aot authored Mar 19, 2024
2 parents e6c1e72 + cb87404 commit e3f632b
Show file tree
Hide file tree
Showing 470 changed files with 129,874 additions and 6,745 deletions.
29 changes: 27 additions & 2 deletions backend/applications/src/app/controllers/form.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Controller, Get, Param, Patch, Post, Put } from '@nestjs/common';
import { Resource, Unprotected } from 'nest-keycloak-connect';
import { Unprotected } from 'nest-keycloak-connect';
import { SubmissionResponse } from '../dto/submissionResponse.dto';
import { Form } from '../entities/form.entity';
import { FormService } from '../services/form.service';
Expand All @@ -8,7 +8,24 @@ import { FormService } from '../services/form.service';
//@Resource('application-service')
@Unprotected()
export class FormController {
constructor(private formService: FormService) {}
constructor(private formService: FormService) { }

/**
* Checks if table exists
* @returns boolean
*/
@Get('health')
async healthCheck(): Promise<number> {
const formCount = await this.formService.healthCheck();

if (!formCount) {
return Promise.reject({
statusCode: 404,
message: 'Table not found',
});
}
return formCount;
}

/**
* Get a submitted form using
Expand All @@ -24,6 +41,14 @@ export class FormController {
submissionId,
formId,
);

if (!savedSubmission) {
return Promise.reject({
statusCode: 404,
message: 'Form data not found',
});
}

const submissionResponse: SubmissionResponse =
this.transformResult(savedSubmission);
return submissionResponse;
Expand Down
25 changes: 19 additions & 6 deletions backend/applications/src/app/services/form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ import { Form } from '../entities/form.entity';
export class FormService {
constructor(
@InjectRepository(Form) private readonly formRepository: Repository<Form>,
) {}
) { }

/**
* Checks if table exists
* @returns boolean
*/
async healthCheck(): Promise<any> {
const tableExists = (
await this.formRepository.manager.query(
`SELECT exists (
SELECT FROM information_schema.tables
WHERE table_schema = 'epd_applications'
AND table_name = 'form'
)`,
)
)[0].exists;
return tableExists;
}

/**
* Creates new form submission
Expand Down Expand Up @@ -36,7 +53,7 @@ export class FormService {

buildUpdateString = (pathText, newValue) => {
const returnString =
'jsonb_set("form_data"::jsonb,' + pathText + ',' + newValue + ')';
'jsonb_set("form_data"::jsonb,' + pathText + ',' + newValue + ')';
return returnString;
};

Expand All @@ -46,7 +63,6 @@ export class FormService {
formId,
submissionId,
) => {

for (const property in partialUpdateObject) {
if (typeof partialUpdateObject[property] === 'object') {
this.processContent(
Expand All @@ -64,14 +80,11 @@ export class FormService {
} else {
objectName = property;
}


const pathText = "'{" + objectName + "}'";

const newValue = '\'"' + partialUpdateObject[property] + '"\'';



await this.formRepository
.createQueryBuilder()
.update(Form)
Expand Down
57 changes: 57 additions & 0 deletions bcbox/.codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: "2"
exclude_patterns:
- config/
- db/
- dist/
- features/
- "**/node_modules/"
- script/
- "**/spec/"
- "**/test/"
- "**/tests/"
- Tests/
- "**/vendor/"
- "**/*_test.go"
- "**/*.d.ts"
plugins:
csslint:
enabled: true
editorconfig:
enabled: true
checks:
END_OF_LINE:
enabled: false
INDENTATION_SPACES:
enabled: false
INDENTATION_SPACES_AMOUNT:
enabled: false
TRAILINGSPACES:
enabled: false
eslint:
enabled: true
channel: "eslint-7"
config:
config: app/.eslintrc.js
fixme:
enabled: true
git-legal:
enabled: true
markdownlint:
enabled: true
checks:
MD002:
enabled: false
MD013:
enabled: false
MD029:
enabled: false
MD046:
enabled: false
nodesecurity:
enabled: true
sass-lint:
enabled: true
rules:
nesting-depth:
- 2
- max-depth: 5
42 changes: 42 additions & 0 deletions bcbox/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Editor directories and files
.DS_Store
.gradle
.nyc_output
.scannerwork
build
coverage
dist
files
**/e2e/videos
node_modules
# Ignore only top-level package-lock.json
/package-lock.json

# Ignore Helm subcharts
charts/**/charts
Chart.lock

# local env files
local.*
local-*.*
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
.vscode
*.iml
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.mp4

# temp office files
~$*
23 changes: 23 additions & 0 deletions bcbox/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.html]
indent_style = space
indent_size = 2

[*.{css,js,json,jsx,scss,ts,tsx,vue}]
indent_style = space
indent_size = 2

[.{babelrc,eslintrc}]
indent_style = space
indent_size = 2

[Jenkinsfile*]
indent_style = space
indent_size = 2
8 changes: 8 additions & 0 deletions bcbox/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Autodetect text files and forces unix eols, so Windows does not break them
* text=auto eol=lf

# Force images/fonts to be handled as binaries
*.jpg binary
*.jpeg binary
*.gif binary
*.png binary
42 changes: 42 additions & 0 deletions bcbox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Editor directories and files
.DS_Store
.gradle
.nyc_output
.scannerwork
build
coverage
dist
files
**/e2e/videos
node_modules
# Ignore only top-level package-lock.json
/package-lock.json

# Ignore Helm subcharts
charts/**/charts
Chart.lock

# local env files
*local.*
*local-*.*
.env.local
.env.*.local


# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea
*.iml
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.mp4

# temp office files
~$*
14 changes: 14 additions & 0 deletions bcbox/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
"bierner.markdown-preview-github-styles",
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters",
"vue.volar",
"vue.vscode-typescript-vue-plugin"
]
}
16 changes: 16 additions & 0 deletions bcbox/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"sourceMaps": true,
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
26 changes: 26 additions & 0 deletions bcbox/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"coverage-gutters.showGutterCoverage": false,
"coverage-gutters.showLineCoverage": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"eslint.format.enable": true,
"files.insertFinalNewline": true
}
46 changes: 46 additions & 0 deletions bcbox/CODE-OF-CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
Loading

0 comments on commit e3f632b

Please sign in to comment.