Switch to single branch (#221)
* remove submodules * add api and ui files * update github actions * use sparse checkout * update node setup * update checkout * update docker * change permissions * update mariadb health check * update changelog
This commit is contained in:
parent
42050dc078
commit
9c4c325e5a
55
.github/workflows/api-image.yml
vendored
Normal file
55
.github/workflows/api-image.yml
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'api/**'
|
||||
branches:
|
||||
- master
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: push API docker image
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'api'
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Move API files to root
|
||||
run: |
|
||||
ls -lah
|
||||
shopt -s dotglob
|
||||
mv api/* .
|
||||
rm -rf api
|
||||
ls -lah
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ohmyform/api
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
type=semver,pattern={{major}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
222
.github/workflows/api-test.yml
vendored
Normal file
222
.github/workflows/api-test.yml
vendored
Normal file
@ -0,0 +1,222 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'api/**'
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
CREATE_ADMIN: true
|
||||
ADMIN_EMAIL: admin@localhost
|
||||
ADMIN_USERNAME: admin
|
||||
ADMIN_PASSWORD: admin
|
||||
MAILER_URI: smtp://localhost:1025
|
||||
|
||||
jobs:
|
||||
run-linters:
|
||||
name: run API lint
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'api'
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Move API files to root
|
||||
run: |
|
||||
ls -lah
|
||||
shopt -s dotglob
|
||||
mv api/* .
|
||||
rm -rf api
|
||||
ls -lah
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
# ESLint and Prettier must be in `package.json`
|
||||
- name: Install Node.js dependencies
|
||||
run: yarn install --frozen-lockfile --silent
|
||||
|
||||
- run: ls -lah
|
||||
|
||||
- name: Lint
|
||||
uses: reviewdog/action-eslint@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
reporter: github-pr-review # Change reporter.
|
||||
eslint_flags: '{src,test}/**/*.ts'
|
||||
|
||||
- name: Typecheck
|
||||
uses: andoshin11/typescript-error-reporter-action@v1.0.2
|
||||
|
||||
run-postgres:
|
||||
name: run API postgres migrations
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:10-alpine
|
||||
env:
|
||||
POSTGRES_USER: root
|
||||
POSTGRES_PASSWORD: root
|
||||
POSTGRES_DB: ohmyform
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'api'
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Move API files to root
|
||||
run: |
|
||||
ls -lah
|
||||
shopt -s dotglob
|
||||
mv api/* .
|
||||
rm -rf api
|
||||
ls -lah
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: yarn install --frozen-lockfile --silent
|
||||
|
||||
- name: PostgreSQL Migrations
|
||||
run: yarn typeorm migration:run
|
||||
env:
|
||||
DATABASE_DRIVER: postgres
|
||||
|
||||
TYPEORM_CONNECTION: postgres
|
||||
TYPEORM_HOST: localhost
|
||||
TYPEORM_PORT: 5432
|
||||
TYPEORM_USERNAME: root
|
||||
TYPEORM_PASSWORD: root
|
||||
TYPEORM_DATABASE: ohmyform
|
||||
TYPEORM_AUTO_SCHEMA_SYNC: false
|
||||
TYPEORM_ENTITIES: src/entity/**/*.ts
|
||||
TYPEORM_SUBSCRIBERS: src/subscriber/**/*.ts
|
||||
TYPEORM_MIGRATIONS: src/migrations/postgres/**/*.ts
|
||||
TYPEORM_MIGRATIONS_TRANSACTION_MODE: 'each'
|
||||
TYPEORM_ENTITIES_DIR: src/entity
|
||||
TYPEORM_MIGRATIONS_DIR: src/migrations/postgres
|
||||
TYPEORM_SUBSCRIBERS_DIR: src/subscriber
|
||||
|
||||
run-mariadb:
|
||||
name: run API mariadb migrations
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: ohmyform
|
||||
ports:
|
||||
- 3306:3306
|
||||
options: >-
|
||||
--health-cmd="healthcheck.sh --connect --innodb_initialized"
|
||||
--health-interval=10s
|
||||
--health-timeout=5s
|
||||
--health-retries=3
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'api'
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Move API files to root
|
||||
run: |
|
||||
ls -lah
|
||||
shopt -s dotglob
|
||||
mv api/* .
|
||||
rm -rf api
|
||||
ls -lah
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: yarn install --frozen-lockfile --silent
|
||||
|
||||
- name: MariaDB Migrations
|
||||
run: yarn typeorm migration:run
|
||||
env:
|
||||
DATABASE_DRIVER: mariadb
|
||||
|
||||
TYPEORM_CONNECTION: mariadb
|
||||
TYPEORM_HOST: localhost
|
||||
TYPEORM_PORT: 3306
|
||||
TYPEORM_USERNAME: root
|
||||
TYPEORM_PASSWORD: root
|
||||
TYPEORM_DATABASE: ohmyform
|
||||
TYPEORM_AUTO_SCHEMA_SYNC: false
|
||||
TYPEORM_ENTITIES: src/entity/**/*.ts
|
||||
TYPEORM_SUBSCRIBERS: src/subscriber/**/*.ts
|
||||
TYPEORM_MIGRATIONS: src/migrations/mariadb/**/*.ts
|
||||
TYPEORM_MIGRATIONS_TRANSACTION_MODE: 'each'
|
||||
TYPEORM_ENTITIES_DIR: src/entity
|
||||
TYPEORM_MIGRATIONS_DIR: src/migrations/mariadb
|
||||
TYPEORM_SUBSCRIBERS_DIR: src/subscriber
|
||||
|
||||
run-sqlite:
|
||||
name: run API sqlite migrations
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'api'
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Move API files to root
|
||||
run: |
|
||||
ls -lah
|
||||
shopt -s dotglob
|
||||
mv api/* .
|
||||
rm -rf api
|
||||
ls -lah
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: yarn install --frozen-lockfile --silent
|
||||
|
||||
- name: SQLite Migrations
|
||||
run: yarn typeorm migration:run --transaction none
|
||||
env:
|
||||
DATABASE_DRIVER: sqlite
|
||||
|
||||
TYPEORM_CONNECTION: sqlite
|
||||
TYPEORM_USERNAME: root
|
||||
TYPEORM_DATABASE: data.sqlite
|
||||
TYPEORM_AUTO_SCHEMA_SYNC: false
|
||||
TYPEORM_ENTITIES: src/entity/**/*.ts
|
||||
TYPEORM_SUBSCRIBERS: src/subscriber/**/*.ts
|
||||
TYPEORM_MIGRATIONS: src/migrations/sqlite/**/*.ts
|
||||
TYPEORM_MIGRATIONS_TRANSACTION_MODE: 'none'
|
||||
TYPEORM_ENTITIES_DIR: src/entity
|
||||
TYPEORM_MIGRATIONS_DIR: src/migrations/sqlite
|
||||
TYPEORM_SUBSCRIBERS_DIR: src/subscriber
|
@ -2,6 +2,13 @@ name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'ui/**'
|
||||
- 'api/**'
|
||||
- 'Dockerfile'
|
||||
- 'supervisord.conf'
|
||||
- 'nginx.conf'
|
||||
- 'docker/**'
|
||||
branches:
|
||||
- master
|
||||
release:
|
||||
@ -10,7 +17,7 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Push Docker image to Docker Hub
|
||||
name: push OHMYFORM docker image
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@ -20,14 +27,14 @@ jobs:
|
||||
submodules: true
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ohmyform/ohmyform
|
||||
tags: |
|
||||
@ -37,7 +44,7 @@ jobs:
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: true
|
55
.github/workflows/ui-image.yml
vendored
Normal file
55
.github/workflows/ui-image.yml
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
name: Docker Image CI
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'ui/**'
|
||||
branches:
|
||||
- master
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: push UI docker image
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'ui'
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Move UI files to root
|
||||
run: |
|
||||
ls -lah
|
||||
shopt -s dotglob
|
||||
mv ui/* .
|
||||
rm -rf ui
|
||||
ls -lah
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ohmyform/ui
|
||||
tags: |
|
||||
type=raw,value=latest
|
||||
type=semver,pattern={{major}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
50
.github/workflows/ui-test.yml
vendored
Normal file
50
.github/workflows/ui-test.yml
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'ui/**'
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
run-linters:
|
||||
name: run UI lint
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- name: Check out Git repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: 'ui'
|
||||
sparse-checkout-cone-mode: false
|
||||
- name: Move UI files to root
|
||||
run: |
|
||||
ls -lah
|
||||
shopt -s dotglob
|
||||
mv ui/* .
|
||||
rm -rf ui
|
||||
ls -lah
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
# ESLint and Prettier must be in `package.json`
|
||||
- name: Install Node.js dependencies
|
||||
run: yarn install --frozen-lockfile --silent
|
||||
|
||||
- name: Lint
|
||||
uses: reviewdog/action-eslint@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
reporter: github-pr-review # Change reporter.
|
||||
eslint_flags: 'pages/ store/ components/ graphql/'
|
||||
|
||||
- name: Typecheck
|
||||
uses: andoshin11/typescript-error-reporter-action@v1.0.2
|
||||
|
7
.gitmodules
vendored
7
.gitmodules
vendored
@ -1,7 +0,0 @@
|
||||
[submodule "ui"]
|
||||
path = ui
|
||||
url = https://github.com/ohmyform/ui
|
||||
|
||||
[submodule "api"]
|
||||
path = api
|
||||
url = https://github.com/ohmyform/api
|
200
CHANGELOG.md
200
CHANGELOG.md
@ -9,71 +9,111 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
Template for next version
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
|
||||
### Security
|
||||
-->
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed typo https://github.com/ohmyform/ohmyform/pull/185
|
||||
* node prune location (https://github.com/ohmyform/ohmyform/issues/184)
|
||||
|
||||
### Security
|
||||
- [UI] node prune location (https://github.com/ohmyform/ohmyform/issues/184)
|
||||
- [API] creation of new logic elements
|
||||
- [API] node prune location (https://github.com/ohmyform/ohmyform/issues/184)
|
||||
- Fixed typo https://github.com/ohmyform/ohmyform/pull/185
|
||||
- node prune location (https://github.com/ohmyform/ohmyform/issues/184)
|
||||
- use monorepo (https://github.com/ohmyform/ohmyform/pull/221)
|
||||
|
||||
## [1.0.3] - 2022-03-27
|
||||
|
||||
### Updates
|
||||
|
||||
* https://github.com/ohmyform/api/releases/tag/1.0.3
|
||||
* https://github.com/ohmyform/ui/releases/tag/1.0.3
|
||||
|
||||
### Added
|
||||
|
||||
* minimal configuration example for caddy server (https://github.com/ohmyform/ohmyform/pull/167)
|
||||
- [UI] default form now has an end page
|
||||
- [UI] sorting of fields in excel export
|
||||
- [API] missing encode / decode for form fields within submissions (https://github.com/ohmyform/ui/commit/30ff2c96bca20c1641d9cbb96c34cce934e1afea#r68602651)
|
||||
- [API] form field resolvers were missing
|
||||
- [API] node-gyp update to enable build on osx 12.3
|
||||
- [API] creating of new fields
|
||||
- [API] notifications / hooks / pages and buttons encode and decode their ids
|
||||
- [API] add start and end page to form create call
|
||||
- minimal configuration example for caddy server (https://github.com/ohmyform/ohmyform/pull/167)
|
||||
- [API] form hooks should only be queryable for form admins
|
||||
|
||||
## [1.0.2] - 2022-03-13
|
||||
|
||||
### Updates
|
||||
|
||||
* https://github.com/ohmyform/api/releases/tag/1.0.2
|
||||
* https://github.com/ohmyform/ui/releases/tag/1.0.2
|
||||
|
||||
### Changed
|
||||
|
||||
- [UI] field sort in excel submission export (https://github.com/ohmyform/ohmyform/issues/163)
|
||||
- [API] error sending notification when field is not defined (https://github.com/ohmyform/ohmyform/issues/161)
|
||||
- docker restart policy (https://github.com/ohmyform/ohmyform/issues/164)
|
||||
|
||||
## [1.0.1] - 2022-03-01
|
||||
|
||||
### Updates
|
||||
|
||||
* https://github.com/ohmyform/api/releases/tag/1.0.1
|
||||
* https://github.com/ohmyform/ui/releases/tag/1.0.1
|
||||
- [UI] map field type
|
||||
- [UI] update translations (https://github.com/ohmyform/ui/pull/70)
|
||||
- [UI] show warning icon in form list if not public
|
||||
- [UI] default form layout is now "card"
|
||||
- [UI] creating of new fields combined in new field types
|
||||
- [UI] locale scripts were missing dependency
|
||||
- [UI] edit user shows now email in title
|
||||
- [UI] focus is now passed also do slide layout fields
|
||||
- [UI] empty fields are no longer submitted
|
||||
- [UI] stuttery form because of logic rerenders
|
||||
- [API] allow one field nested data to be submitted
|
||||
- [API] only update user fields in update mutation if they changed
|
||||
- [API] form delete
|
||||
- [API] field submission without value field
|
||||
- [API] start using hashids to prevent insights into form ids (https://hashids.org/javascript/)
|
||||
|
||||
## [1.0.0] - 2022-02-28
|
||||
|
||||
### Updates
|
||||
|
||||
* https://github.com/ohmyform/api/releases/tag/1.0.0
|
||||
* https://github.com/ohmyform/ui/releases/tag/1.0.0
|
||||
|
||||
### Changed
|
||||
|
||||
- [UI] ability to change user passwords
|
||||
- [UI] add default page background
|
||||
- [UI] add environment list in [doc](doc/environment.md)
|
||||
- [UI] show error message on homepage in case there is a problem with api connection
|
||||
- [UI] new slider field type
|
||||
- [UI] new card layout for forms
|
||||
- [UI] field logic
|
||||
- [UI] add environment config
|
||||
- [UI] anonymous form submissions (fixes https://github.com/ohmyform/ohmyform/issues/108)
|
||||
- [UI] checkbox field type (fixed https://github.com/ohmyform/ohmyform/issues/138)
|
||||
- [UI] combined notificationts to become more versatile
|
||||
- [UI] use exported hooks for graphql
|
||||
- [UI] disable swipe gesture
|
||||
- [UI] upgrade to nextjs 12
|
||||
- [UI] change default value from value to defaultValue
|
||||
- [UI] handle options and values as json correctly
|
||||
- [UI] exclude empty submissions per default (https://github.com/ohmyform/ohmyform/issues/153)
|
||||
- [UI] links at the bottom for new users
|
||||
- [UI] fixes for hide contrib setting
|
||||
- [UI] fix problem with node-prune on production build
|
||||
- [UI] translation for prev / continue during form submission
|
||||
- [UI] reload form list after adding new one (https://github.com/ohmyform/ohmyform/issues/139)
|
||||
- [UI] android screen size fix (https://github.com/ohmyform/ohmyform/issues/114)
|
||||
- [UI] sending finish mutation (https://github.com/ohmyform/ui/pull/67)
|
||||
- [UI] fix dev documentation (https://github.com/ohmyform/ui/issues/65)
|
||||
- [UI] remove next/image as it does not work with static exports (https://github.com/ohmyform/ohmyform/issues/154)
|
||||
- [UI] switch back to form.prefixName (https://github.com/ohmyform/ohmyform/issues/150)
|
||||
- [UI] upgrade all packages to latest versions
|
||||
- [UI] upgrad all packages
|
||||
- [API] logic backend components
|
||||
- [API] forms now have multiple notification
|
||||
- [API] layout for forms
|
||||
- [API] mariadb / mysql support (fixes https://github.com/ohmyform/ohmyform/issues/143)
|
||||
- [API] user confirmation tokens
|
||||
- [API] email verification
|
||||
- [API] idx for fields and logic to have stable order
|
||||
- [API] ability to load submission by id if token is present
|
||||
- [API] anonymous form submissions (fixes https://github.com/ohmyform/ohmyform/issues/108)
|
||||
- [API] ability to filter for partial / completed or empty submissions
|
||||
- [API] migration tests for all commits
|
||||
- [API] switched from mongoose to typeorm, with support right now for postgres and sqlite
|
||||
- [API] colors object removed the "colors" postfix
|
||||
- [API] if unsupported database engine is used error is thrown during startup
|
||||
- [API] improved eslint checks
|
||||
- [API] validate submission field data and store it json encoded
|
||||
- [API] forms are no longer finished on 100% but instead on finish mutation
|
||||
- [API] field default value renamed from value to defaultValue
|
||||
- [API] env list in doc
|
||||
- [API] version env variable for yarn
|
||||
- [API] path argument error (https://github.com/ohmyform/ohmyform/issues/149)
|
||||
- [API] webhook and form submission (https://github.com/ohmyform/api/pull/37)
|
||||
- [API] sqlite migration fixes to allow changes to tables
|
||||
- [API] upgraded all packages
|
||||
- switched to supervisord based combined container
|
||||
- upgrade to node 16
|
||||
|
||||
### Fixed
|
||||
|
||||
- heroku deployments
|
||||
- fix problem with node-prune on production build
|
||||
- variable names in examples (https://github.com/ohmyform/ohmyform/issues/134)
|
||||
@ -82,45 +122,25 @@ Template for next version
|
||||
|
||||
## [0.9.9] - 2021-02-14
|
||||
|
||||
### Added
|
||||
|
||||
- Submission export
|
||||
- Lokalize reference
|
||||
- more languages
|
||||
|
||||
### Changed
|
||||
|
||||
- updated french translations by @Vercety87
|
||||
- upgrade to node 14 (https://github.com/ohmyform/ohmyform/issues/99)
|
||||
|
||||
### Fixed
|
||||
|
||||
- missing dependency to @apollo/client
|
||||
- footer rendering during authentication check
|
||||
|
||||
### Security
|
||||
|
||||
- authentication check for profile page
|
||||
- [UI] Submission export
|
||||
- [UI] Lokalize reference
|
||||
- [UI] updated french translations by @Vercety87
|
||||
- [UI] upgrade to node 14 (https://github.com/ohmyform/ohmyform/issues/99)
|
||||
- [UI] missing dependency to @apollo/client
|
||||
- [UI] footer rendering during authentication check
|
||||
- [UI] authentication check for profile page
|
||||
- [API] more languages
|
||||
- [API] upgrade to node 14 (https://github.com/ohmyform/ohmyform/issues/99)
|
||||
|
||||
## [0.9.8] - 2020-09-02
|
||||
|
||||
### Changed
|
||||
|
||||
- improved german translation (https://github.com/ohmyform/ui/pull/28)
|
||||
|
||||
### Fixed
|
||||
|
||||
- colors for landing page buttons
|
||||
- menu selection type
|
||||
|
||||
### Security
|
||||
|
||||
- upgraded dependencies
|
||||
|
||||
## [0.9.6] - 2020-07-17
|
||||
|
||||
### Added
|
||||
|
||||
- slug for fields to be able to set value by url parameter
|
||||
- form submission hokks
|
||||
- default index.html for api without bundled ui
|
||||
@ -141,27 +161,16 @@ Template for next version
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- minify containers to reduce layer size
|
||||
|
||||
### Fixed
|
||||
|
||||
- bug in settings resolver with nullable fields
|
||||
- bug if user was deleted and form still exists
|
||||
- do not show login note if it is not set
|
||||
- typo in dropdown options https://github.com/ohmyform/ohmyform/issues/96
|
||||
- query parms are not parsed https://github.com/ohmyform/ui/pull/27 https://github.com/ohmyform/ohmyform/issues/100
|
||||
- errors because of missing user reference (https://github.com/ohmyform/ohmyform/issues/102)
|
||||
|
||||
### Security
|
||||
|
||||
- container now runs as non root user
|
||||
|
||||
## [0.9.5] - 2020-06-10
|
||||
|
||||
### Added
|
||||
|
||||
- `DEFAULT_ROLE` -> `admin` | `superuser` | `user` - with `user` being the default, making it possible that new users can create their own forms after creating
|
||||
- `LOGIN_NOTE` -> markdown for Login Page, to show info text on login page
|
||||
@ -172,13 +181,7 @@ Template for next version
|
||||
- login notes
|
||||
- username in admin toolbar
|
||||
- github stars in multiple places
|
||||
|
||||
### Changed
|
||||
|
||||
- verified spanish translations https://github.com/ohmyform/ui/pull/23
|
||||
|
||||
### Fixed
|
||||
|
||||
- di on setting resolver, prevented signup settings to be visible in ui
|
||||
- return admin of form also for admins
|
||||
- yes / no field fixed on admin and user view
|
||||
@ -191,8 +194,6 @@ Template for next version
|
||||
|
||||
## [0.9.4] - 2020-06-09
|
||||
|
||||
### Added
|
||||
|
||||
- Fetch Server Settings to determine if signup is available
|
||||
- `SPA` env variable to have static page with loading spinner before redirect
|
||||
- `de`, `fr`, `es`, `it`, `cn` base folders for translations
|
||||
@ -204,25 +205,14 @@ Template for next version
|
||||
- travis for tests
|
||||
- eslint with prettier
|
||||
- `SIGNUP_DISABLED=true` to prevent users from signing up
|
||||
|
||||
### Changed
|
||||
|
||||
- `export` uses now spa mode for initial loading screen
|
||||
|
||||
### Fixed
|
||||
|
||||
- [OMF#93](https://github.com/ohmyform/ohmyform/issues/93) dropdown options are not saved
|
||||
- redirect attempts on static export
|
||||
- startup error with invalid create admin config
|
||||
|
||||
## [0.9.3] - 2020-06-04
|
||||
|
||||
### Added
|
||||
|
||||
- nginx example
|
||||
- load balanced example
|
||||
- minimal example
|
||||
|
||||
### Fixed
|
||||
|
||||
- docker-compose mongo data dir to persist data
|
||||
|
1
api
1
api
@ -1 +0,0 @@
|
||||
Subproject commit c2c421baa6f41e4e6fb812fa2978956aaf7aa0dd
|
4
api/.dockerignore
Normal file
4
api/.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
/dist
|
||||
/node_modules
|
||||
/data
|
||||
/.git
|
72
api/.eslintrc.js
Normal file
72
api/.eslintrc.js
Normal file
@ -0,0 +1,72 @@
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.json',
|
||||
sourceType: 'module',
|
||||
},
|
||||
'plugins': [
|
||||
'nestjs',
|
||||
'@typescript-eslint/eslint-plugin',
|
||||
'@typescript-eslint',
|
||||
'unused-imports'
|
||||
],
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:nestjs/recommended',
|
||||
'plugin:@typescript-eslint/eslint-recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||
'prettier',
|
||||
],
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-unsafe-return': 'warn',
|
||||
'@typescript-eslint/no-unsafe-call': 'warn',
|
||||
'@typescript-eslint/no-unsafe-argument': 'warn',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'array-element-newline': ['error', {
|
||||
'ArrayExpression': 'consistent',
|
||||
'ArrayPattern': {
|
||||
'minItems': 3,
|
||||
'multiline': true,
|
||||
}
|
||||
}],
|
||||
'array-bracket-newline': ['error', {
|
||||
'minItems': 3,
|
||||
'multiline': true,
|
||||
}],
|
||||
'indent': [
|
||||
'error',
|
||||
2,
|
||||
{
|
||||
'SwitchCase': 1
|
||||
}
|
||||
],
|
||||
'no-tabs': ['error'],
|
||||
'max-len': ['error', {
|
||||
'code': 100,
|
||||
'ignoreComments': true,
|
||||
'ignoreUrls': true,
|
||||
'ignoreTemplateLiterals': true,
|
||||
'ignoreTrailingComments': true,
|
||||
'ignoreStrings': true,
|
||||
}],
|
||||
'quotes': ['error', 'single', { 'avoidEscape': true }],
|
||||
'comma-dangle': ['error', 'always-multiline'],
|
||||
'linebreak-style': [
|
||||
'error',
|
||||
'unix'
|
||||
],
|
||||
'no-trailing-spaces': 'error',
|
||||
'eol-last': 'error',
|
||||
'unused-imports/no-unused-imports': 'error',
|
||||
},
|
||||
};
|
43
api/.gitignore
vendored
Normal file
43
api/.gitignore
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
# compiled output
|
||||
/dist
|
||||
/node_modules
|
||||
/public
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
|
||||
# Tests
|
||||
/coverage
|
||||
/.nyc_output
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
# local data
|
||||
/data
|
||||
/.env
|
||||
/src/schema.gql
|
||||
/data.sqlite
|
||||
/maria_data
|
||||
/pg_data
|
4
api/.prettierrc
Normal file
4
api/.prettierrc
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
49
api/Dockerfile
Normal file
49
api/Dockerfile
Normal file
@ -0,0 +1,49 @@
|
||||
FROM node:14-alpine AS builder
|
||||
MAINTAINER OhMyForm <admin@ohmyform.com>
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
RUN apk update && apk add curl bash && rm -rf /var/cache/apk/*
|
||||
|
||||
# install node-prune (https://github.com/tj/node-prune)
|
||||
RUN curl -sf https://gobinaries.com/tj/node-prune | sh
|
||||
|
||||
# just copy everhing
|
||||
COPY . .
|
||||
|
||||
RUN touch /usr/src/app/src/schema.gql && chown 9999:9999 /usr/src/app/src/schema.gql
|
||||
|
||||
RUN yarn install --frozen-lockfile
|
||||
RUN yarn build
|
||||
|
||||
# remove development dependencies
|
||||
RUN npm prune --production
|
||||
|
||||
# run node prune
|
||||
RUN /usr/local/bin/node-prune
|
||||
|
||||
FROM node:14-alpine
|
||||
MAINTAINER OhMyForm <admin@ohmyform.com>
|
||||
|
||||
# Create a group and a user with name "ohmyform".
|
||||
RUN addgroup --gid 9999 ohmyform && adduser -D --uid 9999 -G ohmyform ohmyform
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY --from=builder /usr/src/app /usr/src/app
|
||||
|
||||
ENV PORT=3000 \
|
||||
SECRET_KEY=ChangeMe \
|
||||
CREATE_ADMIN=FALSE \
|
||||
ADMIN_EMAIL=admin@ohmyform.com \
|
||||
ADMIN_USERNAME=root \
|
||||
ADMIN_PASSWORD=root \
|
||||
NODE_ENV=production
|
||||
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# Change to non-root privilege
|
||||
USER ohmyform
|
||||
|
||||
CMD [ "yarn", "start:prod" ]
|
661
api/LICENSE.md
Normal file
661
api/LICENSE.md
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
40
api/README.md
Normal file
40
api/README.md
Normal file
@ -0,0 +1,40 @@
|
||||
# OhMyForm API
|
||||
|
||||
[![Build Status](https://travis-ci.org/ohmyform/api.svg?branch=master)](https://travis-ci.org/ohmyform/api)
|
||||
![Latest Release](https://badgen.net/github/tag/ohmyform/api)
|
||||
[![Docker Pulls](https://badgen.net/docker/pulls/ohmyform/api)](https://hub.docker.com/r/ohmyform/api)
|
||||
[![Lokalise](https://badgen.net/badge/Lokalise/EN/green?icon=libraries)](https://app.lokalise.com/public/379418475ede5d5c6937b0.31012044/)
|
||||
![Last Commit](https://badgen.net/github/last-commit/ohmyform/api)
|
||||
|
||||
[Demo](https://demo.ohmyform.com/login)
|
||||
|
||||
> An *open source alternative to TypeForm* that can create stunning mobile-ready forms, surveys and questionnaires.
|
||||
|
||||
[![Discord](https://img.shields.io/discord/595773457862492190.svg?label=Discord%20Chat)](https://discord.gg/MJqAuAZ)
|
||||
[![Financial Contributors on Open Collective](https://opencollective.com/ohmyform-sustainability/all/badge.svg?label=financial+contributors)](https://opencollective.com/ohmyform-sustainability)
|
||||
|
||||
## Description
|
||||
|
||||
[OhMyForm](https://github.com/ohmyform) api backend
|
||||
|
||||
All calls to the api are through GraphQL, with the endpoint
|
||||
providing an introspectable schema at `GET /graphql`
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Running the app
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ yarn run start
|
||||
|
||||
# watch mode
|
||||
$ yarn run start:dev
|
||||
|
||||
# production mode
|
||||
$ yarn run start:prod
|
||||
```
|
14
api/doc/cli.md
Normal file
14
api/doc/cli.md
Normal file
@ -0,0 +1,14 @@
|
||||
# CLI
|
||||
|
||||
Run `yarn cli` to get basic information of available commands
|
||||
|
||||
## user commands
|
||||
|
||||
### `yarn cli user create`
|
||||
|
||||
create a new user
|
||||
|
||||
### `yarn cli user activate <username>`
|
||||
|
||||
activate the given user
|
||||
|
8
api/doc/development.md
Normal file
8
api/doc/development.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Development
|
||||
|
||||
tip's and tricks to get you started
|
||||
|
||||
## First Run
|
||||
|
||||
install yarn on your system if not already present and then install all dependencies
|
||||
by running `yarn install`
|
46
api/doc/environment.md
Normal file
46
api/doc/environment.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Environment Variables
|
||||
|
||||
| Name | Default Value | Description |
|
||||
|------------------------------|----------------------------|---------------------------------------------------------------------------------------|
|
||||
| DISABLE_INSTALLATION_METRICS | *not set* | Per default installations are [publishing](./installation.metrics.md) their existence |
|
||||
| SECRET_KEY | `changeMe` | JWT Secret for authentication |
|
||||
| CLI | *automatically* | activates pretty print for log output |
|
||||
| NODE_ENV | `production` | |
|
||||
| HIDE_CONTRIB | `false` | decide if backlings to ohmyform should be added |
|
||||
| SIGNUP_DISABLED | `false` | if users can sign up |
|
||||
| LOGIN_NOTE | *not set* | Info box on top of login screen |
|
||||
| LOCALES_PATH | *not set* | Path to translated elementes in backend like emails |
|
||||
| LOCALE | `en` | Default Locale |
|
||||
| BASE_URL | `http://localhost` | Url to Frontend root |
|
||||
| USER_CONFIRM_PATH | `/confirm?token={{token}}` | Path to confirm user |
|
||||
|
||||
## Default Account
|
||||
|
||||
*username and email are unique on an instance*
|
||||
|
||||
| Name | Default Value | Description |
|
||||
|----------------|----------------------|-------------------------------------|
|
||||
| CREATE_ADMIN | `false` | if `true` will create a super admin |
|
||||
| ADMIN_USERNAME | `root` | username for the default admin user |
|
||||
| ADMIN_EMAIL | `admin@ohmyform.com` | email to send notifications |
|
||||
| ADMIN_PASSWORD | `root` | password for user |
|
||||
|
||||
## Mailing
|
||||
|
||||
| Name | Default Value | Description |
|
||||
|-------------|---------------------------------|-----------------------------------------------------------------------------------|
|
||||
| MAILER_URI | `smtp://localhost:1025` | [Mail Connection](https://nodemailer.com/smtp/) |
|
||||
| MAILER_FROM | `OhMyForm <no-reply@localhost>` | Default From path, make sure that your mail server supports the given from addres |
|
||||
|
||||
## Database Variables
|
||||
|
||||
| Name | Default Value | Description |
|
||||
|-----------------------|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| DATABASE_DRIVER | `sqlite` | database driver, either `sqlite` or `postgres` |
|
||||
| DATABASE_URL | `sqlite://data.sqlite` | url in the format `TYPE://USER:PASS@HOST:PORT/NAME?EXTRA` ([read more](https://typeorm.io/#/connection-options/common-connection-options)) |
|
||||
| DATABASE_TABLE_PREFIX | *empty* | prefix all tables if used within same database as other applications. |
|
||||
| DATABASE_LOGGING | `false` | if `true` all db interactions will be logged to stdout |
|
||||
| DATABASE_MIGRATE | `true` | can be used in load balanced environments to only allow one container to perform migrations / manually execute migrations |
|
||||
| DATABASE_SSL | `false` | if `true` will require ssl database connection |
|
||||
| REDIS_HOST | *not set* | required in multinode environments |
|
||||
| REDIS_PORT | `6379` | port for redis |
|
11
api/doc/installation.metrics.md
Normal file
11
api/doc/installation.metrics.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Installation Metrics
|
||||
|
||||
Attention: OhMyForm now collects completely anonymous
|
||||
telemetry regarding usage. This information is used to
|
||||
shape OhMyForm's roadmap and prioritize features.
|
||||
|
||||
If you want to opt out you can disable this behavior by
|
||||
setting the environment variable `DISABLE_INSTALLATION_METRICS=1`
|
||||
|
||||
You can take a look [here](../src/service/installation.metrics.service.ts) to see how we trigger the metric
|
||||
collection
|
24
api/doc/roles.md
Normal file
24
api/doc/roles.md
Normal file
@ -0,0 +1,24 @@
|
||||
# Roles
|
||||
|
||||
## unauthenticated
|
||||
|
||||
every request is unauthenticated unless an `Authorization`
|
||||
header with a valid `JWT Bearer` token is provided.
|
||||
|
||||
## user
|
||||
|
||||
any new registration is a user per default, they can only see their
|
||||
responses and do not have access to forms.
|
||||
|
||||
## admin
|
||||
|
||||
an admin can create forms and edit their own forms. They do not
|
||||
have access to forms from other users.
|
||||
|
||||
## superuser
|
||||
|
||||
a superuser can create and edit any form on the platform as well as
|
||||
modify any user
|
||||
|
||||
they can also grant a user admin or superuser access, they cannot revoke
|
||||
their own superuser role
|
65
api/docker-compose.yml
Normal file
65
api/docker-compose.yml
Normal file
@ -0,0 +1,65 @@
|
||||
version: "3"
|
||||
services:
|
||||
#mongo:
|
||||
# image: mongo
|
||||
# ports:
|
||||
# - "27017:27017"
|
||||
# volumes:
|
||||
# - "./data/mongo:/data/db"
|
||||
|
||||
maria:
|
||||
image: mariadb
|
||||
volumes:
|
||||
- ./maria_data:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: ohmyform
|
||||
ports:
|
||||
- "3306:3306"
|
||||
|
||||
postgres:
|
||||
image: postgres:10-alpine
|
||||
volumes:
|
||||
- ./pg_data:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_USER: root
|
||||
POSTGRES_PASSWORD: root
|
||||
POSTGRES_DB: ohmyform
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- "6003:6379"
|
||||
# api:
|
||||
# build: .
|
||||
# volumes:
|
||||
# - ".:/usr/src/app"
|
||||
# environment:
|
||||
# MONGODB_URI: mongodb://mongo/ohmyform
|
||||
# MAILER_URI: smtp://mail:1025
|
||||
# PORT: 3000
|
||||
#command: yarn start:dev
|
||||
# links:
|
||||
# - mongo
|
||||
# - mail
|
||||
# ports:
|
||||
# - "6100:3000"
|
||||
# depends_on:
|
||||
# - mongo
|
||||
mail:
|
||||
image: mailhog/mailhog
|
||||
ports:
|
||||
- "6001:8025"
|
||||
- "6004:1025"
|
||||
#mongoexpress:
|
||||
# image: mongo-express
|
||||
# environment:
|
||||
# ME_CONFIG_MONGODB_SERVER: mongo
|
||||
# ports:
|
||||
# - "6002:8081"
|
||||
# links:
|
||||
# - mongo
|
||||
# depends_on:
|
||||
# - mongo
|
22
api/locales/en/mail/user/created.mjml
Normal file
22
api/locales/en/mail/user/created.mjml
Normal file
@ -0,0 +1,22 @@
|
||||
<mjml>
|
||||
<mj-head>
|
||||
<mj-title>Welcome to OhMyForm</mj-title>
|
||||
</mj-head>
|
||||
<mj-body>
|
||||
<mj-section>
|
||||
<mj-column>
|
||||
<mj-text font-size="25px" color="#444" font-family="helvetica">OhMyForm!</mj-text>
|
||||
|
||||
<mj-divider border-color="#444"></mj-divider>
|
||||
|
||||
<mj-text font-size="20px" color="#444" font-family="helvetica">
|
||||
Your Username is {{username}}
|
||||
</mj-text>
|
||||
|
||||
<mj-text font-size="14px" color="#444" font-family="helvetica">
|
||||
<a href="{{confirm}}">Click here to verify your Account</a>
|
||||
</mj-text>
|
||||
</mj-column>
|
||||
</mj-section>
|
||||
</mj-body>
|
||||
</mjml>
|
7
api/nest-cli.json
Normal file
7
api/nest-cli.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"plugins": ["@nestjs/graphql/plugin"]
|
||||
}
|
||||
}
|
22
api/ormconfig_mariadb.json
Normal file
22
api/ormconfig_mariadb.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"type": "mariadb",
|
||||
"host": "localhost",
|
||||
"username": "root",
|
||||
"password": "root",
|
||||
"database": "ohmyform",
|
||||
"synchronize": false,
|
||||
"logging": false,
|
||||
"entities": [
|
||||
"src/entity/**/*.ts"
|
||||
],
|
||||
"migrations": [
|
||||
"src/migrations/mariadb/**/*.ts"
|
||||
],
|
||||
"migrationsTransactionMode": "each",
|
||||
"subscribers": [
|
||||
"src/subscriber/**/*.ts"
|
||||
],
|
||||
"cli": {
|
||||
"migrationsDir": "src/migrations/mariadb"
|
||||
}
|
||||
}
|
22
api/ormconfig_postgres.json
Normal file
22
api/ormconfig_postgres.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"type": "postgres",
|
||||
"host": "localhost",
|
||||
"username": "root",
|
||||
"password": "root",
|
||||
"database": "ohmyform",
|
||||
"synchronize": false,
|
||||
"logging": false,
|
||||
"entities": [
|
||||
"src/entity/**/*.ts"
|
||||
],
|
||||
"migrations": [
|
||||
"src/migrations/postgres/**/*.ts"
|
||||
],
|
||||
"migrationsTransactionMode": "each",
|
||||
"subscribers": [
|
||||
"src/subscriber/**/*.ts"
|
||||
],
|
||||
"cli": {
|
||||
"migrationsDir": "src/migrations/postgres"
|
||||
}
|
||||
}
|
16
api/ormconfig_sqlite.json
Normal file
16
api/ormconfig_sqlite.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"type": "sqlite",
|
||||
"database": "data.sqlite",
|
||||
"synchronize": false,
|
||||
"logging": false,
|
||||
"entities": [
|
||||
"src/entity/**/*.ts"
|
||||
],
|
||||
"migrations": [
|
||||
"src/migrations/sqlite/**/*.ts"
|
||||
],
|
||||
"migrationsTransactionMode": "none",
|
||||
"cli": {
|
||||
"migrationsDir": "src/migrations/sqlite"
|
||||
}
|
||||
}
|
126
api/package.json
Normal file
126
api/package.json
Normal file
@ -0,0 +1,126 @@
|
||||
{
|
||||
"name": "ohmyform-api",
|
||||
"version": "1.0.3",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"cli:dev": "cross-env CLI=true TS_NODE_TRANSPILE_ONLY=true ts-node -r tsconfig-paths/register src/cli.ts",
|
||||
"cli": "cross-env CLI=true node dist/console.js",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "cross-env NODE_ENV=production node dist/main",
|
||||
"lint": "eslint \"{src,test}/**/*.ts\" --fix",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||
"typeorm:sqlite": "cross-env TS_NODE_TRANSPILE_ONLY=true ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -f ormconfig_sqlite.json",
|
||||
"typeorm:postgres": "cross-env TS_NODE_TRANSPILE_ONLY=true ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -f ormconfig_postgres.json",
|
||||
"typeorm:mariadb": "cross-env TS_NODE_TRANSPILE_ONLY=true ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -f ormconfig_mariadb.json",
|
||||
"typeorm": "cross-env TS_NODE_TRANSPILE_ONLY=true ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ardatan/aggregate-error": "^0.0.6",
|
||||
"@nestjs-modules/mailer": "^1.6.1",
|
||||
"@nestjs/apollo": "^10.0.5",
|
||||
"@nestjs/axios": "^0.0.6",
|
||||
"@nestjs/common": "^8.3.1",
|
||||
"@nestjs/config": "^1.2.0",
|
||||
"@nestjs/core": "^8.3.1",
|
||||
"@nestjs/graphql": "^10.0.5",
|
||||
"@nestjs/jwt": "^8.0.0",
|
||||
"@nestjs/passport": "^8.2.1",
|
||||
"@nestjs/platform-express": "^8.3.1",
|
||||
"@nestjs/serve-static": "^2.2.2",
|
||||
"@nestjs/typeorm": "^8.0.3",
|
||||
"apollo-server-express": "^3.6.3",
|
||||
"bcrypt": "^5.0.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.13.2",
|
||||
"cors": "^2.8.5",
|
||||
"cross-env": "^7.0.3",
|
||||
"dayjs": "^1.10.7",
|
||||
"graphql": "15.8.0",
|
||||
"graphql-redis-subscriptions": "^2.4.2",
|
||||
"graphql-subscriptions": "^2.0.0",
|
||||
"graphql-tools": "^8.2.0",
|
||||
"handlebars": "^4.7.7",
|
||||
"hashids": "^2.2.10",
|
||||
"html-to-text": "^8.1.0",
|
||||
"inquirer": "^8.2.0",
|
||||
"ioredis": "^4.28.5",
|
||||
"ip-anonymize": "^0.1.0",
|
||||
"matomo-tracker": "^2.2.4",
|
||||
"mjml": "^4.12.0",
|
||||
"mysql2": "^2.3.3",
|
||||
"nestjs-console": "^7.0.1",
|
||||
"nestjs-pino": "^2.5.0",
|
||||
"nodemailer": "^6.7.2",
|
||||
"passport": "^0.5.2",
|
||||
"passport-jwt": "^4.0.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.7.3",
|
||||
"pino-http": "^6.6.0",
|
||||
"pino-pretty": "^7.5.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"request-ip": "^2.1.3",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.4",
|
||||
"serialize-error": "^8.1.0",
|
||||
"sqlite3": "^5.0.2",
|
||||
"typeorm": "^0.2.44"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^8.2.1",
|
||||
"@nestjs/schematics": "^8.0.7",
|
||||
"@nestjs/testing": "^8.3.1",
|
||||
"@types/bcrypt": "^5.0.0",
|
||||
"@types/express-serve-static-core": "^4.17.28",
|
||||
"@types/handlebars": "^4.1.0",
|
||||
"@types/html-to-text": "^8.0.1",
|
||||
"@types/inquirer": "^8.2.0",
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/mjml": "^4.7.0",
|
||||
"@types/node": "^17.0.21",
|
||||
"@types/passport-jwt": "^3.0.6",
|
||||
"@types/passport-local": "^1.0.34",
|
||||
"@types/request-ip": "^0.0.37",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
||||
"@typescript-eslint/parser": "^5.12.1",
|
||||
"eslint": "^8.10.0",
|
||||
"eslint-config-prettier": "^8.4.0",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-nestjs": "^1.2.3",
|
||||
"eslint-plugin-unused-imports": "^2.0.0",
|
||||
"jest": "^27.5.1",
|
||||
"node-gyp": "^9.0.0",
|
||||
"prettier": "^2.5.1",
|
||||
"supertest": "^6.2.2",
|
||||
"ts-jest": "27.1.3",
|
||||
"ts-loader": "^9.2.6",
|
||||
"ts-node": "^10.5.0",
|
||||
"tsconfig-paths": "^3.12.0",
|
||||
"typescript": "^4.5.5"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
0
api/public/.gitkeep
Normal file
0
api/public/.gitkeep
Normal file
5
api/public/index.html
Normal file
5
api/public/index.html
Normal file
@ -0,0 +1,5 @@
|
||||
<pre>
|
||||
<h1>OhMyForm API endpoint</h1>
|
||||
|
||||
visit us at <a href="https://ohmyform.com">ohmyform.com</a>
|
||||
</pre>
|
168
api/src/app.imports.ts
Normal file
168
api/src/app.imports.ts
Normal file
@ -0,0 +1,168 @@
|
||||
import { MailerModule } from '@nestjs-modules/mailer'
|
||||
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo'
|
||||
import { HttpModule } from '@nestjs/axios'
|
||||
import { RequestMethod } from '@nestjs/common'
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config'
|
||||
import { GraphQLModule } from '@nestjs/graphql'
|
||||
import { JwtModule, JwtModuleOptions } from '@nestjs/jwt'
|
||||
import { ServeStaticModule } from '@nestjs/serve-static'
|
||||
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm'
|
||||
import crypto from 'crypto'
|
||||
import { Request } from 'express-serve-static-core'
|
||||
import { IncomingHttpHeaders } from 'http'
|
||||
import { ConsoleModule } from 'nestjs-console'
|
||||
import { LoggerModule, Params as LoggerModuleParams } from 'nestjs-pino'
|
||||
import { join } from 'path'
|
||||
import { serializeError } from 'serialize-error'
|
||||
import { entities } from './entity'
|
||||
|
||||
export const LoggerConfig: LoggerModuleParams = {
|
||||
pinoHttp: {
|
||||
level: process.env.CLI ? 'warn' : process.env.NODE_ENV !== 'production' ? 'debug' : 'info',
|
||||
serializers: {
|
||||
error: serializeError,
|
||||
},
|
||||
transport: process.env.NODE_ENV !== 'production' || process.env.CLI ? {
|
||||
options: {
|
||||
ignore: 'req,res,pid,hostname',
|
||||
translateTime: true,
|
||||
},
|
||||
target: 'pino-pretty',
|
||||
} : undefined,
|
||||
},
|
||||
exclude: [
|
||||
{
|
||||
method: RequestMethod.ALL,
|
||||
path: '_health',
|
||||
},
|
||||
{
|
||||
method: RequestMethod.ALL,
|
||||
path: 'favicon.ico',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
export const imports = [
|
||||
ConsoleModule,
|
||||
HttpModule.register({
|
||||
timeout: 5000,
|
||||
maxRedirects: 10,
|
||||
}),
|
||||
ServeStaticModule.forRoot({
|
||||
rootPath: join(__dirname, '..', 'public'),
|
||||
exclude: ['/graphql'],
|
||||
}),
|
||||
ConfigModule.forRoot({
|
||||
load: [
|
||||
() => {
|
||||
return {
|
||||
LOCALES_PATH: join(process.cwd(), 'locales'),
|
||||
SECRET_KEY: process.env.SECRET_KEY || crypto.randomBytes(20).toString('hex'),
|
||||
}
|
||||
},
|
||||
],
|
||||
}),
|
||||
JwtModule.registerAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService): JwtModuleOptions => ({
|
||||
secret: configService.get<string>('SECRET_KEY'),
|
||||
signOptions: {
|
||||
expiresIn: '4h',
|
||||
},
|
||||
}),
|
||||
}),
|
||||
LoggerModule.forRoot(LoggerConfig),
|
||||
GraphQLModule.forRoot<ApolloDriverConfig>({
|
||||
debug: process.env.NODE_ENV !== 'production',
|
||||
definitions: {
|
||||
outputAs: 'class',
|
||||
},
|
||||
driver: ApolloDriver,
|
||||
sortSchema: true,
|
||||
introspection: process.env.NODE_ENV !== 'production',
|
||||
playground: process.env.NODE_ENV !== 'production',
|
||||
installSubscriptionHandlers: true,
|
||||
autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
|
||||
// to allow guards on resolver props https://github.com/nestjs/graphql/issues/295
|
||||
fieldResolverEnhancers: [
|
||||
'guards',
|
||||
'interceptors',
|
||||
],
|
||||
resolverValidationOptions: {
|
||||
|
||||
},
|
||||
context: ({ req, connection }) => {
|
||||
if (!req && connection) {
|
||||
const headers: IncomingHttpHeaders = {}
|
||||
|
||||
Object.keys(connection.context).forEach(key => {
|
||||
headers[key.toLowerCase()] = connection.context[key]
|
||||
})
|
||||
|
||||
return {
|
||||
req: {
|
||||
headers,
|
||||
} as Request,
|
||||
}
|
||||
}
|
||||
|
||||
return { req }
|
||||
},
|
||||
}),
|
||||
TypeOrmModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService): TypeOrmModuleOptions => {
|
||||
const type: any = configService.get<string>('DATABASE_DRIVER', 'sqlite')
|
||||
let migrationFolder: string
|
||||
let migrationsTransactionMode: 'each' | 'none' | 'all' = 'each'
|
||||
|
||||
switch (type) {
|
||||
case 'cockroachdb':
|
||||
case 'postgres':
|
||||
migrationFolder = 'postgres'
|
||||
break
|
||||
|
||||
case 'mysql':
|
||||
case 'mariadb':
|
||||
migrationFolder = 'mariadb'
|
||||
break
|
||||
|
||||
case 'sqlite':
|
||||
migrationFolder = 'sqlite'
|
||||
migrationsTransactionMode = 'none'
|
||||
break
|
||||
|
||||
default:
|
||||
throw new Error('unsupported driver')
|
||||
}
|
||||
|
||||
return ({
|
||||
name: 'ohmyform',
|
||||
synchronize: false,
|
||||
type,
|
||||
url: configService.get<string>('DATABASE_URL'),
|
||||
database: type === 'sqlite' ? configService.get<string>('DATABASE_URL', 'data.sqlite').replace('sqlite://', '') : undefined,
|
||||
ssl: configService.get<string>('DATABASE_SSL', 'false') === 'true' ? { rejectUnauthorized: false } : false,
|
||||
entityPrefix: configService.get<string>('DATABASE_TABLE_PREFIX', ''),
|
||||
logging: configService.get<string>('DATABASE_LOGGING', 'false') === 'true',
|
||||
entities,
|
||||
migrations: [`${__dirname}/**/migrations/${migrationFolder}/**/*{.ts,.js}`],
|
||||
migrationsRun: configService.get<boolean>('DATABASE_MIGRATE', true),
|
||||
migrationsTransactionMode,
|
||||
})
|
||||
},
|
||||
}),
|
||||
TypeOrmModule.forFeature(entities),
|
||||
MailerModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
transport: configService.get<string>('MAILER_URI', 'smtp://localhost:1025'),
|
||||
defaults: {
|
||||
from: configService.get<string>('MAILER_FROM', 'OhMyForm <no-reply@localhost>'),
|
||||
},
|
||||
}),
|
||||
}),
|
||||
]
|
11
api/src/app.module.ts
Normal file
11
api/src/app.module.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { imports } from './app.imports'
|
||||
import { providers } from './app.providers'
|
||||
import { controllers } from './controller'
|
||||
|
||||
@Module({
|
||||
imports,
|
||||
controllers,
|
||||
providers,
|
||||
})
|
||||
export class AppModule {}
|
13
api/src/app.providers.ts
Normal file
13
api/src/app.providers.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { commands } from './command'
|
||||
import { guards } from './guard'
|
||||
import { pipes } from './pipe'
|
||||
import { resolvers } from './resolver'
|
||||
import { services } from './service'
|
||||
|
||||
export const providers = [
|
||||
...commands,
|
||||
...guards,
|
||||
...pipes,
|
||||
...resolvers,
|
||||
...services,
|
||||
]
|
16
api/src/cli.ts
Normal file
16
api/src/cli.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { BootstrapConsole } from 'nestjs-console'
|
||||
import { AppModule } from './app.module'
|
||||
|
||||
const bootstrap = new BootstrapConsole({
|
||||
module: AppModule,
|
||||
useDecorators: true,
|
||||
});
|
||||
void bootstrap.init().then(async (app) => {
|
||||
try {
|
||||
await app.init();
|
||||
await bootstrap.boot();
|
||||
process.exit(0);
|
||||
} catch (e) {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
3
api/src/command/index.ts
Normal file
3
api/src/command/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { UserCommand } from './user.command'
|
||||
|
||||
export const commands = [UserCommand]
|
65
api/src/command/user.command.ts
Normal file
65
api/src/command/user.command.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import inquirer from 'inquirer'
|
||||
import { Command, Console } from 'nestjs-console'
|
||||
import { matchType, validatePassword } from '../config/fields'
|
||||
import { UserCreateInput } from '../dto/user/user.create.input'
|
||||
import { UserCreateService } from '../service/user/user.create.service'
|
||||
|
||||
@Console({
|
||||
command: 'user',
|
||||
description: 'handle instance users',
|
||||
})
|
||||
export class UserCommand {
|
||||
constructor(
|
||||
private readonly createUser: UserCreateService
|
||||
) {
|
||||
}
|
||||
|
||||
@Command({
|
||||
command: 'create',
|
||||
})
|
||||
async create(): Promise<void> {
|
||||
const answers = await inquirer.prompt<UserCreateInput>([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'username',
|
||||
message: 'username for login',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'email',
|
||||
message: 'email to send notifications to',
|
||||
validate(input: string): boolean | string {
|
||||
if (!matchType.email.test(input)) {
|
||||
return 'invalid email'
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'password',
|
||||
name: 'password',
|
||||
validate: validatePassword,
|
||||
message: 'password to login',
|
||||
},
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'create',
|
||||
message: current => {
|
||||
return `create user ${current.username} with email ${current.email}`
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
await this.createUser.create(answers)
|
||||
|
||||
console.info(`user ${answers.username} has been created`)
|
||||
}
|
||||
|
||||
@Command({
|
||||
command: 'activate <username>',
|
||||
})
|
||||
activate(username: string): void {
|
||||
console.log(`activate user ${username}`)
|
||||
}
|
||||
}
|
32
api/src/config/fields.ts
Normal file
32
api/src/config/fields.ts
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
export const fieldTypes = [
|
||||
'textfield',
|
||||
'date',
|
||||
'email',
|
||||
// 'legal',
|
||||
'textarea',
|
||||
'link',
|
||||
// 'statement',
|
||||
'dropdown',
|
||||
'rating',
|
||||
'radio',
|
||||
'hidden',
|
||||
'yes_no',
|
||||
'number',
|
||||
]
|
||||
|
||||
export const matchType = {
|
||||
color: /^#([A-F0-9]{6}|[A-F0-9]{3})$/i,
|
||||
// eslint-disable-next-line max-len
|
||||
url: /((([A-Z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/i,
|
||||
email: /.+@.+\..+/,
|
||||
slug: /^[a-z0-9_]+$/,
|
||||
}
|
||||
|
||||
export const validatePassword = (password: string): true | string => {
|
||||
if (password.length < 4) {
|
||||
return 'password is too short'
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
23
api/src/config/languages.ts
Normal file
23
api/src/config/languages.ts
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
export const languages = [
|
||||
'en',
|
||||
'ar',
|
||||
'cn',
|
||||
'da',
|
||||
'nl',
|
||||
'fr',
|
||||
'de',
|
||||
'hi',
|
||||
'it',
|
||||
'ja',
|
||||
'pl',
|
||||
'pt_BR',
|
||||
'pt_PT',
|
||||
'ru',
|
||||
'es',
|
||||
'sv',
|
||||
'ta',
|
||||
'uk',
|
||||
]
|
||||
|
||||
export const defaultLanguage = 'en'
|
7
api/src/config/roles.ts
Normal file
7
api/src/config/roles.ts
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
export type roleType = 'user' | 'admin' | 'superuser'
|
||||
export type rolesType = roleType[]
|
||||
|
||||
export const roles: rolesType = [
|
||||
'user', 'admin', 'superuser',
|
||||
]
|
9
api/src/controller/health.controller.ts
Normal file
9
api/src/controller/health.controller.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Controller, Get } from '@nestjs/common'
|
||||
|
||||
@Controller()
|
||||
export class HealthController {
|
||||
@Get('/_health')
|
||||
getHello(): string {
|
||||
return 'ok';
|
||||
}
|
||||
}
|
3
api/src/controller/index.ts
Normal file
3
api/src/controller/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { HealthController } from './health.controller'
|
||||
|
||||
export const controllers = [HealthController]
|
19
api/src/decorator/ip.address.decorator.ts
Normal file
19
api/src/decorator/ip.address.decorator.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
import { GqlExecutionContext } from '@nestjs/graphql'
|
||||
import { getClientIp } from 'request-ip'
|
||||
|
||||
export const IpAddress = createParamDecorator((data: string, ctx: ExecutionContext) => {
|
||||
let req
|
||||
|
||||
if (ctx.getType<string>() === 'graphql') {
|
||||
req = GqlExecutionContext.create(ctx).getContext().req
|
||||
} else {
|
||||
req = ctx.switchToHttp().getRequest()
|
||||
}
|
||||
|
||||
if (req.clientIp) {
|
||||
return req.clientIp
|
||||
}
|
||||
|
||||
return getClientIp(req)
|
||||
})
|
4
api/src/decorator/roles.decorator.ts
Normal file
4
api/src/decorator/roles.decorator.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { SetMetadata } from '@nestjs/common'
|
||||
import { rolesType } from '../config/roles'
|
||||
|
||||
export const Roles = (...roles: rolesType) => SetMetadata('roles', roles);
|
14
api/src/decorator/user.decorator.ts
Normal file
14
api/src/decorator/user.decorator.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'
|
||||
import { GqlExecutionContext } from '@nestjs/graphql'
|
||||
|
||||
export const User = createParamDecorator(
|
||||
(data: unknown, ctx: ExecutionContext) => {
|
||||
const user = GqlExecutionContext.create(ctx).getContext().req.user
|
||||
|
||||
if (!user) {
|
||||
return null
|
||||
}
|
||||
|
||||
return user
|
||||
},
|
||||
);
|
15
api/src/dto/auth/auth.jwt.model.ts
Normal file
15
api/src/dto/auth/auth.jwt.model.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
|
||||
@ObjectType('AuthToken')
|
||||
export class AuthJwtModel {
|
||||
@Field()
|
||||
readonly accessToken: string
|
||||
|
||||
@Field()
|
||||
readonly refreshToken: string
|
||||
|
||||
constructor(partial: Partial<AuthJwtModel>) {
|
||||
this.accessToken = partial.accessToken
|
||||
this.refreshToken = partial.refreshToken
|
||||
}
|
||||
}
|
11
api/src/dto/deleted.model.ts
Normal file
11
api/src/dto/deleted.model.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
|
||||
@ObjectType('Deleted')
|
||||
export class DeletedModel {
|
||||
@Field(() => ID)
|
||||
id: string
|
||||
|
||||
constructor(id: string) {
|
||||
this.id = id
|
||||
}
|
||||
}
|
25
api/src/dto/form/button.input.ts
Normal file
25
api/src/dto/form/button.input.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType()
|
||||
export class ButtonInput {
|
||||
@Field(() => ID, { nullable: true })
|
||||
readonly id?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly url?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly action?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly text?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly bgColor?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly activeColor?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly color?: string
|
||||
}
|
39
api/src/dto/form/button.model.ts
Normal file
39
api/src/dto/form/button.model.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { PageButtonEntity } from '../../entity/page.button.entity'
|
||||
|
||||
@ObjectType('Button')
|
||||
export class ButtonModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly url?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly action?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly text?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly bgColor?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly activeColor?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly color?: string
|
||||
|
||||
constructor(id: string, button: Partial<PageButtonEntity>) {
|
||||
this._id = button.id
|
||||
this.id = id
|
||||
this.url = button.url
|
||||
this.action = button.action
|
||||
this.text = button.text
|
||||
this.bgColor = button.bgColor
|
||||
this.activeColor = button.activeColor
|
||||
this.color = button.color
|
||||
}
|
||||
}
|
22
api/src/dto/form/colors.input.ts
Normal file
22
api/src/dto/form/colors.input.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Field, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType()
|
||||
export class ColorsInput {
|
||||
@Field()
|
||||
readonly background: string
|
||||
|
||||
@Field()
|
||||
readonly question: string
|
||||
|
||||
@Field()
|
||||
readonly answer: string
|
||||
|
||||
@Field()
|
||||
readonly button: string
|
||||
|
||||
@Field()
|
||||
readonly buttonActive: string
|
||||
|
||||
@Field()
|
||||
readonly buttonText: string
|
||||
}
|
32
api/src/dto/form/colors.model.ts
Normal file
32
api/src/dto/form/colors.model.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { ColorsEmbedded } from '../../entity/embedded/colors.embedded'
|
||||
|
||||
@ObjectType('Colors')
|
||||
export class ColorsModel {
|
||||
@Field()
|
||||
readonly background: string
|
||||
|
||||
@Field()
|
||||
readonly question: string
|
||||
|
||||
@Field()
|
||||
readonly answer: string
|
||||
|
||||
@Field()
|
||||
readonly button: string
|
||||
|
||||
@Field()
|
||||
readonly buttonActive: string
|
||||
|
||||
@Field()
|
||||
readonly buttonText: string
|
||||
|
||||
constructor(partial: Partial<ColorsEmbedded>) {
|
||||
this.background = partial.background ?? '#fff'
|
||||
this.question = partial.question ?? '#333'
|
||||
this.answer = partial.answer ?? '#333'
|
||||
this.button = partial.button ?? '#fff'
|
||||
this.buttonActive = partial.buttonActive ?? '#40a9ff'
|
||||
this.buttonText = partial.buttonText ?? '#666'
|
||||
}
|
||||
}
|
14
api/src/dto/form/design.input.ts
Normal file
14
api/src/dto/form/design.input.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Field, InputType } from '@nestjs/graphql'
|
||||
import { ColorsInput } from './colors.input'
|
||||
|
||||
@InputType()
|
||||
export class DesignInput {
|
||||
@Field()
|
||||
readonly colors: ColorsInput
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly font?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly layout?: string
|
||||
}
|
21
api/src/dto/form/design.model.ts
Normal file
21
api/src/dto/form/design.model.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { DesignEmbedded } from '../../entity/embedded/design.embedded'
|
||||
import { ColorsModel } from './colors.model'
|
||||
|
||||
@ObjectType('Design')
|
||||
export class DesignModel {
|
||||
@Field()
|
||||
readonly colors: ColorsModel
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly font?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly layout?: string
|
||||
|
||||
constructor(partial: Partial<DesignEmbedded>) {
|
||||
this.colors = new ColorsModel(partial.colors)
|
||||
this.font = partial.font
|
||||
this.layout = partial.layout
|
||||
}
|
||||
}
|
29
api/src/dto/form/form.create.input.ts
Normal file
29
api/src/dto/form/form.create.input.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Field, InputType } from '@nestjs/graphql'
|
||||
import { PageInput } from './page.input'
|
||||
|
||||
@InputType('FormCreateInput')
|
||||
export class FormCreateInput {
|
||||
@Field()
|
||||
readonly title: string
|
||||
|
||||
@Field()
|
||||
readonly language: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly showFooter: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly anonymousSubmission: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly isLive: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly layout: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly startPage: PageInput
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly endPage: PageInput
|
||||
}
|
43
api/src/dto/form/form.field.input.ts
Normal file
43
api/src/dto/form/form.field.input.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
import { FormFieldLogicInput } from './form.field.logic.input'
|
||||
import { FormFieldOptionInput } from './form.field.option.input'
|
||||
import { FormFieldRatingInput } from './form.field.rating.input'
|
||||
|
||||
@InputType()
|
||||
export class FormFieldInput {
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly title: string
|
||||
|
||||
@Field()
|
||||
readonly type: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly slug?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly idx?: number
|
||||
|
||||
@Field()
|
||||
readonly description: string
|
||||
|
||||
@Field()
|
||||
readonly required: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly defaultValue: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly disabled?: boolean
|
||||
|
||||
@Field(() => [FormFieldOptionInput], { nullable: true })
|
||||
readonly options: FormFieldOptionInput[]
|
||||
|
||||
@Field(() => [FormFieldLogicInput], { nullable: true })
|
||||
readonly logic: FormFieldLogicInput[]
|
||||
|
||||
@Field(() => FormFieldRatingInput, { nullable: true })
|
||||
readonly rating: FormFieldRatingInput
|
||||
}
|
33
api/src/dto/form/form.field.logic.input.ts
Normal file
33
api/src/dto/form/form.field.logic.input.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
import { FormFieldLogicAction } from '../../entity/form.field.logic.entity'
|
||||
|
||||
@InputType()
|
||||
export class FormFieldLogicInput {
|
||||
@Field(() => ID, { nullable: true })
|
||||
readonly id?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly formula: string
|
||||
|
||||
// TODO verify action value
|
||||
@Field(() => String, { nullable: true })
|
||||
readonly action: FormFieldLogicAction
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly idx?: number
|
||||
|
||||
@Field(() => ID, { nullable: true })
|
||||
readonly jumpTo?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly visible?: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly disable?: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly require?: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly enabled: boolean
|
||||
}
|
49
api/src/dto/form/form.field.logic.model.ts
Normal file
49
api/src/dto/form/form.field.logic.model.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { FormFieldLogicEntity } from '../../entity/form.field.logic.entity'
|
||||
|
||||
@ObjectType('FormFieldLogic')
|
||||
export class FormFieldLogicModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly formula: string
|
||||
|
||||
@Field()
|
||||
readonly action: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly idx?: number
|
||||
|
||||
@Field(() => ID, { nullable: true })
|
||||
readonly jumpTo?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly visible?: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly disable?: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly require?: boolean
|
||||
|
||||
@Field()
|
||||
readonly enabled: boolean
|
||||
|
||||
constructor(id: string, document: FormFieldLogicEntity) {
|
||||
this._id = document.id
|
||||
this.id = id
|
||||
this.enabled = document.enabled
|
||||
|
||||
this.formula = document.formula
|
||||
this.jumpTo = document.jumpTo?.id.toString()
|
||||
|
||||
this.idx = document.idx
|
||||
this.action = document.action
|
||||
this.visible = document.visible
|
||||
this.disable = document.disable
|
||||
this.require = document.require
|
||||
}
|
||||
}
|
43
api/src/dto/form/form.field.model.ts
Normal file
43
api/src/dto/form/form.field.model.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { FormFieldEntity } from '../../entity/form.field.entity'
|
||||
|
||||
@ObjectType('FormField')
|
||||
export class FormFieldModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly title: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly slug?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly idx: number
|
||||
|
||||
@Field()
|
||||
readonly type: string
|
||||
|
||||
@Field()
|
||||
readonly description: string
|
||||
|
||||
@Field()
|
||||
readonly required: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly defaultValue: string
|
||||
|
||||
constructor(id: string, document: FormFieldEntity) {
|
||||
this._id = document.id
|
||||
this.id = id
|
||||
this.idx = document.idx
|
||||
this.title = document.title
|
||||
this.slug = document.slug
|
||||
this.type = document.type
|
||||
this.description = document.description
|
||||
this.required = document.required
|
||||
this.defaultValue = document.defaultValue
|
||||
}
|
||||
}
|
16
api/src/dto/form/form.field.option.input.ts
Normal file
16
api/src/dto/form/form.field.option.input.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType()
|
||||
export class FormFieldOptionInput {
|
||||
@Field(() => ID, { nullable: true })
|
||||
readonly id?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly key: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly title: string
|
||||
|
||||
@Field()
|
||||
readonly value: string
|
||||
}
|
27
api/src/dto/form/form.field.option.model.ts
Normal file
27
api/src/dto/form/form.field.option.model.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { FormFieldOptionEntity } from '../../entity/form.field.option.entity'
|
||||
|
||||
@ObjectType('FormFieldOption')
|
||||
export class FormFieldOptionModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly key: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly title: string
|
||||
|
||||
@Field()
|
||||
readonly value: string
|
||||
|
||||
constructor(id: string, option: FormFieldOptionEntity) {
|
||||
this._id = option.id
|
||||
this.id = id
|
||||
this.key = option.key
|
||||
this.title = option.title
|
||||
this.value = option.value
|
||||
}
|
||||
}
|
11
api/src/dto/form/form.field.rating.input.ts
Normal file
11
api/src/dto/form/form.field.rating.input.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Field, InputType } from '@nestjs/graphql'
|
||||
import { GraphQLInt } from 'graphql'
|
||||
|
||||
@InputType()
|
||||
export class FormFieldRatingInput {
|
||||
@Field(() => GraphQLInt, { nullable: true })
|
||||
readonly steps: number
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly shape: string
|
||||
}
|
17
api/src/dto/form/form.field.rating.model.ts
Normal file
17
api/src/dto/form/form.field.rating.model.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { GraphQLInt } from 'graphql'
|
||||
import { RatingEmbedded } from '../../entity/embedded/rating.embedded'
|
||||
|
||||
@ObjectType('FormFieldRating')
|
||||
export class FormFieldRatingModel {
|
||||
@Field(() => GraphQLInt, { nullable: true })
|
||||
readonly steps: number
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly shape: string
|
||||
|
||||
constructor(option: RatingEmbedded) {
|
||||
this.steps = option.steps
|
||||
this.shape = option.shape
|
||||
}
|
||||
}
|
16
api/src/dto/form/form.hook.input.ts
Normal file
16
api/src/dto/form/form.hook.input.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType()
|
||||
export class FormHookInput {
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly enabled: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly url?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly format?: string
|
||||
}
|
27
api/src/dto/form/form.hook.model.ts
Normal file
27
api/src/dto/form/form.hook.model.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { FormHookEntity } from '../../entity/form.hook.entity'
|
||||
|
||||
@ObjectType('FormHook')
|
||||
export class FormHookModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly enabled: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly url?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly format?: string
|
||||
|
||||
constructor(id, hook: FormHookEntity) {
|
||||
this._id = hook.id
|
||||
this.id = id
|
||||
this.enabled = hook.enabled
|
||||
this.url = hook.url
|
||||
this.format = hook.format
|
||||
}
|
||||
}
|
39
api/src/dto/form/form.model.ts
Normal file
39
api/src/dto/form/form.model.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { FormEntity } from '../../entity/form.entity'
|
||||
|
||||
@ObjectType('Form')
|
||||
export class FormModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly title: string
|
||||
|
||||
@Field()
|
||||
readonly created: Date
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly lastModified?: Date
|
||||
|
||||
@Field()
|
||||
readonly language: string
|
||||
|
||||
@Field()
|
||||
readonly showFooter: boolean
|
||||
|
||||
@Field()
|
||||
readonly anonymousSubmission: boolean
|
||||
|
||||
constructor(id: string, form: FormEntity) {
|
||||
this._id = form.id
|
||||
this.id = id
|
||||
this.title = form.title
|
||||
this.created = form.created
|
||||
this.lastModified = form.lastModified
|
||||
this.language = form.language
|
||||
this.showFooter = form.showFooter
|
||||
this.anonymousSubmission = form.anonymousSubmission
|
||||
}
|
||||
}
|
28
api/src/dto/form/form.notification.input.ts
Normal file
28
api/src/dto/form/form.notification.input.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType('FormNotificationInput')
|
||||
export class FormNotificationInput {
|
||||
@Field(() => ID, { nullable: true })
|
||||
readonly id?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly subject?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly htmlTemplate?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly toField?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly fromEmail?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly fromField?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly toEmail?: string
|
||||
|
||||
@Field()
|
||||
readonly enabled: boolean
|
||||
}
|
43
api/src/dto/form/form.notification.model.ts
Normal file
43
api/src/dto/form/form.notification.model.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { FormNotificationEntity } from '../../entity/form.notification.entity'
|
||||
|
||||
@ObjectType('FormNotification')
|
||||
export class FormNotificationModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly subject?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly htmlTemplate?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly toField?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly fromEmail?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly fromField?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly toEmail?: string
|
||||
|
||||
@Field()
|
||||
readonly enabled: boolean
|
||||
|
||||
constructor(id: string, partial: Partial<FormNotificationEntity>) {
|
||||
this._id = partial.id
|
||||
this.id = id
|
||||
this.subject = partial.subject
|
||||
this.htmlTemplate = partial.htmlTemplate
|
||||
this.enabled = partial.enabled
|
||||
this.toField = partial.toField?.id.toString()
|
||||
this.toEmail = partial.toEmail
|
||||
this.fromField = partial.fromField?.id.toString()
|
||||
this.fromEmail = partial.fromEmail
|
||||
}
|
||||
}
|
25
api/src/dto/form/form.pager.model.ts
Normal file
25
api/src/dto/form/form.pager.model.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { GraphQLInt } from 'graphql'
|
||||
import { FormModel } from './form.model'
|
||||
|
||||
@ObjectType('FormPager')
|
||||
export class FormPagerModel {
|
||||
@Field(() => [FormModel])
|
||||
entries: FormModel[]
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
total: number
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
limit: number
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
start: number
|
||||
|
||||
constructor(entries: FormModel[], total: number, limit: number, start: number) {
|
||||
this.entries = entries
|
||||
this.total = total
|
||||
this.limit = limit
|
||||
this.start = start
|
||||
}
|
||||
}
|
6
api/src/dto/form/form.statistic.model.ts
Normal file
6
api/src/dto/form/form.statistic.model.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ObjectType } from '@nestjs/graphql'
|
||||
|
||||
@ObjectType('FormStatistic')
|
||||
export class FormStatisticModel {
|
||||
|
||||
}
|
45
api/src/dto/form/form.update.input.ts
Normal file
45
api/src/dto/form/form.update.input.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
import { DesignInput } from './design.input'
|
||||
import { FormFieldInput } from './form.field.input'
|
||||
import { FormHookInput } from './form.hook.input'
|
||||
import { FormNotificationInput } from './form.notification.input'
|
||||
import { PageInput } from './page.input'
|
||||
|
||||
@InputType()
|
||||
export class FormUpdateInput {
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly title: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly language: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly showFooter: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly anonymousSubmission: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly isLive: boolean
|
||||
|
||||
@Field(() => [FormFieldInput], { nullable: true })
|
||||
readonly fields: FormFieldInput[]
|
||||
|
||||
@Field(() => [FormHookInput], { nullable: true })
|
||||
readonly hooks: FormHookInput[]
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly design: DesignInput
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly startPage: PageInput
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly endPage: PageInput
|
||||
|
||||
@Field(() => [FormNotificationInput], { nullable: true })
|
||||
readonly notifications: FormNotificationInput[]
|
||||
}
|
23
api/src/dto/form/page.input.ts
Normal file
23
api/src/dto/form/page.input.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
import { ButtonInput } from './button.input'
|
||||
|
||||
@InputType()
|
||||
export class PageInput {
|
||||
@Field(() => ID, { nullable: true })
|
||||
readonly id?: string
|
||||
|
||||
@Field()
|
||||
readonly show: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly title?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly paragraph?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly buttonText?: string
|
||||
|
||||
@Field(() => [ButtonInput], { nullable: true })
|
||||
readonly buttons: ButtonInput[]
|
||||
}
|
37
api/src/dto/form/page.model.ts
Normal file
37
api/src/dto/form/page.model.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { PageEntity } from '../../entity/page.entity'
|
||||
|
||||
@ObjectType('Page')
|
||||
export class PageModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly show: boolean
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly title?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly paragraph?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly buttonText?: string
|
||||
|
||||
constructor(id: string, page?: Partial<PageEntity>) {
|
||||
if (!page) {
|
||||
this.id = id
|
||||
this.show = false
|
||||
return
|
||||
}
|
||||
|
||||
this._id = page.id
|
||||
this.id = id
|
||||
this.show = page.show
|
||||
this.title = page.title
|
||||
this.paragraph = page.paragraph
|
||||
this.buttonText = page.buttonText
|
||||
}
|
||||
}
|
15
api/src/dto/profile/profile.model.ts
Normal file
15
api/src/dto/profile/profile.model.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { UserEntity } from '../../entity/user.entity'
|
||||
import { UserModel } from '../user/user.model'
|
||||
|
||||
@ObjectType('Profile')
|
||||
export class ProfileModel extends UserModel {
|
||||
@Field(() => [String])
|
||||
readonly roles: string[]
|
||||
|
||||
constructor(id: string, user: UserEntity) {
|
||||
super(id, user)
|
||||
|
||||
this.roles = user.roles
|
||||
}
|
||||
}
|
25
api/src/dto/profile/profile.update.input.ts
Normal file
25
api/src/dto/profile/profile.update.input.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType()
|
||||
export class ProfileUpdateInput {
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly username: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly email: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly firstName: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly lastName: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly password: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly language: string
|
||||
}
|
24
api/src/dto/setting/setting.model.ts
Normal file
24
api/src/dto/setting/setting.model.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
|
||||
@ObjectType('Setting')
|
||||
export class SettingModel {
|
||||
@Field(() => ID)
|
||||
readonly key: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly value?: string
|
||||
|
||||
@Field()
|
||||
readonly isTrue: boolean
|
||||
|
||||
@Field()
|
||||
readonly isFalse: boolean
|
||||
|
||||
constructor(key: string, value: string) {
|
||||
this.key = key
|
||||
this.value = value
|
||||
|
||||
this.isTrue = value ? (value.toLowerCase() === 'true' || value === '1') : false
|
||||
this.isFalse = !this.isTrue
|
||||
}
|
||||
}
|
25
api/src/dto/setting/setting.pager.model.ts
Normal file
25
api/src/dto/setting/setting.pager.model.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { GraphQLInt } from 'graphql'
|
||||
import { SettingModel } from './setting.model'
|
||||
|
||||
@ObjectType('SettingPager')
|
||||
export class SettingPagerModel {
|
||||
@Field(() => [SettingModel])
|
||||
entries: SettingModel[]
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
total: number
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
limit: number
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
start: number
|
||||
|
||||
constructor(entries: SettingModel[], total: number, limit: number, start: number) {
|
||||
this.entries = entries
|
||||
this.total = total
|
||||
this.limit = limit
|
||||
this.start = start
|
||||
}
|
||||
}
|
11
api/src/dto/status.model.ts
Normal file
11
api/src/dto/status.model.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
|
||||
@ObjectType('Version')
|
||||
export class StatusModel {
|
||||
@Field()
|
||||
readonly version: string
|
||||
|
||||
constructor(partial: Partial<StatusModel>) {
|
||||
this.version = partial.version
|
||||
}
|
||||
}
|
13
api/src/dto/submission/device.input.ts
Normal file
13
api/src/dto/submission/device.input.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Field, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType()
|
||||
export class DeviceInput {
|
||||
@Field()
|
||||
readonly type: string
|
||||
|
||||
@Field()
|
||||
readonly name: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly language: string
|
||||
}
|
20
api/src/dto/submission/device.model.ts
Normal file
20
api/src/dto/submission/device.model.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { DeviceEmbedded } from '../../entity/embedded/device.embedded'
|
||||
|
||||
@ObjectType('Device')
|
||||
export class DeviceModel {
|
||||
@Field()
|
||||
readonly type: string
|
||||
|
||||
@Field()
|
||||
readonly name: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly language: string
|
||||
|
||||
constructor(device: DeviceEmbedded) {
|
||||
this.type = device.type
|
||||
this.name = device.name
|
||||
this.language = device.language
|
||||
}
|
||||
}
|
16
api/src/dto/submission/geo.location.model.ts
Normal file
16
api/src/dto/submission/geo.location.model.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { GeoLocationEmbedded } from '../../entity/embedded/geo.location.embedded'
|
||||
|
||||
@ObjectType('GeoLocation')
|
||||
export class GeoLocationModel {
|
||||
@Field({ nullable: true })
|
||||
country?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
city?: string
|
||||
|
||||
constructor(geo: GeoLocationEmbedded) {
|
||||
this.country = geo.country
|
||||
this.city = geo.city
|
||||
}
|
||||
}
|
23
api/src/dto/submission/submission.field.model.ts
Normal file
23
api/src/dto/submission/submission.field.model.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { SubmissionFieldEntity } from '../../entity/submission.field.entity'
|
||||
|
||||
@ObjectType('SubmissionField')
|
||||
export class SubmissionFieldModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly value: string
|
||||
|
||||
@Field()
|
||||
readonly type: string
|
||||
|
||||
constructor(id: string, field: SubmissionFieldEntity) {
|
||||
this._id = field.id
|
||||
this.id = id
|
||||
this.value = JSON.stringify(field.content)
|
||||
this.type = field.type
|
||||
}
|
||||
}
|
48
api/src/dto/submission/submission.model.ts
Normal file
48
api/src/dto/submission/submission.model.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { SubmissionEntity } from '../../entity/submission.entity'
|
||||
import { DeviceModel } from './device.model'
|
||||
import { GeoLocationModel } from './geo.location.model'
|
||||
|
||||
@ObjectType('Submission')
|
||||
export class SubmissionModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly ipAddr: string
|
||||
|
||||
@Field(() => GeoLocationModel)
|
||||
readonly geoLocation: GeoLocationModel
|
||||
|
||||
@Field(() => DeviceModel)
|
||||
readonly device: DeviceModel
|
||||
|
||||
@Field()
|
||||
readonly timeElapsed: number
|
||||
|
||||
@Field()
|
||||
readonly percentageComplete: number
|
||||
|
||||
@Field()
|
||||
readonly created: Date
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly lastModified?: Date
|
||||
|
||||
constructor(id: string, submission: SubmissionEntity) {
|
||||
this._id = submission.id
|
||||
this.id = id
|
||||
|
||||
this.ipAddr = submission.ipAddr
|
||||
this.geoLocation = new GeoLocationModel(submission.geoLocation)
|
||||
this.device = new DeviceModel(submission.device)
|
||||
|
||||
this.timeElapsed = submission.timeElapsed
|
||||
this.percentageComplete = submission.percentageComplete
|
||||
|
||||
this.created = submission.created
|
||||
this.lastModified = submission.lastModified
|
||||
}
|
||||
}
|
10
api/src/dto/submission/submission.pager.filter.input.ts
Normal file
10
api/src/dto/submission/submission.pager.filter.input.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { Field, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType('SubmissionPagerFilterInput')
|
||||
export class SubmissionPagerFilterInput {
|
||||
@Field({ nullable: true } )
|
||||
finished?: boolean
|
||||
|
||||
@Field({ nullable: true } )
|
||||
excludeEmpty?: boolean
|
||||
}
|
25
api/src/dto/submission/submission.pager.model.ts
Normal file
25
api/src/dto/submission/submission.pager.model.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { GraphQLInt } from 'graphql'
|
||||
import { SubmissionModel } from './submission.model'
|
||||
|
||||
@ObjectType('SubmissionPager')
|
||||
export class SubmissionPagerModel {
|
||||
@Field(() => [SubmissionModel])
|
||||
entries: SubmissionModel[]
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
total: number
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
limit: number
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
start: number
|
||||
|
||||
constructor(entries: SubmissionModel[], total: number, limit: number, start: number) {
|
||||
this.entries = entries
|
||||
this.total = total
|
||||
this.limit = limit
|
||||
this.start = start
|
||||
}
|
||||
}
|
33
api/src/dto/submission/submission.progress.model.ts
Normal file
33
api/src/dto/submission/submission.progress.model.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { SubmissionEntity } from '../../entity/submission.entity'
|
||||
|
||||
@ObjectType('SubmissionProgress')
|
||||
export class SubmissionProgressModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field()
|
||||
readonly timeElapsed: number
|
||||
|
||||
@Field()
|
||||
readonly percentageComplete: number
|
||||
|
||||
@Field()
|
||||
readonly created: Date
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly lastModified?: Date
|
||||
|
||||
constructor(id: string, submission: Partial<SubmissionEntity>) {
|
||||
this._id = submission.id
|
||||
this.id = id
|
||||
|
||||
this.timeElapsed = submission.timeElapsed
|
||||
this.percentageComplete = submission.percentageComplete
|
||||
|
||||
this.created = submission.created
|
||||
this.lastModified = submission.lastModified
|
||||
}
|
||||
}
|
13
api/src/dto/submission/submission.set.field.input.ts
Normal file
13
api/src/dto/submission/submission.set.field.input.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType()
|
||||
export class SubmissionSetFieldInput {
|
||||
@Field()
|
||||
readonly token: string
|
||||
|
||||
@Field(() => ID)
|
||||
readonly field: string
|
||||
|
||||
@Field()
|
||||
readonly data: string
|
||||
}
|
11
api/src/dto/submission/submission.start.input.ts
Normal file
11
api/src/dto/submission/submission.start.input.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Field, InputType } from '@nestjs/graphql'
|
||||
import { DeviceInput } from './device.input'
|
||||
|
||||
@InputType()
|
||||
export class SubmissionStartInput {
|
||||
@Field()
|
||||
readonly token: string
|
||||
|
||||
@Field(() => DeviceInput)
|
||||
readonly device: DeviceInput
|
||||
}
|
6
api/src/dto/submission/submission.statistic.model.ts
Normal file
6
api/src/dto/submission/submission.statistic.model.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ObjectType } from '@nestjs/graphql'
|
||||
|
||||
@ObjectType('SubmissionStatistic')
|
||||
export class SubmissionStatisticModel {
|
||||
|
||||
}
|
28
api/src/dto/user/user.create.input.ts
Normal file
28
api/src/dto/user/user.create.input.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Field, InputType } from '@nestjs/graphql'
|
||||
import { IsEmail, IsNotEmpty, MaxLength, MinLength } from 'class-validator'
|
||||
|
||||
@InputType()
|
||||
export class UserCreateInput {
|
||||
@Field()
|
||||
@MinLength(2)
|
||||
@MaxLength(50)
|
||||
username: string
|
||||
|
||||
@Field()
|
||||
@IsEmail()
|
||||
@IsNotEmpty()
|
||||
email: string
|
||||
|
||||
@Field()
|
||||
@MinLength(5)
|
||||
password: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
firstName?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
lastName?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
language?: string
|
||||
}
|
57
api/src/dto/user/user.model.ts
Normal file
57
api/src/dto/user/user.model.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { Field, ID, ObjectType } from '@nestjs/graphql'
|
||||
import { UserEntity } from '../../entity/user.entity'
|
||||
|
||||
@ObjectType('User')
|
||||
export class UserModel {
|
||||
readonly _id: number
|
||||
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
/**
|
||||
* @deprecated use emailVerified instead
|
||||
*/
|
||||
@Field({ deprecationReason: 'use emailVerified instead' })
|
||||
readonly verifiedEmail: boolean
|
||||
|
||||
@Field()
|
||||
readonly emailVerified: boolean
|
||||
|
||||
@Field()
|
||||
readonly username: string
|
||||
|
||||
@Field()
|
||||
readonly email: string
|
||||
|
||||
@Field()
|
||||
readonly language: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly firstName?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly lastName?: string
|
||||
|
||||
@Field()
|
||||
readonly created: Date
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly lastModified: Date
|
||||
|
||||
constructor(id: string, user: UserEntity) {
|
||||
this._id = user.id
|
||||
this.id = id
|
||||
this.username = user.username
|
||||
this.email = user.email
|
||||
|
||||
this.language = user.language
|
||||
this.firstName = user.firstName
|
||||
this.lastName = user.lastName
|
||||
|
||||
this.verifiedEmail = user.emailVerified
|
||||
this.emailVerified = user.emailVerified
|
||||
|
||||
this.created = user.created
|
||||
this.lastModified = user.lastModified
|
||||
}
|
||||
}
|
25
api/src/dto/user/user.pager.model.ts
Normal file
25
api/src/dto/user/user.pager.model.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql'
|
||||
import { GraphQLInt } from 'graphql'
|
||||
import { UserModel } from './user.model'
|
||||
|
||||
@ObjectType('UserPager')
|
||||
export class UserPagerModel {
|
||||
@Field(() => [UserModel])
|
||||
entries: UserModel[]
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
total: number
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
limit: number
|
||||
|
||||
@Field(() => GraphQLInt)
|
||||
start: number
|
||||
|
||||
constructor(entries: UserModel[], total: number, limit: number, start: number) {
|
||||
this.entries = entries
|
||||
this.total = total
|
||||
this.limit = limit
|
||||
this.start = start
|
||||
}
|
||||
}
|
6
api/src/dto/user/user.statistic.model.ts
Normal file
6
api/src/dto/user/user.statistic.model.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { ObjectType } from '@nestjs/graphql'
|
||||
|
||||
@ObjectType('UserStatistic')
|
||||
export class UserStatisticModel {
|
||||
|
||||
}
|
29
api/src/dto/user/user.update.input.ts
Normal file
29
api/src/dto/user/user.update.input.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Field, ID, InputType } from '@nestjs/graphql'
|
||||
|
||||
@InputType()
|
||||
export class UserUpdateInput {
|
||||
@Field(() => ID)
|
||||
readonly id: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly username: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly email: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly firstName: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly lastName: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly password: string
|
||||
|
||||
// TODO validate
|
||||
@Field(() => [String], { nullable: true })
|
||||
readonly roles: string[]
|
||||
|
||||
@Field({ nullable: true })
|
||||
readonly language: string
|
||||
}
|
6
api/src/entity/embedded/analytics.embedded.ts
Normal file
6
api/src/entity/embedded/analytics.embedded.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { Column } from 'typeorm'
|
||||
|
||||
export class AnalyticsEmbedded {
|
||||
@Column({ nullable: true })
|
||||
readonly gaCode?: string
|
||||
}
|
21
api/src/entity/embedded/colors.embedded.ts
Normal file
21
api/src/entity/embedded/colors.embedded.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Column } from 'typeorm'
|
||||
|
||||
export class ColorsEmbedded {
|
||||
@Column({ nullable: true })
|
||||
public background?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public question?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public answer?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public button?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public buttonActive?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public buttonText?: string
|
||||
}
|
13
api/src/entity/embedded/design.embedded.ts
Normal file
13
api/src/entity/embedded/design.embedded.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Column } from 'typeorm'
|
||||
import { ColorsEmbedded } from './colors.embedded'
|
||||
|
||||
export class DesignEmbedded {
|
||||
@Column(() => ColorsEmbedded)
|
||||
colors: ColorsEmbedded = new ColorsEmbedded()
|
||||
|
||||
@Column({ nullable: true })
|
||||
font?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
layout?: string
|
||||
}
|
12
api/src/entity/embedded/device.embedded.ts
Normal file
12
api/src/entity/embedded/device.embedded.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Column } from 'typeorm'
|
||||
|
||||
export class DeviceEmbedded {
|
||||
@Column({ nullable: true })
|
||||
public language?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public type?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public name?: string
|
||||
}
|
9
api/src/entity/embedded/geo.location.embedded.ts
Normal file
9
api/src/entity/embedded/geo.location.embedded.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Column } from 'typeorm'
|
||||
|
||||
export class GeoLocationEmbedded {
|
||||
@Column({ nullable: true })
|
||||
readonly country?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
readonly city?: string
|
||||
}
|
9
api/src/entity/embedded/rating.embedded.ts
Normal file
9
api/src/entity/embedded/rating.embedded.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Column } from 'typeorm'
|
||||
|
||||
export class RatingEmbedded {
|
||||
@Column({ nullable: true })
|
||||
readonly steps?: number
|
||||
|
||||
@Column({ nullable: true })
|
||||
readonly shape?: string
|
||||
}
|
81
api/src/entity/form.entity.ts
Normal file
81
api/src/entity/form.entity.ts
Normal file
@ -0,0 +1,81 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import { AnalyticsEmbedded } from './embedded/analytics.embedded'
|
||||
import { DesignEmbedded } from './embedded/design.embedded'
|
||||
import { FormFieldEntity } from './form.field.entity'
|
||||
import { FormHookEntity } from './form.hook.entity'
|
||||
import { FormNotificationEntity } from './form.notification.entity'
|
||||
import { PageEntity } from './page.entity'
|
||||
import { SubmissionEntity } from './submission.entity'
|
||||
import { UserEntity } from './user.entity'
|
||||
import { VisitorEntity } from './visitor.entity'
|
||||
|
||||
@Entity({ name: 'form' })
|
||||
export class FormEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
public id: number
|
||||
|
||||
@Column()
|
||||
public title: string
|
||||
|
||||
@Column({ length: 10 })
|
||||
public language: string
|
||||
|
||||
@Column(() => AnalyticsEmbedded)
|
||||
public analytics: AnalyticsEmbedded = new AnalyticsEmbedded()
|
||||
|
||||
@OneToMany(() => VisitorEntity, visitor => visitor.form)
|
||||
public visitors: VisitorEntity[]
|
||||
|
||||
@OneToMany(() => SubmissionEntity, submission => submission.form)
|
||||
public submissions: SubmissionEntity[]
|
||||
|
||||
@OneToMany(() => FormFieldEntity, field => field.form, { eager: true, orphanedRowAction: 'delete', cascade: true })
|
||||
public fields: FormFieldEntity[]
|
||||
|
||||
@OneToMany(() => FormHookEntity, field => field.form, { eager: true, orphanedRowAction: 'delete', cascade: true })
|
||||
public hooks: FormHookEntity[]
|
||||
|
||||
@ManyToOne(() => UserEntity, { eager: true })
|
||||
public admin: UserEntity
|
||||
|
||||
@ManyToOne(() => PageEntity, { eager: true, cascade: true })
|
||||
public startPage: PageEntity;
|
||||
|
||||
@ManyToOne(() => PageEntity, { eager: true, cascade: true })
|
||||
public endPage: PageEntity;
|
||||
|
||||
@OneToMany(() => FormNotificationEntity, notification => notification.form, { eager: true, orphanedRowAction: 'delete', cascade: true })
|
||||
public notifications: FormNotificationEntity[]
|
||||
|
||||
@Column()
|
||||
public showFooter: boolean;
|
||||
|
||||
@Column()
|
||||
public isLive: boolean;
|
||||
|
||||
@Column({ default: false })
|
||||
public anonymousSubmission: boolean;
|
||||
|
||||
@Column(() => DesignEmbedded)
|
||||
public design: DesignEmbedded = new DesignEmbedded();
|
||||
|
||||
@CreateDateColumn()
|
||||
public created: Date
|
||||
|
||||
@UpdateDateColumn()
|
||||
public lastModified: Date
|
||||
|
||||
constructor(partial?: Partial<FormEntity>) {
|
||||
if (partial) {
|
||||
Object.assign(this, partial)
|
||||
}
|
||||
}
|
||||
}
|
47
api/src/entity/form.field.entity.ts
Normal file
47
api/src/entity/form.field.entity.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm'
|
||||
import { RatingEmbedded } from './embedded/rating.embedded'
|
||||
import { FormEntity } from './form.entity'
|
||||
import { FormFieldLogicEntity } from './form.field.logic.entity'
|
||||
import { FormFieldOptionEntity } from './form.field.option.entity'
|
||||
|
||||
@Entity({ name: 'form_field' })
|
||||
export class FormFieldEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
public id: number
|
||||
|
||||
@ManyToOne(() => FormEntity, form => form.fields)
|
||||
public form: FormEntity
|
||||
|
||||
@Column()
|
||||
public title: string
|
||||
|
||||
@Column({ type: 'text' })
|
||||
public description: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public slug?: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public idx?: number
|
||||
|
||||
@OneToMany(() => FormFieldLogicEntity, logic => logic.field, { eager: true, orphanedRowAction: 'delete', cascade: true })
|
||||
public logic: FormFieldLogicEntity[]
|
||||
|
||||
@Column(() => RatingEmbedded)
|
||||
public rating: RatingEmbedded = new RatingEmbedded()
|
||||
|
||||
@OneToMany(() => FormFieldOptionEntity, option => option.field, { eager: true, orphanedRowAction: 'delete', cascade: true })
|
||||
public options?: FormFieldOptionEntity[]
|
||||
|
||||
@Column()
|
||||
public required: boolean
|
||||
|
||||
@Column({ type: 'boolean' })
|
||||
public disabled = false
|
||||
|
||||
@Column()
|
||||
public type: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public defaultValue: string
|
||||
}
|
37
api/src/entity/form.field.logic.entity.ts
Normal file
37
api/src/entity/form.field.logic.entity.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'
|
||||
import { FormFieldEntity } from './form.field.entity'
|
||||
|
||||
export type FormFieldLogicAction = 'visible' | 'require' | 'disable' | 'jumpTo'
|
||||
|
||||
@Entity({ name: 'form_field_logic' })
|
||||
export class FormFieldLogicEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
public id: number
|
||||
|
||||
@ManyToOne(() => FormFieldEntity, field => field.options)
|
||||
public field: FormFieldEntity
|
||||
|
||||
@Column()
|
||||
public formula: string
|
||||
|
||||
@Column({ nullable: true })
|
||||
public idx?: number
|
||||
|
||||
@Column({ type: 'varchar', length: 10 })
|
||||
public action: FormFieldLogicAction
|
||||
|
||||
@Column({ nullable: true })
|
||||
public visible?: boolean
|
||||
|
||||
@Column({ nullable: true })
|
||||
public require?: boolean
|
||||
|
||||
@Column({ nullable: true })
|
||||
public disable?: boolean
|
||||
|
||||
@ManyToOne(() => FormFieldEntity)
|
||||
public jumpTo?: FormFieldEntity
|
||||
|
||||
@Column()
|
||||
public enabled: boolean
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user