@openpeepshq/common 0.1.44 → 0.1.46
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/adminSections.d.ts +4 -0
- package/dist/lib/adminSections.js +5 -0
- package/dist/lib/capabilitiesHelpers.d.ts +9 -7
- package/dist/lib/capabilitiesHelpers.js +21 -13
- package/dist/lib/eventIcs.d.ts +17 -0
- package/dist/lib/eventIcs.js +138 -2
- package/dist/lib/eventRecurrence.d.ts +32 -0
- package/dist/lib/eventRecurrence.js +284 -0
- package/dist/lib/eventTime.d.ts +29 -0
- package/dist/lib/eventTime.js +143 -0
- package/dist/lib/federationHosts.d.ts +3 -0
- package/dist/lib/federationHosts.js +17 -0
- package/dist/lib/feedCursor.d.ts +14 -0
- package/dist/lib/feedCursor.js +22 -0
- package/dist/lib/feedFormat.d.ts +12 -0
- package/dist/lib/feedFormat.js +14 -0
- package/dist/lib/groupHelpers.d.ts +63 -41
- package/dist/lib/groupHelpers.js +155 -45
- package/dist/lib/groupTemplateHelpers.d.ts +16 -0
- package/dist/lib/groupTemplateHelpers.js +51 -0
- package/dist/lib/index.d.ts +11 -0
- package/dist/lib/index.js +11 -0
- package/dist/lib/jamHelpers.d.ts +38 -3
- package/dist/lib/jamHelpers.js +93 -8
- package/dist/lib/legacyThemeRoot.d.ts +3 -0
- package/dist/lib/legacyThemeRoot.js +10 -0
- package/dist/lib/markdownHelpers.d.ts +22 -0
- package/dist/lib/markdownHelpers.js +73 -3
- package/dist/lib/postHelpers.d.ts +164 -9
- package/dist/lib/postHelpers.js +353 -11
- package/dist/lib/profileHelpers.d.ts +11 -0
- package/dist/lib/profileHelpers.js +31 -0
- package/dist/lib/pushHelpers.d.ts +3 -1
- package/dist/lib/pushHelpers.js +13 -0
- package/dist/lib/reactions.d.ts +17 -0
- package/dist/lib/reactions.js +37 -0
- package/dist/lib/scopeHelpers.d.ts +31 -2
- package/dist/lib/scopeHelpers.js +37 -3
- package/dist/lib/ssoLoginUrl.d.ts +24 -0
- package/dist/lib/ssoLoginUrl.js +75 -0
- package/dist/lib/ssoProviders.d.ts +72 -0
- package/dist/lib/ssoProviders.js +370 -0
- package/dist/lib/text.d.ts +2 -0
- package/dist/lib/text.js +2 -0
- package/dist/lib/timeZone.d.ts +9 -0
- package/dist/lib/timeZone.js +44 -0
- package/dist/lib/tokenHelpers.d.ts +5 -0
- package/dist/lib/tokenHelpers.js +19 -0
- package/dist/types/analytics.d.ts +20 -0
- package/dist/types/analytics.js +4 -0
- package/dist/types/api.d.ts +42669 -10689
- package/dist/types/api.js +94 -16
- package/dist/types/auth.d.ts +22 -13
- package/dist/types/capabilities.d.ts +26 -5
- package/dist/types/capabilities.js +95 -1
- package/dist/types/config.d.ts +93 -6
- package/dist/types/config.js +56 -5
- package/dist/types/db.d.ts +1911 -248
- package/dist/types/db.js +17 -3
- package/dist/types/export.d.ts +120 -0
- package/dist/types/export.js +7 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/internal.d.ts +8313 -2675
- package/dist/types/internal.js +16 -1
- package/dist/types/models.d.ts +343 -16
- package/dist/types/models.js +98 -7
- package/dist/types/notifications.d.ts +1 -0
- package/dist/types/plugins.d.ts +43 -1
- package/dist/types/plugins.js +75 -1
- package/dist/types/roleDefaults.d.ts +31 -0
- package/dist/types/roleDefaults.js +110 -0
- package/dist/types/stats.d.ts +54359 -4718
- package/dist/types/stats.js +30 -0
- package/dist/types/utils.d.ts +2 -0
- package/dist/types/utils.js +1 -3
- package/package.json +1 -1
package/dist/types/models.js
CHANGED
|
@@ -7,6 +7,8 @@ import { capabilitiesSchema } from './config.js';
|
|
|
7
7
|
extendZodWithOpenApi(z);
|
|
8
8
|
export const handleRegexBase = '[a-zA-Z0-9_-]{1,16}';
|
|
9
9
|
export const handleRegex = new RegExp(`^${handleRegexBase}$`);
|
|
10
|
+
/** `@handle` using the allowed handle charset. No `\\b` — hyphens are not word chars. */
|
|
11
|
+
export const mentionHandleRegexBase = `(^|[\\s(>])@(${handleRegexBase})(?=\\s|$|[.,!?;:])`;
|
|
10
12
|
export const forbiddenHandles = [
|
|
11
13
|
'admin',
|
|
12
14
|
'allpeep',
|
|
@@ -68,6 +70,8 @@ export const accountSchema = modelSchema(accountDataSchema);
|
|
|
68
70
|
export const roleDataSchema = z.object({
|
|
69
71
|
key: z.string().regex(/^[a-z-]{1,32}$/),
|
|
70
72
|
default: z.boolean(),
|
|
73
|
+
/** Defaults history version the role's capabilities were based on. */
|
|
74
|
+
baseVersion: z.string().optional(),
|
|
71
75
|
displayName: z.string().max(32),
|
|
72
76
|
description: z.string().optional(),
|
|
73
77
|
capabilities: capabilitiesSchema,
|
|
@@ -113,6 +117,7 @@ export const ThemeOptionsSchema = z.enum(THEME_OPTIONS);
|
|
|
113
117
|
export const profileSettingsDataSchema = z.object({
|
|
114
118
|
id: z.string(),
|
|
115
119
|
language: z.string().optional(),
|
|
120
|
+
timeZone: z.string().optional(),
|
|
116
121
|
theme: ThemeOptionsSchema.optional(),
|
|
117
122
|
defaults: profileSettingsDefaultsSchema.optional(),
|
|
118
123
|
notifications: z.record(z.string(), profileNotificationSettings).optional(),
|
|
@@ -124,6 +129,7 @@ export const profileSettingsDataSchema = z.object({
|
|
|
124
129
|
.optional(),
|
|
125
130
|
feedSettings: z
|
|
126
131
|
.object({
|
|
132
|
+
format: z.enum(['threaded', 'linear']).optional(),
|
|
127
133
|
communityFeed: z
|
|
128
134
|
.object({
|
|
129
135
|
showGroupPosts: z.boolean().optional(),
|
|
@@ -148,7 +154,6 @@ export const accountNameSchema = z
|
|
|
148
154
|
description: 'Account handle: 1-16 alphanumeric / underscore / hyphen characters, excluding a reserved set.',
|
|
149
155
|
});
|
|
150
156
|
const profileResourceTypes = [
|
|
151
|
-
'jam',
|
|
152
157
|
'jams',
|
|
153
158
|
'posts',
|
|
154
159
|
'self',
|
|
@@ -200,8 +205,15 @@ export const locationSchema = z.object({
|
|
|
200
205
|
text: z.string(),
|
|
201
206
|
coordinates: latLngSchema.optional(),
|
|
202
207
|
});
|
|
208
|
+
export const federatedHandleSchema = z
|
|
209
|
+
.string()
|
|
210
|
+
.min(1)
|
|
211
|
+
.max(64)
|
|
212
|
+
.regex(/^[a-zA-Z0-9_.-]+$/, {
|
|
213
|
+
message: 'Federated handle: 1–64 letters, numbers, underscores, dots, or hyphens',
|
|
214
|
+
});
|
|
203
215
|
export const profileDataSchema = z.object({
|
|
204
|
-
handle:
|
|
216
|
+
handle: federatedHandleSchema,
|
|
205
217
|
deletedHandle: accountNameSchema.optional(),
|
|
206
218
|
avatar: z.url().nullable().optional(),
|
|
207
219
|
header: z.url().nullable().optional(),
|
|
@@ -232,6 +244,7 @@ export const profileDataSchema = z.object({
|
|
|
232
244
|
resource: resourceSchema.optional(),
|
|
233
245
|
})
|
|
234
246
|
.optional(),
|
|
247
|
+
pinnedPostId: z.string().optional(),
|
|
235
248
|
});
|
|
236
249
|
export const profileSchema = modelSchema(profileDataSchema);
|
|
237
250
|
export const accountWithMetaSchema = accountSchema.extend({
|
|
@@ -253,6 +266,8 @@ export const jamDataSchema = z
|
|
|
253
266
|
.openapi('Jam');
|
|
254
267
|
export const jamSchema = jamDataSchema;
|
|
255
268
|
export const followDataSchema = z.object({
|
|
269
|
+
/** ActivityPub Follow activity id when federated. */
|
|
270
|
+
uri: z.string().url().optional(),
|
|
256
271
|
reblogs: z.boolean().optional(),
|
|
257
272
|
notify: z.boolean().optional(),
|
|
258
273
|
languages: z
|
|
@@ -333,12 +348,14 @@ export const noteSchema = z
|
|
|
333
348
|
language: z.enum(ISO6391.getAllCodes()).optional(),
|
|
334
349
|
})
|
|
335
350
|
.openapi('Note');
|
|
351
|
+
/** Poll choices are stored short so they fit the vote UI on small screens. */
|
|
352
|
+
export const POLL_OPTION_MAX_LENGTH = 30;
|
|
336
353
|
export const questionSchema = noteSchema
|
|
337
354
|
.extend({
|
|
338
355
|
type: z.literal('question'),
|
|
339
356
|
options: z
|
|
340
357
|
.object({
|
|
341
|
-
content: z.string().max(
|
|
358
|
+
content: z.string().max(POLL_OPTION_MAX_LENGTH),
|
|
342
359
|
type: z.literal('note'),
|
|
343
360
|
})
|
|
344
361
|
.array(),
|
|
@@ -354,14 +371,50 @@ export const articleSchema = noteSchema
|
|
|
354
371
|
title: z.string().optional(),
|
|
355
372
|
})
|
|
356
373
|
.openapi('Article');
|
|
374
|
+
export const eventIsoDatetimeSchema = z.iso.datetime({
|
|
375
|
+
offset: true,
|
|
376
|
+
precision: 3,
|
|
377
|
+
});
|
|
378
|
+
export const recurrenceFreqSchema = z.enum(['DAILY', 'WEEKLY', 'MONTHLY']);
|
|
379
|
+
export const recurrenceWeekdaySchema = z.enum([
|
|
380
|
+
'MO',
|
|
381
|
+
'TU',
|
|
382
|
+
'WE',
|
|
383
|
+
'TH',
|
|
384
|
+
'FR',
|
|
385
|
+
'SA',
|
|
386
|
+
'SU',
|
|
387
|
+
]);
|
|
388
|
+
export const eventRecurrenceSchema = z
|
|
389
|
+
.object({
|
|
390
|
+
freq: recurrenceFreqSchema,
|
|
391
|
+
interval: z.number().int().positive().optional(),
|
|
392
|
+
byDay: recurrenceWeekdaySchema.array().optional(),
|
|
393
|
+
until: eventIsoDatetimeSchema.optional(),
|
|
394
|
+
count: z.number().int().positive().optional(),
|
|
395
|
+
})
|
|
396
|
+
.refine((value) => !(value.until && value.count), {
|
|
397
|
+
message: 'until and count are mutually exclusive',
|
|
398
|
+
path: ['until'],
|
|
399
|
+
})
|
|
400
|
+
.openapi('EventRecurrence');
|
|
401
|
+
export const eventOccurrenceExceptionSchema = z
|
|
402
|
+
.object({
|
|
403
|
+
recurrenceId: eventIsoDatetimeSchema,
|
|
404
|
+
cancelled: z.boolean().optional(),
|
|
405
|
+
start: eventIsoDatetimeSchema.optional(),
|
|
406
|
+
end: eventIsoDatetimeSchema.optional(),
|
|
407
|
+
physicalLocation: locationSchema.optional(),
|
|
408
|
+
})
|
|
409
|
+
.openapi('EventOccurrenceException');
|
|
357
410
|
export const eventSchema = noteSchema
|
|
358
411
|
.extend({
|
|
359
412
|
type: z.literal('event'),
|
|
360
413
|
name: z.string().optional(),
|
|
361
414
|
timeZone: z.string().optional(),
|
|
362
415
|
image: z.url().optional(),
|
|
363
|
-
start:
|
|
364
|
-
end:
|
|
416
|
+
start: eventIsoDatetimeSchema,
|
|
417
|
+
end: eventIsoDatetimeSchema.optional(),
|
|
365
418
|
wholeDay: z.boolean(),
|
|
366
419
|
maxAttendees: z.number().int().positive().optional(),
|
|
367
420
|
attendeeListPublic: z.boolean().optional(),
|
|
@@ -369,6 +422,8 @@ export const eventSchema = noteSchema
|
|
|
369
422
|
jam: jamSchema.optional(),
|
|
370
423
|
physicalLocation: locationSchema.optional(),
|
|
371
424
|
url: z.url().optional(),
|
|
425
|
+
recurrence: eventRecurrenceSchema.optional(),
|
|
426
|
+
exceptions: eventOccurrenceExceptionSchema.array().optional(),
|
|
372
427
|
})
|
|
373
428
|
.openapi('Event');
|
|
374
429
|
export const postDataUnionSchema = z.discriminatedUnion('type', [
|
|
@@ -393,6 +448,13 @@ export const answerSchema = z
|
|
|
393
448
|
export const rsvpResponseSchema = z.enum(['yes', 'no', 'tentative', 'removed']);
|
|
394
449
|
export const rsvpSchema = z.object({
|
|
395
450
|
response: rsvpResponseSchema,
|
|
451
|
+
recurrenceId: eventIsoDatetimeSchema.optional(),
|
|
452
|
+
});
|
|
453
|
+
export const rsvpRequestSchema = rsvpSchema.extend({
|
|
454
|
+
recurrenceIds: z.array(eventIsoDatetimeSchema).min(1).optional(),
|
|
455
|
+
});
|
|
456
|
+
export const entryReactionDataSchema = z.object({
|
|
457
|
+
reaction: z.string().min(1),
|
|
396
458
|
});
|
|
397
459
|
export const entryDataSchema = z.discriminatedUnion('type', [
|
|
398
460
|
z.object({
|
|
@@ -415,6 +477,16 @@ export const entryDataSchema = z.discriminatedUnion('type', [
|
|
|
415
477
|
type: z.literal('rsvp'),
|
|
416
478
|
data: rsvpSchema,
|
|
417
479
|
}),
|
|
480
|
+
z.object({
|
|
481
|
+
type: z.literal('reaction'),
|
|
482
|
+
data: entryReactionDataSchema,
|
|
483
|
+
uri: z.string().url().optional(),
|
|
484
|
+
}),
|
|
485
|
+
z.object({
|
|
486
|
+
type: z.literal('unreaction'),
|
|
487
|
+
data: entryReactionDataSchema,
|
|
488
|
+
uri: z.string().url().optional(),
|
|
489
|
+
}),
|
|
418
490
|
]);
|
|
419
491
|
export const accountInteractionsSchema = z.object({
|
|
420
492
|
favorited: z.boolean(),
|
|
@@ -530,11 +602,17 @@ export const profileStatsSchema = z.object({
|
|
|
530
602
|
followersCount: z.number(),
|
|
531
603
|
followingCount: z.number(),
|
|
532
604
|
});
|
|
605
|
+
export const GROUP_DISPLAY_NAME_MAX_LENGTH = 30;
|
|
533
606
|
export const groupDataSchema = z.object({
|
|
534
607
|
handle: accountNameSchema,
|
|
535
608
|
avatar: z.string().url().nullable().optional(),
|
|
536
609
|
header: z.string().url().nullable().optional(),
|
|
537
|
-
displayName: z
|
|
610
|
+
displayName: z
|
|
611
|
+
.string()
|
|
612
|
+
.max(GROUP_DISPLAY_NAME_MAX_LENGTH, {
|
|
613
|
+
message: `Group name should be ${GROUP_DISPLAY_NAME_MAX_LENGTH} characters or fewer`,
|
|
614
|
+
})
|
|
615
|
+
.optional(),
|
|
538
616
|
description: z.string().optional(),
|
|
539
617
|
rules: z.string().optional(),
|
|
540
618
|
pinnedPostId: z.string().optional(),
|
|
@@ -561,10 +639,13 @@ export const jamEventDataSchema = z.object({
|
|
|
561
639
|
'close',
|
|
562
640
|
'recordStart',
|
|
563
641
|
'recordStop',
|
|
642
|
+
'streamStart',
|
|
643
|
+
'streamStop',
|
|
564
644
|
]),
|
|
565
645
|
profileId: z.string(),
|
|
566
646
|
content: z.string().optional(),
|
|
567
647
|
reaction: reactionTypeSchema.optional(),
|
|
648
|
+
recurrenceId: eventIsoDatetimeSchema.optional(),
|
|
568
649
|
});
|
|
569
650
|
export const jamEventSchema = modelSchema(jamEventDataSchema);
|
|
570
651
|
export const inviteLinkDataSchema = z.object({
|
|
@@ -590,8 +671,18 @@ export const jamRecordingTypeSchema = z.enum([
|
|
|
590
671
|
'compositeAudio',
|
|
591
672
|
'streams',
|
|
592
673
|
]);
|
|
674
|
+
export const jamRecordingKindSchema = z.enum(['file', 'rtmp']);
|
|
675
|
+
export const jamRecordingStatusSchema = z.enum([
|
|
676
|
+
'requested',
|
|
677
|
+
'active',
|
|
678
|
+
'finalizing',
|
|
679
|
+
'completed',
|
|
680
|
+
'failed',
|
|
681
|
+
]);
|
|
593
682
|
export const jamRecordingDataSchema = z.object({
|
|
594
|
-
status:
|
|
683
|
+
status: jamRecordingStatusSchema,
|
|
684
|
+
kind: jamRecordingKindSchema.optional(),
|
|
685
|
+
destinationHost: z.string().optional(),
|
|
595
686
|
egressId: z.string().optional(),
|
|
596
687
|
attachment: mediaAttachmentSchema.optional(),
|
|
597
688
|
replyPostId: z.string().optional(),
|
|
@@ -165,6 +165,7 @@ export declare const notificationTypeSchema: z.ZodObject<{
|
|
|
165
165
|
"core-inviteLinks-update": "core-inviteLinks-update";
|
|
166
166
|
"core-inviteLinks-delete": "core-inviteLinks-delete";
|
|
167
167
|
"core-serviceTokens-update": "core-serviceTokens-update";
|
|
168
|
+
"core-plugins-manage": "core-plugins-manage";
|
|
168
169
|
}>>>;
|
|
169
170
|
defaultSettings: z.ZodOptional<z.ZodObject<{
|
|
170
171
|
create: z.ZodBoolean;
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface Plugin {
|
|
|
6
6
|
name: string;
|
|
7
7
|
info: PackageJson;
|
|
8
8
|
path: string;
|
|
9
|
-
status?: 'loaded' | 'failed';
|
|
9
|
+
status?: 'loaded' | 'failed' | 'disabled';
|
|
10
10
|
error?: string;
|
|
11
11
|
}
|
|
12
12
|
export declare const pluginInfoSchema: z.ZodObject<{
|
|
@@ -19,9 +19,50 @@ export declare const pluginInfoSchema: z.ZodObject<{
|
|
|
19
19
|
status: z.ZodOptional<z.ZodEnum<{
|
|
20
20
|
failed: "failed";
|
|
21
21
|
loaded: "loaded";
|
|
22
|
+
disabled: "disabled";
|
|
22
23
|
}>>;
|
|
23
24
|
}, z.core.$strip>;
|
|
24
25
|
export type PluginInfo = z.infer<typeof pluginInfoSchema>;
|
|
26
|
+
export declare const adminPluginInfoSchema: z.ZodObject<{
|
|
27
|
+
key: z.ZodString;
|
|
28
|
+
namespace: z.ZodString;
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
version: z.ZodOptional<z.ZodString>;
|
|
31
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
32
|
+
description: z.ZodOptional<z.ZodString>;
|
|
33
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
failed: "failed";
|
|
35
|
+
loaded: "loaded";
|
|
36
|
+
disabled: "disabled";
|
|
37
|
+
}>>;
|
|
38
|
+
error: z.ZodOptional<z.ZodString>;
|
|
39
|
+
enabled: z.ZodBoolean;
|
|
40
|
+
repositoryUrl: z.ZodOptional<z.ZodString>;
|
|
41
|
+
installed: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export type AdminPluginInfo = z.infer<typeof adminPluginInfoSchema>;
|
|
44
|
+
export declare const pluginInstallSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
45
|
+
type: z.ZodLiteral<"npm">;
|
|
46
|
+
package: z.ZodString;
|
|
47
|
+
version: z.ZodOptional<z.ZodString>;
|
|
48
|
+
auth: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
token: z.ZodString;
|
|
50
|
+
registry: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"git">;
|
|
54
|
+
url: z.ZodString;
|
|
55
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
56
|
+
auth: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
57
|
+
type: z.ZodLiteral<"token">;
|
|
58
|
+
username: z.ZodString;
|
|
59
|
+
token: z.ZodString;
|
|
60
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
61
|
+
type: z.ZodLiteral<"ssh">;
|
|
62
|
+
privateKey: z.ZodString;
|
|
63
|
+
}, z.core.$strip>], "type">>;
|
|
64
|
+
}, z.core.$strip>], "type">;
|
|
65
|
+
export type PluginInstallSource = z.infer<typeof pluginInstallSourceSchema>;
|
|
25
66
|
export declare const pluginManifestSchema: z.ZodObject<{
|
|
26
67
|
components: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
27
68
|
slot: z.ZodString;
|
|
@@ -40,6 +81,7 @@ export declare const pluginEntrySchema: z.ZodObject<{
|
|
|
40
81
|
status: z.ZodOptional<z.ZodEnum<{
|
|
41
82
|
failed: "failed";
|
|
42
83
|
loaded: "loaded";
|
|
84
|
+
disabled: "disabled";
|
|
43
85
|
}>>;
|
|
44
86
|
manifest: z.ZodOptional<z.ZodObject<{
|
|
45
87
|
components: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
package/dist/types/plugins.js
CHANGED
|
@@ -6,8 +6,82 @@ export const pluginInfoSchema = z.object({
|
|
|
6
6
|
version: z.string().optional(),
|
|
7
7
|
displayName: z.string().optional(),
|
|
8
8
|
description: z.string().optional(),
|
|
9
|
-
status: z.enum(['loaded', 'failed']).optional(),
|
|
9
|
+
status: z.enum(['loaded', 'failed', 'disabled']).optional(),
|
|
10
10
|
});
|
|
11
|
+
export const adminPluginInfoSchema = pluginInfoSchema.extend({
|
|
12
|
+
error: z.string().optional(),
|
|
13
|
+
/** Persisted desired state (DB override, falling back to the static gate). */
|
|
14
|
+
enabled: z.boolean(),
|
|
15
|
+
repositoryUrl: z.string().optional(),
|
|
16
|
+
/** True when installed via the admin UI (can be uninstalled). */
|
|
17
|
+
installed: z.boolean().optional(),
|
|
18
|
+
});
|
|
19
|
+
const npmPluginInstallAuthSchema = z.object({
|
|
20
|
+
token: z.string().min(1),
|
|
21
|
+
registry: z
|
|
22
|
+
.string()
|
|
23
|
+
.url()
|
|
24
|
+
.refine((value) => {
|
|
25
|
+
const url = new URL(value);
|
|
26
|
+
return url.protocol === 'https:' && !url.username && !url.password;
|
|
27
|
+
}, {
|
|
28
|
+
message: 'Registry URL must use HTTPS and must not contain credentials',
|
|
29
|
+
})
|
|
30
|
+
.optional(),
|
|
31
|
+
});
|
|
32
|
+
const gitPluginInstallAuthSchema = z.discriminatedUnion('type', [
|
|
33
|
+
z.object({
|
|
34
|
+
type: z.literal('token'),
|
|
35
|
+
username: z.string().min(1),
|
|
36
|
+
token: z.string().min(1),
|
|
37
|
+
}),
|
|
38
|
+
z.object({
|
|
39
|
+
type: z.literal('ssh'),
|
|
40
|
+
privateKey: z.string().min(1),
|
|
41
|
+
}),
|
|
42
|
+
]);
|
|
43
|
+
export const pluginInstallSourceSchema = z.discriminatedUnion('type', [
|
|
44
|
+
z.object({
|
|
45
|
+
type: z.literal('npm'),
|
|
46
|
+
package: z
|
|
47
|
+
.string()
|
|
48
|
+
.regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i, 'Enter an npm package name'),
|
|
49
|
+
version: z.string().optional(),
|
|
50
|
+
auth: npmPluginInstallAuthSchema.optional(),
|
|
51
|
+
}),
|
|
52
|
+
z
|
|
53
|
+
.object({
|
|
54
|
+
type: z.literal('git'),
|
|
55
|
+
url: z.string().url(),
|
|
56
|
+
ref: z.string().optional(),
|
|
57
|
+
auth: gitPluginInstallAuthSchema.optional(),
|
|
58
|
+
})
|
|
59
|
+
.superRefine(({ auth, url }, context) => {
|
|
60
|
+
const parsedUrl = new URL(url);
|
|
61
|
+
if (parsedUrl.password ||
|
|
62
|
+
(parsedUrl.username && parsedUrl.protocol !== 'ssh:')) {
|
|
63
|
+
context.addIssue({
|
|
64
|
+
code: 'custom',
|
|
65
|
+
message: 'Repository URLs must not contain credentials',
|
|
66
|
+
path: ['url'],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if ((auth === null || auth === void 0 ? void 0 : auth.type) === 'token' && parsedUrl.protocol !== 'https:') {
|
|
70
|
+
context.addIssue({
|
|
71
|
+
code: 'custom',
|
|
72
|
+
message: 'Token authentication requires an HTTPS repository URL',
|
|
73
|
+
path: ['url'],
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if ((auth === null || auth === void 0 ? void 0 : auth.type) === 'ssh' && parsedUrl.protocol !== 'ssh:') {
|
|
77
|
+
context.addIssue({
|
|
78
|
+
code: 'custom',
|
|
79
|
+
message: 'SSH authentication requires an ssh:// repository URL',
|
|
80
|
+
path: ['url'],
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
]);
|
|
11
85
|
export const pluginManifestSchema = z.object({
|
|
12
86
|
components: z
|
|
13
87
|
.array(z.object({
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RoleData } from './models';
|
|
2
|
+
/**
|
|
3
|
+
* One point in the history of the built-in role defaults. Entries are
|
|
4
|
+
* immutable: when the defaults change, append a new entry dated with the
|
|
5
|
+
* creation date. The last entry is always the current one — it is used for
|
|
6
|
+
* seeding on server start and as the rebase target for customized roles.
|
|
7
|
+
*/
|
|
8
|
+
export interface RoleDefaultsVersion {
|
|
9
|
+
/** ISO date the version was created. */
|
|
10
|
+
version: string;
|
|
11
|
+
roles: RoleData[];
|
|
12
|
+
}
|
|
13
|
+
export declare const roleDefaultsHistory: RoleDefaultsVersion[];
|
|
14
|
+
/** The current (last) version — the one in use. */
|
|
15
|
+
export declare const currentRoleDefaults: RoleDefaultsVersion;
|
|
16
|
+
/**
|
|
17
|
+
* Built-in instance roles of the current version, seeded on server start.
|
|
18
|
+
* Also the reference for "restore defaults" in the admin capability matrix.
|
|
19
|
+
*/
|
|
20
|
+
export declare const defaultRoles: {
|
|
21
|
+
key: string;
|
|
22
|
+
default: boolean;
|
|
23
|
+
displayName: string;
|
|
24
|
+
baseVersion?: string | undefined;
|
|
25
|
+
description?: string | undefined;
|
|
26
|
+
capabilities?: {
|
|
27
|
+
add?: string[] | undefined;
|
|
28
|
+
remove?: string[] | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
}[];
|
|
31
|
+
export declare const findRoleDefaultsVersion: (version: string) => RoleDefaultsVersion | undefined;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Stamps the version onto the roles so a stored role records its baseline. */
|
|
2
|
+
const versionedRoles = (version, roles) => roles.map((role) => ({ ...role, baseVersion: version }));
|
|
3
|
+
export const roleDefaultsHistory = [
|
|
4
|
+
{
|
|
5
|
+
version: '2026-10-06',
|
|
6
|
+
roles: versionedRoles('2026-10-06', [
|
|
7
|
+
{
|
|
8
|
+
key: 'owner',
|
|
9
|
+
displayName: 'Owner',
|
|
10
|
+
capabilities: { add: ['*'], remove: [] },
|
|
11
|
+
default: true,
|
|
12
|
+
description: 'The owner of this community can do everything',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
key: 'admin',
|
|
16
|
+
displayName: 'Admin',
|
|
17
|
+
capabilities: {
|
|
18
|
+
add: [
|
|
19
|
+
'core-accounts-*',
|
|
20
|
+
'core-reports-*',
|
|
21
|
+
'core-groups-*',
|
|
22
|
+
'core-posts-*',
|
|
23
|
+
'core-profiles-*',
|
|
24
|
+
'core-customization-*',
|
|
25
|
+
'core-backups-*',
|
|
26
|
+
'core-i18n-*',
|
|
27
|
+
'core-logs-*',
|
|
28
|
+
'core-roles-read',
|
|
29
|
+
'core-maintenance-restart',
|
|
30
|
+
'core-inviteLinks-*',
|
|
31
|
+
'core-analytics-read',
|
|
32
|
+
'core-plugins-*',
|
|
33
|
+
],
|
|
34
|
+
remove: [],
|
|
35
|
+
},
|
|
36
|
+
default: true,
|
|
37
|
+
description: 'An admin of the community',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: 'moderator',
|
|
41
|
+
displayName: 'Moderator',
|
|
42
|
+
capabilities: {
|
|
43
|
+
add: [
|
|
44
|
+
'core-posts-delete',
|
|
45
|
+
'core-posts-pin-globally',
|
|
46
|
+
'core-posts-announce',
|
|
47
|
+
'core-profiles-suspend',
|
|
48
|
+
'core-accounts-read',
|
|
49
|
+
'core-profiles-read',
|
|
50
|
+
'core-groups-read',
|
|
51
|
+
'core-inviteLinks-read',
|
|
52
|
+
'core-reports-read',
|
|
53
|
+
'core-reports-update',
|
|
54
|
+
'core-analytics-read',
|
|
55
|
+
'core-local',
|
|
56
|
+
'core-posts-create-*',
|
|
57
|
+
'core-groups-create',
|
|
58
|
+
'core-reports-create',
|
|
59
|
+
],
|
|
60
|
+
remove: [],
|
|
61
|
+
},
|
|
62
|
+
default: true,
|
|
63
|
+
description: 'A moderator of the community',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: 'member',
|
|
67
|
+
displayName: 'Member',
|
|
68
|
+
capabilities: {
|
|
69
|
+
add: [
|
|
70
|
+
'core-local',
|
|
71
|
+
'core-posts-create-*',
|
|
72
|
+
'core-groups-create',
|
|
73
|
+
'core-reports-create',
|
|
74
|
+
],
|
|
75
|
+
remove: [],
|
|
76
|
+
},
|
|
77
|
+
default: true,
|
|
78
|
+
description: 'A member of the community',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
key: 'pendingmember',
|
|
82
|
+
displayName: 'Pending Member',
|
|
83
|
+
capabilities: {
|
|
84
|
+
add: ['core-local'],
|
|
85
|
+
remove: [],
|
|
86
|
+
},
|
|
87
|
+
default: true,
|
|
88
|
+
description: 'A member of the community that has not been approved yet',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
key: 'limitedmember',
|
|
92
|
+
displayName: 'Limited Member',
|
|
93
|
+
capabilities: {
|
|
94
|
+
add: [],
|
|
95
|
+
remove: [],
|
|
96
|
+
},
|
|
97
|
+
default: true,
|
|
98
|
+
description: 'A member of the community that can only partcipate in group they are added to',
|
|
99
|
+
},
|
|
100
|
+
]),
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
/** The current (last) version — the one in use. */
|
|
104
|
+
export const currentRoleDefaults = roleDefaultsHistory[roleDefaultsHistory.length - 1];
|
|
105
|
+
/**
|
|
106
|
+
* Built-in instance roles of the current version, seeded on server start.
|
|
107
|
+
* Also the reference for "restore defaults" in the admin capability matrix.
|
|
108
|
+
*/
|
|
109
|
+
export const defaultRoles = currentRoleDefaults.roles;
|
|
110
|
+
export const findRoleDefaultsVersion = (version) => roleDefaultsHistory.find((entry) => entry.version === version);
|