stream-chat 10.0.0-rc.21 → 10.0.0-rc.23
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/cjs/index.browser.js +2196 -3902
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +2197 -3902
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +2199 -3905
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +120 -233
- package/dist/types/CooldownTimer.d.ts +8 -23
- package/dist/types/EventHandlerPipeline.d.ts +17 -37
- package/dist/types/LiveLocationManager.d.ts +22 -50
- package/dist/types/api-client.d.ts +9 -14
- package/dist/types/channel.d.ts +253 -448
- package/dist/types/channel_state.d.ts +48 -95
- package/dist/types/client.d.ts +245 -370
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +30 -124
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
- package/dist/types/configuration/keys.d.ts +5 -19
- package/dist/types/configuration/shape.d.ts +12 -29
- package/dist/types/configuration/types.d.ts +59 -87
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
- package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
- package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
- package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
- package/dist/types/connection/networkConnection/types.d.ts +12 -27
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
- package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
- package/dist/types/connection/wsConnection/config.d.ts +8 -28
- package/dist/types/connection/wsConnection/types.d.ts +17 -70
- package/dist/types/entityStore/EntityStore.d.ts +153 -113
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
- package/dist/types/errors.d.ts +7 -19
- package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
- package/dist/types/gen/chat/ChatApi.d.ts +28 -14
- package/dist/types/gen/models/index.d.ts +769 -86
- package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
- package/dist/types/index.d.ts +2 -4
- package/dist/types/languageNames.d.ts +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
- package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
- package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
- package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +29 -56
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
- package/dist/types/messageComposer/messageComposer.d.ts +30 -164
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
- package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
- package/dist/types/messageComposer/pollComposer.d.ts +8 -4
- package/dist/types/messageComposer/textComposer.d.ts +3 -9
- package/dist/types/messageComposer/types.d.ts +5 -8
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
- package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
- package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
- package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
- package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
- package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
- package/dist/types/messageOperations/types.d.ts +15 -30
- package/dist/types/middleware.d.ts +7 -5
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +8 -31
- package/dist/types/notifications/types.d.ts +19 -59
- package/dist/types/offline-support/offline_support_api.d.ts +145 -539
- package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
- package/dist/types/offline-support/queueableOperations.d.ts +24 -52
- package/dist/types/offline-support/types.d.ts +24 -187
- package/dist/types/pagination/ItemIndex.d.ts +4 -12
- package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
- package/dist/types/pagination/sortCompiler.d.ts +11 -22
- package/dist/types/pagination/utility.normalization.d.ts +5 -23
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +14 -14
- package/dist/types/poll_manager.d.ts +11 -2
- package/dist/types/poll_optimistic_votes.d.ts +10 -14
- package/dist/types/reminders/Reminder.d.ts +4 -4
- package/dist/types/reminders/ReminderManager.d.ts +7 -20
- package/dist/types/search/BaseSearchSource.d.ts +7 -12
- package/dist/types/search/ChannelSearchSource.d.ts +7 -7
- package/dist/types/search/MessageSearchSource.d.ts +7 -9
- package/dist/types/search/SearchController.d.ts +17 -22
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +23 -71
- package/dist/types/thread_manager.d.ts +45 -70
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +64 -125
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +17 -45
- package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
- package/dist/types/utils/WithSubscriptions.d.ts +5 -15
- package/dist/types/utils/concurrency.d.ts +11 -19
- package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
- package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
- package/dist/types/utils/objectPath.d.ts +6 -41
- package/dist/types/utils/retryable.d.ts +8 -12
- package/dist/types/utils/throttling/throttle.d.ts +8 -23
- package/dist/types/utils/time.d.ts +24 -64
- package/dist/types/utils.d.ts +40 -86
- package/package.json +7 -2
- package/src/ChannelManager.ts +159 -300
- package/src/CooldownTimer.ts +11 -29
- package/src/EventHandlerPipeline.ts +21 -44
- package/src/LiveLocationManager.ts +35 -74
- package/src/api-client.ts +43 -61
- package/src/campaign.ts +1 -1
- package/src/channel.ts +396 -749
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +50 -105
- package/src/client.ts +360 -588
- package/src/client_state.ts +1 -6
- package/src/configuration/ConfigController.ts +41 -157
- package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +67 -70
- package/src/configuration/types.ts +60 -100
- package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
- package/src/configuration/utils/copyConfigPatch.ts +11 -32
- package/src/configuration/utils/declarativeSlices.ts +9 -39
- package/src/configuration/utils/deepFreezeConfig.ts +3 -17
- package/src/configuration/utils/index.ts +2 -4
- package/src/configuration/utils/serverAuthority.ts +20 -68
- package/src/connection/ConnectionIdManager.ts +20 -49
- package/src/connection/ConnectionRecoveryManager.ts +51 -178
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
- package/src/connection/networkConnection/reporters.ts +9 -36
- package/src/connection/networkConnection/types.ts +12 -27
- package/src/connection/wsConnection/StableWSConnection.ts +73 -193
- package/src/connection/wsConnection/WSConnection.ts +56 -131
- package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
- package/src/connection/wsConnection/config.ts +13 -48
- package/src/connection/wsConnection/types.ts +17 -70
- package/src/constants.ts +4 -4
- package/src/entityStore/EntityStore.ts +162 -167
- package/src/entityStore/StoreBackedItemIndex.ts +14 -47
- package/src/errors.ts +7 -19
- package/src/formatMessageMemo.ts +3 -9
- package/src/gen/chat/ChannelApi.ts +19 -0
- package/src/gen/chat/ChatApi.ts +87 -13
- package/src/gen/models/index.ts +793 -71
- package/src/gen/moderation/ModerationApi.ts +0 -4
- package/src/index.ts +10 -14
- package/src/languageNames.ts +9 -24
- package/src/logger.ts +1 -3
- package/src/messageComposer/LocationComposer.ts +7 -23
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +2 -13
- package/src/messageComposer/attachmentManager.ts +17 -63
- package/src/messageComposer/attachmentUtils.ts +3 -17
- package/src/messageComposer/configuration/configuration.ts +5 -8
- package/src/messageComposer/configuration/types.ts +29 -56
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/linkPreviewsManager.ts +8 -20
- package/src/messageComposer/messageComposer.ts +54 -222
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
- package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
- package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
- package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
- package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
- package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
- package/src/messageComposer/middleware/textComposer/types.ts +1 -6
- package/src/messageComposer/pollComposer.ts +11 -8
- package/src/messageComposer/textComposer.ts +9 -59
- package/src/messageComposer/types.ts +9 -12
- package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
- package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
- package/src/messageOperations/FailedSendCache.ts +4 -9
- package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
- package/src/messageOperations/MessageOperations.ts +33 -62
- package/src/messageOperations/applyReactionLocally.ts +9 -28
- package/src/messageOperations/createMessageOperations.ts +17 -33
- package/src/messageOperations/reflectReactionEvent.ts +5 -13
- package/src/messageOperations/sendOrdering.ts +4 -7
- package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
- package/src/messageOperations/types.ts +15 -30
- package/src/middleware.ts +7 -10
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +11 -35
- package/src/notifications/types.ts +19 -59
- package/src/offline-support/offline_support_api.ts +178 -608
- package/src/offline-support/offline_sync_manager.ts +25 -69
- package/src/offline-support/queueableOperations.ts +31 -84
- package/src/offline-support/types.ts +25 -188
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/paginators/BasePaginator.ts +422 -976
- package/src/pagination/paginators/ChannelPaginator.ts +130 -190
- package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
- package/src/pagination/paginators/MessagePaginator.ts +135 -175
- package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
- package/src/pagination/paginators/ReminderPaginator.ts +12 -15
- package/src/pagination/paginators/ThreadPaginator.ts +16 -26
- package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
- package/src/pagination/paginators/stateThrottling.ts +5 -10
- package/src/pagination/sortCompiler.ts +23 -50
- package/src/pagination/utility.normalization.ts +8 -30
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +19 -19
- package/src/poll_manager.ts +16 -20
- package/src/poll_optimistic_votes.ts +17 -22
- package/src/reminders/Reminder.ts +5 -6
- package/src/reminders/ReminderManager.ts +9 -34
- package/src/reminders/ReminderTimer.ts +1 -2
- package/src/search/BaseSearchSource.ts +14 -29
- package/src/search/ChannelSearchSource.ts +8 -8
- package/src/search/MessageSearchSource.ts +19 -25
- package/src/search/SearchController.ts +18 -24
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +72 -173
- package/src/thread_manager.ts +59 -76
- package/src/token_manager.ts +11 -21
- package/src/types.ts +78 -126
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +22 -54
- package/src/utils/FixedSizeQueueCache.ts +13 -21
- package/src/utils/WithSubscriptions.ts +5 -15
- package/src/utils/concurrency.ts +16 -55
- package/src/utils/mergeWith/mergeWith.ts +10 -13
- package/src/utils/mergeWith/mergeWithCore.ts +24 -81
- package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
- package/src/utils/objectPath.ts +6 -41
- package/src/utils/retryable.ts +10 -14
- package/src/utils/throttling/throttle.ts +9 -25
- package/src/utils/time.ts +26 -66
- package/src/utils.ts +72 -128
|
@@ -112,7 +112,6 @@ export class ModerationApi {
|
|
|
112
112
|
|
|
113
113
|
deleteActionConfig(
|
|
114
114
|
pathParams: { id: string },
|
|
115
|
-
_request?: Record<string, never>,
|
|
116
115
|
requestOptions?: StreamRequestOptions,
|
|
117
116
|
): Promise<StreamResponse<DeleteActionConfigResponse>> {
|
|
118
117
|
return this.apiClient.sendRequest<DeleteActionConfigResponse>(
|
|
@@ -143,7 +142,6 @@ export class ModerationApi {
|
|
|
143
142
|
|
|
144
143
|
getAppeal(
|
|
145
144
|
pathParams: { id: string },
|
|
146
|
-
_request?: Record<string, never>,
|
|
147
145
|
requestOptions?: StreamRequestOptions,
|
|
148
146
|
): Promise<StreamResponse<GetAppealResponse>> {
|
|
149
147
|
return this.apiClient.sendRequest<GetAppealResponse>(
|
|
@@ -295,7 +293,6 @@ export class ModerationApi {
|
|
|
295
293
|
}
|
|
296
294
|
|
|
297
295
|
listQueues(
|
|
298
|
-
_request?: Record<string, never>,
|
|
299
296
|
requestOptions?: StreamRequestOptions,
|
|
300
297
|
): Promise<StreamResponse<ListQueuesResponse>> {
|
|
301
298
|
return this.apiClient.sendRequest<ListQueuesResponse>(
|
|
@@ -326,7 +323,6 @@ export class ModerationApi {
|
|
|
326
323
|
|
|
327
324
|
getQueue(
|
|
328
325
|
pathParams: { id: string },
|
|
329
|
-
_request?: Record<string, never>,
|
|
330
326
|
requestOptions?: StreamRequestOptions,
|
|
331
327
|
): Promise<StreamResponse<QueueResponse>> {
|
|
332
328
|
return this.apiClient.sendRequest<QueueResponse>(
|
package/src/index.ts
CHANGED
|
@@ -2,11 +2,9 @@ export * from './client';
|
|
|
2
2
|
export * from './client_state';
|
|
3
3
|
export * from './channel';
|
|
4
4
|
export * from './channel_state';
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// https://github.com/microsoft/TypeScript/issues/46617
|
|
9
|
-
// Named in the signatures of `client.config.set` / `setConfig`, so a caller has to be able to write it.
|
|
5
|
+
// The configuration exports are listed by name, not `export *`, which can break module augmentation
|
|
6
|
+
// (https://github.com/microsoft/TypeScript/issues/46617).
|
|
7
|
+
// `DeepPartial` is named in the signatures of `client.config.set` / `setConfig`.
|
|
10
8
|
export type { DeepPartial } from './types.utility';
|
|
11
9
|
export {
|
|
12
10
|
BUILT_IN_INSTANCE_KEYS,
|
|
@@ -80,15 +78,15 @@ export type {
|
|
|
80
78
|
export * from './thread_manager';
|
|
81
79
|
export * from './token_manager';
|
|
82
80
|
export * from './types';
|
|
83
|
-
// Type-only
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
// the entry point's type graph imports the file that declares it.
|
|
81
|
+
// Type-only, so it is erased from the bundle. Declaration emit keeps it, which carries the
|
|
82
|
+
// `DateConstructor` augmentation (`new Date(timestampNs)` is a compile error) into the published
|
|
83
|
+
// types.
|
|
87
84
|
export type {} from './gen/models/timestamp-guard';
|
|
88
85
|
export * from './uploadManager';
|
|
89
86
|
export * from './offline-support';
|
|
90
87
|
export * from './LiveLocationManager';
|
|
91
|
-
// Don't use * here, that can break module augmentation
|
|
88
|
+
// Don't use * here, that can break module augmentation
|
|
89
|
+
// https://github.com/microsoft/TypeScript/issues/46617
|
|
92
90
|
export type {
|
|
93
91
|
CustomAttachmentData,
|
|
94
92
|
CustomChannelData,
|
|
@@ -124,10 +122,8 @@ export {
|
|
|
124
122
|
nsToRfc3339,
|
|
125
123
|
} from './utils/time';
|
|
126
124
|
/**
|
|
127
|
-
* Tag-keyed async runners.
|
|
128
|
-
*
|
|
129
|
-
* chains. Tags share one process-wide map, so namespace yours (`my-app/thing/${id}`) to avoid
|
|
130
|
-
* colliding with another caller's.
|
|
125
|
+
* Tag-keyed async runners. Tags share one process-wide map, so namespace yours
|
|
126
|
+
* (`my-app/thing/${id}`).
|
|
131
127
|
*/
|
|
132
128
|
export {
|
|
133
129
|
hasPending,
|
package/src/languageNames.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import type { TranslationLanguage } from './types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The human-readable name of each
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* too. A UI SDK uses them to say "Translated from German" rather than "Translated from de".
|
|
9
|
-
*
|
|
10
|
-
* `satisfies Record<TranslationLanguage, string>` is the drift gate, and it works in both
|
|
11
|
-
* directions: adding a language to the API union fails to compile until a name is supplied here, and a
|
|
12
|
-
* name for a language the union does not contain is rejected as an excess property. Before this lived
|
|
13
|
-
* in core, each UI SDK hand-maintained its own copy with nothing tying it to the union — so a miss
|
|
14
|
-
* could only be detected at runtime, by comparing the rendered string against the key.
|
|
15
|
-
*
|
|
16
|
-
* Names are in English on purpose. A language picker conventionally shows each language endonymously
|
|
17
|
-
* ("Deutsch", not "German"), but this is the *source* language of an auto-translated message rendered
|
|
18
|
-
* inside a sentence in the reader's own language, so it has to agree with the surrounding copy. An
|
|
19
|
-
* integrator wanting endonyms overrides the `language.*` keys.
|
|
4
|
+
* The human-readable name of each {@link TranslationLanguage}, for text like "Translated from
|
|
5
|
+
* German". `satisfies Record<TranslationLanguage, string>` fails to compile when the union and this
|
|
6
|
+
* table disagree. Names are in English so they fit inside the reader's sentence; override the
|
|
7
|
+
* `language.*` keys for endonyms.
|
|
20
8
|
*/
|
|
21
9
|
export const LANGUAGE_NAMES = {
|
|
22
10
|
af: 'Afrikaans',
|
|
@@ -79,10 +67,8 @@ export const LANGUAGE_NAMES = {
|
|
|
79
67
|
} as const satisfies Record<TranslationLanguage, string>;
|
|
80
68
|
|
|
81
69
|
/**
|
|
82
|
-
* The `language.*` slice of a translation catalog
|
|
83
|
-
*
|
|
84
|
-
* A UI SDK intersects this into its own generated catalog, which makes `t('language.de')` a checked
|
|
85
|
-
* key rather than something that has to go through `asDynamicKey()`:
|
|
70
|
+
* The `language.*` slice of a translation catalog, to intersect into a UI SDK's own catalog so
|
|
71
|
+
* `t('language.de')` is a checked key:
|
|
86
72
|
*
|
|
87
73
|
* ```ts
|
|
88
74
|
* type TranslationCatalog = GeneratedCatalog & LanguageNameCatalog;
|
|
@@ -93,10 +79,9 @@ export type LanguageNameCatalog = {
|
|
|
93
79
|
};
|
|
94
80
|
|
|
95
81
|
/**
|
|
96
|
-
* {@link LANGUAGE_NAMES} keyed
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* site to carry an inline default — which is exactly why they have to ship as data.
|
|
82
|
+
* {@link LANGUAGE_NAMES} keyed as a catalog (`language.<code>`), ready to merge into an SDK's
|
|
83
|
+
* bundled defaults. The keys are resolved from a runtime value, so there is no call site for an
|
|
84
|
+
* inline default.
|
|
100
85
|
*/
|
|
101
86
|
export const languageNameDefaults: Record<string, string> = Object.fromEntries(
|
|
102
87
|
Object.entries(LANGUAGE_NAMES).map(([code, name]) => [`language.${code}`, name]),
|
package/src/logger.ts
CHANGED
|
@@ -26,15 +26,8 @@ export type LocationComposerState = {
|
|
|
26
26
|
export type LocationComposerSnapshot = LocationComposerState;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* `
|
|
31
|
-
*
|
|
32
|
-
* A location read off a message is the other shape: it carries `channel_cid`, `user_id`,
|
|
33
|
-
* `created_at` and `updated_at` too, and its `end_at` is a unix-**nanosecond** number rather than a
|
|
34
|
-
* `Date`. Narrowing here rather than at each send site is what stops those response-only fields
|
|
35
|
-
* riding along into the next composition and reaching the API as raw nanosecond numbers — which is
|
|
36
|
-
* not a type error, because {@link LiveLocationPreview} omits `end_at` and so accepts an object
|
|
37
|
-
* carrying a numeric one.
|
|
29
|
+
* Keeps only the request-shaped fields of a message's location (plus `message_id`), so response-only
|
|
30
|
+
* fields (`channel_cid`, `user_id`, nanosecond `end_at`) never reach the next composition.
|
|
38
31
|
*/
|
|
39
32
|
const initState = ({
|
|
40
33
|
message,
|
|
@@ -43,8 +36,7 @@ const initState = ({
|
|
|
43
36
|
}): LocationComposerState => {
|
|
44
37
|
const location = message?.shared_location;
|
|
45
38
|
if (!location) return { location: null };
|
|
46
|
-
//
|
|
47
|
-
// `Invalid Date` that would later serialize as `null`.
|
|
39
|
+
// An absent or non-finite `end_at` leaves the location static (no `Invalid Date`).
|
|
48
40
|
const endAt = convertTimestampToDate(location.end_at);
|
|
49
41
|
return {
|
|
50
42
|
location: {
|
|
@@ -91,22 +83,14 @@ export class LocationComposer {
|
|
|
91
83
|
location.longitude &&
|
|
92
84
|
(typeof durationMs === 'undefined' || durationMs >= this.config.minShareDurationMs)
|
|
93
85
|
) {
|
|
94
|
-
//
|
|
95
|
-
// `SharedLocation` request declares. The spread it replaces was how a response-shaped
|
|
96
|
-
// location reached the API: it carried the response's own `created_at` / `updated_at` /
|
|
97
|
-
// `channel_cid` / `user_id` straight into the outgoing payload.
|
|
86
|
+
// Field by field, so only what a `SharedLocation` request declares is sent.
|
|
98
87
|
return {
|
|
99
88
|
created_by_device_id: location.created_by_device_id,
|
|
100
89
|
latitude: location.latitude,
|
|
101
90
|
longitude: location.longitude,
|
|
102
91
|
message_id: location.message_id,
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
// `end_at` is already absolute — keep it, rather than recomputing it, or editing a message
|
|
106
|
-
// would push its live location's expiry out by however long the edit took. Dropping it
|
|
107
|
-
// instead (what the previous `end_at: undefined` did whenever `durationMs` was absent,
|
|
108
|
-
// which is always the case for a location hydrated from a message) silently turned a live
|
|
109
|
-
// location into a static one on every edit.
|
|
92
|
+
// A `durationMs` resolves against the clock when read. An existing `end_at` is kept as is, so
|
|
93
|
+
// editing a message does not extend (or drop) its live location's expiry.
|
|
110
94
|
...(typeof durationMs === 'number'
|
|
111
95
|
? { end_at: new Date(Date.now() + durationMs) }
|
|
112
96
|
: end_at
|
|
@@ -122,7 +106,7 @@ export class LocationComposer {
|
|
|
122
106
|
};
|
|
123
107
|
|
|
124
108
|
/**
|
|
125
|
-
* Takes over `source`'s location,
|
|
109
|
+
* Takes over `source`'s location, re-keyed to this composer's message (`message_id`).
|
|
126
110
|
*
|
|
127
111
|
* @internal
|
|
128
112
|
*/
|
|
@@ -26,7 +26,7 @@ const applyCommandActivationEffect: MessageComposerEffectHandler<
|
|
|
26
26
|
}
|
|
27
27
|
composer.captureSnapshot(snapshot);
|
|
28
28
|
|
|
29
|
-
//
|
|
29
|
+
// Cleared manually: the command itself must persist.
|
|
30
30
|
composer.textComposer.state.next({
|
|
31
31
|
command: effect.command,
|
|
32
32
|
mentionedUsers: [],
|
|
@@ -34,7 +34,6 @@ const applyCommandActivationEffect: MessageComposerEffectHandler<
|
|
|
34
34
|
suggestions: undefined,
|
|
35
35
|
selection: { start: 0, end: 0 },
|
|
36
36
|
text: '',
|
|
37
|
-
typing: {},
|
|
38
37
|
});
|
|
39
38
|
const attachmentsToCancel = composer.attachmentManager.attachments;
|
|
40
39
|
composer.attachmentManager.initState();
|
|
@@ -28,13 +28,7 @@ export const isLocalUploadAttachment = (
|
|
|
28
28
|
): attachment is LocalUploadAttachment =>
|
|
29
29
|
!!(attachment as LocalAttachment)?.localMetadata?.uploadState;
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* Upload states meaning "the bytes are not on the CDN yet, but they are on their way".
|
|
33
|
-
* `blocked` and `failed` are excluded - those never resolve on their own.
|
|
34
|
-
*
|
|
35
|
-
* Typed against {@link AttachmentLoadingState} rather than `string`, so renaming a state fails
|
|
36
|
-
* the build instead of silently making this list match nothing - it decides what gets sent.
|
|
37
|
-
*/
|
|
31
|
+
/** Upload states that still resolve on their own (`blocked` and `failed` never do). */
|
|
38
32
|
const PENDING_UPLOAD_STATES: ReadonlyArray<AttachmentLoadingState> = [
|
|
39
33
|
'pending',
|
|
40
34
|
'uploading',
|
|
@@ -54,12 +48,7 @@ export const isFinishedUpload = (
|
|
|
54
48
|
isLocalUploadAttachment(attachment) &&
|
|
55
49
|
attachment.localMetadata.uploadState === 'finished';
|
|
56
50
|
|
|
57
|
-
/**
|
|
58
|
-
* Whether this attachment's upload resolved to a failure the user can retry.
|
|
59
|
-
*
|
|
60
|
-
* Distinct from `blocked`, which the server's upload configuration rejected outright - that one
|
|
61
|
-
* can never succeed, however many times it is retried.
|
|
62
|
-
*/
|
|
51
|
+
/** Whether this attachment's upload failed in a way that can be retried (unlike `blocked`). */
|
|
63
52
|
export const isFailedUpload = (
|
|
64
53
|
attachment: unknown,
|
|
65
54
|
): attachment is LocalUploadAttachment =>
|
|
@@ -162,11 +162,6 @@ export class AttachmentManager {
|
|
|
162
162
|
set maxNumberOfFilesPerMessage(
|
|
163
163
|
maxNumberOfFilesPerMessage: AttachmentManagerConfig['maxNumberOfFilesPerMessage'],
|
|
164
164
|
) {
|
|
165
|
-
// No early return on "same value". The guard that used to be here compared against the *effective*
|
|
166
|
-
// value, while the write it skipped records the *requested* one — so asking for a value the server
|
|
167
|
-
// was currently masking recorded nothing, and the earlier request stayed in the patch layer to be
|
|
168
|
-
// honoured the moment the server relented. `ConfigController.write` already skips a publish when the
|
|
169
|
-
// resolved value does not move, which is the same guard applied to the right value.
|
|
170
165
|
this.composer.updateConfig({ attachments: { maxNumberOfFilesPerMessage } });
|
|
171
166
|
}
|
|
172
167
|
|
|
@@ -193,28 +188,17 @@ export class AttachmentManager {
|
|
|
193
188
|
}
|
|
194
189
|
|
|
195
190
|
/**
|
|
196
|
-
* Whether uploaded bytes reach Stream
|
|
197
|
-
*
|
|
198
|
-
* Declared through {@link AttachmentManagerConfig.customCdn}, not inferred from `doUploadRequest`. A
|
|
199
|
-
* custom upload function says how files are sent, not where: wrapping the request to add retries,
|
|
200
|
-
* headers or a proxy through your own backend still ends at Stream. Inferring a different destination
|
|
201
|
-
* from it waived Stream's constraints for those integrators too.
|
|
191
|
+
* Whether uploaded bytes reach Stream (and so Stream's rules apply). Set by
|
|
192
|
+
* {@link AttachmentManagerConfig.customCdn}, not inferred from `doUploadRequest`.
|
|
202
193
|
*/
|
|
203
194
|
get usesStreamStorage() {
|
|
204
195
|
return !this.config.customCdn;
|
|
205
196
|
}
|
|
206
197
|
|
|
207
198
|
/**
|
|
208
|
-
* Whether this composer can accept a file
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* - `config.enabled` — the configured answer, already ANDed with the channel type's `uploads` flag by
|
|
213
|
-
* the composer's server restrictions (which apply only when files go to Stream, for the same reason
|
|
214
|
-
* as below). The integrator's own switch, which nothing overrides.
|
|
215
|
-
* - a free slot under `maxNumberOfFilesPerMessage`.
|
|
216
|
-
* - the `upload-file` capability, **only when files go to Stream**. It governs Stream's upload
|
|
217
|
-
* endpoint, so on storage Stream does not host there is nothing for it to permit or refuse.
|
|
199
|
+
* Whether this composer can accept a file (`uploadFiles` enforces it): `config.enabled` (already
|
|
200
|
+
* ANDed with the channel type's `uploads` flag when files go to Stream), a free slot, and the
|
|
201
|
+
* `upload-file` capability (only when files go to Stream).
|
|
218
202
|
*/
|
|
219
203
|
get isUploadEnabled() {
|
|
220
204
|
return (
|
|
@@ -289,11 +273,9 @@ export class AttachmentManager {
|
|
|
289
273
|
};
|
|
290
274
|
|
|
291
275
|
/**
|
|
292
|
-
* Moves `source`'s attachments here,
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
* its result lands here. `source`'s list is emptied without touching the uploads, so clearing
|
|
296
|
-
* `source` afterwards doesn't cancel them either.
|
|
276
|
+
* Moves `source`'s attachments here, replacing this manager's own (their uploads are cancelled) and
|
|
277
|
+
* emptying `source`. Running uploads are not cancelled: this manager joins them (`UploadManager` runs
|
|
278
|
+
* one request per attachment), so their results land here.
|
|
297
279
|
*
|
|
298
280
|
* @internal
|
|
299
281
|
*/
|
|
@@ -348,8 +330,7 @@ export class AttachmentManager {
|
|
|
348
330
|
const attachments = [...this.attachments];
|
|
349
331
|
const attachmentIndex = this.getAttachmentIndex(attachmentToUpdate.localMetadata.id);
|
|
350
332
|
if (attachmentIndex === -1) return null;
|
|
351
|
-
//
|
|
352
|
-
// replace in place only with the attachments with the same id's
|
|
333
|
+
// Replace in place by ID; reordering would break indexing.
|
|
353
334
|
const merged = mergeWithDiff<LocalAttachment>(
|
|
354
335
|
stateAttachments[attachmentIndex],
|
|
355
336
|
attachmentToUpdate,
|
|
@@ -388,20 +369,13 @@ export class AttachmentManager {
|
|
|
388
369
|
attachments = updatedAttachments;
|
|
389
370
|
hasUpdates = true;
|
|
390
371
|
}
|
|
391
|
-
// else: id exists and merge was a no-op (`prepareAttachmentUpdate` returns current state)
|
|
392
372
|
});
|
|
393
373
|
if (hasUpdates) {
|
|
394
374
|
this.state.partialNext({ attachments });
|
|
395
375
|
}
|
|
396
376
|
};
|
|
397
377
|
|
|
398
|
-
/**
|
|
399
|
-
* Releases a local preview URL the SDK minted, if it minted one.
|
|
400
|
-
*
|
|
401
|
-
* Only `blob:` URLs are ours to revoke: `toLocalUploadAttachment` puts a
|
|
402
|
-
* `URL.createObjectURL` result in `previewUri` for a `File`, but for a React Native
|
|
403
|
-
* `FileReference` it stores the caller's own native file URI, which must be left alone.
|
|
404
|
-
*/
|
|
378
|
+
/** Revokes `blob:` preview URLs only. A React Native `FileReference` keeps the caller's own URI. */
|
|
405
379
|
private revokePreviewUri = (attachment: LocalAttachment) => {
|
|
406
380
|
const previewUri = (
|
|
407
381
|
attachment.localMetadata as Partial<LocalAttachmentUploadMetadata>
|
|
@@ -427,16 +401,8 @@ export class AttachmentManager {
|
|
|
427
401
|
this.client.uploadManager.deleteUploadRecord(id);
|
|
428
402
|
}
|
|
429
403
|
|
|
430
|
-
// Removal
|
|
431
|
-
//
|
|
432
|
-
// until the page unloads. Revoked after the record is deleted, so nothing is still
|
|
433
|
-
// rendering from it.
|
|
434
|
-
//
|
|
435
|
-
// Deliberately not done in `initState`/`restoreSnapshot`: those drop the composer's *view*
|
|
436
|
-
// of the attachments without ending their life. A finished upload has already had its
|
|
437
|
-
// `previewUri` revoked and removed by the post-upload middleware, and an unfinished one may
|
|
438
|
-
// still be rendered by whoever took it over (an optimistic message sent with the upload
|
|
439
|
-
// still in flight, for instance).
|
|
404
|
+
// Removal ends the attachments' life, so their preview blobs are revoked (not in `initState` or
|
|
405
|
+
// `restoreSnapshot`, which only drop the composer's view of attachments others may still render).
|
|
440
406
|
removedAttachments.forEach(this.revokePreviewUri);
|
|
441
407
|
};
|
|
442
408
|
|
|
@@ -617,10 +583,7 @@ export class AttachmentManager {
|
|
|
617
583
|
return newAttachment;
|
|
618
584
|
};
|
|
619
585
|
|
|
620
|
-
/**
|
|
621
|
-
* Method to perform the default upload behavior without checking for custom upload functions
|
|
622
|
-
* to prevent recursive calls
|
|
623
|
-
*/
|
|
586
|
+
/** The default upload, skipping the custom `doUploadRequest` so a custom one can delegate here. */
|
|
624
587
|
doDefaultUploadRequest = async (
|
|
625
588
|
fileLike: FileReference | FileLike,
|
|
626
589
|
options?: UploadRequestOptions,
|
|
@@ -655,7 +618,7 @@ export class AttachmentManager {
|
|
|
655
618
|
|
|
656
619
|
const {
|
|
657
620
|
duration: _duration,
|
|
658
|
-
//
|
|
621
|
+
// Per-request artifacts, kept out of the public `doUploadRequest` result.
|
|
659
622
|
metadata: _metadata,
|
|
660
623
|
...result
|
|
661
624
|
} = await this.channel[isImageFile(fileLike) ? 'uploadImage' : 'uploadFile'](
|
|
@@ -727,16 +690,12 @@ export class AttachmentManager {
|
|
|
727
690
|
...attachment.localMetadata,
|
|
728
691
|
uploadState: 'failed',
|
|
729
692
|
uploadProgress: undefined,
|
|
730
|
-
// `false`, not `undefined`:
|
|
731
|
-
// via `mergeWith` — and that skips `undefined` source values, so `undefined` would
|
|
732
|
-
// leave a stale `true` in place.
|
|
693
|
+
// `false`, not `undefined`: `mergeWith` skips `undefined`, which would leave a stale `true`.
|
|
733
694
|
uploadConfirmationPending: false,
|
|
734
695
|
},
|
|
735
696
|
};
|
|
736
697
|
|
|
737
|
-
// A cancellation is
|
|
738
|
-
// notification. This path predates the post-upload middleware chain and notifies
|
|
739
|
-
// directly, so it needs the same guard `createUploadErrorHandlerMiddleware` applies.
|
|
698
|
+
// A cancellation is not an error (same guard as `createUploadErrorHandlerMiddleware`).
|
|
740
699
|
if (!isUploadCancellation(error)) {
|
|
741
700
|
this.client.notifications.addError({
|
|
742
701
|
message: 'Error uploading attachment',
|
|
@@ -757,10 +716,7 @@ export class AttachmentManager {
|
|
|
757
716
|
}
|
|
758
717
|
|
|
759
718
|
if (!response) {
|
|
760
|
-
//
|
|
761
|
-
|
|
762
|
-
// If doUploadRequest returns any falsy value, then don't create the upload preview.
|
|
763
|
-
// This is for the case if someone wants to handle failure on app level.
|
|
719
|
+
// A falsy `doUploadRequest` result drops the attachment, so the app can handle failure itself.
|
|
764
720
|
this.removeAttachments([attachment.localMetadata.id]);
|
|
765
721
|
return;
|
|
766
722
|
}
|
|
@@ -771,7 +727,6 @@ export class AttachmentManager {
|
|
|
771
727
|
...attachment.localMetadata,
|
|
772
728
|
uploadState: 'finished',
|
|
773
729
|
uploadProgress: undefined,
|
|
774
|
-
// See the note in the failure branch: `undefined` cannot clear through `mergeWith`.
|
|
775
730
|
uploadConfirmationPending: false,
|
|
776
731
|
},
|
|
777
732
|
};
|
|
@@ -855,7 +810,6 @@ export class AttachmentManager {
|
|
|
855
810
|
...attachment.localMetadata,
|
|
856
811
|
uploadState: error ? 'failed' : 'finished',
|
|
857
812
|
uploadProgress: undefined,
|
|
858
|
-
// See the note in `uploadAttachment`: `undefined` cannot clear through `mergeWith`.
|
|
859
813
|
uploadConfirmationPending: false,
|
|
860
814
|
},
|
|
861
815
|
},
|
|
@@ -3,14 +3,7 @@ import { isLocalUploadAttachment } from './attachmentIdentity';
|
|
|
3
3
|
import type { Attachment } from '../types';
|
|
4
4
|
import type { LocalAttachment } from './types';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
// answers what kind of attachment it is. Each exists because the answer is not a plain field read.
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The URL to render an attachment from, falling back to the local blob preview while its upload is
|
|
11
|
-
* in flight. Lives here because the preview is this package's: created by `AttachmentManager`,
|
|
12
|
-
* revoked by `settlePendingAttachmentUploads`.
|
|
13
|
-
*/
|
|
6
|
+
/** The first truthy URL, else the local preview URL while the upload is in flight. */
|
|
14
7
|
export const getAttachmentPreviewUrl = (
|
|
15
8
|
attachment?: Attachment | LocalAttachment,
|
|
16
9
|
...urls: (string | undefined)[]
|
|
@@ -23,20 +16,13 @@ export const getAttachmentPreviewUrl = (
|
|
|
23
16
|
: undefined;
|
|
24
17
|
};
|
|
25
18
|
|
|
26
|
-
/**
|
|
27
|
-
* An attachment's declared file size. v10 moved these fields under `attachment.custom`; the flat
|
|
28
|
-
* one remains a fallback for older or hand-built payloads. Where the field lives is this package's
|
|
29
|
-
* schema knowledge, not a UI SDK's.
|
|
30
|
-
*/
|
|
19
|
+
/** The declared file size: `custom.file_size`, falling back to a flat `file_size`. */
|
|
31
20
|
export const resolveAttachmentFileSize = (attachment?: {
|
|
32
21
|
custom?: { file_size?: number | string } | null;
|
|
33
22
|
file_size?: number | string;
|
|
34
23
|
}): number | string | undefined => attachment?.custom?.file_size ?? attachment?.file_size;
|
|
35
24
|
|
|
36
|
-
/**
|
|
37
|
-
* Size in bytes, preferring the held `File` — during an upload that is the only exact figure,
|
|
38
|
-
* since `file_size` may be absent until the server answers.
|
|
39
|
-
*/
|
|
25
|
+
/** Size in bytes, preferring the held `File` (`file_size` may be absent until the server answers). */
|
|
40
26
|
export const resolveAttachmentFullByteSize = (attachment?: {
|
|
41
27
|
custom?: { file_size?: number | string } | null;
|
|
42
28
|
file_size?: number | string;
|
|
@@ -19,19 +19,19 @@ export const DEFAULT_LINK_PREVIEW_MANAGER_CONFIG: LinkPreviewsManagerConfig = {
|
|
|
19
19
|
find(text, 'url', { defaultProtocol: 'https' }).reduce<string[]>((acc, link) => {
|
|
20
20
|
try {
|
|
21
21
|
const url = new URL(link.href);
|
|
22
|
-
//
|
|
22
|
+
// Hostname needs at least one dot and a valid TLD.
|
|
23
23
|
if (link.isLink && /^[a-zA-Z0-9-.]+\.[a-zA-Z]{2,}$/.test(url.hostname)) {
|
|
24
24
|
acc.push(link.href);
|
|
25
25
|
}
|
|
26
26
|
} catch {
|
|
27
|
-
// Invalid URL
|
|
27
|
+
// Invalid URL: skipped.
|
|
28
28
|
}
|
|
29
29
|
return acc;
|
|
30
30
|
}, []),
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export const DEFAULT_ATTACHMENT_MANAGER_CONFIG: AttachmentManagerConfig = {
|
|
34
|
-
acceptedFiles: [],
|
|
34
|
+
acceptedFiles: [],
|
|
35
35
|
customCdn: false,
|
|
36
36
|
enabled: true,
|
|
37
37
|
fileUploadFilter: () => true,
|
|
@@ -56,11 +56,8 @@ export const DEFAULT_LOCATION_COMPOSER_CONFIG: LocationComposerConfig = {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* reachable through the public `composer.config`. Without the freeze,
|
|
62
|
-
* `composer.config.drafts.enabled = true` changed the default for every composer on every client in the
|
|
63
|
-
* process. See {@link deepFreezeConfig}.
|
|
59
|
+
* Deep-frozen: composers share these subtrees by reference through `composer.config`. See
|
|
60
|
+
* {@link deepFreezeConfig}.
|
|
64
61
|
*/
|
|
65
62
|
export const DEFAULT_COMPOSER_CONFIG: MessageComposerConfig = deepFreezeConfig({
|
|
66
63
|
attachments: DEFAULT_ATTACHMENT_MANAGER_CONFIG,
|