@openpeepshq/common 0.9.0 → 0.9.1

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.
@@ -7,6 +7,14 @@ export declare const uniquePostsById: <T extends {
7
7
  }>(posts: (T | undefined)[]) => T[];
8
8
  export declare const getJamUrl: (id: string, origin: string | undefined, occurrence?: string) => string;
9
9
  export declare const jamFromEvent: (event: PublicPost) => Jam | undefined;
10
+ /** A public post that is a real jam (the anonymous state-read short-circuit). */
11
+ export declare const isPublicJamPost: (event: {
12
+ visibility: string;
13
+ data?: {
14
+ type?: string;
15
+ jam?: unknown;
16
+ } | null;
17
+ }) => boolean;
10
18
  export declare const canModerateJam: (profile: Pick<PublicProfile, "id"> | undefined, post: PublicPost) => boolean;
11
19
  /** Host or jam moderator — same gate as the event Attendees tab. */
12
20
  export declare const canViewJamAttendees: (profile: Pick<PublicProfile, "id"> | undefined, post: PublicPost) => boolean;
@@ -34,6 +34,10 @@ export const jamFromEvent = (event) => {
34
34
  }
35
35
  return undefined;
36
36
  };
37
+ /** A public post that is a real jam (the anonymous state-read short-circuit). */
38
+ export const isPublicJamPost = (event) => event.visibility === 'public' &&
39
+ event.data?.type === 'event' &&
40
+ !!event.data?.jam;
37
41
  export const canModerateJam = (profile, post) => !!(profile && jamFromEvent(post)?.moderators?.includes(profile.id));
38
42
  /** Host or jam moderator — same gate as the event Attendees tab. */
