stream-chat 9.5.0 → 9.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,42 +33,84 @@ export type Notification = {
33
33
  * The identifier then can be recognized by notification consumers to act upon specific origin values.
34
34
  */
35
35
  origin: NotificationOrigin;
36
- /** Optional timestamp when notification should expire */
37
- expiresAt?: number;
38
- /** Whether notification should automatically close after duration. Defaults to true */
39
- autoClose?: boolean;
40
36
  /** Array of action buttons for the notification */
41
37
  actions?: NotificationAction[];
38
+ /**
39
+ * Optional code that can be used to group the notifications of the same type, e.g. attachment-upload-blocked.
40
+ * Format: domain:entity:operation:result
41
+ * domain: where the error occurred (api, validation, permission, etc)
42
+ * entity: what was being operated on (poll, attachment, message, etc)
43
+ * operation: what was being attempted (create, upload, validate, etc)
44
+ * result: what happened (failed, blocked, invalid, etc)
45
+ *
46
+ * Poll related errors
47
+ * 'api:poll:create:failed' // API call to create poll failed
48
+ * 'validation:poll:create:invalid' // Poll creation validation failed
49
+ *
50
+ * Attachment related errors
51
+ * 'validation:attachment:file:missing' // Required file is missing
52
+ * 'permission:attachment:upload:blocked' // Upload blocked due to permissions
53
+ * 'api:attachment:upload:failed' // API upload call failed
54
+ * 'validation:attachment:type:unsupported' // Unsupported file type
55
+ * 'validation:attachment:size:exceeded' // File size too large
56
+ * 'validation:attachment:count:exceeded' // Too many attachments
57
+ *
58
+ * Message related errors
59
+ * 'api:message:send:failed' // Message send failed
60
+ * 'validation:message:content:empty' // Message content validation failed
61
+ *
62
+ * Channel related errors
63
+ * 'api:channel:join:failed' // Channel join failed
64
+ * 'permission:channel:access:denied' // Channel access denied
65
+ *
66
+ * Authentication related errors
67
+ * 'auth:token:expired' // Auth token expired
68
+ * 'auth:token:invalid' // Invalid auth token
69
+ *
70
+ * Network related errors
71
+ * 'network:request:timeout' // Request timed out
72
+ * 'network:request:failed' // Network request failed
73
+ *
74
+ * Rate limiting
75
+ * 'rate:limit:exceeded' // Rate limit exceeded
76
+ *
77
+ * System errors
78
+ * 'system:internal:error' // Internal system error
79
+ * 'system:resource:unavailable'; // System resource unavailable
80
+ */
81
+ type?: string;
82
+ /** Optional timestamp when notification should expire */
83
+ expiresAt?: number;
42
84
  /** Optional metadata to attach to the notification */
43
85
  metadata?: Record<string, unknown>;
86
+ /** In case of error notification the instance of the originally thrown error */
87
+ originalError?: Error;
44
88
  };
45
89
 
46
90
  /** Configuration options when creating a notification */
47
- export type NotificationOptions = {
48
- /** The severity level. Defaults to 'info' */
49
- severity?: NotificationSeverity;
50
- /** How long notification should display in milliseconds */
91
+ export type NotificationOptions = Partial<
92
+ Pick<Notification, 'type' | 'severity' | 'actions' | 'metadata' | 'originalError'>
93
+ > & {
94
+ /** How long a notification should be displayed in milliseconds */
51
95
  duration?: number;
52
- /** Whether notification should auto-close after duration. Defaults to true */
53
- autoClose?: boolean;
54
- /** Array of action buttons for the notification */
55
- actions?: NotificationAction[];
56
- /** Optional metadata to attach to the notification */
57
- metadata?: Record<string, unknown>;
58
96
  };
59
97
 
60
- /** State shape for the notification store */
98
+ /**
99
+ * State shape for the notification store
100
+ * @deprcated use NotificationManagerState
101
+ */
61
102
  export type NotificationState = {
62
103
  /** Array of current notification objects */
63
104
  notifications: Notification[];
64
105
  };
65
106
 
107
+ /** State shape for the notification store */
108
+ export type NotificationManagerState = NotificationState;
109
+
66
110
  export type NotificationManagerConfig = {
67
111
  durations: Record<NotificationSeverity, number>;
68
112
  };
69
113
 
70
- export type AddNotificationPayload = {
71
- message: string;
72
- origin: NotificationOrigin;
114
+ export type AddNotificationPayload = Pick<Notification, 'message' | 'origin'> & {
73
115
  options?: NotificationOptions;
74
116
  };
@@ -49,7 +49,13 @@ export class PollManager extends WithSubscriptions {
49
49
  public createPoll = async (poll: CreatePollData) => {
50
50
  const { poll: createdPoll } = await this.client.createPoll(poll);
51
51
 
52
- return new Poll({ client: this.client, poll: createdPoll });
52
+ if (!createdPoll.vote_counts_by_option) {
53
+ createdPoll.vote_counts_by_option = {};
54
+ }
55
+
56
+ this.setOrOverwriteInCache(createdPoll);
57
+
58
+ return this.fromState(createdPoll.id);
53
59
  };
54
60
 
55
61
  public getPoll = async (id: string) => {