@openpeepshq/common 0.1.43 → 0.1.44
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/lib/index.d.ts +1 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/postHelpers.d.ts +2 -0
- package/dist/lib/postHelpers.js +30 -11
- package/dist/lib/profileHelpers.d.ts +11 -0
- package/dist/lib/profileHelpers.js +29 -0
- package/dist/lib/reportHelpers.d.ts +2 -0
- package/dist/lib/reportHelpers.js +2 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/types/analytics.d.ts +86 -0
- package/dist/types/analytics.js +21 -0
- package/dist/types/api.d.ts +8 -5
- package/dist/types/api.js +1 -5
- package/dist/types/config.d.ts +35 -0
- package/dist/types/config.js +18 -7
- package/dist/types/notifications.d.ts +38 -1
- package/dist/types/notifications.js +12 -0
- package/package.json +1 -1
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import { Answer, AnswerWithPublicProfile, AuthorizationData, CapabilitiesConfig,
|
|
|
2
2
|
export declare const buildThreads: (posts: PublicPost[]) => Thread[];
|
|
3
3
|
export declare const getReactionCount: (post: PublicPost) => Record<"👍", number>;
|
|
4
4
|
export declare const countVotes: (optionsCount: number, answers: Answer[]) => number[];
|
|
5
|
+
/** Fill blank poll choices with their placeholder label (e.g. "Option 1"). */
|
|
6
|
+
export declare const resolvePollOptionContents: (options: readonly string[], fallbackLabel: (index: number) => string) => string[];
|
|
5
7
|
export declare const collectVotes: (post: PublicPost) => {
|
|
6
8
|
voteCounts: number[];
|
|
7
9
|
votes: AnswerWithPublicProfile[];
|
package/dist/lib/postHelpers.js
CHANGED
|
@@ -27,6 +27,11 @@ export const countVotes = (optionsCount, answers) => {
|
|
|
27
27
|
}
|
|
28
28
|
return voteCounts;
|
|
29
29
|
};
|
|
30
|
+
/** Fill blank poll choices with their placeholder label (e.g. "Option 1"). */
|
|
31
|
+
export const resolvePollOptionContents = (options, fallbackLabel) => options.map((text, index) => {
|
|
32
|
+
const trimmed = text.trim();
|
|
33
|
+
return trimmed.length > 0 ? trimmed : fallbackLabel(index);
|
|
34
|
+
});
|
|
30
35
|
export const collectVotes = (post) => {
|
|
31
36
|
if (post.type !== 'question') {
|
|
32
37
|
return {
|
|
@@ -92,8 +97,7 @@ export const normalizeEventDataFromDb = (event) => {
|
|
|
92
97
|
};
|
|
93
98
|
export const normalizePostDataFromDb = (data) => data.type === 'event' ? normalizeEventDataFromDb(data) : data;
|
|
94
99
|
export const eventDataForDbUpdate = (previous, normalized) => {
|
|
95
|
-
if ((previous === null || previous === void 0 ? void 0 : previous.maxAttendees) != null &&
|
|
96
|
-
!('maxAttendees' in normalized)) {
|
|
100
|
+
if ((previous === null || previous === void 0 ? void 0 : previous.maxAttendees) != null && !('maxAttendees' in normalized)) {
|
|
97
101
|
return { ...normalized, maxAttendees: null };
|
|
98
102
|
}
|
|
99
103
|
return normalized;
|
|
@@ -124,21 +128,36 @@ export const getJamCapacityJoinBlock = (post, profile) => {
|
|
|
124
128
|
export const canDeletePost = (authData, post, config) => checkPostCapabilities(authData, ['core-posts-delete'], post, config).success;
|
|
125
129
|
export const canCreatePost = (authData, type, visibility, group) => {
|
|
126
130
|
var _a;
|
|
127
|
-
return visibility === 'group'
|
|
128
|
-
!!group &&
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
return visibility === 'group'
|
|
132
|
+
? !!group &&
|
|
133
|
+
checkGroupCapabilities(authData, [`core-posts-create-${type}`], group)
|
|
134
|
+
.success
|
|
135
|
+
: checkRoleCapabilities((_a = authData.profile) === null || _a === void 0 ? void 0 : _a.roles, [
|
|
136
|
+
`core-posts-create-${type}-${visibility}`,
|
|
137
|
+
]).success &&
|
|
138
|
+
scopeMatches({
|
|
139
|
+
scopes: authData.scopes,
|
|
140
|
+
requiredScope: { scopeLevel: 'write', resource: { type: 'posts' } },
|
|
141
|
+
});
|
|
131
142
|
};
|
|
132
143
|
export const canCreatePostTypeInAnyGroup = (authData, type) => {
|
|
133
144
|
var _a, _b;
|
|
134
|
-
return scopeMatches({
|
|
145
|
+
return scopeMatches({
|
|
146
|
+
scopes: authData.scopes,
|
|
147
|
+
requiredScope: { scopeLevel: 'write', resource: { type: 'groups' } },
|
|
148
|
+
}) &&
|
|
135
149
|
!!((_b = (_a = authData.profile) === null || _a === void 0 ? void 0 : _a.memberships) === null || _b === void 0 ? void 0 : _b.some((m) => checkGroupCapabilities(authData, [`core-posts-create-${type}`], m.group).success));
|
|
136
150
|
};
|
|
137
151
|
export const canCreatePostTypeWithVisibility = (authData, type, visibility) => {
|
|
138
152
|
var _a;
|
|
139
|
-
return visibility === 'group'
|
|
140
|
-
canCreatePostTypeInAnyGroup(authData, type)
|
|
141
|
-
checkRoleCapabilities((_a = authData.profile) === null || _a === void 0 ? void 0 : _a.roles, [
|
|
142
|
-
|
|
153
|
+
return visibility === 'group'
|
|
154
|
+
? canCreatePostTypeInAnyGroup(authData, type)
|
|
155
|
+
: checkRoleCapabilities((_a = authData.profile) === null || _a === void 0 ? void 0 : _a.roles, [
|
|
156
|
+
`core-posts-create-${type}-${visibility}`,
|
|
157
|
+
]).success &&
|
|
158
|
+
scopeMatches({
|
|
159
|
+
scopes: authData.scopes,
|
|
160
|
+
requiredScope: { scopeLevel: 'write', resource: { type: 'posts' } },
|
|
161
|
+
});
|
|
143
162
|
};
|
|
144
163
|
export const canCreatePostType = (authData, type) => visibilityTypeValues.some((visibility) => canCreatePostTypeWithVisibility(authData, type, visibility));
|
|
@@ -13,6 +13,17 @@ export declare const isDeletedProfile: (profile: {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const toPublicDeletedProfile: <T extends PublicProfile>(profile: T) => T;
|
|
15
15
|
export declare const anonymizeProfileIfDeleted: <T extends PublicProfile>(profile: T | undefined | null) => T | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Tombstone for internal `ProfileWithMeta` surfaces (e.g. moderation reports).
|
|
18
|
+
* Built explicitly rather than by spreading the original so no PII of the
|
|
19
|
+
* deleted account (email/controllers, social graph, time zone, guest data)
|
|
20
|
+
* can leak, while still satisfying `profileWithMetaSchema` — unlike
|
|
21
|
+
* {@link toPublicDeletedProfile}, whose stripped shape is only valid for the
|
|
22
|
+
* looser `publicProfileSchema`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const toDeletedProfileWithMeta: (profile: ProfileWithMeta) => ProfileWithMeta;
|
|
25
|
+
/** Tombstone a `ProfileWithMeta` only when it is soft-deleted. */
|
|
26
|
+
export declare const tombstoneProfileWithMetaIfDeleted: (profile: ProfileWithMeta | undefined) => ProfileWithMeta | undefined;
|
|
16
27
|
export declare const profileName: (profile?: PublicProfile) => string | undefined;
|
|
17
28
|
export declare const matchesQuery: (profile: PublicProfile | GroupWithMeta | undefined, query: string, queryOptions?: {
|
|
18
29
|
handle: boolean;
|
|
@@ -34,6 +34,35 @@ export const anonymizeProfileIfDeleted = (profile) => {
|
|
|
34
34
|
return undefined;
|
|
35
35
|
return isDeletedProfile(profile) ? toPublicDeletedProfile(profile) : profile;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Tombstone for internal `ProfileWithMeta` surfaces (e.g. moderation reports).
|
|
39
|
+
* Built explicitly rather than by spreading the original so no PII of the
|
|
40
|
+
* deleted account (email/controllers, social graph, time zone, guest data)
|
|
41
|
+
* can leak, while still satisfying `profileWithMetaSchema` — unlike
|
|
42
|
+
* {@link toPublicDeletedProfile}, whose stripped shape is only valid for the
|
|
43
|
+
* looser `publicProfileSchema`.
|
|
44
|
+
*/
|
|
45
|
+
export const toDeletedProfileWithMeta = (profile) => ({
|
|
46
|
+
id: profile.id,
|
|
47
|
+
type: profile.type,
|
|
48
|
+
createdAt: profile.createdAt,
|
|
49
|
+
updatedAt: profile.updatedAt,
|
|
50
|
+
deletedAt: profile.deletedAt,
|
|
51
|
+
handle: DELETED_AUTHOR_HANDLE,
|
|
52
|
+
displayName: DELETED_AUTHOR_DISPLAY_NAME,
|
|
53
|
+
avatar: null,
|
|
54
|
+
header: null,
|
|
55
|
+
roles: [],
|
|
56
|
+
followers: [],
|
|
57
|
+
following: [],
|
|
58
|
+
controllers: [],
|
|
59
|
+
memberships: [],
|
|
60
|
+
profileStats: { followersCount: 0, followingCount: 0 },
|
|
61
|
+
});
|
|
62
|
+
/** Tombstone a `ProfileWithMeta` only when it is soft-deleted. */
|
|
63
|
+
export const tombstoneProfileWithMetaIfDeleted = (profile) => profile && isDeletedProfile(profile)
|
|
64
|
+
? toDeletedProfileWithMeta(profile)
|
|
65
|
+
: profile;
|
|
37
66
|
export const profileName = (profile) => (profile === null || profile === void 0 ? void 0 : profile.displayName) || (profile === null || profile === void 0 ? void 0 : profile.handle);
|
|
38
67
|
export const matchesQuery = (profile, query, queryOptions = { handle: true, displayName: true }) => !!(profile &&
|
|
39
68
|
(query.startsWith('@')
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ export declare const formatTimeStamp: (timestamp: number | null, startDate?: num
|
|
|
29
29
|
export declare const getTheme: (config: CommunityConfig, profileSettings?: ProfileSettings, systemTheme?: "dark" | "light") => {
|
|
30
30
|
dark: boolean;
|
|
31
31
|
primaryHex: string;
|
|
32
|
+
secondaryHex?: string | undefined;
|
|
33
|
+
fontFamily?: string | undefined;
|
|
34
|
+
buttonRadius?: string | undefined;
|
|
35
|
+
radius?: string | undefined;
|
|
32
36
|
logoSmall?: string | undefined;
|
|
33
37
|
defaultProfileAvatar?: string | undefined;
|
|
34
38
|
defaultGroupAvatar?: string | undefined;
|
|
@@ -346,6 +346,36 @@ export declare const analyticsGrowthSchema: z.ZodObject<{
|
|
|
346
346
|
value: z.ZodNumber;
|
|
347
347
|
}, z.core.$strip>>>;
|
|
348
348
|
}, z.core.$strip>;
|
|
349
|
+
dau: z.ZodObject<{
|
|
350
|
+
key: z.ZodString;
|
|
351
|
+
value: z.ZodNumber;
|
|
352
|
+
previousValue: z.ZodNumber;
|
|
353
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
354
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
355
|
+
day: z.ZodString;
|
|
356
|
+
value: z.ZodNumber;
|
|
357
|
+
}, z.core.$strip>>>;
|
|
358
|
+
}, z.core.$strip>;
|
|
359
|
+
mau: z.ZodObject<{
|
|
360
|
+
key: z.ZodString;
|
|
361
|
+
value: z.ZodNumber;
|
|
362
|
+
previousValue: z.ZodNumber;
|
|
363
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
364
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
365
|
+
day: z.ZodString;
|
|
366
|
+
value: z.ZodNumber;
|
|
367
|
+
}, z.core.$strip>>>;
|
|
368
|
+
}, z.core.$strip>;
|
|
369
|
+
dauMau: z.ZodObject<{
|
|
370
|
+
key: z.ZodString;
|
|
371
|
+
value: z.ZodNumber;
|
|
372
|
+
previousValue: z.ZodNumber;
|
|
373
|
+
deltaPct: z.ZodNullable<z.ZodNumber>;
|
|
374
|
+
series: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
375
|
+
day: z.ZodString;
|
|
376
|
+
value: z.ZodNumber;
|
|
377
|
+
}, z.core.$strip>>>;
|
|
378
|
+
}, z.core.$strip>;
|
|
349
379
|
}, z.core.$strip>;
|
|
350
380
|
signupsByDay: z.ZodArray<z.ZodObject<{
|
|
351
381
|
day: z.ZodString;
|
|
@@ -367,6 +397,7 @@ export declare const analyticsEngagementOverTimePointSchema: z.ZodObject<{
|
|
|
367
397
|
comments: z.ZodNumber;
|
|
368
398
|
reposts: z.ZodNumber;
|
|
369
399
|
bookmarks: z.ZodNumber;
|
|
400
|
+
dms: z.ZodNumber;
|
|
370
401
|
}, z.core.$strip>;
|
|
371
402
|
export type AnalyticsEngagementOverTimePoint = z.infer<typeof analyticsEngagementOverTimePointSchema>;
|
|
372
403
|
export declare const analyticsEngagementSchema: z.ZodObject<{
|
|
@@ -464,6 +495,7 @@ export declare const analyticsEngagementSchema: z.ZodObject<{
|
|
|
464
495
|
comments: z.ZodNumber;
|
|
465
496
|
reposts: z.ZodNumber;
|
|
466
497
|
bookmarks: z.ZodNumber;
|
|
498
|
+
dms: z.ZodNumber;
|
|
467
499
|
}, z.core.$strip>>;
|
|
468
500
|
impressionsByPeriod: z.ZodArray<z.ZodObject<{
|
|
469
501
|
day: z.ZodString;
|
|
@@ -581,3 +613,57 @@ export declare const analyticsBackfillResponseSchema: z.ZodObject<{
|
|
|
581
613
|
to: z.ZodString;
|
|
582
614
|
}, z.core.$strip>;
|
|
583
615
|
export type AnalyticsBackfillResponse = z.infer<typeof analyticsBackfillResponseSchema>;
|
|
616
|
+
export declare const analyticsClickKindSchema: z.ZodEnum<{
|
|
617
|
+
link: "link";
|
|
618
|
+
page: "page";
|
|
619
|
+
}>;
|
|
620
|
+
export type AnalyticsClickKind = z.infer<typeof analyticsClickKindSchema>;
|
|
621
|
+
export declare const analyticsClickEventSchema: z.ZodObject<{
|
|
622
|
+
kind: z.ZodEnum<{
|
|
623
|
+
link: "link";
|
|
624
|
+
page: "page";
|
|
625
|
+
}>;
|
|
626
|
+
target: z.ZodString;
|
|
627
|
+
}, z.core.$strip>;
|
|
628
|
+
export type AnalyticsClickEvent = z.infer<typeof analyticsClickEventSchema>;
|
|
629
|
+
export declare const analyticsClicksIngestSchema: z.ZodObject<{
|
|
630
|
+
events: z.ZodArray<z.ZodObject<{
|
|
631
|
+
kind: z.ZodEnum<{
|
|
632
|
+
link: "link";
|
|
633
|
+
page: "page";
|
|
634
|
+
}>;
|
|
635
|
+
target: z.ZodString;
|
|
636
|
+
}, z.core.$strip>>;
|
|
637
|
+
}, z.core.$strip>;
|
|
638
|
+
export type AnalyticsClicksIngest = z.infer<typeof analyticsClicksIngestSchema>;
|
|
639
|
+
export declare const analyticsClickRowSchema: z.ZodObject<{
|
|
640
|
+
target: z.ZodString;
|
|
641
|
+
clicks: z.ZodNumber;
|
|
642
|
+
}, z.core.$strip>;
|
|
643
|
+
export type AnalyticsClickRow = z.infer<typeof analyticsClickRowSchema>;
|
|
644
|
+
export declare const analyticsClicksSchema: z.ZodObject<{
|
|
645
|
+
range: z.ZodObject<{
|
|
646
|
+
from: z.ZodString;
|
|
647
|
+
to: z.ZodString;
|
|
648
|
+
previousFrom: z.ZodString;
|
|
649
|
+
previousTo: z.ZodString;
|
|
650
|
+
preset: z.ZodOptional<z.ZodEnum<{
|
|
651
|
+
all: "all";
|
|
652
|
+
"7d": "7d";
|
|
653
|
+
"30d": "30d";
|
|
654
|
+
"3m": "3m";
|
|
655
|
+
"6m": "6m";
|
|
656
|
+
"12m": "12m";
|
|
657
|
+
}>>;
|
|
658
|
+
compiledAt: z.ZodNullable<z.ZodString>;
|
|
659
|
+
}, z.core.$strip>;
|
|
660
|
+
pages: z.ZodArray<z.ZodObject<{
|
|
661
|
+
target: z.ZodString;
|
|
662
|
+
clicks: z.ZodNumber;
|
|
663
|
+
}, z.core.$strip>>;
|
|
664
|
+
links: z.ZodArray<z.ZodObject<{
|
|
665
|
+
target: z.ZodString;
|
|
666
|
+
clicks: z.ZodNumber;
|
|
667
|
+
}, z.core.$strip>>;
|
|
668
|
+
}, z.core.$strip>;
|
|
669
|
+
export type AnalyticsClicks = z.infer<typeof analyticsClicksSchema>;
|
package/dist/types/analytics.js
CHANGED
|
@@ -154,6 +154,9 @@ export const analyticsGrowthSchema = z.object({
|
|
|
154
154
|
range: analyticsRangeMetaSchema,
|
|
155
155
|
metrics: z.object({
|
|
156
156
|
newSignups: analyticsMetricCardSchema,
|
|
157
|
+
dau: analyticsMetricCardSchema,
|
|
158
|
+
mau: analyticsMetricCardSchema,
|
|
159
|
+
dauMau: analyticsMetricCardSchema,
|
|
157
160
|
}),
|
|
158
161
|
/** New-member counts for every day in the selected range. */
|
|
159
162
|
signupsByDay: analyticsDayHeatmapCellSchema.array(),
|
|
@@ -166,6 +169,7 @@ export const analyticsEngagementOverTimePointSchema = z.object({
|
|
|
166
169
|
comments: z.number(),
|
|
167
170
|
reposts: z.number(),
|
|
168
171
|
bookmarks: z.number(),
|
|
172
|
+
dms: z.number(),
|
|
169
173
|
});
|
|
170
174
|
export const analyticsEngagementSchema = z.object({
|
|
171
175
|
range: analyticsRangeMetaSchema,
|
|
@@ -211,3 +215,20 @@ export const analyticsBackfillResponseSchema = z.object({
|
|
|
211
215
|
from: z.string(),
|
|
212
216
|
to: z.string(),
|
|
213
217
|
});
|
|
218
|
+
export const analyticsClickKindSchema = z.enum(['page', 'link']);
|
|
219
|
+
export const analyticsClickEventSchema = z.object({
|
|
220
|
+
kind: analyticsClickKindSchema,
|
|
221
|
+
target: z.string().min(1).max(2048),
|
|
222
|
+
});
|
|
223
|
+
export const analyticsClicksIngestSchema = z.object({
|
|
224
|
+
events: analyticsClickEventSchema.array().min(1).max(20),
|
|
225
|
+
});
|
|
226
|
+
export const analyticsClickRowSchema = z.object({
|
|
227
|
+
target: z.string(),
|
|
228
|
+
clicks: z.number(),
|
|
229
|
+
});
|
|
230
|
+
export const analyticsClicksSchema = z.object({
|
|
231
|
+
range: analyticsRangeMetaSchema,
|
|
232
|
+
pages: analyticsClickRowSchema.array(),
|
|
233
|
+
links: analyticsClickRowSchema.array(),
|
|
234
|
+
});
|
package/dist/types/api.d.ts
CHANGED
|
@@ -13143,6 +13143,10 @@ export declare const serverInfoSchema: z.ZodObject<{
|
|
|
13143
13143
|
background: z.ZodOptional<z.ZodString>;
|
|
13144
13144
|
light: z.ZodObject<{
|
|
13145
13145
|
primaryHex: z.ZodString;
|
|
13146
|
+
secondaryHex: z.ZodOptional<z.ZodString>;
|
|
13147
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
13148
|
+
buttonRadius: z.ZodOptional<z.ZodString>;
|
|
13149
|
+
radius: z.ZodOptional<z.ZodString>;
|
|
13146
13150
|
logoSmall: z.ZodOptional<z.ZodString>;
|
|
13147
13151
|
defaultProfileAvatar: z.ZodOptional<z.ZodString>;
|
|
13148
13152
|
defaultGroupAvatar: z.ZodOptional<z.ZodString>;
|
|
@@ -13151,6 +13155,10 @@ export declare const serverInfoSchema: z.ZodObject<{
|
|
|
13151
13155
|
}, z.core.$strip>;
|
|
13152
13156
|
dark: z.ZodObject<{
|
|
13153
13157
|
primaryHex: z.ZodString;
|
|
13158
|
+
secondaryHex: z.ZodOptional<z.ZodString>;
|
|
13159
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
13160
|
+
buttonRadius: z.ZodOptional<z.ZodString>;
|
|
13161
|
+
radius: z.ZodOptional<z.ZodString>;
|
|
13154
13162
|
logoSmall: z.ZodOptional<z.ZodString>;
|
|
13155
13163
|
defaultProfileAvatar: z.ZodOptional<z.ZodString>;
|
|
13156
13164
|
defaultGroupAvatar: z.ZodOptional<z.ZodString>;
|
|
@@ -13225,11 +13233,6 @@ export declare const serverInfoSchema: z.ZodObject<{
|
|
|
13225
13233
|
}, z.core.$strip>>;
|
|
13226
13234
|
}, z.core.$strip>;
|
|
13227
13235
|
export type ServerInfo = z.infer<typeof serverInfoSchema>;
|
|
13228
|
-
export declare const notificationStatsSchema: z.ZodObject<{
|
|
13229
|
-
unread: z.ZodNumber;
|
|
13230
|
-
unseen: z.ZodNumber;
|
|
13231
|
-
}, z.core.$strip>;
|
|
13232
|
-
export type NotificationStats = z.infer<typeof notificationStatsSchema>;
|
|
13233
13236
|
export declare const unseenPostCountsSchema: z.ZodObject<{
|
|
13234
13237
|
groups: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
13235
13238
|
direct: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
package/dist/types/api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { pushNotificationSchema } from './notifications.js';
|
|
2
|
+
import { notificationStatsSchema, pushNotificationSchema, } from './notifications.js';
|
|
3
3
|
import { accessTokenSchema, accountInteractionsSchema, accountNameSchema, accountSchema, answerSchema, applicationDataSchema, groupDataSchema, groupRoleSchema, groupSchema, guestDataSchema, hashtagSchema, inviteLinkSchema, latLngSchema, locationSchema, mediaAttachmentSchema, mentionDataSchema, postDataUnionSchema, postTypeSchema, profileDataSchema, profileStatsSchema, reactionDataSchema, reportDataSchema, reportSchema, resourceSchema, rsvpSchema, scopeSchema, visibilityTypeSchema, } from './models.js';
|
|
4
4
|
import { groupWithMetaSchema } from './internal.js';
|
|
5
5
|
import { communityConfigSchema } from './config.js';
|
|
@@ -214,10 +214,6 @@ export const serverInfoSchema = z.object({
|
|
|
214
214
|
})),
|
|
215
215
|
}).optional(),
|
|
216
216
|
});
|
|
217
|
-
export const notificationStatsSchema = z.object({
|
|
218
|
-
unread: z.number(),
|
|
219
|
-
unseen: z.number(),
|
|
220
|
-
});
|
|
221
217
|
export const unseenPostCountsSchema = z.object({
|
|
222
218
|
groups: z.record(z.string(), z.number()),
|
|
223
219
|
direct: z.record(z.string(), z.number()),
|
package/dist/types/config.d.ts
CHANGED
|
@@ -128,6 +128,7 @@ export declare const coreConfigSchemaFactory: (sanitize?: boolean) => z.ZodObjec
|
|
|
128
128
|
}, z.core.$strip>;
|
|
129
129
|
plugins: z.ZodObject<{
|
|
130
130
|
path: z.ZodString;
|
|
131
|
+
rootPackageJsonPath: z.ZodString;
|
|
131
132
|
}, z.core.$strip>;
|
|
132
133
|
secrets: z.ZodObject<{
|
|
133
134
|
jwt: z.ZodString | z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -283,6 +284,7 @@ export declare const coreConfigSchema: z.ZodObject<{
|
|
|
283
284
|
}, z.core.$strip>;
|
|
284
285
|
plugins: z.ZodObject<{
|
|
285
286
|
path: z.ZodString;
|
|
287
|
+
rootPackageJsonPath: z.ZodString;
|
|
286
288
|
}, z.core.$strip>;
|
|
287
289
|
secrets: z.ZodObject<{
|
|
288
290
|
jwt: z.ZodString | z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -438,6 +440,7 @@ export declare const coreConfigSanitizedSchema: z.ZodObject<{
|
|
|
438
440
|
}, z.core.$strip>;
|
|
439
441
|
plugins: z.ZodObject<{
|
|
440
442
|
path: z.ZodString;
|
|
443
|
+
rootPackageJsonPath: z.ZodString;
|
|
441
444
|
}, z.core.$strip>;
|
|
442
445
|
secrets: z.ZodObject<{
|
|
443
446
|
jwt: z.ZodString | z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -541,6 +544,14 @@ export declare const coreConfigSanitizedSchema: z.ZodObject<{
|
|
|
541
544
|
}, z.core.$strip>;
|
|
542
545
|
}, z.core.$strip>;
|
|
543
546
|
export type CoreConfig = z.infer<typeof coreConfigSchema>;
|
|
547
|
+
/** Community-configured member profile fields (`profiles.additionalFields`). */
|
|
548
|
+
export declare const communityProfileAdditionalFieldSchema: z.ZodObject<{
|
|
549
|
+
key: z.ZodString;
|
|
550
|
+
label: z.ZodString;
|
|
551
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
552
|
+
linkPattern: z.ZodOptional<z.ZodString>;
|
|
553
|
+
}, z.core.$strip>;
|
|
554
|
+
export type CommunityProfileAdditionalField = z.infer<typeof communityProfileAdditionalFieldSchema>;
|
|
544
555
|
export declare const communityConfigSchemaFactory: (_sanitize?: boolean) => z.ZodObject<{
|
|
545
556
|
theme: z.ZodObject<{
|
|
546
557
|
base: z.ZodString;
|
|
@@ -555,6 +566,10 @@ export declare const communityConfigSchemaFactory: (_sanitize?: boolean) => z.Zo
|
|
|
555
566
|
background: z.ZodOptional<z.ZodString>;
|
|
556
567
|
light: z.ZodObject<{
|
|
557
568
|
primaryHex: z.ZodString;
|
|
569
|
+
secondaryHex: z.ZodOptional<z.ZodString>;
|
|
570
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
571
|
+
buttonRadius: z.ZodOptional<z.ZodString>;
|
|
572
|
+
radius: z.ZodOptional<z.ZodString>;
|
|
558
573
|
logoSmall: z.ZodOptional<z.ZodString>;
|
|
559
574
|
defaultProfileAvatar: z.ZodOptional<z.ZodString>;
|
|
560
575
|
defaultGroupAvatar: z.ZodOptional<z.ZodString>;
|
|
@@ -563,6 +578,10 @@ export declare const communityConfigSchemaFactory: (_sanitize?: boolean) => z.Zo
|
|
|
563
578
|
}, z.core.$strip>;
|
|
564
579
|
dark: z.ZodObject<{
|
|
565
580
|
primaryHex: z.ZodString;
|
|
581
|
+
secondaryHex: z.ZodOptional<z.ZodString>;
|
|
582
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
583
|
+
buttonRadius: z.ZodOptional<z.ZodString>;
|
|
584
|
+
radius: z.ZodOptional<z.ZodString>;
|
|
566
585
|
logoSmall: z.ZodOptional<z.ZodString>;
|
|
567
586
|
defaultProfileAvatar: z.ZodOptional<z.ZodString>;
|
|
568
587
|
defaultGroupAvatar: z.ZodOptional<z.ZodString>;
|
|
@@ -621,6 +640,10 @@ export declare const communityConfigSchema: z.ZodObject<{
|
|
|
621
640
|
background: z.ZodOptional<z.ZodString>;
|
|
622
641
|
light: z.ZodObject<{
|
|
623
642
|
primaryHex: z.ZodString;
|
|
643
|
+
secondaryHex: z.ZodOptional<z.ZodString>;
|
|
644
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
645
|
+
buttonRadius: z.ZodOptional<z.ZodString>;
|
|
646
|
+
radius: z.ZodOptional<z.ZodString>;
|
|
624
647
|
logoSmall: z.ZodOptional<z.ZodString>;
|
|
625
648
|
defaultProfileAvatar: z.ZodOptional<z.ZodString>;
|
|
626
649
|
defaultGroupAvatar: z.ZodOptional<z.ZodString>;
|
|
@@ -629,6 +652,10 @@ export declare const communityConfigSchema: z.ZodObject<{
|
|
|
629
652
|
}, z.core.$strip>;
|
|
630
653
|
dark: z.ZodObject<{
|
|
631
654
|
primaryHex: z.ZodString;
|
|
655
|
+
secondaryHex: z.ZodOptional<z.ZodString>;
|
|
656
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
657
|
+
buttonRadius: z.ZodOptional<z.ZodString>;
|
|
658
|
+
radius: z.ZodOptional<z.ZodString>;
|
|
632
659
|
logoSmall: z.ZodOptional<z.ZodString>;
|
|
633
660
|
defaultProfileAvatar: z.ZodOptional<z.ZodString>;
|
|
634
661
|
defaultGroupAvatar: z.ZodOptional<z.ZodString>;
|
|
@@ -687,6 +714,10 @@ export declare const communityConfigSanitizedSchema: z.ZodObject<{
|
|
|
687
714
|
background: z.ZodOptional<z.ZodString>;
|
|
688
715
|
light: z.ZodObject<{
|
|
689
716
|
primaryHex: z.ZodString;
|
|
717
|
+
secondaryHex: z.ZodOptional<z.ZodString>;
|
|
718
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
719
|
+
buttonRadius: z.ZodOptional<z.ZodString>;
|
|
720
|
+
radius: z.ZodOptional<z.ZodString>;
|
|
690
721
|
logoSmall: z.ZodOptional<z.ZodString>;
|
|
691
722
|
defaultProfileAvatar: z.ZodOptional<z.ZodString>;
|
|
692
723
|
defaultGroupAvatar: z.ZodOptional<z.ZodString>;
|
|
@@ -695,6 +726,10 @@ export declare const communityConfigSanitizedSchema: z.ZodObject<{
|
|
|
695
726
|
}, z.core.$strip>;
|
|
696
727
|
dark: z.ZodObject<{
|
|
697
728
|
primaryHex: z.ZodString;
|
|
729
|
+
secondaryHex: z.ZodOptional<z.ZodString>;
|
|
730
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
731
|
+
buttonRadius: z.ZodOptional<z.ZodString>;
|
|
732
|
+
radius: z.ZodOptional<z.ZodString>;
|
|
698
733
|
logoSmall: z.ZodOptional<z.ZodString>;
|
|
699
734
|
defaultProfileAvatar: z.ZodOptional<z.ZodString>;
|
|
700
735
|
defaultGroupAvatar: z.ZodOptional<z.ZodString>;
|
package/dist/types/config.js
CHANGED
|
@@ -83,6 +83,7 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
|
|
|
83
83
|
}),
|
|
84
84
|
plugins: z.object({
|
|
85
85
|
path: z.string(),
|
|
86
|
+
rootPackageJsonPath: z.string(),
|
|
86
87
|
}),
|
|
87
88
|
secrets: z.object({
|
|
88
89
|
jwt: password(sanitize),
|
|
@@ -211,6 +212,14 @@ export const coreConfigSchemaFactory = (sanitize) => z.object({
|
|
|
211
212
|
});
|
|
212
213
|
export const coreConfigSchema = coreConfigSchemaFactory(false);
|
|
213
214
|
export const coreConfigSanitizedSchema = coreConfigSchemaFactory(true);
|
|
215
|
+
/** Community-configured member profile fields (`profiles.additionalFields`). */
|
|
216
|
+
export const communityProfileAdditionalFieldSchema = z.object({
|
|
217
|
+
// Trim so whitespace-only keys fail the same as "".
|
|
218
|
+
key: z.string().trim().min(1),
|
|
219
|
+
label: z.string(),
|
|
220
|
+
icon: z.string().optional(),
|
|
221
|
+
linkPattern: z.string().optional(),
|
|
222
|
+
});
|
|
214
223
|
export const communityConfigSchemaFactory = (_sanitize) => z.object({
|
|
215
224
|
theme: z.object({
|
|
216
225
|
base: z.string(),
|
|
@@ -225,6 +234,10 @@ export const communityConfigSchemaFactory = (_sanitize) => z.object({
|
|
|
225
234
|
background: z.string().optional(),
|
|
226
235
|
light: z.object({
|
|
227
236
|
primaryHex: z.string(),
|
|
237
|
+
secondaryHex: z.string().optional(),
|
|
238
|
+
fontFamily: z.string().optional(),
|
|
239
|
+
buttonRadius: z.string().optional(),
|
|
240
|
+
radius: z.string().optional(),
|
|
228
241
|
logoSmall: z.string().optional(),
|
|
229
242
|
defaultProfileAvatar: z.string().optional(),
|
|
230
243
|
defaultGroupAvatar: z.string().optional(),
|
|
@@ -233,6 +246,10 @@ export const communityConfigSchemaFactory = (_sanitize) => z.object({
|
|
|
233
246
|
}),
|
|
234
247
|
dark: z.object({
|
|
235
248
|
primaryHex: z.string(),
|
|
249
|
+
secondaryHex: z.string().optional(),
|
|
250
|
+
fontFamily: z.string().optional(),
|
|
251
|
+
buttonRadius: z.string().optional(),
|
|
252
|
+
radius: z.string().optional(),
|
|
236
253
|
logoSmall: z.string().optional(),
|
|
237
254
|
defaultProfileAvatar: z.string().optional(),
|
|
238
255
|
defaultGroupAvatar: z.string().optional(),
|
|
@@ -243,13 +260,7 @@ export const communityConfigSchemaFactory = (_sanitize) => z.object({
|
|
|
243
260
|
profiles: z
|
|
244
261
|
.object({
|
|
245
262
|
additionalFields: z
|
|
246
|
-
.
|
|
247
|
-
key: z.string(),
|
|
248
|
-
label: z.string(),
|
|
249
|
-
icon: z.string().optional(),
|
|
250
|
-
linkPattern: z.string().optional(),
|
|
251
|
-
})
|
|
252
|
-
.array()
|
|
263
|
+
.array(communityProfileAdditionalFieldSchema)
|
|
253
264
|
.optional(),
|
|
254
265
|
})
|
|
255
266
|
.optional(),
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { NotificationStats } from './api';
|
|
3
2
|
import { RoleCapability } from './capabilities';
|
|
4
3
|
import { ExpandedNotification } from './internal';
|
|
5
4
|
export declare const actionSchema: z.ZodObject<{
|
|
@@ -45,10 +44,48 @@ export declare const pushNotificationSchema: z.ZodObject<{
|
|
|
45
44
|
invalidateQueries: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
46
45
|
}, z.core.$strip>;
|
|
47
46
|
export type PushNotification = z.infer<typeof pushNotificationSchema>;
|
|
47
|
+
export declare const notificationStatsSchema: z.ZodObject<{
|
|
48
|
+
unread: z.ZodNumber;
|
|
49
|
+
unseen: z.ZodNumber;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type NotificationStats = z.infer<typeof notificationStatsSchema>;
|
|
48
52
|
export interface PushMessage {
|
|
49
53
|
notificationStats: NotificationStats;
|
|
50
54
|
notification: PushNotification;
|
|
51
55
|
}
|
|
56
|
+
/** Session SSE / presence platform. */
|
|
57
|
+
export declare const sessionPlatformSchema: z.ZodEnum<{
|
|
58
|
+
ios: "ios";
|
|
59
|
+
android: "android";
|
|
60
|
+
web: "web";
|
|
61
|
+
}>;
|
|
62
|
+
export type SessionPlatform = z.infer<typeof sessionPlatformSchema>;
|
|
63
|
+
/** Invalidate-light envelope mirrored from web push. */
|
|
64
|
+
export declare const sessionEventSchema: z.ZodObject<{
|
|
65
|
+
type: z.ZodLiteral<"invalidate">;
|
|
66
|
+
notification: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
title: z.ZodOptional<z.ZodString>;
|
|
68
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
body: z.ZodOptional<z.ZodString>;
|
|
70
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
71
|
+
image: z.ZodOptional<z.ZodString>;
|
|
72
|
+
link: z.ZodOptional<z.ZodString>;
|
|
73
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
74
|
+
badge: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
76
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
77
|
+
action: z.ZodString;
|
|
78
|
+
title: z.ZodString;
|
|
79
|
+
}, z.core.$strip>>>;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
invalidateQueries: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodString>>>;
|
|
82
|
+
}, z.core.$strip>>;
|
|
83
|
+
notificationStats: z.ZodOptional<z.ZodObject<{
|
|
84
|
+
unread: z.ZodNumber;
|
|
85
|
+
unseen: z.ZodNumber;
|
|
86
|
+
}, z.core.$strip>>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type SessionEvent = z.infer<typeof sessionEventSchema>;
|
|
52
89
|
export interface NotificationHandler {
|
|
53
90
|
type: string;
|
|
54
91
|
event: string;
|
|
@@ -19,6 +19,18 @@ export const pushNotificationSchema = z.object({
|
|
|
19
19
|
options: notificationOptionsSchema.optional(),
|
|
20
20
|
invalidateQueries: z.array(z.array(z.string())).optional(),
|
|
21
21
|
});
|
|
22
|
+
export const notificationStatsSchema = z.object({
|
|
23
|
+
unread: z.number(),
|
|
24
|
+
unseen: z.number(),
|
|
25
|
+
});
|
|
26
|
+
/** Session SSE / presence platform. */
|
|
27
|
+
export const sessionPlatformSchema = z.enum(['web', 'ios', 'android']);
|
|
28
|
+
/** Invalidate-light envelope mirrored from web push. */
|
|
29
|
+
export const sessionEventSchema = z.object({
|
|
30
|
+
type: z.literal('invalidate'),
|
|
31
|
+
notification: pushNotificationSchema.optional(),
|
|
32
|
+
notificationStats: notificationStatsSchema.optional(),
|
|
33
|
+
});
|
|
22
34
|
export const notificationTypeSchema = z.object({
|
|
23
35
|
type: z.string(),
|
|
24
36
|
requiredCapabilities: z.enum(roleCapabilities).array().optional(),
|