39
43
  export const canViewJamAttendees = (profile, post) => !!(profile &&
@@ -276,7 +276,7 @@ export type JamCapacityJoinBlock = {
276
276
  blocked: false;
277
277
  } | {
278
278
  blocked: true;
279
- reason: 'full' | 'rsvp-required' | 'removed';
279
+ reason: 'full' | 'rsvp-required' | 'removed' | 'guest-required';
280
280
  };
281
281
  export declare const getJamCapacityJoinBlock: (post: PublicPost, profile: Pick<PublicProfile, "id"> | undefined, recurrenceId?: string) => JamCapacityJoinBlock;
282
282
  export declare const canDeletePost: (authData: AuthorizationData, post: PublicPost, config: CapabilitiesConfig) => boolean;
@@ -1,4 +1,4 @@
1
- import type { GroupWithMeta, InviteLinkWithMeta, ProfileSettings, ProfileWithMeta, PublicProfile, StripeSubscriptionData } from '../types';
1
+ import type { GroupWithMeta, InviteLinkWithMeta, JamWaitingProfile, ProfileSettings, ProfileWithMeta, PublicProfile, StripeSubscriptionData } from '../types';
2
2
  export declare const PROFILE_DISPLAY_NAME_MAX_LENGTH = 30;
3
3
  /** Public sentinel shown for soft-deleted profiles (API + clients). */
4
4
  export declare const DELETED_AUTHOR_DISPLAY_NAME = "Deleted Profile";
@@ -35,6 +35,8 @@ export declare const toDeletedProfileWithMeta: (profile: ProfileWithMeta) => Pro
35
35
  /** Tombstone a `ProfileWithMeta` only when it is soft-deleted. */
36
36
  export declare const tombstoneProfileWithMetaIfDeleted: (profile: ProfileWithMeta | undefined) => ProfileWithMeta | undefined;
37
37
  export declare const profileName: (profile?: PublicProfile) => string | undefined;
38
+ /** Display name for a waiting-room queue entry (queue stores only a name). */
39
+ export declare const waitingRoomEntryName: (entry?: JamWaitingProfile) => string;
38
40
  export declare const matchesQuery: (profile: PublicProfile | GroupWithMeta | undefined, query: string, queryOptions?: {
39
41
  handle: boolean;
40
42
  displayName: boolean;
@@ -86,6 +86,8 @@ export const tombstoneProfileWithMetaIfDeleted = (profile) => profile && isDelet
86
86
  ? toDeletedProfileWithMeta(profile)
87
87
  : profile;
88
88
  export const profileName = (profile) => profile?.displayName || profile?.handle;
89
+ /** Display name for a waiting-room queue entry (queue stores only a name). */
90
+ export const waitingRoomEntryName = (entry) => entry?.displayName || `#${entry?.id.slice(0, 6)}`;
89
91
  export const matchesQuery = (profile, query, queryOptions = { handle: true, displayName: true }) => !!(profile &&
90
92
  (query.startsWith('@')
91
93
  ? profile.handle && containsIgnoreCase(profile.handle, query.substring(1))
@@ -38933,6 +38933,21 @@ export declare const jamTokenResponseSchema: z.ZodObject<{
38933
38933
  livekitUrl: z.ZodString;
38934
38934
  }, z.core.$strip>;
38935
38935
  export type JamTokenResponse = z.infer<typeof jamTokenResponseSchema>;
38936
+ /**
38937
+ * Waiting-room entry as stored in Redis and streamed to moderators: the
38938
+ * profile's `displayName` (or `handle` when absent) keyed by `profile.id`.
38939
+ * The admission path re-fetches the full profile by id, so the queue never
38940
+ * carries the full object.
38941
+ */
38942
+ export declare const jamWaitingRoomEntrySchema: z.ZodObject<{
38943
+ displayName: z.ZodOptional<z.ZodString>;
38944
+ }, z.core.$strip>;
38945
+ export type JamWaitingRoomEntry = z.infer<typeof jamWaitingRoomEntrySchema>;
38946
+ /** A waiting-room entry resolved for UI: the profile id (the record key) plus display name. */
38947
+ export type JamWaitingProfile = {
38948
+ id: string;
38949
+ displayName?: string;
38950
+ };
38936
38951
  export interface Credentials {
38937
38952
  token: string;
38938
38953
  }
@@ -72374,6 +72389,53 @@ export declare const postCreationDataSchema: z.ZodObject<{
72374
72389
  groupId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
72375
72390
  reportId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
72376
72391
  capabilitiesNeeded: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
72392
+ questionDraft: z.ZodOptional<z.ZodObject<{
72393
+ content: z.ZodOptional<z.ZodOptional<z.ZodString>>;
72394
+ sensitive: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
72395
+ spoilerText: z.ZodOptional<z.ZodOptional<z.ZodString>>;
72396
+ attachments: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
72397
+ type: z.ZodString;
72398
+ url: z.ZodURL;
72399
+ previewUrl: z.ZodNullable<z.ZodURL>;
72400
+ textUrl: z.ZodNull;
72401
+ filename: z.ZodString;
72402
+ meta: z.ZodObject<{
72403
+ usage: z.ZodOptional<z.ZodString>;
72404
+ focus: z.ZodOptional<z.ZodObject<{
72405
+ x: z.ZodNumber;
72406
+ y: z.ZodNumber;
72407
+ }, z.core.$strip>>;
72408
+ mimetype: z.ZodOptional<z.ZodString>;
72409
+ size: z.ZodOptional<z.ZodNumber>;
72410
+ }, z.core.$strip>;
72411
+ description: z.ZodOptional<z.ZodString>;
72412
+ blurhash: z.ZodOptional<z.ZodString>;
72413
+ status: z.ZodOptional<z.ZodEnum<{
72414
+ processing: "processing";
72415
+ ready: "ready";
72416
+ failed: "failed";
72417
+ }>>;
72418
+ error: z.ZodOptional<z.ZodString>;
72419
+ }, z.core.$strip>>>>;
72420
+ customEmojis: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
72421
+ shortcode: z.ZodString;
72422
+ url: z.ZodURL;
72423
+ staticUrl: z.ZodURL;
72424
+ visibleInPicker: z.ZodBoolean;
72425
+ category: z.ZodString;
72426
+ }, z.core.$strip>>>>;
72427
+ language: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
72428
+ [x: string]: string;
72429
+ }>>>;
72430
+ type: z.ZodOptional<z.ZodLiteral<"question">>;
72431
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
72432
+ content: z.ZodString;
72433
+ type: z.ZodLiteral<"note">;
72434
+ }, z.core.$strip>>>;
72435
+ multiple: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
72436
+ votersVisible: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
72437
+ expiresAt: z.ZodOptional<z.ZodOptional<z.ZodISODateTime>>;
72438
+ }, z.core.$strip>>;
72377
72439
  }, z.core.$strip>;
72378
72440
  export type PostCreationData = z.infer<typeof postCreationDataSchema>;
72379
72441
  export declare const postCreationDataFormSchema: z.ZodObject<{
@@ -72902,6 +72964,53 @@ export declare const postCreationDataFormSchema: z.ZodObject<{
72902
72964
  groupId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
72903
72965
  reportId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
72904
72966
  capabilitiesNeeded: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
72967
+ questionDraft: z.ZodOptional<z.ZodObject<{
72968
+ content: z.ZodOptional<z.ZodOptional<z.ZodString>>;
72969
+ sensitive: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
72970
+ spoilerText: z.ZodOptional<z.ZodOptional<z.ZodString>>;
72971
+ attachments: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
72972
+ type: z.ZodString;
72973
+ url: z.ZodURL;
72974
+ previewUrl: z.ZodNullable<z.ZodURL>;
72975
+ textUrl: z.ZodNull;
72976
+ filename: z.ZodString;
72977
+ meta: z.ZodObject<{
72978
+ usage: z.ZodOptional<z.ZodString>;
72979
+ focus: z.ZodOptional<z.ZodObject<{
72980
+ x: z.ZodNumber;
72981
+ y: z.ZodNumber;
72982
+ }, z.core.$strip>>;
72983
+ mimetype: z.ZodOptional<z.ZodString>;
72984
+ size: z.ZodOptional<z.ZodNumber>;
72985
+ }, z.core.$strip>;
72986
+ description: z.ZodOptional<z.ZodString>;
72987
+ blurhash: z.ZodOptional<z.ZodString>;
72988
+ status: z.ZodOptional<z.ZodEnum<{
72989
+ processing: "processing";
72990
+ ready: "ready";
72991
+ failed: "failed";
72992
+ }>>;
72993
+ error: z.ZodOptional<z.ZodString>;
72994
+ }, z.core.$strip>>>>;
72995
+ customEmojis: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
72996
+ shortcode: z.ZodString;
72997
+ url: z.ZodURL;
72998
+ staticUrl: z.ZodURL;
72999
+ visibleInPicker: z.ZodBoolean;
73000
+ category: z.ZodString;
73001
+ }, z.core.$strip>>>>;
73002
+ language: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
73003
+ [x: string]: string;
73004
+ }>>>;
73005
+ type: z.ZodOptional<z.ZodLiteral<"question">>;
73006
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
73007
+ content: z.ZodString;
73008
+ type: z.ZodLiteral<"note">;
73009
+ }, z.core.$strip>>>;
73010
+ multiple: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
73011
+ votersVisible: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
73012
+ expiresAt: z.ZodOptional<z.ZodOptional<z.ZodISODateTime>>;
73013
+ }, z.core.$strip>>;
72905
73014
  }, z.core.$strip>;
