mirror of
https://github.com/harivansh-afk/betterNAS.git
synced 2026-04-19 17:04:44 +00:00
add shared contracts
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
bc1878c1da
commit
679fd504a2
6 changed files with 126 additions and 0 deletions
17
packages/contracts/package.json
Normal file
17
packages/contracts/package.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "@ainas/contracts",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"schemas"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc -p tsconfig.json",
|
||||||
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
48
packages/contracts/schemas/control-plane-health.schema.json
Normal file
48
packages/contracts/schemas/control-plane-health.schema.json
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"$id": "https://ainas.local/schemas/control-plane-health.schema.json",
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"service",
|
||||||
|
"status",
|
||||||
|
"timestamp",
|
||||||
|
"uptimeSeconds",
|
||||||
|
"nextcloud"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"service": {
|
||||||
|
"const": "control-plane"
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"const": "ok"
|
||||||
|
},
|
||||||
|
"timestamp": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"uptimeSeconds": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"nextcloud": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"configured",
|
||||||
|
"baseUrl",
|
||||||
|
"provider"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"configured": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"baseUrl": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"provider": {
|
||||||
|
"const": "nextcloud"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
23
packages/contracts/schemas/control-plane-version.schema.json
Normal file
23
packages/contracts/schemas/control-plane-version.schema.json
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||||
|
"$id": "https://ainas.local/schemas/control-plane-version.schema.json",
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": [
|
||||||
|
"service",
|
||||||
|
"version",
|
||||||
|
"apiVersion"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"service": {
|
||||||
|
"const": "control-plane"
|
||||||
|
},
|
||||||
|
"version": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"apiVersion": {
|
||||||
|
"const": "v1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
25
packages/contracts/src/control-plane.ts
Normal file
25
packages/contracts/src/control-plane.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
export const CONTROL_PLANE_ROUTES = {
|
||||||
|
health: "/health",
|
||||||
|
version: "/version"
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export interface NextcloudBackendStatus {
|
||||||
|
configured: boolean;
|
||||||
|
baseUrl: string;
|
||||||
|
provider: "nextcloud";
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ControlPlaneHealthResponse {
|
||||||
|
service: "control-plane";
|
||||||
|
status: "ok";
|
||||||
|
timestamp: string;
|
||||||
|
uptimeSeconds: number;
|
||||||
|
nextcloud: NextcloudBackendStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ControlPlaneVersionResponse {
|
||||||
|
service: "control-plane";
|
||||||
|
version: string;
|
||||||
|
apiVersion: "v1";
|
||||||
|
}
|
||||||
|
|
||||||
2
packages/contracts/src/index.ts
Normal file
2
packages/contracts/src/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
export * from "./control-plane.js";
|
||||||
|
|
||||||
11
packages/contracts/tsconfig.json
Normal file
11
packages/contracts/tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "src",
|
||||||
|
"outDir": "dist"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue