feat: Use container for the API service
@@ -7,8 +7,9 @@
|
||||
cache/
|
||||
node_modules/
|
||||
|
||||
# Docker
|
||||
docker/
|
||||
# Database
|
||||
mariadb/data/
|
||||
mongodb/data/
|
||||
|
||||
# Build files
|
||||
build/
|
||||
|
||||
|
After Width: | Height: | Size: 494 KiB |
|
After Width: | Height: | Size: 380 KiB |
|
After Width: | Height: | Size: 481 KiB |
|
After Width: | Height: | Size: 288 KiB |
|
After Width: | Height: | Size: 271 KiB |
|
After Width: | Height: | Size: 265 KiB |
|
After Width: | Height: | Size: 246 KiB |
|
After Width: | Height: | Size: 332 KiB |
|
After Width: | Height: | Size: 404 KiB |
@@ -1,103 +1,132 @@
|
||||
# Mit-Vab-Compo-Service-Logiciel
|
||||
# Projet CSL
|
||||
|
||||
## Getting started
|
||||
[](./LICENSE)
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
> Ce projet utilise les micro-services pour filtrer et collecter des données
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
## Prérequis
|
||||
|
||||
## Add your files
|
||||
Pour pouvoir lancer ce projet vous devez avoir installé les outils suivants :
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
- [Docker Desktop](#installation-de-docker-desktop)
|
||||
- [Insonmia](#installation-de-insomnia)
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://git.univ-pau.fr/kmitresse/project-service-log.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
Assurez-vous d'avoir les ports `3000`, `3306` et `27017` de disponible sur votre machine.
|
||||
|
||||
### Installation de Docker Desktop
|
||||
|
||||
Docker Desktop est un outil qui permet de gérer des conteneurs Docker sur votre
|
||||
machine.
|
||||
Il est disponible pour Windows, MacOS et Linux.
|
||||
|
||||
A l'installation de Docker Desktop : Docker engine et Docker compose seront
|
||||
installés.
|
||||
De plus Docker Desktop installe une interface graphique pour gérer les
|
||||
conteneurs.
|
||||
|
||||
Pour installer Docker Desktop sur votre machine vous pouvez suivre les
|
||||
instructions sur
|
||||
le site officiel de Docker :
|
||||
[https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/)
|
||||
|
||||
Une fois Docker Desktop installé, vous pouvez vérifier que tout fonctionne
|
||||
correctement
|
||||
en ouvrant un terminal et en tapant les commandes suivantes :
|
||||
|
||||
```sh
|
||||
docker --version
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
```sh
|
||||
docker-compose --version
|
||||
```
|
||||
|
||||
- [ ] [Set up project integrations](https://git.univ-pau.fr/kmitresse/project-service-log/-/settings/integrations)
|
||||
Vous pouvez également vérifier que Docker Desktop est bien lancé en ouvrant
|
||||
l'interface graphique.
|
||||
|
||||
## Collaborate with your team
|
||||

|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
### Installation de Insomnia
|
||||
|
||||
## Test and Deploy
|
||||
Insomnia est un outil qui permet de tester des API REST.
|
||||
Il est disponible pour Windows, MacOS et Linux.
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
Pour installer Insomnia sur votre machine vous pouvez suivre les instructions
|
||||
sur
|
||||
le site officiel de Insomnia : https://insomnia.rest/download
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
Une fois Insomnia installé, vous pouvez le lancer et vous obtiendrez cette
|
||||
interface :
|
||||

|
||||
|
||||
---
|
||||
Vous pouvez ensuite importer le fichier de test `2024-12-17.json` qui se trouve
|
||||
dans le dossier `app/test/insomnia/`.
|
||||
|
||||
# Editing this README
|
||||
Pour cela, cliquez sur le bouton `import`
|
||||

|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
Cliquez sur `+ File` puis `Choose a file` et sélectionnez le fichier
|
||||
`2024-12-17.json` et cliquez sur `open` ou `Ouvrir`.
|
||||

|
||||
|
||||
## Suggestions for a good README
|
||||
Enfin cliquez sur `Scan` pour scanner le fichier à importer puis sur `Import`.
|
||||

|
||||

|
||||
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
Et voilà vous avez importé le fichier de test ! 🎉
|
||||
|
||||
## Name
|
||||
Une nouvelle collection est apparue, vous pouvez la sélectionner pour voir les
|
||||
requêtes qui ont été importées.
|
||||

|
||||

|
||||
|
||||
Choose a self-explaining name for your project.
|
||||
## Lancez le projet
|
||||
|
||||
## Description
|
||||
Pour lancer le projet, ouvrez votre terminal et rendez-vous à la racine du
|
||||
projet.
|
||||
Ensuite exécutez la commande suivante :
|
||||
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
```sh
|
||||
docker-compose -up -d --build
|
||||
```
|
||||
|
||||
## Badges
|
||||
Cette commande va construire les images Docker et lancer les conteneurs.
|
||||
En effet, cette application contient 3 services :
|
||||
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
- `app` : expose l'API REST (sur le port `3000`)
|
||||
- `mongodb` : contient la base de données qui va stocker les données filtrées (sur le port `27017`)
|
||||
- `mariadb`: contient la base de donnée des logs (sur le port `3306`)
|
||||
|
||||
## Visuals
|
||||
Vous pouvez vérifier que les conteneurs sont bien lancés en exécutant la
|
||||
commande suivante :
|
||||
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
```sh
|
||||
docker ps
|
||||
```
|
||||
|
||||
## Installation
|
||||
Vous devriez voir les 3 conteneurs lancés.
|
||||
```
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
7d90351a5dd4 compo-service-log-project-app "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:3000->3000/tcp app
|
||||
f77729fee31b mongo "docker-entrypoint.s…" 2 hours ago Up 2 hours 27017/tcp mongodb
|
||||
f59177f86802 mariadb "docker-entrypoint.s…" 2 hours ago Up 2 hours 0.0.0.0:3306->3306/tcp mariadb
|
||||
```
|
||||
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
Vous pouvez également vérifier que les conteneurs sont bien lancés en ouvrant l'interface graphique de Docker Desktop.
|
||||

|
||||
|
||||
## Usage
|
||||
Il se peut que le conteneur `app` redémarre plusieurs fois avant de se stabiliser.
|
||||
Cela est dû au fait que le conteneur `app` démarre plus vite que les conteneurs `mongodb` et `mariadb`.
|
||||
Et celui-ci essaye de se connecter aux bases de données mais elles ne sont pas encore prêtes.
|
||||
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
## Tester l'API
|
||||
|
||||
## Support
|
||||
Pour tester l'API rendez-vous sur Insomnia avec la collection importée et
|
||||
assurez-vous que les conteneurs sont bien lancés.
|
||||
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
## Autheurs
|
||||
|
||||
## Contributing
|
||||
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
- 👤 [Kevin Mitressé](https://github.com/kmitresse)
|
||||
- 👤 [Lucàs Vabre](https://github.com/LucasVbr)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
build
|
||||
@@ -0,0 +1,46 @@
|
||||
FROM node:16
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ARG APP_ENV=development
|
||||
ARG APP_HOST=app
|
||||
ARG APP_PORT=3000
|
||||
|
||||
ARG MARIADB_HOST=mariadb
|
||||
ARG MARIADB_PORT=3306
|
||||
ARG MARIADB_USER=root
|
||||
ARG MARIADB_PASSWORD=root
|
||||
ARG MARIADB_DATABASE=db
|
||||
|
||||
ARG MONGODB_HOST=mongodb
|
||||
ARG MONGODB_PORT=27017
|
||||
ARG MONGODB_USER=root
|
||||
ARG MONGODB_PASSWORD=root
|
||||
ARG MONGODB_DATABASE=db
|
||||
|
||||
ENV APP_ENV=$APP_ENV
|
||||
ENV PORT=$APP_PORT
|
||||
|
||||
ENV MARIADB_HOST=$MARIADB_HOST
|
||||
ENV MARIADB_PORT=$MARIADB_PORT
|
||||
ENV MARIADB_USER=$MARIADB_USER
|
||||
ENV MARIADB_PASSWORD=$MARIADB_PASSWORD
|
||||
ENV MARIADB_DATABASE=$MARIADB_DATABASE
|
||||
|
||||
ENV MONGODB_HOST=$MONGODB_HOST
|
||||
ENV MONGODB_PORT=$MONGODB_PORT
|
||||
ENV MONGODB_USER=$MONGODB_USER
|
||||
ENV MONGODB_PASSWORD=$MONGODB_PASSWORD
|
||||
ENV MONGODB_DATABASE=$MONGODB_DATABASE
|
||||
|
||||
COPY package.json .
|
||||
COPY tsconfig.json .
|
||||
COPY .prettierrc .
|
||||
COPY .prettierignore .
|
||||
|
||||
VOLUME /app/src
|
||||
|
||||
RUN npm install
|
||||
CMD sh -c "if [ \"$APP_ENV\" = \"production\" ]; then npm run start; else npm run dev; fi"
|
||||
|
||||
EXPOSE $PORT
|
||||
@@ -3,16 +3,17 @@
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "npm run format && npx ts-node ./src/index.ts",
|
||||
"dev": "npx nodemon src/index.ts",
|
||||
"start": "npm run build && node build/index.js",
|
||||
"build": "npx tsc",
|
||||
"format": "npx prettier . --write --log-level warn"
|
||||
"format": "npx prettier .. --write --log-level warn"
|
||||
},
|
||||
"keywords": [],
|
||||
"authors": [
|
||||
"Kevin Mitressé",
|
||||
"Lucàs Vabre"
|
||||
],
|
||||
"license": "ISC",
|
||||
"license": "MIT",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"axios": "^1.7.7",
|
||||
@@ -35,6 +36,7 @@
|
||||
"@types/node": "^22.5.5",
|
||||
"@types/tar-stream": "^3.1.3",
|
||||
"@types/unzipper": "^0.10.10",
|
||||
"nodemon": "^3.1.9",
|
||||
"prettier": "3.3.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.6.2"
|
||||
@@ -1,15 +1,23 @@
|
||||
import express from "express";
|
||||
import routes from "./routes";
|
||||
import router from "./routes/randomize";
|
||||
import { createServer } from "node:http";
|
||||
import { bodyToSchema, logger, xmlBodyParser } from "./middlewares";
|
||||
import { bodyToSchema, xmlBodyParser } from "./middlewares";
|
||||
|
||||
export default class Server {
|
||||
private readonly app: express.Application;
|
||||
private static PORT: number = 4321;
|
||||
private static PORT: number =
|
||||
process.env.PORT
|
||||
? parseInt(process.env.PORT)
|
||||
: 3000;
|
||||
|
||||
constructor() {
|
||||
this.app = express();
|
||||
this.app.use(express.json(), xmlBodyParser, bodyToSchema, logger, routes);
|
||||
this.app.use(
|
||||
express.json(),
|
||||
xmlBodyParser,
|
||||
bodyToSchema,
|
||||
router,
|
||||
);
|
||||
}
|
||||
|
||||
public start() {
|
||||
@@ -0,0 +1,17 @@
|
||||
import "reflect-metadata";
|
||||
import { DataSource } from "typeorm";
|
||||
import { Log } from "./entity/Log";
|
||||
|
||||
export const TypeOrmDataSource = new DataSource({
|
||||
type: "mariadb",
|
||||
host: process.env.MARIADB_HOST || "localhost",
|
||||
port: process.env.MARIADB_PORT ? parseInt(process.env.MARIADB_PORT) : 3306,
|
||||
username: process.env.MARIADB_USER || "root",
|
||||
password: process.env.MARIADB_PASSWORD || "root",
|
||||
database: process.env.MARIADB_DATABASE || "database",
|
||||
synchronize: true,
|
||||
logging: false,
|
||||
entities: [Log],
|
||||
subscribers: [],
|
||||
migrations: [],
|
||||
});
|
||||
@@ -17,13 +17,18 @@ export class Log {
|
||||
@Column("blob")
|
||||
body: string = "";
|
||||
|
||||
@Column("blob")
|
||||
output: string = "";
|
||||
|
||||
constructor(
|
||||
url: string,
|
||||
method: "GET" | "POST" | "PUT" | "DELETE",
|
||||
body: string
|
||||
body: string,
|
||||
output: string,
|
||||
) {
|
||||
this.url = url;
|
||||
this.method = method;
|
||||
this.body = body;
|
||||
this.output = output;
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@ import { TypeOrmDataSource } from "./TypeOrmDataSource";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
TypeOrmDataSource.initialize()
|
||||
.then(() => DatasetCollection.loadAll())
|
||||
TypeOrmDataSource.initialize().then(() => {
|
||||
new Server().start();
|
||||
DatasetCollection.loadAll()
|
||||
.then(() => console.log("All datasets are loaded"))
|
||||
.catch(console.error);
|
||||
|
||||
new Server().start();
|
||||
});
|
||||
@@ -4,11 +4,12 @@ import { DMN } from "../services/dmn/DMN";
|
||||
|
||||
export default async function (
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
_: Response,
|
||||
next: NextFunction,
|
||||
) {
|
||||
if (req.is("application/xml")) {
|
||||
const dmn: Definitions = await DMN.parse(req.body);
|
||||
|
||||
req.body = DMN.getSchema(dmn);
|
||||
next();
|
||||
} else next();
|
||||
@@ -1,3 +1,2 @@
|
||||
export { default as logger } from "./logger";
|
||||
export { default as xmlBodyParser } from "./xmlBodyParser";
|
||||
export { default as bodyToSchema } from "./bodyToSchema";
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
|
||||
export default function (req: Request, res: Response, next: NextFunction) {
|
||||
export default function (req: Request, _: Response, next: NextFunction) {
|
||||
if (req.is("application/xml")) {
|
||||
let data = "";
|
||||
req.setEncoding("utf8");
|
||||
@@ -0,0 +1,71 @@
|
||||
import { Router, Request, Response } from "express";
|
||||
import { DatasetCollection } from "../services/dataset";
|
||||
import axios from "axios";
|
||||
import { Log } from "../entity/Log";
|
||||
import { TypeOrmDataSource } from "../TypeOrmDataSource";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.all("/", (_: Request, res: Response) => {
|
||||
res.status(200).json({
|
||||
status: "OK",
|
||||
routes: ["/randomize", "/randomize/:id"],
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/randomize", async (req: Request, res: Response) => {
|
||||
const size: number = req.query.size ? parseInt(req.query.size as string) : 10;
|
||||
if (size < 1) return res.status(400).json({ status: "INVALID_SIZE" });
|
||||
let output: { status: string; data?: any[]; error?: any; };
|
||||
|
||||
await Promise
|
||||
.all(
|
||||
DatasetCollection.datasets.map((dataset) =>
|
||||
axios.post(dataset.endpoint, req.body, { params: { size } })
|
||||
.then((res) => res.data.data),
|
||||
),
|
||||
)
|
||||
.then((r) => r.flat()
|
||||
.sort(() => Math.random() - 0.5)
|
||||
.slice(0, size))
|
||||
.then((data) => {
|
||||
output = { status: "RANDOMIZED", data };
|
||||
res.status(200).json(output);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
output = { status: "ERROR", error: e.message };
|
||||
const log: Log = new Log(
|
||||
req.url,
|
||||
req.method as any,
|
||||
JSON.stringify(req.body),
|
||||
JSON.stringify(output),
|
||||
);
|
||||
await TypeOrmDataSource.manager.save(log);
|
||||
|
||||
return res.status(500).json(output);
|
||||
})
|
||||
.finally(() => {
|
||||
const log: Log = new Log(
|
||||
req.url,
|
||||
req.method as any,
|
||||
JSON.stringify(req.body),
|
||||
JSON.stringify(output),
|
||||
);
|
||||
TypeOrmDataSource.manager.save(log);
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/randomize/:id", async (req: Request, res: Response) => {
|
||||
const { id } = req.params;
|
||||
const size: number = req.query.size ? parseInt(req.query.size as string) : 10;
|
||||
|
||||
const dataset = DatasetCollection.datasets.find(
|
||||
(dataset) => dataset.id === id,
|
||||
);
|
||||
if (!dataset) return res.status(404).json({ status: "NOT_FOUND" });
|
||||
|
||||
const data = await dataset.get(size, req.body);
|
||||
return res.status(200).json({ status: "RANDOMIZED", data });
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -1,14 +1,17 @@
|
||||
import { MongoClient, Db } from "mongodb";
|
||||
|
||||
const uri = "mongodb://localhost:27017";
|
||||
const dbName = "db";
|
||||
const uri: string = `mongodb://${process.env.MONGODB_HOST}:${process.env.MONGODB_PORT}`;
|
||||
const dbName: string = process.env.MONGODB_DATABASE || "database";
|
||||
|
||||
let db: Db;
|
||||
|
||||
export const getDatabaseConnexion = async (): Promise<Db> => {
|
||||
if (!db) {
|
||||
const client = new MongoClient(uri, {
|
||||
auth: { username: "root", password: "root" },
|
||||
auth: {
|
||||
username: process.env.MONGODB_USER || "user",
|
||||
password: process.env.MONGODB_PASSWORD || "password",
|
||||
},
|
||||
connectTimeoutMS: 60000,
|
||||
socketTimeoutMS: 60000,
|
||||
});
|
||||
@@ -11,7 +11,7 @@ class FileService {
|
||||
*/
|
||||
public static async getFileStream(url: string): Promise<Readable> {
|
||||
return axios({ method: "GET", url, responseType: "stream" }).then(
|
||||
(response) => response.data
|
||||
(response) => response.data,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export default class Dataset {
|
||||
readonly endpoint: string;
|
||||
|
||||
private extractor: Extractor = ExtractorFactory.getExtractor(
|
||||
ExtractorType.NONE
|
||||
ExtractorType.NONE,
|
||||
);
|
||||
private parser: Parser = ParserFactory.getParser(ParserType.CSV);
|
||||
private extractorOptions: any;
|
||||
@@ -108,7 +108,7 @@ export default class Dataset {
|
||||
.then(() => callback())
|
||||
.catch((error) => callback(error));
|
||||
},
|
||||
})
|
||||
}),
|
||||
)
|
||||
.then(async () => {
|
||||
if (buffer.length > 0) {
|
||||
@@ -117,7 +117,7 @@ export default class Dataset {
|
||||
})
|
||||
.then(() => console.log(`Dataset ${this.id} loaded`))
|
||||
.catch((error) =>
|
||||
console.error(`Error loading dataset ${this.id}: ${error.message}`)
|
||||
console.error(`Error loading dataset ${this.id}: ${error.message}`),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Dataset } from "./";
|
||||
import { Dataset } from "./index";
|
||||
import { ParserType } from "../parser";
|
||||
import WorldCitiesDataTransformer from "../data_transformer/WorldCitiesDataTransformer";
|
||||
import { ExtractorType } from "../archive_extractor/ExtractorFactory";
|
||||
@@ -10,7 +10,7 @@ class DatasetCollection {
|
||||
new Dataset({
|
||||
id: "nudger",
|
||||
uri: "https://files.opendatarchives.fr/data.cquest.org/open4goods/gtin-open-data.zip",
|
||||
endpoint: "http://localhost:4321/randomize/nudger",
|
||||
endpoint: `http://localhost:${process.env.PORT || 3000}/randomize/nudger`,
|
||||
})
|
||||
.setExtractor(ExtractorType.ZIP, {
|
||||
file: "open4goods-full-gtin-dataset.csv",
|
||||
@@ -20,7 +20,7 @@ class DatasetCollection {
|
||||
new Dataset({
|
||||
id: "openfoodfacts",
|
||||
uri: "https://static.openfoodfacts.org/data/en.openfoodfacts.org.products.csv.gz",
|
||||
endpoint: "http://localhost:4321/randomize/openfoodfacts",
|
||||
endpoint: `http://localhost:${process.env.PORT || 3000}/randomize/openfoodfacts`,
|
||||
})
|
||||
.setExtractor(ExtractorType.GZIP, {
|
||||
file: "en.openfoodfacts.org.products.csv",
|
||||
@@ -30,7 +30,7 @@ class DatasetCollection {
|
||||
new Dataset({
|
||||
id: "world-cities",
|
||||
uri: "https://raw.githubusercontent.com/datasets/world-cities/refs/heads/main/data/world-cities.csv",
|
||||
endpoint: "http://localhost:4321/randomize/world-cities",
|
||||
endpoint: `http://localhost:${process.env.PORT || 3000}/randomize/world-cities`,
|
||||
})
|
||||
.setExtractor(ExtractorType.NONE, {})
|
||||
.setParser(ParserType.CSV, {})
|
||||
@@ -40,20 +40,6 @@ class DatasetCollection {
|
||||
public static loadAll(): Promise<void[]> {
|
||||
return Promise.all(this.datasets.map((dataset) => dataset.load()));
|
||||
}
|
||||
|
||||
// public static async getDatasetByMatchingSchema(
|
||||
// schema: any
|
||||
// ): Promise<string[]> {
|
||||
// return await Promise.all(
|
||||
// this.datasets.map((dataset) =>
|
||||
// axios
|
||||
// .post(dataset.endpoint, schema, {
|
||||
// params: { size: 1 },
|
||||
// })
|
||||
// .then((res) => (res.data.data.length > 0 ? dataset.endpoint : null))
|
||||
// )
|
||||
// ).then((endpoints) => endpoints.filter((endpoint) => endpoint !== null));
|
||||
// }
|
||||
}
|
||||
|
||||
export default DatasetCollection;
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-ignore
|
||||
import DmnModdle from "dmn-moddle";
|
||||
import {
|
||||
Decision,
|
||||
@@ -31,7 +32,7 @@ export class DMN {
|
||||
|
||||
private static getInputOutput(dmnDefinitions: Definitions) {
|
||||
const decisions: Decision[] = dmnDefinitions.drgElement.filter((element) =>
|
||||
Is_DMN_Decision(element)
|
||||
Is_DMN_Decision(element),
|
||||
);
|
||||
const { input: inputs, output: outputs } = decisions
|
||||
.map((decision) => decision.decisionLogic)
|
||||
@@ -24,7 +24,7 @@ export class DmnError extends Error {
|
||||
super(
|
||||
Name_of_ModdleElement(me) +
|
||||
DmnError.Separator +
|
||||
messages.join(DmnError.Separator)
|
||||
messages.join(DmnError.Separator),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,10 @@ function Is_Data(data: Data): boolean {
|
||||
return (
|
||||
"action" in data &&
|
||||
(Object.values(Drop_mode).includes(
|
||||
(data.action as string).toUpperCase() as Drop_mode
|
||||
(data.action as string).toUpperCase() as Drop_mode,
|
||||
) ||
|
||||
Object.values(Status_mode).includes(
|
||||
(data.action as string).toUpperCase() as Status_mode
|
||||
(data.action as string).toUpperCase() as Status_mode,
|
||||
)) &&
|
||||
"data" in data &&
|
||||
Array.isArray(data.data)
|
||||
@@ -18,17 +18,17 @@ interface Definitions extends ModdleElement {
|
||||
|
||||
function _Get_type_reference_from_DMN_Definitions(
|
||||
me: Definitions,
|
||||
type_name?: string
|
||||
type_name?: string,
|
||||
): DMN_type_reference_ | undefined {
|
||||
if (Trace)
|
||||
console.assert(
|
||||
Is_DMN_Definitions(me),
|
||||
"'_Get_type_reference_from_DMN_Definitions' >> 'Is_DMN_Definitions(me)', untrue"
|
||||
"'_Get_type_reference_from_DMN_Definitions' >> 'Is_DMN_Definitions(me)', untrue",
|
||||
);
|
||||
|
||||
if (type_name === undefined) return undefined;
|
||||
const index = me.itemDefinition.findIndex(
|
||||
(item: ItemDefinition) => item.name === type_name
|
||||
(item: ItemDefinition) => item.name === type_name,
|
||||
);
|
||||
return index !== -1 ? me.itemDefinition[index].typeRef : undefined;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ interface InformationRequirement extends ModdleElement {
|
||||
}
|
||||
|
||||
function Is_DMN_InformationRequirement(
|
||||
me: ModdleElement
|
||||
me: ModdleElement,
|
||||
): me is InformationRequirement {
|
||||
return (
|
||||
"$type" in me &&
|
||||
@@ -27,7 +27,7 @@ interface InputClause extends ModdleElement {
|
||||
}
|
||||
|
||||
function Get_enumeration_from_DMN_InputClause(
|
||||
me: InputClause
|
||||
me: InputClause,
|
||||
): Array<any> | never {
|
||||
// if (Trace)
|
||||
// console.assert(_Is_DMN_InputClause_enumeration_(me), "Get_enumeration_from_DMN_InputClause >> '_Is_DMN_InputClause_enumeration_(me)', untrue");
|
||||
@@ -36,13 +36,13 @@ function Get_enumeration_from_DMN_InputClause(
|
||||
if (Is_DMN_type_reference_(type_reference) === false) {
|
||||
type_reference = _Get_type_reference_from_DMN_Definitions(
|
||||
me.$parent.$parent.$parent as Definitions,
|
||||
type_reference
|
||||
type_reference,
|
||||
);
|
||||
if (type_reference === undefined)
|
||||
throw new DmnError(
|
||||
me,
|
||||
DmnError.Undefined_DMN_type,
|
||||
Name_of_DMN_InputClause(me)
|
||||
Name_of_DMN_InputClause(me),
|
||||
);
|
||||
}
|
||||
if (type_reference === DMN_type_reference_.BOOLEAN) return [false, true];
|
||||
@@ -52,19 +52,19 @@ function Get_enumeration_from_DMN_InputClause(
|
||||
throw new DmnError(
|
||||
me,
|
||||
DmnError.Undefined_DMN_type,
|
||||
Name_of_DMN_InputClause(me)
|
||||
Name_of_DMN_InputClause(me),
|
||||
);
|
||||
return extraction;
|
||||
} else {
|
||||
const extraction = _Extract_enumeration_values(
|
||||
me.inputValues!.text,
|
||||
type_reference
|
||||
type_reference,
|
||||
);
|
||||
if (extraction === null)
|
||||
throw new DmnError(
|
||||
me,
|
||||
DmnError.Undefined_DMN_type,
|
||||
Name_of_DMN_InputClause(me)
|
||||
Name_of_DMN_InputClause(me),
|
||||
);
|
||||
return extraction;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ function Name_of_DMN_InputClause(me: InputClause): string {
|
||||
|
||||
function Type_of_DMN_InputClause(
|
||||
me: InputClause,
|
||||
decision: Decision
|
||||
decision: Decision,
|
||||
): DMN_type_reference_ | never {
|
||||
if (_Is_DMN_InputClause_enumeration_(me))
|
||||
return DMN_type_reference_.ENUMERATION;
|
||||
@@ -100,7 +100,7 @@ function Type_of_DMN_InputClause(
|
||||
else {
|
||||
const base_type = _Get_type_reference_from_DMN_Definitions(
|
||||
decision.$parent,
|
||||
me.typeRef! as string
|
||||
me.typeRef! as string,
|
||||
);
|
||||
return base_type && Is_DMN_type_reference_(base_type)
|
||||
? base_type
|
||||
@@ -113,7 +113,7 @@ function Type_of_DMN_InputClause(
|
||||
else {
|
||||
const base_type = _Get_type_reference_from_DMN_Definitions(
|
||||
decision.$parent,
|
||||
me.inputExpression!.typeRef as string
|
||||
me.inputExpression!.typeRef as string,
|
||||
);
|
||||
return base_type && Is_DMN_type_reference_(base_type)
|
||||
? base_type
|
||||
@@ -124,7 +124,7 @@ function Type_of_DMN_InputClause(
|
||||
throw new DmnError(
|
||||
me,
|
||||
DmnError.Undefined_DMN_type,
|
||||
Name_of_DMN_InputClause(me)
|
||||
Name_of_DMN_InputClause(me),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ interface OutputClause extends ModdleElement {
|
||||
}
|
||||
|
||||
function Get_enumeration_from_DMN_OutputClause(
|
||||
me: OutputClause
|
||||
me: OutputClause,
|
||||
): any[] | never {
|
||||
// if (Trace)
|
||||
// console.assert(_Is_DMN_OutputClause_enumeration_(me), "Get_enumeration_from_DMN_OutputClause >> '_Is_DMN_OutputClause_enumeration_(me)', untrue");
|
||||
@@ -33,13 +33,13 @@ function Get_enumeration_from_DMN_OutputClause(
|
||||
if (Is_DMN_type_reference_(type_reference) === false) {
|
||||
type_reference = _Get_type_reference_from_DMN_Definitions(
|
||||
me.$parent.$parent.$parent as Definitions,
|
||||
type_reference
|
||||
type_reference,
|
||||
);
|
||||
if (type_reference === undefined)
|
||||
throw new DmnError(
|
||||
me,
|
||||
DmnError.Undefined_DMN_type,
|
||||
Name_of_DMN_OutputClause(me)
|
||||
Name_of_DMN_OutputClause(me),
|
||||
);
|
||||
}
|
||||
if (type_reference === DMN_type_reference_.BOOLEAN) return [false, true];
|
||||
@@ -49,19 +49,19 @@ function Get_enumeration_from_DMN_OutputClause(
|
||||
throw new DmnError(
|
||||
me,
|
||||
DmnError.Undefined_DMN_type,
|
||||
Name_of_DMN_OutputClause(me)
|
||||
Name_of_DMN_OutputClause(me),
|
||||
);
|
||||
return extraction;
|
||||
} else {
|
||||
const extraction = _Extract_enumeration_values(
|
||||
me.outputValues!.text,
|
||||
type_reference
|
||||
type_reference,
|
||||
);
|
||||
if (extraction === null)
|
||||
throw new DmnError(
|
||||
me,
|
||||
DmnError.Undefined_DMN_type,
|
||||
Name_of_DMN_OutputClause(me)
|
||||
Name_of_DMN_OutputClause(me),
|
||||
);
|
||||
return extraction;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ function Name_of_DMN_OutputClause(me: OutputClause): string {
|
||||
function Type_of_DMN_OutputClause(
|
||||
me: OutputClause,
|
||||
decision: Decision,
|
||||
primitive_type = false
|
||||
primitive_type = false,
|
||||
): DMN_type_reference_ | never {
|
||||
if (!primitive_type && _Is_DMN_OutputClause_enumeration_(me))
|
||||
return DMN_type_reference_.ENUMERATION;
|
||||
@@ -96,7 +96,7 @@ function Type_of_DMN_OutputClause(
|
||||
else {
|
||||
const base_type = _Get_type_reference_from_DMN_Definitions(
|
||||
decision.$parent,
|
||||
me.typeRef! as string
|
||||
me.typeRef! as string,
|
||||
);
|
||||
return base_type && Is_DMN_type_reference_(base_type)
|
||||
? base_type
|
||||
@@ -105,7 +105,7 @@ function Type_of_DMN_OutputClause(
|
||||
throw new DmnError(
|
||||
me,
|
||||
DmnError.Undefined_DMN_type,
|
||||
Name_of_DMN_OutputClause(me)
|
||||
Name_of_DMN_OutputClause(me),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ enum DMN_type_reference_ {
|
||||
}
|
||||
|
||||
function Is_DMN_type_reference_(
|
||||
type_reference: string | undefined
|
||||
type_reference: string | undefined,
|
||||
): type_reference is DMN_type_reference_ {
|
||||
if (type_reference === undefined) return false;
|
||||
return Object.values(DMN_type_reference_).includes(
|
||||
type_reference.toLowerCase() as DMN_type_reference_
|
||||
type_reference.toLowerCase() as DMN_type_reference_,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,12 +69,12 @@ function _Extract_enumeration_values(enumeration: string): string[] | null;
|
||||
|
||||
function _Extract_enumeration_values(
|
||||
enumeration: string,
|
||||
type_reference: DMN_type_reference_
|
||||
type_reference: DMN_type_reference_,
|
||||
): number[] | null;
|
||||
|
||||
function _Extract_enumeration_values(
|
||||
enumeration: string,
|
||||
type_reference?: DMN_type_reference_
|
||||
type_reference?: DMN_type_reference_,
|
||||
): string[] | number[] | null {
|
||||
if (type_reference) {
|
||||
if (FEEL_range.test(enumeration)) {
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Parser } from "./";
|
||||
import { Parser } from "./index";
|
||||
import { Duplex } from "node:stream";
|
||||
import * as csv from "fast-csv";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Parser, CsvParser } from "./";
|
||||
import { ParserType } from ".";
|
||||
import { Parser, CsvParser } from "./index";
|
||||
import { ParserType } from "./index";
|
||||
|
||||
class ParserFactory {
|
||||
/**
|
||||
@@ -0,0 +1 @@
|
||||
declare module "src/types/JSONStream";
|
||||
@@ -0,0 +1 @@
|
||||
declare module "src/types/dmn-moddle";
|
||||
@@ -0,0 +1,485 @@
|
||||
{
|
||||
"_type": "export",
|
||||
"__export_format": 4,
|
||||
"__export_date": "2024-12-17T10:03:26.336Z",
|
||||
"__export_source": "insomnia.desktop.app:v10.2.0",
|
||||
"resources": [
|
||||
{
|
||||
"_id": "req_f28881e1a1de4089ab714b56858b3a31",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1734426547137,
|
||||
"created": 1734387131560,
|
||||
"url": "{{ _.base_url }}",
|
||||
"name": "Show routes",
|
||||
"description": "",
|
||||
"method": "GET",
|
||||
"body": {},
|
||||
"parameters": [],
|
||||
"headers": [
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.2.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734387131560,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"parentId": null,
|
||||
"modified": 1727867693579,
|
||||
"created": 1727867693579,
|
||||
"name": "Compo-Service-Log-Project",
|
||||
"description": "",
|
||||
"scope": "collection",
|
||||
"_type": "workspace"
|
||||
},
|
||||
{
|
||||
"_id": "req_55b9623b1d824b52b34d13279176c354",
|
||||
"parentId": "fld_31fe929a6fb9434c9a93ec6c98b8eef7",
|
||||
"modified": 1734426078790,
|
||||
"created": 1727867720980,
|
||||
"url": "{{ _.base_url }}/randomize",
|
||||
"name": "XML",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/xml",
|
||||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<definitions xmlns=\"https://www.omg.org/spec/DMN/20191111/MODEL/\" id=\"definitions_16re855\" name=\"definitions\" namespace=\"http://camunda.org/schema/1.0/dmn\" exporter=\"dmn-js (https://demo.bpmn.io/dmn)\" exporterVersion=\"16.6.2\">\n <decision id=\"decision_02zhvl1\" name=\"\">\n <decisionTable id=\"decisionTable_0k2npw5\">\n <input id=\"InputClause_0eqj4n9\" label=\"Barcode (EAN 13)\">\n <inputExpression id=\"LiteralExpression_1u9u1as\" typeRef=\"string\">\n <text></text>\n </inputExpression>\n </input>\n <output id=\"output1\" label=\"Country\" name=\"\" typeRef=\"string\" />\n <rule id=\"DecisionRule_0oklu3j\">\n <inputEntry id=\"UnaryTests_19vxqzm\">\n <text>string length(?)=13 and starts with(?, \"3\") and not matches(?, \"^3[89]\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_01ucmmd\">\n <text>\"France-Monaco\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_18xknsg\">\n <inputEntry id=\"UnaryTests_0uflcxg\">\n <text>matches(?, \"^46\\d{11}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0hpx07f\">\n <text>\"Russia\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_0jko2nu\">\n <inputEntry id=\"UnaryTests_0u30ape\">\n <text>string length(?)=13 and starts with(?, \"560\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0v8lp29\">\n <text>\"Portugal\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1nsy4ze\">\n <inputEntry id=\"UnaryTests_15tlrit\">\n <text>\nmatches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1hbw2ir\">\n <text>\"AT\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1i8wl7f\">\n <inputEntry id=\"UnaryTests_183xj46\">\n <text>matches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_08v0zvo\">\n <text>\"Austria\"</text>\n </outputEntry>\n </rule>\n </decisionTable>\n </decision>\n</definitions>\n"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_6e4d20c1c5ca42f79d13dfeeb6d11edb",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/xml"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.0.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734425931804,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "fld_31fe929a6fb9434c9a93ec6c98b8eef7",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1734426000926,
|
||||
"created": 1734425846873,
|
||||
"name": "randomize",
|
||||
"description": "",
|
||||
"environment": {},
|
||||
"environmentPropertyOrder": null,
|
||||
"metaSortKey": -1731127426257.5,
|
||||
"environmentType": "kv",
|
||||
"_type": "request_group"
|
||||
},
|
||||
{
|
||||
"_id": "req_acb6ee0958e14336814603597e55df3a",
|
||||
"parentId": "fld_31fe929a6fb9434c9a93ec6c98b8eef7",
|
||||
"modified": 1734426288553,
|
||||
"created": 1734425918670,
|
||||
"url": "{{ _.base_url }}/randomize",
|
||||
"name": "JSON",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/json",
|
||||
"text": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"Barcode (EAN 13)\": { \"type\": \"string\" },\n\t\t\"Country\": { \"type\": \"string\" }\n\t},\n\t\"required\": [ \"Barcode (EAN 13)\", \"Country\" ]\n}"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_6e4d20c1c5ca42f79d13dfeeb6d11edb",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.0.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734425931754,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "req_cc7e8367ddb843da91ef50d9d0df6ed2",
|
||||
"parentId": "fld_f9db710057ee4588b18768a3fed0ef92",
|
||||
"modified": 1734426089740,
|
||||
"created": 1727867896038,
|
||||
"url": "{{ _.base_url }}/randomize/nudger",
|
||||
"name": "XML",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/xml",
|
||||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<definitions xmlns=\"https://www.omg.org/spec/DMN/20191111/MODEL/\" id=\"definitions_16re855\" name=\"definitions\" namespace=\"http://camunda.org/schema/1.0/dmn\" exporter=\"dmn-js (https://demo.bpmn.io/dmn)\" exporterVersion=\"16.6.2\">\n <decision id=\"decision_02zhvl1\" name=\"\">\n <decisionTable id=\"decisionTable_0k2npw5\">\n <input id=\"InputClause_0eqj4n9\" label=\"Barcode (EAN 13)\">\n <inputExpression id=\"LiteralExpression_1u9u1as\" typeRef=\"string\">\n <text></text>\n </inputExpression>\n </input>\n <output id=\"output1\" label=\"Country\" name=\"\" typeRef=\"string\" />\n <rule id=\"DecisionRule_0oklu3j\">\n <inputEntry id=\"UnaryTests_19vxqzm\">\n <text>string length(?)=13 and starts with(?, \"3\") and not matches(?, \"^3[89]\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_01ucmmd\">\n <text>\"France-Monaco\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_18xknsg\">\n <inputEntry id=\"UnaryTests_0uflcxg\">\n <text>matches(?, \"^46\\d{11}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0hpx07f\">\n <text>\"Russia\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_0jko2nu\">\n <inputEntry id=\"UnaryTests_0u30ape\">\n <text>string length(?)=13 and starts with(?, \"560\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0v8lp29\">\n <text>\"Portugal\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1nsy4ze\">\n <inputEntry id=\"UnaryTests_15tlrit\">\n <text>\nmatches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1hbw2ir\">\n <text>\"AT\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1i8wl7f\">\n <inputEntry id=\"UnaryTests_183xj46\">\n <text>matches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_08v0zvo\">\n <text>\"Austria\"</text>\n </outputEntry>\n </rule>\n </decisionTable>\n </decision>\n</definitions>\n"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/xml"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.0.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734426021998,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "fld_f9db710057ee4588b18768a3fed0ef92",
|
||||
"parentId": "fld_31fe929a6fb9434c9a93ec6c98b8eef7",
|
||||
"modified": 1734426015376,
|
||||
"created": 1734426012969,
|
||||
"name": "nudger",
|
||||
"description": "",
|
||||
"environment": {},
|
||||
"environmentPropertyOrder": null,
|
||||
"metaSortKey": -1734425931729,
|
||||
"environmentType": "kv",
|
||||
"_type": "request_group"
|
||||
},
|
||||
{
|
||||
"_id": "req_5113f57a34f147ed896bb196c1f91bf0",
|
||||
"parentId": "fld_f9db710057ee4588b18768a3fed0ef92",
|
||||
"modified": 1734426373114,
|
||||
"created": 1734426367718,
|
||||
"url": "{{ _.base_url }}/randomize/nudger",
|
||||
"name": "JSON",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/json",
|
||||
"text": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"Barcode (EAN 13)\": { \"type\": \"string\" },\n\t\t\"Country\": { \"type\": \"string\" }\n\t},\n\t\"required\": [ \"Barcode (EAN 13)\", \"Country\" ]\n}"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.0.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734425982232,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "req_bfff90a801714354a8362a22e7a635d9",
|
||||
"parentId": "fld_c5536670d5a84d32894b264ded06b297",
|
||||
"modified": 1734426094899,
|
||||
"created": 1728319701558,
|
||||
"url": "{{ _.base_url }}/randomize/openfoodfacts",
|
||||
"name": "XML",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/xml",
|
||||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<definitions xmlns=\"https://www.omg.org/spec/DMN/20191111/MODEL/\" id=\"definitions_16re855\" name=\"definitions\" namespace=\"http://camunda.org/schema/1.0/dmn\" exporter=\"dmn-js (https://demo.bpmn.io/dmn)\" exporterVersion=\"16.6.2\">\n <decision id=\"decision_02zhvl1\" name=\"\">\n <decisionTable id=\"decisionTable_0k2npw5\">\n <input id=\"InputClause_0eqj4n9\" label=\"Barcode (EAN 13)\">\n <inputExpression id=\"LiteralExpression_1u9u1as\" typeRef=\"string\">\n <text></text>\n </inputExpression>\n </input>\n <output id=\"output1\" label=\"Country\" name=\"\" typeRef=\"string\" />\n <rule id=\"DecisionRule_0oklu3j\">\n <inputEntry id=\"UnaryTests_19vxqzm\">\n <text>string length(?)=13 and starts with(?, \"3\") and not matches(?, \"^3[89]\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_01ucmmd\">\n <text>\"France-Monaco\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_18xknsg\">\n <inputEntry id=\"UnaryTests_0uflcxg\">\n <text>matches(?, \"^46\\d{11}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0hpx07f\">\n <text>\"Russia\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_0jko2nu\">\n <inputEntry id=\"UnaryTests_0u30ape\">\n <text>string length(?)=13 and starts with(?, \"560\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0v8lp29\">\n <text>\"Portugal\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1nsy4ze\">\n <inputEntry id=\"UnaryTests_15tlrit\">\n <text>\nmatches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1hbw2ir\">\n <text>\"AT\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1i8wl7f\">\n <inputEntry id=\"UnaryTests_183xj46\">\n <text>matches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_08v0zvo\">\n <text>\"Austria\"</text>\n </outputEntry>\n </rule>\n </decisionTable>\n </decision>\n</definitions>\n"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/xml"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.0.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734425942466,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "fld_c5536670d5a84d32894b264ded06b297",
|
||||
"parentId": "fld_31fe929a6fb9434c9a93ec6c98b8eef7",
|
||||
"modified": 1734426053346,
|
||||
"created": 1734425931704,
|
||||
"name": "openfoodfacts",
|
||||
"description": "",
|
||||
"environment": {},
|
||||
"environmentPropertyOrder": null,
|
||||
"metaSortKey": -1734425931722.75,
|
||||
"environmentType": "kv",
|
||||
"_type": "request_group"
|
||||
},
|
||||
{
|
||||
"_id": "req_271b501a3afd464b8ebfca3c955f6c36",
|
||||
"parentId": "fld_c5536670d5a84d32894b264ded06b297",
|
||||
"modified": 1734426385513,
|
||||
"created": 1734426380249,
|
||||
"url": "{{ _.base_url }}/randomize/openfoodfacts",
|
||||
"name": "JSON",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/json",
|
||||
"text": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"Barcode (EAN 13)\": { \"type\": \"string\" },\n\t\t\"Country\": { \"type\": \"string\" }\n\t},\n\t\"required\": [ \"Barcode (EAN 13)\", \"Country\" ]\n}"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.0.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734425937135,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "req_53d1a1f0862d4cb99e5572c1dd30967b",
|
||||
"parentId": "fld_58b791cceb4241f5adea08be0c63369f",
|
||||
"modified": 1734426100234,
|
||||
"created": 1728900124584,
|
||||
"url": "{{ _.base_url }}/randomize/world-cities",
|
||||
"name": "XML",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/xml",
|
||||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<definitions xmlns=\"https://www.omg.org/spec/DMN/20191111/MODEL/\" xmlns:biodi=\"http://bpmn.io/schema/dmn/biodi/2.0\" id=\"definitions_01gvi3e\" name=\"definitions\" namespace=\"http://camunda.org/schema/1.0/dmn\" exporter=\"dmn-js (https://demo.bpmn.io/dmn)\" exporterVersion=\"16.6.2\">\n <decision id=\"decision_1i2kko9\" name=\"\">\n <decisionTable id=\"decisionTable_0gr70vc\">\n <input id=\"input1\" label=\"Geoname ID\" biodi:width=\"192\">\n <inputExpression id=\"inputExpression1\" typeRef=\"number\">\n <text>GeonameID</text>\n </inputExpression>\n </input>\n <output id=\"output1\" label=\"Country\" name=\"Country\" typeRef=\"string\" />\n <rule id=\"DecisionRule_00g5ohx\">\n <description>Cities with geonameId between 2967245 and 3038789 are in France</description>\n <inputEntry id=\"UnaryTests_00ykcgn\">\n <text>includes(2967245, 3038789)</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_03k0z7u\">\n <text>\"France\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1w8cov6\">\n <description>Cities with geonameId between 3104316 and 3130616 are in Spain</description>\n <inputEntry id=\"UnaryTests_1utcn4l\">\n <text>includes(3104316, 3130616)</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1yd23ys\">\n <text>\"Spain\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_0bqrzts\">\n <description>Cities with geonameId between 5881791 and 6185607 are in Spain</description>\n <inputEntry id=\"UnaryTests_0ny4o6c\">\n <text>includes(5881791,6185607)</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1xdxvkd\">\n <text>\"Canada\"</text>\n </outputEntry>\n </rule>\n </decisionTable>\n </decision>\n</definitions>\n"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/xml"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.0.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734426059110,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "fld_58b791cceb4241f5adea08be0c63369f",
|
||||
"parentId": "fld_31fe929a6fb9434c9a93ec6c98b8eef7",
|
||||
"modified": 1734426051270,
|
||||
"created": 1734426043016,
|
||||
"name": "world-cities",
|
||||
"description": "",
|
||||
"environment": {},
|
||||
"environmentPropertyOrder": null,
|
||||
"metaSortKey": -1734425931716.5,
|
||||
"environmentType": "kv",
|
||||
"_type": "request_group"
|
||||
},
|
||||
{
|
||||
"_id": "req_7433c87ff6e840a4bf5747b8894c99ed",
|
||||
"parentId": "fld_58b791cceb4241f5adea08be0c63369f",
|
||||
"modified": 1734426481018,
|
||||
"created": 1734426413777,
|
||||
"url": "{{ _.base_url }}/randomize/world-cities",
|
||||
"name": "JSON",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/json",
|
||||
"text": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"Geoname ID\": { \"type\": \"string\" },\n\t\t\"Country\": { \"type\": \"string\" }\n\t},\n\t\"required\": [ \"Geoname ID\", \"Country\" ]\n}"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "insomnia/10.0.0"
|
||||
}
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1734426040554,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "env_025a059466ea4c5d1a14c9fd8028c0bb99039906",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1734425681843,
|
||||
"created": 1727867693581,
|
||||
"name": "Base Environment",
|
||||
"data": {
|
||||
"base_url": "{{ _.protocol }}://{{ _.domain }}:{{ _.port }}",
|
||||
"protocol": "http",
|
||||
"domain": "localhost",
|
||||
"port": "3000"
|
||||
},
|
||||
"dataPropertyOrder": {
|
||||
"&": [
|
||||
"base_url",
|
||||
"protocol",
|
||||
"domain",
|
||||
"port"
|
||||
]
|
||||
},
|
||||
"color": null,
|
||||
"isPrivate": false,
|
||||
"metaSortKey": 1727867693581,
|
||||
"_type": "environment"
|
||||
},
|
||||
{
|
||||
"_id": "jar_025a059466ea4c5d1a14c9fd8028c0bb99039906",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1727867693582,
|
||||
"created": 1727867693582,
|
||||
"name": "Default Jar",
|
||||
"cookies": [],
|
||||
"_type": "cookie_jar"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -18,7 +18,10 @@
|
||||
"noImplicitAny": true,
|
||||
/* Completeness */
|
||||
"skipLibCheck": true,
|
||||
"typeRoots": ["./src/types", "./node_modules/@types"],
|
||||
"typeRoots": [
|
||||
"./src/types",
|
||||
"./node_modules/@types"
|
||||
],
|
||||
/* Decorators */
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true
|
||||
@@ -1,18 +1,47 @@
|
||||
# Use root/example as user/password credentials
|
||||
version: "3.1"
|
||||
|
||||
services:
|
||||
mongo:
|
||||
|
||||
app:
|
||||
container_name: app
|
||||
build:
|
||||
context: ./app
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
APP_ENV: ${APP_ENV}
|
||||
APP_PORT: ${APP_PORT}
|
||||
MARIADB_HOST: ${MARIADB_HOST}
|
||||
MARIADB_PORT: ${MARIADB_PORT}
|
||||
MARIADB_USER: ${MARIADB_USER}
|
||||
MARIADB_PASSWORD: ${MARIADB_PASSWORD}
|
||||
MARIADB_DATABASE: ${MARIADB_DATABASE}
|
||||
MONGODB_HOST: ${MONGODB_HOST}
|
||||
MONGODB_PORT: ${MONGODB_PORT}
|
||||
MONGODB_USER: ${MONGODB_USER}
|
||||
MONGODB_PASSWORD: ${MONGODB_PASSWORD}
|
||||
MONGODB_DATABASE: ${MONGODB_DATABASE}
|
||||
restart: "on-failure"
|
||||
volumes:
|
||||
- ./app/src:/app/src
|
||||
depends_on:
|
||||
- mongodb
|
||||
- mariadb
|
||||
networks:
|
||||
- app_network
|
||||
ports:
|
||||
- "${APP_PORT}:${APP_PORT}"
|
||||
|
||||
mongodb:
|
||||
image: mongo
|
||||
container_name: data-db
|
||||
container_name: mongodb
|
||||
restart: "no"
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: root
|
||||
MONGO_INITDB_DATABASE: db
|
||||
MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USER}
|
||||
MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASSWORD}
|
||||
MONGO_INITDB_DATABASE: ${MONGODB_DATABASE}
|
||||
volumes:
|
||||
- ./docker/mongodb/db:/data/db
|
||||
- ./docker/mongodb/logs:/var/log/mongodb
|
||||
- ./mongodb/data:/data/db
|
||||
- ./mongodb/logs:/var/log/mongodb
|
||||
command:
|
||||
[ "mongod", "--logpath", "/var/log/mongodb/mongodb.log", "--logappend" ]
|
||||
deploy:
|
||||
@@ -23,24 +52,26 @@ services:
|
||||
reservations:
|
||||
memory: 2g
|
||||
ports:
|
||||
- "27017:27017"
|
||||
- "${MONGODB_PORT}:27017"
|
||||
networks:
|
||||
- app_network
|
||||
|
||||
mariadb:
|
||||
image: mariadb
|
||||
container_name: log-db
|
||||
container_name: mariadb
|
||||
restart: "no"
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: db
|
||||
MYSQL_USER: user
|
||||
MYSQL_PASSWORD: example
|
||||
MYSQL_DATABASE: ${MARIADB_DATABASE}
|
||||
MYSQL_USER: ${MARIADB_USER}
|
||||
MYSQL_PASSWORD: ${MARIADB_PASSWORD}
|
||||
volumes:
|
||||
- ./mariadb/data:/var/lib/mysql
|
||||
networks:
|
||||
- app_network
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- ./docker/mariadb/db:/var/lib/mysql
|
||||
- "${MARIADB_PORT}:3306"
|
||||
|
||||
volumes:
|
||||
mongodb_data:
|
||||
driver: local
|
||||
mariadb_data:
|
||||
driver: local
|
||||
networks:
|
||||
app_network:
|
||||
driver: bridge
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
{
|
||||
"_type": "export",
|
||||
"__export_format": 4,
|
||||
"__export_date": "2024-10-14T10:07:13.189Z",
|
||||
"__export_source": "insomnia.desktop.app:v10.0.0",
|
||||
"resources": [
|
||||
{
|
||||
"_id": "req_55b9623b1d824b52b34d13279176c354",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1727867887432,
|
||||
"created": 1727867720980,
|
||||
"url": "http://localhost:4321/randomize",
|
||||
"name": "randomize",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {},
|
||||
"parameters": [],
|
||||
"headers": [{ "name": "User-Agent", "value": "insomnia/10.0.0" }],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1727867720980,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"parentId": null,
|
||||
"modified": 1727867693579,
|
||||
"created": 1727867693579,
|
||||
"name": "Compo-Service-Log-Project",
|
||||
"description": "",
|
||||
"scope": "collection",
|
||||
"_type": "workspace"
|
||||
},
|
||||
{
|
||||
"_id": "req_cc7e8367ddb843da91ef50d9d0df6ed2",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1728038602629,
|
||||
"created": 1727867896038,
|
||||
"url": "http://localhost:4321/randomize/nudger",
|
||||
"name": "randomize/nudger",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/xml",
|
||||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<definitions xmlns=\"https://www.omg.org/spec/DMN/20191111/MODEL/\" id=\"definitions_16re855\" name=\"definitions\" namespace=\"http://camunda.org/schema/1.0/dmn\" exporter=\"dmn-js (https://demo.bpmn.io/dmn)\" exporterVersion=\"16.6.2\">\n <decision id=\"decision_02zhvl1\" name=\"\">\n <decisionTable id=\"decisionTable_0k2npw5\">\n <input id=\"InputClause_0eqj4n9\" label=\"Barcode (EAN 13)\">\n <inputExpression id=\"LiteralExpression_1u9u1as\" typeRef=\"string\">\n <text></text>\n </inputExpression>\n </input>\n <output id=\"output1\" label=\"Country\" name=\"\" typeRef=\"string\" />\n <rule id=\"DecisionRule_0oklu3j\">\n <inputEntry id=\"UnaryTests_19vxqzm\">\n <text>string length(?)=13 and starts with(?, \"3\") and not matches(?, \"^3[89]\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_01ucmmd\">\n <text>\"France-Monaco\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_18xknsg\">\n <inputEntry id=\"UnaryTests_0uflcxg\">\n <text>matches(?, \"^46\\d{11}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0hpx07f\">\n <text>\"Russia\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_0jko2nu\">\n <inputEntry id=\"UnaryTests_0u30ape\">\n <text>string length(?)=13 and starts with(?, \"560\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0v8lp29\">\n <text>\"Portugal\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1nsy4ze\">\n <inputEntry id=\"UnaryTests_15tlrit\">\n <text>\nmatches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1hbw2ir\">\n <text>\"AT\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1i8wl7f\">\n <inputEntry id=\"UnaryTests_183xj46\">\n <text>matches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_08v0zvo\">\n <text>\"Austria\"</text>\n </outputEntry>\n </rule>\n </decisionTable>\n </decision>\n</definitions>\n"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{ "name": "Content-Type", "value": "application/xml" },
|
||||
{ "name": "User-Agent", "value": "insomnia/10.0.0" }
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1727867720930,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "req_bfff90a801714354a8362a22e7a635d9",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1728319714698,
|
||||
"created": 1728319701558,
|
||||
"url": "http://localhost:4321/randomize/openfoodfacts",
|
||||
"name": "randomize/openfoodfacts",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/xml",
|
||||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<definitions xmlns=\"https://www.omg.org/spec/DMN/20191111/MODEL/\" id=\"definitions_16re855\" name=\"definitions\" namespace=\"http://camunda.org/schema/1.0/dmn\" exporter=\"dmn-js (https://demo.bpmn.io/dmn)\" exporterVersion=\"16.6.2\">\n <decision id=\"decision_02zhvl1\" name=\"\">\n <decisionTable id=\"decisionTable_0k2npw5\">\n <input id=\"InputClause_0eqj4n9\" label=\"Barcode (EAN 13)\">\n <inputExpression id=\"LiteralExpression_1u9u1as\" typeRef=\"string\">\n <text></text>\n </inputExpression>\n </input>\n <output id=\"output1\" label=\"Country\" name=\"\" typeRef=\"string\" />\n <rule id=\"DecisionRule_0oklu3j\">\n <inputEntry id=\"UnaryTests_19vxqzm\">\n <text>string length(?)=13 and starts with(?, \"3\") and not matches(?, \"^3[89]\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_01ucmmd\">\n <text>\"France-Monaco\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_18xknsg\">\n <inputEntry id=\"UnaryTests_0uflcxg\">\n <text>matches(?, \"^46\\d{11}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0hpx07f\">\n <text>\"Russia\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_0jko2nu\">\n <inputEntry id=\"UnaryTests_0u30ape\">\n <text>string length(?)=13 and starts with(?, \"560\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_0v8lp29\">\n <text>\"Portugal\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1nsy4ze\">\n <inputEntry id=\"UnaryTests_15tlrit\">\n <text>\nmatches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1hbw2ir\">\n <text>\"AT\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1i8wl7f\">\n <inputEntry id=\"UnaryTests_183xj46\">\n <text>matches(?, \"^9[0-1]{1}\\d{10}$\")</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_08v0zvo\">\n <text>\"Austria\"</text>\n </outputEntry>\n </rule>\n </decisionTable>\n </decision>\n</definitions>\n"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{ "name": "Content-Type", "value": "application/xml" },
|
||||
{ "name": "User-Agent", "value": "insomnia/10.0.0" }
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1727867720880,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "req_53d1a1f0862d4cb99e5572c1dd30967b",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1728900408292,
|
||||
"created": 1728900124584,
|
||||
"url": "http://localhost:4321/randomize/world-cities",
|
||||
"name": "randomize/world-cities",
|
||||
"description": "",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mimeType": "application/xml",
|
||||
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<definitions xmlns=\"https://www.omg.org/spec/DMN/20191111/MODEL/\" xmlns:biodi=\"http://bpmn.io/schema/dmn/biodi/2.0\" id=\"definitions_01gvi3e\" name=\"definitions\" namespace=\"http://camunda.org/schema/1.0/dmn\" exporter=\"dmn-js (https://demo.bpmn.io/dmn)\" exporterVersion=\"16.6.2\">\n <decision id=\"decision_1i2kko9\" name=\"\">\n <decisionTable id=\"decisionTable_0gr70vc\">\n <input id=\"input1\" label=\"GeonameID\" biodi:width=\"192\">\n <inputExpression id=\"inputExpression1\" typeRef=\"number\">\n <text>GeonameID</text>\n </inputExpression>\n </input>\n <output id=\"output1\" label=\"Country\" name=\"Country\" typeRef=\"string\" />\n <rule id=\"DecisionRule_00g5ohx\">\n <description>Cities with geonameId between 2967245 and 3038789 are in France</description>\n <inputEntry id=\"UnaryTests_00ykcgn\">\n <text>includes(2967245, 3038789)</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_03k0z7u\">\n <text>\"France\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_1w8cov6\">\n <description>Cities with geonameId between 3104316 and 3130616 are in Spain</description>\n <inputEntry id=\"UnaryTests_1utcn4l\">\n <text>includes(3104316, 3130616)</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1yd23ys\">\n <text>\"Spain\"</text>\n </outputEntry>\n </rule>\n <rule id=\"DecisionRule_0bqrzts\">\n <description>Cities with geonameId between 5881791 and 6185607 are in Spain</description>\n <inputEntry id=\"UnaryTests_0ny4o6c\">\n <text>includes(5881791,6185607)</text>\n </inputEntry>\n <outputEntry id=\"LiteralExpression_1xdxvkd\">\n <text>\"Canada\"</text>\n </outputEntry>\n </rule>\n </decisionTable>\n </decision>\n</definitions>\n"
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"id": "pair_d55b3a61f8fc4ad89303e5b70fc19df6",
|
||||
"name": "size",
|
||||
"value": "1000",
|
||||
"description": "",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
"headers": [
|
||||
{ "name": "Content-Type", "value": "application/xml" },
|
||||
{ "name": "User-Agent", "value": "insomnia/10.0.0" }
|
||||
],
|
||||
"authentication": {},
|
||||
"metaSortKey": -1727867720830,
|
||||
"isPrivate": false,
|
||||
"pathParameters": [],
|
||||
"settingStoreCookies": true,
|
||||
"settingSendCookies": true,
|
||||
"settingDisableRenderRequestBody": false,
|
||||
"settingEncodeUrl": true,
|
||||
"settingRebuildPath": true,
|
||||
"settingFollowRedirects": "global",
|
||||
"_type": "request"
|
||||
},
|
||||
{
|
||||
"_id": "env_025a059466ea4c5d1a14c9fd8028c0bb99039906",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1727867693581,
|
||||
"created": 1727867693581,
|
||||
"name": "Base Environment",
|
||||
"data": {},
|
||||
"dataPropertyOrder": null,
|
||||
"color": null,
|
||||
"isPrivate": false,
|
||||
"metaSortKey": 1727867693581,
|
||||
"_type": "environment"
|
||||
},
|
||||
{
|
||||
"_id": "jar_025a059466ea4c5d1a14c9fd8028c0bb99039906",
|
||||
"parentId": "wrk_b6f7ea92d2f443b2bf923a99dc6fca88",
|
||||
"modified": 1727867693582,
|
||||
"created": 1727867693582,
|
||||
"name": "Default Jar",
|
||||
"cookies": [],
|
||||
"_type": "cookie_jar"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
data/
|
||||
@@ -0,0 +1,2 @@
|
||||
data/
|
||||
logs/
|
||||
@@ -1,17 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
import { DataSource } from "typeorm";
|
||||
import { Log } from "./entity/Log";
|
||||
|
||||
export const TypeOrmDataSource = new DataSource({
|
||||
type: "mariadb",
|
||||
host: "localhost",
|
||||
port: 3306,
|
||||
username: "root",
|
||||
password: "root",
|
||||
database: "db",
|
||||
synchronize: true,
|
||||
logging: false,
|
||||
entities: [Log],
|
||||
subscribers: [],
|
||||
migrations: [],
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
import { Log } from "../entity/Log";
|
||||
import { TypeOrmDataSource } from "../TypeOrmDataSource";
|
||||
|
||||
export default async function logger(
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) {
|
||||
console.info(`[${req.method}] ${req.url}`);
|
||||
|
||||
if (req.path === "/randomize") {
|
||||
// Put the log into the database
|
||||
const log: Log = new Log(
|
||||
req.url,
|
||||
req.method as any,
|
||||
JSON.stringify(req.body)
|
||||
);
|
||||
await TypeOrmDataSource.manager.save(log);
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
import randomize from "./randomize";
|
||||
|
||||
export default randomize;
|
||||
@@ -1,39 +0,0 @@
|
||||
import { Router, Request, Response } from "express";
|
||||
import { DatasetCollection } from "../services/dataset";
|
||||
import axios from "axios";
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.post("/randomize", async (req: Request, res: Response) => {
|
||||
const size: number = req.query.size ? parseInt(req.query.size as string) : 10;
|
||||
|
||||
const data = await Promise.all(
|
||||
DatasetCollection.datasets.map((dataset) =>
|
||||
axios
|
||||
.post(dataset.endpoint, req.body, { params: { size } })
|
||||
.then((res) => res.data.data)
|
||||
)
|
||||
).then((r) =>
|
||||
r
|
||||
.flat()
|
||||
.sort(() => Math.random() - 0.5)
|
||||
.slice(0, size)
|
||||
);
|
||||
|
||||
res.status(200).json({ status: "RANDOMIZED", data });
|
||||
});
|
||||
|
||||
router.post("/randomize/:id", async (req: Request, res: Response) => {
|
||||
const { id } = req.params;
|
||||
const size: number = req.query.size ? parseInt(req.query.size as string) : 10;
|
||||
|
||||
const dataset = DatasetCollection.datasets.find(
|
||||
(dataset) => dataset.id === id
|
||||
);
|
||||
if (!dataset) return res.status(404).json({ status: "NOT_FOUND" });
|
||||
|
||||
const data = await dataset.get(size, req.body);
|
||||
return res.status(200).json({ status: "RANDOMIZED", data });
|
||||
});
|
||||
|
||||
export default router;
|
||||
@@ -1,29 +0,0 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { join } from "node:path";
|
||||
import { existsSync, mkdirSync } from "node:fs";
|
||||
|
||||
class CacheService {
|
||||
public static readonly CACHE_DIR: string = "./cache";
|
||||
|
||||
public static generateCacheKey(name: string): string {
|
||||
return createHash("md5").update(name).digest("hex");
|
||||
}
|
||||
|
||||
public static getCachePath(name: string, extension: string = ""): string {
|
||||
const cacheKey = this.generateCacheKey(name);
|
||||
return join(CacheService.CACHE_DIR, `${cacheKey}${extension}`);
|
||||
}
|
||||
|
||||
public static isCached(name: string, extension: string = ""): boolean {
|
||||
const cacheKey = CacheService.generateCacheKey(name);
|
||||
|
||||
const cachedPath = join(CacheService.CACHE_DIR, `${cacheKey}${extension}`);
|
||||
return existsSync(cachedPath);
|
||||
}
|
||||
}
|
||||
|
||||
// if (!existsSync(CacheService.CACHE_DIR)) {
|
||||
// mkdirSync(CacheService.CACHE_DIR);
|
||||
// }
|
||||
|
||||
export default CacheService;
|
||||
@@ -1 +0,0 @@
|
||||
declare module "JSONStream";
|
||||
@@ -1 +0,0 @@
|
||||
declare module "dmn-moddle";
|
||||