# What this PR does - Split initial data into required base data and master data (options for dropdowns) - Prioritize loading base data over master data - Enable retrying single promises instead of always retrying all of them when only one fails ## Which issue(s) this PR fixes https://github.com/grafana/oncall/issues/3300 ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) |
||
|---|---|---|
| .. | ||
| e2e-tests | ||
| src | ||
| tools | ||
| .dockerignore | ||
| .eslintignore | ||
| .eslintrc.js | ||
| .gitignore | ||
| .prettierrc.js | ||
| .stylelintrc | ||
| babel.config.json | ||
| Dockerfile.dev | ||
| jest.config.js | ||
| jest.setup.ts | ||
| LICENSE | ||
| package.json | ||
| playwright.config.ts | ||
| plopfile.js | ||
| README.md | ||
| tsconfig.json | ||
| webpack.config.js | ||
| yarn.lock | ||
Grafana OnCall
Developer-Friendly Alert Management with Brilliant Slack Integration
- Connect monitoring systems
- Collect and analyze data
- On-call rotation
- Automatic escalation
- Never miss alerts with calls and SMS
Documentation
Development
Autogenerating TS types based on OpenAPI schema
| ⚠️ WARNING |
|---|
| Transition to this approach is in progress |
Overview
In order to automate types creation and prevent API usage pitfalls, OnCall project is using the following approach:
- OnCall Engine (backend) exposes OpenAPI schema
- OnCall Grafana Plugin (frontend) autogenerates TS type definitions based on it
- OnCall Grafana Plugin (frontend) uses autogenerated types as a single source of truth for any backend-related interactions (url paths, request bodies, params, response payloads)
Instruction
-
Whenever API contract changes, run
yarn generate-typesfromgrafana-plugindirectory -
Then you can start consuming types and you can use fully typed http client:
import { ApiSchemas } from 'network/oncall-api/api.types'; import onCallApi from 'network/oncall-api/http-client'; const { data: { results }, } = await onCallApi.GET('/alertgroups/'); const alertGroups: Array<ApiSchemas['AlertGroup']> = results; -
[Optional] If there is any property that is not yet exposed in OpenAPI schema and you already want to use it, you can append missing properties to particular schemas by editing
grafana-plugin/src/network/oncall-api/types-generator/custom-schemas.tsfile:export type CustomApiSchemas = { Alert: { propertyMissingInOpenAPI: string; }; AlertGroup: { anotherPropertyMissingInOpenAPI: number[]; }; };Then add their names to
CUSTOMIZED_SCHEMASarray ingrafana-plugin/src/network/oncall-api/types-generator/generate-types.ts:const CUSTOMIZED_SCHEMAS = ['Alert', 'AlertGroup'];The outcome is that autogenerated schemas will be modified as follows:
import type { CustomApiSchemas } from './types-generator/custom-schemas'; export interface components { schemas: { Alert: CustomApiSchemas['Alert'] & { readonly id: string; ... }; AlertGroup: CustomApiSchemas['AlertGroup'] & { readonly pk: string; ... }, ... } }