@anvil-js/client 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,892 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+ var client = require('@trpc/client');
5
+ var superjson = require('superjson');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var superjson__default = /*#__PURE__*/_interopDefault(superjson);
10
+
11
+ // src/schemas/common.ts
12
+ var UUIDSchema = zod.z.string().uuid();
13
+ var ISODateSchema = zod.z.string().datetime({ offset: true });
14
+ var ArchSchema = zod.z.enum(["x64", "arm64", "x86"]);
15
+ var PlatformSchema = zod.z.enum(["windows", "macos", "linux"]);
16
+ var LoaderTypeSchema = zod.z.enum(["vanilla", "fabric", "forge", "neoforge", "quilt"]);
17
+ var LocalizedStringSchema = zod.z.record(zod.z.string(), zod.z.string());
18
+ var TRPCErrorSchema = zod.z.object({
19
+ code: zod.z.enum([
20
+ "BAD_REQUEST",
21
+ "UNAUTHORIZED",
22
+ "FORBIDDEN",
23
+ "NOT_FOUND",
24
+ "CONFLICT",
25
+ "TOO_MANY_REQUESTS",
26
+ "INTERNAL_SERVER_ERROR"
27
+ ]),
28
+ message: zod.z.string()
29
+ });
30
+ var PaginationInputSchema = zod.z.object({
31
+ page: zod.z.number().int().min(1).default(1),
32
+ pageSize: zod.z.number().int().min(1).max(200).default(50)
33
+ });
34
+ var PaginatedSchema = (item) => zod.z.object({
35
+ items: zod.z.array(item),
36
+ total: zod.z.number().int().min(0),
37
+ page: zod.z.number().int().min(1),
38
+ pageSize: zod.z.number().int().min(1)
39
+ });
40
+ var UserSummarySchema = zod.z.object({
41
+ uuid: UUIDSchema,
42
+ email: zod.z.string().email(),
43
+ username: zod.z.string().min(1).max(64),
44
+ displayName: zod.z.string().min(1).max(128),
45
+ avatarUrl: zod.z.string().url().nullable(),
46
+ role: zod.z.enum(["USER", "MODERATOR", "ADMIN"]).default("USER")
47
+ });
48
+ var SessionSchema = zod.z.object({
49
+ anvil: zod.z.object({
50
+ user: UserSummarySchema,
51
+ accessToken: zod.z.string(),
52
+ refreshToken: zod.z.string(),
53
+ expiresAt: ISODateSchema
54
+ }),
55
+ mojang: zod.z.object({
56
+ uuid: UUIDSchema,
57
+ username: zod.z.string(),
58
+ accessToken: zod.z.string(),
59
+ expiresAt: ISODateSchema
60
+ }).nullable()
61
+ });
62
+ var LoginInputSchema = zod.z.object({
63
+ email: zod.z.string().email(),
64
+ password: zod.z.string().min(8).max(128)
65
+ });
66
+ var RegisterInputSchema = zod.z.object({
67
+ email: zod.z.string().email(),
68
+ username: zod.z.string().min(3).max(64).regex(/^[a-zA-Z0-9_]+$/),
69
+ password: zod.z.string().min(8).max(128)
70
+ });
71
+ var RefreshInputSchema = zod.z.object({
72
+ refreshToken: zod.z.string().min(1)
73
+ });
74
+ var ForgotPasswordInputSchema = zod.z.object({
75
+ email: zod.z.string().email()
76
+ });
77
+ var ResetPasswordInputSchema = zod.z.object({
78
+ token: zod.z.string().min(1),
79
+ newPassword: zod.z.string().min(8).max(128)
80
+ });
81
+ var ValidateInputSchema = zod.z.object({
82
+ token: zod.z.string().min(1)
83
+ });
84
+ var BuildSummarySchema = zod.z.object({
85
+ id: UUIDSchema,
86
+ slug: zod.z.string(),
87
+ name: zod.z.string(),
88
+ shortDescription: zod.z.string(),
89
+ iconUrl: zod.z.string().url().nullable(),
90
+ mcVersions: zod.z.array(zod.z.string()),
91
+ loaders: zod.z.array(LoaderTypeSchema),
92
+ visibility: zod.z.enum(["public", "private", "unlisted"]),
93
+ pricing: zod.z.discriminatedUnion("model", [
94
+ zod.z.object({ model: zod.z.literal("free") }),
95
+ zod.z.object({
96
+ model: zod.z.literal("paid"),
97
+ priceCents: zod.z.number().int().nonnegative(),
98
+ currency: zod.z.string()
99
+ }),
100
+ zod.z.object({
101
+ model: zod.z.literal("subscription"),
102
+ tiers: zod.z.array(
103
+ zod.z.object({
104
+ id: zod.z.string(),
105
+ name: zod.z.string(),
106
+ priceCents: zod.z.number().int().nonnegative(),
107
+ interval: zod.z.enum(["month", "year"])
108
+ })
109
+ )
110
+ })
111
+ ]),
112
+ stats: zod.z.object({
113
+ downloads: zod.z.number().int().nonnegative(),
114
+ favorites: zod.z.number().int().nonnegative(),
115
+ updatedAt: ISODateSchema
116
+ }),
117
+ // Provider source -- UI uses this to badge cards (Modrinth / Anvil).
118
+ source: zod.z.enum(["modrinth", "anvil"]).default("anvil")
119
+ });
120
+ var BuildFileSchema = zod.z.object({
121
+ url: zod.z.string().url(),
122
+ sha256: zod.z.string().regex(/^[a-f0-9]{64}$/),
123
+ sizeBytes: zod.z.number().int().nonnegative(),
124
+ primary: zod.z.boolean()
125
+ });
126
+ var BuildVersionSchema = zod.z.object({
127
+ id: UUIDSchema,
128
+ buildId: UUIDSchema,
129
+ name: zod.z.string(),
130
+ mcVersion: zod.z.string(),
131
+ loader: LoaderTypeSchema,
132
+ loaderVersion: zod.z.string(),
133
+ files: zod.z.array(BuildFileSchema),
134
+ dependencies: zod.z.array(
135
+ zod.z.object({
136
+ kind: zod.z.enum(["required", "optional", "incompatible", "embedded"]),
137
+ projectId: zod.z.string(),
138
+ versionId: zod.z.string().optional()
139
+ })
140
+ ),
141
+ changelog: zod.z.string().optional(),
142
+ publishedAt: ISODateSchema
143
+ });
144
+ var BuildSchema = BuildSummarySchema.extend({
145
+ versions: zod.z.array(BuildVersionSchema),
146
+ description: zod.z.string().optional(),
147
+ longDescription: LocalizedStringSchema.optional()
148
+ });
149
+ var ListBuildsInputSchema = zod.z.object({
150
+ search: zod.z.string().optional(),
151
+ tags: zod.z.array(zod.z.string()).optional(),
152
+ mcVersions: zod.z.array(zod.z.string()).optional(),
153
+ loaders: zod.z.array(LoaderTypeSchema).optional(),
154
+ visibility: zod.z.array(zod.z.enum(["public", "private", "unlisted"])).optional(),
155
+ source: zod.z.array(zod.z.enum(["modrinth", "anvil"])).optional(),
156
+ page: zod.z.number().int().min(1).default(1),
157
+ pageSize: zod.z.number().int().min(1).max(100).default(24),
158
+ sort: zod.z.enum(["popular", "recent", "name"]).default("popular")
159
+ });
160
+ var GetBuildInputSchema = zod.z.object({
161
+ idOrSlug: zod.z.string().min(1)
162
+ });
163
+ var RequestDownloadInputSchema = zod.z.object({
164
+ versionId: UUIDSchema,
165
+ clientArch: ArchSchema.optional()
166
+ });
167
+ var RequestDownloadOutputSchema = zod.z.object({
168
+ installId: UUIDSchema,
169
+ downloadUrl: zod.z.string().url(),
170
+ expiresAt: ISODateSchema,
171
+ sha256: zod.z.string(),
172
+ sizeBytes: zod.z.number().int().nonnegative()
173
+ });
174
+ var LicenseSchema = zod.z.object({
175
+ id: UUIDSchema,
176
+ buildId: UUIDSchema,
177
+ buildName: zod.z.string(),
178
+ status: zod.z.enum(["active", "expired", "revoked"]),
179
+ source: zod.z.enum(["purchase", "subscription", "gift", "promo", "dev_grant"]),
180
+ grantedAt: ISODateSchema,
181
+ expiresAt: ISODateSchema.nullable()
182
+ });
183
+ var ListLicensesInputSchema = zod.z.object({
184
+ buildId: UUIDSchema.optional(),
185
+ status: zod.z.enum(["active", "expired", "revoked"]).optional()
186
+ });
187
+ var CheckLicenseInputSchema = zod.z.object({
188
+ buildId: UUIDSchema
189
+ });
190
+ var CheckLicenseOutputSchema = zod.z.object({
191
+ hasAccess: zod.z.boolean(),
192
+ license: LicenseSchema.optional(),
193
+ reason: zod.z.enum(["no_license", "expired", "revoked", "region_locked"]).optional()
194
+ });
195
+ var LauncherModeSchema = zod.z.enum(["anvil", "mojang", "hybrid"]);
196
+ var AuthProviderSchema = zod.z.enum(["mojang", "anvil"]);
197
+ var ContentSourceSchema = zod.z.enum(["modrinth", "anvil"]);
198
+ var AnvilConnectionSchema = zod.z.object({
199
+ enabled: zod.z.boolean(),
200
+ baseUrl: zod.z.string().url().nullable(),
201
+ apiKey: zod.z.string().nullable()
202
+ });
203
+ var AuthConfigSchema = zod.z.object({
204
+ providers: zod.z.array(AuthProviderSchema).min(1)
205
+ });
206
+ var ContentConfigSchema = zod.z.object({
207
+ sources: zod.z.array(ContentSourceSchema).min(1)
208
+ });
209
+ var LauncherConfigSchema = zod.z.object({
210
+ mode: LauncherModeSchema,
211
+ auth: AuthConfigSchema,
212
+ content: ContentConfigSchema,
213
+ anvil: AnvilConnectionSchema,
214
+ telemetry: zod.z.boolean(),
215
+ autoUpdate: zod.z.boolean(),
216
+ region: zod.z.string().optional(),
217
+ version: zod.z.literal(1)
218
+ }).refine(
219
+ (c) => {
220
+ if (c.mode === "anvil") {
221
+ return c.auth.providers.length === 1 && c.auth.providers[0] === "anvil" && c.anvil.enabled;
222
+ }
223
+ if (c.mode === "mojang") {
224
+ return !c.auth.providers.includes("anvil") && !c.anvil.enabled;
225
+ }
226
+ const wantsAnvil = c.auth.providers.includes("anvil");
227
+ return !wantsAnvil || c.anvil.enabled;
228
+ },
229
+ {
230
+ message: "Auth providers must be consistent with mode and anvil.enabled",
231
+ path: ["auth", "providers"]
232
+ }
233
+ ).refine(
234
+ (c) => {
235
+ return !c.content.sources.includes("anvil") || c.anvil.enabled;
236
+ },
237
+ {
238
+ message: "anvil in content.sources requires anvil.enabled=true",
239
+ path: ["content", "sources"]
240
+ }
241
+ ).refine(
242
+ (c) => {
243
+ return !c.anvil.enabled || c.anvil.baseUrl !== null;
244
+ },
245
+ {
246
+ message: "anvil.enabled=true requires a non-null baseUrl",
247
+ path: ["anvil", "baseUrl"]
248
+ }
249
+ );
250
+ var defaultLauncherConfig = () => ({
251
+ mode: "hybrid",
252
+ // 'anvil' is included in the default provider list so the
253
+ // email/password login form is the first thing a fresh user
254
+ // sees. Q5 (Microsoft Azure App registration) will let us
255
+ // gate 'mojang' on NEXT_PUBLIC_MICROSOFT_CLIENT_ID being
256
+ // non-empty; until then both are listed.
257
+ auth: { providers: ["anvil", "mojang"] },
258
+ content: { sources: ["modrinth"] },
259
+ anvil: { enabled: false, baseUrl: null, apiKey: null },
260
+ telemetry: true,
261
+ autoUpdate: true,
262
+ version: 1
263
+ });
264
+ var isAuthProviderAnvil = (c) => c.mode === "anvil" || c.mode === "hybrid" && c.auth.providers.includes("anvil");
265
+ var RelationshipTypeSchema = zod.z.enum(["FRIENDS", "BLOCKED", "NEUTRAL"]);
266
+ var RelationshipStatusSchema = zod.z.enum(["PENDING", "VERIFIED"]);
267
+ var RelationshipDirectionSchema = zod.z.enum(["INCOMING", "OUTGOING", "MUTUAL"]);
268
+ var RelationshipsListKindSchema = zod.z.enum([
269
+ "FRIENDS",
270
+ "INCOMING_PENDING",
271
+ "OUTGOING_PENDING",
272
+ "BLOCKED"
273
+ ]);
274
+ var PresenceStatusSchema = zod.z.enum(["ONLINE", "OFFLINE", "AWAY", "BUSY"]);
275
+ var RelationshipSchema = zod.z.object({
276
+ id: UUIDSchema,
277
+ type: RelationshipTypeSchema,
278
+ status: RelationshipStatusSchema,
279
+ // 'MUTUAL' for verified friends, 'INCOMING' for pending requests
280
+ // sent to the current user, 'OUTGOING' for pending requests the
281
+ // current user sent.
282
+ direction: RelationshipDirectionSchema,
283
+ // The other side of the relationship.
284
+ otherUser: UserSummarySchema,
285
+ since: ISODateSchema,
286
+ // uuid of the user who sent the original request (FRIENDS only;
287
+ // for BLOCKED this is the user who created the block, which may
288
+ // be either side).
289
+ initiatorUuid: UUIDSchema
290
+ });
291
+ var TrustedHostSchema = zod.z.object({
292
+ id: UUIDSchema,
293
+ name: zod.z.string().min(1).max(64),
294
+ domains: zod.z.array(zod.z.string().min(1).max(255)).min(1).max(32),
295
+ addedAt: ISODateSchema
296
+ });
297
+ var UserActivitySchema = zod.z.object({
298
+ // 'playing <buildId>' / 'building' / 'browsing' / 'afk'
299
+ type: zod.z.string(),
300
+ metadata: zod.z.record(zod.z.string(), zod.z.string())
301
+ });
302
+ var PresenceSchema = zod.z.object({
303
+ uuid: UUIDSchema,
304
+ status: PresenceStatusSchema,
305
+ lastOnline: ISODateSchema,
306
+ currentActivity: UserActivitySchema.optional()
307
+ });
308
+ var LocalizedRuleSchema = zod.z.object({
309
+ locale: zod.z.string(),
310
+ title: zod.z.string(),
311
+ body: zod.z.string()
312
+ });
313
+ var CommunityRulesStatusSchema = zod.z.object({
314
+ accepted: zod.z.boolean(),
315
+ version: zod.z.string(),
316
+ rules: zod.z.array(LocalizedRuleSchema),
317
+ updatedAt: ISODateSchema
318
+ });
319
+ var SuspensionStatusSchema = zod.z.object({
320
+ suspended: zod.z.boolean(),
321
+ reason: zod.z.string().optional(),
322
+ expiresAt: ISODateSchema.optional()
323
+ });
324
+ var CreateRelationshipInputSchema = zod.z.object({
325
+ targetUuid: UUIDSchema,
326
+ type: zod.z.enum(["FRIENDS", "BLOCKED", "NEUTRAL"])
327
+ });
328
+ var DeleteRelationshipInputSchema = zod.z.object({
329
+ targetUuid: UUIDSchema,
330
+ type: zod.z.enum(["FRIENDS", "BLOCKED", "NEUTRAL"])
331
+ });
332
+ var ListRelationshipsInputSchema = zod.z.object({
333
+ type: RelationshipsListKindSchema.optional()
334
+ });
335
+ var AcceptRequestInputSchema = zod.z.object({
336
+ fromUuid: UUIDSchema
337
+ });
338
+ var CancelRequestInputSchema = zod.z.object({
339
+ toUuid: UUIDSchema
340
+ });
341
+ var LookupByNameInputSchema = zod.z.object({
342
+ username: zod.z.string().min(3).max(64).regex(/^[a-zA-Z0-9_]+$/)
343
+ });
344
+ var ReportActivityInputSchema = zod.z.object({
345
+ type: zod.z.string().min(1).max(64),
346
+ metadata: zod.z.record(zod.z.string(), zod.z.string())
347
+ });
348
+ var InviteToServerInputSchema = zod.z.object({
349
+ targetUuid: UUIDSchema,
350
+ address: zod.z.string().min(1).max(512)
351
+ });
352
+ var CreateTrustedHostInputSchema = zod.z.object({
353
+ name: zod.z.string().min(1).max(64),
354
+ domains: zod.z.array(zod.z.string().min(1).max(255)).min(1).max(32)
355
+ });
356
+ var DeleteTrustedHostInputSchema = zod.z.object({
357
+ id: UUIDSchema
358
+ });
359
+ var LookupByNameOutputSchema = zod.z.object({
360
+ user: zod.z.object({
361
+ uuid: UUIDSchema,
362
+ username: zod.z.string(),
363
+ displayName: zod.z.string()
364
+ }).nullable(),
365
+ nameMap: zod.z.record(UUIDSchema, zod.z.string())
366
+ });
367
+ var RELATIONSHIP_LABELS = {
368
+ FRIENDS: "Friends",
369
+ INCOMING_PENDING: "Incoming",
370
+ OUTGOING_PENDING: "Outgoing",
371
+ BLOCKED: "Blocked"
372
+ };
373
+ var PRESENCE_COLORS = {
374
+ ONLINE: "#10b981",
375
+ // emerald-500
376
+ AWAY: "#f59e0b",
377
+ // amber-500
378
+ BUSY: "#ef4444",
379
+ // red-500
380
+ OFFLINE: "#6b7280"
381
+ // gray-500
382
+ };
383
+ var ModrinthProjectTypeSchema = zod.z.enum([
384
+ "mod",
385
+ "modpack",
386
+ "resourcepack",
387
+ "shader",
388
+ "world"
389
+ ]);
390
+ var ModrinthDonationLinkSchema = zod.z.object({
391
+ id: zod.z.string(),
392
+ platform: zod.z.string(),
393
+ url: zod.z.string().url()
394
+ });
395
+ var ModrinthProjectSchema = zod.z.object({
396
+ project_id: zod.z.string(),
397
+ project_type: ModrinthProjectTypeSchema,
398
+ slug: zod.z.string(),
399
+ author: zod.z.string(),
400
+ title: zod.z.string(),
401
+ description: zod.z.string(),
402
+ categories: zod.z.array(zod.z.string()),
403
+ display_categories: zod.z.array(zod.z.string()),
404
+ versions: zod.z.array(zod.z.string()),
405
+ // mcVersions
406
+ downloads: zod.z.number().int().nonnegative(),
407
+ follows: zod.z.number().int().nonnegative(),
408
+ icon_url: zod.z.string().url().nullable(),
409
+ date_created: zod.z.string().datetime({ offset: true }),
410
+ date_modified: zod.z.string().datetime({ offset: true }),
411
+ latest_version: zod.z.string().nullable(),
412
+ license: zod.z.string().nullable(),
413
+ client_side: zod.z.enum(["required", "optional", "unsupported"]),
414
+ server_side: zod.z.enum(["required", "optional", "unsupported"]),
415
+ gallery: zod.z.array(zod.z.string().url())
416
+ });
417
+ var ModrinthSearchResponseSchema = zod.z.object({
418
+ hits: zod.z.array(ModrinthProjectSchema),
419
+ offset: zod.z.number().int().nonnegative(),
420
+ limit: zod.z.number().int().positive(),
421
+ total_hits: zod.z.number().int().nonnegative()
422
+ });
423
+ var ModrinthSearchInputSchema = zod.z.object({
424
+ query: zod.z.string().optional(),
425
+ facets: zod.z.array(zod.z.string()).optional(),
426
+ index: zod.z.enum(["relevance", "downloads", "follows", "newest", "updated"]).default("relevance"),
427
+ offset: zod.z.number().int().min(0).default(0),
428
+ limit: zod.z.number().int().min(1).max(100).default(20),
429
+ filters: zod.z.string().optional()
430
+ });
431
+ var MODRINTH_CATEGORIES = [
432
+ { id: "mod", label: "Mods" },
433
+ { id: "modpack", label: "Modpacks" },
434
+ { id: "resourcepack", label: "Resource Packs" },
435
+ { id: "shader", label: "Shaders" },
436
+ { id: "world", label: "Worlds" }
437
+ ];
438
+ var MC_VERSIONS_POPULAR = [
439
+ "1.21.4",
440
+ "1.21.3",
441
+ "1.21.1",
442
+ "1.21",
443
+ "1.20.6",
444
+ "1.20.4",
445
+ "1.20.1",
446
+ "1.19.4",
447
+ "1.19.2",
448
+ "1.18.2",
449
+ "1.16.5",
450
+ "1.12.2"
451
+ ];
452
+ var CosmeticTypeSchema = zod.z.enum([
453
+ "hat",
454
+ "body",
455
+ "back",
456
+ "face",
457
+ "hand",
458
+ "feet",
459
+ "particle",
460
+ "emote"
461
+ ]);
462
+ var CosmeticRaritySchema = zod.z.enum(["common", "uncommon", "rare", "epic", "legendary"]);
463
+ var CosmeticSchema = zod.z.object({
464
+ id: UUIDSchema,
465
+ type: CosmeticTypeSchema,
466
+ rarity: CosmeticRaritySchema,
467
+ name: LocalizedStringSchema,
468
+ description: LocalizedStringSchema.optional(),
469
+ iconUrl: zod.z.string().url().nullable(),
470
+ modelUrl: zod.z.string().url().nullable(),
471
+ owned: zod.z.boolean().default(false),
472
+ equipped: zod.z.boolean().default(false)
473
+ });
474
+ var OutfitSlotSchema = zod.z.object({
475
+ type: CosmeticTypeSchema,
476
+ cosmeticId: UUIDSchema.nullable()
477
+ });
478
+ var OutfitSchema = zod.z.object({
479
+ id: UUIDSchema,
480
+ name: zod.z.string().min(1).max(64),
481
+ slots: zod.z.array(OutfitSlotSchema).max(8),
482
+ createdAt: ISODateSchema,
483
+ updatedAt: ISODateSchema
484
+ });
485
+ var EmoteWheelSlotSchema = zod.z.object({
486
+ position: zod.z.number().int().min(0).max(7),
487
+ emoteId: UUIDSchema.nullable()
488
+ });
489
+ var EmoteWheelSchema = zod.z.object({
490
+ id: UUIDSchema,
491
+ name: zod.z.string().min(1).max(64),
492
+ slots: zod.z.array(EmoteWheelSlotSchema).length(8),
493
+ createdAt: ISODateSchema
494
+ });
495
+ var SkinVariantSchema = zod.z.enum(["classic", "slim"]);
496
+ var SkinSchema = zod.z.object({
497
+ id: UUIDSchema,
498
+ name: zod.z.string().min(1).max(64),
499
+ variant: SkinVariantSchema,
500
+ textureUrl: zod.z.string().url(),
501
+ sha256: zod.z.string().regex(/^[a-f0-9]{64}$/),
502
+ sizeBytes: zod.z.number().int().nonnegative(),
503
+ source: zod.z.enum(["uploaded", "mojang"]),
504
+ active: zod.z.boolean().default(false),
505
+ createdAt: ISODateSchema
506
+ });
507
+ var EquipCosmeticInputSchema = zod.z.object({
508
+ cosmeticId: UUIDSchema,
509
+ equipped: zod.z.boolean()
510
+ });
511
+ var CreateOutfitInputSchema = zod.z.object({
512
+ name: zod.z.string().min(1).max(64),
513
+ slots: zod.z.array(OutfitSlotSchema).max(8)
514
+ });
515
+ var UpdateOutfitInputSchema = zod.z.object({
516
+ id: UUIDSchema,
517
+ name: zod.z.string().min(1).max(64).optional(),
518
+ slots: zod.z.array(OutfitSlotSchema).max(8).optional()
519
+ });
520
+ var DeleteOutfitInputSchema = zod.z.object({ id: UUIDSchema });
521
+ var SaveEmoteWheelInputSchema = zod.z.object({
522
+ id: UUIDSchema.nullable(),
523
+ name: zod.z.string().min(1).max(64),
524
+ slots: zod.z.array(EmoteWheelSlotSchema).length(8)
525
+ });
526
+ var UploadSkinInputSchema = zod.z.object({
527
+ name: zod.z.string().min(1).max(64),
528
+ variant: SkinVariantSchema,
529
+ // base64 of the PNG bytes
530
+ data: zod.z.string().min(1)
531
+ });
532
+ var SetActiveSkinInputSchema = zod.z.object({ id: UUIDSchema });
533
+ var COSMETIC_TYPE_LABELS = {
534
+ hat: "Hat",
535
+ body: "Body",
536
+ back: "Back",
537
+ face: "Face",
538
+ hand: "Hand",
539
+ feet: "Feet",
540
+ particle: "Particles",
541
+ emote: "Emote"
542
+ };
543
+ var RARITY_COLORS = {
544
+ common: "#9ca3af",
545
+ uncommon: "#10b981",
546
+ rare: "#3b82f6",
547
+ epic: "#a855f7",
548
+ legendary: "#f59e0b"
549
+ };
550
+ var ChannelKindSchema = zod.z.enum(["DM", "GROUP", "ANNOUNCEMENT"]);
551
+ var ChatMemberSchema = zod.z.object({
552
+ user: UserSummarySchema,
553
+ role: zod.z.enum(["owner", "admin", "member"]),
554
+ joinedAt: ISODateSchema,
555
+ lastReadAt: ISODateSchema.nullable(),
556
+ muted: zod.z.boolean().default(false)
557
+ });
558
+ var ChannelSchema = zod.z.object({
559
+ id: UUIDSchema,
560
+ kind: ChannelKindSchema,
561
+ name: zod.z.string().nullable(),
562
+ // null for DMs
563
+ members: zod.z.array(ChatMemberSchema),
564
+ createdAt: ISODateSchema,
565
+ lastMessageAt: ISODateSchema.nullable(),
566
+ unreadCount: zod.z.number().int().nonnegative().default(0)
567
+ });
568
+ var MessageSchema = zod.z.object({
569
+ id: UUIDSchema,
570
+ channelId: UUIDSchema,
571
+ authorUuid: UUIDSchema,
572
+ authorDisplayName: zod.z.string(),
573
+ body: zod.z.string(),
574
+ // Markdown can be client-rendered; for the scaffold we ship it raw.
575
+ bodyMarkdown: zod.z.string().optional(),
576
+ createdAt: ISODateSchema,
577
+ editedAt: ISODateSchema.nullable(),
578
+ deletedAt: ISODateSchema.nullable(),
579
+ // Optional references
580
+ replyTo: UUIDSchema.nullable().optional()
581
+ });
582
+ var ListChannelsInputSchema = zod.z.object({
583
+ kind: ChannelKindSchema.optional()
584
+ });
585
+ var CreateDMInputSchema = zod.z.object({
586
+ otherUserUuid: UUIDSchema
587
+ });
588
+ var CreateGroupInputSchema = zod.z.object({
589
+ name: zod.z.string().min(1).max(64),
590
+ memberUuids: zod.z.array(UUIDSchema).min(1).max(64)
591
+ });
592
+ var ListMessagesInputSchema = zod.z.object({
593
+ channelId: UUIDSchema,
594
+ before: ISODateSchema.optional(),
595
+ limit: zod.z.number().int().min(1).max(200).default(50)
596
+ });
597
+ var SendMessageInputSchema = zod.z.object({
598
+ channelId: UUIDSchema,
599
+ body: zod.z.string().min(1).max(4e3),
600
+ replyTo: UUIDSchema.optional()
601
+ });
602
+ var EditMessageInputSchema = zod.z.object({
603
+ id: UUIDSchema,
604
+ body: zod.z.string().min(1).max(4e3)
605
+ });
606
+ var DeleteMessageInputSchema = zod.z.object({
607
+ id: UUIDSchema
608
+ });
609
+ var MarkReadInputSchema = zod.z.object({
610
+ channelId: UUIDSchema,
611
+ messageId: UUIDSchema
612
+ });
613
+ var ReportMessageInputSchema = zod.z.object({
614
+ messageId: UUIDSchema,
615
+ reason: zod.z.enum(["spam", "harassment", "illegal", "other"]),
616
+ note: zod.z.string().max(500).optional()
617
+ });
618
+ var ChannelReportsInputSchema = zod.z.object({
619
+ channelId: UUIDSchema,
620
+ start: ISODateSchema.optional(),
621
+ end: ISODateSchema.optional()
622
+ });
623
+ var CHANNEL_KIND_LABELS = {
624
+ DM: "Direct messages",
625
+ GROUP: "Groups",
626
+ ANNOUNCEMENT: "Announcements"
627
+ };
628
+ var MediaKindSchema = zod.z.enum(["screenshot", "video", "world", "skin"]);
629
+ var MediaItemSchema = zod.z.object({
630
+ id: UUIDSchema,
631
+ kind: MediaKindSchema,
632
+ url: zod.z.string().url(),
633
+ thumbnailUrl: zod.z.string().url().nullable(),
634
+ sha256: zod.z.string().regex(/^[a-f0-9]{64}$/),
635
+ sizeBytes: zod.z.number().int().nonnegative(),
636
+ width: zod.z.number().int().positive().optional(),
637
+ height: zod.z.number().int().positive().optional(),
638
+ durationSec: zod.z.number().int().nonnegative().optional(),
639
+ createdAt: ISODateSchema
640
+ });
641
+ var ListMediaInputSchema = zod.z.object({
642
+ kind: MediaKindSchema.optional(),
643
+ limit: zod.z.number().int().min(1).max(200).default(50),
644
+ offset: zod.z.number().int().min(0).default(0)
645
+ });
646
+ var UploadMediaInputSchema = zod.z.object({
647
+ kind: MediaKindSchema,
648
+ // base64 of the file bytes
649
+ data: zod.z.string().min(1),
650
+ filename: zod.z.string().min(1).max(255),
651
+ width: zod.z.number().int().positive().optional(),
652
+ height: zod.z.number().int().positive().optional()
653
+ });
654
+ var DeleteMediaInputSchema = zod.z.object({ id: UUIDSchema });
655
+ var SignalingKindSchema = zod.z.enum(["offer", "answer", "candidate"]);
656
+ var SignalingMessageSchema = zod.z.object({
657
+ id: UUIDSchema,
658
+ kind: SignalingKindSchema,
659
+ fromUuid: UUIDSchema,
660
+ toUuid: UUIDSchema,
661
+ payload: zod.z.string(),
662
+ // JSON-encoded SDP / ICE
663
+ createdAt: ISODateSchema
664
+ });
665
+ var SendSignalingInputSchema = zod.z.object({
666
+ toUuid: UUIDSchema,
667
+ kind: SignalingKindSchema,
668
+ payload: zod.z.string()
669
+ });
670
+ var ListSignalingInputSchema = zod.z.object({
671
+ fromUuid: UUIDSchema.optional(),
672
+ since: ISODateSchema.optional()
673
+ });
674
+ var UpnpSessionStatusSchema = zod.z.enum(["pending", "active", "closed", "error"]);
675
+ var UpnpSessionSchema = zod.z.object({
676
+ id: UUIDSchema,
677
+ ownerUuid: UUIDSchema,
678
+ ownerDisplayName: zod.z.string(),
679
+ publicAddress: zod.z.string(),
680
+ publicPort: zod.z.number().int().min(1).max(65535),
681
+ localAddress: zod.z.string(),
682
+ localPort: zod.z.number().int().min(1).max(65535),
683
+ status: UpnpSessionStatusSchema,
684
+ createdAt: ISODateSchema,
685
+ closedAt: ISODateSchema.nullable(),
686
+ invitedUuids: zod.z.array(UUIDSchema)
687
+ });
688
+ var CreateUpnpInputSchema = zod.z.object({
689
+ localAddress: zod.z.string(),
690
+ localPort: zod.z.number().int().min(1).max(65535),
691
+ invitedUuids: zod.z.array(UUIDSchema).default([])
692
+ });
693
+ var CloseUpnpInputSchema = zod.z.object({ id: UUIDSchema });
694
+ var KnownServerSchema = zod.z.object({
695
+ id: UUIDSchema,
696
+ name: zod.z.string(),
697
+ address: zod.z.string(),
698
+ description: zod.z.string().optional(),
699
+ iconUrl: zod.z.string().url().nullable(),
700
+ playerCount: zod.z.number().int().nonnegative().nullable(),
701
+ maxPlayers: zod.z.number().int().positive().nullable(),
702
+ version: zod.z.string().nullable(),
703
+ pingMs: zod.z.number().int().nonnegative().nullable(),
704
+ source: zod.z.enum(["anvil", "community"])
705
+ });
706
+ var SystemStatusSchema = zod.z.object({
707
+ status: zod.z.enum(["operational", "degraded", "outage"]),
708
+ maintenanceUntil: ISODateSchema.nullable(),
709
+ message: zod.z.string().nullable()
710
+ });
711
+ var InstalledInstanceSchema = zod.z.object({
712
+ id: UUIDSchema,
713
+ name: zod.z.string(),
714
+ mcVersion: zod.z.string(),
715
+ loader: LoaderTypeSchema,
716
+ loaderVersion: zod.z.string(),
717
+ path: zod.z.string(),
718
+ sizeBytes: zod.z.number().int().nonnegative(),
719
+ lastPlayedAt: ISODateSchema.nullable(),
720
+ installedAt: ISODateSchema
721
+ });
722
+ var ReportTelemetryInputSchema = zod.z.object({
723
+ event: zod.z.enum(["launch", "playtime", "crash"]),
724
+ metadata: zod.z.record(zod.z.string(), zod.z.string()).default({})
725
+ });
726
+ var LauncherUpdateInfoSchema = zod.z.object({
727
+ currentVersion: zod.z.string(),
728
+ latestVersion: zod.z.string(),
729
+ updateAvailable: zod.z.boolean(),
730
+ changelog: zod.z.string().nullable(),
731
+ downloadUrl: zod.z.string().url().nullable()
732
+ });
733
+ var createAnvilClient = (config) => {
734
+ const http = client.httpBatchLink({
735
+ url: config.baseUrl,
736
+ transformer: superjson__default.default,
737
+ headers: async () => {
738
+ const token = await config.getToken();
739
+ return token ? { authorization: `Bearer ${token}` } : {};
740
+ },
741
+ fetch: async (url, options) => {
742
+ const res = await fetch(url, { ...options, credentials: "include" });
743
+ if (res.status === 401) {
744
+ config.onAuthError?.();
745
+ }
746
+ return res;
747
+ }
748
+ });
749
+ const links = config.disableWebSocket ? [http] : [
750
+ client.splitLink({
751
+ condition: (op) => op.type === "subscription",
752
+ true: client.wsLink({
753
+ client: client.createWSClient({
754
+ url: config.baseUrl.replace(/^http/, "ws"),
755
+ connectionParams: async () => {
756
+ const token = await config.getToken();
757
+ return token ? { token } : {};
758
+ },
759
+ lazy: { enabled: false, closeMs: 0 }
760
+ }),
761
+ transformer: superjson__default.default
762
+ }),
763
+ false: http
764
+ })
765
+ ];
766
+ return client.createTRPCProxyClient({ links });
767
+ };
768
+
769
+ exports.AcceptRequestInputSchema = AcceptRequestInputSchema;
770
+ exports.AnvilConnectionSchema = AnvilConnectionSchema;
771
+ exports.ArchSchema = ArchSchema;
772
+ exports.AuthConfigSchema = AuthConfigSchema;
773
+ exports.AuthProviderSchema = AuthProviderSchema;
774
+ exports.BuildFileSchema = BuildFileSchema;
775
+ exports.BuildSchema = BuildSchema;
776
+ exports.BuildSummarySchema = BuildSummarySchema;
777
+ exports.BuildVersionSchema = BuildVersionSchema;
778
+ exports.CHANNEL_KIND_LABELS = CHANNEL_KIND_LABELS;
779
+ exports.COSMETIC_TYPE_LABELS = COSMETIC_TYPE_LABELS;
780
+ exports.CancelRequestInputSchema = CancelRequestInputSchema;
781
+ exports.ChannelKindSchema = ChannelKindSchema;
782
+ exports.ChannelReportsInputSchema = ChannelReportsInputSchema;
783
+ exports.ChannelSchema = ChannelSchema;
784
+ exports.ChatMemberSchema = ChatMemberSchema;
785
+ exports.CheckLicenseInputSchema = CheckLicenseInputSchema;
786
+ exports.CheckLicenseOutputSchema = CheckLicenseOutputSchema;
787
+ exports.CloseUpnpInputSchema = CloseUpnpInputSchema;
788
+ exports.CommunityRulesStatusSchema = CommunityRulesStatusSchema;
789
+ exports.ContentConfigSchema = ContentConfigSchema;
790
+ exports.ContentSourceSchema = ContentSourceSchema;
791
+ exports.CosmeticRaritySchema = CosmeticRaritySchema;
792
+ exports.CosmeticSchema = CosmeticSchema;
793
+ exports.CosmeticTypeSchema = CosmeticTypeSchema;
794
+ exports.CreateDMInputSchema = CreateDMInputSchema;
795
+ exports.CreateGroupInputSchema = CreateGroupInputSchema;
796
+ exports.CreateOutfitInputSchema = CreateOutfitInputSchema;
797
+ exports.CreateRelationshipInputSchema = CreateRelationshipInputSchema;
798
+ exports.CreateTrustedHostInputSchema = CreateTrustedHostInputSchema;
799
+ exports.CreateUpnpInputSchema = CreateUpnpInputSchema;
800
+ exports.DeleteMediaInputSchema = DeleteMediaInputSchema;
801
+ exports.DeleteMessageInputSchema = DeleteMessageInputSchema;
802
+ exports.DeleteOutfitInputSchema = DeleteOutfitInputSchema;
803
+ exports.DeleteRelationshipInputSchema = DeleteRelationshipInputSchema;
804
+ exports.DeleteTrustedHostInputSchema = DeleteTrustedHostInputSchema;
805
+ exports.EditMessageInputSchema = EditMessageInputSchema;
806
+ exports.EmoteWheelSchema = EmoteWheelSchema;
807
+ exports.EmoteWheelSlotSchema = EmoteWheelSlotSchema;
808
+ exports.EquipCosmeticInputSchema = EquipCosmeticInputSchema;
809
+ exports.ForgotPasswordInputSchema = ForgotPasswordInputSchema;
810
+ exports.GetBuildInputSchema = GetBuildInputSchema;
811
+ exports.ISODateSchema = ISODateSchema;
812
+ exports.InstalledInstanceSchema = InstalledInstanceSchema;
813
+ exports.InviteToServerInputSchema = InviteToServerInputSchema;
814
+ exports.KnownServerSchema = KnownServerSchema;
815
+ exports.LauncherConfigSchema = LauncherConfigSchema;
816
+ exports.LauncherModeSchema = LauncherModeSchema;
817
+ exports.LauncherUpdateInfoSchema = LauncherUpdateInfoSchema;
818
+ exports.LicenseSchema = LicenseSchema;
819
+ exports.ListBuildsInputSchema = ListBuildsInputSchema;
820
+ exports.ListChannelsInputSchema = ListChannelsInputSchema;
821
+ exports.ListLicensesInputSchema = ListLicensesInputSchema;
822
+ exports.ListMediaInputSchema = ListMediaInputSchema;
823
+ exports.ListMessagesInputSchema = ListMessagesInputSchema;
824
+ exports.ListRelationshipsInputSchema = ListRelationshipsInputSchema;
825
+ exports.ListSignalingInputSchema = ListSignalingInputSchema;
826
+ exports.LoaderTypeSchema = LoaderTypeSchema;
827
+ exports.LocalizedRuleSchema = LocalizedRuleSchema;
828
+ exports.LocalizedStringSchema = LocalizedStringSchema;
829
+ exports.LoginInputSchema = LoginInputSchema;
830
+ exports.LookupByNameInputSchema = LookupByNameInputSchema;
831
+ exports.LookupByNameOutputSchema = LookupByNameOutputSchema;
832
+ exports.MC_VERSIONS_POPULAR = MC_VERSIONS_POPULAR;
833
+ exports.MODRINTH_CATEGORIES = MODRINTH_CATEGORIES;
834
+ exports.MarkReadInputSchema = MarkReadInputSchema;
835
+ exports.MediaItemSchema = MediaItemSchema;
836
+ exports.MediaKindSchema = MediaKindSchema;
837
+ exports.MessageSchema = MessageSchema;
838
+ exports.ModrinthDonationLinkSchema = ModrinthDonationLinkSchema;
839
+ exports.ModrinthProjectSchema = ModrinthProjectSchema;
840
+ exports.ModrinthProjectTypeSchema = ModrinthProjectTypeSchema;
841
+ exports.ModrinthSearchInputSchema = ModrinthSearchInputSchema;
842
+ exports.ModrinthSearchResponseSchema = ModrinthSearchResponseSchema;
843
+ exports.OutfitSchema = OutfitSchema;
844
+ exports.OutfitSlotSchema = OutfitSlotSchema;
845
+ exports.PRESENCE_COLORS = PRESENCE_COLORS;
846
+ exports.PaginatedSchema = PaginatedSchema;
847
+ exports.PaginationInputSchema = PaginationInputSchema;
848
+ exports.PlatformSchema = PlatformSchema;
849
+ exports.PresenceSchema = PresenceSchema;
850
+ exports.PresenceStatusSchema = PresenceStatusSchema;
851
+ exports.RARITY_COLORS = RARITY_COLORS;
852
+ exports.RELATIONSHIP_LABELS = RELATIONSHIP_LABELS;
853
+ exports.RefreshInputSchema = RefreshInputSchema;
854
+ exports.RegisterInputSchema = RegisterInputSchema;
855
+ exports.RelationshipDirectionSchema = RelationshipDirectionSchema;
856
+ exports.RelationshipSchema = RelationshipSchema;
857
+ exports.RelationshipStatusSchema = RelationshipStatusSchema;
858
+ exports.RelationshipTypeSchema = RelationshipTypeSchema;
859
+ exports.RelationshipsListKindSchema = RelationshipsListKindSchema;
860
+ exports.ReportActivityInputSchema = ReportActivityInputSchema;
861
+ exports.ReportMessageInputSchema = ReportMessageInputSchema;
862
+ exports.ReportTelemetryInputSchema = ReportTelemetryInputSchema;
863
+ exports.RequestDownloadInputSchema = RequestDownloadInputSchema;
864
+ exports.RequestDownloadOutputSchema = RequestDownloadOutputSchema;
865
+ exports.ResetPasswordInputSchema = ResetPasswordInputSchema;
866
+ exports.SaveEmoteWheelInputSchema = SaveEmoteWheelInputSchema;
867
+ exports.SendMessageInputSchema = SendMessageInputSchema;
868
+ exports.SendSignalingInputSchema = SendSignalingInputSchema;
869
+ exports.SessionSchema = SessionSchema;
870
+ exports.SetActiveSkinInputSchema = SetActiveSkinInputSchema;
871
+ exports.SignalingKindSchema = SignalingKindSchema;
872
+ exports.SignalingMessageSchema = SignalingMessageSchema;
873
+ exports.SkinSchema = SkinSchema;
874
+ exports.SkinVariantSchema = SkinVariantSchema;
875
+ exports.SuspensionStatusSchema = SuspensionStatusSchema;
876
+ exports.SystemStatusSchema = SystemStatusSchema;
877
+ exports.TRPCErrorSchema = TRPCErrorSchema;
878
+ exports.TrustedHostSchema = TrustedHostSchema;
879
+ exports.UUIDSchema = UUIDSchema;
880
+ exports.UpdateOutfitInputSchema = UpdateOutfitInputSchema;
881
+ exports.UploadMediaInputSchema = UploadMediaInputSchema;
882
+ exports.UploadSkinInputSchema = UploadSkinInputSchema;
883
+ exports.UpnpSessionSchema = UpnpSessionSchema;
884
+ exports.UpnpSessionStatusSchema = UpnpSessionStatusSchema;
885
+ exports.UserActivitySchema = UserActivitySchema;
886
+ exports.UserSummarySchema = UserSummarySchema;
887
+ exports.ValidateInputSchema = ValidateInputSchema;
888
+ exports.createAnvilClient = createAnvilClient;
889
+ exports.defaultLauncherConfig = defaultLauncherConfig;
890
+ exports.isAuthProviderAnvil = isAuthProviderAnvil;
891
+ //# sourceMappingURL=index.cjs.map
892
+ //# sourceMappingURL=index.cjs.map