1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-28 19:06:12 +01:00
unleash.unleash/.husky/update-openapi-spec-list.js
Nuno Góis 1d6dc9b195
chore: integration events API (#7639)
https://linear.app/unleash/issue/2-2439/create-new-integration-events-endpoint

https://linear.app/unleash/issue/2-2436/create-new-integration-event-openapi-schemas

This adds a new `/events` endpoint to the Addons API, allowing us to
fetch integration events for a specific integration configuration id.


![image](https://github.com/user-attachments/assets/e95b669e-e498-40c0-9d66-55be30a24c13)

Also includes:
- `IntegrationEventsSchema`: New schema to represent the response object
of the list of integration events;
- `yarn schema:update`: New `package.json` script to update the OpenAPI
spec file;
- `BasePaginationParameters`: This is copied from Enterprise. After
merging this we should be able to refactor Enterprise to use this one
instead of the one it has, so we don't repeat ourselves;

We're also now correctly representing the BIGSERIAL as BigInt (string +
pattern) in our OpenAPI schema. Otherwise our validation would complain,
since we're saying it's a number in the schema but in fact returning a
string.
2024-07-23 10:09:19 +01:00

33 lines
1.1 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const directoryPath = path.join(`${__dirname}/..`, 'src/lib/openapi/spec');
const indexPath = path.join(directoryPath, 'index.ts');
// Read files from the directory
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error('Could not list the directory.', err);
process.exit(1);
}
const exports = files
.filter((file) => file.includes('schema.ts')) // Filter files by 'schema.ts'
.map((file) => `export * from './${file.replace('.ts', '')}';`) // Create export statements
.join('\n');
// Append export statements to index.ts
const script = path.basename(__filename);
const message = `/**
* Auto-generated file by ${script}. Do not edit.
* To run it manually execute \`yarn schema:update\` or \`node ${path.basename(__dirname)}/${script}\`
*/\n`;
fs.writeFileSync(indexPath, `${message}${exports}\n${message}`, (err) => {
if (err) {
console.error('Could not append to file.', err);
process.exit(1);
}
console.log('Export statements added to index.ts successfully.');
});
});