diff --git a/packages/contracts/package.json b/packages/contracts/package.json new file mode 100644 index 0000000..428dbc6 --- /dev/null +++ b/packages/contracts/package.json @@ -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" + } +} + diff --git a/packages/contracts/schemas/control-plane-health.schema.json b/packages/contracts/schemas/control-plane-health.schema.json new file mode 100644 index 0000000..803bb10 --- /dev/null +++ b/packages/contracts/schemas/control-plane-health.schema.json @@ -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" + } + } + } + } +} + diff --git a/packages/contracts/schemas/control-plane-version.schema.json b/packages/contracts/schemas/control-plane-version.schema.json new file mode 100644 index 0000000..15b10da --- /dev/null +++ b/packages/contracts/schemas/control-plane-version.schema.json @@ -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" + } + } +} + diff --git a/packages/contracts/src/control-plane.ts b/packages/contracts/src/control-plane.ts new file mode 100644 index 0000000..c785da3 --- /dev/null +++ b/packages/contracts/src/control-plane.ts @@ -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"; +} + diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts new file mode 100644 index 0000000..adb2a9c --- /dev/null +++ b/packages/contracts/src/index.ts @@ -0,0 +1,2 @@ +export * from "./control-plane.js"; + diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json new file mode 100644 index 0000000..0bff780 --- /dev/null +++ b/packages/contracts/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist" + }, + "include": [ + "src/**/*.ts" + ] +} +