Phase6
This commit is contained in:
@@ -180,3 +180,17 @@ export {
|
||||
type InstallAddonRequest,
|
||||
type InstallAddonResponse,
|
||||
} from './addons';
|
||||
|
||||
export {
|
||||
gameNodeStatusSchema,
|
||||
nodeSummarySchema,
|
||||
nodeListResponseSchema,
|
||||
startQueueStatusSchema,
|
||||
startQueueEntrySchema,
|
||||
startQueueResponseSchema,
|
||||
type GameNodeStatus,
|
||||
type NodeSummary,
|
||||
type NodeListResponse,
|
||||
type StartQueueEntry,
|
||||
type StartQueueResponse,
|
||||
} from './nodes';
|
||||
|
||||
57
packages/contracts/src/nodes.ts
Normal file
57
packages/contracts/src/nodes.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const gameNodeStatusSchema = z.enum([
|
||||
'ONLINE',
|
||||
'OFFLINE',
|
||||
'MAINTENANCE',
|
||||
'DRAINING',
|
||||
'UNREACHABLE',
|
||||
]);
|
||||
|
||||
export const nodeSummarySchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
name: z.string(),
|
||||
hostname: z.string(),
|
||||
status: gameNodeStatusSchema,
|
||||
maxServers: z.number().int(),
|
||||
maxRamMb: z.number().int(),
|
||||
platformRamMb: z.number().int(),
|
||||
activeServers: z.number().int(),
|
||||
reservedRamMb: z.number().int(),
|
||||
availableRamMb: z.number().int(),
|
||||
lastHeartbeatAt: z.string().datetime().nullable(),
|
||||
agentVersion: z.string().nullable(),
|
||||
drainRequestedAt: z.string().datetime().nullable(),
|
||||
createdAt: z.string().datetime(),
|
||||
});
|
||||
|
||||
export const nodeListResponseSchema = z.object({
|
||||
nodes: z.array(nodeSummarySchema),
|
||||
});
|
||||
|
||||
export const startQueueStatusSchema = z.enum([
|
||||
'QUEUED',
|
||||
'DISPATCHED',
|
||||
'CANCELLED',
|
||||
'EXPIRED',
|
||||
]);
|
||||
|
||||
export const startQueueEntrySchema = z.object({
|
||||
serverId: z.string().uuid(),
|
||||
nodeId: z.string().uuid(),
|
||||
status: startQueueStatusSchema,
|
||||
priority: z.number().int(),
|
||||
position: z.number().int().nullable(),
|
||||
requestedAt: z.string().datetime(),
|
||||
expiresAt: z.string().datetime().nullable(),
|
||||
});
|
||||
|
||||
export const startQueueResponseSchema = z.object({
|
||||
entry: startQueueEntrySchema.nullable(),
|
||||
});
|
||||
|
||||
export type GameNodeStatus = z.infer<typeof gameNodeStatusSchema>;
|
||||
export type NodeSummary = z.infer<typeof nodeSummarySchema>;
|
||||
export type NodeListResponse = z.infer<typeof nodeListResponseSchema>;
|
||||
export type StartQueueEntry = z.infer<typeof startQueueEntrySchema>;
|
||||
export type StartQueueResponse = z.infer<typeof startQueueResponseSchema>;
|
||||
@@ -5,11 +5,13 @@ export const gameServerStatusSchema = z.enum([
|
||||
'PROVISIONING',
|
||||
'INSTALLING',
|
||||
'STOPPED',
|
||||
'QUEUED',
|
||||
'STARTING',
|
||||
'RUNNING',
|
||||
'STOPPING',
|
||||
'BACKING_UP',
|
||||
'RESTORING',
|
||||
'UNKNOWN',
|
||||
'ERROR',
|
||||
'DELETING',
|
||||
'DELETED',
|
||||
@@ -68,6 +70,7 @@ export const serverListResponseSchema = z.object({
|
||||
export const serverActionResponseSchema = z.object({
|
||||
server: serverResponseSchema,
|
||||
jobId: z.string().optional(),
|
||||
queuePosition: z.number().int().optional(),
|
||||
});
|
||||
|
||||
export type GameServerStatus = z.infer<typeof gameServerStatusSchema>;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user