mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-05 13:02:54 +00:00
Compare commits
110 Commits
114-improv
...
@openstapp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5c9bcf433 | ||
|
|
b40ba7ad63 | ||
|
|
362f6adf07 | ||
|
|
bbd6b0f874 | ||
|
|
b1a9ba44d0 | ||
|
|
bee38d4a59 | ||
|
|
a5c5c31d09 | ||
|
|
c8e290200f | ||
|
|
ef4e1f8ded | ||
|
|
5759a1cbb1 | ||
| b8ac30b9d0 | |||
|
|
436e1471a7 | ||
|
|
4c9d330c88 | ||
|
|
580ebee362 | ||
|
|
07e5c80223 | ||
|
|
2ac840d845 | ||
|
|
8b581ef9ca | ||
|
|
e2d5d4f187 | ||
|
|
496b50d892 | ||
|
e6c17c860b
|
|||
|
|
bb1f596bfc | ||
|
0c49fd8c34
|
|||
|
|
ce5016a992 | ||
|
3ac8c04765
|
|||
|
|
5c260dd26b | ||
|
|
f2e1a6ddd5 | ||
|
|
ccacfbf710 | ||
|
|
b249b329f7 | ||
|
|
7afc24f1bc | ||
|
|
7276525dfa | ||
|
|
c9e881582f | ||
|
|
df681de083 | ||
| 802a7a3fa7 | |||
|
|
343d03e647 | ||
| 727b92911e | |||
| 11bc987807 | |||
|
|
b8faae5988 | ||
| 67ab1fd613 | |||
|
|
142079bf0e | ||
|
|
5050ac90eb | ||
|
|
688bc5f2e7 | ||
|
|
ad174dd7d7 | ||
|
|
26e654f5b8 | ||
|
|
5439484a90 | ||
|
|
68f3366a27 | ||
|
|
dea9a82105 | ||
|
39d2801114
|
|||
|
|
341b209092 | ||
|
|
a6b88d3534 | ||
|
|
be863daaef | ||
| 2f64d69693 | |||
| 964516d3cf | |||
| 71ff9fd960 | |||
| abf9999461 | |||
| 53c3d0ba0c | |||
|
|
622481a3c9 | ||
|
|
1ab5c0c355 | ||
|
|
b0f6ffb21c | ||
|
|
e658cff9d2 | ||
|
|
e71355a2fb | ||
| 100607740b | |||
|
|
10c4466b37 | ||
|
|
09faa66e98 | ||
|
|
7c5687111f | ||
|
|
c066028e49 | ||
| 0858a26dc1 | |||
| 8667603bd6 | |||
| 65bc9a76b6 | |||
| 912ae42270 | |||
| c4a5d6e73b | |||
| deed376c24 | |||
| a4cc23e9a8 | |||
| e8d72683ef | |||
|
|
e3d068f8d4 | ||
|
|
b346d216a3 | ||
| dbb558508f | |||
|
|
754d99c1b4 | ||
|
|
689ac68be3 | ||
|
|
d36d9596fc | ||
|
|
8d50f669e7 | ||
|
|
dce08d9c03 | ||
|
|
296054c8e0 | ||
|
859763367e
|
|||
|
|
848fde4660 | ||
|
|
bd1046a19a | ||
|
|
3b9068197c | ||
|
|
d2c8120255 | ||
|
d44204cf8d
|
|||
|
9d5dd05bb6
|
|||
|
288a49113f
|
|||
| 791b5c895d | |||
| d7a85b7fae | |||
|
|
bff2d985aa | ||
|
|
655efc9d29 | ||
|
|
66712bdd24 | ||
| 8b5b4c765b | |||
|
|
31a6ebfd3f | ||
|
|
991ed1cb1f | ||
|
|
1efe5c1449 | ||
|
|
4dbeb9936c | ||
|
|
29e6128141 | ||
|
|
753dc7cd11 | ||
|
|
4f3834c20e | ||
|
|
cfb4aa364f | ||
|
|
37945f7d19 | ||
|
5d47a17629
|
|||
| 61587c7ba1 | |||
| 066e374462 | |||
|
a02190fe5a
|
|||
|
04e275e967
|
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
'@openstapps/backend': minor
|
|
||||||
'@openstapps/core': minor
|
|
||||||
'@openstapps/app': minor
|
|
||||||
---
|
|
||||||
|
|
||||||
Add job portal feature
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'@openstapps/api-cli': minor
|
|
||||||
---
|
|
||||||
|
|
||||||
Add "\*" option to copy command that allows for a full database clone
|
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -24,6 +24,7 @@ report-junit.xml
|
|||||||
# NixOS flake
|
# NixOS flake
|
||||||
result
|
result
|
||||||
hsperfdata_root
|
hsperfdata_root
|
||||||
|
.direnv/
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
lib-cov
|
lib-cov
|
||||||
@@ -51,8 +52,6 @@ node_modules/
|
|||||||
.pnpm-store/
|
.pnpm-store/
|
||||||
jspm_packages/
|
jspm_packages/
|
||||||
|
|
||||||
.browser-data
|
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
# TypeScript v1 declaration files
|
||||||
typings/
|
typings/
|
||||||
|
|
||||||
@@ -99,7 +98,8 @@ typings/
|
|||||||
|
|
||||||
# ignore ide files
|
# ignore ide files
|
||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode?*
|
||||||
|
!.vscode/launch.json
|
||||||
|
|
||||||
# ignore lib
|
# ignore lib
|
||||||
lib
|
lib
|
||||||
|
|||||||
@@ -21,13 +21,7 @@ include:
|
|||||||
- local: /.gitlab/publishing.gitlab-ci.yml
|
- local: /.gitlab/publishing.gitlab-ci.yml
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
TURBO_CACHE_BYPASS:
|
TURBO_CACHE_BYPASS: "--force --no-cache"
|
||||||
value: ''
|
|
||||||
options:
|
|
||||||
- '--force'
|
|
||||||
- '--no-cache'
|
|
||||||
- ''
|
|
||||||
description: Bypass turbo cache
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
image: registry.gitlab.com/openstapps/openstapps/node-builder
|
||||||
@@ -36,10 +30,7 @@ default:
|
|||||||
interruptible: true
|
interruptible: true
|
||||||
before_script:
|
before_script:
|
||||||
- corepack enable
|
- corepack enable
|
||||||
- corepack prepare pnpm@latest-8 --activate
|
- corepack prepare pnpm@latest-10 --activate
|
||||||
- echo TURBO_API=$TURBO_API >> .env.local
|
|
||||||
- echo TURBO_TOKEN=$TURBO_TOKEN >> .env.local
|
|
||||||
- echo TURBO_TEAM=$TURBO_TEAM >> .env.local
|
|
||||||
- pnpm config set store-dir .pnpm-store
|
- pnpm config set store-dir .pnpm-store
|
||||||
cache: &pnpm_cache
|
cache: &pnpm_cache
|
||||||
key:
|
key:
|
||||||
@@ -63,13 +54,13 @@ build:
|
|||||||
# - pnpm i --prefer-offline
|
# - pnpm i --prefer-offline
|
||||||
# - pnpm build:full:skip || pnpm i -r --prefer-offline
|
# - pnpm build:full:skip || pnpm i -r --prefer-offline
|
||||||
- pnpm install
|
- pnpm install
|
||||||
# TODO: whats the benifit for CI? something doesn't work with git here...
|
# TODO: whats the benefit for CI? something doesn't work with git here...
|
||||||
# "🦋 error Error: Failed to find where HEAD diverged from master. Does master exist?"
|
# "🦋 error Error: Failed to find where HEAD diverged from master. Does master exist?"
|
||||||
# - pnpm changeset:status
|
# - pnpm changeset:status
|
||||||
- pnpm build:full $TURBO_CACHE_BYPASS
|
- pnpm build:full $TURBO_CACHE_BYPASS
|
||||||
- .gitlab/ci/enableGitlabReviewToolbar.sh frontend/app/www/index.html "$CI_PROJECT_ID" "$CI_OPEN_MERGE_REQUESTS"
|
- .gitlab/ci/enableGitlabReviewToolbar.sh frontend/app/www/browser/index.html "$CI_PROJECT_ID" "$CI_OPEN_MERGE_REQUESTS"
|
||||||
- cp frontend/app/www/index.html frontend/app/www/200.html
|
- cp frontend/app/www/browser/index.html frontend/app/www/browser/200.html
|
||||||
- pnpm dlx surge -p frontend/app/www -d https://$CI_PROJECT_NAME-$DEPLOY_ID.surge.sh/
|
- pnpm dlx surge -p frontend/app/www/browser -d https://$CI_PROJECT_NAME-$DEPLOY_ID.surge.sh/
|
||||||
cache:
|
cache:
|
||||||
<<: *pnpm_cache
|
<<: *pnpm_cache
|
||||||
policy: pull-push
|
policy: pull-push
|
||||||
@@ -105,13 +96,7 @@ unit:
|
|||||||
stage: test
|
stage: test
|
||||||
needs: ['build']
|
needs: ['build']
|
||||||
script:
|
script:
|
||||||
# - pnpm config set recursive-install false
|
|
||||||
# - pnpm i --prefer-offline
|
|
||||||
# - pnpm test:skip || pnpm i -r --prefer-offline
|
|
||||||
- pnpm install
|
- pnpm install
|
||||||
- cd node_modules/.pnpm/re2*/node_modules/re2
|
|
||||||
- npm run install
|
|
||||||
- cd $CI_PROJECT_DIR
|
|
||||||
- pnpm test $TURBO_CACHE_BYPASS
|
- pnpm test $TURBO_CACHE_BYPASS
|
||||||
coverage: '/Statements[^:]*\:[^:]*\s+([\d\.]+)%/'
|
coverage: '/Statements[^:]*\:[^:]*\s+([\d\.]+)%/'
|
||||||
artifacts:
|
artifacts:
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ publish image:
|
|||||||
- tags
|
- tags
|
||||||
needs: ['deploy']
|
needs: ['deploy']
|
||||||
image:
|
image:
|
||||||
name: gcr.io/kaniko-project/executor:v1.12.1-debug
|
name: gcr.io/kaniko-project/executor:v1.24.0-debug
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
script:
|
script:
|
||||||
- >
|
- >
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"extension": ["ts", "js"],
|
"extension": ["ts"],
|
||||||
"node-option": ["loader=ts-node/esm"],
|
"node-option": ["loader=ts-node/esm"],
|
||||||
"reporter": "mocha-junit-reporter",
|
"reporter": "mocha-junit-reporter",
|
||||||
"reporter-option": ["mochaFile=coverage/report-junit.xml"],
|
"reporter-option": ["mochaFile=coverage/report-junit.xml"],
|
||||||
"spec": ["test/**/*.spec.{ts,js}"]
|
"spec": ["test/**/*.spec.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
1
.prettierignore
Normal file
1
.prettierignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pnpm-lock.yaml
|
||||||
@@ -2,7 +2,13 @@
|
|||||||
|
|
||||||
/** @type {import('syncpack').RcFile} */
|
/** @type {import('syncpack').RcFile} */
|
||||||
const config = {
|
const config = {
|
||||||
semverRange: '',
|
semverGroups: [
|
||||||
|
{
|
||||||
|
range: '',
|
||||||
|
dependencies: ['**'],
|
||||||
|
packages: ['**'],
|
||||||
|
}
|
||||||
|
],
|
||||||
source: ['package.json', '**/package.json'],
|
source: ['package.json', '**/package.json'],
|
||||||
indent: ' ',
|
indent: ' ',
|
||||||
sortFirst: [
|
sortFirst: [
|
||||||
@@ -21,6 +27,7 @@ const config = {
|
|||||||
'bin',
|
'bin',
|
||||||
'files',
|
'files',
|
||||||
'engines',
|
'engines',
|
||||||
|
'packageManager',
|
||||||
'scripts',
|
'scripts',
|
||||||
'dependencies',
|
'dependencies',
|
||||||
'devDependencies',
|
'devDependencies',
|
||||||
@@ -40,10 +47,16 @@ const config = {
|
|||||||
packages: ['**'],
|
packages: ['**'],
|
||||||
isIgnored: true,
|
isIgnored: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'ES Mapping Generator Special Dependencies',
|
||||||
|
dependencies: ['typescript', 'typedoc', 'ts-node', '@types/node', 'got'],
|
||||||
|
packages: ['@openstapps/es-mapping-generator'],
|
||||||
|
isIgnored: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Packages should use workspace version',
|
label: 'Packages should use workspace version',
|
||||||
dependencies: ['@openstapps/**'],
|
dependencies: ['@openstapps/**'],
|
||||||
dependencyTypes: ['prod', 'dev'],
|
dependencyTypes: ['prod', 'dev', 'peer'],
|
||||||
packages: ['**'],
|
packages: ['**'],
|
||||||
pinVersion: 'workspace:*',
|
pinVersion: 'workspace:*',
|
||||||
},
|
},
|
||||||
|
|||||||
3
.tool-versions
Normal file
3
.tool-versions
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
nodejs 22.16.0
|
||||||
|
pnpm 10.12.3
|
||||||
|
python 3.11.5
|
||||||
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type":"node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Run mocha for nodejs workspace",
|
||||||
|
"runtimeExecutable": "${fileDirname}/../node_modules/.bin/c8",
|
||||||
|
"cwd": "${fileDirname}/../",
|
||||||
|
"runtimeArgs": ["--config", "${workspaceFolder}/.c8rc.json", "${fileDirname}/../node_modules/.bin/mocha", "--exit", "--reporter", "spec"]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -9,8 +9,8 @@ integration:
|
|||||||
- name: registry.gitlab.com/openstapps/openstapps/database:latest
|
- name: registry.gitlab.com/openstapps/openstapps/database:latest
|
||||||
alias: elasticsearch
|
alias: elasticsearch
|
||||||
script:
|
script:
|
||||||
- pnpm --filter=@openstapps/backend install
|
- pnpm install
|
||||||
- pnpm test:integration:backend
|
- pnpm test:integration:backend --force --no-cache
|
||||||
artifacts:
|
artifacts:
|
||||||
when: on_failure
|
when: on_failure
|
||||||
paths:
|
paths:
|
||||||
|
|||||||
@@ -1,5 +1,92 @@
|
|||||||
# @openstapps/backend
|
# @openstapps/backend
|
||||||
|
|
||||||
|
## 4.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- b40ba7ad: Updated Elasticsearch dependency
|
||||||
|
- @openstapps/core@4.0.0
|
||||||
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- c8e29020: Update to Node 22
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [c8e29020]
|
||||||
|
- @openstapps/core@4.0.0
|
||||||
|
- @openstapps/core-tools@4.0.0
|
||||||
|
- @openstapps/logger@4.0.0
|
||||||
|
|
||||||
|
## 3.3.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @openstapps/core@3.3.2
|
||||||
|
- @openstapps/core-tools@3.3.2
|
||||||
|
|
||||||
|
## 3.3.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 67ab1fd6: fix for geo.point mapping
|
||||||
|
|
||||||
|
## 3.3.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 688bc5f2: v3.3.0 changes
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [688bc5f2]
|
||||||
|
- @openstapps/core@3.3.0
|
||||||
|
- @openstapps/core-tools@3.3.0
|
||||||
|
- @openstapps/logger@3.0.0
|
||||||
|
|
||||||
|
## 3.2.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 912ae422: Add the ability to filter by existence of a field
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 689ac68b: pin alpine version to 3.18 and add healthchecks
|
||||||
|
- e8d72683: Backend unit tests break every year
|
||||||
|
- Updated dependencies [912ae422]
|
||||||
|
- @openstapps/core@4.0.0
|
||||||
|
- @openstapps/core-tools@3.0.0
|
||||||
|
- @openstapps/logger@3.0.0
|
||||||
|
|
||||||
|
## 3.1.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix backend rejecting plugins
|
||||||
|
- Fix backend sliently falling back to default configs
|
||||||
|
|
||||||
|
## 3.1.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Fix version history offered by backend
|
||||||
|
- Updated dependencies
|
||||||
|
- @openstapps/core@3.1.1
|
||||||
|
|
||||||
|
## 3.1.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 06b8ca10: Add job portal feature
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [06b8ca10]
|
||||||
|
- @openstapps/core@3.1.0
|
||||||
|
|
||||||
## 3.0.1
|
## 3.0.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ ENV NODE_ENV=production
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
HEALTHCHECK --interval=10s --timeout=10s --start-period=10s --retries=12 CMD curl -s --fail --request POST --data '{}' --header 'Content-Type: application/json' http://localhost:3000/ >/dev/null || exit 1
|
||||||
|
|
||||||
ENTRYPOINT ["node", "app.js"]
|
ENTRYPOINT ["node", "app.js"]
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the database configuration for the technical university of berlin
|
* This is the database configuration for the technical university of berlin
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const app = {
|
|||||||
name: 'Goethe-Uni',
|
name: 'Goethe-Uni',
|
||||||
privacyPolicyUrl: 'https://mobile.server.uni-frankfurt.de/_static/privacy.md',
|
privacyPolicyUrl: 'https://mobile.server.uni-frankfurt.de/_static/privacy.md',
|
||||||
settings: [userGroupSetting, languageSetting],
|
settings: [userGroupSetting, languageSetting],
|
||||||
|
versionHistory: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {SCSettingInputType, SCThingOriginType, SCThingType} from '@openstapps/core';
|
import {SCSettingInputType, SCThingOriginType, SCThingType} from '@openstapps/core';
|
||||||
|
|
||||||
/** @type {import('@openstapps/core').SCLanguageSetting} */
|
/** @type {import('@openstapps/core').SCLanguageSetting} */
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
/** @type {import('@openstapps/core').SCAppConfigurationMenuCategory[]} */
|
/** @type {import('@openstapps/core').SCAppConfigurationMenuCategory[]} */
|
||||||
const menus = [
|
const menus = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {SCSettingInputType, SCThingOriginType, SCThingType} from '@openstapps/core';
|
import {SCSettingInputType, SCThingOriginType, SCThingType} from '@openstapps/core';
|
||||||
|
|
||||||
/** @type {import('@openstapps/core').SCUserGroupSetting} */
|
/** @type {import('@openstapps/core').SCUserGroupSetting} */
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {SCThingType} from '@openstapps/core';
|
import {SCThingType} from '@openstapps/core';
|
||||||
|
|
||||||
/** @type {import('@openstapps/core').SCBackendAggregationConfiguration[]} */
|
/** @type {import('@openstapps/core').SCBackendAggregationConfiguration[]} */
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {
|
import {
|
||||||
month,
|
month,
|
||||||
sommerRange,
|
sommerRange,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {SCThingType} from '@openstapps/core';
|
import {SCThingType} from '@openstapps/core';
|
||||||
import aggregations from './aggregations.js';
|
import aggregations from './aggregations.js';
|
||||||
import boostings from './boostings.js';
|
import boostings from './boostings.js';
|
||||||
@@ -17,7 +16,7 @@ export const backend = {
|
|||||||
hiddenTypes: [SCThingType.DateSeries, SCThingType.Diff, SCThingType.Floor],
|
hiddenTypes: [SCThingType.DateSeries, SCThingType.Diff, SCThingType.Floor],
|
||||||
mappingIgnoredTags: ['minlength', 'pattern', 'see', 'tjs-format'],
|
mappingIgnoredTags: ['minlength', 'pattern', 'see', 'tjs-format'],
|
||||||
maxMultiSearchRouteQueries: 5,
|
maxMultiSearchRouteQueries: 5,
|
||||||
maxRequestBodySize: 512 * 1024,
|
maxRequestBodySize: 2e6,
|
||||||
name: 'Goethe-Universität Frankfurt am Main',
|
name: 'Goethe-Universität Frankfurt am Main',
|
||||||
namespace: '909a8cbc-8520-456c-b474-ef1525f14209',
|
namespace: '909a8cbc-8520-456c-b474-ef1525f14209',
|
||||||
sortableFields: [
|
sortableFields: [
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import app from './app/index.js';
|
import app from './app/index.js';
|
||||||
import {backend, internal} from './backend/index.js';
|
import {backend, internal} from './backend/index.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default configuration for elasticsearch (a database)
|
* This is the default configuration for elasticsearch (a database)
|
||||||
*
|
*
|
||||||
@@ -11,13 +9,13 @@
|
|||||||
*
|
*
|
||||||
* To get more information about the meaning of specific fields, please use your IDE to read the TSDoc documentation.
|
* To get more information about the meaning of specific fields, please use your IDE to read the TSDoc documentation.
|
||||||
*
|
*
|
||||||
* @type {import('../../src/storage/elasticsearch/types/elasticsearch-config.js')}
|
* @type {import('../../src/storage/elasticsearch/types/elasticsearch-config.js').ElasticsearchConfigFile}
|
||||||
*/
|
*/
|
||||||
const config = {
|
const config = {
|
||||||
internal: {
|
internal: {
|
||||||
database: {
|
database: {
|
||||||
name: 'elasticsearch',
|
name: 'elasticsearch',
|
||||||
version: '5.6',
|
version: '8.4.2',
|
||||||
query: {
|
query: {
|
||||||
minMatch: '75%',
|
minMatch: '75%',
|
||||||
queryType: 'dis_max',
|
queryType: 'dis_max',
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {readFile} from 'fs/promises';
|
import {readFile} from 'fs/promises';
|
||||||
import {SCAboutPageContentType} from '@openstapps/core';
|
import {SCAboutPageContentType} from '@openstapps/core';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
/**
|
/**
|
||||||
* Generates a range of numbers that represent consecutive calendar months
|
* Generates a range of numbers that represent consecutive calendar months
|
||||||
*
|
*
|
||||||
|
|||||||
37
backend/backend/config/default/tools/version.js
Normal file
37
backend/backend/config/default/tools/version.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import {readFile, readdir} from 'fs/promises';
|
||||||
|
import url from 'url';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @example version(1, import.meta.url)
|
||||||
|
* @param options {Omit<import('@openstapps/core').SCAppVersionInfo, 'releaseNotes' | 'translations'>}
|
||||||
|
* @param base {string}
|
||||||
|
* @returns {Promise<import('@openstapps/core').SCAppVersionInfo>}
|
||||||
|
*/
|
||||||
|
export async function version(options, base) {
|
||||||
|
const de = await readFile(new URL(`${options.version}.de.md`, base), 'utf8');
|
||||||
|
const en = await readFile(new URL(`${options.version}.en.md`, base), 'utf8');
|
||||||
|
|
||||||
|
return {
|
||||||
|
...options,
|
||||||
|
releaseNotes: de,
|
||||||
|
translations: {
|
||||||
|
en: {
|
||||||
|
releaseNotes: en,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param base {string} Base path of the file as `import.meta.url`
|
||||||
|
* @returns {Promise<import('@openstapps/core').SCAppVersionInfo[]>}
|
||||||
|
*/
|
||||||
|
export async function versions(base) {
|
||||||
|
const directory = await readdir(path.dirname(url.fileURLToPath(base)));
|
||||||
|
const versions = [
|
||||||
|
...new Set(directory.filter(it => it.endsWith('.md')).map(it => it.replace(/\.\w+\.md$/, ''))),
|
||||||
|
].sort((a, b) => -a.localeCompare(b, undefined, {numeric: true}));
|
||||||
|
|
||||||
|
return Promise.all(versions.map(versionName => version({version: versionName}, base)));
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {SCAboutPageContentType} from '@openstapps/core';
|
import {SCAboutPageContentType} from '@openstapps/core';
|
||||||
import {markdown} from '../../default/tools/markdown.js';
|
import {markdown} from '../../default/tools/markdown.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {SCAboutPageContentType} from '@openstapps/core';
|
import {SCAboutPageContentType} from '@openstapps/core';
|
||||||
|
|
||||||
/** @type {import('@openstapps/core').SCAboutPage} */
|
/** @type {import('@openstapps/core').SCAboutPage} */
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
// @ts-check
|
|
||||||
import about from './about.js';
|
import about from './about.js';
|
||||||
import imprint from './imprint.js';
|
import imprint from './imprint.js';
|
||||||
import privacy from './privacy.js';
|
import privacy from './privacy.js';
|
||||||
|
|
||||||
/** @type {Record<string, import('@openstapps/core').SCAboutPage>} */
|
/** @type {import('@openstapps/core').SCMap<import('@openstapps/core').SCAboutPage>} */
|
||||||
const aboutPages = {
|
const aboutPages = {
|
||||||
'about': about,
|
'about': about,
|
||||||
'about/imprint': imprint,
|
'about/imprint': imprint,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
import {markdown} from '../../default/tools/markdown.js';
|
import {markdown} from '../../default/tools/markdown.js';
|
||||||
|
|
||||||
/** @type {import('@openstapps/core').SCAboutPage} */
|
/** @type {import('@openstapps/core').SCAboutPage} */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// @ts-check
|
|
||||||
import aboutPages from './about-pages/index.js';
|
import aboutPages from './about-pages/index.js';
|
||||||
import defaultApp from '../default/app/index.js';
|
import defaultApp from '../default/app/index.js';
|
||||||
import {backend as defaultBackend, internal as defaultInternal} from '../default/backend/index.js';
|
import {backend as defaultBackend, internal as defaultInternal} from '../default/backend/index.js';
|
||||||
|
import versionHistory from './version-history/index.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default configuration for the Goethe university of Frankfurt
|
* This is the default configuration for the Goethe university of Frankfurt
|
||||||
@@ -76,6 +76,7 @@ const config = {
|
|||||||
} */
|
} */
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
versionHistory,
|
||||||
aboutPages,
|
aboutPages,
|
||||||
},
|
},
|
||||||
backend: defaultBackend,
|
backend: defaultBackend,
|
||||||
|
|||||||
52
backend/backend/config/f-u/version-history/2.4.0.de.md
Normal file
52
backend/backend/config/f-u/version-history/2.4.0.de.md
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Goethe-Uni App 2.4
|
||||||
|
|
||||||
|
Wir freuen uns euch mehr in der Goethe-Uni App
|
||||||
|
bieten zu können.
|
||||||
|
|
||||||
|
## Navigation zu Gebäuden und Orten
|
||||||
|
|
||||||
|
Als eines der Ergebnisse des Ideenwettbewerbs wurde jetzt
|
||||||
|
ein Navigationsfeature in die App integriert.
|
||||||
|
|
||||||
|
Orte auf der Karte, Mensen, sowie sogar Termine (wenn hinterlegt)
|
||||||
|
bieten jetzt direkt die Option eine Verbindung zu finden, gestützt
|
||||||
|
durch die Karten App auf deinem Gerät.
|
||||||
|
|
||||||
|
## Integration der Jobbörse
|
||||||
|
|
||||||
|
Jobs findest du ab sofort auch in der Goethe-Uni App.
|
||||||
|
|
||||||
|
Auch das ist ein Ergebnis des Ideenwettbewerbs,
|
||||||
|
und wir freuen uns es euch hier präsentieren zu können!
|
||||||
|
|
||||||
|
## Der Umweltscore
|
||||||
|
|
||||||
|
Der Umweltscore für Gerichte wird nun auch in der App angezeigt.
|
||||||
|
|
||||||
|
> Nachhaltigkeit, Umweltschutz, Gesundheit und Klimawandel sind
|
||||||
|
> zentrale Begriffe im gesellschaftlichen Miteinander.
|
||||||
|
> Unsere Ernährung spielt hierbei eine wichtige Rolle.
|
||||||
|
> Das Studierendenwerk Frankfurt am Main zeichnet seine Speisenpläne
|
||||||
|
> ab sofort mit einem Umweltscore aus.
|
||||||
|
> Anhand dieser Bewertung können Sie direkt ersehen,
|
||||||
|
> welchen Einfluss Ihre Essenauswahl auf das Klima hat.
|
||||||
|
|
||||||
|
## Weitere Verbesserungen
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
Die Performance der App beim Navigieren wurde stark verbessert und ist datensparender.
|
||||||
|
|
||||||
|
### Kalender
|
||||||
|
|
||||||
|
Die Kalenderabschnitte haben jetzt neue Namen bekommen:
|
||||||
|
|
||||||
|
- Der _Kalender_ zeigt Termine für spezifische Tage
|
||||||
|
- Die _Wochenübersicht_ ist ein Stundenplan mit allen Termine, die sich wiederholen (z. B. Vorlesungen)
|
||||||
|
- Die _Einzeltermine_ zeigen alle Termine, die sich nicht wiederholen
|
||||||
|
(z. B. Klausuren)
|
||||||
|
|
||||||
|
### Meine App
|
||||||
|
|
||||||
|
Der "Meine Kurse" Abschnitt wurde überarbeitet, und zeigt jetzt Termine
|
||||||
|
für die nächsten Tage und mit mehr Details an.
|
||||||
49
backend/backend/config/f-u/version-history/2.4.0.en.md
Normal file
49
backend/backend/config/f-u/version-history/2.4.0.en.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Goethe-Uni App 2.4
|
||||||
|
|
||||||
|
The Goethe-Uni App got even better!
|
||||||
|
|
||||||
|
## Navigation to buildings and places
|
||||||
|
|
||||||
|
As part of the "Ideenwettbewerb," the idea competition,
|
||||||
|
we have now integrated a navigation feature into the app.
|
||||||
|
|
||||||
|
Orte auf der Karte, Mensen, sowie sogar Termine (wenn hinterlegt)
|
||||||
|
bieten jetzt direkt die Option eine Verbindung zu finden, gestützt
|
||||||
|
durch die Karten App auf deinem Gerät.
|
||||||
|
|
||||||
|
## Integration of the job market
|
||||||
|
|
||||||
|
Jobs are now also available in the Goethe-Uni App.
|
||||||
|
|
||||||
|
This feature is also a result of the idea competition,
|
||||||
|
and we're happy to be able to present it to you here!
|
||||||
|
|
||||||
|
## The environment score
|
||||||
|
|
||||||
|
The environment score for dishes is now displayed inside the app.
|
||||||
|
|
||||||
|
> Sustainability, environment protection, health, and climate change are
|
||||||
|
> central topics in how we live today in our society.
|
||||||
|
> Our eating habits play an important role in it.
|
||||||
|
> The "Studierendenwerk Frankfurt am Main" is marking up its menus
|
||||||
|
> from now on with the so-called "Umweltscore," the environment score.
|
||||||
|
> Based on this rating, you can see the impact your meal choice would have on our climate.
|
||||||
|
|
||||||
|
## Further improvements
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
The performance while navigating around the app has been heavily improved and requires less data to work.
|
||||||
|
|
||||||
|
### Calendar
|
||||||
|
|
||||||
|
The calendar sections have new names:
|
||||||
|
|
||||||
|
- The _calendar_ shows appointments on specific days
|
||||||
|
- The _week overview_ is a schedule with all events that repeat (e.g. lectures)
|
||||||
|
- The _single events_ show all appointments that don't repeat (e.g. exams)
|
||||||
|
|
||||||
|
### My App
|
||||||
|
|
||||||
|
The "my courses" section has been revamped,
|
||||||
|
and now shows events for the next days and with more detail.
|
||||||
15
backend/backend/config/f-u/version-history/2.5.0.de.md
Normal file
15
backend/backend/config/f-u/version-history/2.5.0.de.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Goethe-Uni App 2.5
|
||||||
|
|
||||||
|
Die Goethe-Uni App ist noch besser geworden!
|
||||||
|
|
||||||
|
## Komplett neue Kartenansicht
|
||||||
|
|
||||||
|
Wir haben die Karte überarbeitet, um eine klarere und schnellere Übersicht zu bieten.
|
||||||
|
|
||||||
|
## Deutschlandticket mit an Bord
|
||||||
|
|
||||||
|
Wenn du das Upgrade des Semesterticket zum Deutschlandticket gemacht hast und eingeloggt bist, findet es sich jetzt auch in der App.
|
||||||
|
|
||||||
|
## Bibliotheksdienste sind wieder voll funktionsfähig
|
||||||
|
|
||||||
|
Aufgrund einiger Adhoc-Änderungen im Bibliothekssystem haben wir die App so angepasst, dass sie damit umgehen kann.
|
||||||
15
backend/backend/config/f-u/version-history/2.5.0.en.md
Normal file
15
backend/backend/config/f-u/version-history/2.5.0.en.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Goethe-Uni App 2.5
|
||||||
|
|
||||||
|
The Goethe-Uni App got even better!
|
||||||
|
|
||||||
|
## Completely new map view
|
||||||
|
|
||||||
|
We overhauled the map to offer you a clearer and faster and overview.
|
||||||
|
|
||||||
|
## Deutschlandticket included
|
||||||
|
|
||||||
|
If you upgraded your Semesterticket to a Deutschlandticket it will now reside in the App if you are logged in.
|
||||||
|
|
||||||
|
## Library services are fully functional again
|
||||||
|
|
||||||
|
Due to some adhoc changes in the library system we adjusted the app to handle them properly.
|
||||||
6
backend/backend/config/f-u/version-history/index.js
Normal file
6
backend/backend/config/f-u/version-history/index.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import {versions} from '../../default/tools/version.js';
|
||||||
|
|
||||||
|
/** @type {import('@openstapps/core').SCAppVersionInfo[]} */
|
||||||
|
const versionHistory = await versions(import.meta.url);
|
||||||
|
|
||||||
|
export default versionHistory;
|
||||||
@@ -5,18 +5,18 @@ if [ -z $GITLAB_CI ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
( STAPPS_LOG_LEVEL=31 STAPPS_EXIT_LEVEL=8 NODE_CONFIG_ENV=elasticsearch NODE_ENV=integration-test ALLOW_NO_TRANSPORT=true ES_ADDR=http://$ES_HOST:9200 node app.js ) & backend_pid=$!
|
( STAPPS_LOG_LEVEL=31 STAPPS_EXIT_LEVEL=8 NODE_CONFIG_ENV=elasticsearch NODE_ENV=integration-test ALLOW_NO_TRANSPORT=true ES_ADDR=http://$ES_HOST:9200 node app.js ) & backend_pid=$!
|
||||||
( e2e-connector http://$BACKEND_HOST:3000 --reportPath coverage/integration-report-junit.xml --waiton tcp:$BACKEND_HOST:3000 --samples node_modules/@openstapps/core/test/resources/indexable ) & e2e_pid=$!
|
( openstapps-api e2e http://$BACKEND_HOST:3000 --reportPath coverage/integration-report-junit.xml --waiton tcp:$BACKEND_HOST:3000 --samples node_modules/@openstapps/core/test/resources/indexable ) & api_cli_pid=$!
|
||||||
|
|
||||||
## Check output codes
|
## Check output codes
|
||||||
# api-cli output defines passing the test
|
# api-cli output defines passing the test
|
||||||
# backend should not exit early
|
# backend should not exit early
|
||||||
|
|
||||||
wait $e2e_pid
|
wait $api_cli_pid
|
||||||
e2e_exit=$?
|
api_cli_exit=$?
|
||||||
wait $backend_pid
|
wait $backend_pid
|
||||||
backend_exit=$?
|
backend_exit=$?
|
||||||
|
|
||||||
if [ "$e2e_exit" -eq "0" ]; then
|
if [ "$api_cli_exit" -eq "0" ]; then
|
||||||
echo "FINISHED";
|
echo "FINISHED";
|
||||||
exit;
|
exit;
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/backend",
|
"name": "@openstapps/backend",
|
||||||
"description": "A reference implementation for a StApps backend",
|
"description": "A reference implementation for a StApps backend",
|
||||||
"version": "3.0.1",
|
"version": "4.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
"build": "tsup-node",
|
"build": "tsup-node",
|
||||||
"build:docker": "docker build -t openstapps:backend ../../.deploy/backend",
|
"build:docker": "docker build -t openstapps:backend ../../.deploy/backend",
|
||||||
"deploy": "pnpm --prod --filter=@openstapps/backend deploy ../../.deploy/backend",
|
"deploy": "pnpm --prod --filter=@openstapps/backend deploy ../../.deploy/backend",
|
||||||
|
"dev": "tsup --watch --onSuccess \"pnpm run start\"",
|
||||||
"format": "prettier . -c --ignore-path ../../.gitignore",
|
"format": "prettier . -c --ignore-path ../../.gitignore",
|
||||||
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
|
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
|
||||||
"lint": "tsc --noEmit && eslint --ext .ts src/",
|
"lint": "tsc --noEmit && eslint --ext .ts src/",
|
||||||
@@ -42,31 +43,29 @@
|
|||||||
"test:unit": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true STAPPS_LOG_LEVEL=0 mocha --exit"
|
"test:unit": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true STAPPS_LOG_LEVEL=0 mocha --exit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@elastic/elasticsearch": "8.10.0",
|
"@elastic/elasticsearch": "8.14.1",
|
||||||
"@openstapps/core": "workspace:*",
|
"@openstapps/core": "workspace:*",
|
||||||
"@openstapps/core-validator": "workspace:*",
|
"@openstapps/core-tools": "workspace:*",
|
||||||
"@openstapps/logger": "workspace:*",
|
"@openstapps/logger": "workspace:*",
|
||||||
"@types/body-parser": "1.19.2",
|
"@types/body-parser": "1.19.6",
|
||||||
"@types/cors": "2.8.13",
|
"@types/cors": "2.8.13",
|
||||||
"@types/express": "4.17.17",
|
"@types/express": "4.17.17",
|
||||||
"@types/geojson": "1.0.6",
|
"@types/geojson": "1.0.6",
|
||||||
"@types/node": "18.15.3",
|
"@types/node": "22.15.31",
|
||||||
"@types/node-cron": "3.0.7",
|
"@types/node-cron": "3.0.7",
|
||||||
"@types/nodemailer": "6.4.7",
|
"@types/nodemailer": "6.4.7",
|
||||||
"@types/promise-queue": "2.2.0",
|
"@types/promise-queue": "2.2.0",
|
||||||
"@types/uuid": "8.3.4",
|
"@types/uuid": "8.3.4",
|
||||||
"ajv": "8.12.0",
|
"body-parser": "1.20.3",
|
||||||
"ajv-formats": "2.1.1",
|
|
||||||
"body-parser": "1.20.2",
|
|
||||||
"cors": "2.8.5",
|
"cors": "2.8.5",
|
||||||
"cosmiconfig": "8.1.3",
|
"cosmiconfig": "8.1.3",
|
||||||
"deepmerge": "4.3.1",
|
"deepmerge": "4.3.1",
|
||||||
"express": "4.18.2",
|
"express": "4.21.2",
|
||||||
"express-prom-bundle": "6.6.0",
|
"express-prom-bundle": "6.6.0",
|
||||||
"express-promise-router": "4.1.1",
|
"express-promise-router": "4.1.1",
|
||||||
"got": "12.6.0",
|
"got": "12.6.0",
|
||||||
"moment": "2.29.4",
|
"moment": "2.30.1",
|
||||||
"morgan": "1.10.0",
|
"morgan": "1.10.1",
|
||||||
"nock": "13.3.1",
|
"nock": "13.3.1",
|
||||||
"node-cache": "5.1.2",
|
"node-cache": "5.1.2",
|
||||||
"node-cron": "3.0.2",
|
"node-cron": "3.0.2",
|
||||||
@@ -76,32 +75,42 @@
|
|||||||
"uuid": "8.3.2"
|
"uuid": "8.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@openstapps/e2e-connector": "workspace:*",
|
"@openstapps/api-cli": "workspace:*",
|
||||||
"@openstapps/eslint-config": "workspace:*",
|
"@openstapps/eslint-config": "workspace:*",
|
||||||
"@openstapps/prettier-config": "workspace:*",
|
"@openstapps/prettier-config": "workspace:*",
|
||||||
"@openstapps/tsconfig": "workspace:*",
|
"@openstapps/tsconfig": "workspace:*",
|
||||||
"@testdeck/mocha": "0.3.3",
|
"@testdeck/mocha": "0.3.3",
|
||||||
"@types/chai": "4.3.5",
|
"@types/chai": "4.3.20",
|
||||||
"@types/chai-as-promised": "7.1.5",
|
"@types/chai-as-promised": "7.1.8",
|
||||||
"@types/mocha": "10.0.1",
|
"@types/mocha": "10.0.10",
|
||||||
"@types/morgan": "1.9.4",
|
"@types/morgan": "1.9.10",
|
||||||
"@types/sinon": "10.0.14",
|
"@types/sinon": "10.0.14",
|
||||||
"@types/sinon-express-mock": "1.3.9",
|
"@types/sinon-express-mock": "1.3.9",
|
||||||
"@types/supertest": "2.0.12",
|
"@types/supertest": "2.0.12",
|
||||||
"c8": "7.14.0",
|
"c8": "10.1.3",
|
||||||
"chai": "4.3.7",
|
"chai": "4.5.0",
|
||||||
"chai-as-promised": "7.1.1",
|
"chai-as-promised": "7.1.2",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"get-port": "5.1.1",
|
"get-port": "5.1.1",
|
||||||
"mocha": "10.2.0",
|
"mocha": "10.8.2",
|
||||||
"mocha-junit-reporter": "2.2.0",
|
"mocha-junit-reporter": "2.2.0",
|
||||||
"mocked-env": "1.3.5",
|
"mocked-env": "1.3.5",
|
||||||
"sinon": "15.0.4",
|
"sinon": "15.0.4",
|
||||||
"sinon-express-mock": "2.2.1",
|
"sinon-express-mock": "2.2.1",
|
||||||
"supertest": "6.3.3",
|
"supertest": "6.3.3",
|
||||||
"ts-node": "10.9.1",
|
"ts-node": "10.9.2",
|
||||||
"tsup": "7.2.0",
|
"tsup": "8.5.0",
|
||||||
"typescript": "5.2.2"
|
"typescript": "5.4.2"
|
||||||
|
},
|
||||||
|
"tsup": {
|
||||||
|
"entry": [
|
||||||
|
"src/cli.ts"
|
||||||
|
],
|
||||||
|
"sourcemap": true,
|
||||||
|
"clean": true,
|
||||||
|
"target": "es2022",
|
||||||
|
"format": "esm",
|
||||||
|
"outDir": "lib"
|
||||||
},
|
},
|
||||||
"prettier": "@openstapps/prettier-config",
|
"prettier": "@openstapps/prettier-config",
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ import {Logger} from '@openstapps/logger';
|
|||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import {Express} from 'express';
|
import {Express} from 'express';
|
||||||
import morgan from 'morgan';
|
import morgan from 'morgan';
|
||||||
import {DEFAULT_TIMEOUT, isTestEnvironment, mailer, plugins} from './common.js';
|
import path from 'path';
|
||||||
|
import {DEFAULT_TIMEOUT, isTestEnvironment, mailer, plugins, validator} from './common.js';
|
||||||
import {getPrometheusMiddleware} from './middleware/prometheus.js';
|
import {getPrometheusMiddleware} from './middleware/prometheus.js';
|
||||||
import {MailQueue} from './notification/mail-queue.js';
|
import {MailQueue} from './notification/mail-queue.js';
|
||||||
import {bulkAddRouter} from './routes/bulk-add-route.js';
|
import {bulkAddRouter} from './routes/bulk-add-route.js';
|
||||||
@@ -38,7 +39,7 @@ import {virtualPluginRoute} from './routes/virtual-plugin-route.js';
|
|||||||
import {BulkStorage} from './storage/bulk-storage.js';
|
import {BulkStorage} from './storage/bulk-storage.js';
|
||||||
import {DatabaseConstructor} from './storage/database.js';
|
import {DatabaseConstructor} from './storage/database.js';
|
||||||
import {backendConfig} from './config.js';
|
import {backendConfig} from './config.js';
|
||||||
import {validator} from './validator.js';
|
import {fileURLToPath} from 'url';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the backend
|
* Configure the backend
|
||||||
@@ -142,8 +143,20 @@ export async function configureApp(app: Express, databases: {[name: string]: Dat
|
|||||||
request.on('data', chunkGatherer).on('end', endCallback);
|
request.on('data', chunkGatherer).on('end', endCallback);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!validator.validate(backendConfig, 'SCConfigFile')) {
|
// validate config file
|
||||||
throw new Error(`Validation of config file failed. Errors were: ${JSON.stringify(validator.errors)}`);
|
const directory = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
await validator.addSchemas(
|
||||||
|
path.join(directory, '..', 'node_modules', '@openstapps', 'core', 'lib', 'schema'),
|
||||||
|
);
|
||||||
|
|
||||||
|
// validate the config file
|
||||||
|
const configValidation = validator.validate(backendConfig, 'SCConfigFile');
|
||||||
|
|
||||||
|
// validation failed
|
||||||
|
if (configValidation.errors.length > 0) {
|
||||||
|
throw new Error(
|
||||||
|
`Validation of config file failed. Errors were: ${JSON.stringify(configValidation.errors)}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if a database name was given
|
// check if a database name was given
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {SCPluginMetaData} from '@openstapps/core';
|
import {SCPluginMetaData} from '@openstapps/core';
|
||||||
|
import {Validator} from '@openstapps/core-tools';
|
||||||
import {BackendTransport} from './notification/backend-transport.js';
|
import {BackendTransport} from './notification/backend-transport.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +22,11 @@ import {BackendTransport} from './notification/backend-transport.js';
|
|||||||
*/
|
*/
|
||||||
export const mailer = BackendTransport.getTransportInstance();
|
export const mailer = BackendTransport.getTransportInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A validator instance to check if something is a valid JSON object (e.g. a request or a thing)
|
||||||
|
*/
|
||||||
|
export const validator = new Validator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides information if the backend is executed in the "test" (non-production) environment
|
* Provides information if the backend is executed in the "test" (non-production) environment
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import {cosmiconfig, PublicExplorer} from 'cosmiconfig';
|
|||||||
import {SCConfigFile} from '@openstapps/core';
|
import {SCConfigFile} from '@openstapps/core';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import deepmerge from 'deepmerge';
|
import deepmerge from 'deepmerge';
|
||||||
|
import {Logger} from '@openstapps/logger';
|
||||||
|
|
||||||
const fallbackNamespace = 'default';
|
const fallbackNamespace = 'default';
|
||||||
const configPath = 'config';
|
const configPath = 'config';
|
||||||
@@ -23,31 +24,25 @@ function configLoader(moduleName: string): PublicExplorer {
|
|||||||
* Find and load a config file
|
* Find and load a config file
|
||||||
*/
|
*/
|
||||||
async function findConfig<T>(moduleName: string, namespace = fallbackNamespace): Promise<T> {
|
async function findConfig<T>(moduleName: string, namespace = fallbackNamespace): Promise<T> {
|
||||||
return configLoader(moduleName)
|
const config = await configLoader(moduleName).search(path.posix.join('.', configPath, namespace));
|
||||||
.search(path.posix.join('.', configPath, namespace))
|
|
||||||
.then(it => it!.config as T)
|
|
||||||
.catch(() =>
|
|
||||||
configLoader(moduleName)
|
|
||||||
.search(path.posix.join('.', configPath, fallbackNamespace))
|
|
||||||
.then(it => it!.config),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (config) {
|
||||||
* Loads a config file
|
Logger.info(`Using ${namespace} config for ${moduleName}`);
|
||||||
*/
|
return config.config;
|
||||||
async function loadConfig<T>(moduleName: string): Promise<T> {
|
} else {
|
||||||
const namespace = process.env.NODE_APP_INSTANCE;
|
Logger.info(`Using ${fallbackNamespace} config for ${moduleName}`);
|
||||||
const database = process.env.NODE_CONFIG_ENV;
|
return configLoader(moduleName)
|
||||||
|
.search(path.posix.join('.', configPath, fallbackNamespace))
|
||||||
const config = await findConfig<T>(moduleName, namespace);
|
.then(it => it!.config);
|
||||||
if (database) {
|
|
||||||
const databaseConfig = await findConfig<T>(database, namespace);
|
|
||||||
return deepmerge(config, databaseConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const backendConfig = await loadConfig<SCConfigFile>('backend');
|
const namespace = process.env.NODE_APP_INSTANCE;
|
||||||
export const prometheusConfig = await loadConfig<unknown>('prometheus');
|
const database = process.env.NODE_CONFIG_ENV;
|
||||||
|
|
||||||
|
export const prometheusConfig = await findConfig<unknown>('prometheus', namespace);
|
||||||
|
|
||||||
|
const backendConfigWithoutDatabase = await findConfig<SCConfigFile>('backend', namespace);
|
||||||
|
export const backendConfig = database
|
||||||
|
? deepmerge(backendConfigWithoutDatabase, await findConfig<never>(database, namespace))
|
||||||
|
: backendConfigWithoutDatabase;
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ import {
|
|||||||
SCRoute,
|
SCRoute,
|
||||||
SCValidationErrorResponse,
|
SCValidationErrorResponse,
|
||||||
} from '@openstapps/core';
|
} from '@openstapps/core';
|
||||||
|
import {ValidationError} from '@openstapps/core-tools/src/types/validator.js';
|
||||||
import {Logger} from '@openstapps/logger';
|
import {Logger} from '@openstapps/logger';
|
||||||
import {Application, Router} from 'express';
|
import {Application, Router} from 'express';
|
||||||
import PromiseRouter from 'express-promise-router';
|
import PromiseRouter from 'express-promise-router';
|
||||||
import {isTestEnvironment} from '../common.js';
|
import {isTestEnvironment, validator} from '../common.js';
|
||||||
import {isHttpMethod} from './http-types.js';
|
import {isHttpMethod} from './http-types.js';
|
||||||
import {validator} from '../validator.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a router from a route class and a handler function which implements the logic
|
* Creates a router from a route class and a handler function which implements the logic
|
||||||
@@ -56,8 +56,11 @@ export function createRoute<REQUESTTYPE, RETURNTYPE>(
|
|||||||
// create a route handler for the given HTTP method
|
// create a route handler for the given HTTP method
|
||||||
route[verb](async (request, response) => {
|
route[verb](async (request, response) => {
|
||||||
try {
|
try {
|
||||||
if (!validator.validate(request.body, routeClass.requestBodyName as never)) {
|
// validate request
|
||||||
const error = new SCValidationErrorResponse(validator.errors as unknown[], isTestEnvironment);
|
const requestValidation = validator.validate(request.body, routeClass.requestBodyName);
|
||||||
|
|
||||||
|
if (requestValidation.errors.length > 0) {
|
||||||
|
const error = new SCValidationErrorResponse(requestValidation.errors, isTestEnvironment);
|
||||||
response.status(error.statusCode);
|
response.status(error.statusCode);
|
||||||
response.json(error);
|
response.json(error);
|
||||||
await Logger.error(error);
|
await Logger.error(error);
|
||||||
@@ -65,13 +68,17 @@ export function createRoute<REQUESTTYPE, RETURNTYPE>(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handlerResponse = await handler(request.body as REQUESTTYPE, request.app, request.params);
|
// hand over request to handler with path parameters
|
||||||
|
const handlerResponse = await handler(request.body, request.app, request.params);
|
||||||
|
|
||||||
if (!validator.validate(handlerResponse, routeClass.responseBodyName)) {
|
// validate response generated by handler
|
||||||
const validationError = new SCValidationErrorResponse(
|
const responseErrors: ValidationError[] = validator.validate(
|
||||||
validator.errors as unknown[],
|
handlerResponse,
|
||||||
isTestEnvironment,
|
routeClass.responseBodyName,
|
||||||
);
|
).errors;
|
||||||
|
|
||||||
|
if (responseErrors.length > 0) {
|
||||||
|
const validationError = new SCValidationErrorResponse(responseErrors, isTestEnvironment);
|
||||||
// The validation error is not caused by faulty user input, but through an error that originates somewhere in
|
// The validation error is not caused by faulty user input, but through an error that originates somewhere in
|
||||||
// the backend, therefore we use this "stacked" error.
|
// the backend, therefore we use this "stacked" error.
|
||||||
const internalServerError = new SCInternalServerErrorResponse(validationError, isTestEnvironment);
|
const internalServerError = new SCInternalServerErrorResponse(validationError, isTestEnvironment);
|
||||||
|
|||||||
@@ -13,12 +13,12 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {SCInternalServerErrorResponse, SCPluginMetaData, SCValidationErrorResponse} from '@openstapps/core';
|
import {SCInternalServerErrorResponse, SCPluginMetaData, SCValidationErrorResponse} from '@openstapps/core';
|
||||||
import {Request} from 'express';
|
import {Request} from 'express';
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
import {isTestEnvironment} from '../common.js';
|
import {isTestEnvironment, validator} from '../common.js';
|
||||||
import {backendConfig} from '../config.js';
|
import {backendConfig} from '../config.js';
|
||||||
import {validator} from '../validator.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic route function used to proxy actual requests to plugins
|
* Generic route function used to proxy actual requests to plugins
|
||||||
@@ -28,9 +28,10 @@ import {validator} from '../validator.js';
|
|||||||
*/
|
*/
|
||||||
export async function virtualPluginRoute(request: Request, plugin: SCPluginMetaData): Promise<object> {
|
export async function virtualPluginRoute(request: Request, plugin: SCPluginMetaData): Promise<object> {
|
||||||
try {
|
try {
|
||||||
if (!validator.validate(request.body, plugin.requestSchema)) {
|
const requestValidation = validator.validate(request.body, plugin.requestSchema);
|
||||||
|
if (requestValidation.errors.length > 0) {
|
||||||
// noinspection ExceptionCaughtLocallyJS
|
// noinspection ExceptionCaughtLocallyJS
|
||||||
throw new SCValidationErrorResponse(validator.errors as unknown[], isTestEnvironment);
|
throw new SCValidationErrorResponse(requestValidation.errors, isTestEnvironment);
|
||||||
}
|
}
|
||||||
// send the request to the plugin (forward the body) and save the response
|
// send the request to the plugin (forward the body) and save the response
|
||||||
const response = await got.post(plugin.route.replaceAll(/^\//gi, ''), {
|
const response = await got.post(plugin.route.replaceAll(/^\//gi, ''), {
|
||||||
@@ -42,9 +43,10 @@ export async function virtualPluginRoute(request: Request, plugin: SCPluginMetaD
|
|||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
});
|
});
|
||||||
const responseBody = response.body;
|
const responseBody = response.body;
|
||||||
if (!validator.validate(responseBody, plugin.responseSchema)) {
|
const responseValidation = validator.validate(responseBody, plugin.responseSchema);
|
||||||
|
if (responseValidation.errors.length > 0) {
|
||||||
// noinspection ExceptionCaughtLocallyJS
|
// noinspection ExceptionCaughtLocallyJS
|
||||||
throw new SCValidationErrorResponse(validator.errors as unknown[], isTestEnvironment);
|
throw new SCValidationErrorResponse(responseValidation.errors, isTestEnvironment);
|
||||||
}
|
}
|
||||||
return responseBody as object;
|
return responseBody as object;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -13,15 +13,34 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {SCConfigFile, SCSearchQuery, SCSearchResponse, SCThings, SCUuid} from '@openstapps/core';
|
import {
|
||||||
|
SCConfigFile,
|
||||||
|
SCPlace,
|
||||||
|
SCPlaceWithoutReferences,
|
||||||
|
SCSearchQuery,
|
||||||
|
SCSearchResponse,
|
||||||
|
SCThingWithCategoriesWithoutReferences,
|
||||||
|
SCThings,
|
||||||
|
SCUuid,
|
||||||
|
} from '@openstapps/core';
|
||||||
import {MailQueue} from '../notification/mail-queue.js';
|
import {MailQueue} from '../notification/mail-queue.js';
|
||||||
import {Bulk} from './bulk-storage.js';
|
import {Bulk} from './bulk-storage.js';
|
||||||
|
import {FeatureCollection, Point, Polygon} from 'geojson';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance of a database
|
* Creates an instance of a database
|
||||||
*/
|
*/
|
||||||
export type DatabaseConstructor = new (config: SCConfigFile, mailQueue?: MailQueue) => Database;
|
export type DatabaseConstructor = new (config: SCConfigFile, mailQueue?: MailQueue) => Database;
|
||||||
|
|
||||||
|
export type SupplementaryGeoJSON = FeatureCollection<Point | Polygon, SupplementaryGeoJSONThing>;
|
||||||
|
export type SupplementaryGeoJSONThing = Pick<
|
||||||
|
Extract<SCThings, SCPlace>,
|
||||||
|
Exclude<
|
||||||
|
keyof SCPlaceWithoutReferences | keyof SCThingWithCategoriesWithoutReferences<never, never>,
|
||||||
|
'geo' | 'origin' | 'translations'
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines what one database class needs to have defined
|
* Defines what one database class needs to have defined
|
||||||
*/
|
*/
|
||||||
@@ -82,4 +101,9 @@ export interface Database {
|
|||||||
* @param params Parameters which form a search query to search the backend data
|
* @param params Parameters which form a search query to search the backend data
|
||||||
*/
|
*/
|
||||||
search(parameters: SCSearchQuery): Promise<SCSearchResponse>;
|
search(parameters: SCSearchQuery): Promise<SCSearchResponse>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get geo info for display on a map
|
||||||
|
*/
|
||||||
|
geo(): Promise<SupplementaryGeoJSON>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ import {Logger} from '@openstapps/logger';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import {MailQueue} from '../../notification/mail-queue.js';
|
import {MailQueue} from '../../notification/mail-queue.js';
|
||||||
import {Bulk} from '../bulk-storage.js';
|
import {Bulk} from '../bulk-storage.js';
|
||||||
import {Database} from '../database.js';
|
import {Database, SupplementaryGeoJSON, SupplementaryGeoJSONThing} from '../database.js';
|
||||||
import {parseAggregations} from './aggregations.js';
|
import {parseAggregations} from './aggregations.js';
|
||||||
import * as Monitoring from './monitoring.js';
|
import * as Monitoring from './monitoring.js';
|
||||||
import {buildQuery} from './query/query.js';
|
import {buildQuery} from './query/query.js';
|
||||||
import {buildSort} from './query/sort.js';
|
import {buildSort} from './query/sort.js';
|
||||||
import {putTemplate} from './templating.js';
|
import {aggregations, putTemplate} from './templating.js';
|
||||||
import {
|
import {
|
||||||
ElasticsearchConfig,
|
ElasticsearchConfig,
|
||||||
ElasticsearchQueryDisMaxConfig,
|
ElasticsearchQueryDisMaxConfig,
|
||||||
@@ -46,7 +46,7 @@ import {
|
|||||||
} from './util/index.js';
|
} from './util/index.js';
|
||||||
import {noUndefined} from './util/no-undefined.js';
|
import {noUndefined} from './util/no-undefined.js';
|
||||||
import {retryCatch, RetryOptions} from './util/retry.js';
|
import {retryCatch, RetryOptions} from './util/retry.js';
|
||||||
import config from '@openstapps/core/elasticsearch.json' assert {type: 'json'};
|
import {Feature, Point, Polygon} from 'geojson';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A database interface for elasticsearch
|
* A database interface for elasticsearch
|
||||||
@@ -85,7 +85,10 @@ export class Elasticsearch implements Database {
|
|||||||
* @param config an assembled config file
|
* @param config an assembled config file
|
||||||
* @param mailQueue a mail queue for monitoring
|
* @param mailQueue a mail queue for monitoring
|
||||||
*/
|
*/
|
||||||
constructor(private readonly config: SCConfigFile, mailQueue?: MailQueue) {
|
constructor(
|
||||||
|
private readonly config: SCConfigFile,
|
||||||
|
mailQueue?: MailQueue,
|
||||||
|
) {
|
||||||
if (config.internal.database === undefined || typeof config.internal.database.version !== 'string') {
|
if (config.internal.database === undefined || typeof config.internal.database.version !== 'string') {
|
||||||
throw new TypeError('Database version is undefined. Check your config file');
|
throw new TypeError('Database version is undefined. Check your config file');
|
||||||
}
|
}
|
||||||
@@ -371,7 +374,7 @@ export class Elasticsearch implements Database {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const response: SearchResponse<SCThings> = await this.client.search({
|
const response: SearchResponse<SCThings> = await this.client.search({
|
||||||
...config.search,
|
aggs: aggregations,
|
||||||
query: buildQuery(parameters, this.config, esConfig),
|
query: buildQuery(parameters, this.config, esConfig),
|
||||||
from: parameters.from,
|
from: parameters.from,
|
||||||
index: ACTIVE_INDICES_ALIAS,
|
index: ACTIVE_INDICES_ALIAS,
|
||||||
@@ -403,4 +406,49 @@ export class Elasticsearch implements Database {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async geo(): Promise<SupplementaryGeoJSON> {
|
||||||
|
const searchResponse = await this.client.search<Extract<SCThings, {geo: unknown}>>({
|
||||||
|
body: {
|
||||||
|
query: {
|
||||||
|
exists: {
|
||||||
|
field: 'geo',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
from: 0,
|
||||||
|
allow_no_indices: true,
|
||||||
|
index: ACTIVE_INDICES_ALIAS,
|
||||||
|
size: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: 'FeatureCollection',
|
||||||
|
features: searchResponse.hits.hits
|
||||||
|
.map(thing => {
|
||||||
|
return thing._source?.geo
|
||||||
|
? ({
|
||||||
|
id: Number(thing._source.identifiers?.['OSM']) || undefined,
|
||||||
|
type: 'Feature',
|
||||||
|
geometry: thing._source.geo.polygon ?? thing._source.geo.point,
|
||||||
|
properties: {
|
||||||
|
name: thing._source.name,
|
||||||
|
sameAs: thing._source.sameAs,
|
||||||
|
image: thing._source.image,
|
||||||
|
alternateNames: thing._source.alternateNames,
|
||||||
|
description: thing._source.description,
|
||||||
|
identifiers: thing._source.identifiers,
|
||||||
|
categories: thing._source.categories,
|
||||||
|
categorySpecificValues: thing._source.categorySpecificValues,
|
||||||
|
openingHours: thing._source.openingHours,
|
||||||
|
address: thing._source.address,
|
||||||
|
uid: thing._source.uid,
|
||||||
|
type: thing._source.type,
|
||||||
|
},
|
||||||
|
} satisfies Feature<Polygon | Point, SupplementaryGeoJSONThing>)
|
||||||
|
: undefined;
|
||||||
|
})
|
||||||
|
.filter(noUndefined),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export function buildDistanceFilter(
|
|||||||
): QueryDslSpecificQueryContainer<'geo_distance'> {
|
): QueryDslSpecificQueryContainer<'geo_distance'> {
|
||||||
const geoObject: QueryDslGeoDistanceQuery = {
|
const geoObject: QueryDslGeoDistanceQuery = {
|
||||||
distance: `${filter.arguments.distance}m`,
|
distance: `${filter.arguments.distance}m`,
|
||||||
[`${filter.arguments.field}.point.coordinates`]: {
|
[`${filter.arguments.field}.point`]: {
|
||||||
lat: filter.arguments.position[1],
|
lat: filter.arguments.position[1],
|
||||||
lon: filter.arguments.position[0],
|
lon: filter.arguments.position[0],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,14 +19,29 @@ import {QueryDslSpecificQueryContainer} from '../../types/util.js';
|
|||||||
* Converts a geo filter to elasticsearch syntax
|
* Converts a geo filter to elasticsearch syntax
|
||||||
* @param filter A search filter for the retrieval of the data
|
* @param filter A search filter for the retrieval of the data
|
||||||
*/
|
*/
|
||||||
export function buildGeoFilter(filter: SCGeoFilter): QueryDslSpecificQueryContainer<'geo_shape'> {
|
export function buildGeoFilter(filter: SCGeoFilter): QueryDslSpecificQueryContainer<'bool'> {
|
||||||
return {
|
return {
|
||||||
geo_shape: {
|
bool: {
|
||||||
ignore_unmapped: true,
|
should: [
|
||||||
[`${filter.arguments.field}.polygon`]: {
|
{
|
||||||
shape: filter.arguments.shape,
|
geo_shape: {
|
||||||
relation: filter.arguments.spatialRelation,
|
ignore_unmapped: true,
|
||||||
},
|
[`${filter.arguments.field}.polygon`]: {
|
||||||
|
shape: filter.arguments.shape,
|
||||||
|
relation: filter.arguments.spatialRelation,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} satisfies QueryDslSpecificQueryContainer<'geo_shape'>,
|
||||||
|
{
|
||||||
|
geo_shape: {
|
||||||
|
ignore_unmapped: true,
|
||||||
|
[`${filter.arguments.field}.point`]: {
|
||||||
|
shape: filter.arguments.shape,
|
||||||
|
relation: filter.arguments.spatialRelation,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} satisfies QueryDslSpecificQueryContainer<'geo_shape'>,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,16 +21,31 @@ import {QueryDslSpecificQueryContainer} from '../../types/util.js';
|
|||||||
*/
|
*/
|
||||||
export function buildValueFilter(
|
export function buildValueFilter(
|
||||||
filter: SCSearchValueFilter,
|
filter: SCSearchValueFilter,
|
||||||
): QueryDslSpecificQueryContainer<'term'> | QueryDslSpecificQueryContainer<'terms'> {
|
):
|
||||||
return Array.isArray(filter.arguments.value)
|
| QueryDslSpecificQueryContainer<'exists'>
|
||||||
? {
|
| QueryDslSpecificQueryContainer<'term'>
|
||||||
terms: {
|
| QueryDslSpecificQueryContainer<'terms'> {
|
||||||
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
switch (typeof filter.arguments.value) {
|
||||||
|
case 'undefined': {
|
||||||
|
return {
|
||||||
|
exists: {
|
||||||
|
field: filter.arguments.field,
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
: {
|
}
|
||||||
|
case 'string': {
|
||||||
|
return {
|
||||||
term: {
|
term: {
|
||||||
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
case 'object': {
|
||||||
|
return {
|
||||||
|
terms: {
|
||||||
|
[`${filter.arguments.field}.raw`]: filter.arguments.value,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export function buildDistanceSort(sort: SCDistanceSort): SortOptions {
|
|||||||
mode: 'avg',
|
mode: 'avg',
|
||||||
order: sort.order,
|
order: sort.order,
|
||||||
unit: 'm',
|
unit: 'm',
|
||||||
[`${sort.arguments.field}.point.coordinates`]: {
|
[`${sort.arguments.field}.point`]: {
|
||||||
lat: sort.arguments.position[1],
|
lat: sort.arguments.position[1],
|
||||||
lon: sort.arguments.position[0],
|
lon: sort.arguments.position[0],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,7 +15,19 @@
|
|||||||
*/
|
*/
|
||||||
import {Client} from '@elastic/elasticsearch';
|
import {Client} from '@elastic/elasticsearch';
|
||||||
import {SCThingType} from '@openstapps/core';
|
import {SCThingType} from '@openstapps/core';
|
||||||
import config from '@openstapps/core/elasticsearch.json' assert {type: 'json'};
|
import type {AggregationSchema} from '@openstapps/core/lib/mappings/aggregations.json.js';
|
||||||
|
import type {ElasticsearchTemplateCollection} from '@openstapps/core/lib/mappings/mappings.json.js';
|
||||||
|
import {readFileSync} from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const mappingsPath = path.resolve('node_modules', '@openstapps', 'core', 'lib', 'mappings');
|
||||||
|
|
||||||
|
export const mappings = JSON.parse(
|
||||||
|
readFileSync(path.resolve(mappingsPath, 'mappings.json'), 'utf8'),
|
||||||
|
) as ElasticsearchTemplateCollection;
|
||||||
|
export const aggregations = JSON.parse(
|
||||||
|
readFileSync(path.resolve(mappingsPath, 'aggregations.json'), 'utf8'),
|
||||||
|
) as AggregationSchema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares all indices
|
* Prepares all indices
|
||||||
@@ -28,7 +40,7 @@ export async function putTemplate(client: Client, type: SCThingType) {
|
|||||||
const sanitizedType = `template_${type.replaceAll(/\s/g, '_')}`;
|
const sanitizedType = `template_${type.replaceAll(/\s/g, '_')}`;
|
||||||
|
|
||||||
return client.indices.putTemplate({
|
return client.indices.putTemplate({
|
||||||
body: config.mappings[sanitizedType],
|
body: mappings[sanitizedType],
|
||||||
name: sanitizedType,
|
name: sanitizedType,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
import {Validator} from '@openstapps/core-validator';
|
|
||||||
|
|
||||||
export const validator = new Validator();
|
|
||||||
@@ -22,7 +22,7 @@ import http from 'http';
|
|||||||
import {MailQueue} from '../src/notification/mail-queue.js';
|
import {MailQueue} from '../src/notification/mail-queue.js';
|
||||||
import {Bulk, BulkStorage} from '../src/storage/bulk-storage.js';
|
import {Bulk, BulkStorage} from '../src/storage/bulk-storage.js';
|
||||||
import getPort from 'get-port';
|
import getPort from 'get-port';
|
||||||
import {Database} from '../src/storage/database.js';
|
import {Database, SupplementaryGeoJSON} from '../src/storage/database.js';
|
||||||
import {v4} from 'uuid';
|
import {v4} from 'uuid';
|
||||||
import {backendConfig} from '../src/config.js';
|
import {backendConfig} from '../src/config.js';
|
||||||
import {getIndexUID} from '../src/storage/elasticsearch/util/index.js';
|
import {getIndexUID} from '../src/storage/elasticsearch/util/index.js';
|
||||||
@@ -58,7 +58,6 @@ export async function startApp(): Promise<Express> {
|
|||||||
* An elasticsearch mock
|
* An elasticsearch mock
|
||||||
*/
|
*/
|
||||||
export class ElasticsearchMock implements Database {
|
export class ElasticsearchMock implements Database {
|
||||||
// @ts-expect-error never read
|
|
||||||
private bulk: Bulk | undefined;
|
private bulk: Bulk | undefined;
|
||||||
|
|
||||||
private storageMock = new Map<string, SCThings>();
|
private storageMock = new Map<string, SCThings>();
|
||||||
@@ -67,6 +66,10 @@ export class ElasticsearchMock implements Database {
|
|||||||
// Nothing to do here
|
// Nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
geo(): Promise<SupplementaryGeoJSON> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
bulkCreated(bulk: Bulk): Promise<void> {
|
bulkCreated(bulk: Bulk): Promise<void> {
|
||||||
this.bulk = bulk;
|
this.bulk = bulk;
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
|
SCBook,
|
||||||
SCBulkAddRoute,
|
SCBulkAddRoute,
|
||||||
SCBulkDoneRoute,
|
SCBulkDoneRoute,
|
||||||
SCBulkRequest,
|
SCBulkRequest,
|
||||||
@@ -23,29 +24,30 @@ import {
|
|||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {bulk, DEFAULT_TEST_TIMEOUT} from '../common.js';
|
import {bulk, DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||||
import {testApp} from '../tests-setup.js';
|
import {testApp} from '../tests-setup.js';
|
||||||
import {readFile} from 'fs/promises';
|
|
||||||
import {v4} from 'uuid';
|
import {v4} from 'uuid';
|
||||||
|
import bookFile from '@openstapps/core/test/resources/indexable/Book.2.json' with {type: 'json'};
|
||||||
|
|
||||||
const book = JSON.parse(
|
const book = bookFile.instance as SCBook;
|
||||||
await readFile('node_modules/@openstapps/core/test/resources/indexable/Book.2.json', 'utf8'),
|
|
||||||
).instance;
|
|
||||||
|
|
||||||
describe('Bulk routes', async function () {
|
describe('Bulk routes', async function () {
|
||||||
// increase timeout for the suite
|
// increase timeout for the suite
|
||||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||||
|
|
||||||
const request: SCBulkRequest = {
|
let request: SCBulkRequest;
|
||||||
expiration: bulk.expiration,
|
let bulkRoute: SCBulkRoute;
|
||||||
source: bulk.source,
|
let bulkAddRoute: SCBulkAddRoute;
|
||||||
type: bulk.type,
|
let bulkDoneRoute: SCBulkDoneRoute;
|
||||||
};
|
|
||||||
const bulkRoute = new SCBulkRoute();
|
|
||||||
const bulkAddRoute = new SCBulkAddRoute();
|
|
||||||
const bulkDoneRoute = new SCBulkDoneRoute();
|
|
||||||
|
|
||||||
// afterEach(async function() {
|
before(function () {
|
||||||
// TODO: Delete saved bulks
|
request = {
|
||||||
// });
|
expiration: bulk.expiration,
|
||||||
|
source: bulk.source,
|
||||||
|
type: bulk.type,
|
||||||
|
};
|
||||||
|
bulkRoute = new SCBulkRoute();
|
||||||
|
bulkAddRoute = new SCBulkAddRoute();
|
||||||
|
bulkDoneRoute = new SCBulkDoneRoute();
|
||||||
|
});
|
||||||
|
|
||||||
it('should create bulk', async function () {
|
it('should create bulk', async function () {
|
||||||
const {status, body, error} = await testApp
|
const {status, body, error} = await testApp
|
||||||
|
|||||||
@@ -21,7 +21,12 @@ import {expect} from 'chai';
|
|||||||
describe('Index route', async function () {
|
describe('Index route', async function () {
|
||||||
// increase timeout for the suite
|
// increase timeout for the suite
|
||||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||||
const indexRoute = new SCIndexRoute();
|
|
||||||
|
let indexRoute: SCIndexRoute;
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
indexRoute = new SCIndexRoute();
|
||||||
|
});
|
||||||
|
|
||||||
it('should respond with both app and backend configuration', async function () {
|
it('should respond with both app and backend configuration', async function () {
|
||||||
const request: SCIndexRequest = {};
|
const request: SCIndexRequest = {};
|
||||||
|
|||||||
@@ -30,15 +30,11 @@ import chaiAsPromised from 'chai-as-promised';
|
|||||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||||
import {testApp} from '../tests-setup.js';
|
import {testApp} from '../tests-setup.js';
|
||||||
import {backendConfig} from '../../src/config.js';
|
import {backendConfig} from '../../src/config.js';
|
||||||
import {readFile} from 'fs/promises';
|
import registerRequest from '@openstapps/core/test/resources/PluginRegisterRequest.1.json' with {type: 'json'};
|
||||||
|
|
||||||
// for using promises in expectations (to.eventually.be...)
|
// for using promises in expectations (to.eventually.be...)
|
||||||
use(chaiAsPromised);
|
use(chaiAsPromised);
|
||||||
|
|
||||||
const registerRequest = JSON.parse(
|
|
||||||
await readFile('node_modules/@openstapps/core/test/resources/PluginRegisterRequest.1.json', 'utf8'),
|
|
||||||
);
|
|
||||||
|
|
||||||
// cast it because of "TS2322: Type 'string' is not assignable to type '"add"'"
|
// cast it because of "TS2322: Type 'string' is not assignable to type '"add"'"
|
||||||
export const registerAddRequest: SCPluginAdd = registerRequest.instance as SCPluginAdd;
|
export const registerAddRequest: SCPluginAdd = registerRequest.instance as SCPluginAdd;
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ import bodyParser from 'body-parser';
|
|||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {Application} from 'express';
|
import {Application} from 'express';
|
||||||
|
import {validator} from '../../src/common.js';
|
||||||
import {createRoute} from '../../src/routes/route.js';
|
import {createRoute} from '../../src/routes/route.js';
|
||||||
import express, {Express} from 'express';
|
import express, {Express} from 'express';
|
||||||
import supertest from 'supertest';
|
import supertest from 'supertest';
|
||||||
import {Logger} from '@openstapps/logger';
|
import {Logger} from '@openstapps/logger';
|
||||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||||
import {validator} from '../../src/validator.js';
|
|
||||||
|
|
||||||
interface ReturnType {
|
interface ReturnType {
|
||||||
foo: boolean;
|
foo: boolean;
|
||||||
@@ -47,8 +47,8 @@ describe('Create route', async function () {
|
|||||||
const statusCodeSuccess = 222;
|
const statusCodeSuccess = 222;
|
||||||
const bodySuccess = {foo: true};
|
const bodySuccess = {foo: true};
|
||||||
const sandbox = sinon.createSandbox();
|
const sandbox = sinon.createSandbox();
|
||||||
const validationError = new SCValidationErrorResponse([]);
|
let validationError: SCValidationErrorResponse;
|
||||||
const internalServerError = new SCInternalServerErrorResponse();
|
let internalServerError: SCInternalServerErrorResponse;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
app = express();
|
app = express();
|
||||||
@@ -64,6 +64,9 @@ describe('Create route', async function () {
|
|||||||
handler = (_request, _app) => {
|
handler = (_request, _app) => {
|
||||||
return Promise.resolve(bodySuccess);
|
return Promise.resolve(bodySuccess);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
validationError = new SCValidationErrorResponse([]);
|
||||||
|
internalServerError = new SCInternalServerErrorResponse();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
@@ -78,7 +81,8 @@ describe('Create route', async function () {
|
|||||||
|
|
||||||
it('should complain (throw an error) if used method is other than defined in the route creation', async function () {
|
it('should complain (throw an error) if used method is other than defined in the route creation', async function () {
|
||||||
const methodNotAllowedError = new SCMethodNotAllowedErrorResponse();
|
const methodNotAllowedError = new SCMethodNotAllowedErrorResponse();
|
||||||
sandbox.stub(validator, 'validate').returns(true);
|
// @ts-expect-error not assignable
|
||||||
|
sandbox.stub(validator, 'validate').returns({errors: []});
|
||||||
let error: any = {};
|
let error: any = {};
|
||||||
sandbox.stub(Logger, 'warn').callsFake(error_ => {
|
sandbox.stub(Logger, 'warn').callsFake(error_ => {
|
||||||
error = error_;
|
error = error_;
|
||||||
@@ -96,7 +100,8 @@ describe('Create route', async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should provide a route which returns handler response and success code', async function () {
|
it('should provide a route which returns handler response and success code', async function () {
|
||||||
sandbox.stub(validator, 'validate').returns(true);
|
// @ts-expect-error not assignable
|
||||||
|
sandbox.stub(validator, 'validate').returns({errors: []});
|
||||||
const router = createRoute<any, any>(routeClass, handler);
|
const router = createRoute<any, any>(routeClass, handler);
|
||||||
app.use(router);
|
app.use(router);
|
||||||
|
|
||||||
@@ -113,7 +118,8 @@ describe('Create route', async function () {
|
|||||||
app.use(router);
|
app.use(router);
|
||||||
const startApp = supertest(app);
|
const startApp = supertest(app);
|
||||||
const validatorStub = sandbox.stub(validator, 'validate');
|
const validatorStub = sandbox.stub(validator, 'validate');
|
||||||
validatorStub.withArgs(body, routeClass.requestBodyName).returns(false);
|
// @ts-expect-error not assignable
|
||||||
|
validatorStub.withArgs(body, routeClass.requestBodyName).returns({errors: [new Error('Foo Error')]});
|
||||||
|
|
||||||
const response = await startApp
|
const response = await startApp
|
||||||
.post(routeClass.urlPath)
|
.post(routeClass.urlPath)
|
||||||
@@ -128,8 +134,12 @@ describe('Create route', async function () {
|
|||||||
const router = createRoute<any, any>(routeClass, handler);
|
const router = createRoute<any, any>(routeClass, handler);
|
||||||
await app.use(router);
|
await app.use(router);
|
||||||
const startApp = supertest(app);
|
const startApp = supertest(app);
|
||||||
const validatorStub = sandbox.stub(validator, 'validate').returns(false);
|
// @ts-expect-error not assignable
|
||||||
validatorStub.withArgs(bodySuccess, routeClass.responseBodyName).returns(false);
|
const validatorStub = sandbox.stub(validator, 'validate').returns({errors: []});
|
||||||
|
validatorStub
|
||||||
|
.withArgs(bodySuccess, routeClass.responseBodyName)
|
||||||
|
// @ts-expect-error not assignable
|
||||||
|
.returns({errors: [new Error('Foo Error')]});
|
||||||
|
|
||||||
const response = await startApp.post(routeClass.urlPath).send();
|
const response = await startApp.post(routeClass.urlPath).send();
|
||||||
|
|
||||||
@@ -170,7 +180,8 @@ describe('Create route', async function () {
|
|||||||
await app.use(router);
|
await app.use(router);
|
||||||
const startApp = supertest(app);
|
const startApp = supertest(app);
|
||||||
|
|
||||||
sandbox.stub(validator, 'validate').returns(false);
|
// @ts-expect-error not assignable
|
||||||
|
sandbox.stub(validator, 'validate').returns({errors: []});
|
||||||
|
|
||||||
const response = await startApp.post(routeClass.urlPath).send();
|
const response = await startApp.post(routeClass.urlPath).send();
|
||||||
|
|
||||||
@@ -205,7 +216,8 @@ describe('Create route', async function () {
|
|||||||
await app.use(router);
|
await app.use(router);
|
||||||
const startApp = supertest(app);
|
const startApp = supertest(app);
|
||||||
|
|
||||||
sandbox.stub(validator, 'validate').returns(false);
|
// @ts-expect-error not assignable
|
||||||
|
sandbox.stub(validator, 'validate').returns({errors: []});
|
||||||
|
|
||||||
const response = await startApp.post(routeClass.urlPath).send();
|
const response = await startApp.post(routeClass.urlPath).send();
|
||||||
|
|
||||||
|
|||||||
@@ -29,14 +29,21 @@ import {backendConfig} from '../../src/config.js';
|
|||||||
describe('Search route', async function () {
|
describe('Search route', async function () {
|
||||||
// increase timeout for the suite
|
// increase timeout for the suite
|
||||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||||
const searchRoute = new SCSearchRoute();
|
let searchRoute: SCSearchRoute;
|
||||||
const multiSearchRoute = new SCMultiSearchRoute();
|
let multiSearchRoute: SCMultiSearchRoute;
|
||||||
const syntaxError = new SCSyntaxErrorResponse('Foo Message');
|
let syntaxError: SCSyntaxErrorResponse;
|
||||||
const methodNotAllowedError = new SCMethodNotAllowedErrorResponse();
|
let methodNotAllowedError: SCMethodNotAllowedErrorResponse;
|
||||||
const tooManyRequestsError = new SCTooManyRequestsErrorResponse();
|
let tooManyRequestsError: SCTooManyRequestsErrorResponse;
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
searchRoute = new SCSearchRoute();
|
||||||
|
multiSearchRoute = new SCMultiSearchRoute();
|
||||||
|
syntaxError = new SCSyntaxErrorResponse('Foo Message');
|
||||||
|
methodNotAllowedError = new SCMethodNotAllowedErrorResponse();
|
||||||
|
tooManyRequestsError = new SCTooManyRequestsErrorResponse();
|
||||||
|
});
|
||||||
|
|
||||||
it('should reject GET, PUT with a valid search query', async function () {
|
it('should reject GET, PUT with a valid search query', async function () {
|
||||||
// const expectedParams = JSON.parse(JSON.stringify(defaultParams));
|
|
||||||
const {status} = await testApp.get('/search').set('Accept', 'application/json').send({
|
const {status} = await testApp.get('/search').set('Accept', 'application/json').send({
|
||||||
query: 'Some search terms',
|
query: 'Some search terms',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,23 +13,25 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import {SCThingUpdateRoute} from '@openstapps/core';
|
import {SCBook, SCThingUpdateRoute} from '@openstapps/core';
|
||||||
import chaiAsPromised from 'chai-as-promised';
|
import chaiAsPromised from 'chai-as-promised';
|
||||||
import {bulkStorageMock, DEFAULT_TEST_TIMEOUT} from '../common.js';
|
import {bulkStorageMock, DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||||
import {expect, use} from 'chai';
|
import {expect, use} from 'chai';
|
||||||
import {testApp} from '../tests-setup.js';
|
import {testApp} from '../tests-setup.js';
|
||||||
import {readFile} from 'fs/promises';
|
import bookFile from '@openstapps/core/test/resources/indexable/Book.1.json' with {type: 'json'};
|
||||||
|
|
||||||
use(chaiAsPromised);
|
use(chaiAsPromised);
|
||||||
|
|
||||||
const book = JSON.parse(
|
const book = bookFile.instance as SCBook;
|
||||||
await readFile('node_modules/@openstapps/core/test/resources/indexable/Book.1.json', 'utf8'),
|
|
||||||
).instance;
|
|
||||||
|
|
||||||
describe('Thing update route', async function () {
|
describe('Thing update route', async function () {
|
||||||
// increase timeout for the suite
|
// increase timeout for the suite
|
||||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||||
const thingUpdateRoute = new SCThingUpdateRoute();
|
let thingUpdateRoute: SCThingUpdateRoute;
|
||||||
|
|
||||||
|
before(function () {
|
||||||
|
thingUpdateRoute = new SCThingUpdateRoute();
|
||||||
|
});
|
||||||
|
|
||||||
it('should update a thing', async function () {
|
it('should update a thing', async function () {
|
||||||
const thingUpdateRouteurlPath = thingUpdateRoute.urlPath
|
const thingUpdateRouteurlPath = thingUpdateRoute.urlPath
|
||||||
|
|||||||
@@ -22,12 +22,11 @@ import got, {Options} from 'got';
|
|||||||
import nock from 'nock';
|
import nock from 'nock';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import {mockReq} from 'sinon-express-mock';
|
import {mockReq} from 'sinon-express-mock';
|
||||||
import {plugins} from '../../src/common.js';
|
import {plugins, validator} from '../../src/common.js';
|
||||||
import {virtualPluginRoute} from '../../src/routes/virtual-plugin-route.js';
|
import {virtualPluginRoute} from '../../src/routes/virtual-plugin-route.js';
|
||||||
import {DEFAULT_TEST_TIMEOUT, FooError} from '../common.js';
|
import {DEFAULT_TEST_TIMEOUT, FooError} from '../common.js';
|
||||||
import {registerAddRequest} from './plugin-register-route.spec.js';
|
import {registerAddRequest} from './plugin-register-route.spec.js';
|
||||||
import {testApp} from '../tests-setup.js';
|
import {testApp} from '../tests-setup.js';
|
||||||
import {validator} from '../../src/validator.js';
|
|
||||||
|
|
||||||
use(chaiAsPromised);
|
use(chaiAsPromised);
|
||||||
|
|
||||||
@@ -72,7 +71,8 @@ describe('Virtual plugin routes', async function () {
|
|||||||
// spy the post method of got
|
// spy the post method of got
|
||||||
// @ts-expect-error not assignable
|
// @ts-expect-error not assignable
|
||||||
const gotStub = sandbox.stub(got, 'post').returns({body: {}});
|
const gotStub = sandbox.stub(got, 'post').returns({body: {}});
|
||||||
sandbox.stub(validator, 'validate').returns(true);
|
// @ts-expect-error not assignable
|
||||||
|
sandbox.stub(validator, 'validate').returns({errors: []});
|
||||||
const request_ = mockReq(request);
|
const request_ = mockReq(request);
|
||||||
|
|
||||||
await virtualPluginRoute(request_, plugin);
|
await virtualPluginRoute(request_, plugin);
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ import mockedEnv from 'mocked-env';
|
|||||||
import sinon, {SinonStub} from 'sinon';
|
import sinon, {SinonStub} from 'sinon';
|
||||||
import {removeInvalidAliasChars} from '../../../src/storage/elasticsearch/util/alias.js';
|
import {removeInvalidAliasChars} from '../../../src/storage/elasticsearch/util/alias.js';
|
||||||
import {MailQueue} from '../../../src/notification/mail-queue.js';
|
import {MailQueue} from '../../../src/notification/mail-queue.js';
|
||||||
|
import {aggregations} from '../../../src/storage/elasticsearch/templating.js';
|
||||||
import {Elasticsearch} from '../../../src/storage/elasticsearch/elasticsearch.js';
|
import {Elasticsearch} from '../../../src/storage/elasticsearch/elasticsearch.js';
|
||||||
import {bulk, DEFAULT_TEST_TIMEOUT, getTransport, getIndex} from '../../common.js';
|
import {bulk, DEFAULT_TEST_TIMEOUT, getTransport, getIndex} from '../../common.js';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {backendConfig} from '../../../src/config.js';
|
import {backendConfig} from '../../../src/config.js';
|
||||||
import {readFile} from 'fs/promises';
|
|
||||||
import {
|
import {
|
||||||
ACTIVE_INDICES_ALIAS,
|
ACTIVE_INDICES_ALIAS,
|
||||||
getIndexUID,
|
getIndexUID,
|
||||||
@@ -49,7 +49,11 @@ import {
|
|||||||
} from '../../../src/storage/elasticsearch/util/index.js';
|
} from '../../../src/storage/elasticsearch/util/index.js';
|
||||||
import cron from 'node-cron';
|
import cron from 'node-cron';
|
||||||
import {query} from './query.js';
|
import {query} from './query.js';
|
||||||
import {search} from '@openstapps/core/elasticsearch.json' assert {type: 'json'};
|
import messageFile from '@openstapps/core/test/resources/indexable/Message.1.json' with {type: 'json'};
|
||||||
|
import bookFile from '@openstapps/core/test/resources/indexable/Book.1.json' with {type: 'json'};
|
||||||
|
|
||||||
|
const message = messageFile.instance as SCMessage;
|
||||||
|
const book = bookFile.instance as SCBook;
|
||||||
|
|
||||||
use(chaiAsPromised);
|
use(chaiAsPromised);
|
||||||
|
|
||||||
@@ -60,13 +64,6 @@ function searchResponse<T>(...hits: SearchHit<T>[]): SearchResponse<T> {
|
|||||||
return {hits: {hits}, took: 0, timed_out: false, _shards: {total: 1, failed: 0, successful: 1}};
|
return {hits: {hits}, took: 0, timed_out: false, _shards: {total: 1, failed: 0, successful: 1}};
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = JSON.parse(
|
|
||||||
await readFile('node_modules/@openstapps/core/test/resources/indexable/Message.1.json', 'utf8'),
|
|
||||||
);
|
|
||||||
const book = JSON.parse(
|
|
||||||
await readFile('node_modules/@openstapps/core/test/resources/indexable/Book.1.json', 'utf8'),
|
|
||||||
);
|
|
||||||
|
|
||||||
describe('Elasticsearch', function () {
|
describe('Elasticsearch', function () {
|
||||||
// increase timeout for the suite
|
// increase timeout for the suite
|
||||||
this.timeout(DEFAULT_TEST_TIMEOUT);
|
this.timeout(DEFAULT_TEST_TIMEOUT);
|
||||||
@@ -74,8 +71,15 @@ describe('Elasticsearch', function () {
|
|||||||
|
|
||||||
before(function () {
|
before(function () {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('before');
|
|
||||||
sandbox.stub(fs, 'readFileSync').returns('{}');
|
sandbox.stub(fs, 'readFileSync').returns('{}');
|
||||||
|
sandbox.stub(backendConfig.internal.boostings.default[0], 'fields').value({
|
||||||
|
'academicTerms.acronym': {
|
||||||
|
'SS 2023': 1.05,
|
||||||
|
'WS 2023/24': 1.1,
|
||||||
|
'SoSe 2023': 1.05,
|
||||||
|
'WiSe 2023/24': 1.1,
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
after(function () {
|
after(function () {
|
||||||
sandbox.restore();
|
sandbox.restore();
|
||||||
@@ -131,7 +135,7 @@ describe('Elasticsearch', function () {
|
|||||||
expect(indexUID.length).to.be.equal(INDEX_UID_LENGTH);
|
expect(indexUID.length).to.be.equal(INDEX_UID_LENGTH);
|
||||||
// test starting and ending character
|
// test starting and ending character
|
||||||
expect(indexUID[0]).to.be.equal(bulk.uid[0]);
|
expect(indexUID[0]).to.be.equal(bulk.uid[0]);
|
||||||
expect(indexUID.at(-1)).to.be.equal(bulk.uid[INDEX_UID_LENGTH - 1]);
|
expect(indexUID[indexUID.length - 1]).to.be.equal(bulk.uid[INDEX_UID_LENGTH - 1]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide index name from the provided data', function () {
|
it('should provide index name from the provided data', function () {
|
||||||
@@ -445,7 +449,7 @@ describe('Elasticsearch', function () {
|
|||||||
_id: '',
|
_id: '',
|
||||||
_index: '',
|
_index: '',
|
||||||
_score: 0,
|
_score: 0,
|
||||||
_source: message as SCMessage,
|
_source: message,
|
||||||
};
|
};
|
||||||
sandbox.stub(es.client, 'search').resolves(searchResponse(foundObject));
|
sandbox.stub(es.client, 'search').resolves(searchResponse(foundObject));
|
||||||
|
|
||||||
@@ -475,7 +479,7 @@ describe('Elasticsearch', function () {
|
|||||||
const object: SearchHit<SCMessage> = {
|
const object: SearchHit<SCMessage> = {
|
||||||
_id: '',
|
_id: '',
|
||||||
_index: oldIndex,
|
_index: oldIndex,
|
||||||
_source: message as SCMessage,
|
_source: message,
|
||||||
};
|
};
|
||||||
sandbox.stub(es.client, 'search').resolves(searchResponse<SCMessage>(object));
|
sandbox.stub(es.client, 'search').resolves(searchResponse<SCMessage>(object));
|
||||||
sandbox.stub(es, 'prepareBulkWrite').resolves(index);
|
sandbox.stub(es, 'prepareBulkWrite').resolves(index);
|
||||||
@@ -489,7 +493,7 @@ describe('Elasticsearch', function () {
|
|||||||
sandbox.stub(es.client, 'create').resolves({result: 'not_found'} as CreateResponse);
|
sandbox.stub(es.client, 'create').resolves({result: 'not_found'} as CreateResponse);
|
||||||
|
|
||||||
await es.init();
|
await es.init();
|
||||||
return expect(es.post(message as SCMessage, bulk)).to.rejectedWith('creation');
|
return expect(es.post(message, bulk)).to.rejectedWith('creation');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new object', async function () {
|
it('should create a new object', async function () {
|
||||||
@@ -502,7 +506,7 @@ describe('Elasticsearch', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await es.init();
|
await es.init();
|
||||||
await es.post(message as SCMessage, bulk);
|
await es.post(message, bulk);
|
||||||
|
|
||||||
expect(createStub.called).to.be.true;
|
expect(createStub.called).to.be.true;
|
||||||
expect(caughtParameter.document).to.be.eql({
|
expect(caughtParameter.document).to.be.eql({
|
||||||
@@ -527,7 +531,7 @@ describe('Elasticsearch', function () {
|
|||||||
_id: '',
|
_id: '',
|
||||||
_index: getIndex(),
|
_index: getIndex(),
|
||||||
_score: 0,
|
_score: 0,
|
||||||
_source: message as SCMessage,
|
_source: message,
|
||||||
};
|
};
|
||||||
sandbox.stub(es.client, 'search').resolves(searchResponse());
|
sandbox.stub(es.client, 'search').resolves(searchResponse());
|
||||||
|
|
||||||
@@ -541,7 +545,7 @@ describe('Elasticsearch', function () {
|
|||||||
_id: '',
|
_id: '',
|
||||||
_index: getIndex(),
|
_index: getIndex(),
|
||||||
_score: 0,
|
_score: 0,
|
||||||
_source: message as SCMessage,
|
_source: message,
|
||||||
};
|
};
|
||||||
sandbox.stub(es.client, 'search').resolves(searchResponse(object));
|
sandbox.stub(es.client, 'search').resolves(searchResponse(object));
|
||||||
// @ts-expect-error unused
|
// @ts-expect-error unused
|
||||||
@@ -564,13 +568,13 @@ describe('Elasticsearch', function () {
|
|||||||
_id: '123',
|
_id: '123',
|
||||||
_index: getIndex(),
|
_index: getIndex(),
|
||||||
_score: 0,
|
_score: 0,
|
||||||
_source: message as SCMessage,
|
_source: message,
|
||||||
};
|
};
|
||||||
const objectBook: SearchHit<SCBook> = {
|
const objectBook: SearchHit<SCBook> = {
|
||||||
_id: '321',
|
_id: '321',
|
||||||
_index: getIndex(),
|
_index: getIndex(),
|
||||||
_score: 0,
|
_score: 0,
|
||||||
_source: book as SCBook,
|
_source: book,
|
||||||
};
|
};
|
||||||
const fakeEsAggregations = {
|
const fakeEsAggregations = {
|
||||||
'@all': {
|
'@all': {
|
||||||
@@ -679,7 +683,7 @@ describe('Elasticsearch', function () {
|
|||||||
await es.search(parameters);
|
await es.search(parameters);
|
||||||
|
|
||||||
expect(searchStub.firstCall.firstArg).to.be.deep.equal({
|
expect(searchStub.firstCall.firstArg).to.be.deep.equal({
|
||||||
...search,
|
aggs: aggregations,
|
||||||
query,
|
query,
|
||||||
allow_no_indices: true,
|
allow_no_indices: true,
|
||||||
sort: [{'name.sort': 'desc'}],
|
sort: [{'name.sort': 'desc'}],
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ describe('Query', function () {
|
|||||||
const expectedFilter: QueryDslSpecificQueryContainer<'geo_distance'> = {
|
const expectedFilter: QueryDslSpecificQueryContainer<'geo_distance'> = {
|
||||||
geo_distance: {
|
geo_distance: {
|
||||||
'distance': '1000m',
|
'distance': '1000m',
|
||||||
'geo.point.coordinates': {
|
'geo.point': {
|
||||||
lat: 8.123,
|
lat: 8.123,
|
||||||
lon: 50.123,
|
lon: 50.123,
|
||||||
},
|
},
|
||||||
@@ -479,18 +479,39 @@ describe('Query', function () {
|
|||||||
it('should build geo filter for shapes and points', function () {
|
it('should build geo filter for shapes and points', function () {
|
||||||
const filter = buildFilter(searchFilters.geoPoint);
|
const filter = buildFilter(searchFilters.geoPoint);
|
||||||
const expectedFilter = {
|
const expectedFilter = {
|
||||||
geo_shape: {
|
bool: {
|
||||||
'geo.polygon': {
|
should: [
|
||||||
relation: undefined,
|
{
|
||||||
shape: {
|
geo_shape: {
|
||||||
type: 'envelope',
|
'geo.polygon': {
|
||||||
coordinates: [
|
relation: undefined,
|
||||||
[50.123, 8.123],
|
shape: {
|
||||||
[50.123, 8.123],
|
coordinates: [
|
||||||
],
|
[50.123, 8.123],
|
||||||
|
[50.123, 8.123],
|
||||||
|
],
|
||||||
|
type: 'envelope',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'ignore_unmapped': true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
'ignore_unmapped': true,
|
geo_shape: {
|
||||||
|
'geo.point': {
|
||||||
|
relation: undefined,
|
||||||
|
shape: {
|
||||||
|
coordinates: [
|
||||||
|
[50.123, 8.123],
|
||||||
|
[50.123, 8.123],
|
||||||
|
],
|
||||||
|
type: 'envelope',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'ignore_unmapped': true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -500,18 +521,39 @@ describe('Query', function () {
|
|||||||
it('should build geo filter for shapes only', function () {
|
it('should build geo filter for shapes only', function () {
|
||||||
const filter = buildFilter(searchFilters.geoShape);
|
const filter = buildFilter(searchFilters.geoShape);
|
||||||
const expectedFilter = {
|
const expectedFilter = {
|
||||||
geo_shape: {
|
bool: {
|
||||||
'geo.polygon': {
|
should: [
|
||||||
relation: 'contains',
|
{
|
||||||
shape: {
|
geo_shape: {
|
||||||
type: 'envelope',
|
'geo.polygon': {
|
||||||
coordinates: [
|
relation: 'contains',
|
||||||
[50.123, 8.123],
|
shape: {
|
||||||
[50.123, 8.123],
|
coordinates: [
|
||||||
],
|
[50.123, 8.123],
|
||||||
|
[50.123, 8.123],
|
||||||
|
],
|
||||||
|
type: 'envelope',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'ignore_unmapped': true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
'ignore_unmapped': true,
|
geo_shape: {
|
||||||
|
'geo.point': {
|
||||||
|
relation: 'contains',
|
||||||
|
shape: {
|
||||||
|
coordinates: [
|
||||||
|
[50.123, 8.123],
|
||||||
|
[50.123, 8.123],
|
||||||
|
],
|
||||||
|
type: 'envelope',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'ignore_unmapped': true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -594,7 +636,7 @@ describe('Query', function () {
|
|||||||
'mode': 'avg',
|
'mode': 'avg',
|
||||||
'order': 'desc',
|
'order': 'desc',
|
||||||
'unit': 'm',
|
'unit': 'm',
|
||||||
'geo.point.coordinates': {
|
'geo.point': {
|
||||||
lat: 50.123,
|
lat: 50.123,
|
||||||
lon: 8.123,
|
lon: 8.123,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"extends": "@openstapps/tsconfig",
|
"extends": "@openstapps/tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false
|
||||||
"allowJs": true
|
},
|
||||||
}
|
"exclude": ["lib", "app.js"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
import {defineConfig} from 'tsup';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
entry: ['src/cli.ts'],
|
|
||||||
sourcemap: true,
|
|
||||||
clean: true,
|
|
||||||
target: 'esnext',
|
|
||||||
format: 'esm',
|
|
||||||
outDir: 'lib',
|
|
||||||
});
|
|
||||||
@@ -1,256 +0,0 @@
|
|||||||
# @openstapps/minimal-connector
|
|
||||||
|
|
||||||
## 3.0.0
|
|
||||||
|
|
||||||
### Major Changes
|
|
||||||
|
|
||||||
- 64caebaf: Move project to a turbo monorepo & pnpm
|
|
||||||
|
|
||||||
Internal dependencies are now defined using `"@openstapps/package": "workspace:*"`
|
|
||||||
|
|
||||||
- Removed extraneous files from packages
|
|
||||||
- `.npmrc`
|
|
||||||
- `.npmignore`
|
|
||||||
- `.mailmap`
|
|
||||||
- `.gitignore`
|
|
||||||
- `CONTRIBUTING.md`
|
|
||||||
- `LICENSE` (Project license file is added upon publishing, see [pnpm.io](https://pnpm.io/cli/publish))
|
|
||||||
- `package-lock.json`
|
|
||||||
- `.editorconfig`
|
|
||||||
- `.eslintrc.json` (moved eslint config to `package.json`)
|
|
||||||
- `.eslintignore`
|
|
||||||
- `.gitlab-ci.yml` (Most workflows are workspace-level)
|
|
||||||
- `.gitlab/**` (issue templates etc. are now workspace-level)
|
|
||||||
- `.dockerignore` (Docker files are determined by which files are deployed with `pnpm deploy`, as per `package.json/files`)
|
|
||||||
- TSConfig has been moved to its own package (You can now use `"extends": "@openstapps/tsconfig"`)
|
|
||||||
- Removed ESLint and Prettier peer dependency hell by injecting them through the `.pnpmfile.cjs`
|
|
||||||
- Added syncpack for keeping dependency versions in sync (and consistent key ordering in `package.json`)
|
|
||||||
- Replaced conventional changelog with changesets
|
|
||||||
- Apps with binaries now use a top level `app.js`
|
|
||||||
|
|
||||||
```js
|
|
||||||
#!/usr/bin/env node
|
|
||||||
import './lib/app.js';
|
|
||||||
```
|
|
||||||
|
|
||||||
- 64caebaf: Migrate to ESM
|
|
||||||
|
|
||||||
CommonJS is no longer supported in any capacity. To use the new
|
|
||||||
version, you will need to migrate your package to ESM.
|
|
||||||
We recommend using `tsup` and `Node 18`.
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- 64caebaf: Migrate package to Node 18
|
|
||||||
|
|
||||||
- Consumers of this package will need to migrate to Node 18 or
|
|
||||||
higher.
|
|
||||||
- Packages have been migrated from promisified `readFile` or
|
|
||||||
`readFileSync` towards `fs/promises`
|
|
||||||
- Packages use native `flatMap` now
|
|
||||||
|
|
||||||
- 64caebaf: Migrate build system to `tsup`
|
|
||||||
|
|
||||||
All packages now use an `index.ts` file to expose contents.
|
|
||||||
|
|
||||||
You will need to migrate paths from `import foo from '@scope/package/lib/foo` to `import foo from '@scope/package'`
|
|
||||||
|
|
||||||
### Minor Changes
|
|
||||||
|
|
||||||
- 64caebaf: Migrate tests to C8/Chai/Mocha
|
|
||||||
|
|
||||||
- `@testdeck` OOP testing has been removed.
|
|
||||||
- Tests have been unified
|
|
||||||
- CommonJS module mocking has been replaced through
|
|
||||||
refactoring of tests, as ES Modules cannot be mocked
|
|
||||||
(do yourself a favor and don't try to mock them)
|
|
||||||
- C8 now replaces NYC as a native coverage tool
|
|
||||||
|
|
||||||
- 64caebaf: Migrate away from `@krlwlfrt/async-pool`
|
|
||||||
|
|
||||||
```ts
|
|
||||||
import {mapAsyncLimit} from '@openstapps/collection-utils';
|
|
||||||
|
|
||||||
await mapAsyncLimit(
|
|
||||||
[1, 2, 3],
|
|
||||||
async it => {
|
|
||||||
await someNetworkRequest(it);
|
|
||||||
},
|
|
||||||
5,
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 64caebaf: Migrated changelogs to changeset format
|
|
||||||
|
|
||||||
```js
|
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
const path = 'packages/logger/CHANGELOG.md';
|
|
||||||
|
|
||||||
fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/^#+\s+\[/gm, '## ['));
|
|
||||||
```
|
|
||||||
|
|
||||||
- 98546a97: Migrate away from @openstapps/configuration
|
|
||||||
- 23481d0d: Update to TypeScript 5.1.6
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [98546a97]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [1f62b5c5]
|
|
||||||
- Updated dependencies [98546a97]
|
|
||||||
- Updated dependencies [23481d0d]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [0a7e6af1]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [98546a97]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- @openstapps/api@3.0.0
|
|
||||||
- @openstapps/logger@3.0.0
|
|
||||||
- @openstapps/core@3.0.0
|
|
||||||
|
|
||||||
## 3.0.0-next.4
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 23481d0d: Update to TypeScript 5.1.6
|
|
||||||
- Updated dependencies [23481d0d]
|
|
||||||
- @openstapps/logger@3.0.0-next.4
|
|
||||||
- @openstapps/core@3.0.0-next.4
|
|
||||||
- @openstapps/api@3.0.0-next.4
|
|
||||||
|
|
||||||
## 3.0.0-next.0
|
|
||||||
|
|
||||||
### Major Changes
|
|
||||||
|
|
||||||
- 64caebaf: Move project to a turbo monorepo & pnpm
|
|
||||||
|
|
||||||
Internal dependencies are now defined using `"@openstapps/package": "workspace:*"`
|
|
||||||
|
|
||||||
- Removed extraneous files from packages
|
|
||||||
- `.npmrc`
|
|
||||||
- `.npmignore`
|
|
||||||
- `.mailmap`
|
|
||||||
- `.gitignore`
|
|
||||||
- `CONTRIBUTING.md`
|
|
||||||
- `LICENSE` (Project license file is added upon publishing, see [pnpm.io](https://pnpm.io/cli/publish))
|
|
||||||
- `package-lock.json`
|
|
||||||
- `.editorconfig`
|
|
||||||
- `.eslintrc.json` (moved eslint config to `package.json`)
|
|
||||||
- `.eslintignore`
|
|
||||||
- `.gitlab-ci.yml` (Most workflows are workspace-level)
|
|
||||||
- `.gitlab/**` (issue templates etc. are now workspace-level)
|
|
||||||
- `.dockerignore` (Docker files are determined by which files are deployed with `pnpm deploy`, as per `package.json/files`)
|
|
||||||
- TSConfig has been moved to its own package (You can now use `"extends": "@openstapps/tsconfig"`)
|
|
||||||
- Removed ESLint and Prettier peer dependency hell by injecting them through the `.pnpmfile.cjs`
|
|
||||||
- Added syncpack for keeping dependency versions in sync (and consistent key ordering in `package.json`)
|
|
||||||
- Replaced conventional changelog with changesets
|
|
||||||
- Apps with binaries now use a top level `app.js`
|
|
||||||
|
|
||||||
```js
|
|
||||||
#!/usr/bin/env node
|
|
||||||
import './lib/app.js';
|
|
||||||
```
|
|
||||||
|
|
||||||
- 64caebaf: Migrate to ESM
|
|
||||||
|
|
||||||
CommonJS is no longer supported in any capacity. To use the new
|
|
||||||
version, you will need to migrate your package to ESM.
|
|
||||||
We recommend using `tsup` and `Node 18`.
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- 64caebaf: Migrate package to Node 18
|
|
||||||
|
|
||||||
- Consumers of this package will need to migrate to Node 18 or
|
|
||||||
higher.
|
|
||||||
- Packages have been migrated from promisified `readFile` or
|
|
||||||
`readFileSync` towards `fs/promises`
|
|
||||||
- Packages use native `flatMap` now
|
|
||||||
|
|
||||||
- 64caebaf: Migrate build system to `tsup`
|
|
||||||
|
|
||||||
All packages now use an `index.ts` file to expose contents.
|
|
||||||
|
|
||||||
You will need to migrate paths from `import foo from '@scope/package/lib/foo` to `import foo from '@scope/package'`
|
|
||||||
|
|
||||||
### Minor Changes
|
|
||||||
|
|
||||||
- 64caebaf: Migrate tests to C8/Chai/Mocha
|
|
||||||
|
|
||||||
- `@testdeck` OOP testing has been removed.
|
|
||||||
- Tests have been unified
|
|
||||||
- CommonJS module mocking has been replaced through
|
|
||||||
refactoring of tests, as ES Modules cannot be mocked
|
|
||||||
(do yourself a favor and don't try to mock them)
|
|
||||||
- C8 now replaces NYC as a native coverage tool
|
|
||||||
|
|
||||||
- 64caebaf: Migrate away from `@krlwlfrt/async-pool`
|
|
||||||
|
|
||||||
```ts
|
|
||||||
import {mapAsyncLimit} from '@openstapps/collection-utils';
|
|
||||||
|
|
||||||
await mapAsyncLimit(
|
|
||||||
[1, 2, 3],
|
|
||||||
async it => {
|
|
||||||
await someNetworkRequest(it);
|
|
||||||
},
|
|
||||||
5,
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- 64caebaf: Migrated changelogs to changeset format
|
|
||||||
|
|
||||||
```js
|
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
const path = 'packages/logger/CHANGELOG.md';
|
|
||||||
|
|
||||||
fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/^#+\s+\[/gm, '## ['));
|
|
||||||
```
|
|
||||||
|
|
||||||
- 98546a97: Migrate away from @openstapps/configuration
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [98546a97]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [98546a97]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [0a7e6af1]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- Updated dependencies [98546a97]
|
|
||||||
- Updated dependencies [64caebaf]
|
|
||||||
- @openstapps/api@3.0.0-next.0
|
|
||||||
- @openstapps/logger@3.0.0-next.0
|
|
||||||
- @openstapps/core@3.0.0-next.0
|
|
||||||
|
|
||||||
## [0.2.0](https://gitlab.com/openstapps/minimal-connector/compare/v0.1.0...v0.2.0) (2019-02-07)
|
|
||||||
|
|
||||||
## [0.1.0](https://gitlab.com/openstapps/minimal-connector/compare/v0.0.2...v0.1.0) (2019-01-30)
|
|
||||||
|
|
||||||
## [0.0.2](https://gitlab.com/openstapps/minimal-connector/compare/v0.0.1...v0.0.2) (2018-12-03)
|
|
||||||
|
|
||||||
## [0.0.1](https://gitlab.com/openstapps/minimal-connector/compare/d332f6e...v0.0.1) (2018-12-03)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
- add minimal connector ([d332f6e](https://gitlab.com/openstapps/minimal-connector/commit/d332f6e))
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM registry.gitlab.com/openstapps/openstapps/node-base
|
|
||||||
|
|
||||||
ADD . .
|
|
||||||
|
|
||||||
ENTRYPOINT ["node", "lib/cli.js"]
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# @openstapps/copy-connector
|
|
||||||
|
|
||||||
A default connector that copies data from one backend to another
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
import './lib/cli.js';
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@openstapps/copy-connector",
|
|
||||||
"description": "This is a minimal connector which serves as an example",
|
|
||||||
"version": "3.0.0",
|
|
||||||
"private": true,
|
|
||||||
"type": "module",
|
|
||||||
"license": "GPL-3.0-only",
|
|
||||||
"repository": "git@gitlab.com:openstapps/minimal-connector.git",
|
|
||||||
"author": "Anselm Stordeur <anselmstordeur@gmail.com>",
|
|
||||||
"contributors": [
|
|
||||||
"Jovan Krunić <jovan.krunic@gmail.com>",
|
|
||||||
"Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
|
|
||||||
"Michel Jonathan Schmitz <michel.schmitz1992@gmail.com>",
|
|
||||||
"Rainer Killinger <git@killinger.co>"
|
|
||||||
],
|
|
||||||
"bin": "app.js",
|
|
||||||
"files": [
|
|
||||||
"app.js",
|
|
||||||
"lib",
|
|
||||||
"Dockerfile",
|
|
||||||
"README.md",
|
|
||||||
"CHANGELOG.md"
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"build": "tsup-node",
|
|
||||||
"deploy": "pnpm --prod --filter=@openstapps/copy-connector deploy ../../.deploy/copy-connector",
|
|
||||||
"format": "prettier . -c --ignore-path ../../.gitignore",
|
|
||||||
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
|
|
||||||
"lint": "tsc --noEmit && eslint --ext .ts src/",
|
|
||||||
"lint:fix": "eslint --fix --ext .ts src/",
|
|
||||||
"test": "c8 --exclude src/cli.ts mocha --exit"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@openstapps/api": "workspace:*",
|
|
||||||
"@openstapps/core": "workspace:*",
|
|
||||||
"@openstapps/logger": "workspace:*",
|
|
||||||
"@types/cli-progress": "3.11.5",
|
|
||||||
"cli-progress": "3.12.0",
|
|
||||||
"commander": "10.0.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@openstapps/eslint-config": "workspace:*",
|
|
||||||
"@openstapps/prettier-config": "workspace:*",
|
|
||||||
"@openstapps/tsconfig": "workspace:*",
|
|
||||||
"@types/chai": "4.3.5",
|
|
||||||
"@types/chai-as-promised": "7.1.5",
|
|
||||||
"@types/chai-spies": "1.0.6",
|
|
||||||
"@types/mocha": "10.0.1",
|
|
||||||
"@types/node": "18.15.3",
|
|
||||||
"c8": "7.14.0",
|
|
||||||
"chai": "4.3.7",
|
|
||||||
"chai-as-promised": "7.1.1",
|
|
||||||
"chai-spies": "1.1.0",
|
|
||||||
"conventional-changelog-cli": "2.2.2",
|
|
||||||
"mocha": "10.2.0",
|
|
||||||
"mocha-junit-reporter": "2.2.0",
|
|
||||||
"nock": "13.3.1",
|
|
||||||
"ts-node": "10.9.1",
|
|
||||||
"tsup": "7.2.0",
|
|
||||||
"typescript": "5.2.2"
|
|
||||||
},
|
|
||||||
"tsup": {
|
|
||||||
"entry": [
|
|
||||||
"src/cli.ts"
|
|
||||||
],
|
|
||||||
"sourcemap": true,
|
|
||||||
"clean": true,
|
|
||||||
"format": "esm",
|
|
||||||
"outDir": "lib"
|
|
||||||
},
|
|
||||||
"prettier": "@openstapps/prettier-config",
|
|
||||||
"eslintConfig": {
|
|
||||||
"extends": [
|
|
||||||
"@openstapps"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018, 2019 StApps
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the Free
|
|
||||||
* Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* 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 General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
import {Logger} from '@openstapps/logger';
|
|
||||||
import {Command} from 'commander';
|
|
||||||
import {version} from '../package.json';
|
|
||||||
import {copy} from './copy.js';
|
|
||||||
import {SCThingType, STAPPS_CORE_VERSION} from '@openstapps/core';
|
|
||||||
import {Client, ConnectorClient, HttpClient} from '@openstapps/api';
|
|
||||||
|
|
||||||
new Command()
|
|
||||||
.command('run <backendURL> <origin> <licensePlate>')
|
|
||||||
.argument('<backendUrl>', 'The URL of the StApps deployment', 'http://localhost:3000')
|
|
||||||
.argument(
|
|
||||||
'<foreignBackendUrl>',
|
|
||||||
'The URL of the backend to copy the data from',
|
|
||||||
'https://mobile.server.uni-frankfurt.de',
|
|
||||||
)
|
|
||||||
.argument('<types>', 'The type (RegExp full match)', '.*')
|
|
||||||
.argument('<batchSize>', 'Batch Size', 100)
|
|
||||||
.version(version)
|
|
||||||
.action(async (backendUrl: string, foreignBackendUrl: string, types: string, batchSize: number) => {
|
|
||||||
const client = new HttpClient();
|
|
||||||
const apiIn = new Client(client, foreignBackendUrl, STAPPS_CORE_VERSION);
|
|
||||||
const apiOut = new ConnectorClient(client, backendUrl);
|
|
||||||
|
|
||||||
const indexResponse = await apiIn.handshake(STAPPS_CORE_VERSION);
|
|
||||||
const origin = new URL(foreignBackendUrl).host.replaceAll(/[^a-zA-Z0-9-]/g, '-');
|
|
||||||
const licensePlate = indexResponse.backend.namespace;
|
|
||||||
const source = `${licensePlate}-${origin}`;
|
|
||||||
|
|
||||||
for (const type of Object.values(SCThingType)) {
|
|
||||||
if (!new RegExp(`^${types}$`).test(type)) continue;
|
|
||||||
await copy(apiIn, apiOut, source, type, batchSize);
|
|
||||||
}
|
|
||||||
Logger.ok('Done');
|
|
||||||
})
|
|
||||||
.addHelpCommand()
|
|
||||||
.parse(process.argv);
|
|
||||||
@@ -1,5 +1,23 @@
|
|||||||
# @openstapps/database
|
# @openstapps/database
|
||||||
|
|
||||||
|
## 4.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- b40ba7ad: Updated Elasticsearch dependency
|
||||||
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- c8e29020: Update to Node 22
|
||||||
|
|
||||||
|
## 3.2.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 689ac68b: pin alpine version to 3.18 and add healthchecks
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM elasticsearch:8.4.2
|
FROM elasticsearch:8.14.3
|
||||||
|
|
||||||
EXPOSE 9200
|
EXPOSE 9200
|
||||||
EXPOSE 9300
|
EXPOSE 9300
|
||||||
@@ -14,4 +14,6 @@ RUN chown elasticsearch:elasticsearch config/elasticsearch.yml
|
|||||||
|
|
||||||
USER elasticsearch
|
USER elasticsearch
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=10s --timeout=10s --start-period=60s --retries=12 CMD curl --fail -s http://localhost:9200/ >/dev/null || exit 1
|
||||||
|
|
||||||
CMD ["/usr/share/elasticsearch/bin/elasticsearch"]
|
CMD ["/usr/share/elasticsearch/bin/elasticsearch"]
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ discovery.type: "single-node"
|
|||||||
cluster.routing.allocation.disk.threshold_enabled: false
|
cluster.routing.allocation.disk.threshold_enabled: false
|
||||||
network.bind_host: 0.0.0.0
|
network.bind_host: 0.0.0.0
|
||||||
xpack.security.enabled: false
|
xpack.security.enabled: false
|
||||||
|
ingest.geoip.downloader.enabled: false
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/database",
|
"name": "@openstapps/database",
|
||||||
"version": "3.0.0",
|
"version": "4.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"files": [
|
"files": [
|
||||||
"config",
|
"config",
|
||||||
"Dockerfile",
|
"Dockerfile",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
]
|
||||||
"scripts": {
|
|
||||||
"start": "docker run --rm -t -p 9200:9200 -p 9300:9300 $(docker build -q .)"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
import './lib/cli.js';
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2018-2022 Open StApps
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the Free
|
|
||||||
* Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* 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 General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
import {Logger} from '@openstapps/logger';
|
|
||||||
import {Command} from 'commander';
|
|
||||||
import {URL} from 'url';
|
|
||||||
import waitOn from 'wait-on';
|
|
||||||
import {HttpClient} from '@openstapps/api';
|
|
||||||
import {version} from '../package.json';
|
|
||||||
import {endToEndRun} from './end-to-end.js';
|
|
||||||
|
|
||||||
new Command()
|
|
||||||
.command('<to>')
|
|
||||||
.argument('<to>', 'The backend to test', url => new URL(url).toString(), 'http://localhost:3000')
|
|
||||||
.version(version)
|
|
||||||
.description(
|
|
||||||
'Run in end to end test mode. Indexing and afterwards retrieving all test files from @openstapp/core to the backend',
|
|
||||||
)
|
|
||||||
.option(
|
|
||||||
'-s --samples path',
|
|
||||||
'Path to @openstapp/core test files',
|
|
||||||
'./node_modules/@openstapps/core/test/resources/indexable',
|
|
||||||
)
|
|
||||||
.option('-w --waiton [resource]', 'wait-on resource parameter see "www.npmjs.com/wait-on"')
|
|
||||||
.option('-r --reportPath [reportPath]', 'JUnit Report Path')
|
|
||||||
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
||||||
.action(async (to: string, e2eCommand: {samples: string; waiton?: string; reportPath?: string}) => {
|
|
||||||
try {
|
|
||||||
if (typeof e2eCommand.waiton === 'string') {
|
|
||||||
Logger.info(`Waiting for availibilty of resource: ${e2eCommand.waiton}`);
|
|
||||||
await waitOn({
|
|
||||||
resources: [e2eCommand.waiton],
|
|
||||||
timeout: 300_000,
|
|
||||||
});
|
|
||||||
Logger.info(`Resource became available`);
|
|
||||||
}
|
|
||||||
await endToEndRun(new HttpClient(), {
|
|
||||||
to,
|
|
||||||
samplesLocation: e2eCommand.samples,
|
|
||||||
reportLocation: e2eCommand.reportPath,
|
|
||||||
});
|
|
||||||
Logger.ok('Done');
|
|
||||||
} catch (error) {
|
|
||||||
await Logger.error(error);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.addHelpCommand()
|
|
||||||
.parse(process.argv);
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import junit from 'junit-report-builder';
|
|
||||||
import {deepStrictEqual} from 'assert';
|
|
||||||
import {Logger} from '@openstapps/logger';
|
|
||||||
import {TestState} from './test-state.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares all samples (local and remote) with the same uid and throws if they're not deep equal
|
|
||||||
*/
|
|
||||||
export async function compareItems(state: TestState, suite: junit.TestSuite) {
|
|
||||||
for (const localThing of state.localItems.values()) {
|
|
||||||
await state.runTest(suite, `Should be the same for ${localThing.type} (${localThing.uid})`, async () => {
|
|
||||||
if (!state.remoteItems.has(localThing.uid)) {
|
|
||||||
throw new Error(`Did not retrieve expected SCThing with uid: ${localThing.uid}`);
|
|
||||||
}
|
|
||||||
const remoteThing = state.remoteItems.get(localThing.uid);
|
|
||||||
deepStrictEqual(remoteThing, localThing, `Unexpected difference between original and retrieved sample`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Logger.info(`All samples retrieved from the backend have been compared`);
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019-2022 Open StApps
|
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by the Free
|
|
||||||
* Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* 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 General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
import {Logger} from '@openstapps/logger';
|
|
||||||
import {HttpClientInterface} from '@openstapps/api';
|
|
||||||
import junit from 'junit-report-builder';
|
|
||||||
import {indexSamples} from './index-samples.js';
|
|
||||||
import {retrieveItems} from './retreive-items.js';
|
|
||||||
import {compareItems} from './compare-items.js';
|
|
||||||
import {E2EOptions, TestState} from './test-state.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function that can be used for integration tests.
|
|
||||||
* Adds all the SCThings that getItemsFromSamples() returns to the backend.
|
|
||||||
* Afterward, retrieves the items from backend and checks for differences with original ones.
|
|
||||||
*/
|
|
||||||
export async function endToEndRun(client: HttpClientInterface, options: E2EOptions): Promise<string[]> {
|
|
||||||
const state = new TestState(client, options);
|
|
||||||
const builder = junit.newBuilder();
|
|
||||||
|
|
||||||
await indexSamples(state, builder.testSuite().name('e2e index'));
|
|
||||||
Logger.info(`All samples have been indexed via the backend`);
|
|
||||||
|
|
||||||
await retrieveItems(state, builder.testSuite().name('e2e retrieve'));
|
|
||||||
Logger.info(`All samples have been retrieved from the backend`);
|
|
||||||
|
|
||||||
await compareItems(state, builder.testSuite().name('e2e compare'));
|
|
||||||
|
|
||||||
if (options.reportLocation) {
|
|
||||||
builder.writeTo(options.reportLocation);
|
|
||||||
}
|
|
||||||
await (state.errors.length > 0
|
|
||||||
? Logger.error(`\n${state.errors.length} failed test cases`)
|
|
||||||
: Logger.ok('All tests passed.'));
|
|
||||||
|
|
||||||
return state.errors;
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import {SCThings} from '@openstapps/core';
|
|
||||||
import {readdir, readFile} from 'fs/promises';
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all SCThings from the predefined core test json files
|
|
||||||
* @param samplesDirectory Filepath to the directory containing to the core test json files
|
|
||||||
* @returns an Array of all the SCThings specified for test usage
|
|
||||||
*/
|
|
||||||
export async function getItemsFromSamples<T extends SCThings>(samplesDirectory: string): Promise<T[]> {
|
|
||||||
const things: T[] = [];
|
|
||||||
try {
|
|
||||||
const fileNames = await readdir(samplesDirectory);
|
|
||||||
for (const fileName of fileNames) {
|
|
||||||
const filePath = path.join(samplesDirectory, fileName);
|
|
||||||
if (filePath.endsWith('.json')) {
|
|
||||||
const fileContent = await readFile(filePath, {encoding: 'utf8'});
|
|
||||||
const schemaObject = JSON.parse(fileContent);
|
|
||||||
if (schemaObject.errorNames.length === 0 && typeof schemaObject.instance.type === 'string') {
|
|
||||||
things.push(schemaObject.instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
return things;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import junit from 'junit-report-builder';
|
|
||||||
import {SCThings, SCThingType} from '@openstapps/core';
|
|
||||||
import {getItemsFromSamples} from './get-items-from-samples.js';
|
|
||||||
import {TestState} from './test-state.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to add all the SCThings that getItemsFromSamples() returns to the backend
|
|
||||||
*/
|
|
||||||
export async function indexSamples(state: TestState, suite: junit.TestSuite): Promise<void> {
|
|
||||||
const items = await getItemsFromSamples(state.options.samplesLocation);
|
|
||||||
|
|
||||||
if (items.length === 0) {
|
|
||||||
throw new Error('Could not index samples. None were retrieved from the file system.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// sort items by type
|
|
||||||
const itemMap: Map<SCThingType, SCThings[]> = new Map();
|
|
||||||
for (const item of items) {
|
|
||||||
if (!itemMap.has(item.type)) {
|
|
||||||
itemMap.set(item.type, []);
|
|
||||||
}
|
|
||||||
const itemsOfSameType = itemMap.get(item.type) as SCThings[];
|
|
||||||
itemsOfSameType.push(item);
|
|
||||||
itemMap.set(item.type, itemsOfSameType);
|
|
||||||
state.localItems.set(item.uid, item);
|
|
||||||
}
|
|
||||||
// add items depending on their type property with one type per bulk
|
|
||||||
for (const type of itemMap.keys()) {
|
|
||||||
await state.runTest(suite, `Should index ${type}`, async () =>
|
|
||||||
state.api.index(itemMap.get(type) as SCThings[], 'stapps-core-sample-data'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import junit from 'junit-report-builder';
|
|
||||||
import {SCSearchRequest} from '@openstapps/core';
|
|
||||||
import {TestState} from './test-state.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves all samples previously index using the api
|
|
||||||
*/
|
|
||||||
export async function retrieveItems(state: TestState, suite: junit.TestSuite): Promise<void> {
|
|
||||||
const singleItemSearchRequest: SCSearchRequest = {
|
|
||||||
filter: {
|
|
||||||
arguments: {
|
|
||||||
field: 'uid',
|
|
||||||
value: 'replace-me',
|
|
||||||
},
|
|
||||||
type: 'value',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
for (const {uid, type} of state.localItems.values()) {
|
|
||||||
await state.runTest(suite, `Should find ${type} (${uid})`, async () => {
|
|
||||||
singleItemSearchRequest.filter!.arguments.value = uid;
|
|
||||||
const searchResponse = await state.api.search(singleItemSearchRequest);
|
|
||||||
if (searchResponse.data.length !== 1) {
|
|
||||||
throw new Error(
|
|
||||||
`Search for single SCThing with uid: ${uid} returned ${searchResponse.data.length} results`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
state.remoteItems.set(uid, searchResponse.data[0]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
import {SCThings} from '@openstapps/core';
|
|
||||||
import {ConnectorClient, HttpClientInterface} from '@openstapps/api';
|
|
||||||
import {Logger} from '@openstapps/logger';
|
|
||||||
import junit from 'junit-report-builder';
|
|
||||||
|
|
||||||
export class TestState {
|
|
||||||
localItems = new Map<string, SCThings>();
|
|
||||||
|
|
||||||
remoteItems = new Map<string, SCThings>();
|
|
||||||
|
|
||||||
errors: string[] = [];
|
|
||||||
|
|
||||||
api: ConnectorClient;
|
|
||||||
|
|
||||||
constructor(client: HttpClientInterface, readonly options: E2EOptions) {
|
|
||||||
this.api = new ConnectorClient(client, options.to);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run a test
|
|
||||||
* @param suite The suite the test belongs to
|
|
||||||
* @param name The name of the test
|
|
||||||
* @param scope The scope in which the test is run
|
|
||||||
*/
|
|
||||||
async runTest(suite: junit.TestSuite, name: string, scope: () => Promise<void>) {
|
|
||||||
const testCase = suite.testCase().name(name);
|
|
||||||
process.stdout.addListener('data', testCase.standardOutput);
|
|
||||||
process.stderr.addListener('data', testCase.standardError);
|
|
||||||
|
|
||||||
const start = performance.now();
|
|
||||||
try {
|
|
||||||
await scope();
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
} catch (error: any) {
|
|
||||||
await Logger.error(error);
|
|
||||||
testCase.failure(error.message);
|
|
||||||
this.errors.push(error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
process.stdout.removeListener('data', testCase.standardOutput);
|
|
||||||
process.stderr.removeListener('data', testCase.standardError);
|
|
||||||
|
|
||||||
const end = performance.now();
|
|
||||||
testCase.time((end - start) / 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options to set up indexing core test files to backend
|
|
||||||
*/
|
|
||||||
export interface E2EOptions {
|
|
||||||
/**
|
|
||||||
* File path of the directory containing core test files
|
|
||||||
*/
|
|
||||||
samplesLocation: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL of the backend to index to
|
|
||||||
*/
|
|
||||||
to: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Location of the report
|
|
||||||
*/
|
|
||||||
reportLocation?: string;
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "@openstapps/tsconfig"
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,16 @@
|
|||||||
# @openstapps/proxy
|
# @openstapps/proxy
|
||||||
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- c8e29020: Update to Node 22
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [c8e29020]
|
||||||
|
- @openstapps/logger@4.0.0
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
// ESM is not supported, and cts is not detected, so we use type-checked cjs instead.
|
// ESM is not supported, and cts is not detected, so we use type-checked cjs instead.
|
||||||
/** @type {import('../src/common').ConfigFile} */
|
/** @type {import('../src/common').ConfigFile} */
|
||||||
const configFile = {
|
module.exports = {
|
||||||
activeVersions: ['1\\.0\\.\\d+', '2\\.0\\.\\d+'],
|
activeVersions: ['1\\.0\\.\\d+', '2\\.0\\.\\d+'],
|
||||||
hiddenRoutes: ['/bulk'],
|
hiddenRoutes: ['/bulk'],
|
||||||
logFormat: 'default',
|
logFormat: 'default',
|
||||||
@@ -31,5 +31,3 @@ const configFile = {
|
|||||||
dhparam: '/etc/nginx/certs/dhparam.pem',
|
dhparam: '/etc/nginx/certs/dhparam.pem',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default configFile;
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/proxy",
|
"name": "@openstapps/proxy",
|
||||||
"description": "NGINX proxy that is dynamically configured by a Node.js script",
|
"description": "NGINX proxy that is dynamically configured by a Node.js script",
|
||||||
"version": "3.0.0",
|
"version": "4.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
@@ -44,38 +44,39 @@
|
|||||||
"@openstapps/logger": "workspace:*",
|
"@openstapps/logger": "workspace:*",
|
||||||
"@types/config": "3.3.0",
|
"@types/config": "3.3.0",
|
||||||
"@types/dockerode": "3.3.17",
|
"@types/dockerode": "3.3.17",
|
||||||
"@types/node": "18.15.3",
|
"@types/node": "22.15.31",
|
||||||
"@types/sha1": "1.1.3",
|
"@types/sha1": "1.1.3",
|
||||||
"config": "3.3.9",
|
"config": "3.3.9",
|
||||||
"dockerode": "3.3.5",
|
"dockerode": "3.3.5",
|
||||||
"is-cidr": "4.0.2",
|
"is-cidr": "4.0.2",
|
||||||
"mustache": "4.2.0",
|
"mustache": "4.2.0",
|
||||||
"semver": "7.3.8",
|
"semver": "7.6.0",
|
||||||
"typescript": "5.2.2"
|
"typescript": "5.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@openstapps/api-cli": "workspace:*",
|
||||||
"@openstapps/eslint-config": "workspace:*",
|
"@openstapps/eslint-config": "workspace:*",
|
||||||
"@openstapps/prettier-config": "workspace:*",
|
"@openstapps/prettier-config": "workspace:*",
|
||||||
"@openstapps/tsconfig": "workspace:*",
|
"@openstapps/tsconfig": "workspace:*",
|
||||||
"@types/chai": "4.3.5",
|
"@types/chai": "4.3.20",
|
||||||
"@types/config": "3.3.0",
|
"@types/config": "3.3.0",
|
||||||
"@types/dockerode": "3.3.17",
|
"@types/dockerode": "3.3.17",
|
||||||
"@types/mocha": "10.0.1",
|
"@types/mocha": "10.0.10",
|
||||||
"@types/mustache": "4.2.2",
|
"@types/mustache": "4.2.2",
|
||||||
"@types/node": "18.15.3",
|
"@types/node": "22.15.31",
|
||||||
"@types/proxyquire": "1.3.28",
|
"@types/proxyquire": "1.3.28",
|
||||||
"@types/semver": "7.3.13",
|
"@types/semver": "7.5.8",
|
||||||
"@types/sha1": "1.1.3",
|
"@types/sha1": "1.1.3",
|
||||||
"@types/sinon": "10.0.14",
|
"@types/sinon": "10.0.14",
|
||||||
"@types/sinon-chai": "3.2.9",
|
"@types/sinon-chai": "3.2.9",
|
||||||
"c8": "7.14.0",
|
"c8": "10.1.3",
|
||||||
"chai": "4.3.7",
|
"chai": "4.5.0",
|
||||||
"mocha": "10.2.0",
|
"mocha": "10.8.2",
|
||||||
"mocha-junit-reporter": "2.2.0",
|
"mocha-junit-reporter": "2.2.0",
|
||||||
"sinon": "15.0.4",
|
"sinon": "15.0.4",
|
||||||
"sinon-chai": "3.7.0",
|
"sinon-chai": "3.7.0",
|
||||||
"ts-node": "10.9.1",
|
"ts-node": "10.9.2",
|
||||||
"tsup": "7.2.0"
|
"tsup": "8.5.0"
|
||||||
},
|
},
|
||||||
"tsup": {
|
"tsup": {
|
||||||
"entry": [
|
"entry": [
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"extends": "@openstapps/tsconfig",
|
"extends": "@openstapps/tsconfig",
|
||||||
"exclude": ["./config/", "./lib/"]
|
"exclude": ["config", "lib", "app.js"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @openstapps/backend-config
|
# @openstapps/backend-config
|
||||||
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- c8e29020: Update to Node 22
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
@@ -30,7 +36,7 @@
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import './lib/app.js';
|
import "./lib/app.js";
|
||||||
```
|
```
|
||||||
|
|
||||||
- 64caebaf: Migrate to ESM
|
- 64caebaf: Migrate to ESM
|
||||||
@@ -105,7 +111,7 @@
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import './lib/app.js';
|
import "./lib/app.js";
|
||||||
```
|
```
|
||||||
|
|
||||||
- 64caebaf: Migrate to ESM
|
- 64caebaf: Migrate to ESM
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/backend-config",
|
"name": "@openstapps/backend-config",
|
||||||
"description": "Backend Configuration for OpenStApps",
|
"description": "Backend Configuration for OpenStApps",
|
||||||
"version": "3.0.0",
|
"version": "4.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @openstapps/eslint-config
|
# @openstapps/eslint-config
|
||||||
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- c8e29020: Update to Node 22
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
@@ -30,7 +36,7 @@
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import './lib/app.js';
|
import "./lib/app.js";
|
||||||
```
|
```
|
||||||
|
|
||||||
- 64caebaf: Migrate to ESM
|
- 64caebaf: Migrate to ESM
|
||||||
@@ -75,11 +81,14 @@
|
|||||||
- 64caebaf: Migrated changelogs to changeset format
|
- 64caebaf: Migrated changelogs to changeset format
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import fs from 'fs';
|
import fs from "fs";
|
||||||
|
|
||||||
const path = 'packages/logger/CHANGELOG.md';
|
const path = "packages/logger/CHANGELOG.md";
|
||||||
|
|
||||||
fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/^#+\s+\[/gm, '## ['));
|
fs.writeFileSync(
|
||||||
|
path,
|
||||||
|
fs.readFileSync(path, "utf8").replace(/^#+\s+\[/gm, "## ["),
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
- 98546a97: Migrate away from @openstapps/configuration
|
- 98546a97: Migrate away from @openstapps/configuration
|
||||||
@@ -122,7 +131,7 @@
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import './lib/app.js';
|
import "./lib/app.js";
|
||||||
```
|
```
|
||||||
|
|
||||||
- 64caebaf: Migrate to ESM
|
- 64caebaf: Migrate to ESM
|
||||||
@@ -167,11 +176,14 @@
|
|||||||
- 64caebaf: Migrated changelogs to changeset format
|
- 64caebaf: Migrated changelogs to changeset format
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import fs from 'fs';
|
import fs from "fs";
|
||||||
|
|
||||||
const path = 'packages/logger/CHANGELOG.md';
|
const path = "packages/logger/CHANGELOG.md";
|
||||||
|
|
||||||
fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/^#+\s+\[/gm, '## ['));
|
fs.writeFileSync(
|
||||||
|
path,
|
||||||
|
fs.readFileSync(path, "utf8").replace(/^#+\s+\[/gm, "## ["),
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
- 98546a97: Migrate away from @openstapps/configuration
|
- 98546a97: Migrate away from @openstapps/configuration
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("node:path");
|
const path = require("node:path");
|
||||||
const child_process = require("child_process");
|
const child_process = require("child_process");
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
const rule = require('./copyright-header-rule')
|
const rule = require('./copyright-header-rule')
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/** @type {import('eslint').Linter.Config} */
|
/** @type {import('eslint').Linter.Config} */
|
||||||
const config = {
|
const config = {
|
||||||
root: true,
|
root: true,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/eslint-config",
|
"name": "@openstapps/eslint-config",
|
||||||
"description": "A collection of configuration base files for StApps projects. Just an (unused) experiment for now.",
|
"description": "A collection of configuration base files for StApps projects. Just an (unused) experiment for now.",
|
||||||
"version": "3.0.0",
|
"version": "4.0.0",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"repository": "git@gitlab.com:openstapps/eslint-config.git",
|
"repository": "git@gitlab.com:openstapps/eslint-config.git",
|
||||||
@@ -17,17 +17,16 @@
|
|||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@openstapps/tsconfig": "workspace:*",
|
"@openstapps/tsconfig": "workspace:*",
|
||||||
"@types/node": "18.15.3",
|
"@types/node": "22.15.31",
|
||||||
"eslint": "8.53.0",
|
"eslint": "8.57.0",
|
||||||
"typescript": "5.2.2"
|
"typescript": "5.4.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@typescript-eslint/eslint-plugin": "6.10.0",
|
"@typescript-eslint/eslint-plugin": "7.2.0",
|
||||||
"@typescript-eslint/parser": "6.10.0",
|
"@typescript-eslint/parser": "7.2.0",
|
||||||
"eslint": "8.53.0",
|
"eslint": "8.57.0",
|
||||||
"eslint-config-prettier": "9.0.0",
|
"eslint-config-prettier": "9.1.0",
|
||||||
"eslint-plugin-jsdoc": "46.8.2",
|
"eslint-plugin-jsdoc": "48.2.1",
|
||||||
"eslint-plugin-prettier": "5.0.1",
|
"eslint-plugin-unicorn": "51.0.1"
|
||||||
"eslint-plugin-unicorn": "49.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
# @openstapps/prettier-config
|
# @openstapps/prettier-config
|
||||||
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- c8e29020: Update to Node 22
|
||||||
|
|
||||||
|
## 3.2.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- dbb55850: Update Prettier to 3.1.1
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
@@ -30,7 +42,7 @@
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import './lib/app.js';
|
import "./lib/app.js";
|
||||||
```
|
```
|
||||||
|
|
||||||
- 64caebaf: Migrate to ESM
|
- 64caebaf: Migrate to ESM
|
||||||
@@ -69,11 +81,14 @@
|
|||||||
- 64caebaf: Migrated changelogs to changeset format
|
- 64caebaf: Migrated changelogs to changeset format
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import fs from 'fs';
|
import fs from "fs";
|
||||||
|
|
||||||
const path = 'packages/logger/CHANGELOG.md';
|
const path = "packages/logger/CHANGELOG.md";
|
||||||
|
|
||||||
fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/^#+\s+\[/gm, '## ['));
|
fs.writeFileSync(
|
||||||
|
path,
|
||||||
|
fs.readFileSync(path, "utf8").replace(/^#+\s+\[/gm, "## ["),
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
- 98546a97: Migrate away from @openstapps/configuration
|
- 98546a97: Migrate away from @openstapps/configuration
|
||||||
@@ -115,7 +130,7 @@
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import './lib/app.js';
|
import "./lib/app.js";
|
||||||
```
|
```
|
||||||
|
|
||||||
- 64caebaf: Migrate to ESM
|
- 64caebaf: Migrate to ESM
|
||||||
@@ -154,11 +169,14 @@
|
|||||||
- 64caebaf: Migrated changelogs to changeset format
|
- 64caebaf: Migrated changelogs to changeset format
|
||||||
|
|
||||||
```js
|
```js
|
||||||
import fs from 'fs';
|
import fs from "fs";
|
||||||
|
|
||||||
const path = 'packages/logger/CHANGELOG.md';
|
const path = "packages/logger/CHANGELOG.md";
|
||||||
|
|
||||||
fs.writeFileSync(path, fs.readFileSync(path, 'utf8').replace(/^#+\s+\[/gm, '## ['));
|
fs.writeFileSync(
|
||||||
|
path,
|
||||||
|
fs.readFileSync(path, "utf8").replace(/^#+\s+\[/gm, "## ["),
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
- 98546a97: Migrate away from @openstapps/configuration
|
- 98546a97: Migrate away from @openstapps/configuration
|
||||||
|
|||||||
15
configuration/prettier-config/index.js
Normal file
15
configuration/prettier-config/index.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/** @type {import('prettier').Config} */
|
||||||
|
const config = {
|
||||||
|
tabWidth: 2,
|
||||||
|
printWidth: 110,
|
||||||
|
useTabs: false,
|
||||||
|
semi: true,
|
||||||
|
singleQuote: true,
|
||||||
|
quoteProps: 'consistent',
|
||||||
|
trailingComma: 'all',
|
||||||
|
bracketSpacing: false,
|
||||||
|
arrowParens: 'avoid',
|
||||||
|
endOfLine: 'lf'
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = config;
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "http://json.schemastore.org/prettierrc",
|
|
||||||
"tabWidth": 2,
|
|
||||||
"printWidth": 110,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": true,
|
|
||||||
"singleQuote": true,
|
|
||||||
"quoteProps": "consistent",
|
|
||||||
"trailingComma": "all",
|
|
||||||
"bracketSpacing": false,
|
|
||||||
"arrowParens": "avoid",
|
|
||||||
"endOfLine": "lf"
|
|
||||||
}
|
|
||||||
@@ -1,24 +1,27 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/prettier-config",
|
"name": "@openstapps/prettier-config",
|
||||||
"description": "StApps Prettier Config",
|
"description": "StApps Prettier Config",
|
||||||
"version": "3.0.0",
|
"version": "4.0.0",
|
||||||
"type": "module",
|
"type": "commonjs",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"repository": "git@gitlab.com:openstapps/prettier-config.git",
|
"repository": "git@gitlab.com:openstapps/prettier-config.git",
|
||||||
"author": "Thea Schöbl <dev@theaninova.de>",
|
"author": "Thea Schöbl <dev@theaninova.de>",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Rainer Killinger <mail-openstapps@killinger.co>"
|
"Rainer Killinger <mail-openstapps@killinger.co>"
|
||||||
],
|
],
|
||||||
"main": "index.json",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
"index.json",
|
"index.js",
|
||||||
"CHANGELOG.md",
|
"CHANGELOG.md",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npx prettier --config index.json --check \"test/*.js\""
|
"test": "prettier --config index.js --check \"test/*.js\""
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "3.1.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"prettier": "3.1.0"
|
"prettier": "3.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
# @openstapps/projectmanagement
|
# @openstapps/projectmanagement
|
||||||
|
|
||||||
|
## 4.0.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- b40ba7ad: Updated Elasticsearch dependency
|
||||||
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Major Changes
|
||||||
|
|
||||||
|
- c8e29020: Update to Node 22
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [c8e29020]
|
||||||
|
- @openstapps/collection-utils@4.0.0
|
||||||
|
- @openstapps/gitlab-api@4.0.0
|
||||||
|
- @openstapps/logger@4.0.0
|
||||||
|
|
||||||
## 3.0.0
|
## 3.0.0
|
||||||
|
|
||||||
### Major Changes
|
### Major Changes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@openstapps/projectmanagement",
|
"name": "@openstapps/projectmanagement",
|
||||||
"description": "Main documentation and scripts for maintenance.",
|
"description": "Main documentation and scripts for maintenance.",
|
||||||
"version": "3.0.0",
|
"version": "4.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
@@ -41,31 +41,30 @@
|
|||||||
"@openstapps/collection-utils": "workspace:*",
|
"@openstapps/collection-utils": "workspace:*",
|
||||||
"@openstapps/gitlab-api": "workspace:*",
|
"@openstapps/gitlab-api": "workspace:*",
|
||||||
"@openstapps/logger": "workspace:*",
|
"@openstapps/logger": "workspace:*",
|
||||||
"@slack/web-api": "6.8.1",
|
|
||||||
"commander": "10.0.0",
|
"commander": "10.0.0",
|
||||||
"date-fns": "2.30.0",
|
"date-fns": "3.6.0",
|
||||||
"glob": "10.2.7",
|
"glob": "10.3.10",
|
||||||
"mustache": "4.2.0"
|
"mustache": "4.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@openstapps/eslint-config": "workspace:*",
|
"@openstapps/eslint-config": "workspace:*",
|
||||||
"@openstapps/prettier-config": "workspace:*",
|
"@openstapps/prettier-config": "workspace:*",
|
||||||
"@openstapps/tsconfig": "workspace:*",
|
"@openstapps/tsconfig": "workspace:*",
|
||||||
"@types/chai": "4.3.5",
|
"@types/chai": "4.3.20",
|
||||||
"@types/chai-as-promised": "7.1.5",
|
"@types/chai-as-promised": "7.1.8",
|
||||||
"@types/glob": "8.0.1",
|
"@types/glob": "8.1.0",
|
||||||
"@types/mocha": "10.0.1",
|
"@types/mocha": "10.0.10",
|
||||||
"@types/mustache": "4.2.2",
|
"@types/mustache": "4.2.2",
|
||||||
"@types/node": "18.15.3",
|
"@types/node": "22.15.31",
|
||||||
"@types/tmp": "0.2.3",
|
"@types/tmp": "0.2.3",
|
||||||
"c8": "7.14.0",
|
"c8": "10.1.3",
|
||||||
"chai": "4.3.7",
|
"chai": "4.5.0",
|
||||||
"chai-as-promised": "7.1.1",
|
"chai-as-promised": "7.1.2",
|
||||||
"mocha": "10.2.0",
|
"mocha": "10.8.2",
|
||||||
"mocha-junit-reporter": "2.2.0",
|
"mocha-junit-reporter": "2.2.0",
|
||||||
"ts-node": "10.9.1",
|
"ts-node": "10.9.2",
|
||||||
"tsup": "7.2.0",
|
"tsup": "8.5.0",
|
||||||
"typescript": "5.2.2"
|
"typescript": "5.4.2"
|
||||||
},
|
},
|
||||||
"tsup": {
|
"tsup": {
|
||||||
"entry": [
|
"entry": [
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user