mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-23 06:36:20 +00:00
Compare commits
1 Commits
114-improv
...
@openstapp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3a416d580 |
@@ -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
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -51,8 +51,6 @@ node_modules/
|
||||
.pnpm-store/
|
||||
jspm_packages/
|
||||
|
||||
.browser-data
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ audit:
|
||||
allow_failure: true
|
||||
needs: []
|
||||
script:
|
||||
- pnpm audit --prod --audit-level critical
|
||||
- pnpm audit --prod
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
allow_failure: false
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
.limit_publish_pipelines:
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_COMMIT_MESSAGE =~ /ci: publish prerelease/ && $CI_PIPELINE_SOURCE != "schedule"'
|
||||
variables:
|
||||
PUBLISH_TAG: next
|
||||
- if: '$CI_COMMIT_BRANCH == "main" && $CI_COMMIT_MESSAGE =~ /ci: publish release/ && $CI_PIPELINE_SOURCE != "schedule"'
|
||||
variables:
|
||||
PUBLISH_TAG: latest
|
||||
- if: '($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop") && $CI_COMMIT_MESSAGE =~ /ci: publish release/ && $CI_PIPELINE_SOURCE != "schedule"'
|
||||
|
||||
deploy:
|
||||
stage: publish
|
||||
@@ -29,6 +24,8 @@ publish image:
|
||||
image:
|
||||
name: gcr.io/kaniko-project/executor:v1.12.1-debug
|
||||
entrypoint: [""]
|
||||
variables:
|
||||
PUBLISH_TAG: next
|
||||
script:
|
||||
- >
|
||||
/kaniko/executor
|
||||
@@ -53,6 +50,9 @@ publish image:
|
||||
- IMAGE_NAME: app
|
||||
DEPLOY_DIR: frontend/app
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
variables:
|
||||
PUBLISH_TAG: latest
|
||||
- !reference [.limit_publish_pipelines, rules]
|
||||
|
||||
publish packages:
|
||||
@@ -61,12 +61,16 @@ publish packages:
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
GIT_DEPTH: 0
|
||||
PUBLISH_TAG: next
|
||||
script:
|
||||
- pnpm install
|
||||
- pnpm build
|
||||
- pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_AUTH_TOKEN}"
|
||||
- pnpm publish -r --publish-branch ${CI_COMMIT_BRANCH} --tag ${PUBLISH_TAG} --no-git-checks # TODO: Git checks...
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
variables:
|
||||
PUBLISH_TAG: latest
|
||||
- !reference [.limit_publish_pipelines, rules]
|
||||
|
||||
publish docs:
|
||||
@@ -80,4 +84,5 @@ publish docs:
|
||||
paths:
|
||||
- public
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == 'main'
|
||||
- !reference [.limit_publish_pipelines, rules]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"extension": ["ts", "js"],
|
||||
"extension": ["ts"],
|
||||
"node-option": ["loader=ts-node/esm"],
|
||||
"reporter": "mocha-junit-reporter",
|
||||
"reporter-option": ["mochaFile=coverage/report-junit.xml"],
|
||||
"spec": ["test/**/*.spec.{ts,js}"]
|
||||
"spec": ["test/**/*.spec.ts"]
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ const config = {
|
||||
packages: ['**'],
|
||||
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',
|
||||
dependencies: ['@openstapps/**'],
|
||||
|
||||
@@ -37,13 +37,13 @@ Adding new types requires changes at multiple locations for it to work correctly
|
||||
- Add your SCThing and SCThingWithoutReferences to `src/things/your-thing-name.ts` and make them extend `SCThingWithoutReferences` and `SCThing` respectively
|
||||
- Add your SCThingMeta to `src/things/your-thing-name.ts` and make it extend `SCThingMeta`
|
||||
- Add your SCThingMeta to `SCClasses` in `src/meta.ts`
|
||||
- Add your SCThing to `SCIndexableThings ` in `src/meta.ts`
|
||||
- Add your SCThing to `SCThingsWithoutDiff` in `src/meta.ts`
|
||||
- Add your SCThingWithoutReferences to `SCAssociatedThingWithoutReferences` in `src/meta.ts`
|
||||
- Add your SCThing to `SCAssociatedThing` in `src/meta.ts`
|
||||
- Add your SCThing to the `SCThingType` enum in `src/things/abstract/thing.ts`
|
||||
- Add an example file for your SCThing in `test/resources/YourThingName.json`
|
||||
- Add the following lines for your SCThing in `test/type.spec.ts`:
|
||||
- Make sure your SCThing (but not SCThingWithoutReferences!) includes the `@indexable` and `@validatable` JSDoc annotations, otherwise neither JSON Schemas nor Elasticsearch mappings will be generated
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* Types of properties of SCYourThingName
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
# @openstapps/backend
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Fix missing dependency
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
@@ -56,19 +56,6 @@ const menus = [
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
icon: 'work',
|
||||
route: '/jobs',
|
||||
title: 'job postings',
|
||||
translations: {
|
||||
de: {
|
||||
title: 'Jobangebote',
|
||||
},
|
||||
en: {
|
||||
title: 'job postings',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
title: 'overview',
|
||||
route: '/overview',
|
||||
|
||||
@@ -3,7 +3,7 @@ import about from './about.js';
|
||||
import imprint from './imprint.js';
|
||||
import privacy from './privacy.js';
|
||||
|
||||
/** @type {Record<string, import('@openstapps/core').SCAboutPage>} */
|
||||
/** @type {import('@openstapps/core').SCMap<import('@openstapps/core').SCAboutPage>} */
|
||||
const aboutPages = {
|
||||
'about': about,
|
||||
'about/imprint': imprint,
|
||||
|
||||
@@ -5,18 +5,18 @@ if [ -z $GITLAB_CI ]; then
|
||||
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=$!
|
||||
( 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
|
||||
# api-cli output defines passing the test
|
||||
# backend should not exit early
|
||||
|
||||
wait $e2e_pid
|
||||
e2e_exit=$?
|
||||
wait $api_cli_pid
|
||||
api_cli_exit=$?
|
||||
wait $backend_pid
|
||||
backend_exit=$?
|
||||
|
||||
if [ "$e2e_exit" -eq "0" ]; then
|
||||
if [ "$api_cli_exit" -eq "0" ]; then
|
||||
echo "FINISHED";
|
||||
exit;
|
||||
fi
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@openstapps/backend",
|
||||
"description": "A reference implementation for a StApps backend",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"license": "AGPL-3.0-only",
|
||||
@@ -31,6 +31,7 @@
|
||||
"build": "tsup-node",
|
||||
"build:docker": "docker build -t openstapps:backend ../../.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:fix": "prettier --write . --ignore-path ../../.gitignore",
|
||||
"lint": "tsc --noEmit && eslint --ext .ts src/",
|
||||
@@ -42,9 +43,9 @@
|
||||
"test:unit": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true STAPPS_LOG_LEVEL=0 mocha --exit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@elastic/elasticsearch": "8.10.0",
|
||||
"@elastic/elasticsearch": "8.4.0",
|
||||
"@openstapps/core": "workspace:*",
|
||||
"@openstapps/core-validator": "workspace:*",
|
||||
"@openstapps/core-tools": "workspace:*",
|
||||
"@openstapps/logger": "workspace:*",
|
||||
"@types/body-parser": "1.19.2",
|
||||
"@types/cors": "2.8.13",
|
||||
@@ -55,12 +56,9 @@
|
||||
"@types/nodemailer": "6.4.7",
|
||||
"@types/promise-queue": "2.2.0",
|
||||
"@types/uuid": "8.3.4",
|
||||
"ajv": "8.12.0",
|
||||
"ajv-formats": "2.1.1",
|
||||
"body-parser": "1.20.2",
|
||||
"cors": "2.8.5",
|
||||
"cosmiconfig": "8.1.3",
|
||||
"deepmerge": "4.3.1",
|
||||
"express": "4.18.2",
|
||||
"express-prom-bundle": "6.6.0",
|
||||
"express-promise-router": "4.1.1",
|
||||
@@ -76,7 +74,7 @@
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/e2e-connector": "workspace:*",
|
||||
"@openstapps/api-cli": "workspace:*",
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
@@ -100,8 +98,18 @@
|
||||
"sinon-express-mock": "2.2.1",
|
||||
"supertest": "6.3.3",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "7.2.0",
|
||||
"typescript": "5.2.2"
|
||||
"tsup": "6.7.0",
|
||||
"typescript": "5.1.6"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
"src/cli.ts"
|
||||
],
|
||||
"sourcemap": true,
|
||||
"clean": true,
|
||||
"target": "es2022",
|
||||
"format": "esm",
|
||||
"outDir": "lib"
|
||||
},
|
||||
"prettier": "@openstapps/prettier-config",
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -23,7 +23,8 @@ import {Logger} from '@openstapps/logger';
|
||||
import cors from 'cors';
|
||||
import {Express} from 'express';
|
||||
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 {MailQueue} from './notification/mail-queue.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 {DatabaseConstructor} from './storage/database.js';
|
||||
import {backendConfig} from './config.js';
|
||||
import {validator} from './validator.js';
|
||||
import {fileURLToPath} from 'url';
|
||||
|
||||
/**
|
||||
* Configure the backend
|
||||
@@ -142,8 +143,20 @@ export async function configureApp(app: Express, databases: {[name: string]: Dat
|
||||
request.on('data', chunkGatherer).on('end', endCallback);
|
||||
});
|
||||
|
||||
if (!validator.validate(backendConfig, 'SCConfigFile')) {
|
||||
throw new Error(`Validation of config file failed. Errors were: ${JSON.stringify(validator.errors)}`);
|
||||
// validate config file
|
||||
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
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCPluginMetaData} from '@openstapps/core';
|
||||
import {Validator} from '@openstapps/core-tools';
|
||||
import {BackendTransport} from './notification/backend-transport.js';
|
||||
|
||||
/**
|
||||
@@ -21,6 +22,11 @@ import {BackendTransport} from './notification/backend-transport.js';
|
||||
*/
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -19,12 +19,12 @@ import {
|
||||
SCRoute,
|
||||
SCValidationErrorResponse,
|
||||
} from '@openstapps/core';
|
||||
import {ValidationError} from '@openstapps/core-tools/src/types/validator.js';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {Application, Router} from 'express';
|
||||
import PromiseRouter from 'express-promise-router';
|
||||
import {isTestEnvironment} from '../common.js';
|
||||
import {isTestEnvironment, validator} from '../common.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
|
||||
@@ -56,8 +56,11 @@ export function createRoute<REQUESTTYPE, RETURNTYPE>(
|
||||
// create a route handler for the given HTTP method
|
||||
route[verb](async (request, response) => {
|
||||
try {
|
||||
if (!validator.validate(request.body, routeClass.requestBodyName as never)) {
|
||||
const error = new SCValidationErrorResponse(validator.errors as unknown[], isTestEnvironment);
|
||||
// validate request
|
||||
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.json(error);
|
||||
await Logger.error(error);
|
||||
@@ -65,13 +68,17 @@ export function createRoute<REQUESTTYPE, RETURNTYPE>(
|
||||
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)) {
|
||||
const validationError = new SCValidationErrorResponse(
|
||||
validator.errors as unknown[],
|
||||
isTestEnvironment,
|
||||
);
|
||||
// validate response generated by handler
|
||||
const responseErrors: ValidationError[] = validator.validate(
|
||||
handlerResponse,
|
||||
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 backend, therefore we use this "stacked" error.
|
||||
const internalServerError = new SCInternalServerErrorResponse(validationError, isTestEnvironment);
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
import {SCInternalServerErrorResponse, SCPluginMetaData, SCValidationErrorResponse} from '@openstapps/core';
|
||||
import {Request} from 'express';
|
||||
import got from 'got';
|
||||
import {isTestEnvironment} from '../common.js';
|
||||
import {isTestEnvironment, validator} from '../common.js';
|
||||
import {backendConfig} from '../config.js';
|
||||
import {validator} from '../validator.js';
|
||||
|
||||
/**
|
||||
* 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> {
|
||||
try {
|
||||
if (!validator.validate(request.body, plugin.requestSchema)) {
|
||||
const requestValidation = validator.validate(request.body, plugin.requestSchema);
|
||||
if (requestValidation.errors.length > 0) {
|
||||
// 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
|
||||
const response = await got.post(plugin.route.replaceAll(/^\//gi, ''), {
|
||||
@@ -42,9 +43,10 @@ export async function virtualPluginRoute(request: Request, plugin: SCPluginMetaD
|
||||
responseType: 'json',
|
||||
});
|
||||
const responseBody = response.body;
|
||||
if (!validator.validate(responseBody, plugin.responseSchema)) {
|
||||
const responseValidation = validator.validate(responseBody, plugin.responseSchema);
|
||||
if (responseValidation.errors.length > 0) {
|
||||
// noinspection ExceptionCaughtLocallyJS
|
||||
throw new SCValidationErrorResponse(validator.errors as unknown[], isTestEnvironment);
|
||||
throw new SCValidationErrorResponse(responseValidation.errors, isTestEnvironment);
|
||||
}
|
||||
return responseBody as object;
|
||||
} catch (error) {
|
||||
|
||||
@@ -31,7 +31,7 @@ import {parseAggregations} from './aggregations.js';
|
||||
import * as Monitoring from './monitoring.js';
|
||||
import {buildQuery} from './query/query.js';
|
||||
import {buildSort} from './query/sort.js';
|
||||
import {putTemplate} from './templating.js';
|
||||
import {aggregations, putTemplate} from './templating.js';
|
||||
import {
|
||||
ElasticsearchConfig,
|
||||
ElasticsearchQueryDisMaxConfig,
|
||||
@@ -46,7 +46,6 @@ import {
|
||||
} from './util/index.js';
|
||||
import {noUndefined} from './util/no-undefined.js';
|
||||
import {retryCatch, RetryOptions} from './util/retry.js';
|
||||
import config from '@openstapps/core/elasticsearch.json' assert {type: 'json'};
|
||||
|
||||
/**
|
||||
* A database interface for elasticsearch
|
||||
@@ -371,7 +370,7 @@ export class Elasticsearch implements Database {
|
||||
};
|
||||
|
||||
const response: SearchResponse<SCThings> = await this.client.search({
|
||||
...config.search,
|
||||
aggs: aggregations,
|
||||
query: buildQuery(parameters, this.config, esConfig),
|
||||
from: parameters.from,
|
||||
index: ACTIVE_INDICES_ALIAS,
|
||||
|
||||
@@ -15,7 +15,19 @@
|
||||
*/
|
||||
import {Client} from '@elastic/elasticsearch';
|
||||
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
|
||||
@@ -28,7 +40,7 @@ export async function putTemplate(client: Client, type: SCThingType) {
|
||||
const sanitizedType = `template_${type.replaceAll(/\s/g, '_')}`;
|
||||
|
||||
return client.indices.putTemplate({
|
||||
body: config.mappings[sanitizedType],
|
||||
body: mappings[sanitizedType],
|
||||
name: sanitizedType,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
import {Validator} from '@openstapps/core-validator';
|
||||
|
||||
export const validator = new Validator();
|
||||
@@ -25,12 +25,12 @@ import bodyParser from 'body-parser';
|
||||
import sinon from 'sinon';
|
||||
import {expect} from 'chai';
|
||||
import {Application} from 'express';
|
||||
import {validator} from '../../src/common.js';
|
||||
import {createRoute} from '../../src/routes/route.js';
|
||||
import express, {Express} from 'express';
|
||||
import supertest from 'supertest';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {DEFAULT_TEST_TIMEOUT} from '../common.js';
|
||||
import {validator} from '../../src/validator.js';
|
||||
|
||||
interface ReturnType {
|
||||
foo: boolean;
|
||||
@@ -78,7 +78,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 () {
|
||||
const methodNotAllowedError = new SCMethodNotAllowedErrorResponse();
|
||||
sandbox.stub(validator, 'validate').returns(true);
|
||||
// @ts-expect-error not assignable
|
||||
sandbox.stub(validator, 'validate').returns({errors: []});
|
||||
let error: any = {};
|
||||
sandbox.stub(Logger, 'warn').callsFake(error_ => {
|
||||
error = error_;
|
||||
@@ -96,7 +97,8 @@ describe('Create route', 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);
|
||||
app.use(router);
|
||||
|
||||
@@ -113,7 +115,8 @@ describe('Create route', async function () {
|
||||
app.use(router);
|
||||
const startApp = supertest(app);
|
||||
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
|
||||
.post(routeClass.urlPath)
|
||||
@@ -128,8 +131,12 @@ describe('Create route', async function () {
|
||||
const router = createRoute<any, any>(routeClass, handler);
|
||||
await app.use(router);
|
||||
const startApp = supertest(app);
|
||||
const validatorStub = sandbox.stub(validator, 'validate').returns(false);
|
||||
validatorStub.withArgs(bodySuccess, routeClass.responseBodyName).returns(false);
|
||||
// @ts-expect-error not assignable
|
||||
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();
|
||||
|
||||
@@ -170,7 +177,8 @@ describe('Create route', async function () {
|
||||
await app.use(router);
|
||||
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();
|
||||
|
||||
@@ -205,7 +213,8 @@ describe('Create route', async function () {
|
||||
await app.use(router);
|
||||
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();
|
||||
|
||||
|
||||
@@ -22,12 +22,11 @@ import got, {Options} from 'got';
|
||||
import nock from 'nock';
|
||||
import sinon from 'sinon';
|
||||
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 {DEFAULT_TEST_TIMEOUT, FooError} from '../common.js';
|
||||
import {registerAddRequest} from './plugin-register-route.spec.js';
|
||||
import {testApp} from '../tests-setup.js';
|
||||
import {validator} from '../../src/validator.js';
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
@@ -72,7 +71,8 @@ describe('Virtual plugin routes', async function () {
|
||||
// spy the post method of got
|
||||
// @ts-expect-error not assignable
|
||||
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);
|
||||
|
||||
await virtualPluginRoute(request_, plugin);
|
||||
|
||||
@@ -34,6 +34,7 @@ import mockedEnv from 'mocked-env';
|
||||
import sinon, {SinonStub} from 'sinon';
|
||||
import {removeInvalidAliasChars} from '../../../src/storage/elasticsearch/util/alias.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 {bulk, DEFAULT_TEST_TIMEOUT, getTransport, getIndex} from '../../common.js';
|
||||
import fs from 'fs';
|
||||
@@ -49,7 +50,6 @@ import {
|
||||
} from '../../../src/storage/elasticsearch/util/index.js';
|
||||
import cron from 'node-cron';
|
||||
import {query} from './query.js';
|
||||
import {search} from '@openstapps/core/elasticsearch.json' assert {type: 'json'};
|
||||
|
||||
use(chaiAsPromised);
|
||||
|
||||
@@ -131,7 +131,7 @@ describe('Elasticsearch', function () {
|
||||
expect(indexUID.length).to.be.equal(INDEX_UID_LENGTH);
|
||||
// test starting and ending character
|
||||
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 () {
|
||||
@@ -679,7 +679,7 @@ describe('Elasticsearch', function () {
|
||||
await es.search(parameters);
|
||||
|
||||
expect(searchStub.firstCall.firstArg).to.be.deep.equal({
|
||||
...search,
|
||||
aggs: aggregations,
|
||||
query,
|
||||
allow_no_indices: true,
|
||||
sort: [{'name.sort': 'desc'}],
|
||||
|
||||
@@ -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);
|
||||
@@ -6,8 +6,5 @@
|
||||
"config",
|
||||
"Dockerfile",
|
||||
"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;
|
||||
}
|
||||
@@ -51,9 +51,10 @@
|
||||
"is-cidr": "4.0.2",
|
||||
"mustache": "4.2.0",
|
||||
"semver": "7.3.8",
|
||||
"typescript": "5.2.2"
|
||||
"typescript": "5.1.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/api-cli": "workspace:*",
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
@@ -75,7 +76,7 @@
|
||||
"sinon": "15.0.4",
|
||||
"sinon-chai": "3.7.0",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "7.2.0"
|
||||
"tsup": "6.7.0"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
<item title="search" title.de="Suche" icon="search" route="/search"/>
|
||||
<item title="library catalog" title.de="Bibliothekskatalog" icon="local_library" route="/hebis-search"/>
|
||||
<item title="course catalog" title.de="Vorlesungsverzeichnis" icon="inventory_2" route="/catalog"/>
|
||||
<item title="job postings" title.de="Jobangebote" icon="work" route="/jobs"/>
|
||||
</group>
|
||||
<group title="canteen" title.de="Mensa" icon="local_cafe" route="/canteen"/>
|
||||
<group title="campus map" title.de="Campus Karte" icon="map" route="/map"/>
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
<item title="search" title.de="Suche" icon="search" route="/search"/>
|
||||
<item title="library catalog" title.de="Bibliothekskatalog" icon="local_library" route="/hebis-search"/>
|
||||
<item title="course catalog" title.de="Vorlesungsverzeichnis" icon="inventory_2" route="/catalog"/>
|
||||
<item title="job postings" title.de="Jobangebote" icon="work" route="/jobs"/>
|
||||
</group>
|
||||
<group title="canteen" title.de="Mensa" icon="local_cafe" route="/canteen"/>
|
||||
<group title="campus map" title.de="Campus Karte" icon="map" route="/map"/>
|
||||
|
||||
@@ -18,16 +18,16 @@
|
||||
"devDependencies": {
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@types/node": "18.15.3",
|
||||
"eslint": "8.53.0",
|
||||
"typescript": "5.2.2"
|
||||
"eslint": "8.43.0",
|
||||
"typescript": "5.1.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "6.10.0",
|
||||
"@typescript-eslint/parser": "6.10.0",
|
||||
"eslint": "8.53.0",
|
||||
"eslint-config-prettier": "9.0.0",
|
||||
"eslint-plugin-jsdoc": "46.8.2",
|
||||
"eslint-plugin-prettier": "5.0.1",
|
||||
"eslint-plugin-unicorn": "49.0.0"
|
||||
"@typescript-eslint/eslint-plugin": "5.60.1",
|
||||
"@typescript-eslint/parser": "5.60.1",
|
||||
"eslint": "8.43.0",
|
||||
"eslint-config-prettier": "8.8.0",
|
||||
"eslint-plugin-jsdoc": "46.4.2",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"eslint-plugin-unicorn": "47.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
"test": "npx prettier --config index.json --check \"test/*.js\""
|
||||
},
|
||||
"peerDependencies": {
|
||||
"prettier": "3.1.0"
|
||||
"prettier": "2.8.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@
|
||||
"mocha": "10.2.0",
|
||||
"mocha-junit-reporter": "2.2.0",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "7.2.0",
|
||||
"typescript": "5.2.2"
|
||||
"tsup": "6.7.0",
|
||||
"typescript": "5.1.6"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
"compilerOptions": {
|
||||
"alwaysStrict": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
@@ -15,7 +14,6 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"isolatedModules": true,
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"noImplicitAny": true,
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"commander": "10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/core-tools": "workspace:*",
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
@@ -53,8 +54,8 @@
|
||||
"mocha-junit-reporter": "2.2.0",
|
||||
"nock": "13.3.1",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "7.2.0",
|
||||
"typescript": "5.2.2"
|
||||
"tsup": "6.7.0",
|
||||
"typescript": "5.1.6"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
@@ -51,7 +51,7 @@ export class MinimalConnector extends Connector<SCMessage> {
|
||||
protected async fetchItems(): Promise<SCMessage[]> {
|
||||
return [
|
||||
{
|
||||
audiences: ['students', 'employees', 'guests'],
|
||||
audiences: ['students', 'employees'],
|
||||
categories: [],
|
||||
description: 'Some description 1',
|
||||
messageBody: 'Some message 1',
|
||||
@@ -61,7 +61,7 @@ export class MinimalConnector extends Connector<SCMessage> {
|
||||
uid: createUUID({id: 'message_1'}, this.licensePlate),
|
||||
},
|
||||
{
|
||||
audiences: ['students', 'employees', 'guests'],
|
||||
audiences: ['students', 'employees'],
|
||||
categories: [],
|
||||
description: 'Some description 2',
|
||||
messageBody: 'Some message 2',
|
||||
@@ -71,7 +71,7 @@ export class MinimalConnector extends Connector<SCMessage> {
|
||||
uid: '', // see Connetor.getItems()
|
||||
},
|
||||
{
|
||||
audiences: ['students', 'employees', 'guests'],
|
||||
audiences: ['students', 'employees'],
|
||||
categories: [],
|
||||
description: 'Some description 3',
|
||||
messageBody: 'Some message 3',
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
"@openstapps/api": "workspace:*",
|
||||
"@openstapps/api-plugin": "workspace:*",
|
||||
"@openstapps/core": "workspace:*",
|
||||
"@openstapps/json-schema-generator": "workspace:*",
|
||||
"@openstapps/core-tools": "workspace:*",
|
||||
"@openstapps/logger": "workspace:*",
|
||||
"commander": "10.0.0",
|
||||
"express": "4.18.2",
|
||||
@@ -43,8 +43,17 @@
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@types/express": "4.17.17",
|
||||
"@types/node": "18.15.3",
|
||||
"tsup": "7.2.0",
|
||||
"typescript": "5.2.2"
|
||||
"tsup": "6.7.0",
|
||||
"typescript": "5.1.6"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
"src/app.ts"
|
||||
],
|
||||
"sourcemap": true,
|
||||
"clean": true,
|
||||
"format": "esm",
|
||||
"outDir": "lib"
|
||||
},
|
||||
"prettier": "@openstapps/prettier-config",
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
import {HttpClient} from '@openstapps/api';
|
||||
import {PluginClient} from '@openstapps/api-plugin';
|
||||
import {Converter} from '@openstapps/core-tools';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {Command, Option} from 'commander';
|
||||
import {readFileSync} from 'fs';
|
||||
@@ -51,11 +52,18 @@ const pluginClient = new PluginClient(new HttpClient(), options.backendUrl);
|
||||
|
||||
// create an instance of your plugin
|
||||
const plugin = new MinimalPlugin(
|
||||
// tslint:disable-next-line:no-magic-numbers
|
||||
Number.parseInt(options.port, 10),
|
||||
options.pluginName,
|
||||
options.url,
|
||||
`/${options.routeName}`,
|
||||
options.backendUrl,
|
||||
new Converter(path.resolve(__dirname, '..', 'src', 'plugin', 'protocol')), // an instance of the converter. Required
|
||||
// because your requests and response schemas are defined in the plugin. The path should lead to your request and
|
||||
// response interfaces
|
||||
'SCMinimalRequest', // TODO: adjust name of the request interface
|
||||
'SCMinimalResponse', // TODO: adjust name of the response interface
|
||||
JSON.parse(readFileSync(path.resolve(__dirname, '..', 'package.json')).toString()).version, // get the version of the plugin from the package.json
|
||||
);
|
||||
|
||||
pluginClient
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
*/
|
||||
import {Plugin} from '@openstapps/api-plugin';
|
||||
import * as express from 'express';
|
||||
import {requestSchema, SCMinimalRequest} from './protocol/request.js';
|
||||
import {responseSchema, SCMinimalResponse} from './protocol/response.js';
|
||||
import {SCMinimalRequest} from './protocol/request.js';
|
||||
import {SCMinimalResponse} from './protocol/response.js';
|
||||
|
||||
/**
|
||||
* The Plugin Class
|
||||
@@ -24,10 +24,6 @@ import {responseSchema, SCMinimalResponse} from './protocol/response.js';
|
||||
* TODO: rename the class
|
||||
*/
|
||||
export class MinimalPlugin extends Plugin {
|
||||
requestSchema = requestSchema;
|
||||
|
||||
responseSchema = responseSchema;
|
||||
|
||||
/**
|
||||
* Calculates the sum of a list of numbers
|
||||
*
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
/**
|
||||
* The Request Interface
|
||||
*
|
||||
* All incoming requests will look like this, this is being checked by the backend.
|
||||
* The request can have any layout you like.
|
||||
* All incoming requests will look like this, this is being checked by the backend. You need to add the @validatable tag
|
||||
* like shown below for the plugin to work. The request can have any layout you like.
|
||||
* TODO: remove body of the interface and replace with your own layout
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCMinimalRequest {
|
||||
/**
|
||||
@@ -26,5 +27,3 @@ export interface SCMinimalRequest {
|
||||
*/
|
||||
numbers: number[];
|
||||
}
|
||||
|
||||
export {default as requestSchema} from 'schema:#SCMinimalRequest';
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
* All your responses to the backend are required to look like this. You need to add the @validatable tag like shown
|
||||
* below for the plugin to work. The response can have any layout you like.
|
||||
* TODO: remove body of the interface and replace with your own layout
|
||||
* @validatable
|
||||
*/
|
||||
export interface SCMinimalResponse {
|
||||
/**
|
||||
@@ -26,5 +27,3 @@ export interface SCMinimalResponse {
|
||||
*/
|
||||
sum: number;
|
||||
}
|
||||
|
||||
export {default as responseSchema} from 'schema:#SCMinimalResponse';
|
||||
|
||||
5
examples/minimal-plugin/src/schemas.d.ts
vendored
5
examples/minimal-plugin/src/schemas.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
declare module 'schema:*' {
|
||||
import {JSONSchema7} from 'json-schema';
|
||||
const schema: JSONSchema7;
|
||||
export default schema;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import {defineConfig} from 'tsup';
|
||||
import {jsonSchemaPlugin} from '@openstapps/json-schema-generator';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['src/app.ts'],
|
||||
sourcemap: true,
|
||||
clean: true,
|
||||
format: 'esm',
|
||||
outDir: 'lib',
|
||||
noExternal: [/.*:schema#.*/],
|
||||
plugins: [jsonSchemaPlugin('schema.json')],
|
||||
});
|
||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1698553279,
|
||||
"narHash": "sha256-T/9P8yBSLcqo/v+FTOBK+0rjzjPMctVymZydbvR/Fak=",
|
||||
"lastModified": 1689752456,
|
||||
"narHash": "sha256-VOChdECcEI8ixz8QY+YC4JaNEFwQd1V8bA0G4B28Ki0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "90e85bc7c1a6fc0760a94ace129d3a1c61c3d035",
|
||||
"rev": "7f256d7da238cb627ef189d56ed590739f42f13b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
"unicorn/no-nested-ternary": "off",
|
||||
"unicorn/better-regex": "off",
|
||||
"unicorn/no-non-null-assertion": "off",
|
||||
"unicorn/consistent-function-scoping": ["error", {"checkArrowFunctions": false}],
|
||||
"jsdoc/no-types": "error",
|
||||
"jsdoc/require-param": "off",
|
||||
"jsdoc/require-param-description": "error",
|
||||
|
||||
@@ -45,5 +45,4 @@ UserInterfaceState.xcuserstate
|
||||
android/
|
||||
ios/
|
||||
|
||||
.browser-data
|
||||
docs
|
||||
|
||||
@@ -17,10 +17,11 @@ module.exports = {
|
||||
...require('@openstapps/prettier-config'),
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.html'],
|
||||
files: 'src/**/*.html',
|
||||
options: {
|
||||
parser: 'angular',
|
||||
},
|
||||
},
|
||||
],
|
||||
ignorePath: ['.prettierignore', '../../.gitignore'],
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ All the npm scripts are defined in `package.json` [file](package.json). It is re
|
||||
|
||||
## Most useful commands
|
||||
|
||||
### Editing the Ionic Database from the browser
|
||||
## Editing the Ionic Database from the browser
|
||||
|
||||
Add the following function using the browser console
|
||||
|
||||
@@ -90,19 +90,6 @@ You'll need to run _Chromium_ using
|
||||
pnpm chromium:no-cors
|
||||
```
|
||||
|
||||
### Help, I can't log in!
|
||||
|
||||
Login services will often block hosts not coming from the production
|
||||
server. You can circumvent this locally by using the `:virtual-host`
|
||||
scripts:
|
||||
|
||||
```shell
|
||||
# Start the dev server on mobile.app.uni-frankfurt.de
|
||||
pnpm start:virtual-host
|
||||
# Run chromium with flags that redirect mobile.app.uni-frankfurt.de to localhost:8100
|
||||
pnpm chromium:virtual-host
|
||||
```
|
||||
|
||||
### Running the app
|
||||
|
||||
Install the npm packages needed for running the app (as for any other node project which uses npm):
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
"schematics": {},
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "www",
|
||||
"index": "src/index.html",
|
||||
"browser": "src/main.ts",
|
||||
"polyfills": ["zone.js"],
|
||||
"main": "src/main.ts",
|
||||
"polyfills": "zone.js",
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"allowedCommonJsDependencies": [
|
||||
"moment",
|
||||
@@ -50,10 +50,7 @@
|
||||
},
|
||||
"./node_modules/leaflet/dist/leaflet.css",
|
||||
"./node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css"
|
||||
],
|
||||
"stylePreprocessorOptions": {
|
||||
"includePaths": ["src", "src/theme/util", "node_modules"]
|
||||
}
|
||||
]
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
@@ -77,20 +74,10 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"local": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.local.ts"
|
||||
}
|
||||
],
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true,
|
||||
"namedChunks": true
|
||||
},
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"optimization": false,
|
||||
"vendorChunk": true,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true,
|
||||
"namedChunks": true
|
||||
@@ -110,20 +97,20 @@
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"buildTarget": "app:build"
|
||||
"browserTarget": "app:build"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "app:build:production"
|
||||
"browserTarget": "app:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "app:build:development"
|
||||
"browserTarget": "app:build:development"
|
||||
},
|
||||
"ci": {
|
||||
"buildTarget": "app:build"
|
||||
"browserTarget": "app:build"
|
||||
},
|
||||
"fake": {
|
||||
"buildTarget": "app:build:fake"
|
||||
"browserTarget": "app:build:fake"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
|
||||
@@ -129,9 +129,7 @@ describe('dashboard', async function () {
|
||||
fixture: 'search/types/message/single-message.json',
|
||||
}).as('search');
|
||||
|
||||
cy.get('stapps-news-section')
|
||||
.contains('ion-item', 'Mehr Nachrichten')
|
||||
.click({scrollBehavior: false, force: true});
|
||||
cy.get('stapps-news-section').contains('ion-item', 'Mehr Nachrichten').click();
|
||||
cy.url().should('include', '/news');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,7 +35,6 @@ const config: IconConfig = {
|
||||
'settings',
|
||||
'info',
|
||||
'rate_review',
|
||||
'work',
|
||||
],
|
||||
},
|
||||
codePoints: {
|
||||
|
||||
@@ -350,12 +350,12 @@
|
||||
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = YSGS9WV338;
|
||||
DEVELOPMENT_TEAM = QN788YUV45;
|
||||
INFOPLIST_FILE = App/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = de.openstapps.app;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = de.anyschool.app;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
@@ -372,11 +372,11 @@
|
||||
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = YSGS9WV338;
|
||||
DEVELOPMENT_TEAM = QN788YUV45;
|
||||
INFOPLIST_FILE = App/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = de.openstapps.app;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = de.anyschool.app;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
|
||||
|
||||
@@ -23,13 +23,8 @@
|
||||
"changelog": "conventional-changelog -p angular -i src/assets/about/CHANGELOG.md -s -r 0",
|
||||
"check-icons": "ts-node-esm scripts/check-icon-correctness.ts",
|
||||
"chromium:no-cors": "chromium --disable-web-security --user-data-dir=\".browser-data/chromium\"",
|
||||
"chromium:virtual-host": "chromium --host-resolver-rules=\"MAP mobile.app.uni-frankfurt.de:* localhost:8100\" --ignore-certificate-errors",
|
||||
"cypress:open": "cypress open",
|
||||
"cypress:run": "cypress run",
|
||||
"dev": "ng serve app",
|
||||
"dev:external": "ionic serve --external",
|
||||
"dev:prod": "ionic serve --prod",
|
||||
"dev:virtual-host": "ionic serve --public-host=mobile.app.uni-frankfurt.de --ssl=true --open=false",
|
||||
"docker:build": "sudo docker run -p 8100:8100 -p 35729:35729 -p 53703:53703 -v $PWD:/app -it registry.gitlab.com/openstapps/app bash -c \"npm install && npm run build\"",
|
||||
"docker:build:android": "sudo docker run -p 8100:8100 -p 35729:35729 -p 53703:53703 -v $PWD:/app -it registry.gitlab.com/openstapps/app bash -c \"npm run build:android\"",
|
||||
"docker:enter": "sudo docker run -p 8100:8100 -p 35729:35729 -p 53703:53703 -v $PWD:/app -it registry.gitlab.com/openstapps/app bash",
|
||||
@@ -49,20 +44,22 @@
|
||||
"resources:android": "cordova-res android --skip-config --copy",
|
||||
"resources:ios": "cordova-res ios --skip-config --copy",
|
||||
"run:android": "ionic capacitor run android --livereload --external",
|
||||
"start": "ionic serve",
|
||||
"start:external": "ionic serve --external",
|
||||
"start:prod": "ionic serve --prod",
|
||||
"test": "ng test --code-coverage",
|
||||
"test:integration": "sh integration-test.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/animations": "17.0.2",
|
||||
"@angular/cdk": "17.0.0",
|
||||
"@angular/common": "17.0.2",
|
||||
"@angular/core": "17.0.2",
|
||||
"@angular/elements": "17.0.2",
|
||||
"@angular/forms": "17.0.2",
|
||||
"@angular/platform-browser": "17.0.2",
|
||||
"@angular/router": "17.0.2",
|
||||
"@asymmetrik/ngx-leaflet": "17.0.0",
|
||||
"@asymmetrik/ngx-leaflet-markercluster": "17.0.0",
|
||||
"@angular/animations": "16.1.4",
|
||||
"@angular/cdk": "16.1.4",
|
||||
"@angular/common": "16.1.4",
|
||||
"@angular/core": "16.1.4",
|
||||
"@angular/forms": "16.1.4",
|
||||
"@angular/platform-browser": "16.1.4",
|
||||
"@angular/router": "16.1.4",
|
||||
"@asymmetrik/ngx-leaflet": "16.0.1",
|
||||
"@asymmetrik/ngx-leaflet-markercluster": "16.0.0",
|
||||
"@awesome-cordova-plugins/calendar": "5.45.0",
|
||||
"@awesome-cordova-plugins/core": "5.45.0",
|
||||
"@capacitor/app": "4.1.1",
|
||||
@@ -83,7 +80,7 @@
|
||||
"@capacitor/status-bar": "4.1.1",
|
||||
"@hugotomazi/capacitor-navigation-bar": "2.0.0",
|
||||
"@ionic-native/core": "5.36.0",
|
||||
"@ionic/angular": "7.5.5",
|
||||
"@ionic/angular": "7.1.3",
|
||||
"@ionic/storage-angular": "4.0.0",
|
||||
"@ngx-translate/core": "15.0.0",
|
||||
"@ngx-translate/http-loader": "8.0.0",
|
||||
@@ -99,7 +96,7 @@
|
||||
"deepmerge": "4.3.1",
|
||||
"form-data": "4.0.0",
|
||||
"geojson": "0.5.0",
|
||||
"ionic-appauth": "2.0.0",
|
||||
"ionic-appauth": "0.9.0",
|
||||
"jsonpath-plus": "6.0.1",
|
||||
"leaflet": "1.9.3",
|
||||
"leaflet.markercluster": "1.5.3",
|
||||
@@ -107,29 +104,29 @@
|
||||
"moment": "2.29.4",
|
||||
"ngx-date-fns": "10.0.1",
|
||||
"ngx-logger": "5.0.12",
|
||||
"ngx-markdown": "17.1.0",
|
||||
"ngx-markdown": "16.0.0",
|
||||
"ngx-moment": "6.0.2",
|
||||
"opening_hours": "3.8.0",
|
||||
"rxjs": "7.8.1",
|
||||
"swiper": "8.4.5",
|
||||
"tslib": "2.4.1",
|
||||
"zone.js": "0.14.2"
|
||||
"zone.js": "0.13.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/architect": "0.1700.0",
|
||||
"@angular-devkit/build-angular": "17.0.0",
|
||||
"@angular-devkit/core": "17.0.0",
|
||||
"@angular-devkit/schematics": "17.0.0",
|
||||
"@angular-eslint/builder": "17.0.1",
|
||||
"@angular-eslint/eslint-plugin": "17.0.1",
|
||||
"@angular-eslint/eslint-plugin-template": "17.0.1",
|
||||
"@angular-eslint/schematics": "17.0.1",
|
||||
"@angular-eslint/template-parser": "17.0.1",
|
||||
"@angular/cli": "17.0.0",
|
||||
"@angular/compiler": "17.0.2",
|
||||
"@angular/compiler-cli": "17.0.2",
|
||||
"@angular/language-service": "17.0.2",
|
||||
"@angular/platform-browser-dynamic": "17.0.2",
|
||||
"@angular-devkit/architect": "0.1601.4",
|
||||
"@angular-devkit/build-angular": "16.1.4",
|
||||
"@angular-devkit/core": "16.1.4",
|
||||
"@angular-devkit/schematics": "16.1.4",
|
||||
"@angular-eslint/builder": "16.1.0",
|
||||
"@angular-eslint/eslint-plugin": "16.1.0",
|
||||
"@angular-eslint/eslint-plugin-template": "16.1.0",
|
||||
"@angular-eslint/schematics": "16.1.0",
|
||||
"@angular-eslint/template-parser": "16.1.0",
|
||||
"@angular/cli": "16.1.4",
|
||||
"@angular/compiler": "16.1.4",
|
||||
"@angular/compiler-cli": "16.1.4",
|
||||
"@angular/language-service": "16.1.4",
|
||||
"@angular/platform-browser-dynamic": "16.1.4",
|
||||
"@capacitor/android": "4.6.1",
|
||||
"@capacitor/cli": "4.6.1",
|
||||
"@capacitor/ios": "4.6.1",
|
||||
@@ -151,14 +148,14 @@
|
||||
"@types/leaflet": "1.9.0",
|
||||
"@types/leaflet.markercluster": "1.5.1",
|
||||
"@types/node": "18.15.3",
|
||||
"@typescript-eslint/eslint-plugin": "6.10.0",
|
||||
"@typescript-eslint/parser": "6.10.0",
|
||||
"@typescript-eslint/eslint-plugin": "5.60.1",
|
||||
"@typescript-eslint/parser": "5.60.1",
|
||||
"cordova-res": "0.15.4",
|
||||
"cypress": "13.2.0",
|
||||
"eslint": "8.53.0",
|
||||
"eslint-plugin-jsdoc": "46.8.2",
|
||||
"eslint-plugin-prettier": "5.0.1",
|
||||
"eslint-plugin-unicorn": "49.0.0",
|
||||
"eslint": "8.43.0",
|
||||
"eslint-plugin-jsdoc": "46.4.2",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"eslint-plugin-unicorn": "47.0.0",
|
||||
"fontkit": "2.0.2",
|
||||
"glob": "10.2.7",
|
||||
"http-server": "14.1.1",
|
||||
@@ -181,9 +178,10 @@
|
||||
"stylelint-config-standard-scss": "10.0.0",
|
||||
"surge": "0.23.1",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "5.2.2",
|
||||
"typescript": "5.1.6",
|
||||
"webpack-bundle-analyzer": "4.7.0"
|
||||
},
|
||||
"prettier": "@openstapps/prettier-config",
|
||||
"cordova": {
|
||||
"plugins": {},
|
||||
"platforms": [
|
||||
|
||||
@@ -49,10 +49,7 @@ export class SharedAxisChoreographer<T> {
|
||||
*/
|
||||
currentValue: T;
|
||||
|
||||
constructor(
|
||||
initialValue: T,
|
||||
readonly pages?: T[],
|
||||
) {
|
||||
constructor(initialValue: T, readonly pages?: T[]) {
|
||||
this.currentValue = initialValue;
|
||||
this.expectedValue = initialValue;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
* 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 {AnimationBuilder, AnimationController} from '@ionic/angular/standalone';
|
||||
import {AnimationOptions} from '@ionic/angular/common/providers/nav-controller';
|
||||
|
||||
import {AnimationBuilder, AnimationController} from '@ionic/angular';
|
||||
import {AnimationOptions} from '@ionic/angular/providers/nav-controller';
|
||||
import {iosDuration, iosEasing, mdDuration, mdEasing} from './easings';
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {Platform} from '@ionic/angular/standalone';
|
||||
import {Platform} from '@ionic/angular';
|
||||
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {ThingTranslateService} from './translation/thing-translate.service';
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
* 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 {AfterContentInit, Component, inject, Injector, NgZone} from '@angular/core';
|
||||
import {AfterContentInit, Component, NgZone} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {App, URLOpenListenerEvent} from '@capacitor/app';
|
||||
import {Platform, ToastController} from '@ionic/angular/standalone';
|
||||
import {Platform, ToastController} from '@ionic/angular';
|
||||
import {SettingsProvider} from './modules/settings/settings.provider';
|
||||
import {AuthHelperService} from './modules/auth/auth-helper.service';
|
||||
import {environment} from '../environments/environment';
|
||||
@@ -24,8 +24,6 @@ import {Capacitor} from '@capacitor/core';
|
||||
import {ScheduleSyncService} from './modules/background/schedule/schedule-sync.service';
|
||||
import {NavigationBar} from '@hugotomazi/capacitor-navigation-bar';
|
||||
import {Keyboard, KeyboardResize} from '@capacitor/keyboard';
|
||||
import {createCustomElement} from '@angular/elements';
|
||||
import {IonIconComponent} from './util/ion-icon/ion-icon.component';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -72,9 +70,6 @@ export class AppComponent implements AfterContentInit {
|
||||
private readonly toastController: ToastController,
|
||||
private readonly scheduleSyncService: ScheduleSyncService,
|
||||
) {
|
||||
const IonIconElement = createCustomElement(IonIconComponent, {injector: inject(Injector)});
|
||||
customElements.define('ion-icon', IonIconElement);
|
||||
|
||||
void this.initializeApp();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import localeDe from '@angular/common/locales/de';
|
||||
import {APP_INITIALIZER, NgModule} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {RouteReuseStrategy} from '@angular/router';
|
||||
import {IonApp, IonicRouteStrategy, Platform} from '@ionic/angular/standalone';
|
||||
import {IonicModule, IonicRouteStrategy, Platform} from '@ionic/angular';
|
||||
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
|
||||
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
|
||||
import moment from 'moment';
|
||||
@@ -47,7 +47,6 @@ import {UtilModule} from './util/util.module';
|
||||
import {initLogger} from './_helpers/ts-logger';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {AboutModule} from './modules/about/about.module';
|
||||
import {JobModule} from './modules/jobs/jobs.module';
|
||||
import {FavoritesModule} from './modules/favorites/favorites.module';
|
||||
import {ProfilePageModule} from './modules/profile/profile.module';
|
||||
import {FeedbackModule} from './modules/feedback/feedback.module';
|
||||
@@ -68,7 +67,6 @@ import {browserFactory, SimpleBrowser} from './util/browser.factory';
|
||||
import {getDateFnsLocale} from './translation/dfns-locale';
|
||||
import {setDefaultOptions} from 'date-fns';
|
||||
import {DateFnsConfigurationService} from 'ngx-date-fns';
|
||||
import {provideIonicAngular} from '@ionic/angular/standalone';
|
||||
|
||||
registerLocaleData(localeDe);
|
||||
|
||||
@@ -134,7 +132,6 @@ export function createTranslateLoader(http: HttpClient) {
|
||||
bootstrap: [AppComponent],
|
||||
declarations: [AppComponent],
|
||||
imports: [
|
||||
IonApp,
|
||||
AboutModule,
|
||||
AppRoutingModule,
|
||||
AuthModule,
|
||||
@@ -148,8 +145,8 @@ export function createTranslateLoader(http: HttpClient) {
|
||||
DashboardModule,
|
||||
DataModule,
|
||||
HebisModule,
|
||||
IonicModule.forRoot(),
|
||||
IonIconModule,
|
||||
JobModule,
|
||||
FavoritesModule,
|
||||
LibraryModule,
|
||||
HttpClientModule,
|
||||
@@ -178,7 +175,6 @@ export function createTranslateLoader(http: HttpClient) {
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
provideIonicAngular(),
|
||||
{
|
||||
provide: RouteReuseStrategy,
|
||||
useClass: IonicRouteStrategy,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ModalController} from '@ionic/angular/standalone';
|
||||
import {ModalController} from '@ionic/angular';
|
||||
import {AboutLicenseModalComponent} from './about-license-modal.component';
|
||||
import licensesFile from 'src/assets/about/licenses.json';
|
||||
|
||||
|
||||
@@ -14,18 +14,18 @@
|
||||
-->
|
||||
|
||||
<div [ngSwitch]="content.type">
|
||||
<markdown [data]="'value' | translateSimple: content" *ngSwitchCase="'markdown'"></markdown>
|
||||
<markdown [data]="'value' | translateSimple : content" *ngSwitchCase="'markdown'"></markdown>
|
||||
<div *ngSwitchCase="'section'">
|
||||
<ion-card *ngIf="content.card; else noCard">
|
||||
<ion-card-header>
|
||||
<ion-card-title>{{ 'title' | translateSimple: content }}</ion-card-title>
|
||||
<ion-card-title>{{ 'title' | translateSimple : content }}</ion-card-title>
|
||||
</ion-card-header>
|
||||
<ion-card-content>
|
||||
<about-page-content [content]="content.content"></about-page-content>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
<ng-template #noCard>
|
||||
<h2>{{ 'title' | translateSimple: content }}</h2>
|
||||
<h2>{{ 'title' | translateSimple : content }}</h2>
|
||||
<about-page-content [content]="content.content"></about-page-content>
|
||||
</ng-template>
|
||||
</div>
|
||||
@@ -38,6 +38,6 @@
|
||||
</ion-grid>
|
||||
<ion-item *ngSwitchCase="'router link'" [routerLink]="content.link">
|
||||
<ion-icon *ngIf="content.icon" [name]="content.icon" slot="start"></ion-icon>
|
||||
<ion-label>{{ 'title' | translateSimple: content }}</ion-label>
|
||||
<ion-label>{{ 'title' | translateSimple : content }}</ion-label>
|
||||
</ion-item>
|
||||
</div>
|
||||
|
||||
@@ -31,10 +31,7 @@ export class AboutPageComponent implements OnInit {
|
||||
|
||||
version = packageJson.version;
|
||||
|
||||
constructor(
|
||||
private readonly route: ActivatedRoute,
|
||||
private readonly configProvider: ConfigProvider,
|
||||
) {}
|
||||
constructor(private readonly route: ActivatedRoute, private readonly configProvider: ConfigProvider) {}
|
||||
|
||||
async ngOnInit() {
|
||||
const route = this.route.snapshot.url.map(it => it.path).join('/');
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<ion-buttons slot="start">
|
||||
<ion-back-button></ion-back-button>
|
||||
</ion-buttons>
|
||||
<ion-title *ngIf="content; else titleLoading">{{ 'title' | translateSimple: content }}</ion-title>
|
||||
<ion-title *ngIf="content; else titleLoading">{{ 'title' | translateSimple : content }}</ion-title>
|
||||
<ng-template #titleLoading>
|
||||
<ion-title><ion-skeleton-text animated="true"></ion-skeleton-text></ion-title>
|
||||
</ng-template>
|
||||
|
||||
@@ -16,6 +16,7 @@ import {RouterModule, Routes} from '@angular/router';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
||||
import {ConfigProvider} from '../config/config.provider';
|
||||
@@ -54,6 +55,7 @@ const settingsRoutes: Routes = [
|
||||
CommonModule,
|
||||
IonIconModule,
|
||||
FormsModule,
|
||||
IonicModule.forRoot(),
|
||||
TranslateModule.forChild(),
|
||||
ThingTranslateModule.forChild(),
|
||||
RouterModule.forChild(settingsRoutes),
|
||||
|
||||
@@ -19,6 +19,7 @@ import {AssessmentBaseInfoComponent} from './types/assessment/assessment-base-in
|
||||
import {AssessmentDetailComponent} from './types/assessment/assessment-detail.component';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {DataModule} from '../data/data.module';
|
||||
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
||||
@@ -69,6 +70,7 @@ const routes: ProtectedRoutes = [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonIconModule,
|
||||
IonicModule,
|
||||
RouterModule.forChild(routes),
|
||||
TranslateModule,
|
||||
DataModule,
|
||||
|
||||
@@ -17,7 +17,7 @@ import {Component, DestroyRef, inject, Input, OnInit, ViewChild} from '@angular/
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {AssessmentsProvider} from '../assessments.provider';
|
||||
import {DataDetailComponent, ExternalDataLoadEvent} from '../../data/detail/data-detail.component';
|
||||
import {NavController} from '@ionic/angular/standalone';
|
||||
import {NavController} from '@ionic/angular';
|
||||
import {DataRoutingService} from '../../data/data-routing.service';
|
||||
import {SCAssessment} from '@openstapps/core';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
class="ion-text-wrap"
|
||||
*ngIf="assessments[key].courseOfStudy | async as course; else defaultLabel"
|
||||
>
|
||||
{{ 'name' | thingTranslate: course }} ({{ 'academicDegree' | thingTranslate: course }})
|
||||
{{ 'name' | thingTranslate : course }} ({{ 'academicDegree' | thingTranslate : course }})
|
||||
</ion-label>
|
||||
</div>
|
||||
<ng-template #defaultLabel>
|
||||
|
||||
@@ -14,12 +14,8 @@
|
||||
-->
|
||||
|
||||
<ion-label [color]="passed ? undefined : 'danger'"
|
||||
>{{
|
||||
(_item.grade | isNumeric)
|
||||
? (_item.grade | numberLocalized: 'minimumFractionDigits:1,maximumFractionDigits:1')
|
||||
: ''
|
||||
}}
|
||||
{{ 'status' | thingTranslate: _item | titlecase }}, {{ 'attempt' | propertyNameTranslate: _item }}
|
||||
{{ _item.attempt }}
|
||||
>{{ (_item.grade | isNumeric) ? (_item.grade | numberLocalized :
|
||||
'minimumFractionDigits:1,maximumFractionDigits:1') : '' }} {{ 'status' | thingTranslate : _item | titlecase
|
||||
}}, {{ 'attempt' | propertyNameTranslate : _item }} {{ _item.attempt }}
|
||||
</ion-label>
|
||||
<ion-note> {{ _item.ects }} {{ 'ects' | propertyNameTranslate: _item }}</ion-note>
|
||||
<ion-note> {{ _item.ects }} {{ 'ects' | propertyNameTranslate : _item }}</ion-note>
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
<ion-card>
|
||||
<ion-card-content>
|
||||
<ion-note *ngIf="item.courseOfStudy as courseOfStudy">
|
||||
{{ $any('courseOfStudy' | propertyNameTranslate: item) | titlecase }}:
|
||||
{{ 'name' | thingTranslate: $any(courseOfStudy) }} ({{
|
||||
'academicDegree' | thingTranslate: $any(courseOfStudy)
|
||||
}})
|
||||
{{ $any('courseOfStudy' | propertyNameTranslate : item) | titlecase }}: {{ 'name' | thingTranslate :
|
||||
$any(courseOfStudy) }} ({{ 'academicDegree' | thingTranslate : $any(courseOfStudy) }})
|
||||
</ion-note>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
-->
|
||||
|
||||
<div class="container">
|
||||
<h2 class="name">{{ 'name' | thingTranslate: item }} {{ item.date ? (item.date | amDateFormat) : '' }}</h2>
|
||||
<h2 class="name">{{ 'name' | thingTranslate : item }} {{ item.date ? (item.date | amDateFormat) : '' }}</h2>
|
||||
<assessment-base-info [item]="item"></assessment-base-info>
|
||||
</div>
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
|
||||
<div class="centered-message-container">
|
||||
<p>
|
||||
{{ 'auth.messages.authorizing' | translate }}
|
||||
{{ 'auth.messages' + '.' + PROVIDER_TYPE + '.' + 'authorizing' | translate }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -13,30 +13,28 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component} from '@angular/core';
|
||||
import {NavController} from '@ionic/angular/standalone';
|
||||
import {NavController} from '@ionic/angular';
|
||||
import {Router} from '@angular/router';
|
||||
import {AuthActions, IAuthAction} from 'ionic-appauth';
|
||||
import {SCAuthorizationProviderType} from '@openstapps/core';
|
||||
import {AuthHelperService} from '../../auth-helper.service';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {Observable} from 'rxjs';
|
||||
import {IPAIAAuthAction} from '../../paia/paia-auth-action';
|
||||
import {DefaultAuthService} from '../../default-auth.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'auth-callback-page.component.html',
|
||||
styleUrls: ['auth-callback-page.component.scss'],
|
||||
})
|
||||
export class AuthCallbackPageComponent {
|
||||
constructor(
|
||||
private navCtrl: NavController,
|
||||
private router: Router,
|
||||
private authHelper: AuthHelperService,
|
||||
private auth: DefaultAuthService,
|
||||
) {
|
||||
const events: Observable<IPAIAAuthAction | IAuthAction> = this.auth.events$;
|
||||
PROVIDER_TYPE: SCAuthorizationProviderType = 'default';
|
||||
|
||||
constructor(private navCtrl: NavController, private router: Router, private authHelper: AuthHelperService) {
|
||||
const provider = this.authHelper.getProvider(this.PROVIDER_TYPE);
|
||||
const events: Observable<IPAIAAuthAction | IAuthAction> = provider.events$;
|
||||
|
||||
events.pipe(takeUntilDestroyed()).subscribe((action: IAuthAction) => this.postCallback(action));
|
||||
this.auth.authorizationCallback(window.location.origin + this.router.url);
|
||||
provider.authorizationCallback(window.location.origin + this.router.url);
|
||||
}
|
||||
|
||||
async postCallback(action: IAuthAction) {
|
||||
|
||||
@@ -22,10 +22,7 @@ import {AuthHelperService} from './auth-helper.service';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthGuardService implements CanActivate {
|
||||
constructor(
|
||||
private authHelper: AuthHelperService,
|
||||
private router: Router,
|
||||
) {}
|
||||
constructor(private authHelper: AuthHelperService, private router: Router) {}
|
||||
|
||||
public async canActivate(route: ActivatedProtectedRouteSnapshot, _state: RouterStateSnapshot) {
|
||||
if (route.queryParamMap.get('token')) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import {StorageProvider} from '../storage/storage.provider';
|
||||
import {DefaultAuthService} from './default-auth.service';
|
||||
import {PAIAAuthService} from './paia/paia-auth.service';
|
||||
import {SimpleBrowser} from '../../util/browser.factory';
|
||||
import {AlertController} from '@ionic/angular/standalone';
|
||||
import {AlertController} from '@ionic/angular';
|
||||
|
||||
const AUTH_ORIGIN_PATH = 'stapps.auth.origin_path';
|
||||
|
||||
@@ -48,12 +48,11 @@ export class AuthHelperService {
|
||||
private browser: SimpleBrowser,
|
||||
private alertController: AlertController,
|
||||
) {
|
||||
this.userConfigurationMap =
|
||||
(
|
||||
this.configProvider.getAnyValue('auth') as {
|
||||
default: SCAuthorizationProvider;
|
||||
}
|
||||
).default?.endpoints.mapping ?? {};
|
||||
this.userConfigurationMap = (
|
||||
this.configProvider.getAnyValue('auth') as {
|
||||
default: SCAuthorizationProvider;
|
||||
}
|
||||
).default.endpoints.mapping;
|
||||
}
|
||||
|
||||
public getAuthMessage(provider: SCAuthorizationProviderType, action: IAuthAction | IPAIAAuthAction) {
|
||||
|
||||
@@ -17,8 +17,7 @@ import {RouterModule, Routes} from '@angular/router';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {authPaths} from './auth-paths';
|
||||
import {AuthCallbackPageComponent} from './auth-callback/page/auth-callback-page.component';
|
||||
import {DefaultAuthService} from './default-auth.service';
|
||||
import {PAIAAuthService} from './paia/paia-auth.service';
|
||||
import {PAIAAuthCallbackPageComponent} from './paia/auth-callback/page/paiaauth-callback-page.component';
|
||||
|
||||
const authRoutes: Routes = [
|
||||
{
|
||||
@@ -27,8 +26,7 @@ const authRoutes: Routes = [
|
||||
},
|
||||
{
|
||||
path: authPaths.paia.redirect_path,
|
||||
component: AuthCallbackPageComponent,
|
||||
providers: [{provide: DefaultAuthService, useExisting: PAIAAuthService}],
|
||||
component: PAIAAuthCallbackPageComponent,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {Platform} from '@ionic/angular/standalone';
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {Requestor, StorageBackend} from '@openid/appauth';
|
||||
import {storageFactory} from './factories';
|
||||
import {Browser} from 'ionic-appauth';
|
||||
@@ -10,11 +10,12 @@ import {HttpClient} from '@angular/common/http';
|
||||
import {AuthRoutingModule} from './auth-routing.module';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {AuthCallbackPageComponent} from './auth-callback/page/auth-callback-page.component';
|
||||
import {PAIAAuthCallbackPageComponent} from './paia/auth-callback/page/paiaauth-callback-page.component';
|
||||
import {DefaultAuthService} from './default-auth.service';
|
||||
import {PAIAAuthService} from './paia/paia-auth.service';
|
||||
|
||||
@NgModule({
|
||||
declarations: [AuthCallbackPageComponent],
|
||||
declarations: [AuthCallbackPageComponent, PAIAAuthCallbackPageComponent],
|
||||
imports: [CommonModule, AuthRoutingModule, TranslateModule],
|
||||
providers: [
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Platform} from '@ionic/angular/standalone';
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {CapacitorRequestor} from '../capacitor-requestor';
|
||||
import {NgHttpService} from '../ng-http.service';
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {Platform} from '@ionic/angular/standalone';
|
||||
import {Platform} from '@ionic/angular';
|
||||
import {IonicStorage} from 'ionic-appauth/lib';
|
||||
import {SafeCapacitorSecureStorage} from '../../storage/capacitor-secure-storage';
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 {Component} from '@angular/core';
|
||||
import {AuthCallbackPageComponent} from '../../../auth-callback/page/auth-callback-page.component';
|
||||
import {SCAuthorizationProviderType} from '@openstapps/core';
|
||||
import {NavController} from '@ionic/angular';
|
||||
import {Router} from '@angular/router';
|
||||
import {AuthHelperService} from '../../../auth-helper.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: '../../../auth-callback/page/auth-callback-page.component.html',
|
||||
styleUrls: ['../../../auth-callback/page/auth-callback-page.component.scss'],
|
||||
})
|
||||
export class PAIAAuthCallbackPageComponent extends AuthCallbackPageComponent {
|
||||
PROVIDER_TYPE = 'paia' as SCAuthorizationProviderType;
|
||||
|
||||
constructor(navCtrl: NavController, router: Router, authHelper: AuthHelperService) {
|
||||
super(navCtrl, router, authHelper);
|
||||
}
|
||||
}
|
||||
@@ -134,9 +134,9 @@ export class ScheduleSyncService {
|
||||
private formatChanges(changes: ChangesOf<SCDateSeries, DateSeriesRelevantData>): string[] {
|
||||
return changes.changes.map(
|
||||
change =>
|
||||
`${this.translator.translator.translatedPropertyNames<SCDateSeries>(SCThingType.DateSeries)?.[
|
||||
change
|
||||
]}: ${formatRelevantKeys[change](
|
||||
`${
|
||||
this.translator.translator.translatedPropertyNames<SCDateSeries>(SCThingType.DateSeries)?.[change]
|
||||
}: ${formatRelevantKeys[change](
|
||||
changes.new[change] as never,
|
||||
this.dateFormatPipe,
|
||||
this.durationFormatPipe,
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<s *ngIf="iCalEvent.cancelled; else date"
|
||||
><ng-container [ngTemplateOutlet]="date"></ng-container>
|
||||
</s>
|
||||
<ng-template #date> {{ moment(iCalEvent.start) | amDateFormat: 'll, HH:mm' }} </ng-template>
|
||||
<ng-template #date> {{ moment(iCalEvent.start) | amDateFormat : 'll, HH:mm' }} </ng-template>
|
||||
</ion-label>
|
||||
<ion-note *ngIf="iCalEvent.rrule">
|
||||
{{ iCalEvent.rrule.interval }} {{ iCalEvent.rrule.freq | sentencecase }}
|
||||
@@ -47,9 +47,9 @@
|
||||
|
||||
<div class="horizontal-flex">
|
||||
<ion-item lines="none">
|
||||
<ion-checkbox [(ngModel)]="includeCancelled">{{
|
||||
'schedule.toCalendar.reviewModal.INCLUDE_CANCELLED' | translate
|
||||
}}</ion-checkbox>
|
||||
<ion-checkbox [(ngModel)]="includeCancelled"
|
||||
>{{ 'schedule.toCalendar.reviewModal.INCLUDE_CANCELLED' | translate }}</ion-checkbox
|
||||
>
|
||||
</ion-item>
|
||||
</div>
|
||||
<div class="horizontal-flex">
|
||||
|
||||
@@ -18,6 +18,7 @@ import {AddEventReviewModalComponent} from './add-event-review-modal.component';
|
||||
import {Calendar} from '@awesome-cordova-plugins/calendar/ngx';
|
||||
import {CalendarService} from './calendar.service';
|
||||
import {ScheduleProvider} from './schedule.provider';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
@@ -29,6 +30,7 @@ import {IonIconModule} from '../../util/ion-icon/ion-icon.module';
|
||||
@NgModule({
|
||||
declarations: [AddEventReviewModalComponent],
|
||||
imports: [
|
||||
IonicModule.forRoot(),
|
||||
TranslateModule.forChild(),
|
||||
ThingTranslateModule.forChild(),
|
||||
IonIconModule,
|
||||
|
||||
@@ -38,10 +38,7 @@ export class CalendarService {
|
||||
calendarName = 'StApps';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
constructor(
|
||||
readonly calendar: Calendar,
|
||||
private readonly configProvider: ConfigProvider,
|
||||
) {
|
||||
constructor(readonly calendar: Calendar, private readonly configProvider: ConfigProvider) {
|
||||
this.calendarName = (this.configProvider.getValue('name') as string) ?? 'StApps';
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import {CommonModule} from '@angular/common';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {MomentModule} from 'ngx-moment';
|
||||
import {DataModule} from '../data/data.module';
|
||||
@@ -35,6 +36,7 @@ const catalogRoutes: Routes = [
|
||||
@NgModule({
|
||||
declarations: [CatalogComponent],
|
||||
imports: [
|
||||
IonicModule.forRoot(),
|
||||
FormsModule,
|
||||
TranslateModule.forChild(),
|
||||
RouterModule.forChild(catalogRoutes),
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
*/
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Client} from '@openstapps/api';
|
||||
import {SCAppConfiguration, SCIndexResponse, STAPPS_CORE_VERSION} from '@openstapps/core';
|
||||
import {SCAppConfiguration, SCIndexResponse} from '@openstapps/core';
|
||||
import packageInfo from '@openstapps/core/package.json';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
import {environment} from '../../../environments/environment';
|
||||
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
|
||||
@@ -54,7 +55,7 @@ export class ConfigProvider {
|
||||
/**
|
||||
* Version of the @openstapps/core package that app is using
|
||||
*/
|
||||
scVersion = STAPPS_CORE_VERSION;
|
||||
scVersion = packageInfo.version;
|
||||
|
||||
/**
|
||||
* First session indicator (config not found in storage)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {Animation, AnimationController} from '@ionic/angular/standalone';
|
||||
import {Animation, AnimationController} from '@ionic/angular';
|
||||
import {NgZone} from '@angular/core';
|
||||
|
||||
export class DashboardCollapse {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<ion-label>
|
||||
{{
|
||||
nextEvent
|
||||
? (nextEvent!.dates | nextDateInList | amDateFormat: 'll, HH:mm')
|
||||
? (nextEvent!.dates | nextDateInList | amDateFormat : 'll, HH:mm')
|
||||
: ('dashboard.schedule.noEvent' | translate)
|
||||
}}
|
||||
</ion-label>
|
||||
@@ -48,5 +48,4 @@
|
||||
<stapps-news-section></stapps-news-section>
|
||||
<stapps-mensa-section></stapps-mensa-section>
|
||||
<stapps-favorites-section></stapps-favorites-section>
|
||||
<stapps-job-section></stapps-job-section>
|
||||
</ion-content>
|
||||
|
||||
@@ -20,7 +20,7 @@ import {SCDateSeries, SCUuid} from '@openstapps/core';
|
||||
import {SplashScreen} from '@capacitor/splash-screen';
|
||||
import {DataRoutingService} from '../data/data-routing.service';
|
||||
import {ScheduleProvider} from '../calendar/schedule.provider';
|
||||
import {AnimationController, IonContent} from '@ionic/angular/standalone';
|
||||
import {AnimationController, IonContent} from '@ionic/angular';
|
||||
import {DashboardCollapse} from './dashboard-collapse';
|
||||
import {BreakpointObserver} from '@angular/cdk/layout';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
@@ -28,7 +28,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
templateUrl: './dashboard.component.html',
|
||||
styleUrls: ['./dashboard.component.scss', './dashboard.collapse.component.scss'],
|
||||
styleUrls: ['./dashboard.component.scss', '/dashboard.collapse.component.scss'],
|
||||
})
|
||||
export class DashboardComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('toolbar', {read: ElementRef}) toolbarRef: ElementRef;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user