Phase7
Some checks failed
CI / Node — lint, typecheck, test, build (push) Failing after 9s
CI / Go — node-agent tests (push) Failing after 8s
CI / Go — edge-gateway build (push) Successful in 14s

This commit is contained in:
smueller
2026-06-26 13:20:55 +02:00
parent 49a98ee31d
commit ab21f53cdd
86 changed files with 1207 additions and 63 deletions

View File

@@ -0,0 +1,43 @@
import { z } from 'zod';
export const idleStatusResponseSchema = z.object({
enabled: z.boolean(),
playerCount: z.number().int().nullable(),
idleStopAt: z.string().datetime().nullable(),
secondsRemaining: z.number().int().nullable(),
lastPlayerSeenAt: z.string().datetime().nullable(),
});
export const creditTransactionSchema = z.object({
id: z.string().uuid(),
amount: z.number().int(),
type: z.enum(['GRANT', 'USAGE_DEBIT', 'ADJUSTMENT', 'EXPIRE']),
referenceType: z.string().nullable(),
referenceId: z.string().nullable(),
createdAt: z.string().datetime(),
});
export const walletResponseSchema = z.object({
balance: z.number().int(),
periodStart: z.string().datetime(),
transactions: z.array(creditTransactionSchema),
});
export const usageRecordSchema = z.object({
id: z.string().uuid(),
serverId: z.string().uuid(),
ramMb: z.number().int(),
durationSeconds: z.number().int(),
creditsCharged: z.number().int(),
periodStart: z.string().datetime(),
periodEnd: z.string().datetime(),
createdAt: z.string().datetime(),
});
export const usageListResponseSchema = z.object({
records: z.array(usageRecordSchema),
});
export type IdleStatusResponse = z.infer<typeof idleStatusResponseSchema>;
export type WalletResponse = z.infer<typeof walletResponseSchema>;
export type UsageListResponse = z.infer<typeof usageListResponseSchema>;

View File

@@ -194,3 +194,14 @@ export {
type StartQueueEntry,
type StartQueueResponse,
} from './nodes';
export {
idleStatusResponseSchema,
creditTransactionSchema,
walletResponseSchema,
usageRecordSchema,
usageListResponseSchema,
type IdleStatusResponse,
type WalletResponse,
type UsageListResponse,
} from './billing';

View File

@@ -59,6 +59,8 @@ export const serverResponseSchema = z.object({
dataPath: z.string().nullable(),
activeWorldName: z.string(),
ramMb: z.number().int(),
idleShutdownEnabled: z.boolean(),
idleStopAt: z.string().datetime().nullable(),
createdAt: z.string().datetime(),
updatedAt: z.string().datetime(),
});