Phase7
This commit is contained in:
43
packages/contracts/src/billing.ts
Normal file
43
packages/contracts/src/billing.ts
Normal 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>;
|
||||
@@ -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';
|
||||
|
||||
@@ -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(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user