72906
73015
  declare const answerWithPublicProfileSchema: z.ZodObject<{
72907
73016
  selection: z.ZodArray<z.ZodNumber>;
package/dist/types/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { notificationStatsSchema, pushNotificationSchema, } from './notifications.js';
3
- import { accessTokenSchema, accountInteractionsSchema, accountNameSchema, federatedHandleSchema, accountSchema, answerSchema, applicationDataSchema, groupDataSchema, groupRoleSchema, groupSchema, guestDataSchema, hashtagSchema, inviteLinkSchema, jamRecordingStatusSchema, latLngSchema, locationSchema, mediaAttachmentSchema, mentionDataSchema, postDataInputUnionSchema, postDataUnionSchema, postTypeSchema, profileDataSchema, profileStatsSchema, reactionDataSchema, roleDataSchema, reportDataSchema, reportSchema, resourceSchema, rsvpSchema, scopeSchema, visibilityTypeSchema, } from './models.js';
3
+ import { accessTokenSchema, accountInteractionsSchema, accountNameSchema, federatedHandleSchema, accountSchema, answerSchema, applicationDataSchema, groupDataSchema, groupRoleSchema, groupSchema, guestDataSchema, hashtagSchema, inviteLinkSchema, jamRecordingStatusSchema, latLngSchema, locationSchema, mediaAttachmentSchema, mentionDataSchema, postDataInputUnionSchema, postDataUnionSchema, postTypeSchema, profileDataSchema, profileStatsSchema, questionSchema, reactionDataSchema, roleDataSchema, reportDataSchema, reportSchema, resourceSchema, rsvpSchema, scopeSchema, visibilityTypeSchema, } from './models.js';
4
4
  import { groupWithMetaSchema } from './internal.js';
5
5
  import { communityConfigSchema } from './config.js';
6
6
  import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
@@ -379,6 +379,15 @@ export const tokenResponseSchema = z.object({
379
379
  export const jamTokenResponseSchema = tokenResponseSchema.extend({
380
380
  livekitUrl: z.string(),
381
381
  });
382
+ /**
383
+ * Waiting-room entry as stored in Redis and streamed to moderators: the
384
+ * profile's `displayName` (or `handle` when absent) keyed by `profile.id`.
385
+ * The admission path re-fetches the full profile by id, so the queue never
386
+ * carries the full object.
387
+ */
388
+ export const jamWaitingRoomEntrySchema = z.object({
389
+ displayName: z.string().optional(),
390
+ });
382
391
  const focusCoordinatesPattern = /^-?\d+,-?\d+$/;
383
392
  // NOTE: `file` / `thumbnail` accept a `File` (browser) or any
384
393
  // multipart body — modelled as `z.any()` for the API contract so the OpenAPI
@@ -539,6 +548,16 @@ export const postCreationDataSchema = z.object({
539
548
  groupId: z.uuid().nullable().optional(),
540
549
  reportId: z.uuid().nullable().optional(),
541
550
  capabilitiesNeeded: z.string().array().nullable().optional(),
551
+ /**
552
+ * Composer-side poll stash: the structural poll fields (`options`,
553
+ * `expiresAt`, `multiple`, `votersVisible`) that `toNote` captures when a
554
+ * poll draft is switched away so `toQuestion` can restore them on the
555
+ * reverse switch. Client-side only, never set by the server, and never
556
+ * persisted: the `POST /posts` handler parses the stored record with
557
+ * `postDataSchema`, which has no `questionDraft` key, so the parse
558
+ * strips it.
559
+ */
560
+ questionDraft: questionSchema.partial().optional(),
542
561
  });
543
562
  export const postCreationDataFormSchema = postCreationDataSchema
544
563
  .refine((data) => {
@@ -885,6 +885,8 @@ export declare const noteSchema: z.ZodObject<{
885
885
  export type Note = z.infer<typeof noteSchema>;
886
886
  /** Poll choices are stored short so they fit the vote UI on small screens. */
887
887
  export declare const POLL_OPTION_MAX_LENGTH = 30;
888
+ /** Default expiry for a new poll, applied by the web and native composers. */
889
+ export declare const POLL_DEFAULT_EXPIRY_MS: number;
888
890
  export declare const questionSchema: z.ZodObject<{
889
891
  content: z.ZodOptional<z.ZodString>;
890
892
  sensitive: z.ZodOptional<z.ZodBoolean>;
@@ -373,6 +373,8 @@ const contentBudgetRefine = {
373
373
  export const noteSchema = noteBaseSchema.openapi('Note');
374
374
  /** Poll choices are stored short so they fit the vote UI on small screens. */
375
375
  export const POLL_OPTION_MAX_LENGTH = 30;
376
+ /** Default expiry for a new poll, applied by the web and native composers. */
377
+ export const POLL_DEFAULT_EXPIRY_MS = 30 * 24 * 60 * 60 * 1000;
376
378
  export const questionSchema = noteBaseSchema
377
379
  .extend({
378
380
  type: z.literal('question'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/common",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -47,6 +47,15 @@ export const jamFromEvent = (event: PublicPost): Jam | undefined => {
47
47
  return undefined;
48
48
  };
49
49
 
50
+ /** A public post that is a real jam (the anonymous state-read short-circuit). */
51
+ export const isPublicJamPost = (event: {
52
+ visibility: string;
53
+ data?: { type?: string; jam?: unknown } | null;
54
+ }): boolean =>
55
+ event.visibility === 'public' &&
56
+ event.data?.type === 'event' &&
57
+ !!event.data?.jam;
58
+
50
59
  export const canModerateJam = (
51
60
  profile: Pick<PublicProfile, 'id'> | undefined,
52
61
  post: PublicPost,
@@ -631,7 +631,10 @@ export const canManageEventRsvps = (
631
631
 
632
632
  export type JamCapacityJoinBlock =
633
633
  | { blocked: false }
634
- | { blocked: true; reason: 'full' | 'rsvp-required' | 'removed' };
634
+ | {
635
+ blocked: true;
636
+ reason: 'full' | 'rsvp-required' | 'removed' | 'guest-required';
637
+ };
635
638
 
636
639
  export const getJamCapacityJoinBlock = (
637
640
  post: PublicPost,
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  GroupWithMeta,
3
3
  InviteLinkWithMeta,
4
+ JamWaitingProfile,
4
5
  ProfileSettings,
5
6
  ProfileWithMeta,
6
7
  PublicProfile,
@@ -131,6 +132,10 @@ export const tombstoneProfileWithMetaIfDeleted = (
131
132
  export const profileName = (profile?: PublicProfile) =>
132
133
  profile?.displayName || profile?.handle;
133
134
 
135
+ /** Display name for a waiting-room queue entry (queue stores only a name). */
136
+ export const waitingRoomEntryName = (entry?: JamWaitingProfile) =>
137
+ entry?.displayName || `#${entry?.id.slice(0, 6)}`;
138
+
134
139
  export const matchesQuery = (
135
140
  profile: PublicProfile | GroupWithMeta | undefined,
136
141
  query: string,
package/src/types/api.ts CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  postTypeSchema,
33
33
  profileDataSchema,
34
34
  profileStatsSchema,
35
+ questionSchema,
35
36
  reactionDataSchema,
36
37
  roleDataSchema,
37
38
  Report,
@@ -579,6 +580,23 @@ export const jamTokenResponseSchema = tokenResponseSchema.extend({
579
580
  });
580
581
  export type JamTokenResponse = z.infer<typeof jamTokenResponseSchema>;
581
582
 
583
+ /**
584
+ * Waiting-room entry as stored in Redis and streamed to moderators: the
585
+ * profile's `displayName` (or `handle` when absent) keyed by `profile.id`.
586
+ * The admission path re-fetches the full profile by id, so the queue never
587
+ * carries the full object.
588
+ */
589
+ export const jamWaitingRoomEntrySchema = z.object({
590
+ displayName: z.string().optional(),
591
+ });
592
+ export type JamWaitingRoomEntry = z.infer<typeof jamWaitingRoomEntrySchema>;
593
+
594
+ /** A waiting-room entry resolved for UI: the profile id (the record key) plus display name. */
595
+ export type JamWaitingProfile = {
596
+ id: string;
597
+ displayName?: string;
598
+ };
599
+
582
600
  export interface Credentials {
583
601
  token: string;
584
602
  }
@@ -832,6 +850,16 @@ export const postCreationDataSchema = z.object({
832
850
  groupId: z.uuid().nullable().optional(),
833
851
  reportId: z.uuid().nullable().optional(),
834
852
  capabilitiesNeeded: z.string().array().nullable().optional(),
853
+ /**
854
+ * Composer-side poll stash: the structural poll fields (`options`,
855
+ * `expiresAt`, `multiple`, `votersVisible`) that `toNote` captures when a
856
+ * poll draft is switched away so `toQuestion` can restore them on the
857
+ * reverse switch. Client-side only, never set by the server, and never
858
+ * persisted: the `POST /posts` handler parses the stored record with
859
+ * `postDataSchema`, which has no `questionDraft` key, so the parse
860
+ * strips it.
861
+ */
862
+ questionDraft: questionSchema.partial().optional(),
835
863
  });
836
864
 
837
865
  export type PostCreationData = z.infer<typeof postCreationDataSchema>;
@@ -535,6 +535,9 @@ export type Note = z.infer<typeof noteSchema>;
535
535
  /** Poll choices are stored short so they fit the vote UI on small screens. */
536
536
  export const POLL_OPTION_MAX_LENGTH = 30;
537
537
 
538
+ /** Default expiry for a new poll, applied by the web and native composers. */
539
+ export const POLL_DEFAULT_EXPIRY_MS = 30 * 24 * 60 * 60 * 1000;
540
+
538
541
  export const questionSchema = noteBaseSchema
539
542
  .extend({
540
543
  type: z.literal('question'),