Phase5
This commit is contained in:
49
packages/contracts/src/addons.ts
Normal file
49
packages/contracts/src/addons.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const addonTypeSchema = z.enum(['PLUGIN', 'MOD', 'MODPACK', 'DATAPACK']);
|
||||
|
||||
export const addonStatusSchema = z.enum([
|
||||
'PENDING',
|
||||
'INSTALLING',
|
||||
'INSTALLED',
|
||||
'FAILED',
|
||||
'REMOVING',
|
||||
'REMOVED',
|
||||
]);
|
||||
|
||||
export const installedAddonSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
serverId: z.string().uuid(),
|
||||
provider: z.string(),
|
||||
projectId: z.string(),
|
||||
projectSlug: z.string(),
|
||||
projectName: z.string(),
|
||||
versionId: z.string(),
|
||||
versionNumber: z.string(),
|
||||
addonType: addonTypeSchema,
|
||||
fileName: z.string(),
|
||||
filePath: z.string(),
|
||||
status: addonStatusSchema,
|
||||
failureReason: z.string().nullable(),
|
||||
installedAt: z.string().datetime().nullable(),
|
||||
createdAt: z.string().datetime(),
|
||||
});
|
||||
|
||||
export const addonListResponseSchema = z.object({
|
||||
addons: z.array(installedAddonSchema),
|
||||
});
|
||||
|
||||
export const installAddonRequestSchema = z.object({
|
||||
projectId: z.string().min(1),
|
||||
versionId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const installAddonResponseSchema = z.object({
|
||||
addon: installedAddonSchema,
|
||||
jobId: z.string().optional(),
|
||||
});
|
||||
|
||||
export type InstalledAddon = z.infer<typeof installedAddonSchema>;
|
||||
export type AddonListResponse = z.infer<typeof addonListResponseSchema>;
|
||||
export type InstallAddonRequest = z.infer<typeof installAddonRequestSchema>;
|
||||
export type InstallAddonResponse = z.infer<typeof installAddonResponseSchema>;
|
||||
50
packages/contracts/src/catalog.ts
Normal file
50
packages/contracts/src/catalog.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const catalogProjectSchema = z.object({
|
||||
id: z.string(),
|
||||
slug: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
projectType: z.enum(['mod', 'plugin', 'modpack', 'resourcepack', 'shader']),
|
||||
downloads: z.number().int(),
|
||||
iconUrl: z.string().url().nullable(),
|
||||
});
|
||||
|
||||
export const catalogSearchQuerySchema = z.object({
|
||||
q: z.string().min(1).max(128),
|
||||
gameVersion: z.string().min(1).max(32),
|
||||
softwareFamily: z.enum([
|
||||
'PAPER',
|
||||
'PURPUR',
|
||||
'FABRIC',
|
||||
'FORGE',
|
||||
'NEOFORGE',
|
||||
'QUILT',
|
||||
]),
|
||||
limit: z.coerce.number().int().min(1).max(50).optional(),
|
||||
});
|
||||
|
||||
export const catalogSearchResponseSchema = z.object({
|
||||
projects: z.array(catalogProjectSchema),
|
||||
});
|
||||
|
||||
export const catalogVersionSchema = z.object({
|
||||
id: z.string(),
|
||||
projectId: z.string(),
|
||||
name: z.string(),
|
||||
versionNumber: z.string(),
|
||||
gameVersions: z.array(z.string()),
|
||||
loaders: z.array(z.string()),
|
||||
compatible: z.boolean(),
|
||||
publishedAt: z.string().datetime(),
|
||||
});
|
||||
|
||||
export const catalogVersionsResponseSchema = z.object({
|
||||
versions: z.array(catalogVersionSchema),
|
||||
});
|
||||
|
||||
export type CatalogProject = z.infer<typeof catalogProjectSchema>;
|
||||
export type CatalogSearchQuery = z.infer<typeof catalogSearchQuerySchema>;
|
||||
export type CatalogSearchResponse = z.infer<typeof catalogSearchResponseSchema>;
|
||||
export type CatalogVersion = z.infer<typeof catalogVersionSchema>;
|
||||
export type CatalogVersionsResponse = z.infer<typeof catalogVersionsResponseSchema>;
|
||||
@@ -154,3 +154,29 @@ export {
|
||||
type WorldUploadResponse,
|
||||
type WorldDownloadUrlResponse,
|
||||
} from './worlds';
|
||||
|
||||
export {
|
||||
catalogProjectSchema,
|
||||
catalogSearchQuerySchema,
|
||||
catalogSearchResponseSchema,
|
||||
catalogVersionSchema,
|
||||
catalogVersionsResponseSchema,
|
||||
type CatalogProject,
|
||||
type CatalogSearchQuery,
|
||||
type CatalogSearchResponse,
|
||||
type CatalogVersion,
|
||||
type CatalogVersionsResponse,
|
||||
} from './catalog';
|
||||
|
||||
export {
|
||||
addonTypeSchema,
|
||||
addonStatusSchema,
|
||||
installedAddonSchema,
|
||||
addonListResponseSchema,
|
||||
installAddonRequestSchema,
|
||||
installAddonResponseSchema,
|
||||
type InstalledAddon,
|
||||
type AddonListResponse,
|
||||
type InstallAddonRequest,
|
||||
type InstallAddonResponse,
|
||||
} from './addons';
|
||||
|
||||
Reference in New Issue
Block a user