refactor: split api into api, api-cli & api-plugin

This commit is contained in:
2023-06-02 16:41:25 +02:00
parent 495a63977c
commit b21833de40
205 changed files with 1981 additions and 1492 deletions

View File

@@ -20,7 +20,7 @@
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "eslint --ext .ts src/",
"lint:fix": "eslint --fix --ext .ts src/",
"test": "c8 mocha"
"test": "c8 mocha --exit"
},
"dependencies": {
"@openstapps/api": "workspace:*",
@@ -45,7 +45,7 @@
"nock": "13.3.1",
"ts-node": "10.9.1",
"tsup": "6.7.0",
"typescript": "4.8.4"
"typescript": "4.9.5"
},
"tsup": {
"entry": [

View File

@@ -18,7 +18,6 @@ import {Connector} from './connector.js';
/**
* Checks if the input is a valid SCNamespace
*
* @param input Name of the potential SCNamespace
*/
export function isValidSCNamespace(input: string): input is SCLicensePlate {
@@ -29,7 +28,6 @@ export function isValidSCNamespace(input: string): input is SCLicensePlate {
* Creates a uuid from a JSON stringified item identifier
*
* You may create custom itemIdentifier-Interfaces to generate UIDs consistently
*
* @param itemIdentifier Identifying representation of the item
* @param licensePlate License plate of the school
*/
@@ -40,7 +38,6 @@ export function createUUID(itemIdentifier: unknown, licensePlate: SCLicensePlate
/**
* Fetches items specified by the connector and pushs them to the backend,
* by overwriting the bulk indexed with the `origin`.
*
* @param backend URL of the StApps backend eployment
* @param connector Connector to be executed
*/

View File

@@ -20,7 +20,6 @@ import {createUUID} from './common.js';
*
* By extending this class connector-developers only need to implement the load and transform of the data
* Pushing the data to the backend will be handled automatically
*
* @template T Any serializable type
*/
export abstract class Connector<T extends SCThings> {
@@ -36,7 +35,6 @@ export abstract class Connector<T extends SCThings> {
/**
* Abstract constructor for a connector
*
* @param licensePlate License plate of the school
* @param origin Name of the connector
*/

View File

@@ -27,7 +27,6 @@ export class MinimalConnector extends Connector<SCMessage> {
/**
* Constructor for the MinimalConnector
*
* @param licensePlate License plate of the school
* @param origin Name of the connector
*/

View File

@@ -20,6 +20,7 @@
},
"dependencies": {
"@openstapps/api": "workspace:*",
"@openstapps/api-plugin": "workspace:*",
"@openstapps/core": "workspace:*",
"@openstapps/core-tools": "workspace:*",
"@openstapps/logger": "workspace:*",
@@ -34,7 +35,7 @@
"@types/express": "4.17.17",
"@types/node": "18.15.3",
"tsup": "6.7.0",
"typescript": "4.8.4"
"typescript": "4.9.5"
},
"tsup": {
"entry": [

View File

@@ -13,7 +13,8 @@
* 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 {HttpClient, PluginClient} from '@openstapps/api';
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';

View File

@@ -12,7 +12,7 @@
* 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 {Plugin} from '@openstapps/api';
import {Plugin} from '@openstapps/api-plugin';
import * as express from 'express';
import {SCMinimalRequest} from './protocol/request.js';
import {SCMinimalResponse} from './protocol/response.js';
@@ -28,7 +28,6 @@ export class MinimalPlugin extends Plugin {
* Calculates the sum of a list of numbers
*
* TODO: remove this function and write your own ones
*
* @param numbers the list of numbers
*/
private static sum(numbers: number[]): number {
@@ -40,7 +39,6 @@ export class MinimalPlugin extends Plugin {
*
* For this example the whole purpose of the plugin is to receive a list of numbers and return the sum of them.
* TODO: remove the body of the function and replace with your own logic
*
* @param request the express request object
* @param response the express response object
*/

View File

@@ -19,7 +19,6 @@
* 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 {

View File

@@ -19,7 +19,6 @@
* 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 {