@domino-sdk/relay 0.28.0 → 0.30.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domino-sdk/relay",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,175 +0,0 @@
1
- import {
2
- identifier
3
- } from "./chunk-IXLY3A7B.js";
4
-
5
- // src/profiles.ts
6
- import { z } from "zod";
7
- var count = z.number().int().nonnegative().safe();
8
- var profileVisibilitySchema = z.enum([
9
- "private",
10
- "participants",
11
- "public"
12
- ]);
13
- var profileDefaultsSchema = z.enum(["generated", "accounts"]);
14
- var avatarProviderSchema = z.enum(["x", "discord", "google"]);
15
- var avatarSeedSchema = z.string().min(1).max(100);
16
- var profileAvatarSchema = z.discriminatedUnion("source", [
17
- z.object({
18
- source: z.literal("upload"),
19
- url: z.string().url(),
20
- seed: avatarSeedSchema
21
- }),
22
- z.object({
23
- source: z.literal("account"),
24
- provider: avatarProviderSchema,
25
- url: z.string().url(),
26
- seed: avatarSeedSchema
27
- }),
28
- z.object({ source: z.literal("generated"), seed: avatarSeedSchema })
29
- ]);
30
- var profileSummarySchema = z.object({
31
- id: identifier,
32
- name: z.string(),
33
- avatar: profileAvatarSchema
34
- });
35
- var invisible = /[\p{Cc}؜᠎​-‏‪-‮⁠-⁤⁦-⁩]/u;
36
- var displayNameSchema = z.string().max(200).transform((value) => value.normalize("NFC").replace(/\s+/g, " ").trim()).pipe(
37
- z.string().min(1, "Enter a name").max(40, "Use at most 40 characters").refine((value) => !invisible.test(value), "Use visible characters only")
38
- );
39
- var profileUpdateSchema = z.object({
40
- displayName: displayNameSchema.nullable().optional(),
41
- avatar: z.discriminatedUnion("source", [
42
- z.object({
43
- source: z.literal("account"),
44
- provider: avatarProviderSchema
45
- }).strict(),
46
- z.object({ source: z.literal("generated") }).strict()
47
- ]).nullable().optional(),
48
- hidden: z.boolean().optional()
49
- }).strict().refine(
50
- (value) => Object.values(value).some((field) => field !== void 0),
51
- "Change at least one field"
52
- );
53
- var ownProfileSchema = profileSummarySchema.extend({
54
- /** The name the member chose, or null for the default. */
55
- displayName: z.string().nullable(),
56
- /** The avatar the member chose: `default` follows the project's defaults. */
57
- avatarChoice: z.enum(["default", "upload", "account", "generated"]),
58
- /** The account of an `account` choice. */
59
- avatarProvider: avatarProviderSchema.nullable(),
60
- hidden: z.boolean(),
61
- /** An operator locked the name and avatar; the member can still hide the profile. */
62
- locked: z.boolean(),
63
- /** Who can see profiles in this project, so the app can explain it. */
64
- visibility: profileVisibilitySchema,
65
- /** The member's connected accounts a picture or name can come from. */
66
- options: z.array(
67
- z.object({
68
- provider: avatarProviderSchema,
69
- name: z.string().nullable(),
70
- imageUrl: z.string().url().nullable()
71
- })
72
- )
73
- });
74
- var publicProfileSchema = profileSummarySchema.extend({
75
- /** The profile is the viewer's own. */
76
- self: z.boolean(),
77
- leaderboards: z.array(
78
- z.object({
79
- leaderboard: identifier,
80
- key: identifier.optional(),
81
- title: z.string(),
82
- rank: count.positive(),
83
- score: z.number().int().safe(),
84
- /** Ranked participants on the board. */
85
- total: count
86
- })
87
- ).nullable(),
88
- quests: z.array(
89
- z.object({
90
- quest: identifier,
91
- key: identifier.optional(),
92
- title: z.string(),
93
- completions: count.positive(),
94
- /** Null for completions recorded before completion times were. */
95
- lastCompletedAt: count.nullable()
96
- })
97
- ).max(200).nullable(),
98
- referrals: z.object({
99
- /** Members this member invited. */
100
- attributed: count,
101
- programs: z.array(
102
- z.object({
103
- program: identifier,
104
- key: identifier.optional(),
105
- title: z.string(),
106
- qualified: count,
107
- milestones: z.array(
108
- z.object({ id: identifier, count, reached: z.boolean() })
109
- )
110
- })
111
- )
112
- }).nullable()
113
- });
114
- var profileSettingsSchema = z.object({
115
- visibility: profileVisibilitySchema,
116
- defaults: profileDefaultsSchema,
117
- /** The sections a profile page shows. */
118
- sections: z.object({
119
- leaderboards: z.boolean(),
120
- quests: z.boolean(),
121
- referrals: z.boolean()
122
- }),
123
- revision: count,
124
- actor: z.string().nullable(),
125
- updatedAt: count.nullable()
126
- });
127
- var profileSettingsInputSchema = profileSettingsSchema.omit({ revision: true, actor: true, updatedAt: true }).extend({
128
- actionId: identifier,
129
- /** The revision the change was made against; a newer one is a 409. */
130
- expectedRevision: count,
131
- reason: z.string().trim().min(1).max(500)
132
- }).strict();
133
- var profileModerationSchema = z.object({
134
- actionId: identifier,
135
- resetName: z.boolean().default(false),
136
- removeAvatar: z.boolean().default(false),
137
- /** True locks the name and avatar, false unlocks them. */
138
- lock: z.boolean().optional(),
139
- reason: z.string().trim().min(1).max(1e3)
140
- }).strict().refine(
141
- (value) => value.resetName || value.removeAvatar || value.lock !== void 0,
142
- "Choose an action"
143
- );
144
- var managedProfileSchema = ownProfileSchema.omit({ options: true }).extend({
145
- member: identifier,
146
- lockedAt: count.nullable(),
147
- lockedBy: z.string().nullable(),
148
- lockedReason: z.string().nullable(),
149
- updatedAt: count
150
- });
151
- var AVATAR_UPLOAD_LIMIT = 5 * 1024 * 1024;
152
- var avatarUploadTypes = ["image/jpeg", "image/png", "image/webp"];
153
- function isProfileParticipantRoute(path, method) {
154
- return method === "GET" && (path === "/v1/me/profile" || /^\/v1\/profiles\/[\w-]+$/.test(path)) || method === "POST" && (path === "/v1/me/profile" || path === "/v1/me/profile/avatar");
155
- }
156
-
157
- export {
158
- profileVisibilitySchema,
159
- profileDefaultsSchema,
160
- avatarProviderSchema,
161
- avatarSeedSchema,
162
- profileAvatarSchema,
163
- profileSummarySchema,
164
- displayNameSchema,
165
- profileUpdateSchema,
166
- ownProfileSchema,
167
- publicProfileSchema,
168
- profileSettingsSchema,
169
- profileSettingsInputSchema,
170
- profileModerationSchema,
171
- managedProfileSchema,
172
- AVATAR_UPLOAD_LIMIT,
173
- avatarUploadTypes,
174
- isProfileParticipantRoute
175
- };