@openpeepshq/common 0.1.45 → 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.
Files changed (62) hide show
  1. package/dist/lib/capabilitiesHelpers.d.ts +9 -7
  2. package/dist/lib/capabilitiesHelpers.js +17 -2
  3. package/dist/lib/eventIcs.d.ts +17 -0
  4. package/dist/lib/eventIcs.js +82 -0
  5. package/dist/lib/eventRecurrence.d.ts +2 -0
  6. package/dist/lib/eventRecurrence.js +9 -4
  7. package/dist/lib/eventTime.d.ts +7 -0
  8. package/dist/lib/eventTime.js +16 -0
  9. package/dist/lib/federationHosts.d.ts +3 -0
  10. package/dist/lib/federationHosts.js +17 -0
  11. package/dist/lib/feedCursor.d.ts +14 -0
  12. package/dist/lib/feedCursor.js +22 -0
  13. package/dist/lib/feedFormat.d.ts +12 -0
  14. package/dist/lib/feedFormat.js +14 -0
  15. package/dist/lib/index.d.ts +7 -0
  16. package/dist/lib/index.js +7 -0
  17. package/dist/lib/jamHelpers.d.ts +11 -2
  18. package/dist/lib/jamHelpers.js +37 -0
  19. package/dist/lib/legacyThemeRoot.d.ts +3 -0
  20. package/dist/lib/legacyThemeRoot.js +10 -0
  21. package/dist/lib/markdownHelpers.d.ts +8 -0
  22. package/dist/lib/markdownHelpers.js +32 -3
  23. package/dist/lib/postHelpers.d.ts +142 -3
  24. package/dist/lib/postHelpers.js +307 -4
  25. package/dist/lib/profileHelpers.d.ts +11 -0
  26. package/dist/lib/profileHelpers.js +31 -0
  27. package/dist/lib/reactions.d.ts +17 -0
  28. package/dist/lib/reactions.js +37 -0
  29. package/dist/lib/scopeHelpers.d.ts +31 -2
  30. package/dist/lib/scopeHelpers.js +37 -3
  31. package/dist/lib/ssoProviders.d.ts +72 -0
  32. package/dist/lib/ssoProviders.js +370 -0
  33. package/dist/lib/timeZone.d.ts +9 -0
  34. package/dist/lib/timeZone.js +44 -0
  35. package/dist/types/analytics.d.ts +20 -0
  36. package/dist/types/analytics.js +4 -0
  37. package/dist/types/api.d.ts +41799 -11853
  38. package/dist/types/api.js +52 -4
  39. package/dist/types/auth.d.ts +20 -6
  40. package/dist/types/capabilities.d.ts +15 -1
  41. package/dist/types/capabilities.js +51 -0
  42. package/dist/types/config.d.ts +96 -0
  43. package/dist/types/config.js +53 -4
  44. package/dist/types/db.d.ts +1155 -164
  45. package/dist/types/db.js +14 -0
  46. package/dist/types/export.d.ts +120 -0
  47. package/dist/types/export.js +7 -0
  48. package/dist/types/index.d.ts +2 -0
  49. package/dist/types/index.js +2 -0
  50. package/dist/types/internal.d.ts +2577 -524
  51. package/dist/types/internal.js +6 -0
  52. package/dist/types/models.d.ts +63 -7
  53. package/dist/types/models.js +39 -2
  54. package/dist/types/plugins.d.ts +22 -0
  55. package/dist/types/plugins.js +66 -0
  56. package/dist/types/roleDefaults.d.ts +31 -0
  57. package/dist/types/roleDefaults.js +110 -0
  58. package/dist/types/stats.d.ts +54606 -6065
  59. package/dist/types/stats.js +30 -0
  60. package/dist/types/utils.d.ts +2 -0
  61. package/dist/types/utils.js +1 -3
  62. package/package.json +1 -1
@@ -23,6 +23,9 @@ export const profileWithMetaSchema = profileDataSchema.extend({
23
23
  controllers: accountSchema.array(),
24
24
  memberships: membershipSchema.array(),
25
25
  profileStats: profileStatsSchema,
26
+ blockingIds: z.array(z.string()).default([]),
27
+ blockedByIds: z.array(z.string()).default([]),
28
+ followedHashtags: hashtagSchema.array().default([]),
26
29
  });
27
30
  export const memberExportStatsSchema = z.object({
28
31
  postsCount: z.number(),
@@ -94,6 +97,9 @@ export const replyPostSchema = z.object({
94
97
  visibility: visibilityTypeSchema,
95
98
  group: groupWithMetaSchema.optional().nullable(),
96
99
  audience: z.array(profileWithMetaSchema).optional().nullable(),
100
+ seen: z.boolean().optional(),
101
+ inReplyToId: z.string().optional().nullable(),
102
+ hidden: z.boolean().optional(),
97
103
  });
98
104
  const basePostSchema = replyPostSchema.extend({
99
105
  repostCount: z.number(),
@@ -66,6 +66,7 @@ export type Account = Model<AccountData>;
66
66
  export declare const roleDataSchema: z.ZodObject<{
67
67
  key: z.ZodString;
68
68
  default: z.ZodBoolean;
69
+ baseVersion: z.ZodOptional<z.ZodString>;
69
70
  displayName: z.ZodString;
70
71
  description: z.ZodOptional<z.ZodString>;
71
72
  capabilities: z.ZodOptional<z.ZodObject<{
@@ -77,6 +78,7 @@ export type RoleData = z.infer<typeof roleDataSchema>;
77
78
  export declare const roleSchema: z.ZodObject<{
78
79
  key: z.ZodString;
79
80
  default: z.ZodBoolean;
81
+ baseVersion: z.ZodOptional<z.ZodString>;
80
82
  displayName: z.ZodString;
81
83
  description: z.ZodOptional<z.ZodString>;
82
84
  capabilities: z.ZodOptional<z.ZodObject<{
@@ -131,6 +133,7 @@ export type JamSettings = z.infer<typeof jamSettingsSchema>;
131
133
  export declare const profileSettingsDataSchema: z.ZodObject<{
132
134
  id: z.ZodString;
133
135
  language: z.ZodOptional<z.ZodString>;
136
+ timeZone: z.ZodOptional<z.ZodString>;
134
137
  theme: z.ZodOptional<z.ZodEnum<{
135
138
  community: "community";
136
139
  light: "light";
@@ -169,6 +172,10 @@ export declare const profileSettingsDataSchema: z.ZodObject<{
169
172
  customerId: z.ZodOptional<z.ZodString>;
170
173
  }, z.core.$strip>>;
171
174
  feedSettings: z.ZodOptional<z.ZodDefault<z.ZodObject<{
175
+ format: z.ZodOptional<z.ZodEnum<{
176
+ threaded: "threaded";
177
+ linear: "linear";
178
+ }>>;
172
179
  communityFeed: z.ZodOptional<z.ZodObject<{
173
180
  showGroupPosts: z.ZodOptional<z.ZodBoolean>;
174
181
  }, z.core.$strip>>;
@@ -177,6 +184,7 @@ export declare const profileSettingsDataSchema: z.ZodObject<{
177
184
  export type ProfileSettingsData = z.infer<typeof profileSettingsDataSchema>;
178
185
  export declare const profileSettingsSchema: z.ZodObject<{
179
186
  language: z.ZodOptional<z.ZodString>;
187
+ timeZone: z.ZodOptional<z.ZodString>;
180
188
  theme: z.ZodOptional<z.ZodEnum<{
181
189
  community: "community";
182
190
  light: "light";
@@ -215,6 +223,10 @@ export declare const profileSettingsSchema: z.ZodObject<{
215
223
  customerId: z.ZodOptional<z.ZodString>;
216
224
  }, z.core.$strip>>;
217
225
  feedSettings: z.ZodOptional<z.ZodDefault<z.ZodObject<{
226
+ format: z.ZodOptional<z.ZodEnum<{
227
+ threaded: "threaded";
228
+ linear: "linear";
229
+ }>>;
218
230
  communityFeed: z.ZodOptional<z.ZodObject<{
219
231
  showGroupPosts: z.ZodOptional<z.ZodBoolean>;
220
232
  }, z.core.$strip>>;
@@ -250,10 +262,10 @@ export type ResourceType = ProfileResourceType | ServiceResourceType | '*';
250
262
  export declare const resourceSchema: z.ZodObject<{
251
263
  type: z.ZodEnum<{
252
264
  self: "self";
265
+ "*": "*";
253
266
  db: "db";
254
267
  jams: "jams";
255
268
  profiles: "profiles";
256
- "*": "*";
257
269
  notifications: "notifications";
258
270
  posts: "posts";
259
271
  groups: "groups";
@@ -283,10 +295,10 @@ export declare const scopeSchema: z.ZodObject<{
283
295
  resource: z.ZodObject<{
284
296
  type: z.ZodEnum<{
285
297
  self: "self";
298
+ "*": "*";
286
299
  db: "db";
287
300
  jams: "jams";
288
301
  profiles: "profiles";
289
- "*": "*";
290
302
  notifications: "notifications";
291
303
  posts: "posts";
292
304
  groups: "groups";
@@ -333,6 +345,7 @@ export declare const locationSchema: z.ZodObject<{
333
345
  }, z.core.$strip>>;
334
346
  }, z.core.$strip>;
335
347
  export type Location = z.infer<typeof locationSchema>;
348
+ export declare const federatedHandleSchema: z.ZodString;
336
349
  export declare const profileDataSchema: z.ZodObject<{
337
350
  handle: z.ZodString;
338
351
  deletedHandle: z.ZodOptional<z.ZodString>;
@@ -371,10 +384,10 @@ export declare const profileDataSchema: z.ZodObject<{
371
384
  resource: z.ZodOptional<z.ZodObject<{
372
385
  type: z.ZodEnum<{
373
386
  self: "self";
387
+ "*": "*";
374
388
  db: "db";
375
389
  jams: "jams";
376
390
  profiles: "profiles";
377
- "*": "*";
378
391
  notifications: "notifications";
379
392
  posts: "posts";
380
393
  groups: "groups";
@@ -386,6 +399,7 @@ export declare const profileDataSchema: z.ZodObject<{
386
399
  id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>>;
387
400
  }, z.core.$strip>>;
388
401
  }, z.core.$strip>>;
402
+ pinnedPostId: z.ZodOptional<z.ZodString>;
389
403
  }, z.core.$strip>;
390
404
  export type ProfileData = z.infer<typeof profileDataSchema>;
391
405
  export declare const profileSchema: z.ZodObject<{
@@ -426,10 +440,10 @@ export declare const profileSchema: z.ZodObject<{
426
440
  resource: z.ZodOptional<z.ZodObject<{
427
441
  type: z.ZodEnum<{
428
442
  self: "self";
443
+ "*": "*";
429
444
  db: "db";
430
445
  jams: "jams";
431
446
  profiles: "profiles";
432
- "*": "*";
433
447
  notifications: "notifications";
434
448
  posts: "posts";
435
449
  groups: "groups";
@@ -441,6 +455,7 @@ export declare const profileSchema: z.ZodObject<{
441
455
  id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>>;
442
456
  }, z.core.$strip>>;
443
457
  }, z.core.$strip>>;
458
+ pinnedPostId: z.ZodOptional<z.ZodString>;
444
459
  id: z.ZodUUID;
445
460
  createdAt: z.ZodISODateTime;
446
461
  updatedAt: z.ZodISODateTime;
@@ -498,10 +513,10 @@ export declare const accountWithMetaSchema: z.ZodObject<{
498
513
  resource: z.ZodOptional<z.ZodObject<{
499
514
  type: z.ZodEnum<{
500
515
  self: "self";
516
+ "*": "*";
501
517
  db: "db";
502
518
  jams: "jams";
503
519
  profiles: "profiles";
504
- "*": "*";
505
520
  notifications: "notifications";
506
521
  posts: "posts";
507
522
  groups: "groups";
@@ -513,6 +528,7 @@ export declare const accountWithMetaSchema: z.ZodObject<{
513
528
  id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>>;
514
529
  }, z.core.$strip>>;
515
530
  }, z.core.$strip>>;
531
+ pinnedPostId: z.ZodOptional<z.ZodString>;
516
532
  id: z.ZodUUID;
517
533
  createdAt: z.ZodISODateTime;
518
534
  updatedAt: z.ZodISODateTime;
@@ -553,12 +569,14 @@ export declare const jamSchema: z.ZodObject<{
553
569
  export type JamData = z.infer<typeof jamDataSchema>;
554
570
  export type Jam = JamData;
555
571
  export declare const followDataSchema: z.ZodObject<{
572
+ uri: z.ZodOptional<z.ZodString>;
556
573
  reblogs: z.ZodOptional<z.ZodBoolean>;
557
574
  notify: z.ZodOptional<z.ZodBoolean>;
558
575
  languages: z.ZodOptional<z.ZodArray<z.ZodString>>;
559
576
  }, z.core.$strip>;
560
577
  export type FollowData = z.infer<typeof followDataSchema>;
561
578
  export declare const followSchema: z.ZodObject<{
579
+ uri: z.ZodOptional<z.ZodString>;
562
580
  reblogs: z.ZodOptional<z.ZodBoolean>;
563
581
  notify: z.ZodOptional<z.ZodBoolean>;
564
582
  languages: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -604,10 +622,10 @@ export declare const followSchema: z.ZodObject<{
604
622
  resource: z.ZodOptional<z.ZodObject<{
605
623
  type: z.ZodEnum<{
606
624
  self: "self";
625
+ "*": "*";
607
626
  db: "db";
608
627
  jams: "jams";
609
628
  profiles: "profiles";
610
- "*": "*";
611
629
  notifications: "notifications";
612
630
  posts: "posts";
613
631
  groups: "groups";
@@ -619,6 +637,7 @@ export declare const followSchema: z.ZodObject<{
619
637
  id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>>;
620
638
  }, z.core.$strip>>;
621
639
  }, z.core.$strip>>;
640
+ pinnedPostId: z.ZodOptional<z.ZodString>;
622
641
  id: z.ZodUUID;
623
642
  createdAt: z.ZodISODateTime;
624
643
  updatedAt: z.ZodISODateTime;
@@ -662,10 +681,10 @@ export declare const followSchema: z.ZodObject<{
662
681
  resource: z.ZodOptional<z.ZodObject<{
663
682
  type: z.ZodEnum<{
664
683
  self: "self";
684
+ "*": "*";
665
685
  db: "db";
666
686
  jams: "jams";
667
687
  profiles: "profiles";
668
- "*": "*";
669
688
  notifications: "notifications";
670
689
  posts: "posts";
671
690
  groups: "groups";
@@ -677,6 +696,7 @@ export declare const followSchema: z.ZodObject<{
677
696
  id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"*">]>>;
678
697
  }, z.core.$strip>>;
679
698
  }, z.core.$strip>>;
699
+ pinnedPostId: z.ZodOptional<z.ZodString>;
680
700
  id: z.ZodUUID;
681
701
  createdAt: z.ZodISODateTime;
682
702
  updatedAt: z.ZodISODateTime;
@@ -1842,6 +1862,20 @@ export declare const rsvpSchema: z.ZodObject<{
1842
1862
  recurrenceId: z.ZodOptional<z.ZodISODateTime>;
1843
1863
  }, z.core.$strip>;
1844
1864
  export type RSVP = z.infer<typeof rsvpSchema>;
1865
+ export declare const rsvpRequestSchema: z.ZodObject<{
1866
+ response: z.ZodEnum<{
1867
+ no: "no";
1868
+ yes: "yes";
1869
+ tentative: "tentative";
1870
+ removed: "removed";
1871
+ }>;
1872
+ recurrenceId: z.ZodOptional<z.ZodISODateTime>;
1873
+ recurrenceIds: z.ZodOptional<z.ZodArray<z.ZodISODateTime>>;
1874
+ }, z.core.$strip>;
1875
+ export type RsvpRequest = z.infer<typeof rsvpRequestSchema>;
1876
+ export declare const entryReactionDataSchema: z.ZodObject<{
1877
+ reaction: z.ZodString;
1878
+ }, z.core.$strip>;
1845
1879
  export declare const entryDataSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1846
1880
  type: z.ZodLiteral<"create">;
1847
1881
  data: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -2327,6 +2361,18 @@ export declare const entryDataSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2327
2361
  }>;
2328
2362
  recurrenceId: z.ZodOptional<z.ZodISODateTime>;
2329
2363
  }, z.core.$strip>;
2364
+ }, z.core.$strip>, z.ZodObject<{
2365
+ type: z.ZodLiteral<"reaction">;
2366
+ data: z.ZodObject<{
2367
+ reaction: z.ZodString;
2368
+ }, z.core.$strip>;
2369
+ uri: z.ZodOptional<z.ZodString>;
2370
+ }, z.core.$strip>, z.ZodObject<{
2371
+ type: z.ZodLiteral<"unreaction">;
2372
+ data: z.ZodObject<{
2373
+ reaction: z.ZodString;
2374
+ }, z.core.$strip>;
2375
+ uri: z.ZodOptional<z.ZodString>;
2330
2376
  }, z.core.$strip>], "type">;
2331
2377
  export type EntryData = z.infer<typeof entryDataSchema>;
2332
2378
  export type Entry = Model<EntryData & {
@@ -2795,11 +2841,20 @@ export declare const jamRecordingKindSchema: z.ZodEnum<{
2795
2841
  rtmp: "rtmp";
2796
2842
  }>;
2797
2843
  export type JamRecordingKind = z.infer<typeof jamRecordingKindSchema>;
2844
+ export declare const jamRecordingStatusSchema: z.ZodEnum<{
2845
+ active: "active";
2846
+ failed: "failed";
2847
+ requested: "requested";
2848
+ finalizing: "finalizing";
2849
+ completed: "completed";
2850
+ }>;
2851
+ export type JamRecordingStatus = z.infer<typeof jamRecordingStatusSchema>;
2798
2852
  export declare const jamRecordingDataSchema: z.ZodObject<{
2799
2853
  status: z.ZodEnum<{
2800
2854
  active: "active";
2801
2855
  failed: "failed";
2802
2856
  requested: "requested";
2857
+ finalizing: "finalizing";
2803
2858
  completed: "completed";
2804
2859
  }>;
2805
2860
  kind: z.ZodOptional<z.ZodEnum<{
@@ -2844,6 +2899,7 @@ export declare const jamRecordingSchema: z.ZodObject<{
2844
2899
  active: "active";
2845
2900
  failed: "failed";
2846
2901
  requested: "requested";
2902
+ finalizing: "finalizing";
2847
2903
  completed: "completed";
2848
2904
  }>;
2849
2905
  kind: z.ZodOptional<z.ZodEnum<{
@@ -70,6 +70,8 @@ export const accountSchema = modelSchema(accountDataSchema);
70
70
  export const roleDataSchema = z.object({
71
71
  key: z.string().regex(/^[a-z-]{1,32}$/),
72
72
  default: z.boolean(),
73
+ /** Defaults history version the role's capabilities were based on. */
74
+ baseVersion: z.string().optional(),
73
75
  displayName: z.string().max(32),
74
76
  description: z.string().optional(),
75
77
  capabilities: capabilitiesSchema,
@@ -115,6 +117,7 @@ export const ThemeOptionsSchema = z.enum(THEME_OPTIONS);
115
117
  export const profileSettingsDataSchema = z.object({
116
118
  id: z.string(),
117
119
  language: z.string().optional(),
120
+ timeZone: z.string().optional(),
118
121
  theme: ThemeOptionsSchema.optional(),
119
122
  defaults: profileSettingsDefaultsSchema.optional(),
120
123
  notifications: z.record(z.string(), profileNotificationSettings).optional(),
@@ -126,6 +129,7 @@ export const profileSettingsDataSchema = z.object({
126
129
  .optional(),
127
130
  feedSettings: z
128
131
  .object({
132
+ format: z.enum(['threaded', 'linear']).optional(),
129
133
  communityFeed: z
130
134
  .object({
131
135
  showGroupPosts: z.boolean().optional(),
@@ -201,8 +205,15 @@ export const locationSchema = z.object({
201
205
  text: z.string(),
202
206
  coordinates: latLngSchema.optional(),
203
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
+ });
204
215
  export const profileDataSchema = z.object({
205
- handle: accountNameSchema,
216
+ handle: federatedHandleSchema,
206
217
  deletedHandle: accountNameSchema.optional(),
207
218
  avatar: z.url().nullable().optional(),
208
219
  header: z.url().nullable().optional(),
@@ -233,6 +244,7 @@ export const profileDataSchema = z.object({
233
244
  resource: resourceSchema.optional(),
234
245
  })
235
246
  .optional(),
247
+ pinnedPostId: z.string().optional(),
236
248
  });
237
249
  export const profileSchema = modelSchema(profileDataSchema);
238
250
  export const accountWithMetaSchema = accountSchema.extend({
@@ -254,6 +266,8 @@ export const jamDataSchema = z
254
266
  .openapi('Jam');
255
267
  export const jamSchema = jamDataSchema;
256
268
  export const followDataSchema = z.object({
269
+ /** ActivityPub Follow activity id when federated. */
270
+ uri: z.string().url().optional(),
257
271
  reblogs: z.boolean().optional(),
258
272
  notify: z.boolean().optional(),
259
273
  languages: z
@@ -436,6 +450,12 @@ export const rsvpSchema = z.object({
436
450
  response: rsvpResponseSchema,
437
451
  recurrenceId: eventIsoDatetimeSchema.optional(),
438
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),
458
+ });
439
459
  export const entryDataSchema = z.discriminatedUnion('type', [
440
460
  z.object({
441
461
  type: z.literal('create'),
@@ -457,6 +477,16 @@ export const entryDataSchema = z.discriminatedUnion('type', [
457
477
  type: z.literal('rsvp'),
458
478
  data: rsvpSchema,
459
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
+ }),
460
490
  ]);
461
491
  export const accountInteractionsSchema = z.object({
462
492
  favorited: z.boolean(),
@@ -642,8 +672,15 @@ export const jamRecordingTypeSchema = z.enum([
642
672
  'streams',
643
673
  ]);
644
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
+ ]);
645
682
  export const jamRecordingDataSchema = z.object({
646
- status: z.enum(['requested', 'active', 'completed', 'failed']),
683
+ status: jamRecordingStatusSchema,
647
684
  kind: jamRecordingKindSchema.optional(),
648
685
  destinationHost: z.string().optional(),
649
686
  egressId: z.string().optional(),
@@ -41,6 +41,28 @@ export declare const adminPluginInfoSchema: z.ZodObject<{
41
41
  installed: z.ZodOptional<z.ZodBoolean>;
42
42
  }, z.core.$strip>;
43
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>;
44
66
  export declare const pluginManifestSchema: z.ZodObject<{
45
67
  components: z.ZodDefault<z.ZodArray<z.ZodObject<{
46
68
  slot: z.ZodString;
@@ -16,6 +16,72 @@ export const adminPluginInfoSchema = pluginInfoSchema.extend({
16
16
  /** True when installed via the admin UI (can be uninstalled). */
17
17
  installed: z.boolean().optional(),
18
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
+ ]);
19
85
  export const pluginManifestSchema = z.object({
20
86
  components: z
21
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);